@axzydev/axzy_ui_system 1.3.2 → 1.3.4
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.cjs +1008 -834
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.cts +53 -8
- package/dist/index.d.ts +53 -8
- package/dist/index.js +927 -753
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/table/table.doc.mdx +11 -0
- package/src/components/molecules/table/table.props.ts +30 -2
- package/src/components/molecules/table/table.stories.tsx +30 -0
- package/src/components/molecules/table/table.tsx +105 -8
- package/src/components/organisms/data-table/ITDataTable.doc.mdx +11 -2
- package/src/components/organisms/data-table/ITDataTable.stories.tsx +73 -0
- package/src/components/organisms/data-table/dataTable.props.ts +8 -4
- package/src/components/organisms/data-table/dataTable.tsx +74 -1
- package/src/components/theme-provider/themePresets.ts +6 -0
- package/src/components/theme-provider/themeProvider.doc.mdx +1 -0
- package/src/components/theme-provider/themeProvider.props.ts +2 -0
- package/src/components/theme-provider/themeProvider.tsx +13 -2
- package/src/hooks/useTableState.ts +17 -11
- package/src/index.ts +3 -3
- package/src/sandbox/LandingShowcase.tsx +416 -227
- package/src/showcases/DataShowcases.tsx +156 -21
- package/src/theme/theme.types.ts +2 -0
- package/src/types/table.types.ts +17 -0
- package/src/utils/styles.ts +3 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
import type { ColumnFilters, ColumnFilterValue } from "@/types/table.types";
|
|
2
3
|
|
|
3
4
|
interface SortConfig {
|
|
4
5
|
key: string;
|
|
@@ -13,30 +14,35 @@ export interface UseTableStateOptions {
|
|
|
13
14
|
export interface UseTableStateResult {
|
|
14
15
|
currentPage: number;
|
|
15
16
|
itemsPerPage: number;
|
|
16
|
-
filters:
|
|
17
|
+
filters: ColumnFilters;
|
|
17
18
|
sortConfig: SortConfig | null;
|
|
18
19
|
totalPages: number;
|
|
19
20
|
setTotalPages: (pages: number) => void;
|
|
20
21
|
goToPage: (page: number) => void;
|
|
21
22
|
handleItemsPerPageChange: (value: number) => void;
|
|
22
|
-
handleFilterChange: (
|
|
23
|
-
key: string,
|
|
24
|
-
value: string | boolean | number | undefined
|
|
25
|
-
) => void;
|
|
23
|
+
handleFilterChange: (key: string, value: ColumnFilterValue | undefined) => void;
|
|
26
24
|
handleSort: (key: string, sortable?: boolean) => void;
|
|
27
25
|
resetPage: () => void;
|
|
28
26
|
clearFilters: () => void;
|
|
29
27
|
}
|
|
30
28
|
|
|
29
|
+
/**
|
|
30
|
+
* A filter value is considered empty when it should be removed from the filter
|
|
31
|
+
* map: `undefined`/`null`/`""`, or a date range whose both ends are null.
|
|
32
|
+
*/
|
|
33
|
+
const isEmptyFilterValue = (value: ColumnFilterValue | undefined): boolean => {
|
|
34
|
+
if (value === undefined || value === null || value === "") return true;
|
|
35
|
+
if (Array.isArray(value)) return value[0] == null && value[1] == null;
|
|
36
|
+
return false;
|
|
37
|
+
};
|
|
38
|
+
|
|
31
39
|
export function useTableState({
|
|
32
40
|
defaultItemsPerPage = 10,
|
|
33
41
|
initialSort = null,
|
|
34
42
|
}: UseTableStateOptions = {}): UseTableStateResult {
|
|
35
43
|
const [currentPage, setCurrentPage] = useState(1);
|
|
36
44
|
const [itemsPerPage, setItemsPerPage] = useState(defaultItemsPerPage);
|
|
37
|
-
const [filters, setFilters] = useState<
|
|
38
|
-
Record<string, string | boolean | number>
|
|
39
|
-
>({});
|
|
45
|
+
const [filters, setFilters] = useState<ColumnFilters>({});
|
|
40
46
|
const [sortConfig, setSortConfig] = useState<SortConfig | null>(initialSort);
|
|
41
47
|
const [totalPages, setTotalPages] = useState(1);
|
|
42
48
|
|
|
@@ -58,14 +64,14 @@ export function useTableState({
|
|
|
58
64
|
}, []);
|
|
59
65
|
|
|
60
66
|
const handleFilterChange = useCallback(
|
|
61
|
-
(key: string, value:
|
|
67
|
+
(key: string, value: ColumnFilterValue | undefined) => {
|
|
62
68
|
setFilters((prev) => {
|
|
63
|
-
if (value
|
|
69
|
+
if (isEmptyFilterValue(value)) {
|
|
64
70
|
const next = { ...prev };
|
|
65
71
|
delete next[key];
|
|
66
72
|
return next;
|
|
67
73
|
}
|
|
68
|
-
return { ...prev, [key]: value };
|
|
74
|
+
return { ...prev, [key]: value as ColumnFilterValue };
|
|
69
75
|
});
|
|
70
76
|
setCurrentPage(1);
|
|
71
77
|
},
|
package/src/index.ts
CHANGED
|
@@ -107,7 +107,7 @@ import type { ITSlideToggleProps } from "./components/atoms/slide/slide.props";
|
|
|
107
107
|
import type { ITSliderProps } from "./components/atoms/slider/slider.props";
|
|
108
108
|
import type { ITStackProps } from "./components/atoms/stack/stack.props";
|
|
109
109
|
import type { ITStatCardProps } from "./components/molecules/stat-card/stat-card.props";
|
|
110
|
-
import type { ITTableProps, Column } from "./components/molecules/table/table.props";
|
|
110
|
+
import type { ITTableProps, Column, ColumnFilterMode } from "./components/molecules/table/table.props";
|
|
111
111
|
import type { ITTextProps } from "./components/atoms/text/text.props";
|
|
112
112
|
import type { ITTextareaProps } from "./components/atoms/textarea/textarea.props";
|
|
113
113
|
import type { ITTabsProps, ITTabItem } from "./components/molecules/tabs/tabs.props";
|
|
@@ -115,7 +115,7 @@ import type { ITTripleFilterProps, ITTripleFilterOption } from "./components/org
|
|
|
115
115
|
import type { ITToastProps } from "./components/organisms/toast/toast.props";
|
|
116
116
|
import type { ITWysiwygProps } from "./components/molecules/wysiwyg/wysiwyg.props";
|
|
117
117
|
import type { FieldConfig, FieldConfigV2 } from "./types/field.types";
|
|
118
|
-
import type { TableDensity } from "./types/table.types";
|
|
118
|
+
import type { ColumnFilters, ColumnFilterValue, TableDensity } from "./types/table.types";
|
|
119
119
|
|
|
120
120
|
// UTILS
|
|
121
121
|
import ITDropfile, { UploadStatus, FileTypeEnum } from "./components/organisms/dropfile/dropfile";
|
|
@@ -157,7 +157,7 @@ export {
|
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
export type {
|
|
160
|
-
Column, FieldConfig,
|
|
160
|
+
Column, ColumnFilters, ColumnFilterMode, ColumnFilterValue, FieldConfig,
|
|
161
161
|
FieldConfigV2,
|
|
162
162
|
ITAccordionItem, ITAccordionProps,
|
|
163
163
|
ITAlertProps, ITAvatarProps, ITBadgetProps,
|