@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.
- package/.eslintrc.json +189 -0
- package/.prettierrc +5 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/babel.config.js +22 -0
- package/bin/build.js +60 -0
- package/bin/release.sh +35 -0
- package/bin/updateCopies.js +86 -0
- package/bootstrapReactMobile.ts +87 -0
- package/dist/bootstrapReactMobile.d.ts +87 -0
- package/dist/bootstrapReactMobile.js +6275 -0
- package/dist/src/Components/ActionSheet/ActionSheet.d.ts +21 -0
- package/dist/src/Components/Card/Card.d.ts +13 -0
- package/dist/src/Components/Clickable/Clickable.d.ts +14 -0
- package/dist/src/Components/Dialog/AlertDialog.d.ts +10 -0
- package/dist/src/Components/Dialog/ButtonDialog.d.ts +13 -0
- package/dist/src/Components/Dialog/ConfirmDialog.d.ts +11 -0
- package/dist/src/Components/Dialog/Dialog.d.ts +14 -0
- package/dist/src/Components/Dialog/DialogBackground.d.ts +7 -0
- package/dist/src/Components/Dialog/DialogContainer.d.ts +6 -0
- package/dist/src/Components/Dialog/DialogContext.d.ts +9 -0
- package/dist/src/Components/Dialog/useAlertDialog.d.ts +1 -0
- package/dist/src/Components/Dialog/useConfirmDialog.d.ts +1 -0
- package/dist/src/Components/DragAndDrop/DragItem.d.ts +7 -0
- package/dist/src/Components/DragAndDrop/DropArea.d.ts +7 -0
- package/dist/src/Components/DragAndDrop/useStrictEnabled.d.ts +1 -0
- package/dist/src/Components/FormElements/Button/Button.d.ts +8 -0
- package/dist/src/Components/FormElements/CheckBox/Checkbox.d.ts +10 -0
- package/dist/src/Components/FormElements/ColorInput/ColorInput.d.ts +17 -0
- package/dist/src/Components/FormElements/ColorInput/sharedSelectedColor.d.ts +4 -0
- package/dist/src/Components/FormElements/ImageInput/ImageInput.d.ts +17 -0
- package/dist/src/Components/FormElements/Input/HiddenInput.d.ts +8 -0
- package/dist/src/Components/FormElements/Input/Input.d.ts +10 -0
- package/dist/src/Components/FormElements/Input/PasswordInput/PasswordInput.d.ts +4 -0
- package/dist/src/Components/FormElements/SearchSelectInput/SearchSelectInput.d.ts +10 -0
- package/dist/src/Components/FormElements/Select/Select.d.ts +16 -0
- package/dist/src/Components/FormElements/Slider/Slider.d.ts +8 -0
- package/dist/src/Components/FormElements/Switch/Switch.d.ts +12 -0
- package/dist/src/Components/FormElements/Textarea/Textarea.d.ts +12 -0
- package/dist/src/Components/FormElements/hooks/useOnChangeDone.d.ts +2 -0
- package/dist/src/Components/FullScreen/FullScreen.d.ts +14 -0
- package/dist/src/Components/Hooks/useBreakpoint.d.ts +11 -0
- package/dist/src/Components/Hooks/useComposedRef.d.ts +2 -0
- package/dist/src/Components/Hooks/useDebounced.d.ts +1 -0
- package/dist/src/Components/Hooks/useDelayed.d.ts +1 -0
- package/dist/src/Components/Hooks/useInViewport.d.ts +2 -0
- package/dist/src/Components/Hooks/useKeyListener.d.ts +3 -0
- package/dist/src/Components/Hooks/useListener.d.ts +18 -0
- package/dist/src/Components/Hooks/useOnMount.d.ts +1 -0
- package/dist/src/Components/Hooks/useOnce.d.ts +1 -0
- package/dist/src/Components/Icon/Icon.d.ts +13 -0
- package/dist/src/Components/Image/Image.d.ts +12 -0
- package/dist/src/Components/InViewport/InViewport.d.ts +11 -0
- package/dist/src/Components/Layout/Block.d.ts +7 -0
- package/dist/src/Components/Layout/Container.d.ts +15 -0
- package/dist/src/Components/Layout/Flex.d.ts +10 -0
- package/dist/src/Components/Layout/Grid/Grid.d.ts +9 -0
- package/dist/src/Components/Layout/Grid/GridItem.d.ts +25 -0
- package/dist/src/Components/Layout/Grow.d.ts +9 -0
- package/dist/src/Components/Layout/Inline.d.ts +7 -0
- package/dist/src/Components/Layout/InlineBlock.d.ts +7 -0
- package/dist/src/Components/Layout/View.d.ts +9 -0
- package/dist/src/Components/Layout/ViewWithoutListeners.d.ts +8 -0
- package/dist/src/Components/List/BulletList/BulletList.d.ts +8 -0
- package/dist/src/Components/List/BulletList/ListItem.d.ts +7 -0
- package/dist/src/Components/List/List.d.ts +10 -0
- package/dist/src/Components/LoadingArea/LoadingArea.d.ts +12 -0
- package/dist/src/Components/LoadingCircle/LoadingCircle.d.ts +8 -0
- package/dist/src/Components/Menu/Menu.d.ts +16 -0
- package/dist/src/Components/Menu/useMenu.d.ts +3 -0
- package/dist/src/Components/RbmComponentProps.d.ts +31 -0
- package/dist/src/Components/SizeCalculator/SizeCalculator.d.ts +9 -0
- package/dist/src/Components/SpoilerList/Spoiler/Spoiler.d.ts +15 -0
- package/dist/src/Components/SpoilerList/SpoilerList.d.ts +15 -0
- package/dist/src/Components/SpoilerList/useSpoilerGroup.d.ts +12 -0
- package/dist/src/Components/TabBar/TabBar.d.ts +30 -0
- package/dist/src/Components/TabBar/TabBarButton.d.ts +9 -0
- package/dist/src/Components/Table/Table.d.ts +36 -0
- package/dist/src/Components/Text/Heading.d.ts +7 -0
- package/dist/src/Components/Text/Text.d.ts +26 -0
- package/dist/src/Components/Toast/Toast.d.ts +13 -0
- package/dist/src/Components/Toast/ToastContainer.d.ts +7 -0
- package/dist/src/Components/TopBar/MoreButton.d.ts +9 -0
- package/dist/src/Components/TopBar/TopBar.d.ts +25 -0
- package/dist/src/Components/TopBar/TopBarButton.d.ts +9 -0
- package/dist/src/StyleProvider.d.ts +2 -0
- package/dist/src/TypeHelpers.d.ts +4 -0
- package/dist/src/WindowContext/WindowContext.d.ts +3 -0
- package/dist/src/WrongChildError.d.ts +4 -0
- package/dist/src/helper/Characters.d.ts +5 -0
- package/dist/src/helper/DistributiveOmit.d.ts +1 -0
- package/dist/src/helper/EmptyProps.d.ts +1 -0
- package/dist/src/helper/memoComparator.d.ts +1 -0
- package/dist/src/helper/nonEmptyString.d.ts +1 -0
- package/dist/src/helper/withForwardRef.d.ts +7 -0
- package/dist/src/helper/withMemo.d.ts +3 -0
- package/dist/src/helper/withRenderBrowserOnly.d.ts +2 -0
- package/dist/src/helper/withRestrictedChildren.d.ts +6 -0
- package/package.json +92 -0
- package/react-bootstrap-mobile.scss +6 -0
- package/scripts/getPackageJson.js +25 -0
- package/src/Components/ActionSheet/ActionSheet.tsx +115 -0
- package/src/Components/ActionSheet/actionSheet.scss +153 -0
- package/src/Components/Card/Card.tsx +46 -0
- package/src/Components/Card/card.scss +76 -0
- package/src/Components/Clickable/Clickable.tsx +174 -0
- package/src/Components/Clickable/clickable.scss +3 -0
- package/src/Components/Dialog/AlertDialog.tsx +44 -0
- package/src/Components/Dialog/ButtonDialog.tsx +57 -0
- package/src/Components/Dialog/ConfirmDialog.tsx +46 -0
- package/src/Components/Dialog/Dialog.tsx +82 -0
- package/src/Components/Dialog/DialogBackground.tsx +38 -0
- package/src/Components/Dialog/DialogContainer.tsx +77 -0
- package/src/Components/Dialog/DialogContext.ts +21 -0
- package/src/Components/Dialog/buttonDialog.scss +114 -0
- package/src/Components/Dialog/dialog.scss +30 -0
- package/src/Components/Dialog/dialogBackground.scss +4 -0
- package/src/Components/Dialog/useAlertDialog.ts +13 -0
- package/src/Components/Dialog/useConfirmDialog.ts +13 -0
- package/src/Components/DragAndDrop/DragItem.tsx +38 -0
- package/src/Components/DragAndDrop/DropArea.tsx +43 -0
- package/src/Components/DragAndDrop/useStrictEnabled.ts +20 -0
- package/src/Components/FormElements/Button/Button.tsx +25 -0
- package/src/Components/FormElements/Button/button.scss +39 -0
- package/src/Components/FormElements/CheckBox/Checkbox.tsx +61 -0
- package/src/Components/FormElements/CheckBox/checkbox.scss +107 -0
- package/src/Components/FormElements/ColorInput/ColorInput.tsx +139 -0
- package/src/Components/FormElements/ColorInput/colorInput.scss +35 -0
- package/src/Components/FormElements/ColorInput/sharedSelectedColor.ts +40 -0
- package/src/Components/FormElements/ImageInput/ImageInput.tsx +97 -0
- package/src/Components/FormElements/ImageInput/imageInput.scss +24 -0
- package/src/Components/FormElements/Input/HiddenInput.tsx +43 -0
- package/src/Components/FormElements/Input/Input.tsx +102 -0
- package/src/Components/FormElements/Input/PasswordInput/PasswordInput.tsx +55 -0
- package/src/Components/FormElements/Input/PasswordInput/passwordInput.scss +7 -0
- package/src/Components/FormElements/Input/input.scss +57 -0
- package/src/Components/FormElements/SearchSelectInput/SearchSelectInput.tsx +162 -0
- package/src/Components/FormElements/SearchSelectInput/seachSelectInput.scss +90 -0
- package/src/Components/FormElements/Select/Select.tsx +77 -0
- package/src/Components/FormElements/Select/select.scss +51 -0
- package/src/Components/FormElements/Slider/Slider.tsx +80 -0
- package/src/Components/FormElements/Slider/slider.scss +92 -0
- package/src/Components/FormElements/Switch/Switch.tsx +82 -0
- package/src/Components/FormElements/Switch/switch.scss +149 -0
- package/src/Components/FormElements/Textarea/Textarea.tsx +77 -0
- package/src/Components/FormElements/Textarea/textarea.scss +22 -0
- package/src/Components/FormElements/hooks/useOnChangeDone.ts +16 -0
- package/src/Components/FullScreen/FullScreen.tsx +89 -0
- package/src/Components/Hooks/useBreakpoint.ts +66 -0
- package/src/Components/Hooks/useComposedRef.ts +17 -0
- package/src/Components/Hooks/useDebounced.ts +22 -0
- package/src/Components/Hooks/useDelayed.ts +46 -0
- package/src/Components/Hooks/useInViewport.ts +23 -0
- package/src/Components/Hooks/useKeyListener.ts +77 -0
- package/src/Components/Hooks/useListener.ts +73 -0
- package/src/Components/Hooks/useOnMount.ts +12 -0
- package/src/Components/Hooks/useOnce.ts +11 -0
- package/src/Components/Icon/Icon.tsx +45 -0
- package/src/Components/Image/Image.tsx +44 -0
- package/src/Components/Image/image.scss +3 -0
- package/src/Components/InViewport/InViewport.tsx +71 -0
- package/src/Components/InViewport/inViewport.scss +3 -0
- package/src/Components/Layout/Block.tsx +48 -0
- package/src/Components/Layout/Container.tsx +57 -0
- package/src/Components/Layout/Flex.tsx +51 -0
- package/src/Components/Layout/Grid/Grid.tsx +53 -0
- package/src/Components/Layout/Grid/GridItem.tsx +138 -0
- package/src/Components/Layout/Grid/grid.scss +43 -0
- package/src/Components/Layout/Grow.tsx +51 -0
- package/src/Components/Layout/Inline.tsx +48 -0
- package/src/Components/Layout/InlineBlock.tsx +48 -0
- package/src/Components/Layout/View.tsx +40 -0
- package/src/Components/Layout/ViewWithoutListeners.tsx +40 -0
- package/src/Components/Layout/container.scss +12 -0
- package/src/Components/Layout/layout.scss +56 -0
- package/src/Components/List/BulletList/BulletList.tsx +33 -0
- package/src/Components/List/BulletList/ListItem.tsx +34 -0
- package/src/Components/List/List.tsx +88 -0
- package/src/Components/List/list.scss +30 -0
- package/src/Components/LoadingArea/LoadingArea.tsx +64 -0
- package/src/Components/LoadingArea/loadingArea.scss +19 -0
- package/src/Components/LoadingCircle/LoadingCircle.tsx +41 -0
- package/src/Components/LoadingCircle/loadingCircle.scss +42 -0
- package/src/Components/Menu/Menu.tsx +113 -0
- package/src/Components/Menu/menu.scss +21 -0
- package/src/Components/Menu/useMenu.ts +20 -0
- package/src/Components/RbmComponentProps.ts +40 -0
- package/src/Components/SizeCalculator/SizeCalculator.tsx +45 -0
- package/src/Components/SpoilerList/Spoiler/Spoiler.tsx +106 -0
- package/src/Components/SpoilerList/Spoiler/spoiler.scss +120 -0
- package/src/Components/SpoilerList/SpoilerList.tsx +63 -0
- package/src/Components/SpoilerList/useSpoilerGroup.ts +39 -0
- package/src/Components/TabBar/TabBar.tsx +117 -0
- package/src/Components/TabBar/TabBarButton.tsx +44 -0
- package/src/Components/TabBar/tabBar.scss +108 -0
- package/src/Components/Table/Table.tsx +182 -0
- package/src/Components/Text/Heading.tsx +44 -0
- package/src/Components/Text/Text.tsx +79 -0
- package/src/Components/Text/heading.scss +3 -0
- package/src/Components/Text/text.scss +60 -0
- package/src/Components/Toast/Toast.tsx +107 -0
- package/src/Components/Toast/ToastContainer.tsx +35 -0
- package/src/Components/Toast/toast.scss +52 -0
- package/src/Components/TopBar/MoreButton.tsx +38 -0
- package/src/Components/TopBar/TopBar.tsx +176 -0
- package/src/Components/TopBar/TopBarButton.tsx +29 -0
- package/src/Components/TopBar/topBar.scss +124 -0
- package/src/StyleProvider.ts +4 -0
- package/src/TypeHelpers.ts +4 -0
- package/src/WindowContext/WindowContext.ts +8 -0
- package/src/WrongChildError.ts +19 -0
- package/src/env.d.ts +1 -0
- package/src/helper/Characters.ts +5 -0
- package/src/helper/DistributiveOmit.ts +1 -0
- package/src/helper/EmptyProps.ts +2 -0
- package/src/helper/memoComparator.ts +18 -0
- package/src/helper/nonEmptyString.ts +8 -0
- package/src/helper/withForwardRef.ts +28 -0
- package/src/helper/withMemo.ts +16 -0
- package/src/helper/withRenderBrowserOnly.tsx +30 -0
- package/src/helper/withRestrictedChildren.tsx +57 -0
- package/src/scss/_animations.scss +46 -0
- package/src/scss/_baseClasses.scss +27 -0
- package/src/scss/_colors.scss +13 -0
- package/src/scss/_default.scss +17 -0
- package/src/scss/_designMixin.scss +13 -0
- package/src/scss/_mobileMixin.scss +35 -0
- package/src/scss/_variables.scss +22 -0
- package/src/types/isomorphic-style-loader.d.ts +3 -0
- package/src/types/react-table-config.d.ts +120 -0
- package/src/types/scss-module.d.ts +7 -0
- package/tsconfig.json +57 -0
- 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,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 };
|