@herca/r-kit 0.0.75 → 0.0.76
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 +62 -120
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +1 -1
- package/dist/clients.d.ts +1 -1
- package/dist/clients.js +62 -120
- package/dist/clients.js.map +1 -1
- package/package.json +1 -1
package/dist/clients.d.cts
CHANGED
|
@@ -980,7 +980,7 @@ type SelectPropsWithDefaultBehavior<Extra extends object = EmptyObject> = {
|
|
|
980
980
|
};
|
|
981
981
|
type SelectProps<Extra extends object = object> = BaseSelectProps<Extra> & (SelectPropsWithCustomRender<Extra> | SelectPropsWithDefaultBehavior<Extra>);
|
|
982
982
|
|
|
983
|
-
declare function Select<Extra extends object = object>({ options, value, onChange, isMulti,
|
|
983
|
+
declare function Select<Extra extends object = object>({ options, value, onChange, isMulti, placeholder, isSearchable, isClearable, isDisabled, renderOption, renderValue, className, label, description, hint, errorMessages, isLoadingMore, onLoadMore, treshold, trigger, triggerClassName, renderOptions, onSearchOptions, onOptionsChange, required, isSelectOpen, onOpenChange, searchOptions, searchPlaceholder, }: SelectProps<Extra>): react_jsx_runtime.JSX.Element;
|
|
984
984
|
|
|
985
985
|
interface TabsProps {
|
|
986
986
|
defaultValue?: string;
|
package/dist/clients.d.ts
CHANGED
|
@@ -980,7 +980,7 @@ type SelectPropsWithDefaultBehavior<Extra extends object = EmptyObject> = {
|
|
|
980
980
|
};
|
|
981
981
|
type SelectProps<Extra extends object = object> = BaseSelectProps<Extra> & (SelectPropsWithCustomRender<Extra> | SelectPropsWithDefaultBehavior<Extra>);
|
|
982
982
|
|
|
983
|
-
declare function Select<Extra extends object = object>({ options, value, onChange, isMulti,
|
|
983
|
+
declare function Select<Extra extends object = object>({ options, value, onChange, isMulti, placeholder, isSearchable, isClearable, isDisabled, renderOption, renderValue, className, label, description, hint, errorMessages, isLoadingMore, onLoadMore, treshold, trigger, triggerClassName, renderOptions, onSearchOptions, onOptionsChange, required, isSelectOpen, onOpenChange, searchOptions, searchPlaceholder, }: SelectProps<Extra>): react_jsx_runtime.JSX.Element;
|
|
984
984
|
|
|
985
985
|
interface TabsProps {
|
|
986
986
|
defaultValue?: string;
|
package/dist/clients.js
CHANGED
|
@@ -11349,7 +11349,7 @@ function useUrlSearchParams() {
|
|
|
11349
11349
|
const next = updater(readParams());
|
|
11350
11350
|
const query = next.toString();
|
|
11351
11351
|
const url = `${window.location.pathname}${query ? `?${query}` : ""}${window.location.hash}`;
|
|
11352
|
-
if (options?.replace) {
|
|
11352
|
+
if (options?.replace == true) {
|
|
11353
11353
|
window.history.replaceState(window.history.state, "", url);
|
|
11354
11354
|
} else {
|
|
11355
11355
|
window.history.pushState(window.history.state, "", url);
|
|
@@ -16901,26 +16901,21 @@ function RoundedSpinner({
|
|
|
16901
16901
|
// src/components/select/select.tsx
|
|
16902
16902
|
import clsx14 from "clsx";
|
|
16903
16903
|
import { Fragment as Fragment10, jsx as jsx435, jsxs as jsxs94 } from "react/jsx-runtime";
|
|
16904
|
-
var isGroup = (item) => item != null && Array.isArray(item.options);
|
|
16905
|
-
var getSearchText = (option) => typeof option.label === "string" ? option.label : String(option.value ?? "");
|
|
16906
16904
|
function Select({
|
|
16907
16905
|
options = [],
|
|
16908
16906
|
value = null,
|
|
16909
16907
|
onChange,
|
|
16910
16908
|
isMulti = false,
|
|
16911
|
-
multiple = false,
|
|
16912
16909
|
placeholder = "Select...",
|
|
16913
16910
|
isSearchable = true,
|
|
16914
16911
|
isClearable = true,
|
|
16915
16912
|
isDisabled = false,
|
|
16916
|
-
disabled = false,
|
|
16917
16913
|
renderOption = null,
|
|
16918
16914
|
renderValue = null,
|
|
16919
16915
|
className,
|
|
16920
16916
|
label,
|
|
16921
16917
|
description,
|
|
16922
16918
|
hint,
|
|
16923
|
-
tooltip,
|
|
16924
16919
|
errorMessages,
|
|
16925
16920
|
isLoadingMore,
|
|
16926
16921
|
onLoadMore,
|
|
@@ -16934,8 +16929,7 @@ function Select({
|
|
|
16934
16929
|
isSelectOpen,
|
|
16935
16930
|
onOpenChange,
|
|
16936
16931
|
searchOptions,
|
|
16937
|
-
searchPlaceholder = "Search..."
|
|
16938
|
-
icon
|
|
16932
|
+
searchPlaceholder = "Search..."
|
|
16939
16933
|
}) {
|
|
16940
16934
|
const [isOpen, setIsOpen] = useState15(false);
|
|
16941
16935
|
const [searchTerm, setSearchTerm] = useState15("");
|
|
@@ -16944,12 +16938,6 @@ function Select({
|
|
|
16944
16938
|
const searchInputRef = useRef8(null);
|
|
16945
16939
|
const optionRefs = useRef8([]);
|
|
16946
16940
|
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
|
-
});
|
|
16953
16941
|
const handleScroll = () => {
|
|
16954
16942
|
const el = listContainerRef.current;
|
|
16955
16943
|
if (!el || Boolean(isLoadingMore)) return;
|
|
@@ -16958,39 +16946,20 @@ function Select({
|
|
|
16958
16946
|
onLoadMore?.();
|
|
16959
16947
|
}
|
|
16960
16948
|
};
|
|
16961
|
-
const
|
|
16962
|
-
|
|
16963
|
-
|
|
16964
|
-
|
|
16965
|
-
const matches2 = (o) => getSearchText(o).toLowerCase().includes(term);
|
|
16966
|
-
for (const item of options) {
|
|
16967
|
-
if (isGroup(item)) {
|
|
16968
|
-
const matched = item.options.filter(matches2);
|
|
16969
|
-
if (matched.length === 0) continue;
|
|
16970
|
-
const items = matched.map((option) => {
|
|
16971
|
-
const index = flat.length;
|
|
16972
|
-
flat.push(option);
|
|
16973
|
-
return { option, index };
|
|
16974
|
-
});
|
|
16975
|
-
entries.push({ kind: "group", label: item.label, items });
|
|
16976
|
-
} else {
|
|
16977
|
-
if (!matches2(item)) continue;
|
|
16978
|
-
const index = flat.length;
|
|
16979
|
-
flat.push(item);
|
|
16980
|
-
entries.push({ kind: "option", option: item, index });
|
|
16981
|
-
}
|
|
16982
|
-
}
|
|
16983
|
-
return { filteredOptions: flat, renderEntries: entries };
|
|
16949
|
+
const filteredOptions = React404.useMemo(() => {
|
|
16950
|
+
return options.filter(
|
|
16951
|
+
(option) => option.label.toLowerCase().includes(searchTerm.toLowerCase()) === true
|
|
16952
|
+
);
|
|
16984
16953
|
}, [options, searchTerm]);
|
|
16985
16954
|
const asArray = (val) => Array.isArray(val) ? val : val ? [val] : [];
|
|
16986
16955
|
const isSelected = (option) => {
|
|
16987
|
-
if (isMulti
|
|
16956
|
+
if (isMulti) {
|
|
16988
16957
|
return asArray(value).some((v3) => v3.value === option.value);
|
|
16989
16958
|
}
|
|
16990
16959
|
return value?.value === option.value;
|
|
16991
16960
|
};
|
|
16992
16961
|
const handleSelect = (option) => {
|
|
16993
|
-
if (isMulti
|
|
16962
|
+
if (isMulti) {
|
|
16994
16963
|
const arr = asArray(value);
|
|
16995
16964
|
const exists = arr.some((v3) => v3.value === option.value);
|
|
16996
16965
|
const newValue = exists ? arr.filter((v3) => v3.value !== option.value) : [...arr, option];
|
|
@@ -17006,7 +16975,7 @@ function Select({
|
|
|
17006
16975
|
};
|
|
17007
16976
|
const handleRemove = (option, e) => {
|
|
17008
16977
|
e.stopPropagation();
|
|
17009
|
-
if (isMulti
|
|
16978
|
+
if (isMulti) {
|
|
17010
16979
|
const arr = asArray(value);
|
|
17011
16980
|
onChange?.(arr.filter((v3) => v3.value !== option.value));
|
|
17012
16981
|
} else {
|
|
@@ -17015,7 +16984,7 @@ function Select({
|
|
|
17015
16984
|
};
|
|
17016
16985
|
const handleClear = (e) => {
|
|
17017
16986
|
e.stopPropagation();
|
|
17018
|
-
onChange?.(isMulti
|
|
16987
|
+
onChange?.(isMulti ? [] : null);
|
|
17019
16988
|
};
|
|
17020
16989
|
const handleKeyDown2 = (e) => {
|
|
17021
16990
|
if (!isOpen) {
|
|
@@ -17042,7 +17011,7 @@ function Select({
|
|
|
17042
17011
|
e.preventDefault();
|
|
17043
17012
|
try {
|
|
17044
17013
|
const opt = filteredOptions[highlightedIndex];
|
|
17045
|
-
if (opt
|
|
17014
|
+
if (opt) handleSelect(opt);
|
|
17046
17015
|
} catch (error) {
|
|
17047
17016
|
console.error(error);
|
|
17048
17017
|
}
|
|
@@ -17058,9 +17027,6 @@ function Select({
|
|
|
17058
17027
|
useEffect13(() => {
|
|
17059
17028
|
setHighlightedIndex(0);
|
|
17060
17029
|
}, [searchTerm]);
|
|
17061
|
-
useEffect13(() => {
|
|
17062
|
-
optionRefs.current.length = filteredOptions.length;
|
|
17063
|
-
}, [filteredOptions]);
|
|
17064
17030
|
useEffect13(() => {
|
|
17065
17031
|
const el = optionRefs.current[highlightedIndex];
|
|
17066
17032
|
if (el) {
|
|
@@ -17087,7 +17053,7 @@ function Select({
|
|
|
17087
17053
|
}
|
|
17088
17054
|
}, [isOpen, isSearchable]);
|
|
17089
17055
|
useEffect13(() => {
|
|
17090
|
-
|
|
17056
|
+
onOptionsChange?.(filteredOptions);
|
|
17091
17057
|
}, [filteredOptions]);
|
|
17092
17058
|
useEffect13(() => {
|
|
17093
17059
|
if (isSelectOpen !== void 0) {
|
|
@@ -17095,7 +17061,7 @@ function Select({
|
|
|
17095
17061
|
}
|
|
17096
17062
|
}, [isSelectOpen]);
|
|
17097
17063
|
useEffect13(() => {
|
|
17098
|
-
|
|
17064
|
+
onOpenChange?.(isOpen);
|
|
17099
17065
|
}, [isOpen]);
|
|
17100
17066
|
useEffect13(() => {
|
|
17101
17067
|
if (searchOptions !== void 0) {
|
|
@@ -17103,11 +17069,11 @@ function Select({
|
|
|
17103
17069
|
}
|
|
17104
17070
|
}, [searchOptions]);
|
|
17105
17071
|
const getDisplayValue = () => {
|
|
17106
|
-
const isEmpty = value == null ||
|
|
17072
|
+
const isEmpty = value == null || isMulti && asArray(value).length === 0;
|
|
17107
17073
|
if (isEmpty) {
|
|
17108
17074
|
return /* @__PURE__ */ jsx435("span", { className: "text-gray-500", children: placeholder });
|
|
17109
17075
|
}
|
|
17110
|
-
if (isMulti
|
|
17076
|
+
if (isMulti) {
|
|
17111
17077
|
return /* @__PURE__ */ jsx435("div", { className: "flex flex-wrap gap-1", children: asArray(value).map((item) => /* @__PURE__ */ jsxs94(
|
|
17112
17078
|
"div",
|
|
17113
17079
|
{
|
|
@@ -17129,33 +17095,8 @@ function Select({
|
|
|
17129
17095
|
}
|
|
17130
17096
|
return renderValue !== void 0 && renderValue !== null ? renderValue?.(value) : value.label;
|
|
17131
17097
|
};
|
|
17132
|
-
const showClearButton = isClearable && (
|
|
17098
|
+
const showClearButton = isClearable && (isMulti && asArray(value).length > 0 || !isMulti && value !== null);
|
|
17133
17099
|
const hasError = fieldHasError(errorMessages);
|
|
17134
|
-
const renderOptionItem = (option, index) => {
|
|
17135
|
-
const selected = isSelected(option);
|
|
17136
|
-
const highlighted = index === highlightedIndex;
|
|
17137
|
-
return /* @__PURE__ */ jsx435(
|
|
17138
|
-
"div",
|
|
17139
|
-
{
|
|
17140
|
-
ref: (el) => {
|
|
17141
|
-
optionRefs.current[index] = el;
|
|
17142
|
-
},
|
|
17143
|
-
onMouseEnter: () => setHighlightedIndex(index),
|
|
17144
|
-
onClick: () => handleSelect(option),
|
|
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
|
-
] }) }) })
|
|
17149
|
-
},
|
|
17150
|
-
option.value
|
|
17151
|
-
);
|
|
17152
|
-
};
|
|
17153
|
-
const hanldeOnClickInput = () => {
|
|
17154
|
-
if (disabled || isDisabled) {
|
|
17155
|
-
return false;
|
|
17156
|
-
}
|
|
17157
|
-
setIsOpen(!isOpen);
|
|
17158
|
-
};
|
|
17159
17100
|
return /* @__PURE__ */ jsx435(
|
|
17160
17101
|
FormField,
|
|
17161
17102
|
{
|
|
@@ -17164,7 +17105,6 @@ function Select({
|
|
|
17164
17105
|
description,
|
|
17165
17106
|
hint,
|
|
17166
17107
|
required,
|
|
17167
|
-
tooltip,
|
|
17168
17108
|
children: /* @__PURE__ */ jsxs94(
|
|
17169
17109
|
"div",
|
|
17170
17110
|
{
|
|
@@ -17177,8 +17117,8 @@ function Select({
|
|
|
17177
17117
|
"div",
|
|
17178
17118
|
{
|
|
17179
17119
|
"aria-selected": isOpen,
|
|
17180
|
-
onClick:
|
|
17181
|
-
tabIndex: isDisabled
|
|
17120
|
+
onClick: () => !isDisabled && setIsOpen(!isOpen),
|
|
17121
|
+
tabIndex: isDisabled ? -1 : 0,
|
|
17182
17122
|
className: triggerClassName,
|
|
17183
17123
|
children: trigger
|
|
17184
17124
|
}
|
|
@@ -17188,36 +17128,33 @@ function Select({
|
|
|
17188
17128
|
{
|
|
17189
17129
|
"aria-selected": isOpen,
|
|
17190
17130
|
className: cn(
|
|
17191
|
-
"focus:ring-primary-300 flex min-h-10 cursor-pointer rounded-lg border bg-white text-gray-900 transition-all focus-within:outline-none focus:ring",
|
|
17192
|
-
|
|
17131
|
+
"focus:ring-primary-300 flex min-h-10 cursor-pointer items-center justify-between rounded-lg border bg-white px-3 py-2 text-gray-900 transition-all focus-within:outline-none focus:ring",
|
|
17132
|
+
isDisabled && "cursor-not-allowed bg-gray-100",
|
|
17193
17133
|
isOpen ? "border-primary-300 ring-0" : "border-gray-200",
|
|
17194
17134
|
hasError && "border-danger-500"
|
|
17195
17135
|
),
|
|
17196
|
-
onClick:
|
|
17197
|
-
tabIndex: isDisabled
|
|
17136
|
+
onClick: () => !isDisabled && setIsOpen(!isOpen),
|
|
17137
|
+
tabIndex: isDisabled ? -1 : 0,
|
|
17198
17138
|
children: [
|
|
17199
|
-
|
|
17200
|
-
/* @__PURE__ */ jsxs94("div", { className: "
|
|
17201
|
-
/* @__PURE__ */ jsx435(
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
"button",
|
|
17205
|
-
|
|
17206
|
-
|
|
17207
|
-
|
|
17208
|
-
|
|
17209
|
-
|
|
17210
|
-
|
|
17211
|
-
|
|
17212
|
-
|
|
17213
|
-
|
|
17214
|
-
|
|
17215
|
-
|
|
17216
|
-
|
|
17217
|
-
|
|
17218
|
-
}
|
|
17219
|
-
)
|
|
17220
|
-
] })
|
|
17139
|
+
/* @__PURE__ */ jsx435("div", { className: "flex-1 overflow-hidden text-xs font-medium text-gray-900", children: getDisplayValue() }),
|
|
17140
|
+
/* @__PURE__ */ jsxs94("div", { className: "ml-2 flex items-center gap-1", children: [
|
|
17141
|
+
showClearButton && /* @__PURE__ */ jsx435(
|
|
17142
|
+
"button",
|
|
17143
|
+
{
|
|
17144
|
+
type: "button",
|
|
17145
|
+
onClick: handleClear,
|
|
17146
|
+
className: "cursor-pointer rounded text-center text-gray-700",
|
|
17147
|
+
children: /* @__PURE__ */ jsx435(Icon_default, { name: "times-circle", size: 20 })
|
|
17148
|
+
}
|
|
17149
|
+
),
|
|
17150
|
+
/* @__PURE__ */ jsx435(
|
|
17151
|
+
Icon_default,
|
|
17152
|
+
{
|
|
17153
|
+
className: "text-gray-700",
|
|
17154
|
+
name: isOpen ? "angle-up-small" : "angle-down-small",
|
|
17155
|
+
size: 20
|
|
17156
|
+
}
|
|
17157
|
+
)
|
|
17221
17158
|
] })
|
|
17222
17159
|
]
|
|
17223
17160
|
}
|
|
@@ -17256,22 +17193,27 @@ function Select({
|
|
|
17256
17193
|
onScroll: onLoadMore !== void 0 ? handleScroll : void 0,
|
|
17257
17194
|
children: [
|
|
17258
17195
|
renderOptions === void 0 && /* @__PURE__ */ jsxs94(Fragment10, { children: [
|
|
17259
|
-
filteredOptions.length === 0 ? /* @__PURE__ */ jsx435("div", { className: "px-3 py-8 text-center text-sm text-gray-500", children: "No options found" }) :
|
|
17260
|
-
|
|
17261
|
-
|
|
17262
|
-
|
|
17263
|
-
|
|
17264
|
-
|
|
17265
|
-
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17270
|
-
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
|
|
17274
|
-
|
|
17196
|
+
filteredOptions.length === 0 ? /* @__PURE__ */ jsx435("div", { className: "px-3 py-8 text-center text-sm text-gray-500", children: "No options found" }) : filteredOptions.map((option, index) => {
|
|
17197
|
+
const selected = isSelected(option);
|
|
17198
|
+
const highlighted = index === highlightedIndex;
|
|
17199
|
+
return /* @__PURE__ */ jsx435(
|
|
17200
|
+
"div",
|
|
17201
|
+
{
|
|
17202
|
+
ref: (el) => {
|
|
17203
|
+
optionRefs.current[index] = el;
|
|
17204
|
+
},
|
|
17205
|
+
onMouseEnter: () => setHighlightedIndex(index),
|
|
17206
|
+
onClick: () => handleSelect(option),
|
|
17207
|
+
className: cn(
|
|
17208
|
+
"flex cursor-pointer items-center justify-between rounded-lg px-3 py-2 text-sm font-medium text-gray-900 transition-colors focus:outline-none",
|
|
17209
|
+
highlighted && "bg-primary-100",
|
|
17210
|
+
selected ? "bg-primary-50 border-primary-300" : "hover:bg-gray-50"
|
|
17211
|
+
),
|
|
17212
|
+
children: /* @__PURE__ */ jsx435("div", { className: "flex-1", children: renderOption !== void 0 && renderOption !== null ? renderOption?.(option, { selected }) : /* @__PURE__ */ jsx435("div", { className: cn(selected && "font-medium"), children: option.label }) })
|
|
17213
|
+
},
|
|
17214
|
+
option.value
|
|
17215
|
+
);
|
|
17216
|
+
}),
|
|
17275
17217
|
onLoadMore !== void 0 && /* @__PURE__ */ jsx435(
|
|
17276
17218
|
"div",
|
|
17277
17219
|
{
|