@6thbridge/hexa 0.0.0-pr81-160 → 0.0.0-pr81-162

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.mts CHANGED
@@ -12,6 +12,7 @@ import { OTPInputProps as OTPInputProps$1 } from 'react-otp-input';
12
12
  import * as PopoverPrimitive from '@radix-ui/react-popover';
13
13
  import { Drawer as Drawer$1 } from 'vaul';
14
14
  import { RowData, Row, Table as Table$1 } from '@tanstack/react-table';
15
+ import { UseFormReturn } from 'react-hook-form';
15
16
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
16
17
  import * as zustand from 'zustand';
17
18
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
@@ -488,37 +489,83 @@ type TableBulkRowActionsProps = {
488
489
  id?: string;
489
490
  };
490
491
 
491
- type SelectOption = {
492
+ type FilterSelectOption = {
492
493
  value: string;
493
494
  label: string;
494
495
  };
495
- type Base = {
496
- type: "input" | "drop-down" | "date-range" | "multi" | "date" | "radio";
496
+ type FilterType = "input" | "drop-down" | "date-range" | "multi" | "date" | "radio";
497
+ /**
498
+ * Base properties shared by all filter types.
499
+ */
500
+ interface FilterBase {
497
501
  key: string;
498
502
  label: string;
503
+ type: FilterType;
499
504
  placeholder?: string;
500
- };
501
- type FilterListOption = {
505
+ }
506
+ /**
507
+ * Input-specific filter properties.
508
+ */
509
+ interface FilterInput extends FilterBase, Omit<InputProps, "value" | "onChange" | "type" | "label"> {
502
510
  type: "input";
503
- } & Exclude<InputProps, "value" | "onChange">;
504
- type FilterListDate = {
511
+ }
512
+ /**
513
+ * Drop-down (Select) specific filter properties.
514
+ */
515
+ interface FilterDropDown extends FilterBase {
516
+ type: "drop-down";
517
+ options: FilterSelectOption[];
518
+ hideSearch?: boolean;
519
+ }
520
+ /**
521
+ * Radio specific filter properties.
522
+ */
523
+ interface FilterRadio extends FilterBase {
524
+ type: "radio";
525
+ options: FilterSelectOption[];
526
+ }
527
+ /**
528
+ * Date specific filter properties.
529
+ */
530
+ interface FilterDate extends FilterBase {
505
531
  type: "date";
506
532
  date?: string | Date;
507
- };
508
- type FilterListInputDropDown = {
509
- type: "drop-down" | "multi" | "radio";
510
- options: SelectOption[];
533
+ }
534
+ /**
535
+ * Multi-select specific filter properties.
536
+ */
537
+ interface FilterMultiSelect extends FilterBase {
538
+ type: "multi";
539
+ options: FilterSelectOption[];
511
540
  hideSearch?: boolean;
512
- };
513
- type FilterListItem = Base & (FilterListOption | FilterListInputDropDown | FilterListDate);
514
- type FilterContentProps = {
515
- filters: FilterListItem[];
516
- values?: Record<string, any>;
517
- setAppliedFilters?: (values: Record<string, any>) => void;
518
- onChange?: (values: Record<string, any>) => void;
519
- id?: string;
520
- };
541
+ }
542
+ /**
543
+ * Date range specific filter properties.
544
+ */
545
+ interface FilterDateRange extends FilterBase {
546
+ type: "date-range";
547
+ }
548
+ /**
549
+ * Discriminated union of all supported filter item configurations.
550
+ */
551
+ type FilterListItem = FilterInput | FilterDropDown | FilterRadio | FilterDate | FilterMultiSelect | FilterDateRange;
552
+ /**
553
+ * Alias for backward compatibility.
554
+ */
521
555
  type FilterListOptions = FilterListItem[];
556
+ /**
557
+ * Type alias for filter values, used to avoid 'any' in filter state management.
558
+ */
559
+ type FilterValues = Record<string, string>;
560
+ /**
561
+ * Shared props for individual filter fields to eliminate 'any'.
562
+ */
563
+ type FilterFieldProps<T extends FilterListItem = FilterListItem> = {
564
+ filter: T;
565
+ id: string;
566
+ form: UseFormReturn<FilterValues>;
567
+ onClear?: (fieldKey: string) => void;
568
+ };
522
569
 
523
570
  type PaginationProps = {
524
571
  currentPage?: number;
@@ -566,6 +613,7 @@ type TableProps<T extends RowData> = {
566
613
  FilterMenu?: ReactNode;
567
614
  setAppliedFilters?: (values: Record<string, any>) => void;
568
615
  filterListOptions?: FilterListItem[];
616
+ filterValues?: Record<string, any>;
569
617
  buttonClassName?: string;
570
618
  download?: TableDownloadProps;
571
619
  id?: string;
@@ -585,7 +633,7 @@ type TableProps<T extends RowData> = {
585
633
  };
586
634
  emptyDataMessage?: ReactNode;
587
635
  };
588
- declare const Table: <T extends RowData>({ table, isMobile, onRowClick, id, onRefetch, isRefetching, FilterMenu, ExtraNode, onExport, search, download, isLoading, pagination, filterListOptions, setAppliedFilters, onFilterChange, tableBulkActions, emptyDataMessage, }: TableProps<T>) => React$1.JSX.Element;
636
+ declare const Table: <T extends RowData>({ table, isMobile, onRowClick, id, onRefetch, isRefetching, FilterMenu, ExtraNode, onExport, search, download, isLoading, pagination, filterListOptions, filterValues, setAppliedFilters, onFilterChange, tableBulkActions, emptyDataMessage, }: TableProps<T>) => React$1.JSX.Element;
589
637
 
590
638
  type PageDataToolbarProps = {
591
639
  onRefetch?: () => void;
@@ -597,10 +645,11 @@ type PageDataToolbarProps = {
597
645
  isRefetching?: boolean;
598
646
  setAppliedFilters?: (values: Record<string, any>) => void;
599
647
  onFilterChange?: (values: Record<string, any>) => void;
648
+ filterValues?: Record<string, any>;
600
649
  filterListOptions?: FilterListItem[];
601
650
  id?: string;
602
651
  };
603
- declare const PageDataToolbar: ({ onRefetch, search, FilterMenu, ExtraNode, onExport, download, isRefetching, filterListOptions, setAppliedFilters, onFilterChange, id, }: PageDataToolbarProps) => React$1.JSX.Element;
652
+ declare const PageDataToolbar: ({ onRefetch, search, FilterMenu, ExtraNode, onExport, download, isRefetching, filterListOptions, filterValues, setAppliedFilters, onFilterChange, id, }: PageDataToolbarProps) => React$1.JSX.Element;
604
653
 
605
654
  declare const PermissionsContext: React$1.Context<ResourcePermissions | undefined>;
606
655
  declare const PermissionsProvider: ({ permissions, children, }: {
@@ -645,13 +694,24 @@ declare const RadioGroupItem: React$1.ForwardRefExoticComponent<Omit<RadioGroupP
645
694
  className?: string;
646
695
  } & React$1.RefAttributes<HTMLButtonElement>>;
647
696
 
648
- type FilterPopoverProps = FilterContentProps & {
697
+ type FilterContentProps = {
698
+ filters: FilterListItem[];
699
+ values?: FilterValues;
700
+ onChange?: (values: FilterValues) => void;
701
+ onApply?: (values: FilterValues) => void;
702
+ onReset?: () => void;
703
+ /** Called when a single field is cleared, so the parent can update applied state + URL for that key only. */
704
+ onClearApplied?: (fieldKey: string) => void;
705
+ id?: string;
706
+ setAppliedFilters?: (values: FilterValues) => void;
707
+ };
708
+
709
+ type FilterPopoverProps = Omit<FilterContentProps, "onApply"> & {
649
710
  isOpen?: boolean;
650
711
  trigger?: ReactNode;
651
712
  id?: string;
652
- onChange?: (values: Record<string, any>) => void;
653
713
  };
654
- declare const FilterPopover: ({ filters, setAppliedFilters, isOpen, onChange, id, }: FilterPopoverProps) => React$1.JSX.Element | null;
714
+ declare const FilterPopover: ({ filters, setAppliedFilters, isOpen, onChange, values, id, }: FilterPopoverProps) => React$1.JSX.Element | null;
655
715
 
656
716
  interface FilterSliceType {
657
717
  filters: Record<string, any> | null;
@@ -879,4 +939,4 @@ declare const TagsInput: ({ value, onChange, options, label, error, placeholder,
879
939
 
880
940
  declare function cn(...inputs: ClassValue[]): string;
881
941
 
882
- export { Accordion, type AccordionItemType, type AccordionProps, AmountAction, Banner, Button, CalendarInput, CopyableLabel, Country, CurrencySymbolMap, DateAction, DebouncedInput, DevBanner, Dialog, Drawer, DrawerClose, type DrawerPropsType, DrawerRoot, FeatureBanner, type FilterListItem, type FilterListOptions, FilterPopover, FlagComponent, FormLabel, type FormatCurrencyOptions, HasResourcePermission, Input, Loader, LocaleSelector, MultiSelect, type MultiSelectDataType, MultiSelectTrigger, OTPInput, PageDataToolbar, Pagination, PasswordInput, PermissionsContext, PermissionsProvider, PhoneInput, Popover, PopoverContent, PopoverRoot, PopoverTrigger, RadioGroup, RadioGroupItem, type ResourcePermission, type ResourcePermissionProps, type ResourcePermissions, RichTextEditor, ScrollArea, Select, Sidebar, Status, StringAction, Table, type TableBulkRowActionsProps, type TablePaginationProps, Tabs, type TagOption, TagsInput, type TagsInputProps, TextOverflow, type TextOverflowProps, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger, buttonVariants, cn, useFilterStore, useHasPermission, usePermissions };
942
+ export { Accordion, type AccordionItemType, type AccordionProps, AmountAction, Banner, Button, CalendarInput, CopyableLabel, Country, CurrencySymbolMap, DateAction, DebouncedInput, DevBanner, Dialog, Drawer, DrawerClose, type DrawerPropsType, DrawerRoot, FeatureBanner, type FilterFieldProps, type FilterListItem, type FilterListOptions, FilterPopover, FlagComponent, FormLabel, type FormatCurrencyOptions, HasResourcePermission, Input, Loader, LocaleSelector, MultiSelect, type MultiSelectDataType, MultiSelectTrigger, OTPInput, PageDataToolbar, Pagination, PasswordInput, PermissionsContext, PermissionsProvider, PhoneInput, Popover, PopoverContent, PopoverRoot, PopoverTrigger, RadioGroup, RadioGroupItem, type ResourcePermission, type ResourcePermissionProps, type ResourcePermissions, RichTextEditor, ScrollArea, Select, Sidebar, Status, StringAction, Table, type TableBulkRowActionsProps, type TablePaginationProps, Tabs, type TagOption, TagsInput, type TagsInputProps, TextOverflow, type TextOverflowProps, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger, buttonVariants, cn, useFilterStore, useHasPermission, usePermissions };
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ import { OTPInputProps as OTPInputProps$1 } from 'react-otp-input';
12
12
  import * as PopoverPrimitive from '@radix-ui/react-popover';
13
13
  import { Drawer as Drawer$1 } from 'vaul';
14
14
  import { RowData, Row, Table as Table$1 } from '@tanstack/react-table';
15
+ import { UseFormReturn } from 'react-hook-form';
15
16
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
16
17
  import * as zustand from 'zustand';
17
18
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
@@ -488,37 +489,83 @@ type TableBulkRowActionsProps = {
488
489
  id?: string;
489
490
  };
490
491
 
491
- type SelectOption = {
492
+ type FilterSelectOption = {
492
493
  value: string;
493
494
  label: string;
494
495
  };
495
- type Base = {
496
- type: "input" | "drop-down" | "date-range" | "multi" | "date" | "radio";
496
+ type FilterType = "input" | "drop-down" | "date-range" | "multi" | "date" | "radio";
497
+ /**
498
+ * Base properties shared by all filter types.
499
+ */
500
+ interface FilterBase {
497
501
  key: string;
498
502
  label: string;
503
+ type: FilterType;
499
504
  placeholder?: string;
500
- };
501
- type FilterListOption = {
505
+ }
506
+ /**
507
+ * Input-specific filter properties.
508
+ */
509
+ interface FilterInput extends FilterBase, Omit<InputProps, "value" | "onChange" | "type" | "label"> {
502
510
  type: "input";
503
- } & Exclude<InputProps, "value" | "onChange">;
504
- type FilterListDate = {
511
+ }
512
+ /**
513
+ * Drop-down (Select) specific filter properties.
514
+ */
515
+ interface FilterDropDown extends FilterBase {
516
+ type: "drop-down";
517
+ options: FilterSelectOption[];
518
+ hideSearch?: boolean;
519
+ }
520
+ /**
521
+ * Radio specific filter properties.
522
+ */
523
+ interface FilterRadio extends FilterBase {
524
+ type: "radio";
525
+ options: FilterSelectOption[];
526
+ }
527
+ /**
528
+ * Date specific filter properties.
529
+ */
530
+ interface FilterDate extends FilterBase {
505
531
  type: "date";
506
532
  date?: string | Date;
507
- };
508
- type FilterListInputDropDown = {
509
- type: "drop-down" | "multi" | "radio";
510
- options: SelectOption[];
533
+ }
534
+ /**
535
+ * Multi-select specific filter properties.
536
+ */
537
+ interface FilterMultiSelect extends FilterBase {
538
+ type: "multi";
539
+ options: FilterSelectOption[];
511
540
  hideSearch?: boolean;
512
- };
513
- type FilterListItem = Base & (FilterListOption | FilterListInputDropDown | FilterListDate);
514
- type FilterContentProps = {
515
- filters: FilterListItem[];
516
- values?: Record<string, any>;
517
- setAppliedFilters?: (values: Record<string, any>) => void;
518
- onChange?: (values: Record<string, any>) => void;
519
- id?: string;
520
- };
541
+ }
542
+ /**
543
+ * Date range specific filter properties.
544
+ */
545
+ interface FilterDateRange extends FilterBase {
546
+ type: "date-range";
547
+ }
548
+ /**
549
+ * Discriminated union of all supported filter item configurations.
550
+ */
551
+ type FilterListItem = FilterInput | FilterDropDown | FilterRadio | FilterDate | FilterMultiSelect | FilterDateRange;
552
+ /**
553
+ * Alias for backward compatibility.
554
+ */
521
555
  type FilterListOptions = FilterListItem[];
556
+ /**
557
+ * Type alias for filter values, used to avoid 'any' in filter state management.
558
+ */
559
+ type FilterValues = Record<string, string>;
560
+ /**
561
+ * Shared props for individual filter fields to eliminate 'any'.
562
+ */
563
+ type FilterFieldProps<T extends FilterListItem = FilterListItem> = {
564
+ filter: T;
565
+ id: string;
566
+ form: UseFormReturn<FilterValues>;
567
+ onClear?: (fieldKey: string) => void;
568
+ };
522
569
 
523
570
  type PaginationProps = {
524
571
  currentPage?: number;
@@ -566,6 +613,7 @@ type TableProps<T extends RowData> = {
566
613
  FilterMenu?: ReactNode;
567
614
  setAppliedFilters?: (values: Record<string, any>) => void;
568
615
  filterListOptions?: FilterListItem[];
616
+ filterValues?: Record<string, any>;
569
617
  buttonClassName?: string;
570
618
  download?: TableDownloadProps;
571
619
  id?: string;
@@ -585,7 +633,7 @@ type TableProps<T extends RowData> = {
585
633
  };
586
634
  emptyDataMessage?: ReactNode;
587
635
  };
588
- declare const Table: <T extends RowData>({ table, isMobile, onRowClick, id, onRefetch, isRefetching, FilterMenu, ExtraNode, onExport, search, download, isLoading, pagination, filterListOptions, setAppliedFilters, onFilterChange, tableBulkActions, emptyDataMessage, }: TableProps<T>) => React$1.JSX.Element;
636
+ declare const Table: <T extends RowData>({ table, isMobile, onRowClick, id, onRefetch, isRefetching, FilterMenu, ExtraNode, onExport, search, download, isLoading, pagination, filterListOptions, filterValues, setAppliedFilters, onFilterChange, tableBulkActions, emptyDataMessage, }: TableProps<T>) => React$1.JSX.Element;
589
637
 
590
638
  type PageDataToolbarProps = {
591
639
  onRefetch?: () => void;
@@ -597,10 +645,11 @@ type PageDataToolbarProps = {
597
645
  isRefetching?: boolean;
598
646
  setAppliedFilters?: (values: Record<string, any>) => void;
599
647
  onFilterChange?: (values: Record<string, any>) => void;
648
+ filterValues?: Record<string, any>;
600
649
  filterListOptions?: FilterListItem[];
601
650
  id?: string;
602
651
  };
603
- declare const PageDataToolbar: ({ onRefetch, search, FilterMenu, ExtraNode, onExport, download, isRefetching, filterListOptions, setAppliedFilters, onFilterChange, id, }: PageDataToolbarProps) => React$1.JSX.Element;
652
+ declare const PageDataToolbar: ({ onRefetch, search, FilterMenu, ExtraNode, onExport, download, isRefetching, filterListOptions, filterValues, setAppliedFilters, onFilterChange, id, }: PageDataToolbarProps) => React$1.JSX.Element;
604
653
 
605
654
  declare const PermissionsContext: React$1.Context<ResourcePermissions | undefined>;
606
655
  declare const PermissionsProvider: ({ permissions, children, }: {
@@ -645,13 +694,24 @@ declare const RadioGroupItem: React$1.ForwardRefExoticComponent<Omit<RadioGroupP
645
694
  className?: string;
646
695
  } & React$1.RefAttributes<HTMLButtonElement>>;
647
696
 
648
- type FilterPopoverProps = FilterContentProps & {
697
+ type FilterContentProps = {
698
+ filters: FilterListItem[];
699
+ values?: FilterValues;
700
+ onChange?: (values: FilterValues) => void;
701
+ onApply?: (values: FilterValues) => void;
702
+ onReset?: () => void;
703
+ /** Called when a single field is cleared, so the parent can update applied state + URL for that key only. */
704
+ onClearApplied?: (fieldKey: string) => void;
705
+ id?: string;
706
+ setAppliedFilters?: (values: FilterValues) => void;
707
+ };
708
+
709
+ type FilterPopoverProps = Omit<FilterContentProps, "onApply"> & {
649
710
  isOpen?: boolean;
650
711
  trigger?: ReactNode;
651
712
  id?: string;
652
- onChange?: (values: Record<string, any>) => void;
653
713
  };
654
- declare const FilterPopover: ({ filters, setAppliedFilters, isOpen, onChange, id, }: FilterPopoverProps) => React$1.JSX.Element | null;
714
+ declare const FilterPopover: ({ filters, setAppliedFilters, isOpen, onChange, values, id, }: FilterPopoverProps) => React$1.JSX.Element | null;
655
715
 
656
716
  interface FilterSliceType {
657
717
  filters: Record<string, any> | null;
@@ -879,4 +939,4 @@ declare const TagsInput: ({ value, onChange, options, label, error, placeholder,
879
939
 
880
940
  declare function cn(...inputs: ClassValue[]): string;
881
941
 
882
- export { Accordion, type AccordionItemType, type AccordionProps, AmountAction, Banner, Button, CalendarInput, CopyableLabel, Country, CurrencySymbolMap, DateAction, DebouncedInput, DevBanner, Dialog, Drawer, DrawerClose, type DrawerPropsType, DrawerRoot, FeatureBanner, type FilterListItem, type FilterListOptions, FilterPopover, FlagComponent, FormLabel, type FormatCurrencyOptions, HasResourcePermission, Input, Loader, LocaleSelector, MultiSelect, type MultiSelectDataType, MultiSelectTrigger, OTPInput, PageDataToolbar, Pagination, PasswordInput, PermissionsContext, PermissionsProvider, PhoneInput, Popover, PopoverContent, PopoverRoot, PopoverTrigger, RadioGroup, RadioGroupItem, type ResourcePermission, type ResourcePermissionProps, type ResourcePermissions, RichTextEditor, ScrollArea, Select, Sidebar, Status, StringAction, Table, type TableBulkRowActionsProps, type TablePaginationProps, Tabs, type TagOption, TagsInput, type TagsInputProps, TextOverflow, type TextOverflowProps, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger, buttonVariants, cn, useFilterStore, useHasPermission, usePermissions };
942
+ export { Accordion, type AccordionItemType, type AccordionProps, AmountAction, Banner, Button, CalendarInput, CopyableLabel, Country, CurrencySymbolMap, DateAction, DebouncedInput, DevBanner, Dialog, Drawer, DrawerClose, type DrawerPropsType, DrawerRoot, FeatureBanner, type FilterFieldProps, type FilterListItem, type FilterListOptions, FilterPopover, FlagComponent, FormLabel, type FormatCurrencyOptions, HasResourcePermission, Input, Loader, LocaleSelector, MultiSelect, type MultiSelectDataType, MultiSelectTrigger, OTPInput, PageDataToolbar, Pagination, PasswordInput, PermissionsContext, PermissionsProvider, PhoneInput, Popover, PopoverContent, PopoverRoot, PopoverTrigger, RadioGroup, RadioGroupItem, type ResourcePermission, type ResourcePermissionProps, type ResourcePermissions, RichTextEditor, ScrollArea, Select, Sidebar, Status, StringAction, Table, type TableBulkRowActionsProps, type TablePaginationProps, Tabs, type TagOption, TagsInput, type TagsInputProps, TextOverflow, type TextOverflowProps, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger, buttonVariants, cn, useFilterStore, useHasPermission, usePermissions };