@udixio/ui-react 2.8.0 → 2.8.2
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/CHANGELOG.md +20 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +1356 -1336
- package/dist/lib/components/FabMenu.d.ts.map +1 -1
- package/dist/lib/effects/block-scroll.effect.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/FabMenu.tsx +5 -2
- package/src/lib/effects/block-scroll.effect.tsx +62 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FabMenu.d.ts","sourceRoot":"","sources":["../../../src/lib/components/FabMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"FabMenu.d.ts","sourceRoot":"","sources":["../../../src/lib/components/FabMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAUhD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,+IAerB,UAAU,CAAC,gBAAgB,CAAC,4CAsM9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-scroll.effect.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/block-scroll.effect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,KAAK,YAAY,GACb;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,KAAK,CAAC;CACtB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEN,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,EAAE,EAAE,WAAW,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"block-scroll.effect.d.ts","sourceRoot":"","sources":["../../../src/lib/effects/block-scroll.effect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,KAAK,YAAY,GACb;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,KAAK,CAAC;CACtB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEN,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,EAAE,EAAE,WAAW,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAkNlD,CAAC"}
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import { classNames } from '../utils';
|
|
|
9
9
|
import { IconButton } from './IconButton';
|
|
10
10
|
import { faClose } from '@fortawesome/free-solid-svg-icons';
|
|
11
11
|
import { AnimatePresence, motion } from 'motion/react';
|
|
12
|
+
import { v4 } from 'uuid';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Floating action buttons (FABs) help people take primary actions
|
|
@@ -88,6 +89,8 @@ export const FabMenu = ({
|
|
|
88
89
|
/>
|
|
89
90
|
);
|
|
90
91
|
|
|
92
|
+
const [uuid] = useState(v4());
|
|
93
|
+
|
|
91
94
|
return (
|
|
92
95
|
<div className={styles.fabMenu} ref={resolvedRef} {...restProps}>
|
|
93
96
|
<AnimatePresence>
|
|
@@ -179,13 +182,13 @@ export const FabMenu = ({
|
|
|
179
182
|
renderFab({
|
|
180
183
|
className: '',
|
|
181
184
|
layout: true,
|
|
182
|
-
layoutId: 'fab-menu',
|
|
185
|
+
layoutId: 'fab-menu' + uuid,
|
|
183
186
|
})}
|
|
184
187
|
{open && (
|
|
185
188
|
<>
|
|
186
189
|
<MotionIconButton
|
|
187
190
|
layout
|
|
188
|
-
layoutId=
|
|
191
|
+
layoutId={'fab-menu' + uuid}
|
|
189
192
|
variant={'filled'}
|
|
190
193
|
className={() => ({
|
|
191
194
|
iconButton: classNames('', {
|
|
@@ -43,7 +43,46 @@ export const BlockScroll: React.FC<BlockScrollProps> = ({
|
|
|
43
43
|
onScroll?.(payload);
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
const findScrollableParent = (
|
|
47
|
+
node: HTMLElement | null,
|
|
48
|
+
): HTMLElement | null => {
|
|
49
|
+
let elNode: HTMLElement | null = node;
|
|
50
|
+
while (
|
|
51
|
+
elNode &&
|
|
52
|
+
elNode !== document.body &&
|
|
53
|
+
elNode !== document.documentElement
|
|
54
|
+
) {
|
|
55
|
+
const style = window.getComputedStyle(elNode);
|
|
56
|
+
const overflowY = style.overflowY || style.overflow;
|
|
57
|
+
const isScrollableY =
|
|
58
|
+
(overflowY === 'auto' || overflowY === 'scroll') &&
|
|
59
|
+
elNode.scrollHeight > elNode.clientHeight;
|
|
60
|
+
if (isScrollableY) return elNode;
|
|
61
|
+
elNode = elNode.parentElement;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
|
|
46
66
|
const onWheel = (e: WheelEvent) => {
|
|
67
|
+
// Auto-detect closest scrollable ancestor and allow native scroll when it can handle the intent
|
|
68
|
+
const target = e.target as HTMLElement | null;
|
|
69
|
+
|
|
70
|
+
const scrollableParent = findScrollableParent(target);
|
|
71
|
+
|
|
72
|
+
if (scrollableParent && scrollableParent !== el) {
|
|
73
|
+
const canScrollDown =
|
|
74
|
+
scrollableParent.scrollTop <
|
|
75
|
+
scrollableParent.scrollHeight - scrollableParent.clientHeight;
|
|
76
|
+
const canScrollUp = scrollableParent.scrollTop > 0;
|
|
77
|
+
|
|
78
|
+
// Wheel: positive deltaY => scroll down, negative => scroll up
|
|
79
|
+
if ((e.deltaY > 0 && canScrollDown) || (e.deltaY < 0 && canScrollUp)) {
|
|
80
|
+
// Let the native scrolling happen inside the scrollable element
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Otherwise, block native scroll and emit intent for global smooth scroll
|
|
47
86
|
e.preventDefault();
|
|
48
87
|
emitIntent({
|
|
49
88
|
type: 'intent',
|
|
@@ -64,9 +103,31 @@ export const BlockScroll: React.FC<BlockScrollProps> = ({
|
|
|
64
103
|
if (!touch) return;
|
|
65
104
|
const t = e.touches[0];
|
|
66
105
|
if (!t || !lastTouch.current) return;
|
|
67
|
-
|
|
106
|
+
|
|
68
107
|
const dx = lastTouch.current.x - t.clientX;
|
|
69
108
|
const dy = lastTouch.current.y - t.clientY;
|
|
109
|
+
|
|
110
|
+
// Auto-detect closest scrollable ancestor for touch and allow native scroll when possible
|
|
111
|
+
const target = e.target as HTMLElement | null;
|
|
112
|
+
|
|
113
|
+
const scrollableParent = findScrollableParent(target);
|
|
114
|
+
|
|
115
|
+
if (scrollableParent && scrollableParent !== el) {
|
|
116
|
+
const canScrollDown =
|
|
117
|
+
scrollableParent.scrollTop <
|
|
118
|
+
scrollableParent.scrollHeight - scrollableParent.clientHeight;
|
|
119
|
+
const canScrollUp = scrollableParent.scrollTop > 0;
|
|
120
|
+
|
|
121
|
+
// Touch: dy > 0 means user moves finger up -> intent to scroll down
|
|
122
|
+
if ((dy > 0 && canScrollDown) || (dy < 0 && canScrollUp)) {
|
|
123
|
+
// Update last touch and allow native scroll inside the element
|
|
124
|
+
lastTouch.current = { x: t.clientX, y: t.clientY };
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Otherwise block and emit intent for global smooth scroll
|
|
130
|
+
e.preventDefault();
|
|
70
131
|
lastTouch.current = { x: t.clientX, y: t.clientY };
|
|
71
132
|
emitIntent({
|
|
72
133
|
type: 'intent',
|