jrs-react 1.2.19 → 1.2.20

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.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var React = require('react');
5
+ var React$1 = require('react');
6
6
  var styled = require('styled-components');
7
7
  var client = require('react-dom/client');
8
8
 
@@ -26,8 +26,8 @@ function _interopNamespace(e) {
26
26
  return Object.freeze(n);
27
27
  }
28
28
 
29
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
30
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
30
+ var React__namespace = /*#__PURE__*/_interopNamespace(React$1);
31
31
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
32
32
 
33
33
  function bind(fn, thisArg) {
@@ -3296,36 +3296,197 @@ const whatType = ({
3296
3296
  return doElse;
3297
3297
  }
3298
3298
  };
3299
+ function random(max = 100, min = 0) {
3300
+ return Math.floor(Math.random() * (max + 1 - min)) + min;
3301
+ }
3299
3302
 
3300
- // import { IconSpinner } from '../assets/image';
3303
+ class JRHTML{
3304
+ isJRHTML=true
3305
+ _hijos=[]
3306
+ _padre
3307
+ _madre
3308
+ _yo
3309
+ constructor(params){
3310
+ var {yo,padre,madre,clases,personajes={},...params}=params;
3311
+ this.yo=yo;
3312
+ if(padre){
3313
+ this.padre=padre;
3314
+ this.madre=padre.yo;
3315
+ }else if(madre){
3316
+ this.madre=madre;
3317
+ }
3318
+ if(clases)personajes.class=clases.join(' ');
3319
+ params.personajes=personajes;
3320
+ Object.assign(this,params);
3321
+ this._init();
3322
+ }
3323
+ _init(){
3324
+
3325
+ }
3326
+ set style(styles){
3327
+ Object.entries(styles).forEach((style,i)=>{
3328
+ this._yo.style[style[0]]=style[1];
3329
+ });
3330
+ }
3331
+ set personajes(personajes){
3332
+ Object.entries(personajes).forEach(([personaje,valor])=>{
3333
+ this._yo.setAttribute(personaje,valor);
3334
+ });
3335
+ }
3336
+ agregarHijo(hijo){
3337
+ if(hijo.isJRHTML){
3338
+ hijo.padre=this;
3339
+ hijo.madre=this.yo;
3340
+ }else if(hijo.yo){
3341
+ hijo.padre=this;
3342
+ hijo= hijo.yo.name?new hijo.yo(hijo):new JRHTML(hijo);
3343
+ }else {
3344
+ this.yo.appendChild(document.createTextNode(hijo));
3345
+ }
3346
+ return hijo
3347
+ }
3348
+ set html(html){
3349
+ this._yo.innerHTML=html;
3350
+ }
3351
+ get html(){
3352
+ return this._yo.innerHTML
3353
+ }
3354
+ set hijos(hijos){
3355
+ hijos.forEach((hijo,i)=>{
3356
+ this.agregarHijo(hijo);
3357
+ });
3358
+ }
3359
+ get hijos(){
3360
+ return this._hijos
3361
+ }
3362
+ removeAllHijos(){
3363
+ this.hijos.forEach(hijo=>{
3364
+ hijo.yo.remove();
3365
+ });
3366
+ delete this.hijos;
3367
+ this.hijos=[];
3368
+ }
3369
+ removeHijo(hijo){
3370
+ var index=this.hijos.indexOf(hijo);
3371
+ if(index>=0){
3372
+ this.yo.removeChild(this.yo.childNodes[index]);
3373
+ this.hijos.splice(index, 1);
3374
+ }
3375
+ }
3376
+ nacido(yo){
3377
+ return document.createElement(yo)
3378
+ }
3379
+ set yo(yo){
3380
+ if(typeof yo === 'string' ){
3381
+ this._yo=this.nacido(yo);
3382
+ }else {
3383
+ this._yo=yo;
3384
+ }
3385
+ }
3386
+ get yo(){
3387
+ return this._yo
3388
+ }
3389
+ set padre(padre){
3390
+ this._padre=padre;
3391
+ if(this._padre)this._padre._hijos.push(this);
3392
+ }
3393
+ get padre(){
3394
+ return this._padre
3395
+ }
3396
+ set madre(madre){
3397
+ if(typeof madre === 'string' ){
3398
+ this._madre=document.getElementById(madre);
3399
+ }else {
3400
+ this._madre=madre;
3401
+ }
3402
+ if(this._madre&&this._yo)this._madre.appendChild(this._yo);
3403
+ }
3404
+ get madre(){
3405
+ return this._madre
3406
+ }
3407
+ set listeners(listeners){
3408
+ Object.entries(listeners).forEach(([event,func])=>{
3409
+ var me=this;
3410
+ if(event=='listeners'){
3411
+ this.listeners=func;
3412
+ }else {
3413
+ this._yo.addEventListener(event,function(e){
3414
+ func(e,me);
3415
+ },false);
3416
+ }
3417
+ });
3418
+ }
3419
+ get width(){
3420
+ return this._yo.clientWidth//offsetWidth
3421
+ }
3422
+ set width(width){
3423
+ this._yo.style.width=width;
3424
+ }
3425
+ get height(){
3426
+ return this._yo.clientHeight//offsetWidth
3427
+ }
3428
+ set height(height){
3429
+ this._yo.style.height=height;
3430
+ }
3431
+ set textContent(textContent){
3432
+ this._yo.textContent=textContent;
3433
+ }
3434
+ set color(color){
3435
+ this.yo.style.color=color;
3436
+ this._color=color;
3437
+ }
3438
+ get color(){
3439
+ return this._color
3440
+ }
3441
+ set visibility(visibility){
3442
+ this.yo.style.visibility=visibility;
3443
+ }
3444
+ set tip(tip){
3445
+ this.agregarHijo({
3446
+ yo:'span'
3447
+ ,clases:['tooltiptext']
3448
+ ,textContent:tip
3449
+ });
3450
+ }
3451
+ }
3452
+
3453
+ const StyledMask = styled__default["default"].dialog`
3454
+ display:none;
3455
+ &:open{
3456
+ display:flex;
3457
+ }
3458
+
3459
+ &:modal {
3460
+ outline: 0;
3461
+ background: #000c6e77;
3462
+ }
3463
+
3464
+ #jr-mask-msg{
3465
+ padding: 10px;
3466
+ }
3467
+
3468
+ max-width: 100vw;
3469
+ max-height: 100vh;
3470
+
3471
+ width: 100vw;
3472
+ height: 100vh;
3473
+
3474
+ border:0;
3475
+ margin: 0;
3476
+ top: 0;
3477
+ left: 0;
3301
3478
 
3302
- styled__default["default"].div`
3303
3479
  user-select: none;
3304
3480
  cursor: wait;
3305
- display: none;
3306
3481
  flex-direction: column;
3307
3482
  justify-content: center;
3308
3483
  align-items: center;
3309
3484
  position: fixed;
3310
- width: 100vw;
3311
- height: 100vh;
3312
- background-color: #000000aa;
3485
+
3313
3486
  z-index: 20000;
3314
- color: ${({
3315
- theme
3316
- }) => theme.colorPrimary};
3317
-
3318
- svg{
3319
- width: 80px;
3320
- height: 80px;
3321
- path, circle{
3322
- fill: ${({
3323
- theme
3324
- }) => theme.colorPrimary};
3325
- }
3326
- }
3487
+ overflow: hidden;
3327
3488
 
3328
- .cs-loader-inner {
3489
+ .cs-loader-inner {
3329
3490
  transform: translateY(-30%);
3330
3491
  width: calc(100% - 200xpx);
3331
3492
  }
@@ -3334,96 +3495,150 @@ styled__default["default"].div`
3334
3495
  font-size: 20px;
3335
3496
  opacity: 0;
3336
3497
  display:inline-block;
3337
- color:${({
3338
- theme
3339
- }) => theme.colorPrimary};
3498
+ color:white;
3340
3499
  }
3341
3500
 
3342
- @keyframes lol {
3343
- 0% {
3344
- opacity: 0;
3345
- transform: translateX(-300px);
3346
- }
3347
- 33% {
3348
- opacity: 1;
3349
- transform: translateX(0px);
3350
- }
3351
- 66% {
3352
- opacity: 1;
3353
- transform: translateX(0px);
3354
- }
3355
- 100% {
3356
- opacity: 0;
3357
- transform: translateX(300px);
3358
- }
3359
- }
3501
+ @keyframes lol {
3502
+ 0% {
3503
+ opacity: 0;
3504
+ transform: translateX(-300px);
3505
+ }
3506
+ 33% {
3507
+ opacity: 1;
3508
+ transform: translateX(0px);
3509
+ }
3510
+ 66% {
3511
+ opacity: 1;
3512
+ transform: translateX(0px);
3513
+ }
3514
+ 100% {
3515
+ opacity: 0;
3516
+ transform: translateX(300px);
3517
+ }
3518
+ }
3360
3519
 
3361
- @-webkit-keyframes lol {
3362
- 0% {
3363
- opacity: 0;
3364
- -webkit-transform: translateX(-300px);
3365
- }
3366
- 33% {
3367
- opacity: 1;
3368
- -webkit-transform: translateX(0px);
3369
- }
3370
- 66% {
3371
- opacity: 1;
3372
- -webkit-transform: translateX(0px);
3373
- }
3374
- 100% {
3375
- opacity: 0;
3376
- -webkit-transform: translateX(300px);
3377
- }
3378
- }
3520
+ @-webkit-keyframes lol {
3521
+ 0% {
3522
+ opacity: 0;
3523
+ -webkit-transform: translateX(-300px);
3524
+ }
3525
+ 33% {
3526
+ opacity: 1;
3527
+ -webkit-transform: translateX(0px);
3528
+ }
3529
+ 66% {
3530
+ opacity: 1;
3531
+ -webkit-transform: translateX(0px);
3532
+ }
3533
+ 100% {
3534
+ opacity: 0;
3535
+ -webkit-transform: translateX(300px);
3536
+ }
3537
+ }
3379
3538
 
3380
- .cs-loader-inner label:nth-child(6) {
3381
- -webkit-animation: lol 3s infinite ease-in-out;
3382
- animation: lol 3s infinite ease-in-out;
3383
- }
3539
+ .cs-loader-inner label:nth-child(6) {
3540
+ -webkit-animation: lol 3s infinite ease-in-out;
3541
+ animation: lol 3s infinite ease-in-out;
3542
+ }
3384
3543
 
3385
- .cs-loader-inner label:nth-child(5) {
3386
- -webkit-animation: lol 3s 100ms infinite ease-in-out;
3387
- animation: lol 3s 100ms infinite ease-in-out;
3388
- }
3544
+ .cs-loader-inner label:nth-child(5) {
3545
+ -webkit-animation: lol 3s 100ms infinite ease-in-out;
3546
+ animation: lol 3s 100ms infinite ease-in-out;
3547
+ }
3389
3548
 
3390
- .cs-loader-inner label:nth-child(4) {
3391
- -webkit-animation: lol 3s 200ms infinite ease-in-out;
3392
- animation: lol 3s 200ms infinite ease-in-out;
3393
- }
3549
+ .cs-loader-inner label:nth-child(4) {
3550
+ -webkit-animation: lol 3s 200ms infinite ease-in-out;
3551
+ animation: lol 3s 200ms infinite ease-in-out;
3552
+ }
3394
3553
 
3395
- .cs-loader-inner label:nth-child(3) {
3396
- -webkit-animation: lol 3s 300ms infinite ease-in-out;
3397
- animation: lol 3s 300ms infinite ease-in-out;
3398
- }
3554
+ .cs-loader-inner label:nth-child(3) {
3555
+ -webkit-animation: lol 3s 300ms infinite ease-in-out;
3556
+ animation: lol 3s 300ms infinite ease-in-out;
3557
+ }
3399
3558
 
3400
- .cs-loader-inner label:nth-child(2) {
3401
- -webkit-animation: lol 3s 400ms infinite ease-in-out;
3402
- animation: lol 3s 400ms infinite ease-in-out;
3403
- }
3559
+ .cs-loader-inner label:nth-child(2) {
3560
+ -webkit-animation: lol 3s 400ms infinite ease-in-out;
3561
+ animation: lol 3s 400ms infinite ease-in-out;
3562
+ }
3404
3563
 
3405
- .cs-loader-inner label:nth-child(1) {
3406
- -webkit-animation: lol 3s 500ms infinite ease-in-out;
3407
- animation: lol 3s 500ms infinite ease-in-out;
3408
- }
3564
+ .cs-loader-inner label:nth-child(1) {
3565
+ -webkit-animation: lol 3s 500ms infinite ease-in-out;
3566
+ animation: lol 3s 500ms infinite ease-in-out;
3567
+ }
3409
3568
  `;
3410
- const displaySpinner = ({
3411
- mask
3412
- }) => {
3413
- const spin = document.getElementById("loadingBar");
3414
- const text = document.getElementById("loadingText");
3415
- if (spin == null) {
3416
- //alert("Spin or msgSpan is not initialized")
3417
- return;
3569
+ function JRMask({
3570
+ id = 'jr-mask'
3571
+ }) {
3572
+ return /*#__PURE__*/React.createElement(StyledMask, {
3573
+ id: id,
3574
+ className: 'jr-mask'
3575
+ }, /*#__PURE__*/React.createElement("div", {
3576
+ id: 'jr-mask-msg'
3577
+ }), /*#__PURE__*/React.createElement("div", {
3578
+ className: "cs-loader-inner"
3579
+ }, /*#__PURE__*/React.createElement("label", null, "\u25CF"), /*#__PURE__*/React.createElement("label", null, "\u25CF"), /*#__PURE__*/React.createElement("label", null, "\u25CF"), /*#__PURE__*/React.createElement("label", null, "\u25CF"), /*#__PURE__*/React.createElement("label", null, "\u25CF"), /*#__PURE__*/React.createElement("label", null, "\u25CF")));
3580
+ }
3581
+ class Mask extends JRHTML {
3582
+ msg = [];
3583
+ #msgIndex = 0;
3584
+ #mask;
3585
+ get msgIndex() {
3586
+ return this.#msgIndex++;
3587
+ }
3588
+ addMsg(msg) {
3589
+ const index = this.msgIndex;
3590
+ this.msg.push({
3591
+ i: index,
3592
+ msg
3593
+ });
3594
+ this.renderMsg();
3595
+ return () => {
3596
+ po('remove function', index);
3597
+ this.removeMsg(index);
3598
+ };
3418
3599
  }
3419
- if (mask) {
3420
- spin.style.display = "flex";
3421
- text.innerText = mask;
3422
- } else {
3423
- spin.style.display = "none";
3424
- text.innerText = '';
3600
+ removeMsg(index) {
3601
+ this.msg = this.msg.filter(r => r.i != index);
3602
+ this.renderMsg();
3425
3603
  }
3426
- };
3604
+ renderMsg() {
3605
+ this.msgDiv.removeAllHijos();
3606
+ if (this.msg.length) {
3607
+ this.msgDiv.agregarHijo(new JRHTML({
3608
+ yo: 'div',
3609
+ textContent: this.msg[this.msg.length - 1].msg
3610
+ }));
3611
+ if (!this.yo.open) {
3612
+ this.yo.showModal();
3613
+ }
3614
+ } else {
3615
+ this.yo.close();
3616
+ }
3617
+ }
3618
+ get msg() {
3619
+ return 'msg';
3620
+ }
3621
+ }
3622
+ function showMask(msg, maskTarget, whichMask) {
3623
+ const jrMask = document.getElementById('jr-mask');
3624
+ const jrMaskMsg = document.getElementById('jr-mask-msg');
3625
+ if (!jrMask.maskDiv) {
3626
+ jrMask.maskDiv = new Mask({
3627
+ yo: jrMask,
3628
+ msgDiv: new JRHTML({
3629
+ yo: jrMaskMsg
3630
+ }),
3631
+ listeners: {
3632
+ keydown(e) {
3633
+ if (e.key === 'Escape') {
3634
+ e.preventDefault();
3635
+ }
3636
+ }
3637
+ }
3638
+ });
3639
+ }
3640
+ return jrMask.maskDiv.addMsg(msg);
3641
+ }
3427
3642
 
3428
3643
  const axiosSubmit = axios$1.create({
3429
3644
  authorization: `Bearer ${localStorage.getItem("accessToken")}`,
@@ -3620,13 +3835,10 @@ class JRSubmit extends React__default["default"].Component {
3620
3835
  po('reload 還沒有做 ');
3621
3836
  }
3622
3837
  submit(config) {
3623
- const me = this;
3624
- displaySpinner({
3625
- mask: config.mask
3626
- });
3627
- this.setState({
3628
- loading: true
3629
- });
3838
+ // const me=this
3839
+ // displaySpinner({mask:config.mask})
3840
+ // this.setState({loading:true})//拿掉可能會有問題, 先觀察看看
3841
+ if (config.mask) config.removeMaskFunction = showMask(config.mask);
3630
3842
  let _payload;
3631
3843
  (() => {
3632
3844
  if (Array.isArray(config.url)) {
@@ -3661,13 +3873,12 @@ class JRSubmit extends React__default["default"].Component {
3661
3873
  this.handleResponse(res, _payload, config);
3662
3874
  }).catch(res => {
3663
3875
  this.handleResponse(res, _payload, config);
3664
- }).finally(function (a, b, c) {
3665
- me.setState({
3666
- loading: false
3667
- });
3668
- displaySpinner({
3669
- mask: false
3670
- });
3876
+ }).finally(() => {
3877
+ // this.setState({loading:false})
3878
+ // displaySpinner({mask:false})
3879
+ // setTimeout(()=>{
3880
+ config.removeMaskFunction?.();
3881
+ // },random(4000,1000))
3671
3882
  });
3672
3883
  }
3673
3884
  handleResponse = (response, payload, config) => {
@@ -3940,7 +4151,6 @@ class TitleBar extends React__default["default"].Component {
3940
4151
  }
3941
4152
  };
3942
4153
  floatScreen = e => {
3943
- po('floatScreen');
3944
4154
  this.props.windowRef.current;
3945
4155
  this.props.windowRef.current.style.transition = 'var(--transition-x-y), left .05s ease-in';
3946
4156
  this.props.windowRef.current.style.left = `${this.props.window.orgLeft}px`;
@@ -3950,7 +4160,6 @@ class TitleBar extends React__default["default"].Component {
3950
4160
  document.body.style.overflow = this.props.window.orgBodyOverflow;
3951
4161
  };
3952
4162
  fullScreen = e => {
3953
- po('fullScreen', this.props.thick);
3954
4163
  this.props.windowRef.current.style.transition = 'var(--transition-x-y), left .05s ease-in';
3955
4164
  this.props.windowRef.current.style.left = `${-this.props.thick}px`;
3956
4165
  this.props.windowRef.current.style.top = `${-this.props.thick}px`;
@@ -3963,7 +4172,6 @@ class TitleBar extends React__default["default"].Component {
3963
4172
  }, 50);
3964
4173
  };
3965
4174
  stop = e => {
3966
- po('stop');
3967
4175
  e.preventDefault();
3968
4176
  if (this.moved) {
3969
4177
  const {
@@ -3986,7 +4194,6 @@ class TitleBar extends React__default["default"].Component {
3986
4194
  window.removeEventListener('mousemove', this.preMove);
3987
4195
  };
3988
4196
  move = e => {
3989
- po('move');
3990
4197
  e.preventDefault();
3991
4198
  this.moved = true;
3992
4199
  const {
@@ -4001,35 +4208,24 @@ class TitleBar extends React__default["default"].Component {
4001
4208
  const w = this.props.windowRef.current;
4002
4209
  this.y = w.offsetTop - this.pos2;
4003
4210
  this.x = w.offsetLeft - this.pos1;
4004
-
4005
- // if(this.props.window.orgWidth){
4006
- // w.style.width=`${this.props.window.orgWidth}px`
4007
- // this.props.window.orgWidth=null
4008
- // }
4009
-
4010
4211
  this.y = this.y < -this.props.thick ? -this.props.thick : this.y;
4011
4212
  w.style.transition = 'unset';
4012
4213
  w.style.top = `${this.y}px`;
4013
4214
  w.style.left = `${this.x}px`;
4014
4215
  };
4015
4216
  preMove = e => {
4016
- console.clear();
4017
- po('preMove');
4018
4217
  const w = this.props.windowRef.current;
4019
4218
  const {
4020
4219
  clientX,
4021
4220
  clientY,
4022
4221
  ...oe
4023
4222
  } = e;
4024
- po('e', e);
4025
4223
  const {
4026
4224
  x,
4027
4225
  y,
4028
4226
  width,
4029
4227
  height
4030
4228
  } = w.getBoundingClientRect();
4031
- po('width', width);
4032
- if (y <= -this.props.thick) ;
4033
4229
  w.style.transition = 'left .05s ease-in, height .05s ease-in';
4034
4230
  if (y <= 0) {
4035
4231
  // contt browserWidth=
@@ -4052,7 +4248,6 @@ class TitleBar extends React__default["default"].Component {
4052
4248
  window.removeEventListener('mousemove', this.preMove);
4053
4249
  };
4054
4250
  start(e) {
4055
- po('start');
4056
4251
  e.preventDefault();
4057
4252
  this.moved = false;
4058
4253
  this.pos3 = e.clientX;
@@ -6076,7 +6271,7 @@ function JRAlertWindow({
6076
6271
  container,
6077
6272
  ...props
6078
6273
  }) {
6079
- const [open, setOpen] = React.useState(true);
6274
+ const [open, setOpen] = React$1.useState(true);
6080
6275
  return /*#__PURE__*/React__default["default"].createElement(StyledAlert, _extends({
6081
6276
  initValue: {
6082
6277
  message
@@ -6321,6 +6516,7 @@ exports.JRButton = JRButton;
6321
6516
  exports.JRCheckbox = JRCheckbox;
6322
6517
  exports.JRFields = JRFields;
6323
6518
  exports.JRFrame = JRFrame;
6519
+ exports.JRMask = JRMask;
6324
6520
  exports.JRRadio = JRRadio;
6325
6521
  exports.JRSelect = JRSelect;
6326
6522
  exports.JRSubmit = JRSubmit;
@@ -6328,3 +6524,5 @@ exports.JRTable = JRTable;
6328
6524
  exports.JRTestReact = JRTestReact;
6329
6525
  exports.JRText = JRText;
6330
6526
  exports.JRWindow = JRWindow;
6527
+ exports.random = random;
6528
+ exports.showMask = showMask;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jrs-react",
3
- "version": "1.2.19",
3
+ "version": "1.2.20",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.es.js",
@@ -23,6 +23,7 @@
23
23
  "axios": "^1.6.2",
24
24
  "create-react-class": "^15.7.0",
25
25
  "globals": "^15.15.0",
26
+ "jrs-js": "^0.0.0",
26
27
  "react": "^18.2.0",
27
28
  "react-dom": "^18.2.0",
28
29
  "react-router-dom": "^7.4.0",
package/src/app/App.css CHANGED
@@ -28,4 +28,15 @@ html,*,*:before,*:after {
28
28
  >div:not(:last-child){
29
29
  display: none;
30
30
  }
31
- }
31
+ }
32
+
33
+
34
+
35
+ Xdialog.jr-mask::backdrop {
36
+ background: #000c6e;
37
+ opacity: .3;
38
+ }
39
+
40
+ dialog:modal {
41
+ max-width: 100vw;
42
+ }
package/src/app/App.jsx CHANGED
@@ -8,10 +8,12 @@ import AlertApp from './alert/AlertApp'
8
8
  import { po } from '../components/JRUtils'
9
9
  import TestApp from './test'
10
10
  import InputApp from './input/InputApp'
11
+ import DevApp from './dev/devApp'
11
12
 
12
13
  function App() {
13
14
  const apps={
14
15
  TableApp,FieldsApp,WindowApp,AxiosApp,AlertApp,InputApp,TestApp
16
+ ,DevApp
15
17
  }
16
18
  return <BrowserRouter>
17
19
  {