@pareto-engineering/design-system 4.0.0-alpha.73 → 4.0.0-alpha.75

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 (46) hide show
  1. package/dist/cjs/a/DatePicker/DatePicker.js +162 -0
  2. package/dist/cjs/a/DatePicker/index.js +13 -0
  3. package/dist/cjs/a/DatePicker/styles.scss +380 -0
  4. package/dist/cjs/a/XMLEditor/XMLEditor.js +5 -0
  5. package/dist/cjs/a/index.js +8 -1
  6. package/dist/cjs/f/fields/SelectInput/SelectInput.js +33 -42
  7. package/dist/cjs/f/fields/SelectInput/common/Menu/Menu.js +83 -0
  8. package/dist/cjs/f/fields/SelectInput/common/Menu/index.js +13 -0
  9. package/dist/cjs/f/fields/SelectInput/common/Multiple/Multiple.js +244 -0
  10. package/dist/cjs/f/fields/SelectInput/common/Multiple/index.js +13 -0
  11. package/dist/cjs/f/fields/SelectInput/common/Single/Single.js +104 -0
  12. package/dist/cjs/f/fields/SelectInput/common/Single/index.js +13 -0
  13. package/dist/cjs/f/fields/SelectInput/common/index.js +26 -0
  14. package/dist/cjs/f/fields/SelectInput/styles.scss +149 -45
  15. package/dist/es/a/DatePicker/DatePicker.js +154 -0
  16. package/dist/es/a/DatePicker/index.js +2 -0
  17. package/dist/es/a/DatePicker/styles.scss +380 -0
  18. package/dist/es/a/XMLEditor/XMLEditor.js +5 -0
  19. package/dist/es/a/index.js +2 -1
  20. package/dist/es/f/fields/SelectInput/SelectInput.js +31 -42
  21. package/dist/es/f/fields/SelectInput/common/Menu/Menu.js +73 -0
  22. package/dist/es/f/fields/SelectInput/common/Menu/index.js +2 -0
  23. package/dist/es/f/fields/SelectInput/common/Multiple/Multiple.js +235 -0
  24. package/dist/es/f/fields/SelectInput/common/Multiple/index.js +2 -0
  25. package/dist/es/f/fields/SelectInput/common/Single/Single.js +96 -0
  26. package/dist/es/f/fields/SelectInput/common/Single/index.js +2 -0
  27. package/dist/es/f/fields/SelectInput/common/index.js +3 -0
  28. package/dist/es/f/fields/SelectInput/styles.scss +149 -45
  29. package/package.json +3 -2
  30. package/src/stories/a/DatePicker.stories.jsx +88 -0
  31. package/src/stories/f/SelectInput.stories.jsx +15 -0
  32. package/src/ui/a/DatePicker/DatePicker.jsx +201 -0
  33. package/src/ui/a/DatePicker/index.js +2 -0
  34. package/src/ui/a/DatePicker/styles.scss +380 -0
  35. package/src/ui/a/XMLEditor/XMLEditor.jsx +6 -0
  36. package/src/ui/a/index.js +1 -0
  37. package/src/ui/f/fields/SelectInput/SelectInput.jsx +34 -47
  38. package/src/ui/f/fields/SelectInput/common/Menu/Menu.jsx +103 -0
  39. package/src/ui/f/fields/SelectInput/common/Menu/index.js +2 -0
  40. package/src/ui/f/fields/SelectInput/common/Multiple/Multiple.jsx +288 -0
  41. package/src/ui/f/fields/SelectInput/common/Multiple/index.js +2 -0
  42. package/src/ui/f/fields/SelectInput/common/Single/Single.jsx +125 -0
  43. package/src/ui/f/fields/SelectInput/common/Single/index.js +2 -0
  44. package/src/ui/f/fields/SelectInput/common/index.js +3 -0
  45. package/src/ui/f/fields/SelectInput/styles.scss +149 -45
  46. package/tests/__snapshots__/Storyshots.test.js.snap +7559 -398
@@ -0,0 +1,235 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ /* @pareto-engineering/generator-front 1.0.12 */
3
+ import * as React from 'react';
4
+ import { useState, useEffect, useMemo, useRef } from 'react';
5
+ import { useField } from 'formik';
6
+ import PropTypes from 'prop-types';
7
+ import { useCombobox, useMultipleSelection } from 'downshift';
8
+ import styleNames from '@pareto-engineering/bem/exports';
9
+ import { Button } from "../../../../../b";
10
+ import { Popover } from "../../../../../a";
11
+ import { FormDescription, FormLabel } from "../../../..";
12
+ import { Menu } from "../Menu";
13
+
14
+ // Local Definitions
15
+
16
+ const baseClassName = styleNames.base;
17
+ const componentClassName = 'multiple';
18
+
19
+ /**
20
+ * @param {Array[Object]} first - first array to check if it has an item not in the second array.
21
+ * @param {Array[Object]} second - second array to check against the first array.
22
+ *
23
+ * @returns {Boolean} - true if the first array has an item not in the second array.
24
+ */
25
+ const testIfArraysAreUnique = (first, second) => first.filter(objInFirstArray => !second.some(objInSecondArray => objInFirstArray.value === objInSecondArray.value)).length > 0;
26
+
27
+ /**
28
+ * This is the component description.
29
+ */
30
+ const Multiple = ({
31
+ id,
32
+ className: userClassName,
33
+ style,
34
+ name,
35
+ label,
36
+ labelColor,
37
+ color,
38
+ options,
39
+ validate,
40
+ optional,
41
+ description,
42
+ disabled,
43
+ autoComplete,
44
+ transformSearch,
45
+ getTagColor,
46
+ placeholder
47
+ // ...otherProps
48
+ }) => {
49
+ const [, meta, helpers] = useField({
50
+ name,
51
+ validate
52
+ });
53
+ const {
54
+ setValue
55
+ } = helpers;
56
+ const {
57
+ value
58
+ } = meta;
59
+ const [searchInputValue, setSearchInputValue] = useState('');
60
+ const {
61
+ getSelectedItemProps,
62
+ getDropdownProps,
63
+ addSelectedItem,
64
+ removeSelectedItem,
65
+ setSelectedItems,
66
+ selectedItems
67
+ } = useMultipleSelection({
68
+ initialSelectedItems: value || []
69
+ });
70
+
71
+ /**
72
+ * @returns {Boolean} - Unique items from the options array so that the combobox
73
+ * shows only the options that are not yet selected.
74
+ */
75
+
76
+ const items = useMemo(() => {
77
+ const lowerCasedInputValue = searchInputValue.toLowerCase();
78
+ return options.filter(option => {
79
+ const lowerCasedOption = option.label.toLowerCase();
80
+ return lowerCasedOption.includes(lowerCasedInputValue) && !selectedItems.includes(option);
81
+ });
82
+ }, [searchInputValue, selectedItems]);
83
+ const {
84
+ isOpen,
85
+ getLabelProps,
86
+ getMenuProps,
87
+ getInputProps,
88
+ getComboboxProps,
89
+ highlightedIndex,
90
+ getItemProps
91
+ } = useCombobox({
92
+ inputValue: searchInputValue,
93
+ defaultHighlightedIndex: 0,
94
+ // after selection, highlight the first item.
95
+ selectedItem: null,
96
+ items,
97
+ circularNavigation: true,
98
+ stateReducer: (state, actionAndChanges) => {
99
+ const {
100
+ changes,
101
+ type
102
+ } = actionAndChanges;
103
+ switch (type) {
104
+ case useCombobox.stateChangeTypes.InputKeyDownEnter:
105
+ case useCombobox.stateChangeTypes.ItemClick:
106
+ return {
107
+ ...changes,
108
+ isOpen: true // keep the menu open after selection.
109
+ };
110
+ default:
111
+ break;
112
+ }
113
+ return changes;
114
+ },
115
+ onStateChange: ({
116
+ inputValue: newSearchInputValue,
117
+ type,
118
+ selectedItem
119
+ }) => {
120
+ switch (type) {
121
+ case useCombobox.stateChangeTypes.InputChange:
122
+ {
123
+ const transformedInput = transformSearch(newSearchInputValue);
124
+ setSearchInputValue(transformedInput);
125
+ break;
126
+ }
127
+ case useCombobox.stateChangeTypes.InputKeyDownEnter:
128
+ case useCombobox.stateChangeTypes.ItemClick:
129
+ case useCombobox.stateChangeTypes.InputBlur:
130
+ if (selectedItem) {
131
+ setSearchInputValue('');
132
+ addSelectedItem(selectedItem);
133
+ }
134
+ break;
135
+ default:
136
+ break;
137
+ }
138
+ }
139
+ });
140
+ useEffect(() => {
141
+ if (selectedItems?.length > 0) {
142
+ setValue(selectedItems);
143
+ }
144
+ }, [selectedItems]);
145
+ useEffect(() => {
146
+ if (value?.length > 0 && (testIfArraysAreUnique(value, selectedItems) || testIfArraysAreUnique(selectedItems, value))) {
147
+ setSelectedItems(value);
148
+ }
149
+ }, [value]);
150
+ const parentRef = useRef(null);
151
+ return /*#__PURE__*/React.createElement("div", _extends({
152
+ id: id,
153
+ className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
154
+ style: style,
155
+ ref: parentRef
156
+ }, getComboboxProps()), /*#__PURE__*/React.createElement(FormLabel, _extends({
157
+ className: [baseClassName, componentClassName].filter(e => e).join(' ')
158
+ }, getLabelProps(), {
159
+ name: name,
160
+ optional: optional,
161
+ color: labelColor
162
+ }), label), selectedItems?.length > 0 && /*#__PURE__*/React.createElement("div", {
163
+ className: "selected-items"
164
+ }, selectedItems.map((selectedItem, index) => /*#__PURE__*/React.createElement("div", _extends({
165
+ key: selectedItem.label
166
+ }, getSelectedItemProps({
167
+ selectedItem,
168
+ index
169
+ }), {
170
+ className: "item"
171
+ }), /*#__PURE__*/React.createElement(Button, {
172
+ onClick: e => {
173
+ e.stopPropagation();
174
+ removeSelectedItem(selectedItem);
175
+ },
176
+ isCompact: true,
177
+ color: getTagColor ? getTagColor(selectedItem) : color
178
+ }, /*#__PURE__*/React.createElement("span", null, selectedItem.label), /*#__PURE__*/React.createElement("span", {
179
+ className: "icon close"
180
+ }, "Y"))))), /*#__PURE__*/React.createElement("div", {
181
+ className: "input-container"
182
+ }, /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(getDropdownProps({
183
+ preventKeyAction: isOpen
184
+ })), {
185
+ className: "input",
186
+ disabled: disabled,
187
+ placeholder: placeholder,
188
+ autoComplete: autoComplete
189
+ }))), /*#__PURE__*/React.createElement(FormDescription, {
190
+ className: "s-1",
191
+ description: description,
192
+ name: name
193
+ }), /*#__PURE__*/React.createElement(Popover, {
194
+ isOpen: isOpen,
195
+ parentRef: parentRef
196
+ }, /*#__PURE__*/React.createElement(Menu, _extends({
197
+ className: `y-${color}`,
198
+ isOpen: isOpen,
199
+ getItemProps: getItemProps,
200
+ highlightedIndex: highlightedIndex,
201
+ items: items
202
+ }, getMenuProps()))));
203
+ };
204
+ Multiple.propTypes = {
205
+ /**
206
+ * The HTML id for this element
207
+ */
208
+ id: PropTypes.string,
209
+ /**
210
+ * The HTML class names for this element
211
+ */
212
+ className: PropTypes.string,
213
+ /**
214
+ * The React-written, css properties for this element.
215
+ */
216
+ style: PropTypes.objectOf(PropTypes.string),
217
+ /**
218
+ * A function that transforms the search input value
219
+ */
220
+ transformSearch: PropTypes.func,
221
+ /**
222
+ * The minimum length of the search input value
223
+ */
224
+ minLength: PropTypes.number,
225
+ /**
226
+ * The base color of the component
227
+ */
228
+ color: PropTypes.string
229
+ };
230
+ Multiple.defaultProps = {
231
+ transformSearch: e => e,
232
+ minLength: 2,
233
+ color: 'interactive'
234
+ };
235
+ export default Multiple;
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as Multiple } from "./Multiple";
@@ -0,0 +1,96 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ /* @pareto-engineering/generator-front 1.0.12 */
3
+ import * as React from 'react';
4
+ import { useField } from 'formik';
5
+ import PropTypes from 'prop-types';
6
+ import styleNames from '@pareto-engineering/bem/exports';
7
+ import { LoadingCircle } from "../../../../../a";
8
+ import { FormLabel, FormDescription } from "../../../..";
9
+
10
+ // Local Definitions
11
+
12
+ const baseClassName = styleNames.base;
13
+ const componentClassName = 'single';
14
+
15
+ /**
16
+ * This is the component description.
17
+ */
18
+ const Single = ({
19
+ id,
20
+ className: userClassName,
21
+ style,
22
+ name,
23
+ label,
24
+ labelColor,
25
+ color,
26
+ options,
27
+ validate,
28
+ optional,
29
+ description,
30
+ disabled,
31
+ isLoading,
32
+ autoComplete
33
+ // ...otherProps
34
+ }) => {
35
+ const [field] = useField({
36
+ name,
37
+ validate
38
+ });
39
+ return /*#__PURE__*/React.createElement("div", {
40
+ id: id,
41
+ className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
42
+ style: style
43
+ }, /*#__PURE__*/React.createElement(FormLabel, {
44
+ name: name,
45
+ color: labelColor,
46
+ optional: optional
47
+ }, label), /*#__PURE__*/React.createElement("div", {
48
+ className: `select-wrapper${disabled ? ' disabled' : ''}`
49
+ }, /*#__PURE__*/React.createElement("select", _extends({
50
+ className: `input y-${color}`
51
+ }, field, {
52
+ value: field.value || '',
53
+ id: name,
54
+ disabled: disabled,
55
+ autoComplete: autoComplete
56
+ }), options.map(option => {
57
+ // i.e if option is a string like "blah", return { value: "blah", label: "blah" }
58
+ const newOption = typeof option === 'string' ? {
59
+ value: option,
60
+ label: option
61
+ } : option;
62
+ return /*#__PURE__*/React.createElement("option", {
63
+ key: newOption.value,
64
+ value: newOption.value,
65
+ disabled: newOption?.disabled || false
66
+ }, newOption.label);
67
+ })), isLoading && /*#__PURE__*/React.createElement(LoadingCircle, {
68
+ className: "x-main"
69
+ })), /*#__PURE__*/React.createElement(FormDescription, {
70
+ className: "s-1",
71
+ description: description,
72
+ name: name
73
+ }));
74
+ };
75
+ Single.propTypes = {
76
+ /**
77
+ * The HTML id for this element
78
+ */
79
+ id: PropTypes.string,
80
+ /**
81
+ * The HTML class names for this element
82
+ */
83
+ className: PropTypes.string,
84
+ /**
85
+ * The React-written, css properties for this element.
86
+ */
87
+ style: PropTypes.objectOf(PropTypes.string),
88
+ /**
89
+ * The base color of the component
90
+ */
91
+ color: PropTypes.string
92
+ };
93
+ Single.defaultProps = {
94
+ color: 'paragraph'
95
+ };
96
+ export default Single;
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as Single } from "./Single";
@@ -0,0 +1,3 @@
1
+ export { Multiple } from "./Multiple";
2
+ export { Single } from "./Single";
3
+ export { Menu } from "./Menu";
@@ -14,72 +14,176 @@ $hover-border: var(--theme-hover-input-border);
14
14
  $focus-border: var(--theme-focus-input-border);
15
15
  $default-background: var(--background-inputs);
16
16
  $disabled-background: var(--background-inputs-30);
17
+ $default-gap: var(--gap);
17
18
 
18
- .#{bem.$base}.select-input {
19
- display: flex;
20
- flex-direction: column;
21
-
22
- > .#{bem.$base}.form-label {
23
- margin-bottom: var(--gap);
24
- }
25
19
 
26
- .select-wrapper {
27
- background-color: $default-background;
28
- border: $default-border;
29
- border-radius: $default-input-border-radius;
20
+ .#{bem.$base}.select-input {
21
+ > .#{bem.$base}.single {
30
22
  display: flex;
31
23
  flex-direction: column;
32
- padding: $default-padding;
33
- padding-right: 0;
34
- position: relative;
35
24
 
36
- &:not(.disabled) {
37
- &:hover,
38
- &:active {
39
- border: $hover-border;
25
+ > .#{bem.$base}.form-label {
26
+ margin-bottom: var(--gap);
27
+ }
28
+
29
+ .select-wrapper {
30
+ background-color: $default-background;
31
+ border: $default-border;
32
+ border-radius: $default-input-border-radius;
33
+ display: flex;
34
+ flex-direction: column;
35
+ padding: $default-padding;
36
+ padding-right: 0;
37
+ position: relative;
38
+
39
+ &:not(.disabled) {
40
+ &:hover,
41
+ &:active {
42
+ border: $hover-border;
43
+ }
44
+
45
+ &:focus {
46
+ border: $focus-border;
47
+ }
40
48
  }
41
49
 
42
- &:focus {
43
- border: $focus-border;
50
+ &.disabled {
51
+ background: $disabled-background;
44
52
  }
45
- }
46
53
 
47
- &.disabled {
48
- background: $disabled-background;
54
+ &::placeholder {
55
+ color: var(--metadata);
56
+ }
57
+
58
+ &::after {
59
+ border-radius: $default-input-border-radius;
60
+ }
61
+
62
+ >.#{bem.$base}.loading-circle {
63
+ position: absolute;
64
+ right: $default-spacing-size;
65
+ top: 50%;
66
+ transform: translateY(-50%);
67
+ }
68
+
69
+ select {
70
+ appearance: none;
71
+ background-color: $default-background;
72
+ background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAyMCAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE5IDEuNUwxMCAxMC41TDEgMS41IiBzdHJva2U9IiM0QzRENTMiIHN0cm9rZS13aWR0aD0iMiIvPgo8L3N2Zz4=");
73
+ background-position: calc(100% - $default-spacing-size);
74
+ background-repeat: no-repeat;
75
+ background-size: $default-spacing-size;
76
+ padding-right: $default-spacing-size;
77
+
78
+ &.input {
79
+ border: none;
80
+ color: var(--y);
81
+ outline: none;
82
+ width: 100%;
83
+
84
+ /* stylelint-disable-next-line max-nesting-depth -- required */
85
+ &:disabled {
86
+ opacity: 0%;
87
+ }
88
+ }
89
+ }
49
90
  }
91
+ }
50
92
 
51
- &::placeholder {
52
- color: var(--metadata);
93
+ > .#{bem.$base}.multiple {
94
+ display: flex;
95
+ flex-direction: column;
96
+ outline: none;
97
+ position: relative;
98
+
99
+ > .#{bem.$base}.form-label {
100
+ margin-bottom: var(--gap);
53
101
  }
54
102
 
55
- &::after {
103
+
104
+ .#{bem.$base}.popover {
105
+ border: $default-border;
56
106
  border-radius: $default-input-border-radius;
57
- }
107
+ width: 100%;
108
+
109
+ >.menu {
110
+ list-style: none;
111
+ margin: 0;
112
+ outline: 0;
113
+ padding: 0;
114
+
115
+ /* stylelint-disable selector-max-compound-selectors -- required */
116
+ >.item {
117
+ border-radius: $default-input-border-radius;
118
+ padding: $default-padding;
119
+
120
+ /* stylelint-disable max-nesting-depth -- required */
121
+ > p {
122
+ margin: 0;
123
+ }
58
124
 
59
- >.#{bem.$base}.loading-circle {
60
- position: absolute;
61
- right: $default-spacing-size;
62
- top: 50%;
63
- transform: translateY(-50%);
125
+ &.#{bem.$modifier-active} {
126
+ background-color: var(--y);
127
+
128
+ > p {
129
+ color: var(--on-y);
130
+ }
131
+ }
132
+ }
133
+ }
64
134
  }
65
135
 
66
- select {
67
- appearance: none;
68
- background-color: $default-background;
69
- background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAyMCAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE5IDEuNUwxMCAxMC41TDEgMS41IiBzdHJva2U9IiM0QzRENTMiIHN0cm9rZS13aWR0aD0iMiIvPgo8L3N2Zz4=");
70
- background-position: calc(100% - $default-spacing-size);
71
- background-repeat: no-repeat;
72
- background-size: $default-spacing-size;
73
- padding-right: $default-spacing-size;
74
-
75
- &.input {
76
- border: none;
77
- color: var(--y);
136
+
137
+ > .input-container {
138
+ position: relative;
139
+
140
+ > .input {
141
+ background: $default-background;
142
+ border: $default-border;
143
+ border-radius: calc(var(--theme-default-border-radius) / 2);
144
+ color: var(--paragraph);
78
145
  outline: none;
146
+ padding: $default-padding;
79
147
  width: 100%;
80
148
 
149
+ &::placeholder {
150
+ color: var(--metadata);
151
+ }
152
+
81
153
  &:disabled {
82
- opacity: 0%;
154
+ background-color: $disabled-background;
155
+ color: var(--paragraph);
156
+ }
157
+
158
+ &:not(:disabled) {
159
+ &:hover,
160
+ &:active {
161
+ border: $hover-border;
162
+ }
163
+
164
+ &:focus {
165
+ border: $focus-border;
166
+ }
167
+ }
168
+ }
169
+ }
170
+
171
+
172
+ >.selected-items {
173
+ display: flex;
174
+ flex-wrap: wrap;
175
+ gap: calc($default-gap / 2);
176
+ margin-bottom: calc($default-gap / 2);
177
+
178
+ >.item {
179
+ >.#{bem.$base}.button {
180
+ align-items: center;
181
+ display: flex;
182
+ gap: calc($default-gap / 2);
183
+ }
184
+
185
+ .close {
186
+ font-size: calc(var(--s-3) * 1em);
83
187
  }
84
188
  }
85
189
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "4.0.0-alpha.73",
3
+ "version": "4.0.0-alpha.75",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -66,6 +66,7 @@
66
66
  "lodash": "^4.17.21",
67
67
  "prop-types": "^15.8.1",
68
68
  "react": "^18.2.0",
69
+ "react-day-picker": "^8.10.0",
69
70
  "react-dom": "^18.2.0",
70
71
  "react-helmet-async": "^1.3.0",
71
72
  "react-relay": "^15.0.0",
@@ -73,5 +74,5 @@
73
74
  "relay-test-utils": "^15.0.0"
74
75
  },
75
76
  "browserslist": "> 2%",
76
- "gitHead": "d2ee57be69cd58cf2bcfbba3d225b8e7fad7e37b"
77
+ "gitHead": "7a62860757dd5b5253f8881913e18c5ab8aa8687"
77
78
  }
@@ -0,0 +1,88 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import { useState } from 'react'
5
+
6
+ import { DatePicker } from 'ui'
7
+
8
+ export default {
9
+ title :'a/DatePicker',
10
+ component :DatePicker,
11
+ decorators:[
12
+ // storyfn => <div className="">{ storyfn() }</div>,
13
+ ],
14
+ argTypes:{
15
+ mode:{
16
+ control:{
17
+ type :'select',
18
+ options:['single', 'multiple', 'range'],
19
+ },
20
+ },
21
+ dateFormat:{
22
+ control:{
23
+ type:'text',
24
+ },
25
+ },
26
+ showDebugger:{
27
+ control:{
28
+ type:'boolean',
29
+ },
30
+ },
31
+ },
32
+ }
33
+
34
+ const Template = (args) => {
35
+ const [value, setValue] = useState()
36
+
37
+ return (
38
+ <DatePicker selected={value} setSelection={setValue} {...args} />
39
+ )
40
+ }
41
+
42
+ const TimeTemplate = ({ timeMode, ...args }) => {
43
+ const [value, setValue] = useState()
44
+ const [timeFrom, setTimeFrom] = useState('00:00')
45
+ const [timeTo, setTimeTo] = useState('23:59')
46
+
47
+ return (
48
+ <DatePicker
49
+ selected={value}
50
+ setSelection={setValue}
51
+ timeFrom={timeFrom}
52
+ setTimeFrom={setTimeFrom}
53
+ timeTo={timeMode === 'multiple' ? timeTo : undefined}
54
+ setTimeTo={timeMode === 'multiple' ? setTimeTo : undefined}
55
+ {...args}
56
+ />
57
+ )
58
+ }
59
+
60
+ export const Base = Template.bind({})
61
+ Base.args = {}
62
+
63
+ export const MultipleSelection = Template.bind({})
64
+ MultipleSelection.args = {
65
+ mode:'multiple',
66
+ }
67
+
68
+ export const RangeSelection = Template.bind({})
69
+ RangeSelection.args = {
70
+ mode:'range',
71
+ }
72
+
73
+ export const TimeSelection = TimeTemplate.bind({})
74
+ TimeSelection.args = {
75
+ mode :'single',
76
+ timeMode:'single',
77
+ }
78
+
79
+ export const TimeRangeSelection = TimeTemplate.bind({})
80
+ TimeRangeSelection.args = {
81
+ mode :'range',
82
+ timeMode:'multiple',
83
+ }
84
+
85
+ export const WithCustomFooter = Template.bind({})
86
+ WithCustomFooter.args = {
87
+ customFooter:<div>Custom footer</div>,
88
+ }
@@ -93,3 +93,18 @@ DisabledWithDescriptionSelectInput.args = {
93
93
  disabled :true,
94
94
  description:'This is a description',
95
95
  }
96
+
97
+ export const Multiple = Template.bind({})
98
+ Multiple.args = {
99
+ name :'status',
100
+ label :'Status',
101
+ getTagColor:(tag) => tag.color,
102
+ options :[
103
+ { value: 'Approved', label: 'Approved', color: 'green' },
104
+ { value: 'To be reviewed', label: 'To be reviewed', color: 'purple' },
105
+ { value: 'Revised', label: 'Revised', color: 'blue' },
106
+ { value: 'Rejected', label: 'Rejected', color: 'red' },
107
+ ],
108
+ placeholder:'Type to search',
109
+ multiple :true,
110
+ }