jrs-react 1.2.6 → 1.2.8

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.6",
3
+ "version": "1.2.8",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.es.js",
@@ -14,7 +14,6 @@
14
14
  "author": "JorenLai",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@eslint/js": "^9.21.0",
18
17
  "@rollup/plugin-commonjs": "^28.0.3",
19
18
  "@rollup/plugin-json": "^6.1.0",
20
19
  "@types/react": "^19.0.10",
@@ -22,20 +21,16 @@
22
21
  "@vitejs/plugin-react": "^4.3.4",
23
22
  "antd": "^5.12.5",
24
23
  "axios": "^1.6.2",
25
- "eslint": "^9.21.0",
26
- "eslint-plugin-react-hooks": "^5.1.0",
27
- "eslint-plugin-react-refresh": "^0.4.19",
28
24
  "globals": "^15.15.0",
29
25
  "react": "^18.2.0",
30
26
  "react-dom": "^18.2.0",
31
27
  "react-router-dom": "^7.4.0",
32
- "rollup-plugin-node-resolve": "^5.2.0",
33
28
  "styled-components": "^6.1.15",
34
- "vite": "^6.2.0"
29
+ "vite": "^6.2.0",
30
+ "vite-plugin-svgr": "^4.3.0"
35
31
  },
36
32
  "devDependencies": {
37
33
  "@babel/core": "^7.26.10",
38
- "@babel/preset-react": "^7.26.3",
39
34
  "@chromatic-com/storybook": "^3.2.6",
40
35
  "@rollup/plugin-node-resolve": "^16.0.1",
41
36
  "@storybook/addon-essentials": "^8.6.6",
@@ -45,10 +40,9 @@
45
40
  "@storybook/react": "^8.6.6",
46
41
  "@storybook/react-vite": "^8.6.6",
47
42
  "@storybook/test": "^8.6.6",
43
+ "@svgr/rollup": "^8.1.0",
48
44
  "@vitest/browser": "^3.0.8",
49
45
  "@vitest/coverage-v8": "^3.0.8",
50
- "babel-loader": "^10.0.0",
51
- "playwright": "^1.51.0",
52
46
  "prop-types": "^15.8.1",
53
47
  "rollup": "^2.79.2",
54
48
  "rollup-plugin-babel": "^4.4.0",
@@ -3,17 +3,31 @@ import JRTable from "../../components/JRTable/JRTable";
3
3
  import JRFields from "../../components/JRFields/JRFields";
4
4
  import JRText from "../../components/JRInput/JRText";
5
5
  import { po } from "../../components/JRUtils";
6
+ import { useState } from "react";
6
7
 
7
8
  export default function WindowApp() {
9
+ const [popup,setPopup]=useState(true)
10
+ const [open,setOpen]=useState(true)
8
11
  return <>
12
+ <button
13
+ onClick={()=>{
14
+ setPopup(!popup)
15
+ }}
16
+ >Popup</button>
17
+ <button
18
+ onClick={()=>{
19
+ setOpen(!open)
20
+ }}
21
+ >Open</button>
9
22
  <JRTable
10
- title={function(){
11
- return `共: ${this.getValue()?.length ??0 }筆`
12
- }}
13
- width={800}
14
- // popup={true}
15
- xxx={0}
16
- xy={0}
23
+ title={function(){
24
+ return `共: ${this.getValue()?.length ??0 }筆`
25
+ }}
26
+ width={600}
27
+ height={350}
28
+ popup={popup}
29
+ open={open}
30
+ setOpen={setOpen}
17
31
  get={{
18
32
  url:'list.json'
19
33
  ,autoRun:true
@@ -24,21 +38,27 @@ export default function WindowApp() {
24
38
  ]}
25
39
  resizableColumns={true}
26
40
  />
27
- .<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>
41
+
28
42
 
29
43
  <JRFields
30
44
  title={function(){
31
45
  return 'JRFields'//this.getValue()?.name
32
46
  }}
33
- width={480}
34
- height={480}
35
- popup={true}
47
+ width={400}
48
+ height={150}
49
+ popup={popup}
50
+ open={open}
51
+ setOpen={setOpen}
36
52
  get={{
37
53
  url:'data.json'
38
54
  ,mask:'Loading'
39
55
  }}
56
+ onOpen={function(){
57
+ po('open',this)
58
+ this.get()
59
+ }}
40
60
  columns={[
41
- {name:'name',label:'姓名',type:JRText}
61
+ {name:'name',type:JRText}
42
62
  ,{name:'email',label:'E-mail',type:JRText}
43
63
  ]}
44
64
  bottom={function(){
@@ -62,11 +82,13 @@ export default function WindowApp() {
62
82
  }}
63
83
  />
64
84
 
65
- {/* <JRWindow
85
+ <JRWindow
66
86
  title={'JRWindow'}
67
87
  width={180}
68
88
  height={180}
69
- popup={true}
89
+ popup={popup}
90
+ open={open}
91
+ setOpen={setOpen}
70
92
  get={{
71
93
  url:'data.json'
72
94
  ,autoRun:true
@@ -78,7 +100,19 @@ export default function WindowApp() {
78
100
  return <button>Get</button>
79
101
  }}
80
102
  >
81
- JRWindow
82
- </JRWindow> */}
103
+ JRWindow<br/>
104
+ 1<br/>
105
+ 2<br/>
106
+ 3<br/>
107
+ 4<br/>
108
+ 5<br/>
109
+ 6<br/>
110
+ 7<br/>
111
+ 8<br/>9<br/>10<br/>
112
+
113
+
114
+
115
+ </JRWindow>
116
+ {/* .<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/>.<br/> */}
83
117
  </>
84
118
  }
@@ -0,0 +1,14 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="24"
4
+ height="24"
5
+ viewBox="0 0 24 24"
6
+ fill="none"
7
+ stroke="currentColor"
8
+ stroke-width="2"
9
+ stroke-linecap="round"
10
+ stroke-linejoin="round"
11
+ >
12
+ <rect x="1" y="4" width="22" height="16" rx="2" ry="2" />
13
+ <line x1="1" y1="10" x2="23" y2="10" />
14
+ </svg>
@@ -0,0 +1,14 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="24"
4
+ height="24"
5
+ viewBox="0 0 24 24"
6
+ fill="none"
7
+ stroke="currentColor"
8
+ stroke-width="2"
9
+ stroke-linecap="round"
10
+ stroke-linejoin="round"
11
+ >
12
+ <rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
13
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
14
+ </svg>
@@ -0,0 +1,26 @@
1
+ // import IconX from "./x.svg?react"
2
+ // import IconCard from "./card.svg?react"
3
+ // import IconCopy from "./copy.svg?react"
4
+ // import IconSquare from "./square.svg?react"
5
+ // import IconMinus from "./minus.svg?react"
6
+
7
+ import IconX from "./x.svg"
8
+ import IconCard from "./card.svg"
9
+ import IconCopy from "./copy.svg"
10
+ import IconSquare from "./square.svg"
11
+ import IconMinus from "./minus.svg"
12
+
13
+ // import { ReactComponent as IconX } from "./x.svg"
14
+ // import { ReactComponent as IconCard } from "./card.svg"
15
+ // import { ReactComponent as IconCopy } from "./copy.svg"
16
+ // import { ReactComponent as IconSquare } from "./square.svg"
17
+ // import { ReactComponent as IconMinus } from "./minus.svg"
18
+
19
+ // import { ReactComponent as Logo } from './logo.svg'
20
+ export {
21
+ IconX
22
+ ,IconCard
23
+ ,IconCopy
24
+ ,IconSquare
25
+ ,IconMinus
26
+ }
@@ -0,0 +1,13 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="24"
4
+ height="24"
5
+ viewBox="0 0 24 24"
6
+ fill="none"
7
+ stroke="currentColor"
8
+ stroke-width="2"
9
+ stroke-linecap="round"
10
+ stroke-linejoin="round"
11
+ >
12
+ <line x1="5" y1="12" x2="19" y2="12" />
13
+ </svg>
@@ -0,0 +1,13 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="24"
4
+ height="24"
5
+ viewBox="0 0 24 24"
6
+ fill="none"
7
+ stroke="currentColor"
8
+ stroke-width="2"
9
+ stroke-linecap="round"
10
+ stroke-linejoin="round"
11
+ >
12
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
13
+ </svg>
@@ -0,0 +1,14 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="24"
4
+ height="24"
5
+ viewBox="0 0 24 24"
6
+ fill="none"
7
+ stroke="currentColor"
8
+ stroke-width="2"
9
+ stroke-linecap="round"
10
+ stroke-linejoin="round"
11
+ >
12
+ <line x1="18" y1="6" x2="6" y2="18" />
13
+ <line x1="6" y1="6" x2="18" y2="18" />
14
+ </svg>
@@ -0,0 +1,3 @@
1
+ export default function JRButton({icon,children,...props}){
2
+ return <button {...props}>{icon}{children}</button>
3
+ }
@@ -4,12 +4,17 @@ import styled from "styled-components";
4
4
  import TitleBar from "./TitleBar";
5
5
  import { po } from "../JRUtils";
6
6
  import Slider from "./Slider";
7
+ import Sliders from "./Slider";
8
+
7
9
 
8
10
  const StyledJRWindow=styled.div`
11
+ --jr-window-radius:3px;
9
12
  --padding-child:8px;
13
+ --transition-x-y:height .1s ease-in, width .1s ease-in;
10
14
  xborder:1px solid gray;
11
- position: absolute;
15
+ position: fixed;
12
16
  padding: ${({$thick})=>$thick}px;
17
+ border-radius: var(--jr-window-radius);
13
18
 
14
19
  top: ${({$y})=>$y}px;
15
20
  left: ${({$x})=>$x}px;
@@ -22,6 +27,7 @@ const StyledJRWindow=styled.div`
22
27
  overflow: hidden;
23
28
 
24
29
  > main{
30
+ border-radius: var(--jr-window-radius);
25
31
  box-shadow: 0px 0px 5px 1px gray;
26
32
  Xbackground: white;
27
33
  display: flex;
@@ -42,69 +48,65 @@ export default class JRWindow extends JRFrame {
42
48
  y=0
43
49
  width=300
44
50
  height=300
45
- padding=5
46
- thick=3
51
+ padding=1
52
+ thick=5
47
53
 
48
54
  constructor(props){
49
55
  super(props)
50
56
  this.ref=React.createRef()
51
57
  this.titleBarRef=React.createRef()
52
- if(this.props.popup===true)this.renderer=this.renderWindow
58
+ // if(this.props.popup===true)this.renderer=this.renderWindow
53
59
  this.init()
54
60
  }
61
+ componentWillUpdate(prevProps, prevState, snapshot){
62
+ po('componentWillUpdate-------------------------')
63
+ if(this.props.popup===true && this.props.open===true && prevProps.open===false){
64
+ this.props.onOpen?.bind(this)()
65
+ }
66
+ }
55
67
  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
68
+ this.height=window.innerHeight>=(this.props.height??this.height)?(this.props.height??this.height):window.innerHeight
69
+ this.width=window.innerWidth>=(this.props.width??this.width)?(this.props.width??this.width):window.innerWidth
58
70
  this.x=this.props.x??((window.innerWidth-(this.width??300))/2)
59
71
  this.y=this.props.y??(window.innerHeight-(this.height??300))/2
60
72
  }
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}
73
+ renderer(){
74
+
75
+ return this.props.popup===true
76
+ ?this.props.open===true
77
+ ?<StyledJRWindow
78
+ ref={this.ref}
79
+ className={`jr-window ${this.props.className??''}`}
80
+ $x={this.x}
81
+ $y={this.y}
82
+ $width={this.width}
83
+ $height={this.height}
84
+ $thick={this.thick}
79
85
  // 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>
86
+ // po('onFocus')
87
+ // this.ref.current.style.zIndex=100
88
+ // }}
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
+ {super.renderer()}
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
+ :super.renderer()
109
111
  }
110
112
  }
@@ -3,10 +3,23 @@ import styled from "styled-components"
3
3
  import { po } from "../JRUtils"
4
4
 
5
5
  const borderWidth='px'
6
+ const directions=['n','e','s','w','nww','nnw','nne','nee','sse','see','sww','ssw']
7
+ export default class Sliders extends React.Component {
8
+ render(){
9
+ return directions.map((direction,index)=><Slider
10
+ direction={direction}
11
+ thick={this.props.thick}
12
+ windowRef={this.props.windowRef}
13
+ window={this.props.window}
14
+ titleBarRef={this.props.titleBarRef}
15
+ key={index}
16
+ />)
17
+ }
18
+ }
6
19
 
7
20
  const StyledSlider=styled.div`
8
21
  Xborder:1px solid ${({$direction:{color}})=>color};
9
- xbackground:${({$direction:{color}})=>color};
22
+ Xbackground:${({$direction:{color}})=>color};
10
23
  position: absolute;
11
24
  top: ${({$direction:{top}})=>top};
12
25
  bottom: ${({$direction:{bottom}})=>bottom};
@@ -23,10 +36,10 @@ const StyledSlider=styled.div`
23
36
  user-select: none;
24
37
 
25
38
  `
26
- export default class Slider extends React.Component {
39
+ class Slider extends React.Component {
27
40
  width='3px'
28
41
  borderWidth='px'
29
- borderLong='10px'
42
+ borderLong=30
30
43
 
31
44
  constructor(props){
32
45
  super(props);
@@ -74,12 +87,24 @@ export default class Slider extends React.Component {
74
87
  this.resizeW(props)
75
88
  }
76
89
  }
90
+ ,nw:{
91
+ top:0
92
+ ,left:0
93
+ ,color:'blue'
94
+ ,width:`${this.borderLong}px`
95
+ ,height:`${this.borderLong}px`
96
+ ,cursor: 'nw-resize'
97
+ ,resize:(props)=>{
98
+ this.resizeN(props)
99
+ this.resizeW(props)
100
+ }
101
+ }
77
102
  ,nww:{
78
103
  top:0
79
104
  ,left:0
80
105
  ,color:'blue'
81
- ,width:`${this.props.thick}px`
82
- ,height:this.borderLong
106
+ ,width:`${this.props.thick+this.borderLong}px`
107
+ ,height:`${this.props.thick}px`
83
108
  ,cursor: 'nw-resize'
84
109
  ,resize:(props)=>{
85
110
  this.resizeN(props)
@@ -90,8 +115,8 @@ export default class Slider extends React.Component {
90
115
  top:0
91
116
  ,left:0
92
117
  ,color:'blue'
93
- ,width:this.borderLong
94
- ,height:`${this.props.thick}px`
118
+ ,width:`${this.props.thick}px`
119
+ ,height:`${this.props.thick+this.borderLong}px`
95
120
  ,cursor: 'nw-resize'
96
121
  ,resize:(props)=>{
97
122
  this.resizeN(props)
@@ -102,7 +127,7 @@ export default class Slider extends React.Component {
102
127
  top:0
103
128
  ,right:0
104
129
  ,color:'green'
105
- ,width:this.borderLong
130
+ ,width:`${this.props.thick+this.borderLong}px`
106
131
  ,height:`${this.props.thick}px`
107
132
  ,cursor: 'ne-resize'
108
133
  ,resize:(props)=>{
@@ -115,7 +140,7 @@ export default class Slider extends React.Component {
115
140
  ,right:0
116
141
  ,color:'green'
117
142
  ,width:`${this.props.thick}px`
118
- ,height:this.borderLong
143
+ ,height:`${this.props.thick+this.borderLong}px`
119
144
  ,cursor: 'ne-resize'
120
145
  ,resize:(props)=>{
121
146
  this.resizeN(props)
@@ -126,7 +151,7 @@ export default class Slider extends React.Component {
126
151
  color:'red'
127
152
  ,right:0
128
153
  ,bottom:0
129
- ,width:this.borderLong
154
+ ,width:`${this.props.thick+this.borderLong}px`
130
155
  ,height:`${this.props.thick}px`
131
156
  ,cursor: 'se-resize'
132
157
  ,resize:(props)=>{
@@ -139,7 +164,7 @@ export default class Slider extends React.Component {
139
164
  ,right:0
140
165
  ,bottom:0
141
166
  ,width:`${this.props.thick}px`
142
- ,height:this.borderLong
167
+ ,height:`${this.props.thick+this.borderLong}px`
143
168
  ,cursor: 'se-resize'
144
169
  ,resize:(props)=>{
145
170
  this.resizeS(props)
@@ -150,7 +175,7 @@ export default class Slider extends React.Component {
150
175
  color:'yellow'
151
176
  ,bottom:0
152
177
  ,left:0
153
- ,width:this.borderLong
178
+ ,width:`${this.props.thick+this.borderLong}px`
154
179
  ,height:`${this.props.thick}px`
155
180
  ,cursor: 'sw-resize'
156
181
  ,resize:(props)=>{
@@ -163,7 +188,7 @@ export default class Slider extends React.Component {
163
188
  ,bottom:0
164
189
  ,left:0
165
190
  ,width:`${this.props.thick}px`
166
- ,height:this.borderLong
191
+ ,height:`${this.props.thick+this.borderLong}px`
167
192
  ,cursor: 'sw-resize'
168
193
  ,resize:(props)=>{
169
194
  this.resizeS(props)
@@ -172,20 +197,16 @@ export default class Slider extends React.Component {
172
197
  }
173
198
  }
174
199
 
175
- stop=(e)=>{
176
- document.body.style.cursor='default'
177
- window.removeEventListener('mousemove',this.move)
178
- window.removeEventListener('mouseup',this.stop)
179
- }
180
-
181
200
  resizeN=({window,cursorY,startY,startHeight,titleBarHeight})=>{
182
201
  let y=cursorY-(this.props.thick)
183
202
  if(y<0)y=0
184
203
  let height=startHeight+(startY-y)
204
+
185
205
  if(height<titleBarHeight+(this.props.thick*2)){
186
206
  height=titleBarHeight+(this.props.thick*2)
187
207
  y=startY + startHeight - titleBarHeight - (this.props.thick*2)
188
208
  }
209
+
189
210
  window.style.top=`${y}px`
190
211
  window.style.height=`${height}px`
191
212
 
@@ -201,8 +222,8 @@ export default class Slider extends React.Component {
201
222
  window.style.height=`${height+(this.props.thick*2)}px`
202
223
  }
203
224
  resizeW=({window,cursorX,startX,startWidth,titleBarHeight})=>{
204
- let x=cursorX
205
- if(x<=1)x=1
225
+ let x=cursorX-this.props.thick
226
+ if(x<0)x=0
206
227
  let width=startWidth+(startX-x)
207
228
  if(width<titleBarHeight+ (this.props.thick*2)){
208
229
  width=titleBarHeight+ (this.props.thick*2)
@@ -211,7 +232,26 @@ export default class Slider extends React.Component {
211
232
  window.style.left=`${x}px`
212
233
  window.style.width=`${width}px`
213
234
  }
235
+
236
+ stop=(e)=>{
237
+ e.preventDefault()
238
+ const {height:titleBarHeight}=this.props.titleBarRef.current.getBoundingClientRect()
239
+ const {x,y,width,height}=this.props.windowRef.current.getBoundingClientRect()
240
+
241
+ this.props.windowRef.current.style.transition='var(--transition-x-y)'
242
+ if(y==0 && this.data.direction.indexOf('n')>-1){
243
+ this.props.window.orgHeight=height
244
+ this.props.windowRef.current.style.height=`${window.innerHeight}px`
245
+ }
246
+ if(y>window.innerHeight)this.props.windowRef.current.style.top = `${window.innerHeight-titleBarHeight}px`
247
+ if(x+width-this.props.thick<0)this.props.windowRef.current.style.left = 0
248
+ if(x>window.innerWidth)this.props.windowRef.current.style.left = `${window.innerWidth-width}px`
249
+ document.body.style.cursor='default'
250
+ window.removeEventListener('mousemove',this.move)
251
+ window.removeEventListener('mouseup',this.stop)
252
+ }
214
253
  move=(e)=>{
254
+ e.preventDefault()
215
255
  const {clientX,clientY,x:cursorX,y:cursorY}=e
216
256
  const window=this.props.windowRef.current
217
257
  const {left,top}=window.getBoundingClientRect()
@@ -222,20 +262,29 @@ export default class Slider extends React.Component {
222
262
  ,clientX,cursorX,startX,startWidth,left
223
263
  ,clientY,cursorY,startY,startHeight,top
224
264
  })
225
- /////////////////////////////////////////////////////////////
226
-
227
-
228
-
229
-
230
- /////////////////////////////////////////////////////////////
231
-
232
-
233
-
234
265
  }
235
- start=()=>{
266
+ start=(e,direction)=>{
267
+ e.preventDefault()
236
268
  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}
269
+ let {x,y,width,height}=this.props.windowRef.current.getBoundingClientRect()
270
+
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){
277
+ this.props.window.orgHeight=null
278
+ }
279
+
280
+ this.data={
281
+ x,y
282
+ ,width
283
+ ,height
284
+ ,titleBarHeight
285
+ ,direction
286
+ }
287
+ this.props.windowRef.current.style.transition='unset'
239
288
  document.body.style.cursor=this.directions[this.props.direction].cursor
240
289
  window.addEventListener('mousemove',this.move)
241
290
  window.addEventListener('mouseup',this.stop)
@@ -245,7 +294,9 @@ export default class Slider extends React.Component {
245
294
  return <StyledSlider
246
295
  $direction={this.directions[this.props.direction]}
247
296
  $padding={this.props.padding}
248
- onMouseDown={this.start}
297
+ onMouseDown={(e)=>{
298
+ this.start(e,this.props.direction)
299
+ }}
249
300
  />
250
301
  }
251
302
  }