@farmzone/fz-react-ui 1.1.5 → 1.1.6
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.cjs +52 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +53 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -482,6 +482,8 @@ function Input2(props) {
|
|
|
482
482
|
leftIcon,
|
|
483
483
|
rightIcon,
|
|
484
484
|
showPasswordToggle = true,
|
|
485
|
+
clearable = false,
|
|
486
|
+
onClear,
|
|
485
487
|
onChange,
|
|
486
488
|
...rest
|
|
487
489
|
} = props;
|
|
@@ -511,7 +513,16 @@ function Input2(props) {
|
|
|
511
513
|
const shouldShowPasswordToggle = type === "password" && showPasswordToggle;
|
|
512
514
|
const actualType = type === "password" && showPassword ? "text" : type;
|
|
513
515
|
const handlePasswordToggle = () => setShowPassword((prev) => !prev);
|
|
514
|
-
const
|
|
516
|
+
const handleClear = () => onClear?.();
|
|
517
|
+
const shouldShowClearButton = clearable && !disabled && typeof rest.value === "string" && rest.value.length > 0;
|
|
518
|
+
const finalRightIcon = rightIcon || (shouldShowClearButton ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
519
|
+
"div",
|
|
520
|
+
{
|
|
521
|
+
onClick: handleClear,
|
|
522
|
+
className: "text-muted-foreground hover:text-foreground cursor-pointer transition-colors",
|
|
523
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { className: "h-4 w-4" })
|
|
524
|
+
}
|
|
525
|
+
) : null) || (shouldShowPasswordToggle ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
515
526
|
"div",
|
|
516
527
|
{
|
|
517
528
|
onClick: handlePasswordToggle,
|
|
@@ -977,6 +988,29 @@ function SelectScrollDownButton({
|
|
|
977
988
|
}
|
|
978
989
|
);
|
|
979
990
|
}
|
|
991
|
+
function SelectOptionVisual(props) {
|
|
992
|
+
const { icon, avatarUrl, avatarAlt, fallbackLabel } = props;
|
|
993
|
+
const [hasAvatarError, setHasAvatarError] = React6.useState(false);
|
|
994
|
+
const handleAvatarError = () => setHasAvatarError(true);
|
|
995
|
+
if (avatarUrl && !hasAvatarError) {
|
|
996
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
997
|
+
"img",
|
|
998
|
+
{
|
|
999
|
+
src: avatarUrl,
|
|
1000
|
+
alt: avatarAlt ?? "",
|
|
1001
|
+
className: "size-5 shrink-0 rounded-full object-cover",
|
|
1002
|
+
onError: handleAvatarError
|
|
1003
|
+
}
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
if (avatarUrl && hasAvatarError) {
|
|
1007
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-5 shrink-0 items-center justify-center rounded-full bg-gray-200 text-[10px] font-medium text-gray-500", children: fallbackLabel?.charAt(0).toUpperCase() ?? "?" });
|
|
1008
|
+
}
|
|
1009
|
+
if (icon) {
|
|
1010
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-4 shrink-0 items-center justify-center text-gray-500", children: icon });
|
|
1011
|
+
}
|
|
1012
|
+
return null;
|
|
1013
|
+
}
|
|
980
1014
|
|
|
981
1015
|
// src/components/Select/config/default.ts
|
|
982
1016
|
var SELECT_BORDER_COLORS = {
|
|
@@ -1068,7 +1102,18 @@ function Select2(props) {
|
|
|
1068
1102
|
itemClassName,
|
|
1069
1103
|
option.disabled && cn("opacity-50 cursor-not-allowed text-gray-300 bg-white", disabledItemClassName)
|
|
1070
1104
|
),
|
|
1071
|
-
children:
|
|
1105
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex w-full min-w-0 items-center gap-2", children: [
|
|
1106
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1107
|
+
SelectOptionVisual,
|
|
1108
|
+
{
|
|
1109
|
+
icon: option.icon,
|
|
1110
|
+
avatarUrl: option.avatarUrl,
|
|
1111
|
+
avatarAlt: option.avatarAlt,
|
|
1112
|
+
fallbackLabel: typeof option.label === "string" ? option.label : void 0
|
|
1113
|
+
}
|
|
1114
|
+
),
|
|
1115
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: option.label })
|
|
1116
|
+
] })
|
|
1072
1117
|
},
|
|
1073
1118
|
String(option.value)
|
|
1074
1119
|
)) })
|
|
@@ -7884,6 +7929,9 @@ function PageFilter(props) {
|
|
|
7884
7929
|
const handleInputChange = (key) => (e) => {
|
|
7885
7930
|
onChange({ [key]: e.target.value });
|
|
7886
7931
|
};
|
|
7932
|
+
const handleInputClear = (key) => () => {
|
|
7933
|
+
onChange({ [key]: "" });
|
|
7934
|
+
};
|
|
7887
7935
|
const handleSelectChange = (key, autoSubmit) => (value) => {
|
|
7888
7936
|
onChange({ [key]: value });
|
|
7889
7937
|
if (autoSubmit) pendingAutoSubmitRef.current = { key, value };
|
|
@@ -7928,6 +7976,8 @@ function PageFilter(props) {
|
|
|
7928
7976
|
if (e.key === "Enter") handleSubmit();
|
|
7929
7977
|
},
|
|
7930
7978
|
leftIcon: option.leftIcon !== false ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { size: 16 }) : void 0,
|
|
7979
|
+
clearable: option.canReset ?? true,
|
|
7980
|
+
onClear: handleInputClear(optionKey),
|
|
7931
7981
|
className: option.className
|
|
7932
7982
|
}
|
|
7933
7983
|
) }, String(optionKey));
|