jrs-react 1.2.12 → 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 (41) hide show
  1. package/build/index.es.js +964 -3488
  2. package/build/index.js +982 -3486
  3. package/index.html +2 -2
  4. package/package.json +6 -1
  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 +28 -5
  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 -73
  21. package/src/assets/icon/index.jsx +0 -13
  22. package/src/components/JRAlert/index.jsx +71 -0
  23. package/src/components/JRFields/JRFields.jsx +178 -129
  24. package/src/components/JRFields/StyleJRFields.jsx +2 -3
  25. package/src/components/JRFields/Validators.jsx +33 -0
  26. package/src/components/JRFrame/JRFrame.jsx +12 -7
  27. package/src/components/JRFrame/JRFrameHOC.jsx +61 -0
  28. package/src/components/JRInput/JRInput.jsx +3 -2
  29. package/src/components/JRS.jsx +4 -0
  30. package/src/components/JRSubmit.jsx +1 -3
  31. package/src/components/JRTable/JRTable.jsx +10 -7
  32. package/src/components/JRTable/StyledJRTable.jsx +8 -0
  33. package/src/components/JRTable/THead.jsx +1 -1
  34. package/src/components/JRWindow/JRWindow.jsx +74 -10
  35. package/src/components/JRWindow/JRWindowHOC.jsx +114 -0
  36. package/src/components/JRWindow/Slider.jsx +21 -15
  37. package/src/components/JRWindow/Style.module.css +35 -0
  38. package/src/components/JRWindow/TitleBar.jsx +137 -35
  39. package/src/index.js +2 -1
  40. package/src/main.jsx +2 -1
  41. package/src/components/JRUtil.jsx +0 -1
@@ -5,6 +5,9 @@ import { StyledJRTable } from "./StyledJRTable";
5
5
  import JRFrame from "../JRFrame/JRFrame";
6
6
  import React from "react";
7
7
  import JRWindow from "../JRWindow/JRWindow";
8
+ import JRSubmit from "../JRSubmit";
9
+ import { JRFrameHOC } from "../JRFrame/JRFrameHOC";
10
+ import { JRWindowHOC } from "../JRWindow/JRWindowHOC";
8
11
 
9
12
 
10
13
  const getMapObject=(map,names)=>{
@@ -38,9 +41,6 @@ export default class JRTable extends JRWindow {
38
41
  }
39
42
 
40
43
  //------------------------------------------------------------------------------------
41
- getChecked(){
42
- return [1,2,3,4]
43
- }
44
44
  checkableColumn(props){
45
45
  return {//方法1
46
46
  render({value,onChange}){
@@ -195,8 +195,7 @@ export default class JRTable extends JRWindow {
195
195
  }
196
196
  this.setValue(this.getValue())
197
197
  }else{
198
- //未完成. 沒有資料的時候, 要考慮有或沒有dataSourceName的不同處理
199
- this.setValue({[this.props.dataSourceName]:[record]})
198
+ this.setValue(this.props.dataSourceName?{[this.props.dataSourceName]:[record]}:[record])
200
199
  }
201
200
  }
202
201
 
@@ -230,7 +229,11 @@ export default class JRTable extends JRWindow {
230
229
  table={this}
231
230
  />
232
231
  </table>
233
- <div className={'empty'}>{this.noData() && '無資料'}</div>
232
+ {this.noData() && <div className={'empty'}></div>}
233
+
234
234
  </StyledJRTable>
235
235
  }
236
- }
236
+ }
237
+
238
+ // export const FTable=JRFrameHOC(JRTable)
239
+ // export const WTable=JRWindowHOC(JRTable)
@@ -130,5 +130,13 @@ export const StyledJRTable=styled.div`
130
130
  display:flex;
131
131
  justify-content: center;
132
132
  align-items: center;
133
+
134
+
133
135
  }
136
+
137
+ > .empty::after{
138
+ content:'無資料';
139
+ position: block;
140
+ }
141
+
134
142
  `
@@ -29,7 +29,7 @@ const Ths=({deep,rowColumn,rowIndex,table})=>{
29
29
  {/* [s={column.colSpan??0}]
30
30
  [c={column.columnNo??0}] */}
31
31
  {
32
- table.props.resizableColumns===true
32
+ (table.props.resizableColumns===undefined || table.props.resizableColumns)
33
33
  && <Slider table={table} thRef={thRef} column={column}/>
34
34
  }
35
35
  </th>
@@ -5,22 +5,27 @@ import TitleBar from "./TitleBar";
5
5
  import { po } from "../JRUtils";
6
6
  import Slider from "./Slider";
7
7
  import Sliders from "./Slider";
8
+ import Fields from "../JRFields/JRFields";
9
+ import JRText from "../JRInput/JRText";
10
+ import style from './Style.module.css'
8
11
 
9
12
 
10
13
  const StyledJRWindow=styled.div`
11
14
  --jr-window-radius:3px;
12
15
  --padding-child:8px;
13
- --transition-x-y:height .1s ease-in, width .1s ease-in;
16
+ --transition-x-y:height .05s ease-in, width .05s ease-in;
14
17
  xborder:1px solid gray;
15
18
  position: fixed;
16
19
  padding: ${({$thick})=>$thick}px;
17
20
  border-radius: var(--jr-window-radius);
21
+ user-select: text;
18
22
 
19
23
  top: ${({$y})=>$y}px;
20
24
  left: ${({$x})=>$x}px;
21
25
  width: ${({$width=300})=>`${$width}px`};
22
26
  height: ${({$height=300})=>`${$height}px`};
23
27
  overflow: hidden;
28
+ z-index: 2;
24
29
 
25
30
  display: flex;
26
31
  flex-direction: column;
@@ -29,19 +34,19 @@ const StyledJRWindow=styled.div`
29
34
  > main{
30
35
  border-radius: var(--jr-window-radius);
31
36
  box-shadow: 0px 0px 5px 1px gray;
32
- Xbackground: white;
33
37
  display: flex;
34
38
  flex-direction: column;
35
39
  overflow: hidden;
36
40
  flex:1;
37
41
  > main {
38
- background: white;
39
42
  Xpadding:var(--padding-child);
40
43
  overflow: overlay;
41
44
  flex:1;
42
45
  display: flex;
46
+ min-height:32px;
43
47
  }
44
48
  }
49
+
45
50
  `
46
51
  export default class JRWindow extends JRFrame {
47
52
  x=0
@@ -57,9 +62,67 @@ export default class JRWindow extends JRFrame {
57
62
  this.titleBarRef=React.createRef()
58
63
  this.init()
59
64
  }
60
- componentWillUpdate(prevProps, prevState, snapshot){
61
- if(this.props.popup===true && this.props.open===true && prevProps.open===false){
62
- this.props.onOpen?.bind(this)()
65
+
66
+ addMaskToTarget=(target)=>{
67
+ this.mask=document.createElement('div')
68
+ this.mask.style.background='#868686cc'
69
+ this.mask.style.position='absolute'
70
+ this.mask.style.top='0'
71
+ this.mask.style.left='0'
72
+ this.mask.style.right='0'
73
+ this.mask.style.bottom='0'
74
+ this.mask.style.borderRadius='inherit'
75
+ this.mask.style.height='10000px'
76
+ this.mask.style.width='10000px'
77
+ target.appendChild(this.mask)
78
+ po('style.mask',style.mask)
79
+ po('addMask+++++++++++++++++++++++++++')
80
+ }
81
+ removeMaskFromTarget=()=>{
82
+ po('removeMask-----------------------')
83
+ this.mask.remove()
84
+ }
85
+
86
+ maskOnTarget(on){
87
+ po('typeof this.props.maskOn',typeof this.props.maskOn)
88
+ const target=(typeof this.props.maskOn)==='object'
89
+ ?this.props.maskOn
90
+ :typeof this.props.maskOn ==='string'
91
+ ?document.getElementById(this.props.maskOn)
92
+ :document.body
93
+
94
+ // this[on?'addMaskToTarget':'removeMaskFromTarget'](target)
95
+ target?.classList[on?'add':'remove']('withMask')
96
+ }
97
+
98
+ componentDidMount(){
99
+ super.componentDidMount()
100
+ if(this.props.maskOn && this.props.open){
101
+ this.maskOnTarget(this.props.open)
102
+ }
103
+
104
+ if(this.props.open){
105
+ this.open()
106
+ }
107
+ }
108
+
109
+ open(){
110
+ this.props.onOpen?.bind(this)()
111
+ }
112
+ close(){
113
+ this.props.onClose?.bind(this)()
114
+ }
115
+
116
+ componentDidUpdate(prevProps, prevState, snapshot){
117
+ if(this.props.popup===true){
118
+ if(this.props.open && prevProps.open===false){
119
+ this.open()
120
+ }else if(this.props.open===false && prevProps.open){
121
+ this.close()
122
+ }
123
+ if(this.props.maskOn && this.props.open!=prevProps.open){
124
+ this.maskOnTarget(this.props.open)
125
+ }
63
126
  }
64
127
  }
65
128
  init(){
@@ -68,10 +131,10 @@ export default class JRWindow extends JRFrame {
68
131
  this.x=this.props.x??((window.innerWidth-(this.width??300))/2)
69
132
  this.y=this.props.y??(window.innerHeight-(this.height??300))/2
70
133
  }
134
+
71
135
  renderer(){
72
-
73
136
  return this.props.popup===true
74
- ?this.props.open===true
137
+ ?this.props.open
75
138
  ?<StyledJRWindow
76
139
  ref={this.ref}
77
140
  className={`jr-window ${this.props.className??''}`}
@@ -88,7 +151,7 @@ export default class JRWindow extends JRFrame {
88
151
  window={this}
89
152
  title={this.props.title}
90
153
  thick={this.thick}
91
- />
154
+ />
92
155
  <main>
93
156
  {super.renderer()}
94
157
  </main>
@@ -103,4 +166,5 @@ export default class JRWindow extends JRFrame {
103
166
  :''
104
167
  :super.renderer()
105
168
  }
106
- }
169
+ }
170
+
@@ -0,0 +1,114 @@
1
+ import React from "react";
2
+ import JRFields from "../JRFields/JRFields";
3
+ import styled from "styled-components";
4
+ import Sliders from "./Slider";
5
+ import TitleBar from "./TitleBar";
6
+
7
+
8
+ const StyledJRWindow=styled.div`
9
+ --jr-window-radius:3px;
10
+ --padding-child:8px;
11
+ --transition-x-y:height .05s ease-in, width .05s ease-in;
12
+ xborder:1px solid gray;
13
+ position: fixed;
14
+ padding: ${({$thick})=>$thick}px;
15
+ border-radius: var(--jr-window-radius);
16
+
17
+ top: ${({$y})=>$y}px;
18
+ left: ${({$x})=>$x}px;
19
+ width: ${({$width=300})=>`${$width}px`};
20
+ height: ${({$height=300})=>`${$height}px`};
21
+ overflow: hidden;
22
+
23
+ display: flex;
24
+ flex-direction: column;
25
+ overflow: hidden;
26
+
27
+ > main{
28
+ border-radius: var(--jr-window-radius);
29
+ box-shadow: 0px 0px 5px 1px gray;
30
+ Xbackground: white;
31
+ display: flex;
32
+ flex-direction: column;
33
+ overflow: hidden;
34
+ flex:1;
35
+ > main {
36
+ background: white;
37
+ Xpadding:var(--padding-child);
38
+ overflow: overlay;
39
+ flex:1;
40
+ display: flex;
41
+ }
42
+ }
43
+
44
+ @container (min-width: 700px) {
45
+ &{
46
+ border: 1px solid red;
47
+ }
48
+ }
49
+ `
50
+
51
+ export const JRWindowHOC = (WrappedComponent) => {
52
+ return class extends React.Component {
53
+ x=0
54
+ y=0
55
+ width=300
56
+ height=300
57
+ padding=1
58
+ thick=5
59
+
60
+ constructor(props){
61
+ super(props)
62
+ this.ref=React.createRef()
63
+ this.titleBarRef=React.createRef()
64
+ this.init()
65
+ }
66
+ componentWillUpdate(prevProps, prevState, snapshot){
67
+ if(this.props.popup===true && this.props.open===true && prevProps.open===false){
68
+ this.props.onOpen?.bind(this)()
69
+ }
70
+ }
71
+ init(){
72
+ this.height=window.innerHeight>=(this.props.height??this.height)?(this.props.height??this.height):window.innerHeight
73
+ this.width=window.innerWidth>=(this.props.width??this.width)?(this.props.width??this.width):window.innerWidth
74
+ this.x=this.props.x??((window.innerWidth-(this.width??300))/2)
75
+ this.y=this.props.y??(window.innerHeight-(this.height??300))/2
76
+ }
77
+
78
+ render() {
79
+ return this.props.popup===true
80
+ ?this.props.open===true
81
+ ?<StyledJRWindow
82
+ ref={this.ref}
83
+ className={`jr-window ${this.props.className??''}`}
84
+ $x={this.x}
85
+ $y={this.y}
86
+ $width={this.width}
87
+ $height={this.height}
88
+ $thick={this.thick}
89
+ >
90
+ <main>
91
+ <TitleBar
92
+ titleBarRef={this.titleBarRef}
93
+ windowRef={this.ref}
94
+ window={this}
95
+ title={this.props.title}
96
+ thick={this.thick}
97
+ />
98
+ <main>
99
+ <WrappedComponent {...this.props} />
100
+ </main>
101
+ </main>
102
+ <Sliders
103
+ thick={this.thick}
104
+ windowRef={this.ref}
105
+ window={this}
106
+ titleBarRef={this.titleBarRef}
107
+ />
108
+ </StyledJRWindow>
109
+ :''
110
+ :<WrappedComponent {...this.props} />
111
+ }
112
+ }
113
+ };
114
+
@@ -2,7 +2,6 @@ import React from "react"
2
2
  import styled from "styled-components"
3
3
  import { po } from "../JRUtils"
4
4
 
5
- const borderWidth='px'
6
5
  const directions=['n','e','s','w','nww','nnw','nne','nee','sse','see','sww','ssw']
7
6
  export default class Sliders extends React.Component {
8
7
  render(){
@@ -39,7 +38,7 @@ const StyledSlider=styled.div`
39
38
  class Slider extends React.Component {
40
39
  width='3px'
41
40
  borderWidth='px'
42
- borderLong=30
41
+ borderLong=5
43
42
 
44
43
  constructor(props){
45
44
  super(props);
@@ -201,15 +200,12 @@ class Slider extends React.Component {
201
200
  let y=cursorY-(this.props.thick)
202
201
  if(y<0)y=0
203
202
  let height=startHeight+(startY-y)
204
-
205
203
  if(height<titleBarHeight+(this.props.thick*2)){
206
204
  height=titleBarHeight+(this.props.thick*2)
207
205
  y=startY + startHeight - titleBarHeight - (this.props.thick*2)
208
206
  }
209
-
210
207
  window.style.top=`${y}px`
211
208
  window.style.height=`${height}px`
212
-
213
209
  }
214
210
  resizeE=({window,clientX,left,titleBarHeight})=>{
215
211
  let width=clientX-left-this.props.thick
@@ -248,14 +244,16 @@ class Slider extends React.Component {
248
244
  if(x>window.innerWidth)this.props.windowRef.current.style.left = `${window.innerWidth-width}px`
249
245
  document.body.style.cursor='default'
250
246
  window.removeEventListener('mousemove',this.move)
247
+ window.removeEventListener('mousemove',this.preMove)
251
248
  window.removeEventListener('mouseup',this.stop)
252
249
  }
253
250
  move=(e)=>{
254
251
  e.preventDefault()
252
+ this.props.windowRef.current.style.transition='unset'
255
253
  const {clientX,clientY,x:cursorX,y:cursorY}=e
256
254
  const window=this.props.windowRef.current
257
255
  const {left,top}=window.getBoundingClientRect()
258
- const {x:startX,width:startWidth,y:startY,height:startHeight,titleBarHeight}=this.data
256
+ let {x:startX,width:startWidth,y:startY,height:startHeight,titleBarHeight}=this.data
259
257
 
260
258
  this.directions[this.props.direction].resize({
261
259
  window,titleBarHeight
@@ -263,20 +261,25 @@ class Slider extends React.Component {
263
261
  ,clientY,cursorY,startY,startHeight,top
264
262
  })
265
263
  }
264
+ preMove=()=>{
265
+ 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
269
+ }
270
+ window.removeEventListener('mousemove',this.preMove)
271
+ setTimeout(()=>{
272
+ window.addEventListener('mousemove',this.move)
273
+ },100)
274
+ }
266
275
  start=(e,direction)=>{
267
276
  e.preventDefault()
268
277
  const {height:titleBarHeight}=this.props.titleBarRef.current.getBoundingClientRect()
269
278
  let {x,y,width,height}=this.props.windowRef.current.getBoundingClientRect()
270
279
 
271
- if(direction.indexOf('n')>-1){
272
- if(this.props.window.orgHeight){
273
- height=this.props.window.orgHeight
274
- this.props.window.orgHeight=null
275
- }
276
- }else if(direction.indexOf('s')>-1){
280
+ if(this.props.direction.indexOf('s')>-1){
277
281
  this.props.window.orgHeight=null
278
282
  }
279
-
280
283
  this.data={
281
284
  x,y
282
285
  ,width
@@ -284,9 +287,12 @@ class Slider extends React.Component {
284
287
  ,titleBarHeight
285
288
  ,direction
286
289
  }
287
- this.props.windowRef.current.style.transition='unset'
288
290
  document.body.style.cursor=this.directions[this.props.direction].cursor
289
- window.addEventListener('mousemove',this.move)
291
+ if(this.props.window.orgHeight){
292
+ window.addEventListener('mousemove',this.preMove)
293
+ }else{
294
+ window.addEventListener('mousemove',this.move)
295
+ }
290
296
  window.addEventListener('mouseup',this.stop)
291
297
  }
292
298
 
@@ -0,0 +1,35 @@
1
+ .test {
2
+ color: red;
3
+ border: 1px solid red;
4
+ }
5
+
6
+ .withMask{
7
+ position: relative;
8
+ overflow: hidden !important;
9
+ user-select: none;
10
+ &::after{
11
+ content:'' ;
12
+ background : #868686cc;
13
+ a:#868686cc;
14
+ position: absolute;
15
+ top: 0;
16
+ left: 0;
17
+ right: 0;
18
+ bottom: 0;
19
+ border-radius: inherit;
20
+ height: 10000px;
21
+ width: 10000px;
22
+ }
23
+ }
24
+
25
+ mask{
26
+ background : #868686cc;
27
+ position: absolute;
28
+ top: 0;
29
+ left: 0;
30
+ right: 0;
31
+ bottom: 0;
32
+ border-radius: inherit;
33
+ height: 10000px;
34
+ width: 10000px;
35
+ }