jrs-react 1.2.45 → 1.2.47

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,61 +1,61 @@
1
- {
2
- "name": "jrs-react",
3
- "version": "1.2.45",
4
- "description": "",
5
- "main": "build/index.js",
6
- "module": "build/index.es.js",
7
- "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1",
9
- "build": "rollup -c",
10
- "storybook": "storybook dev -p 6006",
11
- "build-storybook": "storybook build",
12
- "vite": "vite"
13
- },
14
- "author": "JorenLai",
15
- "license": "MIT",
16
- "dependencies": {
17
- "@rollup/plugin-commonjs": "^28.0.3",
18
- "@rollup/plugin-json": "^6.1.0",
19
- "@types/react": "^19.0.10",
20
- "@types/react-dom": "^19.0.4",
21
- "@vitejs/plugin-react": "^4.3.4",
22
- "antd": "^5.12.5",
23
- "axios": "^1.6.2",
24
- "create-react-class": "^15.7.0",
25
- "globals": "^15.15.0",
26
- "jrs-js": "^0.0.0",
27
- "react": "^18.2.0",
28
- "react-dom": "^18.2.0",
29
- "react-router-dom": "^7.4.0",
30
- "styled-components": "^6.1.15",
31
- "vite": "^6.2.0",
32
- "vite-plugin-svgr": "^4.3.0"
33
- },
34
- "peerDependencies": {
35
- "react": "^18.2.0",
36
- "react-dom": "^18.2.0"
37
- },
38
- "devDependencies": {
39
- "@babel/core": "^7.26.10",
40
- "@chromatic-com/storybook": "^3.2.6",
41
- "@rollup/plugin-node-resolve": "^16.0.1",
42
- "@storybook/addon-essentials": "^8.6.6",
43
- "@storybook/addon-onboarding": "^8.6.6",
44
- "@storybook/blocks": "^8.6.6",
45
- "@storybook/experimental-addon-test": "^8.6.6",
46
- "@storybook/react": "^8.6.6",
47
- "@storybook/react-vite": "^8.6.6",
48
- "@storybook/test": "^8.6.6",
49
- "@svgr/rollup": "^8.1.0",
50
- "@vitest/browser": "^3.0.8",
51
- "@vitest/coverage-v8": "^3.0.8",
52
- "prop-types": "^15.8.1",
53
- "rollup": "^2.79.2",
54
- "rollup-plugin-babel": "^4.4.0",
55
- "rollup-plugin-peer-deps-external": "^2.2.4",
56
- "rollup-plugin-postcss": "^4.0.2",
57
- "rollup-plugin-terser": "^7.0.2",
58
- "storybook": "^8.6.6",
59
- "vitest": "^3.0.8"
60
- }
61
- }
1
+ {
2
+ "name": "jrs-react",
3
+ "version": "1.2.47",
4
+ "description": "",
5
+ "main": "build/index.js",
6
+ "module": "build/index.es.js",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "build": "rollup -c",
10
+ "storybook": "storybook dev -p 6006",
11
+ "build-storybook": "storybook build",
12
+ "vite": "vite"
13
+ },
14
+ "author": "JorenLai",
15
+ "license": "MIT",
16
+ "dependencies": {
17
+ "@rollup/plugin-commonjs": "^28.0.3",
18
+ "@rollup/plugin-json": "^6.1.0",
19
+ "@types/react": "^19.0.10",
20
+ "@types/react-dom": "^19.0.4",
21
+ "@vitejs/plugin-react": "^4.3.4",
22
+ "antd": "^5.12.5",
23
+ "axios": "^1.6.2",
24
+ "create-react-class": "^15.7.0",
25
+ "globals": "^15.15.0",
26
+ "jrs-js": "^0.0.0",
27
+ "react": "^18.2.0",
28
+ "react-dom": "^18.2.0",
29
+ "react-router-dom": "^7.4.0",
30
+ "styled-components": "^6.1.15",
31
+ "vite": "^6.2.0",
32
+ "vite-plugin-svgr": "^4.3.0"
33
+ },
34
+ "peerDependencies": {
35
+ "react": "^18.2.0",
36
+ "react-dom": "^18.2.0"
37
+ },
38
+ "devDependencies": {
39
+ "@babel/core": "^7.26.10",
40
+ "@chromatic-com/storybook": "^3.2.6",
41
+ "@rollup/plugin-node-resolve": "^16.0.1",
42
+ "@storybook/addon-essentials": "^8.6.6",
43
+ "@storybook/addon-onboarding": "^8.6.6",
44
+ "@storybook/blocks": "^8.6.6",
45
+ "@storybook/experimental-addon-test": "^8.6.6",
46
+ "@storybook/react": "^8.6.6",
47
+ "@storybook/react-vite": "^8.6.6",
48
+ "@storybook/test": "^8.6.6",
49
+ "@svgr/rollup": "^8.1.0",
50
+ "@vitest/browser": "^3.0.8",
51
+ "@vitest/coverage-v8": "^3.0.8",
52
+ "prop-types": "^15.8.1",
53
+ "rollup": "^2.79.2",
54
+ "rollup-plugin-babel": "^4.4.0",
55
+ "rollup-plugin-peer-deps-external": "^2.2.4",
56
+ "rollup-plugin-postcss": "^4.0.2",
57
+ "rollup-plugin-terser": "^7.0.2",
58
+ "storybook": "^8.6.6",
59
+ "vitest": "^3.0.8"
60
+ }
61
+ }
@@ -1,14 +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>
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>
@@ -1,14 +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>
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>
@@ -1,13 +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>
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>
@@ -1,13 +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>
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>
@@ -1,14 +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>
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>
@@ -276,7 +276,6 @@ export default class JRFields extends JRWindow {
276
276
  )
277
277
  }
278
278
  validate(value){
279
- console.clear()
280
279
  const validators=[]
281
280
  const testValue=this.getTestValue()??{}
282
281
  this.#validators(this.getColumns(),validators,[],testValue,value!==undefined?value:this.getValue())
@@ -22,19 +22,15 @@ export default class Slider extends React.Component {
22
22
  const ref=this.props.contenerRef.current
23
23
  let width=this.frame.x2-clientX-this.frame.shw
24
24
  if(width<0)width=0
25
- po('width',width)
26
25
  ref.style.flexBasis=`${width}px`
27
26
  }
28
27
  ,top:({clientY})=>{
29
- po('top')
30
28
  const ref=this.props.contenerRef.current
31
29
  let height=clientY-this.frame.y-this.frame.shh
32
- po('height',height)
33
30
  // if(width<0)width=0
34
31
  ref.style.flexBasis=`${height}px`
35
32
  }
36
33
  ,bottom:({clientY})=>{
37
- po('bottom')
38
34
  const ref=this.props.contenerRef.current
39
35
  let height=this.frame.w2-clientY-this.frame.shh
40
36
  // clientY-this.frame.y-this.frame.shh
@@ -44,7 +40,6 @@ export default class Slider extends React.Component {
44
40
  }
45
41
  }
46
42
  stop=(e)=>{
47
- po('stop',this.stop)
48
43
  document.body.style.cursor='default'
49
44
  window.removeEventListener('mousemove',this.move)
50
45
  window.removeEventListener('mouseup',this.stop)
@@ -53,11 +48,8 @@ export default class Slider extends React.Component {
53
48
  this.resize[this.props.dir](e)
54
49
  }
55
50
  start=({clientX})=>{
56
- console.clear()
57
51
  const ref=this.props.contenerRef.current
58
52
  const {x,y,width,height,...other}=ref.getBoundingClientRect()
59
- po('other',ref.getBoundingClientRect())
60
- po('ref.getBoundingClientRect()',this.ref.current.getBoundingClientRect())
61
53
  const {width:sw,height:sh}=this.ref.current.getBoundingClientRect()
62
54
  this.frame={
63
55
  x,y
@@ -4,7 +4,9 @@ import styled from "styled-components";
4
4
  import TitleBar from "./TitleBar";
5
5
  import Sliders from "./Slider";
6
6
  import { JRHTML } from "jrs-js";
7
- import { po } from "../JRUtils";
7
+ import { po, random } from "../JRUtils";
8
+
9
+
8
10
 
9
11
  const StyledBackdrop=styled.div`
10
12
  ${({$zIndex})=>$zIndex!=null?`z-index:${$zIndex};`:null}
@@ -56,6 +58,8 @@ const StyledJRWindow=styled.div`
56
58
  }
57
59
  `
58
60
 
61
+
62
+
59
63
  class Backdrop extends JRHTML{
60
64
  backdropConfig={
61
65
  yo:'div'
@@ -69,114 +73,51 @@ class Backdrop extends JRHTML{
69
73
  }
70
74
  }
71
75
 
72
- constructor(params){
76
+ constructor({zIndex,fullScreen,...params}){
73
77
  super(params)
78
+ this.backdropConfig.style.zIndex=zIndex
79
+ this.backdropConfig.personajes={
80
+ id:params.backdropId
81
+ }
74
82
  Object.assign(this.backdropConfig.style,params.backdropStyle)
75
83
  }
76
-
77
-
78
84
  show(){
79
- this.backdrop=this.agregarHijo(this.backdropConfig)
85
+ this.agregarHijo(this.backdropConfig)
80
86
  }
81
87
  hide(){
82
- if(this.hijos.length){
83
- this.yo.removeChild(this.yo.children[this.yo.children.length-1])
84
- this.hijos=[]
88
+ const backdrop=document.getElementById(this.backdropId)
89
+ if(backdrop){
90
+ backdrop.parentNode.removeChild(backdrop);
85
91
  }
92
+ this.hijos=[]
86
93
  }
87
94
  }
88
95
 
89
- export default class JRWindow extends JRFrame {
90
- // x=0
91
- // y=0
92
- // width=300
93
- // height=300
96
+
97
+
98
+ class RWindow extends React.Component {
94
99
  padding=1
95
100
  thick=5
96
-
97
101
  constructor(props){
98
102
  super(props)
99
- this.ref=React.createRef()
100
103
  this.titleBarRef=React.createRef()
101
104
  }
102
105
 
103
- createBackdrop(){
104
- if(typeof this.props.backdrop === 'string'){
105
- const target=document.getElementById(this.props.backdrop)
106
- if(target){
107
- this.backdropTarget=new Backdrop({
108
- yo:target
109
- ,style:{
110
- position: 'relative'
111
- }
112
- ,backdropStyle:this.props.backdropStyle
113
- })
114
- }
115
- }
116
- }
117
-
118
- addMaskToTarget=(target)=>{
119
- this.mask=document.createElement('div')
120
- this.mask.style.background='#868686cc'
121
- this.mask.style.position='absolute'
122
- this.mask.style.top='0'
123
- this.mask.style.left='0'
124
- this.mask.style.right='0'
125
- this.mask.style.bottom='0'
126
- this.mask.style.borderRadius='inherit'
127
- this.mask.style.height='10000px'
128
- this.mask.style.width='10000px'
129
- target.appendChild(this.mask)
130
- }
131
- removeMaskFromTarget=()=>{
132
- this.mask.remove()
133
- }
134
-
135
- // backdropOn(on){
136
- // const target=(typeof this.props.backdrop)==='object'
137
- // ?this.props.backdrop
138
- // :typeof this.props.backdrop ==='string'
139
- // ?document.getElementById(this.props.backdrop)
140
- // :document.body
141
- // target?.classList[on?'add':'remove']('withMask')
142
- // }
143
-
144
106
  componentDidMount(){
145
- super.componentDidMount()
146
- this.createBackdrop()
147
107
  if(this.props.open){
148
- this.open()
108
+ this.props.jrWindow.backdropTarget?.show()
109
+ this.props.onOpen?.bind(this.props.jrWindow)()
149
110
  }
150
111
  }
151
-
152
112
  componentWillUnmount(){
153
- this.backdropTarget?.hide()
154
- }
155
-
156
- open(){
157
- this.backdropTarget?.show()
158
- this.props.onOpen?.bind(this)()
159
- }
160
- close(){
161
- this.backdropTarget?.hide()
162
- this.props.onClose?.bind(this)()
163
- }
164
-
165
- componentDidUpdate(prevProps, prevState, snapshot){
166
- if(this.props.popup===true){
167
- if(this.props.open && prevProps.open===false){
168
- this.open()
169
- }else if(this.props.open===false && prevProps.open){
170
- this.close()
171
- }
172
- // if(this.props.backdrop && this.props.open!=prevProps.open){
173
- // this.backdropOn(this.props.open)
174
- // }
113
+ if(this.props.open){
114
+ this.props.jrWindow.backdropTarget?.hide()
175
115
  }
176
116
  }
177
117
 
118
+
178
119
  get xw(){
179
- let width
120
+ let width=700
180
121
  if(this.props.width?.indexOf?.('%')>-1){
181
122
  width=(this.props.width.split('%')[0]*window.innerWidth)/100
182
123
  }else{
@@ -189,7 +130,7 @@ export default class JRWindow extends JRFrame {
189
130
  }
190
131
 
191
132
  get yh(){
192
- let height
133
+ let height=400
193
134
  if(this.props.height?.indexOf?.('%')>-1){
194
135
  height=(this.props.height.split('%')[0]*window.innerHeight)/100
195
136
  }else{
@@ -201,43 +142,89 @@ export default class JRWindow extends JRFrame {
201
142
  }
202
143
  }
203
144
 
145
+ render(){
146
+ const {children,title,resizable,jrWindow,...props}=this.props
147
+ return <StyledJRWindow
148
+ $zIndex={this.props.zIndex?this.props.zIndex+1:null}
149
+ className={`jr-window ${this.props.className??''}`}
150
+ ref={this.props.windowRef}
151
+ $xw={this.xw}
152
+ $yh={this.yh}
153
+ $thick={this.thick}
154
+ >
155
+ <main style={{zIndex:this.props.zIndex?this.props.zIndex+1:null}} >
156
+ <TitleBar
157
+ titleBarRef={this.titleBarRef}
158
+ jrWindow={jrWindow}
159
+ windowRef={this.props.windowRef}
160
+ window={this}
161
+ title={title}
162
+ thick={this.thick}
163
+ resizable={resizable}
164
+ />
165
+ {children}
166
+ {this.props.resizable !== false
167
+ && <Sliders
168
+ thick={this.thick}
169
+ windowRef={this.props.windowRef}
170
+ window={this}
171
+ titleBarRef={this.titleBarRef}
172
+ />
173
+ }
174
+ </main>
175
+ {this.props.backdrop===true && <StyledBackdrop $zIndex={this.props.zIndex}/>}
176
+ </StyledJRWindow>
177
+ }
178
+ }
179
+
180
+ export default class JRWindow extends JRFrame {
181
+ constructor(props){
182
+ super(props)
183
+ this.windowRef=React.createRef()
184
+ this.backdropId=`backdropId-${random(10000,99999)}`
185
+ }
186
+
187
+ componentDidMount(){
188
+ super.componentDidMount()
189
+ this.createBackdrop()
190
+ }
191
+ componentWillUnmount(){
192
+ if(this.props.open){
193
+ this.backdropTarget?.hide()
194
+ }
195
+ }
196
+ componentDidUpdate(prevProps, prevState){
197
+ if(prevProps.open && prevProps.open!=this.props.open){
198
+ this.props.onClose?.bind(this)()
199
+ }
200
+ }
201
+
202
+ componentWillUpdate
203
+ createBackdrop(){
204
+ if(typeof this.props.backdrop === 'string'){
205
+ const target=document.getElementById(this.props.backdrop)
206
+ if(target){
207
+ this.backdropTarget=new Backdrop({
208
+ yo:target
209
+ ,backdropId:this.backdropId
210
+ ,fullScreen:this.props.backdrop===true
211
+ ,zIndex:this.props.zIndex
212
+ ,backdropStyle:this.props.backdropStyle
213
+ })
214
+ if(this.props.open){
215
+ this.backdropTarget.show()
216
+ }
217
+ }
218
+ }
219
+ }
220
+
204
221
  renderer(){
205
- return this.props.popup===true
206
- ?this.props.open
207
- ?<>
208
- <StyledJRWindow
209
- $zIndex={this.props.zIndex}
210
- rule={'dialog'}
211
- ref={this.ref}
212
- className={`jr-window ${this.props.className??''}`}
213
- $xw={this.xw}
214
- $yh={this.yh}
215
- $thick={this.thick}
216
- >
217
- <main style={{zIndex:1}}>
218
- <TitleBar
219
- titleBarRef={this.titleBarRef}
220
- windowRef={this.ref}
221
- window={this}
222
- title={this.props.title}
223
- thick={this.thick}
224
- resizable={this.props.resizable}
225
- />
226
- <main>
227
- {super.renderer()}
228
- </main>
229
- {this.props.resizable !== false
230
- && <Sliders
231
- thick={this.thick}
232
- windowRef={this.ref}
233
- window={this}
234
- titleBarRef={this.titleBarRef}
235
- />
236
- }
237
- </main>
238
- {this.props.backdrop!==false && typeof this.props.backdrop!=='string' && <StyledBackdrop $zIndex={this.props.zIndex}/>}
239
- </StyledJRWindow>
240
- </>
222
+ const {popup,open,xzIndex=1,...props}=this.props
223
+ return popup===true
224
+ ?open
225
+ ?<RWindow {...props} jrWindow={this} open={open} windowRef={this.windowRef}>
226
+ {super.renderer()}
227
+ </RWindow>
241
228
  :''
242
229
  :super.renderer()
243
230
  }
@@ -199,6 +199,8 @@ export default class TitleBar extends React.Component{
199
199
  window.removeEventListener('mousemove',this.preMove)
200
200
  }
201
201
  start(e){
202
+ po('start',this)
203
+ po('this.props.windowRef',this.props.windowRef)
202
204
  e.preventDefault()
203
205
  this.moved=false
204
206
  this.pos3 = e.clientX
@@ -226,7 +228,7 @@ export default class TitleBar extends React.Component{
226
228
  {/* <JRButton icon={<IconMinus />}/>
227
229
  <JRButton icon={<IconSquare />}/> */}
228
230
  {
229
- this.props.window.props.setOpen
231
+ this.props.jrWindow.props.close
230
232
  ?<JRButton icon={<IconX />}
231
233
  className={'danger'}
232
234
  onClick={(e)=>{
@@ -234,7 +236,7 @@ export default class TitleBar extends React.Component{
234
236
  if(this.props.window.orgBodyOverflow!=null){
235
237
  document.body.style.overflow=this.props.window.orgBodyOverflow
236
238
  }
237
- this.props.window.props.setOpen(false)
239
+ this.props.jrWindow.props.close()
238
240
  }}
239
241
  onMouseDown={(e)=>{
240
242
  e.stopPropagation()
package/src/main.jsx CHANGED
@@ -1,10 +1,10 @@
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
- import JRFields from './components/JRFields/JRFields.jsx'
6
- import JRText from './components/JRInput/JRText.jsx'
7
-
8
- const root = createRoot(document.getElementById('root'))
9
- root.render(<App/>)
10
-
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
+ import JRFields from './components/JRFields/JRFields.jsx'
6
+ import JRText from './components/JRInput/JRText.jsx'
7
+
8
+ const root = createRoot(document.getElementById('root'))
9
+ root.render(<App/>)
10
+