@oneuptime/common 7.0.4707 → 7.0.4717
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/UI/Components/Button/Button.tsx +9 -9
- package/UI/Components/Card/Card.tsx +2 -2
- package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +2 -2
- package/UI/Components/Date/StartAndEndDate.tsx +8 -3
- package/UI/Components/HeaderAlert/HeaderAlert.tsx +9 -1
- package/UI/Components/HeaderAlert/HeaderModelAlert.tsx +2 -1
- package/UI/Components/Modal/Modal.tsx +16 -14
- package/UI/Components/Modal/ModalFooter.tsx +1 -1
- package/UI/Components/Page/Page.tsx +1 -1
- package/UI/Components/Table/Table.tsx +48 -25
- package/UI/Components/Table/TableBody.tsx +52 -0
- package/UI/Components/Table/TableRow.tsx +221 -0
- package/build/dist/UI/Components/Button/Button.js +9 -9
- package/build/dist/UI/Components/Card/Card.js +2 -2
- package/build/dist/UI/Components/Card/Card.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +2 -2
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
- package/build/dist/UI/Components/Date/StartAndEndDate.js +8 -8
- package/build/dist/UI/Components/Date/StartAndEndDate.js.map +1 -1
- package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js +2 -1
- package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js.map +1 -1
- package/build/dist/UI/Components/HeaderAlert/HeaderModelAlert.js +1 -1
- package/build/dist/UI/Components/HeaderAlert/HeaderModelAlert.js.map +1 -1
- package/build/dist/UI/Components/Modal/Modal.js +14 -14
- package/build/dist/UI/Components/Modal/Modal.js.map +1 -1
- package/build/dist/UI/Components/Modal/ModalFooter.js +1 -1
- package/build/dist/UI/Components/Modal/ModalFooter.js.map +1 -1
- package/build/dist/UI/Components/Page/Page.js +1 -1
- package/build/dist/UI/Components/Table/Table.js +29 -15
- package/build/dist/UI/Components/Table/Table.js.map +1 -1
- package/build/dist/UI/Components/Table/TableBody.js +19 -1
- package/build/dist/UI/Components/Table/TableBody.js.map +1 -1
- package/build/dist/UI/Components/Table/TableRow.js +68 -0
- package/build/dist/UI/Components/Table/TableRow.js.map +1 -1
- package/package.json +1 -1
|
@@ -107,7 +107,7 @@ const Button: FunctionComponent<ComponentProps> = ({
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
let buttonStyleCssClass: string = `inline-flex w-full justify-center rounded-md border border-gray-300 bg-white text-base font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2
|
|
110
|
+
let buttonStyleCssClass: string = `inline-flex w-full justify-center rounded-md border border-gray-300 bg-white text-base font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 md:mt-0 md:ml-3 md:w-auto md:text-sm`;
|
|
111
111
|
let loadingIconClassName: string = `w-5 h-5 mr-3 -ml-1 mr-1 animate-spin`;
|
|
112
112
|
let iconClassName: string = `w-5 h-5`;
|
|
113
113
|
|
|
@@ -139,20 +139,20 @@ const Button: FunctionComponent<ComponentProps> = ({
|
|
|
139
139
|
if (buttonStyle === ButtonStyleType.DANGER) {
|
|
140
140
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-transparent bg-red-600 text-base font-medium text-white shadow-sm ${
|
|
141
141
|
disabled ? "hover:bg-red-700" : ""
|
|
142
|
-
} focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2
|
|
142
|
+
} focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 md:ml-3 md:w-auto md:text-sm`;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
if (buttonStyle === ButtonStyleType.DANGER_OUTLINE) {
|
|
146
146
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-red-700 bg-white text-base font-medium text-red-700 shadow-sm ${
|
|
147
147
|
disabled ? "hover:bg-red-50" : ""
|
|
148
|
-
} focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2
|
|
148
|
+
} focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 md:mt-0 md:ml-3 md:w-auto md:text-sm`;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
if (buttonStyle === ButtonStyleType.PRIMARY) {
|
|
152
152
|
loadingIconClassName += ` text-indigo-100`;
|
|
153
153
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-transparent bg-indigo-600 text-base font-medium text-white shadow-sm ${
|
|
154
154
|
disabled ? "hover:bg-indigo-700" : ""
|
|
155
|
-
} focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2
|
|
155
|
+
} focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 md:ml-3 md:w-auto md:text-sm`;
|
|
156
156
|
|
|
157
157
|
if (disabled) {
|
|
158
158
|
buttonStyleCssClass += ` bg-indigo-300`;
|
|
@@ -188,7 +188,7 @@ const Button: FunctionComponent<ComponentProps> = ({
|
|
|
188
188
|
buttonStyle === ButtonStyleType.HOVER_SUCCESS_OUTLINE ||
|
|
189
189
|
buttonStyle === ButtonStyleType.HOVER_PRIMARY_OUTLINE
|
|
190
190
|
) {
|
|
191
|
-
buttonStyleCssClass = `flex btn-outline-secondary background-very-light-Gray500-on-hover
|
|
191
|
+
buttonStyleCssClass = `flex btn-outline-secondary background-very-light-Gray500-on-hover md:text-sm ml-1`;
|
|
192
192
|
|
|
193
193
|
if (buttonStyle === ButtonStyleType.HOVER_DANGER_OUTLINE) {
|
|
194
194
|
buttonStyleCssClass += ` hover:text-red-500`;
|
|
@@ -206,25 +206,25 @@ const Button: FunctionComponent<ComponentProps> = ({
|
|
|
206
206
|
if (buttonStyle === ButtonStyleType.SUCCESS) {
|
|
207
207
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-transparent bg-green-600 text-base font-medium text-white shadow-sm ${
|
|
208
208
|
disabled ? "hover:bg-green-700" : ""
|
|
209
|
-
} focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2
|
|
209
|
+
} focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2 md:ml-3 md:w-auto md:text-sm`;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
if (buttonStyle === ButtonStyleType.SUCCESS_OUTLINE) {
|
|
213
213
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-green-700 bg-white text-base font-medium text-green-700 shadow-sm ${
|
|
214
214
|
disabled ? "hover:bg-green-50" : ""
|
|
215
|
-
} focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2
|
|
215
|
+
} focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2 md:mt-0 md:ml-3 md:w-auto md:text-sm`;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
if (buttonStyle === ButtonStyleType.WARNING) {
|
|
219
219
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-transparent bg-yellow-600 text-base font-medium text-white shadow-sm ${
|
|
220
220
|
disabled ? "hover:bg-yellow-700" : ""
|
|
221
|
-
} focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2
|
|
221
|
+
} focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2 md:ml-3 md:w-auto md:text-sm`;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
if (buttonStyle === ButtonStyleType.WARNING_OUTLINE) {
|
|
225
225
|
buttonStyleCssClass = `inline-flex w-full justify-center rounded-md border border-yellow-700 bg-white text-base font-medium text-yellow-700 shadow-sm ${
|
|
226
226
|
disabled ? "hover:bg-yellow-50" : ""
|
|
227
|
-
} focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2
|
|
227
|
+
} focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2 md:mt-0 md:ml-3 md:w-auto md:text-sm`;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
buttonStyleCssClass += ` ` + buttonSize;
|
|
@@ -32,7 +32,7 @@ const Card: FunctionComponent<ComponentProps> = (
|
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<React.Fragment>
|
|
35
|
-
<div data-testid="card" className={props.className}>
|
|
35
|
+
<div data-testid="card" className={`mb-4 ${props.className || ""}`}>
|
|
36
36
|
<div className="shadow md:rounded-md">
|
|
37
37
|
<div className="bg-white py-6 px-4 md:p-6">
|
|
38
38
|
<div className="flex flex-col md:flex-row md:justify-between">
|
|
@@ -49,7 +49,7 @@ const Card: FunctionComponent<ComponentProps> = (
|
|
|
49
49
|
{props.description && (
|
|
50
50
|
<p
|
|
51
51
|
data-testid="card-description"
|
|
52
|
-
className="mt-1 text-sm text-gray-500 w-full"
|
|
52
|
+
className="mt-1 text-sm text-gray-500 w-full hidden md:block"
|
|
53
53
|
>
|
|
54
54
|
{props.description}
|
|
55
55
|
</p>
|
|
@@ -29,7 +29,7 @@ const ChartGroup: FunctionComponent<ComponentProps> = (
|
|
|
29
29
|
const syncId: string = Text.generateRandomText(10);
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
|
-
<div className="lg:grid grid-cols-1 gap-5">
|
|
32
|
+
<div className="lg:grid grid-cols-1 gap-5 space-y-5 lg:space-y-0">
|
|
33
33
|
{props.charts.map((chart: Chart, index: number) => {
|
|
34
34
|
switch (chart.type) {
|
|
35
35
|
case ChartType.LINE:
|
|
@@ -48,7 +48,7 @@ const ChartGroup: FunctionComponent<ComponentProps> = (
|
|
|
48
48
|
{chart.description && (
|
|
49
49
|
<p
|
|
50
50
|
data-testid="card-description"
|
|
51
|
-
className="mt-1 text-sm text-gray-500 w-full"
|
|
51
|
+
className="mt-1 text-sm text-gray-500 w-full hidden md:block"
|
|
52
52
|
>
|
|
53
53
|
{chart.description}
|
|
54
54
|
</p>
|
|
@@ -126,8 +126,8 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
126
126
|
) {
|
|
127
127
|
return (
|
|
128
128
|
<div>
|
|
129
|
-
<div className="flex space-x-3 mt-1">
|
|
130
|
-
<div className="w-1/2">
|
|
129
|
+
<div className="flex flex-col md:flex-row md:space-x-3 space-y-3 md:space-y-0 mt-1">
|
|
130
|
+
<div className="w-full md:w-1/2">
|
|
131
131
|
<div className="text-xs text-gray-500">From:</div>
|
|
132
132
|
<div>
|
|
133
133
|
<Input
|
|
@@ -161,7 +161,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
161
161
|
/>
|
|
162
162
|
</div>
|
|
163
163
|
</div>
|
|
164
|
-
<div className="w-1/2">
|
|
164
|
+
<div className="w-full md:w-1/2">
|
|
165
165
|
<div className="text-xs text-gray-500">To:</div>
|
|
166
166
|
<div>
|
|
167
167
|
<Input
|
|
@@ -240,6 +240,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
240
240
|
);
|
|
241
241
|
}}
|
|
242
242
|
title="3 hours"
|
|
243
|
+
className="hidden md:block"
|
|
243
244
|
/>
|
|
244
245
|
)}
|
|
245
246
|
|
|
@@ -295,6 +296,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
295
296
|
props.onValueChanged?.(new InBetween<Date>(startDate, endDate));
|
|
296
297
|
}}
|
|
297
298
|
title="2 weeks"
|
|
299
|
+
className="hidden md:block"
|
|
298
300
|
/>
|
|
299
301
|
|
|
300
302
|
<Button
|
|
@@ -313,6 +315,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
313
315
|
props.onValueChanged?.(new InBetween<Date>(startDate, endDate));
|
|
314
316
|
}}
|
|
315
317
|
title="3 weeks"
|
|
318
|
+
className="hidden md:block"
|
|
316
319
|
/>
|
|
317
320
|
|
|
318
321
|
<Button
|
|
@@ -331,6 +334,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
331
334
|
props.onValueChanged?.(new InBetween<Date>(startDate, endDate));
|
|
332
335
|
}}
|
|
333
336
|
title="1 month"
|
|
337
|
+
className="hidden md:block"
|
|
334
338
|
/>
|
|
335
339
|
|
|
336
340
|
<Button
|
|
@@ -349,6 +353,7 @@ const StartAndEndDate: DateFilterFunction = (
|
|
|
349
353
|
props.onValueChanged?.(new InBetween<Date>(startDate, endDate));
|
|
350
354
|
}}
|
|
351
355
|
title="3 months"
|
|
356
|
+
className="hidden md:block"
|
|
352
357
|
/>
|
|
353
358
|
</div>
|
|
354
359
|
)}
|
|
@@ -20,6 +20,7 @@ export interface ComponentProps {
|
|
|
20
20
|
alertType: HeaderAlertType;
|
|
21
21
|
tooltip?: string | undefined;
|
|
22
22
|
colorSwatch?: ColorSwatch | undefined;
|
|
23
|
+
suffix?: string | undefined;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
const HeaderAlert: (props: ComponentProps) => ReactElement = (
|
|
@@ -82,9 +83,16 @@ const HeaderAlert: (props: ComponentProps) => ReactElement = (
|
|
|
82
83
|
/>
|
|
83
84
|
</div>
|
|
84
85
|
<div className="ml-1 flex-1 md:flex md:justify-between">
|
|
85
|
-
<p className={`text-sm font-semibold ${textColor}
|
|
86
|
+
<p className={`text-sm font-semibold ${textColor}`}>
|
|
86
87
|
{props.title}
|
|
87
88
|
</p>
|
|
89
|
+
{props.suffix && (
|
|
90
|
+
<span
|
|
91
|
+
className={`ml-1 ${textColor} text-sm font-semibold hidden md:block`}
|
|
92
|
+
>
|
|
93
|
+
{props.suffix}
|
|
94
|
+
</span>
|
|
95
|
+
)}
|
|
88
96
|
</div>
|
|
89
97
|
</div>
|
|
90
98
|
</div>
|
|
@@ -82,7 +82,8 @@ const HeaderModelAlert: <TBaseModel extends BaseModel>(
|
|
|
82
82
|
|
|
83
83
|
return (
|
|
84
84
|
<HeaderAlert
|
|
85
|
-
title={`${count}
|
|
85
|
+
title={`${count}`}
|
|
86
|
+
suffix={`${count > 1 ? props.pluralName : props.singularName}`}
|
|
86
87
|
icon={props.icon}
|
|
87
88
|
onClick={props.onClick}
|
|
88
89
|
className={props.className}
|
|
@@ -60,21 +60,21 @@ const Modal: FunctionComponent<ComponentProps> = (
|
|
|
60
60
|
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"></div>
|
|
61
61
|
|
|
62
62
|
<div className="fixed inset-0 z-20 overflow-y-auto">
|
|
63
|
-
<div className="flex min-h-screen items-end justify-center p-
|
|
63
|
+
<div className="flex min-h-screen items-end justify-center p-0 text-center md:items-center md:p-4">
|
|
64
64
|
<div
|
|
65
|
-
className={`relative transform
|
|
65
|
+
className={`relative transform bg-white text-left shadow-xl transition-all w-full h-full md:h-auto md:w-auto md:rounded-lg md:my-8 ${
|
|
66
66
|
props.modalWidth && props.modalWidth === ModalWidth.Large
|
|
67
|
-
? "
|
|
67
|
+
? "md:max-w-7xl"
|
|
68
68
|
: ""
|
|
69
69
|
} ${
|
|
70
70
|
props.modalWidth && props.modalWidth === ModalWidth.Medium
|
|
71
|
-
? "
|
|
71
|
+
? "md:max-w-3xl"
|
|
72
72
|
: ""
|
|
73
|
-
} ${!props.modalWidth ? "
|
|
73
|
+
} ${!props.modalWidth ? "md:max-w-lg" : ""} `}
|
|
74
74
|
data-testid="modal"
|
|
75
75
|
>
|
|
76
76
|
{props.onClose && (
|
|
77
|
-
<div className="absolute top-0 right-0
|
|
77
|
+
<div className="absolute top-0 right-0 z-10 pt-4 pr-4 md:hidden lg:block">
|
|
78
78
|
<Button
|
|
79
79
|
buttonStyle={ButtonStyleType.ICON}
|
|
80
80
|
icon={IconProp.Close}
|
|
@@ -85,10 +85,10 @@ const Modal: FunctionComponent<ComponentProps> = (
|
|
|
85
85
|
/>
|
|
86
86
|
</div>
|
|
87
87
|
)}
|
|
88
|
-
<div className="
|
|
88
|
+
<div className="p-4 md:p-6">
|
|
89
89
|
{props.icon && (
|
|
90
90
|
<div
|
|
91
|
-
className={`mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full ${iconBgColor}
|
|
91
|
+
className={`mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full ${iconBgColor} md:mx-0 md:h-10 md:w-10`}
|
|
92
92
|
data-testid="icon"
|
|
93
93
|
>
|
|
94
94
|
<Icon
|
|
@@ -104,13 +104,13 @@ const Modal: FunctionComponent<ComponentProps> = (
|
|
|
104
104
|
/>
|
|
105
105
|
</div>
|
|
106
106
|
)}
|
|
107
|
-
<div className="
|
|
108
|
-
<div className="flex justify-between">
|
|
109
|
-
<div>
|
|
107
|
+
<div className="text-left md:mt-0 md:ml-4 md:mr-4">
|
|
108
|
+
<div className="flex flex-col md:flex-row md:justify-between">
|
|
109
|
+
<div className="flex-1">
|
|
110
110
|
<h3
|
|
111
111
|
data-testid="modal-title"
|
|
112
112
|
className={`text-lg font-medium leading-6 text-gray-900 ${
|
|
113
|
-
props.icon ? "ml-10
|
|
113
|
+
props.icon ? "mt-4 md:ml-10 md:-mt-8 md:mb-5" : ""
|
|
114
114
|
}`}
|
|
115
115
|
id="modal-title"
|
|
116
116
|
>
|
|
@@ -119,14 +119,16 @@ const Modal: FunctionComponent<ComponentProps> = (
|
|
|
119
119
|
{props.description && (
|
|
120
120
|
<h3
|
|
121
121
|
data-testid="modal-description"
|
|
122
|
-
className="text-sm leading-6 text-gray-500"
|
|
122
|
+
className="text-sm leading-6 text-gray-500 mt-2"
|
|
123
123
|
>
|
|
124
124
|
{props.description}
|
|
125
125
|
</h3>
|
|
126
126
|
)}
|
|
127
127
|
</div>
|
|
128
128
|
{props.rightElement && (
|
|
129
|
-
<div data-testid="right-element">
|
|
129
|
+
<div data-testid="right-element" className="mt-4 md:mt-0">
|
|
130
|
+
{props.rightElement}
|
|
131
|
+
</div>
|
|
130
132
|
)}
|
|
131
133
|
</div>
|
|
132
134
|
<div className="mt-2">
|
|
@@ -18,7 +18,7 @@ const ModalFooter: FunctionComponent<ComponentProps> = (
|
|
|
18
18
|
props: ComponentProps,
|
|
19
19
|
): ReactElement => {
|
|
20
20
|
return (
|
|
21
|
-
<div className="bg-gray-50 px-4 py-3
|
|
21
|
+
<div className="bg-gray-50 px-4 py-3 flex flex-row gap-3 md:flex-row-reverse md:px-6">
|
|
22
22
|
{props.onSubmit ? (
|
|
23
23
|
<Button
|
|
24
24
|
buttonStyle={
|
|
@@ -69,7 +69,7 @@ const Page: FunctionComponent<ComponentProps> = (
|
|
|
69
69
|
{props.sideMenu}
|
|
70
70
|
|
|
71
71
|
{!props.isLoading && (
|
|
72
|
-
<div className="space-y-6
|
|
72
|
+
<div className="space-y-6 md:px-6 lg:col-span-10 md:col-span-9 lg:px-0">
|
|
73
73
|
{props.children}
|
|
74
74
|
</div>
|
|
75
75
|
)}
|
|
@@ -88,6 +88,20 @@ const Table: TableFunction = <T extends GenericObject>(
|
|
|
88
88
|
|
|
89
89
|
const [isAllItemsSelected, setIsAllItemsSelected] = useState<boolean>(false);
|
|
90
90
|
const [bulkSelectedItems, setBulkSelectedItems] = useState<Array<T>>([]);
|
|
91
|
+
const [isMobile, setIsMobile] = useState<boolean>(false);
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
const checkMobile: () => void = (): void => {
|
|
95
|
+
setIsMobile(window.innerWidth < 768); // md breakpoint
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
checkMobile();
|
|
99
|
+
window.addEventListener("resize", checkMobile);
|
|
100
|
+
|
|
101
|
+
return () => {
|
|
102
|
+
window.removeEventListener("resize", checkMobile);
|
|
103
|
+
};
|
|
104
|
+
}, []);
|
|
91
105
|
|
|
92
106
|
useEffect(() => {
|
|
93
107
|
if (props.bulkSelectedItems) {
|
|
@@ -189,6 +203,7 @@ const Table: TableFunction = <T extends GenericObject>(
|
|
|
189
203
|
}}
|
|
190
204
|
selectedItems={bulkSelectedItems}
|
|
191
205
|
matchBulkSelectedItemByField={props.matchBulkSelectedItemByField}
|
|
206
|
+
isMobile={isMobile}
|
|
192
207
|
/>
|
|
193
208
|
);
|
|
194
209
|
};
|
|
@@ -259,7 +274,7 @@ const Table: TableFunction = <T extends GenericObject>(
|
|
|
259
274
|
}
|
|
260
275
|
}}
|
|
261
276
|
>
|
|
262
|
-
<div className="-my-2 overflow-x-auto
|
|
277
|
+
<div className="-my-2 overflow-x-auto md:-mx-6">
|
|
263
278
|
<div className="inline-block min-w-full py-2 align-middle">
|
|
264
279
|
<div
|
|
265
280
|
className={
|
|
@@ -268,33 +283,41 @@ const Table: TableFunction = <T extends GenericObject>(
|
|
|
268
283
|
: "overflow-hidden border-t border-gray-200"
|
|
269
284
|
}
|
|
270
285
|
>
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
props.
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
286
|
+
{isMobile ? (
|
|
287
|
+
// Mobile view: render as list
|
|
288
|
+
<div className="min-w-full divide-y divide-gray-200">
|
|
289
|
+
{getTablebody()}
|
|
290
|
+
</div>
|
|
291
|
+
) : (
|
|
292
|
+
// Desktop view: render as table
|
|
293
|
+
<table className="min-w-full divide-y divide-gray-200">
|
|
294
|
+
<TableHeader
|
|
295
|
+
id={`${props.id}-header`}
|
|
296
|
+
columns={props.columns}
|
|
297
|
+
onSortChanged={props.onSortChanged}
|
|
298
|
+
enableDragAndDrop={props.enableDragAndDrop}
|
|
299
|
+
sortBy={props.sortBy}
|
|
300
|
+
sortOrder={props.sortOrder}
|
|
301
|
+
isBulkActionsEnabled={isBulkActionsEnabled}
|
|
302
|
+
onAllItemsDeselected={() => {
|
|
303
|
+
setIsAllItemsSelected(false);
|
|
304
|
+
props.onBulkClearAllItems?.();
|
|
305
|
+
}}
|
|
306
|
+
onAllItemsOnThePageSelected={() => {
|
|
307
|
+
if (props.onBulkSelectItemsOnCurrentPage) {
|
|
308
|
+
props.onBulkSelectItemsOnCurrentPage();
|
|
309
|
+
}
|
|
310
|
+
}}
|
|
311
|
+
isAllItemsOnThePageSelected={isAllItemsOnThePageSelected}
|
|
312
|
+
hasTableItems={props.data.length > 0}
|
|
313
|
+
/>
|
|
314
|
+
{getTablebody()}
|
|
315
|
+
</table>
|
|
316
|
+
)}
|
|
294
317
|
</div>
|
|
295
318
|
</div>
|
|
296
319
|
</div>
|
|
297
|
-
<div className="bg-gray-50 text-right -
|
|
320
|
+
<div className="bg-gray-50 text-right md:-mx-6 -mb-6">
|
|
298
321
|
{!props.disablePagination && (
|
|
299
322
|
<Pagination
|
|
300
323
|
singularLabel={props.singularLabel}
|
|
@@ -21,6 +21,9 @@ export interface ComponentProps<T extends GenericObject> {
|
|
|
21
21
|
onItemDeselected?: undefined | ((item: T) => void);
|
|
22
22
|
selectedItems: Array<T>;
|
|
23
23
|
matchBulkSelectedItemByField: keyof T | undefined; // which field to use to match selected items. For exmaple this could be '_id'
|
|
24
|
+
|
|
25
|
+
// responsive
|
|
26
|
+
isMobile?: boolean;
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
type TableBodyFunction = <T extends GenericObject>(
|
|
@@ -35,6 +38,54 @@ const TableBody: TableBodyFunction = <T extends GenericObject>(
|
|
|
35
38
|
const getBody: GetBodyFunction = (
|
|
36
39
|
provided?: DroppableProvided,
|
|
37
40
|
): ReactElement => {
|
|
41
|
+
// Mobile view: render as list
|
|
42
|
+
if (props.isMobile) {
|
|
43
|
+
return (
|
|
44
|
+
<div
|
|
45
|
+
id={props.id}
|
|
46
|
+
ref={provided?.innerRef}
|
|
47
|
+
{...provided?.droppableProps}
|
|
48
|
+
className="divide-y divide-gray-200 bg-white"
|
|
49
|
+
>
|
|
50
|
+
{props.data &&
|
|
51
|
+
props.data.map((item: T, i: number) => {
|
|
52
|
+
return (
|
|
53
|
+
<TableRow
|
|
54
|
+
isBulkActionsEnabled={props.isBulkActionsEnabled}
|
|
55
|
+
onItemSelected={props.onItemSelected}
|
|
56
|
+
onItemDeselected={props.onItemDeselected}
|
|
57
|
+
isItemSelected={
|
|
58
|
+
props.selectedItems?.filter((selectedItem: T) => {
|
|
59
|
+
if (props.matchBulkSelectedItemByField === undefined) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
selectedItem[
|
|
65
|
+
props.matchBulkSelectedItemByField
|
|
66
|
+
]?.toString() ===
|
|
67
|
+
item[props.matchBulkSelectedItemByField]?.toString()
|
|
68
|
+
);
|
|
69
|
+
}).length > 0 || false
|
|
70
|
+
}
|
|
71
|
+
dragAndDropScope={props.dragAndDropScope}
|
|
72
|
+
enableDragAndDrop={props.enableDragAndDrop}
|
|
73
|
+
key={i}
|
|
74
|
+
item={item}
|
|
75
|
+
columns={props.columns}
|
|
76
|
+
actionButtons={props.actionButtons}
|
|
77
|
+
dragDropIdField={props.dragDropIdField}
|
|
78
|
+
dragDropIndexField={props.dragDropIndexField}
|
|
79
|
+
isMobile={true}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
})}
|
|
83
|
+
{provided?.placeholder}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Desktop view: render as table
|
|
38
89
|
return (
|
|
39
90
|
<tbody
|
|
40
91
|
id={props.id}
|
|
@@ -71,6 +122,7 @@ const TableBody: TableBodyFunction = <T extends GenericObject>(
|
|
|
71
122
|
actionButtons={props.actionButtons}
|
|
72
123
|
dragDropIdField={props.dragDropIdField}
|
|
73
124
|
dragDropIndexField={props.dragDropIndexField}
|
|
125
|
+
isMobile={false}
|
|
74
126
|
/>
|
|
75
127
|
);
|
|
76
128
|
})}
|