@hbuesing/ui-library 3.0.0 → 3.0.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/bundle.js +2 -0
- package/dist/bundle.js.map +1 -0
- package/dist/components/button/customButton.d.ts +10 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/checkbox/customCheckBox.d.ts +10 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/images/index.d.ts +1 -0
- package/dist/components/images/svgIcon.d.ts +9 -0
- package/dist/components/input/baseInput.d.ts +11 -0
- package/dist/components/input/customInput.d.ts +8 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/passwordInput.d.ts +18 -0
- package/dist/components/modal/baseModal.d.ts +16 -0
- package/dist/components/modal/index.d.ts +2 -0
- package/dist/components/modal/notifyModal.d.ts +11 -0
- package/dist/components/modal/questionModal.d.ts +10 -0
- package/dist/components/radio/customRadio.d.ts +17 -0
- package/dist/components/radio/index.d.ts +1 -0
- package/dist/enums/index.d.ts +1 -0
- package/dist/enums/modalType.d.ts +6 -0
- package/dist/enums/passwordRuleTypes.d.ts +8 -0
- package/dist/hooks/clickOutside.d.ts +1 -0
- package/dist/hooks/getColor.d.ts +1 -0
- package/{src/hooks/index.ts → dist/hooks/index.d.ts} +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/utils/generateKey.d.ts +1 -0
- package/dist/utils/useInjectStyles.d.ts +2 -0
- package/package.json +9 -4
- package/src/components/button/button.scss +0 -25
- package/src/components/button/customButton.tsx +0 -84
- package/src/components/button/index.ts +0 -1
- package/src/components/checkbox/checkbox.scss +0 -13
- package/src/components/checkbox/customCheckBox.tsx +0 -35
- package/src/components/checkbox/index.ts +0 -1
- package/src/components/global.scss +0 -60
- package/src/components/images/images.scss +0 -12
- package/src/components/images/index.ts +0 -1
- package/src/components/images/svgIcon.tsx +0 -39
- package/src/components/input/baseInput.tsx +0 -48
- package/src/components/input/customInput.tsx +0 -54
- package/src/components/input/index.ts +0 -2
- package/src/components/input/input.scss +0 -142
- package/src/components/input/passwordInput.tsx +0 -118
- package/src/components/modal/baseModal.tsx +0 -105
- package/src/components/modal/index.ts +0 -2
- package/src/components/modal/modal.scss +0 -125
- package/src/components/modal/notifyModal.tsx +0 -24
- package/src/components/modal/questionModal.tsx +0 -23
- package/src/components/radio/customRadio.tsx +0 -72
- package/src/components/radio/index.ts +0 -1
- package/src/components/radio/radio.scss +0 -28
- package/src/components/variables.scss +0 -61
- package/src/enums/index.ts +0 -1
- package/src/enums/modalType.ts +0 -6
- package/src/enums/passwordRuleTypes.ts +0 -8
- package/src/hooks/clickOutside.ts +0 -25
- package/src/hooks/getColor.ts +0 -16
- package/src/index.ts +0 -9
- package/src/utils/generateKey.ts +0 -3
- package/src/utils/styles.scss +0 -7
- package/src/utils/styles.scss.d.ts +0 -2
- package/src/utils/useInjectStyles.ts +0 -19
- package/tsconfig.json +0 -24
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, {ComponentPropsWithoutRef, CSSProperties, useRef} from 'react';
|
|
2
|
-
import useInjectStyleSheet from "utils/useInjectStyles";
|
|
3
|
-
|
|
4
|
-
interface ISvgIcon extends ComponentPropsWithoutRef<'svg'>{
|
|
5
|
-
src : string;
|
|
6
|
-
color? : string | undefined;
|
|
7
|
-
height?: number;
|
|
8
|
-
width? : number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function SVG(props: ISvgIcon) {
|
|
12
|
-
const {
|
|
13
|
-
src,
|
|
14
|
-
color,
|
|
15
|
-
height,
|
|
16
|
-
width
|
|
17
|
-
} = props;
|
|
18
|
-
|
|
19
|
-
if (!src.includes('.svg')) {
|
|
20
|
-
throw new Error('Provided src is not an svg image');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const nodeRef = useRef<HTMLDivElement>(null);
|
|
24
|
-
useInjectStyleSheet(nodeRef);
|
|
25
|
-
|
|
26
|
-
const style: CSSProperties = {
|
|
27
|
-
fill: color,
|
|
28
|
-
height: `${height}px`,
|
|
29
|
-
width: `${width}px`
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div ref={nodeRef} className={'uil-svg-wrapper'}>
|
|
34
|
-
<svg aria-hidden={true} className={'uil-svg'} style={style}>
|
|
35
|
-
<use href={src}/>
|
|
36
|
-
</svg>
|
|
37
|
-
</div>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React, {ComponentPropsWithoutRef, useRef} from 'react';
|
|
2
|
-
import {SVG} from 'components/images/svgIcon';
|
|
3
|
-
import useInjectStyleSheet from "../../utils/useInjectStyles";
|
|
4
|
-
|
|
5
|
-
export interface IBaseInput extends ComponentPropsWithoutRef<'input'> {
|
|
6
|
-
label : string;
|
|
7
|
-
value : string;
|
|
8
|
-
valueChanged: (value: string) => void;
|
|
9
|
-
iconColor? : string;
|
|
10
|
-
iconSrc? : string;
|
|
11
|
-
inputColor? : string;
|
|
12
|
-
toggle? : () => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function BaseInput(props: IBaseInput) {
|
|
16
|
-
const {
|
|
17
|
-
iconColor,
|
|
18
|
-
iconSrc,
|
|
19
|
-
inputColor,
|
|
20
|
-
label,
|
|
21
|
-
toggle,
|
|
22
|
-
valueChanged,
|
|
23
|
-
...inputProps
|
|
24
|
-
} = props;
|
|
25
|
-
|
|
26
|
-
const nodeRef = useRef<HTMLLabelElement>(null);
|
|
27
|
-
useInjectStyleSheet(nodeRef);
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<label className={'uil-input-wrapper'} htmlFor={inputProps.id} ref={nodeRef}>
|
|
31
|
-
<input
|
|
32
|
-
className={'uil-input uil-font-base'}
|
|
33
|
-
onChange={(e) => valueChanged(e.target.value)}
|
|
34
|
-
placeholder={label}
|
|
35
|
-
style={{color: inputColor}}
|
|
36
|
-
{...inputProps}
|
|
37
|
-
/>
|
|
38
|
-
|
|
39
|
-
{iconSrc &&
|
|
40
|
-
<div className={'uil-icon'} onClick={toggle}>
|
|
41
|
-
<SVG src={iconSrc} width={24} height={24} color={iconColor}/>
|
|
42
|
-
</div>
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
<span className={'uil-label uil-font-base'} style={{color: inputColor}}>{label}</span>
|
|
46
|
-
</label>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React, {useState} from 'react';
|
|
2
|
-
import {BaseInput, IBaseInput} from './baseInput';
|
|
3
|
-
import {SVG} from 'components/images/svgIcon';
|
|
4
|
-
import {useClickOutsideRef} from 'hooks/clickOutside';
|
|
5
|
-
|
|
6
|
-
export interface ICustomInput extends IBaseInput {
|
|
7
|
-
tooltipClose?: string;
|
|
8
|
-
tooltipIcon? : string;
|
|
9
|
-
tooltipText? : string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function CustomInput(props: ICustomInput) {
|
|
13
|
-
const {
|
|
14
|
-
tooltipClose,
|
|
15
|
-
tooltipIcon,
|
|
16
|
-
tooltipText,
|
|
17
|
-
...inputProps
|
|
18
|
-
} = props;
|
|
19
|
-
|
|
20
|
-
const [tooltipVisible, setTooltipVisible] = useState(false);
|
|
21
|
-
const ref = useClickOutsideRef<HTMLDivElement>(closeTooltip);
|
|
22
|
-
|
|
23
|
-
function closeTooltip() {
|
|
24
|
-
setTooltipVisible(false);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<>
|
|
29
|
-
{tooltipIcon ?
|
|
30
|
-
<div className={'uil-tooltip-wrapper'} ref={ref}>
|
|
31
|
-
{tooltipVisible &&
|
|
32
|
-
<div className={'uil-tooltip'}>
|
|
33
|
-
{tooltipClose &&
|
|
34
|
-
<button className={'uil-tooltip-button uil-fit'} onClick={closeTooltip}>
|
|
35
|
-
{tooltipClose}
|
|
36
|
-
</button>
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
<span>{tooltipText}</span>
|
|
40
|
-
</div>
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
<div className={'uil-tooltip-icon uil-fit'} onClick={() => setTooltipVisible(!tooltipVisible)}>
|
|
44
|
-
<SVG src={tooltipIcon} height={16} width={16}/>
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
<BaseInput {...inputProps}/>
|
|
48
|
-
</div> :
|
|
49
|
-
|
|
50
|
-
<BaseInput {...inputProps}/>
|
|
51
|
-
}
|
|
52
|
-
</>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
@use '../variables' as *;
|
|
2
|
-
|
|
3
|
-
.uil-input-wrapper {
|
|
4
|
-
position: relative;
|
|
5
|
-
display: block;
|
|
6
|
-
|
|
7
|
-
& .uil-label {
|
|
8
|
-
position: absolute;
|
|
9
|
-
top: 25%;
|
|
10
|
-
left: var(--uil-xxs);
|
|
11
|
-
cursor: text;
|
|
12
|
-
font-weight: bold;
|
|
13
|
-
color: var(--uil-black);
|
|
14
|
-
background: linear-gradient(0deg, var(--uil-white) 9px, rgba(0,0,0,0) 0%);
|
|
15
|
-
opacity: .6;
|
|
16
|
-
padding: 0 var(--uil-xxxs);
|
|
17
|
-
transition: top .25s ease-in-out;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
& .uil-input {
|
|
21
|
-
box-sizing: border-box;
|
|
22
|
-
width: 100%;
|
|
23
|
-
color: var(--uil-black);
|
|
24
|
-
background-color: var(--uil-white);
|
|
25
|
-
border: 1px solid var(--uil-black);
|
|
26
|
-
border-radius: 0;
|
|
27
|
-
padding: var(--uil-xs);
|
|
28
|
-
|
|
29
|
-
//hide placeholder as it is only needed for stylesheet rules
|
|
30
|
-
&::placeholder {
|
|
31
|
-
color: transparent;
|
|
32
|
-
width: 0;
|
|
33
|
-
height: 0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&:focus {
|
|
37
|
-
outline: 1px solid var(--uil-outline-focus);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&:disabled {
|
|
41
|
-
cursor: not-allowed;
|
|
42
|
-
border: 2px solid var(--uil-outline-disabled);
|
|
43
|
-
background-color: var(--uil-grey);
|
|
44
|
-
color: var(--uil-grey-dark);
|
|
45
|
-
|
|
46
|
-
& ~ .uil-label {
|
|
47
|
-
cursor: not-allowed;
|
|
48
|
-
background: transparent;
|
|
49
|
-
color: var(--uil-grey-dark);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
& ~ .uil-icon {
|
|
53
|
-
cursor: not-allowed;
|
|
54
|
-
fill: var(--uil-grey-dark);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&:not(:placeholder-shown) ~ .uil-label {
|
|
58
|
-
background: linear-gradient(0deg, var(--uil-grey) 8px, rgba(0,0,0,0) 0%);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
& .uil-icon {
|
|
64
|
-
position: absolute;
|
|
65
|
-
top: 50%;
|
|
66
|
-
right: var(--uil-xs);
|
|
67
|
-
transform: translate(0%, -50%);
|
|
68
|
-
display: flex;
|
|
69
|
-
align-items: center;
|
|
70
|
-
justify-content: center;
|
|
71
|
-
fill: var(--uil-black);
|
|
72
|
-
opacity: .5;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
& .uil-input:focus ~ .uil-label, .uil-input:not(:placeholder-shown) ~ .uil-label {
|
|
76
|
-
top: -30%;
|
|
77
|
-
opacity: 1;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
& .uil-input:focus ~ .uil-icon, .uil-input:not(:placeholder-shown) ~ .uil-icon {
|
|
81
|
-
opacity: 1;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.uil-tooltip-wrapper {
|
|
86
|
-
position: relative;
|
|
87
|
-
|
|
88
|
-
.uil-tooltip-icon {
|
|
89
|
-
cursor: pointer;
|
|
90
|
-
fill: var(--uil-black-alt);
|
|
91
|
-
margin-bottom: var(--uil-xxs);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
& .uil-tooltip-icon:has(~ .uil-input-wrapper > .uil-input:not(:placeholder-shown), ~ .uil-input-wrapper:focus-within) {
|
|
95
|
-
opacity: 0;
|
|
96
|
-
visibility: hidden;
|
|
97
|
-
transition: opacity .3s, visibility .3s;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.uil-tooltip {
|
|
101
|
-
position: absolute;
|
|
102
|
-
top: 0;
|
|
103
|
-
left: 0;
|
|
104
|
-
width: 100%;
|
|
105
|
-
box-sizing: border-box;
|
|
106
|
-
z-index: 1;
|
|
107
|
-
color: var(--uil-white);
|
|
108
|
-
background-color: rgba(34, 34, 34, .9);
|
|
109
|
-
padding: var(--uil-s);
|
|
110
|
-
border-radius: 3px;
|
|
111
|
-
font-size: var(--uil-font-small);
|
|
112
|
-
line-height: var(--uil-font-small);
|
|
113
|
-
|
|
114
|
-
.uil-tooltip-button {
|
|
115
|
-
display: block;
|
|
116
|
-
margin-left: auto;
|
|
117
|
-
margin-bottom: var(--uil-m);
|
|
118
|
-
color: var(--uil-white);
|
|
119
|
-
background-color: transparent;
|
|
120
|
-
border: none;
|
|
121
|
-
padding: 0;
|
|
122
|
-
border-bottom: 1px solid var(--uil-white);
|
|
123
|
-
cursor: pointer;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.uil-password-rules {
|
|
129
|
-
margin-top: var(--uil-m);
|
|
130
|
-
display: flex;
|
|
131
|
-
flex-direction: column;
|
|
132
|
-
gap: var(--uil-xs);
|
|
133
|
-
margin-left: var(--uil-xs);
|
|
134
|
-
|
|
135
|
-
.uil-password-rule {
|
|
136
|
-
display: flex;
|
|
137
|
-
align-items: center;
|
|
138
|
-
gap: var(--uil-xxs);
|
|
139
|
-
font-size: var(--uil-font-small);
|
|
140
|
-
line-height: var(--uil-font-small);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import React, {useEffect, useState} from 'react';
|
|
2
|
-
import {CustomInput, ICustomInput} from './customInput';
|
|
3
|
-
import {SVG} from 'components/images/svgIcon';
|
|
4
|
-
import {PasswordRuleTypes} from 'enums/passwordRuleTypes';
|
|
5
|
-
|
|
6
|
-
interface IPasswordInput extends ICustomInput {
|
|
7
|
-
ruleChecked : string;
|
|
8
|
-
rules : PasswordRule[];
|
|
9
|
-
ruleUnchecked : string;
|
|
10
|
-
capsLockWarning?: string;
|
|
11
|
-
setFailedRules? : (value: PasswordRule[]) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface PasswordRule {
|
|
15
|
-
label : string;
|
|
16
|
-
count? : number;
|
|
17
|
-
type? : PasswordRuleTypes;
|
|
18
|
-
pattern?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function PasswordInput(props: IPasswordInput) {
|
|
22
|
-
const {
|
|
23
|
-
capsLockWarning,
|
|
24
|
-
rules,
|
|
25
|
-
ruleChecked,
|
|
26
|
-
ruleUnchecked,
|
|
27
|
-
setFailedRules,
|
|
28
|
-
...inputProps
|
|
29
|
-
} = props;
|
|
30
|
-
|
|
31
|
-
const [capsLock, setCapsLock] = useState(false);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
validateInput();
|
|
35
|
-
}, [props.value]);
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (!capsLockWarning) return;
|
|
39
|
-
|
|
40
|
-
function setCapsLockState(event: globalThis.KeyboardEvent) {
|
|
41
|
-
setCapsLock(event.getModifierState?.('CapsLock'));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
document.addEventListener('keydown', setCapsLockState);
|
|
45
|
-
|
|
46
|
-
return () => document.removeEventListener('keydown', setCapsLockState);
|
|
47
|
-
}, []);
|
|
48
|
-
|
|
49
|
-
function validateInput() {
|
|
50
|
-
const failedRules: PasswordRule[] = [];
|
|
51
|
-
|
|
52
|
-
rules.forEach(rule => {
|
|
53
|
-
if (!checkRule(rule)) {
|
|
54
|
-
failedRules.push(rule);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
setFailedRules?.(failedRules);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function checkRule(rule: PasswordRule): boolean {
|
|
62
|
-
let pattern: string;
|
|
63
|
-
|
|
64
|
-
if (rule.type) {
|
|
65
|
-
if (!rule.count) throw new Error('count must not be empty if a type is provided');
|
|
66
|
-
|
|
67
|
-
switch (rule.type) {
|
|
68
|
-
case PasswordRuleTypes.minLength:
|
|
69
|
-
pattern = `[a-zA-Z0-9ßÄäÖöÜü._!"\`'#%&§,:;<>=@{}~\\$\\(\\)\\*\\+\\/\\\\\\?\\[\\]\\^\\|\\-]{${rule.count},}`;
|
|
70
|
-
break;
|
|
71
|
-
case PasswordRuleTypes.maxLength:
|
|
72
|
-
pattern = `^[a-zA-Z0-9ßÄäÖöÜü._!"\`'#%&,:;<>=@{}~\\$\\(\\)\\*\\+\\/\\\\\\?\\[\\]\\^\\|\\-]{0,${rule.count}}$`;
|
|
73
|
-
break;
|
|
74
|
-
case PasswordRuleTypes.letters:
|
|
75
|
-
pattern = `[a-zA-ZßÄäÖöÜü]{${rule.count},}`;
|
|
76
|
-
break;
|
|
77
|
-
case PasswordRuleTypes.numbers:
|
|
78
|
-
pattern = `[0-9]{${rule.count},}`;
|
|
79
|
-
break;
|
|
80
|
-
case PasswordRuleTypes.special:
|
|
81
|
-
pattern = `[._!"\`'#%&§,:;<>=@{}~\\$\\(\\)\\*\\+\\/\\\\\\?\\[\\]\\^\\|\\-]{${rule.count},}`;
|
|
82
|
-
break;
|
|
83
|
-
case PasswordRuleTypes.upper:
|
|
84
|
-
pattern = `[A-ZÄÖÜ]{${rule.count},}`;
|
|
85
|
-
break;
|
|
86
|
-
default:
|
|
87
|
-
throw new Error('unrecognized rule type provided');
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
pattern = rule.pattern ? rule.pattern : '';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (pattern === '') throw new Error('pattern must not be an empty string');
|
|
94
|
-
|
|
95
|
-
const reg = new RegExp(pattern);
|
|
96
|
-
return reg.test(props.value);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<>
|
|
101
|
-
<CustomInput {...inputProps}/>
|
|
102
|
-
|
|
103
|
-
<div className={'uil-password-rules'}>
|
|
104
|
-
{capsLock &&
|
|
105
|
-
<div className={'uil-password-rule'}>{capsLockWarning}</div>
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
{rules.map((rule, idx) =>
|
|
109
|
-
<div key={idx} className={'uil-password-rule'}>
|
|
110
|
-
<SVG src={checkRule(rule) ? ruleChecked : ruleUnchecked} height={12} width={12}/>
|
|
111
|
-
|
|
112
|
-
<span>{rule.label}</span>
|
|
113
|
-
</div>
|
|
114
|
-
)}
|
|
115
|
-
</div>
|
|
116
|
-
</>
|
|
117
|
-
);
|
|
118
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import React, {useEffect, useRef} from 'react';
|
|
2
|
-
import {ModalType} from 'enums/modalType';
|
|
3
|
-
import {CustomButton} from 'components/button/customButton';
|
|
4
|
-
import useInjectStyleSheet from "utils/useInjectStyles";
|
|
5
|
-
|
|
6
|
-
interface IBaseModal {
|
|
7
|
-
close : () => void;
|
|
8
|
-
message : string | string[];
|
|
9
|
-
title : string;
|
|
10
|
-
type : ModalType;
|
|
11
|
-
callback? : (() => void) | undefined;
|
|
12
|
-
cancelLabel? : string;
|
|
13
|
-
closeLabel? : string;
|
|
14
|
-
confirm? : () => void;
|
|
15
|
-
confirmLabel?: string;
|
|
16
|
-
timeout? : number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function BaseModal(props: IBaseModal) {
|
|
20
|
-
const {
|
|
21
|
-
callback,
|
|
22
|
-
cancelLabel = '',
|
|
23
|
-
close,
|
|
24
|
-
closeLabel,
|
|
25
|
-
confirm,
|
|
26
|
-
confirmLabel = '',
|
|
27
|
-
message,
|
|
28
|
-
timeout,
|
|
29
|
-
title,
|
|
30
|
-
type
|
|
31
|
-
} = props;
|
|
32
|
-
|
|
33
|
-
let timer: NodeJS.Timeout | undefined = undefined;
|
|
34
|
-
const nodeRef = useRef<HTMLDivElement>(null);
|
|
35
|
-
useInjectStyleSheet(nodeRef);
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (!timeout) return;
|
|
39
|
-
|
|
40
|
-
timer = setTimeout(() => {
|
|
41
|
-
return callback ? callback() : close();
|
|
42
|
-
}, timeout);
|
|
43
|
-
|
|
44
|
-
return () => clearTimeout(timer);
|
|
45
|
-
},[]);
|
|
46
|
-
|
|
47
|
-
function setHeaderClass() {
|
|
48
|
-
const base = 'uil-header';
|
|
49
|
-
|
|
50
|
-
switch (type) {
|
|
51
|
-
case ModalType.error:
|
|
52
|
-
return `${base} uil-error`;
|
|
53
|
-
case ModalType.success:
|
|
54
|
-
return `${base} uil-success`;
|
|
55
|
-
case ModalType.warning:
|
|
56
|
-
return `${base} uil-warning`;
|
|
57
|
-
default:
|
|
58
|
-
return base;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
//run callback if timeout and callback are set, otherwise close
|
|
63
|
-
function handleClose() {
|
|
64
|
-
clearTimeout(timer);
|
|
65
|
-
timeout && callback ? callback() : close();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div className={'uil-modal-wrapper'} ref={nodeRef}>
|
|
70
|
-
<div className={'uil-modal'}>
|
|
71
|
-
<div className={setHeaderClass()}>
|
|
72
|
-
{title}
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
{timeout &&
|
|
76
|
-
<div className={'uil-progress-wrapper'}>
|
|
77
|
-
<div className={'uil-progress-bar'} style={{animationDuration: `${(timeout / 1000) + .5}s`}}/>
|
|
78
|
-
</div>
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
<div className={'uil-content'}>
|
|
82
|
-
<div>
|
|
83
|
-
{Array.isArray(message) ?
|
|
84
|
-
message.map((m, idx) => <p key={idx} className={'uil-modal-text'}>{m}</p>)
|
|
85
|
-
: <p className={'uil-modal-text'}>{message}</p>
|
|
86
|
-
}
|
|
87
|
-
</div>
|
|
88
|
-
|
|
89
|
-
<div className={`uil-button-wrapper ${type !== ModalType.question ? 'uil-single' : ''}`}>
|
|
90
|
-
{type !== ModalType.question &&
|
|
91
|
-
<CustomButton label={closeLabel?? ''} onClick={handleClose} type={'button'}/>
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
{type == ModalType.question && props.confirm &&
|
|
95
|
-
<>
|
|
96
|
-
<CustomButton label={confirmLabel} theme={'#00416A'} onClick={confirm} type={'button'}/>
|
|
97
|
-
<CustomButton label={cancelLabel} onClick={close} type={'button'}/>
|
|
98
|
-
</>
|
|
99
|
-
}
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
@use '../variables' as *;
|
|
2
|
-
|
|
3
|
-
.uil-modal-wrapper {
|
|
4
|
-
position: fixed;
|
|
5
|
-
left: 0;
|
|
6
|
-
top: 0;
|
|
7
|
-
width: 100%;
|
|
8
|
-
height: 100%;
|
|
9
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
10
|
-
z-index: 99;
|
|
11
|
-
|
|
12
|
-
.uil-modal {
|
|
13
|
-
position: absolute;
|
|
14
|
-
top: 30%;
|
|
15
|
-
left: 50%;
|
|
16
|
-
transform: translateX(-50%);
|
|
17
|
-
width: 95%;
|
|
18
|
-
-webkit-box-shadow: 0 0 6px 0 var(--uil-black);
|
|
19
|
-
box-shadow: 0 0 6px 0 var(--uil-black);
|
|
20
|
-
border-radius: 5px;
|
|
21
|
-
z-index: 999;
|
|
22
|
-
|
|
23
|
-
@include uil-desktop {
|
|
24
|
-
width: 75%;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@include uil-widescreen {
|
|
28
|
-
width: 55%;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@include uil-fullHD {
|
|
32
|
-
width: 35%;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.uil-progress-wrapper {
|
|
36
|
-
background-color: var(--uil-grey-alt);
|
|
37
|
-
|
|
38
|
-
& .uil-progress-bar {
|
|
39
|
-
border: 2px solid var(--uil-grey-dark);
|
|
40
|
-
animation-duration: 2s;
|
|
41
|
-
animation-iteration-count: initial;
|
|
42
|
-
animation-name: uil-progress;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@keyframes uil-progress {
|
|
47
|
-
0% {
|
|
48
|
-
width: 100%;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
100% {
|
|
52
|
-
width: 0;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.uil-header {
|
|
57
|
-
color: var(--uil-white);
|
|
58
|
-
background-color: var(--uil-question);
|
|
59
|
-
display: flex;
|
|
60
|
-
justify-content: space-between;
|
|
61
|
-
font-size: var(--uil-xl);
|
|
62
|
-
line-height: var(--uil-xl);
|
|
63
|
-
font-weight: bold;
|
|
64
|
-
margin: 0;
|
|
65
|
-
padding: var(--uil-s);
|
|
66
|
-
border-top-left-radius: 3px;
|
|
67
|
-
border-top-right-radius: 3px;
|
|
68
|
-
|
|
69
|
-
@include uil-desktop {
|
|
70
|
-
font-size: var(--uil-xxxl);
|
|
71
|
-
line-height: var(--uil-xxxl);
|
|
72
|
-
padding: var(--uil-m);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&.uil-success {
|
|
76
|
-
background-color: var(--uil-success);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
&.uil-error {
|
|
80
|
-
background-color: var(--uil-error);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
&.uil-warning {
|
|
84
|
-
color: var(--uil-black);
|
|
85
|
-
background-color: var(--uil-warning);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.uil-content {
|
|
90
|
-
background-color: var(--uil-white);
|
|
91
|
-
padding: var(--uil-m);
|
|
92
|
-
border-bottom-left-radius: 3px;
|
|
93
|
-
border-bottom-right-radius: 3px;
|
|
94
|
-
display: flex;
|
|
95
|
-
flex-direction: column;
|
|
96
|
-
gap: var(--uil-m);
|
|
97
|
-
|
|
98
|
-
@include uil-desktop {
|
|
99
|
-
padding: var(--uil-l);
|
|
100
|
-
gap: var(--uil-xxxl);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.uil-modal-text {
|
|
104
|
-
font-size: var(--uil-font-small);
|
|
105
|
-
line-height: var(--uil-font-small);
|
|
106
|
-
color: var(--uil-black);
|
|
107
|
-
margin: var(--uil-s) 0;
|
|
108
|
-
|
|
109
|
-
@include uil-tablet {
|
|
110
|
-
font-size: var(--uil-font-base);
|
|
111
|
-
line-height: var(--uil-font-base);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.uil-button-wrapper {
|
|
116
|
-
display: flex;
|
|
117
|
-
justify-content: space-between;
|
|
118
|
-
|
|
119
|
-
&.uil-single {
|
|
120
|
-
justify-content: end;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {BaseModal} from './baseModal';
|
|
3
|
-
import {ModalType} from 'enums/modalType';
|
|
4
|
-
|
|
5
|
-
export interface INotifyModal {
|
|
6
|
-
close : () => void;
|
|
7
|
-
closeLabel: string;
|
|
8
|
-
modalType : 'success' | 'warning' | 'error';
|
|
9
|
-
message : string | string[];
|
|
10
|
-
title : string;
|
|
11
|
-
callback? : (() => void) | undefined;
|
|
12
|
-
timeout? : number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function NotifyModal(props: INotifyModal) {
|
|
16
|
-
const {
|
|
17
|
-
modalType,
|
|
18
|
-
...modalProps
|
|
19
|
-
} = props;
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<BaseModal type={modalType as ModalType} {...modalProps}/>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {BaseModal} from './baseModal';
|
|
3
|
-
import {ModalType} from 'enums/modalType';
|
|
4
|
-
|
|
5
|
-
export interface IQuestionModal {
|
|
6
|
-
cancel : () => void;
|
|
7
|
-
cancelLabel : string;
|
|
8
|
-
confirm : () => void;
|
|
9
|
-
confirmLabel: string;
|
|
10
|
-
message : string | string[];
|
|
11
|
-
title : string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function QuestionModal(props: IQuestionModal) {
|
|
15
|
-
const {
|
|
16
|
-
cancel,
|
|
17
|
-
...modalProps
|
|
18
|
-
} = props;
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<BaseModal type={ModalType.question} close={cancel} {...modalProps}/>
|
|
22
|
-
);
|
|
23
|
-
}
|