@sustaina/shared-ui 1.64.2 → 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.mjs CHANGED
@@ -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
- currentSelectedOption,
7192
- getLabelField,
7193
- placeholder2,
7195
+ isLoading,
7194
7196
  selectedValue,
7197
+ placeholder2,
7198
+ currentSelectedOption,
7195
7199
  showValueWhenNoMatch,
7196
- isLoading,
7197
- loadingContent
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
  {
@@ -14236,6 +14283,7 @@ function UploadImagePlugin({
14236
14283
  onImageUploadError,
14237
14284
  onImageDialogUpload,
14238
14285
  onImageDialogUploadError,
14286
+ hideImageUploadButton,
14239
14287
  acceptImageMimeTypes
14240
14288
  }) {
14241
14289
  const [editor] = useLexicalComposerContext();
@@ -14520,7 +14568,7 @@ function UploadImagePlugin({
14520
14568
  disabled: imageDialogLoading
14521
14569
  }
14522
14570
  ),
14523
- onImageDialogUpload && /* @__PURE__ */ jsx(
14571
+ onImageDialogUpload && !hideImageUploadButton && /* @__PURE__ */ jsx(
14524
14572
  Button,
14525
14573
  {
14526
14574
  type: "button",
@@ -16047,6 +16095,7 @@ function RichTextInner({
16047
16095
  onImageDialogUploadError,
16048
16096
  acceptImageMimeTypes = "image/*",
16049
16097
  allowImageUrlInsert = true,
16098
+ hideImageUploadButton = false,
16050
16099
  maxLength,
16051
16100
  mentions,
16052
16101
  mentionConfig,
@@ -16129,6 +16178,7 @@ function RichTextInner({
16129
16178
  onImageUploadError,
16130
16179
  allowImageUrlInsert,
16131
16180
  acceptImageMimeTypes,
16181
+ hideImageUploadButton,
16132
16182
  onImageDialogUpload,
16133
16183
  onImageDialogUploadError
16134
16184
  }