@scripso-homepad/ui 0.4.23 → 0.4.25
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/{chunk-KJYQA5OY.js → chunk-N73KHOZ4.js} +13 -13
- package/dist/chunk-N73KHOZ4.js.map +1 -0
- package/dist/index.cjs +35 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -9
- package/dist/index.d.ts +11 -9
- package/dist/index.js +32 -14
- package/dist/index.js.map +1 -1
- package/dist/web/index.cjs +38 -78
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.css +9 -30
- package/dist/web/index.css.map +1 -1
- package/dist/web/index.d.cts +1 -3
- package/dist/web/index.d.ts +1 -3
- package/dist/web/index.js +38 -78
- package/dist/web/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CountryCodeSelector.tsx +3 -1
- package/src/components/Input.tsx +2 -2
- package/src/components/PhoneInput.tsx +23 -9
- package/src/components/Select.tsx +9 -1
- package/src/theme/tokens.ts +8 -8
- package/src/web/components/Modal.tsx +2 -1
- package/src/web/components/Table.stories.tsx +2 -2
- package/src/web/components/drawer-scroll.css +11 -2
- package/src/web/components/sonner-toast.css +1 -1
- package/src/web/components/table/TablePrimitives.tsx +3 -15
- package/src/web/components/table/TableScrollArea.tsx +1 -12
- package/src/web/components/table/constants.ts +0 -8
- package/src/web/components/table/index.ts +0 -3
- package/src/web/components/table-scroll.css +0 -27
- package/src/web/layout/BuildingSelect.tsx +46 -6
- package/dist/chunk-KJYQA5OY.js.map +0 -1
- package/src/web/components/table/use-horizontal-scroll-state.ts +0 -72
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
export type HorizontalScrollState = {
|
|
4
|
-
hasOverflow: boolean;
|
|
5
|
-
atEnd: boolean;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
9
|
-
|
|
10
|
-
function getHorizontalScrollState(element: HTMLElement): HorizontalScrollState {
|
|
11
|
-
const inner = element.firstElementChild as HTMLElement | null;
|
|
12
|
-
const table = inner?.querySelector('table');
|
|
13
|
-
const contentWidth = table?.scrollWidth ?? inner?.scrollWidth ?? element.scrollWidth;
|
|
14
|
-
const viewportWidth = element.clientWidth;
|
|
15
|
-
const maxScrollLeft = element.scrollWidth - element.clientWidth;
|
|
16
|
-
const hasOverflow = contentWidth > viewportWidth + 1;
|
|
17
|
-
const atEnd = !hasOverflow || element.scrollLeft >= maxScrollLeft - 1;
|
|
18
|
-
|
|
19
|
-
return { hasOverflow, atEnd };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function useHorizontalScrollState() {
|
|
23
|
-
const scrollRef = useRef<HTMLDivElement>(null);
|
|
24
|
-
const [scrollState, setScrollState] = useState<HorizontalScrollState>({
|
|
25
|
-
hasOverflow: false,
|
|
26
|
-
atEnd: true,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const updateScrollState = useCallback(() => {
|
|
30
|
-
const element = scrollRef.current;
|
|
31
|
-
if (!element) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
setScrollState(getHorizontalScrollState(element));
|
|
36
|
-
}, []);
|
|
37
|
-
|
|
38
|
-
useIsomorphicLayoutEffect(() => {
|
|
39
|
-
const element = scrollRef.current;
|
|
40
|
-
if (!element) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
updateScrollState();
|
|
45
|
-
|
|
46
|
-
element.addEventListener('scroll', updateScrollState, { passive: true });
|
|
47
|
-
|
|
48
|
-
if (typeof ResizeObserver === 'undefined') {
|
|
49
|
-
window.addEventListener('resize', updateScrollState);
|
|
50
|
-
|
|
51
|
-
return () => {
|
|
52
|
-
element.removeEventListener('scroll', updateScrollState);
|
|
53
|
-
window.removeEventListener('resize', updateScrollState);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const resizeObserver = new ResizeObserver(updateScrollState);
|
|
58
|
-
resizeObserver.observe(element);
|
|
59
|
-
|
|
60
|
-
const inner = element.firstElementChild;
|
|
61
|
-
if (inner) {
|
|
62
|
-
resizeObserver.observe(inner);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return () => {
|
|
66
|
-
element.removeEventListener('scroll', updateScrollState);
|
|
67
|
-
resizeObserver.disconnect();
|
|
68
|
-
};
|
|
69
|
-
}, [updateScrollState]);
|
|
70
|
-
|
|
71
|
-
return { scrollRef, scrollState };
|
|
72
|
-
}
|