jrs-react 1.2.46 → 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.46",
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,115 +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
84
  show(){
78
- this.backdrop=this.agregarHijo(this.backdropConfig)
79
- this.on=true
85
+ this.agregarHijo(this.backdropConfig)
80
86
  }
81
87
  hide(){
82
- if(this.on){
83
- this.yo.removeChild(this.yo.children[this.yo.children.length-1])
84
- this.hijos=[]
85
- this.on=false
88
+ const backdrop=document.getElementById(this.backdropId)
89
+ if(backdrop){
90
+ backdrop.parentNode.removeChild(backdrop);
86
91
  }
92
+ this.hijos=[]
87
93
  }
88
94
  }
89
95
 
90
- export default class JRWindow extends JRFrame {
91
- // x=0
92
- // y=0
93
- // width=300
94
- // height=300
96
+
97
+
98
+ class RWindow extends React.Component {
95
99
  padding=1
96
100
  thick=5
97
-
98
101
  constructor(props){
99
102
  super(props)
100
- this.ref=React.createRef()
101
103
  this.titleBarRef=React.createRef()
102
104
  }
103
105
 
104
- createBackdrop(){
105
- if(typeof this.props.backdrop === 'string'){
106
- const target=document.getElementById(this.props.backdrop)
107
- if(target){
108
- this.backdropTarget=new Backdrop({
109
- yo:target
110
- ,style:{
111
- position: 'relative'
112
- }
113
- ,backdropStyle:this.props.backdropStyle
114
- })
115
- }
116
- }
117
- }
118
-
119
- addMaskToTarget=(target)=>{
120
- this.mask=document.createElement('div')
121
- this.mask.style.background='#868686cc'
122
- this.mask.style.position='absolute'
123
- this.mask.style.top='0'
124
- this.mask.style.left='0'
125
- this.mask.style.right='0'
126
- this.mask.style.bottom='0'
127
- this.mask.style.borderRadius='inherit'
128
- this.mask.style.height='10000px'
129
- this.mask.style.width='10000px'
130
- target.appendChild(this.mask)
131
- }
132
- removeMaskFromTarget=()=>{
133
- this.mask.remove()
134
- }
135
-
136
- // backdropOn(on){
137
- // const target=(typeof this.props.backdrop)==='object'
138
- // ?this.props.backdrop
139
- // :typeof this.props.backdrop ==='string'
140
- // ?document.getElementById(this.props.backdrop)
141
- // :document.body
142
- // target?.classList[on?'add':'remove']('withMask')
143
- // }
144
-
145
106
  componentDidMount(){
146
- super.componentDidMount()
147
- this.createBackdrop()
148
107
  if(this.props.open){
149
- this.open()
108
+ this.props.jrWindow.backdropTarget?.show()
109
+ this.props.onOpen?.bind(this.props.jrWindow)()
150
110
  }
151
111
  }
152
-
153
112
  componentWillUnmount(){
154
- this.backdropTarget?.hide()
155
- }
156
-
157
- open(){
158
- this.backdropTarget?.show()
159
- this.props.onOpen?.bind(this)()
160
- }
161
- close(){
162
- this.backdropTarget?.hide()
163
- this.props.onClose?.bind(this)()
164
- }
165
-
166
- componentDidUpdate(prevProps, prevState, snapshot){
167
- if(this.props.popup===true){
168
- if(this.props.open && prevProps.open===false){
169
- this.open()
170
- }else if(this.props.open===false && prevProps.open){
171
- this.close()
172
- }
173
- // if(this.props.backdrop && this.props.open!=prevProps.open){
174
- // this.backdropOn(this.props.open)
175
- // }
113
+ if(this.props.open){
114
+ this.props.jrWindow.backdropTarget?.hide()
176
115
  }
177
116
  }
178
117
 
118
+
179
119
  get xw(){
180
- let width
120
+ let width=700
181
121
  if(this.props.width?.indexOf?.('%')>-1){
182
122
  width=(this.props.width.split('%')[0]*window.innerWidth)/100
183
123
  }else{
@@ -190,7 +130,7 @@ export default class JRWindow extends JRFrame {
190
130
  }
191
131
 
192
132
  get yh(){
193
- let height
133
+ let height=400
194
134
  if(this.props.height?.indexOf?.('%')>-1){
195
135
  height=(this.props.height.split('%')[0]*window.innerHeight)/100
196
136
  }else{
@@ -202,43 +142,89 @@ export default class JRWindow extends JRFrame {
202
142
  }
203
143
  }
204
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
+
205
221
  renderer(){
206
- return this.props.popup===true
207
- ?this.props.open
208
- ?<>
209
- <StyledJRWindow
210
- $zIndex={this.props.zIndex}
211
- rule={'dialog'}
212
- ref={this.ref}
213
- className={`jr-window ${this.props.className??''}`}
214
- $xw={this.xw}
215
- $yh={this.yh}
216
- $thick={this.thick}
217
- >
218
- <main style={{zIndex:1}}>
219
- <TitleBar
220
- titleBarRef={this.titleBarRef}
221
- windowRef={this.ref}
222
- window={this}
223
- title={this.props.title}
224
- thick={this.thick}
225
- resizable={this.props.resizable}
226
- />
227
- <main>
228
- {super.renderer()}
229
- </main>
230
- {this.props.resizable !== false
231
- && <Sliders
232
- thick={this.thick}
233
- windowRef={this.ref}
234
- window={this}
235
- titleBarRef={this.titleBarRef}
236
- />
237
- }
238
- </main>
239
- {this.props.backdrop!==false && typeof this.props.backdrop!=='string' && <StyledBackdrop $zIndex={this.props.zIndex}/>}
240
- </StyledJRWindow>
241
- </>
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>
242
228
  :''
243
229
  :super.renderer()
244
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
+