@6thbridge/hexa 0.0.96 → 0.0.97

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';
@@ -474,37 +475,83 @@ type TableBulkRowActionsProps = {
474
475
  id?: string;
475
476
  };
476
477
 
477
- type SelectOption = {
478
+ type FilterSelectOption = {
478
479
  value: string;
479
480
  label: string;
480
481
  };
481
- type Base = {
482
- type: "input" | "drop-down" | "date-range" | "multi" | "date" | "radio";
482
+ type FilterType = "input" | "drop-down" | "date-range" | "multi" | "date" | "radio";
483
+ /**
484
+ * Base properties shared by all filter types.
485
+ */
486
+ interface FilterBase {
483
487
  key: string;
484
488
  label: string;
489
+ type: FilterType;
485
490
  placeholder?: string;
486
- };
487
- type FilterListOption = {
491
+ }
492
+ /**
493
+ * Input-specific filter properties.
494
+ */
495
+ interface FilterInput extends FilterBase, Omit<InputProps, "value" | "onChange" | "type" | "label"> {
488
496
  type: "input";
489
- } & Exclude<InputProps, "value" | "onChange">;
490
- type FilterListDate = {
497
+ }
498
+ /**
499
+ * Drop-down (Select) specific filter properties.
500
+ */
501
+ interface FilterDropDown extends FilterBase {
502
+ type: "drop-down";
503
+ options: FilterSelectOption[];
504
+ hideSearch?: boolean;
505
+ }
506
+ /**
507
+ * Radio specific filter properties.
508
+ */
509
+ interface FilterRadio extends FilterBase {
510
+ type: "radio";
511
+ options: FilterSelectOption[];
512
+ }
513
+ /**
514
+ * Date specific filter properties.
515
+ */
516
+ interface FilterDate extends FilterBase {
491
517
  type: "date";
492
518
  date?: string | Date;
493
- };
494
- type FilterListInputDropDown = {
495
- type: "drop-down" | "multi" | "radio";
496
- options: SelectOption[];
519
+ }
520
+ /**
521
+ * Multi-select specific filter properties.
522
+ */
523
+ interface FilterMultiSelect extends FilterBase {
524
+ type: "multi";
525
+ options: FilterSelectOption[];
497
526
  hideSearch?: boolean;
498
- };
499
- type FilterListItem = Base & (FilterListOption | FilterListInputDropDown | FilterListDate);
500
- type FilterContentProps = {
501
- filters: FilterListItem[];
502
- values?: Record<string, any>;
503
- setAppliedFilters?: (values: Record<string, any>) => void;
504
- onChange?: (values: Record<string, any>) => void;
505
- id?: string;
506
- };
527
+ }
528
+ /**
529
+ * Date range specific filter properties.
530
+ */
531
+ interface FilterDateRange extends FilterBase {
532
+ type: "date-range";
533
+ }
534
+ /**
535
+ * Discriminated union of all supported filter item configurations.
536
+ */
537
+ type FilterListItem = FilterInput | FilterDropDown | FilterRadio | FilterDate | FilterMultiSelect | FilterDateRange;
538
+ /**
539
+ * Alias for backward compatibility.
540
+ */
507
541
  type FilterListOptions = FilterListItem[];
542
+ /**
543
+ * Type alias for filter values, used to avoid 'any' in filter state management.
544
+ */
545
+ type FilterValues = Record<string, string>;
546
+ /**
547
+ * Shared props for individual filter fields to eliminate 'any'.
548
+ */
549
+ type FilterFieldProps<T extends FilterListItem = FilterListItem> = {
550
+ filter: T;
551
+ id: string;
552
+ form: UseFormReturn<FilterValues>;
553
+ onClear?: (fieldKey: string) => void;
554
+ };
508
555
 
509
556
  type PaginationProps = {
510
557
  currentPage?: number;
@@ -552,6 +599,7 @@ type TableProps<T extends RowData> = {
552
599
  FilterMenu?: ReactNode;
553
600
  setAppliedFilters?: (values: Record<string, any>) => void;
554
601
  filterListOptions?: FilterListItem[];
602
+ filterValues?: Record<string, any>;
555
603
  buttonClassName?: string;
556
604
  download?: TableDownloadProps;
557
605
  id?: string;
@@ -571,7 +619,7 @@ type TableProps<T extends RowData> = {
571
619
  };
572
620
  emptyDataMessage?: ReactNode;
573
621
  };
574
- 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;
622
+ 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;
575
623
 
576
624
  type PageDataToolbarProps = {
577
625
  onRefetch?: () => void;
@@ -583,10 +631,11 @@ type PageDataToolbarProps = {
583
631
  isRefetching?: boolean;
584
632
  setAppliedFilters?: (values: Record<string, any>) => void;
585
633
  onFilterChange?: (values: Record<string, any>) => void;
634
+ filterValues?: Record<string, any>;
586
635
  filterListOptions?: FilterListItem[];
587
636
  id?: string;
588
637
  };
589
- declare const PageDataToolbar: ({ onRefetch, search, FilterMenu, ExtraNode, onExport, download, isRefetching, filterListOptions, setAppliedFilters, onFilterChange, id, }: PageDataToolbarProps) => React$1.JSX.Element;
638
+ declare const PageDataToolbar: ({ onRefetch, search, FilterMenu, ExtraNode, onExport, download, isRefetching, filterListOptions, filterValues, setAppliedFilters, onFilterChange, id, }: PageDataToolbarProps) => React$1.JSX.Element;
590
639
 
591
640
  declare const PermissionsContext: React$1.Context<ResourcePermissions | undefined>;
592
641
  declare const PermissionsProvider: ({ permissions, children, }: {
@@ -631,13 +680,24 @@ declare const RadioGroupItem: React$1.ForwardRefExoticComponent<Omit<RadioGroupP
631
680
  className?: string;
632
681
  } & React$1.RefAttributes<HTMLButtonElement>>;
633
682
 
634
- type FilterPopoverProps = FilterContentProps & {
683
+ type FilterContentProps = {
684
+ filters: FilterListItem[];
685
+ values?: FilterValues;
686
+ onChange?: (values: FilterValues) => void;
687
+ onApply?: (values: FilterValues) => void;
688
+ onReset?: () => void;
689
+ /** Called when a single field is cleared, so the parent can update applied state + URL for that key only. */
690
+ onClearApplied?: (fieldKey: string) => void;
691
+ id?: string;
692
+ setAppliedFilters?: (values: FilterValues) => void;
693
+ };
694
+
695
+ type FilterPopoverProps = Omit<FilterContentProps, "onApply"> & {
635
696
  isOpen?: boolean;
636
697
  trigger?: ReactNode;
637
698
  id?: string;
638
- onChange?: (values: Record<string, any>) => void;
639
699
  };
640
- declare const FilterPopover: ({ filters, setAppliedFilters, isOpen, onChange, id, }: FilterPopoverProps) => React$1.JSX.Element | null;
700
+ declare const FilterPopover: ({ filters, setAppliedFilters, isOpen, onChange, values, id, }: FilterPopoverProps) => React$1.JSX.Element | null;
641
701
 
642
702
  interface FilterSliceType {
643
703
  filters: Record<string, any> | null;
@@ -865,4 +925,4 @@ declare const TagsInput: ({ value, onChange, options, label, error, placeholder,
865
925
 
866
926
  declare function cn(...inputs: ClassValue[]): string;
867
927
 
868
- export { 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 };
928
+ export { 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';
@@ -474,37 +475,83 @@ type TableBulkRowActionsProps = {
474
475
  id?: string;
475
476
  };
476
477
 
477
- type SelectOption = {
478
+ type FilterSelectOption = {
478
479
  value: string;
479
480
  label: string;
480
481
  };
481
- type Base = {
482
- type: "input" | "drop-down" | "date-range" | "multi" | "date" | "radio";
482
+ type FilterType = "input" | "drop-down" | "date-range" | "multi" | "date" | "radio";
483
+ /**
484
+ * Base properties shared by all filter types.
485
+ */
486
+ interface FilterBase {
483
487
  key: string;
484
488
  label: string;
489
+ type: FilterType;
485
490
  placeholder?: string;
486
- };
487
- type FilterListOption = {
491
+ }
492
+ /**
493
+ * Input-specific filter properties.
494
+ */
495
+ interface FilterInput extends FilterBase, Omit<InputProps, "value" | "onChange" | "type" | "label"> {
488
496
  type: "input";
489
- } & Exclude<InputProps, "value" | "onChange">;
490
- type FilterListDate = {
497
+ }
498
+ /**
499
+ * Drop-down (Select) specific filter properties.
500
+ */
501
+ interface FilterDropDown extends FilterBase {
502
+ type: "drop-down";
503
+ options: FilterSelectOption[];
504
+ hideSearch?: boolean;
505
+ }
506
+ /**
507
+ * Radio specific filter properties.
508
+ */
509
+ interface FilterRadio extends FilterBase {
510
+ type: "radio";
511
+ options: FilterSelectOption[];
512
+ }
513
+ /**
514
+ * Date specific filter properties.
515
+ */
516
+ interface FilterDate extends FilterBase {
491
517
  type: "date";
492
518
  date?: string | Date;
493
- };
494
- type FilterListInputDropDown = {
495
- type: "drop-down" | "multi" | "radio";
496
- options: SelectOption[];
519
+ }
520
+ /**
521
+ * Multi-select specific filter properties.
522
+ */
523
+ interface FilterMultiSelect extends FilterBase {
524
+ type: "multi";
525
+ options: FilterSelectOption[];
497
526
  hideSearch?: boolean;
498
- };
499
- type FilterListItem = Base & (FilterListOption | FilterListInputDropDown | FilterListDate);
500
- type FilterContentProps = {
501
- filters: FilterListItem[];
502
- values?: Record<string, any>;
503
- setAppliedFilters?: (values: Record<string, any>) => void;
504
- onChange?: (values: Record<string, any>) => void;
505
- id?: string;
506
- };
527
+ }
528
+ /**
529
+ * Date range specific filter properties.
530
+ */
531
+ interface FilterDateRange extends FilterBase {
532
+ type: "date-range";
533
+ }
534
+ /**
535
+ * Discriminated union of all supported filter item configurations.
536
+ */
537
+ type FilterListItem = FilterInput | FilterDropDown | FilterRadio | FilterDate | FilterMultiSelect | FilterDateRange;
538
+ /**
539
+ * Alias for backward compatibility.
540
+ */
507
541
  type FilterListOptions = FilterListItem[];
542
+ /**
543
+ * Type alias for filter values, used to avoid 'any' in filter state management.
544
+ */
545
+ type FilterValues = Record<string, string>;
546
+ /**
547
+ * Shared props for individual filter fields to eliminate 'any'.
548
+ */
549
+ type FilterFieldProps<T extends FilterListItem = FilterListItem> = {
550
+ filter: T;
551
+ id: string;
552
+ form: UseFormReturn<FilterValues>;
553
+ onClear?: (fieldKey: string) => void;
554
+ };
508
555
 
509
556
  type PaginationProps = {
510
557
  currentPage?: number;
@@ -552,6 +599,7 @@ type TableProps<T extends RowData> = {
552
599
  FilterMenu?: ReactNode;
553
600
  setAppliedFilters?: (values: Record<string, any>) => void;
554
601
  filterListOptions?: FilterListItem[];
602
+ filterValues?: Record<string, any>;
555
603
  buttonClassName?: string;
556
604
  download?: TableDownloadProps;
557
605
  id?: string;
@@ -571,7 +619,7 @@ type TableProps<T extends RowData> = {
571
619
  };
572
620
  emptyDataMessage?: ReactNode;
573
621
  };
574
- 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;
622
+ 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;
575
623
 
576
624
  type PageDataToolbarProps = {
577
625
  onRefetch?: () => void;
@@ -583,10 +631,11 @@ type PageDataToolbarProps = {
583
631
  isRefetching?: boolean;
584
632
  setAppliedFilters?: (values: Record<string, any>) => void;
585
633
  onFilterChange?: (values: Record<string, any>) => void;
634
+ filterValues?: Record<string, any>;
586
635
  filterListOptions?: FilterListItem[];
587
636
  id?: string;
588
637
  };
589
- declare const PageDataToolbar: ({ onRefetch, search, FilterMenu, ExtraNode, onExport, download, isRefetching, filterListOptions, setAppliedFilters, onFilterChange, id, }: PageDataToolbarProps) => React$1.JSX.Element;
638
+ declare const PageDataToolbar: ({ onRefetch, search, FilterMenu, ExtraNode, onExport, download, isRefetching, filterListOptions, filterValues, setAppliedFilters, onFilterChange, id, }: PageDataToolbarProps) => React$1.JSX.Element;
590
639
 
591
640
  declare const PermissionsContext: React$1.Context<ResourcePermissions | undefined>;
592
641
  declare const PermissionsProvider: ({ permissions, children, }: {
@@ -631,13 +680,24 @@ declare const RadioGroupItem: React$1.ForwardRefExoticComponent<Omit<RadioGroupP
631
680
  className?: string;
632
681
  } & React$1.RefAttributes<HTMLButtonElement>>;
633
682
 
634
- type FilterPopoverProps = FilterContentProps & {
683
+ type FilterContentProps = {
684
+ filters: FilterListItem[];
685
+ values?: FilterValues;
686
+ onChange?: (values: FilterValues) => void;
687
+ onApply?: (values: FilterValues) => void;
688
+ onReset?: () => void;
689
+ /** Called when a single field is cleared, so the parent can update applied state + URL for that key only. */
690
+ onClearApplied?: (fieldKey: string) => void;
691
+ id?: string;
692
+ setAppliedFilters?: (values: FilterValues) => void;
693
+ };
694
+
695
+ type FilterPopoverProps = Omit<FilterContentProps, "onApply"> & {
635
696
  isOpen?: boolean;
636
697
  trigger?: ReactNode;
637
698
  id?: string;
638
- onChange?: (values: Record<string, any>) => void;
639
699
  };
640
- declare const FilterPopover: ({ filters, setAppliedFilters, isOpen, onChange, id, }: FilterPopoverProps) => React$1.JSX.Element | null;
700
+ declare const FilterPopover: ({ filters, setAppliedFilters, isOpen, onChange, values, id, }: FilterPopoverProps) => React$1.JSX.Element | null;
641
701
 
642
702
  interface FilterSliceType {
643
703
  filters: Record<string, any> | null;
@@ -865,4 +925,4 @@ declare const TagsInput: ({ value, onChange, options, label, error, placeholder,
865
925
 
866
926
  declare function cn(...inputs: ClassValue[]): string;
867
927
 
868
- export { 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 };
928
+ export { 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 };