@ainias42/react-bootstrap-mobile 1.0.4 → 1.0.6
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 +2 -2
- package/dist/Components/ActionSheet/ActionSheet.stories.d.ts +3 -3
- package/dist/Components/Card/Card.d.ts +1 -1
- package/dist/Components/Card/Card.stories.d.ts +2 -2
- package/dist/Components/Clickable/Clickable.d.ts +2 -2
- package/dist/Components/Dialog/AlertDialog.stories.d.ts +1 -1
- package/dist/Components/Dialog/ButtonDialog.d.ts +2 -2
- package/dist/Components/Dialog/ConfirmDialog.stories.d.ts +2 -2
- package/dist/Components/Dialog/Dialog.d.ts +1 -1
- package/dist/Components/Dialog/DialogBackground.d.ts +1 -1
- package/dist/Components/Dialog/DialogContainer.d.ts +1 -1
- package/dist/Components/Dialog/DialogContext.d.ts +1 -1
- package/dist/Components/DragAndDrop/DragItem.d.ts +1 -1
- package/dist/Components/DragAndDrop/DropArea.d.ts +1 -1
- package/dist/Components/FormElements/Button/Button.d.ts +9 -6
- package/dist/Components/FormElements/Button/Button.stories.d.ts +12 -6
- package/dist/Components/FormElements/CheckBox/Checkbox.d.ts +2 -2
- package/dist/Components/FormElements/CheckBox/Checkbox.stories.d.ts +1 -1
- package/dist/Components/FormElements/ColorInput/ColorInput.d.ts +1 -1
- package/dist/Components/FormElements/ColorInput/ColorInput.stories.d.ts +1 -1
- package/dist/Components/FormElements/Controller/ColorInputController.d.ts +1 -1
- package/dist/Components/FormElements/Controller/FileInputController.d.ts +1 -1
- package/dist/Components/FormElements/Controller/InputController.d.ts +1 -1
- package/dist/Components/FormElements/Controller/MultipleFileInputController.d.ts +1 -1
- package/dist/Components/FormElements/Controller/PasswordInputController.d.ts +1 -1
- package/dist/Components/FormElements/Controller/SelectController.d.ts +1 -1
- package/dist/Components/FormElements/Controller/SliderController.d.ts +1 -1
- package/dist/Components/FormElements/Controller/SwitchController.d.ts +1 -1
- package/dist/Components/FormElements/Controller/TextareaController.d.ts +1 -1
- package/dist/Components/FormElements/Error/FormError.stories.d.ts +1 -1
- package/dist/Components/FormElements/Form.stories.d.ts +1 -1
- package/dist/Components/FormElements/Input/FileInput/FileInput.d.ts +5 -5
- package/dist/Components/FormElements/Input/FileInput/MultipleFileInput.d.ts +4 -4
- package/dist/Components/FormElements/Input/HiddenInput.d.ts +1 -1
- package/dist/Components/FormElements/Input/HiddenInput.stories.d.ts +1 -1
- package/dist/Components/FormElements/Input/Input.d.ts +3 -3
- package/dist/Components/FormElements/Input/Input.stories.d.ts +1 -1
- package/dist/Components/FormElements/Input/PasswordInput/PasswordInput.d.ts +2 -2
- package/dist/Components/FormElements/Input/PasswordInput/PasswordInput.stories.d.ts +1 -1
- package/dist/Components/FormElements/SearchSelectInput/SearchSelectInput.d.ts +3 -3
- package/dist/Components/FormElements/SearchSelectInput/SearchSelectInput.stories.d.ts +1 -1
- package/dist/Components/FormElements/Select/Select.d.ts +3 -3
- package/dist/Components/FormElements/Select/Select.stories.d.ts +1 -1
- package/dist/Components/FormElements/Slider/Slider.d.ts +3 -3
- package/dist/Components/FormElements/Slider/Slider.stories.d.ts +1 -1
- package/dist/Components/FormElements/Switch/Switch.d.ts +3 -3
- package/dist/Components/FormElements/Switch/Switch.stories.d.ts +1 -1
- package/dist/Components/FormElements/Textarea/Textarea.d.ts +3 -3
- package/dist/Components/FormElements/Textarea/Textarea.stories.d.ts +1 -1
- package/dist/Components/FullScreen/FullScreen.d.ts +2 -2
- package/dist/Components/Icon/BaseIcon.d.ts +15 -0
- package/dist/Components/Icon/DoubleIcon.d.ts +1 -1
- package/dist/Components/Icon/DoubleIcon.stories.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/Image/Image.d.ts +2 -2
- package/dist/Components/Image/Image.stories.d.ts +1 -1
- package/dist/Components/InViewport/InViewport.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/Container.d.ts +1 -1
- package/dist/Components/Layout/Flex.d.ts +8 -3
- package/dist/Components/Layout/Grid/Grid.d.ts +1 -1
- package/dist/Components/Layout/Grid/GridItem.d.ts +1 -1
- package/dist/Components/Layout/Grow.d.ts +1 -1
- package/dist/Components/Layout/Inline.d.ts +2 -2
- package/dist/Components/Layout/InlineBlock.d.ts +4 -10
- package/dist/Components/Layout/View.d.ts +4 -4
- package/dist/Components/Layout/ViewWithoutListeners.d.ts +1 -1
- package/dist/Components/LoadingArea/LoadingArea.d.ts +1 -1
- package/dist/Components/LoadingArea/LoadingArea.stories.d.ts +2 -2
- package/dist/Components/LoadingCircle/LoadingCircle.d.ts +2 -2
- package/dist/Components/LoadingCircle/LoadingCircle.stories.d.ts +2 -2
- package/dist/Components/Menu/HoverMenu.d.ts +1 -1
- package/dist/Components/Menu/HoverMenu.stories.d.ts +1 -1
- package/dist/Components/Menu/Menu.d.ts +2 -2
- package/dist/Components/Menu/Menu.stories.d.ts +1 -1
- package/dist/Components/Menu/MenuItem.d.ts +2 -2
- package/dist/Components/Menu/MenuItem.stories.d.ts +1 -1
- package/dist/Components/Menu/Submenu.d.ts +2 -2
- package/dist/Components/Menu/Submenu.stories.d.ts +1 -1
- package/dist/Components/Menu/useHoverMenu.d.ts +17 -0
- package/dist/Components/Menu/useMenu.d.ts +1 -1
- package/dist/Components/RbmComponentProps.d.ts +1 -1
- package/dist/Components/SizeCalculator/SizeCalculator.d.ts +1 -1
- package/dist/Components/SpoilerList/Spoiler/Spoiler.d.ts +3 -3
- package/dist/Components/SpoilerList/Spoiler/Spoiler.stories.d.ts +1 -1
- package/dist/Components/SpoilerList/SpoilerList.d.ts +1 -1
- package/dist/Components/TabBar/TabBar.d.ts +2 -2
- package/dist/Components/TabBar/TabBar.stories.d.ts +1 -1
- package/dist/Components/TabBar/TabBarButton.d.ts +2 -2
- package/dist/Components/Table/Table.d.ts +1 -1
- package/dist/Components/Text/Heading.d.ts +2 -2
- package/dist/Components/Text/Text.d.ts +2 -2
- package/dist/Components/Text/Text.stories.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/Toast/Toast.d.ts +2 -2
- package/dist/Components/Toast/Toast.stories.d.ts +1 -1
- package/dist/Components/Toast/ToastContainer.d.ts +2 -2
- package/dist/Components/TopBar/MoreButton.d.ts +1 -1
- package/dist/Components/TopBar/TopBar.d.ts +2 -2
- package/dist/Components/TopBar/TopBar.stories.d.ts +1 -1
- package/dist/Components/TopBar/TopBarButton.d.ts +1 -1
- package/dist/helper/withMemo.d.ts +1 -1
- package/dist/helper/withRestrictedChildren.d.ts +1 -1
- package/dist/index.css +4 -3
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +420 -205
- package/dist/index.js.map +1 -1
- package/eslint.config.js +1 -0
- package/package.json +1 -1
- package/src/Components/ActionSheet/ActionSheet.stories.tsx +3 -4
- package/src/Components/ActionSheet/ActionSheet.tsx +20 -18
- package/src/Components/Card/Card.stories.tsx +3 -4
- package/src/Components/Card/Card.tsx +3 -3
- package/src/Components/Clickable/Clickable.tsx +6 -6
- package/src/Components/Colors.stories.tsx +11 -12
- package/src/Components/Dialog/AlertDialog.stories.tsx +2 -2
- package/src/Components/Dialog/AlertDialog.tsx +2 -2
- package/src/Components/Dialog/ButtonDialog.tsx +15 -15
- package/src/Components/Dialog/ConfirmDialog.stories.tsx +3 -4
- package/src/Components/Dialog/ConfirmDialog.tsx +2 -2
- package/src/Components/Dialog/Dialog.tsx +10 -10
- package/src/Components/Dialog/DialogBackground.tsx +12 -12
- package/src/Components/Dialog/DialogContainer.tsx +7 -7
- package/src/Components/Dialog/DialogContext.ts +1 -1
- package/src/Components/Dialog/useAlertDialog.ts +2 -2
- package/src/Components/Dialog/useConfirmDialog.ts +2 -2
- package/src/Components/DragAndDrop/DragItem.tsx +2 -2
- package/src/Components/DragAndDrop/DropArea.tsx +3 -3
- package/src/Components/ErrorBoundary.tsx +5 -5
- package/src/Components/FormElements/Button/Button.stories.tsx +6 -6
- package/src/Components/FormElements/Button/Button.tsx +9 -9
- package/src/Components/FormElements/CheckBox/Checkbox.stories.tsx +1 -1
- package/src/Components/FormElements/CheckBox/Checkbox.tsx +6 -6
- package/src/Components/FormElements/ColorInput/ColorInput.stories.tsx +1 -1
- package/src/Components/FormElements/ColorInput/ColorInput.tsx +8 -8
- package/src/Components/FormElements/Controller/ColorInputController.ts +2 -2
- package/src/Components/FormElements/Controller/FileInputController.tsx +4 -4
- package/src/Components/FormElements/Controller/HookForm.tsx +4 -4
- package/src/Components/FormElements/Controller/InputController.ts +2 -2
- package/src/Components/FormElements/Controller/MultipleFileInputController.ts +2 -2
- package/src/Components/FormElements/Controller/PasswordInputController.ts +2 -2
- package/src/Components/FormElements/Controller/SelectController.ts +2 -2
- package/src/Components/FormElements/Controller/SliderController.ts +2 -2
- package/src/Components/FormElements/Controller/SwitchController.ts +2 -2
- package/src/Components/FormElements/Controller/TextareaController.ts +2 -2
- package/src/Components/FormElements/Controller/withHookController.tsx +2 -2
- package/src/Components/FormElements/Error/FormError.stories.tsx +1 -1
- package/src/Components/FormElements/Error/FormError.tsx +9 -9
- package/src/Components/FormElements/Form.stories.tsx +1 -1
- package/src/Components/FormElements/Input/FileInput/FileInput.tsx +8 -8
- package/src/Components/FormElements/Input/FileInput/MultipleFileInput.tsx +21 -21
- package/src/Components/FormElements/Input/HiddenInput.stories.tsx +1 -1
- package/src/Components/FormElements/Input/HiddenInput.tsx +4 -4
- package/src/Components/FormElements/Input/Input.stories.tsx +1 -1
- package/src/Components/FormElements/Input/Input.tsx +11 -11
- package/src/Components/FormElements/Input/PasswordInput/PasswordInput.stories.tsx +1 -1
- package/src/Components/FormElements/Input/PasswordInput/PasswordInput.tsx +10 -10
- package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.stories.tsx +2 -2
- package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.tsx +19 -19
- package/src/Components/FormElements/Select/Select.stories.tsx +1 -1
- package/src/Components/FormElements/Select/Select.tsx +7 -7
- package/src/Components/FormElements/Slider/Slider.stories.tsx +1 -1
- package/src/Components/FormElements/Slider/Slider.tsx +7 -7
- package/src/Components/FormElements/Switch/Switch.stories.tsx +1 -1
- package/src/Components/FormElements/Switch/Switch.tsx +7 -7
- package/src/Components/FormElements/Textarea/Textarea.stories.tsx +1 -1
- package/src/Components/FormElements/Textarea/Textarea.tsx +9 -9
- package/src/Components/FullScreen/FullScreen.tsx +4 -4
- package/src/Components/Hooks/useBreakpoint.ts +1 -1
- package/src/Components/Hooks/useDelayed.ts +5 -4
- package/src/Components/Hooks/useDelayedState.ts +1 -1
- package/src/Components/Hooks/useKeyListener.ts +1 -1
- package/src/Components/Hooks/useMousePosition.ts +1 -1
- package/src/Components/Hooks/useWindowDimensions.ts +1 -1
- package/src/Components/Icon/{Icon.tsx → BaseIcon.tsx} +10 -8
- package/src/Components/Icon/DoubleIcon.stories.tsx +1 -1
- package/src/Components/Icon/DoubleIcon.tsx +9 -9
- package/src/Components/Icon/Icon.stories.tsx +3 -3
- package/src/Components/Icon/Icon.ts +4 -0
- package/src/Components/Image/Image.stories.tsx +1 -1
- package/src/Components/Image/Image.tsx +4 -4
- package/src/Components/InViewport/InViewport.tsx +3 -3
- package/src/Components/Layout/{Block.tsx → BaseBlock.tsx} +8 -9
- package/src/Components/Layout/{InlineBlock.tsx → BaseInlineBlock.tsx} +6 -6
- package/src/Components/Layout/Block.ts +4 -0
- package/src/Components/Layout/Container.tsx +3 -3
- package/src/Components/Layout/Flex.tsx +21 -5
- package/src/Components/Layout/Grid/Grid.tsx +6 -6
- package/src/Components/Layout/Grid/GridItem.tsx +6 -6
- package/src/Components/Layout/Grow.tsx +3 -3
- package/src/Components/Layout/Inline.tsx +5 -5
- package/src/Components/Layout/InlineBlock.ts +4 -0
- package/src/Components/Layout/View.tsx +4 -4
- package/src/Components/Layout/ViewWithoutListeners.tsx +3 -3
- package/src/Components/Layout/layout.module.scss +13 -0
- package/src/Components/LoadingArea/LoadingArea.stories.tsx +5 -5
- package/src/Components/LoadingArea/LoadingArea.tsx +5 -5
- package/src/Components/LoadingCircle/LoadingCircle.stories.tsx +2 -2
- package/src/Components/LoadingCircle/LoadingCircle.tsx +4 -4
- package/src/Components/Menu/HoverMenu.stories.tsx +5 -5
- package/src/Components/Menu/HoverMenu.tsx +13 -33
- package/src/Components/Menu/Menu.stories.tsx +5 -5
- package/src/Components/Menu/Menu.tsx +12 -12
- package/src/Components/Menu/MenuDivider.tsx +4 -4
- package/src/Components/Menu/MenuItem.stories.tsx +1 -1
- package/src/Components/Menu/MenuItem.tsx +12 -12
- package/src/Components/Menu/Submenu.stories.tsx +3 -3
- package/src/Components/Menu/Submenu.tsx +16 -16
- package/src/Components/Menu/menu.module.scss +3 -2
- package/src/Components/Menu/useHoverMenu.ts +36 -0
- package/src/Components/Menu/useMenu.ts +1 -1
- package/src/Components/RbmComponentProps.ts +1 -1
- package/src/Components/SizeCalculator/SizeCalculator.tsx +5 -5
- package/src/Components/SpoilerList/Spoiler/Spoiler.stories.tsx +1 -1
- package/src/Components/SpoilerList/Spoiler/Spoiler.tsx +18 -18
- package/src/Components/SpoilerList/SpoilerList.tsx +7 -7
- package/src/Components/TabBar/TabBar.stories.tsx +1 -1
- package/src/Components/TabBar/TabBar.tsx +11 -11
- package/src/Components/TabBar/TabBarButton.tsx +5 -5
- package/src/Components/Table/Table.tsx +2 -2
- package/src/Components/Text/Heading.tsx +5 -5
- package/src/Components/Text/Text.stories.tsx +1 -1
- package/src/Components/Text/Text.tsx +6 -6
- 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/Toast/Toast.stories.tsx +1 -1
- package/src/Components/Toast/Toast.tsx +6 -6
- package/src/Components/Toast/ToastContainer.tsx +7 -7
- package/src/Components/TopBar/MoreButton.tsx +7 -8
- package/src/Components/TopBar/TopBar.stories.tsx +1 -1
- package/src/Components/TopBar/TopBar.tsx +18 -18
- package/src/Components/TopBar/TopBarButton.tsx +3 -3
- package/src/WrongChildError.ts +1 -0
- package/src/helper/nonEmptyString.ts +1 -1
- package/src/helper/withMemo.ts +3 -3
- package/src/helper/withRestrictedChildren.tsx +5 -3
- package/src/index.ts +6 -0
- package/tsconfig.json +2 -8
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Inline } from '
|
|
2
|
+
import { Inline } from '../Layout/Inline';
|
|
3
3
|
import { JSX } from 'react/jsx-runtime';
|
|
4
|
-
import { WrongChildError } from '
|
|
4
|
+
import { WrongChildError } from '../../WrongChildError';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import styles from '
|
|
7
|
-
import type { InlineProps } from '
|
|
8
|
-
import type { Recursive, ValueOf } from '
|
|
9
|
-
import type { ViewProps } from '
|
|
6
|
+
import styles from './text.module.scss';
|
|
7
|
+
import type { InlineProps } from '../Layout/Inline';
|
|
8
|
+
import type { Recursive, ValueOf } from '../../TypeHelpers';
|
|
9
|
+
import type { ViewProps } from '../Layout/View';
|
|
10
10
|
import IntrinsicElements = JSX.IntrinsicElements;
|
|
11
11
|
|
|
12
12
|
export const TEXT_PRIO = {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { BaseInlineBlock } from '../Layout/BaseInlineBlock';
|
|
2
|
+
import { useClientLayoutEffect } from '../Hooks/useClientLayoutEffect';
|
|
3
|
+
import { useWindow } from '../../WindowContext/WindowContext';
|
|
4
|
+
import { withMemo } from '../../helper/withMemo';
|
|
5
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
6
|
+
import styles from './hoverTitle.module.scss';
|
|
7
|
+
import type { ReactElement, RefObject } from 'react';
|
|
8
|
+
|
|
9
|
+
export type HoverTitleProps = {
|
|
10
|
+
children: ReactElement | undefined;
|
|
11
|
+
baseElement: RefObject<HTMLElement | null>;
|
|
12
|
+
isOpen: boolean;
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const HoverTitle = withMemo(function HoverTitle({ children, baseElement, isOpen, onClose }: HoverTitleProps) {
|
|
17
|
+
// Refs
|
|
18
|
+
const titleRef = useRef<HTMLDivElement>(null);
|
|
19
|
+
|
|
20
|
+
// States/Variables/Selectors
|
|
21
|
+
const [top, setTop] = useState(0);
|
|
22
|
+
const [left, setLeft] = useState(0);
|
|
23
|
+
|
|
24
|
+
const window = useWindow();
|
|
25
|
+
|
|
26
|
+
// Callbacks
|
|
27
|
+
|
|
28
|
+
// Effects
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!isOpen) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const listener = (e: MouseEvent | TouchEvent) => {
|
|
34
|
+
if (!titleRef.current?.contains(e.target as Node)) {
|
|
35
|
+
onClose();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
window?.addEventListener('mousedown', listener, { capture: true });
|
|
40
|
+
window?.addEventListener('touchstart', listener, { capture: true });
|
|
41
|
+
return () => {
|
|
42
|
+
window?.removeEventListener('mousedown', listener, { capture: true });
|
|
43
|
+
window?.removeEventListener('touchstart', listener, { capture: true });
|
|
44
|
+
};
|
|
45
|
+
}, [isOpen, onClose, window]);
|
|
46
|
+
|
|
47
|
+
useClientLayoutEffect(() => {
|
|
48
|
+
if (!titleRef.current || !baseElement.current || !isOpen) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const titleElement = titleRef.current;
|
|
52
|
+
const base = baseElement.current;
|
|
53
|
+
|
|
54
|
+
const updateInnerPositions = () => {
|
|
55
|
+
const computedStyleElement = base.getBoundingClientRect();
|
|
56
|
+
const computedStyleTitle = getComputedStyle(titleElement);
|
|
57
|
+
|
|
58
|
+
const height = Number.parseFloat(computedStyleTitle.height);
|
|
59
|
+
let newY = computedStyleElement.top - height;
|
|
60
|
+
if (newY < 0) {
|
|
61
|
+
newY = computedStyleElement.top + computedStyleElement.height;
|
|
62
|
+
}
|
|
63
|
+
setTop(Math.min(window?.innerHeight ?? 1600, newY));
|
|
64
|
+
|
|
65
|
+
const width = Number.parseFloat(computedStyleTitle.width);
|
|
66
|
+
let newX = computedStyleElement.left;
|
|
67
|
+
if (newX > (window?.innerWidth ?? 0) - width) {
|
|
68
|
+
newX -= width;
|
|
69
|
+
}
|
|
70
|
+
setLeft(Math.max(0, newX));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const observer = new ResizeObserver(() => {
|
|
74
|
+
updateInnerPositions();
|
|
75
|
+
});
|
|
76
|
+
observer.observe(titleElement);
|
|
77
|
+
observer.observe(base);
|
|
78
|
+
updateInnerPositions();
|
|
79
|
+
|
|
80
|
+
return () => {
|
|
81
|
+
observer.disconnect();
|
|
82
|
+
};
|
|
83
|
+
}, [window, baseElement, isOpen]);
|
|
84
|
+
|
|
85
|
+
// Other
|
|
86
|
+
|
|
87
|
+
// RenderFunctions
|
|
88
|
+
if (!isOpen || !children) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<BaseInlineBlock ref={titleRef} style={{ top, left }} className={styles.title}>
|
|
94
|
+
{children}
|
|
95
|
+
</BaseInlineBlock>
|
|
96
|
+
);
|
|
97
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { BaseIcon } from '../Icon/BaseIcon';
|
|
2
|
+
import { Block } from '../Layout/Block';
|
|
3
|
+
import { HoverMenu } from '../Menu/HoverMenu';
|
|
4
|
+
import { MenuDivider } from '../Menu/MenuDivider';
|
|
5
|
+
import { MenuItem } from '../Menu/MenuItem';
|
|
6
|
+
import { Submenu } from '../Menu/Submenu';
|
|
7
|
+
import { Text } from '../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 '../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 './HoverTitle';
|
|
2
|
+
import { TEXT_SIZE, Text } from '../Text/Text';
|
|
3
|
+
import { useComposedRef } from '../Hooks/useComposedRef';
|
|
4
|
+
import { useHoverMenu } from '../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, 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,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Clickable } from '
|
|
2
|
+
import { Clickable } from '../Clickable/Clickable';
|
|
3
3
|
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
-
import { useListener } from '
|
|
5
|
-
import { withMemo } from '
|
|
4
|
+
import { useListener } from '../Hooks/useListener';
|
|
5
|
+
import { withMemo } from '../../helper/withMemo';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import styles from '
|
|
8
|
-
import type { Listener, OptionalListener } from '
|
|
9
|
-
import type { RbmComponentProps, WithStringProps } from '
|
|
7
|
+
import styles from './toast.module.scss';
|
|
8
|
+
import type { Listener, OptionalListener } from '../Hooks/useListener';
|
|
9
|
+
import type { RbmComponentProps, WithStringProps } from '../RbmComponentProps';
|
|
10
10
|
import type { ReactNode } from 'react';
|
|
11
11
|
|
|
12
12
|
type WithoutActionProps<DismissedData> = {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Container } from '
|
|
2
|
+
import { Container } from '../Layout/Container';
|
|
3
3
|
import { ObjectHelper } from '@ainias42/js-helper';
|
|
4
|
-
import { Toast } from '
|
|
5
|
-
import { ToastContext } from '
|
|
4
|
+
import { Toast } from './Toast';
|
|
5
|
+
import { ToastContext } from './ToastContext';
|
|
6
6
|
import { useCallback, useRef, useState } from 'react';
|
|
7
|
-
import { withMemo } from '
|
|
7
|
+
import { withMemo } from '../../helper/withMemo';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
|
-
import styles from '
|
|
10
|
-
import type { EmptyProps } from '
|
|
11
|
-
import type { RbmComponentProps } from '
|
|
9
|
+
import styles from './toast.module.scss';
|
|
10
|
+
import type { EmptyProps } from '../../helper/EmptyProps';
|
|
11
|
+
import type { RbmComponentProps } from '../RbmComponentProps';
|
|
12
12
|
import type { URecord } from '@ainias42/js-helper';
|
|
13
13
|
|
|
14
14
|
export type ToastContainerProps = RbmComponentProps<EmptyProps>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { TopBarButton } from '
|
|
2
|
+
import { BaseIcon } from '../Icon/BaseIcon';
|
|
3
|
+
import { TopBarButton } from './TopBarButton';
|
|
4
4
|
import { faEllipsisH, faEllipsisV } from '@fortawesome/free-solid-svg-icons';
|
|
5
|
-
import { withMemo } from '
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import baseStyles from '@/scss/baseClasses.module.scss';
|
|
5
|
+
import { withMemo } from '../../helper/withMemo';
|
|
6
|
+
import baseStyles from '../../scss/baseClasses.module.scss';
|
|
7
|
+
import type { RbmComponentProps } from '../RbmComponentProps';
|
|
9
8
|
|
|
10
9
|
export type MoreButtonProps = RbmComponentProps<{
|
|
11
10
|
disabled?: boolean;
|
|
@@ -29,8 +28,8 @@ export const MoreButton = withMemo(function MoreButton({ onClick, disabled, clas
|
|
|
29
28
|
|
|
30
29
|
return (
|
|
31
30
|
<TopBarButton onClick={onClick} disabled={disabled} className={className} style={style}>
|
|
32
|
-
<
|
|
33
|
-
<
|
|
31
|
+
<BaseIcon icon={faEllipsisH} className={baseStyles.materialHidden} />
|
|
32
|
+
<BaseIcon icon={faEllipsisV} className={baseStyles.flatHidden} />
|
|
34
33
|
</TopBarButton>
|
|
35
34
|
);
|
|
36
35
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
|
|
3
|
-
import { TopBar } from '
|
|
3
|
+
import { TopBar } from './TopBar';
|
|
4
4
|
import { faCog, faHome, faSearch, faUser } from '@fortawesome/free-solid-svg-icons';
|
|
5
5
|
import { fn } from 'storybook/test';
|
|
6
6
|
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ActionSheet } from '
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { MoreButton } from '
|
|
6
|
-
import { TopBarButton } from '
|
|
2
|
+
import { ActionSheet } from '../ActionSheet/ActionSheet';
|
|
3
|
+
import { BaseIcon } from '../Icon/BaseIcon';
|
|
4
|
+
import { Container } from '../Layout/Container';
|
|
5
|
+
import { MoreButton } from './MoreButton';
|
|
6
|
+
import { TopBarButton } from './TopBarButton';
|
|
7
7
|
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
8
8
|
import type { ComponentType, ReactElement } from 'react';
|
|
9
|
-
import type { RbmComponentProps } from '
|
|
9
|
+
import type { RbmComponentProps } from '../RbmComponentProps';
|
|
10
10
|
|
|
11
|
-
import styles from '
|
|
11
|
+
import styles from './topBar.module.scss';
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import { Flex } from '
|
|
15
|
-
import { Inline } from '
|
|
16
|
-
import { Text } from '
|
|
17
|
-
import { View } from '
|
|
18
|
-
import { withMemo } from '
|
|
13
|
+
import { BaseBlock } from '../Layout/BaseBlock';
|
|
14
|
+
import { Flex } from '../Layout/Flex';
|
|
15
|
+
import { Inline } from '../Layout/Inline';
|
|
16
|
+
import { Text } from '../Text/Text';
|
|
17
|
+
import { View } from '../Layout/View';
|
|
18
|
+
import { withMemo } from '../../helper/withMemo';
|
|
19
19
|
import classNames from 'classnames';
|
|
20
|
-
import type { ActionSheetAction } from '
|
|
21
|
-
import type { IconSource } from '
|
|
20
|
+
import type { ActionSheetAction } from '../ActionSheet/ActionSheet';
|
|
21
|
+
import type { IconSource } from '../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>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { withMemo } from '
|
|
2
|
+
import { withMemo } from '../../helper/withMemo';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import styles from '
|
|
5
|
-
import type { RbmComponentProps } from '
|
|
4
|
+
import styles from './topBar.module.scss';
|
|
5
|
+
import type { RbmComponentProps } from '../RbmComponentProps';
|
|
6
6
|
|
|
7
7
|
export type TopBarButtonProps = RbmComponentProps<{
|
|
8
8
|
disabled?: boolean;
|
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
|
}
|
package/src/helper/withMemo.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { memoComparator } from '
|
|
2
|
-
import { withRestrictedChildren } from '
|
|
1
|
+
import { memoComparator } from './memoComparator';
|
|
2
|
+
import { withRestrictedChildren } from './withRestrictedChildren';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import type { ComponentType } from 'react';
|
|
5
|
-
import type { RESTRICT_CHILDREN } from '
|
|
5
|
+
import type { RESTRICT_CHILDREN } from './withRestrictedChildren';
|
|
6
6
|
|
|
7
7
|
export function withMemo<C extends ComponentType<any>>(
|
|
8
8
|
component: C,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WrongChildError } from '
|
|
1
|
+
import { WrongChildError } from '../WrongChildError';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { ComponentType, ReactElement } from 'react';
|
|
4
|
-
import type { RbmComponentProps } from '
|
|
4
|
+
import type { RbmComponentProps } from '../Components/RbmComponentProps';
|
|
5
5
|
|
|
6
6
|
export const RESTRICT_CHILDREN = {
|
|
7
7
|
allowChildren: undefined as undefined | 'all' | 'html' | 'text',
|
|
@@ -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
|
@@ -46,10 +46,13 @@ export * from './Components/Hooks/useOnce';
|
|
|
46
46
|
export * from './Components/Hooks/useOnMount';
|
|
47
47
|
export * from './Components/Hooks/useRerender';
|
|
48
48
|
export * from './Components/Hooks/useWindowDimensions';
|
|
49
|
+
export * from './Components/Icon/BaseIcon';
|
|
49
50
|
export * from './Components/Icon/DoubleIcon';
|
|
50
51
|
export * from './Components/Icon/Icon';
|
|
51
52
|
export * from './Components/Image/Image';
|
|
52
53
|
export * from './Components/InViewport/InViewport';
|
|
54
|
+
export * from './Components/Layout/BaseBlock';
|
|
55
|
+
export * from './Components/Layout/BaseInlineBlock';
|
|
53
56
|
export * from './Components/Layout/Block';
|
|
54
57
|
export * from './Components/Layout/Container';
|
|
55
58
|
export * from './Components/Layout/Flex';
|
|
@@ -66,6 +69,7 @@ export * from './Components/Menu/MenuCloseContext';
|
|
|
66
69
|
export * from './Components/Menu/MenuDivider';
|
|
67
70
|
export * from './Components/Menu/MenuItem';
|
|
68
71
|
export * from './Components/Menu/Submenu';
|
|
72
|
+
export * from './Components/Menu/useHoverMenu';
|
|
69
73
|
export * from './Components/Menu/useMenu';
|
|
70
74
|
export * from './Components/SizeCalculator/SizeCalculator';
|
|
71
75
|
export * from './Components/SpoilerList/SpoilerList';
|
|
@@ -75,6 +79,8 @@ export * from './Components/TabBar/TabBarButton';
|
|
|
75
79
|
export * from './Components/Table/Table';
|
|
76
80
|
export * from './Components/Text/Heading';
|
|
77
81
|
export * from './Components/Text/Text';
|
|
82
|
+
export * from './Components/Title/HoverTitle';
|
|
83
|
+
export * from './Components/Title/withTitle';
|
|
78
84
|
export * from './Components/Toast/Toast';
|
|
79
85
|
export * from './Components/Toast/ToastContainer';
|
|
80
86
|
export * from './Components/Toast/ToastContext';
|
package/tsconfig.json
CHANGED
|
@@ -3,13 +3,7 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"jsx": "react",
|
|
5
5
|
"outDir": "./dist",
|
|
6
|
-
"declaration": true
|
|
7
|
-
"baseUrl": "./",
|
|
8
|
-
"paths": {
|
|
9
|
-
"@/*": [
|
|
10
|
-
"src/*"
|
|
11
|
-
]
|
|
12
|
-
}
|
|
6
|
+
"declaration": true
|
|
13
7
|
},
|
|
14
8
|
"exclude": [
|
|
15
9
|
"../../node_modules",
|
|
@@ -19,6 +13,6 @@
|
|
|
19
13
|
"include": [
|
|
20
14
|
"src/**/*.tsx",
|
|
21
15
|
"src/**/*.ts",
|
|
22
|
-
|
|
16
|
+
".storybook/**/*.ts"
|
|
23
17
|
]
|
|
24
18
|
}
|