@pareto-engineering/design-system 2.0.0-alpha.55 → 2.0.0-alpha.57
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/dist/cjs/a/Alert/Alert.js +141 -0
- package/dist/cjs/a/Alert/index.js +15 -0
- package/dist/cjs/a/Alert/styles.scss +74 -0
- package/dist/cjs/a/index.js +9 -1
- package/dist/cjs/f/fields/IntlTelInput/IntlTelInput.js +170 -0
- package/dist/cjs/f/fields/IntlTelInput/index.js +15 -0
- package/dist/cjs/f/fields/IntlTelInput/styles.scss +37 -0
- package/dist/cjs/f/fields/PhoneIntlTelInput/PhoneIntlTelInput.js +180 -0
- package/dist/cjs/f/fields/PhoneIntlTelInput/index.js +15 -0
- package/dist/cjs/f/fields/PhoneIntlTelInput/styles.scss +43 -0
- package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +2 -1
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +10 -3
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +10 -3
- package/dist/es/a/Alert/Alert.js +118 -0
- package/dist/es/a/Alert/index.js +2 -0
- package/dist/es/a/Alert/styles.scss +74 -0
- package/dist/es/a/index.js +2 -1
- package/dist/es/f/fields/IntlTelInput/IntlTelInput.js +152 -0
- package/dist/es/f/fields/IntlTelInput/index.js +2 -0
- package/dist/es/f/fields/IntlTelInput/styles.scss +37 -0
- package/dist/es/f/fields/PhoneIntlTelInput/PhoneIntlTelInput.js +163 -0
- package/dist/es/f/fields/PhoneIntlTelInput/index.js +2 -0
- package/dist/es/f/fields/PhoneIntlTelInput/styles.scss +43 -0
- package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +2 -1
- package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +10 -3
- package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +10 -3
- package/package.json +2 -2
- package/src/__snapshots__/Storyshots.test.js.snap +330 -26
- package/src/stories/a/Alert.stories.jsx +75 -0
- package/src/stories/a/DotInfo.stories.jsx +2 -1
- package/src/stories/a/ProgressBar.stories.jsx +4 -1
- package/src/stories/a/Timestamp.stories.jsx +3 -1
- package/src/stories/b/Logo.stories.jsx +2 -1
- package/src/stories/b/QuestionDropdown.stories.jsx +3 -0
- package/src/stories/b/SocialMediaButton.stories.jsx +2 -1
- package/src/stories/b/Title.stories.jsx +2 -2
- package/src/stories/c/ContentSlides.stories.jsx +3 -1
- package/src/stories/c/Shortener.stories.jsx +9 -3
- package/src/stories/c/SocialMediaShareButton.stories.jsx +14 -6
- package/src/stories/f/ChoicesInput.stories.jsx +4 -1
- package/src/stories/f/Description.stories.jsx +11 -3
- package/src/stories/f/QueryCombobox.stories.jsx +7 -3
- package/src/stories/f/QuerySelect.stories.jsx +2 -1
- package/src/stories/f/RatingsInput.stories.jsx +8 -1
- package/src/stories/f/SelectInput.stories.jsx +2 -1
- package/src/stories/f/TextInput.stories.jsx +7 -1
- package/src/stories/f/TextareaInput.stories.jsx +6 -1
- package/src/ui/a/Alert/Alert.jsx +144 -0
- package/src/ui/a/Alert/index.js +2 -0
- package/src/ui/a/Alert/styles.scss +74 -0
- package/src/ui/a/index.js +1 -0
- package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +1 -0
- package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +7 -1
- package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +6 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
@use "@pareto-engineering/bem";
|
|
3
|
+
|
|
4
|
+
$default-padding: 0.75em 0.75em 0.55em;
|
|
5
|
+
|
|
6
|
+
.#{bem.$base}.phone-intl-tel-input {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
|
|
10
|
+
&.error {
|
|
11
|
+
>.#{bem.$base}.description {
|
|
12
|
+
color: var(--error);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.input-wrapper {
|
|
17
|
+
width: 100%;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.input {
|
|
21
|
+
border: var(--theme-border-style) var(--dark-y);
|
|
22
|
+
background: var(--light-y);
|
|
23
|
+
color: var(--on-y);
|
|
24
|
+
padding: $default-padding;
|
|
25
|
+
width: 100%;
|
|
26
|
+
|
|
27
|
+
&::placeholder {
|
|
28
|
+
color: var(--metadata);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:not(:disabled):hover {
|
|
32
|
+
border: var(--theme-border-style) var(--light-background4);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:disabled {
|
|
36
|
+
background-color: var(--dark-y);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&:focus {
|
|
40
|
+
background: var(--light-background4);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -228,7 +228,8 @@ QueryCombobox.defaultProps = {
|
|
|
228
228
|
color: 'background2',
|
|
229
229
|
searchVariable: 'search',
|
|
230
230
|
transformSearch: search => search,
|
|
231
|
-
minLength: 2
|
|
231
|
+
minLength: 2,
|
|
232
|
+
disabled: false
|
|
232
233
|
};
|
|
233
234
|
var _default = QueryCombobox;
|
|
234
235
|
exports.default = _default;
|
|
@@ -48,7 +48,8 @@ var Combobox = _ref => {
|
|
|
48
48
|
color,
|
|
49
49
|
minLength,
|
|
50
50
|
isFetching,
|
|
51
|
-
transformSearch
|
|
51
|
+
transformSearch,
|
|
52
|
+
disabled // ...otherProps
|
|
52
53
|
|
|
53
54
|
} = _ref;
|
|
54
55
|
var {
|
|
@@ -100,7 +101,8 @@ var Combobox = _ref => {
|
|
|
100
101
|
}), label), /*#__PURE__*/React.createElement("div", _extends({}, getComboboxProps(), {
|
|
101
102
|
className: "input-wrapper"
|
|
102
103
|
}), /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(), {
|
|
103
|
-
className: "input"
|
|
104
|
+
className: "input",
|
|
105
|
+
disabled: disabled
|
|
104
106
|
})), isFetching && /*#__PURE__*/React.createElement(_a.LoadingCircle, {
|
|
105
107
|
className: "x-main2"
|
|
106
108
|
})), /*#__PURE__*/React.createElement(_a.Popover, {
|
|
@@ -193,7 +195,12 @@ Combobox.propTypes = {
|
|
|
193
195
|
/**
|
|
194
196
|
* The function to transform the search input
|
|
195
197
|
*/
|
|
196
|
-
transformSearch: _propTypes.default.func
|
|
198
|
+
transformSearch: _propTypes.default.func,
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Whether the input filed shpuld be disabled
|
|
202
|
+
*/
|
|
203
|
+
disabled: _propTypes.default.bool
|
|
197
204
|
};
|
|
198
205
|
Combobox.defaultProps = {// someProp: false
|
|
199
206
|
};
|
|
@@ -65,7 +65,8 @@ var MultipleCombobox = _ref => {
|
|
|
65
65
|
color,
|
|
66
66
|
isFetching,
|
|
67
67
|
minLength,
|
|
68
|
-
transformSearch
|
|
68
|
+
transformSearch,
|
|
69
|
+
disabled // ...otherProps
|
|
69
70
|
|
|
70
71
|
} = _ref;
|
|
71
72
|
var [searchInputValue, setSearchInputValue] = (0, React.useState)('');
|
|
@@ -199,7 +200,8 @@ var MultipleCombobox = _ref => {
|
|
|
199
200
|
}), /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(getDropdownProps({
|
|
200
201
|
preventKeyAction: isOpen
|
|
201
202
|
})), {
|
|
202
|
-
className: "input"
|
|
203
|
+
className: "input",
|
|
204
|
+
disabled: disabled
|
|
203
205
|
})), isFetching && /*#__PURE__*/React.createElement(_a.LoadingCircle, {
|
|
204
206
|
className: "x-main2"
|
|
205
207
|
})), /*#__PURE__*/React.createElement(_a.Popover, {
|
|
@@ -292,7 +294,12 @@ MultipleCombobox.propTypes = {
|
|
|
292
294
|
/**
|
|
293
295
|
* The function to transform the search input
|
|
294
296
|
*/
|
|
295
|
-
transformSearch: _propTypes.default.func
|
|
297
|
+
transformSearch: _propTypes.default.func,
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Whether the input filed shpuld be disabled
|
|
301
|
+
*/
|
|
302
|
+
disabled: _propTypes.default.bool
|
|
296
303
|
};
|
|
297
304
|
MultipleCombobox.defaultProps = {// someProp: false
|
|
298
305
|
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useState, useEffect, useLayoutEffect } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { Button } from "../../b";
|
|
6
|
+
import styleNames from '@pareto-engineering/bem'; // Local Definitions
|
|
7
|
+
|
|
8
|
+
const baseClassName = styleNames.base;
|
|
9
|
+
const componentClassName = 'alert';
|
|
10
|
+
/**
|
|
11
|
+
* This is the component description.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const Alert = ({
|
|
15
|
+
id,
|
|
16
|
+
className: userClassName,
|
|
17
|
+
style,
|
|
18
|
+
children,
|
|
19
|
+
type,
|
|
20
|
+
withCloseIcon,
|
|
21
|
+
primaryPosition,
|
|
22
|
+
secondaryPosition,
|
|
23
|
+
autoCloseMs,
|
|
24
|
+
width // ...otherProps
|
|
25
|
+
|
|
26
|
+
}) => {
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
import("./styles.scss");
|
|
29
|
+
}, []);
|
|
30
|
+
const [hideAlert, setHideAlert] = useState(false);
|
|
31
|
+
|
|
32
|
+
const handleCloseAlert = () => setHideAlert(true);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (autoCloseMs) {
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
setHideAlert(true);
|
|
38
|
+
}, autoCloseMs);
|
|
39
|
+
}
|
|
40
|
+
}, [autoCloseMs]);
|
|
41
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
id: id,
|
|
43
|
+
className: [baseClassName, componentClassName, userClassName, `x-${type}`, hideAlert && 'hide', primaryPosition, secondaryPosition].filter(e => e).join(' '),
|
|
44
|
+
style: { ...style,
|
|
45
|
+
'--width': width
|
|
46
|
+
} // {...otherProps}
|
|
47
|
+
|
|
48
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
className: "bar"
|
|
50
|
+
}), withCloseIcon && /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "close"
|
|
52
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
53
|
+
isSimple: true,
|
|
54
|
+
color: "heading",
|
|
55
|
+
onClick: handleCloseAlert
|
|
56
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
57
|
+
className: "f-icons"
|
|
58
|
+
}, "Y"))), /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
className: "content"
|
|
60
|
+
}, children));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
Alert.propTypes = {
|
|
64
|
+
/**
|
|
65
|
+
* The HTML id for this element
|
|
66
|
+
*/
|
|
67
|
+
id: PropTypes.string,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The HTML class names for this element
|
|
71
|
+
*/
|
|
72
|
+
className: PropTypes.string,
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The React-written, css properties for this element.
|
|
76
|
+
*/
|
|
77
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The children JSX
|
|
81
|
+
*/
|
|
82
|
+
children: PropTypes.node,
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Whether the alert should have a close Icon
|
|
86
|
+
*/
|
|
87
|
+
withCloseIcon: PropTypes.bool,
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The primary position of the alert
|
|
91
|
+
*/
|
|
92
|
+
primaryPosition: PropTypes.oneOf(['top', 'bottom', 'center']),
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The secondary position of the alert
|
|
96
|
+
*/
|
|
97
|
+
secondaryPosition: PropTypes.oneOf(['left', 'right']),
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The number milisseconds to wait for before closing the alert
|
|
101
|
+
*/
|
|
102
|
+
autoCloseMs: PropTypes.number,
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The type of the alert
|
|
106
|
+
*/
|
|
107
|
+
type: PropTypes.oneOf(['success', 'warning', 'error']),
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The width of the alert
|
|
111
|
+
*/
|
|
112
|
+
width: PropTypes.number
|
|
113
|
+
};
|
|
114
|
+
Alert.defaultProps = {
|
|
115
|
+
withCloseIcon: true,
|
|
116
|
+
primaryPosition: 'top'
|
|
117
|
+
};
|
|
118
|
+
export default Alert;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
@use "@pareto-engineering/bem";
|
|
3
|
+
@use "@aztlan/stylebook/src/mixins";
|
|
4
|
+
@use "@aztlan/stylebook/src/globals" as *;
|
|
5
|
+
|
|
6
|
+
$default-padding: 1em;
|
|
7
|
+
$default-bar-height: .3em;
|
|
8
|
+
$default-alert-desktop-width: var(--width, 30em);
|
|
9
|
+
|
|
10
|
+
.#{bem.$base}.alert {
|
|
11
|
+
border: var(--theme-border);
|
|
12
|
+
padding-bottom: $default-padding * 1.5;
|
|
13
|
+
width: 100%;
|
|
14
|
+
position: absolute;
|
|
15
|
+
z-index: 1;
|
|
16
|
+
|
|
17
|
+
&.center {
|
|
18
|
+
top: 50%;
|
|
19
|
+
left: 50%;
|
|
20
|
+
transform: translate(-50%, -50%);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.top {
|
|
24
|
+
top: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.bottom {
|
|
28
|
+
bottom: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.right {
|
|
32
|
+
right: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.left {
|
|
36
|
+
left: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.hide {
|
|
40
|
+
display: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
>.bar {
|
|
44
|
+
background-color: var(--x);
|
|
45
|
+
height: $default-bar-height;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
>.close {
|
|
49
|
+
display: flex;
|
|
50
|
+
justify-content: flex-end;
|
|
51
|
+
|
|
52
|
+
span {
|
|
53
|
+
padding: $default-padding / 2;
|
|
54
|
+
font-size: calc(var(--s-2) * 1em);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.bar+.content {
|
|
59
|
+
padding-top: $default-padding * 1.5;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
>.content {
|
|
63
|
+
padding-inline: $default-padding;
|
|
64
|
+
|
|
65
|
+
.icon {
|
|
66
|
+
color: var(--x)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Desktop styles
|
|
71
|
+
@include mixins.media($from: $sm-md) {
|
|
72
|
+
width: $default-alert-desktop-width;
|
|
73
|
+
}
|
|
74
|
+
}
|
package/dist/es/a/index.js
CHANGED
|
@@ -23,4 +23,5 @@ export { OvalIllustration } from "./OvalIllustration";
|
|
|
23
23
|
export { SnapScroller } from "./SnapScroller";
|
|
24
24
|
export { BackgroundGradient } from "./BackgroundGradient";
|
|
25
25
|
export { ContentTree } from "./ContentTree";
|
|
26
|
-
export { Popover } from "./Popover";
|
|
26
|
+
export { Popover } from "./Popover";
|
|
27
|
+
export { Alert } from "./Alert";
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
function _extends() { _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; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useRef, useEffect, useLayoutEffect } from 'react';
|
|
6
|
+
import intlTelInput from 'intl-tel-input';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import styleNames from '@pareto-engineering/bem'; // Local Definitions
|
|
9
|
+
|
|
10
|
+
import { useField } from 'formik';
|
|
11
|
+
import { FormLabel, FormDescription } from "../../common";
|
|
12
|
+
const baseClassName = styleNames.base;
|
|
13
|
+
const componentClassName = 'intl-tel-input';
|
|
14
|
+
/**
|
|
15
|
+
* This is the component description.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const IntlTelInput = ({
|
|
19
|
+
id,
|
|
20
|
+
className: userClassName,
|
|
21
|
+
style,
|
|
22
|
+
name,
|
|
23
|
+
label,
|
|
24
|
+
color,
|
|
25
|
+
labelColor,
|
|
26
|
+
validate,
|
|
27
|
+
oneInputLabel,
|
|
28
|
+
description,
|
|
29
|
+
disabled,
|
|
30
|
+
// placeholder,
|
|
31
|
+
optional,
|
|
32
|
+
autoComplete // ...otherProps
|
|
33
|
+
|
|
34
|
+
}) => {
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
import("./styles.scss");
|
|
37
|
+
import('intl-tel-input/build/css/intlTelInput.css');
|
|
38
|
+
}, []);
|
|
39
|
+
const [field] = useField({
|
|
40
|
+
name,
|
|
41
|
+
validate
|
|
42
|
+
});
|
|
43
|
+
const input = useRef(null);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const iti = intlTelInput(input.current, {
|
|
46
|
+
separateDialCode: true,
|
|
47
|
+
customContainer: 'input-wrapper'
|
|
48
|
+
});
|
|
49
|
+
return () => iti.destroy();
|
|
50
|
+
}, [input.current]);
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
id: id,
|
|
53
|
+
className: [baseClassName, componentClassName, userClassName, `y-${color}`].filter(e => e).join(' '),
|
|
54
|
+
style: style // {...otherProps}
|
|
55
|
+
|
|
56
|
+
}, /*#__PURE__*/React.createElement(FormLabel, {
|
|
57
|
+
className: [oneInputLabel ? 'md-s2 s0 v1 mb-v' : 'v50 mb-v'].filter(e => e).join(' '),
|
|
58
|
+
name: name,
|
|
59
|
+
color: labelColor,
|
|
60
|
+
optional: optional
|
|
61
|
+
}, label), /*#__PURE__*/React.createElement("input", _extends({
|
|
62
|
+
id: name,
|
|
63
|
+
className: "input",
|
|
64
|
+
type: "tel",
|
|
65
|
+
disabled: disabled // placeholder={placeholder}
|
|
66
|
+
,
|
|
67
|
+
autoComplete: autoComplete,
|
|
68
|
+
ref: input
|
|
69
|
+
}, field)), /*#__PURE__*/React.createElement(FormDescription, {
|
|
70
|
+
className: "v50 mt-v s-1",
|
|
71
|
+
description: description,
|
|
72
|
+
name: name
|
|
73
|
+
}));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
IntlTelInput.propTypes = {
|
|
77
|
+
/**
|
|
78
|
+
* The HTML id for this element
|
|
79
|
+
*/
|
|
80
|
+
id: PropTypes.string,
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The HTML class names for this element
|
|
84
|
+
*/
|
|
85
|
+
className: PropTypes.string,
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The React-written, css properties for this element.
|
|
89
|
+
*/
|
|
90
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The input name (html - and Formik state)
|
|
94
|
+
*/
|
|
95
|
+
name: PropTypes.string.isRequired,
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The input label
|
|
99
|
+
*/
|
|
100
|
+
label: PropTypes.string.isRequired,
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The input label color
|
|
104
|
+
*/
|
|
105
|
+
labelColor: PropTypes.string,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The input field validator function
|
|
109
|
+
*/
|
|
110
|
+
validate: PropTypes.func,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* If the slide will only have one input
|
|
114
|
+
*/
|
|
115
|
+
oneInputLabel: PropTypes.bool,
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Input description
|
|
119
|
+
*/
|
|
120
|
+
description: PropTypes.string,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Whether the text input should be disabled
|
|
124
|
+
*/
|
|
125
|
+
disabled: PropTypes.bool,
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The placeholder text for the input
|
|
129
|
+
*/
|
|
130
|
+
placeholder: PropTypes.string,
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The text input color
|
|
134
|
+
*/
|
|
135
|
+
color: PropTypes.string,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Whether the input is optional or not
|
|
139
|
+
*/
|
|
140
|
+
optional: PropTypes.bool,
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The autoComplete value that the browser should watch for the input
|
|
144
|
+
* `https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete`
|
|
145
|
+
*/
|
|
146
|
+
autoComplete: PropTypes.string
|
|
147
|
+
};
|
|
148
|
+
IntlTelInput.defaultProps = {
|
|
149
|
+
color: 'background2',
|
|
150
|
+
disabled: false
|
|
151
|
+
};
|
|
152
|
+
export default IntlTelInput;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
@use "@pareto-engineering/bem";
|
|
3
|
+
|
|
4
|
+
$default-padding: 0.75em 0.75em 0.55em;
|
|
5
|
+
|
|
6
|
+
.#{bem.$base}.intl-tel-input {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
|
|
10
|
+
.input-wrapper {
|
|
11
|
+
width: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.input {
|
|
15
|
+
border: var(--theme-border-style) var(--dark-y);
|
|
16
|
+
background: var(--light-y);
|
|
17
|
+
color: var(--on-y);
|
|
18
|
+
padding: $default-padding;
|
|
19
|
+
width: 100%;
|
|
20
|
+
|
|
21
|
+
&::placeholder {
|
|
22
|
+
color: var(--metadata);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&:not(:disabled):hover {
|
|
26
|
+
border: var(--theme-border-style) var(--light-background4);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:disabled {
|
|
30
|
+
background-color: var(--dark-y);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&:focus {
|
|
34
|
+
background: var(--light-background4);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useState, useLayoutEffect } from 'react'; // import intlTelInput from 'intl-tel-input'
|
|
4
|
+
|
|
5
|
+
import IntlTelInput from 'react-intl-tel-input';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import styleNames from '@pareto-engineering/bem'; // Local Definitions
|
|
8
|
+
|
|
9
|
+
import { useField } from 'formik';
|
|
10
|
+
import { FormLabel, FormDescription } from "../../common";
|
|
11
|
+
const baseClassName = styleNames.base;
|
|
12
|
+
const componentClassName = 'phone-intl-tel-input';
|
|
13
|
+
/**
|
|
14
|
+
* This is the component description.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const PhoneIntlTelInput = ({
|
|
18
|
+
id,
|
|
19
|
+
className: userClassName,
|
|
20
|
+
style,
|
|
21
|
+
name,
|
|
22
|
+
label,
|
|
23
|
+
color,
|
|
24
|
+
labelColor,
|
|
25
|
+
oneInputLabel,
|
|
26
|
+
description,
|
|
27
|
+
disabled,
|
|
28
|
+
placeholder,
|
|
29
|
+
optional,
|
|
30
|
+
autoComplete,
|
|
31
|
+
validate,
|
|
32
|
+
errorMessage // ...otherProps
|
|
33
|
+
|
|
34
|
+
}) => {
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
import("./styles.scss");
|
|
37
|
+
import('react-intl-tel-input/dist/main.css');
|
|
38
|
+
}, []);
|
|
39
|
+
const [field,, helpers] = useField({
|
|
40
|
+
name,
|
|
41
|
+
validate
|
|
42
|
+
});
|
|
43
|
+
const {
|
|
44
|
+
setValue
|
|
45
|
+
} = helpers;
|
|
46
|
+
const [intlInputError, setIntlInputError] = useState('');
|
|
47
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
id: id,
|
|
49
|
+
className: [baseClassName, componentClassName, userClassName, `y-${color}`, intlInputError && 'error'].filter(e => e).join(' '),
|
|
50
|
+
style: style // {...otherProps}
|
|
51
|
+
|
|
52
|
+
}, /*#__PURE__*/React.createElement(FormLabel, {
|
|
53
|
+
className: [oneInputLabel ? 'md-s2 s0 v1 mb-v' : 'v50 mb-v'].filter(e => e).join(' '),
|
|
54
|
+
name: name,
|
|
55
|
+
color: labelColor,
|
|
56
|
+
optional: optional
|
|
57
|
+
}, label), /*#__PURE__*/React.createElement(IntlTelInput, {
|
|
58
|
+
inputClassName: "input",
|
|
59
|
+
customContainer: "input-wrapper",
|
|
60
|
+
placeholder: placeholder,
|
|
61
|
+
disabled: disabled,
|
|
62
|
+
value: field.value,
|
|
63
|
+
fieldName: field.name,
|
|
64
|
+
onPhoneNumberChange: (isValid, value) => {
|
|
65
|
+
setValue(value);
|
|
66
|
+
|
|
67
|
+
if (value && !isValid) {
|
|
68
|
+
setIntlInputError(errorMessage);
|
|
69
|
+
} else {
|
|
70
|
+
setIntlInputError('');
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
autoComplete: autoComplete
|
|
74
|
+
}), /*#__PURE__*/React.createElement(FormDescription, {
|
|
75
|
+
className: "v50 mt-v s-1",
|
|
76
|
+
description: intlInputError || description,
|
|
77
|
+
name: name
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
PhoneIntlTelInput.propTypes = {
|
|
82
|
+
/**
|
|
83
|
+
* The HTML id for this element
|
|
84
|
+
*/
|
|
85
|
+
id: PropTypes.string,
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The HTML class names for this element
|
|
89
|
+
*/
|
|
90
|
+
className: PropTypes.string,
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The React-written, css properties for this element.
|
|
94
|
+
*/
|
|
95
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The input name (html - and Formik state)
|
|
99
|
+
*/
|
|
100
|
+
name: PropTypes.string.isRequired,
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The input label
|
|
104
|
+
*/
|
|
105
|
+
label: PropTypes.string.isRequired,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The input label color
|
|
109
|
+
*/
|
|
110
|
+
labelColor: PropTypes.string,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* If the slide will only have one input
|
|
114
|
+
*/
|
|
115
|
+
oneInputLabel: PropTypes.bool,
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Input description
|
|
119
|
+
*/
|
|
120
|
+
description: PropTypes.string,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Whether the text input should be disabled
|
|
124
|
+
*/
|
|
125
|
+
disabled: PropTypes.bool,
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The placeholder text for the input
|
|
129
|
+
*/
|
|
130
|
+
placeholder: PropTypes.string,
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The text input color
|
|
134
|
+
*/
|
|
135
|
+
color: PropTypes.string,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Whether the input is optional or not
|
|
139
|
+
*/
|
|
140
|
+
optional: PropTypes.bool,
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* The autoComplete value that the browser should watch for the input
|
|
144
|
+
* `https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete`
|
|
145
|
+
*/
|
|
146
|
+
autoComplete: PropTypes.string,
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The error message to be siplayed when the input is invalid
|
|
150
|
+
*/
|
|
151
|
+
errorMessage: PropTypes.string,
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The input field validator function
|
|
155
|
+
*/
|
|
156
|
+
validate: PropTypes.func
|
|
157
|
+
};
|
|
158
|
+
PhoneIntlTelInput.defaultProps = {
|
|
159
|
+
color: 'background2',
|
|
160
|
+
disabled: false,
|
|
161
|
+
errorMessage: 'Please enter a valid phone number'
|
|
162
|
+
};
|
|
163
|
+
export default PhoneIntlTelInput;
|