tg-core-components 5.5.0-bethard → 5.5.0-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/List/ListItem.js +1 -7
- 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 +47 -85
- 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 +8 -22
- 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/List/ListItem.js +1 -10
- 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 +50 -88
- 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 +10 -24
- 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,104 +0,0 @@
|
|
|
1
|
-
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; };
|
|
2
|
-
|
|
3
|
-
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; }
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { Input, useId, useValue, useFocus, useTouched, useAutofill, createClassName, statusIcons, flatObj } from '../common';
|
|
7
|
-
import cn from 'classnames';
|
|
8
|
-
|
|
9
|
-
var AutocompleteSuggestion = function AutocompleteSuggestion(_ref) {
|
|
10
|
-
var children = _ref.children,
|
|
11
|
-
value = _ref.value,
|
|
12
|
-
_onClick = _ref.onClick,
|
|
13
|
-
selected = _ref.selected,
|
|
14
|
-
classNames = _ref.classNames,
|
|
15
|
-
rest = _objectWithoutProperties(_ref, ['children', 'value', 'onClick', 'selected', 'classNames']);
|
|
16
|
-
|
|
17
|
-
return React.createElement(
|
|
18
|
-
'div',
|
|
19
|
-
_extends({}, rest, {
|
|
20
|
-
className: cn(classNames, 'tg-autocomplete-input__suggestions__suggestion', {
|
|
21
|
-
'tg-autocomplete-input__suggestions__suggestion--selected': selected
|
|
22
|
-
}),
|
|
23
|
-
onClick: function onClick() {
|
|
24
|
-
_onClick(value);
|
|
25
|
-
} }),
|
|
26
|
-
children
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
var AutocompleteInput = function AutocompleteInput(_ref2) {
|
|
31
|
-
var icon = _ref2.icon,
|
|
32
|
-
props = _objectWithoutProperties(_ref2, ['icon']);
|
|
33
|
-
|
|
34
|
-
var input = {
|
|
35
|
-
id: useId(),
|
|
36
|
-
value: useValue(props.value),
|
|
37
|
-
focus: useFocus(),
|
|
38
|
-
touched: useTouched(),
|
|
39
|
-
autofill: useAutofill()
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
var _onChange = function _onChange(e) {
|
|
43
|
-
return props.onChange && props.onChange(e, e.target.value);
|
|
44
|
-
};
|
|
45
|
-
var _onBlur = function _onBlur(e) {
|
|
46
|
-
return props.onBlur && props.onBlur(e, e.target.value);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
var className = createClassName('tg-autocomplete-input', {
|
|
50
|
-
hasValue: input.value.hasValue,
|
|
51
|
-
hasLabel: Boolean(props.label),
|
|
52
|
-
hasFocus: input.focus.hasFocus,
|
|
53
|
-
hasTouched: input.touched.hasTouched,
|
|
54
|
-
hasAutofill: input.autofill.hasAutofill,
|
|
55
|
-
disabled: props.disabled,
|
|
56
|
-
status: props.status
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
return React.createElement(
|
|
60
|
-
'div',
|
|
61
|
-
{ className: cn(props.className, className) },
|
|
62
|
-
React.createElement(Input, _extends({}, props, flatObj(input), {
|
|
63
|
-
children: null,
|
|
64
|
-
autoComplete: 'off',
|
|
65
|
-
onChange: function onChange(e) {
|
|
66
|
-
if (typeof props.transform === 'function') {
|
|
67
|
-
e.target.value = props.transform(e.target.value);
|
|
68
|
-
}
|
|
69
|
-
input.value.onChange(e.target.value);
|
|
70
|
-
_onChange(e);
|
|
71
|
-
},
|
|
72
|
-
onFocus: function onFocus() {
|
|
73
|
-
input.focus.onFocus();
|
|
74
|
-
input.touched.onFocus();
|
|
75
|
-
},
|
|
76
|
-
onBlur: function onBlur(e) {
|
|
77
|
-
setTimeout(function () {
|
|
78
|
-
input.focus.onBlur();
|
|
79
|
-
_onBlur(e);
|
|
80
|
-
}, 500);
|
|
81
|
-
},
|
|
82
|
-
leadingLane: [icon].filter(function (i) {
|
|
83
|
-
return i;
|
|
84
|
-
}),
|
|
85
|
-
trailingLane: [statusIcons[props.status]].filter(function (i) {
|
|
86
|
-
return i;
|
|
87
|
-
})
|
|
88
|
-
})),
|
|
89
|
-
props.children.length > 0 && input.focus.hasFocus && React.createElement(
|
|
90
|
-
'div',
|
|
91
|
-
{ className: 'tg-autocomplete-input__suggestions' },
|
|
92
|
-
props.children
|
|
93
|
-
),
|
|
94
|
-
React.createElement(
|
|
95
|
-
'div',
|
|
96
|
-
{ className: 'tg-autocomplete-input__status-text' },
|
|
97
|
-
props.statusText
|
|
98
|
-
)
|
|
99
|
-
);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
AutocompleteInput.Suggestion = AutocompleteSuggestion;
|
|
103
|
-
|
|
104
|
-
export default AutocompleteInput;
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
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; };
|
|
2
|
-
|
|
3
|
-
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; }
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { Select, Input, useId, useValue, useFocus, createClassName, flatObj } from '../common';
|
|
7
|
-
import Translate from '../Translate';
|
|
8
|
-
import translate from '../../lib/utils/translate';
|
|
9
|
-
import cn from 'classnames';
|
|
10
|
-
import { useIntl } from 'react-intl';
|
|
11
|
-
|
|
12
|
-
var pad = function pad(num) {
|
|
13
|
-
return ('' + num).length === 1 ? '0' + num : num;
|
|
14
|
-
};
|
|
15
|
-
var yearRange = new Array(100).fill(null, 0, 100).map(function (y, i) {
|
|
16
|
-
return new Date().getFullYear() - 18 - i;
|
|
17
|
-
});
|
|
18
|
-
var monthRange = new Array(12).fill(null, 0, 12).map(function (m, i) {
|
|
19
|
-
return i + 1;
|
|
20
|
-
});
|
|
21
|
-
var dayRange = new Array(31).fill(null, 0, 31).map(function (d, i) {
|
|
22
|
-
return i + 1;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
var BirthdateInput = function BirthdateInput(props) {
|
|
26
|
-
var intl = useIntl();
|
|
27
|
-
|
|
28
|
-
var yearInput = {
|
|
29
|
-
id: useId(),
|
|
30
|
-
value: useValue(props.value.split('/')[0]),
|
|
31
|
-
focus: useFocus()
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
var monthInput = {
|
|
35
|
-
id: useId(),
|
|
36
|
-
value: useValue(props.value.split('/')[1]),
|
|
37
|
-
focus: useFocus()
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
var dayInput = {
|
|
41
|
-
id: useId(),
|
|
42
|
-
value: useValue(props.value.split('/')[2]),
|
|
43
|
-
focus: useFocus()
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var createValue = function createValue() {
|
|
47
|
-
var _Object$values;
|
|
48
|
-
|
|
49
|
-
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
50
|
-
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
51
|
-
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('/');
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var _onChange = function _onChange(e) {
|
|
55
|
-
return props.onChange && props.onChange(e, createValue(e.target.id, e.target.value));
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
var _onBlur = function _onBlur(e) {
|
|
59
|
-
return props.onBlur && props.onBlur(e, createValue(e.target.id, e.target.value));
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
var inputs = [yearInput, monthInput, dayInput];
|
|
63
|
-
var className = createClassName('tg-birthdate-input', {
|
|
64
|
-
hasValue: inputs.some(function (i) {
|
|
65
|
-
return i.value.hasValue;
|
|
66
|
-
}),
|
|
67
|
-
hasFocus: inputs.some(function (i) {
|
|
68
|
-
return i.focus.hasFocus;
|
|
69
|
-
}),
|
|
70
|
-
status: props.status
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
return React.createElement(
|
|
74
|
-
'div',
|
|
75
|
-
{ className: cn(props.className, className) },
|
|
76
|
-
React.createElement(
|
|
77
|
-
'label',
|
|
78
|
-
{ className: 'tg-birthdate-input__label' },
|
|
79
|
-
props.label
|
|
80
|
-
),
|
|
81
|
-
React.createElement(
|
|
82
|
-
Select,
|
|
83
|
-
_extends({}, flatObj(yearInput), {
|
|
84
|
-
autoFocus: props.autoFocus && !yearInput.value.hasValue,
|
|
85
|
-
name: props.name + '_year',
|
|
86
|
-
label: React.createElement(Translate, { id: 'label.year-of-birth', defaultMessage: 'Year' }),
|
|
87
|
-
status: props.status,
|
|
88
|
-
onChange: function onChange(e) {
|
|
89
|
-
yearInput.value.onChange(e.target.value);
|
|
90
|
-
_onChange(e);
|
|
91
|
-
},
|
|
92
|
-
onBlur: function onBlur(e) {
|
|
93
|
-
yearInput.focus.onBlur();
|
|
94
|
-
_onBlur(e);
|
|
95
|
-
} }),
|
|
96
|
-
!yearInput.value.hasValue && React.createElement(
|
|
97
|
-
Select.Option,
|
|
98
|
-
{ value: '', selected: true, disabled: true },
|
|
99
|
-
translate({ id: 'label.year-of-birth', defaultMessage: 'Year' }, intl)
|
|
100
|
-
),
|
|
101
|
-
yearRange.map(function (y) {
|
|
102
|
-
return React.createElement(
|
|
103
|
-
Select.Option,
|
|
104
|
-
{ key: y, value: y },
|
|
105
|
-
y
|
|
106
|
-
);
|
|
107
|
-
})
|
|
108
|
-
),
|
|
109
|
-
React.createElement(
|
|
110
|
-
Select,
|
|
111
|
-
_extends({}, flatObj(monthInput), {
|
|
112
|
-
autoFocus: props.autoFocus && yearInput.value.hasValue && !monthInput.value.hasValue,
|
|
113
|
-
name: props.name + '_month',
|
|
114
|
-
label: React.createElement(Translate, { id: 'label.month-of-birth', defaultMessage: 'Month' }),
|
|
115
|
-
status: props.status,
|
|
116
|
-
onChange: function onChange(e) {
|
|
117
|
-
monthInput.value.onChange(e.target.value);
|
|
118
|
-
_onChange(e);
|
|
119
|
-
},
|
|
120
|
-
onBlur: function onBlur(e) {
|
|
121
|
-
monthInput.focus.onBlur();
|
|
122
|
-
_onBlur(e);
|
|
123
|
-
} }),
|
|
124
|
-
!monthInput.value.hasValue && React.createElement(
|
|
125
|
-
Select.Option,
|
|
126
|
-
{ value: '', selected: true, disabled: true },
|
|
127
|
-
translate({ id: 'label.month-of-birth', defaultMessage: 'Month' }, intl)
|
|
128
|
-
),
|
|
129
|
-
monthRange.map(function (m) {
|
|
130
|
-
return React.createElement(
|
|
131
|
-
Select.Option,
|
|
132
|
-
{ key: m, value: pad(m) },
|
|
133
|
-
m
|
|
134
|
-
);
|
|
135
|
-
})
|
|
136
|
-
),
|
|
137
|
-
React.createElement(
|
|
138
|
-
Select,
|
|
139
|
-
_extends({}, flatObj(dayInput), {
|
|
140
|
-
autoFocus: props.autoFocus && yearInput.value.hasValue && monthInput.value.hasValue,
|
|
141
|
-
name: props.name + '_day',
|
|
142
|
-
label: React.createElement(Translate, { id: 'label.day-of-birth', defaultMessage: 'Day' }),
|
|
143
|
-
status: props.status,
|
|
144
|
-
onChange: function onChange(e) {
|
|
145
|
-
dayInput.value.onChange(e.target.value);
|
|
146
|
-
_onChange(e);
|
|
147
|
-
},
|
|
148
|
-
onBlur: function onBlur(e) {
|
|
149
|
-
dayInput.focus.onBlur();
|
|
150
|
-
_onBlur(e);
|
|
151
|
-
} }),
|
|
152
|
-
!dayInput.value.hasValue && React.createElement(
|
|
153
|
-
Select.Option,
|
|
154
|
-
{ value: '', selected: true, disabled: true },
|
|
155
|
-
translate({ id: 'label.day-of-birth', defaultMessage: 'Day' }, intl)
|
|
156
|
-
),
|
|
157
|
-
dayRange.map(function (d) {
|
|
158
|
-
return React.createElement(
|
|
159
|
-
Select.Option,
|
|
160
|
-
{ key: d, value: pad(d) },
|
|
161
|
-
d
|
|
162
|
-
);
|
|
163
|
-
})
|
|
164
|
-
),
|
|
165
|
-
React.createElement(Input, { type: 'hidden', name: props.name, value: createValue() }),
|
|
166
|
-
React.createElement(
|
|
167
|
-
'div',
|
|
168
|
-
{ className: 'tg-birthdate-input__status-text' },
|
|
169
|
-
props.statusText
|
|
170
|
-
)
|
|
171
|
-
);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
export default BirthdateInput;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
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; };
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { Checkbox, useId, useValue, useFocus, useTouched, useAutofill, createClassName, flatObj } from '../common';
|
|
5
|
-
import cn from 'classnames';
|
|
6
|
-
|
|
7
|
-
var TGCheckbox = function TGCheckbox(props) {
|
|
8
|
-
var checkbox = {
|
|
9
|
-
id: useId(),
|
|
10
|
-
value: useValue(props.value),
|
|
11
|
-
focus: useFocus(),
|
|
12
|
-
touched: useTouched(),
|
|
13
|
-
autofill: useAutofill()
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
var _onChange = function _onChange(e) {
|
|
17
|
-
return props.onChange && props.onChange(e, e.target.checked ? 'true' : '');
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
var className = createClassName('tg-checkbox', {
|
|
21
|
-
hasValue: checkbox.value.hasValue,
|
|
22
|
-
hasLabel: Boolean(props.label),
|
|
23
|
-
hasFocus: checkbox.focus.hasFocus,
|
|
24
|
-
hasTouched: checkbox.touched.hasTouched,
|
|
25
|
-
hasAutofill: checkbox.autofill.hasAutofill,
|
|
26
|
-
disabled: props.disabled,
|
|
27
|
-
status: props.status
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return React.createElement(
|
|
31
|
-
'div',
|
|
32
|
-
{ className: cn(props.className, className) },
|
|
33
|
-
React.createElement(Checkbox, _extends({}, props, flatObj(checkbox), {
|
|
34
|
-
onChange: function onChange(e) {
|
|
35
|
-
checkbox.value.onChange(e.target.checked ? 'true' : '');
|
|
36
|
-
_onChange(e);
|
|
37
|
-
},
|
|
38
|
-
onFocus: function onFocus() {
|
|
39
|
-
checkbox.focus.onFocus();
|
|
40
|
-
checkbox.touched.onFocus();
|
|
41
|
-
}
|
|
42
|
-
})),
|
|
43
|
-
React.createElement(
|
|
44
|
-
'div',
|
|
45
|
-
{ className: 'tg-checkbox__status-text' },
|
|
46
|
-
props.statusText
|
|
47
|
-
)
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default TGCheckbox;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
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; };
|
|
2
|
-
|
|
3
|
-
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; }
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { Input, useId, useValue, useFocus, useTouched, useAutofill, createClassName, statusIcons, flatObj } from '../common';
|
|
7
|
-
import cn from 'classnames';
|
|
8
|
-
|
|
9
|
-
var TGInput = function TGInput(_ref) {
|
|
10
|
-
var icon = _ref.icon,
|
|
11
|
-
props = _objectWithoutProperties(_ref, ['icon']);
|
|
12
|
-
|
|
13
|
-
var input = {
|
|
14
|
-
id: useId(),
|
|
15
|
-
value: useValue(props.value),
|
|
16
|
-
focus: useFocus(),
|
|
17
|
-
touched: useTouched(),
|
|
18
|
-
autofill: useAutofill()
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
var _onChange = function _onChange(e) {
|
|
22
|
-
return props.onChange && props.onChange(e, e.target.value);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
var _onBlur = function _onBlur(e) {
|
|
26
|
-
return props.onBlur && props.onBlur(e, e.target.value);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
var className = createClassName('tg-input', {
|
|
30
|
-
hasValue: input.value.hasValue,
|
|
31
|
-
hasLabel: Boolean(props.label),
|
|
32
|
-
hasFocus: input.focus.hasFocus,
|
|
33
|
-
hasTouched: input.touched.hasTouched,
|
|
34
|
-
hasAutofill: input.autofill.hasAutofill,
|
|
35
|
-
disabled: props.disabled,
|
|
36
|
-
status: props.status
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return React.createElement(
|
|
40
|
-
'div',
|
|
41
|
-
{ className: cn(props.className, className) },
|
|
42
|
-
React.createElement(Input, _extends({}, props, flatObj(input), {
|
|
43
|
-
onChange: function onChange(e) {
|
|
44
|
-
if (typeof props.transform === 'function') {
|
|
45
|
-
e.target.value = props.transform(e.target.value);
|
|
46
|
-
}
|
|
47
|
-
input.value.onChange(e.target.value);
|
|
48
|
-
_onChange(e);
|
|
49
|
-
},
|
|
50
|
-
onFocus: function onFocus() {
|
|
51
|
-
input.focus.onFocus();
|
|
52
|
-
input.touched.onFocus();
|
|
53
|
-
},
|
|
54
|
-
onBlur: function onBlur(e) {
|
|
55
|
-
input.focus.onBlur();
|
|
56
|
-
_onBlur(e);
|
|
57
|
-
},
|
|
58
|
-
leadingLane: [icon].filter(function (i) {
|
|
59
|
-
return i;
|
|
60
|
-
}),
|
|
61
|
-
trailingLane: [statusIcons[props.status]].filter(function (i) {
|
|
62
|
-
return i;
|
|
63
|
-
})
|
|
64
|
-
})),
|
|
65
|
-
React.createElement(
|
|
66
|
-
'div',
|
|
67
|
-
{ className: 'tg-input__status-text' },
|
|
68
|
-
props.statusText
|
|
69
|
-
)
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export default TGInput;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
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; };
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import Icon from '../Icon';
|
|
5
|
-
import { Input, useId, useValue, useFocus, useTouched, useType, createClassName, statusIcons, useAutofill, flatObj } from '../common';
|
|
6
|
-
import cn from 'classnames';
|
|
7
|
-
|
|
8
|
-
var PasswordInput = function PasswordInput(props) {
|
|
9
|
-
var input = {
|
|
10
|
-
id: useId(),
|
|
11
|
-
value: useValue(props.value),
|
|
12
|
-
focus: useFocus(),
|
|
13
|
-
touched: useTouched(),
|
|
14
|
-
type: useType(props.type),
|
|
15
|
-
autofill: useAutofill()
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
var _onChange = function _onChange(e) {
|
|
19
|
-
return props.onChange && props.onChange(e, e.target.value);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
var _onBlur = function _onBlur(e) {
|
|
23
|
-
return props.onBlur && props.onBlur(e, e.target.value);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
var togglePasswordVisibility = function togglePasswordVisibility() {
|
|
27
|
-
return input.type.setType(input.type.type === 'password' ? 'text' : 'password');
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
var icons = {
|
|
31
|
-
password: React.createElement(Icon, {
|
|
32
|
-
icon: 'eye-slash',
|
|
33
|
-
className: 'tg-password-input__toggle',
|
|
34
|
-
onClick: togglePasswordVisibility
|
|
35
|
-
}),
|
|
36
|
-
text: React.createElement(Icon, {
|
|
37
|
-
icon: 'eye',
|
|
38
|
-
className: 'tg-password-input__toggle',
|
|
39
|
-
onClick: togglePasswordVisibility
|
|
40
|
-
})
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
var className = createClassName('tg-password-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 React.createElement(
|
|
54
|
-
'div',
|
|
55
|
-
{ className: cn(props.className, className) },
|
|
56
|
-
React.createElement(Input, _extends({}, props, flatObj(input), {
|
|
57
|
-
onChange: function onChange(e) {
|
|
58
|
-
input.value.onChange(e.target.value);
|
|
59
|
-
_onChange(e);
|
|
60
|
-
},
|
|
61
|
-
onFocus: function onFocus() {
|
|
62
|
-
input.focus.onFocus();
|
|
63
|
-
input.touched.onFocus();
|
|
64
|
-
},
|
|
65
|
-
onBlur: function onBlur(e) {
|
|
66
|
-
input.focus.onBlur();
|
|
67
|
-
_onBlur(e);
|
|
68
|
-
},
|
|
69
|
-
leadingLane: [props.icon].filter(function (i) {
|
|
70
|
-
return i;
|
|
71
|
-
}),
|
|
72
|
-
trailingLane: [icons[input.type.type], statusIcons[props.status]].filter(function (i) {
|
|
73
|
-
return i;
|
|
74
|
-
})
|
|
75
|
-
})),
|
|
76
|
-
React.createElement(
|
|
77
|
-
'div',
|
|
78
|
-
{ className: 'tg-password-input__status-text' },
|
|
79
|
-
props.statusText
|
|
80
|
-
)
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default PasswordInput;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
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; };
|
|
2
|
-
|
|
3
|
-
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; }
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { Input, Select, useId, useValue, useFocus, createClassName, statusIcons, flatObj } from '../common';
|
|
7
|
-
import Translate from '../Translate';
|
|
8
|
-
import cn from 'classnames';
|
|
9
|
-
|
|
10
|
-
var PhoneNumberInput = function PhoneNumberInput(props) {
|
|
11
|
-
var val = props.value || '';
|
|
12
|
-
|
|
13
|
-
var callingCodeValue = ((props.callingCodes || []).slice().sort(function (a, b) {
|
|
14
|
-
return b.value - a.value;
|
|
15
|
-
}).find(function (c) {
|
|
16
|
-
return val.startsWith(c.value);
|
|
17
|
-
}) || (props.callingCodes || [])[0] || {}).value || '';
|
|
18
|
-
var phoneNumberValue = callingCodeValue ? val.replace(new RegExp('^' + callingCodeValue), '').replace(/^0*/, '') : val;
|
|
19
|
-
|
|
20
|
-
var callingCodeSelect = {
|
|
21
|
-
id: useId(),
|
|
22
|
-
value: useValue(callingCodeValue),
|
|
23
|
-
focus: useFocus()
|
|
24
|
-
};
|
|
25
|
-
var phoneNumberInput = {
|
|
26
|
-
id: useId(),
|
|
27
|
-
value: useValue(phoneNumberValue),
|
|
28
|
-
focus: useFocus()
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
var createValue = function createValue() {
|
|
32
|
-
var _Object$values;
|
|
33
|
-
|
|
34
|
-
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
35
|
-
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
36
|
-
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('');
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var _onChange = function _onChange(e) {
|
|
40
|
-
return props.onChange && props.onChange(e, createValue(e.target.id, e.target.value));
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
var _onBlur = function _onBlur(e) {
|
|
44
|
-
return props.onBlur && props.onBlur(e, createValue(e.target.id, e.target.value));
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var inputs = [callingCodeSelect, phoneNumberInput];
|
|
48
|
-
var className = createClassName('tg-phonenumber-input', {
|
|
49
|
-
hasValue: inputs.some(function (i) {
|
|
50
|
-
return i.value.hasValue;
|
|
51
|
-
}),
|
|
52
|
-
hasFocus: inputs.some(function (i) {
|
|
53
|
-
return i.focus.hasFocus;
|
|
54
|
-
}),
|
|
55
|
-
status: props.status
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return React.createElement(
|
|
59
|
-
'div',
|
|
60
|
-
{ className: cn(props.className, className) },
|
|
61
|
-
callingCodeSelect.value.hasValue && React.createElement(
|
|
62
|
-
Select,
|
|
63
|
-
_extends({}, flatObj(callingCodeSelect), {
|
|
64
|
-
name: props.name + '_calling-code',
|
|
65
|
-
label: React.createElement(Translate, { id: 'label.calling-code', defaultMessage: 'Calling code' }),
|
|
66
|
-
onChange: function onChange(e) {
|
|
67
|
-
callingCodeSelect.value.onChange(e.target.value);
|
|
68
|
-
_onChange(e);
|
|
69
|
-
},
|
|
70
|
-
onBlur: function onBlur(e) {
|
|
71
|
-
callingCodeSelect.focus.onBlur();
|
|
72
|
-
_onBlur(e);
|
|
73
|
-
},
|
|
74
|
-
status: props.status }),
|
|
75
|
-
(props.callingCodes || []).map(function (c, i) {
|
|
76
|
-
return React.createElement(
|
|
77
|
-
Select.Option,
|
|
78
|
-
{ key: c.value + i, value: c.value },
|
|
79
|
-
c.label
|
|
80
|
-
);
|
|
81
|
-
})
|
|
82
|
-
),
|
|
83
|
-
React.createElement(Input, _extends({}, flatObj(phoneNumberInput), {
|
|
84
|
-
autoFocus: props.autoFocus,
|
|
85
|
-
type: 'tel',
|
|
86
|
-
name: props.name + '_number',
|
|
87
|
-
label: React.createElement(Translate, {
|
|
88
|
-
id: 'label.mobile_number',
|
|
89
|
-
defaultMessage: 'MobilePhoneNumber'
|
|
90
|
-
}),
|
|
91
|
-
onChange: function onChange(e) {
|
|
92
|
-
phoneNumberInput.value.onChange(e.target.value);
|
|
93
|
-
_onChange(e);
|
|
94
|
-
},
|
|
95
|
-
onBlur: function onBlur(e) {
|
|
96
|
-
phoneNumberInput.focus.onBlur();
|
|
97
|
-
_onBlur(e);
|
|
98
|
-
},
|
|
99
|
-
status: props.status,
|
|
100
|
-
trailingLane: [statusIcons[props.status]].filter(function (i) {
|
|
101
|
-
return i;
|
|
102
|
-
})
|
|
103
|
-
})),
|
|
104
|
-
React.createElement(Input, { type: 'hidden', name: props.name, value: createValue() }),
|
|
105
|
-
React.createElement(
|
|
106
|
-
'div',
|
|
107
|
-
{ className: 'tg-phonenumber-input__status-text' },
|
|
108
|
-
props.statusText
|
|
109
|
-
)
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export default PhoneNumberInput;
|
|
@@ -1,80 +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 './index.js';
|
|
9
|
-
|
|
10
|
-
test('text has value and associated label', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
11
|
-
var input;
|
|
12
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
13
|
-
while (1) {
|
|
14
|
-
switch (_context.prev = _context.next) {
|
|
15
|
-
case 0:
|
|
16
|
-
render(React.createElement(Input, { type: 'text', label: 'input label', value: '1337' }));
|
|
17
|
-
input = screen.getByLabelText('input label');
|
|
18
|
-
|
|
19
|
-
fireEvent.click(input);
|
|
20
|
-
expect(input).toHaveValue('1337');
|
|
21
|
-
|
|
22
|
-
case 4:
|
|
23
|
-
case 'end':
|
|
24
|
-
return _context.stop();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}, _callee, _this);
|
|
28
|
-
})));
|
|
29
|
-
|
|
30
|
-
test('text input has placeholder', _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, {
|
|
37
|
-
type: 'text',
|
|
38
|
-
label: 'input label',
|
|
39
|
-
placeholder: 'Placeholder text',
|
|
40
|
-
value: '1337'
|
|
41
|
-
}));
|
|
42
|
-
input = screen.getByPlaceholderText('Placeholder text');
|
|
43
|
-
|
|
44
|
-
expect(input).toHaveValue('1337');
|
|
45
|
-
|
|
46
|
-
case 3:
|
|
47
|
-
case 'end':
|
|
48
|
-
return _context2.stop();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}, _callee2, _this);
|
|
52
|
-
})));
|
|
53
|
-
|
|
54
|
-
test('text input has correct class names', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
55
|
-
var input;
|
|
56
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
57
|
-
while (1) {
|
|
58
|
-
switch (_context3.prev = _context3.next) {
|
|
59
|
-
case 0:
|
|
60
|
-
render(React.createElement(Input, {
|
|
61
|
-
type: 'text',
|
|
62
|
-
label: 'input label',
|
|
63
|
-
placeholder: 'Placeholder text',
|
|
64
|
-
value: '1337'
|
|
65
|
-
}));
|
|
66
|
-
input = screen.getByLabelText('input label');
|
|
67
|
-
|
|
68
|
-
expect(input.parentElement.parentElement).toHaveClass('DefaultInput');
|
|
69
|
-
fireEvent.click(input);
|
|
70
|
-
waitFor(function () {
|
|
71
|
-
return expect(input.parentElement).toHaveClass('Input--has-focus');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
case 5:
|
|
75
|
-
case 'end':
|
|
76
|
-
return _context3.stop();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}, _callee3, _this);
|
|
80
|
-
})));
|