@sustaina/shared-ui 1.65.0 → 1.65.2
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 +58 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4685,7 +4685,7 @@ var InputPrimitive = React.forwardRef(
|
|
|
4685
4685
|
ref,
|
|
4686
4686
|
type,
|
|
4687
4687
|
className: cn(
|
|
4688
|
-
"placeholder:text-
|
|
4688
|
+
"placeholder:text-sus-gray-1 placeholder:font-normal text-neutral-900 flex h-10 w-full min-w-0 items-center rounded-lg border bg-white px-4 text-sm transition-colors outline-none file:inline-flex file:h-7 file:rounded-md file:border-0 file:bg-transparent file:px-2 file:text-sm file:font-medium hover:border-neutral-500 focus-visible:border-neutral-900 focus-visible:ring-0 disabled:cursor-not-allowed disabled:bg-neutral-100 disabled:text-neutral-400 disabled:border-neutral-200 aria-invalid:border-destructive",
|
|
4689
4689
|
className
|
|
4690
4690
|
),
|
|
4691
4691
|
...props
|
|
@@ -7161,6 +7161,10 @@ var ComboboxInner = ({
|
|
|
7161
7161
|
...props
|
|
7162
7162
|
}, ref) => {
|
|
7163
7163
|
const { getLabelField, getValueField } = useFieldNames_default({ fieldNames });
|
|
7164
|
+
const isFocusedRef = React.useRef(false);
|
|
7165
|
+
const isPopoverOpenRef = React.useRef(false);
|
|
7166
|
+
const suppressNextFocusRef = React.useRef(false);
|
|
7167
|
+
const lastFocusEventRef = React.useRef(null);
|
|
7164
7168
|
const { value: openPopover, setValue: setOpenPopover } = useControllableState_default({
|
|
7165
7169
|
defaultValue: false,
|
|
7166
7170
|
value: open
|
|
@@ -7188,18 +7192,27 @@ var ComboboxInner = ({
|
|
|
7188
7192
|
}
|
|
7189
7193
|
return null;
|
|
7190
7194
|
}, [
|
|
7191
|
-
|
|
7192
|
-
getLabelField,
|
|
7193
|
-
placeholder2,
|
|
7195
|
+
isLoading,
|
|
7194
7196
|
selectedValue,
|
|
7197
|
+
placeholder2,
|
|
7198
|
+
currentSelectedOption,
|
|
7195
7199
|
showValueWhenNoMatch,
|
|
7196
|
-
|
|
7197
|
-
|
|
7200
|
+
loadingContent,
|
|
7201
|
+
valueRender,
|
|
7202
|
+
getLabelField
|
|
7198
7203
|
]);
|
|
7204
|
+
const signalBlur = React.useCallback(() => {
|
|
7205
|
+
if (!isFocusedRef.current || !lastFocusEventRef.current) return;
|
|
7206
|
+
isFocusedRef.current = false;
|
|
7207
|
+
suppressNextFocusRef.current = true;
|
|
7208
|
+
onBlur?.(lastFocusEventRef.current);
|
|
7209
|
+
}, [onBlur]);
|
|
7199
7210
|
const handleSelect = React.useCallback(
|
|
7200
7211
|
(selected, option) => {
|
|
7201
7212
|
setSelectedValue(selected);
|
|
7202
7213
|
setOpenPopover(false);
|
|
7214
|
+
isPopoverOpenRef.current = false;
|
|
7215
|
+
signalBlur();
|
|
7203
7216
|
if (typeof onSelect === "function") {
|
|
7204
7217
|
onSelect(selected, option);
|
|
7205
7218
|
}
|
|
@@ -7207,17 +7220,43 @@ var ComboboxInner = ({
|
|
|
7207
7220
|
onOpenChange(false);
|
|
7208
7221
|
}
|
|
7209
7222
|
},
|
|
7210
|
-
[onOpenChange, onSelect, setOpenPopover, setSelectedValue]
|
|
7223
|
+
[onOpenChange, onSelect, setOpenPopover, setSelectedValue, signalBlur]
|
|
7211
7224
|
);
|
|
7212
7225
|
const handleOpenPopover = React.useCallback(
|
|
7213
7226
|
(isOpen) => {
|
|
7214
7227
|
if (disabled || isLoading) return;
|
|
7228
|
+
isPopoverOpenRef.current = isOpen;
|
|
7215
7229
|
setOpenPopover(isOpen);
|
|
7230
|
+
if (!isOpen) {
|
|
7231
|
+
signalBlur();
|
|
7232
|
+
}
|
|
7216
7233
|
if (typeof onOpenChange === "function") {
|
|
7217
7234
|
onOpenChange(isOpen);
|
|
7218
7235
|
}
|
|
7219
7236
|
},
|
|
7220
|
-
[disabled, isLoading, onOpenChange, setOpenPopover]
|
|
7237
|
+
[disabled, isLoading, onOpenChange, setOpenPopover, signalBlur]
|
|
7238
|
+
);
|
|
7239
|
+
const handleFocus = React.useCallback(
|
|
7240
|
+
(event) => {
|
|
7241
|
+
lastFocusEventRef.current = event;
|
|
7242
|
+
if (suppressNextFocusRef.current) {
|
|
7243
|
+
suppressNextFocusRef.current = false;
|
|
7244
|
+
return;
|
|
7245
|
+
}
|
|
7246
|
+
if (isFocusedRef.current) return;
|
|
7247
|
+
isFocusedRef.current = true;
|
|
7248
|
+
onFocus?.(event);
|
|
7249
|
+
},
|
|
7250
|
+
[onFocus]
|
|
7251
|
+
);
|
|
7252
|
+
const handleBlur = React.useCallback(
|
|
7253
|
+
(event) => {
|
|
7254
|
+
if (isPopoverOpenRef.current) return;
|
|
7255
|
+
if (!isFocusedRef.current) return;
|
|
7256
|
+
isFocusedRef.current = false;
|
|
7257
|
+
onBlur?.(event);
|
|
7258
|
+
},
|
|
7259
|
+
[onBlur]
|
|
7221
7260
|
);
|
|
7222
7261
|
const handleClear = React.useCallback(
|
|
7223
7262
|
(event) => {
|
|
@@ -7250,8 +7289,8 @@ var ComboboxInner = ({
|
|
|
7250
7289
|
"data-state": openPopover ? "open" : "closed",
|
|
7251
7290
|
"data-loading": isLoading,
|
|
7252
7291
|
disabled: disabled || isLoading,
|
|
7253
|
-
onFocus,
|
|
7254
|
-
onBlur,
|
|
7292
|
+
onFocus: handleFocus,
|
|
7293
|
+
onBlur: handleBlur,
|
|
7255
7294
|
"data-testid": `combobox-trigger-${name}`,
|
|
7256
7295
|
...props,
|
|
7257
7296
|
children: [
|
|
@@ -7287,6 +7326,11 @@ var ComboboxInner = ({
|
|
|
7287
7326
|
align: "start",
|
|
7288
7327
|
sideOffset: 4,
|
|
7289
7328
|
...popoverContentProps,
|
|
7329
|
+
onCloseAutoFocus: (event) => {
|
|
7330
|
+
event.preventDefault();
|
|
7331
|
+
suppressNextFocusRef.current = false;
|
|
7332
|
+
popoverContentProps?.onCloseAutoFocus?.(event);
|
|
7333
|
+
},
|
|
7290
7334
|
onWheel: (e) => {
|
|
7291
7335
|
e.stopPropagation();
|
|
7292
7336
|
popoverContentProps?.onWheel?.(e);
|
|
@@ -7295,6 +7339,9 @@ var ComboboxInner = ({
|
|
|
7295
7339
|
"p-0 w-(--radix-popper-anchor-width) min-w-(--radix-popper-anchor-width) max-w-(--radix-popper-available-width) rounded-md",
|
|
7296
7340
|
popoverContentProps?.className
|
|
7297
7341
|
),
|
|
7342
|
+
onInteractOutside: (event) => {
|
|
7343
|
+
popoverContentProps?.onInteractOutside?.(event);
|
|
7344
|
+
},
|
|
7298
7345
|
children: virtual ? /* @__PURE__ */ jsx(
|
|
7299
7346
|
VirtualizedCommand_default,
|
|
7300
7347
|
{
|
|
@@ -12613,7 +12660,7 @@ function TextArea({ className, autoResize = true, ...props }) {
|
|
|
12613
12660
|
{
|
|
12614
12661
|
"data-slot": "textarea",
|
|
12615
12662
|
className: cn(
|
|
12616
|
-
"border-input placeholder:text-
|
|
12663
|
+
"border-input placeholder:text-sus-gray-1 focus-visible:border-neutral-900 focus-visible:ring-0 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
12617
12664
|
autoResize ? "field-sizing-content min-h-16" : "field-sizing-fixed",
|
|
12618
12665
|
className
|
|
12619
12666
|
),
|