@uncinc/uncinc-react-kitchen-sink 2.3.0 → 2.3.2

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.
@@ -17,7 +17,9 @@ const SelectInput = props => {
17
17
  disabled,
18
18
  className,
19
19
  wrapperClassName,
20
- isClearable = true
20
+ isClearable = true,
21
+ multiple = false,
22
+ size
21
23
  } = props;
22
24
  let {
23
25
  selectedOption
@@ -36,10 +38,20 @@ const SelectInput = props => {
36
38
  } // If the selected option is not set, find the currently selected option by value.
37
39
 
38
40
 
39
- if (!selectedOption && value) {
40
- selectedOption = optionsTransformed.find(option => {
41
- return option.value === value;
42
- });
41
+ if (!selectedOption) {
42
+ if (multiple) {
43
+ const _value = value !== undefined ? value : defaultValue || [];
44
+
45
+ selectedOption = optionsTransformed.filter(option => {
46
+ return _value.includes(option.value);
47
+ });
48
+ } else {
49
+ const _value = value !== undefined ? value : defaultValue || '';
50
+
51
+ selectedOption = optionsTransformed.find(option => {
52
+ return option.value === _value;
53
+ });
54
+ }
43
55
  }
44
56
 
45
57
  return /*#__PURE__*/React.createElement(Field, {
@@ -55,27 +67,44 @@ const SelectInput = props => {
55
67
  id: id,
56
68
  className: c("Select__select", className),
57
69
  classNamePrefix: c("Select__inner", wrapperClassName),
58
- value: selectedOption || "",
70
+ value: selectedOption,
59
71
  defaultValue: defaultValue,
60
72
  disabled: disabled,
61
73
  onChange: e => {
74
+ let value = '';
75
+
62
76
  if (e) {
63
- if (onChange) {
64
- onChange(e.value);
77
+ if (multiple) {
78
+ value = e.map(item => {
79
+ return item.value;
80
+ });
81
+ } else {
82
+ value = e.value;
65
83
  }
66
-
67
- form.setFieldValue(fieldName, e.value);
68
84
  } else {
69
- if (onChange) {
70
- onChange('');
85
+ if (multiple) {
86
+ value = [];
71
87
  }
88
+ }
72
89
 
73
- form.setFieldValue(fieldName, null);
90
+ if (onChange) {
91
+ onChange(value);
74
92
  }
93
+
94
+ form.setFieldValue(fieldName, value);
75
95
  },
76
96
  options: optionsTransformed,
97
+ isMulti: multiple,
77
98
  isOptionDisabled: option => {
78
- return option.disabled;
99
+ if (option.disabled) {
100
+ return true;
101
+ }
102
+
103
+ if (size && selectedOption.length >= size) {
104
+ return true;
105
+ }
106
+
107
+ return false;
79
108
  },
80
109
  placeholder: placeholder,
81
110
  isClearable: isClearable,
@@ -18,9 +18,6 @@
18
18
  }
19
19
  }
20
20
  &__option {
21
- &--is-focused {
22
- color: black !important;
23
- }
24
21
  &--is-selected {
25
22
  background-color: transparent !important;
26
23
  color: $color--primary !important;
@@ -17,7 +17,8 @@ const Select = props => {
17
17
  displayRequiredIndicator,
18
18
  className,
19
19
  wrapperClassName,
20
- disabled = false
20
+ disabled = false,
21
+ multiple = false
21
22
  } = props;
22
23
  return /*#__PURE__*/React.createElement(GenericFormElement, {
23
24
  className: c("Select", wrapperClassName),
@@ -32,7 +33,8 @@ const Select = props => {
32
33
  className: c(className, {
33
34
  'error': error && touched
34
35
  }),
35
- disabled: disabled
36
+ disabled: disabled,
37
+ multiple: multiple
36
38
  })));
37
39
  };
38
40
 
@@ -5,22 +5,49 @@ export default {
5
5
  title: 'Molecules/Form'
6
6
  };
7
7
  export const Select = () => {
8
- return /*#__PURE__*/React.createElement(FormikWrapper, {
9
- initialValues: {
10
- poison: 'beer'
8
+ return /*#__PURE__*/React.createElement(FormikWrapper, null, /*#__PURE__*/React.createElement(FormikSelect, {
9
+ title: "Pick your poison",
10
+ required: true,
11
+ description: "This is a test input.",
12
+ placeholder: "Select a value...",
13
+ fieldName: "poison",
14
+ options: {
15
+ beer: 'Beer',
16
+ wine: 'Wine',
17
+ rum: 'Rum',
18
+ whisky: 'Whisk(e)y'
19
+ },
20
+ defaultValue: "wine",
21
+ validation: value => {
22
+ let error;
23
+
24
+ if (!value) {
25
+ error = 'Dit is een vereist veld.';
26
+ }
27
+
28
+ return error;
29
+ },
30
+ onChange: e => {
31
+ console.log(e);
11
32
  }
12
- }, /*#__PURE__*/React.createElement(FormikSelect, {
33
+ }));
34
+ };
35
+ export const SelectMultiple = () => {
36
+ return /*#__PURE__*/React.createElement(FormikWrapper, null, /*#__PURE__*/React.createElement(FormikSelect, {
13
37
  title: "Pick your poison",
14
38
  required: true,
15
39
  description: "This is a test input.",
16
40
  placeholder: "Select a value...",
17
41
  fieldName: "poison",
42
+ multiple: true,
43
+ size: 2,
18
44
  options: {
19
45
  beer: 'Beer',
20
46
  wine: 'Wine',
21
47
  rum: 'Rum',
22
48
  whisky: 'Whisk(e)y'
23
49
  },
50
+ defaultValue: ['wine'],
24
51
  validation: value => {
25
52
  let error;
26
53
 
@@ -11,6 +11,8 @@ const SearchField = ({
11
11
  const timeoutRef = useRef();
12
12
 
13
13
  const onChange = e => {
14
+ e.persist();
15
+
14
16
  if (timeoutRef.current) {
15
17
  clearTimeout(timeoutRef.current);
16
18
  }
@@ -1,3 +1,4 @@
1
+ @use 'sass:math';
1
2
  @import './variables';
2
3
  @import '~bootstrap/scss/mixins';
3
4
 
@@ -17,8 +18,8 @@
17
18
  @each $breakpoint in map-keys($gutters) {
18
19
  @include media-breakpoint-up($breakpoint) {
19
20
  $gutter: map-get($gutters, $breakpoint);
20
- padding-left: div($gutter, 2);
21
- padding-right: div($gutter, 2);
21
+ padding-left: math.div($gutter, 2);
22
+ padding-right: math.div($gutter, 2);
22
23
  }
23
24
  }
24
25
  }
@@ -27,8 +28,8 @@
27
28
  @each $breakpoint in map-keys($gutters) {
28
29
  @include media-breakpoint-up($breakpoint) {
29
30
  $gutter: map-get($gutters, $breakpoint);
30
- padding-left: div($gutter, 2);
31
- padding-right: div($gutter, 2);
31
+ padding-left: math.div($gutter, 2);
32
+ padding-right: math.div($gutter, 2);
32
33
  }
33
34
  }
34
35
  }
@@ -41,13 +42,13 @@
41
42
  @include media-breakpoint-up($breakpoint) {
42
43
  $gutter: map-get($gutters, $breakpoint);
43
44
  @if $sides == all {
44
- margin: div($gutter, -2);
45
+ margin: math.div($gutter, -2);
45
46
  } @else if $sides == left-right {
46
- margin-left: div($gutter, -2);
47
- margin-right: div($gutter, -2);
47
+ margin-left: math.div($gutter, -2);
48
+ margin-right: math.div($gutter, -2);
48
49
  } @else if $sides == top-bottom {
49
- margin-top: div($gutter, -2);
50
- margin-bottom: div($gutter, -2);
50
+ margin-top: math.div($gutter, -2);
51
+ margin-bottom: math.div($gutter, -2);
51
52
  }
52
53
  }
53
54
  }
@@ -62,8 +63,8 @@
62
63
  @each $breakpoint in map-keys($grid-gutter-widths) {
63
64
  @include media-breakpoint-up($breakpoint) {
64
65
  $gutter: map-get($grid-gutter-widths, $breakpoint);
65
- padding-left: div($gutter, 2);
66
- padding-right: div($gutter, 2);
66
+ padding-left: math.div($gutter, 2);
67
+ padding-right: math.div($gutter, 2);
67
68
  }
68
69
  }
69
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncinc/uncinc-react-kitchen-sink",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "Default React components that are easily extended.",
5
5
  "author": "uncinc",
6
6
  "license": "MIT",