@rhc-shared-components/form-multi-select-component 0.1.0 → 0.1.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.
- package/dist/FormMultiSelectInput.d.ts +1 -0
- package/dist/index.js +33 -1
- package/dist/index.modern.js +24 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -96,8 +96,36 @@ var FormMultiSelectInput = function FormMultiSelectInput(_ref) {
|
|
|
96
96
|
setFieldValue(rest.name, newValues, true);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
+
var disabledItems = selectOptions.filter(function (selectItem) {
|
|
100
|
+
var _selectItem$extraProp;
|
|
101
|
+
|
|
102
|
+
return (selectItem == null ? void 0 : selectItem.isDisabled) || (selectItem == null ? void 0 : (_selectItem$extraProp = selectItem.extraProps) == null ? void 0 : _selectItem$extraProp.isDisabled);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
var CustomChipGroup = function CustomChipGroup() {
|
|
106
|
+
return React__namespace.createElement(reactCore.ChipGroup, null, (value || []).map(function (currentValue) {
|
|
107
|
+
return React__namespace.createElement(reactCore.Chip, {
|
|
108
|
+
isReadOnly: !!disabledItems.find(function (item) {
|
|
109
|
+
return item.value === currentValue;
|
|
110
|
+
}),
|
|
111
|
+
key: currentValue,
|
|
112
|
+
onClick: function onClick(event) {
|
|
113
|
+
return onSelect(event, currentValue);
|
|
114
|
+
}
|
|
115
|
+
}, currentValue);
|
|
116
|
+
}));
|
|
117
|
+
};
|
|
118
|
+
|
|
99
119
|
var onClear = function onClear() {
|
|
100
|
-
|
|
120
|
+
var filtered = value == null ? void 0 : value.filter(function (item) {
|
|
121
|
+
var _selectItem$extraProp2;
|
|
122
|
+
|
|
123
|
+
var selectItem = disabledItems.find(function (obj) {
|
|
124
|
+
return obj.value === item;
|
|
125
|
+
});
|
|
126
|
+
return (selectItem == null ? void 0 : selectItem.isDisabled) || (selectItem == null ? void 0 : (_selectItem$extraProp2 = selectItem.extraProps) == null ? void 0 : _selectItem$extraProp2.isDisabled);
|
|
127
|
+
});
|
|
128
|
+
setFieldValue(rest.name, [].concat(filtered), true);
|
|
101
129
|
setIsOpen(false);
|
|
102
130
|
};
|
|
103
131
|
|
|
@@ -127,6 +155,8 @@ var FormMultiSelectInput = function FormMultiSelectInput(_ref) {
|
|
|
127
155
|
}, {
|
|
128
156
|
isDisabled: isSubmitting || isDisabled,
|
|
129
157
|
"aria-label": ariaLabel
|
|
158
|
+
}, disabledItems && {
|
|
159
|
+
chipGroupComponent: React__namespace.createElement(CustomChipGroup, null)
|
|
130
160
|
}, classNames && {
|
|
131
161
|
className: classNames
|
|
132
162
|
}, menuAppendTo && {
|
|
@@ -138,6 +168,8 @@ var FormMultiSelectInput = function FormMultiSelectInput(_ref) {
|
|
|
138
168
|
label: option.value
|
|
139
169
|
}, option.description && {
|
|
140
170
|
description: option.description
|
|
171
|
+
}, option.isDisabled && {
|
|
172
|
+
isDisabled: option.isDisabled
|
|
141
173
|
}, option.extraProps && _extends({}, option.extraProps)));
|
|
142
174
|
}))));
|
|
143
175
|
};
|
package/dist/index.modern.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useField, useFormikContext } from 'formik';
|
|
3
|
-
import { ValidatedOptions, Select, SelectVariant, SelectOption } from '@patternfly/react-core';
|
|
3
|
+
import { ValidatedOptions, Select, SelectVariant, SelectOption, ChipGroup, Chip } from '@patternfly/react-core';
|
|
4
4
|
import { FormGroupContainer } from '@rhc-shared-components/form-group-container';
|
|
5
5
|
import { map } from 'lodash';
|
|
6
6
|
|
|
@@ -72,8 +72,26 @@ const FormMultiSelectInput = _ref => {
|
|
|
72
72
|
setFieldValue(rest.name, newValues, true);
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
+
const disabledItems = selectOptions.filter(selectItem => {
|
|
76
|
+
var _selectItem$extraProp;
|
|
77
|
+
|
|
78
|
+
return (selectItem == null ? void 0 : selectItem.isDisabled) || (selectItem == null ? void 0 : (_selectItem$extraProp = selectItem.extraProps) == null ? void 0 : _selectItem$extraProp.isDisabled);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const CustomChipGroup = () => React.createElement(ChipGroup, null, (value || []).map(currentValue => React.createElement(Chip, {
|
|
82
|
+
isReadOnly: !!disabledItems.find(item => item.value === currentValue),
|
|
83
|
+
key: currentValue,
|
|
84
|
+
onClick: event => onSelect(event, currentValue)
|
|
85
|
+
}, currentValue)));
|
|
86
|
+
|
|
75
87
|
const onClear = () => {
|
|
76
|
-
|
|
88
|
+
const filtered = value == null ? void 0 : value.filter(item => {
|
|
89
|
+
var _selectItem$extraProp2;
|
|
90
|
+
|
|
91
|
+
const selectItem = disabledItems.find(obj => obj.value === item);
|
|
92
|
+
return (selectItem == null ? void 0 : selectItem.isDisabled) || (selectItem == null ? void 0 : (_selectItem$extraProp2 = selectItem.extraProps) == null ? void 0 : _selectItem$extraProp2.isDisabled);
|
|
93
|
+
});
|
|
94
|
+
setFieldValue(rest.name, [...filtered], true);
|
|
77
95
|
setIsOpen(false);
|
|
78
96
|
};
|
|
79
97
|
|
|
@@ -103,6 +121,8 @@ const FormMultiSelectInput = _ref => {
|
|
|
103
121
|
}, {
|
|
104
122
|
isDisabled: isSubmitting || isDisabled,
|
|
105
123
|
"aria-label": ariaLabel
|
|
124
|
+
}, disabledItems && {
|
|
125
|
+
chipGroupComponent: React.createElement(CustomChipGroup, null)
|
|
106
126
|
}, classNames && {
|
|
107
127
|
className: classNames
|
|
108
128
|
}, menuAppendTo && {
|
|
@@ -113,6 +133,8 @@ const FormMultiSelectInput = _ref => {
|
|
|
113
133
|
label: option.value
|
|
114
134
|
}, option.description && {
|
|
115
135
|
description: option.description
|
|
136
|
+
}, option.isDisabled && {
|
|
137
|
+
isDisabled: option.isDisabled
|
|
116
138
|
}, option.extraProps && _extends({}, option.extraProps)))))));
|
|
117
139
|
};
|
|
118
140
|
|