@rhc-shared-components/form-select-component 0.1.2 → 0.1.4
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 +5 -0
- package/dist/index.js +131 -51
- package/dist/index.modern.js +105 -49
- package/package.json +1 -1
|
@@ -6,6 +6,8 @@ export interface ISelectItem {
|
|
|
6
6
|
description?: string;
|
|
7
7
|
isDisabled?: boolean;
|
|
8
8
|
isPlaceholder?: boolean;
|
|
9
|
+
extraProps?: any;
|
|
10
|
+
selectOptionExtraProps?: any;
|
|
9
11
|
}
|
|
10
12
|
export interface FormSelectProps {
|
|
11
13
|
name: string;
|
|
@@ -17,6 +19,9 @@ export interface FormSelectProps {
|
|
|
17
19
|
subInfo?: string;
|
|
18
20
|
ariaLabel?: string;
|
|
19
21
|
helperText?: string;
|
|
22
|
+
onChange?: (_event: any, selection: any) => void;
|
|
23
|
+
extraProps?: any;
|
|
24
|
+
selectOptionExtraProps?: any;
|
|
20
25
|
}
|
|
21
26
|
declare const FormSelect: React.FC<FormSelectProps>;
|
|
22
27
|
export default FormSelect;
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,40 @@ function _interopNamespace(e) {
|
|
|
23
23
|
|
|
24
24
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
25
25
|
|
|
26
|
+
function _extends() {
|
|
27
|
+
_extends = Object.assign || function (target) {
|
|
28
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
29
|
+
var source = arguments[i];
|
|
30
|
+
|
|
31
|
+
for (var key in source) {
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
33
|
+
target[key] = source[key];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return target;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return _extends.apply(this, arguments);
|
|
42
|
+
}
|
|
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
|
+
|
|
26
60
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
27
61
|
if (source == null) return {};
|
|
28
62
|
var target = {};
|
|
@@ -9537,70 +9571,112 @@ function __rest(s, e) {
|
|
|
9537
9571
|
}
|
|
9538
9572
|
|
|
9539
9573
|
var IconSize;
|
|
9574
|
+
|
|
9540
9575
|
(function (IconSize) {
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9576
|
+
IconSize["sm"] = "sm";
|
|
9577
|
+
IconSize["md"] = "md";
|
|
9578
|
+
IconSize["lg"] = "lg";
|
|
9579
|
+
IconSize["xl"] = "xl";
|
|
9545
9580
|
})(IconSize || (IconSize = {}));
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
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
|
+
}
|
|
9559
9599
|
};
|
|
9560
|
-
|
|
9600
|
+
var currentId = 0;
|
|
9561
9601
|
/**
|
|
9562
9602
|
* Factory to create Icon class components for consumers
|
|
9563
9603
|
*/
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9604
|
+
|
|
9605
|
+
function createIcon(_ref) {
|
|
9606
|
+
var name = _ref.name,
|
|
9607
|
+
_ref$xOffset = _ref.xOffset,
|
|
9608
|
+
xOffset = _ref$xOffset === void 0 ? 0 : _ref$xOffset,
|
|
9609
|
+
_ref$yOffset = _ref.yOffset,
|
|
9610
|
+
yOffset = _ref$yOffset === void 0 ? 0 : _ref$yOffset,
|
|
9611
|
+
width = _ref.width,
|
|
9612
|
+
height = _ref.height,
|
|
9613
|
+
svgPath = _ref.svgPath;
|
|
9614
|
+
|
|
9615
|
+
var _a;
|
|
9616
|
+
|
|
9617
|
+
return _a = /*#__PURE__*/function (_React$Component) {
|
|
9618
|
+
_inheritsLoose(SVGIcon, _React$Component);
|
|
9619
|
+
|
|
9620
|
+
function SVGIcon() {
|
|
9621
|
+
var _this;
|
|
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;
|
|
9590
9667
|
}
|
|
9591
9668
|
|
|
9592
|
-
|
|
9669
|
+
var InfoCircleIconConfig = {
|
|
9593
9670
|
name: 'InfoCircleIcon',
|
|
9594
9671
|
height: 512,
|
|
9595
9672
|
width: 512,
|
|
9596
9673
|
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',
|
|
9597
9674
|
yOffset: 0,
|
|
9598
|
-
xOffset: 0
|
|
9675
|
+
xOffset: 0
|
|
9599
9676
|
};
|
|
9677
|
+
var InfoCircleIcon = createIcon(InfoCircleIconConfig);
|
|
9600
9678
|
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
var _excluded = ["label", "isRequired", "children", "selectOptions", "ariaLabel", "placeholder", "helperText", "subLabel", "subInfo"];
|
|
9679
|
+
var _excluded = ["label", "isRequired", "children", "selectOptions", "ariaLabel", "placeholder", "helperText", "subLabel", "subInfo", "onChange", "extraProps", "selectOptionExtraProps"];
|
|
9604
9680
|
|
|
9605
9681
|
var FormSelect = function FormSelect(_ref) {
|
|
9606
9682
|
var label = _ref.label,
|
|
@@ -9612,6 +9688,9 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
9612
9688
|
helperText = _ref.helperText,
|
|
9613
9689
|
subLabel = _ref.subLabel,
|
|
9614
9690
|
subInfo = _ref.subInfo,
|
|
9691
|
+
onChange = _ref.onChange,
|
|
9692
|
+
extraProps = _ref.extraProps,
|
|
9693
|
+
selectOptionExtraProps = _ref.selectOptionExtraProps,
|
|
9615
9694
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
9616
9695
|
|
|
9617
9696
|
var _useField = formik.useField(rest),
|
|
@@ -9637,6 +9716,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
9637
9716
|
};
|
|
9638
9717
|
|
|
9639
9718
|
var onSelect = function onSelect(_event, selection) {
|
|
9719
|
+
if (onChange) onChange(_event, selection);
|
|
9640
9720
|
setFieldValue(rest.name, selection);
|
|
9641
9721
|
validateField(rest.name);
|
|
9642
9722
|
onToggle();
|
|
@@ -9680,7 +9760,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
9680
9760
|
isOpen: isOpen,
|
|
9681
9761
|
isDisabled: isSubmitting,
|
|
9682
9762
|
"aria-label": ariaLabel
|
|
9683
|
-
}, rest), lodash.map(selectOptions, function (option, index) {
|
|
9763
|
+
}, extraProps && _extends({}, extraProps), rest), lodash.map(selectOptions, function (option, index) {
|
|
9684
9764
|
return React__namespace.createElement(reactCore.SelectOption, Object.assign({
|
|
9685
9765
|
key: index,
|
|
9686
9766
|
value: option.value,
|
|
@@ -9691,7 +9771,7 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
9691
9771
|
isPlaceholder: option.isPlaceholder
|
|
9692
9772
|
}, option.isDisabled && {
|
|
9693
9773
|
isDisabled: option.isDisabled
|
|
9694
|
-
}));
|
|
9774
|
+
}, selectOptionExtraProps && _extends({}, selectOptionExtraProps)));
|
|
9695
9775
|
}))));
|
|
9696
9776
|
};
|
|
9697
9777
|
|
package/dist/index.modern.js
CHANGED
|
@@ -3,6 +3,24 @@ import { useField, useFormikContext } from 'formik';
|
|
|
3
3
|
import { ValidatedOptions, Split, SplitItem, Select, SelectVariant, SelectOption } from '@patternfly/react-core';
|
|
4
4
|
import { FormGroupContainer } from '@rhc-shared-components/form-group-container';
|
|
5
5
|
|
|
6
|
+
function _extends() {
|
|
7
|
+
_extends = Object.assign || function (target) {
|
|
8
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
9
|
+
var source = arguments[i];
|
|
10
|
+
|
|
11
|
+
for (var key in source) {
|
|
12
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
13
|
+
target[key] = source[key];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return _extends.apply(this, arguments);
|
|
22
|
+
}
|
|
23
|
+
|
|
6
24
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
7
25
|
if (source == null) return {};
|
|
8
26
|
var target = {};
|
|
@@ -9515,56 +9533,91 @@ function __rest(s, e) {
|
|
|
9515
9533
|
}
|
|
9516
9534
|
|
|
9517
9535
|
var IconSize;
|
|
9536
|
+
|
|
9518
9537
|
(function (IconSize) {
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9538
|
+
IconSize["sm"] = "sm";
|
|
9539
|
+
IconSize["md"] = "md";
|
|
9540
|
+
IconSize["lg"] = "lg";
|
|
9541
|
+
IconSize["xl"] = "xl";
|
|
9523
9542
|
})(IconSize || (IconSize = {}));
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
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
9561
|
};
|
|
9538
9562
|
let currentId = 0;
|
|
9539
9563
|
/**
|
|
9540
9564
|
* Factory to create Icon class components for consumers
|
|
9541
9565
|
*/
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9566
|
+
|
|
9567
|
+
function createIcon({
|
|
9568
|
+
name,
|
|
9569
|
+
xOffset = 0,
|
|
9570
|
+
yOffset = 0,
|
|
9571
|
+
width,
|
|
9572
|
+
height,
|
|
9573
|
+
svgPath
|
|
9574
|
+
}) {
|
|
9575
|
+
var _a;
|
|
9576
|
+
|
|
9577
|
+
return _a = class SVGIcon extends React.Component {
|
|
9578
|
+
constructor() {
|
|
9579
|
+
super(...arguments);
|
|
9580
|
+
this.id = `icon-title-${currentId++}`;
|
|
9581
|
+
}
|
|
9582
|
+
|
|
9583
|
+
render() {
|
|
9584
|
+
const _a = this.props,
|
|
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;
|
|
9568
9621
|
}
|
|
9569
9622
|
|
|
9570
9623
|
const InfoCircleIconConfig = {
|
|
@@ -9573,12 +9626,11 @@ const InfoCircleIconConfig = {
|
|
|
9573
9626
|
width: 512,
|
|
9574
9627
|
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',
|
|
9575
9628
|
yOffset: 0,
|
|
9576
|
-
xOffset: 0
|
|
9629
|
+
xOffset: 0
|
|
9577
9630
|
};
|
|
9578
|
-
|
|
9579
9631
|
const InfoCircleIcon = createIcon(InfoCircleIconConfig);
|
|
9580
9632
|
|
|
9581
|
-
const _excluded = ["label", "isRequired", "children", "selectOptions", "ariaLabel", "placeholder", "helperText", "subLabel", "subInfo"];
|
|
9633
|
+
const _excluded = ["label", "isRequired", "children", "selectOptions", "ariaLabel", "placeholder", "helperText", "subLabel", "subInfo", "onChange", "extraProps", "selectOptionExtraProps"];
|
|
9582
9634
|
|
|
9583
9635
|
const FormSelect = _ref => {
|
|
9584
9636
|
let {
|
|
@@ -9589,7 +9641,10 @@ const FormSelect = _ref => {
|
|
|
9589
9641
|
placeholder,
|
|
9590
9642
|
helperText,
|
|
9591
9643
|
subLabel,
|
|
9592
|
-
subInfo
|
|
9644
|
+
subInfo,
|
|
9645
|
+
onChange,
|
|
9646
|
+
extraProps,
|
|
9647
|
+
selectOptionExtraProps
|
|
9593
9648
|
} = _ref,
|
|
9594
9649
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
9595
9650
|
|
|
@@ -9610,6 +9665,7 @@ const FormSelect = _ref => {
|
|
|
9610
9665
|
};
|
|
9611
9666
|
|
|
9612
9667
|
const onSelect = (_event, selection) => {
|
|
9668
|
+
if (onChange) onChange(_event, selection);
|
|
9613
9669
|
setFieldValue(rest.name, selection);
|
|
9614
9670
|
validateField(rest.name);
|
|
9615
9671
|
onToggle();
|
|
@@ -9653,7 +9709,7 @@ const FormSelect = _ref => {
|
|
|
9653
9709
|
isOpen: isOpen,
|
|
9654
9710
|
isDisabled: isSubmitting,
|
|
9655
9711
|
"aria-label": ariaLabel
|
|
9656
|
-
}, rest), lodash.map(selectOptions, (option, index) => React.createElement(SelectOption, Object.assign({
|
|
9712
|
+
}, extraProps && _extends({}, extraProps), rest), lodash.map(selectOptions, (option, index) => React.createElement(SelectOption, Object.assign({
|
|
9657
9713
|
key: index,
|
|
9658
9714
|
value: option.value,
|
|
9659
9715
|
"data-testid": option.key
|
|
@@ -9663,7 +9719,7 @@ const FormSelect = _ref => {
|
|
|
9663
9719
|
isPlaceholder: option.isPlaceholder
|
|
9664
9720
|
}, option.isDisabled && {
|
|
9665
9721
|
isDisabled: option.isDisabled
|
|
9666
|
-
}))))));
|
|
9722
|
+
}, selectOptionExtraProps && _extends({}, selectOptionExtraProps)))))));
|
|
9667
9723
|
};
|
|
9668
9724
|
|
|
9669
9725
|
export { FormSelect };
|