jrs-react 1.2.5 → 1.2.7

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.
@@ -4,7 +4,6 @@ import { colonValueString, flexType, po } from './JRUtils'
4
4
  import { displaySpinner } from './LoadingBar'
5
5
  import styled from 'styled-components'
6
6
 
7
-
8
7
  const axiosSubmit = axios.create({
9
8
  authorization: `Bearer ${localStorage.getItem("accessToken")}`
10
9
  ,timeout: 120000
@@ -110,6 +109,8 @@ export default class JRSubmit extends React.Component {
110
109
  }
111
110
  setValue(value,reset=false){
112
111
  if(this.props.onChange){
112
+ po('name',this.props.name)
113
+ po('onChange',value)
113
114
  this.props.onChange(value)
114
115
  }else{
115
116
  this.setState({value})
@@ -278,8 +279,8 @@ export default class JRSubmit extends React.Component {
278
279
  }
279
280
 
280
281
  showMessage(success,message){
281
- po('success',success)
282
- po('message',message)
282
+ // po('success',success)
283
+ // po('message',message)
283
284
  }
284
285
 
285
286
  renderer(){
@@ -4,6 +4,7 @@ import { TBodies } from "./TBodies";
4
4
  import { StyledJRTable } from "./StyledJRTable";
5
5
  import JRFrame from "../JRFrame/JRFrame";
6
6
  import React from "react";
7
+ import JRWindow from "../JRWindow/JRWindow";
7
8
 
8
9
 
9
10
  const getMapObject=(map,names)=>{
@@ -26,14 +27,14 @@ const setMapObject=(map,names,value)=>{
26
27
  }
27
28
  }
28
29
 
29
- export default class JRTable extends JRFrame {
30
+ export default class JRTable extends JRWindow {
30
31
  constructor(props) {
31
32
  super(props)
32
33
  this.colGroupRef = React.createRef()
33
34
  }
34
35
 
35
36
  UNSAFE_componentWillMount(){
36
- this.setColumns(this.props.columns)
37
+ this.setColumns(this.props.columns??[])
37
38
  }
38
39
 
39
40
  //------------------------------------------------------------------------------------
@@ -1,7 +1,7 @@
1
1
  import React from "react"
2
2
  import styled from "styled-components"
3
3
 
4
- export const StyledSlider=styled.div`
4
+ const StyledSlider=styled.div`
5
5
  position: absolute;
6
6
  top: 0;
7
7
  right: 0;
@@ -44,8 +44,7 @@ export const StyledJRTable=styled.div`
44
44
 
45
45
  th{
46
46
  position: relative;
47
- height:24px;
48
- padding: 4px;
47
+ padding: 2px 6px;
49
48
  background: linear-gradient(180deg, rgba(227, 227, 226, 1) 0%, rgba(255, 255, 255, 1) 25%, rgba(210, 210, 210, 1) 100%);
50
49
  box-shadow: 2px 2px 2px 0 #ffffffd6 inset, -1px -1px 2px 0px #8a847dbf inset;
51
50
  color: #525252;
@@ -172,7 +172,7 @@ const TBody=({groupData,groupHeader,leafColumns,groupFooter,table,tbodyIndex})=>
172
172
  {...neededProps}
173
173
  />}
174
174
  {
175
- groupData?.map((record,trIndex)=>{
175
+ groupData?.map?.((record,trIndex)=>{
176
176
  const onRowClick=table.props.onRowClick?.bind(table)
177
177
  return <tr key={trIndex}
178
178
  onClick={()=>{
@@ -0,0 +1,110 @@
1
+ import React from "react";
2
+ import JRFrame from "../JRFrame/JRFrame";
3
+ import styled from "styled-components";
4
+ import TitleBar from "./TitleBar";
5
+ import { po } from "../JRUtils";
6
+ import Slider from "./Slider";
7
+
8
+ const StyledJRWindow=styled.div`
9
+ --padding-child:8px;
10
+ xborder:1px solid gray;
11
+ position: absolute;
12
+ padding: ${({$thick})=>$thick}px;
13
+
14
+ top: ${({$y})=>$y}px;
15
+ left: ${({$x})=>$x}px;
16
+ width: ${({$width=300})=>`${$width}px`};
17
+ height: ${({$height=300})=>`${$height}px`};
18
+ overflow: hidden;
19
+
20
+ display: flex;
21
+ flex-direction: column;
22
+ overflow: hidden;
23
+
24
+ > main{
25
+ box-shadow: 0px 0px 5px 1px gray;
26
+ Xbackground: white;
27
+ display: flex;
28
+ flex-direction: column;
29
+ overflow: hidden;
30
+ flex:1;
31
+ > main {
32
+ background: white;
33
+ Xpadding:var(--padding-child);
34
+ overflow: overlay;
35
+ flex:1;
36
+ display: flex;
37
+ }
38
+ }
39
+ `
40
+ export default class JRWindow extends JRFrame {
41
+ x=0
42
+ y=0
43
+ width=300
44
+ height=300
45
+ padding=5
46
+ thick=3
47
+
48
+ constructor(props){
49
+ super(props)
50
+ this.ref=React.createRef()
51
+ this.titleBarRef=React.createRef()
52
+ if(this.props.popup===true)this.renderer=this.renderWindow
53
+ this.init()
54
+ }
55
+ init(){
56
+ this.height=window.innerHeight>=this.props.height?this.props.height:window.innerHeight
57
+ this.width=window.innerWidth>=this.props.width?this.props.width:window.innerWidth
58
+ this.x=this.props.x??((window.innerWidth-(this.width??300))/2)
59
+ this.y=this.props.y??(window.innerHeight-(this.height??300))/2
60
+ }
61
+ componentWillMount(){
62
+ }
63
+ // renderer(){
64
+ // return this.props.popup===true
65
+ // ?<StyledJRWindow>
66
+ // {super.renderer()}
67
+ // </StyledJRWindow>
68
+ // :super.renderer()
69
+ // }
70
+ renderWindow(){
71
+ return <StyledJRWindow
72
+ ref={this.ref}
73
+ className={`jr-window ${this.props.className??''}`}
74
+ $x={this.x}
75
+ $y={this.y}
76
+ $width={this.width}
77
+ $height={this.height}
78
+ $thick={this.thick}
79
+ // onMouseDown={()=>{
80
+ // po('onFocus')
81
+ // this.ref.current.style.zIndex=100
82
+ // }}
83
+ >
84
+ <main>
85
+ <TitleBar
86
+ titleBarRef={this.titleBarRef}
87
+ windowRef={this.ref}
88
+ window={this}
89
+ title={this.props.title}
90
+ />
91
+ <main>
92
+ {super.renderer()}
93
+ </main>
94
+ </main>
95
+ <Slider direction={'n'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
96
+ <Slider direction={'e'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
97
+ <Slider direction={'s'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
98
+ <Slider direction={'w'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
99
+
100
+ <Slider direction={'nww'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
101
+ <Slider direction={'nnw'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
102
+ <Slider direction={'nne'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
103
+ <Slider direction={'nee'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
104
+ <Slider direction={'sse'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
105
+ <Slider direction={'see'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
106
+ <Slider direction={'sww'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
107
+ <Slider direction={'ssw'} thick={this.thick} windowRef={this.ref} window={this} titleBarRef={this.titleBarRef}/>
108
+ </StyledJRWindow>
109
+ }
110
+ }
@@ -0,0 +1,251 @@
1
+ import React from "react"
2
+ import styled from "styled-components"
3
+ import { po } from "../JRUtils"
4
+
5
+ const borderWidth='px'
6
+
7
+ const StyledSlider=styled.div`
8
+ Xborder:1px solid ${({$direction:{color}})=>color};
9
+ xbackground:${({$direction:{color}})=>color};
10
+ position: absolute;
11
+ top: ${({$direction:{top}})=>top};
12
+ bottom: ${({$direction:{bottom}})=>bottom};
13
+ right: ${({$direction:{right}})=>right};
14
+ left: ${({$direction:{left}})=>left};
15
+ height: ${({$direction:{height}})=>height};
16
+ width: ${({$direction:{width}})=>width};
17
+ cursor: ${({$direction:{cursor}})=>cursor};
18
+
19
+ -webkit-user-select: none;
20
+ -khtml-user-select: none;
21
+ -moz-user-select: none;
22
+ -o-user-select: none;
23
+ user-select: none;
24
+
25
+ `
26
+ export default class Slider extends React.Component {
27
+ width='3px'
28
+ borderWidth='px'
29
+ borderLong='10px'
30
+
31
+ constructor(props){
32
+ super(props);
33
+ this.sliderRef=React.createRef()
34
+ }
35
+ directions={
36
+ n:{
37
+ top:0
38
+ ,color:'red'
39
+ ,width:'100%'
40
+ ,height:`${this.props.thick}px`
41
+ ,cursor: 'n-resize'
42
+ ,resize:(props)=>{
43
+ this.resizeN(props)
44
+ }
45
+
46
+ }
47
+ ,e:{
48
+ color:'yellow'
49
+ ,right:0
50
+ ,width:`${this.props.thick}px`
51
+ ,height:'100%'
52
+ ,cursor: 'e-resize'
53
+ ,resize:(props)=>{
54
+ this.resizeE(props)
55
+ }
56
+ }
57
+ ,s:{
58
+ color:'blue'
59
+ ,bottom:0
60
+ ,width:'100%'
61
+ ,height:`${this.props.thick}px`
62
+ ,cursor: 's-resize'
63
+ ,resize:(props)=>{
64
+ this.resizeS(props)
65
+ }
66
+ }
67
+ ,w:{
68
+ color:'green'
69
+ ,left:0
70
+ ,width:`${this.props.thick}px`
71
+ ,height:'100%'
72
+ ,cursor: 'w-resize'
73
+ ,resize:(props)=>{
74
+ this.resizeW(props)
75
+ }
76
+ }
77
+ ,nww:{
78
+ top:0
79
+ ,left:0
80
+ ,color:'blue'
81
+ ,width:`${this.props.thick}px`
82
+ ,height:this.borderLong
83
+ ,cursor: 'nw-resize'
84
+ ,resize:(props)=>{
85
+ this.resizeN(props)
86
+ this.resizeW(props)
87
+ }
88
+ }
89
+ ,nnw:{
90
+ top:0
91
+ ,left:0
92
+ ,color:'blue'
93
+ ,width:this.borderLong
94
+ ,height:`${this.props.thick}px`
95
+ ,cursor: 'nw-resize'
96
+ ,resize:(props)=>{
97
+ this.resizeN(props)
98
+ this.resizeW(props)
99
+ }
100
+ }
101
+ ,nne:{
102
+ top:0
103
+ ,right:0
104
+ ,color:'green'
105
+ ,width:this.borderLong
106
+ ,height:`${this.props.thick}px`
107
+ ,cursor: 'ne-resize'
108
+ ,resize:(props)=>{
109
+ this.resizeN(props)
110
+ this.resizeE(props)
111
+ }
112
+ }
113
+ ,nee:{
114
+ top:0
115
+ ,right:0
116
+ ,color:'green'
117
+ ,width:`${this.props.thick}px`
118
+ ,height:this.borderLong
119
+ ,cursor: 'ne-resize'
120
+ ,resize:(props)=>{
121
+ this.resizeN(props)
122
+ this.resizeE(props)
123
+ }
124
+ }
125
+ ,sse:{
126
+ color:'red'
127
+ ,right:0
128
+ ,bottom:0
129
+ ,width:this.borderLong
130
+ ,height:`${this.props.thick}px`
131
+ ,cursor: 'se-resize'
132
+ ,resize:(props)=>{
133
+ this.resizeS(props)
134
+ this.resizeE(props)
135
+ }
136
+ }
137
+ ,see:{
138
+ color:'red'
139
+ ,right:0
140
+ ,bottom:0
141
+ ,width:`${this.props.thick}px`
142
+ ,height:this.borderLong
143
+ ,cursor: 'se-resize'
144
+ ,resize:(props)=>{
145
+ this.resizeS(props)
146
+ this.resizeE(props)
147
+ }
148
+ }
149
+ ,ssw:{
150
+ color:'yellow'
151
+ ,bottom:0
152
+ ,left:0
153
+ ,width:this.borderLong
154
+ ,height:`${this.props.thick}px`
155
+ ,cursor: 'sw-resize'
156
+ ,resize:(props)=>{
157
+ this.resizeS(props)
158
+ this.resizeW(props)
159
+ }
160
+ }
161
+ ,sww:{
162
+ color:'yellow'
163
+ ,bottom:0
164
+ ,left:0
165
+ ,width:`${this.props.thick}px`
166
+ ,height:this.borderLong
167
+ ,cursor: 'sw-resize'
168
+ ,resize:(props)=>{
169
+ this.resizeS(props)
170
+ this.resizeW(props)
171
+ }
172
+ }
173
+ }
174
+
175
+ stop=(e)=>{
176
+ document.body.style.cursor='default'
177
+ window.removeEventListener('mousemove',this.move)
178
+ window.removeEventListener('mouseup',this.stop)
179
+ }
180
+
181
+ resizeN=({window,cursorY,startY,startHeight,titleBarHeight})=>{
182
+ let y=cursorY-(this.props.thick)
183
+ if(y<0)y=0
184
+ let height=startHeight+(startY-y)
185
+ if(height<titleBarHeight+(this.props.thick*2)){
186
+ height=titleBarHeight+(this.props.thick*2)
187
+ y=startY + startHeight - titleBarHeight - (this.props.thick*2)
188
+ }
189
+ window.style.top=`${y}px`
190
+ window.style.height=`${height}px`
191
+
192
+ }
193
+ resizeE=({window,clientX,left,titleBarHeight})=>{
194
+ let width=clientX-left-this.props.thick
195
+ if(width<titleBarHeight)width=titleBarHeight
196
+ window.style.width=`${width+(this.props.thick*2)}px`
197
+ }
198
+ resizeS=({window,clientY,top,titleBarHeight})=>{
199
+ let height=clientY-top-this.props.thick
200
+ if(height<titleBarHeight)height=titleBarHeight
201
+ window.style.height=`${height+(this.props.thick*2)}px`
202
+ }
203
+ resizeW=({window,cursorX,startX,startWidth,titleBarHeight})=>{
204
+ let x=cursorX
205
+ if(x<=1)x=1
206
+ let width=startWidth+(startX-x)
207
+ if(width<titleBarHeight+ (this.props.thick*2)){
208
+ width=titleBarHeight+ (this.props.thick*2)
209
+ x=startX+startWidth -titleBarHeight - (this.props.thick*2)
210
+ }
211
+ window.style.left=`${x}px`
212
+ window.style.width=`${width}px`
213
+ }
214
+ move=(e)=>{
215
+ const {clientX,clientY,x:cursorX,y:cursorY}=e
216
+ const window=this.props.windowRef.current
217
+ const {left,top}=window.getBoundingClientRect()
218
+ const {x:startX,width:startWidth,y:startY,height:startHeight,titleBarHeight}=this.data
219
+
220
+ this.directions[this.props.direction].resize({
221
+ window,titleBarHeight
222
+ ,clientX,cursorX,startX,startWidth,left
223
+ ,clientY,cursorY,startY,startHeight,top
224
+ })
225
+ /////////////////////////////////////////////////////////////
226
+
227
+
228
+
229
+
230
+ /////////////////////////////////////////////////////////////
231
+
232
+
233
+
234
+ }
235
+ start=()=>{
236
+ const {height:titleBarHeight}=this.props.titleBarRef.current.getBoundingClientRect()
237
+ const {x,y,width,height}=this.props.windowRef.current.getBoundingClientRect()
238
+ this.data={x,y,width,height,titleBarHeight}
239
+ document.body.style.cursor=this.directions[this.props.direction].cursor
240
+ window.addEventListener('mousemove',this.move)
241
+ window.addEventListener('mouseup',this.stop)
242
+ }
243
+
244
+ render(){
245
+ return <StyledSlider
246
+ $direction={this.directions[this.props.direction]}
247
+ $padding={this.props.padding}
248
+ onMouseDown={this.start}
249
+ />
250
+ }
251
+ }
@@ -0,0 +1,84 @@
1
+ import styled from "styled-components";
2
+ import { po } from "../JRUtils";
3
+ import React from "react";
4
+ import { FreeType } from "../JRFrame/JRFrame";
5
+
6
+ const StyledTitle=styled.div`
7
+ overflow: hidden;
8
+ display: flex;
9
+ padding:2px 8px;
10
+ border:1px solid black;
11
+ background:rgb(214, 214, 214);
12
+ color: black;
13
+ &:active:hover{
14
+ cursor: grabbing;
15
+ }
16
+
17
+ -webkit-user-select: none;
18
+ -khtml-user-select: none;
19
+ -moz-user-select: none;
20
+ -o-user-select: none;
21
+ user-select: none;
22
+
23
+ > .title{
24
+ flex: 1;
25
+ }
26
+ `
27
+
28
+
29
+
30
+
31
+ export default class TitleBar extends React.Component{
32
+ pos1 = 0
33
+ pos2 = 0
34
+ pos3 = 0
35
+ pos4 = 0
36
+ x=0
37
+ y=0
38
+
39
+ move=(e)=>{
40
+ e.preventDefault()
41
+ const {clientX,clientY}=e
42
+ this.pos1 = this.pos3 - e.clientX
43
+ this.pos2 = this.pos4 - e.clientY
44
+ this.pos3 = e.clientX
45
+ this.pos4 = e.clientY
46
+
47
+ const w= this.props.windowRef.current
48
+ this.x=w.offsetLeft - this.pos1
49
+ this.y=w.offsetTop - this.pos2
50
+ w.style.top = this.y + 'px'
51
+ w.style.left = this.x + 'px'
52
+ }
53
+ stop=(e)=>{
54
+ // const w= this.props.windowRef.current
55
+ // if(this.y<1)this.props.windowRef.current.style.top = '1px'
56
+ // if(this.y>window.innerHeight)this.props.windowRef.current.style.top = `${window.innerHeight-32}px`
57
+ // if(this.x<1)this.props.windowRef.current.style.left = '1px'
58
+ // if(this.x>window.innerWidth)this.props.windowRef.current.style.left = `${window.innerWidth-100}px`
59
+ document.body.style.cursor='default'
60
+ window.removeEventListener('mousemove',this.move)
61
+ window.removeEventListener('mouseup',this.stop)
62
+ }
63
+ start(e){
64
+ e.preventDefault()
65
+ this.pos3 = e.clientX
66
+ this.pos4 = e.clientY
67
+
68
+ document.body.style.cursor='grabbing'
69
+ window.addEventListener('mousemove',this.move)
70
+ window.addEventListener('mouseup',this.stop)
71
+ }
72
+ render(){
73
+ return <StyledTitle
74
+ ref={this.props.titleBarRef}
75
+ draggable="false"
76
+ onMouseDown={(e)=>{
77
+ this.start(e)
78
+ }}
79
+ >
80
+ <FreeType tag='div' config={this.props.title??''} me={this.props.window} className={'title'}/>
81
+ <nav><button>X</button></nav>
82
+ </StyledTitle>
83
+ }
84
+ }
package/src/main.jsx ADDED
@@ -0,0 +1,6 @@
1
+ import { StrictMode } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+ import './app/index.css'
4
+ import App from './app/App.jsx'
5
+
6
+ createRoot(document.getElementById('root')).render(<App/>)
package/vite.config.js ADDED
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+
4
+ // https://vite.dev/config/
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ })