@ainias42/react-bootstrap-mobile 0.1.16 → 0.1.18
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/bin/updateCopies.js +1 -0
- package/bootstrapReactMobile.ts +2 -0
- package/dist/bootstrapReactMobile.d.ts +2 -0
- package/dist/bootstrapReactMobile.js +184 -55
- package/dist/bootstrapReactMobile.js.map +1 -1
- package/dist/src/Components/Clickable/Clickable.d.ts +5 -3
- package/dist/src/Components/DragAndDrop/DragItem.d.ts +1 -1
- package/dist/src/Components/Flavor.d.ts +4 -0
- package/dist/src/Components/FormElements/Button/Button.d.ts +3 -1
- package/dist/src/Components/Icon/DoubleIcon.d.ts +7 -0
- package/dist/src/Components/Menu/HoverMenu.d.ts +3 -1
- package/dist/src/Components/Menu/Menu.d.ts +1 -0
- package/dist/src/Components/Menu/Submenu.d.ts +3 -1
- package/dist/src/Components/Text/Text.d.ts +1 -0
- package/package.json +1 -1
- package/src/Components/Clickable/Clickable.tsx +49 -15
- package/src/Components/DragAndDrop/DragItem.tsx +7 -7
- package/src/Components/Flavor.ts +4 -0
- package/src/Components/FormElements/Button/Button.tsx +19 -9
- package/src/Components/FormElements/Input/input.scss +1 -1
- package/src/Components/FormElements/SearchSelectInput/seachSelectInput.scss +3 -1
- package/src/Components/Icon/DoubleIcon.tsx +34 -0
- package/src/Components/Icon/Icon.tsx +13 -10
- package/src/Components/Icon/icon.scss +16 -0
- package/src/Components/Layout/Grid/grid.scss +28 -22
- package/src/Components/Menu/HoverMenu.tsx +17 -6
- package/src/Components/Menu/Menu.tsx +47 -24
- package/src/Components/Menu/Submenu.tsx +9 -3
- package/src/Components/Menu/menu.scss +5 -1
- package/src/Components/Text/Text.tsx +1 -0
- package/src/Components/Text/text.scss +13 -5
- package/src/Components/Toast/toast.scss +1 -0
- package/src/scss/_colors.scss +1 -1
- package/src/scss/_flavorMixin.scss +8 -1
|
@@ -10,6 +10,7 @@ import {withRenderBrowserOnly} from '../../helper/withRenderBrowserOnly';
|
|
|
10
10
|
import {useWindow} from '../../WindowContext/WindowContext';
|
|
11
11
|
import {MenuItem} from "./MenuItem";
|
|
12
12
|
import {MenuCloseContextProvider} from "./MenuCloseContext";
|
|
13
|
+
import {createPortal} from "react-dom";
|
|
13
14
|
|
|
14
15
|
export type MenuItemType = {
|
|
15
16
|
label: string;
|
|
@@ -33,6 +34,8 @@ export type MenuProps = RbmComponentProps<
|
|
|
33
34
|
}
|
|
34
35
|
>;
|
|
35
36
|
|
|
37
|
+
export const MENU_CONTAINER_CLASS = "rbm-menu-container";
|
|
38
|
+
|
|
36
39
|
export const Menu = withMemo(
|
|
37
40
|
withRenderBrowserOnly(function Menu({
|
|
38
41
|
className,
|
|
@@ -53,6 +56,10 @@ export const Menu = withMemo(
|
|
|
53
56
|
const window = useWindow();
|
|
54
57
|
|
|
55
58
|
// States
|
|
59
|
+
const [portalContainer] = useState<HTMLDivElement>(() => {
|
|
60
|
+
return document.createElement('div');
|
|
61
|
+
});
|
|
62
|
+
|
|
56
63
|
const [innerX, setInnerX] = useState(x);
|
|
57
64
|
const [innerY, setInnerY] = useState(y);
|
|
58
65
|
|
|
@@ -74,6 +81,18 @@ export const Menu = withMemo(
|
|
|
74
81
|
return undefined;
|
|
75
82
|
}, [isOpen, onClose, window]);
|
|
76
83
|
|
|
84
|
+
useLayoutEffect(() => {
|
|
85
|
+
if (!isOpen) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
let elem = window?.document.body.querySelector("." + MENU_CONTAINER_CLASS);
|
|
89
|
+
if (!elem) {
|
|
90
|
+
elem = window?.document.body;
|
|
91
|
+
}
|
|
92
|
+
elem?.appendChild(portalContainer)
|
|
93
|
+
}, [isOpen, portalContainer, window?.document.body]);
|
|
94
|
+
|
|
95
|
+
|
|
77
96
|
useLayoutEffect(() => {
|
|
78
97
|
if (!menuRef.current) {
|
|
79
98
|
return;
|
|
@@ -81,7 +100,7 @@ export const Menu = withMemo(
|
|
|
81
100
|
const width = parseFloat(getComputedStyle(menuRef.current).width);
|
|
82
101
|
let newX = x;
|
|
83
102
|
if (newX > (window?.innerWidth ?? 0) - width) {
|
|
84
|
-
newX -= width+offsetX;
|
|
103
|
+
newX -= width + offsetX;
|
|
85
104
|
}
|
|
86
105
|
|
|
87
106
|
if (newX < 0) {
|
|
@@ -98,7 +117,7 @@ export const Menu = withMemo(
|
|
|
98
117
|
const height = parseFloat(getComputedStyle(menuRef.current).height);
|
|
99
118
|
let newY = y;
|
|
100
119
|
if (newY > (window?.innerHeight ?? 0) - height) {
|
|
101
|
-
newY -= height+offsetY;
|
|
120
|
+
newY -= height + offsetY;
|
|
102
121
|
}
|
|
103
122
|
|
|
104
123
|
if (newY < 0) {
|
|
@@ -116,28 +135,32 @@ export const Menu = withMemo(
|
|
|
116
135
|
}
|
|
117
136
|
|
|
118
137
|
return (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
<>
|
|
139
|
+
{createPortal(
|
|
140
|
+
<MenuCloseContextProvider value={onClose}>
|
|
141
|
+
<Block
|
|
142
|
+
className={classNames(className, styles.menu)}
|
|
143
|
+
style={{...style, top: innerY, left: innerX}}
|
|
144
|
+
ref={menuRef}
|
|
145
|
+
__allowChildren="all"
|
|
146
|
+
>
|
|
147
|
+
{items?.map((item) => {
|
|
148
|
+
const icon = (!!item.icon && typeof item.icon === "object" && "color" in item.icon) ? item.icon.icon : item.icon;
|
|
149
|
+
const iconColor = (!!item.icon && typeof item.icon === "object" && "color" in item.icon) ? item.icon.color : undefined;
|
|
150
|
+
|
|
151
|
+
return <MenuItem key={item.key}
|
|
152
|
+
onClick={item.callback}
|
|
153
|
+
className={classNames(styles.item, item.className)}
|
|
154
|
+
onMouseEnter={item.onMouseEnter}
|
|
155
|
+
icon={icon}
|
|
156
|
+
iconColor={iconColor}
|
|
157
|
+
onMouseLeave={item.onMouseLeave}>{item.label}</MenuItem>;
|
|
158
|
+
})}
|
|
159
|
+
{children}
|
|
160
|
+
</Block>
|
|
161
|
+
</MenuCloseContextProvider>
|
|
162
|
+
, portalContainer)}
|
|
163
|
+
</>
|
|
141
164
|
);
|
|
142
165
|
}),
|
|
143
166
|
styles
|
|
@@ -17,6 +17,8 @@ export type SubmenuProps = RbmComponentProps<{
|
|
|
17
17
|
label: string, icon?: IconSource;
|
|
18
18
|
iconColor?: string;
|
|
19
19
|
disabled?: boolean;
|
|
20
|
+
onMouseEnter?: () => void;
|
|
21
|
+
onMouseLeave?: () => void;
|
|
20
22
|
}, WithNoStringAndChildrenProps>;
|
|
21
23
|
|
|
22
24
|
export const Submenu = withMemo(function Submenu({
|
|
@@ -26,7 +28,9 @@ export const Submenu = withMemo(function Submenu({
|
|
|
26
28
|
iconColor,
|
|
27
29
|
className,
|
|
28
30
|
style,
|
|
29
|
-
disabled = false
|
|
31
|
+
disabled = false,
|
|
32
|
+
onMouseEnter,
|
|
33
|
+
onMouseLeave,
|
|
30
34
|
}: SubmenuProps) {
|
|
31
35
|
// Refs
|
|
32
36
|
|
|
@@ -52,11 +56,13 @@ export const Submenu = withMemo(function Submenu({
|
|
|
52
56
|
setOpenLeft(right + parseFloat(width) >= (window?.innerWidth ?? 0));
|
|
53
57
|
setOpenTop(top + parseFloat(height) >= (window?.innerHeight ?? 0));
|
|
54
58
|
setIsOpen(true);
|
|
55
|
-
|
|
59
|
+
onMouseEnter?.();
|
|
60
|
+
}, [onMouseEnter, window?.innerHeight, window?.innerWidth]);
|
|
56
61
|
|
|
57
62
|
const closeSubmenu = useCallback(() => {
|
|
58
63
|
setIsOpen(false);
|
|
59
|
-
|
|
64
|
+
onMouseLeave?.();
|
|
65
|
+
}, [onMouseLeave]);
|
|
60
66
|
|
|
61
67
|
const closeParent = useMenuClose();
|
|
62
68
|
const closeAllMenus = useCallback(() => {
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
border: 1px solid var(--border-light);
|
|
5
5
|
border-radius: 2px;
|
|
6
6
|
z-index: 1000;
|
|
7
|
+
|
|
8
|
+
&.hidden {
|
|
9
|
+
visibility: hidden;
|
|
10
|
+
}
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
.divider {
|
|
@@ -33,7 +37,7 @@
|
|
|
33
37
|
white-space: nowrap;
|
|
34
38
|
|
|
35
39
|
.icon {
|
|
36
|
-
|
|
40
|
+
margin-right: 4px;
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
$primaryColor: #
|
|
2
|
-
$secondaryColor: #
|
|
1
|
+
$primaryColor: #18181B; // Gray-900
|
|
2
|
+
$secondaryColor: #71717a; // Gray-500
|
|
3
|
+
$tertiaryColor: #A1A1AA; // Gray-400
|
|
3
4
|
|
|
4
5
|
:root {
|
|
5
|
-
--text-primary-default-color: $primaryColor;
|
|
6
|
+
--text-primary-default-color: #{$primaryColor};
|
|
7
|
+
--text-prmary: #{$primaryColor};
|
|
8
|
+
--text-secondary: #{$secondaryColor};
|
|
9
|
+
--text-tertiary: #{$tertiaryColor};
|
|
6
10
|
}
|
|
7
11
|
|
|
8
12
|
.text {
|
|
@@ -21,11 +25,15 @@ $secondaryColor: #717171;
|
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
&.primary {
|
|
24
|
-
color:
|
|
28
|
+
color: var(--text-primary)
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
&.secondary {
|
|
28
|
-
color:
|
|
32
|
+
color: var(--text-secondary);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.tertiary {
|
|
36
|
+
color: var(--text-tertiary);
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
&.xsmall {
|
package/src/scss/_colors.scss
CHANGED