dce-reactkit 2.0.10 → 2.0.11
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/lib/components/AppWrapper.d.ts +16 -1
- package/lib/components/AppWrapper.js +155 -11
- package/lib/components/AppWrapper.js.map +1 -1
- package/lib/components/Modal.d.ts +2 -0
- package/lib/components/Modal.js +9 -3
- package/lib/components/Modal.js.map +1 -1
- package/lib/components/TabBox.d.ts +11 -0
- package/lib/components/TabBox.js +42 -0
- package/lib/components/TabBox.js.map +1 -0
- package/lib/helpers/alert.d.ts +2 -0
- package/lib/helpers/alert.js +5 -0
- package/lib/helpers/alert.js.map +1 -0
- package/lib/helpers/confirm.d.ts +2 -0
- package/lib/helpers/confirm.js +5 -0
- package/lib/helpers/confirm.js.map +1 -0
- package/package.json +1 -1
- package/src/components/AppWrapper.tsx +190 -10
- package/src/components/Modal.tsx +16 -2
- package/src/components/TabBox.tsx +136 -0
- package/src/helpers/alert.tsx +3 -0
- package/src/helpers/confirm.tsx +3 -0
|
@@ -9,12 +9,27 @@ declare type Props = {
|
|
|
9
9
|
dark?: boolean;
|
|
10
10
|
sessionExpiredMessage?: string;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Show an alert modal with an "Okay" button
|
|
14
|
+
* @author Gabe Abrams
|
|
15
|
+
* @param title the title text to display at the top of the alert
|
|
16
|
+
* @param text the text to display in the alert
|
|
17
|
+
*/
|
|
18
|
+
export declare const alert: (title: string, text: string) => Promise<unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* Show a confirmation modal with an "Okay" and a "Cancel" button
|
|
21
|
+
* @author Gabe Abrams
|
|
22
|
+
* @param title the title text to display at the top of the alert
|
|
23
|
+
* @param text the text to display in the alert
|
|
24
|
+
* @returns true if the user confirmed
|
|
25
|
+
*/
|
|
26
|
+
export declare const confirm: (title: string, text: string) => Promise<boolean>;
|
|
12
27
|
/**
|
|
13
28
|
* Show a fatal error message
|
|
14
29
|
* @author Gabe Abrams
|
|
15
30
|
* @param error the error to show
|
|
16
31
|
* @param [errorTitle] title of the error box
|
|
17
32
|
*/
|
|
18
|
-
export declare const showFatalError: (error: any, errorTitle?: string) =>
|
|
33
|
+
export declare const showFatalError: (error: any, errorTitle?: string) => Promise<unknown>;
|
|
19
34
|
declare const AppWrapper: (props: Props) => React.ReactElement;
|
|
20
35
|
export default AppWrapper;
|
|
@@ -10,11 +10,47 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
13
49
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
51
|
};
|
|
16
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.showFatalError = void 0;
|
|
53
|
+
exports.showFatalError = exports.confirm = exports.alert = void 0;
|
|
18
54
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
55
|
/**
|
|
20
56
|
* A wrapper for the entire React app that adds global functionality like
|
|
@@ -29,11 +65,83 @@ var ErrorBox_1 = __importDefault(require("./ErrorBox"));
|
|
|
29
65
|
var visitServerEndpoint_1 = require("../helpers/visitServerEndpoint");
|
|
30
66
|
// Import shared types
|
|
31
67
|
var ReactKitErrorCode_1 = __importDefault(require("../types/ReactKitErrorCode"));
|
|
68
|
+
// Import shared components
|
|
69
|
+
var Modal_1 = __importDefault(require("./Modal"));
|
|
32
70
|
// Import custom errors
|
|
33
71
|
var ErrorWithCode_1 = __importDefault(require("../errors/ErrorWithCode"));
|
|
34
72
|
/*------------------------------------------------------------------------*/
|
|
35
73
|
/* Static Helpers */
|
|
36
74
|
/*------------------------------------------------------------------------*/
|
|
75
|
+
/*----------------------------------------*/
|
|
76
|
+
/* Alert */
|
|
77
|
+
/*----------------------------------------*/
|
|
78
|
+
// Stored copies of setters
|
|
79
|
+
var setAlertInfo;
|
|
80
|
+
var onAlertClosed;
|
|
81
|
+
/**
|
|
82
|
+
* Show an alert modal with an "Okay" button
|
|
83
|
+
* @author Gabe Abrams
|
|
84
|
+
* @param title the title text to display at the top of the alert
|
|
85
|
+
* @param text the text to display in the alert
|
|
86
|
+
*/
|
|
87
|
+
var alert = function (title, text) { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
// Fallback if alert not available
|
|
90
|
+
if (!setAlertInfo) {
|
|
91
|
+
return [2 /*return*/, window.alert("".concat(title, "\n\n").concat(text))];
|
|
92
|
+
}
|
|
93
|
+
// Return promise that resolves when alert is closed
|
|
94
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
95
|
+
// Setup handler
|
|
96
|
+
onAlertClosed = function () {
|
|
97
|
+
resolve(null);
|
|
98
|
+
};
|
|
99
|
+
// Show the alert
|
|
100
|
+
setAlertInfo({
|
|
101
|
+
title: title,
|
|
102
|
+
text: text,
|
|
103
|
+
});
|
|
104
|
+
})];
|
|
105
|
+
});
|
|
106
|
+
}); };
|
|
107
|
+
exports.alert = alert;
|
|
108
|
+
/*----------------------------------------*/
|
|
109
|
+
/* Confirm */
|
|
110
|
+
/*----------------------------------------*/
|
|
111
|
+
// Stored copies of setters
|
|
112
|
+
var setConfirmInfo;
|
|
113
|
+
var onConfirmClosed;
|
|
114
|
+
/**
|
|
115
|
+
* Show a confirmation modal with an "Okay" and a "Cancel" button
|
|
116
|
+
* @author Gabe Abrams
|
|
117
|
+
* @param title the title text to display at the top of the alert
|
|
118
|
+
* @param text the text to display in the alert
|
|
119
|
+
* @returns true if the user confirmed
|
|
120
|
+
*/
|
|
121
|
+
var confirm = function (title, text) { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
// Fallback if confirm is not available
|
|
124
|
+
if (!setConfirmInfo) {
|
|
125
|
+
return [2 /*return*/, window.confirm("".concat(title, "\n\n").concat(text))];
|
|
126
|
+
}
|
|
127
|
+
// Return promise that resolves with result of confirmation
|
|
128
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
129
|
+
// Setup handler
|
|
130
|
+
onConfirmClosed = function (confirmed) {
|
|
131
|
+
resolve(confirmed);
|
|
132
|
+
};
|
|
133
|
+
// Show the confirm
|
|
134
|
+
setConfirmInfo({
|
|
135
|
+
title: title,
|
|
136
|
+
text: text,
|
|
137
|
+
});
|
|
138
|
+
})];
|
|
139
|
+
});
|
|
140
|
+
}); };
|
|
141
|
+
exports.confirm = confirm;
|
|
142
|
+
/*----------------------------------------*/
|
|
143
|
+
/* Fatal Error */
|
|
144
|
+
/*----------------------------------------*/
|
|
37
145
|
// Stored copies of setters
|
|
38
146
|
var setFatalErrorMessage;
|
|
39
147
|
var setFatalErrorCode;
|
|
@@ -56,7 +164,7 @@ var showFatalError = function (error, errorTitle) {
|
|
|
56
164
|
: String((_b = error.code) !== null && _b !== void 0 ? _b : ReactKitErrorCode_1.default.NoCode));
|
|
57
165
|
// Handle case where app hasn't loaded
|
|
58
166
|
if (!setFatalErrorMessage || !setFatalErrorCode) {
|
|
59
|
-
return alert(
|
|
167
|
+
return (0, exports.alert)(errorTitle, "".concat(message, " (code: ").concat(code, "). Please contact support."));
|
|
60
168
|
}
|
|
61
169
|
// Use setters
|
|
62
170
|
setFatalErrorMessage(message);
|
|
@@ -75,14 +183,20 @@ var AppWrapper = function (props) {
|
|
|
75
183
|
var children = props.children, dark = props.dark, _a = props.sessionExpiredMessage, sessionExpiredMessage = _a === void 0 ? 'Your session has expired. Please go back to Canvas and start over.' : _a;
|
|
76
184
|
/* -------------- State ------------- */
|
|
77
185
|
// Fatal error
|
|
78
|
-
var _b = (0, react_1.useState)(
|
|
186
|
+
var _b = (0, react_1.useState)(), fatalErrorMessage = _b[0], setFatalErrorMessageInner = _b[1];
|
|
79
187
|
setFatalErrorMessage = setFatalErrorMessageInner;
|
|
80
|
-
var _c = (0, react_1.useState)(
|
|
188
|
+
var _c = (0, react_1.useState)(), fatalErrorCode = _c[0], setFatalErrorCodeInner = _c[1];
|
|
81
189
|
setFatalErrorCode = setFatalErrorCodeInner;
|
|
82
|
-
var _d = (0, react_1.useState)(
|
|
190
|
+
var _d = (0, react_1.useState)(), fatalErrorTitle = _d[0], setFatalErrorTitleInner = _d[1];
|
|
83
191
|
setFatalErrorTitle = setFatalErrorTitleInner;
|
|
192
|
+
// Alert
|
|
193
|
+
var _e = (0, react_1.useState)(), alertInfo = _e[0], setAlertInfoInner = _e[1];
|
|
194
|
+
setAlertInfo = setAlertInfoInner;
|
|
195
|
+
// Confirm
|
|
196
|
+
var _f = (0, react_1.useState)(), confirmInfo = _f[0], setConfirmInfoInner = _f[1];
|
|
197
|
+
setConfirmInfo = setConfirmInfoInner;
|
|
84
198
|
// Session expired
|
|
85
|
-
var
|
|
199
|
+
var _g = (0, react_1.useState)(false), sessionHasExpired = _g[0], setSessionHasExpired = _g[1];
|
|
86
200
|
/*------------------------------------------------------------------------*/
|
|
87
201
|
/* Lifecycle Functions */
|
|
88
202
|
/*------------------------------------------------------------------------*/
|
|
@@ -101,16 +215,40 @@ var AppWrapper = function (props) {
|
|
|
101
215
|
/* Render */
|
|
102
216
|
/*------------------------------------------------------------------------*/
|
|
103
217
|
/*----------------------------------------*/
|
|
104
|
-
/*
|
|
218
|
+
/* Modal */
|
|
219
|
+
/*----------------------------------------*/
|
|
220
|
+
// Modal that may be defined
|
|
221
|
+
var modal;
|
|
222
|
+
/* -------------- Alert ------------- */
|
|
223
|
+
if (alertInfo) {
|
|
224
|
+
modal = ((0, jsx_runtime_1.jsx)(Modal_1.default, __assign({ title: alertInfo.title, type: Modal_1.default.ModalType.Okay, onClose: function () {
|
|
225
|
+
// Alert closed
|
|
226
|
+
if (onAlertClosed) {
|
|
227
|
+
onAlertClosed();
|
|
228
|
+
}
|
|
229
|
+
}, onTopOfOtherModals: true }, { children: alertInfo.text })));
|
|
230
|
+
}
|
|
231
|
+
/* ------------- Confirm ------------ */
|
|
232
|
+
if (confirmInfo) {
|
|
233
|
+
modal = ((0, jsx_runtime_1.jsx)(Modal_1.default, { title: confirmInfo.title, type: Modal_1.default.ModalType.OkayCancel, onClose: function (buttonType) {
|
|
234
|
+
if (onConfirmClosed) {
|
|
235
|
+
onConfirmClosed(buttonType === Modal_1.default.ButtonType.Okay);
|
|
236
|
+
}
|
|
237
|
+
}, dontAllowBackdropExit: true }));
|
|
238
|
+
}
|
|
105
239
|
/*----------------------------------------*/
|
|
106
|
-
|
|
240
|
+
/* Views */
|
|
241
|
+
/*----------------------------------------*/
|
|
242
|
+
// Body that will be filled with the current view
|
|
243
|
+
var body;
|
|
244
|
+
/* ----------- Fatal Error ---------- */
|
|
107
245
|
if (fatalErrorMessage || fatalErrorCode || sessionHasExpired) {
|
|
108
246
|
// Re-encapsulate in an error
|
|
109
247
|
var error = (sessionHasExpired
|
|
110
248
|
? new ErrorWithCode_1.default(fatalErrorMessage, fatalErrorCode)
|
|
111
249
|
: new ErrorWithCode_1.default(sessionExpiredMessage, ReactKitErrorCode_1.default.SessionExpired));
|
|
112
250
|
// Build error screen
|
|
113
|
-
|
|
251
|
+
body = ((0, jsx_runtime_1.jsx)("div", __assign({ style: {
|
|
114
252
|
display: 'block',
|
|
115
253
|
width: '100vw',
|
|
116
254
|
minHeight: '100vh',
|
|
@@ -122,8 +260,14 @@ var AppWrapper = function (props) {
|
|
|
122
260
|
? 'Session Expired'
|
|
123
261
|
: fatalErrorTitle), error: error }) })));
|
|
124
262
|
}
|
|
125
|
-
|
|
126
|
-
|
|
263
|
+
/* --------------- App -------------- */
|
|
264
|
+
if (!body) {
|
|
265
|
+
body = ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
|
|
266
|
+
}
|
|
267
|
+
/*----------------------------------------*/
|
|
268
|
+
/* Main UI */
|
|
269
|
+
/*----------------------------------------*/
|
|
270
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [modal, body] }));
|
|
127
271
|
};
|
|
128
272
|
/*------------------------------------------------------------------------*/
|
|
129
273
|
/* Wrap Up */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppWrapper.js","sourceRoot":"","sources":["../../src/components/AppWrapper.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AppWrapper.js","sourceRoot":"","sources":["../../src/components/AppWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AAEH,eAAe;AACf,+BAAmD;AAEnD,2BAA2B;AAC3B,wDAAkC;AAElC,iBAAiB;AACjB,sEAAyE;AAEzE,sBAAsB;AACtB,iFAA2D;AAE3D,2BAA2B;AAC3B,kDAA4B;AAE5B,uBAAuB;AACvB,0EAAoD;AAepD,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,2BAA2B;AAC3B,IAAI,YAA6D,CAAC;AAClE,IAAI,aAAyB,CAAC;AAE9B;;;;;GAKG;AACI,IAAM,KAAK,GAAG,UAAO,KAAa,EAAE,IAAY;;QACrD,kCAAkC;QAClC,IAAI,CAAC,YAAY,EAAE;YACjB,sBAAO,MAAM,CAAC,KAAK,CAAC,UAAG,KAAK,iBAAO,IAAI,CAAE,CAAC,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,CAAC,CAAC;AAEF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,mBAAmB;AACnB,kBAAe,UAAU,CAAC"}
|
|
@@ -39,6 +39,7 @@ declare type Props = {
|
|
|
39
39
|
title?: React.ReactNode;
|
|
40
40
|
children?: React.ReactNode;
|
|
41
41
|
onClose?: (type: ButtonType) => void;
|
|
42
|
+
dontAllowBackdropExit?: boolean;
|
|
42
43
|
okayLabel?: string;
|
|
43
44
|
okayVariant?: Variant;
|
|
44
45
|
cancelLabel?: string;
|
|
@@ -59,6 +60,7 @@ declare type Props = {
|
|
|
59
60
|
deleteVariant?: Variant;
|
|
60
61
|
confirmLabel?: string;
|
|
61
62
|
confirmVariant?: Variant;
|
|
63
|
+
onTopOfOtherModals?: boolean;
|
|
62
64
|
};
|
|
63
65
|
declare const Modal: (React.FC<Props> & {
|
|
64
66
|
ModalType: typeof ModalType;
|
package/lib/components/Modal.js
CHANGED
|
@@ -196,7 +196,7 @@ var Modal = function (props) {
|
|
|
196
196
|
/*------------------------------------------------------------------------*/
|
|
197
197
|
var _a;
|
|
198
198
|
/* -------------- Props ------------- */
|
|
199
|
-
var _b = props.type, type = _b === void 0 ? ModalType.NoButtons : _b, _c = props.size, size = _c === void 0 ? ModalSize.Large : _c, title = props.title, children = props.children, onClose = props.onClose;
|
|
199
|
+
var _b = props.type, type = _b === void 0 ? ModalType.NoButtons : _b, _c = props.size, size = _c === void 0 ? ModalSize.Large : _c, title = props.title, children = props.children, onClose = props.onClose, dontAllowBackdropExit = props.dontAllowBackdropExit, onTopOfOtherModals = props.onTopOfOtherModals;
|
|
200
200
|
/* -------------- State ------------- */
|
|
201
201
|
// If true, the modal is shown
|
|
202
202
|
var _d = (0, react_1.useState)(false), visible = _d[0], setVisible = _d[1];
|
|
@@ -300,8 +300,14 @@ var Modal = function (props) {
|
|
|
300
300
|
: undefined);
|
|
301
301
|
// Render the modal
|
|
302
302
|
return ((0, jsx_runtime_1.jsxs)(Modal_1.default, __assign({ show: visible, size: size !== ModalSize.Medium ? size : undefined, onHide: function () {
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
if (!dontAllowBackdropExit) {
|
|
304
|
+
handleClose(ButtonType.Cancel);
|
|
305
|
+
}
|
|
306
|
+
}, style: {
|
|
307
|
+
zIndex: (onTopOfOtherModals
|
|
308
|
+
? 6000000000
|
|
309
|
+
: 5000000000),
|
|
310
|
+
}, backdropClassName: "Modal-backdrop", centered: true }, { children: [(0, jsx_runtime_1.jsx)("style", { children: style }), title && ((0, jsx_runtime_1.jsx)(Modal_1.default.Header, __assign({ closeButton: !!onClose }, { children: (0, jsx_runtime_1.jsx)(Modal_1.default.Title, { children: title }) }))), children && ((0, jsx_runtime_1.jsx)(Modal_1.default.Body, { children: children })), footer && ((0, jsx_runtime_1.jsx)(Modal_1.default.Footer, { children: footer }))] })));
|
|
305
311
|
};
|
|
306
312
|
/*------------------------------------------------------------------------*/
|
|
307
313
|
/* Wrap Up */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/components/Modal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;GAGG;AAEH,eAAe;AACf,+BAAmD;AAEnD,0BAA0B;AAC1B,gEAAmD;AACnD,6DAAuC;AAEvC,eAAe;AACf,6DAAuC;AAEvC,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,IAAM,KAAK,GAAG,6kCAiDb,CAAC;AAEF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,YAAY;AACZ,IAAM,aAAa,GAAG,GAAG,CAAC,CAAC,gDAAgD;AAC3E,IAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,2EAA2E;AAE3E,cAAc;AACd,IAAK,SAUJ;AAVD,WAAK,SAAS;IACZ,0BAAa,CAAA;IACb,uCAA0B,CAAA;IAC1B,6BAAgB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ACD,KAAK,EAAE;YACL,MAAM,EAAE,CACN,kBAAkB;gBAChB,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,UAAU,CACf;SACF,EACD,iBAAiB,EAAC,gBAAgB,EAClC,QAAQ,uBAER,4CAAQ,KAAK,GAAS,EACrB,KAAK,IAAI,CACR,uBAAC,eAAc,CAAC,MAAM,aACpB,WAAW,EAAE,CAAC,CAAC,OAAO,gBAEtB,uBAAC,eAAc,CAAC,KAAK,cAClB,KAAK,GACe,IACD,CACzB,EACA,QAAQ,IAAI,CACX,uBAAC,eAAc,CAAC,IAAI,cACjB,QAAQ,GACW,CACvB,EACA,MAAM,IAAI,CACT,uBAAC,eAAc,CAAC,MAAM,cACnB,MAAM,GACe,CACzB,KACc,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,YAAY;AACZ,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;AAC5B,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;AAC5B,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;AAC9B,KAAK,CAAC,OAAO,GAAG,iBAAO,CAAC;AAExB,kBAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A box with a tab on the top that holds buttons and other content
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
declare type Props = {
|
|
7
|
+
title: React.ReactNode;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
declare const TabBox: React.FC<Props>;
|
|
11
|
+
export default TabBox;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
+
/*------------------------------------------------------------------------*/
|
|
16
|
+
/* Style */
|
|
17
|
+
/*------------------------------------------------------------------------*/
|
|
18
|
+
var style = "\n/* Tab Box */\n.TabBox-box {\n /* Light Border */\n border: 2px solid #dedede;\n \n /* Rounded Corners (except top-left) */\n border-bottom-right-radius: 5px;\n border-bottom-left-radius: 5px;\n border-top-right-radius: 5px;\n\n /* Very Light Gray Border */\n background: #fdfdfd;\n\n /* Align Contents on Left */\n text-align: left;\n}\n\n/* Container for Title */\n.TabBox-title-container {\n /* Place on Left */\n position: relative;\n left: 0;\n text-align: left;\n}\n\n/* Tab-style Title */\n.TabBox-title {\n /* Place so it Barely Overlaps the Box Border */\n display: inline-block;\n position: relative;\n top: 2px; /* Gives Illusion that Border Doesn't Exist Below Tab */\n\n /* Title-sized Font */\n font-size: 25px;\n\n /* Add Border on Top and Sides */\n border-top: 2px solid #dedede;\n border-left: 2px solid #dedede;\n border-right: 2px solid #dedede;\n\n /* Round the Top Corners */\n border-top-left-radius: 5px;\n border-top-right-radius: 5px;\n\n /* Add Text Padding */\n padding-left: 12px;\n padding-right: 12px;\n\n /* Match Background Color of Box */\n background: #fdfdfd;\n}\n\n/* Make the TabBox's Children Appear Above Title if Overlap Occurs */\n.TabBox-children {\n position: relative;\n z-index: 1;\n}\n";
|
|
19
|
+
/*------------------------------------------------------------------------*/
|
|
20
|
+
/* Component */
|
|
21
|
+
/*------------------------------------------------------------------------*/
|
|
22
|
+
var TabBox = function (props) {
|
|
23
|
+
/*------------------------------------------------------------------------*/
|
|
24
|
+
/* Setup */
|
|
25
|
+
/*------------------------------------------------------------------------*/
|
|
26
|
+
/* -------------- Props ------------- */
|
|
27
|
+
var title = props.title, children = props.children;
|
|
28
|
+
/*------------------------------------------------------------------------*/
|
|
29
|
+
/* Render */
|
|
30
|
+
/*------------------------------------------------------------------------*/
|
|
31
|
+
/*----------------------------------------*/
|
|
32
|
+
/* Main UI */
|
|
33
|
+
/*----------------------------------------*/
|
|
34
|
+
// Full UI
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("style", { children: style }), (0, jsx_runtime_1.jsx)("div", __assign({ className: "TabBox-title-container" }, { children: (0, jsx_runtime_1.jsx)("div", __assign({ className: "TabBox-title" }, { children: title })) })), (0, jsx_runtime_1.jsx)("div", __assign({ className: "TabBox-box p-2" }, { children: (0, jsx_runtime_1.jsx)("div", __assign({ className: "TabBox-children" }, { children: children })) }))] }));
|
|
36
|
+
};
|
|
37
|
+
/*------------------------------------------------------------------------*/
|
|
38
|
+
/* Wrap Up */
|
|
39
|
+
/*------------------------------------------------------------------------*/
|
|
40
|
+
// Export component
|
|
41
|
+
exports.default = TabBox;
|
|
42
|
+
//# sourceMappingURL=TabBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabBox.js","sourceRoot":"","sources":["../../src/components/TabBox.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAmBA,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,IAAM,KAAK,GAAG,uvCA0Db,CAAC;AAEF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,IAAM,MAAM,GAAoB,UAAC,KAAK;IACpC,4EAA4E;IAC5E,4EAA4E;IAC5E,4EAA4E;IAE5E,wCAAwC;IAGtC,IAAA,KAAK,GAEH,KAAK,MAFF,EACL,QAAQ,GACN,KAAK,SADC,CACA;IAEV,4EAA4E;IAC5E,4EAA4E;IAC5E,4EAA4E;IAE5E,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAE5C,UAAU;IACV,OAAO,CACL,4CAEE,4CAAQ,KAAK,GAAS,EAGtB,yCAAK,SAAS,EAAC,wBAAwB,gBACrC,yCAAK,SAAS,EAAC,cAAc,gBAC1B,KAAK,IACF,IACF,EAGN,yCAAK,SAAS,EAAC,gBAAgB,gBAC7B,yCAAK,SAAS,EAAC,iBAAiB,gBAC7B,QAAQ,IACL,IACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,mBAAmB;AACnB,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../src/helpers/alert.tsx"],"names":[],"mappings":";;AAAA,uDAAiD;AAEjD,kBAAe,kBAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../../src/helpers/confirm.tsx"],"names":[],"mappings":";;AAAA,uDAAmD;AAEnD,kBAAe,oBAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -16,6 +16,9 @@ import { setSessionExpiryHandler } from '../helpers/visitServerEndpoint';
|
|
|
16
16
|
// Import shared types
|
|
17
17
|
import ReactKitErrorCode from '../types/ReactKitErrorCode';
|
|
18
18
|
|
|
19
|
+
// Import shared components
|
|
20
|
+
import Modal from './Modal';
|
|
21
|
+
|
|
19
22
|
// Import custom errors
|
|
20
23
|
import ErrorWithCode from '../errors/ErrorWithCode';
|
|
21
24
|
|
|
@@ -36,6 +39,84 @@ type Props = {
|
|
|
36
39
|
/* Static Helpers */
|
|
37
40
|
/*------------------------------------------------------------------------*/
|
|
38
41
|
|
|
42
|
+
/*----------------------------------------*/
|
|
43
|
+
/* Alert */
|
|
44
|
+
/*----------------------------------------*/
|
|
45
|
+
|
|
46
|
+
// Stored copies of setters
|
|
47
|
+
let setAlertInfo: (info: { title: string, text: string }) => void;
|
|
48
|
+
let onAlertClosed: () => void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Show an alert modal with an "Okay" button
|
|
52
|
+
* @author Gabe Abrams
|
|
53
|
+
* @param title the title text to display at the top of the alert
|
|
54
|
+
* @param text the text to display in the alert
|
|
55
|
+
*/
|
|
56
|
+
export const alert = async (title: string, text: string) => {
|
|
57
|
+
// Fallback if alert not available
|
|
58
|
+
if (!setAlertInfo) {
|
|
59
|
+
return window.alert(`${title}\n\n${text}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Return promise that resolves when alert is closed
|
|
63
|
+
return new Promise((resolve) => {
|
|
64
|
+
// Setup handler
|
|
65
|
+
onAlertClosed = () => {
|
|
66
|
+
resolve(null);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// Show the alert
|
|
70
|
+
setAlertInfo({
|
|
71
|
+
title,
|
|
72
|
+
text,
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/*----------------------------------------*/
|
|
78
|
+
/* Confirm */
|
|
79
|
+
/*----------------------------------------*/
|
|
80
|
+
|
|
81
|
+
// Stored copies of setters
|
|
82
|
+
let setConfirmInfo: (info: { title: string, text: string }) => void;
|
|
83
|
+
let onConfirmClosed: (confirmed: boolean) => void;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Show a confirmation modal with an "Okay" and a "Cancel" button
|
|
87
|
+
* @author Gabe Abrams
|
|
88
|
+
* @param title the title text to display at the top of the alert
|
|
89
|
+
* @param text the text to display in the alert
|
|
90
|
+
* @returns true if the user confirmed
|
|
91
|
+
*/
|
|
92
|
+
export const confirm = async (
|
|
93
|
+
title: string,
|
|
94
|
+
text: string,
|
|
95
|
+
): Promise<boolean> => {
|
|
96
|
+
// Fallback if confirm is not available
|
|
97
|
+
if (!setConfirmInfo) {
|
|
98
|
+
return window.confirm(`${title}\n\n${text}`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Return promise that resolves with result of confirmation
|
|
102
|
+
return new Promise((resolve) => {
|
|
103
|
+
// Setup handler
|
|
104
|
+
onConfirmClosed = (confirmed: boolean) => {
|
|
105
|
+
resolve(confirmed)
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Show the confirm
|
|
109
|
+
setConfirmInfo({
|
|
110
|
+
title,
|
|
111
|
+
text,
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/*----------------------------------------*/
|
|
117
|
+
/* Fatal Error */
|
|
118
|
+
/*----------------------------------------*/
|
|
119
|
+
|
|
39
120
|
// Stored copies of setters
|
|
40
121
|
let setFatalErrorMessage: (message: string) => void;
|
|
41
122
|
let setFatalErrorCode: (code: string) => void;
|
|
@@ -65,7 +146,10 @@ export const showFatalError = (
|
|
|
65
146
|
|
|
66
147
|
// Handle case where app hasn't loaded
|
|
67
148
|
if (!setFatalErrorMessage || !setFatalErrorCode) {
|
|
68
|
-
return alert(
|
|
149
|
+
return alert(
|
|
150
|
+
errorTitle,
|
|
151
|
+
`${message} (code: ${code}). Please contact support.`,
|
|
152
|
+
);
|
|
69
153
|
}
|
|
70
154
|
|
|
71
155
|
// Use setters
|
|
@@ -94,15 +178,47 @@ const AppWrapper = (props: Props): React.ReactElement => {
|
|
|
94
178
|
/* -------------- State ------------- */
|
|
95
179
|
|
|
96
180
|
// Fatal error
|
|
97
|
-
const [
|
|
181
|
+
const [
|
|
182
|
+
fatalErrorMessage,
|
|
183
|
+
setFatalErrorMessageInner,
|
|
184
|
+
] = useState<string | undefined>();
|
|
98
185
|
setFatalErrorMessage = setFatalErrorMessageInner;
|
|
99
|
-
const [
|
|
186
|
+
const [
|
|
187
|
+
fatalErrorCode,
|
|
188
|
+
setFatalErrorCodeInner,
|
|
189
|
+
] = useState<string | undefined>();
|
|
100
190
|
setFatalErrorCode = setFatalErrorCodeInner;
|
|
101
|
-
const [
|
|
191
|
+
const [
|
|
192
|
+
fatalErrorTitle,
|
|
193
|
+
setFatalErrorTitleInner,
|
|
194
|
+
] = useState<string | undefined>();
|
|
102
195
|
setFatalErrorTitle = setFatalErrorTitleInner;
|
|
103
196
|
|
|
197
|
+
// Alert
|
|
198
|
+
const [
|
|
199
|
+
alertInfo,
|
|
200
|
+
setAlertInfoInner,
|
|
201
|
+
] = useState<{
|
|
202
|
+
title: string,
|
|
203
|
+
text: string
|
|
204
|
+
}>();
|
|
205
|
+
setAlertInfo = setAlertInfoInner;
|
|
206
|
+
|
|
207
|
+
// Confirm
|
|
208
|
+
const [
|
|
209
|
+
confirmInfo,
|
|
210
|
+
setConfirmInfoInner,
|
|
211
|
+
] = useState<{
|
|
212
|
+
title: string,
|
|
213
|
+
text: string
|
|
214
|
+
}>();
|
|
215
|
+
setConfirmInfo = setConfirmInfoInner;
|
|
216
|
+
|
|
104
217
|
// Session expired
|
|
105
|
-
const [
|
|
218
|
+
const [
|
|
219
|
+
sessionHasExpired,
|
|
220
|
+
setSessionHasExpired,
|
|
221
|
+
] = useState<boolean>(false);
|
|
106
222
|
|
|
107
223
|
/*------------------------------------------------------------------------*/
|
|
108
224
|
/* Lifecycle Functions */
|
|
@@ -128,10 +244,60 @@ const AppWrapper = (props: Props): React.ReactElement => {
|
|
|
128
244
|
/*------------------------------------------------------------------------*/
|
|
129
245
|
|
|
130
246
|
/*----------------------------------------*/
|
|
131
|
-
/*
|
|
247
|
+
/* Modal */
|
|
248
|
+
/*----------------------------------------*/
|
|
249
|
+
|
|
250
|
+
// Modal that may be defined
|
|
251
|
+
let modal: React.ReactNode;
|
|
252
|
+
|
|
253
|
+
/* -------------- Alert ------------- */
|
|
254
|
+
|
|
255
|
+
if (alertInfo) {
|
|
256
|
+
modal = (
|
|
257
|
+
<Modal
|
|
258
|
+
title={alertInfo.title}
|
|
259
|
+
type={Modal.ModalType.Okay}
|
|
260
|
+
onClose={() => {
|
|
261
|
+
// Alert closed
|
|
262
|
+
if (onAlertClosed) {
|
|
263
|
+
onAlertClosed();
|
|
264
|
+
}
|
|
265
|
+
}}
|
|
266
|
+
onTopOfOtherModals
|
|
267
|
+
>
|
|
268
|
+
{alertInfo.text}
|
|
269
|
+
</Modal>
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/* ------------- Confirm ------------ */
|
|
274
|
+
|
|
275
|
+
if (confirmInfo) {
|
|
276
|
+
modal = (
|
|
277
|
+
<Modal
|
|
278
|
+
title={confirmInfo.title}
|
|
279
|
+
type={Modal.ModalType.OkayCancel}
|
|
280
|
+
onClose={(buttonType) => {
|
|
281
|
+
if (onConfirmClosed) {
|
|
282
|
+
onConfirmClosed(buttonType === Modal.ButtonType.Okay);
|
|
283
|
+
}
|
|
284
|
+
}}
|
|
285
|
+
dontAllowBackdropExit
|
|
286
|
+
>
|
|
287
|
+
|
|
288
|
+
</Modal>
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/*----------------------------------------*/
|
|
293
|
+
/* Views */
|
|
132
294
|
/*----------------------------------------*/
|
|
133
295
|
|
|
134
|
-
//
|
|
296
|
+
// Body that will be filled with the current view
|
|
297
|
+
let body: React.ReactNode;
|
|
298
|
+
|
|
299
|
+
/* ----------- Fatal Error ---------- */
|
|
300
|
+
|
|
135
301
|
if (fatalErrorMessage || fatalErrorCode || sessionHasExpired) {
|
|
136
302
|
// Re-encapsulate in an error
|
|
137
303
|
const error = (
|
|
@@ -147,7 +313,7 @@ const AppWrapper = (props: Props): React.ReactElement => {
|
|
|
147
313
|
);
|
|
148
314
|
|
|
149
315
|
// Build error screen
|
|
150
|
-
|
|
316
|
+
body = (
|
|
151
317
|
<div
|
|
152
318
|
style={{
|
|
153
319
|
display: 'block',
|
|
@@ -173,10 +339,24 @@ const AppWrapper = (props: Props): React.ReactElement => {
|
|
|
173
339
|
);
|
|
174
340
|
}
|
|
175
341
|
|
|
176
|
-
|
|
342
|
+
/* --------------- App -------------- */
|
|
343
|
+
|
|
344
|
+
if (!body) {
|
|
345
|
+
body = (
|
|
346
|
+
<>
|
|
347
|
+
{children}
|
|
348
|
+
</>
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/*----------------------------------------*/
|
|
353
|
+
/* Main UI */
|
|
354
|
+
/*----------------------------------------*/
|
|
355
|
+
|
|
177
356
|
return (
|
|
178
357
|
<>
|
|
179
|
-
{
|
|
358
|
+
{modal}
|
|
359
|
+
{body}
|
|
180
360
|
</>
|
|
181
361
|
);
|
|
182
362
|
};
|
package/src/components/Modal.tsx
CHANGED
|
@@ -209,6 +209,8 @@ type Props = {
|
|
|
209
209
|
children?: React.ReactNode,
|
|
210
210
|
// Handler to call when modal is closed (if excluded, not closable)
|
|
211
211
|
onClose?: (type: ButtonType) => void,
|
|
212
|
+
// If true, don't allow the user to click the backdrop to exit
|
|
213
|
+
dontAllowBackdropExit?: boolean,
|
|
212
214
|
// Custom label for "okay" button
|
|
213
215
|
okayLabel?: string,
|
|
214
216
|
// Custom variant for "okay" button
|
|
@@ -249,6 +251,8 @@ type Props = {
|
|
|
249
251
|
confirmLabel?: string,
|
|
250
252
|
// Custom variant for "confirm" button
|
|
251
253
|
confirmVariant?: Variant,
|
|
254
|
+
// True if modal should be on top of other modals
|
|
255
|
+
onTopOfOtherModals?: boolean,
|
|
252
256
|
};
|
|
253
257
|
|
|
254
258
|
/*------------------------------------------------------------------------*/
|
|
@@ -276,6 +280,8 @@ const Modal: (
|
|
|
276
280
|
title,
|
|
277
281
|
children,
|
|
278
282
|
onClose,
|
|
283
|
+
dontAllowBackdropExit,
|
|
284
|
+
onTopOfOtherModals,
|
|
279
285
|
} = props;
|
|
280
286
|
|
|
281
287
|
/* -------------- State ------------- */
|
|
@@ -404,9 +410,17 @@ const Modal: (
|
|
|
404
410
|
show={visible}
|
|
405
411
|
size={size !== ModalSize.Medium ? size : undefined}
|
|
406
412
|
onHide={() => {
|
|
407
|
-
|
|
413
|
+
if (!dontAllowBackdropExit) {
|
|
414
|
+
handleClose(ButtonType.Cancel);
|
|
415
|
+
}
|
|
416
|
+
}}
|
|
417
|
+
style={{
|
|
418
|
+
zIndex: (
|
|
419
|
+
onTopOfOtherModals
|
|
420
|
+
? 6000000000
|
|
421
|
+
: 5000000000
|
|
422
|
+
),
|
|
408
423
|
}}
|
|
409
|
-
style={{ zIndex: 5000000000 }}
|
|
410
424
|
backdropClassName="Modal-backdrop"
|
|
411
425
|
centered
|
|
412
426
|
>
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A box with a tab on the top that holds buttons and other content
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Import React
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
/*------------------------------------------------------------------------*/
|
|
10
|
+
/* Types */
|
|
11
|
+
/*------------------------------------------------------------------------*/
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
// Title of the box
|
|
15
|
+
title: React.ReactNode,
|
|
16
|
+
// Children/contents inside the box
|
|
17
|
+
children: React.ReactNode,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/*------------------------------------------------------------------------*/
|
|
21
|
+
/* Style */
|
|
22
|
+
/*------------------------------------------------------------------------*/
|
|
23
|
+
|
|
24
|
+
const style = `
|
|
25
|
+
/* Tab Box */
|
|
26
|
+
.TabBox-box {
|
|
27
|
+
/* Light Border */
|
|
28
|
+
border: 2px solid #dedede;
|
|
29
|
+
|
|
30
|
+
/* Rounded Corners (except top-left) */
|
|
31
|
+
border-bottom-right-radius: 5px;
|
|
32
|
+
border-bottom-left-radius: 5px;
|
|
33
|
+
border-top-right-radius: 5px;
|
|
34
|
+
|
|
35
|
+
/* Very Light Gray Border */
|
|
36
|
+
background: #fdfdfd;
|
|
37
|
+
|
|
38
|
+
/* Align Contents on Left */
|
|
39
|
+
text-align: left;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Container for Title */
|
|
43
|
+
.TabBox-title-container {
|
|
44
|
+
/* Place on Left */
|
|
45
|
+
position: relative;
|
|
46
|
+
left: 0;
|
|
47
|
+
text-align: left;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Tab-style Title */
|
|
51
|
+
.TabBox-title {
|
|
52
|
+
/* Place so it Barely Overlaps the Box Border */
|
|
53
|
+
display: inline-block;
|
|
54
|
+
position: relative;
|
|
55
|
+
top: 2px; /* Gives Illusion that Border Doesn't Exist Below Tab */
|
|
56
|
+
|
|
57
|
+
/* Title-sized Font */
|
|
58
|
+
font-size: 25px;
|
|
59
|
+
|
|
60
|
+
/* Add Border on Top and Sides */
|
|
61
|
+
border-top: 2px solid #dedede;
|
|
62
|
+
border-left: 2px solid #dedede;
|
|
63
|
+
border-right: 2px solid #dedede;
|
|
64
|
+
|
|
65
|
+
/* Round the Top Corners */
|
|
66
|
+
border-top-left-radius: 5px;
|
|
67
|
+
border-top-right-radius: 5px;
|
|
68
|
+
|
|
69
|
+
/* Add Text Padding */
|
|
70
|
+
padding-left: 12px;
|
|
71
|
+
padding-right: 12px;
|
|
72
|
+
|
|
73
|
+
/* Match Background Color of Box */
|
|
74
|
+
background: #fdfdfd;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* Make the TabBox's Children Appear Above Title if Overlap Occurs */
|
|
78
|
+
.TabBox-children {
|
|
79
|
+
position: relative;
|
|
80
|
+
z-index: 1;
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
/*------------------------------------------------------------------------*/
|
|
85
|
+
/* Component */
|
|
86
|
+
/*------------------------------------------------------------------------*/
|
|
87
|
+
|
|
88
|
+
const TabBox: React.FC<Props> = (props) => {
|
|
89
|
+
/*------------------------------------------------------------------------*/
|
|
90
|
+
/* Setup */
|
|
91
|
+
/*------------------------------------------------------------------------*/
|
|
92
|
+
|
|
93
|
+
/* -------------- Props ------------- */
|
|
94
|
+
|
|
95
|
+
const {
|
|
96
|
+
title,
|
|
97
|
+
children,
|
|
98
|
+
} = props;
|
|
99
|
+
|
|
100
|
+
/*------------------------------------------------------------------------*/
|
|
101
|
+
/* Render */
|
|
102
|
+
/*------------------------------------------------------------------------*/
|
|
103
|
+
|
|
104
|
+
/*----------------------------------------*/
|
|
105
|
+
/* Main UI */
|
|
106
|
+
/*----------------------------------------*/
|
|
107
|
+
|
|
108
|
+
// Full UI
|
|
109
|
+
return (
|
|
110
|
+
<div>
|
|
111
|
+
{/* Style */}
|
|
112
|
+
<style>{style}</style>
|
|
113
|
+
|
|
114
|
+
{/* Title */}
|
|
115
|
+
<div className="TabBox-title-container">
|
|
116
|
+
<div className="TabBox-title">
|
|
117
|
+
{title}
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
{/* Contents */}
|
|
122
|
+
<div className="TabBox-box p-2">
|
|
123
|
+
<div className="TabBox-children">
|
|
124
|
+
{children}
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/*------------------------------------------------------------------------*/
|
|
132
|
+
/* Wrap Up */
|
|
133
|
+
/*------------------------------------------------------------------------*/
|
|
134
|
+
|
|
135
|
+
// Export component
|
|
136
|
+
export default TabBox;
|