@sustaina/shared-ui 1.65.0 → 1.65.1
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.js +56 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7204,6 +7204,10 @@ var ComboboxInner = ({
|
|
|
7204
7204
|
...props
|
|
7205
7205
|
}, ref) => {
|
|
7206
7206
|
const { getLabelField, getValueField } = useFieldNames_default({ fieldNames });
|
|
7207
|
+
const isFocusedRef = React__namespace.useRef(false);
|
|
7208
|
+
const isPopoverOpenRef = React__namespace.useRef(false);
|
|
7209
|
+
const suppressNextFocusRef = React__namespace.useRef(false);
|
|
7210
|
+
const lastFocusEventRef = React__namespace.useRef(null);
|
|
7207
7211
|
const { value: openPopover, setValue: setOpenPopover } = useControllableState_default({
|
|
7208
7212
|
defaultValue: false,
|
|
7209
7213
|
value: open
|
|
@@ -7231,18 +7235,27 @@ var ComboboxInner = ({
|
|
|
7231
7235
|
}
|
|
7232
7236
|
return null;
|
|
7233
7237
|
}, [
|
|
7234
|
-
|
|
7235
|
-
getLabelField,
|
|
7236
|
-
placeholder2,
|
|
7238
|
+
isLoading,
|
|
7237
7239
|
selectedValue,
|
|
7240
|
+
placeholder2,
|
|
7241
|
+
currentSelectedOption,
|
|
7238
7242
|
showValueWhenNoMatch,
|
|
7239
|
-
|
|
7240
|
-
|
|
7243
|
+
loadingContent,
|
|
7244
|
+
valueRender,
|
|
7245
|
+
getLabelField
|
|
7241
7246
|
]);
|
|
7247
|
+
const signalBlur = React__namespace.useCallback(() => {
|
|
7248
|
+
if (!isFocusedRef.current || !lastFocusEventRef.current) return;
|
|
7249
|
+
isFocusedRef.current = false;
|
|
7250
|
+
suppressNextFocusRef.current = true;
|
|
7251
|
+
onBlur?.(lastFocusEventRef.current);
|
|
7252
|
+
}, [onBlur]);
|
|
7242
7253
|
const handleSelect = React__namespace.useCallback(
|
|
7243
7254
|
(selected, option) => {
|
|
7244
7255
|
setSelectedValue(selected);
|
|
7245
7256
|
setOpenPopover(false);
|
|
7257
|
+
isPopoverOpenRef.current = false;
|
|
7258
|
+
signalBlur();
|
|
7246
7259
|
if (typeof onSelect === "function") {
|
|
7247
7260
|
onSelect(selected, option);
|
|
7248
7261
|
}
|
|
@@ -7250,17 +7263,43 @@ var ComboboxInner = ({
|
|
|
7250
7263
|
onOpenChange(false);
|
|
7251
7264
|
}
|
|
7252
7265
|
},
|
|
7253
|
-
[onOpenChange, onSelect, setOpenPopover, setSelectedValue]
|
|
7266
|
+
[onOpenChange, onSelect, setOpenPopover, setSelectedValue, signalBlur]
|
|
7254
7267
|
);
|
|
7255
7268
|
const handleOpenPopover = React__namespace.useCallback(
|
|
7256
7269
|
(isOpen) => {
|
|
7257
7270
|
if (disabled || isLoading) return;
|
|
7271
|
+
isPopoverOpenRef.current = isOpen;
|
|
7258
7272
|
setOpenPopover(isOpen);
|
|
7273
|
+
if (!isOpen) {
|
|
7274
|
+
signalBlur();
|
|
7275
|
+
}
|
|
7259
7276
|
if (typeof onOpenChange === "function") {
|
|
7260
7277
|
onOpenChange(isOpen);
|
|
7261
7278
|
}
|
|
7262
7279
|
},
|
|
7263
|
-
[disabled, isLoading, onOpenChange, setOpenPopover]
|
|
7280
|
+
[disabled, isLoading, onOpenChange, setOpenPopover, signalBlur]
|
|
7281
|
+
);
|
|
7282
|
+
const handleFocus = React__namespace.useCallback(
|
|
7283
|
+
(event) => {
|
|
7284
|
+
lastFocusEventRef.current = event;
|
|
7285
|
+
if (suppressNextFocusRef.current) {
|
|
7286
|
+
suppressNextFocusRef.current = false;
|
|
7287
|
+
return;
|
|
7288
|
+
}
|
|
7289
|
+
if (isFocusedRef.current) return;
|
|
7290
|
+
isFocusedRef.current = true;
|
|
7291
|
+
onFocus?.(event);
|
|
7292
|
+
},
|
|
7293
|
+
[onFocus]
|
|
7294
|
+
);
|
|
7295
|
+
const handleBlur = React__namespace.useCallback(
|
|
7296
|
+
(event) => {
|
|
7297
|
+
if (isPopoverOpenRef.current) return;
|
|
7298
|
+
if (!isFocusedRef.current) return;
|
|
7299
|
+
isFocusedRef.current = false;
|
|
7300
|
+
onBlur?.(event);
|
|
7301
|
+
},
|
|
7302
|
+
[onBlur]
|
|
7264
7303
|
);
|
|
7265
7304
|
const handleClear = React__namespace.useCallback(
|
|
7266
7305
|
(event) => {
|
|
@@ -7293,8 +7332,8 @@ var ComboboxInner = ({
|
|
|
7293
7332
|
"data-state": openPopover ? "open" : "closed",
|
|
7294
7333
|
"data-loading": isLoading,
|
|
7295
7334
|
disabled: disabled || isLoading,
|
|
7296
|
-
onFocus,
|
|
7297
|
-
onBlur,
|
|
7335
|
+
onFocus: handleFocus,
|
|
7336
|
+
onBlur: handleBlur,
|
|
7298
7337
|
"data-testid": `combobox-trigger-${name}`,
|
|
7299
7338
|
...props,
|
|
7300
7339
|
children: [
|
|
@@ -7330,6 +7369,11 @@ var ComboboxInner = ({
|
|
|
7330
7369
|
align: "start",
|
|
7331
7370
|
sideOffset: 4,
|
|
7332
7371
|
...popoverContentProps,
|
|
7372
|
+
onCloseAutoFocus: (event) => {
|
|
7373
|
+
event.preventDefault();
|
|
7374
|
+
suppressNextFocusRef.current = false;
|
|
7375
|
+
popoverContentProps?.onCloseAutoFocus?.(event);
|
|
7376
|
+
},
|
|
7333
7377
|
onWheel: (e) => {
|
|
7334
7378
|
e.stopPropagation();
|
|
7335
7379
|
popoverContentProps?.onWheel?.(e);
|
|
@@ -7338,6 +7382,9 @@ var ComboboxInner = ({
|
|
|
7338
7382
|
"p-0 w-(--radix-popper-anchor-width) min-w-(--radix-popper-anchor-width) max-w-(--radix-popper-available-width) rounded-md",
|
|
7339
7383
|
popoverContentProps?.className
|
|
7340
7384
|
),
|
|
7385
|
+
onInteractOutside: (event) => {
|
|
7386
|
+
popoverContentProps?.onInteractOutside?.(event);
|
|
7387
|
+
},
|
|
7341
7388
|
children: virtual ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
7342
7389
|
VirtualizedCommand_default,
|
|
7343
7390
|
{
|