@rhc-shared-components/form-multi-select-component 0.2.0 → 0.2.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/index.js +41 -56
- package/dist/index.modern.js +42 -56
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -41,54 +41,38 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
41
41
|
return target;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
Copyright (c) Microsoft Corporation.
|
|
46
|
-
|
|
47
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
48
|
-
purpose with or without fee is hereby granted.
|
|
49
|
-
|
|
50
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
51
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
52
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
53
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
54
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
55
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
56
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
57
|
-
***************************************************************************** */
|
|
58
|
-
|
|
59
|
-
function __rest(s, e) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
44
|
+
/******************************************************************************
|
|
45
|
+
Copyright (c) Microsoft Corporation.
|
|
46
|
+
|
|
47
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
48
|
+
purpose with or without fee is hereby granted.
|
|
49
|
+
|
|
50
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
51
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
52
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
53
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
54
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
55
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
56
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
57
|
+
***************************************************************************** */
|
|
58
|
+
|
|
59
|
+
function __rest(s, e) {
|
|
60
|
+
var t = {};
|
|
61
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
62
|
+
t[p] = s[p];
|
|
63
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
64
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
65
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
66
|
+
t[p[i]] = s[p[i]];
|
|
67
|
+
}
|
|
68
|
+
return t;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
IconSize["md"] = "md";
|
|
75
|
-
IconSize["lg"] = "lg";
|
|
76
|
-
IconSize["xl"] = "xl";
|
|
77
|
-
})(IconSize || (IconSize = {}));
|
|
78
|
-
const getSize = (size) => {
|
|
79
|
-
switch (size) {
|
|
80
|
-
case IconSize.sm:
|
|
81
|
-
return '1em';
|
|
82
|
-
case IconSize.md:
|
|
83
|
-
return '1.5em';
|
|
84
|
-
case IconSize.lg:
|
|
85
|
-
return '2em';
|
|
86
|
-
case IconSize.xl:
|
|
87
|
-
return '3em';
|
|
88
|
-
default:
|
|
89
|
-
return '1em';
|
|
90
|
-
}
|
|
71
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
72
|
+
var e = new Error(message);
|
|
73
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
91
74
|
};
|
|
75
|
+
|
|
92
76
|
let currentId = 0;
|
|
93
77
|
/**
|
|
94
78
|
* Factory to create Icon class components for consumers
|
|
@@ -101,23 +85,16 @@ function createIcon({ name, xOffset = 0, yOffset = 0, width, height, svgPath })
|
|
|
101
85
|
this.id = `icon-title-${currentId++}`;
|
|
102
86
|
}
|
|
103
87
|
render() {
|
|
104
|
-
const _a = this.props, {
|
|
88
|
+
const _a = this.props, { title, className } = _a, props = __rest(_a, ["title", "className"]);
|
|
89
|
+
const classes = className ? `pf-v5-svg ${className}` : 'pf-v5-svg';
|
|
105
90
|
const hasTitle = Boolean(title);
|
|
106
|
-
const heightWidth = getSize(size);
|
|
107
|
-
const baseAlign = -0.125 * Number.parseFloat(heightWidth);
|
|
108
|
-
const style = noVerticalAlign ? null : { verticalAlign: `${baseAlign}em` };
|
|
109
91
|
const viewBox = [xOffset, yOffset, width, height].join(' ');
|
|
110
|
-
return (React__namespace.createElement("svg", Object.assign({
|
|
92
|
+
return (React__namespace.createElement("svg", Object.assign({ className: classes, viewBox: viewBox, fill: "currentColor", "aria-labelledby": hasTitle ? this.id : null, "aria-hidden": hasTitle ? null : true, role: "img", width: "1em", height: "1em" }, props),
|
|
111
93
|
hasTitle && React__namespace.createElement("title", { id: this.id }, title),
|
|
112
94
|
React__namespace.createElement("path", { d: svgPath })));
|
|
113
95
|
}
|
|
114
96
|
},
|
|
115
97
|
_a.displayName = name,
|
|
116
|
-
_a.defaultProps = {
|
|
117
|
-
color: 'currentColor',
|
|
118
|
-
size: IconSize.sm,
|
|
119
|
-
noVerticalAlign: false
|
|
120
|
-
},
|
|
121
98
|
_a;
|
|
122
99
|
}
|
|
123
100
|
|
|
@@ -149,6 +126,8 @@ var FormMultiSelectInput = function FormMultiSelectInput(_ref) {
|
|
|
149
126
|
var _useField = formik.useField(rest),
|
|
150
127
|
meta = _useField[1];
|
|
151
128
|
|
|
129
|
+
var value = meta.value;
|
|
130
|
+
|
|
152
131
|
var _useFormikContext = formik.useFormikContext(),
|
|
153
132
|
isSubmitting = _useFormikContext.isSubmitting,
|
|
154
133
|
setFieldValue = _useFormikContext.setFieldValue,
|
|
@@ -205,6 +184,12 @@ var FormMultiSelectInput = function FormMultiSelectInput(_ref) {
|
|
|
205
184
|
setFocusedItemIndex(null);
|
|
206
185
|
setActiveItem(null);
|
|
207
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
|
+
}, []);
|
|
208
193
|
|
|
209
194
|
var handleMenuArrowKeys = function handleMenuArrowKeys(key) {
|
|
210
195
|
var indexToFocus = 0;
|
|
@@ -378,7 +363,7 @@ var FormMultiSelectInput = function FormMultiSelectInput(_ref) {
|
|
|
378
363
|
isFocused: focusedItemIndex === index,
|
|
379
364
|
className: option.className,
|
|
380
365
|
id: "select-multi-typeahead-" + option.value.replace(' ', '-'),
|
|
381
|
-
isDisabled: option.isDisabled
|
|
366
|
+
isDisabled: option.isDisabled || isSubmitting
|
|
382
367
|
}, option, {
|
|
383
368
|
ref: null
|
|
384
369
|
}));
|
package/dist/index.modern.js
CHANGED
|
@@ -19,54 +19,38 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
19
19
|
return target;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
Copyright (c) Microsoft Corporation.
|
|
24
|
-
|
|
25
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
26
|
-
purpose with or without fee is hereby granted.
|
|
27
|
-
|
|
28
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
29
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
30
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
31
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
32
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
33
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
34
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
35
|
-
***************************************************************************** */
|
|
36
|
-
|
|
37
|
-
function __rest(s, e) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
/******************************************************************************
|
|
23
|
+
Copyright (c) Microsoft Corporation.
|
|
24
|
+
|
|
25
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
26
|
+
purpose with or without fee is hereby granted.
|
|
27
|
+
|
|
28
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
29
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
30
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
31
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
32
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
33
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
34
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
35
|
+
***************************************************************************** */
|
|
36
|
+
|
|
37
|
+
function __rest(s, e) {
|
|
38
|
+
var t = {};
|
|
39
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
40
|
+
t[p] = s[p];
|
|
41
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
42
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
43
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
44
|
+
t[p[i]] = s[p[i]];
|
|
45
|
+
}
|
|
46
|
+
return t;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
IconSize["md"] = "md";
|
|
53
|
-
IconSize["lg"] = "lg";
|
|
54
|
-
IconSize["xl"] = "xl";
|
|
55
|
-
})(IconSize || (IconSize = {}));
|
|
56
|
-
const getSize = (size) => {
|
|
57
|
-
switch (size) {
|
|
58
|
-
case IconSize.sm:
|
|
59
|
-
return '1em';
|
|
60
|
-
case IconSize.md:
|
|
61
|
-
return '1.5em';
|
|
62
|
-
case IconSize.lg:
|
|
63
|
-
return '2em';
|
|
64
|
-
case IconSize.xl:
|
|
65
|
-
return '3em';
|
|
66
|
-
default:
|
|
67
|
-
return '1em';
|
|
68
|
-
}
|
|
49
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
69
52
|
};
|
|
53
|
+
|
|
70
54
|
let currentId = 0;
|
|
71
55
|
/**
|
|
72
56
|
* Factory to create Icon class components for consumers
|
|
@@ -79,23 +63,16 @@ function createIcon({ name, xOffset = 0, yOffset = 0, width, height, svgPath })
|
|
|
79
63
|
this.id = `icon-title-${currentId++}`;
|
|
80
64
|
}
|
|
81
65
|
render() {
|
|
82
|
-
const _a = this.props, {
|
|
66
|
+
const _a = this.props, { title, className } = _a, props = __rest(_a, ["title", "className"]);
|
|
67
|
+
const classes = className ? `pf-v5-svg ${className}` : 'pf-v5-svg';
|
|
83
68
|
const hasTitle = Boolean(title);
|
|
84
|
-
const heightWidth = getSize(size);
|
|
85
|
-
const baseAlign = -0.125 * Number.parseFloat(heightWidth);
|
|
86
|
-
const style = noVerticalAlign ? null : { verticalAlign: `${baseAlign}em` };
|
|
87
69
|
const viewBox = [xOffset, yOffset, width, height].join(' ');
|
|
88
|
-
return (React.createElement("svg", Object.assign({
|
|
70
|
+
return (React.createElement("svg", Object.assign({ className: classes, viewBox: viewBox, fill: "currentColor", "aria-labelledby": hasTitle ? this.id : null, "aria-hidden": hasTitle ? null : true, role: "img", width: "1em", height: "1em" }, props),
|
|
89
71
|
hasTitle && React.createElement("title", { id: this.id }, title),
|
|
90
72
|
React.createElement("path", { d: svgPath })));
|
|
91
73
|
}
|
|
92
74
|
},
|
|
93
75
|
_a.displayName = name,
|
|
94
|
-
_a.defaultProps = {
|
|
95
|
-
color: 'currentColor',
|
|
96
|
-
size: IconSize.sm,
|
|
97
|
-
noVerticalAlign: false
|
|
98
|
-
},
|
|
99
76
|
_a;
|
|
100
77
|
}
|
|
101
78
|
|
|
@@ -128,6 +105,9 @@ const FormMultiSelectInput = _ref => {
|
|
|
128
105
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
129
106
|
|
|
130
107
|
const [, meta] = useField(rest);
|
|
108
|
+
const {
|
|
109
|
+
value
|
|
110
|
+
} = meta;
|
|
131
111
|
const {
|
|
132
112
|
isSubmitting,
|
|
133
113
|
setFieldValue,
|
|
@@ -164,6 +144,12 @@ const FormMultiSelectInput = _ref => {
|
|
|
164
144
|
setFocusedItemIndex(null);
|
|
165
145
|
setActiveItem(null);
|
|
166
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
|
+
}, []);
|
|
167
153
|
|
|
168
154
|
const handleMenuArrowKeys = key => {
|
|
169
155
|
let indexToFocus = 0;
|
|
@@ -319,7 +305,7 @@ const FormMultiSelectInput = _ref => {
|
|
|
319
305
|
isFocused: focusedItemIndex === index,
|
|
320
306
|
className: option.className,
|
|
321
307
|
id: `select-multi-typeahead-${option.value.replace(' ', '-')}`,
|
|
322
|
-
isDisabled: option.isDisabled
|
|
308
|
+
isDisabled: option.isDisabled || isSubmitting
|
|
323
309
|
}, option, {
|
|
324
310
|
ref: null
|
|
325
311
|
})))))));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhc-shared-components/form-multi-select-component",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "project description",
|
|
5
5
|
"author": "shkale",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@patternfly/react-core": "5.3.0",
|
|
66
|
-
"@rhc-shared-components/form-group-container": "^0.
|
|
66
|
+
"@rhc-shared-components/form-group-container": "^0.4.0",
|
|
67
67
|
"@types/lodash": "^4.14.177",
|
|
68
68
|
"formik": "^2.1.4",
|
|
69
69
|
"lodash": "^4.17.21",
|