@ainias42/react-bootstrap-mobile 1.0.3 → 1.0.5
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/Components/ActionSheet/ActionSheet.d.ts +1 -1
- package/dist/Components/ErrorBoundary.d.ts +18 -0
- package/dist/Components/FormElements/Button/Button.d.ts +4 -1
- package/dist/Components/FormElements/Button/Button.stories.d.ts +8 -2
- package/dist/Components/Icon/BaseIcon.d.ts +15 -0
- package/dist/Components/Icon/DoubleIcon.d.ts +1 -1
- package/dist/Components/Icon/Icon.d.ts +4 -13
- package/dist/Components/Icon/Icon.stories.d.ts +1 -1
- package/dist/Components/Layout/BaseBlock.d.ts +10 -0
- package/dist/Components/Layout/BaseInlineBlock.d.ts +10 -0
- package/dist/Components/Layout/Block.d.ts +4 -10
- package/dist/Components/Layout/Flex.d.ts +6 -1
- package/dist/Components/Layout/InlineBlock.d.ts +4 -10
- package/dist/Components/Layout/View.d.ts +1 -1
- package/dist/Components/Menu/Menu.d.ts +1 -1
- package/dist/Components/Menu/MenuItem.d.ts +1 -1
- package/dist/Components/Menu/Submenu.d.ts +1 -1
- package/dist/Components/Menu/useHoverMenu.d.ts +17 -0
- package/dist/Components/SpoilerList/Spoiler/Spoiler.d.ts +1 -1
- package/dist/Components/TabBar/TabBar.d.ts +1 -1
- package/dist/Components/Title/HoverTitle.d.ts +9 -0
- package/dist/Components/Title/Title.stories.d.ts +11 -0
- package/dist/Components/Title/withTitle.d.ts +6 -0
- package/dist/Components/TopBar/TopBar.d.ts +1 -1
- package/dist/index.css +6 -5
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +707 -447
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Components/ActionSheet/ActionSheet.tsx +12 -10
- package/src/Components/Colors.stories.tsx +7 -7
- package/src/Components/Dialog/ButtonDialog.tsx +9 -9
- package/src/Components/Dialog/Dialog.tsx +6 -6
- package/src/Components/Dialog/DialogBackground.tsx +5 -5
- package/src/Components/Dialog/DialogContainer.tsx +3 -3
- package/src/Components/ErrorBoundary.tsx +46 -0
- package/src/Components/FormElements/Button/Button.tsx +2 -2
- package/src/Components/FormElements/Error/FormError.tsx +6 -6
- package/src/Components/FormElements/Input/FileInput/MultipleFileInput.tsx +7 -7
- package/src/Components/FormElements/Input/PasswordInput/PasswordInput.tsx +2 -2
- package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.tsx +9 -9
- package/src/Components/Hooks/useDelayed.ts +5 -4
- package/src/Components/Icon/{Icon.tsx → BaseIcon.tsx} +6 -4
- package/src/Components/Icon/DoubleIcon.tsx +7 -7
- package/src/Components/Icon/Icon.stories.tsx +3 -3
- package/src/Components/Icon/Icon.ts +4 -0
- package/src/Components/Layout/{Block.tsx → BaseBlock.tsx} +2 -3
- package/src/Components/Layout/{InlineBlock.tsx → BaseInlineBlock.tsx} +2 -2
- package/src/Components/Layout/Block.ts +4 -0
- package/src/Components/Layout/Flex.tsx +16 -0
- package/src/Components/Layout/Grid/Grid.tsx +3 -3
- package/src/Components/Layout/Grid/GridItem.tsx +3 -3
- package/src/Components/Layout/InlineBlock.ts +4 -0
- package/src/Components/Layout/layout.module.scss +13 -0
- package/src/Components/LoadingArea/LoadingArea.stories.tsx +3 -3
- package/src/Components/Menu/HoverMenu.stories.tsx +3 -3
- package/src/Components/Menu/HoverMenu.tsx +8 -28
- package/src/Components/Menu/Menu.tsx +4 -4
- package/src/Components/Menu/MenuDivider.tsx +2 -2
- package/src/Components/Menu/MenuItem.tsx +6 -6
- package/src/Components/Menu/Submenu.tsx +7 -7
- package/src/Components/Menu/menu.module.scss +3 -2
- package/src/Components/Menu/useHoverMenu.ts +36 -0
- package/src/Components/SizeCalculator/SizeCalculator.tsx +3 -3
- package/src/Components/SpoilerList/Spoiler/Spoiler.tsx +9 -9
- package/src/Components/SpoilerList/SpoilerList.tsx +3 -3
- package/src/Components/TabBar/TabBar.tsx +3 -3
- package/src/Components/Title/HoverTitle.tsx +97 -0
- package/src/Components/Title/Title.stories.tsx +95 -0
- package/src/Components/Title/hoverTitle.module.scss +8 -0
- package/src/Components/Title/withTitle.module.scss +7 -0
- package/src/Components/Title/withTitle.tsx +48 -0
- package/src/Components/TopBar/MoreButton.tsx +3 -3
- package/src/Components/TopBar/TopBar.tsx +6 -6
- package/src/WrongChildError.ts +1 -0
- package/src/helper/withRestrictedChildren.tsx +3 -1
- package/src/index.ts +7 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { BaseIcon } from '@/Components/Icon/BaseIcon';
|
|
2
|
+
import { Block } from '@/Components/Layout/Block';
|
|
3
|
+
import { HoverMenu } from '@/Components/Menu/HoverMenu';
|
|
4
|
+
import { MenuDivider } from '@/Components/Menu/MenuDivider';
|
|
5
|
+
import { MenuItem } from '@/Components/Menu/MenuItem';
|
|
6
|
+
import { Submenu } from '@/Components/Menu/Submenu';
|
|
7
|
+
import { Text } from '@/Components/Text/Text';
|
|
8
|
+
import { faCog, faCogs, faHome, faUser } from '@fortawesome/free-solid-svg-icons';
|
|
9
|
+
import { fn } from 'storybook/test';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import type { HoverMenuProps } from '@/Components/Menu/HoverMenu';
|
|
12
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
13
|
+
|
|
14
|
+
const meta = {
|
|
15
|
+
args: {
|
|
16
|
+
title: 'This is a title',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default meta;
|
|
21
|
+
|
|
22
|
+
type Story = StoryObj<typeof meta>;
|
|
23
|
+
|
|
24
|
+
export const Default: Story = {
|
|
25
|
+
render: ({ title }: { title: string }) => {
|
|
26
|
+
return (
|
|
27
|
+
<Block title={title}>
|
|
28
|
+
<Text>Test</Text>
|
|
29
|
+
</Block>
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const WithElement: Story = {
|
|
35
|
+
render: ({ title }: { title: string }) => {
|
|
36
|
+
return (
|
|
37
|
+
<Block
|
|
38
|
+
title={
|
|
39
|
+
<Block style={{ background: 'red', padding: 4 }} title="Inner Title">
|
|
40
|
+
<Text>{title}</Text>
|
|
41
|
+
</Block>
|
|
42
|
+
}
|
|
43
|
+
>
|
|
44
|
+
<Text>Test</Text>
|
|
45
|
+
</Block>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const HoverMenuWithTitle: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
openToSide: false,
|
|
53
|
+
children: <BaseIcon icon={faCogs} />,
|
|
54
|
+
items: (
|
|
55
|
+
<>
|
|
56
|
+
<MenuItem onClick={fn()} icon={faHome}>
|
|
57
|
+
One
|
|
58
|
+
</MenuItem>
|
|
59
|
+
<MenuDivider />
|
|
60
|
+
<Submenu label="Submenu" icon={faCogs}>
|
|
61
|
+
<MenuItem onClick={fn()} icon={faHome}>
|
|
62
|
+
<Block title="Title">
|
|
63
|
+
<Text>Has Title</Text>
|
|
64
|
+
</Block>
|
|
65
|
+
</MenuItem>
|
|
66
|
+
<MenuItem onClick={fn()} icon={faHome}>
|
|
67
|
+
<Block title="Title">
|
|
68
|
+
<Text>Has Title</Text>
|
|
69
|
+
</Block>
|
|
70
|
+
</MenuItem>
|
|
71
|
+
<MenuItem onClick={fn()} icon={faUser}>
|
|
72
|
+
Sub Two
|
|
73
|
+
</MenuItem>
|
|
74
|
+
<MenuItem onClick={fn()} icon={faCog}>
|
|
75
|
+
Sub Three
|
|
76
|
+
</MenuItem>
|
|
77
|
+
</Submenu>
|
|
78
|
+
<MenuItem onClick={fn()} icon={faUser} disabled={true}>
|
|
79
|
+
Four
|
|
80
|
+
</MenuItem>
|
|
81
|
+
<MenuItem onClick={fn()} icon={faCog}>
|
|
82
|
+
Five
|
|
83
|
+
</MenuItem>
|
|
84
|
+
<MenuDivider />
|
|
85
|
+
<MenuItem iconColor="green" onClick={fn()} icon={faUser}>
|
|
86
|
+
Six
|
|
87
|
+
</MenuItem>
|
|
88
|
+
<MenuItem iconColor="green" onClick={fn()} icon={faCog} disabled={true}>
|
|
89
|
+
Seven
|
|
90
|
+
</MenuItem>
|
|
91
|
+
</>
|
|
92
|
+
),
|
|
93
|
+
},
|
|
94
|
+
render: (args: HoverMenuProps) => <HoverMenu {...args} />,
|
|
95
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { HoverTitle } from '@/Components/Title/HoverTitle';
|
|
2
|
+
import { TEXT_SIZE, Text } from '@/Components/Text/Text';
|
|
3
|
+
import { useComposedRef } from '@/Components/Hooks/useComposedRef';
|
|
4
|
+
import { useHoverMenu } from '@/Components/Menu/useHoverMenu';
|
|
5
|
+
import { withMemo } from '@/helper/withMemo';
|
|
6
|
+
import React, { useEffect, useRef } from 'react';
|
|
7
|
+
import type { FunctionComponent, ReactElement, Ref } from 'react';
|
|
8
|
+
|
|
9
|
+
export function withTitle<Props extends Record<string, any>>(Comp: FunctionComponent<Props>) {
|
|
10
|
+
return withMemo(
|
|
11
|
+
({
|
|
12
|
+
title,
|
|
13
|
+
ref,
|
|
14
|
+
...otherProps
|
|
15
|
+
}: Props & {
|
|
16
|
+
title?: string | ReactElement;
|
|
17
|
+
ref?: Ref<HTMLElement | null>;
|
|
18
|
+
}) => {
|
|
19
|
+
const titleRef = useRef<HTMLElement | null>(null);
|
|
20
|
+
const composedRef = useComposedRef(titleRef, ref);
|
|
21
|
+
const titleElement = typeof title === 'string' ? <Text size={TEXT_SIZE.small}>{title.trim()}</Text> : title;
|
|
22
|
+
const { isOpen, position, offset, open, close } = useHoverMenu({ ref: titleRef });
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const element = titleRef.current;
|
|
26
|
+
if (!element || !title) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
element.addEventListener('mouseenter', open);
|
|
30
|
+
element.addEventListener('mouseleave', close);
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
element.removeEventListener('mouseenter', open);
|
|
34
|
+
element.removeEventListener('mouseleave', close);
|
|
35
|
+
};
|
|
36
|
+
}, [close, open, title]);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<>
|
|
40
|
+
<Comp {...(otherProps as Props)} ref={composedRef} />
|
|
41
|
+
<HoverTitle baseElement={titleRef} isOpen={isOpen} onClose={close}>
|
|
42
|
+
{titleElement}
|
|
43
|
+
</HoverTitle>
|
|
44
|
+
</>
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseIcon } from '@/Components/Icon/BaseIcon';
|
|
3
3
|
import { TopBarButton } from '@/Components/TopBar/TopBarButton';
|
|
4
4
|
import { faEllipsisH, faEllipsisV } from '@fortawesome/free-solid-svg-icons';
|
|
5
5
|
import { withMemo } from '@/helper/withMemo';
|
|
@@ -29,8 +29,8 @@ export const MoreButton = withMemo(function MoreButton({ onClick, disabled, clas
|
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
31
|
<TopBarButton onClick={onClick} disabled={disabled} className={className} style={style}>
|
|
32
|
-
<
|
|
33
|
-
<
|
|
32
|
+
<BaseIcon icon={faEllipsisH} className={baseStyles.materialHidden} />
|
|
33
|
+
<BaseIcon icon={faEllipsisV} className={baseStyles.flatHidden} />
|
|
34
34
|
</TopBarButton>
|
|
35
35
|
);
|
|
36
36
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ActionSheet } from '@/Components/ActionSheet/ActionSheet';
|
|
3
|
+
import { BaseIcon } from '@/Components/Icon/BaseIcon';
|
|
3
4
|
import { Container } from '@/Components/Layout/Container';
|
|
4
|
-
import { Icon } from '@/Components/Icon/Icon';
|
|
5
5
|
import { MoreButton } from '@/Components/TopBar/MoreButton';
|
|
6
6
|
import { TopBarButton } from '@/Components/TopBar/TopBarButton';
|
|
7
7
|
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
@@ -10,7 +10,7 @@ import type { RbmComponentProps } from '@/Components/RbmComponentProps';
|
|
|
10
10
|
|
|
11
11
|
import styles from '@/Components/TopBar/topBar.module.scss';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { BaseBlock } from '@/Components/Layout/BaseBlock';
|
|
14
14
|
import { Flex } from '@/Components/Layout/Flex';
|
|
15
15
|
import { Inline } from '@/Components/Layout/Inline';
|
|
16
16
|
import { Text } from '@/Components/Text/Text';
|
|
@@ -18,7 +18,7 @@ import { View } from '@/Components/Layout/View';
|
|
|
18
18
|
import { withMemo } from '@/helper/withMemo';
|
|
19
19
|
import classNames from 'classnames';
|
|
20
20
|
import type { ActionSheetAction } from '@/Components/ActionSheet/ActionSheet';
|
|
21
|
-
import type { IconSource } from '@/Components/Icon/
|
|
21
|
+
import type { IconSource } from '@/Components/Icon/BaseIcon';
|
|
22
22
|
|
|
23
23
|
export type TopBarActionButtonType = {
|
|
24
24
|
order?: number;
|
|
@@ -53,7 +53,7 @@ function getButtonComponents(buttons: TopBarButtonType[]) {
|
|
|
53
53
|
}
|
|
54
54
|
let child: string | ReactElement | undefined = button.title;
|
|
55
55
|
if (button.icon) {
|
|
56
|
-
child = <
|
|
56
|
+
child = <BaseIcon icon={button.icon} />;
|
|
57
57
|
}
|
|
58
58
|
return (
|
|
59
59
|
<TopBarButton key={key} onClick={button.action} disabled={button.disabled} __allowChildren="all">
|
|
@@ -165,9 +165,9 @@ export const TopBar = withMemo(function TopBar({
|
|
|
165
165
|
<Flex grow={true} className={classNames(styles.buttonContainer, styles.left)} horizontal={true}>
|
|
166
166
|
{leftButtonComponents}
|
|
167
167
|
</Flex>
|
|
168
|
-
<
|
|
168
|
+
<BaseBlock className={styles.titleContainer}>
|
|
169
169
|
<Text className={styles.title}>{title}</Text>
|
|
170
|
-
</
|
|
170
|
+
</BaseBlock>
|
|
171
171
|
<Flex grow={true} className={classNames(styles.buttonContainer, styles.right)} horizontal={true}>
|
|
172
172
|
{rightButtonComponents}
|
|
173
173
|
</Flex>
|
package/src/WrongChildError.ts
CHANGED
|
@@ -11,6 +11,7 @@ export class WrongChildError extends Error {
|
|
|
11
11
|
super(
|
|
12
12
|
`Expected Children of type '${expectedType}' but got type '${gotType}' in component ${component}. Value of child is '${value}'`,
|
|
13
13
|
);
|
|
14
|
+
|
|
14
15
|
this.name = 'WrongChildError';
|
|
15
16
|
this.childValue = child;
|
|
16
17
|
}
|
|
@@ -46,7 +46,9 @@ export function withRestrictedChildren<C extends ComponentType<RbmComponentProps
|
|
|
46
46
|
return (
|
|
47
47
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
48
48
|
// @ts-ignore
|
|
49
|
-
<Component {...(newProps as Props)}
|
|
49
|
+
<Component {...(newProps as Props)} __allowChildren={__allowChildren}>
|
|
50
|
+
{children}
|
|
51
|
+
</Component>
|
|
50
52
|
);
|
|
51
53
|
};
|
|
52
54
|
hocComponent.displayName = displayName;
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './Size';
|
|
|
2
2
|
export * from './treeshakeTest';
|
|
3
3
|
export * from './TypeHelpers';
|
|
4
4
|
export * from './WrongChildError';
|
|
5
|
+
export * from './Components/ErrorBoundary';
|
|
5
6
|
export * from './Components/Flavor';
|
|
6
7
|
export * from './Components/RbmComponentProps';
|
|
7
8
|
export * from './helper/Characters';
|
|
@@ -45,10 +46,13 @@ export * from './Components/Hooks/useOnce';
|
|
|
45
46
|
export * from './Components/Hooks/useOnMount';
|
|
46
47
|
export * from './Components/Hooks/useRerender';
|
|
47
48
|
export * from './Components/Hooks/useWindowDimensions';
|
|
49
|
+
export * from './Components/Icon/BaseIcon';
|
|
48
50
|
export * from './Components/Icon/DoubleIcon';
|
|
49
51
|
export * from './Components/Icon/Icon';
|
|
50
52
|
export * from './Components/Image/Image';
|
|
51
53
|
export * from './Components/InViewport/InViewport';
|
|
54
|
+
export * from './Components/Layout/BaseBlock';
|
|
55
|
+
export * from './Components/Layout/BaseInlineBlock';
|
|
52
56
|
export * from './Components/Layout/Block';
|
|
53
57
|
export * from './Components/Layout/Container';
|
|
54
58
|
export * from './Components/Layout/Flex';
|
|
@@ -65,6 +69,7 @@ export * from './Components/Menu/MenuCloseContext';
|
|
|
65
69
|
export * from './Components/Menu/MenuDivider';
|
|
66
70
|
export * from './Components/Menu/MenuItem';
|
|
67
71
|
export * from './Components/Menu/Submenu';
|
|
72
|
+
export * from './Components/Menu/useHoverMenu';
|
|
68
73
|
export * from './Components/Menu/useMenu';
|
|
69
74
|
export * from './Components/SizeCalculator/SizeCalculator';
|
|
70
75
|
export * from './Components/SpoilerList/SpoilerList';
|
|
@@ -74,6 +79,8 @@ export * from './Components/TabBar/TabBarButton';
|
|
|
74
79
|
export * from './Components/Table/Table';
|
|
75
80
|
export * from './Components/Text/Heading';
|
|
76
81
|
export * from './Components/Text/Text';
|
|
82
|
+
export * from './Components/Title/HoverTitle';
|
|
83
|
+
export * from './Components/Title/withTitle';
|
|
77
84
|
export * from './Components/Toast/Toast';
|
|
78
85
|
export * from './Components/Toast/ToastContainer';
|
|
79
86
|
export * from './Components/Toast/ToastContext';
|