@chekinapp/ui 0.0.119 → 0.0.120
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 +38 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +38 -16
- 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({
|
|
@@ -15203,6 +15212,7 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15203
15212
|
const {
|
|
15204
15213
|
options: rawOptions = [],
|
|
15205
15214
|
value,
|
|
15215
|
+
defaultValue,
|
|
15206
15216
|
onChange,
|
|
15207
15217
|
trigger,
|
|
15208
15218
|
components: userComponents,
|
|
@@ -15220,7 +15230,19 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15220
15230
|
paginationAndRest
|
|
15221
15231
|
);
|
|
15222
15232
|
const [inputValue, setInputValue] = React59.useState("");
|
|
15223
|
-
const
|
|
15233
|
+
const isControlled = value !== void 0;
|
|
15234
|
+
const [internalValue, setInternalValue] = React59.useState(
|
|
15235
|
+
() => defaultValue ?? []
|
|
15236
|
+
);
|
|
15237
|
+
const currentValue = isControlled ? value : internalValue;
|
|
15238
|
+
const selected = React59.useMemo(() => currentValue ?? [], [currentValue]);
|
|
15239
|
+
const handleChange = React59.useCallback(
|
|
15240
|
+
(next, meta) => {
|
|
15241
|
+
if (!isControlled) setInternalValue(next);
|
|
15242
|
+
onChange?.(next, meta);
|
|
15243
|
+
},
|
|
15244
|
+
[isControlled, onChange]
|
|
15245
|
+
);
|
|
15224
15246
|
const flatRawOptions = React59.useMemo(
|
|
15225
15247
|
() => flattenGroupedOptions(rawOptions),
|
|
15226
15248
|
[rawOptions]
|
|
@@ -15247,7 +15269,7 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15247
15269
|
const handleToggleAll = React59.useCallback(() => {
|
|
15248
15270
|
if (allVisibleSelected) {
|
|
15249
15271
|
const visibleValues = new Set(filteredFlat.map((option) => option.value));
|
|
15250
|
-
|
|
15272
|
+
handleChange(
|
|
15251
15273
|
selected.filter((s) => !visibleValues.has(s.value)),
|
|
15252
15274
|
{ action: "deselect" }
|
|
15253
15275
|
);
|
|
@@ -15257,8 +15279,8 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15257
15279
|
for (const option of filteredFlat) {
|
|
15258
15280
|
if (!merged.some((s) => s.value === option.value)) merged.push(option);
|
|
15259
15281
|
}
|
|
15260
|
-
|
|
15261
|
-
}, [allVisibleSelected, filteredFlat,
|
|
15282
|
+
handleChange(merged, { action: "select" });
|
|
15283
|
+
}, [allVisibleSelected, filteredFlat, handleChange, selected]);
|
|
15262
15284
|
const Control = React59.useMemo(() => {
|
|
15263
15285
|
if (trigger) return makeTriggerSlot2(trigger);
|
|
15264
15286
|
return createCountTrigger({
|
|
@@ -15291,8 +15313,8 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15291
15313
|
);
|
|
15292
15314
|
const baseSharedProps = {
|
|
15293
15315
|
...paginationAndRest,
|
|
15294
|
-
value,
|
|
15295
|
-
onChange,
|
|
15316
|
+
value: currentValue,
|
|
15317
|
+
onChange: handleChange,
|
|
15296
15318
|
filterOption: passthroughFilter2,
|
|
15297
15319
|
components,
|
|
15298
15320
|
closeMenuOnSelect,
|
|
@@ -19025,7 +19047,7 @@ function useDesktopSelect({
|
|
|
19025
19047
|
const handleSelect = React76.useCallback(
|
|
19026
19048
|
(option) => {
|
|
19027
19049
|
if (option.isDisabled || disabled) return;
|
|
19028
|
-
onChange(option);
|
|
19050
|
+
onChange?.(option);
|
|
19029
19051
|
},
|
|
19030
19052
|
[disabled, onChange]
|
|
19031
19053
|
);
|
|
@@ -19103,7 +19125,7 @@ function useDesktopSelect({
|
|
|
19103
19125
|
event.preventDefault();
|
|
19104
19126
|
const option = options[highlightedIndex];
|
|
19105
19127
|
if (option && !option.isDisabled) {
|
|
19106
|
-
onChange(option);
|
|
19128
|
+
onChange?.(option);
|
|
19107
19129
|
onClose();
|
|
19108
19130
|
focusTrigger();
|
|
19109
19131
|
}
|
|
@@ -19432,7 +19454,7 @@ var AirbnbSelect = React79.forwardRef(function AirbnbSelect2({
|
|
|
19432
19454
|
}
|
|
19433
19455
|
const validOption = filteredOptions.find((option) => option.value === value.value);
|
|
19434
19456
|
if (validOption) {
|
|
19435
|
-
onChange(validOption);
|
|
19457
|
+
onChange?.(validOption);
|
|
19436
19458
|
}
|
|
19437
19459
|
},
|
|
19438
19460
|
[onChange, filteredOptions, value]
|
|
@@ -19452,7 +19474,7 @@ var AirbnbSelect = React79.forwardRef(function AirbnbSelect2({
|
|
|
19452
19474
|
if (isBlocked) return;
|
|
19453
19475
|
const finalOption = pendingValue;
|
|
19454
19476
|
if (finalOption && finalOption.value !== value?.value) {
|
|
19455
|
-
onChange(finalOption);
|
|
19477
|
+
onChange?.(finalOption);
|
|
19456
19478
|
}
|
|
19457
19479
|
setIsOpen(false);
|
|
19458
19480
|
focusTrigger();
|