@pareto-engineering/design-system 2.0.0-alpha.43 → 2.0.0-alpha.46
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/.env.scripts.example +4 -0
- package/.eslintrc.js +25 -1
- package/babel.config.js +1 -0
- package/dist/cjs/f/FormInput/FormInput.js +13 -3
- package/dist/cjs/f/FormInput/styles.scss +11 -0
- package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +214 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +194 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Menu/Menu.js +103 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Menu/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +281 -0
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/common/index.js +21 -0
- package/dist/cjs/f/fields/QueryCombobox/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/styles.scss +84 -0
- package/dist/cjs/f/fields/SelectInput/SelectInput.js +0 -1
- package/dist/cjs/f/fields/SelectInput/styles.scss +8 -6
- package/dist/cjs/f/fields/index.js +9 -1
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/test/QueryLoader/QueryLoader.js +41 -0
- package/dist/cjs/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +71 -0
- package/dist/cjs/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +49 -0
- package/dist/cjs/test/QueryLoader/common/PreloadedTestData/index.js +15 -0
- package/dist/cjs/test/QueryLoader/common/index.js +13 -0
- package/dist/cjs/test/QueryLoader/index.js +15 -0
- package/dist/cjs/test/QueryLoader/styles.scss +9 -0
- package/dist/cjs/test/index.js +13 -0
- package/dist/es/f/FormInput/FormInput.js +13 -3
- package/dist/es/f/FormInput/styles.scss +11 -0
- package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +191 -0
- package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +174 -0
- package/dist/es/f/fields/QueryCombobox/common/Combobox/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/common/Menu/Menu.js +77 -0
- package/dist/es/f/fields/QueryCombobox/common/Menu/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +253 -0
- package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/common/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/styles.scss +84 -0
- package/dist/es/f/fields/SelectInput/SelectInput.js +0 -1
- package/dist/es/f/fields/SelectInput/styles.scss +8 -6
- package/dist/es/f/fields/index.js +2 -1
- package/dist/es/index.js +2 -1
- package/dist/es/test/QueryLoader/QueryLoader.js +29 -0
- package/dist/es/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +71 -0
- package/dist/es/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +31 -0
- package/dist/es/test/QueryLoader/common/PreloadedTestData/index.js +2 -0
- package/dist/es/test/QueryLoader/common/index.js +1 -0
- package/dist/es/test/QueryLoader/index.js +2 -0
- package/dist/es/test/QueryLoader/styles.scss +9 -0
- package/dist/es/test/index.js +1 -0
- package/package.json +16 -3
- package/relay.config.js +12 -0
- package/schema.graphql +4075 -0
- package/scripts/fetchSchema.js +74 -0
- package/src/__snapshots__/Storyshots.test.js.snap +323 -8
- package/src/stories/f/FormInput.stories.jsx +115 -0
- package/src/stories/f/QueryCombobox.stories.jsx +220 -0
- package/src/stories/f/__generated__/FormInputAllTeamsQuery.graphql.js +139 -0
- package/src/stories/f/__generated__/QueryComboboxAllTeamsQuery.graphql.js +139 -0
- package/src/stories/test/QueryLoader.stories.jsx +36 -0
- package/src/stories/utils/generateNodeId.js +12 -0
- package/src/stories/utils/relay/EnvironmentProvider.jsx +14 -0
- package/src/stories/utils/relay/environment.js +5 -0
- package/src/stories/utils/relay/index.js +4 -0
- package/src/stories/utils/relay/mockRelayOperation.js +14 -0
- package/src/stories/utils/relay/mockResolvers.js +299 -0
- package/src/stories/utils/testData.js +63 -0
- package/src/ui/f/FormInput/FormInput.jsx +16 -1
- package/src/ui/f/FormInput/styles.scss +11 -0
- package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +207 -0
- package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +214 -0
- package/src/ui/f/fields/QueryCombobox/common/Combobox/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/common/Menu/Menu.jsx +103 -0
- package/src/ui/f/fields/QueryCombobox/common/Menu/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/common/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/styles.scss +84 -0
- package/src/ui/f/fields/SelectInput/SelectInput.jsx +1 -1
- package/src/ui/f/fields/SelectInput/styles.scss +8 -6
- package/src/ui/f/fields/index.js +1 -0
- package/src/ui/index.js +1 -0
- package/src/ui/test/QueryLoader/QueryLoader.jsx +41 -0
- package/src/ui/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +68 -0
- package/src/ui/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.jsx +51 -0
- package/src/ui/test/QueryLoader/common/PreloadedTestData/index.js +2 -0
- package/src/ui/test/QueryLoader/common/index.js +1 -0
- package/src/ui/test/QueryLoader/index.js +2 -0
- package/src/ui/test/index.js +1 -0
|
@@ -0,0 +1,253 @@
|
|
|
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 { useState, useEffect, useRef } from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import styleNames from '@pareto-engineering/bem';
|
|
8
|
+
import { useCombobox, useMultipleSelection } from 'downshift';
|
|
9
|
+
import { Button } from "../../../../../b";
|
|
10
|
+
import { Popover, LoadingCircle } from "../../../../../a";
|
|
11
|
+
import { FormDescription, FormLabel } from "../../../.."; // Local Definitions
|
|
12
|
+
|
|
13
|
+
import { Menu } from "../Menu";
|
|
14
|
+
const baseClassName = styleNames.base;
|
|
15
|
+
const componentClassName = 'multiple-combobox';
|
|
16
|
+
/**
|
|
17
|
+
* @param {Array[Object]} first - first array to check if it has an item not in the second array.
|
|
18
|
+
* @param {Array[Object]} second - second array to check against the first array.
|
|
19
|
+
*
|
|
20
|
+
* @returns {Boolean} - true if the first array has an item not in the second array.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const testIfArraysAreUnique = (first, second) => first.filter(objInFirstArray => !second.some(objInSecondArray => objInFirstArray.value === objInSecondArray.value)).length > 0;
|
|
24
|
+
/**
|
|
25
|
+
* This is the component description.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const MultipleCombobox = ({
|
|
30
|
+
id,
|
|
31
|
+
className: userClassName,
|
|
32
|
+
style,
|
|
33
|
+
label,
|
|
34
|
+
name,
|
|
35
|
+
options: items,
|
|
36
|
+
getOptions,
|
|
37
|
+
setValue,
|
|
38
|
+
error,
|
|
39
|
+
description,
|
|
40
|
+
value,
|
|
41
|
+
color,
|
|
42
|
+
isFetching,
|
|
43
|
+
loadingCircleColor // ...otherProps
|
|
44
|
+
|
|
45
|
+
}) => {
|
|
46
|
+
const [searchInputValue, setSearchInputValue] = useState('');
|
|
47
|
+
const {
|
|
48
|
+
getSelectedItemProps,
|
|
49
|
+
getDropdownProps,
|
|
50
|
+
addSelectedItem,
|
|
51
|
+
removeSelectedItem,
|
|
52
|
+
setSelectedItems,
|
|
53
|
+
selectedItems
|
|
54
|
+
} = useMultipleSelection({
|
|
55
|
+
initialSelectedItems: value || []
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const getFilteredItems = () => items.filter(item => selectedItems.findIndex(e => e.label === item.label) < 0 && item.label.toLowerCase().startsWith(searchInputValue.toLowerCase()));
|
|
59
|
+
|
|
60
|
+
const {
|
|
61
|
+
isOpen,
|
|
62
|
+
getLabelProps,
|
|
63
|
+
getMenuProps,
|
|
64
|
+
getInputProps,
|
|
65
|
+
getComboboxProps,
|
|
66
|
+
highlightedIndex,
|
|
67
|
+
getItemProps
|
|
68
|
+
} = useCombobox({
|
|
69
|
+
searchInputValue,
|
|
70
|
+
defaultHighlightedIndex: 0,
|
|
71
|
+
// after selection, highlight the first item.
|
|
72
|
+
selectedItem: null,
|
|
73
|
+
items: getFilteredItems(),
|
|
74
|
+
circularNavigation: true,
|
|
75
|
+
stateReducer: (state, actionAndChanges) => {
|
|
76
|
+
const {
|
|
77
|
+
changes,
|
|
78
|
+
type
|
|
79
|
+
} = actionAndChanges;
|
|
80
|
+
|
|
81
|
+
switch (type) {
|
|
82
|
+
case useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
83
|
+
case useCombobox.stateChangeTypes.ItemClick:
|
|
84
|
+
return { ...changes,
|
|
85
|
+
isOpen: true // keep the menu open after selection.
|
|
86
|
+
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
default:
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return changes;
|
|
94
|
+
},
|
|
95
|
+
onStateChange: ({
|
|
96
|
+
inputValue: newSearchInputValue,
|
|
97
|
+
type,
|
|
98
|
+
selectedItem
|
|
99
|
+
}) => {
|
|
100
|
+
switch (type) {
|
|
101
|
+
case useCombobox.stateChangeTypes.InputChange:
|
|
102
|
+
getOptions(newSearchInputValue);
|
|
103
|
+
setSearchInputValue(newSearchInputValue);
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
case useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
107
|
+
case useCombobox.stateChangeTypes.ItemClick:
|
|
108
|
+
case useCombobox.stateChangeTypes.InputBlur:
|
|
109
|
+
if (selectedItem) {
|
|
110
|
+
setSearchInputValue('');
|
|
111
|
+
addSelectedItem(selectedItem);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
break;
|
|
115
|
+
|
|
116
|
+
default:
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if ((selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) > 0) {
|
|
123
|
+
setValue(selectedItems);
|
|
124
|
+
}
|
|
125
|
+
}, [selectedItems]);
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if ((value === null || value === void 0 ? void 0 : value.length) > 0 && (testIfArraysAreUnique(value, selectedItems) || testIfArraysAreUnique(selectedItems, value))) {
|
|
128
|
+
setSelectedItems(value);
|
|
129
|
+
}
|
|
130
|
+
}, [value]);
|
|
131
|
+
const parentRef = useRef(null);
|
|
132
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
133
|
+
id: id,
|
|
134
|
+
className: [baseClassName, componentClassName, userClassName, `y-${color}`, `x-${loadingCircleColor}`].filter(e => e).join(' '),
|
|
135
|
+
style: style
|
|
136
|
+
}, /*#__PURE__*/React.createElement(FormLabel, _extends({}, getLabelProps(), {
|
|
137
|
+
name: name
|
|
138
|
+
}), label), /*#__PURE__*/React.createElement("div", {
|
|
139
|
+
className: "selected-items"
|
|
140
|
+
}, selectedItems && selectedItems.map((selectedItem, index) => /*#__PURE__*/React.createElement("div", _extends({
|
|
141
|
+
key: selectedItem.label
|
|
142
|
+
}, getSelectedItemProps({
|
|
143
|
+
selectedItem,
|
|
144
|
+
index
|
|
145
|
+
})), selectedItem.label, /*#__PURE__*/React.createElement(Button, {
|
|
146
|
+
className: "f-icons",
|
|
147
|
+
onClick: e => {
|
|
148
|
+
e.stopPropagation();
|
|
149
|
+
removeSelectedItem(selectedItem);
|
|
150
|
+
},
|
|
151
|
+
isCompact: true,
|
|
152
|
+
isSimple: true,
|
|
153
|
+
color: "main2"
|
|
154
|
+
}, "X")))), /*#__PURE__*/React.createElement("div", _extends({}, getComboboxProps(), {
|
|
155
|
+
className: "input-wrapper"
|
|
156
|
+
}), /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(getDropdownProps({
|
|
157
|
+
preventKeyAction: isOpen
|
|
158
|
+
})), {
|
|
159
|
+
className: "input"
|
|
160
|
+
})), isFetching && /*#__PURE__*/React.createElement(LoadingCircle, null)), /*#__PURE__*/React.createElement(Popover, {
|
|
161
|
+
isOpen: isOpen,
|
|
162
|
+
parentRef: parentRef
|
|
163
|
+
}, /*#__PURE__*/React.createElement(Menu, _extends({
|
|
164
|
+
isOpen: isOpen,
|
|
165
|
+
getItemProps: getItemProps,
|
|
166
|
+
highlightedIndex: highlightedIndex,
|
|
167
|
+
items: getFilteredItems()
|
|
168
|
+
}, getMenuProps()))), (description || error) && /*#__PURE__*/React.createElement(FormDescription, {
|
|
169
|
+
isError: !!error
|
|
170
|
+
}, error || description));
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
MultipleCombobox.propTypes = {
|
|
174
|
+
/**
|
|
175
|
+
* The HTML id for this element
|
|
176
|
+
*/
|
|
177
|
+
id: PropTypes.string,
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The HTML class names for this element
|
|
181
|
+
*/
|
|
182
|
+
className: PropTypes.string,
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The React-written, css properties for this element.
|
|
186
|
+
*/
|
|
187
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The label of the custom select input
|
|
191
|
+
*/
|
|
192
|
+
label: PropTypes.string,
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The custom select input options from the backend
|
|
196
|
+
*/
|
|
197
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
|
198
|
+
value: PropTypes.string,
|
|
199
|
+
label: PropTypes.string
|
|
200
|
+
})),
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The name of the custom select input
|
|
204
|
+
*/
|
|
205
|
+
name: PropTypes.string,
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* The function to fetch the options from the backend
|
|
209
|
+
*/
|
|
210
|
+
getOptions: PropTypes.func,
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* The function to set the value of the custom select input
|
|
214
|
+
*/
|
|
215
|
+
setValue: PropTypes.func.isRequired,
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* The custom select input description
|
|
219
|
+
*/
|
|
220
|
+
description: PropTypes.string,
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The error object
|
|
224
|
+
*/
|
|
225
|
+
error: PropTypes.objectOf(PropTypes.string),
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The value of the custom select input
|
|
229
|
+
*/
|
|
230
|
+
value: PropTypes.arrayOf(PropTypes.shape({
|
|
231
|
+
value: PropTypes.string,
|
|
232
|
+
label: PropTypes.string
|
|
233
|
+
})),
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The base color of the custom select input
|
|
237
|
+
*/
|
|
238
|
+
color: PropTypes.string,
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Whether the query getting the combobox options is inFlight
|
|
242
|
+
*/
|
|
243
|
+
isFetching: PropTypes.bool.isRequired,
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* The loading circle color
|
|
247
|
+
*/
|
|
248
|
+
loadingCircleColor: PropTypes.string
|
|
249
|
+
};
|
|
250
|
+
MultipleCombobox.defaultProps = {
|
|
251
|
+
loadingCircleColor: 'main2'
|
|
252
|
+
};
|
|
253
|
+
export default MultipleCombobox;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-input-padding: .75em .75em .55em;
|
|
6
|
+
$default-padding: 1em;
|
|
7
|
+
$default-margin: 1em;
|
|
8
|
+
$default-loading-circle-displacement: 1em;
|
|
9
|
+
|
|
10
|
+
.#{bem.$base}.combobox,
|
|
11
|
+
.#{bem.$base}.multiple-combobox {
|
|
12
|
+
position: relative;
|
|
13
|
+
|
|
14
|
+
.#{bem.$base}.label {
|
|
15
|
+
margin-bottom: $default-margin
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.#{bem.$base}.popover {
|
|
19
|
+
width: 100%;
|
|
20
|
+
|
|
21
|
+
>.menu {
|
|
22
|
+
list-style: none;
|
|
23
|
+
margin: 0;
|
|
24
|
+
outline: 0;
|
|
25
|
+
padding: 0;
|
|
26
|
+
|
|
27
|
+
>.item {
|
|
28
|
+
padding: $default-padding / 2;
|
|
29
|
+
|
|
30
|
+
&.#{bem.$modifier-active} {
|
|
31
|
+
background-color: var(--background2);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
>.input-wrapper {
|
|
38
|
+
position: relative;
|
|
39
|
+
|
|
40
|
+
>.#{bem.$base}.loading-circle {
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: $default-loading-circle-displacement;
|
|
43
|
+
right: $default-loading-circle-displacement;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
>.input {
|
|
47
|
+
background: var(--light-y);
|
|
48
|
+
border: var(--theme-border-style) var(--dark-y);
|
|
49
|
+
color: var(--on-y);
|
|
50
|
+
padding: $default-input-padding;
|
|
51
|
+
width: 100%;
|
|
52
|
+
|
|
53
|
+
&::placeholder {
|
|
54
|
+
color: var(--metadata);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:not(:disabled):hover {
|
|
58
|
+
border: var(--theme-border-style) var(--light-background4);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&:disabled {
|
|
62
|
+
background-color: var(--dark-y);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&:focus {
|
|
66
|
+
background: var(--light-background4);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
.#{bem.$base}.multiple-combobox {
|
|
74
|
+
>.selected-items {
|
|
75
|
+
display: flex;
|
|
76
|
+
|
|
77
|
+
/* stylelint-disable selector-max-universal -- Allow */
|
|
78
|
+
>*:not(:first-child) {
|
|
79
|
+
margin-left: $default-margin;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* stylelint-enable selector-max-universal */
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -6,24 +6,27 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
$default-padding: 0.75em;
|
|
9
|
-
|
|
9
|
+
$default-margin: 1em;
|
|
10
10
|
|
|
11
11
|
.#{bem.$base}.select-input {
|
|
12
12
|
display: flex;
|
|
13
13
|
flex-direction: column;
|
|
14
14
|
|
|
15
|
+
.#{bem.$base}.label {
|
|
16
|
+
margin-bottom: $default-margin
|
|
17
|
+
}
|
|
15
18
|
|
|
16
19
|
.input {
|
|
17
20
|
border: var(--theme-border-style) var(--dark-y);
|
|
18
21
|
background: var(--light-y);
|
|
19
|
-
color:var(--on-y);
|
|
22
|
+
color: var(--on-y);
|
|
20
23
|
padding: $default-padding;
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
&:not(:disabled):hover {
|
|
23
26
|
border: var(--theme-border-style) var(--light-background4);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
&:disabled {
|
|
27
30
|
background-color: var(--dark-y);
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -31,5 +34,4 @@ $default-padding: 0.75em;
|
|
|
31
34
|
background: var(--y);
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
|
-
}
|
|
35
|
-
|
|
37
|
+
}
|
|
@@ -2,4 +2,5 @@ export { TextInput } from "./TextInput";
|
|
|
2
2
|
export { SelectInput } from "./SelectInput";
|
|
3
3
|
export { ChoicesInput } from "./ChoicesInput";
|
|
4
4
|
export { TextareaInput } from "./TextareaInput";
|
|
5
|
-
export { RatingsInput } from "./RatingsInput";
|
|
5
|
+
export { RatingsInput } from "./RatingsInput";
|
|
6
|
+
export { QueryCombobox } from "./QueryCombobox";
|
package/dist/es/index.js
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var _QueryLoaderHelloQuery;
|
|
2
|
+
|
|
3
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useEffect, Suspense } from 'react';
|
|
6
|
+
import { useQueryLoader } from 'react-relay'; // Local Definitions
|
|
7
|
+
|
|
8
|
+
import { PreloadedTestData } from "./common";
|
|
9
|
+
const testQuery = _QueryLoaderHelloQuery !== void 0 ? _QueryLoaderHelloQuery : (_QueryLoaderHelloQuery = require("./__generated__/QueryLoaderHelloQuery.graphql"), _QueryLoaderHelloQuery.hash && _QueryLoaderHelloQuery.hash !== "b92d001ab0208bd484a99f77c274d5ef" && console.error("The definition of 'QueryLoaderHelloQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _QueryLoaderHelloQuery);
|
|
10
|
+
/**
|
|
11
|
+
* This is the component description.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const QueryLoader = () => {
|
|
15
|
+
const [queryReference, loadQuery] = useQueryLoader(testQuery);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
loadQuery({});
|
|
18
|
+
}, []);
|
|
19
|
+
return /*#__PURE__*/React.createElement(Suspense, {
|
|
20
|
+
fallback: "loading"
|
|
21
|
+
}, queryReference ? /*#__PURE__*/React.createElement(PreloadedTestData, {
|
|
22
|
+
queryReference: queryReference,
|
|
23
|
+
query: testQuery
|
|
24
|
+
}) : null);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
QueryLoader.defaultProps = {// someProp:false
|
|
28
|
+
};
|
|
29
|
+
export default QueryLoader;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @flow
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
'use strict';
|
|
7
|
+
/*::
|
|
8
|
+
import type { ConcreteRequest } from 'relay-runtime';
|
|
9
|
+
export type QueryLoaderHelloQueryVariables = {||};
|
|
10
|
+
export type QueryLoaderHelloQueryResponse = {|
|
|
11
|
+
+hello: ?string
|
|
12
|
+
|};
|
|
13
|
+
export type QueryLoaderHelloQuery = {|
|
|
14
|
+
variables: QueryLoaderHelloQueryVariables,
|
|
15
|
+
response: QueryLoaderHelloQueryResponse,
|
|
16
|
+
|};
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
query QueryLoaderHelloQuery {
|
|
21
|
+
hello
|
|
22
|
+
}
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const node
|
|
26
|
+
/*: ConcreteRequest*/
|
|
27
|
+
= function () {
|
|
28
|
+
var v0 = [{
|
|
29
|
+
"alias": null,
|
|
30
|
+
"args": null,
|
|
31
|
+
"kind": "ScalarField",
|
|
32
|
+
"name": "hello",
|
|
33
|
+
"storageKey": null
|
|
34
|
+
}];
|
|
35
|
+
return {
|
|
36
|
+
"fragment": {
|
|
37
|
+
"argumentDefinitions": [],
|
|
38
|
+
"kind": "Fragment",
|
|
39
|
+
"metadata": null,
|
|
40
|
+
"name": "QueryLoaderHelloQuery",
|
|
41
|
+
"selections": v0
|
|
42
|
+
/*: any*/
|
|
43
|
+
,
|
|
44
|
+
"type": "Query",
|
|
45
|
+
"abstractKey": null
|
|
46
|
+
},
|
|
47
|
+
"kind": "Request",
|
|
48
|
+
"operation": {
|
|
49
|
+
"argumentDefinitions": [],
|
|
50
|
+
"kind": "Operation",
|
|
51
|
+
"name": "QueryLoaderHelloQuery",
|
|
52
|
+
"selections": v0
|
|
53
|
+
/*: any*/
|
|
54
|
+
|
|
55
|
+
},
|
|
56
|
+
"params": {
|
|
57
|
+
"cacheID": "463f9ee8a82dd6ec8dedeb28649cce74",
|
|
58
|
+
"id": null,
|
|
59
|
+
"metadata": {},
|
|
60
|
+
"name": "QueryLoaderHelloQuery",
|
|
61
|
+
"operationKind": "query",
|
|
62
|
+
"text": "query QueryLoaderHelloQuery {\n hello\n}\n"
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}(); // prettier-ignore
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
node
|
|
69
|
+
/*: any*/
|
|
70
|
+
.hash = 'b92d001ab0208bd484a99f77c274d5ef';
|
|
71
|
+
module.exports = node;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { usePreloadedQuery } from 'react-relay';
|
|
5
|
+
/**
|
|
6
|
+
* This is the component description.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const PreloadedTestData = ({
|
|
10
|
+
query,
|
|
11
|
+
queryReference // ...otherProps
|
|
12
|
+
|
|
13
|
+
}) => {
|
|
14
|
+
const data = usePreloadedQuery(query, queryReference);
|
|
15
|
+
return /*#__PURE__*/React.createElement("pre", null, JSON.stringify(data, null, 2));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
PreloadedTestData.propTypes = {
|
|
19
|
+
/**
|
|
20
|
+
* The query to be used to query the test data
|
|
21
|
+
*/
|
|
22
|
+
query: PropTypes.objectOf(PropTypes.PropTypes.oneOfType([PropTypes.string, PropTypes.object])),
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The query reference to be used to access the preloaded data
|
|
26
|
+
*/
|
|
27
|
+
queryReference: PropTypes.objectOf(PropTypes.PropTypes.oneOfType([PropTypes.string, PropTypes.object]))
|
|
28
|
+
};
|
|
29
|
+
PreloadedTestData.defaultProps = {// someProp:false
|
|
30
|
+
};
|
|
31
|
+
export default PreloadedTestData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PreloadedTestData } from "./PreloadedTestData";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { QueryLoader } from "./QueryLoader";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pareto-engineering/design-system",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.46",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/es/index.js",
|
|
@@ -33,7 +33,11 @@
|
|
|
33
33
|
"link:assets": "npm link @pareto-engineering/assets",
|
|
34
34
|
"link:bem": "npm link @pareto-engineering/bem",
|
|
35
35
|
"link:styles": "npm link @pareto-engineering/styles",
|
|
36
|
-
"link:all": "npm run link:bem && npm run link:styles && npm run link:assets"
|
|
36
|
+
"link:all": "npm run link:bem && npm run link:styles && npm run link:assets",
|
|
37
|
+
"relay": "relay-compiler",
|
|
38
|
+
"fetch-schema:dev": "node scripts/fetchSchema.js",
|
|
39
|
+
"fetch-schema:prod": "node scripts/fetchSchema.js -- --ref production",
|
|
40
|
+
"fetch-schema": "npm run fetch-schema:prod"
|
|
37
41
|
},
|
|
38
42
|
"keywords": [],
|
|
39
43
|
"author": "",
|
|
@@ -52,6 +56,7 @@
|
|
|
52
56
|
"babel-jest": "^27.0.6",
|
|
53
57
|
"babel-loader": "^8.2.2",
|
|
54
58
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
59
|
+
"babel-plugin-relay": "^13.2.0",
|
|
55
60
|
"chromatic": "^5.9.2",
|
|
56
61
|
"copyfiles": "^2.4.1",
|
|
57
62
|
"css-mqpacker": "^7.0.0",
|
|
@@ -59,11 +64,13 @@
|
|
|
59
64
|
"eslint": "^7.30.0",
|
|
60
65
|
"eslint-config-airbnb": "^18.2.1",
|
|
61
66
|
"eslint-import-resolver-babel-module": "^5.3.1",
|
|
67
|
+
"eslint-plugin-graphql": "^4.0.0",
|
|
62
68
|
"eslint-plugin-import": "^2.23.4",
|
|
63
69
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
64
70
|
"eslint-plugin-react": "^7.24.0",
|
|
65
71
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
66
72
|
"faker": "^5.5.3",
|
|
73
|
+
"graphql": "^15.8.0",
|
|
67
74
|
"identity-obj-proxy": "^3.0.0",
|
|
68
75
|
"jest": "^27.0.6",
|
|
69
76
|
"jsonlint": "^1.6.3",
|
|
@@ -72,6 +79,8 @@
|
|
|
72
79
|
"postcss-cli": "^8.3.1",
|
|
73
80
|
"postcss-preset-env": "^6.7.0",
|
|
74
81
|
"postcss-scss": "^4.0.0",
|
|
82
|
+
"relay-compiler": "^11.0.2",
|
|
83
|
+
"relay-config": "^11.0.2",
|
|
75
84
|
"sass": "^1.35.1",
|
|
76
85
|
"sass-loader": "=10.1.1",
|
|
77
86
|
"storybook-addon-themes": "^6.1.0",
|
|
@@ -79,10 +88,11 @@
|
|
|
79
88
|
"stylelint-config-palantir": "^5.1.0"
|
|
80
89
|
},
|
|
81
90
|
"dependencies": {
|
|
82
|
-
"@pareto-engineering/assets": "^2.0.0-alpha.
|
|
91
|
+
"@pareto-engineering/assets": "^2.0.0-alpha.21",
|
|
83
92
|
"@pareto-engineering/bem": "^0.1.5",
|
|
84
93
|
"@pareto-engineering/styles": "^2.0.0-alpha.8",
|
|
85
94
|
"date-fns": "^2.22.1",
|
|
95
|
+
"downshift": "^6.1.7",
|
|
86
96
|
"formik": "^2.2.9",
|
|
87
97
|
"hamburgers": "^1.1.3",
|
|
88
98
|
"lodash": "^4.17.21",
|
|
@@ -91,8 +101,11 @@
|
|
|
91
101
|
"react-countup": "^4.4.0",
|
|
92
102
|
"react-dom": "^17.0.2",
|
|
93
103
|
"react-helmet": "^6.1.0",
|
|
104
|
+
"react-relay": "^11.0.2",
|
|
94
105
|
"react-router-dom": "^5.2.0",
|
|
95
106
|
"react-visibility-sensor": "^5.1.1",
|
|
107
|
+
"relay-runtime": "^11.0.2",
|
|
108
|
+
"relay-test-utils": "^11.0.2",
|
|
96
109
|
"swiper": "^6.7.5",
|
|
97
110
|
"typed.js": "^2.0.12"
|
|
98
111
|
},
|
package/relay.config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { resolve } = require('path')
|
|
2
|
+
|
|
3
|
+
// If you're reading this file for the first time, please read this toroughly https://mrtnzlml.com/docs/relay
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
src :resolve(__dirname, './src'),
|
|
7
|
+
schema :resolve(__dirname, './schema.graphql'),
|
|
8
|
+
exclude :['**/node_modules/**', '**/__mocks__/**', '**/__generated__/**'],
|
|
9
|
+
watchman:true,
|
|
10
|
+
verbose :true,
|
|
11
|
+
// language:typescript
|
|
12
|
+
}
|