@pareto-engineering/design-system 2.0.0-alpha.41 → 2.0.0-alpha.44
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/a/GradientBackground/GradientBackground.js +140 -0
- package/dist/cjs/a/GradientBackground/index.js +15 -0
- package/dist/cjs/a/GradientBackground/styles.scss +191 -0
- package/dist/cjs/a/Popover/Popover.js +134 -0
- package/dist/cjs/a/Popover/common/Divider/Divider.js +67 -0
- package/dist/cjs/a/Popover/common/Divider/index.js +15 -0
- package/dist/cjs/a/Popover/common/Item/Item.js +67 -0
- package/dist/cjs/a/Popover/common/Item/index.js +15 -0
- package/dist/cjs/a/Popover/common/index.js +21 -0
- package/dist/cjs/a/Popover/index.js +15 -0
- package/dist/cjs/a/Popover/styles.scss +33 -0
- package/dist/cjs/a/index.js +9 -1
- package/dist/cjs/c/AcceptCookies/AcceptCookies.js +134 -0
- package/dist/cjs/c/AcceptCookies/index.js +15 -0
- package/dist/cjs/c/AcceptCookies/styles.scss +49 -0
- package/dist/cjs/c/BlogCategoryButton/BlogCategoryButton.js +95 -0
- package/dist/cjs/c/BlogCategoryButton/index.js +15 -0
- package/dist/cjs/c/BlogContext/BlogContextProvider.js +63 -0
- package/dist/cjs/c/BlogContext/Context.js +16 -0
- package/dist/cjs/c/BlogContext/ContextProvider.js +63 -0
- package/dist/cjs/c/BlogContext/index.js +31 -0
- package/dist/cjs/c/BlogContext/useBlog.js +16 -0
- package/dist/cjs/c/BlogPost/BlogPost.js +147 -0
- package/dist/cjs/c/BlogPost/index.js +15 -0
- package/dist/cjs/c/BlogPost/styles.scss +33 -0
- package/dist/cjs/c/BlogPostsList/BlogPostsList.js +73 -0
- package/dist/cjs/c/BlogPostsList/common/Card/Card.js +170 -0
- package/dist/cjs/c/BlogPostsList/common/Card/index.js +15 -0
- package/dist/cjs/c/BlogPostsList/common/index.js +13 -0
- package/dist/cjs/c/BlogPostsList/index.js +15 -0
- package/dist/cjs/c/BlogPostsList/styles.scss +72 -0
- package/dist/cjs/c/SiteFooter/SiteFooter.js +73 -0
- package/dist/cjs/c/SiteFooter/common/Section/Section.js +95 -0
- package/dist/cjs/c/SiteFooter/common/Section/index.js +15 -0
- package/dist/cjs/c/SiteFooter/common/index.js +13 -0
- package/dist/cjs/c/SiteFooter/index.js +15 -0
- package/dist/cjs/c/SiteFooter/styles.scss +34 -0
- package/dist/cjs/c/SiteHeaderCTA/SiteHeaderCTA.js +108 -0
- package/dist/cjs/c/SiteHeaderCTA/index.js +15 -0
- package/dist/cjs/c/SiteHeaderCTA/styles.scss +44 -0
- package/dist/cjs/c/SiteMission/SiteMission.js +113 -0
- package/dist/cjs/c/SiteMission/index.js +15 -0
- package/dist/cjs/c/SiteMission/styles.scss +30 -0
- package/dist/cjs/c/SiteNavigation/SiteNavigation.js +130 -0
- package/dist/cjs/c/SiteNavigation/index.js +15 -0
- package/dist/cjs/c/SiteNavigation/styles.scss +118 -0
- package/dist/cjs/c/SiteOnboardingStep/SiteOnboardingStep.js +98 -0
- package/dist/cjs/c/SiteOnboardingStep/index.js +15 -0
- package/dist/cjs/c/SiteOnboardingStep/styles.scss +51 -0
- package/dist/cjs/c/SitePricing/SitePricing.js +108 -0
- package/dist/cjs/c/SitePricing/index.js +15 -0
- package/dist/cjs/c/SitePricing/styles.scss +73 -0
- package/dist/cjs/c/SiteServices/SiteServices.js +211 -0
- package/dist/cjs/c/SiteServices/index.js +15 -0
- package/dist/cjs/c/SiteServices/styles.scss +138 -0
- package/dist/cjs/c/TeamGallery/TeamGallery.js +80 -0
- package/dist/cjs/c/TeamGallery/common/PersonCard/PersonCard.js +84 -0
- package/dist/cjs/c/TeamGallery/common/PersonCard/index.js +15 -0
- package/dist/cjs/c/TeamGallery/common/index.js +13 -0
- package/dist/cjs/c/TeamGallery/index.js +15 -0
- package/dist/cjs/c/TeamGallery/styles.scss +100 -0
- package/dist/cjs/c/Testimonials/Testimonials.js +119 -0
- package/dist/cjs/c/Testimonials/index.js +15 -0
- package/dist/cjs/c/Testimonials/styles.scss +112 -0
- package/dist/cjs/experimental/GradientBackground/GradientBackground.js +98 -0
- package/dist/cjs/experimental/GradientBackground/index.js +15 -0
- package/dist/cjs/experimental/GradientBackground/styles.scss +64 -0
- package/dist/cjs/experimental/index.js +13 -0
- package/dist/cjs/f/FormInput/FormInput.js +5 -2
- package/dist/cjs/f/FormInput/styles.scss +11 -0
- package/dist/cjs/f/fields/CheckboxInput/CheckboxInput.js +105 -0
- package/dist/cjs/f/fields/CheckboxInput/index.js +15 -0
- package/dist/cjs/f/fields/CheckboxInput/styles.scss +28 -0
- package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +222 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +148 -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 +229 -0
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/common/index.js +29 -0
- package/dist/cjs/f/fields/QueryCombobox/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/styles.scss +65 -0
- package/dist/cjs/f/fields/RadioInput/RadioInput.js +110 -0
- package/dist/cjs/f/fields/RadioInput/index.js +15 -0
- package/dist/cjs/f/fields/RadioInput/styles.scss +26 -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/TaskRecommendation/TaskRecommendation.js +129 -0
- package/dist/cjs/f/fields/TaskRecommendation/index.js +15 -0
- package/dist/cjs/f/fields/TaskRecommendation/styles.scss +37 -0
- package/dist/cjs/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +131 -0
- package/dist/cjs/f/fields/TaskRecommendationInput/index.js +15 -0
- package/dist/cjs/f/fields/TaskRecommendationInput/styles.scss +41 -0
- package/dist/cjs/f/fields/TextArea/TextArea.js +141 -0
- package/dist/cjs/f/fields/TextArea/index.js +15 -0
- package/dist/cjs/f/fields/TextArea/styles.scss +19 -0
- package/dist/cjs/index.js +26 -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/cjs/utils/hooks/index.js +23 -0
- package/dist/cjs/utils/hooks/useDynamicPosition.js +107 -0
- package/dist/cjs/utils/hooks/useWindowSize.js +39 -0
- package/dist/cjs/utils/index.js +19 -0
- package/dist/es/a/GradientBackground/GradientBackground.js +118 -0
- package/dist/es/a/GradientBackground/index.js +2 -0
- package/dist/es/a/GradientBackground/styles.scss +191 -0
- package/dist/es/a/Popover/Popover.js +118 -0
- package/dist/es/a/Popover/common/Divider/Divider.js +47 -0
- package/dist/es/a/Popover/common/Divider/index.js +2 -0
- package/dist/es/a/Popover/common/Item/Item.js +47 -0
- package/dist/es/a/Popover/common/Item/index.js +2 -0
- package/dist/es/a/Popover/common/index.js +2 -0
- package/dist/es/a/Popover/index.js +2 -0
- package/dist/es/a/Popover/styles.scss +33 -0
- package/dist/es/a/index.js +2 -1
- package/dist/es/c/AcceptCookies/AcceptCookies.js +117 -0
- package/dist/es/c/AcceptCookies/index.js +2 -0
- package/dist/es/c/AcceptCookies/styles.scss +49 -0
- package/dist/es/c/BlogCategoryButton/BlogCategoryButton.js +68 -0
- package/dist/es/c/BlogCategoryButton/index.js +2 -0
- package/dist/es/c/BlogContext/BlogContextProvider.js +45 -0
- package/dist/es/c/BlogContext/Context.js +2 -0
- package/dist/es/c/BlogContext/ContextProvider.js +45 -0
- package/dist/es/c/BlogContext/index.js +4 -0
- package/dist/es/c/BlogContext/useBlog.js +3 -0
- package/dist/es/c/BlogPost/BlogPost.js +128 -0
- package/dist/es/c/BlogPost/index.js +2 -0
- package/dist/es/c/BlogPost/styles.scss +33 -0
- package/dist/es/c/BlogPostsList/BlogPostsList.js +56 -0
- package/dist/es/c/BlogPostsList/common/Card/Card.js +143 -0
- package/dist/es/c/BlogPostsList/common/Card/index.js +2 -0
- package/dist/es/c/BlogPostsList/common/index.js +1 -0
- package/dist/es/c/BlogPostsList/index.js +2 -0
- package/dist/es/c/BlogPostsList/styles.scss +72 -0
- package/dist/es/c/SiteFooter/SiteFooter.js +56 -0
- package/dist/es/c/SiteFooter/common/Section/Section.js +73 -0
- package/dist/es/c/SiteFooter/common/Section/index.js +2 -0
- package/dist/es/c/SiteFooter/common/index.js +1 -0
- package/dist/es/c/SiteFooter/index.js +2 -0
- package/dist/es/c/SiteFooter/styles.scss +34 -0
- package/dist/es/c/SiteHeaderCTA/SiteHeaderCTA.js +92 -0
- package/dist/es/c/SiteHeaderCTA/index.js +2 -0
- package/dist/es/c/SiteHeaderCTA/styles.scss +44 -0
- package/dist/es/c/SiteMission/SiteMission.js +96 -0
- package/dist/es/c/SiteMission/index.js +2 -0
- package/dist/es/c/SiteMission/styles.scss +30 -0
- package/dist/es/c/SiteNavigation/SiteNavigation.js +111 -0
- package/dist/es/c/SiteNavigation/index.js +2 -0
- package/dist/es/c/SiteNavigation/styles.scss +118 -0
- package/dist/es/c/SiteOnboardingStep/SiteOnboardingStep.js +81 -0
- package/dist/es/c/SiteOnboardingStep/index.js +2 -0
- package/dist/es/c/SiteOnboardingStep/styles.scss +51 -0
- package/dist/es/c/SitePricing/SitePricing.js +91 -0
- package/dist/es/c/SitePricing/index.js +2 -0
- package/dist/es/c/SitePricing/styles.scss +73 -0
- package/dist/es/c/SiteServices/SiteServices.js +195 -0
- package/dist/es/c/SiteServices/index.js +2 -0
- package/dist/es/c/SiteServices/styles.scss +138 -0
- package/dist/es/c/TeamGallery/TeamGallery.js +64 -0
- package/dist/es/c/TeamGallery/common/PersonCard/PersonCard.js +64 -0
- package/dist/es/c/TeamGallery/common/PersonCard/index.js +2 -0
- package/dist/es/c/TeamGallery/common/index.js +1 -0
- package/dist/es/c/TeamGallery/index.js +2 -0
- package/dist/es/c/TeamGallery/styles.scss +100 -0
- package/dist/es/c/Testimonials/Testimonials.js +99 -0
- package/dist/es/c/Testimonials/index.js +2 -0
- package/dist/es/c/Testimonials/styles.scss +112 -0
- package/dist/es/experimental/GradientBackground/GradientBackground.js +76 -0
- package/dist/es/experimental/GradientBackground/index.js +2 -0
- package/dist/es/experimental/GradientBackground/styles.scss +64 -0
- package/dist/es/experimental/index.js +1 -0
- package/dist/es/f/FormInput/FormInput.js +4 -1
- package/dist/es/f/FormInput/styles.scss +11 -0
- package/dist/es/f/fields/CheckboxInput/CheckboxInput.js +85 -0
- package/dist/es/f/fields/CheckboxInput/index.js +2 -0
- package/dist/es/f/fields/CheckboxInput/styles.scss +28 -0
- package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +197 -0
- package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +129 -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 +202 -0
- package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/common/index.js +3 -0
- package/dist/es/f/fields/QueryCombobox/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/styles.scss +65 -0
- package/dist/es/f/fields/RadioInput/RadioInput.js +90 -0
- package/dist/es/f/fields/RadioInput/index.js +2 -0
- package/dist/es/f/fields/RadioInput/styles.scss +26 -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/TaskRecommendation/TaskRecommendation.js +111 -0
- package/dist/es/f/fields/TaskRecommendation/index.js +2 -0
- package/dist/es/f/fields/TaskRecommendation/styles.scss +37 -0
- package/dist/es/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +111 -0
- package/dist/es/f/fields/TaskRecommendationInput/index.js +2 -0
- package/dist/es/f/fields/TaskRecommendationInput/styles.scss +41 -0
- package/dist/es/f/fields/TextArea/TextArea.js +124 -0
- package/dist/es/f/fields/TextArea/index.js +2 -0
- package/dist/es/f/fields/TextArea/styles.scss +19 -0
- package/dist/es/index.js +3 -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/dist/es/utils/hooks/index.js +2 -0
- package/dist/es/utils/hooks/useDynamicPosition.js +93 -0
- package/dist/es/utils/hooks/useWindowSize.js +27 -0
- package/dist/es/utils/index.js +1 -0
- package/package.json +14 -2
- package/relay.config.js +12 -0
- package/schema.graphql +4075 -0
- package/scripts/fetchSchema.js +74 -0
- package/src/__snapshots__/Storyshots.test.js.snap +422 -8
- package/src/stories/a/Popover.stories.jsx +106 -0
- package/src/stories/test/QueryLoader.stories.jsx +36 -0
- package/src/stories/utils/lorem.js +15 -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/ui/a/Popover/Popover.jsx +157 -0
- package/src/ui/a/Popover/index.js +2 -0
- package/src/ui/a/Popover/styles.scss +33 -0
- package/src/ui/a/index.js +1 -0
- package/src/ui/f/FormInput/FormInput.jsx +5 -1
- package/src/ui/f/FormInput/styles.scss +11 -0
- package/src/ui/f/fields/SelectInput/SelectInput.jsx +1 -1
- package/src/ui/f/fields/SelectInput/styles.scss +8 -6
- package/src/ui/index.js +2 -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
- package/src/ui/utils/hooks/index.js +2 -0
- package/src/ui/utils/hooks/useDynamicPosition.js +104 -0
- package/src/ui/utils/hooks/useWindowSize.js +32 -0
- package/src/ui/utils/index.js +1 -0
|
@@ -0,0 +1,129 @@
|
|
|
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 { useEffect } from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { useCombobox } from 'downshift';
|
|
8
|
+
import styleNames from '@pareto-engineering/bem';
|
|
9
|
+
import { FormLabel, FormDescription } from "../../../.."; // Local Definitions
|
|
10
|
+
|
|
11
|
+
import { Menu } from "../Menu";
|
|
12
|
+
const baseClassName = styleNames.base;
|
|
13
|
+
const componentClassName = 'combobox';
|
|
14
|
+
/**
|
|
15
|
+
* This is the component description.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const Combobox = ({
|
|
19
|
+
id,
|
|
20
|
+
className: userClassName,
|
|
21
|
+
style,
|
|
22
|
+
label,
|
|
23
|
+
name,
|
|
24
|
+
options: items,
|
|
25
|
+
fetchOptions,
|
|
26
|
+
setValue,
|
|
27
|
+
error,
|
|
28
|
+
description // ...otherProps
|
|
29
|
+
|
|
30
|
+
}) => {
|
|
31
|
+
const {
|
|
32
|
+
isOpen,
|
|
33
|
+
selectedItem,
|
|
34
|
+
getLabelProps,
|
|
35
|
+
getMenuProps,
|
|
36
|
+
getInputProps,
|
|
37
|
+
highlightedIndex,
|
|
38
|
+
getComboboxProps,
|
|
39
|
+
getItemProps
|
|
40
|
+
} = useCombobox({
|
|
41
|
+
items,
|
|
42
|
+
itemToString: item => item ? item.label : '',
|
|
43
|
+
onInputValueChange: ({
|
|
44
|
+
inputValue
|
|
45
|
+
}) => {
|
|
46
|
+
fetchOptions(inputValue);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (selectedItem) {
|
|
51
|
+
setValue(selectedItem.value);
|
|
52
|
+
}
|
|
53
|
+
}, [selectedItem]);
|
|
54
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
id: id,
|
|
56
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
57
|
+
style: style
|
|
58
|
+
}, /*#__PURE__*/React.createElement(FormLabel, _extends({}, getLabelProps(), {
|
|
59
|
+
className: "input-label",
|
|
60
|
+
name: name
|
|
61
|
+
}), label), /*#__PURE__*/React.createElement("div", getComboboxProps(), /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(), {
|
|
62
|
+
className: "input"
|
|
63
|
+
}))), /*#__PURE__*/React.createElement(Menu, _extends({
|
|
64
|
+
isOpen: isOpen,
|
|
65
|
+
getItemProps: getItemProps,
|
|
66
|
+
highlightedIndex: highlightedIndex,
|
|
67
|
+
items: items
|
|
68
|
+
}, getMenuProps())), (description || error) && /*#__PURE__*/React.createElement(FormDescription, {
|
|
69
|
+
isError: !!error
|
|
70
|
+
}, error || description));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
Combobox.propTypes = {
|
|
74
|
+
/**
|
|
75
|
+
* The HTML id for this element
|
|
76
|
+
*/
|
|
77
|
+
id: PropTypes.string,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The HTML class names for this element
|
|
81
|
+
*/
|
|
82
|
+
className: PropTypes.string,
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The React-written, css properties for this element.
|
|
86
|
+
*/
|
|
87
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The label of the custom select input
|
|
91
|
+
*/
|
|
92
|
+
label: PropTypes.string,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The custom select input options from the backend
|
|
96
|
+
*/
|
|
97
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
|
98
|
+
value: PropTypes.string,
|
|
99
|
+
label: PropTypes.string
|
|
100
|
+
})),
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The name of the custom select input
|
|
104
|
+
*/
|
|
105
|
+
name: PropTypes.string,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The function to fetch the options from the backend
|
|
109
|
+
*/
|
|
110
|
+
fetchOptions: PropTypes.func,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The function to set the value of the custom select input
|
|
114
|
+
*/
|
|
115
|
+
setValue: PropTypes.func.isRequired,
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The custom select input description
|
|
119
|
+
*/
|
|
120
|
+
description: PropTypes.string,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The error object
|
|
124
|
+
*/
|
|
125
|
+
error: PropTypes.objectOf(PropTypes.string)
|
|
126
|
+
};
|
|
127
|
+
Combobox.defaultProps = {// someProp:false
|
|
128
|
+
};
|
|
129
|
+
export default Combobox;
|
|
@@ -0,0 +1,77 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
6
|
+
import styleNames from '@pareto-engineering/bem'; // Local Definitions
|
|
7
|
+
|
|
8
|
+
const baseClassName = styleNames.base;
|
|
9
|
+
const componentClassName = 'menu';
|
|
10
|
+
/**
|
|
11
|
+
* This is the component description.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const Menu = /*#__PURE__*/React.forwardRef(({
|
|
15
|
+
id,
|
|
16
|
+
className: userClassName,
|
|
17
|
+
style,
|
|
18
|
+
items,
|
|
19
|
+
isOpen,
|
|
20
|
+
highlightedIndex,
|
|
21
|
+
getItemProps,
|
|
22
|
+
...otherProps
|
|
23
|
+
}, ref) => /*#__PURE__*/React.createElement("ul", _extends({
|
|
24
|
+
id: id,
|
|
25
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
26
|
+
style: style,
|
|
27
|
+
ref: ref
|
|
28
|
+
}, otherProps), isOpen && items.map((item, index) => /*#__PURE__*/React.createElement("li", _extends({
|
|
29
|
+
key: item.label
|
|
30
|
+
}, getItemProps({
|
|
31
|
+
item,
|
|
32
|
+
index
|
|
33
|
+
}), {
|
|
34
|
+
className: `item ${highlightedIndex === index ? styleNames.modifierActive : ''}`
|
|
35
|
+
}), /*#__PURE__*/React.createElement("p", null, item.label)))));
|
|
36
|
+
Menu.propTypes = {
|
|
37
|
+
/**
|
|
38
|
+
* The HTML id for this element
|
|
39
|
+
*/
|
|
40
|
+
id: PropTypes.string,
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The HTML class names for this element
|
|
44
|
+
*/
|
|
45
|
+
className: PropTypes.string,
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The React-written, css properties for this element.
|
|
49
|
+
*/
|
|
50
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The items to be displayed in the menu
|
|
54
|
+
*/
|
|
55
|
+
items: PropTypes.arrayOf(PropTypes.shape({
|
|
56
|
+
value: PropTypes.string,
|
|
57
|
+
label: PropTypes.string
|
|
58
|
+
})),
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Whether or not the menu is open
|
|
62
|
+
*/
|
|
63
|
+
isOpen: PropTypes.bool,
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The index of the highlighted item
|
|
67
|
+
*/
|
|
68
|
+
highlightedIndex: PropTypes.number,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The function to get the item props
|
|
72
|
+
*/
|
|
73
|
+
getItemProps: PropTypes.func
|
|
74
|
+
};
|
|
75
|
+
Menu.defaultProps = {// someProp:false
|
|
76
|
+
};
|
|
77
|
+
export default Menu;
|
|
@@ -0,0 +1,202 @@
|
|
|
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 } 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 { FormDescription, FormLabel } from "../../../.."; // Local Definitions
|
|
11
|
+
|
|
12
|
+
import { Menu } from "../Menu";
|
|
13
|
+
const baseClassName = styleNames.base;
|
|
14
|
+
const componentClassName = 'multiple-combobox';
|
|
15
|
+
/**
|
|
16
|
+
* This is the component description.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const MultipleCombobox = ({
|
|
20
|
+
id,
|
|
21
|
+
className: userClassName,
|
|
22
|
+
style,
|
|
23
|
+
label,
|
|
24
|
+
name,
|
|
25
|
+
options: items,
|
|
26
|
+
fetchOptions,
|
|
27
|
+
setValue,
|
|
28
|
+
error,
|
|
29
|
+
description // ...otherProps
|
|
30
|
+
|
|
31
|
+
}) => {
|
|
32
|
+
const [inputValue, setInputValue] = useState('');
|
|
33
|
+
const {
|
|
34
|
+
getSelectedItemProps,
|
|
35
|
+
getDropdownProps,
|
|
36
|
+
addSelectedItem,
|
|
37
|
+
removeSelectedItem,
|
|
38
|
+
selectedItems
|
|
39
|
+
} = useMultipleSelection();
|
|
40
|
+
|
|
41
|
+
const getFilteredItems = () => items.filter(item => selectedItems.findIndex(e => e.label === item.label) < 0 && item.label.toLowerCase().startsWith(inputValue.toLowerCase()));
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
isOpen,
|
|
45
|
+
getLabelProps,
|
|
46
|
+
getMenuProps,
|
|
47
|
+
getInputProps,
|
|
48
|
+
getComboboxProps,
|
|
49
|
+
highlightedIndex,
|
|
50
|
+
getItemProps
|
|
51
|
+
} = useCombobox({
|
|
52
|
+
inputValue,
|
|
53
|
+
defaultHighlightedIndex: 0,
|
|
54
|
+
// after selection, highlight the first item.
|
|
55
|
+
selectedItem: null,
|
|
56
|
+
items: getFilteredItems(),
|
|
57
|
+
circularNavigation: true,
|
|
58
|
+
stateReducer: (state, actionAndChanges) => {
|
|
59
|
+
const {
|
|
60
|
+
changes,
|
|
61
|
+
type
|
|
62
|
+
} = actionAndChanges;
|
|
63
|
+
|
|
64
|
+
switch (type) {
|
|
65
|
+
case useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
66
|
+
case useCombobox.stateChangeTypes.ItemClick:
|
|
67
|
+
return { ...changes,
|
|
68
|
+
isOpen: true // keep the menu open after selection.
|
|
69
|
+
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
default:
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return changes;
|
|
77
|
+
},
|
|
78
|
+
onStateChange: ({
|
|
79
|
+
inputValue: newInputValue,
|
|
80
|
+
type,
|
|
81
|
+
selectedItem
|
|
82
|
+
}) => {
|
|
83
|
+
switch (type) {
|
|
84
|
+
case useCombobox.stateChangeTypes.InputChange:
|
|
85
|
+
fetchOptions(newInputValue);
|
|
86
|
+
setInputValue(newInputValue);
|
|
87
|
+
break;
|
|
88
|
+
|
|
89
|
+
case useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
90
|
+
case useCombobox.stateChangeTypes.ItemClick:
|
|
91
|
+
case useCombobox.stateChangeTypes.InputBlur:
|
|
92
|
+
if (selectedItem) {
|
|
93
|
+
setInputValue('');
|
|
94
|
+
addSelectedItem(selectedItem);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
break;
|
|
98
|
+
|
|
99
|
+
default:
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (selectedItems.length > 0) {
|
|
106
|
+
setValue(selectedItems.map(e => e.value));
|
|
107
|
+
}
|
|
108
|
+
}, [selectedItems]);
|
|
109
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
id: id,
|
|
111
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
112
|
+
style: style
|
|
113
|
+
}, /*#__PURE__*/React.createElement(FormLabel, _extends({}, getLabelProps(), {
|
|
114
|
+
className: "input-label",
|
|
115
|
+
name: name
|
|
116
|
+
}), label), /*#__PURE__*/React.createElement("div", {
|
|
117
|
+
className: "selected-items"
|
|
118
|
+
}, selectedItems && selectedItems.map((selectedItem, index) => /*#__PURE__*/React.createElement("div", _extends({
|
|
119
|
+
key: selectedItem.label
|
|
120
|
+
}, getSelectedItemProps({
|
|
121
|
+
selectedItem,
|
|
122
|
+
index
|
|
123
|
+
})), selectedItem.label, /*#__PURE__*/React.createElement(Button, {
|
|
124
|
+
className: "f-icons",
|
|
125
|
+
onClick: e => {
|
|
126
|
+
e.stopPropagation();
|
|
127
|
+
removeSelectedItem(selectedItem);
|
|
128
|
+
},
|
|
129
|
+
isCompact: true,
|
|
130
|
+
isSimple: true,
|
|
131
|
+
color: "main2"
|
|
132
|
+
}, "X")))), /*#__PURE__*/React.createElement("div", getComboboxProps(), /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(getDropdownProps({
|
|
133
|
+
preventKeyAction: isOpen
|
|
134
|
+
})), {
|
|
135
|
+
className: "input"
|
|
136
|
+
}))), /*#__PURE__*/React.createElement(Menu, _extends({
|
|
137
|
+
isOpen: isOpen,
|
|
138
|
+
getItemProps: getItemProps,
|
|
139
|
+
highlightedIndex: highlightedIndex,
|
|
140
|
+
items: getFilteredItems()
|
|
141
|
+
}, getMenuProps())), (description || error) && /*#__PURE__*/React.createElement(FormDescription, {
|
|
142
|
+
isError: !!error
|
|
143
|
+
}, error || description));
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
MultipleCombobox.propTypes = {
|
|
147
|
+
/**
|
|
148
|
+
* The HTML id for this element
|
|
149
|
+
*/
|
|
150
|
+
id: PropTypes.string,
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The HTML class names for this element
|
|
154
|
+
*/
|
|
155
|
+
className: PropTypes.string,
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The React-written, css properties for this element.
|
|
159
|
+
*/
|
|
160
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The label of the custom select input
|
|
164
|
+
*/
|
|
165
|
+
label: PropTypes.string,
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The custom select input options from the backend
|
|
169
|
+
*/
|
|
170
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
|
171
|
+
value: PropTypes.string,
|
|
172
|
+
label: PropTypes.string
|
|
173
|
+
})),
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The name of the custom select input
|
|
177
|
+
*/
|
|
178
|
+
name: PropTypes.string,
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The function to fetch the options from the backend
|
|
182
|
+
*/
|
|
183
|
+
fetchOptions: PropTypes.func,
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The function to set the value of the custom select input
|
|
187
|
+
*/
|
|
188
|
+
setValue: PropTypes.func.isRequired,
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The custom select input description
|
|
192
|
+
*/
|
|
193
|
+
description: PropTypes.string,
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The error object
|
|
197
|
+
*/
|
|
198
|
+
error: PropTypes.objectOf(PropTypes.string)
|
|
199
|
+
};
|
|
200
|
+
MultipleCombobox.defaultProps = {// someProp:false
|
|
201
|
+
};
|
|
202
|
+
export default MultipleCombobox;
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
|
|
9
|
+
.#{bem.$base}.query-combobox {
|
|
10
|
+
.input {
|
|
11
|
+
background: var(--light-y);
|
|
12
|
+
border: var(--theme-border-style) var(--dark-y);
|
|
13
|
+
color: var(--on-y);
|
|
14
|
+
padding: $default-input-padding;
|
|
15
|
+
width: 100%;
|
|
16
|
+
|
|
17
|
+
&::placeholder {
|
|
18
|
+
color: var(--metadata);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:not(:disabled):hover {
|
|
22
|
+
border: var(--theme-border-style) var(--light-background4);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&:disabled {
|
|
26
|
+
background-color: var(--dark-y);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:focus {
|
|
30
|
+
background: var(--light-background4);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.menu {
|
|
35
|
+
list-style: none;
|
|
36
|
+
margin: 0;
|
|
37
|
+
outline: 0;
|
|
38
|
+
padding: 0;
|
|
39
|
+
|
|
40
|
+
/* stylelint-disable selector-max-universal -- Allow */
|
|
41
|
+
>* {
|
|
42
|
+
padding-block: $default-padding / 2;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* stylelint-enable selector-max-universal */
|
|
46
|
+
>.item {
|
|
47
|
+
&.#{bem.$modifier-active} {
|
|
48
|
+
background-color: var(--background2);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.multiple-combobox {
|
|
54
|
+
.selected-items {
|
|
55
|
+
display: flex;
|
|
56
|
+
|
|
57
|
+
/* stylelint-disable selector-max-universal -- Allow */
|
|
58
|
+
>*:not(:first-child) {
|
|
59
|
+
margin-left: $default-margin;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* stylelint-enable selector-max-universal */
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { useLayoutEffect, memo } from 'react';
|
|
6
|
+
import { useField } from 'formik';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import styleNames from '@pareto-engineering/bem';
|
|
9
|
+
import { FormLabel, FormDescription } from "../../common"; // Local Definitions
|
|
10
|
+
|
|
11
|
+
const baseClassName = styleNames.base;
|
|
12
|
+
const componentClassName = 'radio-input';
|
|
13
|
+
/**
|
|
14
|
+
* This is the component description.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const RadioInput = ({
|
|
18
|
+
id,
|
|
19
|
+
className: userClassName,
|
|
20
|
+
children,
|
|
21
|
+
style,
|
|
22
|
+
name,
|
|
23
|
+
value // ...otherProps
|
|
24
|
+
|
|
25
|
+
}) => {
|
|
26
|
+
useLayoutEffect(() => {
|
|
27
|
+
import("./styles.scss");
|
|
28
|
+
}, []);
|
|
29
|
+
const [field, meta] = useField(name);
|
|
30
|
+
const isOptionSelected = field.value === value;
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
id: id,
|
|
33
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
34
|
+
style: style // {...otherProps}
|
|
35
|
+
|
|
36
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: `${isOptionSelected ? 'selected' : 'not-selected'} uc v1 pv-v`
|
|
38
|
+
}, /*#__PURE__*/React.createElement(FormLabel, {
|
|
39
|
+
name: name
|
|
40
|
+
}, /*#__PURE__*/React.createElement("input", _extends({}, field, {
|
|
41
|
+
id: name,
|
|
42
|
+
className: "input",
|
|
43
|
+
type: "radio",
|
|
44
|
+
value: value
|
|
45
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
46
|
+
className: "text"
|
|
47
|
+
}, children))), meta.error && meta.touched && /*#__PURE__*/React.createElement(FormDescription, {
|
|
48
|
+
error: true
|
|
49
|
+
}, meta.error));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
RadioInput.propTypes = {
|
|
53
|
+
/**
|
|
54
|
+
* The HTML id for this element
|
|
55
|
+
*/
|
|
56
|
+
id: PropTypes.string,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The HTML class names for this element
|
|
60
|
+
*/
|
|
61
|
+
className: PropTypes.string,
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The React-written, css properties for this element.
|
|
65
|
+
*/
|
|
66
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The children JSX
|
|
70
|
+
*/
|
|
71
|
+
children: PropTypes.node,
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The name of the radio input
|
|
75
|
+
*/
|
|
76
|
+
name: PropTypes.string,
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The value of the radio input
|
|
80
|
+
*/
|
|
81
|
+
value: PropTypes.string,
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The label of the radio input
|
|
85
|
+
*/
|
|
86
|
+
label: PropTypes.string
|
|
87
|
+
};
|
|
88
|
+
RadioInput.defaultProps = {// someProp:false
|
|
89
|
+
};
|
|
90
|
+
export default /*#__PURE__*/memo(RadioInput);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
@use "../../../form.scss";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
.#{bem.$base}.radio-input {
|
|
8
|
+
.input {
|
|
9
|
+
@include form.radio-checkbox-input;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.not-selected {
|
|
13
|
+
@include form.radio-checkbox-input-not-selected;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
.selected {
|
|
18
|
+
@include form.radio-checkbox-input-selected;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.text {
|
|
22
|
+
color: inherit;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
@@ -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
|
+
}
|