elseware-ui 2.23.1 → 2.24.0

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.
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ type DataViewContentProps<T = any> = {
3
+ children: ReactNode | ((data: T[]) => ReactNode);
4
+ };
5
+ declare function DataViewContent<T = any>({ children }: DataViewContentProps<T>): ReactNode;
6
+ export default DataViewContent;
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ type DataViewHeaderProps = {
3
+ children: ReactNode;
4
+ };
5
+ declare function DataViewHeader({ children }: DataViewHeaderProps): import("react/jsx-runtime").JSX.Element;
6
+ export default DataViewHeader;
@@ -0,0 +1,7 @@
1
+ import { Shape } from "../../../../types";
2
+ type DataViewPaginationProps = {
3
+ pageSizeOptions?: (number | "All")[];
4
+ shape?: Shape;
5
+ };
6
+ declare function DataViewPagination({ pageSizeOptions, shape, }: DataViewPaginationProps): import("react/jsx-runtime").JSX.Element | null;
7
+ export default DataViewPagination;
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ type DataViewSidebarProps = {
3
+ children: ReactNode;
4
+ };
5
+ declare function DataViewSidebar({ children }: DataViewSidebarProps): import("react/jsx-runtime").JSX.Element;
6
+ export default DataViewSidebar;
@@ -0,0 +1,12 @@
1
+ type FilterOption = {
2
+ value: string;
3
+ label: string;
4
+ dotClass?: string;
5
+ };
6
+ type DataViewFilterGroupProps<T = any> = {
7
+ filterKey: keyof T;
8
+ options: FilterOption[];
9
+ title?: string;
10
+ };
11
+ declare function DataViewFilterGroup<T extends Record<string, any>>({ filterKey, options, title, }: DataViewFilterGroupProps<T>): import("react/jsx-runtime").JSX.Element;
12
+ export default DataViewFilterGroup;
@@ -0,0 +1,7 @@
1
+ import { Shape } from "../../../../types";
2
+ type DataViewSearchProps = {
3
+ placeholder: string;
4
+ shape?: Shape;
5
+ };
6
+ declare function DataViewSearch({ placeholder, shape, }: DataViewSearchProps): import("react/jsx-runtime").JSX.Element;
7
+ export default DataViewSearch;
@@ -0,0 +1,11 @@
1
+ import { Shape } from "../../../../types";
2
+ type SortOption = {
3
+ value: string;
4
+ label: string;
5
+ };
6
+ type DataViewSortProps = {
7
+ options: SortOption[];
8
+ shape?: Shape;
9
+ };
10
+ declare function DataViewSort({ options, shape }: DataViewSortProps): import("react/jsx-runtime").JSX.Element;
11
+ export default DataViewSort;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { DataViewContextType } from "./types";
3
+ export declare const DataViewContext: import("react").Context<DataViewContextType<any> | null>;
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from "react";
2
+ import { SortConfig } from "./types";
3
+ interface Props<T> {
4
+ data: T[];
5
+ children: ReactNode;
6
+ defaultPageSize?: number;
7
+ sortConfig?: Record<string, SortConfig<T>>;
8
+ }
9
+ declare function DataViewProvider<T extends Record<string, any>>({ data, children, defaultPageSize, sortConfig, }: Props<T>): import("react/jsx-runtime").JSX.Element;
10
+ export default DataViewProvider;
@@ -0,0 +1,22 @@
1
+ import { Dispatch, SetStateAction } from "react";
2
+ export type SortDirection = "asc" | "desc";
3
+ export type SortConfig<T, K extends keyof T = keyof T> = {
4
+ key: K;
5
+ direction?: "asc" | "desc";
6
+ transform?: (value: T[K]) => number | string;
7
+ };
8
+ export interface DataViewContextType<T = any> {
9
+ rawData: T[];
10
+ data: T[];
11
+ search: string;
12
+ setSearch: (v: string) => void;
13
+ filters: Record<string, any>;
14
+ setFilters: Dispatch<SetStateAction<Record<string, any>>>;
15
+ sort: string;
16
+ setSort: (v: string) => void;
17
+ page: number;
18
+ setPage: (v: number) => void;
19
+ pageSize: number | "All";
20
+ setPageSize: (v: number | "All") => void;
21
+ totalPages: number;
22
+ }
@@ -0,0 +1,2 @@
1
+ import { DataViewContextType } from "../core/types";
2
+ export declare function useDataView<T = any>(): DataViewContextType<T>;
@@ -0,0 +1,17 @@
1
+ import DataViewProvider from "./core/DataViewProvider";
2
+ import DataViewHeader from "./com/DataViewHeader";
3
+ import DataViewSidebar from "./com/DataViewSidebar";
4
+ import DataViewContent from "./com/DataViewContent";
5
+ import DataViewPagination from "./com/DataViewPagination";
6
+ import DataViewSearch from "./controls/DataViewSearch";
7
+ import DataViewSort from "./controls/DataViewSort";
8
+ import DataViewFilterGroup from "./controls/DataViewFilterGroup";
9
+ export declare const DataView: typeof DataViewProvider & {
10
+ Header: typeof DataViewHeader;
11
+ Sidebar: typeof DataViewSidebar;
12
+ Content: typeof DataViewContent;
13
+ Pagination: typeof DataViewPagination;
14
+ Search: typeof DataViewSearch;
15
+ Sort: typeof DataViewSort;
16
+ FilterGroup: typeof DataViewFilterGroup;
17
+ };
@@ -0,0 +1 @@
1
+ export declare function filterData<T extends Record<string, any>>(data: T[], filters: Record<string, any>): T[];
@@ -0,0 +1 @@
1
+ export declare function searchData<T extends Record<string, any>>(data: T[], search: string): T[];
@@ -0,0 +1,2 @@
1
+ import { SortConfig } from "../core/types";
2
+ export declare function sortData<T>(data: T[], sort: string, sortConfig: Record<string, SortConfig<T>>): T[];
@@ -4,6 +4,7 @@ export * from "./banners";
4
4
  export * from "./brand";
5
5
  export * from "./charts";
6
6
  export * from "./chip";
7
+ export * from "./data-view";
7
8
  export * from "./flag";
8
9
  export * from "./graphs";
9
10
  export * from "./image";
@@ -5,7 +5,7 @@ export interface FormProps {
5
5
  enableReinitialize?: boolean;
6
6
  children?: React.ReactNode;
7
7
  styles?: string;
8
- onSubmit: (values: any) => void;
8
+ onSubmit: (values: any, helpers?: any) => void;
9
9
  onChange?: (values: Record<string, any>, meta?: {
10
10
  changed: Record<string, any>;
11
11
  }) => void;