jrs-react 1.2.28 → 1.2.30

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.28",
3
+ "version": "1.2.30",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.es.js",
@@ -1,7 +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
+ import { random } from "../JRUtils";
5
5
 
6
6
  export const FreeType=({tag:Tag,config,me,className})=>{
7
7
  if(typeof config==='function'){
@@ -23,22 +23,15 @@ const StyledJRFrame=styled.div`
23
23
  flex:1;
24
24
  overflow:hidden;
25
25
 
26
- > *{
27
- Xborder:1px solid gray;
28
- }
29
26
  >main{
30
27
  display:flex;
31
28
  flex:1;
32
29
  overflow:hidden;
33
30
  flex-direction: column;
34
31
  > *{
35
- XXborder:1px solid gray;
36
- XXmin-height:30px;
37
32
  }
38
33
 
39
34
  >header{
40
- XXborder:1px solid red;
41
- XXoverflow: overlay;
42
35
  }
43
36
  >main{
44
37
  display:flex;
@@ -48,13 +41,12 @@ const StyledJRFrame=styled.div`
48
41
  >main{
49
42
  width:100%;
50
43
  xdisplay:flex;
51
- xflex:1;
44
+ flex:1;
52
45
  overflow: overlay;
53
46
  }
54
47
 
55
48
  }
56
49
  >footer{
57
- XXborder:1px solid blue;
58
50
  overflow: overlay;
59
51
  }
60
52
 
@@ -65,7 +57,7 @@ export default class JRFrame extends JRSubmit {
65
57
  mask=this.props.mask
66
58
  ?()=>{
67
59
  const {type,props}=this.props.mask
68
- this.maskId=`mask-${this.rid}`
60
+ this.maskId=`mask-${props.id??this.rid}`
69
61
  return React.createElement(
70
62
  type
71
63
  ,{
@@ -77,7 +69,6 @@ export default class JRFrame extends JRSubmit {
77
69
  :null
78
70
  renderer(){
79
71
  return <StyledJRFrame id={this.props.id} style={this.props.style} className={`jr-frame`} >
80
- {this.mask?.()}
81
72
  <FreeType tag='div' config={this.props.start} me={this} className={'start'}/>
82
73
  <main>
83
74
  <FreeType tag='header' config={this.props.top} me={this}/>
@@ -91,6 +82,7 @@ export default class JRFrame extends JRSubmit {
91
82
  <FreeType tag='footer' config={this.props.bottom} me={this}/>
92
83
  </main>
93
84
  <FreeType tag='div' config={this.props.end} me={this} className={'end'}/>
85
+ {this.mask?.()}
94
86
  </StyledJRFrame>
95
87
  }
96
88
  }
@@ -0,0 +1,30 @@
1
+ import styled from "styled-components"
2
+
3
+ const StyleJValue=styled.div`
4
+ background: #efefef;
5
+ border-width: 1px;
6
+ border-style: solid;
7
+ border-color: #d9d9d9;
8
+
9
+ box-sizing: border-box;
10
+ margin: 0;
11
+ padding: 3px 11px;
12
+ color: rgba(0, 0, 0, 0.88);
13
+ font-size: 14px;
14
+ line-height: 1.5714285714285714;
15
+ list-style: none;
16
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
17
+ position: relative;
18
+ display: inline-block;
19
+ width: 100%;
20
+ min-width: 0;
21
+ border-radius: 6px;
22
+ transition: all 0.2s;
23
+ min-height:30px;
24
+ `
25
+ export default function JValue({value,record,menu,render,style,align='align',...param}){
26
+ const _value=render?.({value,record}) ?? value
27
+ return <StyleJValue style={{textAlign:align,...style}}>
28
+ {_value}
29
+ </StyleJValue>
30
+ }
@@ -131,7 +131,7 @@ const StyledDialogMask = styled.dialog`
131
131
 
132
132
  const StyledDivMask = styled.div`
133
133
  ${css}
134
- color: ${({theme})=>theme?.colorPrimary??'whilte'};
134
+ color: ${({theme})=>theme?.colorPrimary??'white'};
135
135
  width:100%;
136
136
  height:100%;
137
137
  position: absolute;
@@ -215,7 +215,6 @@ class Mask extends JRHTML{
215
215
 
216
216
  export function showMask(msg,maskId='jr-mask'){
217
217
  const jrMask=document.getElementById(maskId)
218
-
219
218
  if((jrMask)){
220
219
  const jrMaskMsg=document.getElementById(`${maskId}-msg`)
221
220
  if(!jrMask.maskDiv){
@@ -32,11 +32,17 @@ export default class JRSubmit extends React.Component {
32
32
  }
33
33
  }
34
34
  }
35
- componentDidMount() {
35
+ componentDidMount(){
36
36
  this.#methods
37
37
  .filter((method) => this[method] && this.props[method] && this.props[method].autoRun)
38
38
  .forEach((method) => {
39
- this[method]()
39
+ if(this.props[method].autoRun===true){
40
+ this[method]()
41
+ } else if(this.props[method].autoRun>-1){
42
+ setTimeout(()=>{
43
+ this[method]()
44
+ },this.props[method].autoRun)
45
+ }
40
46
  })
41
47
  }
42
48
  get(_config = {}) {
@@ -248,10 +254,9 @@ export default class JRSubmit extends React.Component {
248
254
  .catch((res)=>{
249
255
  this.handleResponse(res,_payload,config)
250
256
  })
251
- .finally(()=> {
252
- // setTimeout(config.removeMaskFunction??avoid,random(4000,1000))
253
- config.removeMaskFunction?.()
254
- })
257
+ // .finally(()=> {
258
+ // config.removeMaskFunction?.()
259
+ // })
255
260
  }
256
261
 
257
262
  handleResponse=(response,payload,config)=>{
@@ -272,14 +277,27 @@ export default class JRSubmit extends React.Component {
272
277
  const isSuccess = response.status >= 200 && response.status <= 299
273
278
 
274
279
  this.setRes(isSuccess,response,config)
275
- this.showMessage(isSuccess,isSuccess?config.successMessage:config.failedMessage)
276
-
277
- config.callback?.bind(this)(isSuccess,response,payload)
280
+
281
+ if(config.delay!=null){
282
+ setTimeout(()=>{
283
+ this.showMessage(isSuccess,isSuccess?config.successMessage:config.failedMessage)
284
+ config.callback?.bind(this)(isSuccess,response,payload)
285
+ config.removeMaskFunction?.()
286
+ },config.delay)
287
+ }else{
288
+ this.showMessage(isSuccess,isSuccess?config.successMessage:config.failedMessage)
289
+ config.callback?.bind(this)(isSuccess,response,payload)
290
+ config.removeMaskFunction?.()
291
+ }
292
+
293
+
278
294
  }
279
295
 
280
296
  showMessage(success,message){
281
- po('success',success)
282
- po('message',message)
297
+ if(message){
298
+ po('success',success)
299
+ po('message',message)
300
+ }
283
301
  }
284
302
 
285
303
  renderer(){
@@ -43,7 +43,7 @@ export const StyledJRTable=styled.div`
43
43
  top: 0;
44
44
 
45
45
  th{
46
- xposition: relative;
46
+ position: 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;
@@ -1,5 +1,5 @@
1
1
  import React from "react"
2
- import { flexType, po } from "../JRUtils"
2
+ import { flexType } from "../JRUtils"
3
3
  import styled from "styled-components"
4
4
 
5
5
  const StyledSeparator=styled.tbody`
@@ -31,7 +31,6 @@ const Ths=({table,groupData,groupIndex,deep,rowColumn,rowIndex})=>{
31
31
  }else{
32
32
  content=column.label
33
33
  }
34
- // style.textAlign=align
35
34
  return <th key={colIndex}
36
35
 
37
36
  style={{textAlign:align,...style}}
@@ -101,15 +100,10 @@ const Td=({column:_column,record,tbodyIndex,trIndex,tdIndex,table})=>{
101
100
  setValue(record,targetValue)
102
101
  table.setValue(table.getValue())
103
102
  }
104
-
105
103
 
106
104
  const value=getValue(record)
107
105
  let style=render?{}:flexType(_style,table,{value,record},{})
108
- const setStyle=(_style)=>{
109
- style=_style
110
- }
111
- setStyle.bind(table)
112
- render?.bind(table)
106
+
113
107
  if(type){
114
108
  const typeStyle=flexType(_typeStyle,table,{record},{})
115
109
 
@@ -121,13 +115,16 @@ const Td=({column:_column,record,tbodyIndex,trIndex,tdIndex,table})=>{
121
115
  :onChange
122
116
  ,value
123
117
  ,style:typeStyle
124
- ,render
118
+ ,render:render?.bind(table)
125
119
  ,...column
126
120
  ,...funcProps?.bind(table)({value})
127
121
 
128
122
  })
129
123
  }else if(render){
130
- content=render({index:trIndex,groupIndex:tbodyIndex,value,record,onChange,setStyle})
124
+ const setStyle=(_style)=>{
125
+ style=_style
126
+ }
127
+ content=render.bind(table)({index:trIndex,groupIndex:tbodyIndex,value,record,onChange,setStyle})
131
128
  }else{
132
129
  content=value
133
130
  }
@@ -146,7 +143,6 @@ const Td=({column:_column,record,tbodyIndex,trIndex,tdIndex,table})=>{
146
143
  }
147
144
  const Tds=({leafColumns,record,table,tbodyIndex,trIndex})=>{
148
145
  return leafColumns?.map((column,tdIndex)=>{
149
-
150
146
  return <Td
151
147
  column={column}
152
148
  key={tdIndex}
@@ -162,59 +158,51 @@ const Tds=({leafColumns,record,table,tbodyIndex,trIndex})=>{
162
158
 
163
159
 
164
160
  const TBody=({groupData,groupHeader,leafColumns,groupFooter,table,tbodyIndex})=>{
165
-
166
161
  const neededProps={table,tbodyIndex}
167
- return <>
168
- <tbody key={`tbody${tbodyIndex}`}>
169
- {(groupData?.length >0 ) && <GroupHeader
170
- groupData={groupData}
171
- columns={groupHeader}
172
- {...neededProps}
173
- />}
174
- {
175
- groupData?.map?.((record,trIndex)=>{
176
- const onRowClick=table.props.onRowClick?.bind(table)
177
- return <tr key={trIndex}
178
- onClick={()=>{
179
- onRowClick?.({record,index:trIndex,groupIndex:tbodyIndex})
180
- }}
181
- >
182
- <Tds
183
- record={record}
184
- trIndex={trIndex}
185
-
186
- {...neededProps}
187
- leafColumns={leafColumns}
188
- />
189
- </tr>
190
- })
191
- }
192
- {(groupData?.length > 0) && <GroupFooter
193
- groupData={groupData}
194
- columns={groupFooter}
195
- {...neededProps}
196
- />}
162
+ return <tbody key={`tbody${tbodyIndex}`}>
163
+ {(groupData?.length >0 ) && <GroupHeader
164
+ groupData={groupData}
165
+ columns={groupHeader}
166
+ {...neededProps}
167
+ />}
168
+ {
169
+ groupData?.map?.((record,trIndex)=>{
170
+ const onRowClick=table.props.onRowClick?.bind(table)
171
+ return <tr key={trIndex}
172
+ onClick={()=>{
173
+ onRowClick?.({record,index:trIndex,groupIndex:tbodyIndex})
174
+ }}
175
+ >
176
+ <Tds
177
+ record={record}
178
+ trIndex={trIndex}
179
+
180
+ {...neededProps}
181
+ leafColumns={leafColumns}
182
+ />
183
+ </tr>
184
+ })
185
+ }
186
+ {(groupData?.length > 0) && <GroupFooter
187
+ groupData={groupData}
188
+ columns={groupFooter}
189
+ {...neededProps}
190
+ />}
197
191
 
198
- </tbody>
199
- {/* {(dataSource.length > (tbodyIndex+1)) && <Separator length={leafColumns.length} key={`sp-${tbodyIndex}`}></Separator>} */}
200
- </>
192
+ </tbody>
201
193
  }
202
194
 
203
195
  export const TBodies=({groupHeader,leafColumns,groupFooter,dataSource:_dataSource,table})=>{
204
- // po('--TBodies--')
205
196
  const isGroupDataType=Array.isArray(_dataSource?.[0])
206
197
 
207
198
  const dataSource=isGroupDataType
208
199
  ?_dataSource
209
200
  :[_dataSource]
210
201
 
211
- // po('dataSource',dataSource)
212
202
  return dataSource?.map((groupData,tbodyIndex,c)=>{
213
203
  return <TBody
214
204
  key={`tbody${tbodyIndex}`}
215
205
  table={table}
216
- // dataSource={dataSource}
217
- // dataGroup={groupData}
218
206
  groupData={groupData}
219
207
  tbodyIndex={tbodyIndex}
220
208
 
package/src/index.js CHANGED
@@ -11,13 +11,12 @@ import JRCheckbox from './components/JRInput/JRCheckbox'
11
11
  import JRRadio from './components/JRInput/JRRadio'
12
12
  import JRText from './components/JRInput/JRText'
13
13
  import JRMask,{JRDivMask,showMask} from './components/JRMask/JRMask'
14
- import {random} from './components/JRUtils'
14
+ import {random,po} from './components/JRUtils'
15
15
  export {
16
16
  JRTestReact
17
17
  ,JRSubmit,JRFrame,JRWindow,JRTable,JRFields,JRAlert
18
18
  ,JRButton
19
19
  ,JRText,JRSelect,JRCheckbox,JRRadio
20
20
  ,JRMask,JRDivMask,showMask
21
- ,random
22
-
21
+ ,random,po
23
22
  }