@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.
Files changed (247) hide show
  1. package/dist/Components/ActionSheet/ActionSheet.d.ts +2 -2
  2. package/dist/Components/ActionSheet/ActionSheet.stories.d.ts +3 -3
  3. package/dist/Components/Card/Card.d.ts +1 -1
  4. package/dist/Components/Card/Card.stories.d.ts +2 -2
  5. package/dist/Components/Clickable/Clickable.d.ts +2 -2
  6. package/dist/Components/Dialog/AlertDialog.stories.d.ts +1 -1
  7. package/dist/Components/Dialog/ButtonDialog.d.ts +2 -2
  8. package/dist/Components/Dialog/ConfirmDialog.stories.d.ts +2 -2
  9. package/dist/Components/Dialog/Dialog.d.ts +1 -1
  10. package/dist/Components/Dialog/DialogBackground.d.ts +1 -1
  11. package/dist/Components/Dialog/DialogContainer.d.ts +1 -1
  12. package/dist/Components/Dialog/DialogContext.d.ts +1 -1
  13. package/dist/Components/DragAndDrop/DragItem.d.ts +1 -1
  14. package/dist/Components/DragAndDrop/DropArea.d.ts +1 -1
  15. package/dist/Components/FormElements/Button/Button.d.ts +9 -6
  16. package/dist/Components/FormElements/Button/Button.stories.d.ts +12 -6
  17. package/dist/Components/FormElements/CheckBox/Checkbox.d.ts +2 -2
  18. package/dist/Components/FormElements/CheckBox/Checkbox.stories.d.ts +1 -1
  19. package/dist/Components/FormElements/ColorInput/ColorInput.d.ts +1 -1
  20. package/dist/Components/FormElements/ColorInput/ColorInput.stories.d.ts +1 -1
  21. package/dist/Components/FormElements/Controller/ColorInputController.d.ts +1 -1
  22. package/dist/Components/FormElements/Controller/FileInputController.d.ts +1 -1
  23. package/dist/Components/FormElements/Controller/InputController.d.ts +1 -1
  24. package/dist/Components/FormElements/Controller/MultipleFileInputController.d.ts +1 -1
  25. package/dist/Components/FormElements/Controller/PasswordInputController.d.ts +1 -1
  26. package/dist/Components/FormElements/Controller/SelectController.d.ts +1 -1
  27. package/dist/Components/FormElements/Controller/SliderController.d.ts +1 -1
  28. package/dist/Components/FormElements/Controller/SwitchController.d.ts +1 -1
  29. package/dist/Components/FormElements/Controller/TextareaController.d.ts +1 -1
  30. package/dist/Components/FormElements/Error/FormError.stories.d.ts +1 -1
  31. package/dist/Components/FormElements/Form.stories.d.ts +1 -1
  32. package/dist/Components/FormElements/Input/FileInput/FileInput.d.ts +5 -5
  33. package/dist/Components/FormElements/Input/FileInput/MultipleFileInput.d.ts +4 -4
  34. package/dist/Components/FormElements/Input/HiddenInput.d.ts +1 -1
  35. package/dist/Components/FormElements/Input/HiddenInput.stories.d.ts +1 -1
  36. package/dist/Components/FormElements/Input/Input.d.ts +3 -3
  37. package/dist/Components/FormElements/Input/Input.stories.d.ts +1 -1
  38. package/dist/Components/FormElements/Input/PasswordInput/PasswordInput.d.ts +2 -2
  39. package/dist/Components/FormElements/Input/PasswordInput/PasswordInput.stories.d.ts +1 -1
  40. package/dist/Components/FormElements/SearchSelectInput/SearchSelectInput.d.ts +3 -3
  41. package/dist/Components/FormElements/SearchSelectInput/SearchSelectInput.stories.d.ts +1 -1
  42. package/dist/Components/FormElements/Select/Select.d.ts +3 -3
  43. package/dist/Components/FormElements/Select/Select.stories.d.ts +1 -1
  44. package/dist/Components/FormElements/Slider/Slider.d.ts +3 -3
  45. package/dist/Components/FormElements/Slider/Slider.stories.d.ts +1 -1
  46. package/dist/Components/FormElements/Switch/Switch.d.ts +3 -3
  47. package/dist/Components/FormElements/Switch/Switch.stories.d.ts +1 -1
  48. package/dist/Components/FormElements/Textarea/Textarea.d.ts +3 -3
  49. package/dist/Components/FormElements/Textarea/Textarea.stories.d.ts +1 -1
  50. package/dist/Components/FullScreen/FullScreen.d.ts +2 -2
  51. package/dist/Components/Icon/BaseIcon.d.ts +15 -0
  52. package/dist/Components/Icon/DoubleIcon.d.ts +1 -1
  53. package/dist/Components/Icon/DoubleIcon.stories.d.ts +1 -1
  54. package/dist/Components/Icon/Icon.d.ts +4 -13
  55. package/dist/Components/Icon/Icon.stories.d.ts +1 -1
  56. package/dist/Components/Image/Image.d.ts +2 -2
  57. package/dist/Components/Image/Image.stories.d.ts +1 -1
  58. package/dist/Components/InViewport/InViewport.d.ts +1 -1
  59. package/dist/Components/Layout/BaseBlock.d.ts +10 -0
  60. package/dist/Components/Layout/BaseInlineBlock.d.ts +10 -0
  61. package/dist/Components/Layout/Block.d.ts +4 -10
  62. package/dist/Components/Layout/Container.d.ts +1 -1
  63. package/dist/Components/Layout/Flex.d.ts +8 -3
  64. package/dist/Components/Layout/Grid/Grid.d.ts +1 -1
  65. package/dist/Components/Layout/Grid/GridItem.d.ts +1 -1
  66. package/dist/Components/Layout/Grow.d.ts +1 -1
  67. package/dist/Components/Layout/Inline.d.ts +2 -2
  68. package/dist/Components/Layout/InlineBlock.d.ts +4 -10
  69. package/dist/Components/Layout/View.d.ts +4 -4
  70. package/dist/Components/Layout/ViewWithoutListeners.d.ts +1 -1
  71. package/dist/Components/LoadingArea/LoadingArea.d.ts +1 -1
  72. package/dist/Components/LoadingArea/LoadingArea.stories.d.ts +2 -2
  73. package/dist/Components/LoadingCircle/LoadingCircle.d.ts +2 -2
  74. package/dist/Components/LoadingCircle/LoadingCircle.stories.d.ts +2 -2
  75. package/dist/Components/Menu/HoverMenu.d.ts +1 -1
  76. package/dist/Components/Menu/HoverMenu.stories.d.ts +1 -1
  77. package/dist/Components/Menu/Menu.d.ts +2 -2
  78. package/dist/Components/Menu/Menu.stories.d.ts +1 -1
  79. package/dist/Components/Menu/MenuItem.d.ts +2 -2
  80. package/dist/Components/Menu/MenuItem.stories.d.ts +1 -1
  81. package/dist/Components/Menu/Submenu.d.ts +2 -2
  82. package/dist/Components/Menu/Submenu.stories.d.ts +1 -1
  83. package/dist/Components/Menu/useHoverMenu.d.ts +17 -0
  84. package/dist/Components/Menu/useMenu.d.ts +1 -1
  85. package/dist/Components/RbmComponentProps.d.ts +1 -1
  86. package/dist/Components/SizeCalculator/SizeCalculator.d.ts +1 -1
  87. package/dist/Components/SpoilerList/Spoiler/Spoiler.d.ts +3 -3
  88. package/dist/Components/SpoilerList/Spoiler/Spoiler.stories.d.ts +1 -1
  89. package/dist/Components/SpoilerList/SpoilerList.d.ts +1 -1
  90. package/dist/Components/TabBar/TabBar.d.ts +2 -2
  91. package/dist/Components/TabBar/TabBar.stories.d.ts +1 -1
  92. package/dist/Components/TabBar/TabBarButton.d.ts +2 -2
  93. package/dist/Components/Table/Table.d.ts +1 -1
  94. package/dist/Components/Text/Heading.d.ts +2 -2
  95. package/dist/Components/Text/Text.d.ts +2 -2
  96. package/dist/Components/Text/Text.stories.d.ts +1 -1
  97. package/dist/Components/Title/HoverTitle.d.ts +9 -0
  98. package/dist/Components/Title/Title.stories.d.ts +11 -0
  99. package/dist/Components/Title/withTitle.d.ts +6 -0
  100. package/dist/Components/Toast/Toast.d.ts +2 -2
  101. package/dist/Components/Toast/Toast.stories.d.ts +1 -1
  102. package/dist/Components/Toast/ToastContainer.d.ts +2 -2
  103. package/dist/Components/TopBar/MoreButton.d.ts +1 -1
  104. package/dist/Components/TopBar/TopBar.d.ts +2 -2
  105. package/dist/Components/TopBar/TopBar.stories.d.ts +1 -1
  106. package/dist/Components/TopBar/TopBarButton.d.ts +1 -1
  107. package/dist/helper/withMemo.d.ts +1 -1
  108. package/dist/helper/withRestrictedChildren.d.ts +1 -1
  109. package/dist/index.css +4 -3
  110. package/dist/index.css.map +1 -1
  111. package/dist/index.d.ts +6 -0
  112. package/dist/index.js +420 -205
  113. package/dist/index.js.map +1 -1
  114. package/eslint.config.js +1 -0
  115. package/package.json +1 -1
  116. package/src/Components/ActionSheet/ActionSheet.stories.tsx +3 -4
  117. package/src/Components/ActionSheet/ActionSheet.tsx +20 -18
  118. package/src/Components/Card/Card.stories.tsx +3 -4
  119. package/src/Components/Card/Card.tsx +3 -3
  120. package/src/Components/Clickable/Clickable.tsx +6 -6
  121. package/src/Components/Colors.stories.tsx +11 -12
  122. package/src/Components/Dialog/AlertDialog.stories.tsx +2 -2
  123. package/src/Components/Dialog/AlertDialog.tsx +2 -2
  124. package/src/Components/Dialog/ButtonDialog.tsx +15 -15
  125. package/src/Components/Dialog/ConfirmDialog.stories.tsx +3 -4
  126. package/src/Components/Dialog/ConfirmDialog.tsx +2 -2
  127. package/src/Components/Dialog/Dialog.tsx +10 -10
  128. package/src/Components/Dialog/DialogBackground.tsx +12 -12
  129. package/src/Components/Dialog/DialogContainer.tsx +7 -7
  130. package/src/Components/Dialog/DialogContext.ts +1 -1
  131. package/src/Components/Dialog/useAlertDialog.ts +2 -2
  132. package/src/Components/Dialog/useConfirmDialog.ts +2 -2
  133. package/src/Components/DragAndDrop/DragItem.tsx +2 -2
  134. package/src/Components/DragAndDrop/DropArea.tsx +3 -3
  135. package/src/Components/ErrorBoundary.tsx +5 -5
  136. package/src/Components/FormElements/Button/Button.stories.tsx +6 -6
  137. package/src/Components/FormElements/Button/Button.tsx +9 -9
  138. package/src/Components/FormElements/CheckBox/Checkbox.stories.tsx +1 -1
  139. package/src/Components/FormElements/CheckBox/Checkbox.tsx +6 -6
  140. package/src/Components/FormElements/ColorInput/ColorInput.stories.tsx +1 -1
  141. package/src/Components/FormElements/ColorInput/ColorInput.tsx +8 -8
  142. package/src/Components/FormElements/Controller/ColorInputController.ts +2 -2
  143. package/src/Components/FormElements/Controller/FileInputController.tsx +4 -4
  144. package/src/Components/FormElements/Controller/HookForm.tsx +4 -4
  145. package/src/Components/FormElements/Controller/InputController.ts +2 -2
  146. package/src/Components/FormElements/Controller/MultipleFileInputController.ts +2 -2
  147. package/src/Components/FormElements/Controller/PasswordInputController.ts +2 -2
  148. package/src/Components/FormElements/Controller/SelectController.ts +2 -2
  149. package/src/Components/FormElements/Controller/SliderController.ts +2 -2
  150. package/src/Components/FormElements/Controller/SwitchController.ts +2 -2
  151. package/src/Components/FormElements/Controller/TextareaController.ts +2 -2
  152. package/src/Components/FormElements/Controller/withHookController.tsx +2 -2
  153. package/src/Components/FormElements/Error/FormError.stories.tsx +1 -1
  154. package/src/Components/FormElements/Error/FormError.tsx +9 -9
  155. package/src/Components/FormElements/Form.stories.tsx +1 -1
  156. package/src/Components/FormElements/Input/FileInput/FileInput.tsx +8 -8
  157. package/src/Components/FormElements/Input/FileInput/MultipleFileInput.tsx +21 -21
  158. package/src/Components/FormElements/Input/HiddenInput.stories.tsx +1 -1
  159. package/src/Components/FormElements/Input/HiddenInput.tsx +4 -4
  160. package/src/Components/FormElements/Input/Input.stories.tsx +1 -1
  161. package/src/Components/FormElements/Input/Input.tsx +11 -11
  162. package/src/Components/FormElements/Input/PasswordInput/PasswordInput.stories.tsx +1 -1
  163. package/src/Components/FormElements/Input/PasswordInput/PasswordInput.tsx +10 -10
  164. package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.stories.tsx +2 -2
  165. package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.tsx +19 -19
  166. package/src/Components/FormElements/Select/Select.stories.tsx +1 -1
  167. package/src/Components/FormElements/Select/Select.tsx +7 -7
  168. package/src/Components/FormElements/Slider/Slider.stories.tsx +1 -1
  169. package/src/Components/FormElements/Slider/Slider.tsx +7 -7
  170. package/src/Components/FormElements/Switch/Switch.stories.tsx +1 -1
  171. package/src/Components/FormElements/Switch/Switch.tsx +7 -7
  172. package/src/Components/FormElements/Textarea/Textarea.stories.tsx +1 -1
  173. package/src/Components/FormElements/Textarea/Textarea.tsx +9 -9
  174. package/src/Components/FullScreen/FullScreen.tsx +4 -4
  175. package/src/Components/Hooks/useBreakpoint.ts +1 -1
  176. package/src/Components/Hooks/useDelayed.ts +5 -4
  177. package/src/Components/Hooks/useDelayedState.ts +1 -1
  178. package/src/Components/Hooks/useKeyListener.ts +1 -1
  179. package/src/Components/Hooks/useMousePosition.ts +1 -1
  180. package/src/Components/Hooks/useWindowDimensions.ts +1 -1
  181. package/src/Components/Icon/{Icon.tsx → BaseIcon.tsx} +10 -8
  182. package/src/Components/Icon/DoubleIcon.stories.tsx +1 -1
  183. package/src/Components/Icon/DoubleIcon.tsx +9 -9
  184. package/src/Components/Icon/Icon.stories.tsx +3 -3
  185. package/src/Components/Icon/Icon.ts +4 -0
  186. package/src/Components/Image/Image.stories.tsx +1 -1
  187. package/src/Components/Image/Image.tsx +4 -4
  188. package/src/Components/InViewport/InViewport.tsx +3 -3
  189. package/src/Components/Layout/{Block.tsx → BaseBlock.tsx} +8 -9
  190. package/src/Components/Layout/{InlineBlock.tsx → BaseInlineBlock.tsx} +6 -6
  191. package/src/Components/Layout/Block.ts +4 -0
  192. package/src/Components/Layout/Container.tsx +3 -3
  193. package/src/Components/Layout/Flex.tsx +21 -5
  194. package/src/Components/Layout/Grid/Grid.tsx +6 -6
  195. package/src/Components/Layout/Grid/GridItem.tsx +6 -6
  196. package/src/Components/Layout/Grow.tsx +3 -3
  197. package/src/Components/Layout/Inline.tsx +5 -5
  198. package/src/Components/Layout/InlineBlock.ts +4 -0
  199. package/src/Components/Layout/View.tsx +4 -4
  200. package/src/Components/Layout/ViewWithoutListeners.tsx +3 -3
  201. package/src/Components/Layout/layout.module.scss +13 -0
  202. package/src/Components/LoadingArea/LoadingArea.stories.tsx +5 -5
  203. package/src/Components/LoadingArea/LoadingArea.tsx +5 -5
  204. package/src/Components/LoadingCircle/LoadingCircle.stories.tsx +2 -2
  205. package/src/Components/LoadingCircle/LoadingCircle.tsx +4 -4
  206. package/src/Components/Menu/HoverMenu.stories.tsx +5 -5
  207. package/src/Components/Menu/HoverMenu.tsx +13 -33
  208. package/src/Components/Menu/Menu.stories.tsx +5 -5
  209. package/src/Components/Menu/Menu.tsx +12 -12
  210. package/src/Components/Menu/MenuDivider.tsx +4 -4
  211. package/src/Components/Menu/MenuItem.stories.tsx +1 -1
  212. package/src/Components/Menu/MenuItem.tsx +12 -12
  213. package/src/Components/Menu/Submenu.stories.tsx +3 -3
  214. package/src/Components/Menu/Submenu.tsx +16 -16
  215. package/src/Components/Menu/menu.module.scss +3 -2
  216. package/src/Components/Menu/useHoverMenu.ts +36 -0
  217. package/src/Components/Menu/useMenu.ts +1 -1
  218. package/src/Components/RbmComponentProps.ts +1 -1
  219. package/src/Components/SizeCalculator/SizeCalculator.tsx +5 -5
  220. package/src/Components/SpoilerList/Spoiler/Spoiler.stories.tsx +1 -1
  221. package/src/Components/SpoilerList/Spoiler/Spoiler.tsx +18 -18
  222. package/src/Components/SpoilerList/SpoilerList.tsx +7 -7
  223. package/src/Components/TabBar/TabBar.stories.tsx +1 -1
  224. package/src/Components/TabBar/TabBar.tsx +11 -11
  225. package/src/Components/TabBar/TabBarButton.tsx +5 -5
  226. package/src/Components/Table/Table.tsx +2 -2
  227. package/src/Components/Text/Heading.tsx +5 -5
  228. package/src/Components/Text/Text.stories.tsx +1 -1
  229. package/src/Components/Text/Text.tsx +6 -6
  230. package/src/Components/Title/HoverTitle.tsx +97 -0
  231. package/src/Components/Title/Title.stories.tsx +95 -0
  232. package/src/Components/Title/hoverTitle.module.scss +8 -0
  233. package/src/Components/Title/withTitle.module.scss +7 -0
  234. package/src/Components/Title/withTitle.tsx +48 -0
  235. package/src/Components/Toast/Toast.stories.tsx +1 -1
  236. package/src/Components/Toast/Toast.tsx +6 -6
  237. package/src/Components/Toast/ToastContainer.tsx +7 -7
  238. package/src/Components/TopBar/MoreButton.tsx +7 -8
  239. package/src/Components/TopBar/TopBar.stories.tsx +1 -1
  240. package/src/Components/TopBar/TopBar.tsx +18 -18
  241. package/src/Components/TopBar/TopBarButton.tsx +3 -3
  242. package/src/WrongChildError.ts +1 -0
  243. package/src/helper/nonEmptyString.ts +1 -1
  244. package/src/helper/withMemo.ts +3 -3
  245. package/src/helper/withRestrictedChildren.tsx +5 -3
  246. package/src/index.ts +6 -0
  247. package/tsconfig.json +2 -8
@@ -1,6 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
2
 
3
- import { TEXT_PRIO, TEXT_SIZE, Text } from '@/Components/Text/Text';
3
+ import { TEXT_PRIO, TEXT_SIZE, Text } from './Text';
4
4
  import React from 'react';
5
5
 
6
6
  const meta = {
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
- import { Inline } from '@/Components/Layout/Inline';
2
+ import { Inline } from '../Layout/Inline';
3
3
  import { JSX } from 'react/jsx-runtime';
4
- import { WrongChildError } from '@/WrongChildError';
4
+ import { WrongChildError } from '../../WrongChildError';
5
5
  import classNames from 'classnames';
6
- import styles from '@/Components/Text/text.module.scss';
7
- import type { InlineProps } from '@/Components/Layout/Inline';
8
- import type { Recursive, ValueOf } from '@/TypeHelpers';
9
- import type { ViewProps } from '@/Components/Layout/View';
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,8 @@
1
+ .title {
2
+ position: fixed;
3
+ background: var(--foreground-primary);
4
+ border: 1px solid var(--border-light);
5
+ border-radius: 2px;
6
+ z-index: 1002;
7
+ padding: 2px 4px;
8
+ }
@@ -0,0 +1,7 @@
1
+ .titleContainer {
2
+ padding: 2px 4px;
3
+ }
4
+
5
+ .noInteraction {
6
+ pointer-events: none;
7
+ }
@@ -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,4 +1,4 @@
1
- import { Toast } from '@/Components/Toast/Toast';
1
+ import { Toast } from './Toast';
2
2
  import { fn } from 'storybook/test';
3
3
  import type { Meta, StoryObj } from '@storybook/react-vite';
4
4
 
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
- import { Clickable } from '@/Components/Clickable/Clickable';
2
+ import { Clickable } from '../Clickable/Clickable';
3
3
  import { useCallback, useEffect, useState } from 'react';
4
- import { useListener } from '@/Components/Hooks/useListener';
5
- import { withMemo } from '@/helper/withMemo';
4
+ import { useListener } from '../Hooks/useListener';
5
+ import { withMemo } from '../../helper/withMemo';
6
6
  import classNames from 'classnames';
7
- import styles from '@/Components/Toast/toast.module.scss';
8
- import type { Listener, OptionalListener } from '@/Components/Hooks/useListener';
9
- import type { RbmComponentProps, WithStringProps } from '@/Components/RbmComponentProps';
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 '@/Components/Layout/Container';
2
+ import { Container } from '../Layout/Container';
3
3
  import { ObjectHelper } from '@ainias42/js-helper';
4
- import { Toast } from '@/Components/Toast/Toast';
5
- import { ToastContext } from '@/Components/Toast/ToastContext';
4
+ import { Toast } from './Toast';
5
+ import { ToastContext } from './ToastContext';
6
6
  import { useCallback, useRef, useState } from 'react';
7
- import { withMemo } from '@/helper/withMemo';
7
+ import { withMemo } from '../../helper/withMemo';
8
8
  import classNames from 'classnames';
9
- import styles from '@/Components/Toast/toast.module.scss';
10
- import type { EmptyProps } from '@/helper/EmptyProps';
11
- import type { RbmComponentProps } from '@/Components/RbmComponentProps';
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 { Icon } from '@/Components/Icon/Icon';
3
- import { TopBarButton } from '@/Components/TopBar/TopBarButton';
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 '@/helper/withMemo';
6
- import type { RbmComponentProps } from '@/Components/RbmComponentProps';
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
- <Icon icon={faEllipsisH} className={baseStyles.materialHidden} />
33
- <Icon icon={faEllipsisV} className={baseStyles.flatHidden} />
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 '@/Components/TopBar/TopBar';
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 '@/Components/ActionSheet/ActionSheet';
3
- import { Container } from '@/Components/Layout/Container';
4
- import { Icon } from '@/Components/Icon/Icon';
5
- import { MoreButton } from '@/Components/TopBar/MoreButton';
6
- import { TopBarButton } from '@/Components/TopBar/TopBarButton';
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 '@/Components/RbmComponentProps';
9
+ import type { RbmComponentProps } from '../RbmComponentProps';
10
10
 
11
- import styles from '@/Components/TopBar/topBar.module.scss';
11
+ import styles from './topBar.module.scss';
12
12
 
13
- import { Block } from '@/Components/Layout/Block';
14
- import { Flex } from '@/Components/Layout/Flex';
15
- import { Inline } from '@/Components/Layout/Inline';
16
- import { Text } from '@/Components/Text/Text';
17
- import { View } from '@/Components/Layout/View';
18
- import { withMemo } from '@/helper/withMemo';
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 '@/Components/ActionSheet/ActionSheet';
21
- import type { IconSource } from '@/Components/Icon/Icon';
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 = <Icon icon={button.icon} />;
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
- <Block className={styles.titleContainer}>
168
+ <BaseBlock className={styles.titleContainer}>
169
169
  <Text className={styles.title}>{title}</Text>
170
- </Block>
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 '@/helper/withMemo';
2
+ import { withMemo } from '../../helper/withMemo';
3
3
  import classNames from 'classnames';
4
- import styles from '@/Components/TopBar/topBar.module.scss';
5
- import type { RbmComponentProps } from '@/Components/RbmComponentProps';
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;
@@ -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
  }
@@ -1,4 +1,4 @@
1
- import { Characters } from '@/helper/Characters';
1
+ import { Characters } from './Characters';
2
2
 
3
3
  export function nonEmptyString(str: string | undefined | null, other = Characters.NBSP) {
4
4
  if (!str) {
@@ -1,8 +1,8 @@
1
- import { memoComparator } from '@/helper/memoComparator';
2
- import { withRestrictedChildren } from '@/helper/withRestrictedChildren';
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 '@/helper/withRestrictedChildren';
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 '@/WrongChildError';
1
+ import { WrongChildError } from '../WrongChildError';
2
2
  import React from 'react';
3
3
  import type { ComponentType, ReactElement } from 'react';
4
- import type { RbmComponentProps } from '@/Components/RbmComponentProps';
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)}>{children}</Component>
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
- ".storybook/**/*.ts"
16
+ ".storybook/**/*.ts"
23
17
  ]
24
18
  }