@rehagro/ui 1.0.38 → 1.0.39
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 +20 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1100,6 +1100,9 @@ var TextInput = forwardRef(function TextInput2({
|
|
|
1100
1100
|
...rest
|
|
1101
1101
|
}, ref) {
|
|
1102
1102
|
const inputId = id || React9.useId();
|
|
1103
|
+
const [isHelperDismissed, setIsHelperDismissed] = React9.useState(false);
|
|
1104
|
+
const { onChange, ...inputProps } = rest;
|
|
1105
|
+
const visualStatus = helperText && isHelperDismissed ? "default" : status;
|
|
1103
1106
|
return /* @__PURE__ */ jsxs(
|
|
1104
1107
|
"div",
|
|
1105
1108
|
{
|
|
@@ -1117,7 +1120,7 @@ var TextInput = forwardRef(function TextInput2({
|
|
|
1117
1120
|
"rh-border rh-bg-surface rh-font-body",
|
|
1118
1121
|
"rh-transition-colors rh-duration-150",
|
|
1119
1122
|
"rh-overflow-hidden",
|
|
1120
|
-
statusClasses[
|
|
1123
|
+
statusClasses[visualStatus],
|
|
1121
1124
|
radiusClasses3[radius],
|
|
1122
1125
|
sizeClasses3[size],
|
|
1123
1126
|
disabled ? "rh-opacity-50 rh-cursor-not-allowed rh-bg-background" : "",
|
|
@@ -1141,14 +1144,18 @@ var TextInput = forwardRef(function TextInput2({
|
|
|
1141
1144
|
ref,
|
|
1142
1145
|
id: inputId,
|
|
1143
1146
|
disabled,
|
|
1144
|
-
"aria-invalid":
|
|
1147
|
+
"aria-invalid": visualStatus === "error" || void 0,
|
|
1145
1148
|
"aria-describedby": helperText ? `${inputId}-helper` : void 0,
|
|
1146
1149
|
className: [
|
|
1147
1150
|
"rh-flex-1 rh-min-w-0 rh-bg-transparent rh-outline-none",
|
|
1148
1151
|
"rh-text-text placeholder:rh-text-text-muted",
|
|
1149
1152
|
disabled ? "rh-cursor-not-allowed" : ""
|
|
1150
1153
|
].filter(Boolean).join(" "),
|
|
1151
|
-
|
|
1154
|
+
onChange: (e) => {
|
|
1155
|
+
if (helperText) setIsHelperDismissed(true);
|
|
1156
|
+
onChange?.(e);
|
|
1157
|
+
},
|
|
1158
|
+
...inputProps
|
|
1152
1159
|
}
|
|
1153
1160
|
),
|
|
1154
1161
|
rightIcon && /* @__PURE__ */ jsx(
|
|
@@ -1165,13 +1172,13 @@ var TextInput = forwardRef(function TextInput2({
|
|
|
1165
1172
|
]
|
|
1166
1173
|
}
|
|
1167
1174
|
),
|
|
1168
|
-
helperText && /* @__PURE__ */ jsxs(
|
|
1175
|
+
helperText && !isHelperDismissed && /* @__PURE__ */ jsxs(
|
|
1169
1176
|
"span",
|
|
1170
1177
|
{
|
|
1171
1178
|
id: `${inputId}-helper`,
|
|
1172
1179
|
className: [
|
|
1173
1180
|
"rh-flex rh-items-center rh-gap-1 rh-text-xs",
|
|
1174
|
-
helperStatusClasses[
|
|
1181
|
+
helperStatusClasses[visualStatus]
|
|
1175
1182
|
].join(" "),
|
|
1176
1183
|
children: [
|
|
1177
1184
|
/* @__PURE__ */ jsx(WarningCircleIcon, {}),
|
|
@@ -1559,6 +1566,8 @@ var Select = forwardRef(function Select2(props, ref) {
|
|
|
1559
1566
|
const helperId = React9.useId();
|
|
1560
1567
|
const [isOpen, setIsOpen] = React9.useState(false);
|
|
1561
1568
|
const [activeIndex, setActiveIndex] = React9.useState(-1);
|
|
1569
|
+
const [isHelperDismissed, setIsHelperDismissed] = React9.useState(false);
|
|
1570
|
+
React9.useRef({ query: "", lastAt: 0 });
|
|
1562
1571
|
const wrapperRef = React9.useRef(null);
|
|
1563
1572
|
const innerRef = React9.useRef(null);
|
|
1564
1573
|
const listboxRef = React9.useRef(null);
|
|
@@ -1572,7 +1581,9 @@ var Select = forwardRef(function Select2(props, ref) {
|
|
|
1572
1581
|
const isControlled = props.value !== void 0;
|
|
1573
1582
|
const selectedValues = isControlled ? Array.isArray(props.value) ? props.value : props.value !== void 0 ? [props.value] : [] : internalValue;
|
|
1574
1583
|
const enabledOptions = options.filter((o) => !o.disabled);
|
|
1584
|
+
const visualStatus = helperText && isHelperDismissed ? "default" : status;
|
|
1575
1585
|
const handleSelect = (optionValue) => {
|
|
1586
|
+
if (helperText) setIsHelperDismissed(true);
|
|
1576
1587
|
if (multiple) {
|
|
1577
1588
|
const next = selectedValues.includes(optionValue) ? selectedValues.filter((v) => v !== optionValue) : [...selectedValues, optionValue];
|
|
1578
1589
|
if (!isControlled) setInternalValue(next);
|
|
@@ -1722,7 +1733,7 @@ var Select = forwardRef(function Select2(props, ref) {
|
|
|
1722
1733
|
"aria-controls": listboxId,
|
|
1723
1734
|
"aria-labelledby": label ? `${triggerId}-label` : void 0,
|
|
1724
1735
|
"aria-describedby": helperText ? helperId : void 0,
|
|
1725
|
-
"aria-invalid":
|
|
1736
|
+
"aria-invalid": visualStatus === "error" || void 0,
|
|
1726
1737
|
"aria-disabled": disabled || void 0,
|
|
1727
1738
|
disabled,
|
|
1728
1739
|
onClick: () => !disabled && setIsOpen((o) => !o),
|
|
@@ -1732,7 +1743,7 @@ var Select = forwardRef(function Select2(props, ref) {
|
|
|
1732
1743
|
"rh-border rh-bg-surface rh-font-body",
|
|
1733
1744
|
"rh-transition-colors rh-duration-150",
|
|
1734
1745
|
"rh-text-left rh-w-full",
|
|
1735
|
-
statusClasses2[
|
|
1746
|
+
statusClasses2[visualStatus],
|
|
1736
1747
|
radiusClasses4[radius],
|
|
1737
1748
|
sizeClasses5[size],
|
|
1738
1749
|
disabled ? "rh-opacity-50 rh-cursor-not-allowed rh-bg-background" : "rh-cursor-pointer",
|
|
@@ -1825,13 +1836,13 @@ var Select = forwardRef(function Select2(props, ref) {
|
|
|
1825
1836
|
})
|
|
1826
1837
|
}
|
|
1827
1838
|
),
|
|
1828
|
-
helperText && /* @__PURE__ */ jsxs(
|
|
1839
|
+
helperText && !isHelperDismissed && /* @__PURE__ */ jsxs(
|
|
1829
1840
|
"span",
|
|
1830
1841
|
{
|
|
1831
1842
|
id: helperId,
|
|
1832
1843
|
className: [
|
|
1833
1844
|
"rh-flex rh-items-center rh-gap-1 rh-text-xs",
|
|
1834
|
-
helperStatusClasses2[
|
|
1845
|
+
helperStatusClasses2[visualStatus]
|
|
1835
1846
|
].join(" "),
|
|
1836
1847
|
children: [
|
|
1837
1848
|
/* @__PURE__ */ jsx(WarningCircleIcon, {}),
|