@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.
Files changed (256) hide show
  1. package/.env.scripts.example +4 -0
  2. package/.eslintrc.js +25 -1
  3. package/babel.config.js +1 -0
  4. package/dist/cjs/a/GradientBackground/GradientBackground.js +140 -0
  5. package/dist/cjs/a/GradientBackground/index.js +15 -0
  6. package/dist/cjs/a/GradientBackground/styles.scss +191 -0
  7. package/dist/cjs/a/Popover/Popover.js +134 -0
  8. package/dist/cjs/a/Popover/common/Divider/Divider.js +67 -0
  9. package/dist/cjs/a/Popover/common/Divider/index.js +15 -0
  10. package/dist/cjs/a/Popover/common/Item/Item.js +67 -0
  11. package/dist/cjs/a/Popover/common/Item/index.js +15 -0
  12. package/dist/cjs/a/Popover/common/index.js +21 -0
  13. package/dist/cjs/a/Popover/index.js +15 -0
  14. package/dist/cjs/a/Popover/styles.scss +33 -0
  15. package/dist/cjs/a/index.js +9 -1
  16. package/dist/cjs/c/AcceptCookies/AcceptCookies.js +134 -0
  17. package/dist/cjs/c/AcceptCookies/index.js +15 -0
  18. package/dist/cjs/c/AcceptCookies/styles.scss +49 -0
  19. package/dist/cjs/c/BlogCategoryButton/BlogCategoryButton.js +95 -0
  20. package/dist/cjs/c/BlogCategoryButton/index.js +15 -0
  21. package/dist/cjs/c/BlogContext/BlogContextProvider.js +63 -0
  22. package/dist/cjs/c/BlogContext/Context.js +16 -0
  23. package/dist/cjs/c/BlogContext/ContextProvider.js +63 -0
  24. package/dist/cjs/c/BlogContext/index.js +31 -0
  25. package/dist/cjs/c/BlogContext/useBlog.js +16 -0
  26. package/dist/cjs/c/BlogPost/BlogPost.js +147 -0
  27. package/dist/cjs/c/BlogPost/index.js +15 -0
  28. package/dist/cjs/c/BlogPost/styles.scss +33 -0
  29. package/dist/cjs/c/BlogPostsList/BlogPostsList.js +73 -0
  30. package/dist/cjs/c/BlogPostsList/common/Card/Card.js +170 -0
  31. package/dist/cjs/c/BlogPostsList/common/Card/index.js +15 -0
  32. package/dist/cjs/c/BlogPostsList/common/index.js +13 -0
  33. package/dist/cjs/c/BlogPostsList/index.js +15 -0
  34. package/dist/cjs/c/BlogPostsList/styles.scss +72 -0
  35. package/dist/cjs/c/SiteFooter/SiteFooter.js +73 -0
  36. package/dist/cjs/c/SiteFooter/common/Section/Section.js +95 -0
  37. package/dist/cjs/c/SiteFooter/common/Section/index.js +15 -0
  38. package/dist/cjs/c/SiteFooter/common/index.js +13 -0
  39. package/dist/cjs/c/SiteFooter/index.js +15 -0
  40. package/dist/cjs/c/SiteFooter/styles.scss +34 -0
  41. package/dist/cjs/c/SiteHeaderCTA/SiteHeaderCTA.js +108 -0
  42. package/dist/cjs/c/SiteHeaderCTA/index.js +15 -0
  43. package/dist/cjs/c/SiteHeaderCTA/styles.scss +44 -0
  44. package/dist/cjs/c/SiteMission/SiteMission.js +113 -0
  45. package/dist/cjs/c/SiteMission/index.js +15 -0
  46. package/dist/cjs/c/SiteMission/styles.scss +30 -0
  47. package/dist/cjs/c/SiteNavigation/SiteNavigation.js +130 -0
  48. package/dist/cjs/c/SiteNavigation/index.js +15 -0
  49. package/dist/cjs/c/SiteNavigation/styles.scss +118 -0
  50. package/dist/cjs/c/SiteOnboardingStep/SiteOnboardingStep.js +98 -0
  51. package/dist/cjs/c/SiteOnboardingStep/index.js +15 -0
  52. package/dist/cjs/c/SiteOnboardingStep/styles.scss +51 -0
  53. package/dist/cjs/c/SitePricing/SitePricing.js +108 -0
  54. package/dist/cjs/c/SitePricing/index.js +15 -0
  55. package/dist/cjs/c/SitePricing/styles.scss +73 -0
  56. package/dist/cjs/c/SiteServices/SiteServices.js +211 -0
  57. package/dist/cjs/c/SiteServices/index.js +15 -0
  58. package/dist/cjs/c/SiteServices/styles.scss +138 -0
  59. package/dist/cjs/c/TeamGallery/TeamGallery.js +80 -0
  60. package/dist/cjs/c/TeamGallery/common/PersonCard/PersonCard.js +84 -0
  61. package/dist/cjs/c/TeamGallery/common/PersonCard/index.js +15 -0
  62. package/dist/cjs/c/TeamGallery/common/index.js +13 -0
  63. package/dist/cjs/c/TeamGallery/index.js +15 -0
  64. package/dist/cjs/c/TeamGallery/styles.scss +100 -0
  65. package/dist/cjs/c/Testimonials/Testimonials.js +119 -0
  66. package/dist/cjs/c/Testimonials/index.js +15 -0
  67. package/dist/cjs/c/Testimonials/styles.scss +112 -0
  68. package/dist/cjs/experimental/GradientBackground/GradientBackground.js +98 -0
  69. package/dist/cjs/experimental/GradientBackground/index.js +15 -0
  70. package/dist/cjs/experimental/GradientBackground/styles.scss +64 -0
  71. package/dist/cjs/experimental/index.js +13 -0
  72. package/dist/cjs/f/FormInput/FormInput.js +5 -2
  73. package/dist/cjs/f/FormInput/styles.scss +11 -0
  74. package/dist/cjs/f/fields/CheckboxInput/CheckboxInput.js +105 -0
  75. package/dist/cjs/f/fields/CheckboxInput/index.js +15 -0
  76. package/dist/cjs/f/fields/CheckboxInput/styles.scss +28 -0
  77. package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +222 -0
  78. package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +148 -0
  79. package/dist/cjs/f/fields/QueryCombobox/common/Combobox/index.js +15 -0
  80. package/dist/cjs/f/fields/QueryCombobox/common/Menu/Menu.js +103 -0
  81. package/dist/cjs/f/fields/QueryCombobox/common/Menu/index.js +15 -0
  82. package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +229 -0
  83. package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/index.js +15 -0
  84. package/dist/cjs/f/fields/QueryCombobox/common/index.js +29 -0
  85. package/dist/cjs/f/fields/QueryCombobox/index.js +15 -0
  86. package/dist/cjs/f/fields/QueryCombobox/styles.scss +65 -0
  87. package/dist/cjs/f/fields/RadioInput/RadioInput.js +110 -0
  88. package/dist/cjs/f/fields/RadioInput/index.js +15 -0
  89. package/dist/cjs/f/fields/RadioInput/styles.scss +26 -0
  90. package/dist/cjs/f/fields/SelectInput/SelectInput.js +0 -1
  91. package/dist/cjs/f/fields/SelectInput/styles.scss +8 -6
  92. package/dist/cjs/f/fields/TaskRecommendation/TaskRecommendation.js +129 -0
  93. package/dist/cjs/f/fields/TaskRecommendation/index.js +15 -0
  94. package/dist/cjs/f/fields/TaskRecommendation/styles.scss +37 -0
  95. package/dist/cjs/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +131 -0
  96. package/dist/cjs/f/fields/TaskRecommendationInput/index.js +15 -0
  97. package/dist/cjs/f/fields/TaskRecommendationInput/styles.scss +41 -0
  98. package/dist/cjs/f/fields/TextArea/TextArea.js +141 -0
  99. package/dist/cjs/f/fields/TextArea/index.js +15 -0
  100. package/dist/cjs/f/fields/TextArea/styles.scss +19 -0
  101. package/dist/cjs/index.js +26 -0
  102. package/dist/cjs/test/QueryLoader/QueryLoader.js +41 -0
  103. package/dist/cjs/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +71 -0
  104. package/dist/cjs/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +49 -0
  105. package/dist/cjs/test/QueryLoader/common/PreloadedTestData/index.js +15 -0
  106. package/dist/cjs/test/QueryLoader/common/index.js +13 -0
  107. package/dist/cjs/test/QueryLoader/index.js +15 -0
  108. package/dist/cjs/test/QueryLoader/styles.scss +9 -0
  109. package/dist/cjs/test/index.js +13 -0
  110. package/dist/cjs/utils/hooks/index.js +23 -0
  111. package/dist/cjs/utils/hooks/useDynamicPosition.js +107 -0
  112. package/dist/cjs/utils/hooks/useWindowSize.js +39 -0
  113. package/dist/cjs/utils/index.js +19 -0
  114. package/dist/es/a/GradientBackground/GradientBackground.js +118 -0
  115. package/dist/es/a/GradientBackground/index.js +2 -0
  116. package/dist/es/a/GradientBackground/styles.scss +191 -0
  117. package/dist/es/a/Popover/Popover.js +118 -0
  118. package/dist/es/a/Popover/common/Divider/Divider.js +47 -0
  119. package/dist/es/a/Popover/common/Divider/index.js +2 -0
  120. package/dist/es/a/Popover/common/Item/Item.js +47 -0
  121. package/dist/es/a/Popover/common/Item/index.js +2 -0
  122. package/dist/es/a/Popover/common/index.js +2 -0
  123. package/dist/es/a/Popover/index.js +2 -0
  124. package/dist/es/a/Popover/styles.scss +33 -0
  125. package/dist/es/a/index.js +2 -1
  126. package/dist/es/c/AcceptCookies/AcceptCookies.js +117 -0
  127. package/dist/es/c/AcceptCookies/index.js +2 -0
  128. package/dist/es/c/AcceptCookies/styles.scss +49 -0
  129. package/dist/es/c/BlogCategoryButton/BlogCategoryButton.js +68 -0
  130. package/dist/es/c/BlogCategoryButton/index.js +2 -0
  131. package/dist/es/c/BlogContext/BlogContextProvider.js +45 -0
  132. package/dist/es/c/BlogContext/Context.js +2 -0
  133. package/dist/es/c/BlogContext/ContextProvider.js +45 -0
  134. package/dist/es/c/BlogContext/index.js +4 -0
  135. package/dist/es/c/BlogContext/useBlog.js +3 -0
  136. package/dist/es/c/BlogPost/BlogPost.js +128 -0
  137. package/dist/es/c/BlogPost/index.js +2 -0
  138. package/dist/es/c/BlogPost/styles.scss +33 -0
  139. package/dist/es/c/BlogPostsList/BlogPostsList.js +56 -0
  140. package/dist/es/c/BlogPostsList/common/Card/Card.js +143 -0
  141. package/dist/es/c/BlogPostsList/common/Card/index.js +2 -0
  142. package/dist/es/c/BlogPostsList/common/index.js +1 -0
  143. package/dist/es/c/BlogPostsList/index.js +2 -0
  144. package/dist/es/c/BlogPostsList/styles.scss +72 -0
  145. package/dist/es/c/SiteFooter/SiteFooter.js +56 -0
  146. package/dist/es/c/SiteFooter/common/Section/Section.js +73 -0
  147. package/dist/es/c/SiteFooter/common/Section/index.js +2 -0
  148. package/dist/es/c/SiteFooter/common/index.js +1 -0
  149. package/dist/es/c/SiteFooter/index.js +2 -0
  150. package/dist/es/c/SiteFooter/styles.scss +34 -0
  151. package/dist/es/c/SiteHeaderCTA/SiteHeaderCTA.js +92 -0
  152. package/dist/es/c/SiteHeaderCTA/index.js +2 -0
  153. package/dist/es/c/SiteHeaderCTA/styles.scss +44 -0
  154. package/dist/es/c/SiteMission/SiteMission.js +96 -0
  155. package/dist/es/c/SiteMission/index.js +2 -0
  156. package/dist/es/c/SiteMission/styles.scss +30 -0
  157. package/dist/es/c/SiteNavigation/SiteNavigation.js +111 -0
  158. package/dist/es/c/SiteNavigation/index.js +2 -0
  159. package/dist/es/c/SiteNavigation/styles.scss +118 -0
  160. package/dist/es/c/SiteOnboardingStep/SiteOnboardingStep.js +81 -0
  161. package/dist/es/c/SiteOnboardingStep/index.js +2 -0
  162. package/dist/es/c/SiteOnboardingStep/styles.scss +51 -0
  163. package/dist/es/c/SitePricing/SitePricing.js +91 -0
  164. package/dist/es/c/SitePricing/index.js +2 -0
  165. package/dist/es/c/SitePricing/styles.scss +73 -0
  166. package/dist/es/c/SiteServices/SiteServices.js +195 -0
  167. package/dist/es/c/SiteServices/index.js +2 -0
  168. package/dist/es/c/SiteServices/styles.scss +138 -0
  169. package/dist/es/c/TeamGallery/TeamGallery.js +64 -0
  170. package/dist/es/c/TeamGallery/common/PersonCard/PersonCard.js +64 -0
  171. package/dist/es/c/TeamGallery/common/PersonCard/index.js +2 -0
  172. package/dist/es/c/TeamGallery/common/index.js +1 -0
  173. package/dist/es/c/TeamGallery/index.js +2 -0
  174. package/dist/es/c/TeamGallery/styles.scss +100 -0
  175. package/dist/es/c/Testimonials/Testimonials.js +99 -0
  176. package/dist/es/c/Testimonials/index.js +2 -0
  177. package/dist/es/c/Testimonials/styles.scss +112 -0
  178. package/dist/es/experimental/GradientBackground/GradientBackground.js +76 -0
  179. package/dist/es/experimental/GradientBackground/index.js +2 -0
  180. package/dist/es/experimental/GradientBackground/styles.scss +64 -0
  181. package/dist/es/experimental/index.js +1 -0
  182. package/dist/es/f/FormInput/FormInput.js +4 -1
  183. package/dist/es/f/FormInput/styles.scss +11 -0
  184. package/dist/es/f/fields/CheckboxInput/CheckboxInput.js +85 -0
  185. package/dist/es/f/fields/CheckboxInput/index.js +2 -0
  186. package/dist/es/f/fields/CheckboxInput/styles.scss +28 -0
  187. package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +197 -0
  188. package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +129 -0
  189. package/dist/es/f/fields/QueryCombobox/common/Combobox/index.js +2 -0
  190. package/dist/es/f/fields/QueryCombobox/common/Menu/Menu.js +77 -0
  191. package/dist/es/f/fields/QueryCombobox/common/Menu/index.js +2 -0
  192. package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +202 -0
  193. package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/index.js +2 -0
  194. package/dist/es/f/fields/QueryCombobox/common/index.js +3 -0
  195. package/dist/es/f/fields/QueryCombobox/index.js +2 -0
  196. package/dist/es/f/fields/QueryCombobox/styles.scss +65 -0
  197. package/dist/es/f/fields/RadioInput/RadioInput.js +90 -0
  198. package/dist/es/f/fields/RadioInput/index.js +2 -0
  199. package/dist/es/f/fields/RadioInput/styles.scss +26 -0
  200. package/dist/es/f/fields/SelectInput/SelectInput.js +0 -1
  201. package/dist/es/f/fields/SelectInput/styles.scss +8 -6
  202. package/dist/es/f/fields/TaskRecommendation/TaskRecommendation.js +111 -0
  203. package/dist/es/f/fields/TaskRecommendation/index.js +2 -0
  204. package/dist/es/f/fields/TaskRecommendation/styles.scss +37 -0
  205. package/dist/es/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +111 -0
  206. package/dist/es/f/fields/TaskRecommendationInput/index.js +2 -0
  207. package/dist/es/f/fields/TaskRecommendationInput/styles.scss +41 -0
  208. package/dist/es/f/fields/TextArea/TextArea.js +124 -0
  209. package/dist/es/f/fields/TextArea/index.js +2 -0
  210. package/dist/es/f/fields/TextArea/styles.scss +19 -0
  211. package/dist/es/index.js +3 -1
  212. package/dist/es/test/QueryLoader/QueryLoader.js +29 -0
  213. package/dist/es/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +71 -0
  214. package/dist/es/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +31 -0
  215. package/dist/es/test/QueryLoader/common/PreloadedTestData/index.js +2 -0
  216. package/dist/es/test/QueryLoader/common/index.js +1 -0
  217. package/dist/es/test/QueryLoader/index.js +2 -0
  218. package/dist/es/test/QueryLoader/styles.scss +9 -0
  219. package/dist/es/test/index.js +1 -0
  220. package/dist/es/utils/hooks/index.js +2 -0
  221. package/dist/es/utils/hooks/useDynamicPosition.js +93 -0
  222. package/dist/es/utils/hooks/useWindowSize.js +27 -0
  223. package/dist/es/utils/index.js +1 -0
  224. package/package.json +14 -2
  225. package/relay.config.js +12 -0
  226. package/schema.graphql +4075 -0
  227. package/scripts/fetchSchema.js +74 -0
  228. package/src/__snapshots__/Storyshots.test.js.snap +422 -8
  229. package/src/stories/a/Popover.stories.jsx +106 -0
  230. package/src/stories/test/QueryLoader.stories.jsx +36 -0
  231. package/src/stories/utils/lorem.js +15 -0
  232. package/src/stories/utils/relay/EnvironmentProvider.jsx +14 -0
  233. package/src/stories/utils/relay/environment.js +5 -0
  234. package/src/stories/utils/relay/index.js +4 -0
  235. package/src/stories/utils/relay/mockRelayOperation.js +14 -0
  236. package/src/stories/utils/relay/mockResolvers.js +299 -0
  237. package/src/ui/a/Popover/Popover.jsx +157 -0
  238. package/src/ui/a/Popover/index.js +2 -0
  239. package/src/ui/a/Popover/styles.scss +33 -0
  240. package/src/ui/a/index.js +1 -0
  241. package/src/ui/f/FormInput/FormInput.jsx +5 -1
  242. package/src/ui/f/FormInput/styles.scss +11 -0
  243. package/src/ui/f/fields/SelectInput/SelectInput.jsx +1 -1
  244. package/src/ui/f/fields/SelectInput/styles.scss +8 -6
  245. package/src/ui/index.js +2 -0
  246. package/src/ui/test/QueryLoader/QueryLoader.jsx +41 -0
  247. package/src/ui/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +68 -0
  248. package/src/ui/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.jsx +51 -0
  249. package/src/ui/test/QueryLoader/common/PreloadedTestData/index.js +2 -0
  250. package/src/ui/test/QueryLoader/common/index.js +1 -0
  251. package/src/ui/test/QueryLoader/index.js +2 -0
  252. package/src/ui/test/index.js +1 -0
  253. package/src/ui/utils/hooks/index.js +2 -0
  254. package/src/ui/utils/hooks/useDynamicPosition.js +104 -0
  255. package/src/ui/utils/hooks/useWindowSize.js +32 -0
  256. 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,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as Combobox } from "./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,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as Menu } from "./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,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as MultipleCombobox } from "./MultipleCombobox";
@@ -0,0 +1,3 @@
1
+ export { Menu } from "./Menu";
2
+ export { Combobox } from "./Combobox";
3
+ export { MultipleCombobox } from "./MultipleCombobox";
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as QueryCombobox } from "./QueryCombobox";
@@ -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,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as RadioInput } from "./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
+
@@ -40,7 +40,6 @@ const SelectInput = ({
40
40
  style: style // {...otherProps}
41
41
 
42
42
  }, /*#__PURE__*/React.createElement(FormLabel, {
43
- className: "input-label",
44
43
  name: name
45
44
  }, label), /*#__PURE__*/React.createElement("select", _extends({
46
45
  className: "input"
@@ -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
- &:not(:disabled):hover{
25
+ &:not(:disabled):hover {
23
26
  border: var(--theme-border-style) var(--light-background4);
24
27
  }
25
28
 
26
- &:disabled {
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
+ }