jrs-react 1.2.13 → 1.2.14

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 (39) hide show
  1. package/build/index.es.js +1015 -727
  2. package/build/index.js +1015 -727
  3. package/index.html +2 -2
  4. package/package.json +3 -2
  5. package/public/alert.json +4 -0
  6. package/public/data.json +10 -0
  7. package/public/data2.json +19 -0
  8. package/public/list.json +99 -0
  9. package/src/app/App.css +25 -3
  10. package/src/app/App.jsx +22 -1
  11. package/src/app/alert/AlertApp.jsx +92 -0
  12. package/src/app/axios/AxiosApp.jsx +71 -0
  13. package/src/app/fields/FieldsApp.jsx +22 -6
  14. package/src/app/fields/fieldsConfig.jsx +227 -1
  15. package/src/app/fields/tryHOC.jsx +21 -0
  16. package/src/app/fields/validator.jsx +217 -0
  17. package/src/app/index.css +1 -1
  18. package/src/app/table/tableConfig.jsx +4 -1
  19. package/src/app/test/index.jsx +8 -0
  20. package/src/app/window/WindowApp.jsx +120 -83
  21. package/src/components/JRAlert/index.jsx +71 -0
  22. package/src/components/JRFields/JRFields.jsx +178 -129
  23. package/src/components/JRFields/StyleJRFields.jsx +2 -3
  24. package/src/components/JRFields/Validators.jsx +33 -0
  25. package/src/components/JRFrame/JRFrame.jsx +12 -7
  26. package/src/components/JRFrame/JRFrameHOC.jsx +61 -0
  27. package/src/components/JRInput/JRInput.jsx +3 -2
  28. package/src/components/JRS.jsx +4 -0
  29. package/src/components/JRSubmit.jsx +1 -3
  30. package/src/components/JRTable/JRTable.jsx +10 -7
  31. package/src/components/JRTable/StyledJRTable.jsx +8 -0
  32. package/src/components/JRTable/THead.jsx +1 -1
  33. package/src/components/JRWindow/JRWindow.jsx +73 -15
  34. package/src/components/JRWindow/JRWindowHOC.jsx +114 -0
  35. package/src/components/JRWindow/Slider.jsx +8 -3
  36. package/src/components/JRWindow/Style.module.css +35 -0
  37. package/src/components/JRWindow/TitleBar.jsx +116 -33
  38. package/src/main.jsx +2 -1
  39. package/src/components/JRUtil.jsx +0 -1
@@ -4,9 +4,11 @@ import JRSelect from "../../components/JRInput/JRSelect";
4
4
  import JRText from "../../components/JRInput/JRText";
5
5
  import JRTable from "../../components/JRTable/JRTable";
6
6
  import { po } from "../../components/JRUtils";
7
+ import styled from "styled-components";
7
8
 
8
9
  export const fieldsConfig={
9
10
  popup:true
11
+ ,open:true
10
12
  ,mask:true
11
13
  ,width:'700px'
12
14
  ,height:'500px'
@@ -129,9 +131,233 @@ export const fieldsConfig={
129
131
  <pre>
130
132
  {JSON.stringify(this.getValue(),4,4)}
131
133
  </pre>
132
- <pre>
134
+ <pre>rawValue
133
135
  {JSON.stringify(this.rawValue,4,4)}
134
136
  </pre>
135
137
  </div>
136
138
  }
139
+ }
140
+ //////////////////////////////////////////////////////
141
+ export const normalFields={
142
+ get:{
143
+ url:'data.json'
144
+ ,autoRun:true
145
+ }
146
+ ,columns:[
147
+ {name:'name',label:'Name',type:JRText,required:true}
148
+ ,{name:'account',label:'Account',type:JRText
149
+ ,validators:[
150
+ function(){
151
+ return 'Account always error'
152
+ }
153
+ ]
154
+ }
155
+ ,{name:'email',label:'Email',type:JRText}
156
+ ,{name:'birthday',label:'Birthday',type:JRText}
157
+ ,{name:'address',label:'Address',type:JRFields
158
+ ,columns:[
159
+ {name:'no',label:'No',type:JRText,required:true}
160
+ ,{name:'street',label:'Street',type:JRText}
161
+ ,{name:'country',label:'Country',type:JRText}
162
+ ]
163
+ ,labelProps:{
164
+ layout:'h'
165
+ ,colon:":"
166
+ }
167
+ ,style:{
168
+ // border:'1px solid red'
169
+ }
170
+ ,typeStyle:{
171
+ // border:'1px solid blue'
172
+ }
173
+ ,columnStyle:{
174
+ padding:'0 10px 0 0'
175
+ ,marginTop: '4px'
176
+ ,border:'1px solid gray'
177
+ ,borderRadius: '3px'
178
+ }
179
+ ,gridStyle:{
180
+ padding:'unset'
181
+ // ,border:'1px solid black'
182
+ }
183
+ }
184
+ ,{
185
+ label:''
186
+ ,columns:[
187
+ {name:'father',label:'Father',type:JRText,required:true}
188
+ ,{name:'mother',label:'Mother',type:JRText,required:true}
189
+ ]
190
+ ,cols:2
191
+ ,columnStyle:{
192
+ padding:'6px'
193
+ ,marginTop: '4px'
194
+ ,border:'1px solid black'
195
+ ,borderRadius: '3px'
196
+ }
197
+ }
198
+
199
+ ,{name:'phone',label:'Phone',colSpan:2,type:JRTable
200
+ ,columns:[
201
+ {name:'name',label:'Name',type:JRText,width:'160px'}
202
+ ,{name:'phone',label:'Number',type:JRText}
203
+ ]
204
+ ,validators:[
205
+ function(value,column){
206
+ po(value,column)
207
+ return 'Validate table'
208
+ }
209
+ ]
210
+ }
211
+ ]
212
+ ,cols:2
213
+ ,style:{
214
+ border:'1px solid gray'
215
+ }
216
+ }
217
+ ////////////////////////////////////////////////////////////
218
+ const StyledDiv=styled.div`
219
+ display: flex;
220
+ gap: 10px;
221
+ padding: 5px;
222
+ `
223
+ export const withSomeButton={
224
+ top:function({setStyle}){
225
+ return <StyledDiv>
226
+ <button
227
+ onClick={()=>{
228
+ this.get({
229
+ url:'data2.json'
230
+ ,value:{
231
+ abc:123
232
+ }
233
+ })
234
+ }}
235
+ >Get</button>
236
+
237
+ <button
238
+ onClick={()=>{
239
+
240
+ this.setValue(null,true)
241
+ }}
242
+ >Clear</button>
243
+
244
+ <button
245
+ onClick={()=>{
246
+ this.reset()
247
+ }}
248
+ >Reset</button>
249
+
250
+ <button
251
+ onClick={()=>{
252
+ this.validate()
253
+ .then(()=>{
254
+
255
+ })
256
+ .catch(()=>{
257
+
258
+ })
259
+ }}
260
+ >Validate</button>
261
+
262
+ <button
263
+ onClick={()=>{
264
+ this.validate()
265
+ .then(()=>{
266
+ po('submit this',this)
267
+ this.post()
268
+ })
269
+ .catch(()=>{
270
+ po('submit this',this)
271
+ })
272
+ }}
273
+ >Submit</button>
274
+ </StyledDiv>
275
+ }
276
+ ,bottom({setStyle}){
277
+ setStyle({color:'gray',border:'1px solid blue',whiteSpace:'pre',overflow: 'overlay'})
278
+ return <div style={{
279
+ display: 'flex'
280
+ ,justifyContent: 'space-around'
281
+ // ,maxHeight:'300px'
282
+ }}>
283
+ <pre>
284
+ {JSON.stringify(this.getValue(),4,4)}
285
+ </pre>
286
+ <pre>rawValue=
287
+ {JSON.stringify(this.getTestValue(),4,4)}
288
+ </pre>
289
+ </div>
290
+ }
291
+ }
292
+
293
+ ///////////////////////////////////////////////////////////////////////
294
+ export const labelLayout={
295
+ ...normalFields
296
+ ,labelProps:{
297
+ layout:'v'
298
+ ,colon:null
299
+ ,gap:'10px'
300
+ }
301
+ ,gap:'16px'
302
+ }
303
+
304
+ ///////////////////////////////////////////////////////////////////////
305
+ export const devFields={
306
+ get:{
307
+ url:'data.json'
308
+ ,autoRun:true
309
+ ,callback(success,res){
310
+ po('success,data',success,res)
311
+ // setTimeout(()=>{
312
+ // po('callback setTimeout',this.getValue())
313
+ this.validate(res.data)
314
+ .then(()=>{
315
+ po('+++++++++++++++++++')
316
+ })
317
+ .catch(()=>{
318
+ po('-------------------')
319
+ })
320
+ // },1)
321
+ }
322
+ ,xformatValue(data){
323
+ po('formatValue',data)
324
+ return {aaa:'111'}
325
+ }
326
+ }
327
+ ,post:{
328
+ url:'post'
329
+ ,method:'get'
330
+ ,callback(){
331
+ this.setValue(null,true)
332
+ }
333
+ }
334
+ ,columns:[
335
+ {name:'name',label:'Name',type:JRText,Xrequired:true
336
+ ,validators:[
337
+ function(value){
338
+ if(value=='Joren'){
339
+ return Promise.reject('Test cannot be Joren')
340
+ }else{
341
+ return Promise.resolve('Test')
342
+ }
343
+ }
344
+ ]
345
+ }
346
+ ,{name:'email',label:'Email',type:JRText,required:true}
347
+ ,{
348
+ label:'Parents'
349
+ ,columns:[
350
+ {name:'father',label:'Father',type:JRText,required:true}
351
+ ,{name:'mother',label:'Mother',type:JRText,required:true}
352
+ ]
353
+ ,cols:2
354
+ ,columnStyle:{
355
+ padding:'6px'
356
+ ,marginTop: '4px'
357
+ ,border:'1px solid black'
358
+ ,borderRadius: '3px'
359
+ }
360
+ }
361
+ ]
362
+ ,cols:1
137
363
  }
@@ -0,0 +1,21 @@
1
+ import JRText from "../../components/JRInput/JRText";
2
+ import { po } from "../../components/JRUtils";
3
+
4
+ export const tryHOC={
5
+ open:true
6
+ ,popup:true
7
+ ,title:'HOC window'
8
+ ,columns:[
9
+ {name:'name',label:'電信公司',type:JRText,required:true}
10
+ ]
11
+ ,bottom(){
12
+ return <div>
13
+ <button
14
+ onClick={()=>{
15
+ po(this)
16
+ // this.validate()
17
+ }}
18
+ >Validate</button>
19
+ </div>
20
+ }
21
+ }
@@ -0,0 +1,217 @@
1
+ import axios from "axios";
2
+ import JRText from "../../components/JRInput/JRText";
3
+ import {po} from '../../components/JRUtils'
4
+
5
+
6
+ // axios.interceptors.response.use(
7
+ // (Response) => {
8
+ // po('interceptors++++++++++++++++++++++++++',Response,Response)
9
+ // if(Response?.status!=200){
10
+ // po('fffffffffffffffff')
11
+ // return Promise.reject(Error);
12
+ // }
13
+ // return Promise.resolve(Response);
14
+ // },
15
+ // (Error) => {
16
+ // po('interceptors---------------------------',Error)
17
+ // return Promise.reject(Error);
18
+ // }
19
+ // );
20
+
21
+ export const fields={
22
+ open:true
23
+ ,popup:true
24
+ ,title:'Firelds'
25
+ ,cols:2
26
+ ,width:600
27
+ ,height:220
28
+ ,columns:[
29
+ {name:'a',label:'A',type:JRText}
30
+ ,{name:'b',label:'B',type:JRText}
31
+ ,{name:'c',label:'C',type:JRText}
32
+ ,{name:'d',label:'D',type:JRText}
33
+ ,{name:'e',label:'E',type:JRText}
34
+ ,{name:'f',label:'F',type:JRText}
35
+ ,{name:'g',label:'G',type:JRText}
36
+ ,{name:'h',label:'H',type:JRText}
37
+ ,{name:'i',label:'I',type:JRText}
38
+ ,{name:'j',label:'G',type:JRText}
39
+ ,{name:'k',label:'K',type:JRText}
40
+ ]
41
+ }
42
+
43
+ export const fieldsValidator={
44
+ get:{
45
+ url:'data.json'
46
+ ,autoRun:true
47
+ }
48
+ ,columns:[
49
+ {name:'name'
50
+ ,label:'Name'
51
+ ,type:JRText
52
+ ,required:true
53
+ ,max:5
54
+ ,min:3
55
+ ,xvalidators:[
56
+ function(value){
57
+ // return Promise.reject('value cannot be 1')
58
+ if(value=='Joren'){
59
+ return Promise.reject('value cannot be Joren')
60
+ }else{
61
+ return Promise.resolve()
62
+ }
63
+ }
64
+ ,function(value){
65
+ if(value=='11'){
66
+ return Promise.reject('value cannot be 11')
67
+ }else{
68
+ return Promise.resolve()
69
+ }
70
+ }
71
+ ]
72
+ }
73
+ // ,{
74
+ // columns:[
75
+ // {name:'housePhone',label:'House phone'
76
+ // ,columns:[
77
+ // {name:'h1',label:'H1',type:JRText}
78
+ // ,{name:'h2',label:'H2',type:JRText
79
+ // ,validators:[
80
+ // function(value){
81
+ // // po('validators b2 1')
82
+ // if(value==2)
83
+ // return Promise.resolve('H2 2 is 2 good')
84
+ // else{
85
+ // return Promise.reject('H2 1 is not 2 bad')
86
+ // }
87
+ // }
88
+ // ,function(){
89
+ // // po('validators b2 2')
90
+ // return Promise.resolve('H2 2 is good')
91
+ // }
92
+ // ]
93
+ // }
94
+ // ]
95
+
96
+ // }
97
+ // ,{name:'handPhone',label:'Hand phone',type:JRText
98
+
99
+ // ,validators:[
100
+ // function(){
101
+ // // po('validators b2 1')
102
+ // return Promise.resolve('b2 1 bad')
103
+ // }
104
+ // ]
105
+ // }
106
+ // ]
107
+ // }
108
+ // ,{name:'account',label:'Account',type:JRText
109
+ // ,validators:[
110
+ // function(){
111
+ // // po('validators c1',this)
112
+ // return Promise.resolve('c1 good')
113
+ // }
114
+ // ,function(){
115
+ // // po('validators c2')
116
+ // return Promise.resolve('c2 good')
117
+ // }
118
+ // ]
119
+ // }
120
+ ,{name:'dataUrl',label:'data2',type:JRText
121
+ ,validators:[
122
+ function(value){
123
+ return axios.get(value
124
+ , {
125
+ params:{
126
+ name: "2",
127
+ parts: "4"
128
+ }
129
+ }
130
+ ).then((Response)=>{
131
+ po('JRText ++++++++++++++++++++++++++',Response)
132
+ if(Response.data?.dataUrl=='data.json'){
133
+ po('fffffffffffffffff')
134
+ return Promise.resolve(Response);
135
+ }
136
+ return Promise.reject('Url error');
137
+ })
138
+ .catch(()=>{
139
+ po('JRText ffffffffffffff')
140
+ return Promise.reject('url false 2')
141
+ })
142
+ }
143
+ ]
144
+ }
145
+
146
+ ]
147
+ ,typeStyle:{
148
+ // background: 'white'
149
+ border:'5px solid green'
150
+ }
151
+ ,debugMode:true
152
+ ,top:function({setStyle}){
153
+ setStyle({
154
+ placeSelf: 'end'
155
+ ,padding:'10px'
156
+ })
157
+
158
+ return <div>
159
+ <button
160
+ onClick={()=>{
161
+ this.get({value:{a:'111x'}})
162
+ }}
163
+ >Get</button>
164
+
165
+ <button
166
+ onClick={()=>{
167
+ this.setValue(null,true)
168
+ }}
169
+ >Clear</button>
170
+
171
+ <button
172
+ onClick={()=>{
173
+ this.reset()
174
+ }}
175
+ >Reset</button>
176
+
177
+ <button
178
+ onClick={()=>{
179
+ // this.validateFields()
180
+ this.validate()
181
+ .then(()=>{
182
+ po('success',this.state.testValue)
183
+ })
184
+ .catch(()=>{
185
+ po('failed',this.state.testValue)
186
+ })
187
+ }}
188
+ >Validate</button>
189
+ </div>
190
+ }
191
+ ,bottom:function({setStyle}){
192
+ setStyle({
193
+ border:'1px solid red'
194
+ ,maxHeight:'100px'
195
+ })
196
+ return <div style={{
197
+ display: 'flex'
198
+ ,justifyContent: 'space-around'
199
+ }}>
200
+ <pre>Value=
201
+ {JSON.stringify(this.getValue(),4,4)}
202
+ </pre>
203
+ <pre>testValue=
204
+ {JSON.stringify(this.getTestValue(),4,4)}
205
+ </pre>
206
+ </div>
207
+ }
208
+ ,left:function({setStyle}){
209
+ setStyle({
210
+ border:'4px solid blue'
211
+ })
212
+ return 'Left'
213
+ }
214
+ ,open:true
215
+ ,popup:true
216
+ ,title:'Firelds'
217
+ }
package/src/app/index.css CHANGED
@@ -1,5 +1,5 @@
1
1
  :root {
2
-
2
+ color-scheme: dark;
3
3
  }
4
4
 
5
5
  a {
@@ -2,8 +2,10 @@ import JRText from "../../components/JRInput/JRText";
2
2
 
3
3
  export const tableConfig={
4
4
  popup:true
5
+ ,open:true
5
6
  ,height:500
6
7
  ,width:600
8
+ ,title:'HOC table'
7
9
  ,get:{
8
10
  url:'list.json'
9
11
  ,autoRun:true
@@ -11,7 +13,8 @@ export const tableConfig={
11
13
  ,mask:'Loading'
12
14
  }
13
15
  ,columns:[
14
- {name:'Test',label:'1'
16
+ {name:'name',label:'Name'}
17
+ ,{name:'Test',label:'1'
15
18
  ,rowSpan:4
16
19
  ,columns:[
17
20
  {name:'Test21',label:'1_1'
@@ -0,0 +1,8 @@
1
+ import React, { useEffect } from "react"
2
+
3
+
4
+ export default function TestApp(){
5
+ useEffect(()=>{
6
+ },[])
7
+ return <div>Test</div>
8
+ }