@ainias42/react-bootstrap-mobile 0.1.16 → 0.1.17
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 +1 -0
- package/dist/bootstrapReactMobile.d.ts +1 -0
- package/dist/bootstrapReactMobile.js +139 -54
- 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/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 +1 -1
- package/src/Components/Icon/Icon.tsx +13 -10
- package/src/Components/Icon/icon.scss +5 -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/scss/_colors.scss +1 -1
- package/src/scss/_flavorMixin.scss +8 -1
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { RbmComponentProps } from '../RbmComponentProps';
|
|
2
2
|
import { OptionalListener } from '../Hooks/useListener';
|
|
3
|
+
import { MouseEvent as ReactMouseEvent, MouseEvent } from 'react';
|
|
3
4
|
type OnClickListener<Data> = OptionalListener<'onClick', Data>;
|
|
4
5
|
type OnMouseDownListener<Data> = OptionalListener<'onMouseDown', Data>;
|
|
5
6
|
type OnMouseUpListener<Data> = OptionalListener<'onMouseUp', Data>;
|
|
6
7
|
type OnMouseMoveListener<Data> = OptionalListener<'onMouseMove', Data>;
|
|
7
8
|
type OnDropListener<Data> = OptionalListener<'onDrop', Data>;
|
|
8
9
|
type OnDragOverListener<Data> = OptionalListener<'onDragOver', Data>;
|
|
9
|
-
export type ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMouseUpData, OnClickCaptureData, OnDropData, OnDragOverData, OnMouseEnterData, OnMouseLeaveData, HrefType extends string | undefined> = RbmComponentProps<{
|
|
10
|
+
export type ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMouseUpData, OnClickCaptureData, OnDropData, OnDragOverData, OnMouseEnterData, OnMouseLeaveData, OnDoubleClickData, HrefType extends string | undefined> = RbmComponentProps<{
|
|
10
11
|
interactable?: boolean;
|
|
11
12
|
href?: HrefType;
|
|
12
13
|
preventDefault?: boolean;
|
|
13
14
|
stopPropagation?: boolean;
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
useReactOnMouseLeave?: boolean;
|
|
16
|
+
} & OnClickListener<OnClickData> & OnMouseDownListener<OnMouseDownData> & OnMouseMoveListener<OnMouseMoveData> & OnMouseUpListener<OnMouseUpData> & OnDropListener<OnDropData> & OnDragOverListener<OnDragOverData> & OptionalListener<'onClickCapture', OnClickCaptureData> & OptionalListener<'onMouseEnter', OnMouseEnterData> & OptionalListener<'onMouseLeave', OnMouseLeaveData, MouseEvent | ReactMouseEvent> & OptionalListener<'onDoubleClick', OnDoubleClickData>>;
|
|
17
|
+
declare const ClickableMemo: import("../../helper/withForwardRef").RefComponent<ClickableProps<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, string | undefined>, HTMLAnchorElement | HTMLSpanElement>;
|
|
16
18
|
export { ClickableMemo as Clickable };
|
|
@@ -2,6 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
import { RbmComponentProps, WithNoStringAndChildrenProps } from '../RbmComponentProps';
|
|
3
3
|
import { DraggableProps } from 'react-beautiful-dnd';
|
|
4
4
|
export type DragItemProps = RbmComponentProps<Omit<DraggableProps, 'children'>, WithNoStringAndChildrenProps>;
|
|
5
|
-
declare function DragItem({ children, ...dragProps }: DragItemProps): React.JSX.Element;
|
|
5
|
+
declare function DragItem({ children, className, ...dragProps }: DragItemProps): React.JSX.Element;
|
|
6
6
|
declare const DragItemMemo: typeof DragItem;
|
|
7
7
|
export { DragItemMemo as DragItem };
|
|
@@ -4,8 +4,10 @@ import { OptionalListener } from '../../Hooks/useListener';
|
|
|
4
4
|
import { HTMLAttributes } from 'react';
|
|
5
5
|
import { RbmComponentProps } from '../../RbmComponentProps';
|
|
6
6
|
import { ButtonType } from "./ButtonType";
|
|
7
|
+
import { Flavor } from "../../Flavor";
|
|
7
8
|
export type ButtonProps<ClickData> = RbmComponentProps<Override<HTMLAttributes<HTMLButtonElement>, {
|
|
8
9
|
type?: ButtonType;
|
|
9
10
|
disabled?: boolean;
|
|
11
|
+
flavor?: Flavor;
|
|
10
12
|
} & OptionalListener<'onClick', ClickData>>>;
|
|
11
|
-
export declare const Button: <ClickData>({ children, className, disabled, type, ...props }: ButtonProps<ClickData>) => React.JSX.Element;
|
|
13
|
+
export declare const Button: <ClickData>({ children, className, disabled, flavor, type, ...props }: ButtonProps<ClickData>) => React.JSX.Element;
|
|
@@ -2,6 +2,8 @@ import React from "react";
|
|
|
2
2
|
import { RbmChildWithoutString, RbmComponentProps, WithNoStringAndChildrenProps } from "../RbmComponentProps";
|
|
3
3
|
export type HoverMenuProps = RbmComponentProps<{
|
|
4
4
|
items: RbmChildWithoutString;
|
|
5
|
+
openToSide?: boolean;
|
|
5
6
|
onClick?: () => void;
|
|
7
|
+
onClose?: () => void;
|
|
6
8
|
}, WithNoStringAndChildrenProps>;
|
|
7
|
-
export declare const HoverMenu: ({ children, items, className, style, onClick, }: HoverMenuProps) => React.JSX.Element;
|
|
9
|
+
export declare const HoverMenu: ({ children, items, className, style, onClick, onClose, openToSide }: HoverMenuProps) => React.JSX.Element;
|
|
@@ -22,4 +22,5 @@ export type MenuProps = RbmComponentProps<{
|
|
|
22
22
|
offsetX?: number;
|
|
23
23
|
offsetY?: number;
|
|
24
24
|
}>;
|
|
25
|
+
export declare const MENU_CONTAINER_CLASS = "rbm-menu-container";
|
|
25
26
|
export declare const Menu: ({ className, style, items, y, x, isOpen, onClose, children, offsetY, offsetX, }: MenuProps) => React.JSX.Element | null;
|
|
@@ -6,5 +6,7 @@ export type SubmenuProps = RbmComponentProps<{
|
|
|
6
6
|
icon?: IconSource;
|
|
7
7
|
iconColor?: string;
|
|
8
8
|
disabled?: boolean;
|
|
9
|
+
onMouseEnter?: () => void;
|
|
10
|
+
onMouseLeave?: () => void;
|
|
9
11
|
}, WithNoStringAndChildrenProps>;
|
|
10
|
-
export declare const Submenu: ({ children, label, icon, iconColor, className, style, disabled }: SubmenuProps) => React.JSX.Element;
|
|
12
|
+
export declare const Submenu: ({ children, label, icon, iconColor, className, style, disabled, onMouseEnter, onMouseLeave, }: SubmenuProps) => React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -4,8 +4,9 @@ import {OptionalListener, useListener} from '../Hooks/useListener';
|
|
|
4
4
|
|
|
5
5
|
import styles from './clickable.scss';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import {useCallback, MouseEvent, ForwardedRef} from 'react';
|
|
7
|
+
import {useCallback, MouseEvent as ReactMouseEvent, ForwardedRef, useEffect, MouseEvent} from 'react';
|
|
8
8
|
import {withForwardRef} from '../../helper/withForwardRef';
|
|
9
|
+
import {useComposedRef} from "../Hooks/useComposedRef";
|
|
9
10
|
|
|
10
11
|
type OnClickListener<Data> = OptionalListener<'onClick', Data>;
|
|
11
12
|
type OnMouseDownListener<Data> = OptionalListener<'onMouseDown', Data>;
|
|
@@ -24,6 +25,7 @@ export type ClickableProps<
|
|
|
24
25
|
OnDragOverData,
|
|
25
26
|
OnMouseEnterData,
|
|
26
27
|
OnMouseLeaveData,
|
|
28
|
+
OnDoubleClickData,
|
|
27
29
|
HrefType extends string | undefined
|
|
28
30
|
> = RbmComponentProps<
|
|
29
31
|
{
|
|
@@ -31,6 +33,7 @@ export type ClickableProps<
|
|
|
31
33
|
href?: HrefType;
|
|
32
34
|
preventDefault?: boolean;
|
|
33
35
|
stopPropagation?: boolean;
|
|
36
|
+
useReactOnMouseLeave?: boolean;
|
|
34
37
|
} & OnClickListener<OnClickData> &
|
|
35
38
|
OnMouseDownListener<OnMouseDownData> &
|
|
36
39
|
OnMouseMoveListener<OnMouseMoveData> &
|
|
@@ -39,7 +42,8 @@ export type ClickableProps<
|
|
|
39
42
|
OnDragOverListener<OnDragOverData> &
|
|
40
43
|
OptionalListener<'onClickCapture', OnClickCaptureData> &
|
|
41
44
|
OptionalListener<'onMouseEnter', OnMouseEnterData> &
|
|
42
|
-
OptionalListener<'onMouseLeave', OnMouseLeaveData>
|
|
45
|
+
OptionalListener<'onMouseLeave', OnMouseLeaveData, MouseEvent|ReactMouseEvent> &
|
|
46
|
+
OptionalListener<'onDoubleClick', OnDoubleClickData>
|
|
43
47
|
>;
|
|
44
48
|
|
|
45
49
|
function Clickable<
|
|
@@ -52,6 +56,7 @@ function Clickable<
|
|
|
52
56
|
OnDragOverData,
|
|
53
57
|
OnMouseEnterData,
|
|
54
58
|
OnMouseLeaveData,
|
|
59
|
+
OnDoubleClickData,
|
|
55
60
|
HrefType extends string | undefined
|
|
56
61
|
>(
|
|
57
62
|
{
|
|
@@ -62,8 +67,9 @@ function Clickable<
|
|
|
62
67
|
interactable = true,
|
|
63
68
|
preventDefault = false,
|
|
64
69
|
stopPropagation = true,
|
|
70
|
+
useReactOnMouseLeave = false,
|
|
65
71
|
...clickData
|
|
66
|
-
}: ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMouseUpData, OnClickCaptureData, OnDropData, OnDragOverData,OnMouseEnterData, OnMouseLeaveData, HrefType>,
|
|
72
|
+
}: ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMouseUpData, OnClickCaptureData, OnDropData, OnDragOverData,OnMouseEnterData, OnMouseLeaveData, OnDoubleClickData, HrefType>,
|
|
67
73
|
ref: ForwardedRef<HrefType extends string ? HTMLAnchorElement : HTMLSpanElement>
|
|
68
74
|
) {
|
|
69
75
|
// Variables
|
|
@@ -71,11 +77,12 @@ function Clickable<
|
|
|
71
77
|
// States
|
|
72
78
|
|
|
73
79
|
// Refs
|
|
80
|
+
const clickableRef = useComposedRef(ref);
|
|
74
81
|
|
|
75
82
|
// Callbacks
|
|
76
83
|
const onClickInner = useListener<'onClick', OnClickData>('onClick', clickData);
|
|
77
84
|
const realOnClick = useCallback(
|
|
78
|
-
(e:
|
|
85
|
+
(e: ReactMouseEvent) => {
|
|
79
86
|
if (clickData.onClick) {
|
|
80
87
|
if (stopPropagation) {
|
|
81
88
|
e.stopPropagation();
|
|
@@ -91,7 +98,7 @@ function Clickable<
|
|
|
91
98
|
|
|
92
99
|
const onMouseDownInner = useListener<'onMouseDown', OnMouseDownData>('onMouseDown', clickData);
|
|
93
100
|
const realOnMouseDown = useCallback(
|
|
94
|
-
(e:
|
|
101
|
+
(e: ReactMouseEvent) => {
|
|
95
102
|
if (clickData.onMouseDown) {
|
|
96
103
|
if (stopPropagation) {
|
|
97
104
|
e.stopPropagation();
|
|
@@ -107,7 +114,7 @@ function Clickable<
|
|
|
107
114
|
|
|
108
115
|
const onMouseMoveInner = useListener<'onMouseMove', OnMouseMoveData>('onMouseMove', clickData);
|
|
109
116
|
const realOnMouseMove = useCallback(
|
|
110
|
-
(e:
|
|
117
|
+
(e: ReactMouseEvent) => {
|
|
111
118
|
if (clickData.onMouseMove) {
|
|
112
119
|
if (stopPropagation) {
|
|
113
120
|
e.stopPropagation();
|
|
@@ -123,7 +130,7 @@ function Clickable<
|
|
|
123
130
|
|
|
124
131
|
const onMouseUpInner = useListener<'onMouseUp', OnMouseUpData>('onMouseUp', clickData);
|
|
125
132
|
const realOnMouseUp = useCallback(
|
|
126
|
-
(e:
|
|
133
|
+
(e: ReactMouseEvent) => {
|
|
127
134
|
if (clickData.onMouseUp) {
|
|
128
135
|
if (stopPropagation) {
|
|
129
136
|
e.stopPropagation();
|
|
@@ -139,7 +146,7 @@ function Clickable<
|
|
|
139
146
|
|
|
140
147
|
const onClickCaptureInner = useListener<'onClickCapture', OnClickCaptureData>('onClickCapture', clickData);
|
|
141
148
|
const realOnClickCapture = useCallback(
|
|
142
|
-
(e:
|
|
149
|
+
(e: ReactMouseEvent) => {
|
|
143
150
|
if (clickData.onClickCapture) {
|
|
144
151
|
if (stopPropagation) {
|
|
145
152
|
e.stopPropagation();
|
|
@@ -155,7 +162,7 @@ function Clickable<
|
|
|
155
162
|
|
|
156
163
|
const onDropInner = useListener<'onDrop', OnDropData>('onDrop', clickData);
|
|
157
164
|
const realOnDrop = useCallback(
|
|
158
|
-
(e:
|
|
165
|
+
(e: ReactMouseEvent) => {
|
|
159
166
|
if (clickData.onDrop) {
|
|
160
167
|
if (stopPropagation) {
|
|
161
168
|
e.stopPropagation();
|
|
@@ -171,7 +178,7 @@ function Clickable<
|
|
|
171
178
|
|
|
172
179
|
const onDragOver = useListener<'onDragOver', OnDragOverData>('onDragOver', clickData);
|
|
173
180
|
const realOnDragOver = useCallback(
|
|
174
|
-
(e:
|
|
181
|
+
(e: ReactMouseEvent) => {
|
|
175
182
|
if (clickData.onDragOver) {
|
|
176
183
|
if (stopPropagation) {
|
|
177
184
|
e.stopPropagation();
|
|
@@ -187,7 +194,7 @@ function Clickable<
|
|
|
187
194
|
|
|
188
195
|
const onMouseEnter = useListener<'onMouseEnter', OnMouseEnterData>('onMouseEnter', clickData);
|
|
189
196
|
const realOnMouseEnter = useCallback(
|
|
190
|
-
(e:
|
|
197
|
+
(e: ReactMouseEvent) => {
|
|
191
198
|
if (clickData.onMouseEnter) {
|
|
192
199
|
if (stopPropagation) {
|
|
193
200
|
e.stopPropagation();
|
|
@@ -203,7 +210,7 @@ function Clickable<
|
|
|
203
210
|
|
|
204
211
|
const onMouseLeave = useListener<'onMouseLeave', OnMouseLeaveData>('onMouseLeave', clickData);
|
|
205
212
|
const realOnMouseLeave = useCallback(
|
|
206
|
-
(e:
|
|
213
|
+
(e: Event|ReactMouseEvent) => {
|
|
207
214
|
if (clickData.onMouseLeave) {
|
|
208
215
|
if (stopPropagation) {
|
|
209
216
|
e.stopPropagation();
|
|
@@ -217,7 +224,33 @@ function Clickable<
|
|
|
217
224
|
[clickData.onMouseLeave, onMouseLeave, preventDefault, stopPropagation]
|
|
218
225
|
);
|
|
219
226
|
|
|
227
|
+
const onDoubleClick = useListener<'onDoubleClick', OnDoubleClickData>('onDoubleClick', clickData);
|
|
228
|
+
const realOnDoubleClick = useCallback(
|
|
229
|
+
(e: Event|ReactMouseEvent) => {
|
|
230
|
+
if (clickData.onDoubleClick) {
|
|
231
|
+
if (stopPropagation) {
|
|
232
|
+
e.stopPropagation();
|
|
233
|
+
}
|
|
234
|
+
if (preventDefault) {
|
|
235
|
+
e.preventDefault();
|
|
236
|
+
}
|
|
237
|
+
onDoubleClick(e);
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
[clickData.onDoubleClick, onDoubleClick, preventDefault, stopPropagation]
|
|
241
|
+
);
|
|
242
|
+
|
|
220
243
|
// Effects
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
if (useReactOnMouseLeave) {
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
const elem = clickableRef.current;
|
|
249
|
+
elem?.addEventListener('mouseleave', realOnMouseLeave);
|
|
250
|
+
return () => {
|
|
251
|
+
elem?.removeEventListener('mouseleave', realOnMouseLeave);
|
|
252
|
+
};
|
|
253
|
+
}, [useReactOnMouseLeave, clickableRef, realOnMouseLeave]);
|
|
221
254
|
|
|
222
255
|
// Other
|
|
223
256
|
|
|
@@ -235,18 +268,19 @@ function Clickable<
|
|
|
235
268
|
onDrop: realOnDrop,
|
|
236
269
|
onDragOver: realOnDragOver,
|
|
237
270
|
onMouseEnter: realOnMouseEnter,
|
|
238
|
-
onMouseLeave: realOnMouseLeave,
|
|
271
|
+
onMouseLeave: useReactOnMouseLeave ? realOnMouseLeave : undefined,
|
|
272
|
+
onDoubleClick: realOnDoubleClick,
|
|
239
273
|
tabIndex: interactable ? 0 : undefined,
|
|
240
274
|
};
|
|
241
275
|
if (typeof href === 'string') {
|
|
242
276
|
return (
|
|
243
|
-
<a {...props} href={href} ref={
|
|
277
|
+
<a {...props} href={href} ref={clickableRef as ForwardedRef<HTMLAnchorElement>}>
|
|
244
278
|
{children}
|
|
245
279
|
</a>
|
|
246
280
|
);
|
|
247
281
|
}
|
|
248
282
|
return (
|
|
249
|
-
<span {...props} ref={
|
|
283
|
+
<span {...props} ref={clickableRef as ForwardedRef<HTMLSpanElement>}>
|
|
250
284
|
{children}
|
|
251
285
|
</span>
|
|
252
286
|
);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import {withMemo} from '../../helper/withMemo';
|
|
3
|
+
import {RbmComponentProps, WithNoStringAndChildrenProps} from '../RbmComponentProps';
|
|
4
|
+
import {Draggable, DraggableProps} from 'react-beautiful-dnd';
|
|
5
5
|
|
|
6
6
|
export type DragItemProps = RbmComponentProps<Omit<DraggableProps, 'children'>, WithNoStringAndChildrenProps>;
|
|
7
7
|
|
|
8
|
-
function DragItem({
|
|
8
|
+
function DragItem({children, className, ...dragProps}: DragItemProps) {
|
|
9
9
|
// Variables
|
|
10
10
|
|
|
11
11
|
// Refs
|
|
@@ -24,8 +24,8 @@ function DragItem({ children, ...dragProps }: DragItemProps) {
|
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
26
|
<Draggable {...dragProps}>
|
|
27
|
-
{({
|
|
28
|
-
<div {...draggableProps} {...dragHandleProps} ref={innerRef}>
|
|
27
|
+
{({innerRef, dragHandleProps, draggableProps}) => (
|
|
28
|
+
<div className={className} {...draggableProps} {...dragHandleProps} ref={innerRef}>
|
|
29
29
|
{children}
|
|
30
30
|
</div>
|
|
31
31
|
)}
|
|
@@ -35,4 +35,4 @@ function DragItem({ children, ...dragProps }: DragItemProps) {
|
|
|
35
35
|
|
|
36
36
|
// Need DragItemMemo for autocompletion of phpstorm
|
|
37
37
|
const DragItemMemo = withMemo(DragItem);
|
|
38
|
-
export {
|
|
38
|
+
export {DragItemMemo as DragItem};
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import {Override} from '@ainias42/js-helper';
|
|
3
|
+
import {OptionalListener, useListener, useListenerWithExtractedProps} from '../../Hooks/useListener';
|
|
4
4
|
|
|
5
5
|
import styles from './button.scss';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import {withMemo} from '../../../helper/withMemo';
|
|
8
|
+
import {HTMLAttributes} from 'react';
|
|
9
|
+
import {RbmComponentProps} from '../../RbmComponentProps';
|
|
10
10
|
import {ButtonType} from "./ButtonType";
|
|
11
|
+
import {Flavor} from "../../Flavor";
|
|
11
12
|
|
|
12
13
|
export type ButtonProps<ClickData> = RbmComponentProps<
|
|
13
14
|
Override<HTMLAttributes<HTMLButtonElement>, {
|
|
14
|
-
|
|
15
|
+
type?: ButtonType,
|
|
15
16
|
disabled?: boolean;
|
|
17
|
+
flavor?: Flavor
|
|
16
18
|
} & OptionalListener<'onClick', ClickData>>
|
|
17
19
|
>;
|
|
18
20
|
|
|
19
|
-
export const Button = withMemo(function Button<ClickData>({
|
|
20
|
-
|
|
21
|
+
export const Button = withMemo(function Button<ClickData>({
|
|
22
|
+
children,
|
|
23
|
+
className,
|
|
24
|
+
disabled,
|
|
25
|
+
flavor = Flavor.Accent,
|
|
26
|
+
type = ButtonType.Primary,
|
|
27
|
+
...props
|
|
28
|
+
}: ButtonProps<ClickData>) {
|
|
29
|
+
const [onClick, otherProps] = useListenerWithExtractedProps<'onClick', ClickData>('onClick', props);
|
|
21
30
|
|
|
22
31
|
const classes = {
|
|
23
32
|
[styles.primary]: type === ButtonType.Primary,
|
|
@@ -26,7 +35,8 @@ export const Button = withMemo(function Button<ClickData>({ children, className,
|
|
|
26
35
|
};
|
|
27
36
|
|
|
28
37
|
return (
|
|
29
|
-
<button {...
|
|
38
|
+
<button {...otherProps} disabled={disabled} type="button" onClick={onClick}
|
|
39
|
+
className={classNames(styles.button, classes, flavor, className)}>
|
|
30
40
|
{children}
|
|
31
41
|
</button>
|
|
32
42
|
);
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
padding-bottom: 2px;
|
|
22
22
|
|
|
23
23
|
&:focus {
|
|
24
|
-
background-image: linear-gradient(var(--flavor-
|
|
24
|
+
background-image: linear-gradient(var(--flavor-accent), var(--flavor-accent)),
|
|
25
25
|
linear-gradient(to top, transparent 1px, #afafaf 1px);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {FontAwesomeIcon, FontAwesomeIconProps} from '@fortawesome/react-fontawesome';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import {RbmComponentProps} from '../RbmComponentProps';
|
|
4
|
+
import {Override} from '../../TypeHelpers';
|
|
5
|
+
import {IconProp} from '@fortawesome/fontawesome-svg-core';
|
|
6
|
+
import {withMemo} from '../../helper/withMemo';
|
|
7
|
+
import {IconDefinition} from '@fortawesome/free-regular-svg-icons';
|
|
8
8
|
import classNames from "classnames";
|
|
9
9
|
|
|
10
10
|
import styles from "./icon.scss";
|
|
@@ -22,7 +22,7 @@ export type IconProps = RbmComponentProps<
|
|
|
22
22
|
>
|
|
23
23
|
>;
|
|
24
24
|
|
|
25
|
-
export const Icon = withMemo(function Icon({
|
|
25
|
+
export const Icon = withMemo(function Icon({icon, alt, className, noMargin = true, style, title, ...props}: IconProps) {
|
|
26
26
|
// Variables
|
|
27
27
|
|
|
28
28
|
// States
|
|
@@ -40,8 +40,11 @@ export const Icon = withMemo(function Icon({ icon, alt, className, noMargin=true
|
|
|
40
40
|
|
|
41
41
|
// Render Functions
|
|
42
42
|
|
|
43
|
-
if (typeof icon === 'string' && icon.indexOf('.') !== -1) {
|
|
44
|
-
return <img src={icon} alt={alt} className={classNames(className, {[styles.margin]: !noMargin})}
|
|
43
|
+
if (typeof icon === 'string' && (icon.indexOf('.') !== -1 || icon.startsWith("data:"))) {
|
|
44
|
+
return <img src={icon} alt={alt} className={classNames(styles.imgIcon, className, {[styles.margin]: !noMargin})}
|
|
45
|
+
style={style} title={title}/>;
|
|
45
46
|
}
|
|
46
|
-
return <FontAwesomeIcon {...props} icon={icon as IconProp}
|
|
47
|
+
return <FontAwesomeIcon {...props} icon={icon as IconProp}
|
|
48
|
+
className={classNames(className, {[styles.margin]: !noMargin})} style={style}
|
|
49
|
+
title={title}/>;
|
|
47
50
|
}, styles);
|
|
@@ -15,6 +15,31 @@ $columns: 12;
|
|
|
15
15
|
$breakpoints: $grid-breakpoints;
|
|
16
16
|
$containerBreakpoints: $grid-breakpoints;
|
|
17
17
|
|
|
18
|
+
@mixin printClasses {
|
|
19
|
+
@media print {
|
|
20
|
+
@for $i from 1 through $columns {
|
|
21
|
+
.item-print-#{$i} {
|
|
22
|
+
grid-column: auto / span $i;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Start with `1` because `0` is and invalid value.
|
|
27
|
+
// Ends with `$columns - 1` because offsetting by the width of an entire row isn't possible.
|
|
28
|
+
@for $i from 1 through ($columns - 1) {
|
|
29
|
+
.start-print-#{$i} {
|
|
30
|
+
grid-column-start: $i;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Add classes for reordering
|
|
35
|
+
@for $i from -10 through 10 {
|
|
36
|
+
.order-print-#{$i} {
|
|
37
|
+
order: $i;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
18
43
|
@mixin contentMin($breakpointName) {
|
|
19
44
|
@for $i from 1 through $columns {
|
|
20
45
|
.item-#{$breakpointName}-#{$i} {
|
|
@@ -81,6 +106,8 @@ $containerBreakpoints: $grid-breakpoints;
|
|
|
81
106
|
}
|
|
82
107
|
}
|
|
83
108
|
}
|
|
109
|
+
|
|
110
|
+
@include printClasses;
|
|
84
111
|
}
|
|
85
112
|
|
|
86
113
|
&:not(.useContainerWidth) {
|
|
@@ -110,28 +137,7 @@ $containerBreakpoints: $grid-breakpoints;
|
|
|
110
137
|
}
|
|
111
138
|
}
|
|
112
139
|
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
@media print {
|
|
116
|
-
@for $i from 1 through $columns {
|
|
117
|
-
.item-print-#{$i} {
|
|
118
|
-
grid-column: auto / span $i;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
140
|
|
|
122
|
-
|
|
123
|
-
// Ends with `$columns - 1` because offsetting by the width of an entire row isn't possible.
|
|
124
|
-
@for $i from 1 through ($columns - 1) {
|
|
125
|
-
.start-print-#{$i} {
|
|
126
|
-
grid-column-start: $i;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Add classes for reordering
|
|
131
|
-
@for $i from -10 through 10 {
|
|
132
|
-
.order-print-#{$i} {
|
|
133
|
-
order: $i;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
141
|
+
@include printClasses;
|
|
136
142
|
}
|
|
137
143
|
}
|
|
@@ -8,7 +8,9 @@ import {Menu} from "./Menu";
|
|
|
8
8
|
|
|
9
9
|
export type HoverMenuProps = RbmComponentProps<{
|
|
10
10
|
items: RbmChildWithoutString,
|
|
11
|
+
openToSide?: boolean;
|
|
11
12
|
onClick?: () => void;
|
|
13
|
+
onClose?: () => void;
|
|
12
14
|
}, WithNoStringAndChildrenProps>;
|
|
13
15
|
|
|
14
16
|
export const HoverMenu = withMemo(function HoverMenu({
|
|
@@ -17,6 +19,8 @@ export const HoverMenu = withMemo(function HoverMenu({
|
|
|
17
19
|
className,
|
|
18
20
|
style,
|
|
19
21
|
onClick,
|
|
22
|
+
onClose,
|
|
23
|
+
openToSide
|
|
20
24
|
}: HoverMenuProps) {
|
|
21
25
|
// Refs
|
|
22
26
|
|
|
@@ -34,14 +38,20 @@ export const HoverMenu = withMemo(function HoverMenu({
|
|
|
34
38
|
if (!hoverItemRef.current) {
|
|
35
39
|
return;
|
|
36
40
|
}
|
|
37
|
-
const {left, bottom, width, height} = hoverItemRef.current.getBoundingClientRect();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
const {top, left, bottom, right, width, height} = hoverItemRef.current.getBoundingClientRect();
|
|
42
|
+
if (openToSide) {
|
|
43
|
+
setPosition({x: right, y: top});
|
|
44
|
+
setOffset({x: width, y: -height});
|
|
45
|
+
} else {
|
|
46
|
+
setPosition({x: left, y: bottom});
|
|
47
|
+
setOffset({x: -width, y: height});
|
|
48
|
+
}
|
|
49
|
+
}, [openToSide]);
|
|
41
50
|
|
|
42
51
|
const close = useCallback(() => {
|
|
43
52
|
setIsOpen(false);
|
|
44
|
-
|
|
53
|
+
onClose?.();
|
|
54
|
+
}, [onClose]);
|
|
45
55
|
|
|
46
56
|
const open = useCallback(() => {
|
|
47
57
|
recalculatePosition();
|
|
@@ -57,6 +67,7 @@ export const HoverMenu = withMemo(function HoverMenu({
|
|
|
57
67
|
return <Clickable
|
|
58
68
|
onMouseEnter={open}
|
|
59
69
|
onMouseLeave={close}
|
|
70
|
+
useReactOnMouseLeave={true}
|
|
60
71
|
onClick={onClick}
|
|
61
72
|
className={classNames(styles.hoverMenu, {[styles.open]: isOpen}, className)}
|
|
62
73
|
style={style}
|
|
@@ -64,7 +75,7 @@ export const HoverMenu = withMemo(function HoverMenu({
|
|
|
64
75
|
__allowChildren="all"
|
|
65
76
|
>
|
|
66
77
|
{children}
|
|
67
|
-
<Menu x={position.x} y={position.y} isOpen={true} onClose={close} offsetX={offset.x} offsetY={offset.y}>
|
|
78
|
+
<Menu x={position.x} y={position.y} isOpen={true} onClose={close} offsetX={offset.x} offsetY={offset.y} className={classNames({[styles.hidden]: !isOpen})}>
|
|
68
79
|
{items}
|
|
69
80
|
</Menu>
|
|
70
81
|
</Clickable>;
|