@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,182 @@
1
+ import * as React from 'react';
2
+ import {
3
+ Cell,
4
+ Column as RTColumn,
5
+ HeaderGroup,
6
+ PluginHook,
7
+ Row,
8
+ TableOptions,
9
+ useSortBy,
10
+ UseSortByOptions,
11
+ useTable,
12
+ } from 'react-table';
13
+ import { RbmComponentProps } from '../RbmComponentProps';
14
+ import { ReactNode } from 'react';
15
+ import { withMemo } from '../../helper/withMemo';
16
+
17
+ export type ColumnCellData<DataType extends string | number | Record<string, unknown>> = {
18
+ value: DataType;
19
+ cell: {
20
+ column: {
21
+ id: string;
22
+ };
23
+ row: {
24
+ original: Record<string, DataType>;
25
+ index: number;
26
+ id: string;
27
+ };
28
+ };
29
+ };
30
+
31
+ export type Column<DataType extends string | number | Record<string, unknown>> = RTColumn<Record<string, DataType>> & {
32
+ Cell?: (cellData: ColumnCellData<DataType>) => ReactNode;
33
+ };
34
+
35
+ export type TableSortOptions<DataType extends string | number | Record<string, unknown>> = UseSortByOptions<
36
+ Record<string, DataType>
37
+ > & {
38
+ renderSortIndicator?: (column: HeaderGroup<Record<string, DataType>>) => ReactNode;
39
+ };
40
+
41
+ export type TableProps<DataType extends string | number | Record<string, unknown>> = RbmComponentProps<{
42
+ columns: Column<DataType>[];
43
+ data: Record<string, DataType>[];
44
+ cellRenderer?: ({ value }: { value: DataType }) => ReactNode;
45
+ sortOptions?: TableSortOptions<DataType>;
46
+ getCellProperties?: (row: Cell<Record<string, DataType>>) => React.TdHTMLAttributes<HTMLTableDataCellElement>;
47
+ getRowProperties?: (row: Row<Record<string, DataType>>) => React.HTMLAttributes<HTMLTableRowElement>;
48
+ }>;
49
+
50
+ const defaultPropertiesGetter = () => ({});
51
+
52
+ function Table<DataType extends string | number | Record<string, unknown>>({
53
+ columns,
54
+ data,
55
+ cellRenderer,
56
+ sortOptions,
57
+ className,
58
+ style,
59
+ getCellProperties = defaultPropertiesGetter,
60
+ getRowProperties = defaultPropertiesGetter,
61
+ }: TableProps<DataType>) {
62
+ // Variables
63
+
64
+ if (cellRenderer) {
65
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
+ // @ts-ignore
67
+ columns.forEach((c) => (c.Cell = c.Cell ?? cellRenderer));
68
+ }
69
+
70
+ columns.forEach((c) => {
71
+ if (!('width' in c)) {
72
+ c.width = 0;
73
+ }
74
+ });
75
+
76
+ let tableOptions: TableOptions<Record<string, DataType>> = {
77
+ columns,
78
+ data,
79
+ };
80
+
81
+ const plugins: PluginHook<Record<string, DataType>>[] = [];
82
+
83
+ if (sortOptions) {
84
+ tableOptions = {
85
+ autoResetSortBy: false,
86
+ ...sortOptions,
87
+ ...tableOptions,
88
+ };
89
+ plugins.push(useSortBy);
90
+ }
91
+
92
+ const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable<Record<string, DataType>>(
93
+ tableOptions,
94
+ ...plugins
95
+ );
96
+
97
+ // States
98
+
99
+ // Refs
100
+
101
+ // Callbacks
102
+
103
+ // Effects
104
+
105
+ // Other
106
+
107
+ // Render Functions
108
+ const renderSorting = (column: HeaderGroup<Record<string, DataType>>) => {
109
+ if (sortOptions?.renderSortIndicator) {
110
+ return sortOptions.renderSortIndicator(column);
111
+ }
112
+ if (column.isSorted) return <span>{column.isSortedDesc ? ' ↓' : ' ↑'}</span>;
113
+ return null;
114
+ };
115
+
116
+ return (
117
+ // apply the table props
118
+ <table className={className} {...getTableProps()} style={style}>
119
+ <thead>
120
+ {
121
+ // Loop over the header rows
122
+ headerGroups.map((headerGroup) => (
123
+ // Apply the header row props
124
+ <tr {...headerGroup.getHeaderGroupProps()}>
125
+ {
126
+ // Loop over the headers in each row
127
+ headerGroup.headers.map((column) => (
128
+ // Apply the header cell props
129
+ <th
130
+ {...column.getHeaderProps(
131
+ sortOptions ? column.getSortByToggleProps() : undefined
132
+ )}
133
+ >
134
+ {
135
+ // Render the header
136
+ column.render('Header')
137
+ }
138
+ {renderSorting(column)}
139
+ </th>
140
+ ))
141
+ }
142
+ </tr>
143
+ ))
144
+ }
145
+ </thead>
146
+ {/* Apply the table body props */}
147
+ <tbody {...getTableBodyProps()}>
148
+ {
149
+ // Loop over the table rows
150
+ rows.map((row) => {
151
+ // Prepare the row for display
152
+ prepareRow(row);
153
+ return (
154
+ // Apply the row props
155
+ <tr {...row.getRowProps(getRowProperties(row))}>
156
+ {
157
+ // Loop over the rows cells
158
+ row.cells.map((cell) => {
159
+ const width = cell.column.width || undefined;
160
+
161
+ // Apply the cell props
162
+ return (
163
+ <td {...cell.getCellProps(getCellProperties(cell))} width={width}>
164
+ {
165
+ // Render the cell contents
166
+ cell.render('Cell')
167
+ }
168
+ </td>
169
+ );
170
+ })
171
+ }
172
+ </tr>
173
+ );
174
+ })
175
+ }
176
+ </tbody>
177
+ </table>
178
+ );
179
+ }
180
+
181
+ const tmp = withMemo(Table);
182
+ export { tmp as Table };
@@ -0,0 +1,44 @@
1
+ import * as React from 'react';
2
+ import { withMemo } from '../../helper/withMemo';
3
+ import { Text, TEXT_PRIO, TEXT_SIZE } from './Text';
4
+ import { RbmComponentProps, WithStringProps } from '../RbmComponentProps';
5
+
6
+ import styles from './heading.scss';
7
+ import classNames from 'classnames';
8
+ import { EmptyProps } from '../../helper/EmptyProps';
9
+
10
+ export type HeadingProps = RbmComponentProps<EmptyProps, WithStringProps>;
11
+
12
+ function Heading({ children, className, style }: HeadingProps) {
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
+
29
+ return (
30
+ <Text
31
+ as="h1"
32
+ size={TEXT_SIZE.xxLarge}
33
+ prio={TEXT_PRIO.heading}
34
+ className={classNames(styles.heading, className)}
35
+ style={style}
36
+ >
37
+ {children}
38
+ </Text>
39
+ );
40
+ }
41
+
42
+ // Need HeadingMemo for autocompletion of phpstorm
43
+ const HeadingMemo = withMemo(Heading, styles, 'text');
44
+ export { HeadingMemo as Heading };
@@ -0,0 +1,79 @@
1
+ import * as React from 'react';
2
+ import classNames from 'classnames';
3
+
4
+ import styles from './text.scss';
5
+ import { Recursive, ValueOf } from '../../TypeHelpers';
6
+ import { WrongChildError } from '../../WrongChildError';
7
+ import withStyles from 'isomorphic-style-loader/withStyles';
8
+ import { Inline } from '../Layout/Inline';
9
+ import { ViewProps } from '../Layout/View';
10
+
11
+ export const TEXT_PRIO = {
12
+ primary: styles.primary,
13
+ secondary: styles.secondary,
14
+ heading: styles.heading,
15
+ };
16
+
17
+ export const TEXT_SIZE = {
18
+ xSmall: styles.xsmall,
19
+ small: styles.small,
20
+ medium: styles.medium,
21
+ large: styles.large,
22
+ xLarge: styles.xlarge,
23
+ xxLarge: styles.xxlarge,
24
+ };
25
+
26
+ export type TextProps<AsType extends keyof JSX.IntrinsicElements> = {
27
+ block?: boolean;
28
+ prio?: ValueOf<typeof TEXT_PRIO>;
29
+ size?: ValueOf<typeof TEXT_SIZE>;
30
+ className?: string;
31
+ children: Recursive<string | undefined | null | number>;
32
+ } & ViewProps<AsType>;
33
+
34
+ function Text<AsType extends keyof JSX.IntrinsicElements = 'span'>({
35
+ className,
36
+ children,
37
+ block = false,
38
+ prio,
39
+ size = TEXT_SIZE.medium,
40
+ as = 'span' as AsType,
41
+ ...props
42
+ }: TextProps<AsType>) {
43
+ // Variables
44
+ prio = prio ?? styles.primaryDefault;
45
+
46
+ // States
47
+
48
+ // Refs
49
+
50
+ // Callbacks
51
+
52
+ // Effects
53
+
54
+ // Other
55
+ React.Children.forEach(children, (child) => {
56
+ const type = typeof child;
57
+ if (
58
+ (type !== 'string' && type !== 'undefined' && type !== 'object' && type !== 'number') ||
59
+ (type === 'object' && child !== null)
60
+ ) {
61
+ throw new WrongChildError('string, number, undefined, null', type, child, 'Text');
62
+ }
63
+ });
64
+
65
+ // Render Functions
66
+ return (
67
+ <Inline
68
+ __allowChildren="text"
69
+ as={as}
70
+ {...props}
71
+ className={classNames(styles.text, { [styles.block]: block }, prio, size, className)}
72
+ >
73
+ {children}
74
+ </Inline>
75
+ );
76
+ }
77
+
78
+ const tmp = React.memo(withStyles(styles)(Text)) as typeof Text;
79
+ export { tmp as Text };
@@ -0,0 +1,3 @@
1
+ .heading {
2
+ display: block;
3
+ }
@@ -0,0 +1,60 @@
1
+ $primaryColor: #000000;
2
+ $secondaryColor: #717171;
3
+
4
+ :root {
5
+ --text-primary-default-color: $primaryColor;
6
+ }
7
+
8
+ .text {
9
+ display: inline;
10
+
11
+ &.block {
12
+ display: block;
13
+ }
14
+
15
+ &.heading {
16
+ font-weight: bold;
17
+ }
18
+
19
+ &.primaryDefault {
20
+ color: var(--text-primary-default-color)
21
+ }
22
+
23
+ &.primary {
24
+ color: $primaryColor
25
+ }
26
+
27
+ &.secondary {
28
+ color: $secondaryColor;
29
+ }
30
+
31
+ &.xsmall {
32
+ font-size: 0.75rem;
33
+ line-height: 1rem;
34
+ }
35
+
36
+ &.small {
37
+ font-size: 0.875rem;
38
+ line-height: 1.25rem;
39
+ }
40
+
41
+ &.medium {
42
+ font-size: 1rem;
43
+ line-height: 1.5rem;
44
+ }
45
+
46
+ &.large {
47
+ font-size: 1.125rem;
48
+ line-height: 1.75;
49
+ }
50
+
51
+ &.xlarge {
52
+ font-size: 1.25rem;
53
+ line-height: 1.75rem;
54
+ }
55
+
56
+ &.xxlarge {
57
+ font-size: 1.5rem;
58
+ line-height: 2rem;
59
+ }
60
+ }
@@ -0,0 +1,107 @@
1
+ import * as React from 'react';
2
+ import { RbmComponentProps, WithNoStringAndChildrenProps } from '../RbmComponentProps';
3
+ import { Clickable } from '../Clickable/Clickable';
4
+ import { ReactNode, useCallback, useEffect, useState } from 'react';
5
+ import { Listener, OptionalListener, useListener } from '../Hooks/useListener';
6
+
7
+ import styles from './toast.scss';
8
+ import { withMemo } from '../../helper/withMemo';
9
+ import classNames from 'classnames';
10
+
11
+ type WithoutActionProps<DismissedData> = {
12
+ timeToShow?: number;
13
+ } & OptionalListener<'onDismissed', DismissedData>;
14
+ type WithActionProps<ActionData, DismissedData> = WithoutActionProps<DismissedData> & {
15
+ actionName: string;
16
+ } & Listener<'onClick', ActionData>;
17
+
18
+ export type ToastProps<ActionData, DismissedData> = RbmComponentProps<
19
+ WithActionProps<ActionData, DismissedData> | WithoutActionProps<DismissedData>,
20
+ WithNoStringAndChildrenProps
21
+ >;
22
+
23
+ function Toast<ActionData, DismissedData>({
24
+ className,
25
+ timeToShow = 0,
26
+ children,
27
+ style,
28
+ ...otherProps
29
+ }: ToastProps<ActionData, DismissedData>) {
30
+ // Variables
31
+
32
+ const ANIMATION_DURATION = 250;
33
+
34
+ // States
35
+ const [hidingStart, setHidingStart] = useState<number>(0);
36
+ const [startShow] = useState(new Date().getTime());
37
+ const isHidden = hidingStart > 0 && ANIMATION_DURATION + hidingStart < new Date().getTime();
38
+
39
+ // Refs
40
+
41
+ // Callbacks
42
+ const updateHidingStart = useCallback(() => {
43
+ setHidingStart((oldHidingStart) => (oldHidingStart > 0 ? oldHidingStart : new Date().getTime()));
44
+ }, [setHidingStart]);
45
+
46
+ const onDismissed = useListener('onDismissed', otherProps);
47
+
48
+ // Effects
49
+ useEffect(() => {
50
+ if (timeToShow > 0) {
51
+ const diff = timeToShow + startShow - new Date().getTime();
52
+ const timeout = setTimeout(updateHidingStart, diff);
53
+ return () => {
54
+ if (timeout) {
55
+ clearTimeout(timeout);
56
+ }
57
+ };
58
+ }
59
+ return undefined;
60
+ }, [timeToShow, updateHidingStart, startShow]);
61
+
62
+ useEffect(() => {
63
+ if (hidingStart > 0) {
64
+ const diff = hidingStart + ANIMATION_DURATION - new Date().getTime();
65
+ if (diff > 0) {
66
+ const timeout = setTimeout(() => onDismissed, diff);
67
+ return () => {
68
+ if (timeout) {
69
+ clearTimeout(timeout);
70
+ }
71
+ };
72
+ }
73
+ }
74
+ return undefined;
75
+ }, [hidingStart, onDismissed, otherProps]);
76
+
77
+ // Other
78
+
79
+ // Render Functions
80
+ if (isHidden) {
81
+ return null;
82
+ }
83
+
84
+ let actionElement: ReactNode = null;
85
+ if ('onClick' in otherProps) {
86
+ actionElement = (
87
+ <Clickable className={styles.action} {...otherProps} __allowChildren="all">
88
+ {otherProps.actionName}
89
+ </Clickable>
90
+ );
91
+ }
92
+
93
+ return (
94
+ <Clickable
95
+ style={style}
96
+ className={classNames(styles.toast, { [styles.hiding]: hidingStart > 0 }, className)}
97
+ onClick={updateHidingStart}
98
+ __allowChildren="all"
99
+ >
100
+ <span>{children}</span>
101
+ {actionElement}
102
+ </Clickable>
103
+ );
104
+ }
105
+
106
+ const ToastMemo = withMemo(Toast, styles, 'text');
107
+ export { ToastMemo as Toast };
@@ -0,0 +1,35 @@
1
+ import * as React from 'react';
2
+ import { RbmComponentProps } from '../RbmComponentProps';
3
+ import { Container } from '../Layout/Container';
4
+
5
+ import styles from './toast.scss';
6
+ import classNames from 'classnames';
7
+ import { withMemo } from '../../helper/withMemo';
8
+ import { EmptyProps } from '../../helper/EmptyProps';
9
+
10
+ export type ToastContainerProps = RbmComponentProps<EmptyProps>;
11
+
12
+ function ToastContainer({ className, children, style }: ToastContainerProps) {
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
+ <Container className={classNames(styles.toastContainer, className)} fluid __allowChildren="all" style={style}>
29
+ {children}
30
+ </Container>
31
+ );
32
+ }
33
+
34
+ const ToastContainerMemo = withMemo(ToastContainer, styles);
35
+ export { ToastContainerMemo as ToastContainer };
@@ -0,0 +1,52 @@
1
+ @import "../../scss/variables";
2
+ @import "../../scss/designMixin";
3
+
4
+ .toastContainer {
5
+ position: fixed;
6
+ left: 0;
7
+ right: 0;
8
+ bottom: 3rem;
9
+ margin: auto;
10
+ max-width: map-get($grid-breakpoints, "sm");
11
+ z-index: 1;
12
+ display: flex;
13
+ align-items: center;
14
+ flex-direction: column;
15
+ }
16
+
17
+ .toast {
18
+ background-color: rgba(0, 0, 0, 0.8);
19
+ min-height: 48px;
20
+ line-height: 1.5;
21
+ color: white;
22
+ font-size: 0.77rem;
23
+ letter-spacing: normal;
24
+ transition-duration: 0.25s;
25
+ margin: 8px;
26
+
27
+ &.hiding {
28
+ opacity: 0;
29
+ }
30
+
31
+ @include design($material) {
32
+ padding: 16px 24px;
33
+ }
34
+
35
+ @include design($flat) {
36
+ border-radius: 0.5rem;
37
+ padding: 16px;
38
+ }
39
+
40
+ .action {
41
+ text-transform: uppercase;
42
+ margin-left: 24px;
43
+
44
+ @include design($material) {
45
+ color: #bbdefb
46
+ }
47
+ @include design($flat) {
48
+ color: #ffffff;
49
+ }
50
+ }
51
+
52
+ }
@@ -0,0 +1,38 @@
1
+ import * as React from 'react';
2
+ import { RbmComponentProps } from '../RbmComponentProps';
3
+ import { TopBarButton } from './TopBarButton';
4
+ import { Icon } from '../Icon/Icon';
5
+ import { faEllipsisH, faEllipsisV } from '@fortawesome/free-solid-svg-icons';
6
+
7
+ import { withMemo } from '../../helper/withMemo';
8
+
9
+ export type MoreButtonProps = RbmComponentProps<{
10
+ disabled?: boolean;
11
+ onClick?: () => void;
12
+ }>;
13
+
14
+ function MoreButton({ onClick, disabled, className, style }: MoreButtonProps) {
15
+ // Variables
16
+
17
+ // States
18
+
19
+ // Refs
20
+
21
+ // Callbacks
22
+
23
+ // Effects
24
+
25
+ // Other
26
+
27
+ // Render Functions
28
+
29
+ return (
30
+ <TopBarButton onClick={onClick} disabled={disabled} className={className} style={style}>
31
+ <Icon icon={faEllipsisH} className="material-hidden" />
32
+ <Icon icon={faEllipsisV} className="flat-hidden" />
33
+ </TopBarButton>
34
+ );
35
+ }
36
+
37
+ const MoreButtonMemo = withMemo(MoreButton);
38
+ export { MoreButtonMemo as MoreButton };