jrs-react 1.2.24 → 1.2.25
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/build/index.es.js +40 -136
- package/build/index.js +35 -131
- package/package.json +1 -1
- package/src/components/JRFrame/JRFrame.jsx +17 -1
- package/src/components/JRMask/JRMask.jsx +77 -53
- package/src/components/JRSubmit.jsx +4 -3
- package/src/index.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import JRSubmit from "../JRSubmit";
|
|
4
|
+
import { po, random } from "../JRUtils";
|
|
4
5
|
|
|
5
6
|
export const FreeType=({tag:Tag,config,me,className})=>{
|
|
6
7
|
if(typeof config==='function'){
|
|
@@ -17,6 +18,7 @@ export const FreeType=({tag:Tag,config,me,className})=>{
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
const StyledJRFrame=styled.div`
|
|
21
|
+
position:relative;
|
|
20
22
|
display:flex;
|
|
21
23
|
flex:1;
|
|
22
24
|
overflow:hidden;
|
|
@@ -58,10 +60,24 @@ const StyledJRFrame=styled.div`
|
|
|
58
60
|
|
|
59
61
|
}
|
|
60
62
|
`
|
|
61
|
-
|
|
62
63
|
export default class JRFrame extends JRSubmit {
|
|
64
|
+
rid=random(99999,10000)
|
|
65
|
+
mask=this.props.mask
|
|
66
|
+
?()=>{
|
|
67
|
+
const {type,props}=this.props.mask
|
|
68
|
+
this.maskId=`mask-${this.rid}`
|
|
69
|
+
return React.createElement(
|
|
70
|
+
type
|
|
71
|
+
,{
|
|
72
|
+
...props
|
|
73
|
+
,id:this.maskId
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
:null
|
|
63
78
|
renderer(){
|
|
64
79
|
return <StyledJRFrame id={this.props.id} style={this.props.style} className={`jr-frame`} >
|
|
80
|
+
{this.mask?.()}
|
|
65
81
|
<FreeType tag='div' config={this.props.start} me={this} className={'start'}/>
|
|
66
82
|
<main>
|
|
67
83
|
<FreeType tag='header' config={this.props.top} me={this}/>
|
|
@@ -3,36 +3,15 @@ import { JRHTML } from "jrs-js"
|
|
|
3
3
|
import { po } from "../JRUtils"
|
|
4
4
|
import styled from "styled-components"
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const css=`
|
|
9
7
|
display:none;
|
|
10
|
-
&:open{
|
|
11
|
-
display:flex;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
&:modal {
|
|
15
|
-
outline: 0;
|
|
16
|
-
background-color: #000000aa;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
8
|
#jr-mask-msg{
|
|
20
9
|
padding: 10px;
|
|
21
10
|
}
|
|
22
|
-
|
|
23
|
-
max-width: 100vw;
|
|
24
|
-
max-height: 100vh;
|
|
25
|
-
|
|
26
|
-
width: 100vw;
|
|
27
|
-
height: 100vh;
|
|
28
|
-
|
|
29
|
-
border:0;
|
|
30
|
-
margin: 0;
|
|
31
|
-
top: 0;
|
|
32
|
-
left: 0;
|
|
33
|
-
color: ${({theme})=>theme?.colorPrimary??'whilte'};
|
|
34
11
|
user-select: none;
|
|
35
12
|
cursor: wait;
|
|
13
|
+
background-color: #000000aa;
|
|
14
|
+
color: ${({theme})=>theme?.colorPrimary??'whilte'};
|
|
36
15
|
flex-direction: column;
|
|
37
16
|
justify-content: center;
|
|
38
17
|
align-items: center;
|
|
@@ -47,7 +26,6 @@ const StyledMask = styled.dialog`
|
|
|
47
26
|
|
|
48
27
|
}
|
|
49
28
|
|
|
50
|
-
|
|
51
29
|
animation: opc .4s ;
|
|
52
30
|
@keyframes opc {
|
|
53
31
|
0% {opacity: 0;background: transparent;visibility:hidden;}
|
|
@@ -128,9 +106,39 @@ const StyledMask = styled.dialog`
|
|
|
128
106
|
animation: lol 3s 500ms infinite ease-in-out;
|
|
129
107
|
}
|
|
130
108
|
`
|
|
109
|
+
const StyledDialogMask = styled.dialog`
|
|
110
|
+
${css}
|
|
111
|
+
&:open{
|
|
112
|
+
display:flex;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&:modal {
|
|
116
|
+
outline: 0;
|
|
117
|
+
background-color: #000000aa;
|
|
118
|
+
}
|
|
131
119
|
|
|
132
|
-
|
|
133
|
-
|
|
120
|
+
max-width: 100vw;
|
|
121
|
+
max-height: 100vh;
|
|
122
|
+
width: 100vw;
|
|
123
|
+
height: 100vh;
|
|
124
|
+
border:0;
|
|
125
|
+
margin: 0;
|
|
126
|
+
top: 0;
|
|
127
|
+
left: 0;
|
|
128
|
+
|
|
129
|
+
`
|
|
130
|
+
|
|
131
|
+
const StyledDivMask = styled.div`
|
|
132
|
+
${css}
|
|
133
|
+
width:100%;
|
|
134
|
+
height:100%;
|
|
135
|
+
position: absolute;
|
|
136
|
+
top: 0;
|
|
137
|
+
left: 0;
|
|
138
|
+
`
|
|
139
|
+
|
|
140
|
+
export default function JRDialogMask({id='jr-mask'}){
|
|
141
|
+
return <StyledDialogMask id={id} className={'jr-mask'}>
|
|
134
142
|
<div id={`${id}-msg`} ></div>
|
|
135
143
|
<div className="cs-loader-inner">
|
|
136
144
|
<label>●</label>
|
|
@@ -140,11 +148,22 @@ export default function JRMask({id='jr-mask'}){
|
|
|
140
148
|
<label>●</label>
|
|
141
149
|
<label>●</label>
|
|
142
150
|
</div>
|
|
143
|
-
</
|
|
151
|
+
</StyledDialogMask>
|
|
144
152
|
}
|
|
145
153
|
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
export function JRDivMask({id='jr-mask'}){
|
|
155
|
+
return <StyledDivMask id={id}>
|
|
156
|
+
<div id={`${id}-msg`} >MSG</div>
|
|
157
|
+
<div className="cs-loader-inner">
|
|
158
|
+
<label>●</label>
|
|
159
|
+
<label>●</label>
|
|
160
|
+
<label>●</label>
|
|
161
|
+
<label>●</label>
|
|
162
|
+
<label>●</label>
|
|
163
|
+
<label>●</label>
|
|
164
|
+
</div>
|
|
165
|
+
</StyledDivMask>
|
|
166
|
+
}
|
|
148
167
|
|
|
149
168
|
class Mask extends JRHTML{
|
|
150
169
|
msg=[]
|
|
@@ -158,11 +177,10 @@ class Mask extends JRHTML{
|
|
|
158
177
|
const index=this.msgIndex
|
|
159
178
|
this.msg.push({
|
|
160
179
|
i:index
|
|
161
|
-
,msg
|
|
180
|
+
,msg:msg!==true?msg:null
|
|
162
181
|
})
|
|
163
182
|
this.renderMsg()
|
|
164
183
|
return ()=>{
|
|
165
|
-
po('remove function', index)
|
|
166
184
|
this.removeMsg(index)
|
|
167
185
|
}
|
|
168
186
|
}
|
|
@@ -171,35 +189,41 @@ class Mask extends JRHTML{
|
|
|
171
189
|
this.renderMsg()
|
|
172
190
|
}
|
|
173
191
|
renderMsg(){
|
|
174
|
-
this.msgDiv
|
|
175
|
-
if(this.msg.length){
|
|
176
|
-
this.msgDiv.html=this.msg[this.msg.length-1].msg
|
|
177
|
-
|
|
178
|
-
// new JRHTML({
|
|
179
|
-
// yo:'div'
|
|
180
|
-
// ,textContent:this.msg[this.msg.length-1].msg
|
|
181
|
-
// })
|
|
182
|
-
// )
|
|
183
|
-
if(!this.yo.open){
|
|
184
|
-
this.yo.showModal()
|
|
185
|
-
}
|
|
192
|
+
this.msgDiv?.removeAllHijos()
|
|
193
|
+
if(this.msg.length ){
|
|
194
|
+
if(this.msgDiv) this.msgDiv.html=this.msg[this.msg.length-1].msg
|
|
195
|
+
this.run()
|
|
186
196
|
}else{
|
|
187
|
-
this.
|
|
197
|
+
this.stop()
|
|
188
198
|
}
|
|
189
199
|
}
|
|
200
|
+
run=()=>{
|
|
201
|
+
this.yo.showModal?.() ?? this.display()
|
|
202
|
+
}
|
|
203
|
+
display(){
|
|
204
|
+
this.yo.style.display='flex'
|
|
205
|
+
}
|
|
206
|
+
stop(){
|
|
207
|
+
this.yo.close?.() ?? this.hide()
|
|
208
|
+
}
|
|
209
|
+
hide(){
|
|
210
|
+
this.yo.style.display='none'
|
|
211
|
+
}
|
|
190
212
|
}
|
|
191
213
|
|
|
192
|
-
export function showMask(msg,
|
|
193
|
-
const jrMask=document.getElementById(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
214
|
+
export function showMask(msg,maskId='jr-mask'){
|
|
215
|
+
const jrMask=document.getElementById(maskId)
|
|
216
|
+
|
|
217
|
+
if((jrMask)){
|
|
218
|
+
const jrMaskMsg=document.getElementById(`${maskId}-msg`)
|
|
197
219
|
if(!jrMask.maskDiv){
|
|
198
220
|
jrMask.maskDiv=new Mask({
|
|
199
221
|
yo:jrMask
|
|
200
|
-
,msgDiv:
|
|
201
|
-
|
|
202
|
-
|
|
222
|
+
,msgDiv:jrMaskMsg
|
|
223
|
+
?new JRHTML({
|
|
224
|
+
yo:jrMaskMsg
|
|
225
|
+
})
|
|
226
|
+
:null
|
|
203
227
|
,listeners:{
|
|
204
228
|
keydown(e){
|
|
205
229
|
if (e.key === 'Escape') {
|
|
@@ -217,8 +217,9 @@ export default class JRSubmit extends React.Component {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
submit(config){
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
if(config.mask) {
|
|
221
|
+
config.removeMaskFunction=showMask(config.mask,this.maskId??'jr-mask')
|
|
222
|
+
}
|
|
222
223
|
|
|
223
224
|
let _payload
|
|
224
225
|
;(()=>{
|
|
@@ -248,6 +249,7 @@ export default class JRSubmit extends React.Component {
|
|
|
248
249
|
this.handleResponse(res,_payload,config)
|
|
249
250
|
})
|
|
250
251
|
.finally(()=> {
|
|
252
|
+
// setTimeout(config.removeMaskFunction??avoid,random(4000,1000))
|
|
251
253
|
config.removeMaskFunction?.()
|
|
252
254
|
})
|
|
253
255
|
}
|
|
@@ -271,7 +273,6 @@ export default class JRSubmit extends React.Component {
|
|
|
271
273
|
|
|
272
274
|
this.setRes(isSuccess,response,config)
|
|
273
275
|
this.showMessage(isSuccess,isSuccess?config.successMessage:config.failedMessage)
|
|
274
|
-
|
|
275
276
|
|
|
276
277
|
config.callback?.bind(this)(isSuccess,response,payload)
|
|
277
278
|
}
|
package/src/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import JRSelect from './components/JRInput/JRSelect'
|
|
|
10
10
|
import JRCheckbox from './components/JRInput/JRCheckbox'
|
|
11
11
|
import JRRadio from './components/JRInput/JRRadio'
|
|
12
12
|
import JRText from './components/JRInput/JRText'
|
|
13
|
-
import JRMask,{showMask} from './components/JRMask/JRMask'
|
|
13
|
+
import JRMask,{JRDivMask,showMask} from './components/JRMask/JRMask'
|
|
14
14
|
import {random} from './components/JRUtils'
|
|
15
15
|
export {
|
|
16
16
|
JRTestReact
|