@ainias42/react-bootstrap-mobile 0.1.7

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 (233) hide show
  1. package/.eslintrc.json +189 -0
  2. package/.prettierrc +5 -0
  3. package/LICENSE +21 -0
  4. package/README.md +1 -0
  5. package/babel.config.js +22 -0
  6. package/bin/build.js +60 -0
  7. package/bin/release.sh +35 -0
  8. package/bin/updateCopies.js +86 -0
  9. package/bootstrapReactMobile.ts +87 -0
  10. package/dist/bootstrapReactMobile.d.ts +87 -0
  11. package/dist/bootstrapReactMobile.js +6275 -0
  12. package/dist/src/Components/ActionSheet/ActionSheet.d.ts +21 -0
  13. package/dist/src/Components/Card/Card.d.ts +13 -0
  14. package/dist/src/Components/Clickable/Clickable.d.ts +14 -0
  15. package/dist/src/Components/Dialog/AlertDialog.d.ts +10 -0
  16. package/dist/src/Components/Dialog/ButtonDialog.d.ts +13 -0
  17. package/dist/src/Components/Dialog/ConfirmDialog.d.ts +11 -0
  18. package/dist/src/Components/Dialog/Dialog.d.ts +14 -0
  19. package/dist/src/Components/Dialog/DialogBackground.d.ts +7 -0
  20. package/dist/src/Components/Dialog/DialogContainer.d.ts +6 -0
  21. package/dist/src/Components/Dialog/DialogContext.d.ts +9 -0
  22. package/dist/src/Components/Dialog/useAlertDialog.d.ts +1 -0
  23. package/dist/src/Components/Dialog/useConfirmDialog.d.ts +1 -0
  24. package/dist/src/Components/DragAndDrop/DragItem.d.ts +7 -0
  25. package/dist/src/Components/DragAndDrop/DropArea.d.ts +7 -0
  26. package/dist/src/Components/DragAndDrop/useStrictEnabled.d.ts +1 -0
  27. package/dist/src/Components/FormElements/Button/Button.d.ts +8 -0
  28. package/dist/src/Components/FormElements/CheckBox/Checkbox.d.ts +10 -0
  29. package/dist/src/Components/FormElements/ColorInput/ColorInput.d.ts +17 -0
  30. package/dist/src/Components/FormElements/ColorInput/sharedSelectedColor.d.ts +4 -0
  31. package/dist/src/Components/FormElements/ImageInput/ImageInput.d.ts +17 -0
  32. package/dist/src/Components/FormElements/Input/HiddenInput.d.ts +8 -0
  33. package/dist/src/Components/FormElements/Input/Input.d.ts +10 -0
  34. package/dist/src/Components/FormElements/Input/PasswordInput/PasswordInput.d.ts +4 -0
  35. package/dist/src/Components/FormElements/SearchSelectInput/SearchSelectInput.d.ts +10 -0
  36. package/dist/src/Components/FormElements/Select/Select.d.ts +16 -0
  37. package/dist/src/Components/FormElements/Slider/Slider.d.ts +8 -0
  38. package/dist/src/Components/FormElements/Switch/Switch.d.ts +12 -0
  39. package/dist/src/Components/FormElements/Textarea/Textarea.d.ts +12 -0
  40. package/dist/src/Components/FormElements/hooks/useOnChangeDone.d.ts +2 -0
  41. package/dist/src/Components/FullScreen/FullScreen.d.ts +14 -0
  42. package/dist/src/Components/Hooks/useBreakpoint.d.ts +11 -0
  43. package/dist/src/Components/Hooks/useComposedRef.d.ts +2 -0
  44. package/dist/src/Components/Hooks/useDebounced.d.ts +1 -0
  45. package/dist/src/Components/Hooks/useDelayed.d.ts +1 -0
  46. package/dist/src/Components/Hooks/useInViewport.d.ts +2 -0
  47. package/dist/src/Components/Hooks/useKeyListener.d.ts +3 -0
  48. package/dist/src/Components/Hooks/useListener.d.ts +18 -0
  49. package/dist/src/Components/Hooks/useOnMount.d.ts +1 -0
  50. package/dist/src/Components/Hooks/useOnce.d.ts +1 -0
  51. package/dist/src/Components/Icon/Icon.d.ts +13 -0
  52. package/dist/src/Components/Image/Image.d.ts +12 -0
  53. package/dist/src/Components/InViewport/InViewport.d.ts +11 -0
  54. package/dist/src/Components/Layout/Block.d.ts +7 -0
  55. package/dist/src/Components/Layout/Container.d.ts +15 -0
  56. package/dist/src/Components/Layout/Flex.d.ts +10 -0
  57. package/dist/src/Components/Layout/Grid/Grid.d.ts +9 -0
  58. package/dist/src/Components/Layout/Grid/GridItem.d.ts +25 -0
  59. package/dist/src/Components/Layout/Grow.d.ts +9 -0
  60. package/dist/src/Components/Layout/Inline.d.ts +7 -0
  61. package/dist/src/Components/Layout/InlineBlock.d.ts +7 -0
  62. package/dist/src/Components/Layout/View.d.ts +9 -0
  63. package/dist/src/Components/Layout/ViewWithoutListeners.d.ts +8 -0
  64. package/dist/src/Components/List/BulletList/BulletList.d.ts +8 -0
  65. package/dist/src/Components/List/BulletList/ListItem.d.ts +7 -0
  66. package/dist/src/Components/List/List.d.ts +10 -0
  67. package/dist/src/Components/LoadingArea/LoadingArea.d.ts +12 -0
  68. package/dist/src/Components/LoadingCircle/LoadingCircle.d.ts +8 -0
  69. package/dist/src/Components/Menu/Menu.d.ts +16 -0
  70. package/dist/src/Components/Menu/useMenu.d.ts +3 -0
  71. package/dist/src/Components/RbmComponentProps.d.ts +31 -0
  72. package/dist/src/Components/SizeCalculator/SizeCalculator.d.ts +9 -0
  73. package/dist/src/Components/SpoilerList/Spoiler/Spoiler.d.ts +15 -0
  74. package/dist/src/Components/SpoilerList/SpoilerList.d.ts +15 -0
  75. package/dist/src/Components/SpoilerList/useSpoilerGroup.d.ts +12 -0
  76. package/dist/src/Components/TabBar/TabBar.d.ts +30 -0
  77. package/dist/src/Components/TabBar/TabBarButton.d.ts +9 -0
  78. package/dist/src/Components/Table/Table.d.ts +36 -0
  79. package/dist/src/Components/Text/Heading.d.ts +7 -0
  80. package/dist/src/Components/Text/Text.d.ts +26 -0
  81. package/dist/src/Components/Toast/Toast.d.ts +13 -0
  82. package/dist/src/Components/Toast/ToastContainer.d.ts +7 -0
  83. package/dist/src/Components/TopBar/MoreButton.d.ts +9 -0
  84. package/dist/src/Components/TopBar/TopBar.d.ts +25 -0
  85. package/dist/src/Components/TopBar/TopBarButton.d.ts +9 -0
  86. package/dist/src/StyleProvider.d.ts +2 -0
  87. package/dist/src/TypeHelpers.d.ts +4 -0
  88. package/dist/src/WindowContext/WindowContext.d.ts +3 -0
  89. package/dist/src/WrongChildError.d.ts +4 -0
  90. package/dist/src/helper/Characters.d.ts +5 -0
  91. package/dist/src/helper/DistributiveOmit.d.ts +1 -0
  92. package/dist/src/helper/EmptyProps.d.ts +1 -0
  93. package/dist/src/helper/memoComparator.d.ts +1 -0
  94. package/dist/src/helper/nonEmptyString.d.ts +1 -0
  95. package/dist/src/helper/withForwardRef.d.ts +7 -0
  96. package/dist/src/helper/withMemo.d.ts +3 -0
  97. package/dist/src/helper/withRenderBrowserOnly.d.ts +2 -0
  98. package/dist/src/helper/withRestrictedChildren.d.ts +6 -0
  99. package/package.json +92 -0
  100. package/react-bootstrap-mobile.scss +6 -0
  101. package/scripts/getPackageJson.js +25 -0
  102. package/src/Components/ActionSheet/ActionSheet.tsx +115 -0
  103. package/src/Components/ActionSheet/actionSheet.scss +153 -0
  104. package/src/Components/Card/Card.tsx +46 -0
  105. package/src/Components/Card/card.scss +76 -0
  106. package/src/Components/Clickable/Clickable.tsx +174 -0
  107. package/src/Components/Clickable/clickable.scss +3 -0
  108. package/src/Components/Dialog/AlertDialog.tsx +44 -0
  109. package/src/Components/Dialog/ButtonDialog.tsx +57 -0
  110. package/src/Components/Dialog/ConfirmDialog.tsx +46 -0
  111. package/src/Components/Dialog/Dialog.tsx +82 -0
  112. package/src/Components/Dialog/DialogBackground.tsx +38 -0
  113. package/src/Components/Dialog/DialogContainer.tsx +77 -0
  114. package/src/Components/Dialog/DialogContext.ts +21 -0
  115. package/src/Components/Dialog/buttonDialog.scss +114 -0
  116. package/src/Components/Dialog/dialog.scss +30 -0
  117. package/src/Components/Dialog/dialogBackground.scss +4 -0
  118. package/src/Components/Dialog/useAlertDialog.ts +13 -0
  119. package/src/Components/Dialog/useConfirmDialog.ts +13 -0
  120. package/src/Components/DragAndDrop/DragItem.tsx +38 -0
  121. package/src/Components/DragAndDrop/DropArea.tsx +43 -0
  122. package/src/Components/DragAndDrop/useStrictEnabled.ts +20 -0
  123. package/src/Components/FormElements/Button/Button.tsx +25 -0
  124. package/src/Components/FormElements/Button/button.scss +39 -0
  125. package/src/Components/FormElements/CheckBox/Checkbox.tsx +61 -0
  126. package/src/Components/FormElements/CheckBox/checkbox.scss +107 -0
  127. package/src/Components/FormElements/ColorInput/ColorInput.tsx +139 -0
  128. package/src/Components/FormElements/ColorInput/colorInput.scss +35 -0
  129. package/src/Components/FormElements/ColorInput/sharedSelectedColor.ts +40 -0
  130. package/src/Components/FormElements/ImageInput/ImageInput.tsx +97 -0
  131. package/src/Components/FormElements/ImageInput/imageInput.scss +24 -0
  132. package/src/Components/FormElements/Input/HiddenInput.tsx +43 -0
  133. package/src/Components/FormElements/Input/Input.tsx +102 -0
  134. package/src/Components/FormElements/Input/PasswordInput/PasswordInput.tsx +55 -0
  135. package/src/Components/FormElements/Input/PasswordInput/passwordInput.scss +7 -0
  136. package/src/Components/FormElements/Input/input.scss +57 -0
  137. package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.tsx +162 -0
  138. package/src/Components/FormElements/SearchSelectInput/seachSelectInput.scss +90 -0
  139. package/src/Components/FormElements/Select/Select.tsx +77 -0
  140. package/src/Components/FormElements/Select/select.scss +51 -0
  141. package/src/Components/FormElements/Slider/Slider.tsx +80 -0
  142. package/src/Components/FormElements/Slider/slider.scss +92 -0
  143. package/src/Components/FormElements/Switch/Switch.tsx +82 -0
  144. package/src/Components/FormElements/Switch/switch.scss +149 -0
  145. package/src/Components/FormElements/Textarea/Textarea.tsx +77 -0
  146. package/src/Components/FormElements/Textarea/textarea.scss +22 -0
  147. package/src/Components/FormElements/hooks/useOnChangeDone.ts +16 -0
  148. package/src/Components/FullScreen/FullScreen.tsx +89 -0
  149. package/src/Components/Hooks/useBreakpoint.ts +66 -0
  150. package/src/Components/Hooks/useComposedRef.ts +17 -0
  151. package/src/Components/Hooks/useDebounced.ts +22 -0
  152. package/src/Components/Hooks/useDelayed.ts +46 -0
  153. package/src/Components/Hooks/useInViewport.ts +23 -0
  154. package/src/Components/Hooks/useKeyListener.ts +77 -0
  155. package/src/Components/Hooks/useListener.ts +73 -0
  156. package/src/Components/Hooks/useOnMount.ts +12 -0
  157. package/src/Components/Hooks/useOnce.ts +11 -0
  158. package/src/Components/Icon/Icon.tsx +45 -0
  159. package/src/Components/Image/Image.tsx +44 -0
  160. package/src/Components/Image/image.scss +3 -0
  161. package/src/Components/InViewport/InViewport.tsx +71 -0
  162. package/src/Components/InViewport/inViewport.scss +3 -0
  163. package/src/Components/Layout/Block.tsx +48 -0
  164. package/src/Components/Layout/Container.tsx +57 -0
  165. package/src/Components/Layout/Flex.tsx +51 -0
  166. package/src/Components/Layout/Grid/Grid.tsx +53 -0
  167. package/src/Components/Layout/Grid/GridItem.tsx +138 -0
  168. package/src/Components/Layout/Grid/grid.scss +43 -0
  169. package/src/Components/Layout/Grow.tsx +51 -0
  170. package/src/Components/Layout/Inline.tsx +48 -0
  171. package/src/Components/Layout/InlineBlock.tsx +48 -0
  172. package/src/Components/Layout/View.tsx +40 -0
  173. package/src/Components/Layout/ViewWithoutListeners.tsx +40 -0
  174. package/src/Components/Layout/container.scss +12 -0
  175. package/src/Components/Layout/layout.scss +56 -0
  176. package/src/Components/List/BulletList/BulletList.tsx +33 -0
  177. package/src/Components/List/BulletList/ListItem.tsx +34 -0
  178. package/src/Components/List/List.tsx +88 -0
  179. package/src/Components/List/list.scss +30 -0
  180. package/src/Components/LoadingArea/LoadingArea.tsx +64 -0
  181. package/src/Components/LoadingArea/loadingArea.scss +19 -0
  182. package/src/Components/LoadingCircle/LoadingCircle.tsx +41 -0
  183. package/src/Components/LoadingCircle/loadingCircle.scss +42 -0
  184. package/src/Components/Menu/Menu.tsx +113 -0
  185. package/src/Components/Menu/menu.scss +21 -0
  186. package/src/Components/Menu/useMenu.ts +20 -0
  187. package/src/Components/RbmComponentProps.ts +40 -0
  188. package/src/Components/SizeCalculator/SizeCalculator.tsx +45 -0
  189. package/src/Components/SpoilerList/Spoiler/Spoiler.tsx +106 -0
  190. package/src/Components/SpoilerList/Spoiler/spoiler.scss +120 -0
  191. package/src/Components/SpoilerList/SpoilerList.tsx +63 -0
  192. package/src/Components/SpoilerList/useSpoilerGroup.ts +39 -0
  193. package/src/Components/TabBar/TabBar.tsx +117 -0
  194. package/src/Components/TabBar/TabBarButton.tsx +44 -0
  195. package/src/Components/TabBar/tabBar.scss +108 -0
  196. package/src/Components/Table/Table.tsx +182 -0
  197. package/src/Components/Text/Heading.tsx +44 -0
  198. package/src/Components/Text/Text.tsx +79 -0
  199. package/src/Components/Text/heading.scss +3 -0
  200. package/src/Components/Text/text.scss +60 -0
  201. package/src/Components/Toast/Toast.tsx +107 -0
  202. package/src/Components/Toast/ToastContainer.tsx +35 -0
  203. package/src/Components/Toast/toast.scss +52 -0
  204. package/src/Components/TopBar/MoreButton.tsx +38 -0
  205. package/src/Components/TopBar/TopBar.tsx +176 -0
  206. package/src/Components/TopBar/TopBarButton.tsx +29 -0
  207. package/src/Components/TopBar/topBar.scss +124 -0
  208. package/src/StyleProvider.ts +4 -0
  209. package/src/TypeHelpers.ts +4 -0
  210. package/src/WindowContext/WindowContext.ts +8 -0
  211. package/src/WrongChildError.ts +19 -0
  212. package/src/env.d.ts +1 -0
  213. package/src/helper/Characters.ts +5 -0
  214. package/src/helper/DistributiveOmit.ts +1 -0
  215. package/src/helper/EmptyProps.ts +2 -0
  216. package/src/helper/memoComparator.ts +18 -0
  217. package/src/helper/nonEmptyString.ts +8 -0
  218. package/src/helper/withForwardRef.ts +28 -0
  219. package/src/helper/withMemo.ts +16 -0
  220. package/src/helper/withRenderBrowserOnly.tsx +30 -0
  221. package/src/helper/withRestrictedChildren.tsx +57 -0
  222. package/src/scss/_animations.scss +46 -0
  223. package/src/scss/_baseClasses.scss +27 -0
  224. package/src/scss/_colors.scss +13 -0
  225. package/src/scss/_default.scss +17 -0
  226. package/src/scss/_designMixin.scss +13 -0
  227. package/src/scss/_mobileMixin.scss +35 -0
  228. package/src/scss/_variables.scss +22 -0
  229. package/src/types/isomorphic-style-loader.d.ts +3 -0
  230. package/src/types/react-table-config.d.ts +120 -0
  231. package/src/types/scss-module.d.ts +7 -0
  232. package/tsconfig.json +57 -0
  233. package/webpack.config.js +85 -0
@@ -0,0 +1,176 @@
1
+ import * as React from 'react';
2
+ import { ComponentType, ReactElement, useCallback, useMemo, useRef, useState } from 'react';
3
+ import { Container } from '../Layout/Container';
4
+ import { TopBarButton } from './TopBarButton';
5
+ import { RbmComponentProps } from '../RbmComponentProps';
6
+ import { ActionSheet, ActionSheetAction } from '../ActionSheet/ActionSheet';
7
+ import { Icon, IconSource } from '../Icon/Icon';
8
+ import { MoreButton } from './MoreButton';
9
+
10
+ import styles from './topBar.scss';
11
+
12
+ import { withMemo } from '../../helper/withMemo';
13
+ import classNames from 'classnames';
14
+ import { Block } from '../Layout/Block';
15
+ import { Text } from '../Text/Text';
16
+ import { Flex } from '../Layout/Flex';
17
+ import { Inline } from '../Layout/Inline';
18
+ import { View } from '../Layout/View';
19
+
20
+ export type TopBarActionButtonType = {
21
+ title: string;
22
+ icon?: IconSource;
23
+ action: () => void;
24
+ disabled?: boolean;
25
+ key?: string;
26
+ };
27
+
28
+ export type TopBarComponentButtonType = Partial<TopBarActionButtonType> & {
29
+ component: ComponentType<Record<string, any>>;
30
+ };
31
+
32
+ export type TopBarButtonType = TopBarComponentButtonType | TopBarActionButtonType;
33
+
34
+ export type TopBarProps = RbmComponentProps<{
35
+ title?: string;
36
+ leftButtons?: TopBarButtonType[];
37
+ rightButtons?: TopBarButtonType[];
38
+ hiddenButtons?: TopBarButtonType[];
39
+ transparent?: boolean;
40
+ drawBehind?: boolean;
41
+ }>;
42
+
43
+ function getButtonComponents(buttons: TopBarButtonType[]) {
44
+ return buttons.map((button, index) => {
45
+ const key = button.key ?? String(index);
46
+ if ('component' in button) {
47
+ const Component = button.component;
48
+ return <Component {...button} key={key} onClick={button.action} />;
49
+ }
50
+ let child: string | ReactElement | undefined = button.title;
51
+ if (button.icon) {
52
+ child = <Icon icon={button.icon} />;
53
+ }
54
+ return (
55
+ <TopBarButton key={key} onClick={button.action} disabled={button.disabled} __allowChildren="all">
56
+ {child}
57
+ </TopBarButton>
58
+ );
59
+ });
60
+ }
61
+
62
+ function TopBar({
63
+ title = '',
64
+ rightButtons = [],
65
+ leftButtons = [],
66
+ hiddenButtons = [],
67
+ className,
68
+ transparent = false,
69
+ drawBehind = false,
70
+ ...rbmProps
71
+ }: TopBarProps) {
72
+ const [isHiddenMenuOpen, setIsHiddenMenuOpen] = useState(false);
73
+
74
+ if (isHiddenMenuOpen) {
75
+ transparent = false;
76
+ }
77
+
78
+ const actionSheetRef = useRef<React.ElementRef<typeof ActionSheet>>(null);
79
+
80
+ const toggleHiddenMenu = useCallback(() => {
81
+ setIsHiddenMenuOpen((isOpen) => {
82
+ if (isOpen) {
83
+ actionSheetRef.current?.hide();
84
+ return false;
85
+ }
86
+ actionSheetRef.current?.show();
87
+ return true;
88
+ });
89
+ }, [actionSheetRef]);
90
+
91
+ const onActionSheetClose = useCallback(() => setIsHiddenMenuOpen(false), [setIsHiddenMenuOpen]);
92
+
93
+ rightButtons = useMemo(() => {
94
+ if (hiddenButtons.length > 0) {
95
+ return [
96
+ ...rightButtons,
97
+ {
98
+ title: '...',
99
+ component: MoreButton,
100
+ action: toggleHiddenMenu,
101
+ },
102
+ ];
103
+ }
104
+ return rightButtons;
105
+ }, [rightButtons, hiddenButtons.length, toggleHiddenMenu]);
106
+
107
+ hiddenButtons = useMemo(
108
+ () =>
109
+ hiddenButtons.map((button) => ({
110
+ ...button,
111
+ action: () => {
112
+ setIsHiddenMenuOpen(false);
113
+ actionSheetRef.current?.hide();
114
+ if (button.action) {
115
+ button.action();
116
+ }
117
+ },
118
+ })),
119
+ [hiddenButtons]
120
+ );
121
+
122
+ const rightButtonComponents = getButtonComponents(rightButtons);
123
+ const leftButtonComponents = getButtonComponents(leftButtons);
124
+ const hiddenButtonComponents = getButtonComponents(hiddenButtons.map(({ icon: _, ...button }) => button));
125
+
126
+ const actions: ActionSheetAction<any>[] = useMemo(
127
+ () =>
128
+ hiddenButtons.map((button) => ({
129
+ action: button.action!,
130
+ name: button.title!,
131
+ icon: button.icon,
132
+ })),
133
+ [hiddenButtons]
134
+ );
135
+
136
+ return (
137
+ <nav
138
+ {...rbmProps}
139
+ className={classNames(
140
+ styles.topBar,
141
+ {
142
+ [styles.transparent]: transparent,
143
+ [styles.drawBehind]: drawBehind,
144
+ },
145
+ className
146
+ )}
147
+ >
148
+ <Container fluid="xxl" className={styles.container}>
149
+ <Flex grow={true} className={classNames(styles.buttonContainer, styles.left)} horizontal={true}>
150
+ {leftButtonComponents}
151
+ </Flex>
152
+ <Block className={styles.titleContainer}>
153
+ <Text className={styles.title}>{title}</Text>
154
+ </Block>
155
+ <Flex grow={true} className={classNames(styles.buttonContainer, styles.right)} horizontal={true}>
156
+ {rightButtonComponents}
157
+ </Flex>
158
+ {hiddenButtons.length > 0 && isHiddenMenuOpen ? (
159
+ <Inline className={styles.hiddenContainer}>
160
+ <View aria-hidden={true} className={styles.hiddenCloseCurtain} onClick={toggleHiddenMenu} />
161
+ <View className={styles.hiddenMenu}>{hiddenButtonComponents}</View>
162
+ </Inline>
163
+ ) : null}
164
+ <ActionSheet
165
+ actions={actions}
166
+ ref={actionSheetRef}
167
+ className={styles.hiddenActionMenu}
168
+ onClose={onActionSheetClose}
169
+ />
170
+ </Container>
171
+ </nav>
172
+ );
173
+ }
174
+
175
+ const TopBarMemo = withMemo(TopBar, styles);
176
+ export { TopBarMemo as TopBar };
@@ -0,0 +1,29 @@
1
+ import * as React from 'react';
2
+ import { useCallback } from 'react';
3
+ import { RbmComponentProps } from '../RbmComponentProps';
4
+
5
+ import styles from './topBar.scss';
6
+ import classNames from 'classnames';
7
+ import { withMemo } from '../../helper/withMemo';
8
+
9
+ export type TopBarButtonProps = RbmComponentProps<{
10
+ disabled?: boolean;
11
+ onClick?: () => void;
12
+ }>;
13
+
14
+ function TopBarButton({ disabled = false, onClick, className, children, ...rbmProps }: TopBarButtonProps) {
15
+ const cb = useCallback(() => (onClick ? onClick() : null), [onClick]);
16
+ return (
17
+ <a
18
+ role="button"
19
+ {...rbmProps}
20
+ onClick={cb}
21
+ className={classNames(styles.button, { [styles.disabled]: disabled }, className)}
22
+ >
23
+ {children}
24
+ </a>
25
+ );
26
+ }
27
+
28
+ const TopBarButtonMemo = withMemo(TopBarButton, styles);
29
+ export { TopBarButtonMemo as TopBarButton };
@@ -0,0 +1,124 @@
1
+ @import "../../scss/variables";
2
+ @import "../../scss/designMixin";
3
+
4
+ .topBar {
5
+ // navbar-expand
6
+ flex-wrap: nowrap;
7
+ justify-content: flex-start;
8
+
9
+ // navbar
10
+ position: relative;
11
+ display: flex;
12
+ align-items: center;
13
+ padding-top: 0.5rem;
14
+ padding-bottom: 0.5rem;
15
+
16
+ background: white;
17
+ height: 56px;
18
+
19
+ .container {
20
+ display: flex;
21
+ flex-wrap: inherit;
22
+ align-items: center;
23
+ justify-content: center;
24
+ }
25
+
26
+ .button {
27
+ display: block;
28
+ padding: 0.5rem 1rem;
29
+ color: #0d3efd; // TODO change color
30
+ text-decoration: none;
31
+ transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
32
+
33
+ &.disabled {
34
+ color: #6c757d; // TODO change color
35
+ pointer-events: none;
36
+ cursor: default;
37
+ }
38
+ }
39
+
40
+ &.transparent {
41
+ opacity: 0.65;
42
+ z-index: 1;
43
+ }
44
+
45
+ &.drawBehind {
46
+ position: absolute;
47
+ left: 0;
48
+ right: 0;
49
+ }
50
+
51
+ .titleContainer {
52
+ overflow: hidden;
53
+
54
+ .title {
55
+ color: rgba(0, 0, 0, 0.55); // TODO Change color
56
+ padding-bottom: 0.5rem;
57
+ padding-top: 0.5rem;
58
+
59
+ white-space: nowrap;
60
+ width: 100%;
61
+ overflow: hidden;
62
+ text-overflow: ellipsis;
63
+ }
64
+ }
65
+
66
+ .buttonContainer {
67
+ white-space: nowrap;
68
+ display: flex;
69
+ flex: 1;
70
+ min-width: -webkit-min-content;
71
+
72
+ &.right {
73
+ justify-content: flex-end;
74
+ }
75
+
76
+ &.left {
77
+ justify-content: flex-start;
78
+ }
79
+ }
80
+
81
+ .hiddenContainer {
82
+ position: relative;
83
+
84
+ .hiddenCloseCurtain {
85
+ position: fixed;
86
+ top: 0;
87
+ left: 0;
88
+ right: 0;
89
+ bottom: 0;
90
+ z-index: 998;
91
+ }
92
+
93
+ .hiddenMenu {
94
+ position: absolute;
95
+ right: 0;
96
+ white-space: nowrap;
97
+ display: flex;
98
+ min-width: -webkit-min-content;
99
+ justify-content: flex-start;
100
+ flex-direction: column;
101
+ z-index: 999;
102
+ background-color: white;
103
+ border: 1px solid var(--border-strong);
104
+ }
105
+ }
106
+
107
+ @include design($material) {
108
+ box-shadow: 0 1px 5px rgb(0 0 0 / 30%);
109
+
110
+ .hiddenActionMenu {
111
+ display: none;
112
+ }
113
+ }
114
+ @include design($flat) {
115
+ background-size: 100% 1px;
116
+ background-repeat: no-repeat;
117
+ background-position: bottom;
118
+ background-image: linear-gradient(0deg, #b2b2b2, #b2b2b2 100%);
119
+
120
+ .hiddenContainer {
121
+ display: none;
122
+ }
123
+ }
124
+ }
@@ -0,0 +1,4 @@
1
+ import StyleContext from 'isomorphic-style-loader/StyleContext';
2
+
3
+ const provider = StyleContext.Provider;
4
+ export { provider as StyleProvider };
@@ -0,0 +1,4 @@
1
+ export type Override<T1, T2> = Omit<T1, keyof T2> & T2;
2
+ export type Conditional<T1, T2> = Partial<T1> | (T1 & T2);
3
+ export type ValueOf<T> = T[keyof T];
4
+ export type Recursive<T> = T | T[] | Recursive<T>[];
@@ -0,0 +1,8 @@
1
+ import React, { useContext } from 'react';
2
+
3
+ export const WindowContext = React.createContext<Window | undefined>(undefined);
4
+ WindowContext.displayName = 'WindowContext';
5
+
6
+ export function useWindow() {
7
+ return useContext(WindowContext) ?? (typeof window !== 'undefined' ? window : undefined);
8
+ }
@@ -0,0 +1,19 @@
1
+ export class WrongChildError extends Error {
2
+ public childValue: any;
3
+
4
+ constructor(expectedType: string, gotType: string, child: any, component: string) {
5
+ const value =
6
+ typeof child === 'object' && child !== null
7
+ ? `${child.toString()} - (${
8
+ child.displayName ?? child.name ?? child.type?.displayName ?? child.type?.name ?? child.type
9
+ })`
10
+ : child;
11
+ super(
12
+ `Expected Children of type '${expectedType}' but got type '${gotType}' in component ${component}. Value of child is '${value}'`
13
+ );
14
+ this.name = 'WrongChildError';
15
+ this.childValue = child;
16
+
17
+ console.log('LOG-d stack', this.stack);
18
+ }
19
+ }
package/src/env.d.ts ADDED
@@ -0,0 +1 @@
1
+ /// <reference types="styled-jsx" />
@@ -0,0 +1,5 @@
1
+ export const Characters = {
2
+ NBSP: '\u00A0',
3
+ PATH_DELIMITER: '/',
4
+ MIDDLE_DOT: '\u00B7',
5
+ };
@@ -0,0 +1 @@
1
+ export type DistributiveOmit<T, K extends keyof T> = T extends any ? Omit<T, K> : never;
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-types
2
+ export type EmptyProps = {};
@@ -0,0 +1,18 @@
1
+ import { JsonHelper } from '@ainias42/js-helper';
2
+
3
+ export function memoComparator(prevProps: Readonly<any>, nextProps: Readonly<any>) {
4
+ const keysPrev = Object.keys(prevProps);
5
+ const keysNext = Object.keys(nextProps);
6
+
7
+ if (keysPrev.length !== keysNext.length) {
8
+ return false;
9
+ }
10
+
11
+ return keysPrev.every((key) => {
12
+ if (key === 'style') {
13
+ return JsonHelper.deepEqual(prevProps[key], nextProps[key]);
14
+ }
15
+
16
+ return prevProps[key] === nextProps[key];
17
+ });
18
+ }
@@ -0,0 +1,8 @@
1
+ import { Characters } from './Characters';
2
+
3
+ export function nonEmptyString(str: string | undefined | null, other = Characters.NBSP) {
4
+ if (!str) {
5
+ return other;
6
+ }
7
+ return str;
8
+ }
@@ -0,0 +1,28 @@
1
+ import React, { ForwardedRef, ForwardRefRenderFunction, PropsWithoutRef, ReactElement, RefAttributes } from 'react';
2
+ import withStyles from 'isomorphic-style-loader/withStyles';
3
+ import { RESTRICT_CHILDREN, withRestrictedChildren } from './withRestrictedChildren';
4
+ import { memoComparator } from './memoComparator';
5
+
6
+ export interface RefComponent<PropTypes, ForwardedRefType> {
7
+ (props: PropsWithoutRef<PropTypes> & RefAttributes<ForwardedRefType>): ReactElement | null;
8
+
9
+ displayName?: string | undefined;
10
+ }
11
+
12
+ export function withForwardRef<PropTypes, ForwardedRefType>(
13
+ component: ForwardRefRenderFunction<ForwardedRefType, PropTypes>,
14
+ styles?: any,
15
+ defaultAllowChildren?: typeof RESTRICT_CHILDREN['allowChildren']
16
+ ) {
17
+ const forwarded = React.forwardRef(component);
18
+ forwarded.displayName = component.displayName ?? component.name;
19
+ const forwardedComp = React.forwardRef(withRestrictedChildren(forwarded, defaultAllowChildren));
20
+ const c: (props: PropTypes, ref: ForwardedRef<ForwardedRefType>) => ReactElement = styles
21
+ ? withStyles(styles)(forwardedComp)
22
+ : forwardedComp;
23
+
24
+ const memoizedComponent = React.memo(c, memoComparator) as RefComponent<PropTypes, ForwardedRefType>;
25
+ memoizedComponent.displayName = `Memoized-Forwarded(${component.displayName || component.name})`;
26
+
27
+ return memoizedComponent;
28
+ }
@@ -0,0 +1,16 @@
1
+ import React, { ComponentType } from 'react';
2
+ import withStyles from 'isomorphic-style-loader/withStyles';
3
+ import { RESTRICT_CHILDREN, withRestrictedChildren } from './withRestrictedChildren';
4
+ import { memoComparator } from './memoComparator';
5
+
6
+ export function withMemo<C extends ComponentType<any>>(
7
+ component: C,
8
+ styles?: any,
9
+ defaultAllowChildren?: typeof RESTRICT_CHILDREN['allowChildren']
10
+ ) {
11
+ const withNoStrings = withRestrictedChildren(component, defaultAllowChildren);
12
+ const c = styles ? withStyles(styles)(withNoStrings) : withNoStrings;
13
+ const memoizedComponent = React.memo(c, memoComparator) as unknown as C;
14
+ memoizedComponent.displayName = `Memoized(${component.displayName || component.name})`;
15
+ return memoizedComponent;
16
+ }
@@ -0,0 +1,30 @@
1
+ import React, { ComponentType, ForwardedRef, useEffect, useState } from 'react';
2
+
3
+ export function withRenderBrowserOnly<C extends ComponentType<any>>(Component: C) {
4
+ type RefType = React.ComponentRef<C>;
5
+ type Props = React.ComponentProps<C>;
6
+
7
+ const displayName = `WithRenderBrowserOnly(${Component.displayName || Component.name})`;
8
+
9
+ const HocComponent = ({ children, ...props }: Props, ref?: ForwardedRef<RefType>) => {
10
+ const [isBrowser, setIsBrowser] = useState(false);
11
+
12
+ useEffect(() => setIsBrowser(true), []);
13
+ if (!isBrowser) {
14
+ return null;
15
+ }
16
+
17
+ const newProps: Record<string, any> = props;
18
+ if (ref && Object.keys(ref).length > 0) {
19
+ newProps.ref = ref;
20
+ }
21
+
22
+ return (
23
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
+ // @ts-ignore
25
+ <Component {...(newProps as Props)}>{children}</Component>
26
+ );
27
+ };
28
+ HocComponent.displayName = displayName;
29
+ return HocComponent as C;
30
+ }
@@ -0,0 +1,57 @@
1
+ import React, { ComponentType, ForwardedRef, ReactElement } from 'react';
2
+ import { RbmComponentProps } from '../Components/RbmComponentProps';
3
+ import { WrongChildError } from '../WrongChildError';
4
+
5
+ export const RESTRICT_CHILDREN = {
6
+ allowChildren: undefined as undefined | 'all' | 'html' | 'text',
7
+ };
8
+
9
+ export function withRestrictedChildren<C extends ComponentType<RbmComponentProps<Record<string, any>>>>(
10
+ Component: C,
11
+ defaultAllowChildren?: typeof RESTRICT_CHILDREN['allowChildren']
12
+ ) {
13
+ type RefType = React.ComponentRef<C>;
14
+ type Props = React.ComponentProps<C>;
15
+
16
+ const displayName = `WithRestrictedChildren(${Component.displayName || Component.name})`;
17
+
18
+ const hocComponent = (
19
+ { children, __allowChildren = defaultAllowChildren ?? RESTRICT_CHILDREN.allowChildren, ...otherProps }: Props,
20
+ ref?: ForwardedRef<RefType>
21
+ ) => {
22
+ if (__allowChildren !== 'all') {
23
+ if (__allowChildren !== 'html') {
24
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
25
+ // @ts-ignore
26
+ React.Children.forEach(children, (c) => {
27
+ if (c && typeof c === 'object' && 'type' in c && typeof c.type === 'string') {
28
+ throw new WrongChildError('No HTML Elements', 'HTML Elements', c, displayName);
29
+ }
30
+ });
31
+ }
32
+ if (__allowChildren !== 'text') {
33
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34
+ // @ts-ignore
35
+ React.Children.forEach(children, (c) => {
36
+ if (typeof c === 'string') {
37
+ throw new WrongChildError('Not String', 'string', c, displayName);
38
+ }
39
+ });
40
+ }
41
+ }
42
+
43
+ const newProps: Record<string, any> = otherProps;
44
+
45
+ if ((ref && Object.keys(ref).length > 0) || typeof ref === 'function') {
46
+ newProps.ref = ref;
47
+ }
48
+
49
+ return (
50
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
51
+ // @ts-ignore
52
+ <Component {...(newProps as Props)}>{children}</Component>
53
+ );
54
+ };
55
+ hocComponent.displayName = displayName;
56
+ return hocComponent as (props: Props, ref: ForwardedRef<RefType>) => ReactElement;
57
+ }
@@ -0,0 +1,46 @@
1
+ @keyframes material-new-site {
2
+ 0% {
3
+ transform: translate(0, 100%);
4
+ z-index: 1;
5
+ }
6
+ 100% {
7
+ transform: translate(0, 0);
8
+ z-index: 1;
9
+ }
10
+ }
11
+
12
+ @keyframes flat-new-site {
13
+ 0% {
14
+ transform: translate(100%, 0);
15
+ z-index: 1;
16
+ }
17
+ 100% {
18
+ transform: translate(0, 0);
19
+ z-index: 1;
20
+ }
21
+ }
22
+
23
+ .animation-new-site {
24
+ background: green;
25
+ @include design($material) {
26
+ animation: material-new-site;
27
+ animation-duration: $animationDurationMaterial;
28
+ }
29
+ @include design($flat) {
30
+ animation: flat-new-site;
31
+ animation-duration: $animationDurationMaterial;
32
+ }
33
+ }
34
+
35
+ .animation-end-site {
36
+ @include design($material) {
37
+ animation: material-new-site;
38
+ animation-duration: $animationDurationMaterial;
39
+ animation-direction: reverse;
40
+ }
41
+ @include design($flat) {
42
+ animation: flat-new-site;
43
+ animation-duration: $animationDurationMaterial;
44
+ animation-direction: reverse;
45
+ }
46
+ }
@@ -0,0 +1,27 @@
1
+ .full-height {
2
+ height: 100%;
3
+ }
4
+
5
+ .full-min-height {
6
+ min-height: 100%;
7
+ }
8
+
9
+ .scrollable {
10
+ overflow-y: auto;
11
+ }
12
+
13
+ .full-width {
14
+ width: 100%;
15
+ }
16
+
17
+ .flat-hidden {
18
+ @include design($flat) {
19
+ display: none;
20
+ }
21
+ }
22
+
23
+ .material-hidden {
24
+ @include design($material) {
25
+ display: none;
26
+ }
27
+ }
@@ -0,0 +1,13 @@
1
+ @include design($material) {
2
+ --flavor-accent: #37474f;
3
+ --flavor-focus: var(--flavor-accent);
4
+ }
5
+
6
+ :root {
7
+ --border-light: #cecece;
8
+ --border-strong: #717171;
9
+ }
10
+
11
+ @include design($flat) {
12
+ --flavor-accent: #0076ff;
13
+ }
@@ -0,0 +1,17 @@
1
+ * {
2
+ box-sizing: border-box;
3
+ -webkit-font-smoothing: antialiased;
4
+ font-weight: 400;
5
+ }
6
+
7
+ @include design($material) {
8
+ * {
9
+ font-family: "Roboto", "Noto", sans-serif;
10
+ }
11
+ }
12
+
13
+ @include design($flat) {
14
+ * {
15
+ font-family: -apple-system, "Helvetica Neue", "Helvetica", "Arial", "Lucida Grande", sans-serif;
16
+ }
17
+ }
@@ -0,0 +1,13 @@
1
+ @use 'sass:selector';
2
+
3
+ @mixin design($designName) {
4
+ @if & {
5
+ @at-root #{selector.nest(':global(.'+$designName+")", &)} {
6
+ @content
7
+ }
8
+ } @else {
9
+ :global(.#{$designName}) {
10
+ @content
11
+ }
12
+ }
13
+ }