@geowiki/design-system 0.16.9-dev.14 → 0.16.9-dev.15

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.ts CHANGED
@@ -116,9 +116,11 @@ declare const Command: React$1.ForwardRefExoticComponent<Omit<{
116
116
  label?: string | undefined;
117
117
  shouldFilter?: boolean | undefined;
118
118
  filter?: ((value: string, search: string) => number) | undefined;
119
+ defaultValue?: string | undefined;
119
120
  value?: string | undefined;
120
121
  onValueChange?: ((value: string) => void) | undefined;
121
122
  loop?: boolean | undefined;
123
+ vimBindings?: boolean | undefined;
122
124
  } & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
123
125
  interface CommandDialogProps extends DialogProps {
124
126
  }
@@ -135,9 +137,10 @@ declare const CommandEmpty: React$1.ForwardRefExoticComponent<Omit<{
135
137
  } & React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
136
138
  declare const CommandGroup: React$1.ForwardRefExoticComponent<Omit<{
137
139
  children?: React$1.ReactNode;
138
- } & Omit<React$1.HTMLAttributes<HTMLDivElement>, "value" | "heading"> & {
140
+ } & Omit<React$1.HTMLAttributes<HTMLDivElement>, "heading" | "value"> & {
139
141
  heading?: React$1.ReactNode;
140
142
  value?: string | undefined;
143
+ forceMount?: boolean | undefined;
141
144
  } & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
142
145
  declare const CommandSeparator: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement> & {
143
146
  alwaysRender?: boolean | undefined;
@@ -148,6 +151,7 @@ declare const CommandItem: React$1.ForwardRefExoticComponent<Omit<{
148
151
  disabled?: boolean | undefined;
149
152
  onSelect?: ((value: string) => void) | undefined;
150
153
  value?: string | undefined;
154
+ forceMount?: boolean | undefined;
151
155
  } & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
152
156
  declare const CommandShortcut: {
153
157
  ({ className, ...props }: React$1.HTMLAttributes<HTMLSpanElement>): react_jsx_runtime.JSX.Element;
@@ -221,7 +225,7 @@ declare const DropdownMenuShortcut: {
221
225
  displayName: string;
222
226
  };
223
227
 
224
- declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = undefined>(props: react_hook_form.FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React$1.JSX.Element;
228
+ declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: react_hook_form.FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React$1.JSX.Element;
225
229
  declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => react_jsx_runtime.JSX.Element;
226
230
  declare const useFormField: () => {
227
231
  invalid: boolean;
@@ -1246,4 +1250,4 @@ interface H1BodyButtonWithAppProps {
1246
1250
  }
1247
1251
  declare const H1BodyButtonWithApp: (props: H1BodyButtonWithAppProps) => react_jsx_runtime.JSX.Element;
1248
1252
 
1249
- export { AboutInfoItem, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountIcon, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppItem, AppItemsList, AspectRatio, AtomIcon, Avatar, AvatarFallback, AvatarImage, Badge, BadgeProps, BasicFooter, BigLandingTitle, BigLandingTitleAccent, Body12, Body12m, Body12sb, Body14, Body14m, Body14sb, Body15, Body15it, Body15m, Body15sb, Body16, Body16it, Body16m, Body16sb, Body18, Body18m, Body18sb, Body20, Body20m, Body20sb, BookTextIcon, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonContent, ButtonLink, ButtonProps$1 as ButtonProps, Calendar, CalendarIcon, CalendarProps, CameraIcon, Caption, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartLineDotsIcon, ChatsIcons, Checkbox$1 as Checkbox, ClipboardIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Cookies, CountryItem, CpuIcon, CustomImage, CustomTable, DeleteButton, DesignButton, Checkbox as DesignCheckbox, DesignFooter, DesignHeader, DesignHeaderProps, DesignInput, DesignInputProps, DesignRadioGroup, DesignRadioGroupItem, DesignResultTag, DesignSelect, DesignSelectContent, DesignSelectGroup, DesignSelectItem, DesignSelectLabel, DesignSelectSeparator, DesignSelectTrigger, DesignSelectValue, DesignSimpleTag, DesignSwitch, DesktopCodeIcon, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DisplayItem, DownloadIcon, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ErrorMessage, FaqComponent, FarmerClusterPin, FarmerClustersIcon, FeatureDisabled, FeaturedItemWithBannerImage, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FullPageLoader, GlobeIcon, GridDividersIcon, H1AccentDesign, H1BodyButton, H1BodyButtonProps, H1BodyButtonWithApp, H1BodyButtonWithAppProps, H1Design, H2AccentDesign, H2BodyButton, H2Design, H3Design, H4Design, H5Design, H6Design, H7Design, H8Design, H9Design, HardDriveIcon, HeadphonesIcon, HeroImage, HeroImageRightWithAppButtons, Hexagon, HoverCard, HoverCardContent, HoverCardTrigger, IPanelHorizontalProps, Icon, IconPaths, IframeViewer, ImageIcon, InfoBox, Input, InputProps, KeyInfoItem, Label, LandingTitle, LandingTitleAccent, LastUpdatedTag, LayerGroupIcon, LegendIcon, LinkButtonItem, Loader, LoaderFull, LocalLoader, LocationIcon, MapIcon, MapLayersIcon, MapLegendIcon, MediaEmbedItem, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, Microscope, MicroscopeIcon, MinusIcon, MultiSelect, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NoResults, Notification, ObservationPin, OldButton, OldCustomInput, OverlayIcon, Pagination, PanelHorizontal, PermissionDisabled, PlusIcon, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PrimaryButton, Progress, RadioGroup, RadioGroupItem, ResourceTag, ResourcesIcon, ResourcesQuickFind, ScrollArea, ScrollBar, Search, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, SettingsIcon, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, ShowLargeText, ShowShortText, SimpleLink, SizedImage, Skeleton, Slider, StopWatchCheckIcon, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TableViewProps, Tabs, TabsContent, TabsList, TabsTrigger, Tag, TagList, TagsGroup, TestWeight, TextArea, Textarea, TextareaProps, ThemeSwitcher, ThreeColumn, Toast$1 as Toast, ToastAction, ToastActionElement, ToastClose, ToastDescription, ToastProps, ToastProvider, ToastTitle, ToastViewport, Toaster, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UmamiAnalytics, UnderConstruction, UserGroupIcon, UsersGroup, VersionDisplay, VideoPlayIcon, XIcon, badgeVariants, buttonVariants, cn, designButtonVariants, getPages, navigationMenuTriggerStyle, reducer, toast, toggleVariants, useDebounce, useFormField, useToast };
1253
+ export { AboutInfoItem, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountIcon, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppItem, AppItemsList, AspectRatio, AtomIcon, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, BasicFooter, BigLandingTitle, BigLandingTitleAccent, Body12, Body12m, Body12sb, Body14, Body14m, Body14sb, Body15, Body15it, Body15m, Body15sb, Body16, Body16it, Body16m, Body16sb, Body18, Body18m, Body18sb, Body20, Body20m, Body20sb, BookTextIcon, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonContent, ButtonLink, type ButtonProps$1 as ButtonProps, Calendar, CalendarIcon, type CalendarProps, CameraIcon, Caption, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, type CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartLineDotsIcon, ChatsIcons, Checkbox$1 as Checkbox, ClipboardIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Cookies, CountryItem, CpuIcon, CustomImage, CustomTable, DeleteButton, DesignButton, Checkbox as DesignCheckbox, DesignFooter, DesignHeader, type DesignHeaderProps, DesignInput, type DesignInputProps, DesignRadioGroup, DesignRadioGroupItem, DesignResultTag, DesignSelect, DesignSelectContent, DesignSelectGroup, DesignSelectItem, DesignSelectLabel, DesignSelectSeparator, DesignSelectTrigger, DesignSelectValue, DesignSimpleTag, DesignSwitch, DesktopCodeIcon, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, type DisplayItem, DownloadIcon, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ErrorMessage, FaqComponent, FarmerClusterPin, FarmerClustersIcon, FeatureDisabled, FeaturedItemWithBannerImage, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FullPageLoader, GlobeIcon, GridDividersIcon, H1AccentDesign, H1BodyButton, type H1BodyButtonProps, H1BodyButtonWithApp, type H1BodyButtonWithAppProps, H1Design, H2AccentDesign, H2BodyButton, H2Design, H3Design, H4Design, H5Design, H6Design, H7Design, H8Design, H9Design, HardDriveIcon, HeadphonesIcon, HeroImage, HeroImageRightWithAppButtons, Hexagon, HoverCard, HoverCardContent, HoverCardTrigger, type IPanelHorizontalProps, Icon, IconPaths, IframeViewer, ImageIcon, InfoBox, Input, type InputProps, KeyInfoItem, Label, LandingTitle, LandingTitleAccent, LastUpdatedTag, LayerGroupIcon, LegendIcon, type LinkButtonItem, Loader, LoaderFull, LocalLoader, LocationIcon, MapIcon, MapLayersIcon, MapLegendIcon, MediaEmbedItem, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, Microscope, MicroscopeIcon, MinusIcon, MultiSelect, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NoResults, Notification, ObservationPin, OldButton, OldCustomInput, OverlayIcon, Pagination, PanelHorizontal, PermissionDisabled, PlusIcon, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PrimaryButton, Progress, RadioGroup, RadioGroupItem, ResourceTag, ResourcesIcon, ResourcesQuickFind, ScrollArea, ScrollBar, Search, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, SettingsIcon, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, ShowLargeText, ShowShortText, SimpleLink, SizedImage, Skeleton, Slider, StopWatchCheckIcon, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, type TableViewProps, Tabs, TabsContent, TabsList, TabsTrigger, Tag, TagList, TagsGroup, TestWeight, TextArea, Textarea, type TextareaProps, ThemeSwitcher, ThreeColumn, Toast$1 as Toast, ToastAction, type ToastActionElement, ToastClose, ToastDescription, type ToastProps, ToastProvider, ToastTitle, ToastViewport, Toaster, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UmamiAnalytics, UnderConstruction, UserGroupIcon, UsersGroup, VersionDisplay, VideoPlayIcon, XIcon, badgeVariants, buttonVariants, cn, designButtonVariants, getPages, navigationMenuTriggerStyle, reducer, toast, toggleVariants, useDebounce, useFormField, useToast };
package/dist/index.js CHANGED
@@ -1582,48 +1582,48 @@ var isNullOrUndefined = (value) => value == null;
1582
1582
  var isObjectType = (value) => typeof value === "object";
1583
1583
  var isObject = (value) => !isNullOrUndefined(value) && !Array.isArray(value) && isObjectType(value) && !isDateObject(value);
1584
1584
  var getEventValue = (event) => isObject(event) && event.target ? isCheckBoxInput(event.target) ? event.target.checked : event.target.value : event;
1585
- var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
1586
- var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
1585
+ var isNameInFieldArray = (names, name) => name.split(".").some((part, index, arr) => !isNaN(Number(part)) && names.has(arr.slice(0, index).join(".")));
1587
1586
  var isPlainObject = (tempObject) => {
1588
1587
  const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
1589
1588
  return isObject(prototypeCopy) && prototypeCopy.hasOwnProperty("isPrototypeOf");
1590
1589
  };
1591
1590
  var isWeb = typeof window !== "undefined" && typeof window.HTMLElement !== "undefined" && typeof document !== "undefined";
1592
1591
  function cloneObject(data) {
1593
- let copy;
1594
- const isArray = Array.isArray(data);
1595
1592
  if (data instanceof Date) {
1596
- copy = new Date(data);
1597
- } else if (data instanceof Set) {
1598
- copy = new Set(data);
1599
- } else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) && (isArray || isObject(data))) {
1600
- copy = isArray ? [] : {};
1601
- if (!isArray && !isPlainObject(data)) {
1602
- copy = data;
1603
- } else {
1604
- for (const key in data) {
1605
- if (data.hasOwnProperty(key)) {
1606
- copy[key] = cloneObject(data[key]);
1607
- }
1608
- }
1609
- }
1610
- } else {
1593
+ return new Date(data);
1594
+ }
1595
+ const isFileListInstance = typeof FileList !== "undefined" && data instanceof FileList;
1596
+ if (isWeb && (data instanceof Blob || isFileListInstance)) {
1611
1597
  return data;
1612
1598
  }
1599
+ const isArray = Array.isArray(data);
1600
+ if (!isArray && !(isObject(data) && isPlainObject(data))) {
1601
+ return data;
1602
+ }
1603
+ const copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
1604
+ for (const key in data) {
1605
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
1606
+ copy[key] = cloneObject(data[key]);
1607
+ }
1608
+ }
1613
1609
  return copy;
1614
1610
  }
1615
- var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
1611
+ var isKey = (value) => /^\w*$/.test(value);
1616
1612
  var isUndefined = (val) => val === void 0;
1613
+ var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
1614
+ var stringToPath = (input) => compact(input.replace(/["|']|\]/g, "").split(/\.|\[/));
1617
1615
  var get = (object, path, defaultValue) => {
1618
1616
  if (!path || !isObject(object)) {
1619
1617
  return defaultValue;
1620
1618
  }
1621
- const result = compact(path.split(/[,[\].]+?/)).reduce((result2, key) => isNullOrUndefined(result2) ? result2 : result2[key], object);
1619
+ const paths = isKey(path) ? [path] : stringToPath(path);
1620
+ const result = paths.reduce((result2, key) => {
1621
+ return isNullOrUndefined(result2) ? void 0 : result2[key];
1622
+ }, object);
1622
1623
  return isUndefined(result) || result === object ? isUndefined(object[path]) ? defaultValue : object[path] : result;
1623
1624
  };
1624
1625
  var isBoolean = (value) => typeof value === "boolean";
1625
- var isKey = (value) => /^\w*$/.test(value);
1626
- var stringToPath = (input) => compact(input.replace(/["|']|\]/g, "").split(/\.|\[/));
1626
+ var isFunction = (value) => typeof value === "function";
1627
1627
  var set = (object, path, value) => {
1628
1628
  let index = -1;
1629
1629
  const tempPath = isKey(path) ? [path] : stringToPath(path);
@@ -1636,18 +1636,20 @@ var set = (object, path, value) => {
1636
1636
  const objValue = object[key];
1637
1637
  newValue = isObject(objValue) || Array.isArray(objValue) ? objValue : !isNaN(+tempPath[index + 1]) ? [] : {};
1638
1638
  }
1639
- if (key === "__proto__") {
1639
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
1640
1640
  return;
1641
1641
  }
1642
1642
  object[key] = newValue;
1643
1643
  object = object[key];
1644
1644
  }
1645
- return object;
1646
1645
  };
1647
1646
  var EVENTS = {
1648
1647
  BLUR: "blur",
1649
1648
  FOCUS_OUT: "focusout",
1650
- CHANGE: "change"
1649
+ CHANGE: "change",
1650
+ SUBMIT: "submit",
1651
+ TRIGGER: "trigger",
1652
+ VALID: "valid"
1651
1653
  };
1652
1654
  var VALIDATION_MODE = {
1653
1655
  onBlur: "onBlur",
@@ -1656,16 +1658,11 @@ var VALIDATION_MODE = {
1656
1658
  onTouched: "onTouched",
1657
1659
  all: "all"
1658
1660
  };
1659
- var HookFormContext = import_react.default.createContext(null);
1660
- var useFormContext = () => import_react.default.useContext(HookFormContext);
1661
- var FormProvider = (props) => {
1662
- const _a = props, { children } = _a, data = __objRest(_a, ["children"]);
1663
- return import_react.default.createElement(HookFormContext.Provider, { value: data }, children);
1664
- };
1661
+ var HookFormControlContext = import_react.default.createContext(null);
1662
+ HookFormControlContext.displayName = "HookFormControlContext";
1663
+ var useFormControlContext = () => import_react.default.useContext(HookFormControlContext);
1665
1664
  var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
1666
- const result = {
1667
- defaultValues: control._defaultValues
1668
- };
1665
+ const result = {};
1669
1666
  for (const key in formState) {
1670
1667
  Object.defineProperty(result, key, {
1671
1668
  get: () => {
@@ -1680,31 +1677,13 @@ var getProxyFormState = (formState, control, localProxyFormState, isRoot = true)
1680
1677
  }
1681
1678
  return result;
1682
1679
  };
1683
- var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
1684
- var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
1685
- updateFormState(formStateData);
1686
- const _a = formStateData, { name } = _a, formState = __objRest(_a, ["name"]);
1687
- return isEmptyObject(formState) || Object.keys(formState).length >= Object.keys(_proxyFormState).length || Object.keys(formState).find((key) => _proxyFormState[key] === (!isRoot || VALIDATION_MODE.all));
1688
- };
1689
- var convertToArrayPayload = (value) => Array.isArray(value) ? value : [value];
1690
- var shouldSubscribeByName = (name, signalName, exact) => !name || !signalName || name === signalName || convertToArrayPayload(name).some((currentName) => currentName && (exact ? currentName === signalName : currentName.startsWith(signalName) || signalName.startsWith(currentName)));
1691
- function useSubscribe(props) {
1692
- const _props = import_react.default.useRef(props);
1693
- _props.current = props;
1694
- import_react.default.useEffect(() => {
1695
- const subscription = !props.disabled && _props.current.subject && _props.current.subject.subscribe({
1696
- next: _props.current.next
1697
- });
1698
- return () => {
1699
- subscription && subscription.unsubscribe();
1700
- };
1701
- }, [props.disabled]);
1702
- }
1680
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react.default.useLayoutEffect : import_react.default.useEffect;
1703
1681
  function useFormState(props) {
1704
- const methods = useFormContext();
1705
- const { control = methods.control, disabled, name, exact } = props || {};
1706
- const [formState, updateFormState] = import_react.default.useState(control._formState);
1707
- const _mounted = import_react.default.useRef(true);
1682
+ const formControl = useFormControlContext();
1683
+ const { control = formControl, disabled, name, exact } = props || {};
1684
+ const [formState, updateFormState] = import_react.default.useState(() => __spreadProps(__spreadValues({}, control._formState), {
1685
+ defaultValues: control._defaultValues
1686
+ }));
1708
1687
  const _localProxyFormState = import_react.default.useRef({
1709
1688
  isDirty: false,
1710
1689
  isLoading: false,
@@ -1715,21 +1694,20 @@ function useFormState(props) {
1715
1694
  isValid: false,
1716
1695
  errors: false
1717
1696
  });
1718
- const _name = import_react.default.useRef(name);
1719
- _name.current = name;
1720
- useSubscribe({
1721
- disabled,
1722
- next: (value) => _mounted.current && shouldSubscribeByName(_name.current, value.name, exact) && shouldRenderFormState(value, _localProxyFormState.current, control._updateFormState) && updateFormState(__spreadValues(__spreadValues({}, control._formState), value)),
1723
- subject: control._subjects.state
1724
- });
1697
+ useIsomorphicLayoutEffect(() => control._subscribe({
1698
+ name,
1699
+ formState: _localProxyFormState.current,
1700
+ exact,
1701
+ callback: (formState2) => {
1702
+ !disabled && updateFormState(__spreadProps(__spreadValues(__spreadValues({}, control._formState), formState2), {
1703
+ defaultValues: control._defaultValues
1704
+ }));
1705
+ }
1706
+ }), [name, disabled, exact]);
1725
1707
  import_react.default.useEffect(() => {
1726
- _mounted.current = true;
1727
- _localProxyFormState.current.isValid && control._updateValid(true);
1728
- return () => {
1729
- _mounted.current = false;
1730
- };
1708
+ _localProxyFormState.current.isValid && control._setValid(true);
1731
1709
  }, [control]);
1732
- return getProxyFormState(formState, control, _localProxyFormState.current, false);
1710
+ return import_react.default.useMemo(() => getProxyFormState(formState, control, _localProxyFormState.current, false), [formState, control]);
1733
1711
  }
1734
1712
  var isString = (value) => typeof value === "string";
1735
1713
  var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
@@ -1743,129 +1721,261 @@ var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) =>
1743
1721
  isGlobal && (_names.watchAll = true);
1744
1722
  return formValues;
1745
1723
  };
1746
- function useWatch(props) {
1747
- const methods = useFormContext();
1748
- const { control = methods.control, name, defaultValue, disabled, exact } = props || {};
1749
- const _name = import_react.default.useRef(name);
1750
- _name.current = name;
1751
- useSubscribe({
1752
- disabled,
1753
- subject: control._subjects.values,
1754
- next: (formState) => {
1755
- if (shouldSubscribeByName(_name.current, formState.name, exact)) {
1756
- updateValue(cloneObject(generateWatchOutput(_name.current, control._names, formState.values || control._formValues, false, defaultValue)));
1724
+ var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
1725
+ function deepEqual(object1, object2, visited = /* @__PURE__ */ new WeakSet()) {
1726
+ if (object1 === object2) {
1727
+ return true;
1728
+ }
1729
+ if (isPrimitive(object1) || isPrimitive(object2)) {
1730
+ return Object.is(object1, object2);
1731
+ }
1732
+ if (isDateObject(object1) && isDateObject(object2)) {
1733
+ return Object.is(object1.getTime(), object2.getTime());
1734
+ }
1735
+ const keys1 = Object.keys(object1);
1736
+ const keys2 = Object.keys(object2);
1737
+ if (keys1.length !== keys2.length) {
1738
+ return false;
1739
+ }
1740
+ if (visited.has(object1) || visited.has(object2)) {
1741
+ return true;
1742
+ }
1743
+ visited.add(object1);
1744
+ visited.add(object2);
1745
+ for (const key of keys1) {
1746
+ const val1 = object1[key];
1747
+ if (!(key in object2)) {
1748
+ return false;
1749
+ }
1750
+ if (key !== "ref") {
1751
+ const val2 = object2[key];
1752
+ if (isDateObject(val1) && isDateObject(val2) || (isObject(val1) || Array.isArray(val1)) && (isObject(val2) || Array.isArray(val2)) ? !deepEqual(val1, val2, visited) : !Object.is(val1, val2)) {
1753
+ return false;
1757
1754
  }
1758
1755
  }
1756
+ }
1757
+ return true;
1758
+ }
1759
+ function useWatch(props) {
1760
+ const formControl = useFormControlContext();
1761
+ const { control = formControl, name, defaultValue, disabled, exact, compute } = props || {};
1762
+ const _defaultValue = import_react.default.useRef(defaultValue);
1763
+ const _compute = import_react.default.useRef(compute);
1764
+ const _computeFormValues = import_react.default.useRef(void 0);
1765
+ const _prevControl = import_react.default.useRef(control);
1766
+ const _prevName = import_react.default.useRef(name);
1767
+ _compute.current = compute;
1768
+ const [value, updateValue] = import_react.default.useState(() => {
1769
+ const defaultValue2 = control._getWatch(name, _defaultValue.current);
1770
+ return _compute.current ? _compute.current(defaultValue2) : defaultValue2;
1759
1771
  });
1760
- const [value, updateValue] = import_react.default.useState(control._getWatch(name, defaultValue));
1772
+ const getCurrentOutput = import_react.default.useCallback((values) => {
1773
+ const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
1774
+ return _compute.current ? _compute.current(formValues) : formValues;
1775
+ }, [control._formValues, control._names, name]);
1776
+ const refreshValue = import_react.default.useCallback((values) => {
1777
+ if (!disabled) {
1778
+ const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
1779
+ if (_compute.current) {
1780
+ const computedFormValues = _compute.current(formValues);
1781
+ if (!deepEqual(computedFormValues, _computeFormValues.current)) {
1782
+ updateValue(computedFormValues);
1783
+ _computeFormValues.current = computedFormValues;
1784
+ }
1785
+ } else {
1786
+ updateValue(formValues);
1787
+ }
1788
+ }
1789
+ }, [control._formValues, control._names, disabled, name]);
1790
+ useIsomorphicLayoutEffect(() => {
1791
+ if (_prevControl.current !== control || !deepEqual(_prevName.current, name)) {
1792
+ _prevControl.current = control;
1793
+ _prevName.current = name;
1794
+ refreshValue();
1795
+ }
1796
+ return control._subscribe({
1797
+ name,
1798
+ formState: {
1799
+ values: true
1800
+ },
1801
+ exact,
1802
+ callback: (formState) => {
1803
+ refreshValue(formState.values);
1804
+ }
1805
+ });
1806
+ }, [control, exact, name, refreshValue]);
1761
1807
  import_react.default.useEffect(() => control._removeUnmounted());
1762
- return value;
1808
+ const controlChanged = _prevControl.current !== control;
1809
+ const prevName = _prevName.current;
1810
+ const computedOutput = import_react.default.useMemo(() => {
1811
+ if (disabled) {
1812
+ return null;
1813
+ }
1814
+ const nameChanged = !controlChanged && !deepEqual(prevName, name);
1815
+ const shouldReturnImmediate = controlChanged || nameChanged;
1816
+ return shouldReturnImmediate ? getCurrentOutput() : null;
1817
+ }, [disabled, controlChanged, name, prevName, getCurrentOutput]);
1818
+ return computedOutput !== null ? computedOutput : value;
1763
1819
  }
1764
1820
  function useController(props) {
1765
- const methods = useFormContext();
1766
- const { name, disabled, control = methods.control, shouldUnregister } = props;
1821
+ const formControl = useFormControlContext();
1822
+ const { name, disabled, control = formControl, shouldUnregister, defaultValue, exact = true } = props;
1767
1823
  const isArrayField = isNameInFieldArray(control._names.array, name);
1824
+ const defaultValueMemo = import_react.default.useMemo(() => get(control._formValues, name, get(control._defaultValues, name, defaultValue)), [control, name, defaultValue]);
1768
1825
  const value = useWatch({
1769
1826
  control,
1770
1827
  name,
1771
- defaultValue: get(control._formValues, name, get(control._defaultValues, name, props.defaultValue)),
1772
- exact: true
1828
+ defaultValue: defaultValueMemo,
1829
+ exact
1773
1830
  });
1774
1831
  const formState = useFormState({
1775
1832
  control,
1776
1833
  name,
1777
- exact: true
1834
+ exact
1778
1835
  });
1836
+ const _props = import_react.default.useRef(props);
1779
1837
  const _registerProps = import_react.default.useRef(control.register(name, __spreadValues(__spreadProps(__spreadValues({}, props.rules), {
1780
1838
  value
1781
1839
  }), isBoolean(props.disabled) ? { disabled: props.disabled } : {})));
1840
+ _props.current = props;
1841
+ const fieldState = import_react.default.useMemo(() => Object.defineProperties({}, {
1842
+ invalid: {
1843
+ enumerable: true,
1844
+ get: () => !!get(formState.errors, name)
1845
+ },
1846
+ isDirty: {
1847
+ enumerable: true,
1848
+ get: () => !!get(formState.dirtyFields, name)
1849
+ },
1850
+ isTouched: {
1851
+ enumerable: true,
1852
+ get: () => !!get(formState.touchedFields, name)
1853
+ },
1854
+ isValidating: {
1855
+ enumerable: true,
1856
+ get: () => !!get(formState.validatingFields, name)
1857
+ },
1858
+ error: {
1859
+ enumerable: true,
1860
+ get: () => get(formState.errors, name)
1861
+ }
1862
+ }), [formState, name]);
1863
+ const onChange = import_react.default.useCallback((event) => _registerProps.current.onChange({
1864
+ target: {
1865
+ value: getEventValue(event),
1866
+ name
1867
+ },
1868
+ type: EVENTS.CHANGE
1869
+ }), [name]);
1870
+ const onBlur = import_react.default.useCallback(() => _registerProps.current.onBlur({
1871
+ target: {
1872
+ value: get(control._formValues, name),
1873
+ name
1874
+ },
1875
+ type: EVENTS.BLUR
1876
+ }), [name, control._formValues]);
1877
+ const ref = import_react.default.useCallback((elm) => {
1878
+ const field2 = get(control._fields, name);
1879
+ if (field2 && field2._f && elm) {
1880
+ field2._f.ref = {
1881
+ focus: () => isFunction(elm.focus) && elm.focus(),
1882
+ select: () => isFunction(elm.select) && elm.select(),
1883
+ setCustomValidity: (message) => isFunction(elm.setCustomValidity) && elm.setCustomValidity(message),
1884
+ reportValidity: () => isFunction(elm.reportValidity) && elm.reportValidity()
1885
+ };
1886
+ }
1887
+ }, [control._fields, name]);
1888
+ const field = import_react.default.useMemo(() => __spreadProps(__spreadValues({
1889
+ name,
1890
+ value
1891
+ }, isBoolean(disabled) || formState.disabled ? { disabled: formState.disabled || disabled } : {}), {
1892
+ onChange,
1893
+ onBlur,
1894
+ ref
1895
+ }), [name, disabled, formState.disabled, onChange, onBlur, ref, value]);
1782
1896
  import_react.default.useEffect(() => {
1783
1897
  const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
1898
+ control.register(name, __spreadValues(__spreadValues({}, _props.current.rules), isBoolean(_props.current.disabled) ? { disabled: _props.current.disabled } : {}));
1784
1899
  const updateMounted = (name2, value2) => {
1785
- const field = get(control._fields, name2);
1786
- if (field && field._f) {
1787
- field._f.mount = value2;
1900
+ const field2 = get(control._fields, name2);
1901
+ if (field2 && field2._f) {
1902
+ field2._f.mount = value2;
1788
1903
  }
1789
1904
  };
1790
1905
  updateMounted(name, true);
1791
1906
  if (_shouldUnregisterField) {
1792
- const value2 = cloneObject(get(control._options.defaultValues, name));
1907
+ const value2 = cloneObject(get(control._options.defaultValues, name, _props.current.defaultValue));
1793
1908
  set(control._defaultValues, name, value2);
1794
1909
  if (isUndefined(get(control._formValues, name))) {
1795
1910
  set(control._formValues, name, value2);
1796
1911
  }
1797
1912
  }
1913
+ !isArrayField && control.register(name);
1798
1914
  return () => {
1799
1915
  (isArrayField ? _shouldUnregisterField && !control._state.action : _shouldUnregisterField) ? control.unregister(name) : updateMounted(name, false);
1800
1916
  };
1801
1917
  }, [name, control, isArrayField, shouldUnregister]);
1802
1918
  import_react.default.useEffect(() => {
1803
- if (get(control._fields, name)) {
1804
- control._updateDisabledField({
1805
- disabled,
1806
- fields: control._fields,
1807
- name,
1808
- value: get(control._fields, name)._f.value
1809
- });
1810
- }
1919
+ control._setDisabledField({
1920
+ disabled,
1921
+ name
1922
+ });
1811
1923
  }, [disabled, name, control]);
1812
- return {
1813
- field: __spreadProps(__spreadValues({
1814
- name,
1815
- value
1816
- }, isBoolean(disabled) || formState.disabled ? { disabled: formState.disabled || disabled } : {}), {
1817
- onChange: import_react.default.useCallback((event) => _registerProps.current.onChange({
1818
- target: {
1819
- value: getEventValue(event),
1820
- name
1821
- },
1822
- type: EVENTS.CHANGE
1823
- }), [name]),
1824
- onBlur: import_react.default.useCallback(() => _registerProps.current.onBlur({
1825
- target: {
1826
- value: get(control._formValues, name),
1827
- name
1828
- },
1829
- type: EVENTS.BLUR
1830
- }), [name, control]),
1831
- ref: import_react.default.useCallback((elm) => {
1832
- const field = get(control._fields, name);
1833
- if (field && elm) {
1834
- field._f.ref = {
1835
- focus: () => elm.focus(),
1836
- select: () => elm.select(),
1837
- setCustomValidity: (message) => elm.setCustomValidity(message),
1838
- reportValidity: () => elm.reportValidity()
1839
- };
1840
- }
1841
- }, [control._fields, name])
1842
- }),
1924
+ return import_react.default.useMemo(() => ({
1925
+ field,
1843
1926
  formState,
1844
- fieldState: Object.defineProperties({}, {
1845
- invalid: {
1846
- enumerable: true,
1847
- get: () => !!get(formState.errors, name)
1848
- },
1849
- isDirty: {
1850
- enumerable: true,
1851
- get: () => !!get(formState.dirtyFields, name)
1852
- },
1853
- isTouched: {
1854
- enumerable: true,
1855
- get: () => !!get(formState.touchedFields, name)
1856
- },
1857
- isValidating: {
1858
- enumerable: true,
1859
- get: () => !!get(formState.validatingFields, name)
1860
- },
1861
- error: {
1862
- enumerable: true,
1863
- get: () => get(formState.errors, name)
1864
- }
1865
- })
1866
- };
1927
+ fieldState
1928
+ }), [field, formState, fieldState]);
1867
1929
  }
1868
1930
  var Controller = (props) => props.render(useController(props));
1931
+ var HookFormContext = import_react.default.createContext(null);
1932
+ HookFormContext.displayName = "HookFormContext";
1933
+ var useFormContext = () => import_react.default.useContext(HookFormContext);
1934
+ var FormProvider = (props) => {
1935
+ const { children, watch, getValues, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, handleSubmit, unregister, control, register, setFocus, subscribe } = props;
1936
+ const memoizedValue = import_react.default.useMemo(() => ({
1937
+ watch,
1938
+ getValues,
1939
+ getFieldState,
1940
+ setError,
1941
+ clearErrors,
1942
+ setValue,
1943
+ setValues,
1944
+ trigger,
1945
+ formState,
1946
+ resetField,
1947
+ reset,
1948
+ handleSubmit,
1949
+ unregister,
1950
+ control,
1951
+ register,
1952
+ setFocus,
1953
+ subscribe
1954
+ }), [
1955
+ clearErrors,
1956
+ control,
1957
+ formState,
1958
+ getFieldState,
1959
+ getValues,
1960
+ handleSubmit,
1961
+ register,
1962
+ reset,
1963
+ resetField,
1964
+ setError,
1965
+ setFocus,
1966
+ setValue,
1967
+ setValues,
1968
+ subscribe,
1969
+ trigger,
1970
+ unregister,
1971
+ watch
1972
+ ]);
1973
+ return import_react.default.createElement(
1974
+ HookFormContext.Provider,
1975
+ { value: memoizedValue },
1976
+ import_react.default.createElement(HookFormControlContext.Provider, { value: memoizedValue.control }, children)
1977
+ );
1978
+ };
1869
1979
  var defaultOptions = {
1870
1980
  mode: VALIDATION_MODE.onSubmit,
1871
1981
  reValidateMode: VALIDATION_MODE.onChange,