@itcase/ui 1.0.4 → 1.0.6
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/components/Avatar.js +56 -31
- package/dist/components/{Counter.js → Badge.js} +7 -7
- package/dist/components/Button.js +55 -56
- package/dist/components/Cell.js +14 -14
- package/dist/components/Checkbox.js +74 -22
- package/dist/components/Chips.js +2 -20
- package/dist/components/Divider.js +17 -1
- package/dist/components/Group.js +13 -1
- package/dist/components/Icon.js +45 -26
- package/dist/components/Input.js +19 -2
- package/dist/components/Label.js +11 -3
- package/dist/components/Logo.js +24 -12
- package/dist/components/MenuItem.js +11 -2
- package/dist/components/Modal.js +219 -41
- package/dist/components/Profile.js +10 -4
- package/dist/components/RadioButton.js +78 -26
- package/dist/components/Scrollbar.js +4 -4
- package/dist/components/Select.js +2 -2
- package/dist/components/Switch.js +2 -1
- package/dist/components/Tab.js +205 -0
- package/dist/components/Text.js +1 -3
- package/dist/components/Textarea.js +9 -1
- package/dist/components/Tile.js +43 -115
- package/dist/css/components/Avatar/Avatar.css +23 -10
- package/dist/css/components/Badge/Badge.css +55 -0
- package/dist/css/components/Button/Button.css +19 -8
- package/dist/css/components/Checkbox/Checkbox.css +60 -63
- package/dist/css/components/Chips/Chips.css +25 -7
- package/dist/css/components/Fader/Fader.css +0 -1
- package/dist/css/components/Icon/Icon.css +4 -4
- package/dist/css/components/Input/Input.css +6 -0
- package/dist/css/components/List/List.css +3 -3
- package/dist/css/components/Logo/Logo.css +23 -0
- package/dist/css/components/{Popup/Popup.css → Modal/Modal.css} +5 -4
- package/dist/css/components/RadioButton/RadioButton.css +60 -59
- package/dist/css/components/Switch/Switch.css +56 -46
- package/dist/css/components/Tab/Tab.css +46 -0
- package/dist/css/components/Tile/Tile.css +27 -10
- package/dist/css/styles/border-color/border-color.css +2 -2
- package/dist/css/styles/border-type/border-type.css +13 -0
- package/dist/css/styles/border-width/border-width.css +7 -0
- package/package.json +2 -1
- package/dist/components/Popup.js +0 -255
- package/dist/css/components/Counter/Counter.css +0 -55
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.
|
|
1
|
+
.modal {
|
|
2
2
|
width: 100%;
|
|
3
3
|
min-height: 100%;
|
|
4
4
|
position: fixed;
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
display: flex;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
.
|
|
18
|
+
.modal-content {
|
|
19
19
|
width: 100%;
|
|
20
|
-
max-width: var(--
|
|
20
|
+
max-width: var(--modal-max-width);
|
|
21
21
|
border-radius: 8px;
|
|
22
22
|
position: relative;
|
|
23
|
-
|
|
23
|
+
height: 200px;
|
|
24
|
+
width: 200px;
|
|
24
25
|
&__close {
|
|
25
26
|
position: absolute;
|
|
26
27
|
top: 8px;
|
|
@@ -1,40 +1,60 @@
|
|
|
1
1
|
.radio-button {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
min-width: 16px;
|
|
9
|
-
&__button {
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-template-columns: auto 1fr;
|
|
4
|
+
grid-template-rows: auto auto;
|
|
5
|
+
column-gap: 4px;
|
|
6
|
+
&__item {
|
|
7
|
+
position: relative;
|
|
10
8
|
cursor: pointer;
|
|
11
|
-
appearance: none;
|
|
12
|
-
border: 0;
|
|
13
|
-
margin: 0;
|
|
14
9
|
font-size: 0;
|
|
15
10
|
line-height: 0;
|
|
16
|
-
position: absolute;
|
|
17
|
-
left: 0;
|
|
18
|
-
top: 0;
|
|
19
|
-
width: 100%;
|
|
20
|
-
height: 100%;
|
|
21
|
-
z-index: 3;
|
|
22
|
-
}
|
|
23
|
-
&__bg {
|
|
24
|
-
flex: 1;
|
|
25
11
|
display: flex;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
12
|
+
min-height: 16px;
|
|
13
|
+
min-width: 16px;
|
|
14
|
+
grid-row-start: span 2;
|
|
15
|
+
align-self: start;
|
|
16
|
+
^&__input {
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
appearance: none;
|
|
19
|
+
border: 0;
|
|
20
|
+
margin: 0;
|
|
21
|
+
font-size: 0;
|
|
22
|
+
line-height: 0;
|
|
23
|
+
position: absolute;
|
|
24
|
+
left: 0;
|
|
25
|
+
top: 0;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
z-index: 3;
|
|
29
|
+
}
|
|
30
|
+
^&__state {
|
|
31
|
+
flex: 1;
|
|
32
|
+
display: flex;
|
|
33
|
+
z-index: 1;
|
|
34
|
+
&_shape {
|
|
35
|
+
&_rounded {
|
|
36
|
+
border-radius: 4px;
|
|
37
|
+
position: relative;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
}
|
|
40
|
+
&_circular {
|
|
41
|
+
border-radius: 50%;
|
|
42
|
+
position: relative;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
^&__state-checkmark {
|
|
48
|
+
height: calc(100% - 6px);
|
|
49
|
+
width: calc(100% - 6px);
|
|
50
|
+
position: absolute;
|
|
51
|
+
z-index: 2;
|
|
52
|
+
left: 50%;
|
|
53
|
+
top: 50%;
|
|
54
|
+
transform: translate(-50%, -50%);
|
|
55
|
+
display: none;
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
}
|
|
38
58
|
}
|
|
39
59
|
}
|
|
40
60
|
.radio-button {
|
|
@@ -52,39 +72,20 @@
|
|
|
52
72
|
}
|
|
53
73
|
}
|
|
54
74
|
.radio-button {
|
|
55
|
-
&
|
|
56
|
-
&
|
|
57
|
-
@each $type in accent, primary, secondary, tertiary, surface, success, error {
|
|
58
|
-
&_$(type) {
|
|
59
|
-
@each $color in primary, secondary, tertiary, quaternary, quinary, senary, accent, disabled, hover {
|
|
60
|
-
&-$(color) {
|
|
61
|
-
& ^^^^&__button {
|
|
62
|
-
&:checked {
|
|
63
|
-
& + ^^^^^^&__bg {
|
|
64
|
-
background: var(--color-$(type)-$(color));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
.radio-button {
|
|
76
|
-
&_fill {
|
|
77
|
-
&_checkmark {
|
|
75
|
+
&_checkmark {
|
|
76
|
+
&_fill {
|
|
78
77
|
@each $type in accent, primary, secondary, tertiary, surface, success, error {
|
|
79
78
|
&_$(type) {
|
|
80
79
|
&-item {
|
|
81
80
|
@each $color in primary, secondary, tertiary, quaternary, quinary, senary, accent, disabled, hover {
|
|
82
81
|
&-$(color) {
|
|
83
|
-
& ^^^^^&
|
|
82
|
+
& ^^^^^&__input {
|
|
84
83
|
&:checked {
|
|
85
|
-
& ~ ^^^^^^^&
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
& ~ ^^^^^^^&__state {
|
|
85
|
+
&-checkmark {
|
|
86
|
+
display: block;
|
|
87
|
+
background: var(--color-$(type)-item-$(color));
|
|
88
|
+
}
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
}
|
|
@@ -1,53 +1,63 @@
|
|
|
1
1
|
.switch {
|
|
2
2
|
position: relative;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
3
|
+
}
|
|
4
|
+
.switch {
|
|
5
|
+
&_size {
|
|
6
|
+
&_normal {
|
|
7
|
+
position: relative;
|
|
8
|
+
min-width: 52px;
|
|
9
|
+
height: 100%;
|
|
10
|
+
border-radius: 50px;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
transition: 0.4s;
|
|
13
|
+
min-height: 32px;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
display: flex;
|
|
16
|
+
^^&__checkbox {
|
|
17
|
+
position: absolute;
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
left: 0;
|
|
21
|
+
top: 0;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
appearance: none;
|
|
24
|
+
border: 0;
|
|
25
|
+
margin: 0;
|
|
26
|
+
z-index: 2;
|
|
27
|
+
&:checked {
|
|
28
|
+
& + .switch__bg {
|
|
29
|
+
background: var(--color-accent-primary);
|
|
30
|
+
}
|
|
31
|
+
& ~ .switch__toggle {
|
|
32
|
+
left: 100%;
|
|
33
|
+
margin: 0 0 0 -3px;
|
|
34
|
+
background: var(--color-accent-item-primary);
|
|
35
|
+
transform: translate(-100%, -50%);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
^^&__bg {
|
|
40
|
+
width: 100%;
|
|
41
|
+
flex: 1;
|
|
42
|
+
background: var(--color-surface-tertiary);
|
|
43
|
+
transition: all 0.25s;
|
|
25
44
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
^^&__toggle {
|
|
46
|
+
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
|
|
47
|
+
height: calc(100% - 6px);
|
|
48
|
+
position: absolute;
|
|
49
|
+
aspect-ratio: 1/1;
|
|
50
|
+
top: 50%;
|
|
51
|
+
transform: translate(3px, -50%);
|
|
52
|
+
left: 0;
|
|
53
|
+
background: #fff;
|
|
54
|
+
border-radius: 50%;
|
|
55
|
+
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
|
|
56
|
+
transition: all 0.25s;
|
|
31
57
|
}
|
|
32
58
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
flex: 1;
|
|
37
|
-
background: var(--color-surface-tertiary);
|
|
38
|
-
transition: all 0.25s;
|
|
39
|
-
}
|
|
40
|
-
&__toggle {
|
|
41
|
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
|
|
42
|
-
height: calc(100% - 6px);
|
|
43
|
-
position: absolute;
|
|
44
|
-
aspect-ratio: 1/1;
|
|
45
|
-
top: 50%;
|
|
46
|
-
transform: translate(3px, -50%);
|
|
47
|
-
left: 0;
|
|
48
|
-
background: #fff;
|
|
49
|
-
border-radius: 50%;
|
|
50
|
-
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
|
|
51
|
-
transition: all 0.25s;
|
|
59
|
+
&_compact {
|
|
60
|
+
border: solid 1px red;
|
|
61
|
+
}
|
|
52
62
|
}
|
|
53
63
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.tab {
|
|
2
|
+
&__label {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
align-content: center;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
.tab {
|
|
9
|
+
@each $val in flex-start, flex-end, center, space-between, space-around, space-evenly {
|
|
10
|
+
&_justify-content_$(val) {
|
|
11
|
+
& > a {
|
|
12
|
+
justify-content: $(val);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
.tab {
|
|
18
|
+
&_shape {
|
|
19
|
+
&_rounded {
|
|
20
|
+
border-radius: 12px;
|
|
21
|
+
}
|
|
22
|
+
&_circular {
|
|
23
|
+
border-radius: 50%;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
.tab {
|
|
28
|
+
&_size {
|
|
29
|
+
@each $size in normal, compact {
|
|
30
|
+
&_$(size) {
|
|
31
|
+
^^&__label {
|
|
32
|
+
padding: var(--tab-size-$(size)-padding);
|
|
33
|
+
gap: var(--tab-size-$(size)-gap);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
:root {
|
|
40
|
+
--tab-size-normal-padding: 10px;
|
|
41
|
+
--tab-size-normal-gap: 10px;
|
|
42
|
+
|
|
43
|
+
--tab-size-compact-padding: 10px;
|
|
44
|
+
--tab-size-compact-gap: 10px;
|
|
45
|
+
}
|
|
46
|
+
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
.tile {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
.tile {
|
|
5
|
-
&_type {
|
|
6
|
-
&_icon {
|
|
7
|
-
padding: 16px;
|
|
8
|
-
^^&__icon {
|
|
9
|
-
margin: 0 0 16px 0;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
2
|
+
&__wrapper {
|
|
3
|
+
position: relative;
|
|
12
4
|
}
|
|
13
5
|
}
|
|
14
6
|
.tile {
|
|
@@ -21,3 +13,28 @@
|
|
|
21
13
|
}
|
|
22
14
|
}
|
|
23
15
|
}
|
|
16
|
+
.tile {
|
|
17
|
+
&_size {
|
|
18
|
+
@each $size in normal, compact {
|
|
19
|
+
&_$(size) {
|
|
20
|
+
padding: var(--tile-size-$(size)-padding);
|
|
21
|
+
min-width: var(--tile-size-$(size)-min-width);
|
|
22
|
+
& ^^&__wrapper {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-flow: column;
|
|
25
|
+
gap: var(--tile-size-$(size)-gap);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
.tile {
|
|
32
|
+
&_type {
|
|
33
|
+
&_icon {
|
|
34
|
+
padding: 16px;
|
|
35
|
+
^^&__icon {
|
|
36
|
+
margin: 0 0 16px 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@each $type in accent, primary, secondary, tertiary, surface, success, error {
|
|
3
3
|
&_$(type) {
|
|
4
4
|
&-border {
|
|
5
|
-
@each $color in primary, secondary, tertiary, quaternary, quinary, senary, accent, disabled, hover {
|
|
5
|
+
@each $color in primary, secondary, tertiary, quaternary, quinary, senary, accent, active, disabled, hover {
|
|
6
6
|
&-$(color) {
|
|
7
7
|
border-width: 1px;
|
|
8
8
|
border-style: solid;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
&_hover {
|
|
15
15
|
&_$(type) {
|
|
16
16
|
&-border {
|
|
17
|
-
@each $color in primary, secondary, tertiary, quaternary, quinary, senary, accent, disabled, hover {
|
|
17
|
+
@each $color in primary, secondary, tertiary, quaternary, quinary, senary, accent, active, disabled, hover {
|
|
18
18
|
&-$(color) {
|
|
19
19
|
&:hover {
|
|
20
20
|
border-color: var(--color-$(type)-border-$(color));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "UI components (Modal, Loader, Popup, etc)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Modal",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"eslint-plugin-prettier": "^4.2.1",
|
|
86
86
|
"eslint-plugin-promise": "^6.1.1",
|
|
87
87
|
"eslint-plugin-react": "^7.32.2",
|
|
88
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
88
89
|
"eslint-plugin-standard": "^5.0.0",
|
|
89
90
|
"husky": "^8.0.3",
|
|
90
91
|
"lint-staged": "^13.2.3",
|
package/dist/components/Popup.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var PropTypes = require('prop-types');
|
|
5
|
-
var ReactDOM = require('react-dom');
|
|
6
|
-
var clsx = require('clsx');
|
|
7
|
-
var index = require('./Icon.js');
|
|
8
|
-
var index$1 = require('./Text.js');
|
|
9
|
-
var index$2 = require('./Fader.js');
|
|
10
|
-
require('lodash/camelCase');
|
|
11
|
-
require('lodash/maxBy');
|
|
12
|
-
require('lodash/upperFirst');
|
|
13
|
-
require('../context/UIContext.js');
|
|
14
|
-
var useDeviceTargetClass = require('../hooks/useDeviceTargetClass.js');
|
|
15
|
-
var index$3 = require('./Loader.js');
|
|
16
|
-
require('react-inlinesvg');
|
|
17
|
-
require('../constants/componentProps/fill.js');
|
|
18
|
-
require('../constants/componentProps/iconSize.js');
|
|
19
|
-
require('../constants/componentProps/shape.js');
|
|
20
|
-
require('../constants/componentProps/strokeColor.js');
|
|
21
|
-
require('./Link.js');
|
|
22
|
-
require('../useStyles-e4accb53.js');
|
|
23
|
-
require('../hooks/styleAttributes.js');
|
|
24
|
-
require('../constants/componentProps/size.js');
|
|
25
|
-
require('../constants/componentProps/textColor.js');
|
|
26
|
-
require('../constants/componentProps/textGradient.js');
|
|
27
|
-
require('../constants/componentProps/textStyle.js');
|
|
28
|
-
require('../constants/componentProps/textWeight.js');
|
|
29
|
-
require('../constants/componentProps/type.js');
|
|
30
|
-
require('../constants/componentProps/underline.js');
|
|
31
|
-
require('../hooks/useMediaQueries.js');
|
|
32
|
-
require('react-responsive');
|
|
33
|
-
require('lodash/castArray');
|
|
34
|
-
require('../constants/componentProps/textColorActive.js');
|
|
35
|
-
require('../constants/componentProps/textColorHover.js');
|
|
36
|
-
require('../constants/componentProps/fillGradient.js');
|
|
37
|
-
|
|
38
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
39
|
-
|
|
40
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
41
|
-
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
42
|
-
var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
43
|
-
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
44
|
-
|
|
45
|
-
var getOrCreatePopupElement = function getOrCreatePopupElement(popupQuerySelector, className) {
|
|
46
|
-
if (className === void 0) {
|
|
47
|
-
className = '';
|
|
48
|
-
}
|
|
49
|
-
// prettier-ignore
|
|
50
|
-
var classList = className && typeof className === 'string' ? className.split(' ').filter(Boolean) : [];
|
|
51
|
-
var popupElement = document.querySelector(popupQuerySelector);
|
|
52
|
-
if (!popupElement) {
|
|
53
|
-
// Add popup element into the DOM on mount.
|
|
54
|
-
popupElement = document.createElement('div');
|
|
55
|
-
popupElement.setAttribute('id', 'popup-global');
|
|
56
|
-
popupElement.classList.add('popup');
|
|
57
|
-
if (classList.length) {
|
|
58
|
-
var _popupElement$classLi;
|
|
59
|
-
(_popupElement$classLi = popupElement.classList).add.apply(_popupElement$classLi, classList);
|
|
60
|
-
}
|
|
61
|
-
document.body.prepend(popupElement);
|
|
62
|
-
}
|
|
63
|
-
return popupElement;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// Popup component that is an abstraction around the portal API.
|
|
67
|
-
var Popup = /*#__PURE__*/React__default.default.forwardRef(function Popup(props, ref) {
|
|
68
|
-
var children = props.children,
|
|
69
|
-
className = props.className,
|
|
70
|
-
closeIcon = props.closeIcon,
|
|
71
|
-
closeIconFill = props.closeIconFill,
|
|
72
|
-
closeIconSize = props.closeIconSize,
|
|
73
|
-
closeText = props.closeText;
|
|
74
|
-
props.contentFill;
|
|
75
|
-
var contentClassName = props.contentClassName,
|
|
76
|
-
id = props.id,
|
|
77
|
-
isFader = props.isFader,
|
|
78
|
-
faderFill = props.faderFill,
|
|
79
|
-
faderFillGradient = props.faderFillGradient,
|
|
80
|
-
faderOpacity = props.faderOpacity,
|
|
81
|
-
initialIsOpen = props.isOpen,
|
|
82
|
-
isScrollOnOpen = props.isScrollOnOpen,
|
|
83
|
-
isSetFocusOnOpen = props.isSetFocusOnOpen,
|
|
84
|
-
popupQuerySelector = props.popupQuerySelector,
|
|
85
|
-
debug = props.debug,
|
|
86
|
-
onClosePopup = props.onClosePopup,
|
|
87
|
-
onOpenPopup = props.onOpenPopup;
|
|
88
|
-
|
|
89
|
-
// Query DOM element
|
|
90
|
-
var _useState = React.useState(null),
|
|
91
|
-
popupElement = _useState[0],
|
|
92
|
-
setPopupElement = _useState[1];
|
|
93
|
-
React.useLayoutEffect(function () {
|
|
94
|
-
var element = getOrCreatePopupElement(popupQuerySelector, className);
|
|
95
|
-
setPopupElement(element);
|
|
96
|
-
if (element) {
|
|
97
|
-
addPopupProps(element);
|
|
98
|
-
}
|
|
99
|
-
}, []);
|
|
100
|
-
var popupContentRef = React.useRef(null);
|
|
101
|
-
var popupFaderRef = React.useRef(null);
|
|
102
|
-
var _useState2 = React.useState(initialIsOpen),
|
|
103
|
-
isOpen = _useState2[0],
|
|
104
|
-
setIsOpen = _useState2[1];
|
|
105
|
-
var addPopupProps = React.useCallback(function (element) {
|
|
106
|
-
// Change class need in "useEffect"
|
|
107
|
-
if (isOpen) {
|
|
108
|
-
// Show popup
|
|
109
|
-
element.classList.add('popup_state_visible');
|
|
110
|
-
// Scroll to opened popup
|
|
111
|
-
if (isScrollOnOpen) {
|
|
112
|
-
// popupContentRef.current.style.top = `${window.visualViewport.pageTop}px`
|
|
113
|
-
element.scrollIntoView({
|
|
114
|
-
block: 'center',
|
|
115
|
-
behavior: 'smooth'
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// "setTimeout" in this implementation is needs for set focus on popup
|
|
120
|
-
// after "onMouseDown" event on button
|
|
121
|
-
if (isSetFocusOnOpen) {
|
|
122
|
-
setTimeout(function () {
|
|
123
|
-
return popupContentRef.current.focus();
|
|
124
|
-
}, 0);
|
|
125
|
-
}
|
|
126
|
-
} else if (!element.children.length) {
|
|
127
|
-
// Hide popup if has no children
|
|
128
|
-
element.classList.remove('popup_state_visible');
|
|
129
|
-
}
|
|
130
|
-
}, [isOpen, isSetFocusOnOpen]);
|
|
131
|
-
React.useEffect(function () {
|
|
132
|
-
if (!popupElement) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
addPopupProps(popupElement);
|
|
136
|
-
}, [isOpen]); // eslint-disable-line
|
|
137
|
-
|
|
138
|
-
// Show popup with children content
|
|
139
|
-
var openPopup = React.useCallback(function () {
|
|
140
|
-
setIsOpen(true);
|
|
141
|
-
|
|
142
|
-
// Callback
|
|
143
|
-
if (typeof onOpenPopup === 'function') {
|
|
144
|
-
onOpenPopup();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/* SHOW TARGET POPUP ABOVE OTHERS POPUPS IF TARGET ALREADY OPENED
|
|
148
|
-
// If current popup is already opened
|
|
149
|
-
// Move content to end of popup root container. For order in DOM.
|
|
150
|
-
const popupContentElement = popupContentRef.current
|
|
151
|
-
if (popupContentElement) {
|
|
152
|
-
popupContentElement.parentNode.appendChild(popupContentElement)
|
|
153
|
-
}
|
|
154
|
-
// Also move fader to end of popup root container after container
|
|
155
|
-
const popupFaderElement = popupFaderRef.current
|
|
156
|
-
if (popupFaderElement) {
|
|
157
|
-
popupFaderElement.parentNode.appendChild(popupFaderElement)
|
|
158
|
-
}
|
|
159
|
-
*/
|
|
160
|
-
}, [onOpenPopup]);
|
|
161
|
-
|
|
162
|
-
// Hide popup and unmount children content
|
|
163
|
-
var closePopup = React.useCallback(function (event) {
|
|
164
|
-
if (event === void 0) {
|
|
165
|
-
event = {};
|
|
166
|
-
}
|
|
167
|
-
var hasRelatedTarget = event.relatedTarget && popupElement.contains(event.relatedTarget);
|
|
168
|
-
if (hasRelatedTarget) {
|
|
169
|
-
return event;
|
|
170
|
-
}
|
|
171
|
-
setIsOpen(false);
|
|
172
|
-
|
|
173
|
-
// Callback
|
|
174
|
-
if (typeof onClosePopup === 'function') {
|
|
175
|
-
onClosePopup();
|
|
176
|
-
}
|
|
177
|
-
}, [popupElement, onClosePopup]);
|
|
178
|
-
|
|
179
|
-
// Save ref things
|
|
180
|
-
React.useImperativeHandle(ref, function () {
|
|
181
|
-
return {
|
|
182
|
-
isOpen: isOpen,
|
|
183
|
-
openPopup: openPopup,
|
|
184
|
-
closePopup: closePopup,
|
|
185
|
-
popupElement: popupElement
|
|
186
|
-
};
|
|
187
|
-
});
|
|
188
|
-
var contentFillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
189
|
-
prefix: 'fill_',
|
|
190
|
-
propsKey: 'contentFill'
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
// Use a portal to render the children into the element
|
|
194
|
-
return popupElement && /*#__PURE__*/ReactDOM__default.default.createPortal(
|
|
195
|
-
// Any valid React child: JSX, strings, arrays, etc.
|
|
196
|
-
isOpen ? /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, /*#__PURE__*/React__default.default.createElement("div", {
|
|
197
|
-
ref: popupContentRef,
|
|
198
|
-
className: clsx__default.default('popup-content', contentClassName, contentFillClass),
|
|
199
|
-
id: id,
|
|
200
|
-
tabIndex: 0,
|
|
201
|
-
onBlur: debug ? undefined : closePopup
|
|
202
|
-
}, closeIcon && /*#__PURE__*/React__default.default.createElement("div", {
|
|
203
|
-
className: "popup-content__close",
|
|
204
|
-
onClick: closePopup
|
|
205
|
-
}, closeIcon && /*#__PURE__*/React__default.default.createElement(index.Icon, {
|
|
206
|
-
SvgImage: closeIcon,
|
|
207
|
-
size: closeIconSize,
|
|
208
|
-
fill: closeIconFill
|
|
209
|
-
}), closeText && /*#__PURE__*/React__default.default.createElement(index$1.Text, null, closeText)), children), /*#__PURE__*/React__default.default.createElement(index$2.Fader, {
|
|
210
|
-
ref: popupFaderRef,
|
|
211
|
-
fill: faderFill,
|
|
212
|
-
fillGradient: faderFillGradient,
|
|
213
|
-
opacity: faderOpacity,
|
|
214
|
-
className: "popup__fader",
|
|
215
|
-
isFader: isFader
|
|
216
|
-
})) : null,
|
|
217
|
-
// A DOM element
|
|
218
|
-
popupElement);
|
|
219
|
-
});
|
|
220
|
-
Popup.propTypes = {
|
|
221
|
-
children: PropTypes__default.default.any,
|
|
222
|
-
className: PropTypes__default.default.string,
|
|
223
|
-
closeIcon: PropTypes__default.default.string,
|
|
224
|
-
closeText: PropTypes__default.default.string,
|
|
225
|
-
faderFill: PropTypes__default.default.string,
|
|
226
|
-
faderFillGradient: PropTypes__default.default.string,
|
|
227
|
-
faderOpacity: PropTypes__default.default.string,
|
|
228
|
-
contentClassName: PropTypes__default.default.string,
|
|
229
|
-
id: PropTypes__default.default.string,
|
|
230
|
-
isFader: PropTypes__default.default.bool,
|
|
231
|
-
isScrollOnOpen: PropTypes__default.default.bool,
|
|
232
|
-
isSetFocusOnOpen: PropTypes__default.default.bool,
|
|
233
|
-
popupQuerySelector: PropTypes__default.default.string,
|
|
234
|
-
debug: PropTypes__default.default.bool,
|
|
235
|
-
onClosePopup: PropTypes__default.default.func,
|
|
236
|
-
onOpenPopup: PropTypes__default.default.func
|
|
237
|
-
};
|
|
238
|
-
Popup.defaultProps = {
|
|
239
|
-
isFader: true,
|
|
240
|
-
isOpen: false,
|
|
241
|
-
isScrollOnOpen: true,
|
|
242
|
-
isSetFocusOnOpen: true,
|
|
243
|
-
popupQuerySelector: '#popup-global'
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
function PopupLoader(props) {
|
|
247
|
-
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
248
|
-
className: "popup-loading"
|
|
249
|
-
}, /*#__PURE__*/React__default.default.createElement("div", {
|
|
250
|
-
className: "popup-loading__inner"
|
|
251
|
-
}, /*#__PURE__*/React__default.default.createElement(index$3.Loader, null)));
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
exports.Popup = Popup;
|
|
255
|
-
exports.PopupLoader = PopupLoader;
|