@udixio/ui-react 2.7.0 → 2.8.1
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 +1747 -1723
- package/dist/lib/components/FabMenu.d.ts +1 -1
- package/dist/lib/components/FabMenu.d.ts.map +1 -1
- package/dist/lib/effects/block-scroll.effect.d.ts.map +1 -1
- package/dist/lib/styles/fab.style.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/FabMenu.tsx +3 -3
- package/src/lib/effects/block-scroll.effect.tsx +62 -1
- package/src/lib/styles/fab.style.ts +13 -9
|
@@ -5,5 +5,5 @@ import { ReactProps } from '../utils/component';
|
|
|
5
5
|
* @status beta
|
|
6
6
|
* @category Action
|
|
7
7
|
*/
|
|
8
|
-
export declare const FabMenu: ({ className, label, variant, size, href,
|
|
8
|
+
export declare const FabMenu: ({ className, label, variant, size, href, icon, extended, ref, transition, children, open: openProp, defaultOpen, onOpenChange, ...restProps }: ReactProps<FabMenuInterface>) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
//# sourceMappingURL=FabMenu.d.ts.map
|
|
@@ -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;AAShD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,
|
|
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;AAShD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,+IAerB,UAAU,CAAC,gBAAgB,CAAC,4CAoM9B,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fab.style.d.ts","sourceRoot":"","sources":["../../../src/lib/styles/fab.style.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"fab.style.d.ts","sourceRoot":"","sources":["../../../src/lib/styles/fab.style.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAwC3D,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DAAoD,CAAC;AAE1E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;6DAAsD,CAAC"}
|
package/package.json
CHANGED
|
@@ -21,7 +21,6 @@ export const FabMenu = ({
|
|
|
21
21
|
variant = 'primary',
|
|
22
22
|
size = 'medium',
|
|
23
23
|
href,
|
|
24
|
-
type,
|
|
25
24
|
icon,
|
|
26
25
|
extended = false,
|
|
27
26
|
ref,
|
|
@@ -105,6 +104,7 @@ export const FabMenu = ({
|
|
|
105
104
|
|
|
106
105
|
const variants = {
|
|
107
106
|
open: {
|
|
107
|
+
overflow: 'visible',
|
|
108
108
|
opacity: 1,
|
|
109
109
|
width: 'auto',
|
|
110
110
|
transition: {
|
|
@@ -116,13 +116,14 @@ export const FabMenu = ({
|
|
|
116
116
|
},
|
|
117
117
|
},
|
|
118
118
|
close: {
|
|
119
|
+
overflow: 'hidden',
|
|
119
120
|
opacity: 0,
|
|
120
121
|
width: 0,
|
|
121
122
|
transition: {
|
|
122
123
|
...transition,
|
|
123
124
|
delay,
|
|
124
125
|
opacity: {
|
|
125
|
-
duration: transition?.duration /
|
|
126
|
+
duration: transition?.duration / 1.5,
|
|
126
127
|
},
|
|
127
128
|
},
|
|
128
129
|
},
|
|
@@ -132,7 +133,6 @@ export const FabMenu = ({
|
|
|
132
133
|
<motion.div
|
|
133
134
|
initial={'close'}
|
|
134
135
|
animate={'open'}
|
|
135
|
-
className={'overflow-hidden'}
|
|
136
136
|
variants={variants}
|
|
137
137
|
transition={transition}
|
|
138
138
|
exit={'close'}
|
|
@@ -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',
|
|
@@ -14,14 +14,14 @@ const fabConfig: ClassNameComponent<FabInterface> = ({
|
|
|
14
14
|
fab: classNames(
|
|
15
15
|
'flex shadow-3 hover:shadow-4 group/fab overflow-hidden outline-none items-center cursor-pointer',
|
|
16
16
|
{
|
|
17
|
-
'rounded-[12px]': size == 'small'
|
|
18
|
-
'rounded-[16px]': size == 'medium'
|
|
19
|
-
'rounded-[28px]': size == 'large'
|
|
17
|
+
'rounded-[12px]': size == 'small',
|
|
18
|
+
'rounded-[16px]': size == 'medium',
|
|
19
|
+
'rounded-[28px]': size == 'large',
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
|
-
'p-2': size == 'small'
|
|
23
|
-
'p-4': size == 'medium'
|
|
24
|
-
'p-[30px]': size == 'large'
|
|
22
|
+
'p-2': size == 'small',
|
|
23
|
+
'p-4': size == 'medium',
|
|
24
|
+
'p-[30px]': size == 'large',
|
|
25
25
|
},
|
|
26
26
|
variant === 'primary' && 'bg-primary text-on-primary',
|
|
27
27
|
variant === 'secondary' && 'bg-secondary text-on-secondary',
|
|
@@ -34,10 +34,14 @@ const fabConfig: ClassNameComponent<FabInterface> = ({
|
|
|
34
34
|
'bg-tertiary-container text-on-tertiary-container',
|
|
35
35
|
),
|
|
36
36
|
icon: classNames({
|
|
37
|
-
'size-6': size == 'small' || size == 'medium'
|
|
38
|
-
'size-9': size == 'large'
|
|
37
|
+
'size-6': size == 'small' || size == 'medium',
|
|
38
|
+
'size-9': size == 'large',
|
|
39
|
+
}),
|
|
40
|
+
label: classNames('text-nowrap', {
|
|
41
|
+
'text-title-medium': size == 'small',
|
|
42
|
+
'text-title-large': size == 'medium',
|
|
43
|
+
'text-headline-small': size == 'large',
|
|
39
44
|
}),
|
|
40
|
-
label: classNames('text-title-medium text-nowrap'),
|
|
41
45
|
});
|
|
42
46
|
|
|
43
47
|
export const fabStyle = defaultClassNames<FabInterface>('fab', fabConfig);
|