@pareto-engineering/design-system 2.0.0-alpha.52 → 2.0.0-alpha.55
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/AppContext/Context.js +16 -0
- package/dist/cjs/a/AppContext/ContextProvider.js +96 -0
- package/dist/cjs/a/AppContext/index.js +39 -0
- package/dist/cjs/a/AppContext/useApp.js +16 -0
- package/dist/cjs/a/AppContext/useTheme.js +45 -0
- package/dist/cjs/a/index.js +8 -8
- package/dist/cjs/b/Page/common/PageHelmet/PageHelmet.js +1 -1
- package/dist/cjs/b/SocialMediaButton/SocialMediaButton.js +4 -4
- package/dist/cjs/b/ThemeSelector/ThemeSelector.js +1 -1
- package/dist/cjs/f/FormInput/FormInput.js +1 -1
- package/dist/cjs/f/common/Description/Description.js +20 -14
- package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +0 -2
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +5 -9
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +5 -9
- package/dist/cjs/f/fields/SelectInput/SelectInput.js +16 -8
- package/dist/cjs/f/fields/TextInput/TextInput.js +18 -9
- package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +16 -8
- package/dist/es/a/AppContext/Context.js +2 -0
- package/dist/es/a/AppContext/ContextProvider.js +78 -0
- package/dist/es/a/AppContext/index.js +5 -0
- package/dist/es/a/AppContext/useApp.js +3 -0
- package/dist/es/a/AppContext/useTheme.js +34 -0
- package/dist/es/a/index.js +1 -1
- package/dist/es/b/Page/common/PageHelmet/PageHelmet.js +2 -2
- package/dist/es/b/SocialMediaButton/SocialMediaButton.js +5 -5
- package/dist/es/b/ThemeSelector/ThemeSelector.js +2 -2
- package/dist/es/f/FormInput/FormInput.js +1 -1
- package/dist/es/f/common/Description/Description.js +19 -14
- package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +0 -2
- package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +5 -9
- package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +5 -9
- package/dist/es/f/fields/SelectInput/SelectInput.js +16 -8
- package/dist/es/f/fields/TextInput/TextInput.js +18 -9
- package/dist/es/f/fields/TextareaInput/TextareaInput.js +16 -8
- package/package.json +1 -1
- package/src/__snapshots__/Storyshots.test.js.snap +1528 -1385
- package/src/stories/a/{SiteContext.stories.jsx → AppContext.stories.jsx} +8 -8
- package/src/stories/a/DotInfo.stories.jsx +12 -12
- package/src/stories/a/ProgressBar.stories.jsx +12 -6
- package/src/stories/a/Timestamp.stories.jsx +32 -38
- package/src/stories/b/Logo.stories.jsx +13 -13
- package/src/stories/b/QuestionDropdown.stories.jsx +17 -30
- package/src/stories/b/SocialMediaButton.stories.jsx +34 -52
- package/src/stories/b/ThemeSelector.stories.jsx +5 -5
- package/src/stories/b/Title.stories.jsx +11 -13
- package/src/stories/c/ContentSlides.stories.jsx +30 -300
- package/src/stories/f/ChoicesInput.stories.jsx +62 -129
- package/src/stories/f/Description.stories.jsx +12 -2
- package/src/stories/f/RatingsInput.stories.jsx +21 -22
- package/src/stories/f/SelectInput.stories.jsx +35 -75
- package/src/stories/f/TextInput.stories.jsx +55 -52
- package/src/stories/f/TextareaInput.stories.jsx +31 -46
- package/src/ui/a/{SiteContext → AppContext}/Context.js +0 -0
- package/src/ui/a/{SiteContext → AppContext}/ContextProvider.jsx +8 -7
- package/src/ui/a/AppContext/index.js +5 -0
- package/src/ui/a/{SiteContext/useSite.js → AppContext/useApp.js} +0 -0
- package/src/ui/a/{SiteContext → AppContext}/useTheme.js +0 -0
- package/src/ui/a/index.js +4 -4
- package/src/ui/b/Page/common/PageHelmet/PageHelmet.jsx +2 -2
- package/src/ui/b/SocialMediaButton/SocialMediaButton.jsx +4 -4
- package/src/ui/b/ThemeSelector/ThemeSelector.jsx +2 -2
- package/src/ui/f/FormInput/FormInput.jsx +1 -0
- package/src/ui/f/common/Description/Description.jsx +34 -29
- package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +1 -2
- package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +1 -11
- package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +1 -11
- package/src/ui/f/fields/SelectInput/SelectInput.jsx +16 -9
- package/src/ui/f/fields/TextInput/TextInput.jsx +13 -7
- package/src/ui/f/fields/TextareaInput/TextareaInput.jsx +9 -8
- package/src/ui/a/SiteContext/index.js +0 -5
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 0.2.3 */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useReducer } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import useTheme from "./useTheme"; // Package-level Imports
|
|
6
|
+
|
|
7
|
+
import Context from "./Context"; // Component-level imports
|
|
8
|
+
// Helper Definitions
|
|
9
|
+
|
|
10
|
+
const reducer = (state, action) => {
|
|
11
|
+
switch (action.type) {
|
|
12
|
+
case 'UPDATE_STATE':
|
|
13
|
+
return { ...state,
|
|
14
|
+
...action.payload
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
default:
|
|
18
|
+
return state;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const AppContextProvider = ({
|
|
23
|
+
children,
|
|
24
|
+
initialTheme,
|
|
25
|
+
config,
|
|
26
|
+
initialState // ...otherProps
|
|
27
|
+
|
|
28
|
+
}) => {
|
|
29
|
+
const theme = useTheme(initialTheme);
|
|
30
|
+
const [state, dispatch] = useReducer(reducer, initialState);
|
|
31
|
+
return /*#__PURE__*/React.createElement(Context.Provider, {
|
|
32
|
+
value: {
|
|
33
|
+
state,
|
|
34
|
+
dispatch,
|
|
35
|
+
...config,
|
|
36
|
+
...theme
|
|
37
|
+
}
|
|
38
|
+
}, children);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
AppContextProvider.propTypes = {
|
|
42
|
+
/**
|
|
43
|
+
* The children JSX
|
|
44
|
+
*/
|
|
45
|
+
children: PropTypes.node,
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The initial theme for the website. If undefined, fallbacks on system preference.
|
|
49
|
+
*/
|
|
50
|
+
initialTheme: PropTypes.string,
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A dictionnary containing settings and preferences to be used application-wide
|
|
54
|
+
*/
|
|
55
|
+
config: PropTypes.shape({
|
|
56
|
+
APP: PropTypes.shape({
|
|
57
|
+
NAME: PropTypes.string.isRequired,
|
|
58
|
+
CANONICAL: PropTypes.string.isRequired,
|
|
59
|
+
SUPPORT_EMAIL: PropTypes.string,
|
|
60
|
+
TITLE_SUFFIX: PropTypes.string
|
|
61
|
+
}),
|
|
62
|
+
SOCIAL: PropTypes.shape({
|
|
63
|
+
FACEBOOK: PropTypes.string,
|
|
64
|
+
INSTAGRAM: PropTypes.string,
|
|
65
|
+
YOUTUBE: PropTypes.string
|
|
66
|
+
}),
|
|
67
|
+
CONSTANTS: PropTypes.shape({})
|
|
68
|
+
}).isRequired,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Application context initial state
|
|
72
|
+
*/
|
|
73
|
+
initialState: PropTypes.objectOf(PropTypes.string)
|
|
74
|
+
};
|
|
75
|
+
AppContextProvider.defaultProps = {
|
|
76
|
+
initialState: {}
|
|
77
|
+
};
|
|
78
|
+
export default AppContextProvider;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useCallback, useState, useEffect } from 'react';
|
|
2
|
+
export default ((initialTheme, storageKey = 'theme') => {
|
|
3
|
+
const isClient = typeof window === 'object';
|
|
4
|
+
const [preferredTheme, setPreferredTheme] = useState(initialTheme);
|
|
5
|
+
const [userTheme, setUserTheme] = useState();
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const storage = window.localStorage;
|
|
8
|
+
|
|
9
|
+
if (isClient) {
|
|
10
|
+
const storedTheme = window.localStorage.getItem(storageKey); // console.log(storedTheme, storedTheme != userTheme)
|
|
11
|
+
|
|
12
|
+
if (storedTheme && storedTheme !== userTheme) {
|
|
13
|
+
// console.warn('Theme load')
|
|
14
|
+
setPreferredTheme(storedTheme);
|
|
15
|
+
setUserTheme(storedTheme);
|
|
16
|
+
} else if (preferredTheme && preferredTheme.length && preferredTheme !== 'system') {
|
|
17
|
+
setUserTheme(preferredTheme);
|
|
18
|
+
storage.setItem(storageKey, preferredTheme); // console.warn('theme change', preferredTheme)
|
|
19
|
+
} else {
|
|
20
|
+
setUserTheme(window.matchMedia('(prefers-color-scheme:dark)').matches ? 'dark' : 'light');
|
|
21
|
+
storage.removeItem(storageKey); // console.warn('theme reset')
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
setUserTheme('light');
|
|
25
|
+
}
|
|
26
|
+
}, [preferredTheme, isClient]);
|
|
27
|
+
const isTheme = useCallback(theme => userTheme === theme || undefined, [userTheme]);
|
|
28
|
+
return {
|
|
29
|
+
userTheme,
|
|
30
|
+
preferredTheme,
|
|
31
|
+
setPreferredTheme,
|
|
32
|
+
isTheme
|
|
33
|
+
};
|
|
34
|
+
});
|
package/dist/es/a/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { SVG } from "./SVG";
|
|
2
2
|
export { DashboardNavbar } from "./DashboardNavbar";
|
|
3
3
|
export { IconList } from "./IconList";
|
|
4
|
-
export {
|
|
4
|
+
export { AppContext, AppContextProvider, useApp, useTheme } from "./AppContext";
|
|
5
5
|
export { ProgressBar } from "./ProgressBar";
|
|
6
6
|
export { TeamInfo } from "./TeamInfo";
|
|
7
7
|
export { AnimatedCounter } from "./AnimatedCounter";
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { Helmet } from 'react-helmet';
|
|
6
|
-
import {
|
|
6
|
+
import { useApp } from "../../../../a";
|
|
7
7
|
const helmetMap = [{
|
|
8
8
|
variables: ['robots'],
|
|
9
9
|
render: v => /*#__PURE__*/React.createElement("meta", {
|
|
@@ -117,7 +117,7 @@ const helmetMap = [{
|
|
|
117
117
|
const PageHelmet = ({ ...props
|
|
118
118
|
}) => {
|
|
119
119
|
// const intl = useIntl()
|
|
120
|
-
const context =
|
|
120
|
+
const context = useApp();
|
|
121
121
|
const HelmetContent = useMemo(() => helmetMap.reduce(
|
|
122
122
|
/* eslint-disable no-unused-vars -- TODO add test or ssr mode */
|
|
123
123
|
(a, {
|
|
@@ -5,7 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import { useLayoutEffect } from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import styleNames from '@pareto-engineering/bem';
|
|
8
|
-
import {
|
|
8
|
+
import { useApp } from "../../a"; // Local Definitions
|
|
9
9
|
|
|
10
10
|
const baseClassName = styleNames.base;
|
|
11
11
|
const componentClassName = 'social-media-button';
|
|
@@ -30,7 +30,7 @@ const defaultsMap = {
|
|
|
30
30
|
/**
|
|
31
31
|
* This is the component description.
|
|
32
32
|
* This component takes `y` as the default color and `x` as the hover color.
|
|
33
|
-
* This components needs to be wrapped within a `
|
|
33
|
+
* This components needs to be wrapped within a `AppContextProvider`.
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
const SocialMediaButton = ({
|
|
@@ -44,14 +44,14 @@ const SocialMediaButton = ({
|
|
|
44
44
|
isTransparent,
|
|
45
45
|
...otherProps
|
|
46
46
|
}) => {
|
|
47
|
-
var
|
|
47
|
+
var _applicationContext$S;
|
|
48
48
|
|
|
49
|
-
const
|
|
49
|
+
const applicationContext = useApp();
|
|
50
50
|
useLayoutEffect(() => {
|
|
51
51
|
import("./styles.scss");
|
|
52
52
|
}, []);
|
|
53
53
|
const content = type && defaultsMap[type];
|
|
54
|
-
const href = link || (
|
|
54
|
+
const href = link || (applicationContext === null || applicationContext === void 0 ? void 0 : (_applicationContext$S = applicationContext.SOCIAL) === null || _applicationContext$S === void 0 ? void 0 : _applicationContext$S[content.link]);
|
|
55
55
|
return /*#__PURE__*/React.createElement("a", {
|
|
56
56
|
href: href,
|
|
57
57
|
target: "_blank",
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useLayoutEffect, useCallback } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import styleNames from '@pareto-engineering/bem';
|
|
6
|
-
import {
|
|
6
|
+
import { useApp } from "../../a"; // Local Definitions
|
|
7
7
|
|
|
8
8
|
const baseClassName = styleNames.base;
|
|
9
9
|
const componentClassName = 'theme-selector';
|
|
@@ -22,7 +22,7 @@ const ThemeSelector = ({
|
|
|
22
22
|
const {
|
|
23
23
|
userTheme,
|
|
24
24
|
setPreferredTheme
|
|
25
|
-
} =
|
|
25
|
+
} = useApp();
|
|
26
26
|
useLayoutEffect(() => {
|
|
27
27
|
import("./styles.scss");
|
|
28
28
|
}, []);
|
|
@@ -83,7 +83,7 @@ FormInput.propTypes = {
|
|
|
83
83
|
/**
|
|
84
84
|
* The HTML class names for this element
|
|
85
85
|
*/
|
|
86
|
-
type: PropTypes.oneOf(['text', 'email', 'password', 'number', 'date', 'datetime', 'month', 'tel', 'hidden', 'select', 'choices', 'textarea', 'query-combobox', // to be removed
|
|
86
|
+
type: PropTypes.oneOf(['text', 'email', 'password', 'number', 'date', 'datetime', 'month', 'tel', 'hidden', 'select', 'choices', 'textarea', 'query-combobox', 'url', // to be removed
|
|
87
87
|
'extendedTypeInput']),
|
|
88
88
|
|
|
89
89
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useLayoutEffect } from 'react';
|
|
4
|
+
import { useField } from 'formik';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import styleNames from '@pareto-engineering/bem'; // Local Definitions
|
|
6
7
|
|
|
@@ -14,20 +15,25 @@ const Description = ({
|
|
|
14
15
|
id,
|
|
15
16
|
className: userClassName,
|
|
16
17
|
style,
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
description,
|
|
19
|
+
name,
|
|
19
20
|
color // ...otherProps
|
|
20
21
|
|
|
21
22
|
}) => {
|
|
22
23
|
useLayoutEffect(() => {
|
|
23
24
|
import("./styles.scss");
|
|
24
25
|
}, []);
|
|
25
|
-
|
|
26
|
-
id: id,
|
|
27
|
-
className: [baseClassName, componentClassName, userClassName, isError ? 'x-error' : `x-${color}`].filter(e => e).join(' '),
|
|
28
|
-
style: style // {...otherProps}
|
|
26
|
+
const [field, meta] = useField(name);
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
if (description || (meta.touched || field.value) && meta.error) {
|
|
29
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
id: id,
|
|
31
|
+
className: [baseClassName, componentClassName, userClassName, meta.error ? 'x-error' : `x-${color}`].filter(e => e).join(' '),
|
|
32
|
+
style: style
|
|
33
|
+
}, meta.error || description);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return null;
|
|
31
37
|
};
|
|
32
38
|
|
|
33
39
|
Description.propTypes = {
|
|
@@ -47,22 +53,21 @@ Description.propTypes = {
|
|
|
47
53
|
style: PropTypes.objectOf(PropTypes.string),
|
|
48
54
|
|
|
49
55
|
/**
|
|
50
|
-
*
|
|
56
|
+
* The base color for the description
|
|
51
57
|
*/
|
|
52
|
-
|
|
58
|
+
color: PropTypes.string,
|
|
53
59
|
|
|
54
60
|
/**
|
|
55
|
-
*
|
|
61
|
+
* Input description - extra description to guide a use in filling the input
|
|
56
62
|
*/
|
|
57
|
-
|
|
63
|
+
description: PropTypes.string,
|
|
58
64
|
|
|
59
65
|
/**
|
|
60
|
-
*
|
|
66
|
+
* The input name (html - and Formik state)
|
|
61
67
|
*/
|
|
62
|
-
|
|
68
|
+
name: PropTypes.string.isRequired
|
|
63
69
|
};
|
|
64
70
|
Description.defaultProps = {
|
|
65
|
-
isError: false,
|
|
66
71
|
color: 'metadata'
|
|
67
72
|
};
|
|
68
73
|
export default Description;
|
|
@@ -38,7 +38,6 @@ const QueryCombobox = ({
|
|
|
38
38
|
setError
|
|
39
39
|
} = helpers;
|
|
40
40
|
const {
|
|
41
|
-
error,
|
|
42
41
|
value
|
|
43
42
|
} = meta;
|
|
44
43
|
const environment = useRelayEnvironment();
|
|
@@ -94,7 +93,6 @@ const QueryCombobox = ({
|
|
|
94
93
|
label,
|
|
95
94
|
description,
|
|
96
95
|
setValue,
|
|
97
|
-
error,
|
|
98
96
|
value,
|
|
99
97
|
color,
|
|
100
98
|
isFetching,
|
|
@@ -25,7 +25,6 @@ const Combobox = ({
|
|
|
25
25
|
options: items,
|
|
26
26
|
getOptions,
|
|
27
27
|
setValue,
|
|
28
|
-
error,
|
|
29
28
|
description,
|
|
30
29
|
value,
|
|
31
30
|
color,
|
|
@@ -93,9 +92,11 @@ const Combobox = ({
|
|
|
93
92
|
getItemProps: getItemProps,
|
|
94
93
|
highlightedIndex: highlightedIndex,
|
|
95
94
|
items: items
|
|
96
|
-
}, getMenuProps()))),
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
}, getMenuProps()))), /*#__PURE__*/React.createElement(FormDescription, {
|
|
96
|
+
className: "v50 mt-v s-1",
|
|
97
|
+
description: description,
|
|
98
|
+
name: name
|
|
99
|
+
}));
|
|
99
100
|
};
|
|
100
101
|
|
|
101
102
|
Combobox.propTypes = {
|
|
@@ -147,11 +148,6 @@ Combobox.propTypes = {
|
|
|
147
148
|
*/
|
|
148
149
|
description: PropTypes.string,
|
|
149
150
|
|
|
150
|
-
/**
|
|
151
|
-
* The error object
|
|
152
|
-
*/
|
|
153
|
-
error: PropTypes.objectOf(PropTypes.string),
|
|
154
|
-
|
|
155
151
|
/**
|
|
156
152
|
* The value of the custom select input
|
|
157
153
|
*/
|
|
@@ -35,7 +35,6 @@ const MultipleCombobox = ({
|
|
|
35
35
|
options: items,
|
|
36
36
|
getOptions,
|
|
37
37
|
setValue,
|
|
38
|
-
error,
|
|
39
38
|
description,
|
|
40
39
|
value,
|
|
41
40
|
color,
|
|
@@ -184,9 +183,11 @@ const MultipleCombobox = ({
|
|
|
184
183
|
getItemProps: getItemProps,
|
|
185
184
|
highlightedIndex: highlightedIndex,
|
|
186
185
|
items: getFilteredItems()
|
|
187
|
-
}, getMenuProps()))),
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
}, getMenuProps()))), /*#__PURE__*/React.createElement(FormDescription, {
|
|
187
|
+
className: "v50 mt-v s-1",
|
|
188
|
+
description: description,
|
|
189
|
+
name: name
|
|
190
|
+
}));
|
|
190
191
|
};
|
|
191
192
|
|
|
192
193
|
MultipleCombobox.propTypes = {
|
|
@@ -238,11 +239,6 @@ MultipleCombobox.propTypes = {
|
|
|
238
239
|
*/
|
|
239
240
|
description: PropTypes.string,
|
|
240
241
|
|
|
241
|
-
/**
|
|
242
|
-
* The error object
|
|
243
|
-
*/
|
|
244
|
-
error: PropTypes.objectOf(PropTypes.string),
|
|
245
|
-
|
|
246
242
|
/**
|
|
247
243
|
* The value of the custom select input
|
|
248
244
|
*/
|
|
@@ -26,13 +26,14 @@ const SelectInput = ({
|
|
|
26
26
|
validate,
|
|
27
27
|
description,
|
|
28
28
|
disabled,
|
|
29
|
-
isLoading
|
|
29
|
+
isLoading,
|
|
30
|
+
autoComplete // ...otherProps
|
|
30
31
|
|
|
31
32
|
}) => {
|
|
32
33
|
useLayoutEffect(() => {
|
|
33
34
|
import("./styles.scss");
|
|
34
35
|
}, []);
|
|
35
|
-
const [field
|
|
36
|
+
const [field] = useField({
|
|
36
37
|
name,
|
|
37
38
|
validate
|
|
38
39
|
});
|
|
@@ -50,7 +51,8 @@ const SelectInput = ({
|
|
|
50
51
|
}, field, {
|
|
51
52
|
value: field.value || '',
|
|
52
53
|
id: name,
|
|
53
|
-
disabled: disabled
|
|
54
|
+
disabled: disabled,
|
|
55
|
+
autoComplete: autoComplete
|
|
54
56
|
}), options.map(option => {
|
|
55
57
|
// i.e if option is a string like "blah", return { value: "blah", label: "blah" }
|
|
56
58
|
const newOption = typeof option === 'string' ? {
|
|
@@ -64,10 +66,11 @@ const SelectInput = ({
|
|
|
64
66
|
}, newOption.label);
|
|
65
67
|
})), isLoading && /*#__PURE__*/React.createElement(LoadingCircle, {
|
|
66
68
|
className: "x-main2"
|
|
67
|
-
})),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
})), /*#__PURE__*/React.createElement(FormDescription, {
|
|
70
|
+
className: "v50 mt-v s-1",
|
|
71
|
+
description: description,
|
|
72
|
+
name: name
|
|
73
|
+
}));
|
|
71
74
|
};
|
|
72
75
|
|
|
73
76
|
SelectInput.propTypes = {
|
|
@@ -128,7 +131,12 @@ SelectInput.propTypes = {
|
|
|
128
131
|
/*
|
|
129
132
|
* Whether the query that is fetching the select options is still in flight
|
|
130
133
|
*/
|
|
131
|
-
isLoading: PropTypes.bool
|
|
134
|
+
isLoading: PropTypes.bool,
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The autoComplete value that the browser should watch for the input
|
|
138
|
+
*/
|
|
139
|
+
autoComplete: PropTypes.string
|
|
132
140
|
};
|
|
133
141
|
SelectInput.defaultProps = {
|
|
134
142
|
disabled: false,
|
|
@@ -28,13 +28,14 @@ const TextInput = ({
|
|
|
28
28
|
description,
|
|
29
29
|
disabled,
|
|
30
30
|
placeholder,
|
|
31
|
-
optional
|
|
31
|
+
optional,
|
|
32
|
+
autoComplete // ...otherProps
|
|
32
33
|
|
|
33
34
|
}) => {
|
|
34
35
|
useLayoutEffect(() => {
|
|
35
36
|
import("./styles.scss");
|
|
36
37
|
}, []);
|
|
37
|
-
const [field
|
|
38
|
+
const [field] = useField({
|
|
38
39
|
name,
|
|
39
40
|
validate
|
|
40
41
|
});
|
|
@@ -53,11 +54,13 @@ const TextInput = ({
|
|
|
53
54
|
className: "input",
|
|
54
55
|
type: type,
|
|
55
56
|
disabled: disabled,
|
|
56
|
-
placeholder: placeholder
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
className: "v50 mt-v s-1"
|
|
60
|
-
|
|
57
|
+
placeholder: placeholder,
|
|
58
|
+
autoComplete: autoComplete
|
|
59
|
+
}, field)), /*#__PURE__*/React.createElement(FormDescription, {
|
|
60
|
+
className: "v50 mt-v s-1",
|
|
61
|
+
description: description,
|
|
62
|
+
name: name
|
|
63
|
+
}));
|
|
61
64
|
};
|
|
62
65
|
|
|
63
66
|
TextInput.propTypes = {
|
|
@@ -94,7 +97,7 @@ TextInput.propTypes = {
|
|
|
94
97
|
/**
|
|
95
98
|
* The type of the input (html)
|
|
96
99
|
*/
|
|
97
|
-
type: PropTypes.oneOf(['text', 'email', 'password', 'number', 'date', 'time', 'datetime', 'month', 'tel', 'hidden']),
|
|
100
|
+
type: PropTypes.oneOf(['text', 'email', 'password', 'number', 'date', 'time', 'datetime', 'month', 'tel', 'hidden', 'url']),
|
|
98
101
|
|
|
99
102
|
/**
|
|
100
103
|
* The input field validator function
|
|
@@ -129,7 +132,13 @@ TextInput.propTypes = {
|
|
|
129
132
|
/**
|
|
130
133
|
* Whether the input is optional or not
|
|
131
134
|
*/
|
|
132
|
-
optional: PropTypes.bool
|
|
135
|
+
optional: PropTypes.bool,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The autoComplete value that the browser should watch for the input
|
|
139
|
+
* `https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete`
|
|
140
|
+
*/
|
|
141
|
+
autoComplete: PropTypes.string
|
|
133
142
|
};
|
|
134
143
|
TextInput.defaultProps = {
|
|
135
144
|
type: 'text',
|
|
@@ -28,13 +28,14 @@ const TextareaInput = ({
|
|
|
28
28
|
labelColor,
|
|
29
29
|
description,
|
|
30
30
|
disabled,
|
|
31
|
-
placeholder
|
|
31
|
+
placeholder,
|
|
32
|
+
autoComplete // ...otherProps
|
|
32
33
|
|
|
33
34
|
}) => {
|
|
34
35
|
useLayoutEffect(() => {
|
|
35
36
|
import("./styles.scss");
|
|
36
37
|
}, []);
|
|
37
|
-
const [field
|
|
38
|
+
const [field] = useField({
|
|
38
39
|
name,
|
|
39
40
|
validate
|
|
40
41
|
});
|
|
@@ -53,11 +54,13 @@ const TextareaInput = ({
|
|
|
53
54
|
}, field, {
|
|
54
55
|
placeholder: placeholder,
|
|
55
56
|
rows: rows,
|
|
56
|
-
disabled: disabled
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
className: "v50 mt-v s-1"
|
|
60
|
-
|
|
57
|
+
disabled: disabled,
|
|
58
|
+
autoComplete: autoComplete
|
|
59
|
+
})), /*#__PURE__*/React.createElement(FormDescription, {
|
|
60
|
+
className: "v50 mt-v s-1",
|
|
61
|
+
description: description,
|
|
62
|
+
name: name
|
|
63
|
+
}));
|
|
61
64
|
};
|
|
62
65
|
|
|
63
66
|
TextareaInput.propTypes = {
|
|
@@ -129,7 +132,12 @@ TextareaInput.propTypes = {
|
|
|
129
132
|
/**
|
|
130
133
|
* The textarea placeholder text
|
|
131
134
|
*/
|
|
132
|
-
placeholder: PropTypes.string
|
|
135
|
+
placeholder: PropTypes.string,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The autoComplete value that the browser should watch for the input
|
|
139
|
+
*/
|
|
140
|
+
autoComplete: PropTypes.string
|
|
133
141
|
};
|
|
134
142
|
TextareaInput.defaultProps = {
|
|
135
143
|
rows: 3,
|