@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 CHANGED
@@ -4728,7 +4728,7 @@ var InputPrimitive = React__namespace.forwardRef(
4728
4728
  ref,
4729
4729
  type,
4730
4730
  className: cn(
4731
- "placeholder:text-neutral-400 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",
4731
+ "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",
4732
4732
  className
4733
4733
  ),
4734
4734
  ...props
@@ -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
- currentSelectedOption,
7235
- getLabelField,
7236
- placeholder2,
7238
+ isLoading,
7237
7239
  selectedValue,
7240
+ placeholder2,
7241
+ currentSelectedOption,
7238
7242
  showValueWhenNoMatch,
7239
- isLoading,
7240
- loadingContent
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
  {
@@ -12656,7 +12703,7 @@ function TextArea({ className, autoResize = true, ...props }) {
12656
12703
  {
12657
12704
  "data-slot": "textarea",
12658
12705
  className: cn(
12659
- "border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 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 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
12706
+ "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",
12660
12707
  autoResize ? "field-sizing-content min-h-16" : "field-sizing-fixed",
12661
12708
  className
12662
12709
  ),