@herca/r-kit 0.0.74 → 0.0.75
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/clients.cjs +35 -8
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +1 -0
- package/dist/clients.d.ts +1 -0
- package/dist/clients.js +35 -8
- package/dist/clients.js.map +1 -1
- package/package.json +1 -1
package/dist/clients.d.cts
CHANGED
package/dist/clients.d.ts
CHANGED
package/dist/clients.js
CHANGED
|
@@ -16902,6 +16902,7 @@ function RoundedSpinner({
|
|
|
16902
16902
|
import clsx14 from "clsx";
|
|
16903
16903
|
import { Fragment as Fragment10, jsx as jsx435, jsxs as jsxs94 } from "react/jsx-runtime";
|
|
16904
16904
|
var isGroup = (item) => item != null && Array.isArray(item.options);
|
|
16905
|
+
var getSearchText = (option) => typeof option.label === "string" ? option.label : String(option.value ?? "");
|
|
16905
16906
|
function Select({
|
|
16906
16907
|
options = [],
|
|
16907
16908
|
value = null,
|
|
@@ -16943,6 +16944,12 @@ function Select({
|
|
|
16943
16944
|
const searchInputRef = useRef8(null);
|
|
16944
16945
|
const optionRefs = useRef8([]);
|
|
16945
16946
|
const listContainerRef = useRef8(null);
|
|
16947
|
+
const onOptionsChangeRef = useRef8(onOptionsChange);
|
|
16948
|
+
const onOpenChangeRef = useRef8(onOpenChange);
|
|
16949
|
+
useEffect13(() => {
|
|
16950
|
+
onOptionsChangeRef.current = onOptionsChange;
|
|
16951
|
+
onOpenChangeRef.current = onOpenChange;
|
|
16952
|
+
});
|
|
16946
16953
|
const handleScroll = () => {
|
|
16947
16954
|
const el = listContainerRef.current;
|
|
16948
16955
|
if (!el || Boolean(isLoadingMore)) return;
|
|
@@ -16951,7 +16958,6 @@ function Select({
|
|
|
16951
16958
|
onLoadMore?.();
|
|
16952
16959
|
}
|
|
16953
16960
|
};
|
|
16954
|
-
const getSearchText = (option) => typeof option.label === "string" ? option.label : String(option.value ?? "");
|
|
16955
16961
|
const { filteredOptions, renderEntries } = React404.useMemo(() => {
|
|
16956
16962
|
const flat = [];
|
|
16957
16963
|
const entries = [];
|
|
@@ -17036,7 +17042,7 @@ function Select({
|
|
|
17036
17042
|
e.preventDefault();
|
|
17037
17043
|
try {
|
|
17038
17044
|
const opt = filteredOptions[highlightedIndex];
|
|
17039
|
-
if (opt) handleSelect(opt);
|
|
17045
|
+
if (opt != void 0) handleSelect(opt);
|
|
17040
17046
|
} catch (error) {
|
|
17041
17047
|
console.error(error);
|
|
17042
17048
|
}
|
|
@@ -17052,6 +17058,9 @@ function Select({
|
|
|
17052
17058
|
useEffect13(() => {
|
|
17053
17059
|
setHighlightedIndex(0);
|
|
17054
17060
|
}, [searchTerm]);
|
|
17061
|
+
useEffect13(() => {
|
|
17062
|
+
optionRefs.current.length = filteredOptions.length;
|
|
17063
|
+
}, [filteredOptions]);
|
|
17055
17064
|
useEffect13(() => {
|
|
17056
17065
|
const el = optionRefs.current[highlightedIndex];
|
|
17057
17066
|
if (el) {
|
|
@@ -17078,7 +17087,7 @@ function Select({
|
|
|
17078
17087
|
}
|
|
17079
17088
|
}, [isOpen, isSearchable]);
|
|
17080
17089
|
useEffect13(() => {
|
|
17081
|
-
|
|
17090
|
+
onOptionsChangeRef.current?.(filteredOptions);
|
|
17082
17091
|
}, [filteredOptions]);
|
|
17083
17092
|
useEffect13(() => {
|
|
17084
17093
|
if (isSelectOpen !== void 0) {
|
|
@@ -17086,7 +17095,7 @@ function Select({
|
|
|
17086
17095
|
}
|
|
17087
17096
|
}, [isSelectOpen]);
|
|
17088
17097
|
useEffect13(() => {
|
|
17089
|
-
|
|
17098
|
+
onOpenChangeRef.current?.(isOpen);
|
|
17090
17099
|
}, [isOpen]);
|
|
17091
17100
|
useEffect13(() => {
|
|
17092
17101
|
if (searchOptions !== void 0) {
|
|
@@ -17124,6 +17133,7 @@ function Select({
|
|
|
17124
17133
|
const hasError = fieldHasError(errorMessages);
|
|
17125
17134
|
const renderOptionItem = (option, index) => {
|
|
17126
17135
|
const selected = isSelected(option);
|
|
17136
|
+
const highlighted = index === highlightedIndex;
|
|
17127
17137
|
return /* @__PURE__ */ jsx435(
|
|
17128
17138
|
"div",
|
|
17129
17139
|
{
|
|
@@ -17132,11 +17142,20 @@ function Select({
|
|
|
17132
17142
|
},
|
|
17133
17143
|
onMouseEnter: () => setHighlightedIndex(index),
|
|
17134
17144
|
onClick: () => handleSelect(option),
|
|
17135
|
-
children: /* @__PURE__ */ jsx435(Chip, { className: "text-left", block: true, selected, children: /* @__PURE__ */ jsx435("div", { className: "flex-1", children: renderOption !== void 0 && renderOption !== null ? renderOption?.(option, { selected }) : /* @__PURE__ */
|
|
17145
|
+
children: /* @__PURE__ */ jsx435(Chip, { className: "text-left", block: true, selected: highlighted, children: /* @__PURE__ */ jsx435("div", { className: "flex-1", children: renderOption !== void 0 && renderOption !== null ? renderOption?.(option, { selected }) : /* @__PURE__ */ jsxs94("div", { className: "flex items-center gap-2", children: [
|
|
17146
|
+
option?.icon != void 0 && /* @__PURE__ */ jsx435(Icon_default, { name: "user", size: 12 }),
|
|
17147
|
+
/* @__PURE__ */ jsx435(Text, { variant: "t2", weight: "medium", className: "text-gray-900", children: option.label })
|
|
17148
|
+
] }) }) })
|
|
17136
17149
|
},
|
|
17137
17150
|
option.value
|
|
17138
17151
|
);
|
|
17139
17152
|
};
|
|
17153
|
+
const hanldeOnClickInput = () => {
|
|
17154
|
+
if (disabled || isDisabled) {
|
|
17155
|
+
return false;
|
|
17156
|
+
}
|
|
17157
|
+
setIsOpen(!isOpen);
|
|
17158
|
+
};
|
|
17140
17159
|
return /* @__PURE__ */ jsx435(
|
|
17141
17160
|
FormField,
|
|
17142
17161
|
{
|
|
@@ -17158,7 +17177,7 @@ function Select({
|
|
|
17158
17177
|
"div",
|
|
17159
17178
|
{
|
|
17160
17179
|
"aria-selected": isOpen,
|
|
17161
|
-
onClick:
|
|
17180
|
+
onClick: hanldeOnClickInput,
|
|
17162
17181
|
tabIndex: isDisabled || disabled ? -1 : 0,
|
|
17163
17182
|
className: triggerClassName,
|
|
17164
17183
|
children: trigger
|
|
@@ -17174,7 +17193,7 @@ function Select({
|
|
|
17174
17193
|
isOpen ? "border-primary-300 ring-0" : "border-gray-200",
|
|
17175
17194
|
hasError && "border-danger-500"
|
|
17176
17195
|
),
|
|
17177
|
-
onClick:
|
|
17196
|
+
onClick: hanldeOnClickInput,
|
|
17178
17197
|
tabIndex: isDisabled && disabled ? -1 : 0,
|
|
17179
17198
|
children: [
|
|
17180
17199
|
icon && /* @__PURE__ */ jsx435("div", { className: "flex items-center border-r border-gray-200 px-3 py-2", children: /* @__PURE__ */ jsx435(Icon_default, { name: icon, size: 22, className: "text-gray-600" }) }),
|
|
@@ -17239,7 +17258,15 @@ function Select({
|
|
|
17239
17258
|
renderOptions === void 0 && /* @__PURE__ */ jsxs94(Fragment10, { children: [
|
|
17240
17259
|
filteredOptions.length === 0 ? /* @__PURE__ */ jsx435("div", { className: "px-3 py-8 text-center text-sm text-gray-500", children: "No options found" }) : renderEntries.map(
|
|
17241
17260
|
(entry, i) => entry.kind === "group" ? /* @__PURE__ */ jsxs94("div", { className: "space-y-2", children: [
|
|
17242
|
-
/* @__PURE__ */ jsx435(
|
|
17261
|
+
/* @__PURE__ */ jsx435(
|
|
17262
|
+
Text,
|
|
17263
|
+
{
|
|
17264
|
+
variant: "t2",
|
|
17265
|
+
weight: "semibold",
|
|
17266
|
+
className: "text-gray-900",
|
|
17267
|
+
children: entry.label
|
|
17268
|
+
}
|
|
17269
|
+
),
|
|
17243
17270
|
entry.items.map(
|
|
17244
17271
|
({ option, index }) => renderOptionItem(option, index)
|
|
17245
17272
|
)
|