jrs-react 1.2.18 → 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.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import * as React$1 from 'react';
2
2
  import React__default, { useState } from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { createRoot } from 'react-dom/client';
@@ -3269,36 +3269,197 @@ const whatType = ({
3269
3269
  return doElse;
3270
3270
  }
3271
3271
  };
3272
+ function random(max = 100, min = 0) {
3273
+ return Math.floor(Math.random() * (max + 1 - min)) + min;
3274
+ }
3272
3275
 
3273
- // import { IconSpinner } from '../assets/image';
3276
+ class JRHTML{
3277
+ isJRHTML=true
3278
+ _hijos=[]
3279
+ _padre
3280
+ _madre
3281
+ _yo
3282
+ constructor(params){
3283
+ var {yo,padre,madre,clases,personajes={},...params}=params;
3284
+ this.yo=yo;
3285
+ if(padre){
3286
+ this.padre=padre;
3287
+ this.madre=padre.yo;
3288
+ }else if(madre){
3289
+ this.madre=madre;
3290
+ }
3291
+ if(clases)personajes.class=clases.join(' ');
3292
+ params.personajes=personajes;
3293
+ Object.assign(this,params);
3294
+ this._init();
3295
+ }
3296
+ _init(){
3297
+
3298
+ }
3299
+ set style(styles){
3300
+ Object.entries(styles).forEach((style,i)=>{
3301
+ this._yo.style[style[0]]=style[1];
3302
+ });
3303
+ }
3304
+ set personajes(personajes){
3305
+ Object.entries(personajes).forEach(([personaje,valor])=>{
3306
+ this._yo.setAttribute(personaje,valor);
3307
+ });
3308
+ }
3309
+ agregarHijo(hijo){
3310
+ if(hijo.isJRHTML){
3311
+ hijo.padre=this;
3312
+ hijo.madre=this.yo;
3313
+ }else if(hijo.yo){
3314
+ hijo.padre=this;
3315
+ hijo= hijo.yo.name?new hijo.yo(hijo):new JRHTML(hijo);
3316
+ }else {
3317
+ this.yo.appendChild(document.createTextNode(hijo));
3318
+ }
3319
+ return hijo
3320
+ }
3321
+ set html(html){
3322
+ this._yo.innerHTML=html;
3323
+ }
3324
+ get html(){
3325
+ return this._yo.innerHTML
3326
+ }
3327
+ set hijos(hijos){
3328
+ hijos.forEach((hijo,i)=>{
3329
+ this.agregarHijo(hijo);
3330
+ });
3331
+ }
3332
+ get hijos(){
3333
+ return this._hijos
3334
+ }
3335
+ removeAllHijos(){
3336
+ this.hijos.forEach(hijo=>{
3337
+ hijo.yo.remove();
3338
+ });
3339
+ delete this.hijos;
3340
+ this.hijos=[];
3341
+ }
3342
+ removeHijo(hijo){
3343
+ var index=this.hijos.indexOf(hijo);
3344
+ if(index>=0){
3345
+ this.yo.removeChild(this.yo.childNodes[index]);
3346
+ this.hijos.splice(index, 1);
3347
+ }
3348
+ }
3349
+ nacido(yo){
3350
+ return document.createElement(yo)
3351
+ }
3352
+ set yo(yo){
3353
+ if(typeof yo === 'string' ){
3354
+ this._yo=this.nacido(yo);
3355
+ }else {
3356
+ this._yo=yo;
3357
+ }
3358
+ }
3359
+ get yo(){
3360
+ return this._yo
3361
+ }
3362
+ set padre(padre){
3363
+ this._padre=padre;
3364
+ if(this._padre)this._padre._hijos.push(this);
3365
+ }
3366
+ get padre(){
3367
+ return this._padre
3368
+ }
3369
+ set madre(madre){
3370
+ if(typeof madre === 'string' ){
3371
+ this._madre=document.getElementById(madre);
3372
+ }else {
3373
+ this._madre=madre;
3374
+ }
3375
+ if(this._madre&&this._yo)this._madre.appendChild(this._yo);
3376
+ }
3377
+ get madre(){
3378
+ return this._madre
3379
+ }
3380
+ set listeners(listeners){
3381
+ Object.entries(listeners).forEach(([event,func])=>{
3382
+ var me=this;
3383
+ if(event=='listeners'){
3384
+ this.listeners=func;
3385
+ }else {
3386
+ this._yo.addEventListener(event,function(e){
3387
+ func(e,me);
3388
+ },false);
3389
+ }
3390
+ });
3391
+ }
3392
+ get width(){
3393
+ return this._yo.clientWidth//offsetWidth
3394
+ }
3395
+ set width(width){
3396
+ this._yo.style.width=width;
3397
+ }
3398
+ get height(){
3399
+ return this._yo.clientHeight//offsetWidth
3400
+ }
3401
+ set height(height){
3402
+ this._yo.style.height=height;
3403
+ }
3404
+ set textContent(textContent){
3405
+ this._yo.textContent=textContent;
3406
+ }
3407
+ set color(color){
3408
+ this.yo.style.color=color;
3409
+ this._color=color;
3410
+ }
3411
+ get color(){
3412
+ return this._color
3413
+ }
3414
+ set visibility(visibility){
3415
+ this.yo.style.visibility=visibility;
3416
+ }
3417
+ set tip(tip){
3418
+ this.agregarHijo({
3419
+ yo:'span'
3420
+ ,clases:['tooltiptext']
3421
+ ,textContent:tip
3422
+ });
3423
+ }
3424
+ }
3425
+
3426
+ const StyledMask = styled.dialog`
3427
+ display:none;
3428
+ &:open{
3429
+ display:flex;
3430
+ }
3431
+
3432
+ &:modal {
3433
+ outline: 0;
3434
+ background: #000c6e77;
3435
+ }
3436
+
3437
+ #jr-mask-msg{
3438
+ padding: 10px;
3439
+ }
3440
+
3441
+ max-width: 100vw;
3442
+ max-height: 100vh;
3443
+
3444
+ width: 100vw;
3445
+ height: 100vh;
3446
+
3447
+ border:0;
3448
+ margin: 0;
3449
+ top: 0;
3450
+ left: 0;
3274
3451
 
3275
- styled.div`
3276
3452
  user-select: none;
3277
3453
  cursor: wait;
3278
- display: none;
3279
3454
  flex-direction: column;
3280
3455
  justify-content: center;
3281
3456
  align-items: center;
3282
3457
  position: fixed;
3283
- width: 100vw;
3284
- height: 100vh;
3285
- background-color: #000000aa;
3458
+
3286
3459
  z-index: 20000;
3287
- color: ${({
3288
- theme
3289
- }) => theme.colorPrimary};
3290
-
3291
- svg{
3292
- width: 80px;
3293
- height: 80px;
3294
- path, circle{
3295
- fill: ${({
3296
- theme
3297
- }) => theme.colorPrimary};
3298
- }
3299
- }
3460
+ overflow: hidden;
3300
3461
 
3301
- .cs-loader-inner {
3462
+ .cs-loader-inner {
3302
3463
  transform: translateY(-30%);
3303
3464
  width: calc(100% - 200xpx);
3304
3465
  }
@@ -3307,96 +3468,150 @@ styled.div`
3307
3468
  font-size: 20px;
3308
3469
  opacity: 0;
3309
3470
  display:inline-block;
3310
- color:${({
3311
- theme
3312
- }) => theme.colorPrimary};
3471
+ color:white;
3313
3472
  }
3314
3473
 
3315
- @keyframes lol {
3316
- 0% {
3317
- opacity: 0;
3318
- transform: translateX(-300px);
3319
- }
3320
- 33% {
3321
- opacity: 1;
3322
- transform: translateX(0px);
3323
- }
3324
- 66% {
3325
- opacity: 1;
3326
- transform: translateX(0px);
3327
- }
3328
- 100% {
3329
- opacity: 0;
3330
- transform: translateX(300px);
3331
- }
3332
- }
3474
+ @keyframes lol {
3475
+ 0% {
3476
+ opacity: 0;
3477
+ transform: translateX(-300px);
3478
+ }
3479
+ 33% {
3480
+ opacity: 1;
3481
+ transform: translateX(0px);
3482
+ }
3483
+ 66% {
3484
+ opacity: 1;
3485
+ transform: translateX(0px);
3486
+ }
3487
+ 100% {
3488
+ opacity: 0;
3489
+ transform: translateX(300px);
3490
+ }
3491
+ }
3333
3492
 
3334
- @-webkit-keyframes lol {
3335
- 0% {
3336
- opacity: 0;
3337
- -webkit-transform: translateX(-300px);
3338
- }
3339
- 33% {
3340
- opacity: 1;
3341
- -webkit-transform: translateX(0px);
3342
- }
3343
- 66% {
3344
- opacity: 1;
3345
- -webkit-transform: translateX(0px);
3346
- }
3347
- 100% {
3348
- opacity: 0;
3349
- -webkit-transform: translateX(300px);
3350
- }
3351
- }
3493
+ @-webkit-keyframes lol {
3494
+ 0% {
3495
+ opacity: 0;
3496
+ -webkit-transform: translateX(-300px);
3497
+ }
3498
+ 33% {
3499
+ opacity: 1;
3500
+ -webkit-transform: translateX(0px);
3501
+ }
3502
+ 66% {
3503
+ opacity: 1;
3504
+ -webkit-transform: translateX(0px);
3505
+ }
3506
+ 100% {
3507
+ opacity: 0;
3508
+ -webkit-transform: translateX(300px);
3509
+ }
3510
+ }
3352
3511
 
3353
- .cs-loader-inner label:nth-child(6) {
3354
- -webkit-animation: lol 3s infinite ease-in-out;
3355
- animation: lol 3s infinite ease-in-out;
3356
- }
3512
+ .cs-loader-inner label:nth-child(6) {
3513
+ -webkit-animation: lol 3s infinite ease-in-out;
3514
+ animation: lol 3s infinite ease-in-out;
3515
+ }
3357
3516
 
3358
- .cs-loader-inner label:nth-child(5) {
3359
- -webkit-animation: lol 3s 100ms infinite ease-in-out;
3360
- animation: lol 3s 100ms infinite ease-in-out;
3361
- }
3517
+ .cs-loader-inner label:nth-child(5) {
3518
+ -webkit-animation: lol 3s 100ms infinite ease-in-out;
3519
+ animation: lol 3s 100ms infinite ease-in-out;
3520
+ }
3362
3521
 
3363
- .cs-loader-inner label:nth-child(4) {
3364
- -webkit-animation: lol 3s 200ms infinite ease-in-out;
3365
- animation: lol 3s 200ms infinite ease-in-out;
3366
- }
3522
+ .cs-loader-inner label:nth-child(4) {
3523
+ -webkit-animation: lol 3s 200ms infinite ease-in-out;
3524
+ animation: lol 3s 200ms infinite ease-in-out;
3525
+ }
3367
3526
 
3368
- .cs-loader-inner label:nth-child(3) {
3369
- -webkit-animation: lol 3s 300ms infinite ease-in-out;
3370
- animation: lol 3s 300ms infinite ease-in-out;
3371
- }
3527
+ .cs-loader-inner label:nth-child(3) {
3528
+ -webkit-animation: lol 3s 300ms infinite ease-in-out;
3529
+ animation: lol 3s 300ms infinite ease-in-out;
3530
+ }
3372
3531
 
3373
- .cs-loader-inner label:nth-child(2) {
3374
- -webkit-animation: lol 3s 400ms infinite ease-in-out;
3375
- animation: lol 3s 400ms infinite ease-in-out;
3376
- }
3532
+ .cs-loader-inner label:nth-child(2) {
3533
+ -webkit-animation: lol 3s 400ms infinite ease-in-out;
3534
+ animation: lol 3s 400ms infinite ease-in-out;
3535
+ }
3377
3536
 
3378
- .cs-loader-inner label:nth-child(1) {
3379
- -webkit-animation: lol 3s 500ms infinite ease-in-out;
3380
- animation: lol 3s 500ms infinite ease-in-out;
3381
- }
3537
+ .cs-loader-inner label:nth-child(1) {
3538
+ -webkit-animation: lol 3s 500ms infinite ease-in-out;
3539
+ animation: lol 3s 500ms infinite ease-in-out;
3540
+ }
3382
3541
  `;
3383
- const displaySpinner = ({
3384
- mask
3385
- }) => {
3386
- const spin = document.getElementById("loadingBar");
3387
- const text = document.getElementById("loadingText");
3388
- if (spin == null) {
3389
- //alert("Spin or msgSpan is not initialized")
3390
- return;
3542
+ function JRMask({
3543
+ id = 'jr-mask'
3544
+ }) {
3545
+ return /*#__PURE__*/React.createElement(StyledMask, {
3546
+ id: id,
3547
+ className: 'jr-mask'
3548
+ }, /*#__PURE__*/React.createElement("div", {
3549
+ id: 'jr-mask-msg'
3550
+ }), /*#__PURE__*/React.createElement("div", {
3551
+ className: "cs-loader-inner"
3552
+ }, /*#__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")));
3553
+ }
3554
+ class Mask extends JRHTML {
3555
+ msg = [];
3556
+ #msgIndex = 0;
3557
+ #mask;
3558
+ get msgIndex() {
3559
+ return this.#msgIndex++;
3560
+ }
3561
+ addMsg(msg) {
3562
+ const index = this.msgIndex;
3563
+ this.msg.push({
3564
+ i: index,
3565
+ msg
3566
+ });
3567
+ this.renderMsg();
3568
+ return () => {
3569
+ po('remove function', index);
3570
+ this.removeMsg(index);
3571
+ };
3391
3572
  }
3392
- if (mask) {
3393
- spin.style.display = "flex";
3394
- text.innerText = mask;
3395
- } else {
3396
- spin.style.display = "none";
3397
- text.innerText = '';
3573
+ removeMsg(index) {
3574
+ this.msg = this.msg.filter(r => r.i != index);
3575
+ this.renderMsg();
3398
3576
  }
3399
- };
3577
+ renderMsg() {
3578
+ this.msgDiv.removeAllHijos();
3579
+ if (this.msg.length) {
3580
+ this.msgDiv.agregarHijo(new JRHTML({
3581
+ yo: 'div',
3582
+ textContent: this.msg[this.msg.length - 1].msg
3583
+ }));
3584
+ if (!this.yo.open) {
3585
+ this.yo.showModal();
3586
+ }
3587
+ } else {
3588
+ this.yo.close();
3589
+ }
3590
+ }
3591
+ get msg() {
3592
+ return 'msg';
3593
+ }
3594
+ }
3595
+ function showMask(msg, maskTarget, whichMask) {
3596
+ const jrMask = document.getElementById('jr-mask');
3597
+ const jrMaskMsg = document.getElementById('jr-mask-msg');
3598
+ if (!jrMask.maskDiv) {
3599
+ jrMask.maskDiv = new Mask({
3600
+ yo: jrMask,
3601
+ msgDiv: new JRHTML({
3602
+ yo: jrMaskMsg
3603
+ }),
3604
+ listeners: {
3605
+ keydown(e) {
3606
+ if (e.key === 'Escape') {
3607
+ e.preventDefault();
3608
+ }
3609
+ }
3610
+ }
3611
+ });
3612
+ }
3613
+ return jrMask.maskDiv.addMsg(msg);
3614
+ }
3400
3615
 
3401
3616
  const axiosSubmit = axios$1.create({
3402
3617
  authorization: `Bearer ${localStorage.getItem("accessToken")}`,
@@ -3593,13 +3808,10 @@ class JRSubmit extends React__default.Component {
3593
3808
  po('reload 還沒有做 ');
3594
3809
  }
3595
3810
  submit(config) {
3596
- const me = this;
3597
- displaySpinner({
3598
- mask: config.mask
3599
- });
3600
- this.setState({
3601
- loading: true
3602
- });
3811
+ // const me=this
3812
+ // displaySpinner({mask:config.mask})
3813
+ // this.setState({loading:true})//拿掉可能會有問題, 先觀察看看
3814
+ if (config.mask) config.removeMaskFunction = showMask(config.mask);
3603
3815
  let _payload;
3604
3816
  (() => {
3605
3817
  if (Array.isArray(config.url)) {
@@ -3634,13 +3846,12 @@ class JRSubmit extends React__default.Component {
3634
3846
  this.handleResponse(res, _payload, config);
3635
3847
  }).catch(res => {
3636
3848
  this.handleResponse(res, _payload, config);
3637
- }).finally(function (a, b, c) {
3638
- me.setState({
3639
- loading: false
3640
- });
3641
- displaySpinner({
3642
- mask: false
3643
- });
3849
+ }).finally(() => {
3850
+ // this.setState({loading:false})
3851
+ // displaySpinner({mask:false})
3852
+ // setTimeout(()=>{
3853
+ config.removeMaskFunction?.();
3854
+ // },random(4000,1000))
3644
3855
  });
3645
3856
  }
3646
3857
  handleResponse = (response, payload, config) => {
@@ -3782,7 +3993,7 @@ class JRFrame extends JRSubmit {
3782
3993
  var _path;
3783
3994
  function _extends$1() { return _extends$1 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$1.apply(null, arguments); }
3784
3995
  var SvgX = function SvgX(props) {
3785
- return /*#__PURE__*/React.createElement("svg", _extends$1({
3996
+ return /*#__PURE__*/React$1.createElement("svg", _extends$1({
3786
3997
  xmlns: "http://www.w3.org/2000/svg",
3787
3998
  width: 24,
3788
3999
  height: 24,
@@ -3792,7 +4003,7 @@ var SvgX = function SvgX(props) {
3792
4003
  strokeLinejoin: "round",
3793
4004
  strokeWidth: 2,
3794
4005
  viewBox: "0 0 24 24"
3795
- }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
4006
+ }, props), _path || (_path = /*#__PURE__*/React$1.createElement("path", {
3796
4007
  d: "M18 6 6 18M6 6l12 12"
3797
4008
  })));
3798
4009
  };
@@ -3913,7 +4124,6 @@ class TitleBar extends React__default.Component {
3913
4124
  }
3914
4125
  };
3915
4126
  floatScreen = e => {
3916
- po('floatScreen');
3917
4127
  this.props.windowRef.current;
3918
4128
  this.props.windowRef.current.style.transition = 'var(--transition-x-y), left .05s ease-in';
3919
4129
  this.props.windowRef.current.style.left = `${this.props.window.orgLeft}px`;
@@ -3923,7 +4133,6 @@ class TitleBar extends React__default.Component {
3923
4133
  document.body.style.overflow = this.props.window.orgBodyOverflow;
3924
4134
  };
3925
4135
  fullScreen = e => {
3926
- po('fullScreen', this.props.thick);
3927
4136
  this.props.windowRef.current.style.transition = 'var(--transition-x-y), left .05s ease-in';
3928
4137
  this.props.windowRef.current.style.left = `${-this.props.thick}px`;
3929
4138
  this.props.windowRef.current.style.top = `${-this.props.thick}px`;
@@ -3936,7 +4145,6 @@ class TitleBar extends React__default.Component {
3936
4145
  }, 50);
3937
4146
  };
3938
4147
  stop = e => {
3939
- po('stop');
3940
4148
  e.preventDefault();
3941
4149
  if (this.moved) {
3942
4150
  const {
@@ -3959,7 +4167,6 @@ class TitleBar extends React__default.Component {
3959
4167
  window.removeEventListener('mousemove', this.preMove);
3960
4168
  };
3961
4169
  move = e => {
3962
- po('move');
3963
4170
  e.preventDefault();
3964
4171
  this.moved = true;
3965
4172
  const {
@@ -3974,35 +4181,24 @@ class TitleBar extends React__default.Component {
3974
4181
  const w = this.props.windowRef.current;
3975
4182
  this.y = w.offsetTop - this.pos2;
3976
4183
  this.x = w.offsetLeft - this.pos1;
3977
-
3978
- // if(this.props.window.orgWidth){
3979
- // w.style.width=`${this.props.window.orgWidth}px`
3980
- // this.props.window.orgWidth=null
3981
- // }
3982
-
3983
4184
  this.y = this.y < -this.props.thick ? -this.props.thick : this.y;
3984
4185
  w.style.transition = 'unset';
3985
4186
  w.style.top = `${this.y}px`;
3986
4187
  w.style.left = `${this.x}px`;
3987
4188
  };
3988
4189
  preMove = e => {
3989
- console.clear();
3990
- po('preMove');
3991
4190
  const w = this.props.windowRef.current;
3992
4191
  const {
3993
4192
  clientX,
3994
4193
  clientY,
3995
4194
  ...oe
3996
4195
  } = e;
3997
- po('e', e);
3998
4196
  const {
3999
4197
  x,
4000
4198
  y,
4001
4199
  width,
4002
4200
  height
4003
4201
  } = w.getBoundingClientRect();
4004
- po('width', width);
4005
- if (y <= -this.props.thick) ;
4006
4202
  w.style.transition = 'left .05s ease-in, height .05s ease-in';
4007
4203
  if (y <= 0) {
4008
4204
  // contt browserWidth=
@@ -4025,7 +4221,6 @@ class TitleBar extends React__default.Component {
4025
4221
  window.removeEventListener('mousemove', this.preMove);
4026
4222
  };
4027
4223
  start(e) {
4028
- po('start');
4029
4224
  e.preventDefault();
4030
4225
  this.moved = false;
4031
4226
  this.pos3 = e.clientX;
@@ -6197,8 +6392,8 @@ const StyledPick = styled.div`
6197
6392
  >label{
6198
6393
  white-space: nowrap;
6199
6394
  display: inline-flex;
6200
- align-items: baseline;
6201
- height: 30px;
6395
+ align-items: center;
6396
+ height: 24px;
6202
6397
  padding-right: 12px;
6203
6398
  }
6204
6399
  `;
@@ -6289,4 +6484,4 @@ class JRText extends JRInput {
6289
6484
  }
6290
6485
  }
6291
6486
 
6292
- export { JRAlert, JRButton, JRCheckbox, JRFields, JRFrame, JRRadio, JRSelect, JRSubmit, JRTable, JRTestReact, JRText, JRWindow };
6487
+ export { JRAlert, JRButton, JRCheckbox, JRFields, JRFrame, JRMask, JRRadio, JRSelect, JRSubmit, JRTable, JRTestReact, JRText, JRWindow, random, showMask };