grep-components 1.26.0 → 1.26.2-GREPF-2195.1
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/dist/index.js +1308 -1599
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47,26 +47,19 @@ import Link$1 from '@mui/material/Link';
|
|
|
47
47
|
dayjs.extend(isBetweenPlugin);
|
|
48
48
|
dayjs.extend(LocalizedFormatPlugin);
|
|
49
49
|
dayjs.locale('nb');
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
class DateRangeValue {
|
|
51
|
+
constructor(from, to) {
|
|
52
52
|
this.from = from;
|
|
53
53
|
this.to = to;
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
enumerable: false,
|
|
60
|
-
configurable: true
|
|
61
|
-
});
|
|
62
|
-
DateRangeValue.prototype.isValid = function (allowNull, allowSame, unit) {
|
|
63
|
-
if (allowNull === void 0) { allowNull = true; }
|
|
64
|
-
if (allowSame === void 0) { allowSame = true; }
|
|
65
|
-
if (unit === void 0) { unit = 'day'; }
|
|
55
|
+
get valid() {
|
|
56
|
+
return this.isValid();
|
|
57
|
+
}
|
|
58
|
+
isValid(allowNull = true, allowSame = true, unit = 'day') {
|
|
66
59
|
if (!this.from && !this.to)
|
|
67
60
|
return allowNull;
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
const dateFrom = dayjs(this.from || undefined);
|
|
62
|
+
const dateTo = dayjs(this.to || undefined);
|
|
70
63
|
if (!this.from)
|
|
71
64
|
return allowNull && dateTo.isValid();
|
|
72
65
|
if (!this.to)
|
|
@@ -77,17 +70,13 @@ var DateRangeValue = /** @class */ (function () {
|
|
|
77
70
|
: dateTo.isAfter(dateFrom, unit);
|
|
78
71
|
}
|
|
79
72
|
return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
var from = _a.from, to = _a.to;
|
|
83
|
-
if (unit === void 0) { unit = 'day'; }
|
|
73
|
+
}
|
|
74
|
+
compare({ from, to }, unit = 'day') {
|
|
84
75
|
return (dayjs(this.from || '').isSame(dayjs(from || ''), unit) &&
|
|
85
76
|
dayjs(this.to || '').isSame(dayjs(to || ''), unit));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
var parseDate = function (datetime, _a) {
|
|
90
|
-
var _b = _a === void 0 ? { utc: true } : _a, format = _b.format, utc = _b.utc;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const parseDate = (datetime, { format, utc } = { utc: true }) => {
|
|
91
80
|
datetime =
|
|
92
81
|
typeof datetime === 'string'
|
|
93
82
|
? datetime
|
|
@@ -96,34 +85,28 @@ var parseDate = function (datetime, _a) {
|
|
|
96
85
|
.replace(/(^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3})(\d*)$/, '$1')
|
|
97
86
|
: datetime;
|
|
98
87
|
// dirty hack to not provide utc flag
|
|
99
|
-
|
|
88
|
+
const parsed = dayjs(datetime, { utc, format });
|
|
100
89
|
return parsed.isValid() ? dayjs(parsed.toISOString()) : parsed;
|
|
101
90
|
};
|
|
102
|
-
|
|
91
|
+
const hasDateChanged = (a, b) => {
|
|
103
92
|
if (a === null || b === null) {
|
|
104
93
|
return a !== b;
|
|
105
94
|
}
|
|
106
95
|
return dayjs(a).format('L') !== dayjs(b).format('L');
|
|
107
96
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
var isSameOrBefore = function (point, match, unit) {
|
|
112
|
-
if (unit === void 0) { unit = 'day'; }
|
|
113
|
-
var date = dayjs(point);
|
|
97
|
+
const isDateValid = (date, allowNull) => !date ? !!allowNull : dayjs(date).isValid();
|
|
98
|
+
const isSameOrBefore = (point, match, unit = 'day') => {
|
|
99
|
+
const date = dayjs(point);
|
|
114
100
|
return ((date.isValid() && date.isSame(match, unit)) || date.isBefore(match, unit));
|
|
115
101
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
var date = dayjs(point);
|
|
102
|
+
const isSameOrAfter = (point, match, unit = 'day') => {
|
|
103
|
+
const date = dayjs(point);
|
|
119
104
|
return ((date.isValid() && date.isSame(match, unit)) || date.isAfter(match, unit));
|
|
120
105
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
var getFullDate = function (datetime, options) { return parseDate(datetime, options).format('LLL'); };
|
|
126
|
-
var getExcelDateTime = function (datetime, options) { return parseDate(datetime, options).format('L HH:mm'); };
|
|
106
|
+
const getShortDate = (datetime, options) => parseDate(datetime, options).format('L');
|
|
107
|
+
const getTime = (datetime, options) => parseDate(datetime, options).format('[kl.] LT');
|
|
108
|
+
const getFullDate = (datetime, options) => parseDate(datetime, options).format('LLL');
|
|
109
|
+
const getExcelDateTime = (datetime, options) => parseDate(datetime, options).format('L HH:mm');
|
|
127
110
|
|
|
128
111
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
129
112
|
|
|
@@ -249,16 +232,16 @@ var Key_enum = {};
|
|
|
249
232
|
})(exports.Key || (exports.Key = {}));
|
|
250
233
|
} (Key_enum));
|
|
251
234
|
|
|
252
|
-
|
|
235
|
+
const onActivation = (cb) => (ev) => {
|
|
253
236
|
switch (ev.which) {
|
|
254
237
|
case Key_enum.Key.Space:
|
|
255
238
|
case Key_enum.Key.Enter:
|
|
256
239
|
cb(ev);
|
|
257
240
|
break;
|
|
258
241
|
}
|
|
259
|
-
};
|
|
242
|
+
};
|
|
260
243
|
var keyboard = {
|
|
261
|
-
onActivation
|
|
244
|
+
onActivation,
|
|
262
245
|
};
|
|
263
246
|
|
|
264
247
|
var index = /*#__PURE__*/Object.freeze({
|
|
@@ -277,7 +260,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
277
260
|
DateTime: dayjs
|
|
278
261
|
});
|
|
279
262
|
|
|
280
|
-
|
|
263
|
+
const Colors = {
|
|
281
264
|
red: red[500],
|
|
282
265
|
pink: pink[500],
|
|
283
266
|
purple: purple[500],
|
|
@@ -304,111 +287,30 @@ var Colors = {
|
|
|
304
287
|
white: '#fff',
|
|
305
288
|
};
|
|
306
289
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
314
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
315
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
316
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
317
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
318
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
319
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
320
|
-
***************************************************************************** */
|
|
321
|
-
/* global Reflect, Promise */
|
|
322
|
-
|
|
323
|
-
var extendStatics = function(d, b) {
|
|
324
|
-
extendStatics = Object.setPrototypeOf ||
|
|
325
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
326
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
327
|
-
return extendStatics(d, b);
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
function __extends(d, b) {
|
|
331
|
-
if (typeof b !== "function" && b !== null)
|
|
332
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
333
|
-
extendStatics(d, b);
|
|
334
|
-
function __() { this.constructor = d; }
|
|
335
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
var __assign = function() {
|
|
339
|
-
__assign = Object.assign || function __assign(t) {
|
|
340
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
341
|
-
s = arguments[i];
|
|
342
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
343
|
-
}
|
|
344
|
-
return t;
|
|
345
|
-
};
|
|
346
|
-
return __assign.apply(this, arguments);
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
function __rest$1(s, e) {
|
|
350
|
-
var t = {};
|
|
351
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
352
|
-
t[p] = s[p];
|
|
353
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
354
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
355
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
356
|
-
t[p[i]] = s[p[i]];
|
|
357
|
-
}
|
|
358
|
-
return t;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function __read(o, n) {
|
|
362
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
363
|
-
if (!m) return o;
|
|
364
|
-
var i = m.call(o), r, ar = [], e;
|
|
365
|
-
try {
|
|
366
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
367
|
-
}
|
|
368
|
-
catch (error) { e = { error: error }; }
|
|
369
|
-
finally {
|
|
370
|
-
try {
|
|
371
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
372
|
-
}
|
|
373
|
-
finally { if (e) throw e.error; }
|
|
374
|
-
}
|
|
375
|
-
return ar;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
function __spreadArray(to, from, pack) {
|
|
379
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
380
|
-
if (ar || !(i in from)) {
|
|
381
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
382
|
-
ar[i] = from[i];
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
var hexPattern = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
|
|
389
|
-
var hexPatternShorthand = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
390
|
-
var convertHex2rgb = function (hex) {
|
|
391
|
-
var match = hex
|
|
392
|
-
.replace(hexPatternShorthand, function (_m, r, g, b) { return r + r + g + g + b + b; })
|
|
290
|
+
const hexPattern = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
|
|
291
|
+
const hexPatternShorthand = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
292
|
+
const convertHex2rgb = (hex) => {
|
|
293
|
+
const match = hex
|
|
294
|
+
.replace(hexPatternShorthand, (_m, r, g, b) => r + r + g + g + b + b)
|
|
393
295
|
.match(hexPattern);
|
|
394
296
|
match && match.shift();
|
|
395
|
-
return match ? match.map(
|
|
297
|
+
return match ? match.map((i) => parseInt(i, 16)) : [];
|
|
396
298
|
};
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
return rgb &&
|
|
299
|
+
const hex2rgb = (hex) => {
|
|
300
|
+
const rgb = convertHex2rgb(hex);
|
|
301
|
+
return rgb && `rgb(${rgb.join(',')})`;
|
|
400
302
|
};
|
|
401
|
-
|
|
402
|
-
|
|
303
|
+
const hex2rgba = (hex, alpha) => {
|
|
304
|
+
const rgb = convertHex2rgb(hex);
|
|
403
305
|
rgb && rgb.push(alpha);
|
|
404
|
-
return rgb &&
|
|
306
|
+
return rgb && `rgba(${rgb.join(',')})`;
|
|
405
307
|
};
|
|
406
|
-
|
|
308
|
+
const convertToRgba = (color, alpha) => {
|
|
407
309
|
if (color.match(/^#/)) {
|
|
408
310
|
return hex2rgba(color, alpha);
|
|
409
311
|
}
|
|
410
|
-
|
|
411
|
-
return value ?
|
|
312
|
+
const [, value] = color.match(/[(](.*)[)]/) || [];
|
|
313
|
+
return value ? `rgba(${value}, ${alpha})` : color;
|
|
412
314
|
};
|
|
413
315
|
|
|
414
316
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -2959,33 +2861,29 @@ function createMakeAndWithStyles(params) {
|
|
|
2959
2861
|
return Object.assign(Object.assign({}, createMakeStyles(params)), createWithStyles(params));
|
|
2960
2862
|
}
|
|
2961
2863
|
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
useTheme: useTheme,
|
|
2864
|
+
const { makeStyles, withStyles } = createMakeAndWithStyles({
|
|
2865
|
+
useTheme,
|
|
2965
2866
|
/*
|
|
2966
2867
|
OR, if you have extended the default mui theme adding your own custom properties:
|
|
2967
2868
|
Let's assume the myTheme object that you provide to the <ThemeProvider /> is of
|
|
2968
2869
|
type MyTheme then you'll write:
|
|
2969
2870
|
*/
|
|
2970
2871
|
//"useTheme": useTheme as (()=> MyTheme)
|
|
2971
|
-
}), _a.makeStyles), withStyles = _a.withStyles;
|
|
2972
|
-
|
|
2973
|
-
var useStyles$i = makeStyles()(function (_a) {
|
|
2974
|
-
var palette = _a.palette;
|
|
2975
|
-
return ({
|
|
2976
|
-
user: {
|
|
2977
|
-
color: palette.text.primary,
|
|
2978
|
-
margin: '0 10px',
|
|
2979
|
-
marginLeft: 20,
|
|
2980
|
-
height: 'fit-content',
|
|
2981
|
-
textAlign: 'left',
|
|
2982
|
-
textTransform: 'none',
|
|
2983
|
-
},
|
|
2984
|
-
});
|
|
2985
2872
|
});
|
|
2986
2873
|
|
|
2987
|
-
|
|
2988
|
-
|
|
2874
|
+
const useStyles$i = makeStyles()(({ palette }) => ({
|
|
2875
|
+
user: {
|
|
2876
|
+
color: palette.text.primary,
|
|
2877
|
+
margin: '0 10px',
|
|
2878
|
+
marginLeft: 20,
|
|
2879
|
+
height: 'fit-content',
|
|
2880
|
+
textAlign: 'left',
|
|
2881
|
+
textTransform: 'none',
|
|
2882
|
+
},
|
|
2883
|
+
}));
|
|
2884
|
+
|
|
2885
|
+
const AppBarProfile = (props) => {
|
|
2886
|
+
const { classes } = useStyles$i();
|
|
2989
2887
|
return (React.createElement(Button, { variant: "text", onClick: props.onButtonClick },
|
|
2990
2888
|
React.createElement(AccountCircle, { color: "primary", fontSize: "large" }),
|
|
2991
2889
|
React.createElement(Box, { className: classes.user },
|
|
@@ -2994,87 +2892,76 @@ var AppBarProfile = function (props) {
|
|
|
2994
2892
|
React.createElement(ArrowDropdown, { color: "primary" })));
|
|
2995
2893
|
};
|
|
2996
2894
|
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
2895
|
+
const useStyles$h = makeStyles()((theme) => ({
|
|
2896
|
+
tabs: {
|
|
2897
|
+
margin: 'auto 0',
|
|
2898
|
+
[theme.breakpoints.down('xl')]: {
|
|
2899
|
+
display: 'none',
|
|
2900
|
+
},
|
|
2901
|
+
[theme.breakpoints.up('lg')]: {
|
|
2902
|
+
display: 'grid',
|
|
2903
|
+
},
|
|
2904
|
+
},
|
|
2905
|
+
tab: {
|
|
2906
|
+
textTransform: 'uppercase',
|
|
2907
|
+
color: theme.palette.primary.main,
|
|
2908
|
+
fontWeight: theme.typography.fontWeightBold,
|
|
2909
|
+
fontSize: theme.typography.subtitle1.fontSize,
|
|
2910
|
+
marginRight: theme.spacing(1),
|
|
2911
|
+
'&:focus': {
|
|
2912
|
+
opacity: 1,
|
|
2913
|
+
},
|
|
2914
|
+
[theme.breakpoints.down('lg')]: {
|
|
2915
|
+
minWidth: 120,
|
|
2916
|
+
marginRight: 0,
|
|
2917
|
+
},
|
|
2918
|
+
[theme.breakpoints.up('lg')]: {
|
|
2919
|
+
minWidth: 160,
|
|
2920
|
+
padding: '12px',
|
|
2921
|
+
},
|
|
2922
|
+
[theme.breakpoints.up('lg')]: {
|
|
2923
|
+
minWidth: 160,
|
|
2924
|
+
padding: '12px',
|
|
2925
|
+
},
|
|
2926
|
+
[theme.breakpoints.up('lg')]: {
|
|
2927
|
+
minWidth: 160,
|
|
2928
|
+
padding: '12px',
|
|
2929
|
+
},
|
|
2930
|
+
},
|
|
2931
|
+
indicator: {
|
|
2932
|
+
display: 'flex',
|
|
2933
|
+
justifyContent: 'center',
|
|
2934
|
+
backgroundColor: 'transparent',
|
|
2935
|
+
'& > div': {
|
|
2936
|
+
maxWidth: 40,
|
|
2937
|
+
width: '100%',
|
|
2938
|
+
backgroundColor: theme.palette.secondary.main,
|
|
2939
|
+
},
|
|
2940
|
+
},
|
|
2941
|
+
}));
|
|
2942
|
+
const useMobileStyles = makeStyles()(({ palette, breakpoints }) => ({
|
|
2943
|
+
mobileNavList: {
|
|
2944
|
+
backgroundColor: `transparent`,
|
|
2945
|
+
color: palette.primary.main,
|
|
2946
|
+
fontFamily: 'MontSerrat, Helvetica Neue, Helvetica, Arial, sans-serif',
|
|
2947
|
+
[breakpoints.down('lg')]: {
|
|
3038
2948
|
display: 'flex',
|
|
3039
|
-
justifyContent: 'center',
|
|
3040
|
-
backgroundColor: 'transparent',
|
|
3041
|
-
'& > div': {
|
|
3042
|
-
maxWidth: 40,
|
|
3043
|
-
width: '100%',
|
|
3044
|
-
backgroundColor: theme.palette.secondary.main,
|
|
3045
|
-
},
|
|
3046
2949
|
},
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
display: 'flex',
|
|
3060
|
-
},
|
|
3061
|
-
_b[breakpoints.up('lg')] = {
|
|
3062
|
-
display: 'none',
|
|
3063
|
-
},
|
|
3064
|
-
_b),
|
|
3065
|
-
});
|
|
3066
|
-
});
|
|
3067
|
-
|
|
3068
|
-
var MobileAppBarNavList = function (_a) {
|
|
3069
|
-
var pages = _a.pages;
|
|
3070
|
-
var classes = useMobileStyles().classes;
|
|
3071
|
-
var history = useHistory();
|
|
3072
|
-
var _b = __read(React.useState(null), 2), anchorElNav = _b[0], setAnchorElNav = _b[1];
|
|
3073
|
-
var openNav = Boolean(anchorElNav);
|
|
3074
|
-
var handleClickNav = function (event) {
|
|
2950
|
+
[breakpoints.up('lg')]: {
|
|
2951
|
+
display: 'none',
|
|
2952
|
+
},
|
|
2953
|
+
},
|
|
2954
|
+
}));
|
|
2955
|
+
|
|
2956
|
+
const MobileAppBarNavList = ({ pages, }) => {
|
|
2957
|
+
const { classes } = useMobileStyles();
|
|
2958
|
+
const history = useHistory();
|
|
2959
|
+
const [anchorElNav, setAnchorElNav] = React.useState(null);
|
|
2960
|
+
const openNav = Boolean(anchorElNav);
|
|
2961
|
+
const handleClickNav = (event) => {
|
|
3075
2962
|
setAnchorElNav(event.currentTarget);
|
|
3076
2963
|
};
|
|
3077
|
-
|
|
2964
|
+
const handleCloseNav = () => {
|
|
3078
2965
|
setAnchorElNav(null);
|
|
3079
2966
|
};
|
|
3080
2967
|
return (React.createElement(Box, { style: { flexGrow: 1 }, className: classes.mobileNavList },
|
|
@@ -3082,34 +2969,30 @@ var MobileAppBarNavList = function (_a) {
|
|
|
3082
2969
|
React.createElement(MenuIcon, { fontSize: "large" })),
|
|
3083
2970
|
React.createElement(Menu, { id: "basic-menu", anchorEl: anchorElNav, open: openNav, onClose: handleCloseNav, MenuListProps: {
|
|
3084
2971
|
'aria-labelledby': 'basic-button',
|
|
3085
|
-
} }, pages.map(
|
|
2972
|
+
} }, pages.map((page) => (React.createElement(MenuItem, { key: page.id, onClick: () => {
|
|
3086
2973
|
handleCloseNav();
|
|
3087
|
-
history.push(
|
|
3088
|
-
}, onKeyDown: keyboard.onActivation(
|
|
3089
|
-
return history.push((page === null || page === void 0 ? void 0 : page.toUrl) || '');
|
|
3090
|
-
}) }, page.label)); }))));
|
|
2974
|
+
history.push(page?.toUrl || '');
|
|
2975
|
+
}, onKeyDown: keyboard.onActivation(() => history.push(page?.toUrl || '')) }, page.label))))));
|
|
3091
2976
|
};
|
|
3092
2977
|
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
var handleChange = function (_event, newValue) {
|
|
2978
|
+
const AppBarNavList = ({ selectedPage, pages, onChange, }) => {
|
|
2979
|
+
const [value, setValue] = React.useState(selectedPage);
|
|
2980
|
+
const { classes } = useStyles$h();
|
|
2981
|
+
const handleChange = (_event, newValue) => {
|
|
3098
2982
|
setValue(newValue);
|
|
3099
2983
|
onChange(newValue);
|
|
3100
2984
|
};
|
|
3101
2985
|
return (React.createElement(React.Fragment, null,
|
|
3102
|
-
React.createElement(Tabs, { classes: { root: classes.tabs, indicator: classes.indicator }, value: value, onChange: handleChange, TabIndicatorProps: { children: React.createElement("div", null) } }, pages.map(
|
|
2986
|
+
React.createElement(Tabs, { classes: { root: classes.tabs, indicator: classes.indicator }, value: value, onChange: handleChange, TabIndicatorProps: { children: React.createElement("div", null) } }, pages.map((page) => (React.createElement(Tab, { disableTouchRipple: true, className: classes.tab, key: page.id, label: page.label })))),
|
|
3103
2987
|
React.createElement(MobileAppBarNavList, { pages: pages })));
|
|
3104
2988
|
};
|
|
3105
2989
|
|
|
3106
|
-
|
|
2990
|
+
const BodyLayout = (props) => (React.createElement(Box, { width: "100%", paddingTop: "20px", display: "flex", flexDirection: "row", marginBottom: "20px", justifyContent: "space-between" }, props.children));
|
|
3107
2991
|
|
|
3108
|
-
|
|
2992
|
+
const MainLayout = (props) => (React.createElement(Box, { display: "flex", flex: "1", flexDirection: "column" }, props.children));
|
|
3109
2993
|
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
var onKeyDown = function (e) {
|
|
2994
|
+
const CollapsableMenu = ({ children, onMenuClose, ...collapseProps }) => {
|
|
2995
|
+
const onKeyDown = (e) => {
|
|
3113
2996
|
switch (e.keyCode) {
|
|
3114
2997
|
case Key_enum.Key.Escape:
|
|
3115
2998
|
onMenuClose && onMenuClose();
|
|
@@ -3119,37 +3002,33 @@ var CollapsableMenu = function (_a) {
|
|
|
3119
3002
|
}
|
|
3120
3003
|
e.stopPropagation();
|
|
3121
3004
|
};
|
|
3122
|
-
return (React__default.createElement(Collapse,
|
|
3005
|
+
return (React__default.createElement(Collapse, { timeout: "auto", unmountOnExit: true, mountOnEnter: true, ...collapseProps },
|
|
3123
3006
|
React__default.createElement(MenuList, { disablePadding: true, autoFocusItem: true, onKeyDown: onKeyDown }, children)));
|
|
3124
3007
|
};
|
|
3125
3008
|
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
}),
|
|
3136
|
-
'&.Mui-focusVisible': {
|
|
3137
|
-
backgroundColor: convertToRgba(palette.primary.light, 0.15),
|
|
3138
|
-
},
|
|
3139
|
-
},
|
|
3140
|
-
subMenu: {
|
|
3141
|
-
margin: '0 -1rem',
|
|
3142
|
-
},
|
|
3143
|
-
expander: {
|
|
3144
|
-
marginLeft: '2rem',
|
|
3145
|
-
transform: "rotate(".concat(open ? 180 : 0, "deg)"),
|
|
3146
|
-
transition: transitions.create(['transform, color, background-color'], {
|
|
3147
|
-
duration: transitions.duration.short,
|
|
3148
|
-
easing: transitions.easing.easeOut,
|
|
3149
|
-
}),
|
|
3009
|
+
const useStyles$g = makeStyles()(({ palette, transitions }, { open }) => ({
|
|
3010
|
+
root: {
|
|
3011
|
+
padding: '0 1rem',
|
|
3012
|
+
transition: transitions.create(['background-color'], {
|
|
3013
|
+
duration: transitions.duration.short,
|
|
3014
|
+
easing: transitions.easing.easeIn,
|
|
3015
|
+
}),
|
|
3016
|
+
'&.Mui-focusVisible': {
|
|
3017
|
+
backgroundColor: convertToRgba(palette.primary.light, 0.15),
|
|
3150
3018
|
},
|
|
3151
|
-
}
|
|
3152
|
-
|
|
3019
|
+
},
|
|
3020
|
+
subMenu: {
|
|
3021
|
+
margin: '0 -1rem',
|
|
3022
|
+
},
|
|
3023
|
+
expander: {
|
|
3024
|
+
marginLeft: '2rem',
|
|
3025
|
+
transform: `rotate(${open ? 180 : 0}deg)`,
|
|
3026
|
+
transition: transitions.create(['transform, color, background-color'], {
|
|
3027
|
+
duration: transitions.duration.short,
|
|
3028
|
+
easing: transitions.easing.easeOut,
|
|
3029
|
+
}),
|
|
3030
|
+
},
|
|
3031
|
+
}));
|
|
3153
3032
|
|
|
3154
3033
|
/**
|
|
3155
3034
|
* TypeError: Failed to construct 'CustomEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
|
|
@@ -3157,42 +3036,36 @@ var useStyles$g = makeStyles()(function (_a, _b) {
|
|
|
3157
3036
|
*
|
|
3158
3037
|
* export class CollapsableMenuStatusEvent extends CustomEvent<React.Ref<any>> {}
|
|
3159
3038
|
*/
|
|
3160
|
-
|
|
3161
|
-
|
|
3039
|
+
class CollapsableMenuStatusEvent {
|
|
3040
|
+
constructor(type, currentTarget) {
|
|
3162
3041
|
this.type = type;
|
|
3163
3042
|
this.currentTarget = currentTarget;
|
|
3164
3043
|
}
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
enumerable: false,
|
|
3170
|
-
configurable: true
|
|
3171
|
-
});
|
|
3172
|
-
CollapsableMenuStatusEvent.prototype.preventDefault = function () {
|
|
3044
|
+
get defaultPrevented() {
|
|
3045
|
+
return !!this._defaultPrevented;
|
|
3046
|
+
}
|
|
3047
|
+
preventDefault() {
|
|
3173
3048
|
this._defaultPrevented = true;
|
|
3174
|
-
}
|
|
3175
|
-
|
|
3176
|
-
}
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
var expand = useCallback$1(function () {
|
|
3183
|
-
var event = onStatusChange('expand');
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
const CollapsableMenuItem = ({ items, onClick, children, onClose: _onclose, tooltipText, disabled, ...props }) => {
|
|
3052
|
+
const listItemRef = useRef(null);
|
|
3053
|
+
const [open, setOpen] = useState(false);
|
|
3054
|
+
const onStatusChange = useCallback$1((type) => new CollapsableMenuStatusEvent(type, listItemRef), [listItemRef]);
|
|
3055
|
+
const expand = useCallback$1(() => {
|
|
3056
|
+
const event = onStatusChange('expand');
|
|
3184
3057
|
!event.defaultPrevented && setOpen(true);
|
|
3185
3058
|
return !event.defaultPrevented;
|
|
3186
3059
|
}, [onStatusChange, setOpen]);
|
|
3187
|
-
|
|
3188
|
-
|
|
3060
|
+
const collapse = useCallback$1(() => {
|
|
3061
|
+
const event = onStatusChange('collapse');
|
|
3189
3062
|
if (!event.defaultPrevented) {
|
|
3190
3063
|
setOpen(false);
|
|
3191
|
-
requestAnimationFrame(
|
|
3064
|
+
requestAnimationFrame(() => listItemRef.current?.focus());
|
|
3192
3065
|
}
|
|
3193
3066
|
return !event.defaultPrevented;
|
|
3194
3067
|
}, [onStatusChange, setOpen, listItemRef]);
|
|
3195
|
-
|
|
3068
|
+
const handleKey = (e) => {
|
|
3196
3069
|
if (items) {
|
|
3197
3070
|
switch (e.keyCode) {
|
|
3198
3071
|
case Key_enum.Key.RightArrow:
|
|
@@ -3204,206 +3077,181 @@ var CollapsableMenuItem = function (_a) {
|
|
|
3204
3077
|
}
|
|
3205
3078
|
}
|
|
3206
3079
|
};
|
|
3207
|
-
|
|
3080
|
+
const onToggleClick = useCallback$1((e) => {
|
|
3208
3081
|
e.preventDefault();
|
|
3209
3082
|
e.stopPropagation();
|
|
3210
3083
|
open ? collapse() : expand();
|
|
3211
3084
|
}, [open, collapse, expand]);
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
var scrimClick = !((_a = listItemRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target));
|
|
3085
|
+
const onScrimClick = useCallback$1((e) => {
|
|
3086
|
+
const scrimClick = !listItemRef.current?.contains(e.target);
|
|
3215
3087
|
scrimClick && collapse();
|
|
3216
3088
|
}, [listItemRef, collapse]);
|
|
3217
|
-
|
|
3218
|
-
useEffect(
|
|
3089
|
+
const handleClick = items ? onToggleClick : onClick;
|
|
3090
|
+
useEffect(() => {
|
|
3219
3091
|
document.addEventListener('click', onScrimClick, { capture: true });
|
|
3220
|
-
return
|
|
3092
|
+
return () => document.removeEventListener('click', onScrimClick);
|
|
3221
3093
|
}, [listItemRef, onScrimClick]);
|
|
3222
|
-
|
|
3223
|
-
|
|
3094
|
+
const { classes } = useStyles$g({ open });
|
|
3095
|
+
const renderInner = () => (React__default.createElement(Box, { display: "flex", flexDirection: "column", width: "100%" },
|
|
3224
3096
|
React__default.createElement(Box, { display: "flex", justifyContent: "space-between", alignItems: "center", minHeight: 48 },
|
|
3225
3097
|
children,
|
|
3226
3098
|
items && React__default.createElement(IconExpand, { className: classes.expander })),
|
|
3227
|
-
items && (React__default.createElement(CollapsableMenu, { className: classes.subMenu, in: open, onMenuClose: collapse, onEntered:
|
|
3228
|
-
return requestAnimationFrame(function () {
|
|
3229
|
-
return window.dispatchEvent(new Event('resize'));
|
|
3230
|
-
});
|
|
3231
|
-
} }, items)))); };
|
|
3099
|
+
items && (React__default.createElement(CollapsableMenu, { className: classes.subMenu, in: open, onMenuClose: collapse, onEntered: () => requestAnimationFrame(() => window.dispatchEvent(new Event('resize'))) }, items))));
|
|
3232
3100
|
return tooltipText ? (React__default.createElement(Tooltip, { title: tooltipText },
|
|
3233
3101
|
React__default.createElement(MenuItem, { role: "menuitem", sx: disabled && !items
|
|
3234
3102
|
? { cursor: 'not-allowed', pointerEvents: 'inherit !important' }
|
|
3235
|
-
: { pointerEvents: 'inherit !important' }, className: classes.root, onMouseOver:
|
|
3103
|
+
: { pointerEvents: 'inherit !important' }, className: classes.root, onMouseOver: (e) => e.currentTarget.focus(), selected: open, ref: listItemRef, onClick: handleClick, onKeyDown: handleKey }, renderInner()))) : (React__default.createElement(MenuItem, { sx: disabled && !items ? { cursor: 'not-allowed' } : {}, className: classes.root, ref: listItemRef, selected: open, onClick: handleClick, onKeyDown: handleKey, ...props }, renderInner()));
|
|
3236
3104
|
};
|
|
3237
3105
|
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
});
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
props.classes = { selected: classes.selected };
|
|
3260
|
-
// ninja way, since rewriting existing code on lpu and admin is daunting
|
|
3261
|
-
props.onClick = function (e) {
|
|
3262
|
-
if (itemOrParentDisabled) {
|
|
3263
|
-
e.preventDefault();
|
|
3264
|
-
e.stopPropagation();
|
|
3265
|
-
return;
|
|
3266
|
-
}
|
|
3267
|
-
menuProps.onClose && menuProps.onClose(e, 'backdropClick');
|
|
3268
|
-
!itemOrParentDisabled && handleClick && handleClick(context);
|
|
3106
|
+
const useStyles$f = makeStyles()(({ palette }) => ({
|
|
3107
|
+
selected: {
|
|
3108
|
+
color: `${palette.common.black} !important`,
|
|
3109
|
+
backgroundColor: 'rgba(0,0,0,.05) !important',
|
|
3110
|
+
},
|
|
3111
|
+
}));
|
|
3112
|
+
|
|
3113
|
+
const DropdownMenu = ({ context, menuItems, ...menuProps }) => {
|
|
3114
|
+
const { classes } = useStyles$f();
|
|
3115
|
+
const renderChild = (level = 0, parentDisabled) =>
|
|
3116
|
+
// eslint-disable-next-line react/display-name
|
|
3117
|
+
(item, index) => {
|
|
3118
|
+
const { label, children, handleClick, disabled, ...props } = item;
|
|
3119
|
+
const itemOrParentDisabled = (parentDisabled || disabled) ?? false;
|
|
3120
|
+
const isDisabled = typeof itemOrParentDisabled === 'function'
|
|
3121
|
+
? itemOrParentDisabled(context)
|
|
3122
|
+
: itemOrParentDisabled;
|
|
3123
|
+
const style = isDisabled
|
|
3124
|
+
? { paddingLeft: `${level * 0.5}rem`, opacity: 0.4 }
|
|
3125
|
+
: {
|
|
3126
|
+
paddingLeft: `${level * 0.5}rem`,
|
|
3269
3127
|
};
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
React__default.createElement("span", { style: style }, label)));
|
|
3128
|
+
props.key = `child-item-${index}`;
|
|
3129
|
+
props.classes = { selected: classes.selected };
|
|
3130
|
+
// ninja way, since rewriting existing code on lpu and admin is daunting
|
|
3131
|
+
props.onClick = (e) => {
|
|
3132
|
+
if (isDisabled) {
|
|
3133
|
+
e.preventDefault();
|
|
3134
|
+
e.stopPropagation();
|
|
3135
|
+
return;
|
|
3136
|
+
}
|
|
3137
|
+
menuProps.onClose && menuProps.onClose(e, 'backdropClick');
|
|
3138
|
+
!isDisabled && handleClick && handleClick(context);
|
|
3282
3139
|
};
|
|
3140
|
+
return (React__default.createElement(CollapsableMenuItem, { sx: isDisabled && !children ? { cursor: 'not-allowed' } : {}, level: level, id: label, disabled: isDisabled, items: children?.map(renderChild(level + 1, isDisabled)), ...props },
|
|
3141
|
+
React__default.createElement("span", { style: style }, label)));
|
|
3283
3142
|
};
|
|
3284
|
-
return (React__default.createElement(Menu,
|
|
3143
|
+
return (React__default.createElement(Menu, { ...menuProps, anchorOrigin: menuProps?.anchorOrigin || {
|
|
3285
3144
|
vertical: 'bottom',
|
|
3286
3145
|
horizontal: 'center',
|
|
3287
3146
|
}, transformOrigin: menuProps.transformOrigin || {
|
|
3288
3147
|
vertical: 'top',
|
|
3289
3148
|
horizontal: 'center',
|
|
3290
|
-
} }
|
|
3149
|
+
} }, menuItems.map(renderChild())));
|
|
3291
3150
|
};
|
|
3292
3151
|
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
':focus': {
|
|
3319
|
-
outlineColor: 'white',
|
|
3320
|
-
outlineOffset: '8px',
|
|
3321
|
-
},
|
|
3322
|
-
}
|
|
3323
|
-
},
|
|
3324
|
-
_b[theme.breakpoints.down('md')] = {
|
|
3325
|
-
flexDirection: 'column',
|
|
3326
|
-
padding: '0',
|
|
3327
|
-
a: {
|
|
3328
|
-
width: '150px',
|
|
3329
|
-
margin: '40px auto 40px auto',
|
|
3330
|
-
},
|
|
3331
|
-
},
|
|
3332
|
-
_b[theme.breakpoints.up('md')] = {
|
|
3333
|
-
flexDirection: 'row',
|
|
3334
|
-
padding: '0 12px 0 12px',
|
|
3335
|
-
a: {
|
|
3336
|
-
marginLeft: '28px',
|
|
3337
|
-
},
|
|
3338
|
-
},
|
|
3339
|
-
_b),
|
|
3340
|
-
serviceNameText: (_c = {
|
|
3341
|
-
color: Colors.white,
|
|
3342
|
-
textAlign: 'center',
|
|
3343
|
-
display: 'block'
|
|
3344
|
-
},
|
|
3345
|
-
_c[theme.breakpoints.down('md')] = {
|
|
3346
|
-
marginBottom: '30px',
|
|
3347
|
-
},
|
|
3348
|
-
_c),
|
|
3349
|
-
list: (_d = {
|
|
3350
|
-
display: 'flex',
|
|
3351
|
-
flexDirection: 'row',
|
|
3352
|
-
justifyContent: 'center'
|
|
3353
|
-
},
|
|
3354
|
-
_d[theme.breakpoints.down('md')] = {
|
|
3355
|
-
marginBottom: '40px',
|
|
3356
|
-
flexWrap: 'wrap',
|
|
3357
|
-
height: '64px',
|
|
3358
|
-
},
|
|
3359
|
-
_d),
|
|
3360
|
-
item: (_e = {
|
|
3361
|
-
color: Colors.white,
|
|
3362
|
-
width: 'fit-content',
|
|
3363
|
-
margin: '0',
|
|
3364
|
-
height: '10px',
|
|
3365
|
-
gap: '10px',
|
|
3366
|
-
borderRight: "1px solid #7dbf9d"
|
|
3367
|
-
},
|
|
3368
|
-
_e[theme.breakpoints.down('md')] = {
|
|
3369
|
-
textAlign: 'center',
|
|
3370
|
-
width: 'filter-content',
|
|
3371
|
-
},
|
|
3372
|
-
_e['&:last-child'] = {
|
|
3373
|
-
border: '0 !important',
|
|
3152
|
+
const useFooterStyles = makeStyles()((theme) => ({
|
|
3153
|
+
footer: {
|
|
3154
|
+
bottom: 0,
|
|
3155
|
+
width: '100%',
|
|
3156
|
+
marginTop: 'auto',
|
|
3157
|
+
display: 'flex',
|
|
3158
|
+
alignItems: 'center',
|
|
3159
|
+
backgroundColor: theme.palette.primary.main,
|
|
3160
|
+
[theme.breakpoints.down('md')]: {
|
|
3161
|
+
minHeight: 'unset',
|
|
3162
|
+
},
|
|
3163
|
+
[theme.breakpoints.up('md')]: {
|
|
3164
|
+
minHeight: '100px',
|
|
3165
|
+
},
|
|
3166
|
+
fontFamily: 'Montserrat',
|
|
3167
|
+
fontWeight: 600,
|
|
3168
|
+
fontSize: '14px',
|
|
3169
|
+
},
|
|
3170
|
+
content: {
|
|
3171
|
+
display: 'flex',
|
|
3172
|
+
width: '100%',
|
|
3173
|
+
a: {
|
|
3174
|
+
':focus': {
|
|
3175
|
+
outlineColor: 'white',
|
|
3176
|
+
outlineOffset: '8px',
|
|
3374
3177
|
},
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3178
|
+
},
|
|
3179
|
+
[theme.breakpoints.down('md')]: {
|
|
3180
|
+
flexDirection: 'column',
|
|
3181
|
+
padding: '0',
|
|
3182
|
+
a: {
|
|
3183
|
+
width: '150px',
|
|
3184
|
+
margin: '40px auto 40px auto',
|
|
3379
3185
|
},
|
|
3380
|
-
_e),
|
|
3381
|
-
itemText: {
|
|
3382
|
-
padding: 0,
|
|
3383
|
-
margin: '0 auto',
|
|
3384
|
-
fontFamily: 'Montserrat',
|
|
3385
|
-
fontWeight: 400,
|
|
3386
|
-
fontSize: '14px',
|
|
3387
|
-
color: Colors.white,
|
|
3388
3186
|
},
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3187
|
+
[theme.breakpoints.up('md')]: {
|
|
3188
|
+
flexDirection: 'row',
|
|
3189
|
+
padding: '0 12px 0 12px',
|
|
3190
|
+
a: {
|
|
3191
|
+
marginLeft: '28px',
|
|
3394
3192
|
},
|
|
3395
3193
|
},
|
|
3396
|
-
}
|
|
3397
|
-
|
|
3194
|
+
},
|
|
3195
|
+
serviceNameText: {
|
|
3196
|
+
color: Colors.white,
|
|
3197
|
+
textAlign: 'center',
|
|
3198
|
+
display: 'block',
|
|
3199
|
+
[theme.breakpoints.down('md')]: {
|
|
3200
|
+
marginBottom: '30px',
|
|
3201
|
+
},
|
|
3202
|
+
},
|
|
3203
|
+
list: {
|
|
3204
|
+
display: 'flex',
|
|
3205
|
+
flexDirection: 'row',
|
|
3206
|
+
justifyContent: 'center',
|
|
3207
|
+
[theme.breakpoints.down('md')]: {
|
|
3208
|
+
marginBottom: '40px',
|
|
3209
|
+
flexWrap: 'wrap',
|
|
3210
|
+
height: '64px',
|
|
3211
|
+
},
|
|
3212
|
+
},
|
|
3213
|
+
item: {
|
|
3214
|
+
color: Colors.white,
|
|
3215
|
+
width: 'fit-content',
|
|
3216
|
+
margin: '0',
|
|
3217
|
+
height: '10px',
|
|
3218
|
+
gap: '10px',
|
|
3219
|
+
borderRight: `1px solid #7dbf9d`,
|
|
3220
|
+
[theme.breakpoints.down('md')]: {
|
|
3221
|
+
textAlign: 'center',
|
|
3222
|
+
width: 'filter-content',
|
|
3223
|
+
},
|
|
3224
|
+
'&:last-child': {
|
|
3225
|
+
border: '0 !important',
|
|
3226
|
+
},
|
|
3227
|
+
':focus': {
|
|
3228
|
+
background: 'inherit',
|
|
3229
|
+
boxShadow: '0px 0px 0px 1px white',
|
|
3230
|
+
borderRadius: '2px',
|
|
3231
|
+
},
|
|
3232
|
+
},
|
|
3233
|
+
itemText: {
|
|
3234
|
+
padding: 0,
|
|
3235
|
+
margin: '0 auto',
|
|
3236
|
+
fontFamily: 'Montserrat',
|
|
3237
|
+
fontWeight: 400,
|
|
3238
|
+
fontSize: '14px',
|
|
3239
|
+
color: Colors.white,
|
|
3240
|
+
},
|
|
3241
|
+
itemBtn: {
|
|
3242
|
+
textDecoration: 'underline',
|
|
3243
|
+
textTransform: 'none',
|
|
3244
|
+
'&:hover': {
|
|
3245
|
+
backgroundColor: 'unset',
|
|
3246
|
+
},
|
|
3247
|
+
},
|
|
3248
|
+
}));
|
|
3398
3249
|
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
style: { fontSize: 14, fontFamily: 'Montserrat', fontWeight: 400 },
|
|
3405
|
-
} }));
|
|
3406
|
-
};
|
|
3250
|
+
const Footer = ({ items, serviceNameText, udirLink, udirLogo, }) => {
|
|
3251
|
+
const { classes } = useFooterStyles();
|
|
3252
|
+
const renderItem = (item) => item.onClickItem ? (React__default.createElement(Button, { className: classes.itemBtn.concat(' ' + classes.itemText), onClick: item.onClickItem }, item.label)) : (React__default.createElement(ListItemText, { className: classes.itemText, primary: item.label, primaryTypographyProps: {
|
|
3253
|
+
style: { fontSize: 14, fontFamily: 'Montserrat', fontWeight: 400 },
|
|
3254
|
+
} }));
|
|
3407
3255
|
return (React__default.createElement(Box, { className: classes.footer, role: "contentinfo" },
|
|
3408
3256
|
React__default.createElement(Box, { className: classes.content },
|
|
3409
3257
|
React__default.createElement("a", { href: udirLink },
|
|
@@ -3414,29 +3262,29 @@ var Footer = function (_a) {
|
|
|
3414
3262
|
paddingRight: '16px !important',
|
|
3415
3263
|
} },
|
|
3416
3264
|
React__default.createElement("span", { className: classes.serviceNameText }, serviceNameText),
|
|
3417
|
-
React__default.createElement(List, { className: classes.list }, items.map(
|
|
3265
|
+
React__default.createElement(List, { className: classes.list }, items.map((item, i) => (React__default.createElement(ListItem, { key: i, classes: {
|
|
3418
3266
|
root: classes.item,
|
|
3419
3267
|
//button: onClickItem ? classes.itemBtn : undefined,
|
|
3420
3268
|
} }, item.render
|
|
3421
|
-
? item.render(
|
|
3422
|
-
: renderItem(item)))
|
|
3269
|
+
? item.render(() => renderItem(item))
|
|
3270
|
+
: renderItem(item)))))))));
|
|
3423
3271
|
};
|
|
3424
3272
|
|
|
3425
|
-
|
|
3273
|
+
const LinkList = (props) => (React.createElement(Box, { width: "100%", flexDirection: "column" },
|
|
3426
3274
|
React.createElement(Typography, { style: { fontSize: 24, color: Colors.black, marginBottom: 20 } }, props.title),
|
|
3427
|
-
React.createElement(List, null, props.pages.map(
|
|
3428
|
-
React.createElement(ListItem, { button: true, onClick:
|
|
3275
|
+
React.createElement(List, null, props.pages.map((page) => (React.createElement(Box, { key: page.id },
|
|
3276
|
+
React.createElement(ListItem, { button: true, onClick: () => props.onPageClick(page), style: { padding: '12px 4px' } },
|
|
3429
3277
|
React.createElement(ListItemText, { primary: page.label, primaryTypographyProps: {
|
|
3430
3278
|
color: 'primary',
|
|
3431
3279
|
style: { fontSize: 18 },
|
|
3432
3280
|
} }),
|
|
3433
3281
|
React.createElement(ListItemIcon, { style: { justifyContent: 'flex-end' } },
|
|
3434
3282
|
React.createElement(ArrowForward, { color: "primary" }))),
|
|
3435
|
-
React.createElement(Divider, null)))
|
|
3283
|
+
React.createElement(Divider, null)))))));
|
|
3436
3284
|
|
|
3437
|
-
|
|
3285
|
+
const useStyles$e = makeStyles()({
|
|
3438
3286
|
container: {
|
|
3439
|
-
border:
|
|
3287
|
+
border: `1px solid ${Colors.lightGrey}`,
|
|
3440
3288
|
height: 'fit-content',
|
|
3441
3289
|
width: 'fit-content',
|
|
3442
3290
|
},
|
|
@@ -3448,32 +3296,30 @@ var useStyles$e = makeStyles()({
|
|
|
3448
3296
|
},
|
|
3449
3297
|
});
|
|
3450
3298
|
|
|
3451
|
-
|
|
3452
|
-
|
|
3299
|
+
const ContainedLinkList = (props) => {
|
|
3300
|
+
const { classes } = useStyles$e();
|
|
3453
3301
|
return (React.createElement(Box, { className: classes.container, style: props.style },
|
|
3454
3302
|
React.createElement(Typography, { className: classes.title }, props.title),
|
|
3455
|
-
React.createElement(List, { style: { padding: 0 } }, props.pages.map(
|
|
3456
|
-
React.createElement(ListItemButton, { onClick:
|
|
3303
|
+
React.createElement(List, { style: { padding: 0 } }, props.pages.map((page) => (React.createElement(ListItem, { divider: true, key: page.id, disablePadding: true },
|
|
3304
|
+
React.createElement(ListItemButton, { onClick: () => props.onPageClick(page) },
|
|
3457
3305
|
page.linkIcon && React.createElement(ListItemIcon$1, null, page.linkIcon),
|
|
3458
|
-
React.createElement(ListItemText, { primary: page.label }))))
|
|
3306
|
+
React.createElement(ListItemText, { primary: page.label }))))))));
|
|
3459
3307
|
};
|
|
3460
3308
|
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
_this.state = { overflow: false };
|
|
3467
|
-
return _this;
|
|
3309
|
+
class OverflowTooltip extends React.Component {
|
|
3310
|
+
constructor(props) {
|
|
3311
|
+
super(props);
|
|
3312
|
+
this.nodeRef = React.createRef();
|
|
3313
|
+
this.state = { overflow: false };
|
|
3468
3314
|
}
|
|
3469
|
-
|
|
3470
|
-
|
|
3315
|
+
componentDidMount() {
|
|
3316
|
+
const element = this.nodeRef.current;
|
|
3471
3317
|
if (element) {
|
|
3472
|
-
|
|
3473
|
-
this.setState({ overflow
|
|
3318
|
+
const overflow = element.clientWidth < element.scrollWidth;
|
|
3319
|
+
this.setState({ overflow });
|
|
3474
3320
|
}
|
|
3475
|
-
}
|
|
3476
|
-
|
|
3321
|
+
}
|
|
3322
|
+
render() {
|
|
3477
3323
|
if (this.state.overflow || this.props.force) {
|
|
3478
3324
|
return (React.createElement(Tooltip, { placement: "left", title: this.props.title || '' },
|
|
3479
3325
|
React.createElement("div", { style: { display: 'unset' }, ref: this.nodeRef }, this.props.children)));
|
|
@@ -3481,56 +3327,50 @@ var OverflowTooltip = /** @class */ (function (_super) {
|
|
|
3481
3327
|
else {
|
|
3482
3328
|
return React.createElement("div", { ref: this.nodeRef }, this.props.children);
|
|
3483
3329
|
}
|
|
3484
|
-
}
|
|
3485
|
-
|
|
3486
|
-
}(React.Component));
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3487
3332
|
|
|
3488
|
-
|
|
3333
|
+
const CellValue = styled('span')({
|
|
3489
3334
|
overflow: 'hidden',
|
|
3490
3335
|
textOverflow: 'ellipsis',
|
|
3491
3336
|
display: '-webkit-box',
|
|
3492
3337
|
WebkitBoxOrient: 'vertical',
|
|
3493
3338
|
});
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
var value = (React__default.createElement(CellValue, { style: { WebkitLineClamp: lines(row) }, lang: typeof lang === 'string' ? lang : lang ? lang(row) : '' }, getCell(row)));
|
|
3339
|
+
const GrepTableRow$1 = ({ row, column, expanded, ...props }) => {
|
|
3340
|
+
const { forceTooltip, getTooltip, getCell, lang, lines = () => (expanded ? undefined : 1), } = column;
|
|
3341
|
+
const { padding } = column;
|
|
3342
|
+
const value = (React__default.createElement(CellValue, { style: { WebkitLineClamp: lines(row) }, lang: typeof lang === 'string' ? lang : lang ? lang(row) : '' }, getCell(row)));
|
|
3499
3343
|
if (forceTooltip || getTooltip) {
|
|
3500
|
-
return (React__default.createElement(TableCell,
|
|
3344
|
+
return (React__default.createElement(TableCell, { padding: padding, ...props },
|
|
3501
3345
|
React__default.createElement(OverflowTooltip, { force: forceTooltip, title: getTooltip ? getTooltip(row) : value }, value)));
|
|
3502
3346
|
}
|
|
3503
|
-
return (React__default.createElement(TableCell,
|
|
3347
|
+
return (React__default.createElement(TableCell, { padding: padding, ...props }, value));
|
|
3504
3348
|
};
|
|
3505
3349
|
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
return (React__default.createElement(TableRow, __assign({ sx: {
|
|
3350
|
+
const GrepTableRow = ({ row, columns, selected, expanded, variant, clickable: _clickable, height: _height, underlineOnFocus, ...props }) => {
|
|
3351
|
+
const render = (column, index) => (React__default.createElement(GrepTableRow$1, { key: index, expanded: expanded, ...{ column, row, variant, selected } }));
|
|
3352
|
+
return (React__default.createElement(TableRow, { sx: {
|
|
3510
3353
|
':focus': { textDecoration: underlineOnFocus ? 'underline' : 'none' },
|
|
3511
|
-
}, tabIndex: props.tabIndex
|
|
3354
|
+
}, tabIndex: props.tabIndex, ...{ selected, ...props } }, columns.map(render)));
|
|
3512
3355
|
};
|
|
3513
3356
|
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
});
|
|
3532
|
-
});
|
|
3533
|
-
var usePaginationStyles = makeStyles()({
|
|
3357
|
+
const usePaginationActionStyles = makeStyles()(({ palette }) => ({
|
|
3358
|
+
button: {
|
|
3359
|
+
minWidth: '18px',
|
|
3360
|
+
minHeight: '20px',
|
|
3361
|
+
padding: '0 6px',
|
|
3362
|
+
margin: '0 8px',
|
|
3363
|
+
borderRadius: '2px',
|
|
3364
|
+
fontSize: 12,
|
|
3365
|
+
backgroundColor: palette.primary.main,
|
|
3366
|
+
},
|
|
3367
|
+
textButton: {
|
|
3368
|
+
textTransform: 'capitalize',
|
|
3369
|
+
fontWeight: 'initial',
|
|
3370
|
+
fontSize: 12,
|
|
3371
|
+
},
|
|
3372
|
+
}));
|
|
3373
|
+
const usePaginationStyles = makeStyles()({
|
|
3534
3374
|
toolbar: {
|
|
3535
3375
|
padding: 0,
|
|
3536
3376
|
width: '100%',
|
|
@@ -3549,42 +3389,39 @@ var usePaginationStyles = makeStyles()({
|
|
|
3549
3389
|
display: 'none',
|
|
3550
3390
|
},
|
|
3551
3391
|
});
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
var width = column.width
|
|
3392
|
+
const useTableHeaderStyles = makeStyles()((_theme, { column }) => {
|
|
3393
|
+
const width = column.width
|
|
3555
3394
|
? typeof column.width === 'number'
|
|
3556
|
-
?
|
|
3395
|
+
? `${column.width}%`
|
|
3557
3396
|
: column.width
|
|
3558
3397
|
: undefined;
|
|
3559
3398
|
return {
|
|
3560
3399
|
th: {
|
|
3561
|
-
width
|
|
3400
|
+
width,
|
|
3562
3401
|
fontSize: 14,
|
|
3563
3402
|
},
|
|
3564
3403
|
};
|
|
3565
3404
|
});
|
|
3566
3405
|
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
var sortable = !!(onSortBy && column.sortable);
|
|
3406
|
+
const TableHeaderCell = ({ column, onSortBy, direction, active, children, empty = false, ...props }) => {
|
|
3407
|
+
const { classes } = useTableHeaderStyles({ column });
|
|
3408
|
+
const sortable = !!(onSortBy && column.sortable);
|
|
3571
3409
|
if (sortable && !empty) {
|
|
3572
|
-
return (React__default.createElement(TableCell,
|
|
3410
|
+
return (React__default.createElement(TableCell, { variant: empty ? 'body' : 'head', className: classes.th, ...props },
|
|
3573
3411
|
React__default.createElement(TableSortLabel, { active: active, direction: direction }, children)));
|
|
3574
3412
|
}
|
|
3575
|
-
return empty ? (React__default.createElement("td", { className: classes.th }, children)) : (React__default.createElement(TableCell,
|
|
3413
|
+
return empty ? (React__default.createElement("td", { className: classes.th }, children)) : (React__default.createElement(TableCell, { variant: empty ? 'body' : 'head', className: classes.th, ...props }, children));
|
|
3576
3414
|
};
|
|
3577
3415
|
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
? columns.concat([{ label: '', width: '48px', getCell: function () { return ''; } }])
|
|
3416
|
+
const TableHeader = ({ columns, sortBy, sortDirection, onSortBy, dropdownItems, ...props }) => {
|
|
3417
|
+
const headerColumns = dropdownItems
|
|
3418
|
+
? columns.concat([{ label: '', width: '48px', getCell: () => '' }])
|
|
3582
3419
|
: columns;
|
|
3583
|
-
return (React__default.createElement(TableHead,
|
|
3584
|
-
React__default.createElement(TableRow, null, headerColumns.map(
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
return (React__default.createElement(TableHeaderCell, { key: index, empty: !label, column: column, direction: sortDirection, active: sortable ? sortBy === colDef : undefined, onClick:
|
|
3420
|
+
return (React__default.createElement(TableHead, { ...props },
|
|
3421
|
+
React__default.createElement(TableRow, null, headerColumns.map((column, index) => {
|
|
3422
|
+
const sortable = !!(onSortBy && column.sortable);
|
|
3423
|
+
const { label, colDef } = column;
|
|
3424
|
+
return (React__default.createElement(TableHeaderCell, { key: index, empty: !label, column: column, direction: sortDirection, active: sortable ? sortBy === colDef : undefined, onClick: () => sortable && onSortBy(column), onKeyDown: onActivation((e) => {
|
|
3588
3425
|
if (sortable) {
|
|
3589
3426
|
e.preventDefault();
|
|
3590
3427
|
onSortBy(column);
|
|
@@ -3593,23 +3430,19 @@ var TableHeader = function (_a) {
|
|
|
3593
3430
|
}))));
|
|
3594
3431
|
};
|
|
3595
3432
|
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
var _loop_1 = function (i) {
|
|
3433
|
+
const PaginationActions = ({ count, page, rowsPerPage, onPageChange }) => {
|
|
3434
|
+
const { classes } = usePaginationActionStyles();
|
|
3435
|
+
const getPageNumbers = (count, currentPage, rowsPerPage) => {
|
|
3436
|
+
const pageNumbers = [];
|
|
3437
|
+
const pageCount = Math.ceil(count / rowsPerPage);
|
|
3438
|
+
for (let i = 0; i < pageCount; i++) {
|
|
3603
3439
|
pageNumbers.push(React.createElement(Button, { key: i, className: classes.button, style: currentPage === i
|
|
3604
3440
|
? {
|
|
3605
3441
|
color: 'white',
|
|
3606
3442
|
}
|
|
3607
3443
|
: {
|
|
3608
3444
|
backgroundColor: Colors.white,
|
|
3609
|
-
}, onClick:
|
|
3610
|
-
};
|
|
3611
|
-
for (var i = 0; i < pageCount; i++) {
|
|
3612
|
-
_loop_1(i);
|
|
3445
|
+
}, onClick: (e) => onPageChange(e, i), disabled: currentPage === i }, i + 1));
|
|
3613
3446
|
}
|
|
3614
3447
|
if (currentPage >= 2 && currentPage < pageCount - 2) {
|
|
3615
3448
|
return pageNumbers.slice(currentPage - 2, currentPage + 3);
|
|
@@ -3619,14 +3452,14 @@ var PaginationActions = function (_a) {
|
|
|
3619
3452
|
: pageNumbers.slice(pageCount - 5, pageCount);
|
|
3620
3453
|
};
|
|
3621
3454
|
return (React.createElement("div", { style: { gridArea: 'right', justifySelf: 'end' } },
|
|
3622
|
-
React.createElement(Button, { className: classes.textButton, onClick:
|
|
3455
|
+
React.createElement(Button, { className: classes.textButton, onClick: (e) => onPageChange(e, page - 1), disabled: page === 0, "aria-label": "Previous Page" }, "Forrige"),
|
|
3623
3456
|
getPageNumbers(count, page, rowsPerPage),
|
|
3624
|
-
React.createElement(Button, { className: classes.textButton, onClick:
|
|
3457
|
+
React.createElement(Button, { className: classes.textButton, onClick: (e) => onPageChange(e, page + 1), disabled: page >= Math.ceil(count / rowsPerPage) - 1, "aria-label": "Next Page" }, "Neste")));
|
|
3625
3458
|
};
|
|
3626
3459
|
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
return (React__default.createElement(TablePagination,
|
|
3460
|
+
const GrepTablePagination = (props) => {
|
|
3461
|
+
const { classes } = usePaginationStyles();
|
|
3462
|
+
return (React__default.createElement(TablePagination, { classes: classes, rowsPerPageOptions: props.rowsPerPageOptions, SelectProps: {
|
|
3630
3463
|
inputProps: {
|
|
3631
3464
|
title: 'Velg antall elementer',
|
|
3632
3465
|
},
|
|
@@ -3634,40 +3467,31 @@ var GrepTablePagination = function (props) {
|
|
|
3634
3467
|
gridArea: 'left',
|
|
3635
3468
|
justifySelf: 'start',
|
|
3636
3469
|
},
|
|
3637
|
-
}, ActionsComponent:
|
|
3470
|
+
}, ActionsComponent: (actions) => (React__default.createElement(PaginationActions, { ...actions })), ...props }));
|
|
3638
3471
|
};
|
|
3639
3472
|
|
|
3640
|
-
|
|
3641
|
-
var columns = _a.columns, padding = _a.padding, _b = _a.text, text = _b === void 0 ? 'Tabellen er tom.' : _b;
|
|
3473
|
+
const GrepTablePlaceholder = ({ columns, padding, text = 'Tabellen er tom.', }) => {
|
|
3642
3474
|
return (React__default.createElement(TableRow, null,
|
|
3643
3475
|
React__default.createElement(TableCell, { padding: padding, colSpan: columns.length }, text)));
|
|
3644
3476
|
};
|
|
3645
3477
|
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
'&:focus': {
|
|
3659
|
-
outline: 'none',
|
|
3660
|
-
},
|
|
3478
|
+
const useStyles$d = makeStyles()((theme, { showHeader, outlined }) => ({
|
|
3479
|
+
table: {
|
|
3480
|
+
border: outlined ? `1px solid ${theme.palette.divider}` : 'none',
|
|
3481
|
+
borderCollapse: outlined ? 'separate' : 'collapse',
|
|
3482
|
+
tableLayout: 'auto',
|
|
3483
|
+
},
|
|
3484
|
+
header: {
|
|
3485
|
+
visibility: showHeader ? 'visible' : 'collapse',
|
|
3486
|
+
},
|
|
3487
|
+
body: {
|
|
3488
|
+
'&:focus': {
|
|
3489
|
+
outline: 'none',
|
|
3661
3490
|
},
|
|
3662
|
-
}
|
|
3663
|
-
});
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
return Array.from(el.getElementsByTagName(tag)).some(function (el) { return el === document.activeElement; });
|
|
3667
|
-
};
|
|
3668
|
-
var getElementIndex = function (el) {
|
|
3669
|
-
return Number(el.getAttribute('data-index') || -1);
|
|
3670
|
-
};
|
|
3491
|
+
},
|
|
3492
|
+
}));
|
|
3493
|
+
const containsFocus = (el, tag = '*') => Array.from(el.getElementsByTagName(tag)).some((el) => el === document.activeElement);
|
|
3494
|
+
const getElementIndex = (el) => Number(el.getAttribute('data-index') || -1);
|
|
3671
3495
|
/**
|
|
3672
3496
|
* Since Grep-Table is so tightly intregrated into LPU and Admin some core logic could not be fixed
|
|
3673
3497
|
* Still works but still messy
|
|
@@ -3675,16 +3499,15 @@ var getElementIndex = function (el) {
|
|
|
3675
3499
|
* @todo enhance page handling
|
|
3676
3500
|
*
|
|
3677
3501
|
*/
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
var setCurrentPage = useCallback$1(function (index, rowIndex, shouldExpand) {
|
|
3502
|
+
const GrepTable = ({ placeholderText, dropdownItems, isRowDisabled, pagination, outlined, columns, header, data, onSelectedRowChange, sortBy, sortDirection, onSortBy, onRowClick, size, caption, stickyHeader, padding, disableSelectOnClick = false, menuButtonLabel, underlineOnFocus, rowTabIndex, rowStyle, rowsPerPageOptions = [5, 10, 25, 50], ...props }) => {
|
|
3503
|
+
const [rowsPerPage, setRowsPerPage] = React__default.useState(props.rowsPerPage || 10);
|
|
3504
|
+
const [menuAnchor, setMenuAnchor] = React__default.useState(null);
|
|
3505
|
+
const [currentPage, _setCurrentPage] = React__default.useState(0);
|
|
3506
|
+
const [selectedRowIndex, _setSelectedRowIndex] = React__default.useState();
|
|
3507
|
+
const [expandedRowIndex, _setExpandedRowIndex] = React__default.useState();
|
|
3508
|
+
const [dropdownContext, setDropdownContext] = React__default.useState();
|
|
3509
|
+
const selectedRow = data[selectedRowIndex] || null;
|
|
3510
|
+
const setCurrentPage = useCallback$1((index, rowIndex, shouldExpand) => {
|
|
3688
3511
|
index = pagination && index >= 0 ? index : 0;
|
|
3689
3512
|
_setCurrentPage(index);
|
|
3690
3513
|
_setSelectedRowIndex(rowIndex);
|
|
@@ -3698,24 +3521,21 @@ var GrepTable = function (_a) {
|
|
|
3698
3521
|
rowsPerPage,
|
|
3699
3522
|
pagination,
|
|
3700
3523
|
]);
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
var pageIndex = Math.floor(index / rowsPerPage);
|
|
3524
|
+
const setSelectedRowIndex = (index, shouldExpand = true) => {
|
|
3525
|
+
const hasIndexChanged = index === selectedRowIndex;
|
|
3526
|
+
const pageIndex = Math.floor(index / rowsPerPage);
|
|
3705
3527
|
setCurrentPage(pageIndex, index, shouldExpand);
|
|
3706
3528
|
if (hasIndexChanged && onSelectedRowChange) {
|
|
3707
3529
|
onSelectedRowChange(data[index]);
|
|
3708
3530
|
}
|
|
3709
3531
|
};
|
|
3710
|
-
|
|
3711
|
-
if (shouldExpand === void 0) { shouldExpand = true; }
|
|
3532
|
+
const setSelectedElement = (el, shouldExpand = true) => {
|
|
3712
3533
|
setSelectedRowIndex(getElementIndex(el), shouldExpand);
|
|
3713
3534
|
};
|
|
3714
|
-
|
|
3535
|
+
const tableRef = React__default.useRef(null);
|
|
3715
3536
|
// focus selected row first tabable item
|
|
3716
|
-
React__default.useEffect(
|
|
3717
|
-
|
|
3718
|
-
var rowTab = (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("[data-index=\"".concat(selectedRowIndex, "\"]"));
|
|
3537
|
+
React__default.useEffect(() => {
|
|
3538
|
+
const rowTab = tableRef.current?.querySelector(`[data-index="${selectedRowIndex}"]`);
|
|
3719
3539
|
if (!rowTab)
|
|
3720
3540
|
return;
|
|
3721
3541
|
if (!containsFocus(rowTab)) {
|
|
@@ -3724,70 +3544,76 @@ var GrepTable = function (_a) {
|
|
|
3724
3544
|
}
|
|
3725
3545
|
}
|
|
3726
3546
|
}, [tableRef, selectedRowIndex]);
|
|
3727
|
-
React__default.useMemo(
|
|
3547
|
+
React__default.useMemo(() => {
|
|
3728
3548
|
setCurrentPage(0);
|
|
3729
3549
|
}, [data.length, setCurrentPage]);
|
|
3730
|
-
|
|
3731
|
-
|
|
3550
|
+
const _openDropdown = (e, row) => {
|
|
3551
|
+
const { onContextIdChanged } = props;
|
|
3732
3552
|
if (onContextIdChanged) {
|
|
3733
3553
|
onContextIdChanged(row);
|
|
3734
3554
|
}
|
|
3735
3555
|
setDropdownContext(row);
|
|
3736
3556
|
setMenuAnchor(e.currentTarget);
|
|
3737
3557
|
};
|
|
3738
|
-
|
|
3739
|
-
|
|
3558
|
+
const _handleRowClick = useCallback$1((row) => {
|
|
3559
|
+
const disabled = isRowDisabled && isRowDisabled(row);
|
|
3740
3560
|
!disabled && onRowClick && onRowClick(row);
|
|
3741
3561
|
}, [onRowClick]);
|
|
3742
|
-
|
|
3562
|
+
const _handlePageChange = (event, newPage) => {
|
|
3743
3563
|
event && event.preventDefault();
|
|
3744
3564
|
setCurrentPage(newPage);
|
|
3745
3565
|
};
|
|
3746
|
-
|
|
3566
|
+
const _handleChangeRowsPerPage = (event) => {
|
|
3747
3567
|
setRowsPerPage(Number(event.target.value));
|
|
3748
3568
|
};
|
|
3749
|
-
|
|
3569
|
+
const _handleMenuClose = () => {
|
|
3750
3570
|
setMenuAnchor(null);
|
|
3751
3571
|
};
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3572
|
+
const _renderCellButton = (row) => {
|
|
3573
|
+
const { menuDisabled, menuTooltip } = props;
|
|
3574
|
+
const disabled = menuDisabled && menuDisabled(row);
|
|
3575
|
+
const tooltip = menuTooltip ? menuTooltip(row) : '';
|
|
3756
3576
|
return (React__default.createElement(Tooltip, { title: tooltip, placement: "bottom" },
|
|
3757
3577
|
React__default.createElement("div", { style: { display: 'flex', justifyContent: 'end' } },
|
|
3758
|
-
React__default.createElement(IconButton, { disableTouchRipple: true, disabled: disabled, style: { float: 'right' }, onMouseDown:
|
|
3578
|
+
React__default.createElement(IconButton, { disableTouchRipple: true, disabled: disabled, style: { float: 'right' }, onMouseDown: (e) => {
|
|
3759
3579
|
e.preventDefault();
|
|
3760
3580
|
e.stopPropagation();
|
|
3761
|
-
}, onClick:
|
|
3581
|
+
}, onClick: (e) => {
|
|
3762
3582
|
_openDropdown(e, row);
|
|
3763
|
-
}, onKeyDown:
|
|
3583
|
+
}, onKeyDown: (e) => {
|
|
3764
3584
|
switch (e.which) {
|
|
3765
3585
|
case Key_enum.Key.Enter:
|
|
3766
3586
|
// dont show dropdown
|
|
3767
3587
|
e.preventDefault();
|
|
3768
3588
|
break;
|
|
3769
3589
|
}
|
|
3770
|
-
}, tabIndex: 0, size: "large", "aria-label": menuButtonLabel
|
|
3590
|
+
}, tabIndex: 0, size: "large", "aria-label": menuButtonLabel ?? 'Åpne meny' },
|
|
3771
3591
|
React__default.createElement(MoreVert, null)))));
|
|
3772
3592
|
};
|
|
3773
|
-
|
|
3774
|
-
|
|
3593
|
+
const getRowStyle = (row, index, clickableRows, disabled) => {
|
|
3594
|
+
let style = { cursor: clickableRows && !disabled ? 'pointer' : '' };
|
|
3775
3595
|
if (typeof rowStyle === "function") {
|
|
3776
|
-
style =
|
|
3596
|
+
style = {
|
|
3597
|
+
...style,
|
|
3598
|
+
...rowStyle(row, index)
|
|
3599
|
+
};
|
|
3777
3600
|
}
|
|
3778
3601
|
else if (rowStyle) {
|
|
3779
|
-
style =
|
|
3602
|
+
style = {
|
|
3603
|
+
...style,
|
|
3604
|
+
...rowStyle
|
|
3605
|
+
};
|
|
3780
3606
|
}
|
|
3781
3607
|
return style;
|
|
3782
3608
|
};
|
|
3783
|
-
|
|
3784
|
-
|
|
3609
|
+
const _renderRow = (row, index) => {
|
|
3610
|
+
const rowColumns = dropdownItems
|
|
3785
3611
|
? columns.concat([{ getCell: _renderCellButton, padding: 'none' }])
|
|
3786
3612
|
: columns;
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
return (React__default.createElement(GrepTableRow, { key: rowIndex, "data-index": rowIndex, tabIndex: rowTabIndex
|
|
3613
|
+
const clickableRows = !!onRowClick;
|
|
3614
|
+
const disabled = isRowDisabled && isRowDisabled(row);
|
|
3615
|
+
const rowIndex = index + currentPage * rowsPerPage;
|
|
3616
|
+
return (React__default.createElement(GrepTableRow, { key: rowIndex, "data-index": rowIndex, tabIndex: rowTabIndex ?? 0, hover: clickableRows, selected: rowIndex === selectedRowIndex, expanded: rowIndex === expandedRowIndex, clickable: clickableRows, onMouseDown: (e) => {
|
|
3791
3617
|
if (e.target.type === 'checkbox') {
|
|
3792
3618
|
e.preventDefault();
|
|
3793
3619
|
e.stopPropagation();
|
|
@@ -3799,16 +3625,16 @@ var GrepTable = function (_a) {
|
|
|
3799
3625
|
_handleRowClick(row);
|
|
3800
3626
|
}
|
|
3801
3627
|
}
|
|
3802
|
-
}, columns: rowColumns, row: row, style: getRowStyle(row, index, clickableRows, disabled), onFocus:
|
|
3628
|
+
}, columns: rowColumns, row: row, style: getRowStyle(row, index, clickableRows, disabled), onFocus: (e) => {
|
|
3803
3629
|
if (selectedRowIndex !== rowIndex) {
|
|
3804
3630
|
setSelectedElement(e.currentTarget);
|
|
3805
3631
|
}
|
|
3806
3632
|
}, underlineOnFocus: underlineOnFocus }));
|
|
3807
3633
|
};
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3634
|
+
const onKey = (e) => {
|
|
3635
|
+
const maxIndex = data.length - 1;
|
|
3636
|
+
const moveSelectedRow = (steps) => {
|
|
3637
|
+
const i = (selectedRowIndex || 0) + steps;
|
|
3812
3638
|
if (i >= 0 && i <= maxIndex) {
|
|
3813
3639
|
setSelectedRowIndex(i);
|
|
3814
3640
|
}
|
|
@@ -3835,7 +3661,7 @@ var GrepTable = function (_a) {
|
|
|
3835
3661
|
setSelectedRowIndex(maxIndex);
|
|
3836
3662
|
break;
|
|
3837
3663
|
case Key_enum.Key.Tab:
|
|
3838
|
-
requestAnimationFrame(
|
|
3664
|
+
requestAnimationFrame(() => {
|
|
3839
3665
|
// check is any children still has focus
|
|
3840
3666
|
!containsFocus(tableRef.current) && setSelectedRowIndex(-1);
|
|
3841
3667
|
});
|
|
@@ -3845,57 +3671,53 @@ var GrepTable = function (_a) {
|
|
|
3845
3671
|
break;
|
|
3846
3672
|
}
|
|
3847
3673
|
};
|
|
3848
|
-
|
|
3674
|
+
const rows = pagination
|
|
3849
3675
|
? data.slice(currentPage * rowsPerPage, currentPage * rowsPerPage + rowsPerPage)
|
|
3850
3676
|
: data;
|
|
3851
|
-
|
|
3677
|
+
const { classes } = useStyles$d({ outlined, showHeader: header });
|
|
3852
3678
|
return (React__default.createElement(TableContainer, { sx: props.style },
|
|
3853
3679
|
React__default.createElement(Table, { className: classes.table, size: size, stickyHeader: stickyHeader, padding: padding },
|
|
3854
3680
|
caption && React__default.createElement("caption", null, caption),
|
|
3855
3681
|
React__default.createElement(TableHeader, { className: classes.header, columns: columns, sortBy: sortBy, sortDirection: sortDirection, onSortBy: onSortBy, dropdownItems: dropdownItems }),
|
|
3856
3682
|
React__default.createElement(TableBody, { ref: tableRef, className: classes.body, onKeyDown: onKey }, data.length ? (rows.map(_renderRow)) : (React__default.createElement(GrepTablePlaceholder, { padding: padding, columns: columns, text: placeholderText }))),
|
|
3857
3683
|
React__default.createElement(TableFooter, null, pagination && (React__default.createElement(TableRow, null,
|
|
3858
|
-
React__default.createElement(GrepTablePagination, { page: currentPage, count: data.length, rowsPerPage: rowsPerPage, onPageChange: _handlePageChange, rowsPerPageOptions: rowsPerPageOptions, onRowsPerPageChange: _handleChangeRowsPerPage, labelRowsPerPage: '', labelDisplayedRows:
|
|
3859
|
-
var from = _a.from, to = _a.to, count = _a.count;
|
|
3860
|
-
return "Viser ".concat(from, "-").concat(to, " av ").concat(count);
|
|
3861
|
-
} }))))),
|
|
3684
|
+
React__default.createElement(GrepTablePagination, { page: currentPage, count: data.length, rowsPerPage: rowsPerPage, onPageChange: _handlePageChange, rowsPerPageOptions: rowsPerPageOptions, onRowsPerPageChange: _handleChangeRowsPerPage, labelRowsPerPage: '', labelDisplayedRows: ({ from, to, count }) => `Viser ${from}-${to} av ${count}` }))))),
|
|
3862
3685
|
dropdownItems && dropdownContext && (React__default.createElement(DropdownMenu, { open: !!menuAnchor, context: dropdownContext, anchorEl: menuAnchor, menuItems: dropdownItems, onClose: _handleMenuClose }))));
|
|
3863
3686
|
};
|
|
3864
3687
|
|
|
3865
|
-
|
|
3688
|
+
const useStyles$c = makeStyles()({
|
|
3866
3689
|
container: {
|
|
3867
|
-
border:
|
|
3690
|
+
border: `1px solid ${Colors.lightGrey}`,
|
|
3868
3691
|
height: 'fit-content',
|
|
3869
3692
|
flex: 'auto',
|
|
3870
3693
|
},
|
|
3871
3694
|
title: { fontSize: 24, padding: 20, color: Colors.black },
|
|
3872
3695
|
});
|
|
3873
3696
|
|
|
3874
|
-
|
|
3875
|
-
|
|
3697
|
+
const GrepTableCard = (props) => {
|
|
3698
|
+
const { classes } = useStyles$c();
|
|
3876
3699
|
return (React.createElement(Box, { className: classes.container, style: props.style },
|
|
3877
3700
|
React.createElement(Typography, { className: classes.title }, props.title),
|
|
3878
|
-
React.createElement(GrepTable,
|
|
3701
|
+
React.createElement(GrepTable, { ...props, header: true })));
|
|
3879
3702
|
};
|
|
3880
3703
|
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
return function () { return clearTimeout(timeout); };
|
|
3704
|
+
const LoadingOverlay = ({ overlay = 'rgba(255,255,255, .5)', show, children, minTime, zIndex, sx, ...box }) => {
|
|
3705
|
+
const [enabled, setEnabled] = useState(show);
|
|
3706
|
+
useEffect(() => {
|
|
3707
|
+
const timeout = setTimeout(() => setEnabled(show), show ? 0 : minTime);
|
|
3708
|
+
return () => clearTimeout(timeout);
|
|
3887
3709
|
}, [show, minTime, setEnabled]);
|
|
3888
3710
|
return (React__default.createElement(Box, { position: "relative", display: "block", overflow: show ? 'hidden' : '' },
|
|
3889
3711
|
children,
|
|
3890
|
-
React__default.createElement(Box,
|
|
3712
|
+
React__default.createElement(Box, { position: "absolute", display: "flex", alignItems: "center", justifyContent: "center", top: 0, left: 0, height: "100%", width: "100%", zIndex: enabled ? (zIndex ? zIndex : 999) : -999, style: {
|
|
3891
3713
|
backgroundColor: overlay,
|
|
3892
3714
|
opacity: show ? 1 : 0,
|
|
3893
|
-
transition:
|
|
3894
|
-
}, sx: sx
|
|
3715
|
+
transition: `opacity ${show ? 0 : minTime}ms ease`,
|
|
3716
|
+
}, sx: sx, ...box },
|
|
3895
3717
|
React__default.createElement(CircularProgress, { "aria-label": "Laster inn" }))));
|
|
3896
3718
|
};
|
|
3897
3719
|
|
|
3898
|
-
|
|
3720
|
+
const useStyles$b = makeStyles()({
|
|
3899
3721
|
container: {
|
|
3900
3722
|
display: 'flex',
|
|
3901
3723
|
marginTop: 30,
|
|
@@ -3923,18 +3745,17 @@ var useStyles$b = makeStyles()({
|
|
|
3923
3745
|
},
|
|
3924
3746
|
});
|
|
3925
3747
|
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
var current = ref.current;
|
|
3748
|
+
const isOverflowing = (e) => e.offsetWidth < e.scrollWidth;
|
|
3749
|
+
const GrepCrumbs = ({ style, onClick, breadcrumbs, }) => {
|
|
3750
|
+
const { classes } = useStyles$b();
|
|
3751
|
+
const dispatch = useDispatch();
|
|
3752
|
+
const ref = React__default.useRef(null);
|
|
3753
|
+
const [showTooltip, setShowTooltip] = React__default.useState(false);
|
|
3754
|
+
React__default.useEffect(() => {
|
|
3755
|
+
const { current } = ref;
|
|
3935
3756
|
setShowTooltip(!!current && isOverflowing(current));
|
|
3936
3757
|
}, [ref]);
|
|
3937
|
-
|
|
3758
|
+
const handleClick = (crumb) => {
|
|
3938
3759
|
if (onClick) {
|
|
3939
3760
|
onClick(crumb);
|
|
3940
3761
|
}
|
|
@@ -3942,15 +3763,13 @@ var GrepCrumbs = function (_a) {
|
|
|
3942
3763
|
crumb.path && dispatch(push(crumb.path));
|
|
3943
3764
|
}
|
|
3944
3765
|
};
|
|
3945
|
-
return (React__default.createElement("div", { className: classes.container, style: style }, breadcrumbs.map(
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
React__default.createElement("div", { className: classes.current, ref: ref }, crumb.label)));
|
|
3950
|
-
})));
|
|
3766
|
+
return (React__default.createElement("div", { className: classes.container, style: style }, breadcrumbs.map((crumb, index) => crumb.path ? (React__default.createElement(Box, { key: index, display: "flex" },
|
|
3767
|
+
React__default.createElement(Link, { className: classes.link, tabIndex: 0, component: "button", onClick: () => handleClick(crumb) }, crumb.label),
|
|
3768
|
+
index !== breadcrumbs.length - 1 && (React__default.createElement(Box, { margin: "auto 8px", height: "fit-content" /*lineHeight="20px"*/ }, ">")))) : (React__default.createElement(Tooltip, { key: index, title: showTooltip ? crumb.label : '' },
|
|
3769
|
+
React__default.createElement("div", { className: classes.current, ref: ref }, crumb.label))))));
|
|
3951
3770
|
};
|
|
3952
3771
|
|
|
3953
|
-
|
|
3772
|
+
const useStyles$a = makeStyles()({
|
|
3954
3773
|
outer: {
|
|
3955
3774
|
alignItems: 'center',
|
|
3956
3775
|
background: Colors.white,
|
|
@@ -3971,27 +3790,27 @@ var useStyles$a = makeStyles()({
|
|
|
3971
3790
|
helptext: { margin: '0 10px 0 10px', color: '#6e6e6e', fontSize: 12 },
|
|
3972
3791
|
});
|
|
3973
3792
|
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
React.useEffect(
|
|
3793
|
+
const SearchBar = (props) => {
|
|
3794
|
+
const inputRef = React.useRef(null);
|
|
3795
|
+
const [value, setValue] = React.useState(props.initValue || '');
|
|
3796
|
+
const { classes } = useStyles$a();
|
|
3797
|
+
React.useEffect(() => {
|
|
3979
3798
|
if (props.autoFocus && inputRef.current) {
|
|
3980
3799
|
inputRef.current.focus();
|
|
3981
3800
|
}
|
|
3982
3801
|
});
|
|
3983
|
-
|
|
3984
|
-
|
|
3802
|
+
const _handleChange = (event) => {
|
|
3803
|
+
const newVal = event.target.value;
|
|
3985
3804
|
setValue(newVal);
|
|
3986
3805
|
props.onInputChange(newVal);
|
|
3987
3806
|
};
|
|
3988
|
-
|
|
3807
|
+
const _handleClear = () => {
|
|
3989
3808
|
setValue('');
|
|
3990
3809
|
props.onClear();
|
|
3991
3810
|
};
|
|
3992
3811
|
return (React.createElement(React.Fragment, null,
|
|
3993
3812
|
React.createElement(Box, { className: classes.outer, "data-testid": "searchBarContainer", style: {
|
|
3994
|
-
border: props.outlined ?
|
|
3813
|
+
border: props.outlined ? `1px solid ${Colors.lightGrey}` : 0,
|
|
3995
3814
|
} },
|
|
3996
3815
|
React.createElement(Box, { className: classes.icon },
|
|
3997
3816
|
React.createElement(Search, null)),
|
|
@@ -4008,53 +3827,42 @@ var SearchBar = function (props) {
|
|
|
4008
3827
|
props.searchAllText && props.onSearchAll && (React.createElement(Button, { color: "primary", onClick: props.onSearchAll }, props.searchAllText)))));
|
|
4009
3828
|
};
|
|
4010
3829
|
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
},
|
|
4022
|
-
});
|
|
4023
|
-
});
|
|
3830
|
+
const useStyles$9 = makeStyles()((theme, { elevation }) => ({
|
|
3831
|
+
cover: {
|
|
3832
|
+
background: theme.palette.grey.A200,
|
|
3833
|
+
marginBottom: 12,
|
|
3834
|
+
padding: '10px 0',
|
|
3835
|
+
boxShadow: elevation
|
|
3836
|
+
? `0px 3px 1px -2px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%);`
|
|
3837
|
+
: 'none',
|
|
3838
|
+
},
|
|
3839
|
+
}));
|
|
4024
3840
|
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
var classes = useStyles$9({ elevation: elevation }).classes;
|
|
3841
|
+
const GreyCover = ({ elevation, children }) => {
|
|
3842
|
+
const { classes } = useStyles$9({ elevation });
|
|
4028
3843
|
return React.createElement(Box, { className: classes.cover }, children);
|
|
4029
3844
|
};
|
|
4030
3845
|
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
return (React.createElement(Box, { height: height, width: "100%", display: "flex", alignItems: "center", justifyContent: "center" },
|
|
4034
|
-
React.createElement(CircularProgress$1, __assign({}, props))));
|
|
4035
|
-
};
|
|
3846
|
+
const CircularLoading = ({ height, ...props }) => (React.createElement(Box, { height: height, width: "100%", display: "flex", alignItems: "center", justifyContent: "center" },
|
|
3847
|
+
React.createElement(CircularProgress$1, { ...props })));
|
|
4036
3848
|
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
},
|
|
4051
|
-
_a),
|
|
4052
|
-
});
|
|
4053
|
-
});
|
|
3849
|
+
const useStyles$8 = makeStyles()((theme) => ({
|
|
3850
|
+
container: {
|
|
3851
|
+
width: '48%',
|
|
3852
|
+
display: 'flex',
|
|
3853
|
+
flexDirection: 'column',
|
|
3854
|
+
[theme.breakpoints.down('lg')]: {
|
|
3855
|
+
width: '100%',
|
|
3856
|
+
},
|
|
3857
|
+
[theme.breakpoints.up('md')]: {
|
|
3858
|
+
width: '48%',
|
|
3859
|
+
},
|
|
3860
|
+
},
|
|
3861
|
+
}));
|
|
4054
3862
|
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
3863
|
+
const renderField$1 = (id, label, value) => (React.createElement(TextField, { id: id, disabled: true, label: label, value: value, variant: "outlined", style: { margin: '10px 0' }, InputProps: { style: { color: 'rgb(84, 84, 84)' } } }));
|
|
3864
|
+
const ProfileInfo = (props) => {
|
|
3865
|
+
const { classes } = useStyles$8();
|
|
4058
3866
|
return (React.createElement(Box, { className: classes.container },
|
|
4059
3867
|
renderField$1('firstname', 'Fornavn', props.firstName),
|
|
4060
3868
|
renderField$1('lastname', 'Etternavn', props.lastName),
|
|
@@ -4063,48 +3871,43 @@ var ProfileInfo = function (props) {
|
|
|
4063
3871
|
renderField$1('role', 'Rolle', props.role)));
|
|
4064
3872
|
};
|
|
4065
3873
|
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
_a[theme.breakpoints.down('lg')] = {
|
|
4076
|
-
maxWidth: 'unset',
|
|
4077
|
-
width: '100%',
|
|
4078
|
-
},
|
|
4079
|
-
_a[theme.breakpoints.up('md')] = {
|
|
4080
|
-
maxWidth: 500,
|
|
4081
|
-
},
|
|
4082
|
-
_a),
|
|
4083
|
-
content: {
|
|
4084
|
-
backgroundColor: 'unset',
|
|
4085
|
-
marginRight: 20,
|
|
3874
|
+
const useStyles$7 = makeStyles()((theme) => ({
|
|
3875
|
+
container: {
|
|
3876
|
+
backgroundColor: 'rgb(241, 243, 244)',
|
|
3877
|
+
height: 'fit-content',
|
|
3878
|
+
display: 'flex',
|
|
3879
|
+
maxWidth: 500,
|
|
3880
|
+
[theme.breakpoints.down('lg')]: {
|
|
3881
|
+
maxWidth: 'unset',
|
|
3882
|
+
width: '100%',
|
|
4086
3883
|
},
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
fontSize: 16,
|
|
4090
|
-
margin: '20px 0',
|
|
3884
|
+
[theme.breakpoints.up('md')]: {
|
|
3885
|
+
maxWidth: 500,
|
|
4091
3886
|
},
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
3887
|
+
},
|
|
3888
|
+
content: {
|
|
3889
|
+
backgroundColor: 'unset',
|
|
3890
|
+
marginRight: 20,
|
|
3891
|
+
},
|
|
3892
|
+
title: {
|
|
3893
|
+
backgroundColor: 'unset',
|
|
3894
|
+
fontSize: 16,
|
|
3895
|
+
margin: '20px 0',
|
|
3896
|
+
},
|
|
3897
|
+
body: {
|
|
3898
|
+
backgroundColor: 'unset',
|
|
3899
|
+
h4: {
|
|
3900
|
+
marginRight: 20,
|
|
4101
3901
|
},
|
|
4102
|
-
}
|
|
4103
|
-
|
|
3902
|
+
},
|
|
3903
|
+
icon: {
|
|
3904
|
+
margin: '20px 10px',
|
|
3905
|
+
color: 'rgb(255, 158, 157)',
|
|
3906
|
+
},
|
|
3907
|
+
}));
|
|
4104
3908
|
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
var classes = useStyles$7().classes;
|
|
3909
|
+
const GDPR = ({ children }) => {
|
|
3910
|
+
const { classes } = useStyles$7();
|
|
4108
3911
|
return (React.createElement(Box, { className: classes.container },
|
|
4109
3912
|
React.createElement(Info, { className: classes.icon }),
|
|
4110
3913
|
React.createElement(Box, { className: classes.content },
|
|
@@ -4112,67 +3915,66 @@ var GDPR = function (_a) {
|
|
|
4112
3915
|
React.createElement(Typography, { className: classes.body }, children))));
|
|
4113
3916
|
};
|
|
4114
3917
|
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
return (React.createElement(TextField, __assign({}, rest, { variant: variant, helperText: errorMessage || helperText, value: value === null ? '' : value, InputLabelProps: { shrink: shrink }, error: error || rest.error })));
|
|
3918
|
+
const GrepInput = ({ variant = 'standard', ...props }) => {
|
|
3919
|
+
const { errorMessage, helperText, shrink, value, ...rest } = props;
|
|
3920
|
+
const error = errorMessage ? errorMessage.length > 0 : false;
|
|
3921
|
+
return (React.createElement(TextField, { ...rest, variant: variant, helperText: errorMessage || helperText, value: value === null ? '' : value, InputLabelProps: { shrink }, error: error || rest.error }));
|
|
4120
3922
|
};
|
|
4121
3923
|
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
React.useEffect(
|
|
3924
|
+
const GrepSelect = (props) => {
|
|
3925
|
+
const inputLabel = React.useRef(null);
|
|
3926
|
+
const [labelWidth, setLabelWidth] = React.useState(0);
|
|
3927
|
+
React.useEffect(() => {
|
|
4126
3928
|
setLabelWidth(inputLabel.current.offsetWidth);
|
|
4127
3929
|
}, []);
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
3930
|
+
const { unselectOption = true, errorMessage, selectItems, helperText, fullWidth, outlined, disabled, required, label, inputProps, value, size, id, useCheckedSelect, ...rest } = props;
|
|
3931
|
+
const error = errorMessage ? errorMessage.length > 0 : false;
|
|
3932
|
+
const selected = value;
|
|
4131
3933
|
return (React.createElement(FormControl, { variant: outlined ? 'outlined' : 'standard', className: props.className, fullWidth: fullWidth, required: required, style: props.style, error: error, size: size, disabled: disabled },
|
|
4132
3934
|
React.createElement(InputLabel, { htmlFor: id, ref: inputLabel, style: {
|
|
4133
3935
|
minWidth: 'max-content',
|
|
4134
3936
|
overflow: 'visible',
|
|
4135
3937
|
} }, label),
|
|
4136
|
-
React.createElement(Select,
|
|
3938
|
+
React.createElement(Select, { ...rest, inputProps: { id, ...inputProps }, disabled: !selectItems || disabled, value: value === null ? '' : value, style: { minWidth: labelWidth + (outlined ? 35 : 25) },
|
|
4137
3939
|
// @todo: make input respect label length
|
|
4138
|
-
input: outlined ? React.createElement(OutlinedInput, { label: label }) : React.createElement(Input, null), MenuProps:
|
|
3940
|
+
input: outlined ? React.createElement(OutlinedInput, { label: label }) : React.createElement(Input, null), MenuProps: {
|
|
3941
|
+
...rest.MenuProps,
|
|
3942
|
+
anchorOrigin: {
|
|
4139
3943
|
vertical: 'bottom',
|
|
4140
3944
|
horizontal: 'center',
|
|
4141
|
-
},
|
|
3945
|
+
},
|
|
3946
|
+
transformOrigin: {
|
|
4142
3947
|
vertical: 'top',
|
|
4143
3948
|
horizontal: 'center',
|
|
4144
|
-
}
|
|
3949
|
+
},
|
|
3950
|
+
} },
|
|
4145
3951
|
unselectOption && (React.createElement(MenuItem, { value: "" },
|
|
4146
3952
|
React.createElement("em", null, "Fjern valgt"))),
|
|
4147
|
-
selectItems.map(
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
useCheckedSelect && (React.createElement(Checkbox, { checked: (selected === null || selected === void 0 ? void 0 : selected.indexOf(value)) > -1 })),
|
|
4151
|
-
React.createElement(ListItemText, { sx: { margin: '0px', span: { lineHeight: '1.4375em' } }, primary: label ? label : value })));
|
|
4152
|
-
})),
|
|
3953
|
+
selectItems.map(({ label, value, disabled, lang }, i) => (React.createElement(MenuItem, { key: i, value: value, disabled: disabled, lang: lang },
|
|
3954
|
+
useCheckedSelect && (React.createElement(Checkbox, { checked: selected?.indexOf(value) > -1 })),
|
|
3955
|
+
React.createElement(ListItemText, { sx: { margin: '0px', span: { lineHeight: '1.4375em' } }, primary: label ? label : value }))))),
|
|
4153
3956
|
React.createElement(FormHelperText, null, errorMessage || helperText)));
|
|
4154
3957
|
};
|
|
4155
3958
|
|
|
4156
|
-
|
|
3959
|
+
const defaultOptions$2 = {
|
|
4157
3960
|
utc: true,
|
|
4158
3961
|
preserveTime: false,
|
|
4159
3962
|
};
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
var getDate = useCallback$1(function (value) {
|
|
3963
|
+
const useDate = (value = null, options) => {
|
|
3964
|
+
const { utc, preserveTime } = { ...options, ...defaultOptions$2 };
|
|
3965
|
+
const [date, _setDate] = useState(null);
|
|
3966
|
+
const getDate = useCallback$1((value) => {
|
|
4165
3967
|
if (value) {
|
|
4166
|
-
|
|
4167
|
-
return preserveTime ?
|
|
3968
|
+
const date = dayjs(value);
|
|
3969
|
+
return preserveTime ? date : date.startOf('day');
|
|
4168
3970
|
}
|
|
4169
3971
|
return null;
|
|
4170
3972
|
}, [preserveTime]);
|
|
4171
|
-
|
|
4172
|
-
|
|
3973
|
+
const setDate = (next) => {
|
|
3974
|
+
const nextDate = getDate(next);
|
|
4173
3975
|
hasDateChanged(date, nextDate) && _setDate(nextDate);
|
|
4174
3976
|
};
|
|
4175
|
-
useMemo$1(
|
|
3977
|
+
useMemo$1(() => setDate(value ? parseDate(value, { utc }) : null), [
|
|
4176
3978
|
value,
|
|
4177
3979
|
utc,
|
|
4178
3980
|
]);
|
|
@@ -4571,55 +4373,58 @@ var lodash_debounce = debounce$1;
|
|
|
4571
4373
|
* return (<><input {...{ref,onChange}}/><p>{txt}</p></>)
|
|
4572
4374
|
* }
|
|
4573
4375
|
*/
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4376
|
+
const useDebounce = (func, opt, deps) => {
|
|
4377
|
+
const debounce = useMemo$1(() => {
|
|
4378
|
+
const { wait, ...settings } = opt;
|
|
4577
4379
|
return lodash_debounce(func, wait, settings);
|
|
4578
4380
|
}, deps || []);
|
|
4579
|
-
useEffect(
|
|
4381
|
+
useEffect(() => debounce.cancel, [debounce]);
|
|
4580
4382
|
return debounce;
|
|
4581
4383
|
};
|
|
4582
4384
|
|
|
4583
|
-
|
|
4584
|
-
return match ? elements.filter(
|
|
4585
|
-
};
|
|
4586
|
-
|
|
4587
|
-
identify:
|
|
4385
|
+
const filterElements = (match) => (elements) => {
|
|
4386
|
+
return match ? elements.filter((el) => el.nodeName.match(match)) : elements;
|
|
4387
|
+
};
|
|
4388
|
+
const defaultOptions$1 = {
|
|
4389
|
+
identify: (el) => el.id,
|
|
4588
4390
|
config: {
|
|
4589
4391
|
attributes: false,
|
|
4590
4392
|
childList: true,
|
|
4591
4393
|
subtree: true,
|
|
4592
4394
|
},
|
|
4593
4395
|
};
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4396
|
+
const useContentElements = (container, selector, options) => {
|
|
4397
|
+
const { filter, config, identify } = {
|
|
4398
|
+
...defaultOptions$1,
|
|
4399
|
+
...options,
|
|
4400
|
+
};
|
|
4401
|
+
const [elements, setElements] = useState({});
|
|
4402
|
+
const getElements = useCallback$1(() => {
|
|
4403
|
+
const all = Array.from(container.querySelectorAll(selector));
|
|
4404
|
+
const elements = filter ? all.filter(filter) : all;
|
|
4405
|
+
return elements.reduce((curr, el) => {
|
|
4406
|
+
const id = identify(el);
|
|
4602
4407
|
if (curr[id])
|
|
4603
4408
|
throw Error('duplicate identifiers!');
|
|
4604
4409
|
curr[id] = el;
|
|
4605
4410
|
return curr;
|
|
4606
4411
|
}, {});
|
|
4607
4412
|
}, [container, selector, identify, filter]);
|
|
4608
|
-
useEffect(
|
|
4413
|
+
useEffect(() => {
|
|
4609
4414
|
// early exit, nothing to observe
|
|
4610
4415
|
if (!container)
|
|
4611
4416
|
return;
|
|
4612
4417
|
// set current elements
|
|
4613
4418
|
setElements(getElements());
|
|
4614
4419
|
// Observe changes in DOM
|
|
4615
|
-
|
|
4420
|
+
const observer = new MutationObserver(() => {
|
|
4616
4421
|
setElements(getElements());
|
|
4617
4422
|
});
|
|
4618
4423
|
// start observing
|
|
4619
4424
|
observer.observe(container, config);
|
|
4620
4425
|
console.debug('observing container', container);
|
|
4621
4426
|
// stop observing when unmounted
|
|
4622
|
-
return
|
|
4427
|
+
return () => {
|
|
4623
4428
|
observer.disconnect();
|
|
4624
4429
|
console.debug('observing disconnected', container);
|
|
4625
4430
|
};
|
|
@@ -4627,100 +4432,98 @@ var useContentElements = function (container, selector, options) {
|
|
|
4627
4432
|
return elements;
|
|
4628
4433
|
};
|
|
4629
4434
|
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
useEffect(function () { return onChange(date); }, [String(date)]);
|
|
4435
|
+
const DatePicker = ({ id, label, value, variant, onChange, errorMessage, placeholder, fullWidth, required, onFocus, margin, sx, ...props }) => {
|
|
4436
|
+
const [date, setDate] = useDate(value);
|
|
4437
|
+
const [error, setError] = useState();
|
|
4438
|
+
const helperText = errorMessage || error || props.helperText;
|
|
4439
|
+
useEffect(() => onChange(date), [String(date)]);
|
|
4636
4440
|
return (React__default.createElement(LocalizationProvider, { dateAdapter: AdapterDayjs, adapterLocale: 'nb' },
|
|
4637
4441
|
React__default.createElement(DesktopDatePicker
|
|
4638
4442
|
// clearable @todo
|
|
4639
|
-
,
|
|
4443
|
+
, {
|
|
4640
4444
|
// clearable @todo
|
|
4641
|
-
inputFormat: "DD/MM/YYYY", onError:
|
|
4445
|
+
inputFormat: "DD/MM/YYYY", onError: (reason) => {
|
|
4642
4446
|
switch (reason) {
|
|
4643
4447
|
case 'invalidDate':
|
|
4644
4448
|
setError('Ugyldig dato');
|
|
4645
4449
|
break;
|
|
4646
4450
|
case 'maxDate':
|
|
4647
|
-
setError(
|
|
4451
|
+
setError(`Dato må være før ${dayjs(props.maxDate)
|
|
4648
4452
|
.add(1, 'day')
|
|
4649
|
-
.format('DD/MM/YYYY'))
|
|
4453
|
+
.format('DD/MM/YYYY')}`);
|
|
4650
4454
|
break;
|
|
4651
4455
|
case 'minDate':
|
|
4652
|
-
setError(
|
|
4456
|
+
setError(`Dato må være etter ${dayjs(props.minDate)
|
|
4653
4457
|
.subtract(1, 'day')
|
|
4654
|
-
.format('DD/MM/YYYY'))
|
|
4458
|
+
.format('DD/MM/YYYY')}`);
|
|
4655
4459
|
break;
|
|
4656
4460
|
default:
|
|
4657
4461
|
setError(undefined);
|
|
4658
4462
|
}
|
|
4659
|
-
}, value: date, onChange: setDate, renderInput:
|
|
4463
|
+
}, value: date, onChange: setDate, renderInput: (params) => (React__default.createElement(TextField, { id: id, ...params, label: label, variant: variant, onFocus: onFocus, required: required, fullWidth: fullWidth, placeholder: placeholder, sx: sx, margin: margin, error: !!error || !!errorMessage, ...(helperText && { helperText }) })), ...props })));
|
|
4660
4464
|
};
|
|
4661
4465
|
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
useEffect(function () { return onChange(new DateRangeValue(from, to)); }, [String(from), String(to)]);
|
|
4466
|
+
const GrepDateRange = ({ onChange, spacing = 3, style, fullWidth, from: fromProperties, to: toProperties, ...properties }) => {
|
|
4467
|
+
const [from, setFrom] = useDate(fromProperties.value);
|
|
4468
|
+
const [to, setTo] = useDate(toProperties.value);
|
|
4469
|
+
const { minDate, maxDate, ...commonProperties } = properties;
|
|
4470
|
+
useEffect(() => onChange(new DateRangeValue(from, to)), [String(from), String(to)]);
|
|
4668
4471
|
return (React__default.createElement(Grid, { container: true, spacing: spacing, style: style },
|
|
4669
4472
|
React__default.createElement(Grid, { item: true, xs: 12, sm: fullWidth ? 12 : 6 },
|
|
4670
|
-
React__default.createElement(DatePicker,
|
|
4473
|
+
React__default.createElement(DatePicker, { id: String(fromProperties.label), fullWidth: true, minDate: minDate, ...commonProperties, ...fromProperties, value: from, maxDate: to?.subtract(1, 'day') || undefined, onChange: setFrom })),
|
|
4671
4474
|
React__default.createElement(Grid, { item: true, xs: 12, sm: fullWidth ? 12 : 6 },
|
|
4672
|
-
React__default.createElement(DatePicker,
|
|
4475
|
+
React__default.createElement(DatePicker, { id: String(toProperties.label), fullWidth: true, maxDate: maxDate, ...commonProperties, ...toProperties, value: to, minDate: from?.add(1, 'day') || undefined, onChange: setTo }))));
|
|
4673
4476
|
};
|
|
4674
4477
|
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
}
|
|
4683
|
-
var renderHorizontal = function (infoFields) { return (React.createElement(Box, { display: "flex", flexWrap: "wrap", justifyContent: "space-between" }, infoFields.map(renderField))); };
|
|
4684
|
-
var renderVertical = function (infoFields) {
|
|
4685
|
-
return infoFields.map(renderField);
|
|
4686
|
-
};
|
|
4687
|
-
var InfoContainer = function (props) { return (React.createElement(Box, { style: __assign({ paddingTop: 20 }, props.style) },
|
|
4478
|
+
const renderField = ({ key, value }) => (React.createElement(Box, { key: key, display: "flex", marginRight: "20px" },
|
|
4479
|
+
React.createElement(Typography, { variant: "body1", style: { color: Colors.grey, marginRight: '2rem' } },
|
|
4480
|
+
key,
|
|
4481
|
+
":"),
|
|
4482
|
+
React.createElement(Typography, { variant: "body1" }, value)));
|
|
4483
|
+
const renderHorizontal = (infoFields) => (React.createElement(Box, { display: "flex", flexWrap: "wrap", justifyContent: "space-between" }, infoFields.map(renderField)));
|
|
4484
|
+
const renderVertical = (infoFields) => infoFields.map(renderField);
|
|
4485
|
+
const InfoContainer = (props) => (React.createElement(Box, { style: { paddingTop: 20, ...props.style } },
|
|
4688
4486
|
props.header && (React.createElement(Typography, { variant: "h6", style: { paddingBottom: 10 } }, props.header)),
|
|
4689
4487
|
props.inline
|
|
4690
4488
|
? renderHorizontal(props.infoFields)
|
|
4691
|
-
: renderVertical(props.infoFields)));
|
|
4489
|
+
: renderVertical(props.infoFields)));
|
|
4692
4490
|
|
|
4693
|
-
|
|
4491
|
+
const textStyles = {
|
|
4694
4492
|
userSelect: 'none',
|
|
4695
4493
|
whiteSpace: 'nowrap',
|
|
4696
4494
|
outline: 'none',
|
|
4697
4495
|
fontSize: 16,
|
|
4698
4496
|
};
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4497
|
+
const useStyles$6 = makeStyles()(({ palette }, _props, classes) => {
|
|
4498
|
+
const text = {
|
|
4499
|
+
...textStyles,
|
|
4500
|
+
color: 'inherit',
|
|
4501
|
+
fontWeight: 400,
|
|
4502
|
+
};
|
|
4703
4503
|
return {
|
|
4704
4504
|
container: {
|
|
4705
4505
|
padding: 10,
|
|
4706
4506
|
display: 'flex',
|
|
4707
4507
|
flexDirection: 'column',
|
|
4708
4508
|
},
|
|
4709
|
-
item:
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
}
|
|
4509
|
+
item: {
|
|
4510
|
+
cursor: 'pointer',
|
|
4511
|
+
color: palette.text.disabled,
|
|
4512
|
+
outline: 'none',
|
|
4513
|
+
'&:hover': {
|
|
4514
|
+
color: palette.primary.main,
|
|
4716
4515
|
},
|
|
4717
|
-
|
|
4516
|
+
[`&:focus .${classes.text}`]: {
|
|
4718
4517
|
color: palette.primary.main,
|
|
4719
4518
|
outline: 'auto',
|
|
4720
4519
|
},
|
|
4721
|
-
|
|
4722
|
-
text
|
|
4723
|
-
selected:
|
|
4520
|
+
},
|
|
4521
|
+
text,
|
|
4522
|
+
selected: {
|
|
4523
|
+
...textStyles,
|
|
4524
|
+
color: palette.primary.main,
|
|
4525
|
+
fontWeight: 500,
|
|
4526
|
+
},
|
|
4724
4527
|
icon: {
|
|
4725
4528
|
minWidth: 'fit-content',
|
|
4726
4529
|
marginRight: 2,
|
|
@@ -4728,44 +4531,39 @@ var useStyles$6 = makeStyles()(function (_a, _props, classes) {
|
|
|
4728
4531
|
};
|
|
4729
4532
|
});
|
|
4730
4533
|
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
React.useEffect(function () {
|
|
4736
|
-
var _a;
|
|
4534
|
+
const Sidebar = ({ pages, onPageClick, currentPageId }) => {
|
|
4535
|
+
const [expanded, setExpanded] = React.useState([]);
|
|
4536
|
+
const { classes } = useStyles$6();
|
|
4537
|
+
React.useEffect(() => {
|
|
4737
4538
|
if (currentPageId) {
|
|
4738
|
-
|
|
4739
|
-
!!pageId && setExpanded(
|
|
4539
|
+
const pageId = pages.find((p) => p.children?.some((c) => c.id === currentPageId))?.id;
|
|
4540
|
+
!!pageId && setExpanded([...expanded, pageId]);
|
|
4740
4541
|
}
|
|
4741
4542
|
}, [pages]);
|
|
4742
|
-
|
|
4543
|
+
const toggleExpand = (id) => {
|
|
4743
4544
|
if (expanded.includes(id)) {
|
|
4744
|
-
setExpanded(
|
|
4545
|
+
setExpanded([...expanded.filter((_id) => _id !== id)]);
|
|
4745
4546
|
}
|
|
4746
4547
|
else {
|
|
4747
|
-
setExpanded(
|
|
4548
|
+
setExpanded([...expanded, id]);
|
|
4748
4549
|
}
|
|
4749
4550
|
};
|
|
4750
|
-
|
|
4551
|
+
const handleClick = (page) => {
|
|
4751
4552
|
page.children ? toggleExpand(page.id) : onPageClick(page);
|
|
4752
4553
|
};
|
|
4753
|
-
|
|
4554
|
+
const renderItem = (page) => (React.createElement(React.Fragment, null,
|
|
4754
4555
|
page.linkIcon && (React.createElement(ListItemIcon, { className: classes.icon }, page.linkIcon)),
|
|
4755
|
-
React.createElement(ListItemText$1, { sx: { outline: 'none !important' }, tabIndex: -1, disableTypography: true, primary: page.label, className: page.id === currentPageId ? classes.selected : classes.text })));
|
|
4556
|
+
React.createElement(ListItemText$1, { sx: { outline: 'none !important' }, tabIndex: -1, disableTypography: true, primary: page.label, className: page.id === currentPageId ? classes.selected : classes.text })));
|
|
4756
4557
|
return (React.createElement(Box$1, { className: classes.container },
|
|
4757
|
-
React.createElement(List$1, null, pages.map(
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
React.createElement(Collapse, { in: expanded.includes(page.id), timeout: "auto", unmountOnExit: true },
|
|
4764
|
-
React.createElement(List$1, { disablePadding: true }, (_a = page.children) === null || _a === void 0 ? void 0 : _a.map(function (child) { return (React.createElement(ListItem$1, { key: child.id, style: { paddingLeft: '30px' }, tabIndex: 0, className: classes.item, onClick: function () { return handleClick(child); }, onKeyPress: keyboard.onActivation(function () { return handleClick(child); }) }, renderItem(child))); })))));
|
|
4765
|
-
}))));
|
|
4558
|
+
React.createElement(List$1, null, pages.map((page) => (React.createElement("div", { key: page.id },
|
|
4559
|
+
React.createElement(ListItem$1, { key: page.id, tabIndex: 0, className: classes.item, onClick: () => handleClick(page), onKeyPress: keyboard.onActivation(() => handleClick(page)) },
|
|
4560
|
+
renderItem(page),
|
|
4561
|
+
page.children ? (expanded.includes(page.id) ? (React.createElement(ExpandMore, null)) : (React.createElement(ExpandLess, null))) : null),
|
|
4562
|
+
React.createElement(Collapse, { in: expanded.includes(page.id), timeout: "auto", unmountOnExit: true },
|
|
4563
|
+
React.createElement(List$1, { disablePadding: true }, page.children?.map((child) => (React.createElement(ListItem$1, { key: child.id, style: { paddingLeft: '30px' }, tabIndex: 0, className: classes.item, onClick: () => handleClick(child), onKeyPress: keyboard.onActivation(() => handleClick(child)) }, renderItem(child))))))))))));
|
|
4766
4564
|
};
|
|
4767
4565
|
|
|
4768
|
-
var useStyles$5 = makeStyles()(
|
|
4566
|
+
var useStyles$5 = makeStyles()(() => ({
|
|
4769
4567
|
message: {
|
|
4770
4568
|
overflowWrap: 'break-word',
|
|
4771
4569
|
backgroundColor: '#f8e9d6',
|
|
@@ -4802,17 +4600,16 @@ var useStyles$5 = makeStyles()(function () { return ({
|
|
|
4802
4600
|
alignSelf: 'center',
|
|
4803
4601
|
marginLeft: 5,
|
|
4804
4602
|
},
|
|
4805
|
-
})
|
|
4603
|
+
}));
|
|
4806
4604
|
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
var classes = useStyles$5().classes;
|
|
4605
|
+
const ServiceMessage = ({ id, message, isPublic, onDismiss }) => {
|
|
4606
|
+
const { classes } = useStyles$5();
|
|
4810
4607
|
return (React.createElement(Box, { className: classes.message },
|
|
4811
4608
|
React.createElement(Typography, { className: classes.messageType },
|
|
4812
4609
|
React.createElement(Warning, { className: classes.warning }),
|
|
4813
4610
|
"Driftsmelding"),
|
|
4814
4611
|
React.createElement(Typography, { className: classes.messageText }, message),
|
|
4815
|
-
!isPublic && onDismiss && (React.createElement(IconButton, { className: classes.button, onClick:
|
|
4612
|
+
!isPublic && onDismiss && (React.createElement(IconButton, { className: classes.button, onClick: () => onDismiss(id), size: "large" },
|
|
4816
4613
|
React.createElement(Close, { className: classes.close })))));
|
|
4817
4614
|
};
|
|
4818
4615
|
|
|
@@ -13609,128 +13406,110 @@ var ConnectedDroppable = connect(makeMapStateToProps$1, mapDispatchToProps$1, nu
|
|
|
13609
13406
|
})(Droppable);
|
|
13610
13407
|
ConnectedDroppable.defaultProps = defaultProps;
|
|
13611
13408
|
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
el.style.width =
|
|
13615
|
-
el.style.height =
|
|
13409
|
+
const setDimensions = (el) => {
|
|
13410
|
+
const { width, height } = el.getBoundingClientRect();
|
|
13411
|
+
el.style.width = `${width}px`;
|
|
13412
|
+
el.style.height = `${height}px`;
|
|
13616
13413
|
};
|
|
13617
|
-
|
|
13414
|
+
const clearDimensions = (el) => {
|
|
13618
13415
|
el.style.removeProperty('height');
|
|
13619
13416
|
el.style.removeProperty('width');
|
|
13620
13417
|
};
|
|
13621
|
-
function SortableTableCell(
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
useMemo$1(function () {
|
|
13418
|
+
function SortableTableCell({ locked, children, ...props }) {
|
|
13419
|
+
const ref = useRef();
|
|
13420
|
+
useMemo$1(() => {
|
|
13625
13421
|
if (ref.current) {
|
|
13626
13422
|
locked ? setDimensions(ref.current) : clearDimensions(ref.current);
|
|
13627
13423
|
}
|
|
13628
13424
|
}, [locked]);
|
|
13629
|
-
return (React__default.createElement(TableCell$1,
|
|
13425
|
+
return (React__default.createElement(TableCell$1, { ref: ref, ...props }, children));
|
|
13630
13426
|
}
|
|
13631
13427
|
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
});
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
var renderRow = useCallback$1(function (isDragging) {
|
|
13652
|
-
return cells.map(function (_a, index) {
|
|
13653
|
-
var value = _a.value, properties = _a.properties;
|
|
13654
|
-
return (React__default.createElement(SortableTableCell, __assign({ key: "dragable-".concat(id, "-").concat(index), locked: isDragging }, properties), value));
|
|
13655
|
-
});
|
|
13656
|
-
}, [cells, id]);
|
|
13657
|
-
return (React__default.createElement(PublicDraggable, { draggableId: "dragable-".concat(id), index: index, isDragDisabled: disabled }, function (provided, _a) {
|
|
13658
|
-
var isDragging = _a.isDragging;
|
|
13659
|
-
var classes = useStyles$4({ isDragging: isDragging }).classes;
|
|
13660
|
-
return (React__default.createElement(TableRow$1, __assign({ className: classes.row, ref: provided.innerRef }, provided.draggableProps),
|
|
13661
|
-
React__default.createElement(TableCell$1, __assign({ style: { width: '45px', padding: '5px 10px' } }, provided.dragHandleProps),
|
|
13428
|
+
const useStyles$4 = makeStyles()(({ palette, transitions }, { isDragging }) => ({
|
|
13429
|
+
row: {
|
|
13430
|
+
transition: transitions.create(['background-color'], {
|
|
13431
|
+
duration: transitions.duration.shorter,
|
|
13432
|
+
easing: transitions.easing.easeOut,
|
|
13433
|
+
}),
|
|
13434
|
+
backgroundColor: isDragging
|
|
13435
|
+
? `var(--tablecell__background--drag, ${hex2rgba(palette.primary.main, 0.25)})`
|
|
13436
|
+
: 'var(--tablecell__background)',
|
|
13437
|
+
},
|
|
13438
|
+
}));
|
|
13439
|
+
|
|
13440
|
+
function SortableTableRow({ item, id, index, render, disabled, }) {
|
|
13441
|
+
const cells = useMemo$1(() => render(item), [item, render]);
|
|
13442
|
+
const renderRow = useCallback$1((isDragging) => cells.map(({ value, properties }, index) => (React__default.createElement(SortableTableCell, { key: `dragable-${id}-${index}`, locked: isDragging, ...properties }, value))), [cells, id]);
|
|
13443
|
+
return (React__default.createElement(PublicDraggable, { draggableId: `dragable-${id}`, index: index, isDragDisabled: disabled }, (provided, { isDragging }) => {
|
|
13444
|
+
const { classes } = useStyles$4({ isDragging: isDragging });
|
|
13445
|
+
return (React__default.createElement(TableRow$1, { className: classes.row, ref: provided.innerRef, ...provided.draggableProps },
|
|
13446
|
+
React__default.createElement(TableCell$1, { style: { width: '45px', padding: '5px 10px' }, ...provided.dragHandleProps },
|
|
13662
13447
|
React__default.createElement(DragIndicator, null)),
|
|
13663
13448
|
renderRow(isDragging)));
|
|
13664
13449
|
}));
|
|
13665
13450
|
}
|
|
13666
13451
|
|
|
13667
13452
|
function reorder(list, startIndex, endIndex) {
|
|
13668
|
-
|
|
13453
|
+
const [removed] = list.splice(startIndex, 1);
|
|
13669
13454
|
list.splice(endIndex, 0, removed);
|
|
13670
13455
|
return list;
|
|
13671
13456
|
}
|
|
13672
13457
|
function castCellNode(value) {
|
|
13673
13458
|
return typeof value === 'object' && value.value !== undefined
|
|
13674
13459
|
? value
|
|
13675
|
-
: { value
|
|
13460
|
+
: { value };
|
|
13676
13461
|
}
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
useMemo$1(function () {
|
|
13462
|
+
const SortableTable = ({ columns, items, identify, headerValue, cellValue, disabled, onChange, }) => {
|
|
13463
|
+
const [records, setRecords] = useState(items);
|
|
13464
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
13465
|
+
useMemo$1(() => {
|
|
13682
13466
|
return setRecords(items);
|
|
13683
13467
|
}, [items]);
|
|
13684
|
-
|
|
13468
|
+
const onDragStart = () => {
|
|
13685
13469
|
setIsDragging(true);
|
|
13686
13470
|
};
|
|
13687
|
-
|
|
13471
|
+
const onDragEnd = (result) => {
|
|
13688
13472
|
setIsDragging(false);
|
|
13689
13473
|
if (result.destination) {
|
|
13690
|
-
|
|
13474
|
+
const newOrder = reorder(records, result.source.index, result.destination.index);
|
|
13691
13475
|
setRecords(newOrder);
|
|
13692
13476
|
onChange &&
|
|
13693
|
-
onChange(newOrder.map(
|
|
13477
|
+
onChange(newOrder.map((record, index) => ({
|
|
13694
13478
|
id: identify(record),
|
|
13695
|
-
index
|
|
13696
|
-
})
|
|
13479
|
+
index,
|
|
13480
|
+
})));
|
|
13697
13481
|
}
|
|
13698
13482
|
};
|
|
13699
|
-
|
|
13700
|
-
return columns.map(
|
|
13701
|
-
return castCellNode(headerValue ? headerValue(column) : column);
|
|
13702
|
-
});
|
|
13483
|
+
const headers = useMemo$1(() => {
|
|
13484
|
+
return columns.map((column) => castCellNode(headerValue ? headerValue(column) : column));
|
|
13703
13485
|
}, [columns, headerValue]);
|
|
13704
|
-
|
|
13486
|
+
const getCellValue = useCallback$1((column, item) => {
|
|
13705
13487
|
return castCellNode(cellValue ? cellValue(column, item) : item[column]);
|
|
13706
13488
|
}, [cellValue]);
|
|
13707
|
-
|
|
13708
|
-
return columns.map(function (column) { return getCellValue(column, item); });
|
|
13709
|
-
}, [columns, getCellValue]);
|
|
13489
|
+
const render = useCallback$1((item) => columns.map((column) => getCellValue(column, item)), [columns, getCellValue]);
|
|
13710
13490
|
return (React__default.createElement(Table$1, null,
|
|
13711
13491
|
React__default.createElement(TableHead, null,
|
|
13712
13492
|
React__default.createElement(TableRow, null,
|
|
13713
13493
|
React__default.createElement(SortableTableCell, { locked: isDragging }),
|
|
13714
|
-
headers.map(
|
|
13715
|
-
|
|
13716
|
-
return (React__default.createElement(SortableTableCell, __assign({ key: "header-".concat(index), locked: isDragging }, properties), value));
|
|
13494
|
+
headers.map(({ value, properties }, index) => {
|
|
13495
|
+
return (React__default.createElement(SortableTableCell, { key: `header-${index}`, locked: isDragging, ...properties }, value));
|
|
13717
13496
|
}))),
|
|
13718
13497
|
React__default.createElement(DragDropContext, { onDragEnd: onDragEnd, onBeforeDragStart: onDragStart },
|
|
13719
|
-
React__default.createElement(ConnectedDroppable, { droppableId: "droppable", direction: "vertical" },
|
|
13720
|
-
records.map(
|
|
13721
|
-
|
|
13498
|
+
React__default.createElement(ConnectedDroppable, { droppableId: "droppable", direction: "vertical" }, (provided) => (React__default.createElement(TableBody$1, { ref: provided.innerRef, ...provided.droppableProps },
|
|
13499
|
+
records.map((item, index) => {
|
|
13500
|
+
const props = {
|
|
13722
13501
|
id: identify(item),
|
|
13723
|
-
item
|
|
13724
|
-
index
|
|
13725
|
-
render
|
|
13726
|
-
disabled
|
|
13502
|
+
item,
|
|
13503
|
+
index,
|
|
13504
|
+
render,
|
|
13505
|
+
disabled,
|
|
13727
13506
|
};
|
|
13728
|
-
return (React__default.createElement(SortableTableRow,
|
|
13507
|
+
return (React__default.createElement(SortableTableRow, { key: `item-${props.id}`, ...props }));
|
|
13729
13508
|
}),
|
|
13730
|
-
provided.placeholder))
|
|
13509
|
+
provided.placeholder))))));
|
|
13731
13510
|
};
|
|
13732
13511
|
|
|
13733
|
-
|
|
13512
|
+
const EditorContext = createContext({});
|
|
13734
13513
|
|
|
13735
13514
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
13736
13515
|
|
|
@@ -20395,58 +20174,52 @@ function stateFromHTML(html, options) {
|
|
|
20395
20174
|
return stateFromElement(element, otherOptions);
|
|
20396
20175
|
}
|
|
20397
20176
|
|
|
20398
|
-
|
|
20399
|
-
|
|
20177
|
+
const createState = (content, decorators) => {
|
|
20178
|
+
const decorator = decorators ? new CompositeDecorator(decorators) : undefined;
|
|
20400
20179
|
if (content) {
|
|
20401
|
-
|
|
20180
|
+
const state = stateFromHTML(content);
|
|
20402
20181
|
return EditorState.createWithContent(state, decorator);
|
|
20403
20182
|
}
|
|
20404
20183
|
return EditorState.createEmpty(decorator);
|
|
20405
20184
|
};
|
|
20406
|
-
|
|
20407
|
-
|
|
20408
|
-
|
|
20409
|
-
|
|
20410
|
-
|
|
20411
|
-
|
|
20412
|
-
|
|
20413
|
-
|
|
20414
|
-
var html = content.getPlainText().trim().length
|
|
20185
|
+
const convert2html = (content, options = {
|
|
20186
|
+
inlineStyles: {
|
|
20187
|
+
BOLD: { element: 'strong' },
|
|
20188
|
+
ITALIC: { element: 'i' },
|
|
20189
|
+
UNSTYLED: { element: 'p' },
|
|
20190
|
+
},
|
|
20191
|
+
}) => {
|
|
20192
|
+
const html = content.getPlainText().trim().length
|
|
20415
20193
|
? stateToHTML(content, options)
|
|
20416
20194
|
: '';
|
|
20417
20195
|
return html; //.replace(/ /, ' ');
|
|
20418
20196
|
};
|
|
20419
|
-
|
|
20420
|
-
|
|
20421
|
-
};
|
|
20422
|
-
var parseContentState = function (state) { return ({
|
|
20197
|
+
const convert2txt = (content) => content.getPlainText();
|
|
20198
|
+
const parseContentState = (state) => ({
|
|
20423
20199
|
txt: convert2txt(state).trim(),
|
|
20424
20200
|
html: convert2html(state),
|
|
20425
|
-
});
|
|
20426
|
-
|
|
20427
|
-
|
|
20428
|
-
};
|
|
20429
|
-
var UpdateStyle = function (state, style) { return RichUtils.toggleInlineStyle(state, style); };
|
|
20201
|
+
});
|
|
20202
|
+
const parseContent = (content, decorators) => parseContentState(createState(content, decorators).getCurrentContent());
|
|
20203
|
+
const UpdateStyle = (state, style) => RichUtils.toggleInlineStyle(state, style);
|
|
20430
20204
|
|
|
20431
|
-
|
|
20432
|
-
|
|
20433
|
-
|
|
20434
|
-
|
|
20435
|
-
useMemo$1(function () {
|
|
20205
|
+
const Provider = ({ html, decorators, children, }) => {
|
|
20206
|
+
const [state, setState] = useState(createState('', decorators));
|
|
20207
|
+
const [selection, setSelection] = useState();
|
|
20208
|
+
useMemo$1(() => {
|
|
20436
20209
|
console.debug('creating new state for editor', html);
|
|
20437
20210
|
setState(createState(html, decorators));
|
|
20438
20211
|
}, [html, decorators]);
|
|
20439
20212
|
return (React__default.createElement(EditorContext.Provider, { value: {
|
|
20440
|
-
state
|
|
20441
|
-
setState
|
|
20442
|
-
selection
|
|
20443
|
-
setSelection
|
|
20213
|
+
state,
|
|
20214
|
+
setState,
|
|
20215
|
+
selection,
|
|
20216
|
+
setSelection,
|
|
20444
20217
|
} }, children));
|
|
20445
20218
|
};
|
|
20446
20219
|
|
|
20447
20220
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
20448
20221
|
|
|
20449
|
-
|
|
20222
|
+
const useButtonStyles = makeStyles()({
|
|
20450
20223
|
btn: {
|
|
20451
20224
|
backgroundColor: 'white',
|
|
20452
20225
|
'&:hover': {
|
|
@@ -20461,121 +20234,114 @@ var useButtonStyles = makeStyles()({
|
|
|
20461
20234
|
},
|
|
20462
20235
|
});
|
|
20463
20236
|
|
|
20464
|
-
|
|
20465
|
-
|
|
20466
|
-
|
|
20467
|
-
|
|
20468
|
-
|
|
20469
|
-
|
|
20470
|
-
|
|
20471
|
-
|
|
20472
|
-
|
|
20473
|
-
|
|
20474
|
-
|
|
20475
|
-
|
|
20476
|
-
|
|
20477
|
-
|
|
20478
|
-
|
|
20479
|
-
|
|
20480
|
-
|
|
20481
|
-
|
|
20482
|
-
|
|
20483
|
-
|
|
20484
|
-
|
|
20237
|
+
const useEditorStyles = makeStyles()((theme, { hasFocus, hasContent, readOnly }) => ({
|
|
20238
|
+
root: {
|
|
20239
|
+
position: 'relative',
|
|
20240
|
+
display: 'inline-flex',
|
|
20241
|
+
flexFlow: 'column',
|
|
20242
|
+
minWidth: '100%', // TODO
|
|
20243
|
+
},
|
|
20244
|
+
legend: {
|
|
20245
|
+
position: 'absolute',
|
|
20246
|
+
top: -5,
|
|
20247
|
+
left: 0,
|
|
20248
|
+
right: 0,
|
|
20249
|
+
bottom: 0,
|
|
20250
|
+
lineHeight: '11px',
|
|
20251
|
+
zIndex: hasFocus ? 0 : 1,
|
|
20252
|
+
paddingLeft: 10,
|
|
20253
|
+
borderStyle: 'solid',
|
|
20254
|
+
borderRadius: theme.shape.borderRadius,
|
|
20255
|
+
borderWidth: hasFocus ? 2 : 1,
|
|
20256
|
+
borderColor: hasFocus
|
|
20257
|
+
? theme.palette.primary.main
|
|
20258
|
+
: hex2rgba('#000', 0.23),
|
|
20259
|
+
'&:hover': {
|
|
20485
20260
|
borderColor: hasFocus
|
|
20486
20261
|
? theme.palette.primary.main
|
|
20487
|
-
:
|
|
20488
|
-
'&:hover': {
|
|
20489
|
-
borderColor: hasFocus
|
|
20490
|
-
? theme.palette.primary.main
|
|
20491
|
-
: theme.palette.text.primary,
|
|
20492
|
-
},
|
|
20493
|
-
transition: theme.transitions.create(['border-color'], {
|
|
20494
|
-
duration: theme.transitions.duration.shorter,
|
|
20495
|
-
easing: theme.transitions.easing.easeOut,
|
|
20496
|
-
}),
|
|
20262
|
+
: theme.palette.text.primary,
|
|
20497
20263
|
},
|
|
20498
|
-
|
|
20499
|
-
|
|
20500
|
-
|
|
20501
|
-
|
|
20502
|
-
|
|
20503
|
-
|
|
20504
|
-
|
|
20505
|
-
|
|
20506
|
-
|
|
20507
|
-
|
|
20508
|
-
|
|
20509
|
-
left: 0,
|
|
20510
|
-
zIndex: 1,
|
|
20511
|
-
transform: hasFocus || hasContent
|
|
20512
|
-
? 'translate(6px, -14px) scale(0.75)'
|
|
20513
|
-
: 'translate(6px, 12px) scale(1)',
|
|
20514
|
-
transformOrigin: 'top left',
|
|
20515
|
-
transition: theme.transitions.create(['color', 'transform'], {
|
|
20516
|
-
duration: theme.transitions.duration.shorter,
|
|
20517
|
-
easing: theme.transitions.easing.easeOut,
|
|
20518
|
-
}),
|
|
20519
|
-
color: hasFocus
|
|
20520
|
-
? theme.palette.primary[theme.palette.mode === 'light' ? 'dark' : 'light']
|
|
20521
|
-
: theme.palette.text.secondary,
|
|
20522
|
-
fontSize: '1.1428571428571428rem',
|
|
20523
|
-
// hack @todo when time
|
|
20524
|
-
backgroundColor: 'white',
|
|
20525
|
-
padding: '2px 10px',
|
|
20526
|
-
},
|
|
20527
|
-
helpertext: {
|
|
20528
|
-
margin: 0,
|
|
20529
|
-
opacity: hasFocus ? 1 : 0,
|
|
20530
|
-
transition: theme.transitions.create(['opacity'], {
|
|
20531
|
-
duration: theme.transitions.duration.shorter,
|
|
20532
|
-
easing: theme.transitions.easing.easeOut,
|
|
20533
|
-
}),
|
|
20534
|
-
fontSize: 'small',
|
|
20535
|
-
// hack @todo when time
|
|
20536
|
-
backgroundColor: 'white',
|
|
20537
|
-
padding: '2px 10px',
|
|
20538
|
-
},
|
|
20539
|
-
charcount: {
|
|
20540
|
-
margin: 0,
|
|
20541
|
-
transition: theme.transitions.create(['opacity'], {
|
|
20542
|
-
duration: theme.transitions.duration.shorter,
|
|
20543
|
-
easing: theme.transitions.easing.easeOut,
|
|
20544
|
-
}),
|
|
20545
|
-
fontSize: 'small',
|
|
20546
|
-
// hack @todo when time
|
|
20547
|
-
backgroundColor: 'white',
|
|
20548
|
-
padding: '2px 10px',
|
|
20264
|
+
transition: theme.transitions.create(['border-color'], {
|
|
20265
|
+
duration: theme.transitions.duration.shorter,
|
|
20266
|
+
easing: theme.transitions.easing.easeOut,
|
|
20267
|
+
}),
|
|
20268
|
+
},
|
|
20269
|
+
editor: {
|
|
20270
|
+
padding: '.8rem 1rem',
|
|
20271
|
+
position: 'relative',
|
|
20272
|
+
zIndex: hasFocus || readOnly ? 1 : 0,
|
|
20273
|
+
'& .unstyled': {
|
|
20274
|
+
margin: '.5rem 0',
|
|
20549
20275
|
},
|
|
20550
|
-
}
|
|
20551
|
-
|
|
20276
|
+
},
|
|
20277
|
+
label: {
|
|
20278
|
+
position: 'absolute',
|
|
20279
|
+
top: 0,
|
|
20280
|
+
left: 0,
|
|
20281
|
+
zIndex: 1,
|
|
20282
|
+
transform: hasFocus || hasContent
|
|
20283
|
+
? 'translate(6px, -14px) scale(0.75)'
|
|
20284
|
+
: 'translate(6px, 12px) scale(1)',
|
|
20285
|
+
transformOrigin: 'top left',
|
|
20286
|
+
transition: theme.transitions.create(['color', 'transform'], {
|
|
20287
|
+
duration: theme.transitions.duration.shorter,
|
|
20288
|
+
easing: theme.transitions.easing.easeOut,
|
|
20289
|
+
}),
|
|
20290
|
+
color: hasFocus
|
|
20291
|
+
? theme.palette.primary[theme.palette.mode === 'light' ? 'dark' : 'light']
|
|
20292
|
+
: theme.palette.text.secondary,
|
|
20293
|
+
fontSize: '1.1428571428571428rem',
|
|
20294
|
+
// hack @todo when time
|
|
20295
|
+
backgroundColor: 'white',
|
|
20296
|
+
padding: '2px 10px',
|
|
20297
|
+
},
|
|
20298
|
+
helpertext: {
|
|
20299
|
+
margin: 0,
|
|
20300
|
+
opacity: hasFocus ? 1 : 0,
|
|
20301
|
+
transition: theme.transitions.create(['opacity'], {
|
|
20302
|
+
duration: theme.transitions.duration.shorter,
|
|
20303
|
+
easing: theme.transitions.easing.easeOut,
|
|
20304
|
+
}),
|
|
20305
|
+
fontSize: 'small',
|
|
20306
|
+
// hack @todo when time
|
|
20307
|
+
backgroundColor: 'white',
|
|
20308
|
+
padding: '2px 10px',
|
|
20309
|
+
},
|
|
20310
|
+
charcount: {
|
|
20311
|
+
margin: 0,
|
|
20312
|
+
transition: theme.transitions.create(['opacity'], {
|
|
20313
|
+
duration: theme.transitions.duration.shorter,
|
|
20314
|
+
easing: theme.transitions.easing.easeOut,
|
|
20315
|
+
}),
|
|
20316
|
+
fontSize: 'small',
|
|
20317
|
+
// hack @todo when time
|
|
20318
|
+
backgroundColor: 'white',
|
|
20319
|
+
padding: '2px 10px',
|
|
20320
|
+
},
|
|
20321
|
+
}));
|
|
20552
20322
|
|
|
20553
|
-
|
|
20554
|
-
|
|
20555
|
-
|
|
20556
|
-
|
|
20557
|
-
|
|
20558
|
-
|
|
20559
|
-
|
|
20560
|
-
|
|
20561
|
-
|
|
20562
|
-
|
|
20563
|
-
|
|
20564
|
-
},
|
|
20565
|
-
});
|
|
20566
|
-
});
|
|
20323
|
+
const useFloatingToolbarStyles = makeStyles()((_theme, { isVisible }) => ({
|
|
20324
|
+
root: {
|
|
20325
|
+
position: 'absolute',
|
|
20326
|
+
zIndex: 9,
|
|
20327
|
+
transition: 'transform 0.15s cubic-bezier(.3,1.2,.2,1)',
|
|
20328
|
+
visibility: isVisible ? 'visible' : 'hidden',
|
|
20329
|
+
transform: isVisible
|
|
20330
|
+
? 'translate(-50%) scale(1)'
|
|
20331
|
+
: 'translate(-50%) scale(0)',
|
|
20332
|
+
},
|
|
20333
|
+
}));
|
|
20567
20334
|
|
|
20568
|
-
|
|
20569
|
-
|
|
20570
|
-
|
|
20571
|
-
|
|
20572
|
-
var onClick = function (event) {
|
|
20335
|
+
const InlineButton = ({ type, editor: _editor, children, ...props }) => {
|
|
20336
|
+
const { classes } = useButtonStyles();
|
|
20337
|
+
const { state, setState } = useContext(EditorContext);
|
|
20338
|
+
const onClick = (event) => {
|
|
20573
20339
|
event.preventDefault();
|
|
20574
|
-
|
|
20340
|
+
const e = event;
|
|
20575
20341
|
setState(UpdateStyle(state, e.currentTarget.value));
|
|
20576
20342
|
};
|
|
20577
|
-
|
|
20578
|
-
return (React__default.createElement(ToggleButton,
|
|
20343
|
+
const selected = state.getCurrentInlineStyle().has(type);
|
|
20344
|
+
return (React__default.createElement(ToggleButton, { ...props, classes: { root: classes.btn, selected: classes.btnSelected }, selected: selected, onClick: onClick, value: type, size: "small" }, children));
|
|
20579
20345
|
};
|
|
20580
20346
|
|
|
20581
20347
|
var ButtonType;
|
|
@@ -20583,7 +20349,7 @@ var ButtonType;
|
|
|
20583
20349
|
ButtonType["bold"] = "BOLD";
|
|
20584
20350
|
ButtonType["italic"] = "ITALIC";
|
|
20585
20351
|
})(ButtonType || (ButtonType = {}));
|
|
20586
|
-
|
|
20352
|
+
const createButton = (style) => {
|
|
20587
20353
|
switch (style) {
|
|
20588
20354
|
case 'bold':
|
|
20589
20355
|
return {
|
|
@@ -20598,117 +20364,109 @@ var createButton = function (style) {
|
|
|
20598
20364
|
}
|
|
20599
20365
|
};
|
|
20600
20366
|
|
|
20601
|
-
|
|
20602
|
-
|
|
20603
|
-
|
|
20604
|
-
|
|
20605
|
-
|
|
20606
|
-
var classes = useFloatingToolbarStyles({ isVisible: isVisible }).classes;
|
|
20367
|
+
const FloatingToolbar = ({ editor, buttons }) => {
|
|
20368
|
+
const { selection } = useContext(EditorContext);
|
|
20369
|
+
const [isVisible, setVisibility] = useState(false);
|
|
20370
|
+
const toolbar = useRef();
|
|
20371
|
+
const { classes } = useFloatingToolbarStyles({ isVisible });
|
|
20607
20372
|
// @eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20608
|
-
useEffect(
|
|
20609
|
-
|
|
20610
|
-
var selectionRect = getVisibleSelectionRect(window);
|
|
20373
|
+
useEffect(() => {
|
|
20374
|
+
const selectionRect = getVisibleSelectionRect(window);
|
|
20611
20375
|
if (!selectionRect || !toolbar.current || !editor.current)
|
|
20612
20376
|
return;
|
|
20613
|
-
|
|
20614
|
-
|
|
20615
|
-
|
|
20377
|
+
const editorRoot = editor.current.editorContainer;
|
|
20378
|
+
const editorRootRect = editorRoot.getBoundingClientRect();
|
|
20379
|
+
const position = {
|
|
20616
20380
|
top: editorRoot.offsetTop -
|
|
20617
|
-
|
|
20381
|
+
toolbar?.current?.offsetHeight +
|
|
20618
20382
|
(selectionRect.top - editorRootRect.top) -
|
|
20619
20383
|
5,
|
|
20620
20384
|
left: editorRoot.offsetLeft +
|
|
20621
20385
|
(selectionRect.left - editorRootRect.left) +
|
|
20622
20386
|
selectionRect.width / 2,
|
|
20623
20387
|
};
|
|
20624
|
-
toolbar.current.style.top =
|
|
20625
|
-
toolbar.current.style.left =
|
|
20388
|
+
toolbar.current.style.top = `${position.top}px`;
|
|
20389
|
+
toolbar.current.style.left = `${position.left}px`;
|
|
20626
20390
|
setVisibility(!!selection && !selection.isCollapsed() && selection.getHasFocus());
|
|
20627
20391
|
});
|
|
20628
20392
|
return (React__default.createElement("div", { ref: toolbar, className: classes.root },
|
|
20629
|
-
React__default.createElement(ToggleButtonGroup, null, buttons.map(
|
|
20630
|
-
var type = _a.type, children = _a.children;
|
|
20631
|
-
return (React__default.createElement(InlineButton, { key: key, type: type, editor: editor }, children));
|
|
20632
|
-
}))));
|
|
20393
|
+
React__default.createElement(ToggleButtonGroup, null, buttons.map(({ type, children }, key) => (React__default.createElement(InlineButton, { key: key, type: type, editor: editor }, children))))));
|
|
20633
20394
|
};
|
|
20634
20395
|
|
|
20635
|
-
|
|
20396
|
+
const customKeyHandler = (setEditorState) => (command, editorState) => {
|
|
20636
20397
|
if (command === 'shift-split-block') {
|
|
20637
|
-
|
|
20398
|
+
const newState = RichUtils.insertSoftNewline(editorState);
|
|
20638
20399
|
setEditorState(newState);
|
|
20639
20400
|
return 'handled';
|
|
20640
20401
|
}
|
|
20641
20402
|
return 'not-handled';
|
|
20642
|
-
};
|
|
20643
|
-
|
|
20644
|
-
if (!allowedStyles || allowedStyles.some(
|
|
20645
|
-
|
|
20403
|
+
};
|
|
20404
|
+
const keyHandler = (setEditorState, allowedStyles) => (command, editorState) => {
|
|
20405
|
+
if (!allowedStyles || allowedStyles.some((s) => s === command)) {
|
|
20406
|
+
const newState = RichUtils.handleKeyCommand(editorState, command);
|
|
20646
20407
|
if (newState) {
|
|
20647
20408
|
setEditorState(newState);
|
|
20648
20409
|
return 'handled';
|
|
20649
20410
|
}
|
|
20650
20411
|
}
|
|
20651
20412
|
return customKeyHandler(setEditorState)(command, editorState);
|
|
20652
|
-
};
|
|
20413
|
+
};
|
|
20653
20414
|
|
|
20654
|
-
|
|
20655
|
-
|
|
20415
|
+
const blockStyleFn = (block) => block.getType();
|
|
20416
|
+
const createDefaultButtons = () => [
|
|
20656
20417
|
createButton('bold'),
|
|
20657
20418
|
createButton('italic'),
|
|
20658
|
-
];
|
|
20659
|
-
|
|
20660
|
-
|
|
20661
|
-
};
|
|
20662
|
-
|
|
20663
|
-
|
|
20664
|
-
|
|
20665
|
-
var ref = useRef();
|
|
20666
|
-
var canStyle = allowedStyles === undefined || allowedStyles.length > 0;
|
|
20667
|
-
var buttons = !allowedStyles
|
|
20419
|
+
];
|
|
20420
|
+
const getCharCount = (editorState) => editorState.getCurrentContent().getPlainText('').length;
|
|
20421
|
+
const EditorComponent = ({ label, classes, autoFocus, helperText, showCharCount, allowedStyles, disableNewlines, onContentChange, Toolbar = FloatingToolbar, blockPasting, lang, ...props }) => {
|
|
20422
|
+
const { state, setState, setSelection } = useContext(EditorContext);
|
|
20423
|
+
const ref = useRef();
|
|
20424
|
+
const canStyle = allowedStyles === undefined || allowedStyles.length > 0;
|
|
20425
|
+
const buttons = !allowedStyles
|
|
20668
20426
|
? createDefaultButtons()
|
|
20669
20427
|
: allowedStyles.map(createButton);
|
|
20670
20428
|
// TODO: make prop
|
|
20671
|
-
|
|
20429
|
+
const handleKeyCommand = canStyle
|
|
20672
20430
|
? keyHandler(setState, allowedStyles)
|
|
20673
20431
|
: customKeyHandler(setState);
|
|
20674
|
-
|
|
20675
|
-
|
|
20432
|
+
const [hasFocus, setFocused] = useState(false);
|
|
20433
|
+
const [charCount, setCharCount] = useState(0);
|
|
20676
20434
|
// defer focus until next tick
|
|
20677
|
-
|
|
20678
|
-
window.requestAnimationFrame(
|
|
20435
|
+
const requestFocus = () => {
|
|
20436
|
+
window.requestAnimationFrame(() => ref.current?.focus());
|
|
20679
20437
|
};
|
|
20680
20438
|
// multiple components might request focus and deligate back focus
|
|
20681
|
-
|
|
20439
|
+
const onBlur = useDebounce(() => ref.current && setFocused(false), {
|
|
20682
20440
|
wait: 150,
|
|
20683
20441
|
});
|
|
20684
|
-
|
|
20442
|
+
const onFocus = () => {
|
|
20685
20443
|
// when editor focused cancel pending defocus
|
|
20686
20444
|
onBlur.cancel();
|
|
20687
20445
|
setFocused(true);
|
|
20688
20446
|
};
|
|
20689
|
-
|
|
20447
|
+
const onChange = (nextState) => {
|
|
20690
20448
|
setState(nextState);
|
|
20691
20449
|
setSelection(nextState.getSelection());
|
|
20692
20450
|
setCharCount(getCharCount(nextState));
|
|
20693
20451
|
};
|
|
20694
|
-
useEffect(
|
|
20452
|
+
useEffect(() => {
|
|
20695
20453
|
autoFocus && ref.current && ref.current.focus();
|
|
20696
20454
|
}, [autoFocus]);
|
|
20697
20455
|
// hacky workaround?
|
|
20698
|
-
|
|
20699
|
-
|
|
20700
|
-
useEffect(
|
|
20456
|
+
const oldContent = useRef(state.getCurrentContent());
|
|
20457
|
+
const currentContent = state.getCurrentContent();
|
|
20458
|
+
useEffect(() => {
|
|
20701
20459
|
if (oldContent.current !== currentContent) {
|
|
20702
20460
|
onContentChange && onContentChange(currentContent);
|
|
20703
20461
|
}
|
|
20704
20462
|
}, [convert2html(currentContent)]);
|
|
20705
|
-
|
|
20706
|
-
|
|
20707
|
-
hasFocus
|
|
20708
|
-
hasContent
|
|
20463
|
+
const hasContent = state.getCurrentContent().hasText();
|
|
20464
|
+
const { classes: styles } = useEditorStyles({
|
|
20465
|
+
hasFocus,
|
|
20466
|
+
hasContent,
|
|
20709
20467
|
readOnly: props.readOnly,
|
|
20710
|
-
})
|
|
20711
|
-
|
|
20468
|
+
});
|
|
20469
|
+
const keyBindingFn = (e) => {
|
|
20712
20470
|
if (disableNewlines && e.key === 'Enter')
|
|
20713
20471
|
return null;
|
|
20714
20472
|
if (e.key === 'Enter' && e.shiftKey) {
|
|
@@ -20718,31 +20476,40 @@ var EditorComponent = function (_a) {
|
|
|
20718
20476
|
return getDefaultKeyBinding(e);
|
|
20719
20477
|
}
|
|
20720
20478
|
};
|
|
20721
|
-
|
|
20479
|
+
const handlePastedText = (text, _html, editorState) => {
|
|
20722
20480
|
if (!blockPasting) {
|
|
20723
20481
|
onChange(EditorState.push(editorState, Modifier.replaceText(editorState.getCurrentContent(), editorState.getSelection(), text.replace(/\n/g, ' ')), 'remove-range'));
|
|
20724
20482
|
}
|
|
20725
20483
|
return 'handled';
|
|
20726
20484
|
};
|
|
20727
|
-
return (React__default.createElement(Box, { className: clsx(styles.root, classes
|
|
20728
|
-
React__default.createElement("legend", { className: clsx(styles.legend, classes
|
|
20485
|
+
return (React__default.createElement(Box, { className: clsx(styles.root, classes?.root), onClick: requestFocus },
|
|
20486
|
+
React__default.createElement("legend", { className: clsx(styles.legend, classes?.legend) },
|
|
20729
20487
|
React__default.createElement("span", { dangerouslySetInnerHTML: { __html: '​' } })),
|
|
20730
|
-
label && (React__default.createElement("label", { className: clsx(styles.label, classes
|
|
20488
|
+
label && (React__default.createElement("label", { className: clsx(styles.label, classes?.label) }, label)),
|
|
20731
20489
|
canStyle && (React__default.createElement(Toolbar, { editor: ref, buttons: buttons })),
|
|
20732
|
-
React__default.createElement(Box, { className: clsx(styles.editor, classes
|
|
20733
|
-
React__default.createElement(Editor,
|
|
20490
|
+
React__default.createElement(Box, { className: clsx(styles.editor, classes?.editor), lang: lang },
|
|
20491
|
+
React__default.createElement(Editor, { ref: ref, ...{
|
|
20492
|
+
editorState: state,
|
|
20493
|
+
onChange,
|
|
20494
|
+
onFocus,
|
|
20495
|
+
onBlur,
|
|
20496
|
+
blockStyleFn,
|
|
20497
|
+
handleKeyCommand,
|
|
20498
|
+
keyBindingFn,
|
|
20499
|
+
handlePastedText,
|
|
20500
|
+
...props,
|
|
20501
|
+
} })),
|
|
20734
20502
|
(showCharCount || helperText) && (React__default.createElement(Box, { margin: ".5rem" },
|
|
20735
|
-
showCharCount && (React__default.createElement(FormHelperText, { className: styles.charcount },
|
|
20503
|
+
showCharCount && (React__default.createElement(FormHelperText, { className: styles.charcount }, `Antall tegn: ${charCount}`)),
|
|
20736
20504
|
helperText && (React__default.createElement(FormHelperText, { className: styles.helpertext }, helperText))))));
|
|
20737
20505
|
};
|
|
20738
20506
|
|
|
20739
|
-
|
|
20740
|
-
|
|
20741
|
-
|
|
20742
|
-
React__default.createElement(EditorComponent, __assign({}, props))));
|
|
20507
|
+
const GrepEditor = ({ html, ...props }) => {
|
|
20508
|
+
return (React__default.createElement(Provider, { ...{ html } },
|
|
20509
|
+
React__default.createElement(EditorComponent, { ...props })));
|
|
20743
20510
|
};
|
|
20744
20511
|
|
|
20745
|
-
|
|
20512
|
+
const dimensions = {
|
|
20746
20513
|
breadcrumbsFontSize: 16,
|
|
20747
20514
|
contentWidth: 1028,
|
|
20748
20515
|
footerHeight: 50,
|
|
@@ -20753,7 +20520,7 @@ var dimensions = {
|
|
|
20753
20520
|
toolbarMenuWidth: 1028,
|
|
20754
20521
|
toolbarMenuHeight: 50,
|
|
20755
20522
|
};
|
|
20756
|
-
|
|
20523
|
+
const ToolbarTitle = styled(NavLink)(() => ({
|
|
20757
20524
|
display: 'flex',
|
|
20758
20525
|
fontSize: '24px',
|
|
20759
20526
|
color: '#303030',
|
|
@@ -20767,102 +20534,84 @@ var ToolbarTitle = styled(NavLink)(function () { return ({
|
|
|
20767
20534
|
outline: 'none',
|
|
20768
20535
|
textDecoration: 'underline',
|
|
20769
20536
|
},
|
|
20770
|
-
})
|
|
20771
|
-
|
|
20537
|
+
}));
|
|
20538
|
+
const EnvironmentTitle = styled('div')(() => ({
|
|
20772
20539
|
color: 'rgba(0, 0, 0, 0.33)',
|
|
20773
20540
|
marginLeft: '17px',
|
|
20774
|
-
})
|
|
20775
|
-
|
|
20776
|
-
|
|
20777
|
-
|
|
20778
|
-
|
|
20779
|
-
|
|
20780
|
-
|
|
20781
|
-
}
|
|
20782
|
-
|
|
20783
|
-
|
|
20784
|
-
|
|
20785
|
-
|
|
20786
|
-
}
|
|
20787
|
-
|
|
20788
|
-
|
|
20789
|
-
|
|
20790
|
-
|
|
20791
|
-
|
|
20792
|
-
|
|
20793
|
-
|
|
20794
|
-
|
|
20795
|
-
|
|
20796
|
-
|
|
20797
|
-
|
|
20798
|
-
|
|
20799
|
-
|
|
20800
|
-
|
|
20801
|
-
|
|
20802
|
-
|
|
20803
|
-
|
|
20804
|
-
|
|
20805
|
-
}
|
|
20806
|
-
|
|
20807
|
-
|
|
20808
|
-
|
|
20809
|
-
maxHeight: "".concat(dimensions.toolbarMenuHeight + dimensions.toolbarHeightMobile, "px"),
|
|
20810
|
-
},
|
|
20811
|
-
_b[theme.breakpoints.up('sm')] = {
|
|
20812
|
-
height: "".concat(dimensions.toolbarMenuHeight + dimensions.toolbarHeight, "px"),
|
|
20813
|
-
minHeight: "".concat(dimensions.toolbarMenuHeight + dimensions.toolbarHeight, "px"),
|
|
20814
|
-
maxHeight: "".concat(dimensions.toolbarMenuHeight + dimensions.toolbarHeight, "px"),
|
|
20815
|
-
},
|
|
20816
|
-
_b);
|
|
20817
|
-
});
|
|
20818
|
-
var ToolbarInner = styled('div')(function (_a) {
|
|
20819
|
-
var _b;
|
|
20820
|
-
var colors = _a.colors, theme = _a.theme;
|
|
20541
|
+
}));
|
|
20542
|
+
const Toolbar = styled('div')(({ theme }) => ({
|
|
20543
|
+
display: 'flex',
|
|
20544
|
+
flexDirection: 'column',
|
|
20545
|
+
[theme.breakpoints.down('sm')]: {
|
|
20546
|
+
height: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeightMobile}px`,
|
|
20547
|
+
minHeight: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeightMobile}px`,
|
|
20548
|
+
maxHeight: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeightMobile}px`,
|
|
20549
|
+
},
|
|
20550
|
+
[theme.breakpoints.up('sm')]: {
|
|
20551
|
+
height: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeight}px`,
|
|
20552
|
+
minHeight: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeight}px`,
|
|
20553
|
+
maxHeight: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeight}px`,
|
|
20554
|
+
},
|
|
20555
|
+
}));
|
|
20556
|
+
const ToolbarFixer = styled('div')(({ theme }) => ({
|
|
20557
|
+
display: 'flex',
|
|
20558
|
+
flexDirection: 'column',
|
|
20559
|
+
position: 'fixed',
|
|
20560
|
+
top: 0,
|
|
20561
|
+
left: 0,
|
|
20562
|
+
right: 0,
|
|
20563
|
+
zIndex: 101,
|
|
20564
|
+
[theme.breakpoints.down('sm')]: {
|
|
20565
|
+
height: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeightMobile}px`,
|
|
20566
|
+
minHeight: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeightMobile}px`,
|
|
20567
|
+
maxHeight: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeightMobile}px`,
|
|
20568
|
+
},
|
|
20569
|
+
[theme.breakpoints.up('sm')]: {
|
|
20570
|
+
height: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeight}px`,
|
|
20571
|
+
minHeight: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeight}px`,
|
|
20572
|
+
maxHeight: `${dimensions.toolbarMenuHeight + dimensions.toolbarHeight}px`,
|
|
20573
|
+
},
|
|
20574
|
+
}));
|
|
20575
|
+
const ToolbarInner = styled('div')(({ colors, theme }) => {
|
|
20821
20576
|
if (!theme) {
|
|
20822
20577
|
return {};
|
|
20823
20578
|
}
|
|
20824
|
-
return
|
|
20825
|
-
|
|
20826
|
-
|
|
20827
|
-
|
|
20828
|
-
|
|
20829
|
-
|
|
20830
|
-
|
|
20831
|
-
|
|
20832
|
-
|
|
20833
|
-
|
|
20834
|
-
minHeight: "".concat(dimensions.toolbarHeightMobile, "px"),
|
|
20579
|
+
return {
|
|
20580
|
+
alignItems: 'center',
|
|
20581
|
+
display: 'flex',
|
|
20582
|
+
margin: '0 auto',
|
|
20583
|
+
width: '100%',
|
|
20584
|
+
padding: 0,
|
|
20585
|
+
backgroundColor: colors.headerBackgroundColor,
|
|
20586
|
+
[theme.breakpoints.down('sm')]: {
|
|
20587
|
+
height: `${dimensions.toolbarHeightMobile}px`,
|
|
20588
|
+
minHeight: `${dimensions.toolbarHeightMobile}px`,
|
|
20835
20589
|
},
|
|
20836
|
-
|
|
20590
|
+
[theme.breakpoints.up('sm')]: {
|
|
20837
20591
|
padding: 0,
|
|
20838
|
-
height:
|
|
20839
|
-
minHeight:
|
|
20592
|
+
height: `${dimensions.toolbarHeight}px`,
|
|
20593
|
+
minHeight: `${dimensions.toolbarHeight}px`,
|
|
20840
20594
|
},
|
|
20841
|
-
|
|
20595
|
+
};
|
|
20842
20596
|
});
|
|
20843
|
-
|
|
20597
|
+
const ToolbarLeft = styled('div')(() => ({
|
|
20844
20598
|
alignItems: 'center',
|
|
20845
20599
|
display: 'flex',
|
|
20846
20600
|
marginLeft: '40px',
|
|
20847
|
-
})
|
|
20848
|
-
|
|
20849
|
-
|
|
20850
|
-
|
|
20851
|
-
|
|
20852
|
-
|
|
20853
|
-
|
|
20854
|
-
|
|
20855
|
-
|
|
20856
|
-
|
|
20857
|
-
|
|
20858
|
-
|
|
20859
|
-
|
|
20860
|
-
|
|
20861
|
-
display: 'flex',
|
|
20862
|
-
},
|
|
20863
|
-
_b);
|
|
20864
|
-
});
|
|
20865
|
-
var UserContainer = styled('div')(function () { return ({
|
|
20601
|
+
}));
|
|
20602
|
+
const ToolbarRight = styled('div')(({ theme }) => ({
|
|
20603
|
+
alignItems: 'center',
|
|
20604
|
+
display: 'flex',
|
|
20605
|
+
marginLeft: 'auto',
|
|
20606
|
+
marginRight: '40px',
|
|
20607
|
+
[theme.breakpoints.down('sm')]: {
|
|
20608
|
+
display: 'none',
|
|
20609
|
+
},
|
|
20610
|
+
[theme.breakpoints.up('sm')]: {
|
|
20611
|
+
display: 'flex',
|
|
20612
|
+
},
|
|
20613
|
+
}));
|
|
20614
|
+
const UserContainer = styled('div')(() => ({
|
|
20866
20615
|
display: 'flex',
|
|
20867
20616
|
flexDirection: 'column',
|
|
20868
20617
|
margin: '0 17px',
|
|
@@ -20870,133 +20619,117 @@ var UserContainer = styled('div')(function () { return ({
|
|
|
20870
20619
|
textTransform: 'none',
|
|
20871
20620
|
fontWeight: '400',
|
|
20872
20621
|
color: 'rgba(0, 0, 0, 0.87)',
|
|
20873
|
-
})
|
|
20874
|
-
|
|
20622
|
+
}));
|
|
20623
|
+
const AccountName = styled('span')(() => ({
|
|
20875
20624
|
fontSize: '18px',
|
|
20876
20625
|
lineHeight: '25px',
|
|
20877
|
-
})
|
|
20878
|
-
|
|
20879
|
-
|
|
20880
|
-
|
|
20881
|
-
|
|
20882
|
-
|
|
20883
|
-
|
|
20884
|
-
|
|
20885
|
-
|
|
20886
|
-
|
|
20887
|
-
|
|
20888
|
-
|
|
20889
|
-
|
|
20890
|
-
boxShadow: '0 3px 5px 0 rgba(0, 0, 0, 0.3)'
|
|
20891
|
-
},
|
|
20892
|
-
_b[theme.breakpoints.down('sm')] = {
|
|
20893
|
-
display: 'none',
|
|
20894
|
-
},
|
|
20895
|
-
_b[theme.breakpoints.up('sm')] = {
|
|
20896
|
-
display: 'flex',
|
|
20897
|
-
},
|
|
20898
|
-
_b;
|
|
20899
|
-
});
|
|
20900
|
-
var MobileToolbarMenu = styled('div')(function (_a) {
|
|
20901
|
-
var _b;
|
|
20902
|
-
var theme = _a.theme;
|
|
20903
|
-
return (_b = {
|
|
20904
|
-
backgroundColor: theme.palette.primary.main,
|
|
20905
|
-
height: "".concat(dimensions.toolbarMenuHeight, "px"),
|
|
20906
|
-
maxHeight: "".concat(dimensions.toolbarMenuHeight, "px"),
|
|
20907
|
-
minHeight: "".concat(dimensions.toolbarMenuHeight, "px"),
|
|
20908
|
-
width: '100%',
|
|
20909
|
-
flexGrow: 1,
|
|
20910
|
-
alignItems: 'center',
|
|
20911
|
-
fontFamily: 'MontSerrat, Helvetica Neue, Helvetica, Arial, sans-serif',
|
|
20912
|
-
boxShadow: '0 3px 5px 0 rgba(0, 0, 0, 0.3)'
|
|
20913
|
-
},
|
|
20914
|
-
_b[theme.breakpoints.down('sm')] = {
|
|
20915
|
-
display: 'flex',
|
|
20916
|
-
},
|
|
20917
|
-
_b[theme.breakpoints.up('sm')] = {
|
|
20626
|
+
}));
|
|
20627
|
+
const ToolbarMenu = styled('div')(({ theme }) => {
|
|
20628
|
+
return {
|
|
20629
|
+
backgroundColor: theme.palette.primary.main,
|
|
20630
|
+
height: `${dimensions.toolbarMenuHeight}px`,
|
|
20631
|
+
maxHeight: `${dimensions.toolbarMenuHeight}px`,
|
|
20632
|
+
minHeight: `${dimensions.toolbarMenuHeight}px`,
|
|
20633
|
+
width: '100%',
|
|
20634
|
+
display: 'flex',
|
|
20635
|
+
alignItems: 'center',
|
|
20636
|
+
fontFamily: 'MontSerrat, Helvetica Neue, Helvetica, Arial, sans-serif',
|
|
20637
|
+
boxShadow: '0 3px 5px 0 rgba(0, 0, 0, 0.3)',
|
|
20638
|
+
[theme.breakpoints.down('sm')]: {
|
|
20918
20639
|
display: 'none',
|
|
20919
20640
|
},
|
|
20920
|
-
|
|
20921
|
-
});
|
|
20922
|
-
var ToolbarMenuInner = styled('div')(function (_a) {
|
|
20923
|
-
var _b;
|
|
20924
|
-
var theme = _a.theme;
|
|
20925
|
-
return (_b = {
|
|
20641
|
+
[theme.breakpoints.up('sm')]: {
|
|
20926
20642
|
display: 'flex',
|
|
20927
|
-
height: 'fit-content',
|
|
20928
|
-
maxWidth: "".concat(dimensions.toolbarMenuWidth, "px"),
|
|
20929
|
-
margin: '0 auto'
|
|
20930
|
-
},
|
|
20931
|
-
_b[theme.breakpoints.down('lg')] = {
|
|
20932
|
-
padding: '0 24px',
|
|
20933
|
-
},
|
|
20934
|
-
_b[theme.breakpoints.up('lg')] = {
|
|
20935
|
-
padding: 0,
|
|
20936
20643
|
},
|
|
20937
|
-
|
|
20644
|
+
};
|
|
20938
20645
|
});
|
|
20939
|
-
|
|
20940
|
-
|
|
20941
|
-
|
|
20942
|
-
|
|
20943
|
-
|
|
20944
|
-
|
|
20945
|
-
|
|
20946
|
-
|
|
20646
|
+
const MobileToolbarMenu = styled('div')(({ theme }) => ({
|
|
20647
|
+
backgroundColor: theme.palette.primary.main,
|
|
20648
|
+
height: `${dimensions.toolbarMenuHeight}px`,
|
|
20649
|
+
maxHeight: `${dimensions.toolbarMenuHeight}px`,
|
|
20650
|
+
minHeight: `${dimensions.toolbarMenuHeight}px`,
|
|
20651
|
+
width: '100%',
|
|
20652
|
+
flexGrow: 1,
|
|
20653
|
+
alignItems: 'center',
|
|
20654
|
+
fontFamily: 'MontSerrat, Helvetica Neue, Helvetica, Arial, sans-serif',
|
|
20655
|
+
boxShadow: '0 3px 5px 0 rgba(0, 0, 0, 0.3)',
|
|
20656
|
+
[theme.breakpoints.down('sm')]: {
|
|
20947
20657
|
display: 'flex',
|
|
20948
|
-
|
|
20949
|
-
|
|
20950
|
-
|
|
20951
|
-
|
|
20952
|
-
|
|
20953
|
-
|
|
20954
|
-
|
|
20955
|
-
|
|
20956
|
-
|
|
20957
|
-
|
|
20958
|
-
|
|
20959
|
-
|
|
20960
|
-
|
|
20961
|
-
|
|
20962
|
-
|
|
20963
|
-
|
|
20964
|
-
|
|
20658
|
+
},
|
|
20659
|
+
[theme.breakpoints.up('sm')]: {
|
|
20660
|
+
display: 'none',
|
|
20661
|
+
},
|
|
20662
|
+
}));
|
|
20663
|
+
const ToolbarMenuInner = styled('div')(({ theme }) => ({
|
|
20664
|
+
display: 'flex',
|
|
20665
|
+
height: 'fit-content',
|
|
20666
|
+
maxWidth: `${dimensions.toolbarMenuWidth}px`,
|
|
20667
|
+
margin: '0 auto',
|
|
20668
|
+
[theme.breakpoints.down('lg')]: {
|
|
20669
|
+
padding: '0 24px',
|
|
20670
|
+
},
|
|
20671
|
+
[theme.breakpoints.up('lg')]: {
|
|
20672
|
+
padding: 0,
|
|
20673
|
+
},
|
|
20674
|
+
}));
|
|
20675
|
+
const menuItemHoverGreen = '#B9E1CC';
|
|
20676
|
+
const ToolbarMenuItem = styled(NavLink)(({ theme }) => ({
|
|
20677
|
+
alignItems: 'center',
|
|
20678
|
+
borderRight: '1px solid #696868',
|
|
20679
|
+
color: theme.palette.background.default,
|
|
20680
|
+
cursor: 'pointer',
|
|
20681
|
+
display: 'flex',
|
|
20682
|
+
fontSize: '16px',
|
|
20683
|
+
padding: '0 17px',
|
|
20684
|
+
height: '100%',
|
|
20685
|
+
textTransform: 'capitalize',
|
|
20686
|
+
userSelect: 'none',
|
|
20687
|
+
position: 'relative',
|
|
20688
|
+
textDecoration: 'none',
|
|
20689
|
+
fontWeight: 500,
|
|
20690
|
+
':first-child': {
|
|
20691
|
+
paddingLeft: 0,
|
|
20965
20692
|
':after': {
|
|
20966
|
-
|
|
20967
|
-
bottom: 0,
|
|
20968
|
-
left: '50%',
|
|
20969
|
-
width: '32px',
|
|
20970
|
-
marginLeft: '-16px',
|
|
20971
|
-
borderBottom: "2px solid ".concat(theme.palette.secondary.light),
|
|
20972
|
-
opacity: 0,
|
|
20973
|
-
content: '""',
|
|
20974
|
-
transition: 'all 0.3s ease',
|
|
20975
|
-
pointerEvents: 'none',
|
|
20976
|
-
},
|
|
20977
|
-
':focus': {
|
|
20978
|
-
outline: 'none',
|
|
20979
|
-
color: menuItemHoverGreen,
|
|
20980
|
-
':after': {
|
|
20981
|
-
bottom: '-4px',
|
|
20982
|
-
opacity: '1',
|
|
20983
|
-
},
|
|
20693
|
+
marginLeft: '-24px',
|
|
20984
20694
|
},
|
|
20985
|
-
|
|
20986
|
-
|
|
20987
|
-
|
|
20988
|
-
|
|
20989
|
-
|
|
20990
|
-
|
|
20991
|
-
|
|
20695
|
+
},
|
|
20696
|
+
':last-child': {
|
|
20697
|
+
borderRight: 'none',
|
|
20698
|
+
},
|
|
20699
|
+
':after': {
|
|
20700
|
+
position: 'absolute',
|
|
20701
|
+
bottom: 0,
|
|
20702
|
+
left: '50%',
|
|
20703
|
+
width: '32px',
|
|
20704
|
+
marginLeft: '-16px',
|
|
20705
|
+
borderBottom: `2px solid ${theme.palette.secondary.light}`,
|
|
20706
|
+
opacity: 0,
|
|
20707
|
+
content: '""',
|
|
20708
|
+
transition: 'all 0.3s ease',
|
|
20709
|
+
pointerEvents: 'none',
|
|
20710
|
+
},
|
|
20711
|
+
':focus': {
|
|
20712
|
+
outline: 'none',
|
|
20713
|
+
color: menuItemHoverGreen,
|
|
20714
|
+
':after': {
|
|
20715
|
+
bottom: '-4px',
|
|
20716
|
+
opacity: '1',
|
|
20992
20717
|
},
|
|
20993
|
-
|
|
20718
|
+
},
|
|
20719
|
+
':hover': {
|
|
20720
|
+
textDecoration: 'none',
|
|
20721
|
+
color: menuItemHoverGreen,
|
|
20722
|
+
':after': {
|
|
20994
20723
|
bottom: '-4px',
|
|
20995
20724
|
opacity: '1',
|
|
20996
20725
|
},
|
|
20997
|
-
}
|
|
20998
|
-
|
|
20999
|
-
|
|
20726
|
+
},
|
|
20727
|
+
'.active:after': {
|
|
20728
|
+
bottom: '-4px',
|
|
20729
|
+
opacity: '1',
|
|
20730
|
+
},
|
|
20731
|
+
}));
|
|
20732
|
+
const MobileToolbarMenuItem = styled(NavLink)(() => ({
|
|
21000
20733
|
alignItems: 'center',
|
|
21001
20734
|
color: 'black',
|
|
21002
20735
|
cursor: 'pointer',
|
|
@@ -21006,24 +20739,23 @@ var MobileToolbarMenuItem = styled(NavLink)(function () { return ({
|
|
|
21006
20739
|
userSelect: 'none',
|
|
21007
20740
|
position: 'relative',
|
|
21008
20741
|
textDecoration: 'none',
|
|
21009
|
-
})
|
|
20742
|
+
}));
|
|
21010
20743
|
|
|
21011
|
-
|
|
21012
|
-
|
|
21013
|
-
|
|
21014
|
-
|
|
21015
|
-
var handleClickNav = function (event) {
|
|
20744
|
+
const MobileAppBar = ({ userMenuItems, menuItems, }) => {
|
|
20745
|
+
const [anchorElNav, setAnchorElNav] = React.useState(null);
|
|
20746
|
+
const openNav = Boolean(anchorElNav);
|
|
20747
|
+
const handleClickNav = (event) => {
|
|
21016
20748
|
setAnchorElNav(event.currentTarget);
|
|
21017
20749
|
};
|
|
21018
|
-
|
|
20750
|
+
const handleCloseNav = () => {
|
|
21019
20751
|
setAnchorElNav(null);
|
|
21020
20752
|
};
|
|
21021
|
-
|
|
21022
|
-
|
|
21023
|
-
|
|
20753
|
+
const [anchorElMenu, setAnchorElMenu] = React.useState(null);
|
|
20754
|
+
const openMenu = Boolean(anchorElMenu);
|
|
20755
|
+
const handleClickMenu = (event) => {
|
|
21024
20756
|
setAnchorElMenu(event.currentTarget);
|
|
21025
20757
|
};
|
|
21026
|
-
|
|
20758
|
+
const handleCloseMenu = () => {
|
|
21027
20759
|
setAnchorElMenu(null);
|
|
21028
20760
|
};
|
|
21029
20761
|
return (React.createElement(MobileToolbarMenu, { style: { flexGrow: 1 } },
|
|
@@ -21033,40 +20765,39 @@ var MobileAppBar = function (_a) {
|
|
|
21033
20765
|
React.createElement(Menu$1, { sx: { color: 'white' } })),
|
|
21034
20766
|
React.createElement(Menu, { id: "basic-menu", anchorEl: anchorElNav, open: openNav, onClose: handleCloseNav, MenuListProps: {
|
|
21035
20767
|
'aria-labelledby': 'basic-button',
|
|
21036
|
-
} }, menuItems.map(
|
|
20768
|
+
} }, menuItems.map((page) => (React.createElement(MobileToolbarMenuItem, { key: page.name, to: page.redirectUrl || '' },
|
|
21037
20769
|
React.createElement(MenuItem, { sx: {
|
|
21038
20770
|
width: '100%',
|
|
21039
|
-
}, key: page.name }, page.translatedTextRef)))
|
|
20771
|
+
}, key: page.name }, page.translatedTextRef))))),
|
|
21040
20772
|
React.createElement(IconButton, { size: "medium", edge: "end", color: "inherit", "aria-label": "menu", style: { marginLeft: 'auto' }, onClick: handleClickMenu },
|
|
21041
20773
|
React.createElement(MoreVert, { sx: { color: 'white' } })),
|
|
21042
20774
|
React.createElement(Menu, { id: "basic-menu", anchorEl: anchorElMenu, open: openMenu, onClose: handleCloseMenu, MenuListProps: {
|
|
21043
20775
|
'aria-labelledby': 'basic-button',
|
|
21044
|
-
} }, userMenuItems.map(
|
|
21045
|
-
React.createElement(MenuItem, { key: i.id, onClick:
|
|
20776
|
+
} }, userMenuItems.map((i, index) => (React.createElement(Box, { key: i.id },
|
|
20777
|
+
React.createElement(MenuItem, { key: i.id, onClick: () => {
|
|
21046
20778
|
handleCloseMenu();
|
|
21047
20779
|
i.action && i.action();
|
|
21048
20780
|
} }, i.isAnchor ? (React.createElement("a", { style: {
|
|
21049
20781
|
textDecoration: 'inherit',
|
|
21050
20782
|
color: 'inherit',
|
|
21051
20783
|
}, rel: "noreferrer", href: i.href }, i.label)) : (i.label)),
|
|
21052
|
-
userMenuItems.length > index + 1 && React.createElement(Divider, null)))
|
|
20784
|
+
userMenuItems.length > index + 1 && React.createElement(Divider, null)))))))));
|
|
21053
20785
|
};
|
|
21054
20786
|
|
|
21055
|
-
|
|
21056
|
-
|
|
21057
|
-
|
|
21058
|
-
var _handleIconButtonClick = function (event) {
|
|
20787
|
+
const AppBar = ({ username, currentPath, isProd, appTitle, userMenuItems, menuItems, userRole, colors, }) => {
|
|
20788
|
+
const [userMenuAnchor, setUserMenuAnchor] = React.useState(null);
|
|
20789
|
+
const _handleIconButtonClick = (event) => {
|
|
21059
20790
|
event.preventDefault();
|
|
21060
20791
|
setUserMenuAnchor(event.currentTarget);
|
|
21061
20792
|
};
|
|
21062
|
-
|
|
20793
|
+
const _handleCloseUserMenu = () => {
|
|
21063
20794
|
setUserMenuAnchor(null);
|
|
21064
20795
|
};
|
|
21065
|
-
|
|
21066
|
-
|
|
20796
|
+
const _renderToolbarMenuItem = (page) => {
|
|
20797
|
+
const isActive = page?.exact
|
|
21067
20798
|
? currentPath === page.redirectUrl
|
|
21068
20799
|
: currentPath.includes(page.redirectUrl || '');
|
|
21069
|
-
return (React.createElement(ToolbarMenuItem, { className: isActive ? 'active' : '', to: page.redirectUrl || '', key: page.name, tabIndex: 0 }, page
|
|
20800
|
+
return (React.createElement(ToolbarMenuItem, { className: isActive ? 'active' : '', to: page.redirectUrl || '', key: page.name, tabIndex: 0 }, page?.translatedTextRef));
|
|
21070
20801
|
};
|
|
21071
20802
|
return (React.createElement(Toolbar, null,
|
|
21072
20803
|
React.createElement(ToolbarFixer, null,
|
|
@@ -21088,8 +20819,8 @@ var AppBar = function (_a) {
|
|
|
21088
20819
|
}, transformOrigin: {
|
|
21089
20820
|
vertical: 'top',
|
|
21090
20821
|
horizontal: 'center',
|
|
21091
|
-
} }, userMenuItems.map(
|
|
21092
|
-
return (React.createElement(MenuItem$1, { key: i.id, onClick:
|
|
20822
|
+
} }, userMenuItems.map((i, index) => {
|
|
20823
|
+
return (React.createElement(MenuItem$1, { key: i.id, onClick: () => {
|
|
21093
20824
|
setUserMenuAnchor(null);
|
|
21094
20825
|
i.action && i.action();
|
|
21095
20826
|
}, divider: userMenuItems.length > index + 1, sx: {
|
|
@@ -21102,36 +20833,35 @@ var AppBar = function (_a) {
|
|
|
21102
20833
|
}, rel: "noreferrer", href: i.href, onClick: i.onClick }, i.label)) : (i.label)));
|
|
21103
20834
|
})))),
|
|
21104
20835
|
React.createElement(ToolbarMenu, { role: "navigation" },
|
|
21105
|
-
React.createElement(ToolbarMenuInner, null, menuItems.map(
|
|
20836
|
+
React.createElement(ToolbarMenuInner, null, menuItems.map((page) => _renderToolbarMenuItem(page)))),
|
|
21106
20837
|
React.createElement(MobileAppBar, { menuItems: menuItems, userMenuItems: userMenuItems, colors: colors }))));
|
|
21107
20838
|
};
|
|
21108
20839
|
|
|
21109
|
-
|
|
21110
|
-
|
|
21111
|
-
|
|
21112
|
-
|
|
21113
|
-
|
|
21114
|
-
|
|
21115
|
-
var handleCancel = function () {
|
|
20840
|
+
const NavGuard = ({ when, title, txt, txtSave, txtCancel, txtDiscard, onSave, onCancel, onDiscard, }) => {
|
|
20841
|
+
const [open, setOpen] = React.useState(false);
|
|
20842
|
+
const [leave, setLeave] = React.useState(false);
|
|
20843
|
+
const [lastLocation, setLastLocation] = React.useState();
|
|
20844
|
+
const dispatch = useDispatch();
|
|
20845
|
+
const handleCancel = () => {
|
|
21116
20846
|
setLeave(false);
|
|
21117
20847
|
setOpen(false);
|
|
21118
20848
|
onCancel && onCancel();
|
|
21119
20849
|
};
|
|
21120
|
-
|
|
20850
|
+
const handleDiscard = () => {
|
|
21121
20851
|
setLeave(true);
|
|
21122
20852
|
setOpen(false);
|
|
21123
20853
|
onDiscard && onDiscard();
|
|
21124
20854
|
lastLocation &&
|
|
21125
|
-
window.requestAnimationFrame(
|
|
20855
|
+
window.requestAnimationFrame(() => dispatch(push(lastLocation)));
|
|
21126
20856
|
};
|
|
21127
|
-
|
|
20857
|
+
const handleSave = () => {
|
|
21128
20858
|
onSave && onSave();
|
|
21129
20859
|
setLeave(true);
|
|
21130
20860
|
setOpen(false);
|
|
21131
20861
|
lastLocation &&
|
|
21132
|
-
window.requestAnimationFrame(
|
|
20862
|
+
window.requestAnimationFrame(() => dispatch(push(lastLocation)));
|
|
21133
20863
|
};
|
|
21134
|
-
|
|
20864
|
+
const handleLeave = (location) => {
|
|
21135
20865
|
setLastLocation(location);
|
|
21136
20866
|
setOpen(!leave);
|
|
21137
20867
|
return !!leave;
|
|
@@ -21148,21 +20878,17 @@ var NavGuard = function (_a) {
|
|
|
21148
20878
|
onSave && (React.createElement(Button, { onClick: handleSave, color: "primary" }, txtSave))))));
|
|
21149
20879
|
};
|
|
21150
20880
|
|
|
21151
|
-
|
|
21152
|
-
|
|
21153
|
-
|
|
21154
|
-
|
|
21155
|
-
|
|
21156
|
-
'&:hover': {
|
|
21157
|
-
backgroundColor: hex2rgba(palette.error.main, 0.1),
|
|
21158
|
-
},
|
|
20881
|
+
const useStyles$3 = makeStyles()(({ palette }) => ({
|
|
20882
|
+
discard: {
|
|
20883
|
+
color: palette.error.main,
|
|
20884
|
+
'&:hover': {
|
|
20885
|
+
backgroundColor: hex2rgba(palette.error.main, 0.1),
|
|
21159
20886
|
},
|
|
21160
|
-
}
|
|
21161
|
-
});
|
|
20887
|
+
},
|
|
20888
|
+
}));
|
|
21162
20889
|
|
|
21163
|
-
|
|
21164
|
-
|
|
21165
|
-
var classes = useStyles$3().classes;
|
|
20890
|
+
const ConfirmationDialog = ({ open, title, description, warning, onSubmit, onCancel, confirmText = 'OK', cancelText = 'Avbryt', }) => {
|
|
20891
|
+
const { classes } = useStyles$3();
|
|
21166
20892
|
return (React__default.createElement(Dialog, { open: open },
|
|
21167
20893
|
React__default.createElement(DialogTitle, null, title),
|
|
21168
20894
|
React__default.createElement(DialogContent, null,
|
|
@@ -21172,62 +20898,56 @@ var ConfirmationDialog = function (_a) {
|
|
|
21172
20898
|
React__default.createElement(Button, { className: warning ? classes.discard : '', onClick: onSubmit }, confirmText))));
|
|
21173
20899
|
};
|
|
21174
20900
|
|
|
21175
|
-
|
|
21176
|
-
|
|
21177
|
-
|
|
21178
|
-
|
|
21179
|
-
|
|
21180
|
-
|
|
21181
|
-
var openDialog = function (options) {
|
|
20901
|
+
const ConfirmationServiceContext = React__default.createContext(Promise.reject);
|
|
20902
|
+
const ConfirmationServiceProvider = ({ children, }) => {
|
|
20903
|
+
const [confirmationState, setConfirmationState] = React__default.useState(null);
|
|
20904
|
+
const [dialogOpen, setDialogOpen] = React__default.useState(false);
|
|
20905
|
+
const awaitingPromiseRef = React__default.useRef();
|
|
20906
|
+
const openDialog = (options) => {
|
|
21182
20907
|
setConfirmationState(options);
|
|
21183
20908
|
setDialogOpen(true);
|
|
21184
|
-
return new Promise(
|
|
21185
|
-
awaitingPromiseRef.current = { resolve
|
|
20909
|
+
return new Promise((resolve, reject) => {
|
|
20910
|
+
awaitingPromiseRef.current = { resolve, reject };
|
|
21186
20911
|
});
|
|
21187
20912
|
};
|
|
21188
|
-
|
|
20913
|
+
const handleCancel = () => {
|
|
21189
20914
|
setDialogOpen(false);
|
|
21190
20915
|
};
|
|
21191
|
-
|
|
21192
|
-
|
|
21193
|
-
(_a = awaitingPromiseRef.current) === null || _a === void 0 ? void 0 : _a.resolve();
|
|
20916
|
+
const handleSubmit = () => {
|
|
20917
|
+
awaitingPromiseRef.current?.resolve();
|
|
21194
20918
|
setDialogOpen(false);
|
|
21195
20919
|
};
|
|
21196
20920
|
return (React__default.createElement(ConfirmationServiceContext.Provider, { value: openDialog },
|
|
21197
|
-
React__default.createElement(ConfirmationDialog,
|
|
20921
|
+
React__default.createElement(ConfirmationDialog, { open: dialogOpen, onSubmit: handleSubmit, onCancel: handleCancel, ...confirmationState }),
|
|
21198
20922
|
children));
|
|
21199
20923
|
};
|
|
21200
|
-
|
|
21201
|
-
return React__default.useContext(ConfirmationServiceContext);
|
|
21202
|
-
};
|
|
20924
|
+
const useConfirmation = () => React__default.useContext(ConfirmationServiceContext);
|
|
21203
20925
|
|
|
21204
|
-
|
|
21205
|
-
|
|
21206
|
-
var actions = [
|
|
20926
|
+
const GrepDialog = ({ open, title, content, onClose, closeBtnText = 'Lukk', ...props }) => {
|
|
20927
|
+
const actions = [
|
|
21207
20928
|
React__default.createElement(Button, { key: "OK", color: "primary", onClick: onClose }, closeBtnText),
|
|
21208
20929
|
];
|
|
21209
20930
|
if (props.actions)
|
|
21210
|
-
actions.push
|
|
20931
|
+
actions.push(...props.actions);
|
|
21211
20932
|
return (React__default.createElement(Dialog, { open: open, onClose: onClose },
|
|
21212
20933
|
React__default.createElement(DialogTitle, null, title),
|
|
21213
20934
|
React__default.createElement(DialogContent, null, content),
|
|
21214
|
-
React__default.createElement(DialogActions, null, actions.map(
|
|
20935
|
+
React__default.createElement(DialogActions, null, actions.map((action) => action))));
|
|
21215
20936
|
};
|
|
21216
20937
|
|
|
21217
|
-
|
|
21218
|
-
|
|
21219
|
-
|
|
21220
|
-
|
|
21221
|
-
|
|
21222
|
-
var openDialog = function (options) {
|
|
20938
|
+
const GrepDialogServiceContext = React__default.createContext(() => null);
|
|
20939
|
+
const GrepDialogServiceProvider = ({ children, }) => {
|
|
20940
|
+
const [dialogOpen, setDialogOpen] = React__default.useState(false);
|
|
20941
|
+
const [dialogState, setDialogState] = React__default.useState({});
|
|
20942
|
+
const openDialog = (options) => {
|
|
21223
20943
|
setDialogState(options);
|
|
21224
20944
|
setDialogOpen(true);
|
|
21225
20945
|
};
|
|
21226
20946
|
return (React__default.createElement(GrepDialogServiceContext.Provider, { value: openDialog },
|
|
21227
|
-
React__default.createElement(GrepDialog,
|
|
20947
|
+
React__default.createElement(GrepDialog, { open: dialogOpen, onClose: () => setDialogOpen(false), ...dialogState }),
|
|
21228
20948
|
children));
|
|
21229
20949
|
};
|
|
21230
|
-
|
|
20950
|
+
const useGrepDialog = () => React__default.useContext(GrepDialogServiceContext);
|
|
21231
20951
|
|
|
21232
20952
|
/**
|
|
21233
20953
|
* lodash (Custom Build) <https://lodash.com/>
|
|
@@ -21669,89 +21389,89 @@ function toNumber(value) {
|
|
|
21669
21389
|
|
|
21670
21390
|
var lodash_throttle = throttle;
|
|
21671
21391
|
|
|
21672
|
-
|
|
21673
|
-
|
|
21674
|
-
|
|
21392
|
+
const generateElementId = (element) => {
|
|
21393
|
+
const tmpId = element.innerText.replace(/\s/g, '-').toLowerCase();
|
|
21394
|
+
let id = tmpId, index = 1;
|
|
21675
21395
|
while (document.getElementById(id)) {
|
|
21676
|
-
id =
|
|
21396
|
+
id = `${tmpId}-${++index}`;
|
|
21677
21397
|
}
|
|
21678
21398
|
return id;
|
|
21679
21399
|
};
|
|
21680
|
-
|
|
21400
|
+
const identifyElement = (identify) => {
|
|
21681
21401
|
identify = identify || generateElementId;
|
|
21682
|
-
return
|
|
21402
|
+
return (element) => {
|
|
21683
21403
|
!element.id && (element.id = identify(element));
|
|
21684
21404
|
return element.id;
|
|
21685
21405
|
};
|
|
21686
21406
|
};
|
|
21687
21407
|
|
|
21688
|
-
|
|
21408
|
+
const initial = {
|
|
21689
21409
|
elements: {},
|
|
21690
|
-
setSelected:
|
|
21410
|
+
setSelected: () => {
|
|
21691
21411
|
throw Error('not implemented');
|
|
21692
21412
|
},
|
|
21693
21413
|
};
|
|
21694
|
-
|
|
21414
|
+
const context = React__default.createContext(initial);
|
|
21695
21415
|
context.displayName = 'Grep.ToC.Context';
|
|
21696
21416
|
|
|
21697
|
-
|
|
21417
|
+
const defaultSelector = [...new Array(9)]
|
|
21418
|
+
.map((_, i) => `h${i + 1}:not([role="presentation"])`)
|
|
21698
21419
|
.join(',');
|
|
21699
|
-
|
|
21700
|
-
|
|
21701
|
-
|
|
21702
|
-
|
|
21703
|
-
|
|
21704
|
-
|
|
21705
|
-
|
|
21706
|
-
|
|
21707
|
-
|
|
21708
|
-
|
|
21709
|
-
|
|
21710
|
-
target.scrollBy({ top: top });
|
|
21420
|
+
const GrepTableOfContentProvider = ({ ...props }) => {
|
|
21421
|
+
const { container, identifier, onSelected, classes, scrollTarget, children, offsetTop = -10, identifyElementFn = identifyElement, } = props;
|
|
21422
|
+
const [selected, _setSelected] = useState();
|
|
21423
|
+
const [initialized, setInitialized] = useState();
|
|
21424
|
+
const hash = useSelector((s) => decodeURI(getHash(s))).substring(1);
|
|
21425
|
+
const scrollToElement = useCallback$1((element) => {
|
|
21426
|
+
const target = scrollTarget || window;
|
|
21427
|
+
const elementBounds = element.getBoundingClientRect();
|
|
21428
|
+
const elementTop = elementBounds.top - element.clientHeight;
|
|
21429
|
+
const top = elementTop - offsetTop;
|
|
21430
|
+
target.scrollBy({ top });
|
|
21711
21431
|
}, [scrollTarget, offsetTop]);
|
|
21712
|
-
|
|
21432
|
+
const identify = useMemo$1(() => {
|
|
21713
21433
|
return identifyElementFn(identifier || generateElementId);
|
|
21714
21434
|
}, [identifier, identifyElementFn]);
|
|
21715
|
-
|
|
21716
|
-
|
|
21435
|
+
const elements = useContentElements(container, props.selector || defaultSelector, { identify });
|
|
21436
|
+
const setSelected = useCallback$1(lodash_throttle((element, scroll) => {
|
|
21717
21437
|
element && scroll && scrollToElement(element);
|
|
21718
21438
|
_setSelected(element);
|
|
21719
21439
|
}, 50, { trailing: false }), [_setSelected, scrollToElement]);
|
|
21720
|
-
|
|
21721
|
-
|
|
21440
|
+
const getViewportElement = useCallback$1(() => {
|
|
21441
|
+
const records = Object.values(elements);
|
|
21722
21442
|
if (!records.length)
|
|
21723
21443
|
return;
|
|
21724
|
-
|
|
21444
|
+
const index = records.findIndex((e) => e.getBoundingClientRect().bottom > offsetTop);
|
|
21725
21445
|
if (index > 0) {
|
|
21726
|
-
|
|
21727
|
-
|
|
21728
|
-
|
|
21446
|
+
const rect = records[index].getBoundingClientRect();
|
|
21447
|
+
const offset = Math.floor(rect.top - offsetTop);
|
|
21448
|
+
const within = offset < rect.height + 20;
|
|
21729
21449
|
return records[within ? index : index - 1];
|
|
21730
21450
|
}
|
|
21731
21451
|
return records[index];
|
|
21732
21452
|
}, [elements, offsetTop]);
|
|
21733
21453
|
// attach observer to elements
|
|
21734
|
-
useEffect(
|
|
21735
|
-
|
|
21454
|
+
useEffect(() => {
|
|
21455
|
+
const target = scrollTarget || window;
|
|
21736
21456
|
if (!target)
|
|
21737
21457
|
return;
|
|
21738
|
-
|
|
21739
|
-
|
|
21458
|
+
const onScroll = lodash_throttle(() => {
|
|
21459
|
+
const element = getViewportElement();
|
|
21740
21460
|
setSelected(element);
|
|
21741
21461
|
}, 50);
|
|
21742
21462
|
target.addEventListener('scroll', onScroll, false);
|
|
21743
21463
|
console.debug('scroll observer attached');
|
|
21744
|
-
return
|
|
21464
|
+
return () => {
|
|
21745
21465
|
console.debug('scroll observer detached');
|
|
21746
21466
|
return target.removeEventListener('scroll', onScroll);
|
|
21747
21467
|
};
|
|
21748
21468
|
}, [scrollTarget, setSelected, offsetTop, getViewportElement]);
|
|
21749
21469
|
// notify observer when selected change
|
|
21750
|
-
useEffect(
|
|
21470
|
+
useEffect(() => {
|
|
21751
21471
|
selected && onSelected && onSelected(selected);
|
|
21752
21472
|
}, [selected, onSelected]);
|
|
21753
21473
|
// observe changes in hash
|
|
21754
|
-
useEffect(
|
|
21474
|
+
useEffect(() => {
|
|
21755
21475
|
if (hash && elements[hash]) {
|
|
21756
21476
|
console.debug('anchor change, setting selected element');
|
|
21757
21477
|
setSelected(elements[hash], true);
|
|
@@ -21763,17 +21483,15 @@ var GrepTableOfContentProvider = function (_a) {
|
|
|
21763
21483
|
setSelected(elements[hash], true);
|
|
21764
21484
|
setInitialized(true);
|
|
21765
21485
|
}
|
|
21766
|
-
return (React__default.createElement(context.Provider, { value: { elements
|
|
21486
|
+
return (React__default.createElement(context.Provider, { value: { elements, selected, classes, setSelected } }, children));
|
|
21767
21487
|
};
|
|
21768
21488
|
GrepTableOfContentProvider.displayName = 'Grep.ToC.Provider';
|
|
21769
21489
|
|
|
21770
|
-
|
|
21771
|
-
|
|
21772
|
-
|
|
21773
|
-
|
|
21774
|
-
|
|
21775
|
-
var selectedColor = "var(--grep-toc-selected-color, ".concat(palette.primary.main, ")");
|
|
21776
|
-
var focusBackground = "var(--grep-toc-focused-background, ".concat(convertToRgba(palette.primary.main, 0.1), ")");
|
|
21490
|
+
const useStyles$2 = makeStyles()(({ palette }, { lvl }) => {
|
|
21491
|
+
const defaultColor = convertToRgba(palette.primary.main, 0.75);
|
|
21492
|
+
const linkcolor = `var(--grep-toc-link-color, ${defaultColor})`;
|
|
21493
|
+
const selectedColor = `var(--grep-toc-selected-color, ${palette.primary.main})`;
|
|
21494
|
+
const focusBackground = `var(--grep-toc-focused-background, ${convertToRgba(palette.primary.main, 0.1)})`;
|
|
21777
21495
|
return {
|
|
21778
21496
|
root: {
|
|
21779
21497
|
color: linkcolor,
|
|
@@ -21789,7 +21507,7 @@ var useStyles$2 = makeStyles()(function (_a, _b) {
|
|
|
21789
21507
|
textOverflow: 'ellipsis',
|
|
21790
21508
|
'&--selected': {
|
|
21791
21509
|
color: selectedColor,
|
|
21792
|
-
borderLeft:
|
|
21510
|
+
borderLeft: `5px solid ${selectedColor}`,
|
|
21793
21511
|
},
|
|
21794
21512
|
'&:focus': {
|
|
21795
21513
|
outline: 'none',
|
|
@@ -21799,48 +21517,47 @@ var useStyles$2 = makeStyles()(function (_a, _b) {
|
|
|
21799
21517
|
};
|
|
21800
21518
|
});
|
|
21801
21519
|
|
|
21802
|
-
|
|
21803
|
-
|
|
21804
|
-
|
|
21805
|
-
|
|
21806
|
-
|
|
21807
|
-
|
|
21808
|
-
|
|
21809
|
-
|
|
21810
|
-
|
|
21811
|
-
|
|
21812
|
-
|
|
21813
|
-
|
|
21814
|
-
useEffect(
|
|
21815
|
-
|
|
21520
|
+
const GrepTableOfContentNavTreeNode = (props) => {
|
|
21521
|
+
const linkRef = useRef(null);
|
|
21522
|
+
const { node, style, renderChilds, setSelectedValue, percentageRendered } = props;
|
|
21523
|
+
const { lvl, el, index, children } = node;
|
|
21524
|
+
const { selected, setSelected, classes, elements } = useContext(context);
|
|
21525
|
+
const isSelected = el === selected;
|
|
21526
|
+
const { classes: styles } = useStyles$2({ lvl });
|
|
21527
|
+
const className = clsx('grep-toc__nav-tree-node', isSelected && 'grep-toc__nav-tree-node--selected', styles.root, classes?.node, props.className);
|
|
21528
|
+
const [awaitingRender, setAwaitingRender] = useState(false);
|
|
21529
|
+
const txt = el.innerText;
|
|
21530
|
+
const location = useSelector((s) => getLocation(s));
|
|
21531
|
+
const url = `${location.pathname}${location.search}#${node.id}`;
|
|
21532
|
+
useEffect(() => {
|
|
21533
|
+
const link = linkRef.current;
|
|
21816
21534
|
if (isSelected) {
|
|
21817
|
-
link
|
|
21535
|
+
link?.scrollIntoViewIfNeeded();
|
|
21818
21536
|
//setTimeout(() => link?.scrollIntoViewIfNeeded(), 2000);
|
|
21819
21537
|
}
|
|
21820
21538
|
else if (link === document.activeElement) {
|
|
21821
|
-
link
|
|
21539
|
+
link?.blur();
|
|
21822
21540
|
}
|
|
21823
21541
|
}, [isSelected, linkRef, setSelectedValue]);
|
|
21824
|
-
|
|
21825
|
-
useEffect(
|
|
21542
|
+
const tabIndex = isSelected ? 0 : -1;
|
|
21543
|
+
useEffect(() => {
|
|
21826
21544
|
if (awaitingRender) {
|
|
21827
21545
|
doSelect();
|
|
21828
21546
|
setAwaitingRender(false);
|
|
21829
21547
|
}
|
|
21830
21548
|
}, [percentageRendered]);
|
|
21831
|
-
|
|
21832
|
-
if (checkAwaitRender === void 0) { checkAwaitRender = false; }
|
|
21549
|
+
const doSelect = (checkAwaitRender = false) => {
|
|
21833
21550
|
window.history.replaceState({}, txt, url);
|
|
21834
21551
|
setSelected(el, true);
|
|
21835
|
-
|
|
21836
|
-
|
|
21552
|
+
const values = Object.values(elements);
|
|
21553
|
+
const newPercentage = values.findIndex((e) => e === el) / values.length + 0.1;
|
|
21837
21554
|
setSelectedValue(newPercentage);
|
|
21838
21555
|
if (checkAwaitRender && newPercentage > percentageRendered) {
|
|
21839
21556
|
setAwaitingRender(true);
|
|
21840
21557
|
}
|
|
21841
21558
|
};
|
|
21842
21559
|
return (React__default.createElement("li", { key: index, "data-lvl": lvl, className: className, style: style },
|
|
21843
|
-
React__default.createElement(Link$1, { ref: linkRef, className: clsx(styles.link, isSelected &&
|
|
21560
|
+
React__default.createElement(Link$1, { ref: linkRef, className: clsx(styles.link, isSelected && `${styles.link}--selected`), href: url, tabIndex: tabIndex, onClick: (event) => {
|
|
21844
21561
|
console.debug('node click', node);
|
|
21845
21562
|
event.preventDefault();
|
|
21846
21563
|
event.stopPropagation();
|
|
@@ -21850,7 +21567,7 @@ var GrepTableOfContentNavTreeNode = function (props) {
|
|
|
21850
21567
|
};
|
|
21851
21568
|
GrepTableOfContentNavTreeNode.displayName = 'Grep.ToC.NavTree.Node';
|
|
21852
21569
|
|
|
21853
|
-
|
|
21570
|
+
const useStyles$1 = makeStyles()(() => ({
|
|
21854
21571
|
root: {
|
|
21855
21572
|
listStyle: 'none',
|
|
21856
21573
|
padding: 0,
|
|
@@ -21858,18 +21575,18 @@ var useStyles$1 = makeStyles()(function () { return ({
|
|
|
21858
21575
|
fontSize: '.9em',
|
|
21859
21576
|
},
|
|
21860
21577
|
},
|
|
21861
|
-
})
|
|
21862
|
-
|
|
21863
|
-
|
|
21864
|
-
|
|
21865
|
-
|
|
21866
|
-
|
|
21867
|
-
|
|
21868
|
-
return (React__default.createElement("ul", { className: className, style: style }, Object.values(elements).map(
|
|
21578
|
+
}));
|
|
21579
|
+
|
|
21580
|
+
const NavTree = (props) => {
|
|
21581
|
+
const { elements, style, setSelectedValue, percentageRendered } = props;
|
|
21582
|
+
const { classes } = useContext(context);
|
|
21583
|
+
const { classes: styles } = useStyles$1();
|
|
21584
|
+
const className = clsx('grep-toc__nav-tree', styles.root, classes?.tree, props.className);
|
|
21585
|
+
return (React__default.createElement("ul", { className: className, style: style }, Object.values(elements).map((node) => (React__default.createElement(GrepTableOfContentNavTreeNode, { node: node, key: node.index, renderChilds: (children) => (React__default.createElement(NavTree, { elements: children, setSelectedValue: setSelectedValue, percentageRendered: percentageRendered })), setSelectedValue: setSelectedValue, percentageRendered: percentageRendered })))));
|
|
21869
21586
|
};
|
|
21870
21587
|
NavTree.displayName = 'Grep.ToC.NavTree';
|
|
21871
21588
|
|
|
21872
|
-
|
|
21589
|
+
const useStyles = makeStyles()(() => ({
|
|
21873
21590
|
root: {
|
|
21874
21591
|
fontSize: 18,
|
|
21875
21592
|
overflowY: 'scroll',
|
|
@@ -21892,54 +21609,47 @@ var useStyles = makeStyles()(function () { return ({
|
|
|
21892
21609
|
padding: '2px 5px',
|
|
21893
21610
|
},
|
|
21894
21611
|
},
|
|
21895
|
-
})
|
|
21612
|
+
}));
|
|
21896
21613
|
|
|
21897
|
-
|
|
21898
|
-
|
|
21614
|
+
const getElementLevel = (el) => {
|
|
21615
|
+
const res = el.nodeName.match(/H([1-9])/);
|
|
21899
21616
|
if (res) {
|
|
21900
|
-
|
|
21617
|
+
const [_, lvl] = res;
|
|
21901
21618
|
return Number(lvl);
|
|
21902
21619
|
}
|
|
21903
21620
|
return 0;
|
|
21904
21621
|
};
|
|
21905
21622
|
|
|
21906
|
-
|
|
21907
|
-
return elements.reduce(
|
|
21908
|
-
|
|
21909
|
-
|
|
21910
|
-
|
|
21911
|
-
|
|
21912
|
-
curr.push({ id: id, el: el, lvl: lvl, parent: parent, index: index });
|
|
21623
|
+
const normalize = (elements) => {
|
|
21624
|
+
return elements.reduce((curr, el, index) => {
|
|
21625
|
+
const { id } = el;
|
|
21626
|
+
const lvl = getElementLevel(el, elements[index - 1]);
|
|
21627
|
+
const parent = [...curr].reverse().find((obj) => obj.lvl < lvl)?.index;
|
|
21628
|
+
curr.push({ id, el, lvl, parent, index });
|
|
21913
21629
|
return curr;
|
|
21914
21630
|
}, []);
|
|
21915
21631
|
};
|
|
21916
21632
|
|
|
21917
|
-
|
|
21918
|
-
|
|
21919
|
-
|
|
21920
|
-
|
|
21921
|
-
|
|
21922
|
-
|
|
21923
|
-
|
|
21924
|
-
_a));
|
|
21925
|
-
}, {});
|
|
21926
|
-
};
|
|
21927
|
-
var buildTree = function (elements, normalizer) {
|
|
21928
|
-
if (normalizer === void 0) { normalizer = normalize; }
|
|
21929
|
-
var items = normalizer(elements);
|
|
21633
|
+
const nest = (items, id) => items
|
|
21634
|
+
.filter((item) => item.parent === id)
|
|
21635
|
+
.reduce((curr, item) => Object.assign(curr, {
|
|
21636
|
+
[item.index]: { ...item, children: nest(items, item.index) },
|
|
21637
|
+
}), {});
|
|
21638
|
+
const buildTree = (elements, normalizer = normalize) => {
|
|
21639
|
+
const items = normalizer(elements);
|
|
21930
21640
|
return nest(items);
|
|
21931
21641
|
};
|
|
21932
21642
|
|
|
21933
|
-
|
|
21934
|
-
|
|
21935
|
-
|
|
21936
|
-
|
|
21937
|
-
|
|
21938
|
-
|
|
21939
|
-
requestAnimationFrame(
|
|
21643
|
+
const GrepTableOfContentNav = (props) => {
|
|
21644
|
+
const [showKeyboardHint, setShowKeyboardHint] = useState(false);
|
|
21645
|
+
const ref = useRef(null);
|
|
21646
|
+
const { elements, classes, selected, setSelected } = useContext(context);
|
|
21647
|
+
const tree = useMemo$1(() => buildTree(Object.values(elements)), [elements]);
|
|
21648
|
+
const focusSelected = useCallback$1(() => {
|
|
21649
|
+
requestAnimationFrame(() => {
|
|
21940
21650
|
if (!(ref.current instanceof HTMLElement))
|
|
21941
21651
|
return;
|
|
21942
|
-
|
|
21652
|
+
const active = ref.current.querySelector('[tabindex="0"]');
|
|
21943
21653
|
if (active instanceof HTMLElement) {
|
|
21944
21654
|
active.focus();
|
|
21945
21655
|
}
|
|
@@ -21948,55 +21658,54 @@ var GrepTableOfContentNav = function (props) {
|
|
|
21948
21658
|
}
|
|
21949
21659
|
});
|
|
21950
21660
|
}, [ref]);
|
|
21951
|
-
|
|
21661
|
+
const onKeyDown = (e) => {
|
|
21952
21662
|
if (selected && e.which === Key_enum.Key.Tab && e.shiftKey === false) {
|
|
21953
|
-
|
|
21663
|
+
const tabindex = selected.getAttribute('tabindex');
|
|
21954
21664
|
selected.setAttribute('tabindex', '0');
|
|
21955
21665
|
selected.focus();
|
|
21956
|
-
requestAnimationFrame(
|
|
21957
|
-
|
|
21666
|
+
requestAnimationFrame(() => {
|
|
21667
|
+
tabindex === null
|
|
21958
21668
|
? selected.removeAttribute('tabindex')
|
|
21959
|
-
: selected.setAttribute('tabindex',
|
|
21669
|
+
: selected.setAttribute('tabindex', tabindex);
|
|
21960
21670
|
});
|
|
21961
21671
|
}
|
|
21962
21672
|
if ([Key_enum.Key.UpArrow, Key_enum.Key.DownArrow].includes(e.which)) {
|
|
21963
21673
|
e.preventDefault();
|
|
21964
21674
|
e.stopPropagation();
|
|
21965
|
-
|
|
21966
|
-
|
|
21967
|
-
|
|
21968
|
-
|
|
21675
|
+
const nodes = Object.values(elements);
|
|
21676
|
+
const currentIndex = nodes.indexOf(selected);
|
|
21677
|
+
const moveIndex = e.which === Key_enum.Key.UpArrow ? -1 : 1;
|
|
21678
|
+
const next = nodes[currentIndex + moveIndex];
|
|
21969
21679
|
next && setSelected(next, true);
|
|
21970
21680
|
focusSelected();
|
|
21971
21681
|
}
|
|
21972
21682
|
};
|
|
21973
|
-
useEffect(
|
|
21974
|
-
|
|
21683
|
+
useEffect(() => {
|
|
21684
|
+
const onKeyDown = (e) => {
|
|
21975
21685
|
e.keyCode === Key_enum.Key.Alt && setShowKeyboardHint(true);
|
|
21976
21686
|
if (e.altKey) {
|
|
21977
21687
|
e.keyCode === Key_enum.Key.I && focusSelected();
|
|
21978
21688
|
}
|
|
21979
21689
|
};
|
|
21980
|
-
|
|
21690
|
+
const onKeyUp = (e) => {
|
|
21981
21691
|
e.keyCode === Key_enum.Key.Alt && setShowKeyboardHint(false);
|
|
21982
21692
|
};
|
|
21983
21693
|
window.addEventListener('keydown', onKeyDown);
|
|
21984
21694
|
window.addEventListener('keyup', onKeyUp);
|
|
21985
|
-
return
|
|
21695
|
+
return () => {
|
|
21986
21696
|
window.removeEventListener('keydown', onKeyDown);
|
|
21987
21697
|
window.removeEventListener('keyup', onKeyUp);
|
|
21988
21698
|
};
|
|
21989
21699
|
}, [focusSelected]);
|
|
21990
|
-
|
|
21991
|
-
|
|
21700
|
+
const { classes: style } = useStyles();
|
|
21701
|
+
const className = clsx('grep-toc__nav', style.root, classes?.nav, props.className, showKeyboardHint && style.keyboardHint);
|
|
21992
21702
|
return (React__default.createElement("nav", { className: className, style: props.style, tabIndex: selected ? -1 : 0, onKeyDown: onKeyDown, ref: ref },
|
|
21993
21703
|
React__default.createElement(NavTree, { elements: tree, setSelectedValue: props.setSelectedValue, percentageRendered: props.percentageRendered })));
|
|
21994
21704
|
};
|
|
21995
21705
|
GrepTableOfContentNav.displayName = 'Grep.ToC.Nav';
|
|
21996
21706
|
|
|
21997
|
-
|
|
21998
|
-
|
|
21999
|
-
return (React__default.createElement(GrepTableOfContentProvider, __assign({}, props),
|
|
21707
|
+
const GrepTableOfContent = ({ style, className, setSelectedValue, percentageRendered, ...props }) => {
|
|
21708
|
+
return (React__default.createElement(GrepTableOfContentProvider, { ...props },
|
|
22000
21709
|
React__default.createElement(GrepTableOfContentNav, { className: className, style: style, setSelectedValue: setSelectedValue, percentageRendered: percentageRendered })));
|
|
22001
21710
|
};
|
|
22002
21711
|
GrepTableOfContent.displayName = 'Grep.ToC';
|