aio-popup 3.3.0 → 4.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.
Files changed (4) hide show
  1. package/index.css +65 -110
  2. package/index.d.ts +35 -65
  3. package/index.js +8 -1283
  4. package/package.json +1 -1
package/index.css CHANGED
@@ -1,127 +1,66 @@
1
+ .aio-popup-backdrop.not-mounted {
2
+ background: none !important;
3
+ transition: .3s;
4
+ }
5
+
1
6
  .aio-popup-backdrop {
2
7
  position: fixed;
3
8
  display: flex;
4
9
  width: 100%;
5
10
  height: 100%;
6
- left: 0;
7
- top: 0;
11
+ left: 0 !important;
12
+ top: 0 !important;
8
13
  align-items: center;
9
14
  justify-content: center;
10
15
  z-index: 10000;
11
16
  background: rgba(0, 0, 0, 0.1);
12
- transition: 0.3s;
17
+ transition: .3s;
13
18
  pointer-events: all;
19
+ outline:none;
20
+ flex-shrink:0;
14
21
  }
15
-
16
- .aio-popup.not-mounted {
17
- transition: 0.3s;
18
- }
19
-
20
- .aio-popup-position-fullscreen>.aio-popup.not-mounted {
21
- transform: scale(0);
22
-
23
- }
24
-
25
- .aio-popup-position-popover>.aio-popup.not-mounted {
26
- opacity: 0;
27
- }
28
-
29
- .aio-popup-position-top>.aio-popup.not-mounted {
30
- top: -500px;
31
- }
32
-
33
- .aio-popup-position-bottom>.aio-popup.not-mounted {
34
- bottom: -500px;
35
- opacity: 0;
36
- }
37
-
38
- .aio-popup-position-right>.aio-popup.not-mounted {
39
- right: -500px;
40
- }
41
-
42
- .aio-popup-position-left>.aio-popup.not-mounted {
43
- left: -500px;
44
- }
45
-
46
- .aio-popup-position-center>.aio-popup.not-mounted {
47
- transform: translateY(500px);
48
- opacity: 0;
49
- }
50
-
51
- .aio-popup-position-fullscreen>.aio-popup {
52
- width: 100%;
53
- height: 100%;
54
- }
55
-
56
- .aio-popup-position-popover {
57
- opacity: 1;
58
- }
59
-
60
- .aio-popup-position-top {
61
- align-items: flex-start;
62
- }
63
-
64
- .aio-popup-position-top>.aio-popup {
65
- width: 100%;
66
- max-height: 90vh;
67
- top: 0;
68
- }
69
-
70
- .aio-popup-position-bottom {
71
- align-items: flex-end;
72
- }
73
-
74
- .aio-popup-position-bottom>.aio-popup {
75
- width: 100%;
76
- max-height: 90vh;
77
- bottom: 0;
78
- opacity: 1;
79
- }
80
-
81
- .aio-popup-backdrop.not-mounted {
82
- background: none !important;
83
- transition: 0.3s;
84
- }
85
-
86
- .aio-popup-position-right {
87
- justify-content: right;
88
- }
89
-
90
- .aio-popup-position-right .aio-popup {
91
- height: 100%;
92
- max-width: 90vh;
93
- right: 0;
94
- }
95
-
96
- .aio-popup-position-left {
97
- justify-content: left;
98
- }
99
-
100
- .aio-popup-position-left>.aio-popup {
101
- height: 100%;
102
- max-width: 90vh;
103
- left: 0;
104
- }
105
-
106
- .aio-popup-position-center>.aio-popup {
107
- max-width: 100vw;
108
- width: fit-content;
109
- opacity: 1;
110
- max-height: 100vh;
111
- }
112
-
113
22
  .aio-popup {
114
23
  border-radius: 4px;
115
24
  font-size: 14px;
116
- transition: 0.3s;
25
+ transition: .3s;
117
26
  max-width: 100vw;
118
27
  max-height: 100vh;
119
28
  pointer-events: auto;
120
- }
121
-
122
- .aio-popup.rtl {
123
- direction: rtl;
124
- }
29
+ display:flex;
30
+ flex-direction: column;
31
+ outline:none;
32
+ z-index:10;
33
+ position:absolute;
34
+ }
35
+ .aio-popup.rtl {direction: rtl;}
36
+ .aio-popup.not-mounted {transition: .3s;}
37
+ /**********position (fullscreen)*******/
38
+ .aio-popup-position-fullscreen>.aio-popup.not-mounted {transform: scale(0);}
39
+ .aio-popup-position-fullscreen>.aio-popup {width: 100%;height: 100%;}
40
+ /**********position (top)**************/
41
+ .aio-popup-position-top {align-items: flex-start;}
42
+ .aio-popup-position-top > .aio-popup.not-mounted {transform: translateY(-500px);}
43
+ .aio-popup-position-top > .aio-popup {width: 100%;max-height: 90vh;transform: translateY(0px);}
44
+ /**********position (bottom)***********/
45
+ .aio-popup-position-bottom {align-items: flex-end;}
46
+ .aio-popup-position-bottom>.aio-popup.not-mounted {opacity: 0; bottom:-500px; transform: scaleY(0);}
47
+ .aio-popup-position-bottom>.aio-popup {width: 100%; bottom: 0; opacity: 1; transform: scaleY(1); }
48
+
49
+ /**********position (left)*************/
50
+ .aio-popup-position-left {justify-content: left;}
51
+ .aio-popup-position-left > .aio-popup.not-mounted {transform: translateX(-500px);}
52
+ .aio-popup-position-left > .aio-popup {height: 100%;max-width: 90vh;transform: translateX(0px);}
53
+ /**********position (right)************/
54
+ .aio-popup-position-right {justify-content: right;}
55
+ .aio-popup-position-right > .aio-popup.not-mounted {transform: translateX(500px) scaleX(0);}
56
+ .aio-popup-position-right > .aio-popup {height: 100%;max-width: 90vh;transform: translateX(0px) scaleX(1);;}
57
+ /**********position (popover)************/
58
+ .aio-popup-position-popover {opacity: 1;}
59
+ .aio-popup-position-popover>.aio-popup.not-mounted {opacity: 0;}
60
+ /**********position (center)***********/
61
+ .aio-popup-position-center>.aio-popup.not-mounted {transform: translateY(-500px);opacity: 0;}
62
+ .aio-popup-position-center>.aio-popup {max-width: 100vw;width: fit-content;opacity: 1;max-height: 100vh;transform: translateY(0px); transform-origin:top;}
63
+ /**************************************/
125
64
 
126
65
  .aio-popup-header {
127
66
  display:flex;
@@ -132,18 +71,29 @@
132
71
  font-size: 16px;
133
72
  font-weight: bold;
134
73
  min-height: 48px;
74
+ gap:12px;
135
75
  }
136
76
 
137
- .aio-popup-subtitle {
77
+ .aio-popup-header-subtitle {
138
78
  font-size: 85%;
139
79
  opacity: 0.5;
140
80
  }
141
-
81
+ .aio-popup-header-before{
82
+ display:flex;
83
+ align-items: center;
84
+ justify-content: center;
85
+ }
86
+ .aio-popup-header-after{
87
+ display:flex;
88
+ align-items: center;
89
+ justify-content: center;
90
+ }
142
91
  .aio-popup-body {
143
92
  background: #fff;
144
93
  flex: 1;
145
94
  width: 100%;
146
95
  overflow-y: auto;
96
+ box-sizing:border-box;
147
97
  }
148
98
  .aio-popup-body *{
149
99
  box-sizing: border-box;
@@ -157,6 +107,7 @@
157
107
  display: flex;
158
108
  border-top: 1px solid #f2f4f7;
159
109
  justify-content: flex-end;
110
+ box-sizing: border-box;
160
111
  }
161
112
  .aio-popup-header-buttons{
162
113
  display:flex;
@@ -176,7 +127,11 @@
176
127
  justify-content: center;
177
128
  width: 36px;
178
129
  }
179
-
130
+ .aio-popup-header-after{
131
+ display:flex;
132
+ align-items: center;
133
+ height:100%;
134
+ }
180
135
  .aio-popup-footer-button {
181
136
  height: 30px;
182
137
  background: dodgerblue;
package/index.d.ts CHANGED
@@ -1,41 +1,42 @@
1
- import React from 'react';
1
+ import React, { FC } from 'react';
2
2
  import './index.css';
3
3
  export type AP_props = {
4
4
  rtl?: boolean;
5
5
  id?: string;
6
6
  };
7
7
  export type AP_position = 'fullscreen' | 'center' | 'popover' | 'left' | 'right' | 'top' | 'bottom';
8
- export type AP_header = {
8
+ export type AP_attrsKey = 'backdrop' | 'modal' | 'header' | 'body' | 'footer';
9
+ export type AP_header = ((p: {
10
+ close: () => void;
11
+ state: any;
12
+ setState: any;
13
+ }) => React.ReactNode) | {
9
14
  title?: string;
10
15
  subtitle?: string;
11
- buttons?: AP_modal_button[];
16
+ before?: React.ReactNode;
17
+ after?: React.ReactNode;
12
18
  onClose?: boolean | ((p: {
13
19
  state: any;
14
20
  setState: (state: any) => void;
15
21
  }) => void);
16
- backButton?: () => void;
17
- attrs?: any;
18
- };
19
- export type AP_backdrop = false | {
20
- attrs?: any;
21
- close?: boolean;
22
- };
23
- export type AP_body = {
24
- render?: (p: {
25
- close: () => void;
26
- state?: any;
27
- setState?: (state: any) => void;
28
- }) => React.ReactNode;
29
22
  attrs?: any;
30
23
  };
31
- export type AP_footer = React.ReactNode | {
32
- attrs?: any;
33
- buttons?: AP_modal_button[];
34
- };
24
+ export type AP_body = (p: {
25
+ close: () => void;
26
+ state?: any;
27
+ setState?: (state: any) => void;
28
+ }) => React.ReactNode;
29
+ export type AP_footer = (p: {
30
+ state: any;
31
+ setState: (v: any) => void;
32
+ close: () => void;
33
+ }) => React.ReactNode;
34
+ type AP_setAttrs = (mode: AP_attrsKey) => any;
35
35
  export type AP_modal = {
36
36
  getTarget?: () => any;
37
37
  pageSelector?: string;
38
- openRelatedTo?: string;
38
+ limitTo?: string;
39
+ maxHeight?: number | 'string';
39
40
  fixStyle?: (o: any, p: {
40
41
  targetLimit: any;
41
42
  pageLimit: any;
@@ -45,14 +46,13 @@ export type AP_modal = {
45
46
  id?: string;
46
47
  onClose?: boolean | (() => void);
47
48
  position?: AP_position;
48
- attrs?: any;
49
- backdrop?: AP_backdrop;
50
49
  header?: AP_header;
51
50
  state?: any;
52
51
  footer?: AP_footer;
53
52
  body?: AP_body;
54
53
  animate?: boolean;
55
54
  fitHorizontal?: boolean;
55
+ setAttrs?: AP_setAttrs;
56
56
  };
57
57
  export type AP_alert = {
58
58
  icon?: false | React.ReactNode;
@@ -64,6 +64,7 @@ export type AP_alert = {
64
64
  className?: string;
65
65
  closeText?: string;
66
66
  animate?: boolean;
67
+ onClose?: boolean | (() => void);
67
68
  };
68
69
  export type AP_snackebar = {
69
70
  id?: string;
@@ -78,7 +79,7 @@ export type AP_snackebar = {
78
79
  type: 'success' | 'error' | 'warning' | 'info';
79
80
  verticalAlign?: 'start' | 'end';
80
81
  horizontalAlign?: 'start' | 'center' | 'end';
81
- onClose?: false;
82
+ onClose?: boolean | (() => void);
82
83
  attrs?: any;
83
84
  };
84
85
  export type AP_confirm = {
@@ -89,7 +90,7 @@ export type AP_confirm = {
89
90
  canselText?: string;
90
91
  onSubmit?: () => Promise<boolean>;
91
92
  onCansel?: () => void;
92
- attrs?: any;
93
+ setAttrs?: AP_setAttrs;
93
94
  };
94
95
  export type AP_prompt = {
95
96
  title?: string;
@@ -99,42 +100,7 @@ export type AP_prompt = {
99
100
  canselText?: string;
100
101
  onSubmit?: (text: string) => Promise<boolean>;
101
102
  onCansel?: () => void;
102
- attrs?: any;
103
- };
104
- export type AP_modal_button = [text: React.ReactNode, attrs?: any | ((p: {
105
- state: any;
106
- setState: (v: any) => void;
107
- }) => any)];
108
- export type AP_Popups = {
109
- getActions: (p: {
110
- removeModal: (p?: string, animate?: boolean) => void;
111
- addModal: (p: AP_modal) => void;
112
- getModals: () => AP_modal[];
113
- }) => void;
114
- rtl: boolean;
115
- id?: string;
116
- };
117
- export type AP_Popup = {
118
- modal: AP_modal;
119
- rtl: boolean;
120
- index: number;
121
- isLast: boolean;
122
- onClose: () => void;
123
- removeModal: (p?: string, animate?: boolean) => void;
124
- };
125
- export type AP_ModalHeader = {
126
- rtl: boolean;
127
- header: AP_header;
128
- handleClose: () => void;
129
- state: any;
130
- setState: (state: any) => void;
131
- };
132
- export type AP_ModalBody = {
133
- body?: AP_body;
134
- handleClose: () => void;
135
- updatePopoverStyle: () => void;
136
- state: any;
137
- setState: (state: any) => void;
103
+ setAttrs?: AP_setAttrs;
138
104
  };
139
105
  export type AP_Snackebar = {
140
106
  getActions: (p: {
@@ -153,14 +119,18 @@ export default class AIOPopup {
153
119
  render: () => React.ReactNode;
154
120
  addModal: (p: AP_modal) => void;
155
121
  addAlert: (p: AP_alert) => void;
156
- removeModal: (arg?: string, animate?: boolean) => void;
157
- _removeModal: (arg?: string, animate?: boolean) => void;
122
+ removeModal: (arg?: string) => void;
158
123
  addSnackebar: (p: AP_snackebar) => void;
159
124
  getModals: () => AP_modal[];
160
- _getModals: () => AP_modal[];
161
125
  addConfirm: (p: AP_confirm) => void;
162
126
  addPrompt: (p: AP_prompt) => void;
163
127
  popupId?: string;
164
- isRenderCalled: boolean;
128
+ popupsRef: React.RefObject<typeof Popups>;
165
129
  constructor(obj?: AP_props);
166
130
  }
131
+ type AP_Popups = {
132
+ ref: any;
133
+ rtl: boolean;
134
+ };
135
+ declare const Popups: FC<AP_Popups>;
136
+ export {};