@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,153 @@
1
+ @import "../../scss/variables";
2
+ @import "../../scss/designMixin";
3
+
4
+ $zIndexActionSheet: 10000;
5
+
6
+ .actionSheet {
7
+ position: fixed;
8
+ top: 100%;
9
+ left: 0;
10
+ right: 0;
11
+ bottom: 0;
12
+ background-color: rgba(0, 0, 0, 0.1);
13
+ z-index: $zIndexActionSheet;
14
+
15
+ transition-duration: 0s;
16
+ transition-delay: 0.25s;
17
+
18
+ &.open {
19
+ transition-delay: 0s;
20
+ top: 0;
21
+
22
+ > :global(.full-height) {;
23
+ top: 0
24
+ }
25
+ }
26
+
27
+ > :global(.full-height) {
28
+ position: absolute;
29
+ left: 0;
30
+ right: 0;
31
+ bottom: 0;
32
+ top: 100%;
33
+ }
34
+
35
+ .content {
36
+ bottom: 0;
37
+ height: 100%;
38
+
39
+ display: flex;
40
+ flex-direction: column;
41
+ justify-content: end;
42
+
43
+ .action {
44
+ height: 56px;
45
+ width: 100%;
46
+ font-size: 20px;
47
+ background-color: #ffffff;
48
+ border-radius: 0;
49
+ line-height: 56px;
50
+ display: block;
51
+ text-overflow: ellipsis;
52
+ overflow: hidden;
53
+ white-space: nowrap;
54
+ }
55
+
56
+ .cancel {
57
+ height: 56px;
58
+ width: 100%;
59
+ font-size: 20px;
60
+ background-color: #ffffff;
61
+ line-height: 56px;
62
+ display: block;
63
+ text-overflow: ellipsis;
64
+ overflow: hidden;
65
+ white-space: nowrap;
66
+ }
67
+ }
68
+
69
+ @include design($material) {
70
+ > .full-height {
71
+ padding: 0;
72
+ }
73
+
74
+ .content {
75
+ text-align: left;
76
+
77
+ .action {
78
+ padding: 0 0 0 16px;
79
+ color: #686868;
80
+
81
+ .actionIcon {
82
+ display: inline-block;
83
+ float: left;
84
+ margin-right: 32px;
85
+ font-size: 26px;
86
+ text-align: center;
87
+ width: 0.8em;
88
+ height: 56px;
89
+ }
90
+ }
91
+
92
+ .cancel {
93
+ padding: 0 0 0 16px;
94
+ color: #686868;
95
+
96
+ .actionIcon {
97
+ display: inline-block;
98
+ float: left;
99
+ margin-right: 32px;
100
+ font-size: 1rem;
101
+ text-align: center;
102
+ width: 0.8em;
103
+ height: 56px;
104
+ }
105
+ }
106
+ }
107
+ }
108
+
109
+ @include design($flat) {
110
+ .content {
111
+
112
+ text-align: center;
113
+
114
+ padding-right: 10px;
115
+ padding-left: 10px;
116
+ padding-bottom: 10px;
117
+
118
+ .action {
119
+ color: var(--flavor-accent);
120
+
121
+ background-size: 100% 1px;
122
+ background-repeat: no-repeat;
123
+ background-position: bottom;
124
+ background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1) 100%);
125
+
126
+ &:first-child {
127
+ border-top-right-radius: 12px;
128
+ border-top-left-radius: 12px;
129
+ }
130
+
131
+ &:nth-last-child(2) {
132
+ border-bottom-right-radius: 12px;
133
+ border-bottom-left-radius: 12px;
134
+ }
135
+
136
+ .actionIcon {
137
+ display: none;
138
+ }
139
+ }
140
+
141
+ .cancel {
142
+ color: var(--flavor-accent);
143
+
144
+ border-radius: 12px;
145
+ margin: 8px 0 0 0;
146
+
147
+ .actionIcon {
148
+ display: none;
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
@@ -0,0 +1,46 @@
1
+ import * as React from 'react';
2
+ import { RbmComponentProps } from '../RbmComponentProps';
3
+
4
+ import styles from './card.scss';
5
+ import { withMemo } from '../../helper/withMemo';
6
+ import classNames from 'classnames';
7
+ import { ReactElement } from 'react';
8
+
9
+ export type CardProps = RbmComponentProps<{
10
+ title?: string | ReactElement;
11
+ fullHeight?: boolean;
12
+ noPaddingHeight?: boolean;
13
+ noPaddingWidth?: boolean;
14
+ noPadding?: boolean;
15
+ noMargin?: boolean;
16
+ }>;
17
+
18
+ function Card({
19
+ title,
20
+ children,
21
+ fullHeight = false,
22
+ noPaddingHeight = false,
23
+ noPadding = false,
24
+ noPaddingWidth = false,
25
+ noMargin = false,
26
+ className,
27
+ ...rbmProps
28
+ }: CardProps) {
29
+ const classes = classNames(styles.card, className, {
30
+ [styles.fullHeight]: fullHeight,
31
+ [styles.noPadding]: noPadding,
32
+ [styles.noMargin]: noMargin,
33
+ [styles.noPaddingHeight]: noPaddingHeight,
34
+ [styles.noPaddingWidth]: noPaddingWidth,
35
+ });
36
+
37
+ return (
38
+ <div {...rbmProps} className={classes}>
39
+ {title ? <div className={styles.title}>{title}</div> : null}
40
+ <div className={styles.content}>{children}</div>
41
+ </div>
42
+ );
43
+ }
44
+
45
+ const CardMemo = withMemo(Card, styles);
46
+ export { CardMemo as Card };
@@ -0,0 +1,76 @@
1
+ @import "../../scss/variables";
2
+ @import "../../scss/designMixin";
3
+
4
+ $marginCard: 8px;
5
+
6
+ .card {
7
+ margin: $marginCard;
8
+ padding: 16px;
9
+ word-wrap: break-word;
10
+ background-color: #ffffff;
11
+
12
+ &.fullHeight {
13
+ height: calc(100% - #{2*$marginCard})
14
+ }
15
+
16
+ &.noPaddingHeight {
17
+ padding-top: 0;
18
+ padding-bottom: 0;
19
+ }
20
+
21
+ &.noPaddingWidth {
22
+ padding-left: 0;
23
+ padding-right: 0;
24
+ }
25
+
26
+ &.noPadding {
27
+ padding: 0
28
+ }
29
+
30
+ &.noMargin {
31
+ margin: 0;
32
+
33
+ &.fullHeight {
34
+ height: 100%
35
+ }
36
+ }
37
+
38
+ .content {
39
+ font-size: $fontSizeBase;
40
+ margin: 0;
41
+ line-height: 1.4;
42
+ }
43
+
44
+ .title {
45
+ padding: 0;
46
+ }
47
+
48
+ @include design($material) {
49
+ border-radius: 2px;
50
+ box-shadow: $boxShadowMaterial;
51
+
52
+ .content {
53
+ color: #000000;
54
+ color: rgba(0, 0, 0, 0.54);
55
+ }
56
+
57
+ .title {
58
+ margin: 8px 0 12px 0;
59
+ font-size: 24px;
60
+ }
61
+ }
62
+
63
+ @include design($flat) {
64
+ border-radius: 8px;
65
+ box-shadow: 0 1px 2px 0 rgb(0 0 0 / 12%);
66
+
67
+ .content {
68
+ color: #030303;
69
+ }
70
+
71
+ .title {
72
+ margin: 4px 0 8px 0;
73
+ font-size: 20px;
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,174 @@
1
+ import * as React from 'react';
2
+ import { RbmComponentProps } from '../RbmComponentProps';
3
+ import { OptionalListener, useListener } from '../Hooks/useListener';
4
+
5
+ import styles from './clickable.scss';
6
+ import classNames from 'classnames';
7
+ import { useCallback, MouseEvent, ForwardedRef } from 'react';
8
+ import { withForwardRef } from '../../helper/withForwardRef';
9
+
10
+ type OnClickListener<Data> = OptionalListener<'onClick', Data>;
11
+ type OnMouseDownListener<Data> = OptionalListener<'onMouseDown', Data>;
12
+ type OnMouseUpListener<Data> = OptionalListener<'onMouseUp', Data>;
13
+ type OnMouseMoveListener<Data> = OptionalListener<'onMouseMove', Data>;
14
+
15
+ export type ClickableProps<
16
+ OnClickData,
17
+ OnMouseDownData,
18
+ OnMouseMoveData,
19
+ OnMouseUpData,
20
+ OnClickCaptureData,
21
+ HrefType extends string | undefined
22
+ > = RbmComponentProps<
23
+ {
24
+ interactable?: boolean;
25
+ href?: HrefType;
26
+ preventDefault?: boolean;
27
+ stopPropagation?: boolean;
28
+ } & OnClickListener<OnClickData> &
29
+ OnMouseDownListener<OnMouseDownData> &
30
+ OnMouseMoveListener<OnMouseMoveData> &
31
+ OnMouseUpListener<OnMouseUpData> &
32
+ OptionalListener<'onClickCapture', OnClickCaptureData>
33
+ >;
34
+
35
+ function Clickable<
36
+ OnClickData,
37
+ OnMouseDownData,
38
+ OnMouseMoveData,
39
+ OnMouseUpData,
40
+ OnClickCaptureData,
41
+ HrefType extends string | undefined
42
+ >(
43
+ {
44
+ className,
45
+ children,
46
+ style,
47
+ href,
48
+ interactable = true,
49
+ preventDefault = true,
50
+ stopPropagation = true,
51
+ ...clickData
52
+ }: ClickableProps<OnClickData, OnMouseDownData, OnMouseMoveData, OnMouseUpData, OnClickCaptureData, HrefType>,
53
+ ref: ForwardedRef<HrefType extends string ? HTMLAnchorElement : HTMLSpanElement>
54
+ ) {
55
+ // Variables
56
+
57
+ // States
58
+
59
+ // Refs
60
+
61
+ // Callbacks
62
+ const onClickInner = useListener<'onClick', OnClickData>('onClick', clickData);
63
+ const realOnClick = useCallback(
64
+ (e: MouseEvent) => {
65
+ if (clickData.onClick) {
66
+ if (stopPropagation) {
67
+ e.stopPropagation();
68
+ }
69
+ if (preventDefault) {
70
+ e.preventDefault();
71
+ }
72
+ onClickInner(e);
73
+ }
74
+ },
75
+ [clickData.onClick, onClickInner, preventDefault, stopPropagation]
76
+ );
77
+
78
+ const onMouseDownInner = useListener<'onMouseDown', OnMouseDownData>('onMouseDown', clickData);
79
+ const realOnMouseDown = useCallback(
80
+ (e: MouseEvent) => {
81
+ if (clickData.onMouseDown) {
82
+ if (stopPropagation) {
83
+ e.stopPropagation();
84
+ }
85
+ if (preventDefault) {
86
+ e.preventDefault();
87
+ }
88
+ onMouseDownInner(e);
89
+ }
90
+ },
91
+ [clickData.onMouseDown, onMouseDownInner, preventDefault, stopPropagation]
92
+ );
93
+
94
+ const onMouseMoveInner = useListener<'onMouseMove', OnMouseMoveData>('onMouseMove', clickData);
95
+ const realOnMouseMove = useCallback(
96
+ (e: MouseEvent) => {
97
+ if (clickData.onMouseMove) {
98
+ if (stopPropagation) {
99
+ e.stopPropagation();
100
+ }
101
+ if (preventDefault) {
102
+ e.preventDefault();
103
+ }
104
+ onMouseMoveInner(e);
105
+ }
106
+ },
107
+ [clickData.onMouseMove, onMouseMoveInner, preventDefault, stopPropagation]
108
+ );
109
+
110
+ const onMouseUpInner = useListener<'onMouseUp', OnMouseUpData>('onMouseUp', clickData);
111
+ const realOnMouseUp = useCallback(
112
+ (e: MouseEvent) => {
113
+ if (clickData.onMouseUp) {
114
+ if (stopPropagation) {
115
+ e.stopPropagation();
116
+ }
117
+ if (preventDefault) {
118
+ e.preventDefault();
119
+ }
120
+ onMouseUpInner(e);
121
+ }
122
+ },
123
+ [clickData.onMouseUp, onMouseUpInner, preventDefault, stopPropagation]
124
+ );
125
+
126
+ const onClickCaptureInner = useListener<'onClickCapture', OnClickCaptureData>('onClickCapture', clickData);
127
+ const realOnClickCaptureInner = useCallback(
128
+ (e: MouseEvent) => {
129
+ if (clickData.onClickCapture) {
130
+ if (stopPropagation) {
131
+ e.stopPropagation();
132
+ }
133
+ if (preventDefault) {
134
+ e.preventDefault();
135
+ }
136
+ onClickCaptureInner(e);
137
+ }
138
+ },
139
+ [clickData.onClickCapture, onClickCaptureInner, preventDefault, stopPropagation]
140
+ );
141
+
142
+ // Effects
143
+
144
+ // Other
145
+
146
+ // Render Functions
147
+ const props = {
148
+ style,
149
+ role: interactable ? 'button' : undefined,
150
+ 'aria-hidden': interactable ? undefined : true,
151
+ className: classNames(styles.clickable, className),
152
+ onClick: realOnClick,
153
+ onMouseDown: realOnMouseDown,
154
+ onMouseMove: realOnMouseMove,
155
+ onMouseUp: realOnMouseUp,
156
+ onClickCapture: realOnClickCaptureInner,
157
+ tabIndex: interactable ? 0 : undefined,
158
+ };
159
+ if (typeof href === 'string') {
160
+ return (
161
+ <a {...props} href={href} ref={ref as ForwardedRef<HTMLAnchorElement>}>
162
+ {children}
163
+ </a>
164
+ );
165
+ }
166
+ return (
167
+ <span {...props} ref={ref as ForwardedRef<HTMLSpanElement>}>
168
+ {children}
169
+ </span>
170
+ );
171
+ }
172
+
173
+ const ClickableMemo = withForwardRef(Clickable, styles);
174
+ export { ClickableMemo as Clickable };
@@ -0,0 +1,3 @@
1
+ .clickable {
2
+ cursor: pointer;
3
+ }
@@ -0,0 +1,44 @@
1
+ import * as React from 'react';
2
+ import { useMemo } from 'react';
3
+ import { withMemo } from '../../helper/withMemo';
4
+ import { ButtonDialog } from './ButtonDialog';
5
+
6
+ export type AlertDialogProps = {
7
+ title?: string;
8
+ message: string;
9
+ close: () => void;
10
+ confirmText?: string;
11
+ };
12
+
13
+ function AlertDialog({ title, message, close, confirmText = 'OK' }: AlertDialogProps) {
14
+ // Variables
15
+ const buttons = useMemo(
16
+ () => [
17
+ {
18
+ text: confirmText,
19
+ callback: () => close(),
20
+ },
21
+ ],
22
+ [close, confirmText]
23
+ );
24
+
25
+ // Refs
26
+
27
+ // States
28
+
29
+ // Selectors
30
+
31
+ // Callbacks
32
+
33
+ // Effects
34
+
35
+ // Other
36
+
37
+ // Render Functions
38
+
39
+ return <ButtonDialog message={message} buttons={buttons} title={title} />;
40
+ }
41
+
42
+ // Need AlertDialogMemo for autocompletion of phpstorm
43
+ const AlertDialogMemo = withMemo(AlertDialog);
44
+ export { AlertDialogMemo as AlertDialog };
@@ -0,0 +1,57 @@
1
+ import * as React from 'react';
2
+ import { withMemo } from '../../helper/withMemo';
3
+ import { Block } from '../Layout/Block';
4
+ import { Text } from '../Text/Text';
5
+ import { Clickable } from '../Clickable/Clickable';
6
+
7
+ import styles from './buttonDialog.scss';
8
+ import { RbmComponentProps, WithNoChildren } from '../RbmComponentProps';
9
+ import classNames from 'classnames';
10
+
11
+ export type ButtonDialogProps = RbmComponentProps<
12
+ { title?: string; message: string; buttons: { text: string; callback: () => void }[] },
13
+ WithNoChildren
14
+ >;
15
+
16
+ function ButtonDialog({ title, message, buttons, style, className }: ButtonDialogProps) {
17
+ // Variables
18
+
19
+ // Refs
20
+
21
+ // States
22
+
23
+ // Selectors
24
+
25
+ // Callbacks
26
+
27
+ // Effects
28
+
29
+ // Other
30
+
31
+ // Render Functions
32
+
33
+ return (
34
+ <Block className={classNames(styles.buttonDialog, className)} style={style}>
35
+ {!!title && (
36
+ <Block className={styles.title}>
37
+ <Text>{title}</Text>
38
+ </Block>
39
+ )}
40
+ <Block className={styles.message}>
41
+ <Text>{message}</Text>
42
+ </Block>
43
+ <Block className={styles.buttonContainer}>
44
+ {buttons.map((b, i) => (
45
+ // eslint-disable-next-line react/no-array-index-key
46
+ <Clickable onClick={b.callback} className={styles.button} key={i + b.text}>
47
+ <Text>{b.text}</Text>
48
+ </Clickable>
49
+ ))}
50
+ </Block>
51
+ </Block>
52
+ );
53
+ }
54
+
55
+ // Need ButtonDialogMemo for autocompletion of phpstorm
56
+ const ButtonDialogMemo = withMemo(ButtonDialog, styles);
57
+ export { ButtonDialogMemo as ButtonDialog };
@@ -0,0 +1,46 @@
1
+ import * as React from 'react';
2
+ import { useMemo } from 'react';
3
+ import { withMemo } from '../../helper/withMemo';
4
+ import { ButtonDialog } from './ButtonDialog';
5
+
6
+ export type ConfirmDialogProps = {
7
+ title?: string;
8
+ message: string;
9
+ close: (confirmed: boolean) => void;
10
+ cancelText?: string;
11
+ confirmText?: string;
12
+ };
13
+
14
+ function ConfirmDialog({ title, message, close, cancelText = 'Cancel', confirmText = 'OK' }: ConfirmDialogProps) {
15
+ // Variables
16
+ const buttons = useMemo(
17
+ () => [
18
+ {
19
+ text: confirmText,
20
+ callback: () => close(true),
21
+ },
22
+ { text: cancelText, callback: () => close(false) },
23
+ ],
24
+ [cancelText, close, confirmText]
25
+ );
26
+
27
+ // Refs
28
+
29
+ // States
30
+
31
+ // Selectors
32
+
33
+ // Callbacks
34
+
35
+ // Effects
36
+
37
+ // Other
38
+
39
+ // Render Functions
40
+
41
+ return <ButtonDialog message={message} buttons={buttons} title={title} />;
42
+ }
43
+
44
+ // Need ConfirmDialogMemo for autocompletion of phpstorm
45
+ const ConfirmDialogMemo = withMemo(ConfirmDialog);
46
+ export { ConfirmDialogMemo as ConfirmDialog };
@@ -0,0 +1,82 @@
1
+ import * as React from 'react';
2
+ import classNames from 'classnames';
3
+
4
+ import styles from './dialog.scss';
5
+ import { RbmComponentProps } from '../RbmComponentProps';
6
+ import { withMemo } from '../../helper/withMemo';
7
+ import { InlineBlock } from '../Layout/InlineBlock';
8
+ import { Block } from '../Layout/Block';
9
+ import { ReactElement, useCallback, useState } from 'react';
10
+ import { Clickable } from '../Clickable/Clickable';
11
+
12
+ export type DialogProps<ReturnData> = RbmComponentProps<
13
+ {
14
+ closable?: boolean;
15
+ onClose?: (data?: ReturnData, identifier?: number) => void;
16
+ identifier?: number;
17
+ },
18
+ {
19
+ children: ReactElement<Record<string, any> & { close?: (data?: ReturnData) => void }> | string | number;
20
+ }
21
+ >;
22
+
23
+ function Dialog<ReturnData>({
24
+ style,
25
+ children,
26
+ className,
27
+ closable = true,
28
+ onClose,
29
+ identifier,
30
+ }: DialogProps<ReturnData>) {
31
+ // Variables
32
+ const [isClosed, setIsClosed] = useState(false);
33
+
34
+ // Refs
35
+
36
+ // States
37
+
38
+ // Selectors
39
+
40
+ // Callbacks
41
+ const close = useCallback(
42
+ (data?: ReturnData) => {
43
+ setIsClosed(true);
44
+ onClose?.(data, identifier);
45
+ },
46
+ [identifier, onClose]
47
+ );
48
+
49
+ const onCurtainClick = useCallback(() => {
50
+ if (!closable) {
51
+ return;
52
+ }
53
+ close();
54
+ }, [closable, close]);
55
+
56
+ // Effects
57
+
58
+ // Other
59
+
60
+ // Render Functions
61
+ if (isClosed) {
62
+ return null;
63
+ }
64
+
65
+ return (
66
+ <Block className={classNames(styles.dialogContainer, className)} __allowChildren="all" style={style}>
67
+ <Clickable onClick={onCurtainClick} className={styles.closeCurtain} interactable={closable} />
68
+ <InlineBlock __allowChildren="all" className={styles.dialog}>
69
+ {React.Children.map(children, (child) => {
70
+ if (React.isValidElement(child)) {
71
+ return React.cloneElement(child, { close });
72
+ }
73
+ return child;
74
+ })}
75
+ </InlineBlock>
76
+ </Block>
77
+ );
78
+ }
79
+
80
+ // Need Dialog Memo for autocompletion of phpstorm
81
+ const DialogMemo = withMemo(Dialog, styles);
82
+ export { DialogMemo as Dialog };