@rhc-shared-components/form-multi-select-component 0.2.1 → 1.0.0

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.
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
2
  import { SelectOptionProps } from '@patternfly/react-core';
3
+ declare type IMultiSelectInputOptionProps = SelectOptionProps;
3
4
  export interface FormMultiSelectInputProps {
4
5
  name: string;
5
6
  label: string;
6
7
  isRequired?: boolean;
7
8
  placeholder?: string;
8
- selectMenuOptions: SelectOptionProps[];
9
+ selectMenuOptions: IMultiSelectInputOptionProps[];
9
10
  ariaLabel?: string;
10
11
  helperText?: string;
11
12
  maxHeight?: string | number;
@@ -15,4 +16,4 @@ export interface FormMultiSelectInputProps {
15
16
  extraProps?: any;
16
17
  }
17
18
  declare const FormMultiSelectInput: React.FunctionComponent<FormMultiSelectInputProps>;
18
- export default FormMultiSelectInput;
19
+ export { FormMultiSelectInput, IMultiSelectInputOptionProps };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import FormMultiSelectInput from './FormMultiSelectInput';
2
- export { FormMultiSelectInput };
1
+ import { FormMultiSelectInput, IMultiSelectInputOptionProps } from './FormMultiSelectInput';
2
+ export { FormMultiSelectInput, IMultiSelectInputOptionProps };
package/dist/index.js CHANGED
@@ -126,6 +126,8 @@ var FormMultiSelectInput = function FormMultiSelectInput(_ref) {
126
126
  var _useField = formik.useField(rest),
127
127
  meta = _useField[1];
128
128
 
129
+ var value = meta.value;
130
+
129
131
  var _useFormikContext = formik.useFormikContext(),
130
132
  isSubmitting = _useFormikContext.isSubmitting,
131
133
  setFieldValue = _useFormikContext.setFieldValue,
@@ -182,6 +184,12 @@ var FormMultiSelectInput = function FormMultiSelectInput(_ref) {
182
184
  setFocusedItemIndex(null);
183
185
  setActiveItem(null);
184
186
  }, [inputValue]);
187
+ React__default["default"].useEffect(function () {
188
+ if ((value == null ? void 0 : value.length) > 0) {
189
+ setFieldValue(rest.name, value, true);
190
+ setSelected(value);
191
+ }
192
+ }, []);
185
193
 
186
194
  var handleMenuArrowKeys = function handleMenuArrowKeys(key) {
187
195
  var indexToFocus = 0;
@@ -355,10 +363,8 @@ var FormMultiSelectInput = function FormMultiSelectInput(_ref) {
355
363
  isFocused: focusedItemIndex === index,
356
364
  className: option.className,
357
365
  id: "select-multi-typeahead-" + option.value.replace(' ', '-'),
358
- isDisabled: option.isDisabled
359
- }, option, {
360
- ref: null
361
- }));
366
+ isDisabled: option.isDisabled || isSubmitting
367
+ }, option));
362
368
  })))));
363
369
  };
364
370
 
@@ -105,6 +105,9 @@ const FormMultiSelectInput = _ref => {
105
105
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
106
106
 
107
107
  const [, meta] = useField(rest);
108
+ const {
109
+ value
110
+ } = meta;
108
111
  const {
109
112
  isSubmitting,
110
113
  setFieldValue,
@@ -141,6 +144,12 @@ const FormMultiSelectInput = _ref => {
141
144
  setFocusedItemIndex(null);
142
145
  setActiveItem(null);
143
146
  }, [inputValue]);
147
+ React__default.useEffect(() => {
148
+ if ((value == null ? void 0 : value.length) > 0) {
149
+ setFieldValue(rest.name, value, true);
150
+ setSelected(value);
151
+ }
152
+ }, []);
144
153
 
145
154
  const handleMenuArrowKeys = key => {
146
155
  let indexToFocus = 0;
@@ -296,10 +305,8 @@ const FormMultiSelectInput = _ref => {
296
305
  isFocused: focusedItemIndex === index,
297
306
  className: option.className,
298
307
  id: `select-multi-typeahead-${option.value.replace(' ', '-')}`,
299
- isDisabled: option.isDisabled
300
- }, option, {
301
- ref: null
302
- })))))));
308
+ isDisabled: option.isDisabled || isSubmitting
309
+ }, option)))))));
303
310
  };
304
311
 
305
312
  export { FormMultiSelectInput };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhc-shared-components/form-multi-select-component",
3
- "version": "0.2.1",
3
+ "version": "1.0.0",
4
4
  "description": "project description",
5
5
  "author": "shkale",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "predeploy": "cd example && yarn install && yarn run build"
25
25
  },
26
26
  "peerDependencies": {
27
- "@patternfly/react-core": ">=4.101.3",
27
+ "@patternfly/react-core": ">=5.3.0",
28
28
  "formik": ">=2.1.4",
29
29
  "react": ">=16.13.1",
30
30
  "react-dom": ">=16.13.1"