@pareto-engineering/design-system 4.0.0-alpha.72 → 4.0.0-alpha.74
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/f/fields/SelectInput/SelectInput.js +33 -42
- package/dist/cjs/f/fields/SelectInput/common/Menu/Menu.js +83 -0
- package/dist/cjs/f/fields/SelectInput/common/Menu/index.js +13 -0
- package/dist/cjs/f/fields/SelectInput/common/Multiple/Multiple.js +244 -0
- package/dist/cjs/f/fields/SelectInput/common/Multiple/index.js +13 -0
- package/dist/cjs/f/fields/SelectInput/common/Single/Single.js +104 -0
- package/dist/cjs/f/fields/SelectInput/common/Single/index.js +13 -0
- package/dist/cjs/f/fields/SelectInput/common/index.js +26 -0
- package/dist/cjs/f/fields/SelectInput/styles.scss +149 -45
- package/dist/es/f/fields/SelectInput/SelectInput.js +31 -42
- package/dist/es/f/fields/SelectInput/common/Menu/Menu.js +73 -0
- package/dist/es/f/fields/SelectInput/common/Menu/index.js +2 -0
- package/dist/es/f/fields/SelectInput/common/Multiple/Multiple.js +235 -0
- package/dist/es/f/fields/SelectInput/common/Multiple/index.js +2 -0
- package/dist/es/f/fields/SelectInput/common/Single/Single.js +96 -0
- package/dist/es/f/fields/SelectInput/common/Single/index.js +2 -0
- package/dist/es/f/fields/SelectInput/common/index.js +3 -0
- package/dist/es/f/fields/SelectInput/styles.scss +149 -45
- package/package.json +5 -5
- package/src/stories/f/SelectInput.stories.jsx +15 -0
- package/src/ui/f/fields/SelectInput/SelectInput.jsx +34 -47
- package/src/ui/f/fields/SelectInput/common/Menu/Menu.jsx +103 -0
- package/src/ui/f/fields/SelectInput/common/Menu/index.js +2 -0
- package/src/ui/f/fields/SelectInput/common/Multiple/Multiple.jsx +288 -0
- package/src/ui/f/fields/SelectInput/common/Multiple/index.js +2 -0
- package/src/ui/f/fields/SelectInput/common/Single/Single.jsx +125 -0
- package/src/ui/f/fields/SelectInput/common/Single/index.js +2 -0
- package/src/ui/f/fields/SelectInput/common/index.js +3 -0
- package/src/ui/f/fields/SelectInput/styles.scss +149 -45
- package/tests/__snapshots__/Storyshots.test.js.snap +523 -393
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useField } from 'formik';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
7
|
+
import { LoadingCircle } from "../../../../../a";
|
|
8
|
+
import { FormLabel, FormDescription } from "../../../../../../../dist/cjs";
|
|
9
|
+
|
|
10
|
+
// Local Definitions
|
|
11
|
+
|
|
12
|
+
const baseClassName = styleNames.base;
|
|
13
|
+
const componentClassName = 'single';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This is the component description.
|
|
17
|
+
*/
|
|
18
|
+
const Single = ({
|
|
19
|
+
id,
|
|
20
|
+
className: userClassName,
|
|
21
|
+
style,
|
|
22
|
+
name,
|
|
23
|
+
label,
|
|
24
|
+
labelColor,
|
|
25
|
+
color,
|
|
26
|
+
options,
|
|
27
|
+
validate,
|
|
28
|
+
optional,
|
|
29
|
+
description,
|
|
30
|
+
disabled,
|
|
31
|
+
isLoading,
|
|
32
|
+
autoComplete
|
|
33
|
+
// ...otherProps
|
|
34
|
+
}) => {
|
|
35
|
+
const [field] = useField({
|
|
36
|
+
name,
|
|
37
|
+
validate
|
|
38
|
+
});
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
id: id,
|
|
41
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
42
|
+
style: style
|
|
43
|
+
}, /*#__PURE__*/React.createElement(FormLabel, {
|
|
44
|
+
name: name,
|
|
45
|
+
color: labelColor,
|
|
46
|
+
optional: optional
|
|
47
|
+
}, label), /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: `select-wrapper${disabled ? ' disabled' : ''}`
|
|
49
|
+
}, /*#__PURE__*/React.createElement("select", _extends({
|
|
50
|
+
className: `input y-${color}`
|
|
51
|
+
}, field, {
|
|
52
|
+
value: field.value || '',
|
|
53
|
+
id: name,
|
|
54
|
+
disabled: disabled,
|
|
55
|
+
autoComplete: autoComplete
|
|
56
|
+
}), options.map(option => {
|
|
57
|
+
// i.e if option is a string like "blah", return { value: "blah", label: "blah" }
|
|
58
|
+
const newOption = typeof option === 'string' ? {
|
|
59
|
+
value: option,
|
|
60
|
+
label: option
|
|
61
|
+
} : option;
|
|
62
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
63
|
+
key: newOption.value,
|
|
64
|
+
value: newOption.value,
|
|
65
|
+
disabled: newOption?.disabled || false
|
|
66
|
+
}, newOption.label);
|
|
67
|
+
})), isLoading && /*#__PURE__*/React.createElement(LoadingCircle, {
|
|
68
|
+
className: "x-main"
|
|
69
|
+
})), /*#__PURE__*/React.createElement(FormDescription, {
|
|
70
|
+
className: "s-1",
|
|
71
|
+
description: description,
|
|
72
|
+
name: name
|
|
73
|
+
}));
|
|
74
|
+
};
|
|
75
|
+
Single.propTypes = {
|
|
76
|
+
/**
|
|
77
|
+
* The HTML id for this element
|
|
78
|
+
*/
|
|
79
|
+
id: PropTypes.string,
|
|
80
|
+
/**
|
|
81
|
+
* The HTML class names for this element
|
|
82
|
+
*/
|
|
83
|
+
className: PropTypes.string,
|
|
84
|
+
/**
|
|
85
|
+
* The React-written, css properties for this element.
|
|
86
|
+
*/
|
|
87
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
88
|
+
/**
|
|
89
|
+
* The base color of the component
|
|
90
|
+
*/
|
|
91
|
+
color: PropTypes.string
|
|
92
|
+
};
|
|
93
|
+
Single.defaultProps = {
|
|
94
|
+
color: 'paragraph'
|
|
95
|
+
};
|
|
96
|
+
export default Single;
|
|
@@ -14,72 +14,176 @@ $hover-border: var(--theme-hover-input-border);
|
|
|
14
14
|
$focus-border: var(--theme-focus-input-border);
|
|
15
15
|
$default-background: var(--background-inputs);
|
|
16
16
|
$disabled-background: var(--background-inputs-30);
|
|
17
|
+
$default-gap: var(--gap);
|
|
17
18
|
|
|
18
|
-
.#{bem.$base}.select-input {
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
|
|
22
|
-
> .#{bem.$base}.form-label {
|
|
23
|
-
margin-bottom: var(--gap);
|
|
24
|
-
}
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
border: $default-border;
|
|
29
|
-
border-radius: $default-input-border-radius;
|
|
20
|
+
.#{bem.$base}.select-input {
|
|
21
|
+
> .#{bem.$base}.single {
|
|
30
22
|
display: flex;
|
|
31
23
|
flex-direction: column;
|
|
32
|
-
padding: $default-padding;
|
|
33
|
-
padding-right: 0;
|
|
34
|
-
position: relative;
|
|
35
24
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
> .#{bem.$base}.form-label {
|
|
26
|
+
margin-bottom: var(--gap);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.select-wrapper {
|
|
30
|
+
background-color: $default-background;
|
|
31
|
+
border: $default-border;
|
|
32
|
+
border-radius: $default-input-border-radius;
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
padding: $default-padding;
|
|
36
|
+
padding-right: 0;
|
|
37
|
+
position: relative;
|
|
38
|
+
|
|
39
|
+
&:not(.disabled) {
|
|
40
|
+
&:hover,
|
|
41
|
+
&:active {
|
|
42
|
+
border: $hover-border;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:focus {
|
|
46
|
+
border: $focus-border;
|
|
47
|
+
}
|
|
40
48
|
}
|
|
41
49
|
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
&.disabled {
|
|
51
|
+
background: $disabled-background;
|
|
44
52
|
}
|
|
45
|
-
}
|
|
46
53
|
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
&::placeholder {
|
|
55
|
+
color: var(--metadata);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&::after {
|
|
59
|
+
border-radius: $default-input-border-radius;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
>.#{bem.$base}.loading-circle {
|
|
63
|
+
position: absolute;
|
|
64
|
+
right: $default-spacing-size;
|
|
65
|
+
top: 50%;
|
|
66
|
+
transform: translateY(-50%);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
select {
|
|
70
|
+
appearance: none;
|
|
71
|
+
background-color: $default-background;
|
|
72
|
+
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAyMCAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE5IDEuNUwxMCAxMC41TDEgMS41IiBzdHJva2U9IiM0QzRENTMiIHN0cm9rZS13aWR0aD0iMiIvPgo8L3N2Zz4=");
|
|
73
|
+
background-position: calc(100% - $default-spacing-size);
|
|
74
|
+
background-repeat: no-repeat;
|
|
75
|
+
background-size: $default-spacing-size;
|
|
76
|
+
padding-right: $default-spacing-size;
|
|
77
|
+
|
|
78
|
+
&.input {
|
|
79
|
+
border: none;
|
|
80
|
+
color: var(--y);
|
|
81
|
+
outline: none;
|
|
82
|
+
width: 100%;
|
|
83
|
+
|
|
84
|
+
/* stylelint-disable-next-line max-nesting-depth -- required */
|
|
85
|
+
&:disabled {
|
|
86
|
+
opacity: 0%;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
49
90
|
}
|
|
91
|
+
}
|
|
50
92
|
|
|
51
|
-
|
|
52
|
-
|
|
93
|
+
> .#{bem.$base}.multiple {
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
outline: none;
|
|
97
|
+
position: relative;
|
|
98
|
+
|
|
99
|
+
> .#{bem.$base}.form-label {
|
|
100
|
+
margin-bottom: var(--gap);
|
|
53
101
|
}
|
|
54
102
|
|
|
55
|
-
|
|
103
|
+
|
|
104
|
+
.#{bem.$base}.popover {
|
|
105
|
+
border: $default-border;
|
|
56
106
|
border-radius: $default-input-border-radius;
|
|
57
|
-
|
|
107
|
+
width: 100%;
|
|
108
|
+
|
|
109
|
+
>.menu {
|
|
110
|
+
list-style: none;
|
|
111
|
+
margin: 0;
|
|
112
|
+
outline: 0;
|
|
113
|
+
padding: 0;
|
|
114
|
+
|
|
115
|
+
/* stylelint-disable selector-max-compound-selectors -- required */
|
|
116
|
+
>.item {
|
|
117
|
+
border-radius: $default-input-border-radius;
|
|
118
|
+
padding: $default-padding;
|
|
119
|
+
|
|
120
|
+
/* stylelint-disable max-nesting-depth -- required */
|
|
121
|
+
> p {
|
|
122
|
+
margin: 0;
|
|
123
|
+
}
|
|
58
124
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
125
|
+
&.#{bem.$modifier-active} {
|
|
126
|
+
background-color: var(--y);
|
|
127
|
+
|
|
128
|
+
> p {
|
|
129
|
+
color: var(--on-y);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
64
134
|
}
|
|
65
135
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
&.input {
|
|
76
|
-
border: none;
|
|
77
|
-
color: var(--y);
|
|
136
|
+
|
|
137
|
+
> .input-container {
|
|
138
|
+
position: relative;
|
|
139
|
+
|
|
140
|
+
> .input {
|
|
141
|
+
background: $default-background;
|
|
142
|
+
border: $default-border;
|
|
143
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
144
|
+
color: var(--paragraph);
|
|
78
145
|
outline: none;
|
|
146
|
+
padding: $default-padding;
|
|
79
147
|
width: 100%;
|
|
80
148
|
|
|
149
|
+
&::placeholder {
|
|
150
|
+
color: var(--metadata);
|
|
151
|
+
}
|
|
152
|
+
|
|
81
153
|
&:disabled {
|
|
82
|
-
|
|
154
|
+
background-color: $disabled-background;
|
|
155
|
+
color: var(--paragraph);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&:not(:disabled) {
|
|
159
|
+
&:hover,
|
|
160
|
+
&:active {
|
|
161
|
+
border: $hover-border;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&:focus {
|
|
165
|
+
border: $focus-border;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
>.selected-items {
|
|
173
|
+
display: flex;
|
|
174
|
+
flex-wrap: wrap;
|
|
175
|
+
gap: calc($default-gap / 2);
|
|
176
|
+
margin-bottom: calc($default-gap / 2);
|
|
177
|
+
|
|
178
|
+
>.item {
|
|
179
|
+
>.#{bem.$base}.button {
|
|
180
|
+
align-items: center;
|
|
181
|
+
display: flex;
|
|
182
|
+
gap: calc($default-gap / 2);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.close {
|
|
186
|
+
font-size: calc(var(--s-3) * 1em);
|
|
83
187
|
}
|
|
84
188
|
}
|
|
85
189
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pareto-engineering/design-system",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.74",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/es/index.js",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@codemirror/lang-xml": "^6.0.2",
|
|
54
54
|
"@lexical/react": "^0.11.3",
|
|
55
|
-
"@pareto-engineering/assets": "^4.0.0-alpha.
|
|
55
|
+
"@pareto-engineering/assets": "^4.0.0-alpha.73",
|
|
56
56
|
"@pareto-engineering/bem": "^4.0.0-alpha.20",
|
|
57
|
-
"@pareto-engineering/styles": "^4.0.0-alpha.
|
|
58
|
-
"@pareto-engineering/utils": "^4.0.0-alpha.
|
|
57
|
+
"@pareto-engineering/styles": "^4.0.0-alpha.73",
|
|
58
|
+
"@pareto-engineering/utils": "^4.0.0-alpha.73",
|
|
59
59
|
"codemirror": "^6.0.1",
|
|
60
60
|
"date-fns": "^2.29.3",
|
|
61
61
|
"downshift": "^6.1.12",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"relay-test-utils": "^15.0.0"
|
|
74
74
|
},
|
|
75
75
|
"browserslist": "> 2%",
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "81827866347e056b8fb3ba1cb7c6e6f22c5eddbb"
|
|
77
77
|
}
|
|
@@ -93,3 +93,18 @@ DisabledWithDescriptionSelectInput.args = {
|
|
|
93
93
|
disabled :true,
|
|
94
94
|
description:'This is a description',
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
export const Multiple = Template.bind({})
|
|
98
|
+
Multiple.args = {
|
|
99
|
+
name :'status',
|
|
100
|
+
label :'Status',
|
|
101
|
+
getTagColor:(tag) => tag.color,
|
|
102
|
+
options :[
|
|
103
|
+
{ value: 'Approved', label: 'Approved', color: 'green' },
|
|
104
|
+
{ value: 'To be reviewed', label: 'To be reviewed', color: 'purple' },
|
|
105
|
+
{ value: 'Revised', label: 'Revised', color: 'blue' },
|
|
106
|
+
{ value: 'Rejected', label: 'Rejected', color: 'red' },
|
|
107
|
+
],
|
|
108
|
+
placeholder:'Type to search',
|
|
109
|
+
multiple :true,
|
|
110
|
+
}
|
|
@@ -3,18 +3,14 @@ import * as React from 'react'
|
|
|
3
3
|
|
|
4
4
|
import { memo } from 'react'
|
|
5
5
|
|
|
6
|
-
import { useField } from 'formik'
|
|
7
|
-
|
|
8
6
|
import PropTypes from 'prop-types'
|
|
9
7
|
|
|
10
8
|
import styleNames from '@pareto-engineering/bem/exports'
|
|
11
9
|
|
|
12
|
-
import { LoadingCircle } from 'ui/a'
|
|
13
|
-
|
|
14
|
-
import { FormLabel, FormDescription } from '../../common'
|
|
15
|
-
|
|
16
10
|
import './styles.scss'
|
|
17
11
|
|
|
12
|
+
import { Single, Multiple } from './common'
|
|
13
|
+
|
|
18
14
|
// Local Definitions
|
|
19
15
|
|
|
20
16
|
const baseClassName = styleNames.base
|
|
@@ -39,9 +35,28 @@ const SelectInput = ({
|
|
|
39
35
|
disabled,
|
|
40
36
|
isLoading,
|
|
41
37
|
autoComplete,
|
|
38
|
+
placeholder,
|
|
39
|
+
getTagColor,
|
|
40
|
+
multiple,
|
|
42
41
|
// ...otherProps
|
|
43
42
|
}) => {
|
|
44
|
-
const
|
|
43
|
+
const inputProps = {
|
|
44
|
+
name,
|
|
45
|
+
label,
|
|
46
|
+
labelColor,
|
|
47
|
+
color,
|
|
48
|
+
options,
|
|
49
|
+
validate,
|
|
50
|
+
optional,
|
|
51
|
+
description,
|
|
52
|
+
disabled,
|
|
53
|
+
isLoading,
|
|
54
|
+
placeholder,
|
|
55
|
+
getTagColor,
|
|
56
|
+
autoComplete,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const Input = multiple ? Multiple : Single
|
|
45
60
|
|
|
46
61
|
return (
|
|
47
62
|
<div
|
|
@@ -55,45 +70,7 @@ const SelectInput = ({
|
|
|
55
70
|
.join(' ')}
|
|
56
71
|
style={style}
|
|
57
72
|
>
|
|
58
|
-
<
|
|
59
|
-
name={name}
|
|
60
|
-
color={labelColor}
|
|
61
|
-
optional={optional}
|
|
62
|
-
// {...otherProps}
|
|
63
|
-
>
|
|
64
|
-
{label}
|
|
65
|
-
</FormLabel>
|
|
66
|
-
<div className={`select-wrapper${disabled ? ' disabled' : ''}`}>
|
|
67
|
-
<select
|
|
68
|
-
className={`input y-${color}`}
|
|
69
|
-
{...field}
|
|
70
|
-
value={field.value || ''}
|
|
71
|
-
id={name}
|
|
72
|
-
disabled={disabled}
|
|
73
|
-
autoComplete={autoComplete}
|
|
74
|
-
>
|
|
75
|
-
{
|
|
76
|
-
options.map((option) => {
|
|
77
|
-
// i.e if option is a string like "blah", return { value: "blah", label: "blah" }
|
|
78
|
-
const newOption = typeof option === 'string' ? { value: option, label: option } : option
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<option
|
|
82
|
-
key={newOption.value}
|
|
83
|
-
value={newOption.value}
|
|
84
|
-
disabled={newOption?.disabled || false}
|
|
85
|
-
>
|
|
86
|
-
{newOption.label}
|
|
87
|
-
</option>
|
|
88
|
-
)
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
</select>
|
|
92
|
-
{isLoading && (
|
|
93
|
-
<LoadingCircle className="x-main" />
|
|
94
|
-
)}
|
|
95
|
-
</div>
|
|
96
|
-
<FormDescription className="s-1" description={description} name={name} />
|
|
73
|
+
<Input {...inputProps} />
|
|
97
74
|
</div>
|
|
98
75
|
)
|
|
99
76
|
}
|
|
@@ -175,11 +152,21 @@ SelectInput.propTypes = {
|
|
|
175
152
|
* Whether the input is optional or not
|
|
176
153
|
*/
|
|
177
154
|
optional:PropTypes.bool,
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Whether the select input should allow multiple selections
|
|
158
|
+
*/
|
|
159
|
+
multiple:PropTypes.bool,
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The placeholder of the select input
|
|
163
|
+
*/
|
|
164
|
+
placeholder:PropTypes.string,
|
|
178
165
|
}
|
|
179
166
|
|
|
180
167
|
SelectInput.defaultProps = {
|
|
181
168
|
disabled:false,
|
|
182
|
-
|
|
169
|
+
multiple:false,
|
|
183
170
|
}
|
|
184
171
|
|
|
185
172
|
export default memo(SelectInput)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
5
|
+
|
|
6
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
7
|
+
|
|
8
|
+
// Local Definitions
|
|
9
|
+
|
|
10
|
+
const baseClassName = styleNames.base
|
|
11
|
+
|
|
12
|
+
const componentClassName = 'menu'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This is the component description.
|
|
16
|
+
*/
|
|
17
|
+
const Menu = React.forwardRef(({
|
|
18
|
+
id,
|
|
19
|
+
className:userClassName,
|
|
20
|
+
style,
|
|
21
|
+
items,
|
|
22
|
+
isOpen,
|
|
23
|
+
highlightedIndex,
|
|
24
|
+
getItemProps,
|
|
25
|
+
...otherProps
|
|
26
|
+
}, ref) => (
|
|
27
|
+
<ul
|
|
28
|
+
id={id}
|
|
29
|
+
className={[
|
|
30
|
+
|
|
31
|
+
baseClassName,
|
|
32
|
+
|
|
33
|
+
componentClassName,
|
|
34
|
+
userClassName,
|
|
35
|
+
]
|
|
36
|
+
.filter((e) => e)
|
|
37
|
+
.join(' ')}
|
|
38
|
+
style={style}
|
|
39
|
+
ref={ref}
|
|
40
|
+
{...otherProps}
|
|
41
|
+
>
|
|
42
|
+
{isOpen && items.map((item, index) => (
|
|
43
|
+
<li
|
|
44
|
+
key={item.label}
|
|
45
|
+
{...getItemProps({ item, index })}
|
|
46
|
+
className={[
|
|
47
|
+
'item',
|
|
48
|
+
highlightedIndex === index && styleNames.modifierActive,
|
|
49
|
+
].filter(Boolean)
|
|
50
|
+
.join(' ')}
|
|
51
|
+
>
|
|
52
|
+
<p>
|
|
53
|
+
{item.label}
|
|
54
|
+
</p>
|
|
55
|
+
</li>
|
|
56
|
+
))}
|
|
57
|
+
</ul>
|
|
58
|
+
))
|
|
59
|
+
Menu.propTypes = {
|
|
60
|
+
/**
|
|
61
|
+
* The HTML id for this element
|
|
62
|
+
*/
|
|
63
|
+
id:PropTypes.string,
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The HTML class names for this element
|
|
67
|
+
*/
|
|
68
|
+
className:PropTypes.string,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The React-written, css properties for this element.
|
|
72
|
+
*/
|
|
73
|
+
style:PropTypes.objectOf(PropTypes.string),
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The items to be displayed in the menu
|
|
77
|
+
*/
|
|
78
|
+
items:PropTypes.arrayOf(PropTypes.shape({
|
|
79
|
+
value:PropTypes.string,
|
|
80
|
+
label:PropTypes.string,
|
|
81
|
+
})),
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Whether or not the menu is open
|
|
85
|
+
*/
|
|
86
|
+
isOpen:PropTypes.bool,
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The index of the highlighted item
|
|
90
|
+
*/
|
|
91
|
+
highlightedIndex:PropTypes.number,
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The function to get the item props
|
|
95
|
+
*/
|
|
96
|
+
getItemProps:PropTypes.func,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
Menu.defaultProps = {
|
|
100
|
+
// someProp:false
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default Menu
|