@sito/dashboard 0.0.27 → 0.0.29
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/README.md +8 -5
- package/dist/components/Chip/Chip.d.ts +7 -0
- package/dist/components/Chip/index.d.ts +2 -0
- package/dist/components/Chip/types.d.ts +12 -0
- package/dist/components/Form/AutocompleteInput/AutocompleteInput.d.ts +7 -0
- package/dist/components/Form/AutocompleteInput/index.d.ts +2 -0
- package/dist/components/Form/AutocompleteInput/types.d.ts +6 -0
- package/dist/components/Form/CheckInput/CheckInput.d.ts +7 -0
- package/dist/components/Form/CheckInput/index.d.ts +2 -0
- package/dist/components/Form/CheckInput/types.d.ts +4 -0
- package/dist/components/Form/SelectInput/SelectInput.d.ts +1 -2
- package/dist/components/Form/SelectInput/index.d.ts +2 -0
- package/dist/components/Form/SelectInput/types.d.ts +2 -14
- package/dist/components/Form/TextInput/TextInput.d.ts +7 -0
- package/dist/components/Form/TextInput/index.d.ts +2 -0
- package/dist/components/Form/TextInput/types.d.ts +5 -0
- package/dist/components/Form/index.d.ts +6 -4
- package/dist/components/Form/types.d.ts +15 -0
- package/dist/components/Form/utils.d.ts +3 -3
- package/dist/components/Loading/Loading.d.ts +1 -7
- package/dist/components/Loading/index.d.ts +1 -1
- package/dist/components/Loading/types.d.ts +6 -0
- package/dist/components/SvgIcons/ChevronDown.d.ts +2 -0
- package/dist/components/SvgIcons/ChevronLeft.d.ts +2 -0
- package/dist/components/SvgIcons/ChevronRight.d.ts +2 -0
- package/dist/components/SvgIcons/ChevronUp.d.ts +2 -0
- package/dist/components/SvgIcons/Close.d.ts +2 -0
- package/dist/components/SvgIcons/Filters.d.ts +2 -0
- package/dist/components/SvgIcons/index.d.ts +7 -0
- package/dist/components/{Chevron → SvgIcons}/types.d.ts +1 -1
- package/dist/components/Table/components/Columns.d.ts +2 -2
- package/dist/components/Table/components/FilterPopup/FilterPopup.d.ts +2 -0
- package/dist/components/Table/components/FilterPopup/index.d.ts +3 -0
- package/dist/components/Table/components/FilterPopup/types.d.ts +7 -0
- package/dist/components/Table/components/FilterPopup/utils.d.ts +3 -0
- package/dist/components/Table/components/Footer/CountOfTotal.d.ts +1 -0
- package/dist/components/Table/components/Footer/Footer.d.ts +4 -0
- package/dist/components/Table/components/Footer/JumpToPage.d.ts +5 -0
- package/dist/components/Table/components/Footer/Navigation.d.ts +1 -0
- package/dist/components/Table/components/Footer/index.d.ts +4 -0
- package/dist/components/Table/components/Rows.d.ts +3 -0
- package/dist/components/Table/components/Widgets/AutocompleteWidget.d.ts +2 -0
- package/dist/components/Table/components/Widgets/CheckWidget.d.ts +2 -0
- package/dist/components/Table/components/Widgets/DateWidget.d.ts +2 -0
- package/dist/components/Table/components/Widgets/NumberWidget.d.ts +2 -0
- package/dist/components/Table/components/Widgets/SelectWidget.d.ts +2 -0
- package/dist/components/Table/components/Widgets/TextWidget.d.ts +2 -0
- package/dist/components/Table/components/Widgets/index.d.ts +7 -0
- package/dist/components/Table/components/Widgets/types.d.ts +14 -0
- package/dist/components/Table/components/index.d.ts +6 -0
- package/dist/components/Table/components/types.d.ts +37 -0
- package/dist/components/Table/index.d.ts +3 -4
- package/dist/components/Table/types.d.ts +6 -26
- package/dist/components/Tooltip/Tooltip.d.ts +1 -6
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/components/Tooltip/types.d.ts +5 -0
- package/dist/components/index.d.ts +6 -6
- package/dist/dashboard.cjs +1 -1
- package/dist/dashboard.js +887 -302
- package/dist/lib/filters.d.ts +45 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/main.css +1 -1
- package/dist/providers/FiltersProvider/FiltersProvider.d.ts +8 -0
- package/dist/providers/FiltersProvider/index.d.ts +3 -0
- package/dist/providers/FiltersProvider/types.d.ts +18 -0
- package/dist/providers/FiltersProvider/utils.d.ts +5 -0
- package/dist/{components/Table/hooks → providers/TableOptions}/TableOptionsProvider.d.ts +1 -1
- package/dist/providers/TableOptions/index.d.ts +2 -0
- package/dist/{components/Table/hooks → providers/TableOptions}/types.d.ts +9 -3
- package/dist/providers/Translation/index.d.ts +2 -0
- package/dist/providers/index.d.ts +3 -2
- package/package.json +1 -1
- package/dist/components/Chevron/ChevronDown.d.ts +0 -3
- package/dist/components/Chevron/ChevronUp.d.ts +0 -3
- package/dist/components/Chevron/index.d.ts +0 -3
- package/dist/components/Table/components/Navigation.d.ts +0 -5
- /package/dist/components/Table/components/{PageSize.d.ts → Footer/PageSize.d.ts} +0 -0
- /package/dist/lib/{models/query.d.ts → query.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -49,8 +49,7 @@ const App = () => {
|
|
|
49
49
|
return (
|
|
50
50
|
<Table
|
|
51
51
|
title="User Table"
|
|
52
|
-
|
|
53
|
-
parseRows={parseRows}
|
|
52
|
+
data={rows}
|
|
54
53
|
columns={columns}
|
|
55
54
|
/>
|
|
56
55
|
);
|
|
@@ -93,12 +92,16 @@ The Table component is a flexible and feature-rich table for displaying data.
|
|
|
93
92
|
|
|
94
93
|
#### Props
|
|
95
94
|
- `title` (string): The title of the table.
|
|
96
|
-
- `
|
|
97
|
-
- `
|
|
98
|
-
- `columns` (array): Column definitions, including keys and labels.
|
|
95
|
+
- `subtitle` (string): The subtitle of the table.
|
|
96
|
+
- `data` (array): The data to display in the table.
|
|
97
|
+
- `columns` (array): Column definitions, including keys and labels, etc.
|
|
99
98
|
- `isLoading` (boolean): Whether the table is in a loading state.
|
|
100
99
|
- `actions` (function): A function to render actions for each row.
|
|
101
100
|
- `className` (string): Custom class for the table container.
|
|
101
|
+
- `contentClassName` (string): Custom class for the table content
|
|
102
|
+
- `softDeleteProperty` (string): Property for the softDelete logic
|
|
103
|
+
- `toolbar` (ReactNode): component for toolbar
|
|
104
|
+
- `onSort` (function): callback to call after sort change
|
|
102
105
|
|
|
103
106
|
### TranslationProvider
|
|
104
107
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare enum ChipVariant {
|
|
2
|
+
empty = "empty",
|
|
3
|
+
outlined = "outlined",
|
|
4
|
+
default = "default"
|
|
5
|
+
}
|
|
6
|
+
export type ChipPropsType = {
|
|
7
|
+
variant?: ChipVariant;
|
|
8
|
+
label?: string;
|
|
9
|
+
onDelete?: () => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
spanClassName?: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AutocompleteInputPropsType } from './types';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {object} props
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare const AutocompleteInput: import('react').ForwardRefExoticComponent<Omit<AutocompleteInputPropsType, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CheckInputPropsType } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* CheckInput
|
|
4
|
+
* @param {object} props
|
|
5
|
+
* @returns CheckInput component
|
|
6
|
+
*/
|
|
7
|
+
export declare const CheckInput: import('react').ForwardRefExoticComponent<Omit<CheckInputPropsType, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -4,5 +4,4 @@ import { SelectInputPropsType } from './types';
|
|
|
4
4
|
* @param {object} props
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
|
-
declare const SelectInput: import('react').ForwardRefExoticComponent<Omit<SelectInputPropsType, "ref"> & import('react').RefAttributes<HTMLSelectElement>>;
|
|
8
|
-
export default SelectInput;
|
|
7
|
+
export declare const SelectInput: import('react').ForwardRefExoticComponent<Omit<SelectInputPropsType, "ref"> & import('react').RefAttributes<HTMLSelectElement>>;
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import { HTMLProps } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseInputPropsType } from '../types';
|
|
3
3
|
export type Option = {
|
|
4
4
|
id: number | string;
|
|
5
5
|
value: number | string;
|
|
6
6
|
};
|
|
7
|
-
export interface SelectInputPropsType extends HTMLProps<HTMLSelectElement
|
|
8
|
-
state?: State;
|
|
9
|
-
value: any;
|
|
10
|
-
onChange: (e: any) => void;
|
|
7
|
+
export interface SelectInputPropsType extends Omit<HTMLProps<HTMLSelectElement>, "value" | "onChange">, BaseInputPropsType {
|
|
11
8
|
options: Option[];
|
|
12
|
-
name?: string;
|
|
13
|
-
id?: string;
|
|
14
|
-
label?: string;
|
|
15
|
-
containerClassName?: string;
|
|
16
|
-
inputClassName?: string;
|
|
17
|
-
labelClassName?: string;
|
|
18
|
-
helperText?: string;
|
|
19
|
-
helperTextClassName?: string;
|
|
20
|
-
placeholder?: string;
|
|
21
9
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TextInputPropsType } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* TextInput
|
|
4
|
+
* @param {object} props
|
|
5
|
+
* @returns TextInput Component
|
|
6
|
+
*/
|
|
7
|
+
export declare const TextInput: import('react').ForwardRefExoticComponent<Omit<TextInputPropsType, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export * from './SelectInput';
|
|
2
|
+
export * from './TextInput';
|
|
3
|
+
export * from './CheckInput';
|
|
4
|
+
export * from './AutocompleteInput';
|
|
5
|
+
export * from './utils';
|
|
6
|
+
export * from './types';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { State } from './utils';
|
|
2
|
+
export type BaseInputPropsType = {
|
|
3
|
+
state?: State;
|
|
4
|
+
value: any;
|
|
5
|
+
onChange: (e: any) => void;
|
|
6
|
+
name?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
containerClassName?: string;
|
|
10
|
+
inputClassName?: string;
|
|
11
|
+
labelClassName?: string;
|
|
12
|
+
helperText?: string;
|
|
13
|
+
helperTextClassName?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
};
|
|
@@ -8,16 +8,16 @@ export declare enum State {
|
|
|
8
8
|
* @param {string} state - input state
|
|
9
9
|
* @returns input class name by
|
|
10
10
|
*/
|
|
11
|
-
export declare const inputStateClassName: (state: State) => "
|
|
11
|
+
export declare const inputStateClassName: (state: State) => "input-error" | "input-good" | "input-normal";
|
|
12
12
|
/**
|
|
13
13
|
* Label State Class Name
|
|
14
14
|
* @param {string} state - input state
|
|
15
15
|
* @returns input class name by
|
|
16
16
|
*/
|
|
17
|
-
export declare const labelStateClassName: (state: State) => "
|
|
17
|
+
export declare const labelStateClassName: (state: State) => "input-label-error" | "input-label-good" | "input-label-normal";
|
|
18
18
|
/**
|
|
19
19
|
* Helper Text State Class Name
|
|
20
20
|
* @param {string} state - input state
|
|
21
21
|
* @returns input class name by
|
|
22
22
|
*/
|
|
23
|
-
export declare const helperTextStateClassName: (state: State) => "text-
|
|
23
|
+
export declare const helperTextStateClassName: (state: State) => "input-helper-text-error" | "input-helper-text-good" | "input-helper-text-normal";
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface LoadingPropsType extends HTMLProps<HTMLDivElement> {
|
|
3
|
-
color?: string;
|
|
4
|
-
loaderClass?: string;
|
|
5
|
-
strokeWidth?: string;
|
|
6
|
-
}
|
|
1
|
+
import { LoadingPropsType } from './types';
|
|
7
2
|
/**
|
|
8
3
|
* Loading
|
|
9
4
|
* @param {object} props - Props
|
|
10
5
|
* @returns Loading component
|
|
11
6
|
*/
|
|
12
7
|
export declare function Loading(props: LoadingPropsType): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './Loading';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColumnPropsType } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Columns component
|
|
4
4
|
* @param {object} props properties for the columns
|
|
5
5
|
* @returns Row of columns
|
|
6
6
|
*/
|
|
7
|
-
export declare function Columns(props:
|
|
7
|
+
export declare function Columns(props: ColumnPropsType): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CountOfTotal: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Navigation: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AutocompleteFilterType, CheckFilterType, DateFilterType, NumberFilterType, SelectFilterType, TextFilterType } from '../../../../lib';
|
|
2
|
+
export interface SelectWidgetPropsType extends SelectFilterType {
|
|
3
|
+
}
|
|
4
|
+
export interface DateWidgetPropsType extends DateFilterType {
|
|
5
|
+
}
|
|
6
|
+
export interface AutocompleteWidgetPropsType extends AutocompleteFilterType {
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CheckWidgetPropsType extends CheckFilterType {
|
|
10
|
+
}
|
|
11
|
+
export interface TextWidgetPropsType extends TextFilterType {
|
|
12
|
+
}
|
|
13
|
+
export interface NumberWidgetPropsType extends NumberFilterType {
|
|
14
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FilterTypes, SortOrder } from '../../../lib';
|
|
2
|
+
import { Action } from '../types';
|
|
3
|
+
export type ColumnType = {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
sortable?: boolean;
|
|
7
|
+
sortOptions: {
|
|
8
|
+
icons: {
|
|
9
|
+
className: string;
|
|
10
|
+
asc: string;
|
|
11
|
+
desc: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
className?: string;
|
|
15
|
+
display?: "visible" | "none";
|
|
16
|
+
pos?: number;
|
|
17
|
+
renderBody?: (value: any, row: any) => React.ReactNode;
|
|
18
|
+
renderHead?: () => void;
|
|
19
|
+
filterOptions?: ColumnFilterOptions;
|
|
20
|
+
};
|
|
21
|
+
export type ColumnPropsType = {
|
|
22
|
+
entity: string;
|
|
23
|
+
columns: ColumnType[];
|
|
24
|
+
hasAction: boolean;
|
|
25
|
+
onSortCallback: (prop: string, sortOrder: SortOrder) => void;
|
|
26
|
+
};
|
|
27
|
+
export type ColumnFilterOptions = {
|
|
28
|
+
type: FilterTypes;
|
|
29
|
+
defaultValue: any;
|
|
30
|
+
label?: string;
|
|
31
|
+
};
|
|
32
|
+
export type RowsPropsType = {
|
|
33
|
+
data: any[];
|
|
34
|
+
columns: ColumnType[];
|
|
35
|
+
softDeleteProperty: string;
|
|
36
|
+
actions: ((row: any) => Action[]) | undefined;
|
|
37
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export type { TableOptionsContextType, TableOptionsProviderPropsType, } from './hooks/types';
|
|
1
|
+
export * from './Table';
|
|
2
|
+
export * from './components';
|
|
3
|
+
export * from './types';
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { SortOrder } from '../../lib';
|
|
2
|
+
import { ColumnType } from './components';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
1
4
|
export type Action = {
|
|
2
5
|
id: string;
|
|
3
6
|
onClick: (entity: object) => void;
|
|
@@ -5,40 +8,17 @@ export type Action = {
|
|
|
5
8
|
tooltip: string;
|
|
6
9
|
hidden: (entity: object) => boolean;
|
|
7
10
|
};
|
|
8
|
-
export type ColumnsOptionsType = {
|
|
9
|
-
noSortableColumns: {
|
|
10
|
-
[key: string]: boolean;
|
|
11
|
-
};
|
|
12
|
-
columnClassNames: {
|
|
13
|
-
[key: string]: string;
|
|
14
|
-
};
|
|
15
|
-
icons: {
|
|
16
|
-
className: string;
|
|
17
|
-
asc: string;
|
|
18
|
-
desc: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export type ColumnType = {
|
|
22
|
-
key: string;
|
|
23
|
-
label: string;
|
|
24
|
-
};
|
|
25
|
-
export type ColumnPropTypes = {
|
|
26
|
-
entity: string;
|
|
27
|
-
columns: ColumnType[];
|
|
28
|
-
columnsOptions?: ColumnsOptionsType;
|
|
29
|
-
hasAction: boolean;
|
|
30
|
-
};
|
|
31
11
|
export type TablePropsType = {
|
|
32
12
|
entity: string;
|
|
33
13
|
title?: string;
|
|
34
14
|
subtitle?: string;
|
|
35
|
-
|
|
36
|
-
parseRows?: any;
|
|
15
|
+
data: object[];
|
|
37
16
|
isLoading?: boolean;
|
|
38
17
|
actions?: (row: object) => Action[];
|
|
39
18
|
columns?: ColumnType[];
|
|
40
|
-
columnsOptions?: ColumnsOptionsType;
|
|
41
19
|
contentClassName?: string;
|
|
42
20
|
className?: string;
|
|
43
21
|
softDeleteProperty?: string;
|
|
22
|
+
toolbar?: ReactNode;
|
|
23
|
+
onSort: (prop: string, sortOrder: SortOrder) => void;
|
|
44
24
|
};
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface TooltipPropsType extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
content: string;
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
}
|
|
1
|
+
import { TooltipPropsType } from './types';
|
|
6
2
|
export declare function Tooltip(props: TooltipPropsType): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
1
|
+
export * from './SvgIcons';
|
|
2
|
+
export * from './Form';
|
|
3
|
+
export * from './Loading';
|
|
4
|
+
export * from './Table';
|
|
5
|
+
export * from './Tooltip';
|
|
6
|
+
export * from './Chip';
|
package/dist/dashboard.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var H=require("./main.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react");var N=(s=>(s.ASC="ASC",s.DESC="DESC",s))(N||{});const E=[20,50,100],S=d.createContext({}),M=s=>{const{children:t}=s,[l,n]=d.useState(0),[a,r]=d.useState(20),[b,g]=d.useState(0),[u,j]=d.useState("id"),[i,o]=d.useState(N.DESC),m={onSort:d.useCallback(c=>{let v=i;if(u===c)switch(i){case N.ASC:v=N.DESC;break;default:v=N.ASC;break}j(c),o(v)},[u,i]),total:l,setTotal:n,sortingBy:u,setSortingBy:j,sortingOrder:i,setSortingOrder:o,pageSize:a,pageSizes:E,setPageSize:r,currentPage:b,setCurrentPage:g};return e.jsx(S.Provider,{value:m,children:t})},f=()=>{const s=d.useContext(S);if(s===void 0)throw new Error("tableOptionsContext must be used within a Provider");return s},$=d.createContext({});function A(s){const{children:t,t:l}=s;return e.jsx($.Provider,{value:{t:l},children:t})}const C=()=>{const s=d.useContext($);if(s===void 0)throw new Error("translationContext must be used within a Provider");return s};function T(s){const{content:t,children:l}=s;return e.jsxs("div",{className:"tooltip-container",children:[l,e.jsx("div",{className:"tooltip-text",children:t})]})}function w(s){const{color:t="stroke-blue-800",loaderClass:l,strokeWidth:n="4",...a}=s;return e.jsx("div",{...a,className:`loading ${a.className}`,children:e.jsx("div",{className:"loader-container",children:e.jsx("div",{className:`loader ${l}`,children:e.jsx("svg",{className:"circular",viewBox:"25 25 50 50",children:e.jsx("circle",{className:`path ${t}`,cx:"50",cy:"50",r:"20",fill:"none",strokeWidth:n,strokeMiterlimit:"10"})})})})})}function D(){const{t:s}=C();return e.jsx("div",{className:"table-empty",children:e.jsx("p",{children:s("_accessibility:components.table.empty")})})}function k(s){const{className:t}=s;return e.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:e.jsx("path",{d:"M233.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L256 173.3 86.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z"})})}function P(s){const{className:t}=s;return e.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})})}function B(s){const{t}=C(),{entity:l="",columns:n=[],hasAction:a=!0,columnsOptions:r}=s,{onSort:b,sortingOrder:g,sortingBy:u}=f(),j=d.useMemo(()=>{const{noSortableColumns:i={},columnClassNames:o={}}=r??{};return n==null?void 0:n.map(h=>({id:h.key,label:h.label,className:o[h.key]??"",sortable:!i[h.key]}))},[n,r,l,t]);return e.jsx("thead",{className:"table-headers-row",children:e.jsxs("tr",{children:[j.map(i=>{var o,h,m,c;return e.jsx("th",{scope:"col",className:`table-headers-column ${i.className}`,children:e.jsxs("button",{disabled:!i.sortable,onClick:()=>b(i.id),className:"table-headers-cell",children:[e.jsx("span",{className:"table-headers-label",children:i.label}),i.sortable&&e.jsx("span",{className:`${u===i.id?"table-headers-sort-on":"table-headers-sort"}`,children:g===N.ASC?((o=r==null?void 0:r.icons)==null?void 0:o.asc)??e.jsx(k,{className:((h=r==null?void 0:r.icons)==null?void 0:h.className)??"table-headers-sort-indicator"}):((m=r==null?void 0:r.icons)==null?void 0:m.desc)??e.jsx(P,{className:((c=r==null?void 0:r.icons)==null?void 0:c.className)??"table-headers-sort-indicator"})})]})},i.id)}),a&&e.jsx("th",{scope:"col",className:"table-headers-action",children:t("_accessibility:labels.actions")})]})})}var z=(s=>(s.error="error",s.good="good",s.default="default",s))(z||{});const L=s=>{switch(s){case"error":return"border-red-500 text-red-900 placeholder-red-700 focus:ring-red-500 focus:border-red-500";case"good":return"border-green-500 text-green-900 placeholder-green-700 focus:ring-green-500 focus:border-green-500";default:return"text-gray-900 border-gray-300 focus:border-blue-600"}},F=s=>{switch(s){case"error":return"peer-focus:text-red-700 text-red-700";case"good":return"peer-focus:text-green-700 text-green-700";default:return"peer-focus:text-blue-600 text-gray-500"}},q=s=>{switch(s){case"error":return"text-red-600";case"good":return"text-green-600";default:return"text-gray-500"}};const I=d.forwardRef(function(s,t){const{value:l,onChange:n,options:a,containerClassName:r="",inputClassName:b="",labelClassName:g="",helperText:u="",helperTextClassName:j="",placeholder:i="",label:o="",name:h="",id:m="",state:c=z.default,...v}=s;return d.useEffect(()=>{var p;(!l||l==="")&&(a!=null&&a.length)&&n({target:{value:(p=a[0])==null?void 0:p.id}})},[n,a,l]),e.jsxs("div",{className:`select-input-container ${r}`,children:[e.jsx("select",{...v,id:m,ref:t,name:h,value:l,onChange:n,className:`select-input ${L(c)} peer ${b}`,children:a==null?void 0:a.map(p=>e.jsx("option",{value:p.id,children:p.value},p.id))}),e.jsx("label",{htmlFor:h,className:`select-input-label ${F(c)} ${g}`,children:o}),e.jsx("p",{className:`select-input-helper-text ${q(c)} ${j}`,children:c!=="error"&&c!=="good"?i:u})]})}),R=I;function U(){const{t:s}=C(),{pageSizes:t,pageSize:l,setPageSize:n}=f(),a=d.useMemo(()=>t==null?void 0:t.map(r=>({id:r,value:r})),[t]);return e.jsxs("div",{className:"page-size",children:[e.jsx("p",{children:s("_accessibility:components.table.pageSizes")}),e.jsx(R,{value:l,options:a,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:r=>n(r.target.value)})]})}function W(){const{t:s}=C(),{total:t,pageSize:l,pageSizes:n,currentPage:a,setCurrentPage:r}=f(),b=(a+1)*l>t?t:(a+1)*l;return e.jsxs("div",{className:"table-navigation",children:[e.jsxs("div",{className:"table-navigation-sizes",children:[e.jsx("p",{children:s("_accessibility:components.table.pageSizes")}),n[0]<t&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[s("_accessibility:components.table.from")," ",a*l+1," ",s("_accessibility:components.table.to")," ",b," ",s("_accessibility:components.table.of")]})}),e.jsxs("p",{children:[t," ",s("_accessibility:components.table.results")]})]}),e.jsxs("div",{className:"table-navigation-pages",children:[e.jsx("button",{className:"table-navigation-buttons",disabled:a===0,onClick:()=>r(a-1),children:s("_accessibility:buttons.previous")}),e.jsx("button",{disabled:Math.floor(t/((a+1)*l))===0,className:"table-navigation-buttons",onClick:()=>r(a+1),children:s("_accessibility:buttons.next")})]})]})}function G(s){const{t}=C(),{title:l="",rows:n,parseRows:a,entity:r="",isLoading:b=!1,actions:g,columns:u=[],contentClassName:j="",className:i="",columnsOptions:o,softDeleteProperty:h="deleted"}=s,m=d.useMemo(()=>(n==null?void 0:n.map(c=>a(c)))??[],[a,n,t]);return e.jsxs("div",{className:`${i} table`,children:[e.jsx("div",{className:"table-header",children:e.jsxs("div",{children:[e.jsx("h1",{className:"table-header-title",children:l}),n!=null&&n.length&&!b?e.jsx(U,{}):null]})}),b?e.jsx(w,{className:"table-loading"}):e.jsx("div",{className:`${j} table-body`,children:n!=null&&n.length?e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"table-content",children:[e.jsx(B,{entity:r,columns:u,columnsOptions:o,hasAction:!!g}),e.jsx("tbody",{children:m==null?void 0:m.map(c=>{var v,p;return e.jsxs("tr",{className:`table-row ${(v=c[h])!=null&&v.value?"deleted-class":""}`,children:[u==null?void 0:u.map((x,_)=>{var y;return e.jsx("td",{className:`table-row-cell ${_===0?"basic":""} ${o!=null&&o.columnClassNames?o==null?void 0:o.columnClassNames[x.key]:""}`,children:((y=c[x.key])==null?void 0:y.render)??c[x.key]},x.key)}),g?e.jsx("td",{children:e.jsx("div",{className:"table-row-cell-action",children:(p=g(c).filter(x=>!x.hidden))==null?void 0:p.map(x=>e.jsx(T,{content:x.tooltip,children:e.jsx("button",{onClick:x.onClick,children:x.icon})},x.id))})}):null]},c.id)})})]}),e.jsx(W,{})]}):e.jsx(D,{})})]})}exports.ChevronDown=P;exports.ChevronUp=k;exports.Loading=w;exports.Table=G;exports.TableOptionsProvider=M;exports.Tooltip=T;exports.TranslationProvider=A;exports.useTableOptions=f;exports.useTranslation=C;
|
|
1
|
+
var $e=require("./main.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react");function W(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})})}function H(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:e.jsx("path",{d:"M233.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L256 173.3 86.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z"})})}function q(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",fill:"currentColor",children:e.jsx("path",{d:"M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"})})}function J(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",fill:"currentColor",children:e.jsx("path",{d:"M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"})})}const V=t=>{const{className:n=""}=t;return e.jsx("svg",{className:n,viewBox:"0 0 16 16",children:e.jsx("path",{d:"M9 15H7a1 1 0 010-2h2a1 1 0 010 2zM11 11H5a1 1 0 010-2h6a1 1 0 010 2zM13 7H3a1 1 0 010-2h10a1 1 0 010 2zM15 3H1a1 1 0 010-2h14a1 1 0 010 2z"})})};function D(t){const{className:n=""}=t;return e.jsx("svg",{className:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor",children:e.jsx("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"})})}var E=(t=>(t.error="error",t.good="good",t.default="default",t))(E||{});const A=t=>{switch(t){case"error":return"input-error";case"good":return"input-good";default:return"input-normal"}},B=t=>{switch(t){case"error":return"input-label-error";case"good":return"input-label-good";default:return"input-label-normal"}},I=t=>{switch(t){case"error":return"input-helper-text-error";case"good":return"input-helper-text-good";default:return"input-helper-text-normal"}};const R=o.forwardRef(function(t,n){const{value:r,onChange:s,options:a,containerClassName:l="",inputClassName:i="",labelClassName:c="",helperText:u="",helperTextClassName:x="",placeholder:d="",label:p="",name:v="",id:h="",state:m=E.default,...g}=t;return o.useEffect(()=>{var C;(!r||r==="")&&(a!=null&&a.length)&&s({target:{value:(C=a[0])==null?void 0:C.id}})},[s,a,r]),e.jsxs("div",{className:`select-input-container ${l}`,children:[e.jsx("select",{...g,id:h,ref:n,name:v,value:r,onChange:s,className:`select-input ${A(m)} peer ${i}`,children:a==null?void 0:a.map(C=>e.jsx("option",{value:C.id,children:C.value},C.id))}),e.jsx("label",{htmlFor:v,className:`select-input-label ${B(m)} ${c}`,children:p}),e.jsx("p",{className:`select-input-helper-text ${I(m)} ${x}`,children:m!=="error"&&m!=="good"?d:u})]})});const L=o.forwardRef(function(t,n){const{children:r,value:s,onChange:a,state:l=E.default,name:i="",id:c="",type:u="text",label:x="",required:d=!1,placeholder:p="",containerClassName:v="",inputClassName:h="",labelClassName:m="",helperText:g="",helperTextClassName:C="",...j}=t;return e.jsxs("div",{className:`text-input-container ${v}`,children:[e.jsx("input",{ref:n,type:u,name:i,id:c,className:`text-input ${A(l)} peer ${h}`,placeholder:"",required:d,value:s,onChange:a,...j}),e.jsxs("label",{htmlFor:i,className:`text-input-label ${B(l)} ${m}`,children:[x,d?" *":""]}),r,e.jsx("p",{className:`text-input-helper-text ${I(l)} ${C}`,children:l!=="error"&&l!=="good"?p:g})]})});const G=o.forwardRef(function(t,n){const{checked:r,onChange:s,state:a=E.default,name:l="",id:i="",type:c="text",label:u="",containerClassName:x="",inputClassName:d="",labelClassName:p="",helperText:v="",helperTextClassName:h="",...m}=t;return e.jsxs("label",{className:`input-check-container ${x}`,children:[e.jsx("input",{id:i,ref:n,name:l,type:"checkbox",checked:r,onChange:s,className:`input-check ${d}`,...m}),e.jsx("span",{className:`input-check-label ${p}`,children:u})]})});const K=o.forwardRef(function(t,n){const{state:r,value:s,onChange:a,options:l=[],name:i="",id:c="",label:u="",containerClassName:x="",inputContainerClassName:d="",helperText:p="",placeholder:v="",multiple:h=!1,...m}=t,[g,C]=o.useState(""),[j,f]=o.useState(!1),y=l.filter(b=>{const w=String(b.value).toLowerCase().includes(g==null?void 0:g.toLowerCase());return s&&s.length?s!=null&&s.some?!(s!=null&&s.some(_=>_.id===b.id)):(s==null?void 0:s.id)!==b.id:w}),M=o.useRef(null);o.useEffect(()=>{const b=z=>{M.current&&!M.current.contains(z.target)&&f(!1)},w=z=>{z.key==="Escape"&&f(!1)};return document.addEventListener("click",b),document.addEventListener("keydown",w),()=>{document.removeEventListener("click",b),document.removeEventListener("keydown",w)}},[]);const O=b=>{C(b.target.value)},U=o.useCallback(b=>{C(""),a(b?h?s?[...s,b]:[b]:b:null),f(!1)},[h,a,s]),he=o.useCallback(b=>{const w=s.filter((z,_)=>_!==b);w.length?a(w):a(null)},[a,s]);return e.jsxs("div",{className:`autocomplete-input-container ${x}`,ref:M,children:[e.jsx(L,{state:r,name:i,id:c,value:!h&&s?s.value:g,onChange:O,placeholder:v,helperText:p,onFocus:()=>f(!0),label:u,containerClassName:`autocomplete-text-input ${d}`,ref:n,...m,children:!h&&s&&e.jsx("button",{type:"button",className:"autocomplete-delete-button",onClick:()=>U(),children:e.jsx(D,{})})}),j&&e.jsx("ul",{className:"autocomplete-suggestions-container",children:y.map(b=>e.jsx("li",{className:"autocomplete-suggestion-item hover:bg-primary/20",onClick:()=>U(b),children:b.value},b.id))}),h&&Array.isArray(s)&&s.length?e.jsx("ul",{className:"autocomplete-value-container",children:s.map((b,w)=>e.jsx("li",{children:e.jsx(me,{label:String(b.value),onDelete:()=>he(w)})},b.value))}):null]})});function Q(t){const{color:n="stroke-blue-800",loaderClass:r,strokeWidth:s="4",...a}=t;return e.jsx("div",{...a,className:`loading ${a.className}`,children:e.jsx("div",{className:"loader-container",children:e.jsx("div",{className:`loader ${r}`,children:e.jsx("svg",{className:"circular",viewBox:"25 25 50 50",children:e.jsx("circle",{className:`path ${n}`,cx:"50",cy:"50",r:"20",fill:"none",strokeWidth:s,strokeMiterlimit:"10"})})})})})}const X=o.createContext({});function xe(t){const{children:n,t:r}=t;return e.jsx(X.Provider,{value:{t:r},children:n})}const k=()=>{const t=o.useContext(X);if(t===void 0)throw new Error("translationContext must be used within a Provider");return t};var F=(t=>(t[t.text=0]="text",t[t.number=1]="number",t[t.select=2]="select",t[t.autocomplete=3]="autocomplete",t[t.date=4]="date",t[t.check=5]="check",t))(F||{}),T=(t=>(t.ASC="ASC",t.DESC="DESC",t))(T||{});const be=[20,50,100],Y=o.createContext({}),ge=t=>{const{children:n}=t,[r,s]=o.useState(0),[a,l]=o.useState(20),[i,c]=o.useState(0),[u,x]=o.useState("id"),[d,p]=o.useState(T.DESC),[v,h]=o.useState({}),m=o.useCallback((j,f)=>{let y=d;if(u===j)switch(d){case T.ASC:y=T.DESC;break;default:y=T.ASC;break}x(j),p(y),f&&f(j,y)},[u,d]),g=o.useCallback(j=>{const f=Object.entries(j).reduce((y,[M,O])=>(O&&typeof O.value<"u"&&(y[M]=O.value),y),{});h(f)},[]),C={onSort:m,total:r,setTotal:s,sortingBy:u,setSortingBy:x,sortingOrder:d,setSortingOrder:p,pageSize:a,pageSizes:be,setPageSize:l,currentPage:i,setCurrentPage:c,filters:v,onFilterApply:g};return e.jsx(Y.Provider,{value:C,children:n})},$=()=>{const t=o.useContext(Y);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t};var N=(t=>(t[t.update=0]="update",t[t.reset=1]="reset",t))(N||{});const Z=t=>{const n={},r=Object.keys(t);return r==null||r.forEach(s=>{n[s]={value:t[s]}}),n};function ee(t,n){const{type:r}=n;switch(r){case N.reset:{const{filters:s}=n,a={};return s==null||s.forEach(({propertyName:l,defaultValue:i})=>{a[l]={value:i}}),{...t,...a}}case N.update:{const{toUpdate:s}=n;return{...t,...s}}default:return t}}const te=o.createContext({}),se=t=>{const{children:n}=t,{filters:r}=$(),[s,a]=o.useReducer(ee,Z(r)),l={currentFilters:s,setCurrentFilters:a};return e.jsx(te.Provider,{value:l,children:n})},P=()=>{const t=o.useContext(te);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t};function ne(t){const{t:n}=k(),{entity:r="",columns:s=[],hasAction:a=!0,onSortCallback:l}=t,{onSort:i,sortingOrder:c,sortingBy:u}=$(),x=o.useMemo(()=>{var d;return(d=s.sort((p,v)=>(v.pos??0)-(p.pos??0)).filter(p=>p.display!=="none"))==null?void 0:d.map(p=>({id:p.key,label:p.label,className:p.className??"",sortable:p.sortable??!0,sortOptions:p.sortOptions}))},[s,r,n]);return e.jsx("thead",{className:"table-headers-row",children:e.jsxs("tr",{children:[x.map(d=>{var p,v,h,m,g,C,j,f;return e.jsx("th",{scope:"col",className:`table-headers-column ${d.className}`,children:e.jsxs("button",{disabled:!d.sortable,onClick:()=>i(d.id,l),className:"table-headers-cell",children:[e.jsx("span",{className:"table-headers-label",children:d.label}),d.sortable&&e.jsx("span",{className:`${u===d.id?"table-headers-sort-on":"table-headers-sort"}`,children:c===T.ASC?((v=(p=d.sortOptions)==null?void 0:p.icons)==null?void 0:v.asc)??e.jsx(H,{className:((m=(h=d.sortOptions)==null?void 0:h.icons)==null?void 0:m.className)??"table-headers-sort-indicator"}):((C=(g=d.sortOptions)==null?void 0:g.icons)==null?void 0:C.desc)??e.jsx(W,{className:((f=(j=d.sortOptions)==null?void 0:j.icons)==null?void 0:f.className)??"table-headers-sort-indicator"})})]})},d.id)}),a&&e.jsx("th",{scope:"col",className:"table-headers-action",children:n("_accessibility:labels.actions")})]})})}function ae(){const{t}=k();return e.jsx("div",{className:"table-empty",children:e.jsx("p",{children:t("_accessibility:components.table.empty")})})}const re=()=>{const{t}=k(),{total:n,pageSize:r,currentPage:s,setCurrentPage:a}=$();return e.jsxs("div",{className:"table-navigation-pages",children:[e.jsx("button",{className:"table-navigation-buttons",disabled:s===0,"aria-label":t("_accessibility:buttons.previous"),name:t("_accessibility:buttons.previous"),onClick:()=>a(s-1),children:e.jsx(J,{className:"w-2.5"})}),e.jsx("button",{disabled:Math.floor(n/((s+1)*r))===0,className:"table-navigation-buttons",name:t("_accessibility:buttons.next"),"aria-label":t("_accessibility:buttons.next"),onClick:()=>a(s+1),children:e.jsx(q,{className:"w-2.5"})})]})},le=()=>{const{t}=k(),{total:n,pageSize:r,pageSizes:s,currentPage:a}=$(),l=(a+1)*r>n?n:(a+1)*r;return e.jsxs("div",{className:"table-navigation-sizes",children:[s[0]<n&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[a*r+1," - ",l," ",t("_accessibility:components.table.of")]})}),e.jsx("p",{children:n})]})};function oe(){const{t}=k(),{pageSizes:n,pageSize:r,setPageSize:s}=$(),a=o.useMemo(()=>n==null?void 0:n.map(l=>({id:l,value:l})),[n]);return e.jsxs("div",{className:"page-size",children:[e.jsx("p",{children:t("_accessibility:components.table.pageSizes")}),e.jsx(R,{value:r,options:a,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:l=>s(l.target.value)})]})}function ve(){const{t}=k(),{total:n,pageSize:r,currentPage:s,setCurrentPage:a}=$(),l=o.useMemo(()=>{const i=Math.ceil(n/r);return Array.from({length:i},(c,u)=>({id:u,value:u+1}))},[n,r]);return e.jsxs("div",{className:"jump-to-page",children:[e.jsx("p",{children:t("_accessibility:components.table.jumpToPage")}),e.jsx(R,{value:s,options:l,inputClassName:"jump-to-page-input",containerClassName:"jump-to-page-input-container",helperTextClassName:"hidden",onChange:i=>a(Number(i.target.value))})]})}function ce(){return e.jsxs("div",{className:"table-footer",children:[e.jsx(ve,{}),e.jsx(oe,{}),e.jsx(le,{}),e.jsx(re,{})]})}function Ce(t){const{propertyName:n,options:r,label:s}=t,{currentFilters:a,setCurrentFilters:l}=P(),i=o.useMemo(()=>{var u;return((u=a[n])==null?void 0:u.value)??r[0]},[a]),c=o.useCallback(u=>{l({type:N.update,toUpdate:{[n]:{value:u.target.value}}})},[]);return e.jsx(R,{value:i,label:s,options:r,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:c})}const je=t=>{const{propertyName:n,label:r}=t,{currentFilters:s,setCurrentFilters:a}=P(),l=o.useMemo(()=>{var c;return((c=s[n])==null?void 0:c.value)??""},[s]),i=o.useCallback(c=>{a({type:N.update,toUpdate:{[n]:{value:c.target.value}}})},[]);return e.jsx(L,{value:l??"",label:r,onChange:i,containerClassName:"input-widget-container",helperTextClassName:""})},fe=t=>{const{propertyName:n,label:r,min:s,max:a}=t,{currentFilters:l,setCurrentFilters:i}=P(),c=o.useMemo(()=>{var x;return((x=l[n])==null?void 0:x.value)??""},[l]),u=o.useCallback(x=>{i({type:N.update,toUpdate:{[n]:{value:x.target.value}}})},[c]);return e.jsx(L,{value:c??"",min:s,max:a,type:"number",label:r,containerClassName:"input-widget-container",onChange:u,helperTextClassName:""})},Ne=t=>{const{propertyName:n,label:r}=t,{currentFilters:s,setCurrentFilters:a}=P(),l=o.useMemo(()=>{var c;return((c=s[n])==null?void 0:c.value)??""},[s]),i=o.useCallback(c=>{a({type:N.update,toUpdate:{[n]:{value:c.target.checked}}})},[]);return e.jsx(G,{label:r,checked:l??!1,onChange:i})};function ye(t){const{propertyName:n,label:r,options:s,multiple:a=!0}=t,{currentFilters:l,setCurrentFilters:i}=P(),c=o.useMemo(()=>l[n]??s[0],[l]),u=o.useCallback(x=>{i({type:N.update,toUpdate:{[n]:{value:x}}})},[a]);return e.jsx(K,{value:c==null?void 0:c.value,label:r,options:s,multiple:a,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:u})}const we=t=>{const{propertyName:n,label:r}=t,{currentFilters:s,setCurrentFilters:a}=P(),l=o.useMemo(()=>{var c,u;return(c=s[n])!=null&&c.value?new Date(String((u=s[n])==null?void 0:u.value)).toISOString().slice(0,10):""},[s]),i=o.useCallback(c=>{a({type:N.update,toUpdate:{[n]:{value:c.target.value}}})},[]);return e.jsx(L,{value:l??"",label:r,type:"date",onChange:i,containerClassName:"input-widget-container",helperTextClassName:""})},ie=t=>{switch(t.type){case F.text:return e.jsx(je,{...t});case F.number:return e.jsx(fe,{...t});case F.select:return e.jsx(Ce,{...t});case F.autocomplete:return e.jsx(ye,{...t});case F.date:return e.jsx(we,{...t});case F.check:return e.jsx(Ne,{...t})}return e.jsx(e.Fragment,{})};const ue=t=>{const{align:n="right",filters:r=[],icon:s}=t,[a,l]=o.useState(!1),{onFilterApply:i,filters:c}=$(),{currentFilters:u,setCurrentFilters:x}=P(),{t:d}=k(),p=o.useRef(null),v=o.useRef(null);return o.useEffect(()=>{const h=({target:m})=>{var g,C;v.current&&(!a||(g=v.current)!=null&&g.contains(m)||(C=p==null?void 0:p.current)!=null&&C.contains(m)||l(!1))};return document.addEventListener("click",h),()=>document.removeEventListener("click",h)}),o.useEffect(()=>{const h=m=>{!a||m.code!=="Escape"||l(!1)};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)}),e.jsxs("div",{className:"filter-dropdown-main",children:[e.jsxs("button",{ref:p,className:"filter-dropdown-button normal filter-dropdown-trigger","aria-haspopup":"true",onClick:()=>l(!a),"aria-expanded":a,children:[e.jsx("span",{className:"sr-only",children:d("_accessibility:buttons.filters")}),e.jsx("wbr",{}),s??e.jsx(V,{className:"filter-dropdown-trigger-icon"})]}),e.jsx("div",{className:`filter-dropdown-transition ${a?"opened":"closed"} ${n==="right"?"right":"left"}`,children:e.jsxs("div",{ref:v,children:[e.jsx("div",{className:"filter-title",children:d("_accessibility:buttons.filters")}),e.jsx("ul",{className:"filter-container",children:r.map(h=>e.jsx("li",{className:"filter-container-item",children:ie(h)},h.propertyName))}),e.jsx("div",{className:"filter-footer",children:e.jsxs("ul",{className:"filter-buttons-row",children:[e.jsx("li",{children:e.jsx("button",{onClick:()=>x({type:N.reset}),className:"filter-dropdown-button small filter-dropdown-cancel",children:d("_accessibility:buttons.clear")})}),e.jsx("li",{children:e.jsx("button",{className:"filter-dropdown-button small filter-dropdown-submit bg-primary hover:bg-light-primary",onClick:()=>{l(!1),i(u)},onBlur:()=>l(!1),children:d("_accessibility:buttons.applyFilters")})})]})})]})})]})},Se=t=>t,de=t=>{const{columns:n,softDeleteProperty:r="deleted",data:s,actions:a}=t,l=o.useMemo(()=>n.sort((i,c)=>(c.pos??0)-(i.pos??0)).filter(i=>i.display!=="none"),[n]);return s==null?void 0:s.map(i=>{var c;return e.jsxs("tr",{className:`table-row ${i[r]?"deleted-class":""}`,children:[l==null?void 0:l.map((u,x)=>e.jsx("td",{className:`table-row-cell ${x===0?"basic":""} ${u.className??""}`,children:u.renderBody?u.renderBody(i[u.key],i):Se(i[u.key])},u.key)),a?e.jsx("td",{children:e.jsx("div",{className:"table-row-cell-action",children:(c=a(i).filter(u=>!u.hidden))==null?void 0:c.map(u=>e.jsx(pe,{content:u.tooltip,children:e.jsx("button",{onClick:u.onClick,children:u.icon})},u.id))})}):null]},i.id)})};function ke(t){const{title:n="",data:r,onSort:s,entity:a="",isLoading:l=!1,actions:i,columns:c=[],contentClassName:u="",className:x="",toolbar:d=e.jsx(e.Fragment,{}),softDeleteProperty:p="deleted"}=t,v=o.useMemo(()=>c?c.sort((m,g)=>(g.pos??0)-(m.pos??0)).filter(m=>!!m.filterOptions).map(m=>{var g;return{...m.filterOptions,label:((g=m.filterOptions)==null?void 0:g.label)??m.label,propertyName:m.key}}):[],[c]),h=o.useMemo(()=>!(r!=null&&r.length),[r]);return e.jsx(se,{children:e.jsxs("div",{className:`${x} table-main`,children:[e.jsxs("div",{className:"table-header",children:[e.jsx("h1",{className:"table-header-title",children:n}),l?null:e.jsxs("div",{className:"table-header-right",children:[d,e.jsx(ue,{filters:v})]})]}),l?e.jsx(Q,{className:"table-loading"}):e.jsx(e.Fragment,{children:h?e.jsx(ae,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${u} table-body`,children:e.jsxs("table",{className:"table-content",children:[e.jsx(ne,{entity:a,columns:c,onSortCallback:s,hasAction:!!i}),e.jsx("tbody",{children:e.jsx(de,{data:r,actions:i,columns:c,softDeleteProperty:p})})]})}),e.jsx(ce,{})]})})]})})}function pe(t){const{content:n,children:r}=t;return e.jsxs("div",{className:"tooltip-container",children:[r,e.jsx("div",{className:"tooltip-text",children:n})]})}var S=(t=>(t.empty="empty",t.outlined="outlined",t.default="default",t))(S||{});function me(t){const{label:n,onDelete:r,className:s="",spanClassName:a="",variant:l=S.default}=t,i=o.useMemo(()=>{switch(l){case S.empty:return"text-primary bg-transparent";case S.outlined:return"border border-primary";case S.default:default:return"text-white bg-primary"}},[l]),c=o.useMemo(()=>{switch(l){case S.empty:case S.outlined:return"chip-delete-button-svg";case S.default:default:return"filled-chip-delete-button-svg"}},[l]);return e.jsxs("div",{className:`chip-main ${i} ${s}`,children:[e.jsx("span",{className:a,children:n}),r?e.jsx("button",{type:"button",className:"chip-delete-button",onClick:r,children:e.jsx(D,{className:c})}):null]})}exports.AutocompleteInput=K;exports.CheckInput=G;exports.ChevronDown=W;exports.ChevronLeft=J;exports.ChevronRight=q;exports.ChevronUp=H;exports.Chip=me;exports.ChipVariant=S;exports.Close=D;exports.Columns=ne;exports.CountOfTotal=le;exports.Empty=ae;exports.FilterPopup=ue;exports.Filters=V;exports.FiltersActions=N;exports.FiltersProvider=se;exports.Footer=ce;exports.Loading=Q;exports.Navigation=re;exports.PageSize=oe;exports.Rows=de;exports.SelectInput=R;exports.State=E;exports.Table=ke;exports.TableOptionsProvider=ge;exports.TextInput=L;exports.Tooltip=pe;exports.TranslationProvider=xe;exports.filtersReducer=ee;exports.helperTextStateClassName=I;exports.initializer=Z;exports.inputStateClassName=A;exports.labelStateClassName=B;exports.renderFilterComponent=ie;exports.useFilters=P;exports.useTableOptions=$;exports.useTranslation=k;
|