jrs-react 1.2.13 → 1.2.14

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.
Files changed (39) hide show
  1. package/build/index.es.js +1015 -727
  2. package/build/index.js +1015 -727
  3. package/index.html +2 -2
  4. package/package.json +3 -2
  5. package/public/alert.json +4 -0
  6. package/public/data.json +10 -0
  7. package/public/data2.json +19 -0
  8. package/public/list.json +99 -0
  9. package/src/app/App.css +25 -3
  10. package/src/app/App.jsx +22 -1
  11. package/src/app/alert/AlertApp.jsx +92 -0
  12. package/src/app/axios/AxiosApp.jsx +71 -0
  13. package/src/app/fields/FieldsApp.jsx +22 -6
  14. package/src/app/fields/fieldsConfig.jsx +227 -1
  15. package/src/app/fields/tryHOC.jsx +21 -0
  16. package/src/app/fields/validator.jsx +217 -0
  17. package/src/app/index.css +1 -1
  18. package/src/app/table/tableConfig.jsx +4 -1
  19. package/src/app/test/index.jsx +8 -0
  20. package/src/app/window/WindowApp.jsx +120 -83
  21. package/src/components/JRAlert/index.jsx +71 -0
  22. package/src/components/JRFields/JRFields.jsx +178 -129
  23. package/src/components/JRFields/StyleJRFields.jsx +2 -3
  24. package/src/components/JRFields/Validators.jsx +33 -0
  25. package/src/components/JRFrame/JRFrame.jsx +12 -7
  26. package/src/components/JRFrame/JRFrameHOC.jsx +61 -0
  27. package/src/components/JRInput/JRInput.jsx +3 -2
  28. package/src/components/JRS.jsx +4 -0
  29. package/src/components/JRSubmit.jsx +1 -3
  30. package/src/components/JRTable/JRTable.jsx +10 -7
  31. package/src/components/JRTable/StyledJRTable.jsx +8 -0
  32. package/src/components/JRTable/THead.jsx +1 -1
  33. package/src/components/JRWindow/JRWindow.jsx +73 -15
  34. package/src/components/JRWindow/JRWindowHOC.jsx +114 -0
  35. package/src/components/JRWindow/Slider.jsx +8 -3
  36. package/src/components/JRWindow/Style.module.css +35 -0
  37. package/src/components/JRWindow/TitleBar.jsx +116 -33
  38. package/src/main.jsx +2 -1
  39. package/src/components/JRUtil.jsx +0 -1
package/build/index.es.js CHANGED
@@ -3475,7 +3475,7 @@ class JRSubmit extends React__default.Component {
3475
3475
  }
3476
3476
  setRawValue(rawValue) {
3477
3477
  this.setState({
3478
- rawValue: JSON.parse(JSON.stringify(rawValue ?? ''))
3478
+ rawValue: rawValue != null ? JSON.parse(JSON.stringify(rawValue)) : null
3479
3479
  });
3480
3480
  }
3481
3481
  reset() {
@@ -3483,8 +3483,6 @@ class JRSubmit extends React__default.Component {
3483
3483
  }
3484
3484
  setValue(value, reset = false) {
3485
3485
  if (this.props.onChange) {
3486
- po('name', this.props.name);
3487
- po('onChange', value);
3488
3486
  this.props.onChange(value);
3489
3487
  } else {
3490
3488
  this.setState({
@@ -3708,7 +3706,7 @@ const StyledJRFrame$1 = styled.div`
3708
3706
  >main{
3709
3707
  display:flex;
3710
3708
  flex:1;
3711
- overflow:overlay;
3709
+ overflow:hidden;
3712
3710
  flex-direction: column;
3713
3711
  > *{
3714
3712
  XXborder:1px solid gray;
@@ -3723,6 +3721,13 @@ const StyledJRFrame$1 = styled.div`
3723
3721
  display:flex;
3724
3722
  flex:1;
3725
3723
  overflow:hidden;
3724
+
3725
+ >main{
3726
+ display:flex;
3727
+ flex:1;
3728
+ overflow: overlay;
3729
+ }
3730
+
3726
3731
  }
3727
3732
  >footer{
3728
3733
  XXborder:1px solid blue;
@@ -3730,11 +3735,11 @@ const StyledJRFrame$1 = styled.div`
3730
3735
  }
3731
3736
 
3732
3737
  }
3733
-
3734
3738
  `;
3735
3739
  class JRFrame extends JRSubmit {
3736
3740
  renderer() {
3737
3741
  return /*#__PURE__*/React__default.createElement(StyledJRFrame$1, {
3742
+ id: this.props.id,
3738
3743
  style: this.props.style,
3739
3744
  className: `${this.props.className} jr-frame`
3740
3745
  }, /*#__PURE__*/React__default.createElement(FreeType$1, {
@@ -3751,7 +3756,9 @@ class JRFrame extends JRSubmit {
3751
3756
  config: this.props.left,
3752
3757
  me: this,
3753
3758
  className: 'left'
3754
- }), this.renderMe?.() ?? this.props.children, /*#__PURE__*/React__default.createElement(FreeType$1, {
3759
+ }), /*#__PURE__*/React__default.createElement("main", {
3760
+ className: 'body'
3761
+ }, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default.createElement(FreeType$1, {
3755
3762
  tag: "div",
3756
3763
  config: this.props.right,
3757
3764
  me: this,
@@ -3767,9 +3774,6 @@ class JRFrame extends JRSubmit {
3767
3774
  className: 'end'
3768
3775
  }));
3769
3776
  }
3770
- // renderMe(){
3771
- // return <div style={{flex:1}}>Render me</div>
3772
- // }
3773
3777
  }
3774
3778
 
3775
3779
  const StyledSlider$1 = styled.div`
@@ -3881,7 +3885,7 @@ const Ths$1 = ({
3881
3885
  ref: thRef,
3882
3886
  colSpan: column.colSpan,
3883
3887
  rowSpan: column.rowSpan ?? (column.isLeaf && deep > rowIndex ? deep - rowIndex + 1 : null)
3884
- }, flexType(column.label, table), table.props.resizableColumns === true && /*#__PURE__*/React__default.createElement(Slider$1, {
3888
+ }, flexType(column.label, table), (table.props.resizableColumns === undefined || table.props.resizableColumns) && /*#__PURE__*/React__default.createElement(Slider$1, {
3885
3889
  table: table,
3886
3890
  thRef: thRef,
3887
3891
  column: column
@@ -4367,7 +4371,15 @@ const StyledJRTable = styled.div`
4367
4371
  display:flex;
4368
4372
  justify-content: center;
4369
4373
  align-items: center;
4374
+
4375
+
4370
4376
  }
4377
+
4378
+ > .empty::after{
4379
+ content:'無資料';
4380
+ position: block;
4381
+ }
4382
+
4371
4383
  `;
4372
4384
 
4373
4385
  var _path;
@@ -4400,9 +4412,12 @@ const StyledTitle = styled.div`
4400
4412
  overflow: hidden;
4401
4413
  display: flex;
4402
4414
  border-radius: var(--jr-window-radius) var(--jr-window-radius) 0 0;
4403
- background:rgb(214, 214, 214);
4404
- color: black;
4405
- &:active:hover{
4415
+ background:#464646;
4416
+ color: white;
4417
+ display: flex;
4418
+ align-items: center;
4419
+ min-height: min-content;
4420
+ XX&:active{
4406
4421
  cursor: grabbing;
4407
4422
  }
4408
4423
 
@@ -4426,6 +4441,7 @@ const StyledTitle = styled.div`
4426
4441
 
4427
4442
 
4428
4443
  >button{
4444
+ outline: unset;
4429
4445
  display:flex;
4430
4446
  align-items: center;
4431
4447
  justify-content: center;
@@ -4442,10 +4458,11 @@ const StyledTitle = styled.div`
4442
4458
  color:white;
4443
4459
  }
4444
4460
  >svg{
4445
- color:black;
4461
+ color:#bababa;
4446
4462
  width:14px;
4447
4463
  height:14px;
4448
4464
  cursor: pointer;
4465
+ stroke-width: 3;
4449
4466
  }
4450
4467
  }
4451
4468
  >button.danger:hover{
@@ -4463,13 +4480,68 @@ class TitleBar extends React__default.Component {
4463
4480
  pos4 = 0;
4464
4481
  x = 0;
4465
4482
  y = 0;
4483
+ remember = e => {
4484
+ po('remember');
4485
+ const {
4486
+ clientX,
4487
+ clientY
4488
+ } = e;
4489
+ const {
4490
+ x,
4491
+ y,
4492
+ width,
4493
+ height
4494
+ } = this.props.windowRef.current.getBoundingClientRect();
4495
+ this.props.window.orgHeight = height;
4496
+ this.props.window.orgWidth = width;
4497
+ this.props.window.orgTop = y;
4498
+ this.props.window.orgLeft = x;
4499
+ this.props.window.orgXd = clientX - x;
4500
+ this.props.window.orgBodyOverflow = document.body.style.overflow;
4501
+ };
4502
+ adjustScreen = e => {
4503
+ po('double click adjustScreen');
4504
+ e.preventDefault();
4505
+ const {
4506
+ x,
4507
+ y,
4508
+ width,
4509
+ height
4510
+ } = this.props.windowRef.current.getBoundingClientRect();
4511
+ if (y > 1 - this.props.thick) {
4512
+ this.remember(e);
4513
+ this.fullScreen(e);
4514
+ } else {
4515
+ this.floatScreen(e);
4516
+ }
4517
+ };
4518
+ floatScreen = e => {
4519
+ po('floatScreen');
4520
+ this.props.windowRef.current;
4521
+ this.props.windowRef.current.style.transition = 'var(--transition-x-y), left .05s ease-in';
4522
+ this.props.windowRef.current.style.left = `${this.props.window.orgLeft}px`;
4523
+ this.props.windowRef.current.style.top = `${this.props.window.orgTop}px`;
4524
+ this.props.windowRef.current.style.width = `${this.props.window.orgWidth}px`;
4525
+ this.props.windowRef.current.style.height = `${this.props.window.orgHeight}px`;
4526
+ document.body.style.overflow = this.props.window.orgBodyOverflow;
4527
+ };
4528
+ fullScreen = e => {
4529
+ po('fullScreen', this.props.thick);
4530
+ this.props.windowRef.current.style.transition = 'var(--transition-x-y), left .05s ease-in';
4531
+ this.props.windowRef.current.style.left = `${-this.props.thick}px`;
4532
+ this.props.windowRef.current.style.top = `${-this.props.thick}px`;
4533
+ this.props.windowRef.current.style.width = `calc(100vw + ${this.props.thick * 2}px)`; //`${window.innerWidth+(this.props.thick*2)}px`
4534
+ this.props.windowRef.current.style.height = `calc(100vh + ${this.props.thick * 2}px)`; //`${window.innerHeight+(this.props.thick*2)}px`
4535
+
4536
+ setTimeout(() => {
4537
+ document.body.style.overflow = 'hidden';
4538
+ this.props.windowRef.current.style.transition = 'unset';
4539
+ }, 50);
4540
+ };
4466
4541
  stop = e => {
4542
+ po('stop');
4467
4543
  e.preventDefault();
4468
4544
  if (this.moved) {
4469
- const {
4470
- clientX,
4471
- clientY
4472
- } = e;
4473
4545
  const {
4474
4546
  height: titleBarHeight
4475
4547
  } = this.props.titleBarRef.current.getBoundingClientRect();
@@ -4479,26 +4551,18 @@ class TitleBar extends React__default.Component {
4479
4551
  width,
4480
4552
  height
4481
4553
  } = this.props.windowRef.current.getBoundingClientRect();
4482
- if (y < 1) {
4483
- this.props.windowRef.current.style.transition = 'var(--transition-x-y), left .1s ease-in';
4484
- this.props.windowRef.current.style.left = `${-this.props.thick}px`;
4485
- this.props.windowRef.current.style.width = `calc(100vw + ${this.props.thick * 2}px)`; //`${window.innerWidth+(this.props.thick*2)}px`
4486
- this.props.windowRef.current.style.height = `calc(100vh + ${this.props.thick * 2}px)`; //`${window.innerHeight+(this.props.thick*2)}px`
4487
-
4488
- this.props.window.orgHeight = height;
4489
- this.props.window.orgWidth = width;
4490
- this.props.window.orgXd = clientX - x;
4491
- }
4492
- if (y > window.innerHeight) this.props.windowRef.current.style.top = `${window.innerHeight - titleBarHeight}px`;
4554
+ if (y < 1 - this.props.thick) this.fullScreen(e);
4555
+ if (y > window.innerHeight - titleBarHeight) this.props.windowRef.current.style.top = `${window.innerHeight - titleBarHeight}px`;
4493
4556
  if (x + width - this.props.thick < 0) this.props.windowRef.current.style.left = 0;
4494
4557
  if (x > window.innerWidth) this.props.windowRef.current.style.left = `${window.innerWidth - width}px`;
4495
- document.body.style.cursor = 'default';
4496
4558
  }
4559
+ document.body.style.cursor = 'default';
4497
4560
  window.removeEventListener('mousemove', this.move);
4498
4561
  window.removeEventListener('mouseup', this.stop);
4499
4562
  window.removeEventListener('mousemove', this.preMove);
4500
4563
  };
4501
4564
  move = e => {
4565
+ po('move');
4502
4566
  e.preventDefault();
4503
4567
  this.moved = true;
4504
4568
  const {
@@ -4513,55 +4577,77 @@ class TitleBar extends React__default.Component {
4513
4577
  const w = this.props.windowRef.current;
4514
4578
  this.y = w.offsetTop - this.pos2;
4515
4579
  this.x = w.offsetLeft - this.pos1;
4516
- if (this.props.window.orgWidth) {
4517
- if (clientX > this.props.window.orgWidth) {
4518
- this.x = clientX - this.props.window.orgWidth / 2;
4519
- }
4520
- w.style.width = `${this.props.window.orgWidth}px`;
4521
- this.props.window.orgWidth = null;
4522
- }
4580
+
4581
+ // if(this.props.window.orgWidth){
4582
+ // w.style.width=`${this.props.window.orgWidth}px`
4583
+ // this.props.window.orgWidth=null
4584
+ // }
4585
+
4523
4586
  this.y = this.y < -this.props.thick ? -this.props.thick : this.y;
4524
4587
  w.style.transition = 'unset';
4525
4588
  w.style.top = `${this.y}px`;
4526
4589
  w.style.left = `${this.x}px`;
4527
4590
  };
4528
4591
  preMove = e => {
4592
+ console.clear();
4593
+ po('preMove');
4529
4594
  const w = this.props.windowRef.current;
4530
4595
  const {
4531
4596
  clientX,
4532
- clientY
4597
+ clientY,
4598
+ ...oe
4533
4599
  } = e;
4534
- if (this.props.window.orgXd) {
4535
- w.style.left = `${clientX - this.props.window.orgXd}px`;
4536
- this.props.window.orgXd = null;
4537
- }
4538
- if (this.props.window.orgHeight) {
4600
+ po('e', e);
4601
+ const {
4602
+ x,
4603
+ y,
4604
+ width,
4605
+ height
4606
+ } = w.getBoundingClientRect();
4607
+ po('width', width);
4608
+ if (y <= -this.props.thick) ;
4609
+ w.style.transition = 'left .05s ease-in, height .05s ease-in';
4610
+ if (y <= 0) {
4611
+ // contt browserWidth=
4612
+ const w1 = window.innerWidth - this.props.thick * 2;
4613
+ const x1 = clientX;
4614
+ const w2 = this.props.window.orgWidth - 32;
4615
+ const x2 = x1 / w1 * w2;
4616
+ // po('xp' , x2)
4617
+ w.style.left = `${clientX - x2}px`;
4618
+ w.style.width = `${this.props.window.orgWidth}px`;
4539
4619
  w.style.height = `${this.props.window.orgHeight}px`;
4540
- this.props.window.orgHeight = null;
4620
+ } else {
4621
+ this.remember(e);
4541
4622
  }
4542
- w.style.transition = 'left .1s ease-in, height .1s ease-in';
4623
+ document.body.style.cursor = 'grabbing';
4624
+ document.body.style.overflow = this.props.window.orgBodyOverflow;
4543
4625
  setTimeout(() => {
4544
4626
  window.addEventListener('mousemove', this.move);
4545
- }, 100);
4627
+ }, 50);
4546
4628
  window.removeEventListener('mousemove', this.preMove);
4547
4629
  };
4548
4630
  start(e) {
4631
+ po('start');
4549
4632
  e.preventDefault();
4550
4633
  this.moved = false;
4551
4634
  this.pos3 = e.clientX;
4552
4635
  this.pos4 = e.clientY;
4553
4636
  this.props.windowRef.current.style.transition = 'var(--transition-x-y)';
4554
- document.body.style.cursor = 'grabbing';
4555
4637
  window.addEventListener('mousemove', this.preMove);
4556
4638
  window.addEventListener('mouseup', this.stop);
4557
4639
  }
4640
+ onDoubleClick() {
4641
+ po('onDoubleClick');
4642
+ }
4558
4643
  render() {
4559
4644
  return /*#__PURE__*/React__default.createElement(StyledTitle, {
4560
4645
  ref: this.props.titleBarRef,
4561
4646
  draggable: "false",
4562
4647
  onMouseDown: e => {
4563
4648
  this.start(e);
4564
- }
4649
+ },
4650
+ onDoubleClick: this.adjustScreen
4565
4651
  }, /*#__PURE__*/React__default.createElement(FreeType$1, {
4566
4652
  tag: "div",
4567
4653
  config: this.props.title ?? '',
@@ -4570,8 +4656,15 @@ class TitleBar extends React__default.Component {
4570
4656
  }), /*#__PURE__*/React__default.createElement("nav", null, this.props.window.props.setOpen ? /*#__PURE__*/React__default.createElement(JRButton, {
4571
4657
  icon: /*#__PURE__*/React__default.createElement(SvgX, null),
4572
4658
  className: 'danger',
4573
- onClick: () => {
4659
+ onClick: e => {
4660
+ e.stopPropagation();
4661
+ if (this.props.window.orgBodyOverflow != null) {
4662
+ document.body.style.overflow = this.props.window.orgBodyOverflow;
4663
+ }
4574
4664
  this.props.window.props.setOpen(false);
4665
+ },
4666
+ onMouseDown: e => {
4667
+ e.stopPropagation();
4575
4668
  }
4576
4669
  }) : null));
4577
4670
  }
@@ -4918,9 +5011,11 @@ class Slider extends React__default.Component {
4918
5011
  });
4919
5012
  };
4920
5013
  preMove = () => {
4921
- this.props.windowRef.current.style.height = `${this.props.window.orgHeight}px`;
4922
- this.data.height = this.props.window.orgHeight;
4923
- this.props.window.orgHeight = null;
5014
+ if (this.props.direction.indexOf('n') > -1) {
5015
+ this.props.windowRef.current.style.height = `${this.props.window.orgHeight}px`;
5016
+ this.data.height = this.props.window.orgHeight;
5017
+ this.props.window.orgHeight = null;
5018
+ }
4924
5019
  window.removeEventListener('mousemove', this.preMove);
4925
5020
  setTimeout(() => {
4926
5021
  window.addEventListener('mousemove', this.move);
@@ -4937,6 +5032,9 @@ class Slider extends React__default.Component {
4937
5032
  width,
4938
5033
  height
4939
5034
  } = this.props.windowRef.current.getBoundingClientRect();
5035
+ if (this.props.direction.indexOf('s') > -1) {
5036
+ this.props.window.orgHeight = null;
5037
+ }
4940
5038
  this.data = {
4941
5039
  x,
4942
5040
  y,
@@ -4964,770 +5062,960 @@ class Slider extends React__default.Component {
4964
5062
  }
4965
5063
  }
4966
5064
 
4967
- const StyledJRWindow = styled.div`
4968
- --jr-window-radius:3px;
4969
- --padding-child:8px;
4970
- --transition-x-y:height .1s ease-in, width .1s ease-in;
4971
- xborder:1px solid gray;
4972
- position: fixed;
4973
- padding: ${({
4974
- $thick
4975
- }) => $thick}px;
4976
- border-radius: var(--jr-window-radius);
4977
-
4978
- top: ${({
4979
- $y
4980
- }) => $y}px;
4981
- left: ${({
4982
- $x
4983
- }) => $x}px;
4984
- width: ${({
4985
- $width = 300
4986
- }) => `${$width}px`};
4987
- height: ${({
4988
- $height = 300
4989
- }) => `${$height}px`};
4990
- overflow: hidden;
5065
+ const StyleJRFields = styled.main`
5066
+ --column-bd-color:#cccccc;
5067
+ --column-b-color:unset;
5068
+ --column-b-hover-color:#ffffff;
4991
5069
 
4992
- display: flex;
4993
5070
  flex-direction: column;
4994
- overflow: hidden;
5071
+ flex:1;
5072
+ overflow: overlay;
4995
5073
 
4996
- > main{
4997
- border-radius: var(--jr-window-radius);
4998
- box-shadow: 0px 0px 5px 1px gray;
4999
- Xbackground: white;
5000
- display: flex;
5001
- flex-direction: column;
5002
- overflow: hidden;
5003
- flex:1;
5004
- > main {
5005
- background: white;
5006
- Xpadding:var(--padding-child);
5007
- overflow: overlay;
5008
- flex:1;
5009
- display: flex;
5010
- }
5011
- }
5012
-
5013
- @container (min-width: 700px) {
5014
- &{
5015
- border: 1px solid red;
5074
+ color:#525252;
5075
+
5076
+ >.jr-grid{
5077
+ padding: 10px;
5078
+ .jr-column{
5079
+ > .label{
5080
+ color:#525252;
5081
+ text-wrap: nowrap;
5082
+ font-weight: bold;
5083
+ }
5084
+ > .jr-column-value{
5016
5085
  }
5086
+ }
5017
5087
  }
5018
5088
  `;
5019
- class JRWindow extends JRFrame {
5020
- x = 0;
5021
- y = 0;
5022
- width = 300;
5023
- height = 300;
5024
- padding = 1;
5025
- thick = 5;
5026
- constructor(props) {
5027
- super(props);
5028
- this.ref = /*#__PURE__*/React__default.createRef();
5029
- this.titleBarRef = /*#__PURE__*/React__default.createRef();
5030
- this.init();
5031
- }
5032
- componentWillUpdate(prevProps, prevState, snapshot) {
5033
- if (this.props.popup === true && this.props.open === true && prevProps.open === false) {
5034
- this.props.onOpen?.bind(this)();
5089
+
5090
+ function required(value) {
5091
+ return value == null || value == '' || value.trim?.() == '' ? 'This is required' : true;
5092
+ }
5093
+ function max(value, colum) {
5094
+ return value == null ? true : typeof value === 'string' && value.length > colum.max ? `Length can not more than ${colum.max}` : Array.isArray(value) && value.length > colum.max ? `Length can not more than ${colum.max}` : typeof value === 'number' && value > colum.max ? `Length can not more than ${colum.max}` : true;
5095
+ }
5096
+ function min(value, colum) {
5097
+ return value = typeof value === 'string' && colum.min > value.length ? `Length can not less than ${colum.min}` : Array.isArray(value) && colum.min > value.length ? `Length can not less than ${colum.min}` : typeof value === 'number' && colum.min > value ? `Can not less than ${colum.min}` : true;
5098
+ }
5099
+
5100
+ // import JRSubmit from "../JRSubmit";
5101
+ // import { JRWindowHOC } from "../JRWindow/JRWindowHOC";
5102
+ // import { JRFrameHOC } from "../JRFrame/JRFrameHOC";
5103
+
5104
+ function checkMap(_name, inputValue, mapValue, nameList) {
5105
+ if (nameList.length) {
5106
+ const name = nameList.shift();
5107
+ if (typeof mapValue[name] != 'object') {
5108
+ mapValue[name] = {};
5035
5109
  }
5036
- }
5037
- init() {
5038
- this.height = window.innerHeight >= (this.props.height ?? this.height) ? this.props.height ?? this.height : window.innerHeight;
5039
- this.width = window.innerWidth >= (this.props.width ?? this.width) ? this.props.width ?? this.width : window.innerWidth;
5040
- this.x = this.props.x ?? (window.innerWidth - (this.width ?? 300)) / 2;
5041
- this.y = this.props.y ?? (window.innerHeight - (this.height ?? 300)) / 2;
5042
- }
5043
- renderer() {
5044
- return this.props.popup === true ? this.props.open === true ? /*#__PURE__*/React__default.createElement(StyledJRWindow, {
5045
- ref: this.ref,
5046
- className: `jr-window ${this.props.className ?? ''}`,
5047
- $x: this.x,
5048
- $y: this.y,
5049
- $width: this.width,
5050
- $height: this.height,
5051
- $thick: this.thick
5052
- }, /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(TitleBar, {
5053
- titleBarRef: this.titleBarRef,
5054
- windowRef: this.ref,
5055
- window: this,
5056
- title: this.props.title,
5057
- thick: this.thick
5058
- }), /*#__PURE__*/React__default.createElement("main", null, super.renderer())), /*#__PURE__*/React__default.createElement(Sliders, {
5059
- thick: this.thick,
5060
- windowRef: this.ref,
5061
- window: this,
5062
- titleBarRef: this.titleBarRef
5063
- })) : '' : super.renderer();
5110
+ checkMap(_name, inputValue, mapValue[name], nameList);
5111
+ } else {
5112
+ mapValue[_name] = inputValue;
5064
5113
  }
5065
5114
  }
5115
+ styled.div`
5116
+ overflow: auto;
5117
+ flex:1;
5118
+ `;
5119
+ const StyledGrid = styled.div`
5120
+ display: grid;
5121
+ grid: ${({
5122
+ grid,
5123
+ cols,
5124
+ children
5125
+ }) => grid ? grid : `auto / ${Array(cols ?? 1).fill().map(() => "1fr").join(" ")}`};
5066
5126
 
5067
- const getMapObject = (map, names) => {
5068
- const name = names.shift(names);
5069
- if (names.length) {
5070
- return getMapObject(map?.[name], names);
5127
+ gap: ${({
5128
+ $gap
5129
+ }) => $gap};
5130
+ `;
5131
+ styled.div`
5132
+ `;
5133
+ const StyledColumn = styled.div`
5134
+ flex:1;
5135
+ display: grid;
5136
+
5137
+ ${({
5138
+ $layout,
5139
+ $labelWidth,
5140
+ $hasLabel,
5141
+ $valueWidth
5142
+ }) => {
5143
+ if ($layout == 'v') {
5144
+ return `grid: auto 1fr / 1fr;`;
5071
5145
  } else {
5072
- return map;
5146
+ return `grid: 1fr / ${$hasLabel ? $labelWidth : ''} ${$valueWidth};`;
5073
5147
  }
5074
- };
5075
- const setMapObject = (map, names, value) => {
5076
- const name = names.shift(names);
5077
- if (names?.length) {
5078
- if (typeof map[name] != 'object') {
5079
- map[name] = {};
5080
- }
5081
- setMapObject(map[name], names, value);
5148
+ }}
5149
+ `;
5150
+ const StyledColumnLabel = styled.div`
5151
+ ${({
5152
+ $layout
5153
+ }) => {
5154
+ if ($layout == 'v') {
5155
+ return `text-align: start;`;
5082
5156
  } else {
5083
- map[name] = value;
5084
- }
5085
- };
5086
- class JRTable extends JRWindow {
5087
- constructor(props) {
5088
- super(props);
5089
- this.colGroupRef = /*#__PURE__*/React__default.createRef();
5090
- }
5091
- UNSAFE_componentWillMount() {
5092
- this.setColumns(this.props.columns ?? []);
5157
+ return `text-align: end;
5158
+ padding: 3px 8px;
5159
+ `;
5093
5160
  }
5161
+ }}
5094
5162
 
5095
- //------------------------------------------------------------------------------------
5096
- getChecked() {
5097
- return [1, 2, 3, 4];
5163
+ ${({
5164
+ $required
5165
+ }) => {
5166
+ if ($required !== undefined && $required) return `
5167
+ &:not(:empty)::before{
5168
+ padding-right:4px;
5169
+ color:red;
5170
+ content:'*';
5171
+ }
5172
+ `;
5173
+ }}
5174
+
5175
+ ${({
5176
+ $colon
5177
+ }) => {
5178
+ if ($colon) {
5179
+ return `
5180
+ &:not(:empty)::after{
5181
+ content:'${$colon}';
5182
+ }
5183
+ `;
5098
5184
  }
5099
- checkableColumn(props) {
5100
- return {
5101
- //方法1
5102
- render({
5103
- value,
5104
- onChange
5105
- }) {
5106
- return /*#__PURE__*/React__default.createElement("checkbox", {
5107
- checked: value,
5108
- onChange: e => {
5109
- onChange(e.target.checked);
5110
- }
5111
- });
5112
- },
5113
- align: 'center',
5114
- name: 'checked',
5115
- ...props
5116
- };
5117
- // return {//方法2
5118
- // type:Checkbox
5119
- // ,funcProps({value}){
5120
- // po('fffffffffffff',value)
5121
- // return {
5122
- // align:'center'
5123
- // ,checked:value
5124
- // }
5125
- // }
5126
- // // ,label:'A'
5127
- // ,onChange(e,{value,onChange,me}){
5128
- // onChange(e.target.checked)
5129
- // }
5130
- // ,...props
5131
- // }
5185
+ }}
5186
+
5187
+ `;
5188
+ const StyledColumnValue = styled.main`
5189
+ flex:1;
5190
+ flex-direction: column;
5191
+ overflow: hidden;
5192
+ padding: 4px 0;
5193
+
5194
+ text-align: start;
5195
+ ${({
5196
+ $validateValue
5197
+ }) => {
5198
+ if ($validateValue != null) {
5199
+ return `
5200
+ > * {
5201
+ xborder:1px solid red;
5202
+ }
5203
+ `;
5132
5204
  }
5133
- deletableColumn({
5134
- name = 'deletable',
5135
- sendValue,
5136
- sendName,
5137
- valueName,
5138
- ...props
5139
- }) {
5140
- return {
5141
- render({
5142
- value,
5143
- onChange
5144
- }) {
5145
- return /*#__PURE__*/React__default.createElement("checkbox", {
5146
- checked: value,
5147
- onChange: e => {
5148
- onChange(e.target.checked);
5149
- }
5150
- });
5151
- },
5152
- align: 'center',
5153
- name,
5154
- label() {
5155
- return /*#__PURE__*/React__default.createElement("button", {
5156
- onClick: () => {
5157
- const value = this.props.delete.value ?? this.getDataSource()?.filter(record => record[name]).map(record => sendValue ? record[sendValue] : record);
5158
- const callback = this.props.delete.callback ?? function (a, b, c) {
5159
- this.reload();
5160
- };
5161
- this.delete({
5162
- value: sendName ? {
5163
- [sendName]: value
5164
- } : value,
5165
- callback,
5166
- ...props
5167
- });
5168
- }
5169
- }, "\u522A\u9664");
5170
- },
5171
- ...props
5172
- };
5205
+ }}
5206
+ `;
5207
+ const StyledColumnFooter = styled.div`
5208
+ &:has(.left:empty):has(.right:empty)
5209
+ {
5210
+ border:1px solid blue;
5211
+ display: none;
5212
+ }
5213
+
5214
+ ${({
5215
+ $layout
5216
+ }) => {
5217
+ if ($layout == 'v') {
5218
+ return ``;
5219
+ } else {
5220
+ return `grid-column-start:2;`;
5173
5221
  }
5174
- initColumn(column, level, result, leafColumns, names, lastColSpan) {
5175
- const isBranch = column.type === undefined && column?.columns && column?.columns.length;
5176
- const _names = column.name ? [...names, column.name] : names;
5177
- if (isBranch) {
5178
- if (column.label !== null) result[level].push(column);
5179
- const c = this.initColumns(column.columns, level + (column.label !== null ? 1 : 0) + (column.rowSpan != null ? column.rowSpan - 1 : 0), result, leafColumns, _names, lastColSpan);
5180
- column.colSpan = c.colSpan;
5181
- column.columnNo = lastColSpan;
5182
- return {
5183
- colSpan: column.colSpan
5184
- };
5185
- } else {
5186
- column.columnNo = lastColSpan;
5187
- result[level].push({
5188
- ...column,
5189
- isLeaf: true
5222
+ }}
5223
+ height:25px;
5224
+ color:#ff6060;
5225
+
5226
+ display: flex;
5227
+ justify-content: space-between;
5228
+
5229
+ .left:{
5230
+ xflex:1;
5231
+ }
5232
+ .right{
5233
+ color:gray;
5234
+ xflex:1;
5235
+ }
5236
+ `;
5237
+ class JRFields extends JRWindow {
5238
+ UNSAFE_componentWillMount() {
5239
+ this.#initValidatorValue();
5240
+ }
5241
+ reset() {
5242
+ this.clearTestValue();
5243
+ super.reset();
5244
+ }
5245
+ setValue(value, reset) {
5246
+ super.setValue(value, reset);
5247
+ if (reset) {
5248
+ this.clearTestValue();
5249
+ }
5250
+ }
5251
+ //Validate-----------------------------------------------------------------------------------
5252
+ #initValidatorValue() {
5253
+ if (this.validateValueFrom == 'state') {
5254
+ this.setState({
5255
+ validatorValue: {}
5190
5256
  });
5191
- leafColumns.push(column);
5192
- column.names = _names;
5193
- if (_names?.length > 1) {
5194
- column.setValue = function (record, value) {
5195
- try {
5196
- getMapObject(record, [..._names])[column.name] = value;
5197
- } catch {
5198
- setMapObject(record, [..._names], value);
5257
+ }
5258
+ }
5259
+ get testValueFrom() {
5260
+ return this.props.testValue === undefined ? 'state' : 'props';
5261
+ }
5262
+ clearTestValue() {
5263
+ this.setTestValue({});
5264
+ }
5265
+ setTestValue(testValue, name) {
5266
+ if (this.testValueFrom == 'state') {
5267
+ if (name) {
5268
+ const newTestValue = this.getTestValue();
5269
+ newTestValue[name] = testValue;
5270
+ this.setState({
5271
+ testValue: {
5272
+ ...this.getTestValue(),
5273
+ ...testValue
5199
5274
  }
5200
- };
5201
- column.getValue = function (record) {
5202
- return _names.reduce((acc, name) => {
5203
- return acc?.[name];
5204
- }, record);
5205
- };
5275
+ });
5206
5276
  } else {
5207
- column.setValue = function (record, value) {
5208
- record[column.name] = value;
5209
- };
5210
- column.getValue = function (record) {
5211
- return record[column.name];
5212
- };
5277
+ this.setState({
5278
+ testValue
5279
+ });
5213
5280
  }
5214
- return {
5215
- colSpan: 1
5281
+ }
5282
+ }
5283
+ getTestValue(fullname) {
5284
+ if (fullname) {
5285
+ return this.state?.testValue?.[fullname];
5286
+ } else {
5287
+ return this.state?.testValue;
5288
+ }
5289
+ }
5290
+ #validateField(column, fullNameArray, testValue, value) {
5291
+ const {
5292
+ name,
5293
+ validators: _validators,
5294
+ columns,
5295
+ type
5296
+ } = column;
5297
+ const fullName = fullNameArray.join('.');
5298
+ const validators = _validators ? [..._validators] : [];
5299
+ if (column.required) {
5300
+ validators.push(required);
5301
+ }
5302
+ if (column.max) {
5303
+ validators.push(max);
5304
+ }
5305
+ if (column.min) {
5306
+ validators.push(min);
5307
+ }
5308
+ if (validators.length) {
5309
+ testValue[fullName] = {
5310
+ isValid: null,
5311
+ msg: []
5216
5312
  };
5313
+ const promises = [];
5314
+ for (let i = 0; i < validators.length; i++) {
5315
+ const validator = validators[i].bind(this)(value, column);
5316
+ if (validator?.then) {
5317
+ promises.push(validator);
5318
+ } else if (typeof validator == 'string') {
5319
+ promises.push(Promise.reject(validator));
5320
+ break;
5321
+ }
5322
+ }
5323
+ return Promise.all(promises).then(reason => {
5324
+ testValue[fullName].isValid = true;
5325
+ return Promise.resolve(reason);
5326
+ }).catch(reason => {
5327
+ testValue[fullName].msg.push(reason);
5328
+ testValue[fullName].isValid = false;
5329
+ return Promise.reject(reason);
5330
+ });
5331
+ }
5332
+ }
5333
+ #validators(_columns, validators, names, testValue, value) {
5334
+ return _columns?.reduce((aco, column) => {
5335
+ const {
5336
+ name,
5337
+ validators,
5338
+ columns,
5339
+ type
5340
+ } = column;
5341
+ const fullNameArray = name ? [...names, name] : names;
5342
+ fullNameArray.join('.');
5343
+ {
5344
+ // 要的 if(this.getTestValue(fullName)?.isValid==null){//執行過的不再執行
5345
+ const validate = this.#validateField(column, fullNameArray, testValue, name ? value?.[name] : value);
5346
+ if (validate) {
5347
+ aco.push(validate);
5348
+ }
5349
+ }
5350
+ if (columns && type == undefined) {
5351
+ this.#validators(columns, aco, fullNameArray, testValue, name ? value?.[name] : value);
5352
+ }
5353
+ return aco;
5354
+ }, validators);
5355
+ }
5356
+ validate(value) {
5357
+ console.clear();
5358
+ const validators = [];
5359
+ const testValue = this.getTestValue() ?? {};
5360
+ this.#validators(this.getColumns(), validators, [], testValue, value !== undefined ? value : this.getValue());
5361
+ return Promise.all(validators).then(msg => {
5362
+ this.setTestValue(testValue);
5363
+ return Promise.resolve();
5364
+ }).catch(msg => {
5365
+ this.setTestValue(testValue);
5366
+ return Promise.reject();
5367
+ });
5368
+ }
5369
+
5370
+ //--------------------------------------------------------------------------------------
5371
+ get columnsFrom() {
5372
+ return this.props.initColumns !== undefined ? 'state' : 'props';
5373
+ }
5374
+ getColumns() {
5375
+ return this[this.columnsFrom]?.columns;
5376
+ }
5377
+ //-------------------------------------------------------------------------------------------
5378
+
5379
+ createColumn(parentValue, {
5380
+ type,
5381
+ name,
5382
+ colSpan,
5383
+ rowSpan,
5384
+ style,
5385
+ typeStyle: _typeStyle,
5386
+ columnStyle,
5387
+ ...column
5388
+ }, index, parentName, fullnameArray, labelProps) {
5389
+ const value = name ? parentValue?.[name] : parentValue;
5390
+ const gap = column.gap ?? this.props.gap;
5391
+ const label = column.label;
5392
+ const _style = flexType(style, this, {}, {});
5393
+ const _columnStyle = flexType(columnStyle, this, {}, {});
5394
+ if (colSpan) _style.gridColumn = `span ${colSpan}`;
5395
+ if (rowSpan) _style.gridRow = `span ${rowSpan}`;
5396
+ let content;
5397
+ const onChange = inputValue => {
5398
+ const targetValue = inputValue?.target?.value ?? inputValue;
5399
+ try {
5400
+ parentValue[name] = targetValue;
5401
+ this.setValue({
5402
+ ...this.getValue()
5403
+ });
5404
+ } catch (e) {
5405
+ const _value = this.getValue() ?? {};
5406
+ checkMap(name, targetValue, _value, [...parentName]);
5407
+ this.setValue(_value);
5408
+ }
5409
+ const testValue = this.getTestValue() ?? {};
5410
+ this.#validateField(column, fullnameArray, testValue, targetValue)?.then(() => {
5411
+ this.setTestValue(testValue);
5412
+ }).catch(() => {
5413
+ this.setTestValue(testValue);
5414
+ });
5415
+ };
5416
+ const _parentName = [...parentName];
5417
+ if (name !== undefined) {
5418
+ _parentName.push(name);
5419
+ }
5420
+ if (type) {
5421
+ const typeStyle = flexType(_typeStyle, this, null);
5422
+ content = /*#__PURE__*/React__default.createElement(StyledColumnValue, {
5423
+ className: 'jr-column-value',
5424
+ style: {
5425
+ gridColumn: label == null ? 'span 2' : null,
5426
+ ..._columnStyle
5427
+ }
5428
+ }, /*#__PURE__*/React__default.createElement(type, {
5429
+ value: value,
5430
+ onChange,
5431
+ record: parentValue,
5432
+ style: {
5433
+ width: '100%',
5434
+ ...typeStyle
5435
+ },
5436
+ ...column
5437
+ }));
5438
+ } else if (column.columns) {
5439
+ content = /*#__PURE__*/React__default.createElement(StyledGrid, {
5440
+ cols: column.cols,
5441
+ className: 'jr-grid',
5442
+ $gap: gap,
5443
+ style: _columnStyle
5444
+ }, this.createColumns(value, column.columns, _parentName, fullnameArray, column.labelProps ?? this.props.labelProps));
5445
+ } else if (name || column.render) {
5446
+ content = /*#__PURE__*/React__default.createElement(StyledColumnValue, {
5447
+ className: 'jr-column-value',
5448
+ style: {
5449
+ gridColumn: label == null ? 'span 2' : null,
5450
+ padding: column.render ? '4px 0' : null
5451
+ }
5452
+ }, column.render ? column.render.bind(this)({
5453
+ onChange,
5454
+ value: value,
5455
+ record: this.getValue()
5456
+ }) : typeof value === 'object' ? JSON.stringify(value) : value);
5217
5457
  }
5458
+ const layout = labelProps?.layout;
5459
+ const colon = labelProps?.colon === undefined ? ':' : labelProps.colon;
5460
+ const labelStyle = column.labelProps?.style ?? this.props.labelProps?.style ?? {};
5461
+ return /*#__PURE__*/React__default.createElement(StyledColumn, {
5462
+ $layout: layout,
5463
+ $hasLabel: label != null,
5464
+ key: `f${index}`,
5465
+ style: _style,
5466
+ className: 'jr-column',
5467
+ $labelWidth: column.labelProps?.width ?? this.props.labelProps?.width ?? '120px',
5468
+ $valueWidth: column.valueProps?.width ?? this.props.valueProps?.width ?? '1fr'
5469
+ }, label != null && /*#__PURE__*/React__default.createElement(StyledColumnLabel, {
5470
+ style: labelStyle,
5471
+ $required: column.required,
5472
+ className: 'label',
5473
+ $layout: layout,
5474
+ $colon: colon
5475
+ }, label), content, /*#__PURE__*/React__default.createElement(StyledColumnFooter, {
5476
+ $layout: layout
5477
+ }, /*#__PURE__*/React__default.createElement("div", {
5478
+ className: "left"
5479
+ }, this.getTestValue(_parentName.join('.'))?.msg?.map(msg => {
5480
+ return msg;
5481
+ })), /*#__PURE__*/React__default.createElement("div", {
5482
+ className: "right"
5483
+ })));
5218
5484
  }
5219
- initColumns(columns, level, result, leafColumns, names, lastColSpan) {
5220
- for (let i = result.length; i <= level; i++) {
5221
- if (!result[i]) {
5222
- result.push([]);
5223
- }
5224
- }
5225
- let _lastColSpan = lastColSpan;
5226
- const childrenLength = columns?.reduce((acc, column) => {
5227
- const c = this.initColumn(column, level, result, leafColumns, names, _lastColSpan);
5228
- acc.colSpan += c.colSpan;
5229
- _lastColSpan += c.colSpan;
5230
- return acc;
5231
- }, {
5232
- colSpan: 0
5485
+ createColumns(parentValue, columns, parentName, fullname, labelProps) {
5486
+ return columns?.map((column, index) => {
5487
+ return this.createColumn(parentValue, column, index, parentName, column.name ? [...fullname, column.name] : fullname, labelProps);
5233
5488
  });
5234
- return childrenLength;
5235
5489
  }
5236
- setColumns([..._columns]) {
5237
- if (this.props.checkable) _columns.unshift(this.checkableColumn(this.props.checkable));
5238
- if (this.props.deletable) {
5239
- _columns.unshift(this.deletableColumn(this.props.deletable));
5490
+ renderMe() {
5491
+ return /*#__PURE__*/React__default.createElement(StyleJRFields, {
5492
+ className: 'jr-fields',
5493
+ style: this.props.typeStyle
5494
+ }, /*#__PURE__*/React__default.createElement(StyledGrid, {
5495
+ cols: this.props.cols,
5496
+ style: this.props.gridStyle,
5497
+ className: 'jr-grid',
5498
+ $gap: this.props.gap
5499
+ }, this.createColumns(this.props.dataSourceName ? this.getValue()?.[this.props.dataSourceName] : this.getValue(), this.props.columns, this.props.dataSourceName ? [this.props.dataSourceName] : [], this.props.dataSourceName ? [this.props.dataSourceName] : [], this.props.labelProps)));
5500
+ }
5501
+ }
5502
+
5503
+ // export const FFields=JRFrameHOC(JRFields)
5504
+ // export const WFields=JRWindowHOC(FFields)
5505
+
5506
+ const StyledInput = styled.div`
5507
+ display:flex;
5508
+ input:focus{
5509
+ outline: none;
5240
5510
  }
5241
- const columns = [];
5242
- const leafColumns = [];
5243
- this.initColumns(_columns, 0, columns, leafColumns, [], 0);
5244
- // po('initColumns',initColumns)
5245
- this.setState({
5246
- columns,
5247
- leafColumns
5248
- });
5511
+ `;
5512
+ class JRInput extends React__default.Component {
5513
+ setValue(value) {
5514
+ this.props?.onChange?.(value);
5249
5515
  }
5250
- //------------------------------------------------------------------------------------
5251
- setDataSource(dataSource) {}
5252
- getDataSource() {
5253
- return this.props.dataSourceName ? this.getValue()?.[this.props.dataSourceName] : this.getValue();
5516
+ render() {
5517
+ return /*#__PURE__*/React__default.createElement(StyledInput, null, this.input());
5254
5518
  }
5255
- add(record, index = this.getDataSource()?.length ?? 0, group) {
5256
- //group 還沒有考慮到
5519
+ }
5257
5520
 
5258
- if (this.getDataSource()) {
5259
- if (group === undefined) {
5260
- this.getDataSource().splice(index, 0, record); //.push(record)
5261
- } else {
5262
- this.getDataSource()[group].splice(index, 0, record); //.push(record)
5263
- }
5264
- this.setValue(this.getValue());
5521
+ function styleInject(css, ref) {
5522
+ if ( ref === void 0 ) ref = {};
5523
+ var insertAt = ref.insertAt;
5524
+
5525
+ if (!css || typeof document === 'undefined') { return; }
5526
+
5527
+ var head = document.head || document.getElementsByTagName('head')[0];
5528
+ var style = document.createElement('style');
5529
+ style.type = 'text/css';
5530
+
5531
+ if (insertAt === 'top') {
5532
+ if (head.firstChild) {
5533
+ head.insertBefore(style, head.firstChild);
5265
5534
  } else {
5266
- //未完成. 沒有資料的時候, 要考慮有或沒有dataSourceName的不同處理
5267
- this.setValue({
5268
- [this.props.dataSourceName]: [record]
5269
- });
5535
+ head.appendChild(style);
5270
5536
  }
5537
+ } else {
5538
+ head.appendChild(style);
5271
5539
  }
5272
- noData() {
5273
- const data = this.getDataSource();
5274
- return data == null || data.length == 0;
5275
- }
5276
- //------------------------------------------------------------------------------------
5277
- renderMe() {
5278
- return /*#__PURE__*/React__default.createElement(StyledJRTable, {
5279
- className: `${this.props.className ?? ''} jr-table ${this.props.onRowClick ? 'row-highlightable' : ''}`
5280
- }, /*#__PURE__*/React__default.createElement("table", {
5281
- className: 'jr-table-table'
5282
- }, /*#__PURE__*/React__default.createElement(TBodies, {
5283
- table: this,
5284
- leafColumns: this.state.leafColumns,
5285
- groupHeader: this.props.groupHeader,
5286
- groupFooter: this.props.groupFooter,
5287
- dataSource: this.getDataSource(),
5288
- onRowClick: this.props.onRowClick
5289
- }), /*#__PURE__*/React__default.createElement(TFoot, {
5290
- columns: this.props.footColumns,
5291
- table: this
5292
- }), /*#__PURE__*/React__default.createElement(THead, {
5293
- columns: this.state.columns,
5294
- leafColumns: this.state.leafColumns,
5295
- table: this
5296
- })), /*#__PURE__*/React__default.createElement("div", {
5297
- className: 'empty'
5298
- }, this.noData() && '無資料'));
5540
+
5541
+ if (style.styleSheet) {
5542
+ style.styleSheet.cssText = css;
5543
+ } else {
5544
+ style.appendChild(document.createTextNode(css));
5299
5545
  }
5300
5546
  }
5301
5547
 
5302
- const StyleJRFields = styled.main`
5303
- --column-bd-color:#cccccc;
5304
- --column-b-color:unset;
5305
- --column-b-hover-color:#ffffff;
5548
+ var css_248z = ".Style-module_test__LrdEc{border:1px solid red;color:red}.Style-module_withMask__LPcai{overflow:hidden!important;position:relative;user-select:none;&:after{a:#868686cc;background:#868686cc;border-radius:inherit;bottom:0;content:\"\";height:10000px;left:0;position:absolute;right:0;top:0;width:10000px}}mask{background:#868686cc;border-radius:inherit;bottom:0;height:10000px;left:0;position:absolute;right:0;top:0;width:10000px}";
5549
+ var style = {"test":"Style-module_test__LrdEc","withMask":"Style-module_withMask__LPcai"};
5550
+ styleInject(css_248z);
5551
+
5552
+ const StyledJRWindow = styled.div`
5553
+ --jr-window-radius:3px;
5554
+ --padding-child:8px;
5555
+ --transition-x-y:height .05s ease-in, width .05s ease-in;
5556
+ xborder:1px solid gray;
5557
+ position: fixed;
5558
+ padding: ${({
5559
+ $thick
5560
+ }) => $thick}px;
5561
+ border-radius: var(--jr-window-radius);
5562
+ user-select: text;
5563
+
5564
+ top: ${({
5565
+ $y
5566
+ }) => $y}px;
5567
+ left: ${({
5568
+ $x
5569
+ }) => $x}px;
5570
+ width: ${({
5571
+ $width = 300
5572
+ }) => `${$width}px`};
5573
+ height: ${({
5574
+ $height = 300
5575
+ }) => `${$height}px`};
5576
+ overflow: hidden;
5577
+ z-index: 2;
5306
5578
 
5579
+ display: flex;
5307
5580
  flex-direction: column;
5308
- flex:1;
5309
- overflow: overlay;
5310
- padding: 10px;
5581
+ overflow: hidden;
5311
5582
 
5312
- color:#525252;
5313
-
5314
- >.jr-grid{
5315
- .jr-column{
5316
- > .label{
5317
- color:#525252;
5318
- text-wrap: nowrap;
5319
- padding: 3px 8px;
5320
- font-weight: bold;
5321
- }
5322
- > .jr-column-value{
5323
- }
5583
+ > main{
5584
+ border-radius: var(--jr-window-radius);
5585
+ box-shadow: 0px 0px 5px 1px gray;
5586
+ display: flex;
5587
+ flex-direction: column;
5588
+ overflow: hidden;
5589
+ flex:1;
5590
+ > main {
5591
+ Xpadding:var(--padding-child);
5592
+ overflow: overlay;
5593
+ flex:1;
5594
+ display: flex;
5595
+ min-height:32px;
5324
5596
  }
5325
5597
  }
5598
+
5326
5599
  `;
5600
+ class JRWindow extends JRFrame {
5601
+ x = 0;
5602
+ y = 0;
5603
+ width = 300;
5604
+ height = 300;
5605
+ padding = 1;
5606
+ thick = 5;
5607
+ constructor(props) {
5608
+ super(props);
5609
+ this.ref = /*#__PURE__*/React__default.createRef();
5610
+ this.titleBarRef = /*#__PURE__*/React__default.createRef();
5611
+ this.init();
5612
+ }
5613
+ addMaskToTarget = target => {
5614
+ this.mask = document.createElement('div');
5615
+ this.mask.style.background = '#868686cc';
5616
+ this.mask.style.position = 'absolute';
5617
+ this.mask.style.top = '0';
5618
+ this.mask.style.left = '0';
5619
+ this.mask.style.right = '0';
5620
+ this.mask.style.bottom = '0';
5621
+ this.mask.style.borderRadius = 'inherit';
5622
+ this.mask.style.height = '10000px';
5623
+ this.mask.style.width = '10000px';
5624
+ target.appendChild(this.mask);
5625
+ po('style.mask', style.mask);
5626
+ po('addMask+++++++++++++++++++++++++++');
5627
+ };
5628
+ removeMaskFromTarget = () => {
5629
+ po('removeMask-----------------------');
5630
+ this.mask.remove();
5631
+ };
5632
+ maskOnTarget(on) {
5633
+ po('typeof this.props.maskOn', typeof this.props.maskOn);
5634
+ const target = typeof this.props.maskOn === 'object' ? this.props.maskOn : typeof this.props.maskOn === 'string' ? document.getElementById(this.props.maskOn) : document.body;
5327
5635
 
5328
- function checkMap(_name, inputValue, mapValue, nameList) {
5329
- if (nameList.length) {
5330
- const name = nameList.shift();
5331
- if (typeof mapValue[name] != 'object') {
5332
- mapValue[name] = {};
5636
+ // this[on?'addMaskToTarget':'removeMaskFromTarget'](target)
5637
+ target?.classList[on ? 'add' : 'remove']('withMask');
5638
+ }
5639
+ componentDidMount() {
5640
+ super.componentDidMount();
5641
+ if (this.props.maskOn && this.props.open) {
5642
+ this.maskOnTarget(this.props.open);
5643
+ }
5644
+ if (this.props.open) {
5645
+ this.open();
5333
5646
  }
5334
- checkMap(_name, inputValue, mapValue[name], nameList);
5335
- } else {
5336
- mapValue[_name] = inputValue;
5337
5647
  }
5338
- }
5339
- styled.div`
5340
- overflow: auto;
5341
- flex:1;
5342
- `;
5343
- const StyledGrid = styled.div`
5344
- display: grid;
5345
- grid: ${({
5346
- grid,
5347
- cols,
5348
- children
5349
- }) => grid ? grid : `auto / ${Array(cols ?? 1).fill().map(() => "1fr").join(" ")}`};
5648
+ open() {
5649
+ this.props.onOpen?.bind(this)();
5650
+ }
5651
+ close() {
5652
+ this.props.onClose?.bind(this)();
5653
+ }
5654
+ componentDidUpdate(prevProps, prevState, snapshot) {
5655
+ if (this.props.popup === true) {
5656
+ if (this.props.open && prevProps.open === false) {
5657
+ this.open();
5658
+ } else if (this.props.open === false && prevProps.open) {
5659
+ this.close();
5660
+ }
5661
+ if (this.props.maskOn && this.props.open != prevProps.open) {
5662
+ this.maskOnTarget(this.props.open);
5663
+ }
5664
+ }
5665
+ }
5666
+ init() {
5667
+ this.height = window.innerHeight >= (this.props.height ?? this.height) ? this.props.height ?? this.height : window.innerHeight;
5668
+ this.width = window.innerWidth >= (this.props.width ?? this.width) ? this.props.width ?? this.width : window.innerWidth;
5669
+ this.x = this.props.x ?? (window.innerWidth - (this.width ?? 300)) / 2;
5670
+ this.y = this.props.y ?? (window.innerHeight - (this.height ?? 300)) / 2;
5671
+ }
5672
+ renderer() {
5673
+ return this.props.popup === true ? this.props.open ? /*#__PURE__*/React__default.createElement(StyledJRWindow, {
5674
+ ref: this.ref,
5675
+ className: `jr-window ${this.props.className ?? ''}`,
5676
+ $x: this.x,
5677
+ $y: this.y,
5678
+ $width: this.width,
5679
+ $height: this.height,
5680
+ $thick: this.thick
5681
+ }, /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(TitleBar, {
5682
+ titleBarRef: this.titleBarRef,
5683
+ windowRef: this.ref,
5684
+ window: this,
5685
+ title: this.props.title,
5686
+ thick: this.thick
5687
+ }), /*#__PURE__*/React__default.createElement("main", null, super.renderer())), /*#__PURE__*/React__default.createElement(Sliders, {
5688
+ thick: this.thick,
5689
+ windowRef: this.ref,
5690
+ window: this,
5691
+ titleBarRef: this.titleBarRef
5692
+ })) : '' : super.renderer();
5693
+ }
5694
+ }
5350
5695
 
5351
- gap: ${({
5352
- $gap
5353
- }) => $gap};
5354
- `;
5355
5696
  styled.div`
5356
- `;
5357
- const StyledColumn = styled.div`
5697
+ display:flex;
5358
5698
  flex:1;
5359
- display: grid;
5699
+ overflow:hidden;
5360
5700
 
5361
- ${({
5362
- $layout,
5363
- $labelWidth,
5364
- $hasLabel,
5365
- $valueWidth
5366
- }) => {
5367
- if ($layout == 'v') {
5368
- return `grid: auto 1fr / 1fr;`;
5369
- } else {
5370
- return `grid: 1fr / ${$hasLabel ? $labelWidth : ''} ${$valueWidth};`;
5371
- }
5372
- }}
5373
- `;
5374
- const StyledColumnLabel = styled.div`
5375
- ${({
5376
- $layout
5377
- }) => {
5378
- if ($layout == 'v') {
5379
- return `text-align: start;`;
5380
- } else {
5381
- return `text-align: end;`;
5382
- }
5383
- }}
5701
+ > *{
5702
+ Xborder:1px solid gray;
5703
+ }
5704
+ >main{
5705
+ display:flex;
5706
+ flex:1;
5707
+ overflow:overlay;
5708
+ flex-direction: column;
5709
+ > *{
5710
+ XXborder:1px solid gray;
5711
+ XXmin-height:30px;
5712
+ }
5384
5713
 
5385
- ${({
5386
- $required
5387
- }) => {
5388
- if ($required !== undefined && $required) return `
5389
- &:not(:empty)::before{
5390
- padding-right:4px;
5391
- color:red;
5392
- content:'*';
5393
- }
5394
- `;
5395
- }}
5714
+ >header{
5715
+ XXborder:1px solid red;
5716
+ XXoverflow: overlay;
5717
+ }
5718
+ >main{
5719
+ display:flex;
5720
+ flex:1;
5721
+ overflow:hidden;
5722
+ }
5723
+ >footer{
5724
+ XXborder:1px solid blue;
5725
+ overflow: overlay;
5726
+ }
5396
5727
 
5397
- ${({
5398
- $colon
5399
- }) => {
5400
- if ($colon) {
5401
- return `
5402
- &:not(:empty)::after{
5403
- content:'${$colon}';
5404
- }
5405
- `;
5406
- }
5407
- }}
5728
+ }
5408
5729
 
5409
5730
  `;
5410
- const StyledColumnValue = styled.main`
5411
- flex:1;
5412
- Xdisplay:flex;
5731
+
5732
+ styled.div`
5733
+ --jr-window-radius:3px;
5734
+ --padding-child:8px;
5735
+ --transition-x-y:height .05s ease-in, width .05s ease-in;
5736
+ xborder:1px solid gray;
5737
+ position: fixed;
5738
+ padding: ${({
5739
+ $thick
5740
+ }) => $thick}px;
5741
+ border-radius: var(--jr-window-radius);
5742
+
5743
+ top: ${({
5744
+ $y
5745
+ }) => $y}px;
5746
+ left: ${({
5747
+ $x
5748
+ }) => $x}px;
5749
+ width: ${({
5750
+ $width = 300
5751
+ }) => `${$width}px`};
5752
+ height: ${({
5753
+ $height = 300
5754
+ }) => `${$height}px`};
5755
+ overflow: hidden;
5756
+
5757
+ display: flex;
5413
5758
  flex-direction: column;
5414
5759
  overflow: hidden;
5760
+
5761
+ > main{
5762
+ border-radius: var(--jr-window-radius);
5763
+ box-shadow: 0px 0px 5px 1px gray;
5764
+ Xbackground: white;
5765
+ display: flex;
5766
+ flex-direction: column;
5767
+ overflow: hidden;
5768
+ flex:1;
5769
+ > main {
5770
+ background: white;
5771
+ Xpadding:var(--padding-child);
5772
+ overflow: overlay;
5773
+ flex:1;
5774
+ display: flex;
5775
+ }
5776
+ }
5415
5777
 
5416
- text-align: start;
5417
- ${({
5418
- $validateValue
5419
- }) => {
5420
- if ($validateValue != null) {
5421
- return `
5422
- > * {
5423
- xborder:1px solid red;
5424
- }
5425
- `;
5426
- }
5427
- }}
5778
+ @container (min-width: 700px) {
5779
+ &{
5780
+ border: 1px solid red;
5781
+ }
5782
+ }
5428
5783
  `;
5429
5784
 
5430
- // String.prototype.valueString = function (value = {}) {
5431
- // return Array.from(new Set(this.match(/[^{}]+(?=})/g))).reduce((aco, name) => {
5432
- // return aco.replace(new RegExp(`\\{${name}\\}`, "g"), value[name] ?? `{${name}}`);
5433
- // }, String(this));
5434
- // };
5435
-
5436
- const valueString = (str = '', value = {}) => {
5437
- return Array.from(new Set(str.match(/[^{}]+(?=})/g))).reduce((aco, name) => {
5438
- return aco.replace(new RegExp(`\\{${name}\\}`, "g"), value?.[name] ?? `{${name}}`);
5439
- }, String(str));
5440
- };
5441
- const ColumnMessage = ({
5442
- value = {},
5443
- record
5444
- }) => {
5445
- if (value.isValid === false) {
5446
- return valueString(value.msg, record);
5785
+ const getMapObject = (map, names) => {
5786
+ const name = names.shift(names);
5787
+ if (names.length) {
5788
+ return getMapObject(map?.[name], names);
5789
+ } else {
5790
+ return map;
5447
5791
  }
5448
5792
  };
5449
- const StyledColumnFooter = styled.div`
5450
- &:empty{
5451
- display: none;
5793
+ const setMapObject = (map, names, value) => {
5794
+ const name = names.shift(names);
5795
+ if (names?.length) {
5796
+ if (typeof map[name] != 'object') {
5797
+ map[name] = {};
5452
5798
  }
5453
- ${({
5454
- $layout
5455
- }) => {
5456
- if ($layout == 'v') {
5457
- return ``;
5799
+ setMapObject(map[name], names, value);
5458
5800
  } else {
5459
- return `grid-column-start:2;`;
5801
+ map[name] = value;
5802
+ }
5803
+ };
5804
+ class JRTable extends JRWindow {
5805
+ constructor(props) {
5806
+ super(props);
5807
+ this.colGroupRef = /*#__PURE__*/React__default.createRef();
5808
+ }
5809
+ UNSAFE_componentWillMount() {
5810
+ this.setColumns(this.props.columns ?? []);
5460
5811
  }
5461
- }}
5462
- height:25px;
5463
- color:#ff6060;
5464
-
5465
- display: flex;
5466
- justify-content: space-between;
5467
5812
 
5468
- .left:{
5469
- xflex:1;
5470
- }
5471
- .right{
5472
- color:gray;
5473
- xflex:1;
5474
- }
5475
- `;
5476
- function requiredValidator({
5477
- value
5478
- }) {
5479
- if (value == null || value == '') {
5813
+ //------------------------------------------------------------------------------------
5814
+ checkableColumn(props) {
5815
+ return {
5816
+ //方法1
5817
+ render({
5818
+ value,
5819
+ onChange
5820
+ }) {
5821
+ return /*#__PURE__*/React__default.createElement("checkbox", {
5822
+ checked: value,
5823
+ onChange: e => {
5824
+ onChange(e.target.checked);
5825
+ }
5826
+ });
5827
+ },
5828
+ align: 'center',
5829
+ name: 'checked',
5830
+ ...props
5831
+ };
5832
+ // return {//方法2
5833
+ // type:Checkbox
5834
+ // ,funcProps({value}){
5835
+ // po('fffffffffffff',value)
5836
+ // return {
5837
+ // align:'center'
5838
+ // ,checked:value
5839
+ // }
5840
+ // }
5841
+ // // ,label:'A'
5842
+ // ,onChange(e,{value,onChange,me}){
5843
+ // onChange(e.target.checked)
5844
+ // }
5845
+ // ,...props
5846
+ // }
5847
+ }
5848
+ deletableColumn({
5849
+ name = 'deletable',
5850
+ sendValue,
5851
+ sendName,
5852
+ valueName,
5853
+ ...props
5854
+ }) {
5480
5855
  return {
5481
- msg: this.msg ?? 'This is required'
5856
+ render({
5857
+ value,
5858
+ onChange
5859
+ }) {
5860
+ return /*#__PURE__*/React__default.createElement("checkbox", {
5861
+ checked: value,
5862
+ onChange: e => {
5863
+ onChange(e.target.checked);
5864
+ }
5865
+ });
5866
+ },
5867
+ align: 'center',
5868
+ name,
5869
+ label() {
5870
+ return /*#__PURE__*/React__default.createElement("button", {
5871
+ onClick: () => {
5872
+ const value = this.props.delete.value ?? this.getDataSource()?.filter(record => record[name]).map(record => sendValue ? record[sendValue] : record);
5873
+ const callback = this.props.delete.callback ?? function (a, b, c) {
5874
+ this.reload();
5875
+ };
5876
+ this.delete({
5877
+ value: sendName ? {
5878
+ [sendName]: value
5879
+ } : value,
5880
+ callback,
5881
+ ...props
5882
+ });
5883
+ }
5884
+ }, "\u522A\u9664");
5885
+ },
5886
+ ...props
5482
5887
  };
5483
5888
  }
5484
- }
5485
- class JRFields extends JRWindow {
5486
- UNSAFE_componentWillMount() {
5487
- this.#initValidateValue();
5488
- }
5489
- reset() {
5490
- this.clearValidateValue();
5491
- super.reset();
5492
- }
5493
- setValue(value, reset) {
5494
- super.setValue(value, reset);
5495
- if (reset) {
5496
- this.clearValidateValue();
5497
- }
5498
- }
5499
- //-----------------------------------------------------------------------------------
5500
- #findValidator(acc, fullname, {
5501
- required,
5502
- ...column
5503
- }) {
5504
- const _required = required;
5505
- if (required == true || required?.value) {
5506
- acc[fullname] = {
5507
- isValid: null,
5508
- validators: [requiredValidator.bind(_required)]
5889
+ initColumn(column, level, result, leafColumns, names, lastColSpan) {
5890
+ const isBranch = column.type === undefined && column?.columns && column?.columns.length;
5891
+ const _names = column.name ? [...names, column.name] : names;
5892
+ if (isBranch) {
5893
+ if (column.label !== null) result[level].push(column);
5894
+ const c = this.initColumns(column.columns, level + (column.label !== null ? 1 : 0) + (column.rowSpan != null ? column.rowSpan - 1 : 0), result, leafColumns, _names, lastColSpan);
5895
+ column.colSpan = c.colSpan;
5896
+ column.columnNo = lastColSpan;
5897
+ return {
5898
+ colSpan: column.colSpan
5899
+ };
5900
+ } else {
5901
+ column.columnNo = lastColSpan;
5902
+ result[level].push({
5903
+ ...column,
5904
+ isLeaf: true
5905
+ });
5906
+ leafColumns.push(column);
5907
+ column.names = _names;
5908
+ if (_names?.length > 1) {
5909
+ column.setValue = function (record, value) {
5910
+ try {
5911
+ getMapObject(record, [..._names])[column.name] = value;
5912
+ } catch {
5913
+ setMapObject(record, [..._names], value);
5914
+ }
5915
+ };
5916
+ column.getValue = function (record) {
5917
+ return _names.reduce((acc, name) => {
5918
+ return acc?.[name];
5919
+ }, record);
5920
+ };
5921
+ } else {
5922
+ column.setValue = function (record, value) {
5923
+ record[column.name] = value;
5924
+ };
5925
+ column.getValue = function (record) {
5926
+ return record[column.name];
5927
+ };
5928
+ }
5929
+ return {
5930
+ colSpan: 1
5509
5931
  };
5510
5932
  }
5511
5933
  }
5512
- #loopColumnsForValidateValue(no, _fullnameList, columns, tab, result) {
5513
- const validateValue = columns?.reduce((acc, {
5514
- name,
5515
- type,
5516
- columns,
5517
- ...column
5518
- }, index) => {
5519
- no += 1;
5520
- const fullnameList = name ? [..._fullnameList, name] : _fullnameList;
5521
- const fullname = fullnameList.join('.');
5522
- this.#findValidator(acc, fullname, column);
5523
- if (type == null && columns) {
5524
- this.#loopColumnsForValidateValue(no, fullnameList, columns, `${tab}\t`, result);
5934
+ initColumns(columns, level, result, leafColumns, names, lastColSpan) {
5935
+ for (let i = result.length; i <= level; i++) {
5936
+ if (!result[i]) {
5937
+ result.push([]);
5525
5938
  }
5939
+ }
5940
+ let _lastColSpan = lastColSpan;
5941
+ const childrenLength = columns?.reduce((acc, column) => {
5942
+ const c = this.initColumn(column, level, result, leafColumns, names, _lastColSpan);
5943
+ acc.colSpan += c.colSpan;
5944
+ _lastColSpan += c.colSpan;
5526
5945
  return acc;
5527
- }, result);
5528
- return validateValue;
5529
- }
5530
- clearValidateValue() {
5531
- Object.values(this.getValidateValue()).forEach(v => v.isValid = null);
5532
- }
5533
- #initValidateValue() {
5534
- const columns = this.getColumns();
5535
- const validateValue = this.#loopColumnsForValidateValue(0, this.props.dataSourceName ? [this.props.dataSourceName] : [], columns, '', {});
5536
- this.setState({
5537
- validateValue
5946
+ }, {
5947
+ colSpan: 0
5538
5948
  });
5949
+ return childrenLength;
5539
5950
  }
5540
- #exeValidateConfig(validateConfig, value, record) {
5541
- validateConfig.isValid = true;
5542
- for (var i = 0; i < validateConfig.validators.length; i++) {
5543
- const result = validateConfig.validators[i]({
5544
- value,
5545
- record
5546
- });
5547
- if (result) {
5548
- validateConfig.isValid = false;
5549
- validateConfig.msg = result.msg;
5550
- break;
5551
- }
5951
+ setColumns([..._columns]) {
5952
+ if (this.props.checkable) _columns.unshift(this.checkableColumn(this.props.checkable));
5953
+ if (this.props.deletable) {
5954
+ _columns.unshift(this.deletableColumn(this.props.deletable));
5552
5955
  }
5553
- }
5554
- validateFields() {
5555
- console.clear();
5556
- Object.entries(this.getValidateValue()).filter(([fullname, validateConfig]) => validateConfig.isValid != true).forEach(([fullname, validateConfig]) => {
5557
- this.#exeValidateConfig(validateConfig, this.getValue(fullname), this.getValue());
5558
- });
5956
+ const columns = [];
5957
+ const leafColumns = [];
5958
+ this.initColumns(_columns, 0, columns, leafColumns, [], 0);
5959
+ // po('initColumns',initColumns)
5559
5960
  this.setState({
5560
- validateValue: this.getValidateValue()
5961
+ columns,
5962
+ leafColumns
5561
5963
  });
5562
5964
  }
5563
- get validateValueFrom() {
5564
- return this.props.validateValue === undefined ? 'state' : 'props';
5565
- }
5566
- getValidateValue(fullname) {
5567
- if (fullname === undefined) {
5568
- return this[this.validateValueFrom]?.validateValue;
5569
- } else {
5570
- return this[this.validateValueFrom]?.validateValue?.[fullname];
5571
- }
5572
- }
5573
- setValidateValue(validateValue) {
5574
- if (this.props.setValidateValue) {
5575
- this.props.setValidateValue(validateValue);
5576
- } else {
5577
- this.setState({
5578
- validateValue
5579
- });
5580
- }
5581
- }
5582
- createValidator({
5583
- required
5584
- }) {
5585
- const validators = [];
5586
- if (required === true && required.value) {
5587
- validators.push(requiredValidator);
5588
- }
5589
- return validators;
5590
- }
5591
- //--------------------------------------------------------------------------------------
5592
- get columnsFrom() {
5593
- return this.props.initColumns !== undefined ? 'state' : 'props';
5594
- }
5595
- getColumns() {
5596
- return this[this.columnsFrom]?.columns;
5965
+ //------------------------------------------------------------------------------------
5966
+ setDataSource(dataSource) {}
5967
+ getDataSource() {
5968
+ return this.props.dataSourceName ? this.getValue()?.[this.props.dataSourceName] : this.getValue();
5597
5969
  }
5598
- //-------------------------------------------------------------------------------------------
5970
+ add(record, index = this.getDataSource()?.length ?? 0, group) {
5971
+ //group 還沒有考慮到
5599
5972
 
5600
- get colon() {
5601
- return this.props.labelProps?.colon === undefined ? ':' : this.props.labelProps?.colon;
5602
- }
5603
- createColumn(parentValue, {
5604
- type,
5605
- name,
5606
- colSpan,
5607
- rowSpan,
5608
- style,
5609
- typeStyle: _typeStyle,
5610
- required,
5611
- ...column
5612
- }, index, parentName, fullname) {
5613
- const value = name ? parentValue?.[name] : parentValue;
5614
- const gap = column.gap ?? this.props.gap;
5615
- const label = column.label;
5616
- const _style = flexType(style, this, {}, {});
5617
- if (colSpan) _style.gridColumn = `span ${colSpan}`;
5618
- if (rowSpan) _style.gridRow = `span ${rowSpan}`;
5619
- let content;
5620
- this.createValidator({
5621
- required,
5622
- column
5623
- });
5624
- const fn = fullname.join('.');
5625
- const onChange = inputValue => {
5626
- const targetValue = inputValue?.target?.value ?? inputValue;
5627
- try {
5628
- parentValue[name] = targetValue;
5629
- this.setValue({
5630
- ...this.getValue()
5631
- });
5632
- } catch (e) {
5633
- const _value = this.getValue() ?? {};
5634
- checkMap(name, targetValue, _value, [...parentName]);
5635
- this.setValue(_value);
5973
+ if (this.getDataSource()) {
5974
+ if (group === undefined) {
5975
+ this.getDataSource().splice(index, 0, record); //.push(record)
5976
+ } else {
5977
+ this.getDataSource()[group].splice(index, 0, record); //.push(record)
5636
5978
  }
5637
- if (this.getValidateValue()[fn]) this.#exeValidateConfig(this.getValidateValue()[fn], targetValue, this.getValue());
5638
- };
5639
- const _parentName = [...parentName];
5640
- if (name !== undefined) {
5641
- _parentName.push(name);
5642
- }
5643
- if (type) {
5644
- const typeStyle = flexType(_typeStyle, this, null);
5645
- content = /*#__PURE__*/React__default.createElement(StyledColumnValue, {
5646
- className: 'jr-column-value',
5647
- style: {
5648
- gridColumn: label == null ? 'span 2' : null
5649
- }
5650
- }, /*#__PURE__*/React__default.createElement(type, {
5651
- value: value,
5652
- onChange,
5653
- record: parentValue,
5654
- style: {
5655
- width: '100%',
5656
- ...typeStyle
5657
- },
5658
- ...column
5659
- }));
5660
- } else if (column.columns) {
5661
- content = /*#__PURE__*/React__default.createElement(StyledGrid, {
5662
- cols: column.cols,
5663
- className: 'jr-grid',
5664
- $gap: gap
5665
- }, this.createColumns(value, column.columns, _parentName, fullname));
5666
- } else if (name || column.render) {
5667
- content = /*#__PURE__*/React__default.createElement(StyledColumnValue, {
5668
- className: 'jr-column-value',
5669
- style: {
5670
- gridColumn: label == null ? 'span 2' : null,
5671
- padding: column.render ? '4px 0' : null
5672
- }
5673
- }, column.render ? column.render.bind(this)({
5674
- onChange,
5675
- value: value,
5676
- record: this.getValue()
5677
- }) : typeof value === 'object' ? JSON.stringify(value) : value);
5979
+ this.setValue(this.getValue());
5980
+ } else {
5981
+ this.setValue(this.props.dataSourceName ? {
5982
+ [this.props.dataSourceName]: [record]
5983
+ } : [record]);
5678
5984
  }
5679
- const layout = column.labelProps?.layout === undefined ? this.props.labelProps?.layout : column.labelProps?.layout;
5680
- const labelStyle = column.labelProps?.style ?? this.props.labelProps?.style ?? {};
5681
- return /*#__PURE__*/React__default.createElement(StyledColumn, {
5682
- $layout: layout,
5683
- $hasLabel: label != null,
5684
- key: `f${index}`,
5685
- style: _style,
5686
- className: 'jr-column',
5687
- $labelWidth: column.labelProps?.width ?? this.props.labelProps?.width ?? '120px',
5688
- $valueWidth: column.valueProps?.width ?? this.props.valueProps?.width ?? '1fr'
5689
- }, label != null && /*#__PURE__*/React__default.createElement(StyledColumnLabel, {
5690
- style: labelStyle,
5691
- $required: required,
5692
- className: 'label',
5693
- $layout: layout,
5694
- $colon: column.labelProps?.colon === undefined ? this.colon : column.labelProps?.colon
5695
- }, label), content, this.props.debugMode && /*#__PURE__*/React__default.createElement(StyledColumnFooter, null, /*#__PURE__*/React__default.createElement("div", {
5696
- className: "left"
5697
- }, /*#__PURE__*/React__default.createElement(ColumnMessage, {
5698
- value: this.getValidateValue(_parentName.join('.')),
5699
- record: this.getValue()
5700
- })), /*#__PURE__*/React__default.createElement("div", {
5701
- className: "right"
5702
- }))
5703
- // validateValue?.[name]!==undefined && <StyledColumnFooter $layout={layout}>
5704
- // {/* {validateValue?.[name]?.$message} */}
5705
- // <ColumnMessage value={validateValue?.[name]}/>
5706
- // </StyledColumnFooter>
5707
- );
5708
5985
  }
5709
- createColumns(parentValue, columns, parentName, fullname) {
5710
- return columns?.map((column, index) => {
5711
- return this.createColumn(parentValue, column, index, parentName, column.name ? [...fullname, column.name] : fullname);
5712
- });
5986
+ noData() {
5987
+ const data = this.getDataSource();
5988
+ return data == null || data.length == 0;
5713
5989
  }
5990
+ //------------------------------------------------------------------------------------
5714
5991
  renderMe() {
5715
- return /*#__PURE__*/React__default.createElement(StyleJRFields, {
5716
- className: 'jr-fields',
5717
- style: this.props.typeStyle
5718
- }, /*#__PURE__*/React__default.createElement(StyledGrid, {
5719
- cols: this.props.cols,
5720
- style: this.props.gridStyle,
5721
- className: 'jr-grid',
5722
- $gap: this.props.gap ?? '8px'
5723
- }, this.createColumns(this.props.dataSourceName ? this.getValue()?.[this.props.dataSourceName] : this.getValue(), this.props.columns, this.props.dataSourceName ? [this.props.dataSourceName] : [], this.props.dataSourceName ? [this.props.dataSourceName] : [])));
5992
+ return /*#__PURE__*/React__default.createElement(StyledJRTable, {
5993
+ className: `${this.props.className ?? ''} jr-table ${this.props.onRowClick ? 'row-highlightable' : ''}`
5994
+ }, /*#__PURE__*/React__default.createElement("table", {
5995
+ className: 'jr-table-table'
5996
+ }, /*#__PURE__*/React__default.createElement(TBodies, {
5997
+ table: this,
5998
+ leafColumns: this.state.leafColumns,
5999
+ groupHeader: this.props.groupHeader,
6000
+ groupFooter: this.props.groupFooter,
6001
+ dataSource: this.getDataSource(),
6002
+ onRowClick: this.props.onRowClick
6003
+ }), /*#__PURE__*/React__default.createElement(TFoot, {
6004
+ columns: this.props.footColumns,
6005
+ table: this
6006
+ }), /*#__PURE__*/React__default.createElement(THead, {
6007
+ columns: this.state.columns,
6008
+ leafColumns: this.state.leafColumns,
6009
+ table: this
6010
+ })), this.noData() && /*#__PURE__*/React__default.createElement("div", {
6011
+ className: 'empty'
6012
+ }));
5724
6013
  }
5725
-
5726
- // render(){
5727
- // return this.renderMe()
5728
- // }
5729
6014
  }
5730
6015
 
6016
+ // export const FTable=JRFrameHOC(JRTable)
6017
+ // export const WTable=JRWindowHOC(JRTable)
6018
+
5731
6019
  const StyledJRFrame = styled.div`
5732
6020
  display:flex;
5733
6021
  flex:1;