@axzydev/axzy_ui_system 1.3.1 → 1.3.3
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 +6 -2
- package/dist/index.cjs +957 -554
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.cts +191 -9
- package/dist/index.d.ts +191 -9
- package/dist/index.js +908 -505
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/App.tsx +150 -154
- package/src/components/molecules/table/table.doc.mdx +64 -21
- package/src/components/molecules/table/table.props.ts +81 -2
- package/src/components/molecules/table/table.stories.tsx +155 -0
- package/src/components/molecules/table/table.tsx +178 -36
- package/src/components/organisms/data-table/ITDataTable.doc.mdx +37 -3
- package/src/components/organisms/data-table/ITDataTable.stories.tsx +43 -0
- package/src/components/organisms/data-table/dataTable.props.ts +64 -0
- package/src/components/organisms/data-table/dataTable.tsx +241 -82
- package/src/components/organisms/sidebar/sidebar.doc.mdx +5 -0
- package/src/components/organisms/sidebar/sidebar.props.ts +5 -0
- package/src/components/organisms/sidebar/sidebar.stories.tsx +1 -1
- package/src/components/organisms/sidebar/sidebar.tsx +27 -7
- package/src/components/organisms/topbar/topbar.doc.mdx +3 -0
- package/src/components/organisms/topbar/topbar.props.ts +16 -0
- package/src/components/organisms/topbar/topbar.tsx +133 -98
- package/src/components/templates/layout/layout.doc.mdx +2 -0
- package/src/components/templates/layout/layout.tsx +7 -1
- package/src/components/templates/page/page.doc.mdx +8 -2
- package/src/components/templates/page/page.props.ts +11 -1
- package/src/components/templates/page/page.tsx +11 -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/dev.css +58 -1
- package/src/hooks/useElementSize.ts +46 -0
- package/src/hooks/useVirtualRows.ts +123 -0
- package/src/index.ts +2 -0
- package/src/sandbox/LandingShowcase.tsx +654 -0
- package/src/sandbox/NotFoundShowcase.tsx +70 -0
- package/src/sandbox/TopbarSearch.tsx +85 -0
- package/src/sandbox/navigation.ts +148 -0
- package/src/sandbox/useHashRoute.ts +149 -0
- package/src/showcases/DataShowcases.tsx +321 -24
- package/src/showcases/PageShowcases.tsx +31 -0
- package/src/showcases/StructureShowcases.tsx +42 -4
- package/src/theme/theme.types.ts +2 -0
- package/src/types/table.types.ts +48 -0
- package/src/utils/styles.ts +12 -5
- package/src/utils/table.utils.ts +31 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { useCallback, useLayoutEffect, useRef, useState, type RefObject } from "react";
|
|
2
|
+
|
|
3
|
+
/** Options for {@link useVirtualRows}. */
|
|
4
|
+
export interface UseVirtualRowsOptions {
|
|
5
|
+
/** Total number of rows in the dataset being windowed. */
|
|
6
|
+
count: number;
|
|
7
|
+
/** Assumed uniform row height in pixels. Values `<= 0` disable windowing. */
|
|
8
|
+
rowHeight: number;
|
|
9
|
+
/** Extra rows rendered above and below the viewport. @default 5 */
|
|
10
|
+
overscan?: number;
|
|
11
|
+
/** When `false`, no listeners are attached and the full range is returned. @default true */
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* When this value changes, `scrollTop` is reset to `0` both in state and on
|
|
15
|
+
* the scroll element. Pass a page/size signature so pagination resets scroll.
|
|
16
|
+
*/
|
|
17
|
+
resetKey?: string | number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Result of {@link useVirtualRows}. */
|
|
21
|
+
export interface UseVirtualRowsResult {
|
|
22
|
+
/** Attach to the scrollable container that holds the rows. */
|
|
23
|
+
scrollRef: RefObject<HTMLDivElement | null>;
|
|
24
|
+
/** First row index (inclusive) that should be rendered. */
|
|
25
|
+
startIndex: number;
|
|
26
|
+
/** Last row index (inclusive) that should be rendered. */
|
|
27
|
+
endIndex: number;
|
|
28
|
+
/** Pixel height of the top spacer row. */
|
|
29
|
+
topSpacerHeight: number;
|
|
30
|
+
/** Pixel height of the bottom spacer row. */
|
|
31
|
+
bottomSpacerHeight: number;
|
|
32
|
+
/** Current scroll offset in pixels. */
|
|
33
|
+
scrollTop: number;
|
|
34
|
+
/** Imperatively resets scroll to the top. */
|
|
35
|
+
scrollToTop: () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Zero-dependency row virtualizer for scroll containers. Tracks the scroll
|
|
40
|
+
* offset and viewport height of the element referenced by `scrollRef`, then
|
|
41
|
+
* computes the inclusive index window that must be rendered plus the spacer
|
|
42
|
+
* heights that preserve the full scroll height.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const { scrollRef, startIndex, endIndex, topSpacerHeight, bottomSpacerHeight } =
|
|
46
|
+
* useVirtualRows({ count: rows.length, rowHeight: 44, overscan: 5, enabled: virtualized, resetKey: page });
|
|
47
|
+
* // render rows.slice(startIndex, endIndex + 1) between spacer rows of the given heights
|
|
48
|
+
*/
|
|
49
|
+
export function useVirtualRows({
|
|
50
|
+
count,
|
|
51
|
+
rowHeight,
|
|
52
|
+
overscan = 5,
|
|
53
|
+
enabled = true,
|
|
54
|
+
resetKey,
|
|
55
|
+
}: UseVirtualRowsOptions): UseVirtualRowsResult {
|
|
56
|
+
const scrollRef = useRef<HTMLDivElement>(null);
|
|
57
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
58
|
+
const [viewportHeight, setViewportHeight] = useState(0);
|
|
59
|
+
|
|
60
|
+
const scrollToTop = useCallback(() => {
|
|
61
|
+
setScrollTop(0);
|
|
62
|
+
const element = scrollRef.current;
|
|
63
|
+
if (element) element.scrollTop = 0;
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
66
|
+
useLayoutEffect(() => {
|
|
67
|
+
if (!enabled) return;
|
|
68
|
+
const element = scrollRef.current;
|
|
69
|
+
if (!element) return;
|
|
70
|
+
|
|
71
|
+
const onScroll = () => setScrollTop(element.scrollTop);
|
|
72
|
+
const measure = () => setViewportHeight(element.clientHeight);
|
|
73
|
+
|
|
74
|
+
measure();
|
|
75
|
+
setScrollTop(element.scrollTop);
|
|
76
|
+
|
|
77
|
+
element.addEventListener("scroll", onScroll, { passive: true });
|
|
78
|
+
const observer = new ResizeObserver(measure);
|
|
79
|
+
observer.observe(element);
|
|
80
|
+
|
|
81
|
+
return () => {
|
|
82
|
+
element.removeEventListener("scroll", onScroll);
|
|
83
|
+
observer.disconnect();
|
|
84
|
+
};
|
|
85
|
+
}, [enabled]);
|
|
86
|
+
|
|
87
|
+
useLayoutEffect(() => {
|
|
88
|
+
if (!enabled) return;
|
|
89
|
+
const element = scrollRef.current;
|
|
90
|
+
if (element) element.scrollTop = 0;
|
|
91
|
+
setScrollTop(0);
|
|
92
|
+
}, [resetKey, enabled]);
|
|
93
|
+
|
|
94
|
+
const valid = enabled && rowHeight > 0 && count > 0;
|
|
95
|
+
const safeScrollTop = valid ? scrollTop : 0;
|
|
96
|
+
|
|
97
|
+
const startIndex = valid
|
|
98
|
+
? Math.min(count - 1, Math.max(0, Math.floor(safeScrollTop / rowHeight) - overscan))
|
|
99
|
+
: 0;
|
|
100
|
+
const endIndex = valid
|
|
101
|
+
? Math.min(
|
|
102
|
+
count - 1,
|
|
103
|
+
Math.ceil((safeScrollTop + viewportHeight) / rowHeight) + overscan
|
|
104
|
+
)
|
|
105
|
+
: Math.max(0, count - 1);
|
|
106
|
+
|
|
107
|
+
const topSpacerHeight = valid ? startIndex * rowHeight : 0;
|
|
108
|
+
const bottomSpacerHeight = valid
|
|
109
|
+
? Math.max(0, (count - 1 - endIndex) * rowHeight)
|
|
110
|
+
: 0;
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
scrollRef,
|
|
114
|
+
startIndex,
|
|
115
|
+
endIndex,
|
|
116
|
+
topSpacerHeight,
|
|
117
|
+
bottomSpacerHeight,
|
|
118
|
+
scrollTop: safeScrollTop,
|
|
119
|
+
scrollToTop,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default useVirtualRows;
|
package/src/index.ts
CHANGED
|
@@ -115,6 +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
119
|
|
|
119
120
|
// UTILS
|
|
120
121
|
import ITDropfile, { UploadStatus, FileTypeEnum } from "./components/organisms/dropfile/dropfile";
|
|
@@ -178,6 +179,7 @@ export {
|
|
|
178
179
|
ITSegmentedControlProps, ITSidebarProps, ITSkeletonProps, ITSlideToggleProps, ITSliderProps,
|
|
179
180
|
ITStackProps, ITStatCardProps, ITStepperProps,
|
|
180
181
|
ITTableProps, ITTabsProps, ITTabItem, ITTextProps, ITTextareaProps,
|
|
182
|
+
TableDensity,
|
|
181
183
|
ITTripleFilterProps, ITTripleFilterOption, ITThemeConfig, ITThemeProviderProps, ITThemePalette,
|
|
182
184
|
ITTimePickerProps, ITToastProps,
|
|
183
185
|
ITWysiwygProps,
|