@starasia/admin 1.2.5 → 1.2.6

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,4 @@
1
+ import { default as React } from 'react';
2
+ import { AdvanceFilterBarProps } from './types';
3
+
4
+ export declare const AdvanceFilterBar: ({ searchKey, statusKey, searchPlaceholder, searchHighlightPlaceholder, extendedFilter, showSearchFilter, showStatusFilter, filterKey, pageKey, customWidthSearch, handleOnReset, filterConfigs, buttonToggleProps, position, titleSearchLabel, withTitleLabels }: AdvanceFilterBarProps) => React.JSX.Element;
@@ -0,0 +1,61 @@
1
+ import { default as React } from 'react';
2
+ import { IDateProps } from '@starasia/date';
3
+ import { IDropdown } from '@starasia/dropdown';
4
+
5
+ interface RadioFilterConfig {
6
+ type: 'radio';
7
+ title: string;
8
+ name: string;
9
+ radioList: {
10
+ id: number;
11
+ label: string;
12
+ value: string;
13
+ icon?: React.ReactNode;
14
+ }[];
15
+ show?: boolean;
16
+ }
17
+ interface DropdownFilterConfig {
18
+ type: 'dropdown';
19
+ title: string;
20
+ name: string;
21
+ dropdownLists?: IDropdown['dropdownLists'];
22
+ isLoading?: boolean;
23
+ onSearch?: (v: string) => void;
24
+ search?: string;
25
+ searchable?: boolean;
26
+ onClickContainer?: () => void;
27
+ show?: boolean;
28
+ }
29
+ interface DropdownMultipleFilterConfig {
30
+ type: 'dropdown-multiple';
31
+ title: string;
32
+ name: string;
33
+ dropdownLists?: {
34
+ label: string;
35
+ value: string;
36
+ }[];
37
+ isLoading?: boolean;
38
+ onClickContainer?: () => void;
39
+ show?: boolean;
40
+ }
41
+ interface DateRangeFilterConfig {
42
+ type: 'date-range';
43
+ title: string;
44
+ name: string;
45
+ }
46
+ interface DateFilterConfig {
47
+ type: 'date';
48
+ title: string;
49
+ name: string;
50
+ filter: IDateProps['filter'];
51
+ }
52
+ export type FilterConfig = RadioFilterConfig | DropdownFilterConfig | DropdownMultipleFilterConfig | DateRangeFilterConfig | DateFilterConfig;
53
+ interface FilterDrawerProps {
54
+ isOpen?: boolean;
55
+ onClose: () => void;
56
+ filterKey?: string;
57
+ pageKey?: string;
58
+ filters?: FilterConfig[];
59
+ }
60
+ export declare const FilterDrawer: ({ isOpen, onClose, filterKey, pageKey, filters }: FilterDrawerProps) => React.JSX.Element;
61
+ export {};
@@ -0,0 +1,5 @@
1
+ export { AdvanceFilterBar } from './AdvanceFilterBar';
2
+ export { FilterDrawer } from './FilterDrawer';
3
+ export type { FilterConfig } from './FilterDrawer';
4
+ export type { AdvanceFilterBarProps, TableFilterBarProps, ChangeHandler, ExtendedFilter, GetValuesFilterProps } from './types';
5
+ export { handleChangeFilter, getValueSearch, getValuesFilter, getValueDropdownMultipleFilter, getValueRadioFilter, getDateRangeFilterValue, getDateFilterValue, isFilterActive, resolveDropdownValueToString, resolveRadioValueToString, resolveDateRangeValueToString, resolveDateValueToString } from './utils';
@@ -0,0 +1,53 @@
1
+ import { SetURLSearchParams } from 'react-router';
2
+ import { FilterConfig } from './FilterDrawer';
3
+ import { IconName } from '@starasia/icon';
4
+
5
+ export interface TableFilterBarProps {
6
+ titleSearchLabel?: string;
7
+ searchKey?: string;
8
+ statusKey?: string;
9
+ searchPlaceholder?: string;
10
+ searchHighlightPlaceholder?: string;
11
+ withSearchParam?: boolean;
12
+ extendedFilter?: ExtendedFilter[];
13
+ showStatusFilter?: boolean;
14
+ showSearchFilter?: boolean;
15
+ filterKey?: string;
16
+ pageKey?: string;
17
+ handleOnReset?: () => void;
18
+ customWidthSearch?: string;
19
+ withTitleLabels?: boolean;
20
+ position?: 'left' | 'right';
21
+ }
22
+ export interface AdvanceFilterBarProps extends Omit<TableFilterBarProps, 'withSearchParam'> {
23
+ filterConfigs?: FilterConfig[];
24
+ buttonToggleProps?: {
25
+ isShowLabel?: boolean;
26
+ icon?: IconName;
27
+ };
28
+ }
29
+ type InputType = 'search' | 'dropdown' | 'date-range' | 'advanced-date-range' | 'radio' | 'dropdown-multiple' | 'date';
30
+ export type ChangeHandler = (params: {
31
+ value: any;
32
+ name?: string;
33
+ type?: InputType;
34
+ withSearchParam?: boolean;
35
+ setSearchParams: SetURLSearchParams;
36
+ searchQueries: Record<string, string>;
37
+ dropdownSearchKey?: string;
38
+ filterKey?: string;
39
+ pageKey?: string;
40
+ }) => void;
41
+ export type ExtendedFilter = {
42
+ minWidth?: string;
43
+ title: string;
44
+ content: React.ReactNode;
45
+ onClickContainer?: () => void;
46
+ };
47
+ export type GetValuesFilterProps = {
48
+ searchParams: URLSearchParams;
49
+ filterKey?: string;
50
+ name: string;
51
+ get: 'value' | 'label';
52
+ };
53
+ export {};
@@ -0,0 +1,31 @@
1
+ import { IDateRange } from '@starasia/date';
2
+ import { IDropdown } from '@starasia/dropdown';
3
+ import { ChangeHandler, GetValuesFilterProps } from './types';
4
+
5
+ export declare const resolveDropdownValueToString: (value: IDropdown["defaultValue"]) => string;
6
+ export declare const resolveRadioValueToString: (value: {
7
+ id: number;
8
+ label: string;
9
+ value: string;
10
+ }) => string;
11
+ export declare const resolveDateRangeValueToString: (value: IDateRange) => string;
12
+ export declare const resolveDateValueToString: (value: Date) => string;
13
+ export declare const handleChangeFilter: ChangeHandler;
14
+ export declare const getValuesFilter: ({ name, filterKey, searchParams, get }: GetValuesFilterProps) => any;
15
+ export declare const getValueDropdownMultipleFilter: ({ name, filterKey, searchParams, get }: Omit<GetValuesFilterProps, "get"> & {
16
+ get: "value" | "label" | "array";
17
+ }) => any;
18
+ export declare const getValueRadioFilter: ({ name, filterKey, searchParams, get }: Omit<GetValuesFilterProps, "get"> & {
19
+ get: "value" | "label" | "id";
20
+ }) => any;
21
+ export declare const getValueSearch: (name: string, searchParams: URLSearchParams, filterKey?: string) => any;
22
+ export declare const getDateRangeFilterValue: ({ name, filterKey, searchParams }: GetValuesFilterProps) => {
23
+ start: string;
24
+ end: string;
25
+ };
26
+ export declare const getDateFilterValue: ({ name, filterKey, searchParams }: GetValuesFilterProps) => Date | undefined;
27
+ export declare const isFilterActive: (searchParams: URLSearchParams, { filterKey, perPageKey, pageKey }: {
28
+ filterKey?: string;
29
+ perPageKey?: string;
30
+ pageKey?: string;
31
+ }) => boolean;
@@ -16,6 +16,10 @@ interface AppLayoutProps {
16
16
  * Dapat berupa: Organization Menu, User Switcher, Custom Component, atau kombinasinya
17
17
  */
18
18
  sidebarHeaderContent?: ReactNode;
19
+ /**
20
+ * Show/hide module switcher control in header (and its modal)
21
+ */
22
+ showModuleSwitcher?: boolean;
19
23
  }
20
24
  /**
21
25
  * AppLayout - Main application layout component based on workspace pattern
@@ -30,5 +34,5 @@ interface AppLayoutProps {
30
34
  * - Loading overlay support
31
35
  * - Embed mode for iframes
32
36
  */
33
- export declare function AppLayout({ children, headerRight, profile, isLoadingProfile, onLogout, isLoggingOut, loadingComponent, sidebarHeaderContent, }: AppLayoutProps): React.JSX.Element;
37
+ export declare function AppLayout({ children, headerRight, profile, isLoadingProfile, onLogout, isLoggingOut, loadingComponent, sidebarHeaderContent, showModuleSwitcher, }: AppLayoutProps): React.JSX.Element;
34
38
  export {};
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { ColumnFilter } from '../types';
3
+
4
+ interface Props {
5
+ filter: ColumnFilter;
6
+ columnTitle: string;
7
+ }
8
+ export declare const ColumnFilterDropdown: ({ filter, columnTitle }: Props) => React.JSX.Element;
9
+ export {};
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { BaseRecord, DataTableProps } from '../types';
3
+
4
+ export declare const DataTable: <T extends BaseRecord>({ columns, records, handleDetail, handleUpdate, handleDelete, isLoading, visibleHandleDelete, visibleHandleUpdate, visibleHandleDetail, showHeadBorder, scrollParentRef, frozenCount, onFrozenCountChange, customActions, actionsOrder, customEmptyState }: DataTableProps<T>) => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { TableFooterProps } from '../types';
3
+
4
+ export declare const TableFooter: ({ pagination, pageKey, perPageKey, defaultPerPage, showPagination, totalData }: TableFooterProps) => React.JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ import { AdvanceFilterBarProps } from '../../AdvanceFilterBar/types';
3
+ import { ButtonProps } from '@starasia/button';
4
+ import { IconName } from '@starasia/icon';
5
+
6
+ interface ActionProps {
7
+ title?: string | ReactNode;
8
+ icon?: IconName;
9
+ buttonProps?: ButtonProps;
10
+ onClick?: () => void;
11
+ }
12
+ export type TableHeaderProps = {
13
+ action?: ActionProps[] | React.ReactNode;
14
+ advanceFilter?: AdvanceFilterBarProps;
15
+ show?: boolean;
16
+ showFilter?: boolean;
17
+ };
18
+ export declare const TableHeader: ({ action, advanceFilter, showFilter }: TableHeaderProps) => React.JSX.Element;
19
+ export {};
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { BaseRecord, TableSectionProps } from '../types';
3
+
4
+ export declare const TableSection: <T extends BaseRecord>({ wrapperProps, dataTableProps, headerProps, footerProps }: TableSectionProps<T>) => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { WrapperProps } from '../types';
3
+
4
+ export declare const TableWrapper: ({ children, borderRadius }: WrapperProps) => React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ export { TableSection } from './components/TableSection';
2
+ export { TableWrapper } from './components/Wrapper';
3
+ export { TableHeader } from './components/Header';
4
+ export { TableFooter } from './components/Footer';
5
+ export { DataTable } from './components/DataTable';
6
+ export { ColumnFilterDropdown } from './components/ColumnFilterDropdown';
7
+ export type { TableSectionProps, BaseRecord, Column, ColumnFilter, DataTableProps, WrapperProps, TableHeaderProps, TableFooterProps } from './types';
@@ -0,0 +1,99 @@
1
+ import { BoxProps } from '@starasia/box';
2
+ import { ButtonProps } from '@starasia/button';
3
+ import { IconName } from '@starasia/icon';
4
+ import { AdvanceFilterBarProps } from '../AdvanceFilterBar';
5
+ import { ReactNode } from 'react';
6
+
7
+ export interface BaseRecord {
8
+ id: number | string;
9
+ }
10
+ export interface Pagination {
11
+ currentPage: number;
12
+ perPage: number;
13
+ totalPage: number;
14
+ totalData: number;
15
+ totalCurrentPage: number;
16
+ rangeStart?: number;
17
+ rangeEnd?: number;
18
+ }
19
+ type Accessor<T> = keyof T | ((record: T) => React.ReactNode) | string;
20
+ export interface ColumnFilter {
21
+ options: {
22
+ label: string;
23
+ value: string;
24
+ }[];
25
+ selectedValues: string[];
26
+ onFilterChange: (values: string[]) => void;
27
+ isLoadingOptions?: boolean;
28
+ position?: 'left' | 'right';
29
+ hideSearch?: boolean;
30
+ onOpen?: () => void;
31
+ }
32
+ export interface Column<T> {
33
+ accessor?: Accessor<T>;
34
+ title: string;
35
+ textAlign?: 'text-left' | 'text-center' | 'text-right';
36
+ render?: (record: T, colIndex: number, records: T[]) => React.ReactNode;
37
+ bgColor?: (record: T, colIndex: number, records: T[]) => string;
38
+ showBorderLeft?: boolean;
39
+ showBorderRight?: boolean;
40
+ width?: string;
41
+ filter?: ColumnFilter;
42
+ }
43
+ export interface DataTableProps<T extends BaseRecord> {
44
+ columns: Column<T>[];
45
+ records?: T[];
46
+ handleDetail?: (id: number | string, item: T) => void;
47
+ handleUpdate?: (item: T) => void;
48
+ handleDelete?: (id: number | string, record: T) => void;
49
+ visibleHandleDelete?: (item: T) => boolean;
50
+ visibleHandleUpdate?: (item: T) => boolean;
51
+ visibleHandleDetail?: (item: T) => boolean;
52
+ pagination?: Pagination;
53
+ showHeadBorder?: boolean;
54
+ perPageKey?: string;
55
+ pageKey?: string;
56
+ isLoading?: boolean;
57
+ scrollParentRef?: React.RefObject<HTMLDivElement>;
58
+ defaultPerPage?: number;
59
+ showPagination?: boolean;
60
+ customEmptyState?: React.ReactNode;
61
+ enableFreezeColumns?: boolean;
62
+ defaultFrozenCount?: number;
63
+ frozenCount?: number;
64
+ onFrozenCountChange?: (count: number) => void;
65
+ customActions?: (record: T) => React.ReactNode;
66
+ actionsOrder?: Array<'detail' | 'update' | 'delete' | 'custom'>;
67
+ }
68
+ export type WrapperProps = {
69
+ children: React.ReactNode;
70
+ borderRadius?: BoxProps['borderRadius'];
71
+ };
72
+ interface ActionProps {
73
+ title?: string | ReactNode;
74
+ icon?: IconName;
75
+ buttonProps?: ButtonProps;
76
+ onClick?: () => void;
77
+ }
78
+ export type TableHeaderProps = {
79
+ action?: ActionProps[] | React.ReactNode;
80
+ advanceFilter?: AdvanceFilterBarProps;
81
+ show?: boolean;
82
+ showFilter?: boolean;
83
+ };
84
+ export type TableFooterProps = {
85
+ pageKey?: string;
86
+ perPageKey?: string;
87
+ pagination?: Pagination;
88
+ defaultPerPage?: number;
89
+ showPagination?: boolean;
90
+ showFooter?: boolean;
91
+ totalData?: number;
92
+ };
93
+ export type TableSectionProps<T extends BaseRecord> = {
94
+ headerProps?: TableHeaderProps;
95
+ wrapperProps?: Omit<WrapperProps, 'children'>;
96
+ dataTableProps?: DataTableProps<T>;
97
+ footerProps?: Pick<TableFooterProps, 'showFooter' | 'totalData'>;
98
+ };
99
+ export {};
@@ -10,6 +10,8 @@ export * from './RightDrawer';
10
10
  export * from './Section';
11
11
  export * from './ActionMenu';
12
12
  export * from './AdvanceFilter';
13
+ export * from './AdvanceFilterBar';
14
+ export * from './TableSection';
13
15
  export * from './EachUtils';
14
16
  export * from './DecisionWrapper';
15
17
  export * from './SwitchApps';