jrs-react 1.2.23 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jrs-react",
3
- "version": "1.2.23",
3
+ "version": "1.2.25",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.es.js",
@@ -1,6 +1,8 @@
1
1
  import styled from "styled-components";
2
2
 
3
3
  export const StyleJRFields=styled.main`
4
+
5
+
4
6
  --column-bd-color:#cccccc;
5
7
  --column-b-color:unset;
6
8
  --column-b-hover-color:#ffffff;
@@ -10,12 +12,13 @@ export const StyleJRFields=styled.main`
10
12
  overflow: overlay;
11
13
 
12
14
  color:#525252;
15
+ height: 100%;
13
16
 
14
17
  >.jr-grid{
15
18
  padding: 10px;
16
19
  .jr-column{
17
20
  > .label{
18
- color:#525252;
21
+ color:#2e2e2e;
19
22
  text-wrap: nowrap;
20
23
  font-weight: bold;
21
24
  }
@@ -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;
@@ -44,8 +46,9 @@ const StyledJRFrame=styled.div`
44
46
  overflow:hidden;
45
47
 
46
48
  >main{
47
- display:flex;
48
- flex:1;
49
+ width:100%;
50
+ xdisplay:flex;
51
+ xflex:1;
49
52
  overflow: overlay;
50
53
  }
51
54
 
@@ -57,10 +60,24 @@ const StyledJRFrame=styled.div`
57
60
 
58
61
  }
59
62
  `
60
-
61
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
62
78
  renderer(){
63
- return <StyledJRFrame id={this.props.id} style={this.props.style} className={`${this.props.className} jr-frame`} >
79
+ return <StyledJRFrame id={this.props.id} style={this.props.style} className={`jr-frame`} >
80
+ {this.mask?.()}
64
81
  <FreeType tag='div' config={this.props.start} me={this} className={'start'}/>
65
82
  <main>
66
83
  <FreeType tag='header' config={this.props.top} me={this}/>
@@ -3,34 +3,15 @@ import { JRHTML } from "jrs-js"
3
3
  import { po } from "../JRUtils"
4
4
  import styled from "styled-components"
5
5
 
6
- const StyledMask = styled.dialog`
6
+ const css=`
7
7
  display:none;
8
- &:open{
9
- display:flex;
10
- }
11
-
12
- &:modal {
13
- outline: 0;
14
- background-color: #000000aa;
15
- }
16
-
17
8
  #jr-mask-msg{
18
9
  padding: 10px;
19
10
  }
20
-
21
- max-width: 100vw;
22
- max-height: 100vh;
23
-
24
- width: 100vw;
25
- height: 100vh;
26
-
27
- border:0;
28
- margin: 0;
29
- top: 0;
30
- left: 0;
31
- color: ${({theme})=>theme?.colorPrimary??'whilte'};
32
11
  user-select: none;
33
12
  cursor: wait;
13
+ background-color: #000000aa;
14
+ color: ${({theme})=>theme?.colorPrimary??'whilte'};
34
15
  flex-direction: column;
35
16
  justify-content: center;
36
17
  align-items: center;
@@ -42,8 +23,15 @@ const StyledMask = styled.dialog`
42
23
  .cs-loader-inner {
43
24
  transform: translateY(-30%);
44
25
  width: calc(100% - 200xpx);
26
+
45
27
  }
46
28
 
29
+ animation: opc .4s ;
30
+ @keyframes opc {
31
+ 0% {opacity: 0;background: transparent;visibility:hidden;}
32
+ 20% {opacity: 1;background: #000000aa; visibility: visible;}
33
+ }
34
+
47
35
  .cs-loader-inner label {
48
36
  font-size: 20px;
49
37
  opacity: 0;
@@ -118,10 +106,40 @@ const StyledMask = styled.dialog`
118
106
  animation: lol 3s 500ms infinite ease-in-out;
119
107
  }
120
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
+ }
119
+
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
+ `
121
130
 
122
- export default function JRMask({id='jr-mask'}){
123
- return <StyledMask id={id} className={'jr-mask'}>
124
- <div id={'jr-mask-msg'} ></div>
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'}>
142
+ <div id={`${id}-msg`} ></div>
125
143
  <div className="cs-loader-inner">
126
144
  <label>●</label>
127
145
  <label>●</label>
@@ -130,11 +148,22 @@ export default function JRMask({id='jr-mask'}){
130
148
  <label>●</label>
131
149
  <label>●</label>
132
150
  </div>
133
- </StyledMask>
151
+ </StyledDialogMask>
134
152
  }
135
153
 
136
-
137
-
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
+ }
138
167
 
139
168
  class Mask extends JRHTML{
140
169
  msg=[]
@@ -148,11 +177,10 @@ class Mask extends JRHTML{
148
177
  const index=this.msgIndex
149
178
  this.msg.push({
150
179
  i:index
151
- ,msg
180
+ ,msg:msg!==true?msg:null
152
181
  })
153
182
  this.renderMsg()
154
183
  return ()=>{
155
- po('remove function', index)
156
184
  this.removeMsg(index)
157
185
  }
158
186
  }
@@ -161,41 +189,50 @@ class Mask extends JRHTML{
161
189
  this.renderMsg()
162
190
  }
163
191
  renderMsg(){
164
- this.msgDiv.removeAllHijos()
165
- if(this.msg.length){
166
- this.msgDiv.agregarHijo(
167
- new JRHTML({
168
- yo:'div'
169
- ,textContent:this.msg[this.msg.length-1].msg
170
- })
171
- )
172
- if(!this.yo.open){
173
- this.yo.showModal()
174
- }
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()
175
196
  }else{
176
- this.yo.close()
197
+ this.stop()
177
198
  }
178
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
+ }
179
212
  }
180
213
 
181
- export function showMask(msg,maskTarget,whichMask){
182
- const jrMask=document.getElementById('jr-mask')
183
- const jrMaskMsg=document.getElementById('jr-mask-msg')
184
-
185
- if(!jrMask.maskDiv){
186
- jrMask.maskDiv=new Mask({
187
- yo:jrMask
188
- ,msgDiv:new JRHTML({
189
- yo:jrMaskMsg
190
- })
191
- ,listeners:{
192
- keydown(e){
193
- if (e.key === 'Escape') {
194
- e.preventDefault();
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`)
219
+ if(!jrMask.maskDiv){
220
+ jrMask.maskDiv=new Mask({
221
+ yo:jrMask
222
+ ,msgDiv:jrMaskMsg
223
+ ?new JRHTML({
224
+ yo:jrMaskMsg
225
+ })
226
+ :null
227
+ ,listeners:{
228
+ keydown(e){
229
+ if (e.key === 'Escape') {
230
+ e.preventDefault();
231
+ }
195
232
  }
196
233
  }
197
- }
198
- })
234
+ })
235
+ }
236
+ return jrMask.maskDiv.addMsg(msg)
199
237
  }
200
- return jrMask.maskDiv.addMsg(msg)
201
238
  }
@@ -142,7 +142,6 @@ export default class JRSubmit extends React.Component {
142
142
  const fullnamList=fullname.split('.')
143
143
  return this.#getValueByName(fullnamList,this[this.from]?.value)
144
144
  }else{
145
- // po('ssssssssssssssssssssssssssssssssssssssssss')
146
145
  // 忘記為甚麼這樣寫了 XDD
147
146
  return flexType(this[this.from]?.value,this,null,null)
148
147
  }
@@ -218,10 +217,9 @@ export default class JRSubmit extends React.Component {
218
217
  }
219
218
 
220
219
  submit(config){
221
- // const me=this
222
- // displaySpinner({mask:config.mask})
223
- // this.setState({loading:true})//拿掉可能會有問題, 先觀察看看
224
- if(config.mask) config.removeMaskFunction=showMask(config.mask,null,'jr-mask')
220
+ if(config.mask) {
221
+ config.removeMaskFunction=showMask(config.mask,this.maskId??'jr-mask')
222
+ }
225
223
 
226
224
  let _payload
227
225
  ;(()=>{
@@ -251,11 +249,8 @@ export default class JRSubmit extends React.Component {
251
249
  this.handleResponse(res,_payload,config)
252
250
  })
253
251
  .finally(()=> {
254
- // this.setState({loading:false})
255
- // displaySpinner({mask:false})
256
- // setTimeout(()=>{
257
- config.removeMaskFunction?.()
258
- // },random(4000,1000))
252
+ // setTimeout(config.removeMaskFunction??avoid,random(4000,1000))
253
+ config.removeMaskFunction?.()
259
254
  })
260
255
  }
261
256
 
@@ -278,14 +273,13 @@ export default class JRSubmit extends React.Component {
278
273
 
279
274
  this.setRes(isSuccess,response,config)
280
275
  this.showMessage(isSuccess,isSuccess?config.successMessage:config.failedMessage)
281
-
282
276
 
283
277
  config.callback?.bind(this)(isSuccess,response,payload)
284
278
  }
285
279
 
286
280
  showMessage(success,message){
287
- // po('success',success)
288
- // po('message',message)
281
+ po('success',success)
282
+ po('message',message)
289
283
  }
290
284
 
291
285
  renderer(){
@@ -293,8 +287,6 @@ export default class JRSubmit extends React.Component {
293
287
  }
294
288
 
295
289
  render() {
296
- return this.props.cover!=null && this.state?.lodaing
297
- ?<Cover>{flexType(this.props.cover,this,null,null)}</Cover>
298
- :this.renderer()
290
+ return this.renderer()
299
291
  }
300
292
  }
@@ -207,7 +207,7 @@ export default class JRTable extends JRWindow {
207
207
  renderMe(){
208
208
 
209
209
  return<StyledJRTable
210
- className={`${this.props.className??''} jr-table ${this.props.onRowClick?'row-highlightable':''}`}
210
+ className={`jr-table ${this.props.onRowClick?'row-highlightable':''}`}
211
211
  >
212
212
  <table className={'jr-table-table'}>
213
213
  <TBodies
@@ -2,8 +2,8 @@ import styled from "styled-components";
2
2
 
3
3
  export const StyledJRTable=styled.div`
4
4
  --column-bd-color:#cccccc;
5
- --column-b-color:#eeeeee;
6
- --column-b-hover-color:#ffffff;
5
+ --column-b-color:#ffffff;
6
+ --column-b-hover-color:#eeeeee;
7
7
 
8
8
  position: relative;
9
9
  background: var(--column-b-color);
@@ -13,7 +13,7 @@ export const StyledJRTable=styled.div`
13
13
  flex-direction: column;
14
14
  flex:1;
15
15
  overflow: overlay;
16
-
16
+ height:100%;
17
17
 
18
18
 
19
19
 
@@ -43,7 +43,7 @@ export const StyledJRTable=styled.div`
43
43
  top: 0;
44
44
 
45
45
  th{
46
- position: relative;
46
+ xposition: relative;
47
47
  padding: 2px 6px;
48
48
  background: linear-gradient(180deg, rgba(227, 227, 226, 1) 0%, rgba(255, 255, 255, 1) 25%, rgba(210, 210, 210, 1) 100%);
49
49
  box-shadow: 2px 2px 2px 0 #ffffffd6 inset, -1px -1px 2px 0px #8a847dbf inset;
@@ -8,6 +8,8 @@ import style from './Style.module.css'
8
8
 
9
9
 
10
10
  const StyledJRWindow=styled.div`
11
+ z-index:1;
12
+
11
13
  --jr-window-radius:3px;
12
14
  --padding-child:8px;
13
15
  --transition-x-y:height .05s ease-in, width .05s ease-in;
@@ -15,36 +17,35 @@ const StyledJRWindow=styled.div`
15
17
  position: fixed;
16
18
  padding: ${({$thick})=>$thick}px;
17
19
  border-radius: var(--jr-window-radius);
18
- user-select: text;
20
+ user-select: text;
19
21
 
20
22
  top: ${({$y})=>$y}px;
21
23
  left: ${({$x})=>$x}px;
22
24
  width: ${({$width=300})=>`${$width}px`};
23
25
  height: ${({$height=300})=>`${$height}px`};
24
26
  overflow: hidden;
25
- z-index: 2;
26
27
 
27
28
  display: flex;
28
29
  flex-direction: column;
29
30
  overflow: hidden;
31
+ color:#2e2e2e;
30
32
 
31
33
  > main{
32
34
  border-radius: var(--jr-window-radius);
35
+ background:#ffffff;;
33
36
  box-shadow: 0px 0px 5px 1px gray;
34
37
  display: flex;
35
38
  flex-direction: column;
36
39
  overflow: hidden;
37
40
  flex:1;
38
41
  > main {
39
- Xpadding:var(--padding-child);
40
42
  overflow: overlay;
41
43
  flex:1;
42
44
  display: flex;
43
- min-height:32px;
44
45
  }
45
46
  }
46
-
47
47
  `
48
+
48
49
  export default class JRWindow extends JRFrame {
49
50
  x=0
50
51
  y=0
@@ -80,12 +81,11 @@ export default class JRWindow extends JRFrame {
80
81
  this.mask.remove()
81
82
  }
82
83
 
83
- maskOnTarget(on){
84
- po('typeof this.props.maskOn',typeof this.props.maskOn)
85
- const target=(typeof this.props.maskOn)==='object'
86
- ?this.props.maskOn
87
- :typeof this.props.maskOn ==='string'
88
- ?document.getElementById(this.props.maskOn)
84
+ backdropOn(on){
85
+ const target=(typeof this.props.backdrop)==='object'
86
+ ?this.props.backdrop
87
+ :typeof this.props.backdrop ==='string'
88
+ ?document.getElementById(this.props.backdrop)
89
89
  :document.body
90
90
 
91
91
  // this[on?'addMaskToTarget':'removeMaskFromTarget'](target)
@@ -94,8 +94,8 @@ export default class JRWindow extends JRFrame {
94
94
 
95
95
  componentDidMount(){
96
96
  super.componentDidMount()
97
- if(this.props.maskOn && this.props.open){
98
- this.maskOnTarget(this.props.open)
97
+ if(this.props.backdrop && this.props.open){
98
+ this.backdropOn(this.props.open)
99
99
  }
100
100
 
101
101
  if(this.props.open){
@@ -117,8 +117,8 @@ export default class JRWindow extends JRFrame {
117
117
  }else if(this.props.open===false && prevProps.open){
118
118
  this.close()
119
119
  }
120
- if(this.props.maskOn && this.props.open!=prevProps.open){
121
- this.maskOnTarget(this.props.open)
120
+ if(this.props.backdrop && this.props.open!=prevProps.open){
121
+ this.backdropOn(this.props.open)
122
122
  }
123
123
  }
124
124
  }
@@ -133,6 +133,12 @@ export default class JRWindow extends JRFrame {
133
133
  return this.props.popup===true
134
134
  ?this.props.open
135
135
  ?<StyledJRWindow
136
+
137
+ // role="dialog"
138
+ // aria-labelledby="dialog1Title"
139
+ // aria-describedby="dialog1Desc"
140
+
141
+ rule={'dialog'}
136
142
  ref={this.ref}
137
143
  className={`jr-window ${this.props.className??''}`}
138
144
  $x={this.x}
@@ -236,7 +236,8 @@ class Slider extends React.Component {
236
236
 
237
237
  this.props.windowRef.current.style.transition='var(--transition-x-y)'
238
238
  if(y==0 && this.data.direction.indexOf('n')>-1){
239
- this.props.window.orgHeight=height
239
+ this.props.window.orgSHeight=height
240
+
240
241
  this.props.windowRef.current.style.height=`${window.innerHeight}px`
241
242
  }
242
243
  if(y>window.innerHeight)this.props.windowRef.current.style.top = `${window.innerHeight-titleBarHeight}px`
@@ -263,10 +264,11 @@ class Slider extends React.Component {
263
264
  }
264
265
  preMove=()=>{
265
266
  if(this.props.direction.indexOf('n')>-1){
266
- this.props.windowRef.current.style.height=`${this.props.window.orgHeight}px`
267
- this.data.height=this.props.window.orgHeight
268
- this.props.window.orgHeight=null
267
+ this.props.windowRef.current.style.height=`${this.props.window.orgSHeight}px`
268
+ this.data.height=this.props.window.orgSHeight
269
+ this.props.window.orgSHeight=null
269
270
  }
271
+
270
272
  window.removeEventListener('mousemove',this.preMove)
271
273
  setTimeout(()=>{
272
274
  window.addEventListener('mousemove',this.move)
@@ -276,9 +278,9 @@ class Slider extends React.Component {
276
278
  e.preventDefault()
277
279
  const {height:titleBarHeight}=this.props.titleBarRef.current.getBoundingClientRect()
278
280
  let {x,y,width,height}=this.props.windowRef.current.getBoundingClientRect()
279
-
281
+ this.props.window.orgHeight=height
280
282
  if(this.props.direction.indexOf('s')>-1){
281
- this.props.window.orgHeight=null
283
+ this.props.window.orgSHeight=null
282
284
  }
283
285
  this.data={
284
286
  x,y
@@ -288,7 +290,7 @@ class Slider extends React.Component {
288
290
  ,direction
289
291
  }
290
292
  document.body.style.cursor=this.directions[this.props.direction].cursor
291
- if(this.props.window.orgHeight){
293
+ if(this.props.window.orgSHeight){
292
294
  window.addEventListener('mousemove',this.preMove)
293
295
  }else{
294
296
  window.addEventListener('mousemove',this.move)
@@ -190,7 +190,7 @@ export default class TitleBar extends React.Component{
190
190
  }else{
191
191
  this.remember(e)
192
192
  }
193
-
193
+ this.props.window.orgSHeight=null
194
194
  document.body.style.cursor='grabbing'
195
195
  document.body.style.overflow=this.props.window.orgBodyOverflow
196
196
 
package/src/index.js CHANGED
@@ -5,12 +5,12 @@ import JRTable from './components/JRTable/JRTable'
5
5
  import JRFields from './components/JRFields/JRFields'
6
6
  import JRTestReact from './components/JRTest'
7
7
  import JRButton from './components/JRInput/JRButton'
8
- import JRAlert from './components/JRAlert'
8
+ import JRAlert from './components/JRAlert/JRAlert'
9
9
  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