@agility/plenum-ui 1.3.9 → 1.3.12
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 +3 -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 +5 -3
- package/lib/index.esm.js +78 -30
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +78 -30
- package/lib/index.js.map +1 -1
- package/lib/util/useID.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
export interface RadioProps {
|
|
3
3
|
/** group name */
|
|
4
|
-
name
|
|
4
|
+
name?: string;
|
|
5
5
|
/** Radio label */
|
|
6
6
|
label: string;
|
|
7
7
|
/** Radio ID */
|
|
8
|
-
id
|
|
8
|
+
id?: string;
|
|
9
9
|
/** Disabled state */
|
|
10
10
|
isDisabled?: boolean;
|
|
11
11
|
/** Check state */
|
|
@@ -7,9 +7,9 @@ export interface SimpleSelectProps {
|
|
|
7
7
|
/** Label */
|
|
8
8
|
label?: string;
|
|
9
9
|
/** Select ID prop */
|
|
10
|
-
id
|
|
10
|
+
id?: string;
|
|
11
11
|
/** Select name prop */
|
|
12
|
-
name
|
|
12
|
+
name?: string;
|
|
13
13
|
/** List of options to display in the select menu */
|
|
14
14
|
options: SimpleSelectOptions[];
|
|
15
15
|
/** Select name prop */
|
|
@@ -4,9 +4,9 @@ export interface TextInputProps {
|
|
|
4
4
|
/** Input type*/
|
|
5
5
|
type: Type;
|
|
6
6
|
/** Input ID */
|
|
7
|
-
id
|
|
7
|
+
id?: string;
|
|
8
8
|
/** Input Name */
|
|
9
|
-
name
|
|
9
|
+
name?: string;
|
|
10
10
|
/** Label for the input */
|
|
11
11
|
label: string;
|
|
12
12
|
/** Force the focus state on the input */
|
|
@@ -29,6 +29,7 @@ export interface TextInputProps {
|
|
|
29
29
|
onChange?(value: string): void;
|
|
30
30
|
/** input value */
|
|
31
31
|
value?: string;
|
|
32
|
+
className?: string;
|
|
32
33
|
}
|
|
33
34
|
declare const _TextInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
34
35
|
export { _TextInput as TextInput };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { IconName } from
|
|
3
|
-
export declare type Type =
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IconName } from "../../../util/DynamicIcons";
|
|
3
|
+
export declare type Type = "text" | "email" | "number" | "password" | "search" | "tel" | "url" | "date" | "datetime-local" | "month" | "time" | "week" | "currency";
|
|
4
4
|
export interface TextInputAddonProps {
|
|
5
5
|
/** Input type*/
|
|
6
6
|
type: Type;
|
|
7
7
|
/** Input ID */
|
|
8
|
-
id
|
|
8
|
+
id?: string;
|
|
9
9
|
/** Input Name */
|
|
10
|
-
name
|
|
10
|
+
name?: string;
|
|
11
11
|
/** Label for the input */
|
|
12
12
|
label?: string;
|
|
13
13
|
/** placeholder for the input */
|
|
@@ -41,7 +41,7 @@ export interface TextInputAddonProps {
|
|
|
41
41
|
/** Leading label for input CTA */
|
|
42
42
|
leadLabel?: string;
|
|
43
43
|
/** Remove bg and border from CTA */
|
|
44
|
-
clearCta?:
|
|
44
|
+
clearCta?: "left" | "right" | "both" | "none";
|
|
45
45
|
/** Callback on change */
|
|
46
46
|
onChange?(value: string): void;
|
|
47
47
|
/** Callback on Cta click */
|
|
@@ -8,9 +8,9 @@ export interface TextInputSelectProps {
|
|
|
8
8
|
/** Input type*/
|
|
9
9
|
type: Type;
|
|
10
10
|
/** Input ID */
|
|
11
|
-
id
|
|
11
|
+
id?: string;
|
|
12
12
|
/** Input Name */
|
|
13
|
-
name
|
|
13
|
+
name?: string;
|
|
14
14
|
/** Label for the input */
|
|
15
15
|
label?: string;
|
|
16
16
|
/** placeholder for the input */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface TextareaProps {
|
|
3
3
|
/** Input ID */
|
|
4
|
-
id
|
|
4
|
+
id?: string;
|
|
5
5
|
/** Input Name */
|
|
6
|
-
name
|
|
6
|
+
name?: string;
|
|
7
7
|
/** Label for the input */
|
|
8
|
-
label
|
|
8
|
+
label?: string;
|
|
9
9
|
/** Error state */
|
|
10
10
|
isError?: boolean;
|
|
11
11
|
/** If field is required */
|
|
@@ -14,6 +14,7 @@ export interface TextareaProps {
|
|
|
14
14
|
isDisabled?: boolean;
|
|
15
15
|
/** Set default value */
|
|
16
16
|
defaultValue?: string;
|
|
17
|
+
value?: string;
|
|
17
18
|
/** Message shown under the text field */
|
|
18
19
|
message?: string;
|
|
19
20
|
/** Input character counter */
|
|
@@ -24,6 +25,7 @@ export interface TextareaProps {
|
|
|
24
25
|
onChange?(value: string): void;
|
|
25
26
|
/** Number of rows */
|
|
26
27
|
rows?: number;
|
|
28
|
+
placeholder?: string;
|
|
27
29
|
}
|
|
28
30
|
declare const _Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
29
31
|
export { _Textarea as Textarea };
|
package/lib/index.esm.js
CHANGED
|
@@ -7324,7 +7324,7 @@ var Switch = function (_a) {
|
|
|
7324
7324
|
}, [enabled]);
|
|
7325
7325
|
var switchStyles = cn("relative inline-flex flex-shrink-0", "border-2 border-transparent rounded-full cursor-pointer", "transition-colors ease-in-out duration-200 focus:outline-none", "focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75", { "bg-purple-600": enabled }, { "bg-gray-200": !enabled }, { "h-[38px] w-[74px]": size === "lg" }, { "h-[28px] w-[64px]": size === "md" }, { "h-[18px] w-[34px]": size === "sm" });
|
|
7326
7326
|
// the circular button inside the switch
|
|
7327
|
-
var toggleStyles = cn("pointer-events-none inline-block rounded-full bg-white", "
|
|
7327
|
+
var toggleStyles = cn("pointer-events-none inline-block rounded-full bg-white", " transform ring-0 transition ease-in-out duration-200", { "translate-x-9": enabled }, { "translate-x-0": !enabled }, { "h-[34px] w-[34px]": size === "lg" }, { "h-[24px] w-[24px]": size === "md" }, { "h-[14px] w-[14px] translate-x-4": size === "sm" && enabled }, { "h-[14px] w-[14px] translate-x-0": size === "sm" && !enabled });
|
|
7328
7328
|
return (React__default.createElement("div", { className: "text-center" },
|
|
7329
7329
|
React__default.createElement(ue, { checked: enabled, onChange: setEnabled, className: switchStyles },
|
|
7330
7330
|
React__default.createElement("span", { className: "sr-only" }, "Use setting"),
|
|
@@ -12422,15 +12422,26 @@ var BaseField = function (_a, ref) {
|
|
|
12422
12422
|
};
|
|
12423
12423
|
var _BaseField = forwardRef(BaseField);
|
|
12424
12424
|
|
|
12425
|
+
var id = 0;
|
|
12426
|
+
function generateId() {
|
|
12427
|
+
return ++id;
|
|
12428
|
+
}
|
|
12429
|
+
var useId = function () {
|
|
12430
|
+
var _a = useState(generateId), id = _a[0], setId = _a[1];
|
|
12431
|
+
useLayoutEffect(function () {
|
|
12432
|
+
if (id === null)
|
|
12433
|
+
setId(generateId());
|
|
12434
|
+
}, [id]);
|
|
12435
|
+
return id != null ? '' + id : undefined;
|
|
12436
|
+
};
|
|
12437
|
+
|
|
12425
12438
|
var TextInput = function (_a, ref) {
|
|
12426
|
-
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;
|
|
12439
|
+
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, className = _a.className;
|
|
12440
|
+
var uniqueID = useId();
|
|
12427
12441
|
var _c = useState(Boolean(isFocused)), isFocus = _c[0], setIsFocus = _c[1];
|
|
12428
12442
|
var _d = useState(false); _d[0]; var setIsActive = _d[1];
|
|
12429
|
-
var _e = useState(defaultValue || ""), value = _e[0], setValue = _e[1];
|
|
12443
|
+
var _e = useState(externalValue || defaultValue || ""), value = _e[0], setValue = _e[1];
|
|
12430
12444
|
var inputRef = useRef(null);
|
|
12431
|
-
useEffect(function () {
|
|
12432
|
-
setValue(externalValue);
|
|
12433
|
-
}, [externalValue]);
|
|
12434
12445
|
// set force focus
|
|
12435
12446
|
useEffect(function () {
|
|
12436
12447
|
var input = inputRef.current;
|
|
@@ -12460,16 +12471,22 @@ var TextInput = function (_a, ref) {
|
|
|
12460
12471
|
setIsFocus(false);
|
|
12461
12472
|
setIsActive(!(input && input.value === ""));
|
|
12462
12473
|
};
|
|
12463
|
-
var className = cn("border py-2 px-3 rounded text-sm leading-5 font-normal w-full", { "border-gray-300 shadow-sm": !isFocus && !isError }, {
|
|
12464
|
-
"focus:ring-purple-500 border-purple-500 outline-purple-500 shadow-none": isFocus && !isError
|
|
12465
|
-
}, { "focus:ring-red-500 !border-red-500 shadow-none": isError });
|
|
12466
12474
|
var discriptionStyles = cn("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError });
|
|
12475
|
+
if (!id)
|
|
12476
|
+
id = "input-".concat(uniqueID);
|
|
12477
|
+
if (!name)
|
|
12478
|
+
name = id;
|
|
12479
|
+
console.log();
|
|
12467
12480
|
return (React__default.createElement("div", null,
|
|
12468
12481
|
React__default.createElement(InputLabel, { isPlaceholder: true, label: label, isRequired: isRequired, id: id, isError: isError, isActive: true, isDisabled: isDisabled }),
|
|
12469
12482
|
React__default.createElement("div", null,
|
|
12470
|
-
React__default.createElement(_BaseField, { onFocus: handleInputFocus, onBlur: handleInputBlur, onChange: onChange, onValueChange: setValue, ref: ref, type: type, name: name, id: id, className:
|
|
12483
|
+
React__default.createElement(_BaseField, { onFocus: handleInputFocus, onBlur: handleInputBlur, onChange: onChange, onValueChange: setValue, ref: ref, type: type, name: name, id: id, className: cn("w-full rounded border py-2 px-3 text-sm font-normal leading-5", { "border-gray-300": !isFocus && !isError }, {
|
|
12484
|
+
"border-purple-500 shadow-none outline-purple-500 focus:ring-purple-500": isFocus && !isError
|
|
12485
|
+
}, {
|
|
12486
|
+
"!border-red-500 shadow-none focus:ring-red-500": isError
|
|
12487
|
+
}, className), isDisabled: isDisabled, value: value, defaultValue: defaultValue, maxLength: maxLength }),
|
|
12471
12488
|
React__default.createElement("div", { className: "flex flex-row space-x-3" },
|
|
12472
|
-
React__default.createElement("div", { className: "grow" }, message && React__default.createElement("span", { className: discriptionStyles }, message)),
|
|
12489
|
+
React__default.createElement("div", { className: "grow" }, message && (React__default.createElement("span", { className: discriptionStyles }, message))),
|
|
12473
12490
|
isShowCounter && (React__default.createElement("div", { className: "shrink-0" },
|
|
12474
12491
|
React__default.createElement(InputCounter, { current: Number(value === null || value === void 0 ? void 0 : value.length), limit: maxLength })))))));
|
|
12475
12492
|
};
|
|
@@ -12504,17 +12521,25 @@ var InputCta = function (_a) {
|
|
|
12504
12521
|
};
|
|
12505
12522
|
|
|
12506
12523
|
var TextInputAddon = function (_a, ref) {
|
|
12507
|
-
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 ?
|
|
12524
|
+
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;
|
|
12508
12525
|
var _d = useState(Boolean(isFocused)), isFocus = _d[0], setIsFocus = _d[1];
|
|
12509
|
-
var _e = useState(defaultValue ||
|
|
12526
|
+
var _e = useState(defaultValue || ""), value = _e[0], setValue = _e[1];
|
|
12510
12527
|
var inputRef = useRef(null);
|
|
12528
|
+
var uniqueID = useId();
|
|
12529
|
+
if (!id)
|
|
12530
|
+
id = "input-".concat(uniqueID);
|
|
12531
|
+
if (!name)
|
|
12532
|
+
name = id;
|
|
12511
12533
|
useEffect(function () {
|
|
12512
12534
|
setValue(externalValue);
|
|
12513
12535
|
}, [externalValue]);
|
|
12514
12536
|
// set force focus
|
|
12515
12537
|
useEffect(function () {
|
|
12516
12538
|
var input = inputRef.current;
|
|
12517
|
-
if (!input ||
|
|
12539
|
+
if (!input ||
|
|
12540
|
+
isFocus === undefined ||
|
|
12541
|
+
isFocused === undefined ||
|
|
12542
|
+
isDisabled)
|
|
12518
12543
|
return;
|
|
12519
12544
|
if (isFocus || isFocused) {
|
|
12520
12545
|
input.focus();
|
|
@@ -12526,7 +12551,7 @@ var TextInputAddon = function (_a, ref) {
|
|
|
12526
12551
|
// set label as active if default value is set
|
|
12527
12552
|
useEffect(function () {
|
|
12528
12553
|
var input = inputRef.current;
|
|
12529
|
-
if (!input || defaultValue === undefined || defaultValue ===
|
|
12554
|
+
if (!input || defaultValue === undefined || defaultValue === "")
|
|
12530
12555
|
return;
|
|
12531
12556
|
}, [defaultValue]);
|
|
12532
12557
|
var handleInputFocus = function () {
|
|
@@ -12537,19 +12562,25 @@ var TextInputAddon = function (_a, ref) {
|
|
|
12537
12562
|
setIsFocus(false);
|
|
12538
12563
|
// add other focus effects here
|
|
12539
12564
|
};
|
|
12540
|
-
var className = cn(
|
|
12541
|
-
|
|
12565
|
+
var className = cn("border py-2 px-3 rounded text-sm leading-5 font-normal w-full border-gray-300 outline-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500 focus:border-purple-500 ", {
|
|
12566
|
+
"focus:ring-red-500 !border-red-500 !outline-red-500 shadow-none": isError
|
|
12567
|
+
}, { "pl-10": inlineIcon }, {
|
|
12568
|
+
"!rounded-r-none !rounded-l": (trailIcon || trailLabel) && !(leadIcon || leadLabel)
|
|
12569
|
+
}, {
|
|
12570
|
+
"!rounded-r-none !rounded-r": !(trailIcon || trailLabel) && (leadIcon || leadLabel)
|
|
12571
|
+
}, { "rounded-none": (trailIcon || trailLabel) && (leadIcon || leadLabel) });
|
|
12572
|
+
var discriptionStyles = cn("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError });
|
|
12542
12573
|
return (React__default.createElement("div", null,
|
|
12543
12574
|
label && (React__default.createElement(InputLabel, { label: label, isRequired: isRequired, id: id, isError: isError, isDisabled: isDisabled })),
|
|
12544
12575
|
React__default.createElement("div", { className: "flex" },
|
|
12545
|
-
(leadIcon || leadLabel) && (React__default.createElement(InputCta, { icon: leadIcon, ctaLabel: leadLabel, align: "left", isClear: clearCta ===
|
|
12546
|
-
React__default.createElement("div", { className: "flex-grow focus-within:z-20
|
|
12547
|
-
inlineIcon && (React__default.createElement("div", { className: "absolute inset-y-0 left-0
|
|
12576
|
+
(leadIcon || leadLabel) && (React__default.createElement(InputCta, { icon: leadIcon, ctaLabel: leadLabel, align: "left", isClear: clearCta === "left" || clearCta === "both" })),
|
|
12577
|
+
React__default.createElement("div", { className: "relative flex-grow focus-within:z-20" },
|
|
12578
|
+
inlineIcon && (React__default.createElement("div", { className: "pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3" },
|
|
12548
12579
|
React__default.createElement(DynamicIcons, { icon: inlineIcon, className: "h-5 w-5 text-gray-400", outline: false }))),
|
|
12549
12580
|
React__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 })),
|
|
12550
|
-
(trailIcon || trailLabel) && (React__default.createElement(InputCta, { icon: trailIcon, ctaLabel: trailLabel, align: "right", isClear: clearCta ===
|
|
12581
|
+
(trailIcon || trailLabel) && (React__default.createElement(InputCta, { icon: trailIcon, ctaLabel: trailLabel, align: "right", isClear: clearCta === "right" || clearCta === "both", onClickHandler: onCtaClick }))),
|
|
12551
12582
|
React__default.createElement("div", { className: "flex flex-row space-x-3" },
|
|
12552
|
-
React__default.createElement("div", { className: "grow" }, message && React__default.createElement("span", { className: discriptionStyles }, message)),
|
|
12583
|
+
React__default.createElement("div", { className: "grow" }, message && (React__default.createElement("span", { className: discriptionStyles }, message))),
|
|
12553
12584
|
isShowCounter && (React__default.createElement("div", { className: "shrink-0" },
|
|
12554
12585
|
React__default.createElement(InputCounter, { current: Number(value === null || value === void 0 ? void 0 : value.length), limit: maxLength }))))));
|
|
12555
12586
|
};
|
|
@@ -12578,6 +12609,11 @@ var TextInputSelect = function (_a) {
|
|
|
12578
12609
|
var _d = useState(Boolean(isFocused)), isFocus = _d[0], setIsFocus = _d[1];
|
|
12579
12610
|
var _e = useState(defaultValue || ""), value = _e[0], setValue = _e[1];
|
|
12580
12611
|
var inputRef = useRef(null);
|
|
12612
|
+
var uniqueID = useId();
|
|
12613
|
+
if (!id)
|
|
12614
|
+
id = "select-".concat(uniqueID);
|
|
12615
|
+
if (!name)
|
|
12616
|
+
name = id;
|
|
12581
12617
|
useEffect(function () {
|
|
12582
12618
|
setValue(externalValue);
|
|
12583
12619
|
}, [externalValue]);
|
|
@@ -12623,7 +12659,7 @@ var TextInputSelect = function (_a) {
|
|
|
12623
12659
|
React__default.createElement("div", { className: "relative flex-grow focus-within:z-20" },
|
|
12624
12660
|
prefix && (React__default.createElement("div", { className: "pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3" },
|
|
12625
12661
|
React__default.createElement("span", { className: "text-gray-500 sm:text-sm" }, prefix))),
|
|
12626
|
-
React__default.createElement(_BaseField, { onFocus: handleInputFocus, onBlur: handleInputBlur, onChange: onChange, onValueChange: setValue, ref: inputRef, type: type, name: name, id: id, className: cn("w-full border border-gray-300 py-2 px-3 text-sm font-normal leading-5
|
|
12662
|
+
React__default.createElement(_BaseField, { onFocus: handleInputFocus, onBlur: handleInputBlur, onChange: onChange, onValueChange: setValue, ref: inputRef, type: type, name: name, id: id, className: cn("w-full border border-gray-300 py-2 px-3 text-sm font-normal leading-5", "focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500 sm:text-sm", selectLocation === "right"
|
|
12627
12663
|
? "rounded-l"
|
|
12628
12664
|
: "rounded-r", isError ? "border-red-500" : "", prefix ? "pl-7" : ""), isDisabled: isDisabled, defaultValue: defaultValue, value: value, maxLength: maxLength, placeholder: placeholder })),
|
|
12629
12665
|
(inputOptions === null || inputOptions === void 0 ? void 0 : inputOptions.length) && selectLocation === "right" && (React__default.createElement(InputSelect, { inputOptions: inputOptions, align: "right", onSelectOption: onSelectOption, isDisabled: isDisabled, className: cn(isError ? "border-red-500" : "") }))),
|
|
@@ -12636,6 +12672,11 @@ var TextInputSelect = function (_a) {
|
|
|
12636
12672
|
/** Comment */
|
|
12637
12673
|
var Radio = function (_a) {
|
|
12638
12674
|
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;
|
|
12675
|
+
var uniqueID = useId();
|
|
12676
|
+
if (!id)
|
|
12677
|
+
id = "input-".concat(uniqueID);
|
|
12678
|
+
if (!name)
|
|
12679
|
+
name = id;
|
|
12639
12680
|
var checboxStyles = cn('focus:ring-purple-500 h-4 w-4 text-purple-600 border-gray-300', {
|
|
12640
12681
|
'border-red-500 shadow-none': isError
|
|
12641
12682
|
});
|
|
@@ -12663,22 +12704,24 @@ var Radio = function (_a) {
|
|
|
12663
12704
|
};
|
|
12664
12705
|
|
|
12665
12706
|
var Textarea = function (_a, ref) {
|
|
12666
|
-
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;
|
|
12667
|
-
var
|
|
12707
|
+
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, placeholder = _a.placeholder;
|
|
12708
|
+
var uniqueID = useId();
|
|
12709
|
+
var _d = useState(externalValue || defaultValue || ""), value = _d[0], setValue = _d[1];
|
|
12668
12710
|
var handleOnchange = function (e) {
|
|
12669
12711
|
var targetValue = e.currentTarget.value;
|
|
12670
12712
|
typeof onChange === "function" && onChange(targetValue);
|
|
12671
12713
|
setValue(targetValue);
|
|
12672
12714
|
};
|
|
12673
|
-
var className = cn("
|
|
12715
|
+
var className = cn("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": isError });
|
|
12674
12716
|
var discriptionStyles = cn("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError });
|
|
12675
|
-
|
|
12676
|
-
|
|
12717
|
+
if (!id)
|
|
12718
|
+
id = "ta-".concat(uniqueID);
|
|
12719
|
+
return (React__default.createElement("div", { className: cn({ "opacity-50": isDisabled }) },
|
|
12677
12720
|
label && (React__default.createElement(InputLabel, { isPlaceholder: true, isActive: true, label: label, isRequired: isRequired, id: id, isError: isError, isDisabled: isDisabled })),
|
|
12678
12721
|
React__default.createElement("div", null,
|
|
12679
|
-
React__default.createElement("textarea", { ref: ref, maxLength: maxLength, onChange: handleOnchange, rows: rows, name: name, id: id, className: className, defaultValue: defaultValue })),
|
|
12722
|
+
React__default.createElement("textarea", { ref: ref, maxLength: maxLength, onChange: handleOnchange, rows: rows, name: name, id: id, className: className, defaultValue: defaultValue, value: value, placeholder: placeholder })),
|
|
12680
12723
|
React__default.createElement("div", { className: "flex flex-row space-x-3" },
|
|
12681
|
-
React__default.createElement("div", { className: "grow" }, message && React__default.createElement("span", { className: discriptionStyles }, message)),
|
|
12724
|
+
React__default.createElement("div", { className: "grow" }, message && (React__default.createElement("span", { className: discriptionStyles }, message))),
|
|
12682
12725
|
isShowCounter && (React__default.createElement("div", { className: "shrink-0" },
|
|
12683
12726
|
React__default.createElement(InputCounter, { current: Number(value === null || value === void 0 ? void 0 : value.length), limit: maxLength }))))));
|
|
12684
12727
|
};
|
|
@@ -12688,6 +12731,11 @@ var _Textarea = forwardRef(Textarea);
|
|
|
12688
12731
|
var Select = function (_a) {
|
|
12689
12732
|
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;
|
|
12690
12733
|
var _b = useState(options[0].value), selectedOption = _b[0], setSelectedOption = _b[1];
|
|
12734
|
+
var uniqueID = useId();
|
|
12735
|
+
if (!id)
|
|
12736
|
+
id = "select-".concat(uniqueID);
|
|
12737
|
+
if (!name)
|
|
12738
|
+
name = id;
|
|
12691
12739
|
var handleChange = function (e) {
|
|
12692
12740
|
var targetValue = e.target.value;
|
|
12693
12741
|
typeof onChange == "function" && onChange(targetValue);
|