@chekinapp/ui 0.0.119 → 0.0.121
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 +59 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -19
- package/dist/index.d.ts +18 -19
- package/dist/index.js +59 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -14211,19 +14211,28 @@ function SelectInternal(props, ref) {
|
|
|
14211
14211
|
const clearable = !isMulti ? props.clearable ?? true : true;
|
|
14212
14212
|
const closeMenuOnSelect = isMulti ? props.closeMenuOnSelect ?? false : void 0;
|
|
14213
14213
|
const { t } = (0, import_react_i18next33.useTranslation)();
|
|
14214
|
+
const isControlled = props.value !== void 0;
|
|
14215
|
+
const [internalValue, setInternalValue] = React49.useState(() => {
|
|
14216
|
+
if (isMulti) return props.defaultValue ?? [];
|
|
14217
|
+
return props.defaultValue ?? null;
|
|
14218
|
+
});
|
|
14219
|
+
const currentValue = isControlled ? props.value : internalValue;
|
|
14214
14220
|
const selectedOptions = React49.useMemo(() => {
|
|
14215
|
-
if (isMulti) return
|
|
14216
|
-
return
|
|
14217
|
-
}, [isMulti,
|
|
14221
|
+
if (isMulti) return currentValue ?? [];
|
|
14222
|
+
return currentValue ? [currentValue] : [];
|
|
14223
|
+
}, [isMulti, currentValue]);
|
|
14218
14224
|
const onSelectionChange = React49.useCallback(
|
|
14219
14225
|
(next, meta) => {
|
|
14220
14226
|
if (isMulti) {
|
|
14221
|
-
|
|
14227
|
+
if (!isControlled) setInternalValue(next);
|
|
14228
|
+
props.onChange?.(next, meta);
|
|
14222
14229
|
} else {
|
|
14223
|
-
|
|
14230
|
+
const nextValue = next[0] ?? null;
|
|
14231
|
+
if (!isControlled) setInternalValue(nextValue);
|
|
14232
|
+
props.onChange?.(nextValue, meta);
|
|
14224
14233
|
}
|
|
14225
14234
|
},
|
|
14226
|
-
[isMulti, props.onChange]
|
|
14235
|
+
[isMulti, isControlled, props.onChange]
|
|
14227
14236
|
);
|
|
14228
14237
|
const flatOptions = React49.useMemo(() => flattenGroupedOptions(options), [options]);
|
|
14229
14238
|
const state = useSelectState({
|
|
@@ -14666,6 +14675,7 @@ function InfiniteScrollSelectInternal(props, ref) {
|
|
|
14666
14675
|
filterOption: userFilterOption,
|
|
14667
14676
|
components: userComponents,
|
|
14668
14677
|
onInputChange: userOnInputChange,
|
|
14678
|
+
isMulti = false,
|
|
14669
14679
|
...rest
|
|
14670
14680
|
} = props;
|
|
14671
14681
|
const isPaginated = canLoadMore !== void 0 || isLoadingMore !== void 0 || loadMoreItems !== void 0 || onSearchChange !== void 0 || getFullSearchOption !== void 0;
|
|
@@ -14674,8 +14684,8 @@ function InfiniteScrollSelectInternal(props, ref) {
|
|
|
14674
14684
|
const filteredOptions = React52.useMemo(() => {
|
|
14675
14685
|
const trimmed = inputValue.trim();
|
|
14676
14686
|
const valueLabel = (() => {
|
|
14677
|
-
if (
|
|
14678
|
-
const single =
|
|
14687
|
+
if (isMulti) return "";
|
|
14688
|
+
const single = rest.value;
|
|
14679
14689
|
if (!single) return "";
|
|
14680
14690
|
return rest.getValueLabel?.(single) ?? String(single.label);
|
|
14681
14691
|
})();
|
|
@@ -14689,7 +14699,7 @@ function InfiniteScrollSelectInternal(props, ref) {
|
|
|
14689
14699
|
if (synthetic) list = [synthetic, ...list];
|
|
14690
14700
|
}
|
|
14691
14701
|
return list;
|
|
14692
|
-
}, [rawOptions, inputValue, filterOption, getFullSearchOption,
|
|
14702
|
+
}, [rawOptions, inputValue, filterOption, getFullSearchOption, isMulti, rest]);
|
|
14693
14703
|
const contextValue = React52.useMemo(
|
|
14694
14704
|
() => ({
|
|
14695
14705
|
canLoadMore,
|
|
@@ -14724,16 +14734,27 @@ function InfiniteScrollSelectInternal(props, ref) {
|
|
|
14724
14734
|
},
|
|
14725
14735
|
[onSearchChange, userOnInputChange]
|
|
14726
14736
|
);
|
|
14727
|
-
|
|
14737
|
+
const selectExtras = {
|
|
14738
|
+
options: filteredOptions,
|
|
14739
|
+
filterOption: passthroughFilter,
|
|
14740
|
+
components,
|
|
14741
|
+
onInputChange: handleInputChange
|
|
14742
|
+
};
|
|
14743
|
+
return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(InfiniteScrollContext.Provider, { value: contextValue, children: isMulti ? /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
|
|
14728
14744
|
Select,
|
|
14729
14745
|
{
|
|
14730
14746
|
ref,
|
|
14731
14747
|
...rest,
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
14748
|
+
...selectExtras,
|
|
14749
|
+
isMulti: true
|
|
14750
|
+
}
|
|
14751
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(
|
|
14752
|
+
Select,
|
|
14753
|
+
{
|
|
14754
|
+
ref,
|
|
14755
|
+
...rest,
|
|
14756
|
+
...selectExtras,
|
|
14757
|
+
isMulti: false
|
|
14737
14758
|
}
|
|
14738
14759
|
) });
|
|
14739
14760
|
}
|
|
@@ -15203,6 +15224,7 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15203
15224
|
const {
|
|
15204
15225
|
options: rawOptions = [],
|
|
15205
15226
|
value,
|
|
15227
|
+
defaultValue,
|
|
15206
15228
|
onChange,
|
|
15207
15229
|
trigger,
|
|
15208
15230
|
components: userComponents,
|
|
@@ -15220,7 +15242,19 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15220
15242
|
paginationAndRest
|
|
15221
15243
|
);
|
|
15222
15244
|
const [inputValue, setInputValue] = React59.useState("");
|
|
15223
|
-
const
|
|
15245
|
+
const isControlled = value !== void 0;
|
|
15246
|
+
const [internalValue, setInternalValue] = React59.useState(
|
|
15247
|
+
() => defaultValue ?? []
|
|
15248
|
+
);
|
|
15249
|
+
const currentValue = isControlled ? value : internalValue;
|
|
15250
|
+
const selected = React59.useMemo(() => currentValue ?? [], [currentValue]);
|
|
15251
|
+
const handleChange = React59.useCallback(
|
|
15252
|
+
(next, meta) => {
|
|
15253
|
+
if (!isControlled) setInternalValue(next);
|
|
15254
|
+
onChange?.(next, meta);
|
|
15255
|
+
},
|
|
15256
|
+
[isControlled, onChange]
|
|
15257
|
+
);
|
|
15224
15258
|
const flatRawOptions = React59.useMemo(
|
|
15225
15259
|
() => flattenGroupedOptions(rawOptions),
|
|
15226
15260
|
[rawOptions]
|
|
@@ -15247,7 +15281,7 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15247
15281
|
const handleToggleAll = React59.useCallback(() => {
|
|
15248
15282
|
if (allVisibleSelected) {
|
|
15249
15283
|
const visibleValues = new Set(filteredFlat.map((option) => option.value));
|
|
15250
|
-
|
|
15284
|
+
handleChange(
|
|
15251
15285
|
selected.filter((s) => !visibleValues.has(s.value)),
|
|
15252
15286
|
{ action: "deselect" }
|
|
15253
15287
|
);
|
|
@@ -15257,8 +15291,8 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15257
15291
|
for (const option of filteredFlat) {
|
|
15258
15292
|
if (!merged.some((s) => s.value === option.value)) merged.push(option);
|
|
15259
15293
|
}
|
|
15260
|
-
|
|
15261
|
-
}, [allVisibleSelected, filteredFlat,
|
|
15294
|
+
handleChange(merged, { action: "select" });
|
|
15295
|
+
}, [allVisibleSelected, filteredFlat, handleChange, selected]);
|
|
15262
15296
|
const Control = React59.useMemo(() => {
|
|
15263
15297
|
if (trigger) return makeTriggerSlot2(trigger);
|
|
15264
15298
|
return createCountTrigger({
|
|
@@ -15291,8 +15325,8 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15291
15325
|
);
|
|
15292
15326
|
const baseSharedProps = {
|
|
15293
15327
|
...paginationAndRest,
|
|
15294
|
-
value,
|
|
15295
|
-
onChange,
|
|
15328
|
+
value: currentValue,
|
|
15329
|
+
onChange: handleChange,
|
|
15296
15330
|
filterOption: passthroughFilter2,
|
|
15297
15331
|
components,
|
|
15298
15332
|
closeMenuOnSelect,
|
|
@@ -19025,7 +19059,7 @@ function useDesktopSelect({
|
|
|
19025
19059
|
const handleSelect = React76.useCallback(
|
|
19026
19060
|
(option) => {
|
|
19027
19061
|
if (option.isDisabled || disabled) return;
|
|
19028
|
-
onChange(option);
|
|
19062
|
+
onChange?.(option);
|
|
19029
19063
|
},
|
|
19030
19064
|
[disabled, onChange]
|
|
19031
19065
|
);
|
|
@@ -19103,7 +19137,7 @@ function useDesktopSelect({
|
|
|
19103
19137
|
event.preventDefault();
|
|
19104
19138
|
const option = options[highlightedIndex];
|
|
19105
19139
|
if (option && !option.isDisabled) {
|
|
19106
|
-
onChange(option);
|
|
19140
|
+
onChange?.(option);
|
|
19107
19141
|
onClose();
|
|
19108
19142
|
focusTrigger();
|
|
19109
19143
|
}
|
|
@@ -19432,7 +19466,7 @@ var AirbnbSelect = React79.forwardRef(function AirbnbSelect2({
|
|
|
19432
19466
|
}
|
|
19433
19467
|
const validOption = filteredOptions.find((option) => option.value === value.value);
|
|
19434
19468
|
if (validOption) {
|
|
19435
|
-
onChange(validOption);
|
|
19469
|
+
onChange?.(validOption);
|
|
19436
19470
|
}
|
|
19437
19471
|
},
|
|
19438
19472
|
[onChange, filteredOptions, value]
|
|
@@ -19452,7 +19486,7 @@ var AirbnbSelect = React79.forwardRef(function AirbnbSelect2({
|
|
|
19452
19486
|
if (isBlocked) return;
|
|
19453
19487
|
const finalOption = pendingValue;
|
|
19454
19488
|
if (finalOption && finalOption.value !== value?.value) {
|
|
19455
|
-
onChange(finalOption);
|
|
19489
|
+
onChange?.(finalOption);
|
|
19456
19490
|
}
|
|
19457
19491
|
setIsOpen(false);
|
|
19458
19492
|
focusTrigger();
|