@ainias42/react-bootstrap-mobile 1.0.4 → 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.
Files changed (76) hide show
  1. package/dist/Components/ActionSheet/ActionSheet.d.ts +1 -1
  2. package/dist/Components/FormElements/Button/Button.d.ts +4 -1
  3. package/dist/Components/FormElements/Button/Button.stories.d.ts +8 -2
  4. package/dist/Components/Icon/BaseIcon.d.ts +15 -0
  5. package/dist/Components/Icon/DoubleIcon.d.ts +1 -1
  6. package/dist/Components/Icon/Icon.d.ts +4 -13
  7. package/dist/Components/Icon/Icon.stories.d.ts +1 -1
  8. package/dist/Components/Layout/BaseBlock.d.ts +10 -0
  9. package/dist/Components/Layout/BaseInlineBlock.d.ts +10 -0
  10. package/dist/Components/Layout/Block.d.ts +4 -10
  11. package/dist/Components/Layout/Flex.d.ts +6 -1
  12. package/dist/Components/Layout/InlineBlock.d.ts +4 -10
  13. package/dist/Components/Menu/Menu.d.ts +1 -1
  14. package/dist/Components/Menu/MenuItem.d.ts +1 -1
  15. package/dist/Components/Menu/Submenu.d.ts +1 -1
  16. package/dist/Components/Menu/useHoverMenu.d.ts +17 -0
  17. package/dist/Components/SpoilerList/Spoiler/Spoiler.d.ts +1 -1
  18. package/dist/Components/TabBar/TabBar.d.ts +1 -1
  19. package/dist/Components/Title/HoverTitle.d.ts +9 -0
  20. package/dist/Components/Title/Title.stories.d.ts +11 -0
  21. package/dist/Components/Title/withTitle.d.ts +6 -0
  22. package/dist/Components/TopBar/TopBar.d.ts +1 -1
  23. package/dist/index.css +4 -3
  24. package/dist/index.css.map +1 -1
  25. package/dist/index.d.ts +6 -0
  26. package/dist/index.js +422 -205
  27. package/dist/index.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/Components/ActionSheet/ActionSheet.tsx +12 -10
  30. package/src/Components/Colors.stories.tsx +7 -7
  31. package/src/Components/Dialog/ButtonDialog.tsx +9 -9
  32. package/src/Components/Dialog/Dialog.tsx +6 -6
  33. package/src/Components/Dialog/DialogBackground.tsx +5 -5
  34. package/src/Components/Dialog/DialogContainer.tsx +3 -3
  35. package/src/Components/ErrorBoundary.tsx +3 -3
  36. package/src/Components/FormElements/Button/Button.tsx +2 -2
  37. package/src/Components/FormElements/Error/FormError.tsx +6 -6
  38. package/src/Components/FormElements/Input/FileInput/MultipleFileInput.tsx +7 -7
  39. package/src/Components/FormElements/Input/PasswordInput/PasswordInput.tsx +2 -2
  40. package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.tsx +9 -9
  41. package/src/Components/Hooks/useDelayed.ts +5 -4
  42. package/src/Components/Icon/{Icon.tsx → BaseIcon.tsx} +6 -4
  43. package/src/Components/Icon/DoubleIcon.tsx +7 -7
  44. package/src/Components/Icon/Icon.stories.tsx +3 -3
  45. package/src/Components/Icon/Icon.ts +4 -0
  46. package/src/Components/Layout/{Block.tsx → BaseBlock.tsx} +2 -3
  47. package/src/Components/Layout/{InlineBlock.tsx → BaseInlineBlock.tsx} +2 -2
  48. package/src/Components/Layout/Block.ts +4 -0
  49. package/src/Components/Layout/Flex.tsx +16 -0
  50. package/src/Components/Layout/Grid/Grid.tsx +3 -3
  51. package/src/Components/Layout/Grid/GridItem.tsx +3 -3
  52. package/src/Components/Layout/InlineBlock.ts +4 -0
  53. package/src/Components/Layout/layout.module.scss +13 -0
  54. package/src/Components/LoadingArea/LoadingArea.stories.tsx +3 -3
  55. package/src/Components/Menu/HoverMenu.stories.tsx +3 -3
  56. package/src/Components/Menu/HoverMenu.tsx +8 -28
  57. package/src/Components/Menu/Menu.tsx +4 -4
  58. package/src/Components/Menu/MenuDivider.tsx +2 -2
  59. package/src/Components/Menu/MenuItem.tsx +6 -6
  60. package/src/Components/Menu/Submenu.tsx +7 -7
  61. package/src/Components/Menu/menu.module.scss +3 -2
  62. package/src/Components/Menu/useHoverMenu.ts +36 -0
  63. package/src/Components/SizeCalculator/SizeCalculator.tsx +3 -3
  64. package/src/Components/SpoilerList/Spoiler/Spoiler.tsx +9 -9
  65. package/src/Components/SpoilerList/SpoilerList.tsx +3 -3
  66. package/src/Components/TabBar/TabBar.tsx +3 -3
  67. package/src/Components/Title/HoverTitle.tsx +97 -0
  68. package/src/Components/Title/Title.stories.tsx +95 -0
  69. package/src/Components/Title/hoverTitle.module.scss +8 -0
  70. package/src/Components/Title/withTitle.module.scss +7 -0
  71. package/src/Components/Title/withTitle.tsx +48 -0
  72. package/src/Components/TopBar/MoreButton.tsx +3 -3
  73. package/src/Components/TopBar/TopBar.tsx +6 -6
  74. package/src/WrongChildError.ts +1 -0
  75. package/src/helper/withRestrictedChildren.tsx +3 -1
  76. package/src/index.ts +6 -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,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 '@/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 { Icon } from '@/Components/Icon/Icon';
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
- <Icon icon={faEllipsisH} className={baseStyles.materialHidden} />
33
- <Icon icon={faEllipsisV} className={baseStyles.flatHidden} />
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 { Block } from '@/Components/Layout/Block';
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/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 = <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>
@@ -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)}>{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';