@agility/plenum-ui 1.3.9 → 1.3.10
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/lib/components/Forms/Radio/Radio.d.ts +2 -2
- package/lib/components/Forms/Select/Select.d.ts +2 -2
- package/lib/components/Forms/TextInput/TextInput.d.ts +2 -2
- package/lib/components/Forms/TextInputAddon/TextInputAddon.d.ts +6 -6
- package/lib/components/Forms/TextInputSelect/TextInputSelect.d.ts +2 -2
- package/lib/components/Forms/Textarea/Textarea.d.ts +4 -3
- package/lib/index.esm.js +68 -21
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +68 -21
- package/lib/index.js.map +1 -1
- package/lib/util/useID.d.ts +1 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -12448,15 +12448,26 @@ var BaseField = function (_a, ref) {
|
|
|
12448
12448
|
};
|
|
12449
12449
|
var _BaseField = React.forwardRef(BaseField);
|
|
12450
12450
|
|
|
12451
|
+
var id = 0;
|
|
12452
|
+
function generateId() {
|
|
12453
|
+
return ++id;
|
|
12454
|
+
}
|
|
12455
|
+
var useId = function () {
|
|
12456
|
+
var _a = React.useState(generateId), id = _a[0], setId = _a[1];
|
|
12457
|
+
React.useLayoutEffect(function () {
|
|
12458
|
+
if (id === null)
|
|
12459
|
+
setId(generateId());
|
|
12460
|
+
}, [id]);
|
|
12461
|
+
return id != null ? '' + id : undefined;
|
|
12462
|
+
};
|
|
12463
|
+
|
|
12451
12464
|
var TextInput = function (_a, ref) {
|
|
12452
12465
|
var label = _a.label, isFocused = _a.isFocused, isError = _a.isError, id = _a.id, name = _a.name, isRequired = _a.isRequired, type = _a.type, defaultValue = _a.defaultValue, isDisabled = _a.isDisabled, message = _a.message, isShowCounter = _a.isShowCounter, _b = _a.maxLength, maxLength = _b === void 0 ? 100 : _b, onChange = _a.onChange, externalValue = _a.value;
|
|
12466
|
+
var uniqueID = useId();
|
|
12453
12467
|
var _c = React.useState(Boolean(isFocused)), isFocus = _c[0], setIsFocus = _c[1];
|
|
12454
12468
|
var _d = React.useState(false); _d[0]; var setIsActive = _d[1];
|
|
12455
|
-
var _e = React.useState(defaultValue || ""), value = _e[0], setValue = _e[1];
|
|
12469
|
+
var _e = React.useState(externalValue || defaultValue || ""), value = _e[0], setValue = _e[1];
|
|
12456
12470
|
var inputRef = React.useRef(null);
|
|
12457
|
-
React.useEffect(function () {
|
|
12458
|
-
setValue(externalValue);
|
|
12459
|
-
}, [externalValue]);
|
|
12460
12471
|
// set force focus
|
|
12461
12472
|
React.useEffect(function () {
|
|
12462
12473
|
var input = inputRef.current;
|
|
@@ -12490,6 +12501,11 @@ var TextInput = function (_a, ref) {
|
|
|
12490
12501
|
"focus:ring-purple-500 border-purple-500 outline-purple-500 shadow-none": isFocus && !isError
|
|
12491
12502
|
}, { "focus:ring-red-500 !border-red-500 shadow-none": isError });
|
|
12492
12503
|
var discriptionStyles = cn("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError });
|
|
12504
|
+
if (!id)
|
|
12505
|
+
id = "input-".concat(uniqueID);
|
|
12506
|
+
if (!name)
|
|
12507
|
+
name = id;
|
|
12508
|
+
console.log();
|
|
12493
12509
|
return (React__default["default"].createElement("div", null,
|
|
12494
12510
|
React__default["default"].createElement(InputLabel, { isPlaceholder: true, label: label, isRequired: isRequired, id: id, isError: isError, isActive: true, isDisabled: isDisabled }),
|
|
12495
12511
|
React__default["default"].createElement("div", null,
|
|
@@ -12530,17 +12546,25 @@ var InputCta = function (_a) {
|
|
|
12530
12546
|
};
|
|
12531
12547
|
|
|
12532
12548
|
var TextInputAddon = function (_a, ref) {
|
|
12533
|
-
var label = _a.label, isFocused = _a.isFocused, isError = _a.isError, id = _a.id, name = _a.name, isRequired = _a.isRequired, type = _a.type, defaultValue = _a.defaultValue, isDisabled = _a.isDisabled, message = _a.message, isShowCounter = _a.isShowCounter, _b = _a.maxLength, maxLength = _b === void 0 ? 100 : _b, placeholder = _a.placeholder, leadIcon = _a.leadIcon, trailIcon = _a.trailIcon, inlineIcon = _a.inlineIcon, trailLabel = _a.trailLabel, leadLabel = _a.leadLabel, _c = _a.clearCta, clearCta = _c === void 0 ?
|
|
12549
|
+
var label = _a.label, isFocused = _a.isFocused, isError = _a.isError, id = _a.id, name = _a.name, isRequired = _a.isRequired, type = _a.type, defaultValue = _a.defaultValue, isDisabled = _a.isDisabled, message = _a.message, isShowCounter = _a.isShowCounter, _b = _a.maxLength, maxLength = _b === void 0 ? 100 : _b, placeholder = _a.placeholder, leadIcon = _a.leadIcon, trailIcon = _a.trailIcon, inlineIcon = _a.inlineIcon, trailLabel = _a.trailLabel, leadLabel = _a.leadLabel, _c = _a.clearCta, clearCta = _c === void 0 ? "none" : _c, onChange = _a.onChange, onCtaClick = _a.onCtaClick, externalValue = _a.value;
|
|
12534
12550
|
var _d = React.useState(Boolean(isFocused)), isFocus = _d[0], setIsFocus = _d[1];
|
|
12535
|
-
var _e = React.useState(defaultValue ||
|
|
12551
|
+
var _e = React.useState(defaultValue || ""), value = _e[0], setValue = _e[1];
|
|
12536
12552
|
var inputRef = React.useRef(null);
|
|
12553
|
+
var uniqueID = useId();
|
|
12554
|
+
if (!id)
|
|
12555
|
+
id = "input-".concat(uniqueID);
|
|
12556
|
+
if (!name)
|
|
12557
|
+
name = id;
|
|
12537
12558
|
React.useEffect(function () {
|
|
12538
12559
|
setValue(externalValue);
|
|
12539
12560
|
}, [externalValue]);
|
|
12540
12561
|
// set force focus
|
|
12541
12562
|
React.useEffect(function () {
|
|
12542
12563
|
var input = inputRef.current;
|
|
12543
|
-
if (!input ||
|
|
12564
|
+
if (!input ||
|
|
12565
|
+
isFocus === undefined ||
|
|
12566
|
+
isFocused === undefined ||
|
|
12567
|
+
isDisabled)
|
|
12544
12568
|
return;
|
|
12545
12569
|
if (isFocus || isFocused) {
|
|
12546
12570
|
input.focus();
|
|
@@ -12552,7 +12576,7 @@ var TextInputAddon = function (_a, ref) {
|
|
|
12552
12576
|
// set label as active if default value is set
|
|
12553
12577
|
React.useEffect(function () {
|
|
12554
12578
|
var input = inputRef.current;
|
|
12555
|
-
if (!input || defaultValue === undefined || defaultValue ===
|
|
12579
|
+
if (!input || defaultValue === undefined || defaultValue === "")
|
|
12556
12580
|
return;
|
|
12557
12581
|
}, [defaultValue]);
|
|
12558
12582
|
var handleInputFocus = function () {
|
|
@@ -12563,19 +12587,25 @@ var TextInputAddon = function (_a, ref) {
|
|
|
12563
12587
|
setIsFocus(false);
|
|
12564
12588
|
// add other focus effects here
|
|
12565
12589
|
};
|
|
12566
|
-
var className = cn(
|
|
12567
|
-
|
|
12590
|
+
var className = cn("border py-2 px-3 rounded text-sm leading-5 font-normal w-full border-gray-300 outline-purple-500 shadow-sm focus:outline-none focus:ring-1 focus:ring-purple-500 focus:border-purple-500 ", {
|
|
12591
|
+
"focus:ring-red-500 !border-red-500 !outline-red-500 shadow-none": isError
|
|
12592
|
+
}, { "pl-10": inlineIcon }, {
|
|
12593
|
+
"!rounded-r-none !rounded-l": (trailIcon || trailLabel) && !(leadIcon || leadLabel)
|
|
12594
|
+
}, {
|
|
12595
|
+
"!rounded-r-none !rounded-r": !(trailIcon || trailLabel) && (leadIcon || leadLabel)
|
|
12596
|
+
}, { "rounded-none": (trailIcon || trailLabel) && (leadIcon || leadLabel) });
|
|
12597
|
+
var discriptionStyles = cn("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError });
|
|
12568
12598
|
return (React__default["default"].createElement("div", null,
|
|
12569
12599
|
label && (React__default["default"].createElement(InputLabel, { label: label, isRequired: isRequired, id: id, isError: isError, isDisabled: isDisabled })),
|
|
12570
12600
|
React__default["default"].createElement("div", { className: "flex" },
|
|
12571
|
-
(leadIcon || leadLabel) && (React__default["default"].createElement(InputCta, { icon: leadIcon, ctaLabel: leadLabel, align: "left", isClear: clearCta ===
|
|
12572
|
-
React__default["default"].createElement("div", { className: "flex-grow focus-within:z-20
|
|
12573
|
-
inlineIcon && (React__default["default"].createElement("div", { className: "absolute inset-y-0 left-0
|
|
12601
|
+
(leadIcon || leadLabel) && (React__default["default"].createElement(InputCta, { icon: leadIcon, ctaLabel: leadLabel, align: "left", isClear: clearCta === "left" || clearCta === "both" })),
|
|
12602
|
+
React__default["default"].createElement("div", { className: "relative flex-grow focus-within:z-20" },
|
|
12603
|
+
inlineIcon && (React__default["default"].createElement("div", { className: "pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3" },
|
|
12574
12604
|
React__default["default"].createElement(DynamicIcons, { icon: inlineIcon, className: "h-5 w-5 text-gray-400", outline: false }))),
|
|
12575
12605
|
React__default["default"].createElement(_BaseField, { onFocus: handleInputFocus, onBlur: handleInputBlur, onChange: onChange, onValueChange: setValue, ref: ref, type: type, name: name, id: id, className: className, isDisabled: isDisabled, value: value, defaultValue: defaultValue, maxLength: maxLength, placeholder: placeholder })),
|
|
12576
|
-
(trailIcon || trailLabel) && (React__default["default"].createElement(InputCta, { icon: trailIcon, ctaLabel: trailLabel, align: "right", isClear: clearCta ===
|
|
12606
|
+
(trailIcon || trailLabel) && (React__default["default"].createElement(InputCta, { icon: trailIcon, ctaLabel: trailLabel, align: "right", isClear: clearCta === "right" || clearCta === "both", onClickHandler: onCtaClick }))),
|
|
12577
12607
|
React__default["default"].createElement("div", { className: "flex flex-row space-x-3" },
|
|
12578
|
-
React__default["default"].createElement("div", { className: "grow" }, message && React__default["default"].createElement("span", { className: discriptionStyles }, message)),
|
|
12608
|
+
React__default["default"].createElement("div", { className: "grow" }, message && (React__default["default"].createElement("span", { className: discriptionStyles }, message))),
|
|
12579
12609
|
isShowCounter && (React__default["default"].createElement("div", { className: "shrink-0" },
|
|
12580
12610
|
React__default["default"].createElement(InputCounter, { current: Number(value === null || value === void 0 ? void 0 : value.length), limit: maxLength }))))));
|
|
12581
12611
|
};
|
|
@@ -12604,6 +12634,11 @@ var TextInputSelect = function (_a) {
|
|
|
12604
12634
|
var _d = React.useState(Boolean(isFocused)), isFocus = _d[0], setIsFocus = _d[1];
|
|
12605
12635
|
var _e = React.useState(defaultValue || ""), value = _e[0], setValue = _e[1];
|
|
12606
12636
|
var inputRef = React.useRef(null);
|
|
12637
|
+
var uniqueID = useId();
|
|
12638
|
+
if (!id)
|
|
12639
|
+
id = "select-".concat(uniqueID);
|
|
12640
|
+
if (!name)
|
|
12641
|
+
name = id;
|
|
12607
12642
|
React.useEffect(function () {
|
|
12608
12643
|
setValue(externalValue);
|
|
12609
12644
|
}, [externalValue]);
|
|
@@ -12662,6 +12697,11 @@ var TextInputSelect = function (_a) {
|
|
|
12662
12697
|
/** Comment */
|
|
12663
12698
|
var Radio = function (_a) {
|
|
12664
12699
|
var label = _a.label, id = _a.id, name = _a.name, _b = _a.isDisabled, isDisabled = _b === void 0 ? false : _b, _c = _a.isChecked, isChecked = _c === void 0 ? false : _c, _d = _a.isRequired, isRequired = _d === void 0 ? false : _d, _e = _a.isError, isError = _e === void 0 ? false : _e, message = _a.message, onChange = _a.onChange, onClick = _a.onClick, value = _a.value;
|
|
12700
|
+
var uniqueID = useId();
|
|
12701
|
+
if (!id)
|
|
12702
|
+
id = "input-".concat(uniqueID);
|
|
12703
|
+
if (!name)
|
|
12704
|
+
name = id;
|
|
12665
12705
|
var checboxStyles = cn('focus:ring-purple-500 h-4 w-4 text-purple-600 border-gray-300', {
|
|
12666
12706
|
'border-red-500 shadow-none': isError
|
|
12667
12707
|
});
|
|
@@ -12689,8 +12729,9 @@ var Radio = function (_a) {
|
|
|
12689
12729
|
};
|
|
12690
12730
|
|
|
12691
12731
|
var Textarea = function (_a, ref) {
|
|
12692
|
-
var id = _a.id, name = _a.name, label = _a.label, isError = _a.isError, isRequired = _a.isRequired, isDisabled = _a.isDisabled, defaultValue = _a.defaultValue, message = _a.message, isShowCounter = _a.isShowCounter, _b = _a.maxLength, maxLength = _b === void 0 ? 500 : _b, _c = _a.rows, rows = _c === void 0 ? 4 : _c, onChange = _a.onChange;
|
|
12693
|
-
var
|
|
12732
|
+
var id = _a.id, name = _a.name, label = _a.label, isError = _a.isError, isRequired = _a.isRequired, isDisabled = _a.isDisabled, defaultValue = _a.defaultValue, message = _a.message, isShowCounter = _a.isShowCounter, _b = _a.maxLength, maxLength = _b === void 0 ? 500 : _b, _c = _a.rows, rows = _c === void 0 ? 4 : _c, onChange = _a.onChange, externalValue = _a.value;
|
|
12733
|
+
var uniqueID = useId();
|
|
12734
|
+
var _d = React.useState(externalValue || defaultValue || ""), value = _d[0], setValue = _d[1];
|
|
12694
12735
|
var handleOnchange = function (e) {
|
|
12695
12736
|
var targetValue = e.currentTarget.value;
|
|
12696
12737
|
typeof onChange === "function" && onChange(targetValue);
|
|
@@ -12698,13 +12739,14 @@ var Textarea = function (_a, ref) {
|
|
|
12698
12739
|
};
|
|
12699
12740
|
var className = cn("shadow-sm focus:ring-purple-500 focus:border-purple-500 block w-full sm:text-sm rounded", { "border-gray-300 ": !isError }, { "focus:ring-red-500 border-red-500 outline-red-500 shadow-none": isError });
|
|
12700
12741
|
var discriptionStyles = cn("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError });
|
|
12701
|
-
|
|
12702
|
-
|
|
12742
|
+
if (!id)
|
|
12743
|
+
id = "ta-".concat(uniqueID);
|
|
12744
|
+
return (React__default["default"].createElement("div", { className: cn({ "opacity-50": isDisabled }) },
|
|
12703
12745
|
label && (React__default["default"].createElement(InputLabel, { isPlaceholder: true, isActive: true, label: label, isRequired: isRequired, id: id, isError: isError, isDisabled: isDisabled })),
|
|
12704
12746
|
React__default["default"].createElement("div", null,
|
|
12705
|
-
React__default["default"].createElement("textarea", { ref: ref, maxLength: maxLength, onChange: handleOnchange, rows: rows, name: name, id: id, className: className, defaultValue: defaultValue })),
|
|
12747
|
+
React__default["default"].createElement("textarea", { ref: ref, maxLength: maxLength, onChange: handleOnchange, rows: rows, name: name, id: id, className: className, defaultValue: defaultValue, value: value })),
|
|
12706
12748
|
React__default["default"].createElement("div", { className: "flex flex-row space-x-3" },
|
|
12707
|
-
React__default["default"].createElement("div", { className: "grow" }, message && React__default["default"].createElement("span", { className: discriptionStyles }, message)),
|
|
12749
|
+
React__default["default"].createElement("div", { className: "grow" }, message && (React__default["default"].createElement("span", { className: discriptionStyles }, message))),
|
|
12708
12750
|
isShowCounter && (React__default["default"].createElement("div", { className: "shrink-0" },
|
|
12709
12751
|
React__default["default"].createElement(InputCounter, { current: Number(value === null || value === void 0 ? void 0 : value.length), limit: maxLength }))))));
|
|
12710
12752
|
};
|
|
@@ -12714,6 +12756,11 @@ var _Textarea = React.forwardRef(Textarea);
|
|
|
12714
12756
|
var Select = function (_a) {
|
|
12715
12757
|
var label = _a.label, id = _a.id, name = _a.name, options = _a.options, onChange = _a.onChange, isDisabled = _a.isDisabled, isError = _a.isError, isRequired = _a.isRequired;
|
|
12716
12758
|
var _b = React.useState(options[0].value), selectedOption = _b[0], setSelectedOption = _b[1];
|
|
12759
|
+
var uniqueID = useId();
|
|
12760
|
+
if (!id)
|
|
12761
|
+
id = "select-".concat(uniqueID);
|
|
12762
|
+
if (!name)
|
|
12763
|
+
name = id;
|
|
12717
12764
|
var handleChange = function (e) {
|
|
12718
12765
|
var targetValue = e.target.value;
|
|
12719
12766
|
typeof onChange == "function" && onChange(targetValue);
|