@rhc-shared-components/form-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/FormSelectComponent.d.ts +2 -0
- package/dist/index.js +79 -152
- package/dist/index.modern.js +72 -124
- package/package.json +3 -4
|
@@ -22,6 +22,8 @@ export interface FormSelectProps {
|
|
|
22
22
|
onChange?: (_event: any, selection: any) => void;
|
|
23
23
|
extraProps?: any;
|
|
24
24
|
selectOptionExtraProps?: any;
|
|
25
|
+
isFullWidth?: boolean;
|
|
26
|
+
isFullHeight?: boolean;
|
|
25
27
|
}
|
|
26
28
|
declare const FormSelect: React.FC<FormSelectProps>;
|
|
27
29
|
export default FormSelect;
|
package/dist/index.js
CHANGED
|
@@ -41,22 +41,6 @@ function _extends() {
|
|
|
41
41
|
return _extends.apply(this, arguments);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function _inheritsLoose(subClass, superClass) {
|
|
45
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
46
|
-
subClass.prototype.constructor = subClass;
|
|
47
|
-
|
|
48
|
-
_setPrototypeOf(subClass, superClass);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function _setPrototypeOf(o, p) {
|
|
52
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
53
|
-
o.__proto__ = p;
|
|
54
|
-
return o;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return _setPrototypeOf(o, p);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
44
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
61
45
|
if (source == null) return {};
|
|
62
46
|
var target = {};
|
|
@@ -9543,140 +9527,75 @@ if(freeModule){// Export for Node.js.
|
|
|
9543
9527
|
freeExports._=_;}else {// Export to the global object.
|
|
9544
9528
|
root._=_;}}).call(commonjsGlobal);});
|
|
9545
9529
|
|
|
9546
|
-
|
|
9547
|
-
Copyright (c) Microsoft Corporation.
|
|
9548
|
-
|
|
9549
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9550
|
-
purpose with or without fee is hereby granted.
|
|
9551
|
-
|
|
9552
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9553
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9554
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
9555
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
9556
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
9557
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
9558
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
9530
|
+
/******************************************************************************
|
|
9531
|
+
Copyright (c) Microsoft Corporation.
|
|
9532
|
+
|
|
9533
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
9534
|
+
purpose with or without fee is hereby granted.
|
|
9535
|
+
|
|
9536
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9537
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9538
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
9539
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
9540
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
9541
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
9542
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
9559
9543
|
***************************************************************************** */
|
|
9544
|
+
|
|
9560
9545
|
function __rest(s, e) {
|
|
9561
9546
|
var t = {};
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
}
|
|
9547
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
9548
|
+
t[p] = s[p];
|
|
9549
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
9550
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
9551
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9552
|
+
t[p[i]] = s[p[i]];
|
|
9553
|
+
}
|
|
9570
9554
|
return t;
|
|
9571
9555
|
}
|
|
9572
9556
|
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
IconSize["sm"] = "sm";
|
|
9577
|
-
IconSize["md"] = "md";
|
|
9578
|
-
IconSize["lg"] = "lg";
|
|
9579
|
-
IconSize["xl"] = "xl";
|
|
9580
|
-
})(IconSize || (IconSize = {}));
|
|
9581
|
-
|
|
9582
|
-
var getSize = function getSize(size) {
|
|
9583
|
-
switch (size) {
|
|
9584
|
-
case IconSize.sm:
|
|
9585
|
-
return '1em';
|
|
9586
|
-
|
|
9587
|
-
case IconSize.md:
|
|
9588
|
-
return '1.5em';
|
|
9589
|
-
|
|
9590
|
-
case IconSize.lg:
|
|
9591
|
-
return '2em';
|
|
9592
|
-
|
|
9593
|
-
case IconSize.xl:
|
|
9594
|
-
return '3em';
|
|
9595
|
-
|
|
9596
|
-
default:
|
|
9597
|
-
return '1em';
|
|
9598
|
-
}
|
|
9557
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
9558
|
+
var e = new Error(message);
|
|
9559
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
9599
9560
|
};
|
|
9600
|
-
|
|
9561
|
+
|
|
9562
|
+
let currentId = 0;
|
|
9601
9563
|
/**
|
|
9602
9564
|
* Factory to create Icon class components for consumers
|
|
9603
9565
|
*/
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
_this = _React$Component.apply(this, arguments) || this;
|
|
9624
|
-
_this.id = "icon-title-" + currentId++;
|
|
9625
|
-
return _this;
|
|
9626
|
-
}
|
|
9627
|
-
|
|
9628
|
-
var _proto = SVGIcon.prototype;
|
|
9629
|
-
|
|
9630
|
-
_proto.render = function render() {
|
|
9631
|
-
var _a = this.props,
|
|
9632
|
-
size = _a.size,
|
|
9633
|
-
color = _a.color,
|
|
9634
|
-
title = _a.title,
|
|
9635
|
-
noVerticalAlign = _a.noVerticalAlign,
|
|
9636
|
-
props = __rest(_a, ["size", "color", "title", "noVerticalAlign"]);
|
|
9637
|
-
|
|
9638
|
-
var hasTitle = Boolean(title);
|
|
9639
|
-
var heightWidth = getSize(size);
|
|
9640
|
-
var baseAlign = -0.125 * Number.parseFloat(heightWidth);
|
|
9641
|
-
var style = noVerticalAlign ? null : {
|
|
9642
|
-
verticalAlign: baseAlign + "em"
|
|
9643
|
-
};
|
|
9644
|
-
var viewBox = [xOffset, yOffset, width, height].join(' ');
|
|
9645
|
-
return React__namespace.createElement("svg", Object.assign({
|
|
9646
|
-
style: style,
|
|
9647
|
-
fill: color,
|
|
9648
|
-
height: heightWidth,
|
|
9649
|
-
width: heightWidth,
|
|
9650
|
-
viewBox: viewBox,
|
|
9651
|
-
"aria-labelledby": hasTitle ? this.id : null,
|
|
9652
|
-
"aria-hidden": hasTitle ? null : true,
|
|
9653
|
-
role: "img"
|
|
9654
|
-
}, props), hasTitle && React__namespace.createElement("title", {
|
|
9655
|
-
id: this.id
|
|
9656
|
-
}, title), React__namespace.createElement("path", {
|
|
9657
|
-
d: svgPath
|
|
9658
|
-
}));
|
|
9659
|
-
};
|
|
9660
|
-
|
|
9661
|
-
return SVGIcon;
|
|
9662
|
-
}(React__namespace.Component), _a.displayName = name, _a.defaultProps = {
|
|
9663
|
-
color: 'currentColor',
|
|
9664
|
-
size: IconSize.sm,
|
|
9665
|
-
noVerticalAlign: false
|
|
9666
|
-
}, _a;
|
|
9566
|
+
function createIcon({ name, xOffset = 0, yOffset = 0, width, height, svgPath }) {
|
|
9567
|
+
var _a;
|
|
9568
|
+
return _a = class SVGIcon extends React__namespace.Component {
|
|
9569
|
+
constructor() {
|
|
9570
|
+
super(...arguments);
|
|
9571
|
+
this.id = `icon-title-${currentId++}`;
|
|
9572
|
+
}
|
|
9573
|
+
render() {
|
|
9574
|
+
const _a = this.props, { title, className } = _a, props = __rest(_a, ["title", "className"]);
|
|
9575
|
+
const classes = className ? `pf-v5-svg ${className}` : 'pf-v5-svg';
|
|
9576
|
+
const hasTitle = Boolean(title);
|
|
9577
|
+
const viewBox = [xOffset, yOffset, width, height].join(' ');
|
|
9578
|
+
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),
|
|
9579
|
+
hasTitle && React__namespace.createElement("title", { id: this.id }, title),
|
|
9580
|
+
React__namespace.createElement("path", { d: svgPath })));
|
|
9581
|
+
}
|
|
9582
|
+
},
|
|
9583
|
+
_a.displayName = name,
|
|
9584
|
+
_a;
|
|
9667
9585
|
}
|
|
9668
9586
|
|
|
9669
|
-
|
|
9587
|
+
const InfoCircleIconConfig = {
|
|
9670
9588
|
name: 'InfoCircleIcon',
|
|
9671
9589
|
height: 512,
|
|
9672
9590
|
width: 512,
|
|
9673
9591
|
svgPath: 'M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z',
|
|
9674
9592
|
yOffset: 0,
|
|
9675
|
-
xOffset: 0
|
|
9593
|
+
xOffset: 0,
|
|
9676
9594
|
};
|
|
9677
|
-
var InfoCircleIcon = createIcon(InfoCircleIconConfig);
|
|
9678
9595
|
|
|
9679
|
-
|
|
9596
|
+
const InfoCircleIcon = createIcon(InfoCircleIconConfig);
|
|
9597
|
+
|
|
9598
|
+
var _excluded = ["label", "isRequired", "children", "selectOptions", "ariaLabel", "placeholder", "helperText", "subLabel", "subInfo", "onChange", "extraProps", "selectOptionExtraProps", "isFullWidth", "isFullHeight"];
|
|
9680
9599
|
|
|
9681
9600
|
var FormSelect = function FormSelect(_ref) {
|
|
9682
9601
|
var label = _ref.label,
|
|
@@ -9684,13 +9603,16 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
9684
9603
|
selectOptions = _ref.selectOptions,
|
|
9685
9604
|
_ref$ariaLabel = _ref.ariaLabel,
|
|
9686
9605
|
ariaLabel = _ref$ariaLabel === void 0 ? 'Select Input' : _ref$ariaLabel,
|
|
9687
|
-
placeholder = _ref.placeholder,
|
|
9606
|
+
_ref$placeholder = _ref.placeholder,
|
|
9607
|
+
placeholder = _ref$placeholder === void 0 ? 'Select a value' : _ref$placeholder,
|
|
9688
9608
|
helperText = _ref.helperText,
|
|
9689
9609
|
subLabel = _ref.subLabel,
|
|
9690
9610
|
subInfo = _ref.subInfo,
|
|
9691
9611
|
onChange = _ref.onChange,
|
|
9692
9612
|
extraProps = _ref.extraProps,
|
|
9693
9613
|
selectOptionExtraProps = _ref.selectOptionExtraProps,
|
|
9614
|
+
isFullWidth = _ref.isFullWidth,
|
|
9615
|
+
isFullHeight = _ref.isFullHeight,
|
|
9694
9616
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
9695
9617
|
|
|
9696
9618
|
var _useField = formik.useField(rest),
|
|
@@ -9707,7 +9629,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
9707
9629
|
isOpen = _React$useState[0],
|
|
9708
9630
|
setIsOpen = _React$useState[1];
|
|
9709
9631
|
|
|
9710
|
-
var _React$useState2 = React__namespace.useState(
|
|
9632
|
+
var _React$useState2 = React__namespace.useState(placeholder),
|
|
9711
9633
|
selected = _React$useState2[0],
|
|
9712
9634
|
setSelected = _React$useState2[1];
|
|
9713
9635
|
|
|
@@ -9722,17 +9644,20 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
9722
9644
|
onToggle();
|
|
9723
9645
|
};
|
|
9724
9646
|
|
|
9647
|
+
var toggle = function toggle(toggleRef) {
|
|
9648
|
+
return React__namespace.createElement(reactCore.MenuToggle, {
|
|
9649
|
+
ref: toggleRef,
|
|
9650
|
+
onClick: onToggle,
|
|
9651
|
+
isExpanded: isOpen,
|
|
9652
|
+
isFullWidth: isFullWidth,
|
|
9653
|
+
isFullHeight: isFullHeight,
|
|
9654
|
+
isDisabled: isSubmitting
|
|
9655
|
+
}, selected);
|
|
9656
|
+
};
|
|
9657
|
+
|
|
9725
9658
|
React__namespace.useEffect(function () {
|
|
9726
9659
|
setSelected(value);
|
|
9727
|
-
}, [value]);
|
|
9728
|
-
// // Code to reset check mark when the options are changed
|
|
9729
|
-
// if (value) {
|
|
9730
|
-
// setFieldValue(rest.name, '');
|
|
9731
|
-
// validateField(rest.name);
|
|
9732
|
-
// }
|
|
9733
|
-
// // eslint-disable-next-line
|
|
9734
|
-
// }, [selectOptions]);
|
|
9735
|
-
|
|
9660
|
+
}, [value]);
|
|
9736
9661
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(formGroupContainer.FormGroupContainer, {
|
|
9737
9662
|
validated: meta.touched && meta.error ? reactCore.ValidatedOptions.error : reactCore.ValidatedOptions["default"],
|
|
9738
9663
|
helperTextInvalid: meta.error,
|
|
@@ -9750,17 +9675,19 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
9750
9675
|
})), React__namespace.createElement(reactCore.SplitItem, {
|
|
9751
9676
|
isFilled: true
|
|
9752
9677
|
}, subInfo))), React__namespace.createElement(reactCore.Select, Object.assign({
|
|
9753
|
-
variant: reactCore.SelectVariant.single,
|
|
9754
9678
|
"aria-labelledby": rest.name,
|
|
9755
|
-
|
|
9756
|
-
placeholderText: placeholder || 'Select an option',
|
|
9757
|
-
onToggle: onToggle,
|
|
9679
|
+
toggle: toggle,
|
|
9758
9680
|
onSelect: onSelect,
|
|
9759
|
-
|
|
9681
|
+
selected: selected,
|
|
9760
9682
|
isOpen: isOpen,
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9683
|
+
popperProps: {
|
|
9684
|
+
enableFlip: false
|
|
9685
|
+
},
|
|
9686
|
+
"aria-label": ariaLabel,
|
|
9687
|
+
onOpenChange: function onOpenChange() {
|
|
9688
|
+
return setIsOpen(!isOpen);
|
|
9689
|
+
}
|
|
9690
|
+
}, extraProps && _extends({}, extraProps), rest), React__namespace.createElement(reactCore.SelectList, null, lodash.map(selectOptions, function (option, index) {
|
|
9764
9691
|
return React__namespace.createElement(reactCore.SelectOption, Object.assign({
|
|
9765
9692
|
key: index,
|
|
9766
9693
|
value: option.value,
|
|
@@ -9771,8 +9698,8 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
9771
9698
|
isPlaceholder: option.isPlaceholder
|
|
9772
9699
|
}, option.isDisabled && {
|
|
9773
9700
|
isDisabled: option.isDisabled
|
|
9774
|
-
}, selectOptionExtraProps && _extends({}, selectOptionExtraProps)));
|
|
9775
|
-
}))));
|
|
9701
|
+
}, selectOptionExtraProps && _extends({}, selectOptionExtraProps)), option.value);
|
|
9702
|
+
})))));
|
|
9776
9703
|
};
|
|
9777
9704
|
|
|
9778
9705
|
exports.FormSelect = FormSelect;
|
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, Split, SplitItem, Select,
|
|
3
|
+
import { ValidatedOptions, Split, SplitItem, Select, SelectList, SelectOption, MenuToggle } from '@patternfly/react-core';
|
|
4
4
|
import { FormGroupContainer } from '@rhc-shared-components/form-group-container';
|
|
5
5
|
|
|
6
6
|
function _extends() {
|
|
@@ -9507,117 +9507,61 @@ if(freeModule){// Export for Node.js.
|
|
|
9507
9507
|
freeExports._=_;}else {// Export to the global object.
|
|
9508
9508
|
root._=_;}}).call(commonjsGlobal);});
|
|
9509
9509
|
|
|
9510
|
-
|
|
9511
|
-
Copyright (c) Microsoft Corporation.
|
|
9512
|
-
|
|
9513
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9514
|
-
purpose with or without fee is hereby granted.
|
|
9515
|
-
|
|
9516
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9517
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9518
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
9519
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
9520
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
9521
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
9522
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
9510
|
+
/******************************************************************************
|
|
9511
|
+
Copyright (c) Microsoft Corporation.
|
|
9512
|
+
|
|
9513
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
9514
|
+
purpose with or without fee is hereby granted.
|
|
9515
|
+
|
|
9516
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9517
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9518
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
9519
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
9520
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
9521
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
9522
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
9523
9523
|
***************************************************************************** */
|
|
9524
|
+
|
|
9524
9525
|
function __rest(s, e) {
|
|
9525
9526
|
var t = {};
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9527
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
9528
|
+
t[p] = s[p];
|
|
9529
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
9530
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
9531
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9532
|
+
t[p[i]] = s[p[i]];
|
|
9533
|
+
}
|
|
9532
9534
|
return t;
|
|
9533
9535
|
}
|
|
9534
9536
|
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
IconSize["sm"] = "sm";
|
|
9539
|
-
IconSize["md"] = "md";
|
|
9540
|
-
IconSize["lg"] = "lg";
|
|
9541
|
-
IconSize["xl"] = "xl";
|
|
9542
|
-
})(IconSize || (IconSize = {}));
|
|
9543
|
-
|
|
9544
|
-
const getSize = size => {
|
|
9545
|
-
switch (size) {
|
|
9546
|
-
case IconSize.sm:
|
|
9547
|
-
return '1em';
|
|
9548
|
-
|
|
9549
|
-
case IconSize.md:
|
|
9550
|
-
return '1.5em';
|
|
9551
|
-
|
|
9552
|
-
case IconSize.lg:
|
|
9553
|
-
return '2em';
|
|
9554
|
-
|
|
9555
|
-
case IconSize.xl:
|
|
9556
|
-
return '3em';
|
|
9557
|
-
|
|
9558
|
-
default:
|
|
9559
|
-
return '1em';
|
|
9560
|
-
}
|
|
9537
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
9538
|
+
var e = new Error(message);
|
|
9539
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
9561
9540
|
};
|
|
9541
|
+
|
|
9562
9542
|
let currentId = 0;
|
|
9563
9543
|
/**
|
|
9564
9544
|
* Factory to create Icon class components for consumers
|
|
9565
9545
|
*/
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
})
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
{
|
|
9586
|
-
size,
|
|
9587
|
-
color,
|
|
9588
|
-
title,
|
|
9589
|
-
noVerticalAlign
|
|
9590
|
-
} = _a,
|
|
9591
|
-
props = __rest(_a, ["size", "color", "title", "noVerticalAlign"]);
|
|
9592
|
-
|
|
9593
|
-
const hasTitle = Boolean(title);
|
|
9594
|
-
const heightWidth = getSize(size);
|
|
9595
|
-
const baseAlign = -0.125 * Number.parseFloat(heightWidth);
|
|
9596
|
-
const style = noVerticalAlign ? null : {
|
|
9597
|
-
verticalAlign: `${baseAlign}em`
|
|
9598
|
-
};
|
|
9599
|
-
const viewBox = [xOffset, yOffset, width, height].join(' ');
|
|
9600
|
-
return React.createElement("svg", Object.assign({
|
|
9601
|
-
style: style,
|
|
9602
|
-
fill: color,
|
|
9603
|
-
height: heightWidth,
|
|
9604
|
-
width: heightWidth,
|
|
9605
|
-
viewBox: viewBox,
|
|
9606
|
-
"aria-labelledby": hasTitle ? this.id : null,
|
|
9607
|
-
"aria-hidden": hasTitle ? null : true,
|
|
9608
|
-
role: "img"
|
|
9609
|
-
}, props), hasTitle && React.createElement("title", {
|
|
9610
|
-
id: this.id
|
|
9611
|
-
}, title), React.createElement("path", {
|
|
9612
|
-
d: svgPath
|
|
9613
|
-
}));
|
|
9614
|
-
}
|
|
9615
|
-
|
|
9616
|
-
}, _a.displayName = name, _a.defaultProps = {
|
|
9617
|
-
color: 'currentColor',
|
|
9618
|
-
size: IconSize.sm,
|
|
9619
|
-
noVerticalAlign: false
|
|
9620
|
-
}, _a;
|
|
9546
|
+
function createIcon({ name, xOffset = 0, yOffset = 0, width, height, svgPath }) {
|
|
9547
|
+
var _a;
|
|
9548
|
+
return _a = class SVGIcon extends React.Component {
|
|
9549
|
+
constructor() {
|
|
9550
|
+
super(...arguments);
|
|
9551
|
+
this.id = `icon-title-${currentId++}`;
|
|
9552
|
+
}
|
|
9553
|
+
render() {
|
|
9554
|
+
const _a = this.props, { title, className } = _a, props = __rest(_a, ["title", "className"]);
|
|
9555
|
+
const classes = className ? `pf-v5-svg ${className}` : 'pf-v5-svg';
|
|
9556
|
+
const hasTitle = Boolean(title);
|
|
9557
|
+
const viewBox = [xOffset, yOffset, width, height].join(' ');
|
|
9558
|
+
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),
|
|
9559
|
+
hasTitle && React.createElement("title", { id: this.id }, title),
|
|
9560
|
+
React.createElement("path", { d: svgPath })));
|
|
9561
|
+
}
|
|
9562
|
+
},
|
|
9563
|
+
_a.displayName = name,
|
|
9564
|
+
_a;
|
|
9621
9565
|
}
|
|
9622
9566
|
|
|
9623
9567
|
const InfoCircleIconConfig = {
|
|
@@ -9626,11 +9570,12 @@ const InfoCircleIconConfig = {
|
|
|
9626
9570
|
width: 512,
|
|
9627
9571
|
svgPath: 'M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z',
|
|
9628
9572
|
yOffset: 0,
|
|
9629
|
-
xOffset: 0
|
|
9573
|
+
xOffset: 0,
|
|
9630
9574
|
};
|
|
9575
|
+
|
|
9631
9576
|
const InfoCircleIcon = createIcon(InfoCircleIconConfig);
|
|
9632
9577
|
|
|
9633
|
-
const _excluded = ["label", "isRequired", "children", "selectOptions", "ariaLabel", "placeholder", "helperText", "subLabel", "subInfo", "onChange", "extraProps", "selectOptionExtraProps"];
|
|
9578
|
+
const _excluded = ["label", "isRequired", "children", "selectOptions", "ariaLabel", "placeholder", "helperText", "subLabel", "subInfo", "onChange", "extraProps", "selectOptionExtraProps", "isFullWidth", "isFullHeight"];
|
|
9634
9579
|
|
|
9635
9580
|
const FormSelect = _ref => {
|
|
9636
9581
|
let {
|
|
@@ -9638,13 +9583,15 @@ const FormSelect = _ref => {
|
|
|
9638
9583
|
isRequired,
|
|
9639
9584
|
selectOptions,
|
|
9640
9585
|
ariaLabel = 'Select Input',
|
|
9641
|
-
placeholder,
|
|
9586
|
+
placeholder = 'Select a value',
|
|
9642
9587
|
helperText,
|
|
9643
9588
|
subLabel,
|
|
9644
9589
|
subInfo,
|
|
9645
9590
|
onChange,
|
|
9646
9591
|
extraProps,
|
|
9647
|
-
selectOptionExtraProps
|
|
9592
|
+
selectOptionExtraProps,
|
|
9593
|
+
isFullWidth,
|
|
9594
|
+
isFullHeight
|
|
9648
9595
|
} = _ref,
|
|
9649
9596
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
9650
9597
|
|
|
@@ -9658,7 +9605,7 @@ const FormSelect = _ref => {
|
|
|
9658
9605
|
validateField
|
|
9659
9606
|
} = useFormikContext();
|
|
9660
9607
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
9661
|
-
const [selected, setSelected] = React.useState(
|
|
9608
|
+
const [selected, setSelected] = React.useState(placeholder);
|
|
9662
9609
|
|
|
9663
9610
|
const onToggle = () => {
|
|
9664
9611
|
setIsOpen(!isOpen);
|
|
@@ -9671,17 +9618,18 @@ const FormSelect = _ref => {
|
|
|
9671
9618
|
onToggle();
|
|
9672
9619
|
};
|
|
9673
9620
|
|
|
9621
|
+
const toggle = toggleRef => React.createElement(MenuToggle, {
|
|
9622
|
+
ref: toggleRef,
|
|
9623
|
+
onClick: onToggle,
|
|
9624
|
+
isExpanded: isOpen,
|
|
9625
|
+
isFullWidth: isFullWidth,
|
|
9626
|
+
isFullHeight: isFullHeight,
|
|
9627
|
+
isDisabled: isSubmitting
|
|
9628
|
+
}, selected);
|
|
9629
|
+
|
|
9674
9630
|
React.useEffect(() => {
|
|
9675
9631
|
setSelected(value);
|
|
9676
|
-
}, [value]);
|
|
9677
|
-
// // Code to reset check mark when the options are changed
|
|
9678
|
-
// if (value) {
|
|
9679
|
-
// setFieldValue(rest.name, '');
|
|
9680
|
-
// validateField(rest.name);
|
|
9681
|
-
// }
|
|
9682
|
-
// // eslint-disable-next-line
|
|
9683
|
-
// }, [selectOptions]);
|
|
9684
|
-
|
|
9632
|
+
}, [value]);
|
|
9685
9633
|
return React.createElement(React.Fragment, null, React.createElement(FormGroupContainer, {
|
|
9686
9634
|
validated: meta.touched && meta.error ? ValidatedOptions.error : ValidatedOptions.default,
|
|
9687
9635
|
helperTextInvalid: meta.error,
|
|
@@ -9699,17 +9647,17 @@ const FormSelect = _ref => {
|
|
|
9699
9647
|
})), React.createElement(SplitItem, {
|
|
9700
9648
|
isFilled: true
|
|
9701
9649
|
}, subInfo))), React.createElement(Select, Object.assign({
|
|
9702
|
-
variant: SelectVariant.single,
|
|
9703
9650
|
"aria-labelledby": rest.name,
|
|
9704
|
-
|
|
9705
|
-
placeholderText: placeholder || 'Select an option',
|
|
9706
|
-
onToggle: onToggle,
|
|
9651
|
+
toggle: toggle,
|
|
9707
9652
|
onSelect: onSelect,
|
|
9708
|
-
|
|
9653
|
+
selected: selected,
|
|
9709
9654
|
isOpen: isOpen,
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9655
|
+
popperProps: {
|
|
9656
|
+
enableFlip: false
|
|
9657
|
+
},
|
|
9658
|
+
"aria-label": ariaLabel,
|
|
9659
|
+
onOpenChange: () => setIsOpen(!isOpen)
|
|
9660
|
+
}, extraProps && _extends({}, extraProps), rest), React.createElement(SelectList, null, lodash.map(selectOptions, (option, index) => React.createElement(SelectOption, Object.assign({
|
|
9713
9661
|
key: index,
|
|
9714
9662
|
value: option.value,
|
|
9715
9663
|
"data-testid": option.key
|
|
@@ -9719,7 +9667,7 @@ const FormSelect = _ref => {
|
|
|
9719
9667
|
isPlaceholder: option.isPlaceholder
|
|
9720
9668
|
}, option.isDisabled && {
|
|
9721
9669
|
isDisabled: option.isDisabled
|
|
9722
|
-
}, selectOptionExtraProps && _extends({}, selectOptionExtraProps)))))));
|
|
9670
|
+
}, selectOptionExtraProps && _extends({}, selectOptionExtraProps)), option.value))))));
|
|
9723
9671
|
};
|
|
9724
9672
|
|
|
9725
9673
|
export { FormSelect };
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhc-shared-components/form-select-component",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "project description",
|
|
5
5
|
"author": "redhatofficial",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "https://gitlab.cee.redhat.com/customer-platform/rhc-shared-components/",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.modern.js",
|
|
10
|
-
"source": "src/index.tsx",
|
|
11
10
|
"engines": {
|
|
12
11
|
"node": ">=10"
|
|
13
12
|
},
|
|
@@ -24,7 +23,7 @@
|
|
|
24
23
|
"predeploy": "cd example && yarn install && yarn run build"
|
|
25
24
|
},
|
|
26
25
|
"peerDependencies": {
|
|
27
|
-
"@patternfly/react-core": ">=
|
|
26
|
+
"@patternfly/react-core": ">=5.3.4",
|
|
28
27
|
"formik": ">=2.1.4",
|
|
29
28
|
"react": ">=16.13.1",
|
|
30
29
|
"react-dom": ">=16.13.1"
|
|
@@ -62,7 +61,7 @@
|
|
|
62
61
|
"typescript": "^3.7.5"
|
|
63
62
|
},
|
|
64
63
|
"dependencies": {
|
|
65
|
-
"@patternfly/react-core": "
|
|
64
|
+
"@patternfly/react-core": "5.3.4",
|
|
66
65
|
"@rhc-shared-components/form-group-container": "^1.0.1",
|
|
67
66
|
"formik": "^2.1.4",
|
|
68
67
|
"react": "^16.13.1",
|