jrs-react 1.2.7 → 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/build/index.es.js +356 -216
- package/build/index.js +356 -216
- package/package.json +4 -10
- package/src/app/window/WindowApp.jsx +50 -16
- package/src/assets/icon/card.svg +14 -0
- package/src/assets/icon/copy.svg +14 -0
- package/src/assets/icon/index.jsx +26 -0
- package/src/assets/icon/minus.svg +13 -0
- package/src/assets/icon/square.svg +13 -0
- package/src/assets/icon/x.svg +14 -0
- package/src/components/JRInput/JRButton.jsx +3 -0
- package/src/components/JRWindow/JRWindow.jsx +55 -53
- package/src/components/JRWindow/Slider.jsx +85 -34
- package/src/components/JRWindow/TitleBar.jsx +104 -19
- package/vite.config.js +10 -2
|
@@ -2,12 +2,14 @@ import styled from "styled-components";
|
|
|
2
2
|
import { po } from "../JRUtils";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { FreeType } from "../JRFrame/JRFrame";
|
|
5
|
+
import { IconX,IconCard, IconSquare, IconMinus } from "../../assets/icon";
|
|
6
|
+
import { background } from "storybook/internal/theming";
|
|
7
|
+
import JRButton from "../JRInput/JRButton";
|
|
5
8
|
|
|
6
9
|
const StyledTitle=styled.div`
|
|
7
10
|
overflow: hidden;
|
|
8
11
|
display: flex;
|
|
9
|
-
|
|
10
|
-
border:1px solid black;
|
|
12
|
+
border-radius: var(--jr-window-radius) var(--jr-window-radius) 0 0;
|
|
11
13
|
background:rgb(214, 214, 214);
|
|
12
14
|
color: black;
|
|
13
15
|
&:active:hover{
|
|
@@ -21,7 +23,44 @@ const StyledTitle=styled.div`
|
|
|
21
23
|
user-select: none;
|
|
22
24
|
|
|
23
25
|
> .title{
|
|
24
|
-
|
|
26
|
+
|
|
27
|
+
flex: 1;
|
|
28
|
+
padding:2px 0 2px 8px;
|
|
29
|
+
text-overflow: ellipsis;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
}
|
|
33
|
+
> nav{
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: anchor-center;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
>button{
|
|
39
|
+
display:flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
border: unset;
|
|
43
|
+
background: unset;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
width:32px;
|
|
46
|
+
height:32px;
|
|
47
|
+
xborder:1px solid green;
|
|
48
|
+
padding: 0;
|
|
49
|
+
margin: 0;
|
|
50
|
+
&:hover{
|
|
51
|
+
background: #bbbbbb;
|
|
52
|
+
color:white;
|
|
53
|
+
}
|
|
54
|
+
>svg{
|
|
55
|
+
width:14px;
|
|
56
|
+
height:14px;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
>button.danger:hover{
|
|
61
|
+
background: red;
|
|
62
|
+
color:white;
|
|
63
|
+
}
|
|
25
64
|
}
|
|
26
65
|
`
|
|
27
66
|
|
|
@@ -36,35 +75,67 @@ export default class TitleBar extends React.Component{
|
|
|
36
75
|
x=0
|
|
37
76
|
y=0
|
|
38
77
|
|
|
78
|
+
stop=(e)=>{
|
|
79
|
+
e.preventDefault()
|
|
80
|
+
if(this.moved){
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
const {height:titleBarHeight}=this.props.titleBarRef.current.getBoundingClientRect()
|
|
84
|
+
const {x,y,width,height}=this.props.windowRef.current.getBoundingClientRect()
|
|
85
|
+
po('y',y)
|
|
86
|
+
if(y<1){
|
|
87
|
+
this.props.windowRef.current.style.transition='var(--transition-x-y), left .1s ease-in'
|
|
88
|
+
this.props.windowRef.current.style.left=`${-this.props.thick}px`
|
|
89
|
+
this.props.windowRef.current.style.width=`calc(100vw + ${this.props.thick*2}px)`//`${window.innerWidth+(this.props.thick*2)}px`
|
|
90
|
+
this.props.windowRef.current.style.height=`calc(100vh + ${this.props.thick*2}px)`//`${window.innerHeight+(this.props.thick*2)}px`
|
|
91
|
+
|
|
92
|
+
this.props.window.orgHeight=height
|
|
93
|
+
this.props.window.orgWidth=width
|
|
94
|
+
}
|
|
95
|
+
if(y>window.innerHeight)this.props.windowRef.current.style.top = `${window.innerHeight-titleBarHeight}px`
|
|
96
|
+
if(x+width-this.props.thick<0)this.props.windowRef.current.style.left = 0
|
|
97
|
+
if(x>window.innerWidth)this.props.windowRef.current.style.left = `${window.innerWidth-width}px`
|
|
98
|
+
document.body.style.cursor='default'
|
|
99
|
+
}
|
|
100
|
+
window.removeEventListener('mousemove',this.move)
|
|
101
|
+
window.removeEventListener('mouseup',this.stop)
|
|
102
|
+
}
|
|
39
103
|
move=(e)=>{
|
|
40
104
|
e.preventDefault()
|
|
105
|
+
this.moved=true
|
|
41
106
|
const {clientX,clientY}=e
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
107
|
+
const y=clientY<1 ?0 :clientY
|
|
108
|
+
this.pos1 = this.pos3 - clientX
|
|
109
|
+
this.pos2 = this.pos4 - y
|
|
110
|
+
this.pos3 = clientX
|
|
111
|
+
this.pos4 = y
|
|
46
112
|
|
|
47
113
|
const w= this.props.windowRef.current
|
|
48
114
|
this.x=w.offsetLeft - this.pos1
|
|
49
115
|
this.y=w.offsetTop - this.pos2
|
|
116
|
+
|
|
117
|
+
if(this.props.window.orgHeight){
|
|
118
|
+
w.style.height=`${this.props.window.orgHeight}px`
|
|
119
|
+
this.props.window.orgHeight=null
|
|
120
|
+
}
|
|
121
|
+
if(this.props.window.orgWidth){
|
|
122
|
+
if(clientX>this.props.window.orgWidth){
|
|
123
|
+
this.x=clientX-(this.props.window.orgWidth/2)
|
|
124
|
+
}
|
|
125
|
+
w.style.width=`${this.props.window.orgWidth}px`
|
|
126
|
+
this.props.window.orgWidth=null
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
this.y=this.y<-this.props.thick?-this.props.thick:this.y
|
|
50
130
|
w.style.top = this.y + 'px'
|
|
51
131
|
w.style.left = this.x + 'px'
|
|
52
132
|
}
|
|
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
133
|
start(e){
|
|
64
134
|
e.preventDefault()
|
|
135
|
+
this.moved=false
|
|
65
136
|
this.pos3 = e.clientX
|
|
66
137
|
this.pos4 = e.clientY
|
|
67
|
-
|
|
138
|
+
this.props.windowRef.current.style.transition='var(--transition-x-y)'
|
|
68
139
|
document.body.style.cursor='grabbing'
|
|
69
140
|
window.addEventListener('mousemove',this.move)
|
|
70
141
|
window.addEventListener('mouseup',this.stop)
|
|
@@ -78,7 +149,21 @@ export default class TitleBar extends React.Component{
|
|
|
78
149
|
}}
|
|
79
150
|
>
|
|
80
151
|
<FreeType tag='div' config={this.props.title??''} me={this.props.window} className={'title'}/>
|
|
81
|
-
<nav
|
|
152
|
+
<nav>
|
|
153
|
+
<JRButton icon={<IconMinus />}/>
|
|
154
|
+
<JRButton icon={<IconSquare />}/>
|
|
155
|
+
{
|
|
156
|
+
this.props.window.props.setOpen
|
|
157
|
+
?<JRButton icon={<IconX />}
|
|
158
|
+
className={'danger'}
|
|
159
|
+
onClick={()=>{
|
|
160
|
+
this.props.window.props.setOpen(false)
|
|
161
|
+
}}
|
|
162
|
+
/>
|
|
163
|
+
:null
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
</nav>
|
|
82
167
|
</StyledTitle>
|
|
83
168
|
}
|
|
84
169
|
}
|
package/vite.config.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { defineConfig } from 'vite'
|
|
2
|
+
import svgr from 'vite-plugin-svgr'
|
|
2
3
|
import react from '@vitejs/plugin-react'
|
|
3
4
|
|
|
4
|
-
// https://vite.dev/config/
|
|
5
5
|
export default defineConfig({
|
|
6
|
-
|
|
6
|
+
plugins: [
|
|
7
|
+
react()
|
|
8
|
+
,svgr({
|
|
9
|
+
include: '**/*.svg',
|
|
10
|
+
svgrOptions: {
|
|
11
|
+
exportType: 'default',
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
]
|
|
7
15
|
})
|