@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,48 @@
1
+ import * as React from 'react';
2
+ import { RbmComponentProps } from '../RbmComponentProps';
3
+ import classNames from 'classnames';
4
+
5
+ import styles from './layout.scss';
6
+ import { ViewWithoutListeners, ViewWithoutListenersProps } from './ViewWithoutListeners';
7
+ import { ComponentRef, ForwardedRef } from 'react';
8
+ import { withForwardRef } from '../../helper/withForwardRef';
9
+
10
+ export type InlineBlockProps<AsType extends keyof JSX.IntrinsicElements> = RbmComponentProps<
11
+ ViewWithoutListenersProps<AsType>
12
+ >;
13
+
14
+ function InlineBlock<AsType extends keyof JSX.IntrinsicElements = 'span'>(
15
+ { children, as = 'span' as AsType, className, ...props }: InlineBlockProps<AsType>,
16
+ ref?: ForwardedRef<ComponentRef<AsType>>
17
+ ) {
18
+ // Variables
19
+
20
+ // Refs
21
+
22
+ // States
23
+
24
+ // Selectors
25
+
26
+ // Callbacks
27
+
28
+ // Effects
29
+
30
+ // Other
31
+
32
+ // Render Functions
33
+
34
+ return (
35
+ <ViewWithoutListeners
36
+ {...(props as ViewWithoutListenersProps<AsType>)}
37
+ className={classNames(styles.inlineBlock, className)}
38
+ as={as as AsType}
39
+ ref={ref}
40
+ >
41
+ {children}
42
+ </ViewWithoutListeners>
43
+ );
44
+ }
45
+
46
+ // Need InlineMemo for autocompletion of phpstorm
47
+ const InlineBlockMemo = withForwardRef(InlineBlock, styles);
48
+ export { InlineBlockMemo as InlineBlock };
@@ -0,0 +1,40 @@
1
+ import * as React from 'react';
2
+ import { ComponentRef, ForwardedRef, PropsWithChildren, ReactElement, RefAttributes } from 'react';
3
+ import { Override } from '../../TypeHelpers';
4
+
5
+ export type ViewProps<AsType extends keyof JSX.IntrinsicElements> = PropsWithChildren<
6
+ Override<React.ComponentPropsWithoutRef<AsType>, { as?: AsType; children?: React.ReactNode }>
7
+ >;
8
+
9
+ function View<AsType extends keyof JSX.IntrinsicElements>(
10
+ { children, as, ...otherProps }: ViewProps<AsType>,
11
+ ref?: ForwardedRef<ComponentRef<AsType>>
12
+ ) {
13
+ // Variables
14
+
15
+ // Refs
16
+
17
+ // States
18
+
19
+ // Selectors
20
+
21
+ // Callbacks
22
+
23
+ // Effects
24
+
25
+ // Other
26
+
27
+ // Render Functions
28
+ const element = (as as keyof JSX.IntrinsicElements) ?? 'span';
29
+ const props = {
30
+ ...otherProps,
31
+ ref,
32
+ };
33
+ return React.createElement(element, props, children);
34
+ }
35
+
36
+ // Need ViewMemo for autocompletion of phpstorm
37
+ const ViewMemo: <AsType extends keyof JSX.IntrinsicElements>(
38
+ props: ViewProps<AsType> & RefAttributes<ComponentRef<AsType>>
39
+ ) => ReactElement | null = React.memo(React.forwardRef(View));
40
+ export { ViewMemo as View };
@@ -0,0 +1,40 @@
1
+ import * as React from 'react';
2
+ import { ComponentRef, DOMAttributes, ForwardedRef, ReactElement, RefAttributes } from 'react';
3
+ import { View, ViewProps } from './View';
4
+
5
+ export type ViewWithoutListenersProps<AsType extends keyof JSX.IntrinsicElements> = Omit<
6
+ ViewProps<AsType>,
7
+ keyof DOMAttributes<AsType>
8
+ > & { children?: React.ReactNode };
9
+
10
+ function ViewWithoutListeners<AsType extends keyof JSX.IntrinsicElements>(
11
+ { children, ...props }: ViewWithoutListenersProps<AsType>,
12
+ ref?: ForwardedRef<ComponentRef<AsType>>
13
+ ) {
14
+ // Variables
15
+
16
+ // Refs
17
+
18
+ // States
19
+
20
+ // Selectors
21
+
22
+ // Callbacks
23
+
24
+ // Effects
25
+
26
+ // Other
27
+
28
+ // Render Functions
29
+ return (
30
+ <View {...props} ref={ref}>
31
+ {children}
32
+ </View>
33
+ );
34
+ }
35
+
36
+ // Need ViewWithoutListenersMemo for autocompletion of phpstorm
37
+ const ViewWithoutListenersMemo: <AsType extends keyof JSX.IntrinsicElements>(
38
+ props: ViewWithoutListenersProps<AsType> & RefAttributes<ComponentRef<AsType>>
39
+ ) => ReactElement | null = React.memo(React.forwardRef(ViewWithoutListeners));
40
+ export { ViewWithoutListenersMemo as ViewWithoutListeners };
@@ -0,0 +1,12 @@
1
+ @import "../../scss/variables";
2
+ @import "bootstrap/scss/mixins/container";
3
+ @import "bootstrap/scss/mixins/breakpoints";
4
+
5
+ @import "bootstrap/scss/containers";
6
+
7
+
8
+ @media (min-width: 1400px) {
9
+ .container-xxl {
10
+ max-width: 1400px;
11
+ }
12
+ }
@@ -0,0 +1,56 @@
1
+ .flex {
2
+ display: flex;
3
+ flex-direction: column;
4
+ justify-content: center;
5
+ align-items: center;
6
+
7
+ &.horizontal {
8
+ flex-direction: row;
9
+ }
10
+ }
11
+
12
+ .grow {
13
+ &.weight0 {
14
+ flex: 0
15
+ }
16
+
17
+ &.weight1 {
18
+ flex: 1
19
+ }
20
+
21
+ &.weight2 {
22
+ flex: 2
23
+ }
24
+
25
+ &.weight3 {
26
+ flex: 3
27
+ }
28
+
29
+ &.weight4 {
30
+ flex: 4
31
+ }
32
+
33
+ &.weight5 {
34
+ flex: 5
35
+ }
36
+
37
+ &.weight6 {
38
+ flex: 6
39
+ }
40
+
41
+ &.center {
42
+ text-align: center;
43
+ }
44
+ }
45
+
46
+ .block {
47
+ display: block;
48
+ }
49
+
50
+ .inlineBlock {
51
+ display: inline-block;
52
+ }
53
+
54
+ .inline {
55
+ display: inline;
56
+ }
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import { withMemo } from '../../../helper/withMemo';
3
+ import { RbmComponentProps } from '../../RbmComponentProps';
4
+
5
+ export type BulletListProps = RbmComponentProps<{ numbered?: boolean }>;
6
+
7
+ function BulletList({ numbered = false, className, children, style }: BulletListProps) {
8
+ // Variables
9
+
10
+ // Refs
11
+
12
+ // States
13
+
14
+ // Selectors
15
+
16
+ // Callbacks
17
+
18
+ // Effects
19
+
20
+ // Other
21
+ const props = { className, style };
22
+
23
+ // Render Functions
24
+ if (numbered) {
25
+ return <ol {...props}>{children}</ol>;
26
+ }
27
+
28
+ return <ul {...props}>{children}</ul>;
29
+ }
30
+
31
+ // Need BulletListMemo for autocompletion of phpstorm
32
+ const BulletListMemo = withMemo(BulletList);
33
+ export { BulletListMemo as BulletList };
@@ -0,0 +1,34 @@
1
+ import * as React from 'react';
2
+ import { withMemo } from '../../../helper/withMemo';
3
+ import { RbmComponentProps } from '../../RbmComponentProps';
4
+ import { EmptyProps } from '../../../helper/EmptyProps';
5
+
6
+ export type ListItemProps = RbmComponentProps<EmptyProps>;
7
+
8
+ function ListItem({ className, children, style }: ListItemProps) {
9
+ // Variables
10
+
11
+ // Refs
12
+
13
+ // States
14
+
15
+ // Selectors
16
+
17
+ // Callbacks
18
+
19
+ // Effects
20
+
21
+ // Other
22
+
23
+ // Render Functions
24
+
25
+ return (
26
+ <li className={className} style={style}>
27
+ {children}
28
+ </li>
29
+ );
30
+ }
31
+
32
+ // Need ListItemMemo for autocompletion of phpstorm
33
+ const ListItemMemo = withMemo(ListItem);
34
+ export { ListItemMemo as ListItem };
@@ -0,0 +1,88 @@
1
+ import * as React from 'react';
2
+ import { ComponentType, CSSProperties, ReactElement, ReactNode, useCallback, useState } from 'react';
3
+ import { RbmComponentProps } from '../RbmComponentProps';
4
+
5
+ import styles from './list.scss';
6
+ import { withMemo } from '../../helper/withMemo';
7
+ import { FixedSizeList, ListChildComponentProps } from 'react-window';
8
+ import AutoSizer from 'react-virtualized-auto-sizer';
9
+ import { SizeCalculator, SizeCalculatorProps } from '../SizeCalculator/SizeCalculator';
10
+
11
+ export type ListProps<ItemType> = RbmComponentProps<{
12
+ renderItem: (item: ItemType, style: CSSProperties, index: number) => ReactElement;
13
+ itemHeight?: number;
14
+ items: ItemType[];
15
+ renderBefore?: (item: ItemType, index: number) => ReactNode;
16
+ keyExtractor?: (item: ItemType, index: number) => string;
17
+ }>;
18
+
19
+ export const List = withMemo(function List<ItemType>({
20
+ items,
21
+ renderItem,
22
+ itemHeight: initialItemHeight = 0,
23
+ className,
24
+ style,
25
+ }: ListProps<ItemType>) {
26
+ // Variables
27
+
28
+ // States
29
+ const [itemHeight, setItemHeight] = useState(initialItemHeight);
30
+
31
+ // Refs
32
+
33
+ // Callbacks
34
+ const renderItemInner = useCallback<ComponentType<ListChildComponentProps>>(
35
+ ({ index, style: itemStyle }) => {
36
+ return renderItem(items[index], itemStyle, index);
37
+ },
38
+ [items, renderItem]
39
+ );
40
+
41
+ const setHeight = useCallback<SizeCalculatorProps['onSize']>((_, height) => {
42
+ setItemHeight(height);
43
+ }, []);
44
+
45
+ // Effects
46
+
47
+ // Other
48
+
49
+ // Render Functions
50
+
51
+ return (
52
+ <AutoSizer>
53
+ {({ height, width }) => {
54
+ return (
55
+ <>
56
+ {initialItemHeight === 0 && items.length > 0 && (
57
+ <SizeCalculator onSize={setHeight} absolute={true}>
58
+ {renderItem(
59
+ items[0],
60
+ {
61
+ position: 'relative',
62
+ top: '0px',
63
+ left: '0px',
64
+ width: '100%',
65
+ zIndex: -1,
66
+ },
67
+ 0
68
+ )}
69
+ </SizeCalculator>
70
+ )}
71
+ <FixedSizeList
72
+ height={height}
73
+ itemCount={items.length}
74
+ width={width}
75
+ itemSize={itemHeight}
76
+ style={style}
77
+ className={className}
78
+ itemData={items}
79
+ >
80
+ {renderItemInner}
81
+ </FixedSizeList>
82
+ </>
83
+ );
84
+ }}
85
+ </AutoSizer>
86
+ );
87
+ },
88
+ styles);
@@ -0,0 +1,30 @@
1
+ .list {
2
+ width: 100%;
3
+ background-color: white;
4
+ list-style-type: none;
5
+ background-image: linear-gradient(var(--border-light), var(--border-light)),
6
+ linear-gradient(var(--border-light), var(--border-light));
7
+ background-size: 100% 1px, 100% 1px;
8
+ background-repeat: no-repeat;
9
+ background-position: bottom, top;
10
+ padding: 0;
11
+ margin: 0;
12
+
13
+ .item {
14
+ position: relative;
15
+ width: 100%;
16
+ list-style: none;
17
+ display: flex;
18
+ padding: 0 0 0 0.9rem;
19
+
20
+ .itemMain {
21
+ flex-grow: 1;
22
+ display: flex;
23
+ background-image: linear-gradient(0deg, var(--border-light), var(--border-light) 100%);
24
+ background-size: 100% 1px;
25
+ background-position: bottom;
26
+ background-repeat: no-repeat;
27
+ padding: 0.75rem 0 0.75rem 0;
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,64 @@
1
+ import * as React from 'react';
2
+ import { RbmComponentProps } from '../RbmComponentProps';
3
+ import { LoadingCircle } from '../LoadingCircle/LoadingCircle';
4
+
5
+ import styles from './loadingArea.scss';
6
+ import { withMemo } from '../../helper/withMemo';
7
+ import classNames from 'classnames';
8
+
9
+ export type LoadingAreaProps = RbmComponentProps<{
10
+ opacity?: number;
11
+ loading: boolean;
12
+ fullWidth?: boolean;
13
+ fullHeight?: boolean;
14
+ fullSize?: boolean;
15
+ }>;
16
+
17
+ function LoadingArea({
18
+ loading,
19
+ fullWidth = false,
20
+ fullSize = false,
21
+ fullHeight = false,
22
+ opacity = 0.65,
23
+ className,
24
+ style,
25
+ children,
26
+ }: LoadingAreaProps) {
27
+ // Variables
28
+ if (fullSize) {
29
+ fullHeight = true;
30
+ fullWidth = true;
31
+ }
32
+
33
+ // States
34
+
35
+ // Refs
36
+
37
+ // Callbacks
38
+
39
+ // Effects
40
+
41
+ // Other
42
+
43
+ // Render Functions
44
+
45
+ return (
46
+ <span
47
+ className={classNames(styles.loadingArea, className, {
48
+ 'full-height': fullHeight,
49
+ 'full-width': fullWidth,
50
+ })}
51
+ style={style}
52
+ >
53
+ {children}
54
+ {loading ? (
55
+ <span className={styles.curtain} style={{ opacity }}>
56
+ <LoadingCircle />
57
+ </span>
58
+ ) : null}
59
+ </span>
60
+ );
61
+ }
62
+
63
+ const LoadingAreaMemo = withMemo(LoadingArea, styles);
64
+ export { LoadingAreaMemo as LoadingArea };
@@ -0,0 +1,19 @@
1
+ .loadingArea {
2
+ height: fit-content;
3
+ width: fit-content;
4
+ position: relative;
5
+ display: contents;
6
+
7
+ .curtain {
8
+ z-index: 1;
9
+ position: absolute;
10
+ top: 0;
11
+ left: 0;
12
+ bottom: 0;
13
+ right: 0;
14
+ display: flex;
15
+ justify-content: center;
16
+ align-items: center;
17
+ background-color: #efeff4;
18
+ }
19
+ }
@@ -0,0 +1,41 @@
1
+ import * as React from 'react';
2
+ import { RbmComponentProps } from '../RbmComponentProps';
3
+
4
+ import styles from './loadingCircle.scss';
5
+ import { withMemo } from '../../helper/withMemo';
6
+ import classNames from 'classnames';
7
+
8
+ export type LoadingCircleProps = RbmComponentProps<{
9
+ size?: number;
10
+ }>;
11
+
12
+ function LoadingCircle({ size = 32, className, style }: LoadingCircleProps) {
13
+ // Variables
14
+
15
+ // States
16
+
17
+ // Refs
18
+
19
+ // Callbacks
20
+
21
+ // Effects
22
+
23
+ // Other
24
+
25
+ // Render Functions
26
+
27
+ return (
28
+ <svg
29
+ className={classNames(styles.loadingCircle, className)}
30
+ viewBox={`0 0 ${size} ${size}`}
31
+ width={size}
32
+ height={size}
33
+ style={style}
34
+ >
35
+ <circle cx="50%" cy="50%" r="40%" fill="none" className={styles.spinner} />
36
+ </svg>
37
+ );
38
+ }
39
+
40
+ const LoadingCircleMemo = withMemo(LoadingCircle, styles);
41
+ export { LoadingCircleMemo as LoadingCircle };
@@ -0,0 +1,42 @@
1
+ @import "../../scss/variables";
2
+ @import "../../scss/designMixin";
3
+
4
+ @keyframes loadingCircle {
5
+ 0% {
6
+ stroke-dasharray: 10%, 241.32%;
7
+ stroke-dashoffset: 0;
8
+ }
9
+ 50% {
10
+ stroke-dasharray: 201%, 50.322%;
11
+ stroke-dashoffset: -100%;
12
+ }
13
+ 100% {
14
+ stroke-dasharray: 10%, 241.32%;
15
+ stroke-dashoffset: -251.32%;
16
+ }
17
+ }
18
+
19
+ @keyframes loadingCircleRotate {
20
+ from {
21
+ transform: rotate(0);
22
+ }
23
+ to {
24
+ transform: rotate(360deg);
25
+ }
26
+ }
27
+
28
+ .loadingCircle {
29
+ .spinner {
30
+ stroke-miterlimit: 10;
31
+ transform-origin: 50%;
32
+ animation: loadingCircle 2s ease-in-out infinite, loadingCircleRotate 1.5s linear infinite;
33
+ stroke: var(--flavor-accent);
34
+
35
+ @include design($material) {
36
+ stroke-width: 9%;
37
+ }
38
+ @include design($flat) {
39
+ stroke-width: 5%;
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,113 @@
1
+ import * as React from 'react';
2
+ import { withMemo } from '../../helper/withMemo';
3
+ import { RbmComponentProps, WithNoChildren } from '../RbmComponentProps';
4
+ import { Icon, IconSource } from '../Icon/Icon';
5
+ import { Block } from '../Layout/Block';
6
+ import classNames from 'classnames';
7
+
8
+ import styles from './menu.scss';
9
+ import { Text } from '../Text/Text';
10
+ import { Clickable } from '../Clickable/Clickable';
11
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
12
+ import { withRenderBrowserOnly } from '../../helper/withRenderBrowserOnly';
13
+ import { useWindow } from '../../WindowContext/WindowContext';
14
+
15
+ export type MenuItem = {
16
+ label: string;
17
+ callback: () => void;
18
+ icon?: IconSource;
19
+ key: string;
20
+ };
21
+
22
+ export type MenuProps = RbmComponentProps<
23
+ { items: MenuItem[]; x: number; y: number; isOpen: boolean; onClose: () => void },
24
+ WithNoChildren
25
+ >;
26
+
27
+ export const Menu = withMemo(
28
+ withRenderBrowserOnly(function Menu({ className, style, items, y, x, isOpen, onClose }: MenuProps) {
29
+ // Variables
30
+
31
+ // Refs
32
+ const menuRef = useRef<HTMLDivElement>(null);
33
+ const window = useWindow();
34
+
35
+ // States
36
+ const [innerX, setInnerX] = useState(x);
37
+ const [innerY, setInnerY] = useState(y);
38
+
39
+ // Selectors
40
+
41
+ // Callbacks
42
+ const callItemCallback = useCallback(
43
+ (_: any, cb: () => void) => {
44
+ onClose();
45
+ cb();
46
+ },
47
+ [onClose]
48
+ );
49
+
50
+ // Effects
51
+ useEffect(() => {
52
+ if (isOpen) {
53
+ const listener = (e: MouseEvent) => {
54
+ if (!menuRef.current?.contains(e.target as Node)) {
55
+ onClose();
56
+ }
57
+ };
58
+ window?.addEventListener('mousedown', listener, { capture: true });
59
+ return () => window?.removeEventListener('mousedown', listener, { capture: true });
60
+ }
61
+ return undefined;
62
+ }, [isOpen, onClose, window]);
63
+
64
+ useLayoutEffect(() => {
65
+ if (!menuRef.current) {
66
+ return;
67
+ }
68
+ const { width } = getComputedStyle(menuRef.current);
69
+ const newX = Math.min(x, (window?.innerWidth ?? 0) - parseFloat(width));
70
+ setInnerX(newX);
71
+ }, [window?.innerWidth, x]);
72
+
73
+ useLayoutEffect(() => {
74
+ if (!menuRef.current) {
75
+ return;
76
+ }
77
+ const height = parseFloat(getComputedStyle(menuRef.current).height);
78
+ let newY = y;
79
+ if (newY > (window?.innerHeight ?? 0) - height) {
80
+ newY -= height;
81
+ }
82
+ setInnerY(newY);
83
+ }, [window?.innerHeight, y]);
84
+
85
+ // Other
86
+
87
+ // Render Functions
88
+ if (!isOpen) {
89
+ return null;
90
+ }
91
+
92
+ return (
93
+ <Block
94
+ className={classNames(className, styles.menu)}
95
+ style={{ ...style, top: innerY, left: innerX }}
96
+ ref={menuRef}
97
+ >
98
+ {items.map((item) => (
99
+ <Clickable
100
+ onClick={callItemCallback}
101
+ onClickData={item.callback}
102
+ className={styles.item}
103
+ key={item.key}
104
+ >
105
+ {!!item.icon && <Icon icon={item.icon} />}
106
+ <Text>{item.label}</Text>
107
+ </Clickable>
108
+ ))}
109
+ </Block>
110
+ );
111
+ }),
112
+ styles
113
+ );
@@ -0,0 +1,21 @@
1
+
2
+ .menu {
3
+ position: fixed;
4
+ background: #ffffff;
5
+ border: 1px solid var(--border-light);
6
+
7
+ .item {
8
+ display: block;
9
+ border-top: 1px solid var(--border-light);
10
+ padding: 8px;
11
+ margin: 0 4px;
12
+
13
+ &:hover {
14
+ background-color: #f5f5f5;
15
+ }
16
+
17
+ &:first-child {
18
+ border-top: none;
19
+ }
20
+ }
21
+ }