@algenium/blocks 1.6.0 → 1.7.0-rc.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.d.cts CHANGED
@@ -681,6 +681,13 @@ declare function ChatSidebar({ currentUserId, config, labels, roleLabel, roomTyp
681
681
  * Debounces a value — useful for ZIP lookups and autocomplete queries.
682
682
  */
683
683
  declare function useDebouncedValue<T>(value: T, delayMs: number): T;
684
+ /**
685
+ * Like {@link useDebouncedValue} but the returned value is `undefined` until
686
+ * the first `delayMs` has elapsed for the current `value`, and resets to
687
+ * `undefined` whenever `value` changes. Use for “only act after user pauses”
688
+ * (e.g. auto-submit / auto-validate) without firing on the initial tick.
689
+ */
690
+ declare function useDebouncedValueStrict<T>(value: T, delayMs: number): T | undefined;
684
691
 
685
692
  declare const buttonVariants: (props?: ({
686
693
  variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
@@ -815,8 +822,10 @@ interface USAddressInputLabels {
815
822
  state: string;
816
823
  zip: string;
817
824
  searchPlaceholder: string;
825
+ /** Kept for backward compatibility; manual validate button removed */
818
826
  uspsValidate: string;
819
827
  uspsValidating: string;
828
+ uspsVerified: string;
820
829
  uspsSuggested: string;
821
830
  uspsUseSuggestion: string;
822
831
  uspsKeepMine: string;
@@ -825,19 +834,16 @@ interface USAddressInputLabels {
825
834
  zipLookupFailed: string;
826
835
  placeLookupFailed: string;
827
836
  autocompleteUnavailable: string;
828
- /** Optional copy for the autocomplete toggle header */
837
+ /** @deprecated Toggle removed; kept for consumer compatibility */
829
838
  autocompleteTitle?: string;
830
- /** Optional copy under the autocomplete toggle title */
839
+ /** @deprecated Toggle removed; kept for consumer compatibility */
831
840
  autocompleteDescription?: string;
832
- /** Optional placeholders for fields */
833
841
  streetPlaceholder?: string;
834
842
  street2Placeholder?: string;
835
843
  cityPlaceholder?: string;
836
844
  statePlaceholder?: string;
837
845
  zipPlaceholder?: string;
838
- /** Shown next to street2 label (e.g. "(optional)") */
839
846
  street2OptionalHint?: string;
840
- /** Fixed country line (US-only component) */
841
847
  countryLabel?: string;
842
848
  }
843
849
  interface AddressAutocompleteAdapter {
@@ -866,11 +872,9 @@ interface USAddressInputProps {
866
872
  largeText?: boolean;
867
873
  className?: string;
868
874
  onError?: (message: string) => void;
869
- /** When false, hide the autocomplete on/off row (autocomplete still works if forced on externally — prefer leaving default true when adapter exists). */
870
- showAutocompleteToggle?: boolean;
871
875
  }
872
- declare function USAddressInput({ value, onChange, lookupZip, validateAddress, autocomplete, labels, disabled, largeText, className, onError, showAutocompleteToggle, }: USAddressInputProps): react_jsx_runtime.JSX.Element;
876
+ declare function USAddressInput({ value, onChange, lookupZip, validateAddress, autocomplete, labels, disabled, largeText, className, onError, }: USAddressInputProps): react_jsx_runtime.JSX.Element;
873
877
 
874
878
  declare function cn(...inputs: ClassValue[]): string;
875
879
 
876
- export { type AddressAutocompleteAdapter, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorProps, BLOCKS_DATA_ENVIRONMENTS, type BlocksDataEnvironment, type BlocksLanguage, type BlocksNotification, Button, CalendarContext, type CalendarContextValue, type CalendarData, type CalendarEvent, CalendarSubscribeButton, type CalendarSubscribeButtonProps, CalendarView, type CalendarViewLabels, type CalendarViewMode, type CalendarViewProps, CalendarWidget, type CalendarWidgetLabels, type CalendarWidgetProps, CardInput, type CardInputLabels, type CardInputProps, type CardTokenResult, type ChatConversation, type ChatConversationRoom, type ChatMessageData, type ChatRoomConfig, ChatRoomView, type ChatRoomViewLabels, type ChatRoomViewProps, ChatSidebar, ChatSidebarContext, type ChatSidebarContextValue, type ChatSidebarLabels, type ChatSidebarProps, ChatSidebarProvider, type ChatSidebarProviderProps, type ChatSidebarView, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EnvironmentBanner, type EnvironmentBannerLabels, type EnvironmentBannerProps, EnvironmentContext, type EnvironmentContextValue, EnvironmentDot, type EnvironmentDotProps, EnvironmentMiniBadge, type EnvironmentMiniBadgeProps, EnvironmentSwitcher, type EnvironmentSwitcherLabels, type EnvironmentSwitcherProps, EventDialog, type EventDialogLabels, type EventDialogProps, EventRsvpBadge, type EventRsvpBadgeProps, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, MiniCalendar, type MiniCalendarProps, type Notification, type NotificationType, NotificationsContext, type NotificationsContextValue, NotificationsWidget, type NotificationsWidgetProps, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ScrollArea, ScrollBar, Slider, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, USAddressInput, type USAddressInputLabels, type USAddressInputProps, type USAddressValue, UpcomingEvents, type UpcomingEventsProps, type UseChatRoomResult, buttonVariants, cn, defaultLanguages, getEnvironmentDotClass, getEnvironmentLabel, isBlocksDataEnvironment, toggleVariants, useCalendarContext, useChatRoom, useChatSidebar, useDebouncedValue, useEnvironmentContext, useLanguageContext, useNotificationsContext };
880
+ export { type AddressAutocompleteAdapter, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorProps, BLOCKS_DATA_ENVIRONMENTS, type BlocksDataEnvironment, type BlocksLanguage, type BlocksNotification, Button, CalendarContext, type CalendarContextValue, type CalendarData, type CalendarEvent, CalendarSubscribeButton, type CalendarSubscribeButtonProps, CalendarView, type CalendarViewLabels, type CalendarViewMode, type CalendarViewProps, CalendarWidget, type CalendarWidgetLabels, type CalendarWidgetProps, CardInput, type CardInputLabels, type CardInputProps, type CardTokenResult, type ChatConversation, type ChatConversationRoom, type ChatMessageData, type ChatRoomConfig, ChatRoomView, type ChatRoomViewLabels, type ChatRoomViewProps, ChatSidebar, ChatSidebarContext, type ChatSidebarContextValue, type ChatSidebarLabels, type ChatSidebarProps, ChatSidebarProvider, type ChatSidebarProviderProps, type ChatSidebarView, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EnvironmentBanner, type EnvironmentBannerLabels, type EnvironmentBannerProps, EnvironmentContext, type EnvironmentContextValue, EnvironmentDot, type EnvironmentDotProps, EnvironmentMiniBadge, type EnvironmentMiniBadgeProps, EnvironmentSwitcher, type EnvironmentSwitcherLabels, type EnvironmentSwitcherProps, EventDialog, type EventDialogLabels, type EventDialogProps, EventRsvpBadge, type EventRsvpBadgeProps, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, MiniCalendar, type MiniCalendarProps, type Notification, type NotificationType, NotificationsContext, type NotificationsContextValue, NotificationsWidget, type NotificationsWidgetProps, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ScrollArea, ScrollBar, Slider, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, USAddressInput, type USAddressInputLabels, type USAddressInputProps, type USAddressValue, UpcomingEvents, type UpcomingEventsProps, type UseChatRoomResult, buttonVariants, cn, defaultLanguages, getEnvironmentDotClass, getEnvironmentLabel, isBlocksDataEnvironment, toggleVariants, useCalendarContext, useChatRoom, useChatSidebar, useDebouncedValue, useDebouncedValueStrict, useEnvironmentContext, useLanguageContext, useNotificationsContext };
package/dist/index.d.ts CHANGED
@@ -681,6 +681,13 @@ declare function ChatSidebar({ currentUserId, config, labels, roleLabel, roomTyp
681
681
  * Debounces a value — useful for ZIP lookups and autocomplete queries.
682
682
  */
683
683
  declare function useDebouncedValue<T>(value: T, delayMs: number): T;
684
+ /**
685
+ * Like {@link useDebouncedValue} but the returned value is `undefined` until
686
+ * the first `delayMs` has elapsed for the current `value`, and resets to
687
+ * `undefined` whenever `value` changes. Use for “only act after user pauses”
688
+ * (e.g. auto-submit / auto-validate) without firing on the initial tick.
689
+ */
690
+ declare function useDebouncedValueStrict<T>(value: T, delayMs: number): T | undefined;
684
691
 
685
692
  declare const buttonVariants: (props?: ({
686
693
  variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
@@ -815,8 +822,10 @@ interface USAddressInputLabels {
815
822
  state: string;
816
823
  zip: string;
817
824
  searchPlaceholder: string;
825
+ /** Kept for backward compatibility; manual validate button removed */
818
826
  uspsValidate: string;
819
827
  uspsValidating: string;
828
+ uspsVerified: string;
820
829
  uspsSuggested: string;
821
830
  uspsUseSuggestion: string;
822
831
  uspsKeepMine: string;
@@ -825,19 +834,16 @@ interface USAddressInputLabels {
825
834
  zipLookupFailed: string;
826
835
  placeLookupFailed: string;
827
836
  autocompleteUnavailable: string;
828
- /** Optional copy for the autocomplete toggle header */
837
+ /** @deprecated Toggle removed; kept for consumer compatibility */
829
838
  autocompleteTitle?: string;
830
- /** Optional copy under the autocomplete toggle title */
839
+ /** @deprecated Toggle removed; kept for consumer compatibility */
831
840
  autocompleteDescription?: string;
832
- /** Optional placeholders for fields */
833
841
  streetPlaceholder?: string;
834
842
  street2Placeholder?: string;
835
843
  cityPlaceholder?: string;
836
844
  statePlaceholder?: string;
837
845
  zipPlaceholder?: string;
838
- /** Shown next to street2 label (e.g. "(optional)") */
839
846
  street2OptionalHint?: string;
840
- /** Fixed country line (US-only component) */
841
847
  countryLabel?: string;
842
848
  }
843
849
  interface AddressAutocompleteAdapter {
@@ -866,11 +872,9 @@ interface USAddressInputProps {
866
872
  largeText?: boolean;
867
873
  className?: string;
868
874
  onError?: (message: string) => void;
869
- /** When false, hide the autocomplete on/off row (autocomplete still works if forced on externally — prefer leaving default true when adapter exists). */
870
- showAutocompleteToggle?: boolean;
871
875
  }
872
- declare function USAddressInput({ value, onChange, lookupZip, validateAddress, autocomplete, labels, disabled, largeText, className, onError, showAutocompleteToggle, }: USAddressInputProps): react_jsx_runtime.JSX.Element;
876
+ declare function USAddressInput({ value, onChange, lookupZip, validateAddress, autocomplete, labels, disabled, largeText, className, onError, }: USAddressInputProps): react_jsx_runtime.JSX.Element;
873
877
 
874
878
  declare function cn(...inputs: ClassValue[]): string;
875
879
 
876
- export { type AddressAutocompleteAdapter, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorProps, BLOCKS_DATA_ENVIRONMENTS, type BlocksDataEnvironment, type BlocksLanguage, type BlocksNotification, Button, CalendarContext, type CalendarContextValue, type CalendarData, type CalendarEvent, CalendarSubscribeButton, type CalendarSubscribeButtonProps, CalendarView, type CalendarViewLabels, type CalendarViewMode, type CalendarViewProps, CalendarWidget, type CalendarWidgetLabels, type CalendarWidgetProps, CardInput, type CardInputLabels, type CardInputProps, type CardTokenResult, type ChatConversation, type ChatConversationRoom, type ChatMessageData, type ChatRoomConfig, ChatRoomView, type ChatRoomViewLabels, type ChatRoomViewProps, ChatSidebar, ChatSidebarContext, type ChatSidebarContextValue, type ChatSidebarLabels, type ChatSidebarProps, ChatSidebarProvider, type ChatSidebarProviderProps, type ChatSidebarView, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EnvironmentBanner, type EnvironmentBannerLabels, type EnvironmentBannerProps, EnvironmentContext, type EnvironmentContextValue, EnvironmentDot, type EnvironmentDotProps, EnvironmentMiniBadge, type EnvironmentMiniBadgeProps, EnvironmentSwitcher, type EnvironmentSwitcherLabels, type EnvironmentSwitcherProps, EventDialog, type EventDialogLabels, type EventDialogProps, EventRsvpBadge, type EventRsvpBadgeProps, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, MiniCalendar, type MiniCalendarProps, type Notification, type NotificationType, NotificationsContext, type NotificationsContextValue, NotificationsWidget, type NotificationsWidgetProps, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ScrollArea, ScrollBar, Slider, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, USAddressInput, type USAddressInputLabels, type USAddressInputProps, type USAddressValue, UpcomingEvents, type UpcomingEventsProps, type UseChatRoomResult, buttonVariants, cn, defaultLanguages, getEnvironmentDotClass, getEnvironmentLabel, isBlocksDataEnvironment, toggleVariants, useCalendarContext, useChatRoom, useChatSidebar, useDebouncedValue, useEnvironmentContext, useLanguageContext, useNotificationsContext };
880
+ export { type AddressAutocompleteAdapter, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorProps, BLOCKS_DATA_ENVIRONMENTS, type BlocksDataEnvironment, type BlocksLanguage, type BlocksNotification, Button, CalendarContext, type CalendarContextValue, type CalendarData, type CalendarEvent, CalendarSubscribeButton, type CalendarSubscribeButtonProps, CalendarView, type CalendarViewLabels, type CalendarViewMode, type CalendarViewProps, CalendarWidget, type CalendarWidgetLabels, type CalendarWidgetProps, CardInput, type CardInputLabels, type CardInputProps, type CardTokenResult, type ChatConversation, type ChatConversationRoom, type ChatMessageData, type ChatRoomConfig, ChatRoomView, type ChatRoomViewLabels, type ChatRoomViewProps, ChatSidebar, ChatSidebarContext, type ChatSidebarContextValue, type ChatSidebarLabels, type ChatSidebarProps, ChatSidebarProvider, type ChatSidebarProviderProps, type ChatSidebarView, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EnvironmentBanner, type EnvironmentBannerLabels, type EnvironmentBannerProps, EnvironmentContext, type EnvironmentContextValue, EnvironmentDot, type EnvironmentDotProps, EnvironmentMiniBadge, type EnvironmentMiniBadgeProps, EnvironmentSwitcher, type EnvironmentSwitcherLabels, type EnvironmentSwitcherProps, EventDialog, type EventDialogLabels, type EventDialogProps, EventRsvpBadge, type EventRsvpBadgeProps, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, MiniCalendar, type MiniCalendarProps, type Notification, type NotificationType, NotificationsContext, type NotificationsContextValue, NotificationsWidget, type NotificationsWidgetProps, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ScrollArea, ScrollBar, Slider, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, USAddressInput, type USAddressInputLabels, type USAddressInputProps, type USAddressValue, UpcomingEvents, type UpcomingEventsProps, type UseChatRoomResult, buttonVariants, cn, defaultLanguages, getEnvironmentDotClass, getEnvironmentLabel, isBlocksDataEnvironment, toggleVariants, useCalendarContext, useChatRoom, useChatSidebar, useDebouncedValue, useDebouncedValueStrict, useEnvironmentContext, useLanguageContext, useNotificationsContext };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React2 from 'react';
2
2
  import { createContext, useContext, useState, useCallback, useEffect, useRef, useMemo, useId } from 'react';
3
3
  import { useTheme } from 'next-themes';
4
- import { CheckIcon, CircleIcon, ChevronRightIcon, Monitor, Sun, Moon, Languages, FlaskConical, X, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, XIcon, User, Pencil, Check, Loader2, Bell, CheckCheck, XCircle, AlertTriangle, CheckCircle, Info, Trash2, Clock, MapPin, Link, CalendarDays, ExternalLink, ChevronLeft, ChevronRight, Plus, HelpCircle, MessageSquare, Wifi, WifiOff, FileIcon, Download, Paperclip, Send, ArrowLeft, CreditCard, Search } from 'lucide-react';
4
+ import { CheckIcon, CircleIcon, ChevronRightIcon, Monitor, Sun, Moon, Languages, FlaskConical, X, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, XIcon, User, Pencil, Check, Loader2, Bell, CheckCheck, XCircle, AlertTriangle, CheckCircle, Info, Trash2, Clock, MapPin, Link, CalendarDays, ExternalLink, ChevronLeft, ChevronRight, Plus, HelpCircle, MessageSquare, Wifi, WifiOff, FileIcon, Download, Paperclip, Send, ArrowLeft, CreditCard, Search, CheckCircle2 } from 'lucide-react';
5
5
  import { AnimatePresence, motion } from 'framer-motion';
6
6
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
7
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -7331,6 +7331,15 @@ function useDebouncedValue(value, delayMs) {
7331
7331
  }, [value, delayMs]);
7332
7332
  return debounced;
7333
7333
  }
7334
+ function useDebouncedValueStrict(value, delayMs) {
7335
+ const [debounced, setDebounced] = useState(void 0);
7336
+ useEffect(() => {
7337
+ setDebounced(void 0);
7338
+ const id = window.setTimeout(() => setDebounced(value), delayMs);
7339
+ return () => window.clearTimeout(id);
7340
+ }, [value, delayMs]);
7341
+ return debounced;
7342
+ }
7334
7343
  function onlyDigits(s, max) {
7335
7344
  return s.replace(/\D/g, "").slice(0, max);
7336
7345
  }
@@ -7614,6 +7623,20 @@ function parseInitial(value) {
7614
7623
  country: "US"
7615
7624
  };
7616
7625
  }
7626
+ function addressSig(a) {
7627
+ return JSON.stringify({
7628
+ street: a.street.trim(),
7629
+ street2: (a.street2 ?? "").trim(),
7630
+ city: a.city.trim(),
7631
+ state: a.state.trim().toUpperCase(),
7632
+ zip: a.zip.replace(/\D/g, "").slice(0, 5)
7633
+ });
7634
+ }
7635
+ function isAddressComplete(a) {
7636
+ const zip5 = a.zip.replace(/\D/g, "").slice(0, 5);
7637
+ const st = a.state.trim();
7638
+ return a.street.trim().length > 0 && a.city.trim().length > 0 && /^[A-Za-z]{2}$/.test(st) && zip5.length === 5;
7639
+ }
7617
7640
  var inputClassName2 = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm";
7618
7641
  function USAddressInput({
7619
7642
  value,
@@ -7625,10 +7648,8 @@ function USAddressInput({
7625
7648
  disabled = false,
7626
7649
  largeText = false,
7627
7650
  className,
7628
- onError,
7629
- showAutocompleteToggle = true
7651
+ onError
7630
7652
  }) {
7631
- const [autocompleteEnabled, setAutocompleteEnabled] = useState(false);
7632
7653
  const [searchQuery, setSearchQuery] = useState("");
7633
7654
  const [showSuggestions, setShowSuggestions] = useState(false);
7634
7655
  const [suggestions, setSuggestions] = useState([]);
@@ -7644,6 +7665,7 @@ function USAddressInput({
7644
7665
  const [uspsSuggestion, setUspsSuggestion] = useState(
7645
7666
  null
7646
7667
  );
7668
+ const [uspsVerifiedNoChange, setUspsVerifiedNoChange] = useState(false);
7647
7669
  const searchRef = useRef(null);
7648
7670
  const suggestionCache = useRef(/* @__PURE__ */ new Map());
7649
7671
  const warnedRef = useRef({
@@ -7652,9 +7674,13 @@ function USAddressInput({
7652
7674
  validate: false
7653
7675
  });
7654
7676
  const lastZipLookup = useRef("");
7655
- const debouncedSearch = useDebouncedValue(searchQuery, 300);
7677
+ const addressRef = useRef(address);
7678
+ addressRef.current = address;
7679
+ const lastValidatedSigRef = useRef("");
7680
+ const debouncedSearch = useDebouncedValue(searchQuery, 400);
7656
7681
  const zipDigits = address.zip.replace(/\D/g, "").slice(0, 5);
7657
7682
  const debouncedZip = useDebouncedValue(zipDigits, 400);
7683
+ const debouncedAddressForValidate = useDebouncedValueStrict(address, 1200);
7658
7684
  const inputClass = largeText ? "text-base py-3" : "";
7659
7685
  const labelClass = largeText ? "text-base" : "text-sm";
7660
7686
  useEffect(() => {
@@ -7677,11 +7703,18 @@ function USAddressInput({
7677
7703
  return next;
7678
7704
  });
7679
7705
  };
7706
+ useEffect(() => {
7707
+ const sig = addressSig(addressRef.current);
7708
+ if (sig !== lastValidatedSigRef.current) {
7709
+ setUspsVerifiedNoChange(false);
7710
+ setUspsSuggestion(null);
7711
+ }
7712
+ }, [address]);
7680
7713
  const allowAutocomplete = Boolean(autocomplete);
7681
7714
  const allowUspsValidation = Boolean(validateAddress);
7682
7715
  const allowZipLookup = Boolean(lookupZip);
7683
7716
  useEffect(() => {
7684
- if (!allowAutocomplete || !autocompleteEnabled || !autocomplete) return;
7717
+ if (!allowAutocomplete || !autocomplete) return;
7685
7718
  const q = debouncedSearch.trim();
7686
7719
  if (q.length < 3) {
7687
7720
  setSuggestions([]);
@@ -7700,6 +7733,7 @@ function USAddressInput({
7700
7733
  const ctrl = new AbortController();
7701
7734
  setLoadingAutocomplete(true);
7702
7735
  autocomplete.search(q, sessionToken, ctrl.signal).then((list) => {
7736
+ if (ctrl.signal.aborted) return;
7703
7737
  suggestionCache.current.set(cacheKey, list);
7704
7738
  setSuggestions(list);
7705
7739
  setShowSuggestions(list.length > 0);
@@ -7716,7 +7750,6 @@ function USAddressInput({
7716
7750
  }, [
7717
7751
  debouncedSearch,
7718
7752
  allowAutocomplete,
7719
- autocompleteEnabled,
7720
7753
  autocomplete,
7721
7754
  sessionToken,
7722
7755
  labels.autocompleteUnavailable,
@@ -7729,6 +7762,7 @@ function USAddressInput({
7729
7762
  const ctrl = new AbortController();
7730
7763
  setLoadingZip(true);
7731
7764
  lookupZip(debouncedZip, ctrl.signal).then((data) => {
7765
+ if (ctrl.signal.aborted) return;
7732
7766
  lastZipLookup.current = debouncedZip;
7733
7767
  setAddress((prev) => {
7734
7768
  const cityEmpty = !prev.city.trim();
@@ -7755,6 +7789,52 @@ function USAddressInput({
7755
7789
  labels.zipLookupFailed,
7756
7790
  onError
7757
7791
  ]);
7792
+ useEffect(() => {
7793
+ if (!allowUspsValidation || !validateAddress || disabled) return;
7794
+ if (debouncedAddressForValidate === void 0) return;
7795
+ const addr = debouncedAddressForValidate;
7796
+ if (!isAddressComplete(addr)) return;
7797
+ const requestSig = addressSig(addr);
7798
+ if (requestSig === lastValidatedSigRef.current) return;
7799
+ const ctrl = new AbortController();
7800
+ const timeoutId = window.setTimeout(() => ctrl.abort(), 8e3);
7801
+ setLoadingValidate(true);
7802
+ setUspsVerifiedNoChange(false);
7803
+ setUspsSuggestion(null);
7804
+ validateAddress(addr, ctrl.signal).then((result) => {
7805
+ if (ctrl.signal.aborted) return;
7806
+ if (addressSig(addressRef.current) !== requestSig) return;
7807
+ lastValidatedSigRef.current = requestSig;
7808
+ const std = result.standardized;
7809
+ if (result.changed) {
7810
+ setUspsSuggestion(std);
7811
+ setUspsVerifiedNoChange(false);
7812
+ } else {
7813
+ setUspsSuggestion(null);
7814
+ setUspsVerifiedNoChange(true);
7815
+ }
7816
+ }).catch(() => {
7817
+ if (ctrl.signal.aborted) return;
7818
+ if (!warnedRef.current.validate) {
7819
+ onError?.(labels.uspsUnavailable);
7820
+ warnedRef.current.validate = true;
7821
+ }
7822
+ }).finally(() => {
7823
+ window.clearTimeout(timeoutId);
7824
+ setLoadingValidate(false);
7825
+ });
7826
+ return () => {
7827
+ window.clearTimeout(timeoutId);
7828
+ ctrl.abort();
7829
+ };
7830
+ }, [
7831
+ debouncedAddressForValidate,
7832
+ allowUspsValidation,
7833
+ validateAddress,
7834
+ disabled,
7835
+ labels.uspsUnavailable,
7836
+ onError
7837
+ ]);
7758
7838
  const handleSelectSuggestion = async (row) => {
7759
7839
  if (!autocomplete) return;
7760
7840
  try {
@@ -7771,72 +7851,27 @@ function USAddressInput({
7771
7851
  setShowSuggestions(false);
7772
7852
  setSearchQuery("");
7773
7853
  setUspsSuggestion(null);
7854
+ lastValidatedSigRef.current = "";
7855
+ setUspsVerifiedNoChange(false);
7774
7856
  } catch {
7775
7857
  onError?.(labels.placeLookupFailed);
7776
7858
  }
7777
7859
  };
7778
- const runUspsValidate = async () => {
7779
- if (!allowUspsValidation || !validateAddress || disabled) return;
7780
- setLoadingValidate(true);
7781
- setUspsSuggestion(null);
7782
- try {
7783
- const result = await validateAddress(address, AbortSignal.timeout(8e3));
7784
- const std = result.standardized;
7785
- if (result.changed) {
7786
- setUspsSuggestion(std);
7787
- }
7788
- } catch {
7789
- if (!warnedRef.current.validate) {
7790
- onError?.(labels.uspsUnavailable);
7791
- warnedRef.current.validate = true;
7792
- }
7793
- } finally {
7794
- setLoadingValidate(false);
7795
- }
7796
- };
7797
7860
  const applyUspsSuggestion = () => {
7798
7861
  if (!uspsSuggestion) return;
7799
7862
  setAddress(uspsSuggestion);
7800
7863
  onChange(uspsSuggestion);
7801
7864
  setUspsSuggestion(null);
7865
+ lastValidatedSigRef.current = addressSig(uspsSuggestion);
7866
+ setUspsVerifiedNoChange(true);
7867
+ };
7868
+ const dismissUspsSuggestion = () => {
7869
+ setUspsSuggestion(null);
7870
+ lastValidatedSigRef.current = addressSig(addressRef.current);
7871
+ setUspsVerifiedNoChange(true);
7802
7872
  };
7803
- const showAutocompleteUi = allowAutocomplete && showAutocompleteToggle && autocompleteEnabled;
7804
- const toggleTitle = labels.autocompleteTitle ?? labels.searchPlaceholder;
7805
7873
  return /* @__PURE__ */ jsxs("div", { className: cn("space-y-4", className), children: [
7806
- allowAutocomplete && showAutocompleteToggle && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-lg border bg-muted/50 p-3", children: [
7807
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
7808
- /* @__PURE__ */ jsx(MapPin, { className: "h-4 w-4 text-muted-foreground" }),
7809
- /* @__PURE__ */ jsxs("div", { children: [
7810
- /* @__PURE__ */ jsx("p", { className: cn("font-medium", labelClass), children: toggleTitle }),
7811
- labels.autocompleteDescription ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: labels.autocompleteDescription }) : null
7812
- ] })
7813
- ] }),
7814
- /* @__PURE__ */ jsx(
7815
- "button",
7816
- {
7817
- type: "button",
7818
- role: "switch",
7819
- "aria-checked": autocompleteEnabled,
7820
- disabled,
7821
- onClick: () => setAutocompleteEnabled((v) => !v),
7822
- className: cn(
7823
- "relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors",
7824
- autocompleteEnabled ? "bg-primary" : "bg-input",
7825
- disabled && "cursor-not-allowed opacity-50"
7826
- ),
7827
- children: /* @__PURE__ */ jsx(
7828
- "span",
7829
- {
7830
- className: cn(
7831
- "pointer-events-none block size-5 translate-x-0 rounded-full bg-background shadow-lg ring-0 transition-transform",
7832
- autocompleteEnabled && "translate-x-5"
7833
- )
7834
- }
7835
- )
7836
- }
7837
- )
7838
- ] }),
7839
- showAutocompleteUi && autocomplete && /* @__PURE__ */ jsxs("div", { ref: searchRef, className: "relative", children: [
7874
+ allowAutocomplete && autocomplete && /* @__PURE__ */ jsxs("div", { ref: searchRef, className: "relative", children: [
7840
7875
  /* @__PURE__ */ jsxs("div", { className: "relative", children: [
7841
7876
  /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
7842
7877
  /* @__PURE__ */ jsx(
@@ -7846,7 +7881,8 @@ function USAddressInput({
7846
7881
  onChange: (e) => setSearchQuery(e.target.value),
7847
7882
  placeholder: labels.searchPlaceholder,
7848
7883
  disabled,
7849
- className: cn(inputClassName2, "pl-9 pr-9", inputClass)
7884
+ className: cn(inputClassName2, "pl-9 pr-9", inputClass),
7885
+ "aria-label": labels.searchPlaceholder
7850
7886
  }
7851
7887
  ),
7852
7888
  loadingAutocomplete && /* @__PURE__ */ jsx(Loader2, { className: "absolute right-10 top-1/2 h-4 w-4 -translate-y-1/2 animate-spin text-muted-foreground" }),
@@ -7874,29 +7910,6 @@ function USAddressInput({
7874
7910
  suggestion.placeId
7875
7911
  )) })
7876
7912
  ] }),
7877
- allowUspsValidation && uspsSuggestion && /* @__PURE__ */ jsxs("div", { className: "space-y-2 rounded-lg border border-amber-200 bg-amber-50 p-3 dark:border-amber-900 dark:bg-amber-950/30", children: [
7878
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-amber-900 dark:text-amber-100", children: labels.uspsSuggested }),
7879
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: [
7880
- uspsSuggestion.street,
7881
- uspsSuggestion.street2,
7882
- uspsSuggestion.city,
7883
- uspsSuggestion.state,
7884
- uspsSuggestion.zip
7885
- ].filter(Boolean).join(", ") }),
7886
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
7887
- /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", onClick: applyUspsSuggestion, children: labels.uspsUseSuggestion }),
7888
- /* @__PURE__ */ jsx(
7889
- Button,
7890
- {
7891
- type: "button",
7892
- size: "sm",
7893
- variant: "outline",
7894
- onClick: () => setUspsSuggestion(null),
7895
- children: labels.uspsKeepMine
7896
- }
7897
- )
7898
- ] })
7899
- ] }),
7900
7913
  /* @__PURE__ */ jsxs("div", { className: "grid gap-4", children: [
7901
7914
  /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
7902
7915
  /* @__PURE__ */ jsx(
@@ -8044,26 +8057,50 @@ function USAddressInput({
8044
8057
  }
8045
8058
  )
8046
8059
  ] })
8047
- ] }),
8048
- allowUspsValidation && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx(
8049
- Button,
8060
+ ] })
8061
+ ] }),
8062
+ allowUspsValidation && /* @__PURE__ */ jsxs(Fragment, { children: [
8063
+ /* @__PURE__ */ jsx(
8064
+ "div",
8050
8065
  {
8051
- type: "button",
8052
- variant: "secondary",
8053
- size: "sm",
8054
- disabled: disabled || loadingValidate,
8055
- onClick: () => void runUspsValidate(),
8056
- className: "gap-2",
8066
+ className: "flex min-h-7 items-center gap-2 text-xs text-muted-foreground",
8067
+ "aria-live": "polite",
8057
8068
  children: loadingValidate ? /* @__PURE__ */ jsxs(Fragment, { children: [
8058
- /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
8059
- labels.uspsValidating
8060
- ] }) : labels.uspsValidate
8069
+ /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 shrink-0 animate-spin" }),
8070
+ /* @__PURE__ */ jsx("span", { children: labels.uspsValidating })
8071
+ ] }) : uspsVerifiedNoChange && !uspsSuggestion ? /* @__PURE__ */ jsxs(Fragment, { children: [
8072
+ /* @__PURE__ */ jsx(CheckCircle2, { className: "h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" }),
8073
+ /* @__PURE__ */ jsx("span", { children: labels.uspsVerified })
8074
+ ] }) : /* @__PURE__ */ jsx("span", { className: "select-none opacity-0", "aria-hidden": true, children: "\xA0" })
8061
8075
  }
8062
- ) })
8076
+ ),
8077
+ uspsSuggestion ? /* @__PURE__ */ jsxs("div", { className: "space-y-2 rounded-lg border border-amber-200 bg-amber-50 p-3 dark:border-amber-900 dark:bg-amber-950/30", children: [
8078
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-amber-900 dark:text-amber-100", children: labels.uspsSuggested }),
8079
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: [
8080
+ uspsSuggestion.street,
8081
+ uspsSuggestion.street2,
8082
+ uspsSuggestion.city,
8083
+ uspsSuggestion.state,
8084
+ uspsSuggestion.zip
8085
+ ].filter(Boolean).join(", ") }),
8086
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
8087
+ /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", onClick: applyUspsSuggestion, children: labels.uspsUseSuggestion }),
8088
+ /* @__PURE__ */ jsx(
8089
+ Button,
8090
+ {
8091
+ type: "button",
8092
+ size: "sm",
8093
+ variant: "outline",
8094
+ onClick: dismissUspsSuggestion,
8095
+ children: labels.uspsKeepMine
8096
+ }
8097
+ )
8098
+ ] })
8099
+ ] }) : null
8063
8100
  ] })
8064
8101
  ] });
8065
8102
  }
8066
8103
 
8067
- export { AvatarEditor, AvatarEditorDialog, BLOCKS_DATA_ENVIRONMENTS, Button, CalendarContext, CalendarSubscribeButton, CalendarView, CalendarWidget, CardInput, ChatRoomView, ChatSidebar, ChatSidebarContext, ChatSidebarProvider, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EnvironmentBanner, EnvironmentContext, EnvironmentDot, EnvironmentMiniBadge, EnvironmentSwitcher, EventDialog, EventRsvpBadge, LanguageContext, LanguageSwitcher, MiniCalendar, NotificationsContext, NotificationsWidget, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ScrollArea, ScrollBar, Slider, ThemeSwitcher, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, USAddressInput, UpcomingEvents, buttonVariants, cn, defaultLanguages, getEnvironmentDotClass, getEnvironmentLabel, isBlocksDataEnvironment, toggleVariants, useCalendarContext, useChatRoom, useChatSidebar, useDebouncedValue, useEnvironmentContext, useLanguageContext, useNotificationsContext };
8104
+ export { AvatarEditor, AvatarEditorDialog, BLOCKS_DATA_ENVIRONMENTS, Button, CalendarContext, CalendarSubscribeButton, CalendarView, CalendarWidget, CardInput, ChatRoomView, ChatSidebar, ChatSidebarContext, ChatSidebarProvider, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EnvironmentBanner, EnvironmentContext, EnvironmentDot, EnvironmentMiniBadge, EnvironmentSwitcher, EventDialog, EventRsvpBadge, LanguageContext, LanguageSwitcher, MiniCalendar, NotificationsContext, NotificationsWidget, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ScrollArea, ScrollBar, Slider, ThemeSwitcher, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, USAddressInput, UpcomingEvents, buttonVariants, cn, defaultLanguages, getEnvironmentDotClass, getEnvironmentLabel, isBlocksDataEnvironment, toggleVariants, useCalendarContext, useChatRoom, useChatSidebar, useDebouncedValue, useDebouncedValueStrict, useEnvironmentContext, useLanguageContext, useNotificationsContext };
8068
8105
  //# sourceMappingURL=index.js.map
8069
8106
  //# sourceMappingURL=index.js.map