@firedesktop/react-base 1.50.0 → 1.52.0

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.
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+
3
+
4
+ type AppInputType_Type =
5
+ 'button'
6
+ | 'checkbox'
7
+ | 'color'
8
+ | 'date'
9
+ | 'datetime-local'
10
+ | 'email'
11
+ | 'file'
12
+ | 'hidden'
13
+ | 'image'
14
+ | 'month'
15
+ | 'number'
16
+ | 'password'
17
+ | 'radio'
18
+ | 'range'
19
+ | 'reset'
20
+ | 'search'
21
+ | 'submit'
22
+ | 'tel'
23
+ | 'text'
24
+ | 'url'
25
+ | 'week';
26
+
27
+ type Proptype = {
28
+ appIcon: any;
29
+ ariadescribedby?: string;
30
+ autoComplete?: boolean,
31
+ autoFocus?: boolean,
32
+ className?: string;
33
+ classNameWrapper?: string,
34
+ id?: string;
35
+ name?: string;
36
+ onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
37
+ onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
38
+ placeholder?: string;
39
+ ref?: React.LegacyRef<HTMLInputElement>
40
+ type?: AppInputType_Type;
41
+ value?: string | number;
42
+ };
43
+
44
+ function AppInput({ appIcon, ariadescribedby, autoComplete = true, autoFocus = false, className, classNameWrapper, id, name, onChange, onKeyUp, placeholder, ref, type = 'text', value }: Proptype) {
45
+ const classWrap = classNameWrapper ? `form-group AppInput_form ${classNameWrapper}` : 'form-group AppInput_form';
46
+ return (
47
+ <div className={classWrap}>
48
+ <input
49
+ autoComplete={autoComplete ? 'on' : 'off'}
50
+ autoFocus={autoFocus}
51
+ aria-describedby={ariadescribedby}
52
+ className={`form-control ${className ?? ''}`}
53
+ id={id}
54
+ name={name}
55
+ onChange={onChange}
56
+ onKeyUp={onKeyUp}
57
+ placeholder={placeholder}
58
+ ref={ref}
59
+ type={type}
60
+ value={value} />
61
+ {appIcon}
62
+ </div>
63
+ );
64
+ }
65
+
66
+ export default AppInput;
@@ -0,0 +1,124 @@
1
+ import React from 'react';
2
+ import { AppIcon } from '.';
3
+
4
+ type PropType = {
5
+ activePage: number,
6
+ className?: string
7
+ itemsPerPage: number,
8
+ maxSize?: number,
9
+ onPageChange: (page: number) => void,
10
+ pageFontSize?: number,
11
+ totalItems: number
12
+ };
13
+ function AppPagination({ activePage, className, itemsPerPage, maxSize = 5, onPageChange, pageFontSize = 14, totalItems }: PropType) {
14
+ const calculatePagination = (activePage: number, itemsPerPage: number, maxSize: number, totalItems: number): { totalPages: number, paginationArray: Array<number> } => {
15
+ if (totalItems) {
16
+ return pagination(activePage, itemsPerPage, maxSize, totalItems);
17
+ } else {
18
+ return {
19
+ totalPages: 1,
20
+ paginationArray: [1]
21
+ };
22
+ }
23
+ };
24
+
25
+ const pagination = (activePage: number, itemsPerPage: number, maxSize: number, totalItems: number): { totalPages: number, paginationArray: Array<number> } => {
26
+ const totalPages = Math.ceil((totalItems || 1) / itemsPerPage);
27
+ const allPages = Array.from(Array(totalPages), (_, x) => x + 1);
28
+
29
+ if (maxSize >= allPages.length)
30
+ return { totalPages, paginationArray: Array.from(new Set(allPages)) };
31
+
32
+ const paginationArray = [];
33
+ const beforePages = Math.trunc(maxSize / 2);
34
+ let firstPageToShow = activePage;
35
+ while (true) {
36
+ if (firstPageToShow === 1 || firstPageToShow === activePage - beforePages)
37
+ break;
38
+ firstPageToShow--;
39
+ }
40
+
41
+ const delta = firstPageToShow + maxSize - 1 - totalPages;
42
+ const endPage = firstPageToShow + maxSize - 1 >= totalPages ? totalPages : firstPageToShow + maxSize - 1;
43
+ if (delta > 0)
44
+ firstPageToShow -= delta;
45
+ for (let index = firstPageToShow; index <= endPage; index++)
46
+ paginationArray.push(index);
47
+
48
+ return { totalPages, paginationArray: Array.from(new Set(paginationArray)) };
49
+ };
50
+
51
+ const { paginationArray, totalPages } = calculatePagination(activePage, itemsPerPage, maxSize, totalItems);
52
+
53
+
54
+ const goToFirst = (event: React.MouseEvent<HTMLLIElement>) => {
55
+ event.preventDefault();
56
+ if (activePage !== 1)
57
+ onPageChange(1);
58
+ };
59
+
60
+ const goToLast = (event: React.MouseEvent<HTMLLIElement>) => {
61
+ event.preventDefault();
62
+ if (activePage !== totalPages)
63
+ onPageChange(totalPages);
64
+ };
65
+
66
+ const goToMext = (event: React.MouseEvent<HTMLLIElement>) => {
67
+ event.preventDefault();
68
+ if (activePage !== totalPages)
69
+ onPageChange(activePage + 1);
70
+ };
71
+
72
+ const goToPrev = (event: React.MouseEvent<HTMLLIElement>) => {
73
+ event.preventDefault();
74
+ if (activePage !== 1)
75
+ onPageChange(activePage - 1);
76
+ };
77
+
78
+ return (
79
+ <nav aria-label="Page navigation" className={className ? className : ''}>
80
+ <ul className="pagination">
81
+ {/* First */}
82
+ <li className="page-item" onClick={goToFirst}>
83
+ <span aria-hidden="true">
84
+ <AppIcon name={'arrow-first'} />
85
+ </span>
86
+ </li>
87
+ {/* Prev */}
88
+ <li className="page-item disabled" onClick={goToPrev}>
89
+ <span aria-hidden="true">
90
+ <AppIcon name={'arrow-prev'} />
91
+ </span>
92
+ </li>
93
+ {/* Middle */}
94
+ {paginationArray.map((page: number, index: number) => (
95
+ <li key={index}
96
+ className={`page-item ${page === activePage ? 'active' : ''}`}
97
+ onClick={() => {
98
+ if (activePage !== page)
99
+ onPageChange(page);
100
+ }}
101
+ style={{ borderRadius: 5 }} >
102
+ <span aria-hidden="true" style={{ fontSize: pageFontSize }}>
103
+ {page} <span className="sr-only">(current)</span>
104
+ </span>
105
+ </li>
106
+ ))}
107
+ {/* Next */}
108
+ <li className="page-item" onClick={goToMext}>
109
+ <span aria-hidden="true">
110
+ <AppIcon name={'arrow-next'} />
111
+ </span>
112
+ </li>
113
+ {/* Last */}
114
+ <li className="page-item" onClick={goToLast}>
115
+ <span aria-hidden="true">
116
+ <AppIcon name={'arrow-last'} />
117
+ </span>
118
+ </li>
119
+ </ul>
120
+ </nav>
121
+ );
122
+ }
123
+
124
+ export default AppPagination;
@@ -0,0 +1,31 @@
1
+ import { createSpinner, hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
2
+ import React, { useEffect } from 'react';
3
+
4
+ type Spin_TYPE = {
5
+ spinning: boolean,
6
+ targetId?: string
7
+ }
8
+
9
+ /**
10
+ * Based on this: https://ej2.syncfusion.com/react/documentation/spinner/getting-started/
11
+ * @param param0
12
+ */
13
+ const Spin = ({ spinning, targetId = 'root' }: Spin_TYPE) => {
14
+ useEffect(() => {
15
+ createSpinner({
16
+ target: document.getElementById(targetId) as HTMLElement
17
+ });
18
+ // eslint-disable-next-line react-hooks/exhaustive-deps
19
+ }, []);
20
+
21
+ if (spinning)
22
+ showSpinner(document.getElementById(targetId) as HTMLElement);
23
+ else
24
+ hideSpinner(document.getElementById(targetId) as HTMLElement);
25
+
26
+ return (
27
+ <React.Fragment />
28
+ );
29
+ };
30
+
31
+ export default Spin;
@@ -0,0 +1,50 @@
1
+ import { ToastComponent } from '@syncfusion/ej2-react-notifications';
2
+ import { PositionDataModel } from '@syncfusion/ej2-popups';
3
+ import React, { createRef, useEffect } from 'react';
4
+
5
+ import '../../styles/toaster.css';
6
+ import * as Types from './Types';
7
+
8
+
9
+ type Toaster_Props = {
10
+ propertiesObject: Types.Toaster_Prop_Type
11
+ }
12
+
13
+ /**
14
+ * https://ej2.syncfusion.com/react/demos/?_ga=2.216203862.1349101002.1605820787-2080297629.1605485687#/material/toast/default
15
+ */
16
+ const Toaster = ({ propertiesObject }: Toaster_Props) => {
17
+ const toastObj = createRef<any>();
18
+ const position: PositionDataModel = { X: 'Right' };
19
+
20
+ useEffect(() => {
21
+ if (propertiesObject && propertiesObject.title && propertiesObject.title !== '') {
22
+ toastObj.current.showCloseButton = true;
23
+ toastObj.current.showProgressBar = true;
24
+
25
+ if (propertiesObject.type === 'Information')
26
+ toastObj.current.show({ title: propertiesObject.title, content: propertiesObject.content ?? '', cssClass: 'e-toast-info', icon: 'e-info toast-icons' });
27
+ else if (propertiesObject.type === 'Error')
28
+ toastObj.current.show({
29
+ title: propertiesObject.title, content: propertiesObject.content ?? '', cssClass: 'e-toast-danger', icon: 'e-error toast-icons',
30
+ timeOut: 4000
31
+ });
32
+ else if (propertiesObject.type === 'Success')
33
+ toastObj.current.show({ title: propertiesObject.title, content: propertiesObject.content ?? '', cssClass: 'e-toast-success', icon: 'e-success toast-icons' });
34
+ else if (propertiesObject.type === 'Warning')
35
+ toastObj.current.show({ title: propertiesObject.title, content: propertiesObject.content ?? '', cssClass: 'e-toast-warning', icon: 'e-warning toast-icons' });
36
+ }
37
+ // eslint-disable-next-line react-hooks/exhaustive-deps
38
+ }, [propertiesObject]);
39
+
40
+ return (
41
+ <React.Fragment>
42
+ <ToastComponent
43
+ ref={toastObj}
44
+ id='toast_default'
45
+ position={position}></ToastComponent>
46
+ </React.Fragment>
47
+ );
48
+ };
49
+
50
+ export default Toaster;
@@ -0,0 +1,11 @@
1
+ export type Toaster_Type =
2
+ | 'Error'
3
+ | 'Information'
4
+ | 'Success'
5
+ | 'Warning';
6
+
7
+ export type Toaster_Prop_Type = {
8
+ content?: string,
9
+ title: string,
10
+ type: Toaster_Type
11
+ }
@@ -0,0 +1,8 @@
1
+ import AppIcon from './AppIcon';
2
+ import AppInput from './AppInput';
3
+ import AppPagination from './AppPagination';
4
+ import Spin from './Spin';
5
+ import Toaster from './Toaster/Toaster';
6
+ import * as Toaster_Types from './Toaster/Types';
7
+
8
+ export { AppIcon, AppInput, AppPagination, Spin, Toaster, Toaster_Types };
@@ -0,0 +1,15 @@
1
+ import ConfigurationLoader from './utils/configuration/ConfigurationLoader';
2
+ import ConfigurationReturner from './utils/configuration/ConfigurationReturner';
3
+ import LanguageLoader from './utils/labels/LanguageLoader';
4
+ import LanguageReturner from './utils/labels/LanguageReturner';
5
+ import * as Components from './components';
6
+ import * as Utils from './utils';
7
+
8
+ export {
9
+ Components,
10
+ ConfigurationLoader,
11
+ ConfigurationReturner,
12
+ LanguageLoader,
13
+ LanguageReturner,
14
+ Utils
15
+ };
@@ -0,0 +1,392 @@
1
+ :root {
2
+ --background-color: linear-gradient(
3
+ 180deg,
4
+ #0057ff 0%,
5
+ rgba(0, 87, 255, 0.7) 100%,
6
+ rgba(0, 87, 255, 0.7) 100%
7
+ );
8
+ --background-gradient-active: linear-gradient(
9
+ 270deg,
10
+ rgba(0, 87, 255, 0.7) 0%,
11
+ #0057ff 100%
12
+ );
13
+
14
+ --background-progress-circle: linear-gradient(
15
+ 270deg,
16
+ rgba(0, 87, 255, 0.7) 0%,
17
+ #0057ff 78.42%
18
+ );
19
+
20
+ --background-progress-fill: linear-gradient(
21
+ 270deg,
22
+ rgba(106, 157, 255, 0.7) 0%,
23
+ #6a9dff 50.95%
24
+ );
25
+ --background-progress: linear-gradient(
26
+ 270deg,
27
+ rgba(106, 157, 255, 0.7) 0%,
28
+ #6a9dff 100%
29
+ );
30
+ --font-Josefin-sans: "Josefin Sans", sans-serif !important;
31
+ --font-Roboto: "Roboto", sans-serif !important;
32
+ --primary-color: #0057ff;
33
+ --warning-color: #ffc14e;
34
+ --danger-color: #e80026;
35
+ --tertiary-color: #b1aeae;
36
+ --success-color: #00854d;
37
+ --light-color: #c0c0c0;
38
+ --white-color: #ffffff;
39
+ --dark-pink-color: #de31d2;
40
+ --menu-dropdown-background: rgba(238, 238, 238, 0.9);
41
+ }
42
+
43
+ body {
44
+ background: #f7f7f7;
45
+ font-family: var(--font-Roboto);
46
+ overflow-x: hidden;
47
+ }
48
+
49
+ p {
50
+ color: var(--para-color);
51
+ }
52
+
53
+ .tertiary-text {
54
+ color: var(--tertiary-color);
55
+ }
56
+
57
+ .primary-text {
58
+ color: var(--primary-color);
59
+ }
60
+
61
+ .white-text {
62
+ color: var(--white-color);
63
+ }
64
+
65
+ .light-text {
66
+ color: var(--light-color);
67
+ }
68
+
69
+ .danger-text {
70
+ color: var(--danger-color);
71
+ }
72
+
73
+ .success-text {
74
+ color: var(--success-color);
75
+ }
76
+
77
+ .dark-pink-text {
78
+ color: var(--dark-pink-color);
79
+ }
80
+
81
+ /* SVG Start */
82
+ .warning-svg {
83
+ fill: var(--warning-color);
84
+ }
85
+
86
+ .tertiary-svg {
87
+ fill: var(--tertiary-color);
88
+ }
89
+
90
+ .primary-svg {
91
+ fill: var(--primary-color);
92
+ }
93
+
94
+ .white-svg {
95
+ fill: var(--white-color);
96
+ }
97
+
98
+ .light-svg {
99
+ fill: var(--light-color);
100
+ }
101
+
102
+ .danger-svg {
103
+ fill: var(--danger-color);
104
+ }
105
+
106
+ .success-svg {
107
+ fill: var(--success-color);
108
+ }
109
+
110
+ .dark-pink-svg {
111
+ fill: var(--dark-pink-color);
112
+ }
113
+
114
+ .warning-svg-stroke {
115
+ stroke: var(--warning-color);
116
+ }
117
+
118
+ .tertiary-svg-stroke {
119
+ stroke: var(--tertiary-color);
120
+ }
121
+
122
+ .primary-svg-stroke {
123
+ stroke: var(--primary-color);
124
+ }
125
+
126
+ .white-svg-stroke {
127
+ stroke: var(--white-color);
128
+ }
129
+
130
+ .light-svg-stroke {
131
+ stroke: var(--light-color);
132
+ }
133
+
134
+ .danger-svg-stroke {
135
+ stroke: var(--danger-color);
136
+ }
137
+
138
+ .success-svg-stroke {
139
+ stroke: var(--success-color);
140
+ }
141
+
142
+ .dark-pink-svg-stroke {
143
+ stroke: var(--dark-pink-color);
144
+ }
145
+ /* SVG End */
146
+
147
+ /* Fonts Start */
148
+ .fz10 {
149
+ font-size: 10px;
150
+ }
151
+
152
+ .fz11 {
153
+ font-size: 11px;
154
+ }
155
+
156
+ .fz12 {
157
+ font-size: 12px;
158
+ }
159
+
160
+ .fz13 {
161
+ font-size: 13px;
162
+ }
163
+
164
+ .fz14 {
165
+ font-size: 14px;
166
+ }
167
+
168
+ .fz15 {
169
+ font-size: 15px;
170
+ }
171
+
172
+ .fz16 {
173
+ font-size: 16px;
174
+ }
175
+
176
+ .fz17 {
177
+ font-size: 17px;
178
+ }
179
+
180
+ .fz18 {
181
+ font-size: 18px;
182
+ }
183
+
184
+ .fz19 {
185
+ font-size: 19px;
186
+ }
187
+
188
+ .fz20 {
189
+ font-size: 20px;
190
+ }
191
+
192
+ .fz21 {
193
+ font-size: 21px;
194
+ }
195
+
196
+ .fz22 {
197
+ font-size: 22px;
198
+ }
199
+
200
+ .fz24 {
201
+ font-size: 24px;
202
+ }
203
+
204
+ .fz25 {
205
+ font-size: 25px;
206
+ }
207
+
208
+ .fz26 {
209
+ font-size: 26px;
210
+ }
211
+
212
+ .fz28 {
213
+ font-size: 28px;
214
+ }
215
+
216
+ .fz30 {
217
+ font-size: 30px;
218
+ }
219
+
220
+ .fz32 {
221
+ font-size: 32px;
222
+ }
223
+
224
+ .fz34 {
225
+ font-size: 34px;
226
+ }
227
+
228
+ .fz36 {
229
+ font-size: 36px;
230
+ }
231
+
232
+ .fz38 {
233
+ font-size: 38px;
234
+ }
235
+
236
+ .fz40 {
237
+ font-size: 40px;
238
+ }
239
+
240
+ .fz45 {
241
+ font-size: 45px;
242
+ }
243
+
244
+ .fz50 {
245
+ font-size: 50px;
246
+ }
247
+
248
+ .fz60 {
249
+ font-size: 60px;
250
+ }
251
+
252
+ .fz70 {
253
+ font-size: 70px;
254
+ }
255
+ /* Fonts End */
256
+
257
+
258
+ /* breadcrumb */
259
+ .breadcrumb_text {
260
+ position: relative;
261
+ color: var(--primary-color);
262
+ }
263
+
264
+ .breadcrumb_text::after {
265
+ content: "";
266
+ width: 100%;
267
+ height: 5px;
268
+ background: var(--primary-color);
269
+ position: absolute;
270
+ left: 0;
271
+ bottom: -16px;
272
+ border-radius: 2px;
273
+ }
274
+
275
+ .warning-text {
276
+ color: var(--warning-color);
277
+ }
278
+
279
+ .success-border {
280
+ border: 2px solid var(--success-color);
281
+ }
282
+
283
+ .danger-border {
284
+ border: 2px solid var(--danger-color);
285
+ }
286
+
287
+ .warning-border {
288
+ border: 2px solid var(--warning-color);
289
+ }
290
+ .white-border {
291
+ border: 2px solid var(--primary-color);
292
+ }
293
+ .success-background {
294
+ background: var(--success-color);
295
+ color: var(--white-color);
296
+ }
297
+
298
+ .white-background {
299
+ background: var(--primary-color);
300
+ color: var(--white-color);
301
+ }
302
+ .danger-background {
303
+ background: var(--danger-color);
304
+ color: var(--white-color);
305
+ }
306
+
307
+ .warning-background {
308
+ background: var(--warning-color);
309
+ color: var(--white-color);
310
+ }
311
+ .rounded10 {
312
+ border-radius: 10px;
313
+ }
314
+ .custom-control-label::before {
315
+ border-color: var(--primary-color) !important;
316
+ }
317
+ .custom-control-input:checked ~ .custom-control-label::before {
318
+ color: #fff;
319
+ border-color: var(--primary-color) !important;
320
+ background-color: #fff !important;
321
+ }
322
+ .custom-radio .custom-control-input:checked ~ .custom-control-label::after {
323
+ background-color: var(--primary-color) !important;
324
+ background-image: none !important;
325
+ }
326
+ .custom-control-label::after {
327
+ position: absolute;
328
+ top: 0.4rem !important;
329
+ left: -1.35rem !important;
330
+ display: block;
331
+ width: 0.7rem !important;
332
+ height: 0.7rem !important;
333
+ content: "";
334
+ background: no-repeat 50% / 50% 50%;
335
+ border-radius: 100%;
336
+ }
337
+
338
+ .MuiAutocomplete-proper *{
339
+ transition: none !important;
340
+ }
341
+
342
+ /*******************************************************************************/
343
+ /* AppInput */
344
+ .AppInput_form {
345
+ position: relative;
346
+ }
347
+
348
+ .AppInput_form input {
349
+ padding: 10px 0px 10px 10px;
350
+ border: 2px solid var(--primary-color);
351
+ box-sizing: border-box;
352
+ border-radius: 15px;
353
+ font-size: 17px;
354
+ height: 34px;
355
+ width: 100%;
356
+ }
357
+
358
+ .AppInput_form svg{
359
+ position: absolute;
360
+ }
361
+
362
+ /*******************************************************************************/
363
+ /* AppPagination */
364
+ .page-item {
365
+ cursor: pointer;
366
+ margin-left: 2px;
367
+ margin-right: 2px;
368
+ }
369
+
370
+ .page-item span {
371
+ width: 28px;
372
+ height: 27px;
373
+ display: flex;
374
+ justify-content: center;
375
+ align-items: center;
376
+ }
377
+
378
+ .page-item.active span {
379
+ background: var(--background-color);
380
+ border-radius: 5px;
381
+ width: 28px;
382
+ height: 27px;
383
+ padding: 0;
384
+ text-align: center;
385
+ display: flex;
386
+ justify-content: center;
387
+ align-items: center;
388
+ color: #ffffff !important;
389
+ }
390
+
391
+
392
+
@@ -0,0 +1,10 @@
1
+ /* Spinner */
2
+ .e-spinner-pane {
3
+ background-color: rgba(0, 0, 0, 0.15);
4
+ z-index: 10000;
5
+ height: 10000px;
6
+ }
7
+
8
+ .e-spinner-pane .e-spinner-inner {
9
+ top: 250px;
10
+ }