@pareto-engineering/design-system 2.0.0-alpha.64 → 2.0.0-alpha.66
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/ContentTree/ContentTree.js +1 -1
- package/dist/cjs/f/common/Label/Label.js +10 -4
- package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +9 -2
- package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +8 -1
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +27 -6
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +23 -4
- package/dist/cjs/f/fields/QueryCombobox/styles.scss +2 -1
- package/dist/cjs/f/fields/QuerySelect/QuerySelect.js +8 -1
- package/dist/cjs/f/fields/SelectInput/SelectInput.js +9 -2
- package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +9 -2
- package/dist/cjs/v3/Button/Button.js +70 -0
- package/dist/cjs/v3/Button/index.js +15 -0
- package/dist/cjs/v3/Button/styles.scss +9 -0
- package/dist/cjs/v3/index.js +13 -0
- package/dist/es/a/ContentTree/ContentTree.js +1 -1
- package/dist/es/f/common/Label/Label.js +10 -4
- package/dist/es/f/fields/ChoicesInput/ChoicesInput.js +9 -2
- package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +8 -1
- package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +27 -7
- package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +23 -4
- package/dist/es/f/fields/QueryCombobox/styles.scss +2 -1
- package/dist/es/f/fields/QuerySelect/QuerySelect.js +8 -1
- package/dist/es/f/fields/SelectInput/SelectInput.js +9 -2
- package/dist/es/f/fields/TextareaInput/TextareaInput.js +9 -2
- package/dist/es/v3/Button/Button.js +54 -0
- package/dist/es/v3/Button/index.js +2 -0
- package/dist/es/v3/Button/styles.scss +9 -0
- package/dist/es/v3/index.js +1 -0
- package/package.json +1 -1
- package/src/__snapshots__/Storyshots.test.js.snap +682 -28
- package/src/stories/f/Checkbox.stories.jsx +1 -1
- package/src/stories/f/ChoicesInput.stories.jsx +8 -0
- package/src/stories/f/Label.stories.jsx +8 -3
- package/src/stories/f/QueryCombobox.stories.jsx +6 -0
- package/src/stories/f/QuerySelect.stories.jsx +8 -1
- package/src/stories/f/RatingsInput.stories.jsx +7 -0
- package/src/stories/f/SelectInput.stories.jsx +7 -0
- package/src/stories/f/TextInput.stories.jsx +7 -0
- package/src/stories/f/TextareaInput.stories.jsx +7 -0
- package/src/ui/a/ContentTree/ContentTree.jsx +1 -1
- package/src/ui/f/common/Label/Label.jsx +9 -3
- package/src/ui/f/fields/ChoicesInput/ChoicesInput.jsx +7 -1
- package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +7 -0
- package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +26 -3
- package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +27 -1
- package/src/ui/f/fields/QueryCombobox/styles.scss +2 -1
- package/src/ui/f/fields/QuerySelect/QuerySelect.jsx +7 -0
- package/src/ui/f/fields/SelectInput/SelectInput.jsx +7 -1
- package/src/ui/f/fields/TextareaInput/TextareaInput.jsx +7 -0
|
@@ -73,7 +73,7 @@ ContentTree.propTypes = {
|
|
|
73
73
|
* The reference to the parent element.
|
|
74
74
|
*/
|
|
75
75
|
target: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
76
|
-
current: _propTypes.default.instanceOf(
|
|
76
|
+
current: _propTypes.default.instanceOf(String)
|
|
77
77
|
})])
|
|
78
78
|
};
|
|
79
79
|
ContentTree.defaultProps = {
|
|
@@ -32,6 +32,7 @@ var Label = _ref => {
|
|
|
32
32
|
children,
|
|
33
33
|
name,
|
|
34
34
|
color,
|
|
35
|
+
optional,
|
|
35
36
|
as: Wrapper // ...otherProps
|
|
36
37
|
|
|
37
38
|
} = _ref;
|
|
@@ -44,7 +45,7 @@ var Label = _ref => {
|
|
|
44
45
|
className: [baseClassName, componentClassName, userClassName, "x-".concat(color)].filter(e => e).join(' '),
|
|
45
46
|
style: style // {...otherProps}
|
|
46
47
|
|
|
47
|
-
}, children);
|
|
48
|
+
}, children, optional && '(Optional)');
|
|
48
49
|
};
|
|
49
50
|
|
|
50
51
|
Label.propTypes = {
|
|
@@ -81,12 +82,17 @@ Label.propTypes = {
|
|
|
81
82
|
/**
|
|
82
83
|
* The default color of the label
|
|
83
84
|
*/
|
|
84
|
-
color: _propTypes.default.string
|
|
85
|
+
color: _propTypes.default.string,
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Whether the input should have an optional tag
|
|
89
|
+
*/
|
|
90
|
+
optional: _propTypes.default.bool
|
|
85
91
|
};
|
|
86
92
|
Label.defaultProps = {
|
|
87
|
-
// someProp:false
|
|
88
93
|
as: 'label',
|
|
89
|
-
color: 'main2'
|
|
94
|
+
color: 'main2',
|
|
95
|
+
optional: false
|
|
90
96
|
};
|
|
91
97
|
var _default = Label;
|
|
92
98
|
exports.default = _default;
|
|
@@ -49,6 +49,7 @@ var ChoicesInput = _ref => {
|
|
|
49
49
|
color,
|
|
50
50
|
colorChecked,
|
|
51
51
|
label,
|
|
52
|
+
optional,
|
|
52
53
|
disabled // ...otherProps
|
|
53
54
|
|
|
54
55
|
} = _ref;
|
|
@@ -64,7 +65,8 @@ var ChoicesInput = _ref => {
|
|
|
64
65
|
}, style) // {...otherProps}
|
|
65
66
|
|
|
66
67
|
}, label && /*#__PURE__*/React.createElement(_common2.FormLabel, {
|
|
67
|
-
as: "p"
|
|
68
|
+
as: "p",
|
|
69
|
+
optional: optional
|
|
68
70
|
}, label), /*#__PURE__*/React.createElement("div", {
|
|
69
71
|
className: "choices"
|
|
70
72
|
}, options.map(choice => /*#__PURE__*/React.createElement(_common.Choice, _extends({
|
|
@@ -144,7 +146,12 @@ ChoicesInput.propTypes = {
|
|
|
144
146
|
/**
|
|
145
147
|
* Whether all the Choices inputs should be disabled
|
|
146
148
|
*/
|
|
147
|
-
disabled: _propTypes.default.bool
|
|
149
|
+
disabled: _propTypes.default.bool,
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Whether the input is optional or not
|
|
153
|
+
*/
|
|
154
|
+
optional: _propTypes.default.bool
|
|
148
155
|
};
|
|
149
156
|
ChoicesInput.defaultProps = {
|
|
150
157
|
gridColumnsMobile: 2,
|
|
@@ -40,6 +40,7 @@ var QueryCombobox = _ref => {
|
|
|
40
40
|
name,
|
|
41
41
|
label,
|
|
42
42
|
color,
|
|
43
|
+
optional,
|
|
43
44
|
description,
|
|
44
45
|
disabled,
|
|
45
46
|
debounceMs,
|
|
@@ -117,6 +118,7 @@ var QueryCombobox = _ref => {
|
|
|
117
118
|
disabled,
|
|
118
119
|
name,
|
|
119
120
|
label,
|
|
121
|
+
optional,
|
|
120
122
|
description,
|
|
121
123
|
setValue,
|
|
122
124
|
value,
|
|
@@ -226,7 +228,12 @@ QueryCombobox.propTypes = {
|
|
|
226
228
|
/**
|
|
227
229
|
* The query combobox field validator function
|
|
228
230
|
*/
|
|
229
|
-
validate: _propTypes.default.func
|
|
231
|
+
validate: _propTypes.default.func,
|
|
232
|
+
|
|
233
|
+
/*
|
|
234
|
+
* Whether the input is optional or not
|
|
235
|
+
*/
|
|
236
|
+
optional: _propTypes.default.bool
|
|
230
237
|
};
|
|
231
238
|
QueryCombobox.defaultProps = {
|
|
232
239
|
optionsKeyMap: {
|
|
@@ -17,6 +17,8 @@ var _ = require("../../../..");
|
|
|
17
17
|
|
|
18
18
|
var _a = require("../../../../../a");
|
|
19
19
|
|
|
20
|
+
var _b = require("../../../../../b");
|
|
21
|
+
|
|
20
22
|
var _Menu = require("../Menu");
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -49,13 +51,16 @@ var Combobox = _ref => {
|
|
|
49
51
|
minLength,
|
|
50
52
|
isFetching,
|
|
51
53
|
transformSearch,
|
|
52
|
-
disabled
|
|
54
|
+
disabled,
|
|
55
|
+
optional // ...otherProps
|
|
53
56
|
|
|
54
57
|
} = _ref;
|
|
55
58
|
var {
|
|
56
59
|
isOpen,
|
|
57
60
|
selectItem,
|
|
58
61
|
selectedItem,
|
|
62
|
+
inputValue,
|
|
63
|
+
setInputValue,
|
|
59
64
|
getLabelProps,
|
|
60
65
|
getMenuProps,
|
|
61
66
|
getInputProps,
|
|
@@ -68,9 +73,9 @@ var Combobox = _ref => {
|
|
|
68
73
|
itemToString: item => item ? item.label : '',
|
|
69
74
|
onInputValueChange: _ref2 => {
|
|
70
75
|
var {
|
|
71
|
-
inputValue
|
|
76
|
+
inputValue: searchInputValue
|
|
72
77
|
} = _ref2;
|
|
73
|
-
var transformedInput = transformSearch(
|
|
78
|
+
var transformedInput = transformSearch(searchInputValue);
|
|
74
79
|
|
|
75
80
|
if (transformedInput.length > minLength) {
|
|
76
81
|
getOptions(transformedInput);
|
|
@@ -91,13 +96,17 @@ var Combobox = _ref => {
|
|
|
91
96
|
}
|
|
92
97
|
}, [value]);
|
|
93
98
|
var parentRef = (0, React.useRef)(null);
|
|
99
|
+
|
|
100
|
+
var resetInputValue = () => setInputValue('');
|
|
101
|
+
|
|
94
102
|
return /*#__PURE__*/React.createElement("div", {
|
|
95
103
|
id: id,
|
|
96
104
|
className: [baseClassName, componentClassName, userClassName, "y-".concat(color)].filter(e => e).join(' '),
|
|
97
105
|
style: style,
|
|
98
106
|
ref: parentRef
|
|
99
107
|
}, /*#__PURE__*/React.createElement(_.FormLabel, _extends({}, getLabelProps(), {
|
|
100
|
-
name: name
|
|
108
|
+
name: name,
|
|
109
|
+
optional: optional
|
|
101
110
|
}), label), /*#__PURE__*/React.createElement("div", _extends({}, getComboboxProps(), {
|
|
102
111
|
className: "input-wrapper"
|
|
103
112
|
}), /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(), {
|
|
@@ -105,7 +114,14 @@ var Combobox = _ref => {
|
|
|
105
114
|
disabled: disabled
|
|
106
115
|
})), isFetching && /*#__PURE__*/React.createElement(_a.LoadingCircle, {
|
|
107
116
|
className: "x-main2"
|
|
108
|
-
})
|
|
117
|
+
}), inputValue.length > minLength && !isFetching && /*#__PURE__*/React.createElement(_b.Button, {
|
|
118
|
+
isSimple: true,
|
|
119
|
+
isCompact: true,
|
|
120
|
+
color: "main2",
|
|
121
|
+
onClick: resetInputValue
|
|
122
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
123
|
+
className: "f-icons"
|
|
124
|
+
}, "Y"))), /*#__PURE__*/React.createElement(_a.Popover, {
|
|
109
125
|
isOpen: isOpen,
|
|
110
126
|
parentRef: parentRef
|
|
111
127
|
}, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({
|
|
@@ -200,7 +216,12 @@ Combobox.propTypes = {
|
|
|
200
216
|
/**
|
|
201
217
|
* Whether the input filed shpuld be disabled
|
|
202
218
|
*/
|
|
203
|
-
disabled: _propTypes.default.bool
|
|
219
|
+
disabled: _propTypes.default.bool,
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Whether the input is optional or not
|
|
223
|
+
*/
|
|
224
|
+
optional: _propTypes.default.bool
|
|
204
225
|
};
|
|
205
226
|
Combobox.defaultProps = {// someProp: false
|
|
206
227
|
};
|
|
@@ -57,6 +57,7 @@ var MultipleCombobox = _ref => {
|
|
|
57
57
|
style,
|
|
58
58
|
label,
|
|
59
59
|
name,
|
|
60
|
+
optional,
|
|
60
61
|
options: items,
|
|
61
62
|
getOptions,
|
|
62
63
|
setValue,
|
|
@@ -94,7 +95,9 @@ var MultipleCombobox = _ref => {
|
|
|
94
95
|
getInputProps,
|
|
95
96
|
getComboboxProps,
|
|
96
97
|
highlightedIndex,
|
|
97
|
-
getItemProps
|
|
98
|
+
getItemProps,
|
|
99
|
+
inputValue,
|
|
100
|
+
setInputValue
|
|
98
101
|
} = (0, _downshift.useCombobox)({
|
|
99
102
|
searchInputValue,
|
|
100
103
|
defaultHighlightedIndex: 0,
|
|
@@ -168,12 +171,16 @@ var MultipleCombobox = _ref => {
|
|
|
168
171
|
}
|
|
169
172
|
}, [value]);
|
|
170
173
|
var parentRef = (0, React.useRef)(null);
|
|
174
|
+
|
|
175
|
+
var resetInputValue = () => setInputValue('');
|
|
176
|
+
|
|
171
177
|
return /*#__PURE__*/React.createElement("div", {
|
|
172
178
|
id: id,
|
|
173
179
|
className: [baseClassName, componentClassName, userClassName, "y-".concat(color)].filter(e => e).join(' '),
|
|
174
180
|
style: style
|
|
175
181
|
}, /*#__PURE__*/React.createElement(_.FormLabel, _extends({}, getLabelProps(), {
|
|
176
|
-
name: name
|
|
182
|
+
name: name,
|
|
183
|
+
optional: optional
|
|
177
184
|
}), label), (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) > 0 && /*#__PURE__*/React.createElement("div", {
|
|
178
185
|
className: "selected-items"
|
|
179
186
|
}, selectedItems.map((selectedItem, index) => /*#__PURE__*/React.createElement("div", _extends({
|
|
@@ -204,7 +211,14 @@ var MultipleCombobox = _ref => {
|
|
|
204
211
|
disabled: disabled
|
|
205
212
|
})), isFetching && /*#__PURE__*/React.createElement(_a.LoadingCircle, {
|
|
206
213
|
className: "x-main2"
|
|
207
|
-
})
|
|
214
|
+
}), inputValue.length > minLength && !isFetching && /*#__PURE__*/React.createElement(_b.Button, {
|
|
215
|
+
isSimple: true,
|
|
216
|
+
isCompact: true,
|
|
217
|
+
color: "main2",
|
|
218
|
+
onClick: resetInputValue
|
|
219
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
220
|
+
className: "f-icons"
|
|
221
|
+
}, "Y"))), /*#__PURE__*/React.createElement(_a.Popover, {
|
|
208
222
|
isOpen: isOpen,
|
|
209
223
|
parentRef: parentRef
|
|
210
224
|
}, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({
|
|
@@ -299,7 +313,12 @@ MultipleCombobox.propTypes = {
|
|
|
299
313
|
/**
|
|
300
314
|
* Whether the input filed shpuld be disabled
|
|
301
315
|
*/
|
|
302
|
-
disabled: _propTypes.default.bool
|
|
316
|
+
disabled: _propTypes.default.bool,
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Whether the input is optional or not
|
|
320
|
+
*/
|
|
321
|
+
optional: _propTypes.default.bool
|
|
303
322
|
};
|
|
304
323
|
MultipleCombobox.defaultProps = {// someProp: false
|
|
305
324
|
};
|
|
@@ -38,7 +38,8 @@ $default-loading-circle-displacement: 1em;
|
|
|
38
38
|
>.input-wrapper {
|
|
39
39
|
position: relative;
|
|
40
40
|
|
|
41
|
-
>.#{bem.$base}.loading-circle
|
|
41
|
+
>.#{bem.$base}.loading-circle,
|
|
42
|
+
>.#{bem.$base}.button {
|
|
42
43
|
position: absolute;
|
|
43
44
|
top: $default-loading-circle-displacement;
|
|
44
45
|
right: $default-loading-circle-displacement;
|
|
@@ -34,6 +34,7 @@ var QuerySelect = _ref => {
|
|
|
34
34
|
style,
|
|
35
35
|
name,
|
|
36
36
|
label,
|
|
37
|
+
optional,
|
|
37
38
|
query,
|
|
38
39
|
variables,
|
|
39
40
|
optionsKeyMap,
|
|
@@ -97,6 +98,7 @@ var QuerySelect = _ref => {
|
|
|
97
98
|
style: style,
|
|
98
99
|
name: name,
|
|
99
100
|
label: label,
|
|
101
|
+
optional: optional,
|
|
100
102
|
color: color,
|
|
101
103
|
description: description,
|
|
102
104
|
disabled: isFetching || disabled,
|
|
@@ -190,7 +192,12 @@ QuerySelect.propTypes = {
|
|
|
190
192
|
/**
|
|
191
193
|
* The query select field validator function
|
|
192
194
|
*/
|
|
193
|
-
validate: _propTypes.default.func
|
|
195
|
+
validate: _propTypes.default.func,
|
|
196
|
+
|
|
197
|
+
/*
|
|
198
|
+
* Whether the input is optional or not
|
|
199
|
+
*/
|
|
200
|
+
optional: _propTypes.default.bool
|
|
194
201
|
};
|
|
195
202
|
QuerySelect.defaultProps = {
|
|
196
203
|
disabled: false,
|
|
@@ -42,6 +42,7 @@ var SelectInput = _ref => {
|
|
|
42
42
|
color,
|
|
43
43
|
options,
|
|
44
44
|
validate,
|
|
45
|
+
optional,
|
|
45
46
|
description,
|
|
46
47
|
disabled,
|
|
47
48
|
isLoading,
|
|
@@ -61,7 +62,8 @@ var SelectInput = _ref => {
|
|
|
61
62
|
style: style // {...otherProps}
|
|
62
63
|
|
|
63
64
|
}, /*#__PURE__*/React.createElement(_common.FormLabel, {
|
|
64
|
-
name: name
|
|
65
|
+
name: name,
|
|
66
|
+
optional: optional
|
|
65
67
|
}, label), /*#__PURE__*/React.createElement("div", {
|
|
66
68
|
className: "select-wrapper"
|
|
67
69
|
}, /*#__PURE__*/React.createElement("select", _extends({
|
|
@@ -154,7 +156,12 @@ SelectInput.propTypes = {
|
|
|
154
156
|
/**
|
|
155
157
|
* The autoComplete value that the browser should watch for the input
|
|
156
158
|
*/
|
|
157
|
-
autoComplete: _propTypes.default.string
|
|
159
|
+
autoComplete: _propTypes.default.string,
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Whether the input is optional or not
|
|
163
|
+
*/
|
|
164
|
+
optional: _propTypes.default.bool
|
|
158
165
|
};
|
|
159
166
|
SelectInput.defaultProps = {
|
|
160
167
|
disabled: false,
|
|
@@ -40,6 +40,7 @@ var TextareaInput = _ref => {
|
|
|
40
40
|
labelAsDescription,
|
|
41
41
|
textAreaId,
|
|
42
42
|
rows,
|
|
43
|
+
optional,
|
|
43
44
|
textAreaColor,
|
|
44
45
|
labelColor,
|
|
45
46
|
description,
|
|
@@ -64,7 +65,8 @@ var TextareaInput = _ref => {
|
|
|
64
65
|
}, /*#__PURE__*/React.createElement(_common.FormLabel, {
|
|
65
66
|
className: [labelAsDescription ? 'md-s2 s0 v1 mb-v' : 'v50 mb-v'].filter(e => e).join(' '),
|
|
66
67
|
name: name,
|
|
67
|
-
color: labelColor
|
|
68
|
+
color: labelColor,
|
|
69
|
+
optional: optional
|
|
68
70
|
}, label), /*#__PURE__*/React.createElement("textarea", _extends({
|
|
69
71
|
id: textAreaId,
|
|
70
72
|
className: "textarea"
|
|
@@ -163,7 +165,12 @@ TextareaInput.propTypes = {
|
|
|
163
165
|
* Whether to disable or allow only a certain method of resizing the area
|
|
164
166
|
* Textarea docs - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
|
|
165
167
|
*/
|
|
166
|
-
resize: _propTypes.default.string
|
|
168
|
+
resize: _propTypes.default.string,
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Whether the input is optional or not
|
|
172
|
+
*/
|
|
173
|
+
optional: _propTypes.default.bool
|
|
167
174
|
};
|
|
168
175
|
TextareaInput.defaultProps = {
|
|
169
176
|
rows: 3,
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _bem = _interopRequireDefault(require("@pareto-engineering/bem"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
// Local Definitions
|
|
21
|
+
var baseClassName = _bem.default.base;
|
|
22
|
+
var componentClassName = 'button';
|
|
23
|
+
/**
|
|
24
|
+
* This is the component description.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
var Button = _ref => {
|
|
28
|
+
var {
|
|
29
|
+
id,
|
|
30
|
+
className: userClassName,
|
|
31
|
+
style,
|
|
32
|
+
children // ...otherProps
|
|
33
|
+
|
|
34
|
+
} = _ref;
|
|
35
|
+
(0, React.useLayoutEffect)(() => {
|
|
36
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
|
|
37
|
+
}, []);
|
|
38
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
39
|
+
id: id,
|
|
40
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
41
|
+
style: style // {...otherProps}
|
|
42
|
+
|
|
43
|
+
}, children);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
Button.propTypes = {
|
|
47
|
+
/**
|
|
48
|
+
* The HTML id for this element
|
|
49
|
+
*/
|
|
50
|
+
id: _propTypes.default.string,
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The HTML class names for this element
|
|
54
|
+
*/
|
|
55
|
+
className: _propTypes.default.string,
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The React-written, css properties for this element.
|
|
59
|
+
*/
|
|
60
|
+
style: _propTypes.default.objectOf(_propTypes.default.string),
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The children JSX
|
|
64
|
+
*/
|
|
65
|
+
children: _propTypes.default.node
|
|
66
|
+
};
|
|
67
|
+
Button.defaultProps = {// someProp:false
|
|
68
|
+
};
|
|
69
|
+
var _default = Button;
|
|
70
|
+
exports.default = _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Button", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _Button.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _Button = _interopRequireDefault(require("./Button"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -58,7 +58,7 @@ ContentTree.propTypes = {
|
|
|
58
58
|
* The reference to the parent element.
|
|
59
59
|
*/
|
|
60
60
|
target: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
61
|
-
current: PropTypes.instanceOf(
|
|
61
|
+
current: PropTypes.instanceOf(String)
|
|
62
62
|
})])
|
|
63
63
|
};
|
|
64
64
|
ContentTree.defaultProps = {
|
|
@@ -17,6 +17,7 @@ const Label = ({
|
|
|
17
17
|
children,
|
|
18
18
|
name,
|
|
19
19
|
color,
|
|
20
|
+
optional,
|
|
20
21
|
as: Wrapper // ...otherProps
|
|
21
22
|
|
|
22
23
|
}) => {
|
|
@@ -29,7 +30,7 @@ const Label = ({
|
|
|
29
30
|
className: [baseClassName, componentClassName, userClassName, `x-${color}`].filter(e => e).join(' '),
|
|
30
31
|
style: style // {...otherProps}
|
|
31
32
|
|
|
32
|
-
}, children);
|
|
33
|
+
}, children, optional && '(Optional)');
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
Label.propTypes = {
|
|
@@ -66,11 +67,16 @@ Label.propTypes = {
|
|
|
66
67
|
/**
|
|
67
68
|
* The default color of the label
|
|
68
69
|
*/
|
|
69
|
-
color: PropTypes.string
|
|
70
|
+
color: PropTypes.string,
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Whether the input should have an optional tag
|
|
74
|
+
*/
|
|
75
|
+
optional: PropTypes.bool
|
|
70
76
|
};
|
|
71
77
|
Label.defaultProps = {
|
|
72
|
-
// someProp:false
|
|
73
78
|
as: 'label',
|
|
74
|
-
color: 'main2'
|
|
79
|
+
color: 'main2',
|
|
80
|
+
optional: false
|
|
75
81
|
};
|
|
76
82
|
export default Label;
|
|
@@ -27,6 +27,7 @@ const ChoicesInput = ({
|
|
|
27
27
|
color,
|
|
28
28
|
colorChecked,
|
|
29
29
|
label,
|
|
30
|
+
optional,
|
|
30
31
|
disabled // ...otherProps
|
|
31
32
|
|
|
32
33
|
}) => {
|
|
@@ -43,7 +44,8 @@ const ChoicesInput = ({
|
|
|
43
44
|
} // {...otherProps}
|
|
44
45
|
|
|
45
46
|
}, label && /*#__PURE__*/React.createElement(FormLabel, {
|
|
46
|
-
as: "p"
|
|
47
|
+
as: "p",
|
|
48
|
+
optional: optional
|
|
47
49
|
}, label), /*#__PURE__*/React.createElement("div", {
|
|
48
50
|
className: "choices"
|
|
49
51
|
}, options.map(choice => /*#__PURE__*/React.createElement(Choice, _extends({
|
|
@@ -123,7 +125,12 @@ ChoicesInput.propTypes = {
|
|
|
123
125
|
/**
|
|
124
126
|
* Whether all the Choices inputs should be disabled
|
|
125
127
|
*/
|
|
126
|
-
disabled: PropTypes.bool
|
|
128
|
+
disabled: PropTypes.bool,
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Whether the input is optional or not
|
|
132
|
+
*/
|
|
133
|
+
optional: PropTypes.bool
|
|
127
134
|
};
|
|
128
135
|
ChoicesInput.defaultProps = {
|
|
129
136
|
gridColumnsMobile: 2,
|
|
@@ -19,6 +19,7 @@ const QueryCombobox = ({
|
|
|
19
19
|
name,
|
|
20
20
|
label,
|
|
21
21
|
color,
|
|
22
|
+
optional,
|
|
22
23
|
description,
|
|
23
24
|
disabled,
|
|
24
25
|
debounceMs,
|
|
@@ -95,6 +96,7 @@ const QueryCombobox = ({
|
|
|
95
96
|
disabled,
|
|
96
97
|
name,
|
|
97
98
|
label,
|
|
99
|
+
optional,
|
|
98
100
|
description,
|
|
99
101
|
setValue,
|
|
100
102
|
value,
|
|
@@ -204,7 +206,12 @@ QueryCombobox.propTypes = {
|
|
|
204
206
|
/**
|
|
205
207
|
* The query combobox field validator function
|
|
206
208
|
*/
|
|
207
|
-
validate: PropTypes.func
|
|
209
|
+
validate: PropTypes.func,
|
|
210
|
+
|
|
211
|
+
/*
|
|
212
|
+
* Whether the input is optional or not
|
|
213
|
+
*/
|
|
214
|
+
optional: PropTypes.bool
|
|
208
215
|
};
|
|
209
216
|
QueryCombobox.defaultProps = {
|
|
210
217
|
optionsKeyMap: {
|
|
@@ -7,7 +7,8 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import { useCombobox } from 'downshift';
|
|
8
8
|
import styleNames from '@pareto-engineering/bem';
|
|
9
9
|
import { FormLabel, FormDescription } from "../../../..";
|
|
10
|
-
import { Popover, LoadingCircle } from "../../../../../a";
|
|
10
|
+
import { Popover, LoadingCircle } from "../../../../../a";
|
|
11
|
+
import { Button } from "../../../../../b"; // Local Definitions
|
|
11
12
|
|
|
12
13
|
import { Menu } from "../Menu";
|
|
13
14
|
const baseClassName = styleNames.base;
|
|
@@ -31,13 +32,16 @@ const Combobox = ({
|
|
|
31
32
|
minLength,
|
|
32
33
|
isFetching,
|
|
33
34
|
transformSearch,
|
|
34
|
-
disabled
|
|
35
|
+
disabled,
|
|
36
|
+
optional // ...otherProps
|
|
35
37
|
|
|
36
38
|
}) => {
|
|
37
39
|
const {
|
|
38
40
|
isOpen,
|
|
39
41
|
selectItem,
|
|
40
42
|
selectedItem,
|
|
43
|
+
inputValue,
|
|
44
|
+
setInputValue,
|
|
41
45
|
getLabelProps,
|
|
42
46
|
getMenuProps,
|
|
43
47
|
getInputProps,
|
|
@@ -49,9 +53,9 @@ const Combobox = ({
|
|
|
49
53
|
initialSelectedItem: value,
|
|
50
54
|
itemToString: item => item ? item.label : '',
|
|
51
55
|
onInputValueChange: ({
|
|
52
|
-
inputValue
|
|
56
|
+
inputValue: searchInputValue
|
|
53
57
|
}) => {
|
|
54
|
-
const transformedInput = transformSearch(
|
|
58
|
+
const transformedInput = transformSearch(searchInputValue);
|
|
55
59
|
|
|
56
60
|
if (transformedInput.length > minLength) {
|
|
57
61
|
getOptions(transformedInput);
|
|
@@ -72,13 +76,17 @@ const Combobox = ({
|
|
|
72
76
|
}
|
|
73
77
|
}, [value]);
|
|
74
78
|
const parentRef = useRef(null);
|
|
79
|
+
|
|
80
|
+
const resetInputValue = () => setInputValue('');
|
|
81
|
+
|
|
75
82
|
return /*#__PURE__*/React.createElement("div", {
|
|
76
83
|
id: id,
|
|
77
84
|
className: [baseClassName, componentClassName, userClassName, `y-${color}`].filter(e => e).join(' '),
|
|
78
85
|
style: style,
|
|
79
86
|
ref: parentRef
|
|
80
87
|
}, /*#__PURE__*/React.createElement(FormLabel, _extends({}, getLabelProps(), {
|
|
81
|
-
name: name
|
|
88
|
+
name: name,
|
|
89
|
+
optional: optional
|
|
82
90
|
}), label), /*#__PURE__*/React.createElement("div", _extends({}, getComboboxProps(), {
|
|
83
91
|
className: "input-wrapper"
|
|
84
92
|
}), /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(), {
|
|
@@ -86,7 +94,14 @@ const Combobox = ({
|
|
|
86
94
|
disabled: disabled
|
|
87
95
|
})), isFetching && /*#__PURE__*/React.createElement(LoadingCircle, {
|
|
88
96
|
className: "x-main2"
|
|
89
|
-
})
|
|
97
|
+
}), inputValue.length > minLength && !isFetching && /*#__PURE__*/React.createElement(Button, {
|
|
98
|
+
isSimple: true,
|
|
99
|
+
isCompact: true,
|
|
100
|
+
color: "main2",
|
|
101
|
+
onClick: resetInputValue
|
|
102
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
103
|
+
className: "f-icons"
|
|
104
|
+
}, "Y"))), /*#__PURE__*/React.createElement(Popover, {
|
|
90
105
|
isOpen: isOpen,
|
|
91
106
|
parentRef: parentRef
|
|
92
107
|
}, /*#__PURE__*/React.createElement(Menu, _extends({
|
|
@@ -181,7 +196,12 @@ Combobox.propTypes = {
|
|
|
181
196
|
/**
|
|
182
197
|
* Whether the input filed shpuld be disabled
|
|
183
198
|
*/
|
|
184
|
-
disabled: PropTypes.bool
|
|
199
|
+
disabled: PropTypes.bool,
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Whether the input is optional or not
|
|
203
|
+
*/
|
|
204
|
+
optional: PropTypes.bool
|
|
185
205
|
};
|
|
186
206
|
Combobox.defaultProps = {// someProp: false
|
|
187
207
|
};
|