jrs-react 1.2.13 → 1.2.15

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 (40) hide show
  1. package/build/index.es.js +2142 -1799
  2. package/build/index.js +2141 -1797
  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 +72 -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 +71 -16
  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/index.js +4 -2
  39. package/src/main.jsx +2 -1
  40. package/src/components/JRUtil.jsx +0 -1
package/build/index.es.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
- import React__default from 'react';
2
+ import React__default, { useState } from 'react';
3
3
  import styled from 'styled-components';
4
+ import { createRoot } from 'react-dom/client';
4
5
 
5
6
  function bind(fn, thisArg) {
6
7
  return function wrap() {
@@ -3475,7 +3476,7 @@ class JRSubmit extends React__default.Component {
3475
3476
  }
3476
3477
  setRawValue(rawValue) {
3477
3478
  this.setState({
3478
- rawValue: JSON.parse(JSON.stringify(rawValue ?? ''))
3479
+ rawValue: rawValue != null ? JSON.parse(JSON.stringify(rawValue)) : null
3479
3480
  });
3480
3481
  }
3481
3482
  reset() {
@@ -3483,8 +3484,6 @@ class JRSubmit extends React__default.Component {
3483
3484
  }
3484
3485
  setValue(value, reset = false) {
3485
3486
  if (this.props.onChange) {
3486
- po('name', this.props.name);
3487
- po('onChange', value);
3488
3487
  this.props.onChange(value);
3489
3488
  } else {
3490
3489
  this.setState({
@@ -3708,7 +3707,7 @@ const StyledJRFrame$1 = styled.div`
3708
3707
  >main{
3709
3708
  display:flex;
3710
3709
  flex:1;
3711
- overflow:overlay;
3710
+ overflow:hidden;
3712
3711
  flex-direction: column;
3713
3712
  > *{
3714
3713
  XXborder:1px solid gray;
@@ -3723,6 +3722,13 @@ const StyledJRFrame$1 = styled.div`
3723
3722
  display:flex;
3724
3723
  flex:1;
3725
3724
  overflow:hidden;
3725
+
3726
+ >main{
3727
+ display:flex;
3728
+ flex:1;
3729
+ overflow: overlay;
3730
+ }
3731
+
3726
3732
  }
3727
3733
  >footer{
3728
3734
  XXborder:1px solid blue;
@@ -3730,11 +3736,11 @@ const StyledJRFrame$1 = styled.div`
3730
3736
  }
3731
3737
 
3732
3738
  }
3733
-
3734
3739
  `;
3735
3740
  class JRFrame extends JRSubmit {
3736
3741
  renderer() {
3737
3742
  return /*#__PURE__*/React__default.createElement(StyledJRFrame$1, {
3743
+ id: this.props.id,
3738
3744
  style: this.props.style,
3739
3745
  className: `${this.props.className} jr-frame`
3740
3746
  }, /*#__PURE__*/React__default.createElement(FreeType$1, {
@@ -3751,7 +3757,9 @@ class JRFrame extends JRSubmit {
3751
3757
  config: this.props.left,
3752
3758
  me: this,
3753
3759
  className: 'left'
3754
- }), this.renderMe?.() ?? this.props.children, /*#__PURE__*/React__default.createElement(FreeType$1, {
3760
+ }), /*#__PURE__*/React__default.createElement("main", {
3761
+ className: 'body'
3762
+ }, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default.createElement(FreeType$1, {
3755
3763
  tag: "div",
3756
3764
  config: this.props.right,
3757
3765
  me: this,
@@ -3767,1967 +3775,2233 @@ class JRFrame extends JRSubmit {
3767
3775
  className: 'end'
3768
3776
  }));
3769
3777
  }
3770
- // renderMe(){
3771
- // return <div style={{flex:1}}>Render me</div>
3772
- // }
3773
3778
  }
3774
3779
 
3775
- const StyledSlider$1 = styled.div`
3776
- position: absolute;
3777
- top: 0;
3778
- right: 0;
3779
- height:100%;
3780
- width:6px;
3780
+ var _path;
3781
+ 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); }
3782
+ var SvgX = function SvgX(props) {
3783
+ return /*#__PURE__*/React.createElement("svg", _extends$1({
3784
+ xmlns: "http://www.w3.org/2000/svg",
3785
+ width: 24,
3786
+ height: 24,
3787
+ fill: "none",
3788
+ stroke: "currentColor",
3789
+ strokeLinecap: "round",
3790
+ strokeLinejoin: "round",
3791
+ strokeWidth: 2,
3792
+ viewBox: "0 0 24 24"
3793
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
3794
+ d: "M18 6 6 18M6 6l12 12"
3795
+ })));
3796
+ };
3797
+
3798
+ function JRButton({
3799
+ icon,
3800
+ children,
3801
+ ...props
3802
+ }) {
3803
+ return /*#__PURE__*/React__default.createElement("button", props, icon, children);
3804
+ }
3805
+
3806
+ const StyledTitle = styled.div`
3807
+ overflow: hidden;
3808
+ display: flex;
3809
+ border-radius: var(--jr-window-radius) var(--jr-window-radius) 0 0;
3810
+ background:#464646;
3811
+ color: white;
3812
+ display: flex;
3813
+ align-items: center;
3814
+ min-height: min-content;
3815
+ XX&:active{
3816
+ cursor: grabbing;
3817
+ }
3818
+
3819
+ -webkit-user-select: none;
3820
+ -khtml-user-select: none;
3821
+ -moz-user-select: none;
3822
+ -o-user-select: none;
3781
3823
  user-select: none;
3782
- &.resizing:hover,&.resizing{
3783
- border-right:1px dashed black;
3824
+
3825
+ > .title{
3826
+
3827
+ flex: 1;
3828
+ padding:2px 0 2px 8px;
3829
+ text-overflow: ellipsis;
3830
+ overflow: hidden;
3831
+ white-space: nowrap;
3784
3832
  }
3785
- &:hover{
3786
- cursor: col-resize;
3787
- border-right:1px dashed gray;
3833
+ > nav{
3834
+ display: flex;
3835
+ align-items: anchor-center;
3836
+
3837
+
3838
+ >button{
3839
+ outline: unset;
3840
+ display:flex;
3841
+ align-items: center;
3842
+ justify-content: center;
3843
+ border: unset;
3844
+ background: unset;
3845
+ cursor: pointer;
3846
+ width:32px;
3847
+ height:32px;
3848
+ xborder:1px solid green;
3849
+ padding: 0;
3850
+ margin: 0;
3851
+ &:hover{
3852
+ background: #bbbbbb;
3853
+ color:white;
3854
+ }
3855
+ >svg{
3856
+ color:#bababa;
3857
+ width:14px;
3858
+ height:14px;
3859
+ cursor: pointer;
3860
+ stroke-width: 3;
3861
+ }
3862
+ }
3863
+ >button.danger:hover{
3864
+ background: red;
3865
+ >svg{
3866
+ color:white;
3867
+ }
3868
+ }
3788
3869
  }
3789
3870
  `;
3790
- class Slider$1 extends React__default.Component {
3791
- constructor() {
3792
- super();
3793
- this.sliderRef = /*#__PURE__*/React__default.createRef();
3794
- }
3871
+ class TitleBar extends React__default.Component {
3872
+ pos1 = 0;
3873
+ pos2 = 0;
3874
+ pos3 = 0;
3875
+ pos4 = 0;
3876
+ x = 0;
3877
+ y = 0;
3878
+ remember = e => {
3879
+ po('remember');
3880
+ const {
3881
+ clientX,
3882
+ clientY
3883
+ } = e;
3884
+ const {
3885
+ x,
3886
+ y,
3887
+ width,
3888
+ height
3889
+ } = this.props.windowRef.current.getBoundingClientRect();
3890
+ this.props.window.orgHeight = height;
3891
+ this.props.window.orgWidth = width;
3892
+ this.props.window.orgTop = y;
3893
+ this.props.window.orgLeft = x;
3894
+ this.props.window.orgXd = clientX - x;
3895
+ this.props.window.orgBodyOverflow = document.body.style.overflow;
3896
+ };
3897
+ adjustScreen = e => {
3898
+ po('double click adjustScreen');
3899
+ e.preventDefault();
3900
+ const {
3901
+ x,
3902
+ y,
3903
+ width,
3904
+ height
3905
+ } = this.props.windowRef.current.getBoundingClientRect();
3906
+ if (y > 1 - this.props.thick) {
3907
+ this.remember(e);
3908
+ this.fullScreen(e);
3909
+ } else {
3910
+ this.floatScreen(e);
3911
+ }
3912
+ };
3913
+ floatScreen = e => {
3914
+ po('floatScreen');
3915
+ this.props.windowRef.current;
3916
+ this.props.windowRef.current.style.transition = 'var(--transition-x-y), left .05s ease-in';
3917
+ this.props.windowRef.current.style.left = `${this.props.window.orgLeft}px`;
3918
+ this.props.windowRef.current.style.top = `${this.props.window.orgTop}px`;
3919
+ this.props.windowRef.current.style.width = `${this.props.window.orgWidth}px`;
3920
+ this.props.windowRef.current.style.height = `${this.props.window.orgHeight}px`;
3921
+ document.body.style.overflow = this.props.window.orgBodyOverflow;
3922
+ };
3923
+ fullScreen = e => {
3924
+ po('fullScreen', this.props.thick);
3925
+ this.props.windowRef.current.style.transition = 'var(--transition-x-y), left .05s ease-in';
3926
+ this.props.windowRef.current.style.left = `${-this.props.thick}px`;
3927
+ this.props.windowRef.current.style.top = `${-this.props.thick}px`;
3928
+ this.props.windowRef.current.style.width = `calc(100vw + ${this.props.thick * 2}px)`; //`${window.innerWidth+(this.props.thick*2)}px`
3929
+ this.props.windowRef.current.style.height = `calc(100vh + ${this.props.thick * 2}px)`; //`${window.innerHeight+(this.props.thick*2)}px`
3930
+
3931
+ setTimeout(() => {
3932
+ document.body.style.overflow = 'hidden';
3933
+ this.props.windowRef.current.style.transition = 'unset';
3934
+ }, 50);
3935
+ };
3795
3936
  stop = e => {
3796
- this.sliderRef.current.classList.remove('resizing');
3937
+ po('stop');
3938
+ e.preventDefault();
3939
+ if (this.moved) {
3940
+ const {
3941
+ height: titleBarHeight
3942
+ } = this.props.titleBarRef.current.getBoundingClientRect();
3943
+ const {
3944
+ x,
3945
+ y,
3946
+ width,
3947
+ height
3948
+ } = this.props.windowRef.current.getBoundingClientRect();
3949
+ if (y < 1 - this.props.thick) this.fullScreen(e);
3950
+ if (y > window.innerHeight - titleBarHeight) this.props.windowRef.current.style.top = `${window.innerHeight - titleBarHeight}px`;
3951
+ if (x + width - this.props.thick < 0) this.props.windowRef.current.style.left = 0;
3952
+ if (x > window.innerWidth) this.props.windowRef.current.style.left = `${window.innerWidth - width}px`;
3953
+ }
3797
3954
  document.body.style.cursor = 'default';
3798
3955
  window.removeEventListener('mousemove', this.move);
3799
3956
  window.removeEventListener('mouseup', this.stop);
3957
+ window.removeEventListener('mousemove', this.preMove);
3800
3958
  };
3801
- move = ({
3802
- clientX
3803
- }) => {
3959
+ move = e => {
3960
+ po('move');
3961
+ e.preventDefault();
3962
+ this.moved = true;
3804
3963
  const {
3805
- th,
3806
- selectedCols,
3807
- widthRates
3808
- } = this.data;
3964
+ clientX,
3965
+ clientY
3966
+ } = e;
3967
+ const y = clientY < 1 ? 0 : clientY;
3968
+ this.pos1 = this.pos3 - clientX;
3969
+ this.pos2 = this.pos4 - y;
3970
+ this.pos3 = clientX;
3971
+ this.pos4 = y;
3972
+ const w = this.props.windowRef.current;
3973
+ this.y = w.offsetTop - this.pos2;
3974
+ this.x = w.offsetLeft - this.pos1;
3975
+
3976
+ // if(this.props.window.orgWidth){
3977
+ // w.style.width=`${this.props.window.orgWidth}px`
3978
+ // this.props.window.orgWidth=null
3979
+ // }
3980
+
3981
+ this.y = this.y < -this.props.thick ? -this.props.thick : this.y;
3982
+ w.style.transition = 'unset';
3983
+ w.style.top = `${this.y}px`;
3984
+ w.style.left = `${this.x}px`;
3985
+ };
3986
+ preMove = e => {
3987
+ console.clear();
3988
+ po('preMove');
3989
+ const w = this.props.windowRef.current;
3809
3990
  const {
3810
- left
3811
- } = th.getBoundingClientRect();
3812
- const min = left + 10;
3813
- const x = clientX >= min ? clientX : min;
3814
- const width = x - left;
3815
- selectedCols.forEach((col, index) => {
3816
- const _width = Math.round(width / 100 * widthRates[index]);
3817
- col.style.width = _width + 'px';
3818
- });
3991
+ clientX,
3992
+ clientY,
3993
+ ...oe
3994
+ } = e;
3995
+ po('e', e);
3996
+ const {
3997
+ x,
3998
+ y,
3999
+ width,
4000
+ height
4001
+ } = w.getBoundingClientRect();
4002
+ po('width', width);
4003
+ if (y <= -this.props.thick) ;
4004
+ w.style.transition = 'left .05s ease-in, height .05s ease-in';
4005
+ if (y <= 0) {
4006
+ // contt browserWidth=
4007
+ const w1 = window.innerWidth - this.props.thick * 2;
4008
+ const x1 = clientX;
4009
+ const w2 = this.props.window.orgWidth - 32;
4010
+ const x2 = x1 / w1 * w2;
4011
+ // po('xp' , x2)
4012
+ w.style.left = `${clientX - x2}px`;
4013
+ w.style.width = `${this.props.window.orgWidth}px`;
4014
+ w.style.height = `${this.props.window.orgHeight}px`;
4015
+ } else {
4016
+ this.remember(e);
4017
+ }
4018
+ document.body.style.cursor = 'grabbing';
4019
+ document.body.style.overflow = this.props.window.orgBodyOverflow;
4020
+ setTimeout(() => {
4021
+ window.addEventListener('mousemove', this.move);
4022
+ }, 50);
4023
+ window.removeEventListener('mousemove', this.preMove);
3819
4024
  };
3820
- start(thPRef, column) {
3821
- const selectedCols = [...this.props.table.colGroupRef.current.children].slice(column.columnNo, column.columnNo + (column.colSpan ?? 1));
3822
- const totalWidth = selectedCols.reduce((aco, {
3823
- offsetWidth
3824
- }) => aco + offsetWidth, 0);
3825
- const widthRates = selectedCols.map(({
3826
- offsetWidth
3827
- }) => {
3828
- return 100 * (offsetWidth / totalWidth);
3829
- });
3830
- this.data = {
3831
- selectedCols,
3832
- th: thPRef.current,
3833
- widthRates
3834
- };
3835
- this.sliderRef.current.classList.add('resizing');
3836
- document.body.style.cursor = 'col-resize';
3837
- window.addEventListener('mousemove', this.move);
4025
+ start(e) {
4026
+ po('start');
4027
+ e.preventDefault();
4028
+ this.moved = false;
4029
+ this.pos3 = e.clientX;
4030
+ this.pos4 = e.clientY;
4031
+ this.props.windowRef.current.style.transition = 'var(--transition-x-y)';
4032
+ window.addEventListener('mousemove', this.preMove);
3838
4033
  window.addEventListener('mouseup', this.stop);
3839
4034
  }
4035
+ onDoubleClick() {
4036
+ po('onDoubleClick');
4037
+ }
3840
4038
  render() {
3841
- const column = this.props.column;
3842
- return /*#__PURE__*/React__default.createElement(StyledSlider$1, {
3843
- ref: this.sliderRef,
4039
+ return /*#__PURE__*/React__default.createElement(StyledTitle, {
4040
+ ref: this.props.titleBarRef,
4041
+ draggable: "false",
3844
4042
  onMouseDown: e => {
3845
- this.start(this.props.thRef, column);
4043
+ this.start(e);
4044
+ },
4045
+ onDoubleClick: this.adjustScreen
4046
+ }, /*#__PURE__*/React__default.createElement(FreeType$1, {
4047
+ tag: "div",
4048
+ config: this.props.title ?? '',
4049
+ me: this.props.window,
4050
+ className: 'title'
4051
+ }), /*#__PURE__*/React__default.createElement("nav", null, this.props.window.props.setOpen ? /*#__PURE__*/React__default.createElement(JRButton, {
4052
+ icon: /*#__PURE__*/React__default.createElement(SvgX, null),
4053
+ className: 'danger',
4054
+ onClick: e => {
4055
+ e.stopPropagation();
4056
+ if (this.props.window.orgBodyOverflow != null) {
4057
+ document.body.style.overflow = this.props.window.orgBodyOverflow;
4058
+ }
4059
+ this.props.window.props.setOpen(false);
4060
+ },
4061
+ onMouseDown: e => {
4062
+ e.stopPropagation();
3846
4063
  }
3847
- });
4064
+ }) : null));
3848
4065
  }
3849
4066
  }
3850
4067
 
3851
- const Colgroup = ({
3852
- leafColumns,
3853
- colGroupRef
3854
- }) => {
3855
- return /*#__PURE__*/React__default.createElement("colgroup", {
3856
- ref: colGroupRef
3857
- }, leafColumns?.map((_column, index) => {
3858
- const {
3859
- width,
3860
- ...column
3861
- } = _column;
3862
- const style = {
3863
- width
3864
- };
3865
- return /*#__PURE__*/React__default.createElement("col", {
3866
- style: style,
4068
+ const directions = ['n', 'e', 's', 'w', 'nww', 'nnw', 'nne', 'nee', 'sse', 'see', 'sww', 'ssw'];
4069
+ class Sliders extends React__default.Component {
4070
+ render() {
4071
+ return directions.map((direction, index) => /*#__PURE__*/React__default.createElement(Slider$1, {
4072
+ direction: direction,
4073
+ thick: this.props.thick,
4074
+ windowRef: this.props.windowRef,
4075
+ window: this.props.window,
4076
+ titleBarRef: this.props.titleBarRef,
3867
4077
  key: index
3868
- });
3869
- }));
3870
- };
3871
- const Ths$1 = ({
3872
- deep,
3873
- rowColumn,
3874
- rowIndex,
3875
- table
3876
- }) => {
3877
- return rowColumn?.map((column, colIndex) => {
3878
- const thRef = /*#__PURE__*/React__default.createRef();
3879
- return /*#__PURE__*/React__default.createElement("th", {
3880
- key: colIndex,
3881
- ref: thRef,
3882
- colSpan: column.colSpan,
3883
- 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, {
3885
- table: table,
3886
- thRef: thRef,
3887
- column: column
3888
- }));
3889
- });
3890
- };
3891
- const HeadTrs = ({
3892
- columns: _columns,
3893
- trClassName,
3894
- table
3895
- }) => {
3896
- const columns = Array.isArray(_columns?.[0]) ? _columns : [_columns];
3897
- return columns?.map((rowColumn, rowIndex) => {
3898
- return /*#__PURE__*/React__default.createElement("tr", {
3899
- className: trClassName,
3900
- key: rowIndex
3901
- }, /*#__PURE__*/React__default.createElement(Ths$1, {
3902
- deep: columns.length - 1,
3903
- rowColumn: rowColumn,
3904
- rowIndex: rowIndex,
3905
- table: table
3906
- }));
3907
- });
3908
- };
3909
- const THead = ({
3910
- columns,
3911
- leafColumns,
3912
- table
3913
- }) => {
3914
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement(HeadTrs, {
3915
- columns: columns,
3916
- table: table
3917
- })), /*#__PURE__*/React__default.createElement(Colgroup, {
3918
- leafColumns: leafColumns,
3919
- colGroupRef: table.colGroupRef
3920
- }));
3921
- };
3922
- const FootThs = ({
3923
- table,
3924
- groupData,
3925
- groupIndex,
3926
- deep,
3927
- columns,
3928
- rowIndex
3929
- }) => {
3930
- return columns?.map((column, colIndex) => {
3931
- // let content
3932
- // if(type){
3933
- // content='type'
3934
- // }else if(render){
3935
-
3936
- // content=render?.bind(table)({groupData,groupIndex,ths:111})
3937
- // }else{
3938
- // content=column.label
3939
- // }
3940
- let style = flexType(column.style, table, {}, {});
3941
- const content = whatType(column, table, column.label);
3942
- return /*#__PURE__*/React__default.createElement("th", {
3943
- style: style,
3944
- colSpan: column.colSpan,
3945
- rowSpan: column.rowSpan
3946
- }, content);
3947
- });
3948
- };
3949
- const TFoot = ({
3950
- table,
3951
- columns
3952
- }) => {
3953
- const trs = columns?.map((rowColumn, rowIndex) => {
3954
- return /*#__PURE__*/React__default.createElement("tr", {
3955
- key: rowIndex
3956
- }, /*#__PURE__*/React__default.createElement(FootThs, {
3957
- columns: rowColumn,
3958
- table: table
3959
4078
  }));
3960
- });
3961
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("tfoot", null, trs));
3962
- };
3963
-
3964
- function _extends$1() {
3965
- return _extends$1 = Object.assign ? Object.assign.bind() : function (n) {
3966
- for (var e = 1; e < arguments.length; e++) {
3967
- var t = arguments[e];
3968
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
3969
- }
3970
- return n;
3971
- }, _extends$1.apply(null, arguments);
4079
+ }
3972
4080
  }
4081
+ const StyledSlider$1 = styled.div`
4082
+ Xborder:1px solid ${({
4083
+ $direction: {
4084
+ color
4085
+ }
4086
+ }) => color};
4087
+ Xbackground:${({
4088
+ $direction: {
4089
+ color
4090
+ }
4091
+ }) => color};
4092
+ position: absolute;
4093
+ top: ${({
4094
+ $direction: {
4095
+ top
4096
+ }
4097
+ }) => top};
4098
+ bottom: ${({
4099
+ $direction: {
4100
+ bottom
4101
+ }
4102
+ }) => bottom};
4103
+ right: ${({
4104
+ $direction: {
4105
+ right
4106
+ }
4107
+ }) => right};
4108
+ left: ${({
4109
+ $direction: {
4110
+ left
4111
+ }
4112
+ }) => left};
4113
+ height: ${({
4114
+ $direction: {
4115
+ height
4116
+ }
4117
+ }) => height};
4118
+ width: ${({
4119
+ $direction: {
4120
+ width
4121
+ }
4122
+ }) => width};
4123
+ cursor: ${({
4124
+ $direction: {
4125
+ cursor
4126
+ }
4127
+ }) => cursor};
3973
4128
 
3974
- styled.tbody`
3975
- th{
3976
- height:4px;
3977
- background:#c6c6c6;
3978
- }
3979
- `;
3980
-
3981
- ////////////////////////////////////////////////////////////////////////////
4129
+ -webkit-user-select: none;
4130
+ -khtml-user-select: none;
4131
+ -moz-user-select: none;
4132
+ -o-user-select: none;
4133
+ user-select: none;
3982
4134
 
3983
- const Ths = ({
3984
- table,
3985
- groupData,
3986
- groupIndex,
3987
- deep,
3988
- rowColumn,
3989
- rowIndex
3990
- }) => {
3991
- return rowColumn?.map(({
3992
- style: _style,
3993
- align,
3994
- type,
3995
- render,
3996
- ...column
3997
- }, colIndex) => {
3998
- const style = flexType(_style, table, {}, {});
3999
- let content;
4000
- if (type) {
4001
- content = 'type';
4002
- } else if (render) {
4003
- content = render?.bind(table)({
4004
- groupData,
4005
- groupIndex,
4006
- ths: 111
4007
- });
4008
- } else {
4009
- content = column.label;
4010
- }
4011
- // style.textAlign=align
4012
- return /*#__PURE__*/React__default.createElement("th", {
4013
- key: colIndex,
4014
- style: {
4015
- textAlign: align,
4016
- ...style
4017
- },
4018
- colSpan: column.colSpan,
4019
- rowSpan: column.isLeaf && deep > rowIndex ? deep - rowIndex + 1 : null
4020
- }, content);
4021
- });
4022
- };
4023
- const GroupColumns = ({
4024
- table,
4025
- columns: _columns,
4026
- trClassName,
4027
- groupData,
4028
- tbodyIndex
4029
- }) => {
4030
- const columns = Array.isArray(_columns?.[0]) ? _columns : [_columns];
4031
- return columns?.map((rowColumn, rowIndex) => {
4032
- return /*#__PURE__*/React__default.createElement("tr", {
4033
- className: trClassName,
4034
- key: rowIndex
4035
- }, /*#__PURE__*/React__default.createElement(Ths, {
4036
- table: table,
4037
- groupData: groupData,
4038
- groupIndex: tbodyIndex,
4039
- deep: columns.length - 1,
4040
- rowColumn: rowColumn,
4041
- rowIndex: rowIndex
4042
- }));
4043
- });
4044
- };
4045
- styled.tr`
4046
- z-index: 1;
4047
- XXposition: sticky;
4048
- XXtop: 50px;
4049
- th{
4050
- text-align: left;
4051
- border:1px solid #222222;
4052
- }
4053
4135
  `;
4054
- const GroupHeader = props => {
4055
- return /*#__PURE__*/React__default.createElement(GroupColumns, _extends$1({
4056
- trClassName: 'jr-group-header'
4057
- }, props));
4058
- };
4059
- styled.tr`
4060
- th{
4061
- border:1px solid #222222;
4062
- text-align: left;
4063
- }
4064
- `;
4065
- const GroupFooter = props => {
4066
- return /*#__PURE__*/React__default.createElement(GroupColumns, _extends$1({
4067
- trClassName: 'jr-group-footer'
4068
- }, props));
4069
- };
4070
-
4071
- ////////////////////////////////////////////////////////////////////////////
4072
- const Td = ({
4073
- column: _column,
4074
- record,
4075
- tbodyIndex,
4076
- trIndex,
4077
- tdIndex,
4078
- table
4079
- }) => {
4080
- let content;
4081
- const {
4082
- style: _style,
4083
- align,
4084
- vAlign = 'baseline',
4085
- type,
4086
- typeStyle: _typeStyle,
4087
- render,
4088
- setValue,
4089
- getValue,
4090
- onChange: _onChange,
4091
- funcProps,
4092
- ...column
4093
- } = _column;
4094
- const onChange = inputValue => {
4095
- const targetValue = inputValue?.target?.value ?? inputValue;
4096
- setValue(record, targetValue);
4097
- table.setValue(table.getValue());
4098
- };
4099
- const value = getValue(record);
4100
- let style = render ? {} : flexType(_style, table, {
4101
- value,
4102
- record
4103
- }, {});
4104
- const setStyle = _style => {
4105
- style = _style;
4106
- };
4107
- setStyle.bind(table);
4108
- render?.bind(table);
4109
- if (type) {
4110
- const typeStyle = flexType(_typeStyle, table, {
4111
- record
4112
- }, {});
4113
- content = /*#__PURE__*/React__default.createElement(type, {
4114
- onChange: _onChange ? e => {
4115
- _onChange?.bind(table)(e, {
4116
- value,
4117
- onChange,
4118
- me: content
4119
- });
4120
- } : onChange,
4121
- value,
4122
- style: typeStyle,
4123
- render,
4124
- ...column,
4125
- ...funcProps?.bind(table)({
4126
- value
4127
- })
4128
- });
4129
- } else if (render) {
4130
- content = render({
4131
- index: trIndex,
4132
- groupIndex: tbodyIndex,
4133
- value,
4134
- record,
4135
- onChange,
4136
- setStyle
4137
- });
4138
- } else {
4139
- content = value;
4136
+ class Slider$1 extends React__default.Component {
4137
+ width = '3px';
4138
+ borderWidth = 'px';
4139
+ borderLong = 5;
4140
+ constructor(props) {
4141
+ super(props);
4142
+ this.sliderRef = /*#__PURE__*/React__default.createRef();
4140
4143
  }
4141
- return /*#__PURE__*/React__default.createElement("td", {
4142
- colSpan: style.colSpan,
4143
- rowSpan: style.rowSpan,
4144
- style: {
4145
- textAlign: align,
4146
- verticalAlign: vAlign,
4147
- ...style
4144
+ directions = {
4145
+ n: {
4146
+ top: 0,
4147
+ color: 'red',
4148
+ width: '100%',
4149
+ height: `${this.props.thick}px`,
4150
+ cursor: 'n-resize',
4151
+ resize: props => {
4152
+ this.resizeN(props);
4153
+ }
4148
4154
  },
4149
- key: tdIndex
4150
- }, content);
4151
- };
4152
- const Tds = ({
4153
- leafColumns,
4154
- record,
4155
- table,
4156
- tbodyIndex,
4157
- trIndex
4158
- }) => {
4159
- return leafColumns?.map((column, tdIndex) => {
4160
- return /*#__PURE__*/React__default.createElement(Td, {
4161
- column: column,
4162
- key: tdIndex,
4163
- record: record,
4164
- table: table,
4165
- tbodyIndex: tbodyIndex,
4166
- trIndex: trIndex,
4167
- tdIndex: tdIndex
4168
- });
4169
- });
4170
- };
4171
- ////////////////////////////////////////////////////////////////////////////
4172
-
4173
- const TBody = ({
4174
- groupData,
4175
- groupHeader,
4176
- leafColumns,
4177
- groupFooter,
4178
- table,
4179
- tbodyIndex
4180
- }) => {
4181
- const neededProps = {
4182
- table,
4183
- tbodyIndex
4184
- };
4185
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("tbody", {
4186
- key: `tbody${tbodyIndex}`
4187
- }, groupData?.length > 0 && /*#__PURE__*/React__default.createElement(GroupHeader, _extends$1({
4188
- groupData: groupData,
4189
- columns: groupHeader
4190
- }, neededProps)), groupData?.map?.((record, trIndex) => {
4191
- const onRowClick = table.props.onRowClick?.bind(table);
4192
- return /*#__PURE__*/React__default.createElement("tr", {
4193
- key: trIndex,
4194
- onClick: () => {
4195
- onRowClick?.({
4196
- record,
4197
- index: trIndex,
4198
- groupIndex: tbodyIndex
4199
- });
4155
+ e: {
4156
+ color: 'yellow',
4157
+ right: 0,
4158
+ width: `${this.props.thick}px`,
4159
+ height: '100%',
4160
+ cursor: 'e-resize',
4161
+ resize: props => {
4162
+ this.resizeE(props);
4163
+ }
4164
+ },
4165
+ s: {
4166
+ color: 'blue',
4167
+ bottom: 0,
4168
+ width: '100%',
4169
+ height: `${this.props.thick}px`,
4170
+ cursor: 's-resize',
4171
+ resize: props => {
4172
+ this.resizeS(props);
4173
+ }
4174
+ },
4175
+ w: {
4176
+ color: 'green',
4177
+ left: 0,
4178
+ width: `${this.props.thick}px`,
4179
+ height: '100%',
4180
+ cursor: 'w-resize',
4181
+ resize: props => {
4182
+ this.resizeW(props);
4183
+ }
4184
+ },
4185
+ nw: {
4186
+ top: 0,
4187
+ left: 0,
4188
+ color: 'blue',
4189
+ width: `${this.borderLong}px`,
4190
+ height: `${this.borderLong}px`,
4191
+ cursor: 'nw-resize',
4192
+ resize: props => {
4193
+ this.resizeN(props);
4194
+ this.resizeW(props);
4195
+ }
4196
+ },
4197
+ nww: {
4198
+ top: 0,
4199
+ left: 0,
4200
+ color: 'blue',
4201
+ width: `${this.props.thick + this.borderLong}px`,
4202
+ height: `${this.props.thick}px`,
4203
+ cursor: 'nw-resize',
4204
+ resize: props => {
4205
+ this.resizeN(props);
4206
+ this.resizeW(props);
4207
+ }
4208
+ },
4209
+ nnw: {
4210
+ top: 0,
4211
+ left: 0,
4212
+ color: 'blue',
4213
+ width: `${this.props.thick}px`,
4214
+ height: `${this.props.thick + this.borderLong}px`,
4215
+ cursor: 'nw-resize',
4216
+ resize: props => {
4217
+ this.resizeN(props);
4218
+ this.resizeW(props);
4219
+ }
4220
+ },
4221
+ nne: {
4222
+ top: 0,
4223
+ right: 0,
4224
+ color: 'green',
4225
+ width: `${this.props.thick + this.borderLong}px`,
4226
+ height: `${this.props.thick}px`,
4227
+ cursor: 'ne-resize',
4228
+ resize: props => {
4229
+ this.resizeN(props);
4230
+ this.resizeE(props);
4231
+ }
4232
+ },
4233
+ nee: {
4234
+ top: 0,
4235
+ right: 0,
4236
+ color: 'green',
4237
+ width: `${this.props.thick}px`,
4238
+ height: `${this.props.thick + this.borderLong}px`,
4239
+ cursor: 'ne-resize',
4240
+ resize: props => {
4241
+ this.resizeN(props);
4242
+ this.resizeE(props);
4243
+ }
4244
+ },
4245
+ sse: {
4246
+ color: 'red',
4247
+ right: 0,
4248
+ bottom: 0,
4249
+ width: `${this.props.thick + this.borderLong}px`,
4250
+ height: `${this.props.thick}px`,
4251
+ cursor: 'se-resize',
4252
+ resize: props => {
4253
+ this.resizeS(props);
4254
+ this.resizeE(props);
4255
+ }
4256
+ },
4257
+ see: {
4258
+ color: 'red',
4259
+ right: 0,
4260
+ bottom: 0,
4261
+ width: `${this.props.thick}px`,
4262
+ height: `${this.props.thick + this.borderLong}px`,
4263
+ cursor: 'se-resize',
4264
+ resize: props => {
4265
+ this.resizeS(props);
4266
+ this.resizeE(props);
4267
+ }
4268
+ },
4269
+ ssw: {
4270
+ color: 'yellow',
4271
+ bottom: 0,
4272
+ left: 0,
4273
+ width: `${this.props.thick + this.borderLong}px`,
4274
+ height: `${this.props.thick}px`,
4275
+ cursor: 'sw-resize',
4276
+ resize: props => {
4277
+ this.resizeS(props);
4278
+ this.resizeW(props);
4279
+ }
4280
+ },
4281
+ sww: {
4282
+ color: 'yellow',
4283
+ bottom: 0,
4284
+ left: 0,
4285
+ width: `${this.props.thick}px`,
4286
+ height: `${this.props.thick + this.borderLong}px`,
4287
+ cursor: 'sw-resize',
4288
+ resize: props => {
4289
+ this.resizeS(props);
4290
+ this.resizeW(props);
4200
4291
  }
4201
- }, /*#__PURE__*/React__default.createElement(Tds, _extends$1({
4202
- record: record,
4203
- trIndex: trIndex
4204
- }, neededProps, {
4205
- leafColumns: leafColumns
4206
- })));
4207
- }), groupData?.length > 0 && /*#__PURE__*/React__default.createElement(GroupFooter, _extends$1({
4208
- groupData: groupData,
4209
- columns: groupFooter
4210
- }, neededProps))));
4211
- };
4212
- const TBodies = ({
4213
- groupHeader,
4214
- leafColumns,
4215
- groupFooter,
4216
- dataSource: _dataSource,
4217
- table
4218
- }) => {
4219
- // po('--TBodies--')
4220
- const isGroupDataType = Array.isArray(_dataSource?.[0]);
4221
- const dataSource = isGroupDataType ? _dataSource : [_dataSource];
4222
-
4223
- // po('dataSource',dataSource)
4224
- return dataSource?.map((groupData, tbodyIndex, c) => {
4225
- return /*#__PURE__*/React__default.createElement(TBody, {
4226
- key: `tbody${tbodyIndex}`,
4227
- table: table
4228
- // dataSource={dataSource}
4229
- // dataGroup={groupData}
4230
- ,
4231
- groupData: groupData,
4232
- tbodyIndex: tbodyIndex,
4233
- groupHeader: groupHeader,
4234
- leafColumns: leafColumns,
4235
- groupFooter: groupFooter
4236
- });
4237
- });
4238
- };
4239
-
4240
- const StyledJRTable = styled.div`
4241
- --column-bd-color:#cccccc;
4242
- --column-b-color:#eeeeee;
4243
- --column-b-hover-color:#ffffff;
4244
-
4245
- position: relative;
4246
- background: var(--column-b-color);
4247
- border:1px solid var(--column-bd-color);
4248
-
4249
- display:flex;
4250
- flex-direction: column;
4251
- flex:1;
4252
- overflow: overlay;
4253
-
4254
-
4255
-
4256
-
4257
- &.row-highlightable{
4258
- tbody{
4259
- tr:not(.jr-group-header,.jr-group-footer):hover{
4260
- background:var(--column-b-hover-color);
4261
- cursor: pointer;
4262
- transition: background-color .8s;
4263
- td{
4264
- color:black;
4265
- transition:color .8s;
4266
- }
4267
-
4268
- }
4269
- }
4270
- }
4271
-
4272
- table{
4273
- Xheight: 100%;
4274
- min-width:100%;
4275
- width: max-content;
4276
- border-spacing: 0;
4277
-
4278
- thead{
4279
- position: sticky;
4280
- top: 0;
4281
-
4282
- th{
4283
- position: relative;
4284
- padding: 2px 6px;
4285
- background: linear-gradient(180deg, rgba(227, 227, 226, 1) 0%, rgba(255, 255, 255, 1) 25%, rgba(210, 210, 210, 1) 100%);
4286
- box-shadow: 2px 2px 2px 0 #ffffffd6 inset, -1px -1px 2px 0px #8a847dbf inset;
4287
- color: #525252;
4288
- white-space: nowrap;
4289
- }
4290
- }
4291
-
4292
- tfoot{
4293
- position: sticky;
4294
- bottom: -1px;
4295
-
4296
- Xtr:nth-child(1){
4297
- th{
4298
- Xborder-top:1px solid var(--column-bd-color);
4299
- }
4300
- }
4301
- Xth:nth-child(1){
4302
- Xborder-left:1px solid var(--column-bd-color);
4303
- }
4304
-
4305
- th{
4306
- height:32px;
4307
- padding: 4px;
4308
- background: #e4e4e4;
4309
- xbackground: linear-gradient(180deg, rgba(227, 227, 226, 1) 0%, rgba(255, 255, 255, 1) 25%, rgba(210, 210, 210, 1) 100%);
4310
- xbox-shadow: 2px 2px 2px 0 #ffffffd6 inset, -1px -1px 2px 0px #8a847dbf inset;
4311
- color: #525252;
4312
- white-space: nowrap;
4313
-
4314
- border-left:2px solid #f4f4f4;
4315
- border-top:2px solid #f4f4f4;
4316
- border-right:2px solid var(--column-bd-color);
4317
- border-bottom:2px solid var(--column-bd-color);
4318
- }
4319
- }
4320
-
4321
- tbody{
4322
- tr{
4323
- transition: background .3s linear;
4324
- background:var(--column-b-color);
4325
- a:#ededed;
4326
- th{
4327
- color:#444444;
4328
- }
4329
- td{
4330
- border-bottom: 1px solid var(--column-bd-color);
4331
- color:#2e2e2e;
4332
- padding: 4px;
4333
- }
4334
- }
4335
- tr:hover{
4336
- background:var(--column-b-hover-color);
4337
-
4338
- }
4339
-
4340
- tr.jr-group-header
4341
- ,tr.jr-group-footer{
4342
- text-align:left;
4343
- background:#dddbdb;
4344
-
4345
- th{
4346
- border-bottom: 1px solid var(--column-bd-color);
4347
- border-right: 1px solid var(--column-bd-color);
4348
- padding: 4px 8px;
4349
- }
4350
- }
4351
- }
4352
- tbody.empty-tbody{
4353
- td{
4354
- border:10px solid red;
4355
- }
4356
- }
4357
- }
4358
-
4359
-
4360
-
4361
-
4362
- > .empty{
4363
- user-select: none;
4364
- color:#848484;
4365
- height:100%;
4366
- flex:1;
4367
- display:flex;
4368
- justify-content: center;
4369
- align-items: center;
4370
- }
4371
- `;
4372
-
4373
- var _path;
4374
- function _extends() { return _extends = 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.apply(null, arguments); }
4375
- var SvgX = function SvgX(props) {
4376
- return /*#__PURE__*/React.createElement("svg", _extends({
4377
- xmlns: "http://www.w3.org/2000/svg",
4378
- width: 24,
4379
- height: 24,
4380
- fill: "none",
4381
- stroke: "currentColor",
4382
- strokeLinecap: "round",
4383
- strokeLinejoin: "round",
4384
- strokeWidth: 2,
4385
- viewBox: "0 0 24 24"
4386
- }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
4387
- d: "M18 6 6 18M6 6l12 12"
4388
- })));
4389
- };
4390
-
4391
- function JRButton({
4392
- icon,
4393
- children,
4394
- ...props
4395
- }) {
4396
- return /*#__PURE__*/React__default.createElement("button", props, icon, children);
4397
- }
4398
-
4399
- const StyledTitle = styled.div`
4400
- overflow: hidden;
4401
- display: flex;
4402
- border-radius: var(--jr-window-radius) var(--jr-window-radius) 0 0;
4403
- background:rgb(214, 214, 214);
4404
- color: black;
4405
- &:active:hover{
4406
- cursor: grabbing;
4407
4292
  }
4408
-
4409
- -webkit-user-select: none;
4410
- -khtml-user-select: none;
4411
- -moz-user-select: none;
4412
- -o-user-select: none;
4413
- user-select: none;
4414
-
4415
- > .title{
4416
-
4417
- flex: 1;
4418
- padding:2px 0 2px 8px;
4419
- text-overflow: ellipsis;
4420
- overflow: hidden;
4421
- white-space: nowrap;
4293
+ };
4294
+ resizeN = ({
4295
+ window,
4296
+ cursorY,
4297
+ startY,
4298
+ startHeight,
4299
+ titleBarHeight
4300
+ }) => {
4301
+ let y = cursorY - this.props.thick;
4302
+ if (y < 0) y = 0;
4303
+ let height = startHeight + (startY - y);
4304
+ if (height < titleBarHeight + this.props.thick * 2) {
4305
+ height = titleBarHeight + this.props.thick * 2;
4306
+ y = startY + startHeight - titleBarHeight - this.props.thick * 2;
4422
4307
  }
4423
- > nav{
4424
- display: flex;
4425
- align-items: anchor-center;
4426
-
4427
-
4428
- >button{
4429
- display:flex;
4430
- align-items: center;
4431
- justify-content: center;
4432
- border: unset;
4433
- background: unset;
4434
- cursor: pointer;
4435
- width:32px;
4436
- height:32px;
4437
- xborder:1px solid green;
4438
- padding: 0;
4439
- margin: 0;
4440
- &:hover{
4441
- background: #bbbbbb;
4442
- color:white;
4443
- }
4444
- >svg{
4445
- color:black;
4446
- width:14px;
4447
- height:14px;
4448
- cursor: pointer;
4449
- }
4450
- }
4451
- >button.danger:hover{
4452
- background: red;
4453
- >svg{
4454
- color:white;
4455
- }
4456
- }
4308
+ window.style.top = `${y}px`;
4309
+ window.style.height = `${height}px`;
4310
+ };
4311
+ resizeE = ({
4312
+ window,
4313
+ clientX,
4314
+ left,
4315
+ titleBarHeight
4316
+ }) => {
4317
+ let width = clientX - left - this.props.thick;
4318
+ if (width < titleBarHeight) width = titleBarHeight;
4319
+ window.style.width = `${width + this.props.thick * 2}px`;
4320
+ };
4321
+ resizeS = ({
4322
+ window,
4323
+ clientY,
4324
+ top,
4325
+ titleBarHeight
4326
+ }) => {
4327
+ let height = clientY - top - this.props.thick;
4328
+ if (height < titleBarHeight) height = titleBarHeight;
4329
+ window.style.height = `${height + this.props.thick * 2}px`;
4330
+ };
4331
+ resizeW = ({
4332
+ window,
4333
+ cursorX,
4334
+ startX,
4335
+ startWidth,
4336
+ titleBarHeight
4337
+ }) => {
4338
+ let x = cursorX - this.props.thick;
4339
+ if (x < 0) x = 0;
4340
+ let width = startWidth + (startX - x);
4341
+ if (width < titleBarHeight + this.props.thick * 2) {
4342
+ width = titleBarHeight + this.props.thick * 2;
4343
+ x = startX + startWidth - titleBarHeight - this.props.thick * 2;
4457
4344
  }
4458
- `;
4459
- class TitleBar extends React__default.Component {
4460
- pos1 = 0;
4461
- pos2 = 0;
4462
- pos3 = 0;
4463
- pos4 = 0;
4464
- x = 0;
4465
- y = 0;
4466
- stop = e => {
4467
- e.preventDefault();
4468
- if (this.moved) {
4469
- const {
4470
- clientX,
4471
- clientY
4472
- } = e;
4473
- const {
4474
- height: titleBarHeight
4475
- } = this.props.titleBarRef.current.getBoundingClientRect();
4476
- const {
4477
- x,
4478
- y,
4479
- width,
4480
- height
4481
- } = 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`;
4493
- if (x + width - this.props.thick < 0) this.props.windowRef.current.style.left = 0;
4494
- if (x > window.innerWidth) this.props.windowRef.current.style.left = `${window.innerWidth - width}px`;
4495
- document.body.style.cursor = 'default';
4345
+ window.style.left = `${x}px`;
4346
+ window.style.width = `${width}px`;
4347
+ };
4348
+ stop = e => {
4349
+ e.preventDefault();
4350
+ const {
4351
+ height: titleBarHeight
4352
+ } = this.props.titleBarRef.current.getBoundingClientRect();
4353
+ const {
4354
+ x,
4355
+ y,
4356
+ width,
4357
+ height
4358
+ } = this.props.windowRef.current.getBoundingClientRect();
4359
+ this.props.windowRef.current.style.transition = 'var(--transition-x-y)';
4360
+ if (y == 0 && this.data.direction.indexOf('n') > -1) {
4361
+ this.props.window.orgHeight = height;
4362
+ this.props.windowRef.current.style.height = `${window.innerHeight}px`;
4496
4363
  }
4364
+ if (y > window.innerHeight) this.props.windowRef.current.style.top = `${window.innerHeight - titleBarHeight}px`;
4365
+ if (x + width - this.props.thick < 0) this.props.windowRef.current.style.left = 0;
4366
+ if (x > window.innerWidth) this.props.windowRef.current.style.left = `${window.innerWidth - width}px`;
4367
+ document.body.style.cursor = 'default';
4497
4368
  window.removeEventListener('mousemove', this.move);
4498
- window.removeEventListener('mouseup', this.stop);
4499
4369
  window.removeEventListener('mousemove', this.preMove);
4370
+ window.removeEventListener('mouseup', this.stop);
4500
4371
  };
4501
4372
  move = e => {
4502
4373
  e.preventDefault();
4503
- this.moved = true;
4374
+ this.props.windowRef.current.style.transition = 'unset';
4504
4375
  const {
4505
4376
  clientX,
4506
- clientY
4377
+ clientY,
4378
+ x: cursorX,
4379
+ y: cursorY
4507
4380
  } = e;
4508
- const y = clientY < 1 ? 0 : clientY;
4509
- this.pos1 = this.pos3 - clientX;
4510
- this.pos2 = this.pos4 - y;
4511
- this.pos3 = clientX;
4512
- this.pos4 = y;
4513
- const w = this.props.windowRef.current;
4514
- this.y = w.offsetTop - this.pos2;
4515
- 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
- }
4523
- this.y = this.y < -this.props.thick ? -this.props.thick : this.y;
4524
- w.style.transition = 'unset';
4525
- w.style.top = `${this.y}px`;
4526
- w.style.left = `${this.x}px`;
4527
- };
4528
- preMove = e => {
4529
- const w = this.props.windowRef.current;
4381
+ const window = this.props.windowRef.current;
4530
4382
  const {
4383
+ left,
4384
+ top
4385
+ } = window.getBoundingClientRect();
4386
+ let {
4387
+ x: startX,
4388
+ width: startWidth,
4389
+ y: startY,
4390
+ height: startHeight,
4391
+ titleBarHeight
4392
+ } = this.data;
4393
+ this.directions[this.props.direction].resize({
4394
+ window,
4395
+ titleBarHeight,
4531
4396
  clientX,
4532
- clientY
4533
- } = 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) {
4539
- w.style.height = `${this.props.window.orgHeight}px`;
4397
+ cursorX,
4398
+ startX,
4399
+ startWidth,
4400
+ left,
4401
+ clientY,
4402
+ cursorY,
4403
+ startY,
4404
+ startHeight,
4405
+ top
4406
+ });
4407
+ };
4408
+ preMove = () => {
4409
+ if (this.props.direction.indexOf('n') > -1) {
4410
+ this.props.windowRef.current.style.height = `${this.props.window.orgHeight}px`;
4411
+ this.data.height = this.props.window.orgHeight;
4540
4412
  this.props.window.orgHeight = null;
4541
4413
  }
4542
- w.style.transition = 'left .1s ease-in, height .1s ease-in';
4414
+ window.removeEventListener('mousemove', this.preMove);
4543
4415
  setTimeout(() => {
4544
4416
  window.addEventListener('mousemove', this.move);
4545
4417
  }, 100);
4546
- window.removeEventListener('mousemove', this.preMove);
4547
4418
  };
4548
- start(e) {
4419
+ start = (e, direction) => {
4549
4420
  e.preventDefault();
4550
- this.moved = false;
4551
- this.pos3 = e.clientX;
4552
- this.pos4 = e.clientY;
4553
- this.props.windowRef.current.style.transition = 'var(--transition-x-y)';
4554
- document.body.style.cursor = 'grabbing';
4555
- window.addEventListener('mousemove', this.preMove);
4421
+ const {
4422
+ height: titleBarHeight
4423
+ } = this.props.titleBarRef.current.getBoundingClientRect();
4424
+ let {
4425
+ x,
4426
+ y,
4427
+ width,
4428
+ height
4429
+ } = this.props.windowRef.current.getBoundingClientRect();
4430
+ if (this.props.direction.indexOf('s') > -1) {
4431
+ this.props.window.orgHeight = null;
4432
+ }
4433
+ this.data = {
4434
+ x,
4435
+ y,
4436
+ width,
4437
+ height,
4438
+ titleBarHeight,
4439
+ direction
4440
+ };
4441
+ document.body.style.cursor = this.directions[this.props.direction].cursor;
4442
+ if (this.props.window.orgHeight) {
4443
+ window.addEventListener('mousemove', this.preMove);
4444
+ } else {
4445
+ window.addEventListener('mousemove', this.move);
4446
+ }
4556
4447
  window.addEventListener('mouseup', this.stop);
4557
- }
4448
+ };
4558
4449
  render() {
4559
- return /*#__PURE__*/React__default.createElement(StyledTitle, {
4560
- ref: this.props.titleBarRef,
4561
- draggable: "false",
4450
+ return /*#__PURE__*/React__default.createElement(StyledSlider$1, {
4451
+ $direction: this.directions[this.props.direction],
4452
+ $padding: this.props.padding,
4562
4453
  onMouseDown: e => {
4563
- this.start(e);
4564
- }
4565
- }, /*#__PURE__*/React__default.createElement(FreeType$1, {
4566
- tag: "div",
4567
- config: this.props.title ?? '',
4568
- me: this.props.window,
4569
- className: 'title'
4570
- }), /*#__PURE__*/React__default.createElement("nav", null, this.props.window.props.setOpen ? /*#__PURE__*/React__default.createElement(JRButton, {
4571
- icon: /*#__PURE__*/React__default.createElement(SvgX, null),
4572
- className: 'danger',
4573
- onClick: () => {
4574
- this.props.window.props.setOpen(false);
4454
+ this.start(e, this.props.direction);
4575
4455
  }
4576
- }) : null));
4456
+ });
4577
4457
  }
4578
4458
  }
4579
4459
 
4580
- const directions = ['n', 'e', 's', 'w', 'nww', 'nnw', 'nne', 'nee', 'sse', 'see', 'sww', 'ssw'];
4581
- class Sliders extends React__default.Component {
4582
- render() {
4583
- return directions.map((direction, index) => /*#__PURE__*/React__default.createElement(Slider, {
4584
- direction: direction,
4585
- thick: this.props.thick,
4586
- windowRef: this.props.windowRef,
4587
- window: this.props.window,
4588
- titleBarRef: this.props.titleBarRef,
4589
- key: index
4590
- }));
4591
- }
4592
- }
4593
- const StyledSlider = styled.div`
4594
- Xborder:1px solid ${({
4595
- $direction: {
4596
- color
4460
+ function styleInject(css, ref) {
4461
+ if ( ref === void 0 ) ref = {};
4462
+ var insertAt = ref.insertAt;
4463
+
4464
+ if (!css || typeof document === 'undefined') { return; }
4465
+
4466
+ var head = document.head || document.getElementsByTagName('head')[0];
4467
+ var style = document.createElement('style');
4468
+ style.type = 'text/css';
4469
+
4470
+ if (insertAt === 'top') {
4471
+ if (head.firstChild) {
4472
+ head.insertBefore(style, head.firstChild);
4473
+ } else {
4474
+ head.appendChild(style);
4475
+ }
4476
+ } else {
4477
+ head.appendChild(style);
4597
4478
  }
4598
- }) => color};
4599
- Xbackground:${({
4600
- $direction: {
4601
- color
4479
+
4480
+ if (style.styleSheet) {
4481
+ style.styleSheet.cssText = css;
4482
+ } else {
4483
+ style.appendChild(document.createTextNode(css));
4602
4484
  }
4603
- }) => color};
4604
- position: absolute;
4485
+ }
4486
+
4487
+ 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}";
4488
+ var style = {"test":"Style-module_test__LrdEc","withMask":"Style-module_withMask__LPcai"};
4489
+ styleInject(css_248z);
4490
+
4491
+ const StyledJRWindow = styled.div`
4492
+ --jr-window-radius:3px;
4493
+ --padding-child:8px;
4494
+ --transition-x-y:height .05s ease-in, width .05s ease-in;
4495
+ xborder:1px solid gray;
4496
+ position: fixed;
4497
+ padding: ${({
4498
+ $thick
4499
+ }) => $thick}px;
4500
+ border-radius: var(--jr-window-radius);
4501
+ user-select: text;
4502
+
4605
4503
  top: ${({
4606
- $direction: {
4607
- top
4504
+ $y
4505
+ }) => $y}px;
4506
+ left: ${({
4507
+ $x
4508
+ }) => $x}px;
4509
+ width: ${({
4510
+ $width = 300
4511
+ }) => `${$width}px`};
4512
+ height: ${({
4513
+ $height = 300
4514
+ }) => `${$height}px`};
4515
+ overflow: hidden;
4516
+ z-index: 2;
4517
+
4518
+ display: flex;
4519
+ flex-direction: column;
4520
+ overflow: hidden;
4521
+
4522
+ > main{
4523
+ border-radius: var(--jr-window-radius);
4524
+ box-shadow: 0px 0px 5px 1px gray;
4525
+ display: flex;
4526
+ flex-direction: column;
4527
+ overflow: hidden;
4528
+ flex:1;
4529
+ > main {
4530
+ Xpadding:var(--padding-child);
4531
+ overflow: overlay;
4532
+ flex:1;
4533
+ display: flex;
4534
+ min-height:32px;
4535
+ }
4536
+ }
4537
+
4538
+ `;
4539
+ class JRWindow extends JRFrame {
4540
+ x = 0;
4541
+ y = 0;
4542
+ width = 300;
4543
+ height = 300;
4544
+ padding = 1;
4545
+ thick = 5;
4546
+ constructor(props) {
4547
+ super(props);
4548
+ this.ref = /*#__PURE__*/React__default.createRef();
4549
+ this.titleBarRef = /*#__PURE__*/React__default.createRef();
4550
+ this.init();
4608
4551
  }
4609
- }) => top};
4610
- bottom: ${({
4611
- $direction: {
4612
- bottom
4552
+ addMaskToTarget = target => {
4553
+ this.mask = document.createElement('div');
4554
+ this.mask.style.background = '#868686cc';
4555
+ this.mask.style.position = 'absolute';
4556
+ this.mask.style.top = '0';
4557
+ this.mask.style.left = '0';
4558
+ this.mask.style.right = '0';
4559
+ this.mask.style.bottom = '0';
4560
+ this.mask.style.borderRadius = 'inherit';
4561
+ this.mask.style.height = '10000px';
4562
+ this.mask.style.width = '10000px';
4563
+ target.appendChild(this.mask);
4564
+ po('style.mask', style.mask);
4565
+ po('addMask+++++++++++++++++++++++++++');
4566
+ };
4567
+ removeMaskFromTarget = () => {
4568
+ po('removeMask-----------------------');
4569
+ this.mask.remove();
4570
+ };
4571
+ maskOnTarget(on) {
4572
+ po('typeof this.props.maskOn', typeof this.props.maskOn);
4573
+ const target = typeof this.props.maskOn === 'object' ? this.props.maskOn : typeof this.props.maskOn === 'string' ? document.getElementById(this.props.maskOn) : document.body;
4574
+
4575
+ // this[on?'addMaskToTarget':'removeMaskFromTarget'](target)
4576
+ target?.classList[on ? 'add' : 'remove']('withMask');
4613
4577
  }
4614
- }) => bottom};
4615
- right: ${({
4616
- $direction: {
4617
- right
4578
+ componentDidMount() {
4579
+ super.componentDidMount();
4580
+ if (this.props.maskOn && this.props.open) {
4581
+ this.maskOnTarget(this.props.open);
4582
+ }
4583
+ if (this.props.open) {
4584
+ this.open();
4585
+ }
4618
4586
  }
4619
- }) => right};
4620
- left: ${({
4621
- $direction: {
4622
- left
4587
+ open() {
4588
+ this.props.onOpen?.bind(this)();
4623
4589
  }
4624
- }) => left};
4625
- height: ${({
4626
- $direction: {
4627
- height
4590
+ close() {
4591
+ this.props.onClose?.bind(this)();
4628
4592
  }
4629
- }) => height};
4630
- width: ${({
4631
- $direction: {
4632
- width
4593
+ componentDidUpdate(prevProps, prevState, snapshot) {
4594
+ if (this.props.popup === true) {
4595
+ if (this.props.open && prevProps.open === false) {
4596
+ this.open();
4597
+ } else if (this.props.open === false && prevProps.open) {
4598
+ this.close();
4599
+ }
4600
+ if (this.props.maskOn && this.props.open != prevProps.open) {
4601
+ this.maskOnTarget(this.props.open);
4602
+ }
4603
+ }
4633
4604
  }
4634
- }) => width};
4635
- cursor: ${({
4636
- $direction: {
4637
- cursor
4605
+ init() {
4606
+ this.height = window.innerHeight >= (this.props.height ?? this.height) ? this.props.height ?? this.height : window.innerHeight;
4607
+ this.width = window.innerWidth >= (this.props.width ?? this.width) ? this.props.width ?? this.width : window.innerWidth;
4608
+ this.x = this.props.x ?? (window.innerWidth - (this.width ?? 300)) / 2;
4609
+ this.y = this.props.y ?? (window.innerHeight - (this.height ?? 300)) / 2;
4638
4610
  }
4639
- }) => cursor};
4611
+ renderer() {
4612
+ return this.props.popup === true ? this.props.open ? /*#__PURE__*/React__default.createElement(StyledJRWindow, {
4613
+ ref: this.ref,
4614
+ className: `jr-window ${this.props.className ?? ''}`,
4615
+ $x: this.x,
4616
+ $y: this.y,
4617
+ $width: this.width,
4618
+ $height: this.height,
4619
+ $thick: this.thick
4620
+ }, /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(TitleBar, {
4621
+ titleBarRef: this.titleBarRef,
4622
+ windowRef: this.ref,
4623
+ window: this,
4624
+ title: this.props.title,
4625
+ thick: this.thick
4626
+ }), /*#__PURE__*/React__default.createElement("main", null, super.renderer())), /*#__PURE__*/React__default.createElement(Sliders, {
4627
+ thick: this.thick,
4628
+ windowRef: this.ref,
4629
+ window: this,
4630
+ titleBarRef: this.titleBarRef
4631
+ })) : '' : super.renderer();
4632
+ }
4633
+ }
4640
4634
 
4641
- -webkit-user-select: none;
4642
- -khtml-user-select: none;
4643
- -moz-user-select: none;
4644
- -o-user-select: none;
4635
+ const StyledSlider = styled.div`
4636
+ position: absolute;
4637
+ top: 0;
4638
+ right: 0;
4639
+ height:100%;
4640
+ width:6px;
4645
4641
  user-select: none;
4646
-
4642
+ &.resizing:hover,&.resizing{
4643
+ border-right:1px dashed black;
4644
+ }
4645
+ &:hover{
4646
+ cursor: col-resize;
4647
+ border-right:1px dashed gray;
4648
+ }
4647
4649
  `;
4648
4650
  class Slider extends React__default.Component {
4649
- width = '3px';
4650
- borderWidth = 'px';
4651
- borderLong = 5;
4652
- constructor(props) {
4653
- super(props);
4651
+ constructor() {
4652
+ super();
4654
4653
  this.sliderRef = /*#__PURE__*/React__default.createRef();
4655
4654
  }
4656
- directions = {
4657
- n: {
4658
- top: 0,
4659
- color: 'red',
4660
- width: '100%',
4661
- height: `${this.props.thick}px`,
4662
- cursor: 'n-resize',
4663
- resize: props => {
4664
- this.resizeN(props);
4665
- }
4666
- },
4667
- e: {
4668
- color: 'yellow',
4669
- right: 0,
4670
- width: `${this.props.thick}px`,
4671
- height: '100%',
4672
- cursor: 'e-resize',
4673
- resize: props => {
4674
- this.resizeE(props);
4675
- }
4676
- },
4677
- s: {
4678
- color: 'blue',
4679
- bottom: 0,
4680
- width: '100%',
4681
- height: `${this.props.thick}px`,
4682
- cursor: 's-resize',
4683
- resize: props => {
4684
- this.resizeS(props);
4685
- }
4686
- },
4687
- w: {
4688
- color: 'green',
4689
- left: 0,
4690
- width: `${this.props.thick}px`,
4691
- height: '100%',
4692
- cursor: 'w-resize',
4693
- resize: props => {
4694
- this.resizeW(props);
4695
- }
4696
- },
4697
- nw: {
4698
- top: 0,
4699
- left: 0,
4700
- color: 'blue',
4701
- width: `${this.borderLong}px`,
4702
- height: `${this.borderLong}px`,
4703
- cursor: 'nw-resize',
4704
- resize: props => {
4705
- this.resizeN(props);
4706
- this.resizeW(props);
4707
- }
4708
- },
4709
- nww: {
4710
- top: 0,
4711
- left: 0,
4712
- color: 'blue',
4713
- width: `${this.props.thick + this.borderLong}px`,
4714
- height: `${this.props.thick}px`,
4715
- cursor: 'nw-resize',
4716
- resize: props => {
4717
- this.resizeN(props);
4718
- this.resizeW(props);
4719
- }
4720
- },
4721
- nnw: {
4722
- top: 0,
4723
- left: 0,
4724
- color: 'blue',
4725
- width: `${this.props.thick}px`,
4726
- height: `${this.props.thick + this.borderLong}px`,
4727
- cursor: 'nw-resize',
4728
- resize: props => {
4729
- this.resizeN(props);
4730
- this.resizeW(props);
4731
- }
4732
- },
4733
- nne: {
4734
- top: 0,
4735
- right: 0,
4736
- color: 'green',
4737
- width: `${this.props.thick + this.borderLong}px`,
4738
- height: `${this.props.thick}px`,
4739
- cursor: 'ne-resize',
4740
- resize: props => {
4741
- this.resizeN(props);
4742
- this.resizeE(props);
4743
- }
4744
- },
4745
- nee: {
4746
- top: 0,
4747
- right: 0,
4748
- color: 'green',
4749
- width: `${this.props.thick}px`,
4750
- height: `${this.props.thick + this.borderLong}px`,
4751
- cursor: 'ne-resize',
4752
- resize: props => {
4753
- this.resizeN(props);
4754
- this.resizeE(props);
4755
- }
4756
- },
4757
- sse: {
4758
- color: 'red',
4759
- right: 0,
4760
- bottom: 0,
4761
- width: `${this.props.thick + this.borderLong}px`,
4762
- height: `${this.props.thick}px`,
4763
- cursor: 'se-resize',
4764
- resize: props => {
4765
- this.resizeS(props);
4766
- this.resizeE(props);
4767
- }
4768
- },
4769
- see: {
4770
- color: 'red',
4771
- right: 0,
4772
- bottom: 0,
4773
- width: `${this.props.thick}px`,
4774
- height: `${this.props.thick + this.borderLong}px`,
4775
- cursor: 'se-resize',
4776
- resize: props => {
4777
- this.resizeS(props);
4778
- this.resizeE(props);
4779
- }
4780
- },
4781
- ssw: {
4782
- color: 'yellow',
4783
- bottom: 0,
4784
- left: 0,
4785
- width: `${this.props.thick + this.borderLong}px`,
4786
- height: `${this.props.thick}px`,
4787
- cursor: 'sw-resize',
4788
- resize: props => {
4789
- this.resizeS(props);
4790
- this.resizeW(props);
4791
- }
4792
- },
4793
- sww: {
4794
- color: 'yellow',
4795
- bottom: 0,
4796
- left: 0,
4797
- width: `${this.props.thick}px`,
4798
- height: `${this.props.thick + this.borderLong}px`,
4799
- cursor: 'sw-resize',
4800
- resize: props => {
4801
- this.resizeS(props);
4802
- this.resizeW(props);
4655
+ stop = e => {
4656
+ this.sliderRef.current.classList.remove('resizing');
4657
+ document.body.style.cursor = 'default';
4658
+ window.removeEventListener('mousemove', this.move);
4659
+ window.removeEventListener('mouseup', this.stop);
4660
+ };
4661
+ move = ({
4662
+ clientX
4663
+ }) => {
4664
+ const {
4665
+ th,
4666
+ selectedCols,
4667
+ widthRates
4668
+ } = this.data;
4669
+ const {
4670
+ left
4671
+ } = th.getBoundingClientRect();
4672
+ const min = left + 10;
4673
+ const x = clientX >= min ? clientX : min;
4674
+ const width = x - left;
4675
+ selectedCols.forEach((col, index) => {
4676
+ const _width = Math.round(width / 100 * widthRates[index]);
4677
+ col.style.width = _width + 'px';
4678
+ });
4679
+ };
4680
+ start(thPRef, column) {
4681
+ const selectedCols = [...this.props.table.colGroupRef.current.children].slice(column.columnNo, column.columnNo + (column.colSpan ?? 1));
4682
+ const totalWidth = selectedCols.reduce((aco, {
4683
+ offsetWidth
4684
+ }) => aco + offsetWidth, 0);
4685
+ const widthRates = selectedCols.map(({
4686
+ offsetWidth
4687
+ }) => {
4688
+ return 100 * (offsetWidth / totalWidth);
4689
+ });
4690
+ this.data = {
4691
+ selectedCols,
4692
+ th: thPRef.current,
4693
+ widthRates
4694
+ };
4695
+ this.sliderRef.current.classList.add('resizing');
4696
+ document.body.style.cursor = 'col-resize';
4697
+ window.addEventListener('mousemove', this.move);
4698
+ window.addEventListener('mouseup', this.stop);
4699
+ }
4700
+ render() {
4701
+ const column = this.props.column;
4702
+ return /*#__PURE__*/React__default.createElement(StyledSlider, {
4703
+ ref: this.sliderRef,
4704
+ onMouseDown: e => {
4705
+ this.start(this.props.thRef, column);
4803
4706
  }
4707
+ });
4708
+ }
4709
+ }
4710
+
4711
+ const Colgroup = ({
4712
+ leafColumns,
4713
+ colGroupRef
4714
+ }) => {
4715
+ return /*#__PURE__*/React__default.createElement("colgroup", {
4716
+ ref: colGroupRef
4717
+ }, leafColumns?.map((_column, index) => {
4718
+ const {
4719
+ width,
4720
+ ...column
4721
+ } = _column;
4722
+ const style = {
4723
+ width
4724
+ };
4725
+ return /*#__PURE__*/React__default.createElement("col", {
4726
+ style: style,
4727
+ key: index
4728
+ });
4729
+ }));
4730
+ };
4731
+ const Ths$1 = ({
4732
+ deep,
4733
+ rowColumn,
4734
+ rowIndex,
4735
+ table
4736
+ }) => {
4737
+ return rowColumn?.map((column, colIndex) => {
4738
+ const thRef = /*#__PURE__*/React__default.createRef();
4739
+ return /*#__PURE__*/React__default.createElement("th", {
4740
+ key: colIndex,
4741
+ ref: thRef,
4742
+ colSpan: column.colSpan,
4743
+ rowSpan: column.rowSpan ?? (column.isLeaf && deep > rowIndex ? deep - rowIndex + 1 : null)
4744
+ }, flexType(column.label, table), (table.props.resizableColumns === undefined || table.props.resizableColumns) && /*#__PURE__*/React__default.createElement(Slider, {
4745
+ table: table,
4746
+ thRef: thRef,
4747
+ column: column
4748
+ }));
4749
+ });
4750
+ };
4751
+ const HeadTrs = ({
4752
+ columns: _columns,
4753
+ trClassName,
4754
+ table
4755
+ }) => {
4756
+ const columns = Array.isArray(_columns?.[0]) ? _columns : [_columns];
4757
+ return columns?.map((rowColumn, rowIndex) => {
4758
+ return /*#__PURE__*/React__default.createElement("tr", {
4759
+ className: trClassName,
4760
+ key: rowIndex
4761
+ }, /*#__PURE__*/React__default.createElement(Ths$1, {
4762
+ deep: columns.length - 1,
4763
+ rowColumn: rowColumn,
4764
+ rowIndex: rowIndex,
4765
+ table: table
4766
+ }));
4767
+ });
4768
+ };
4769
+ const THead = ({
4770
+ columns,
4771
+ leafColumns,
4772
+ table
4773
+ }) => {
4774
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement(HeadTrs, {
4775
+ columns: columns,
4776
+ table: table
4777
+ })), /*#__PURE__*/React__default.createElement(Colgroup, {
4778
+ leafColumns: leafColumns,
4779
+ colGroupRef: table.colGroupRef
4780
+ }));
4781
+ };
4782
+ const FootThs = ({
4783
+ table,
4784
+ groupData,
4785
+ groupIndex,
4786
+ deep,
4787
+ columns,
4788
+ rowIndex
4789
+ }) => {
4790
+ return columns?.map((column, colIndex) => {
4791
+ // let content
4792
+ // if(type){
4793
+ // content='type'
4794
+ // }else if(render){
4795
+
4796
+ // content=render?.bind(table)({groupData,groupIndex,ths:111})
4797
+ // }else{
4798
+ // content=column.label
4799
+ // }
4800
+ let style = flexType(column.style, table, {}, {});
4801
+ const content = whatType(column, table, column.label);
4802
+ return /*#__PURE__*/React__default.createElement("th", {
4803
+ style: style,
4804
+ colSpan: column.colSpan,
4805
+ rowSpan: column.rowSpan
4806
+ }, content);
4807
+ });
4808
+ };
4809
+ const TFoot = ({
4810
+ table,
4811
+ columns
4812
+ }) => {
4813
+ const trs = columns?.map((rowColumn, rowIndex) => {
4814
+ return /*#__PURE__*/React__default.createElement("tr", {
4815
+ key: rowIndex
4816
+ }, /*#__PURE__*/React__default.createElement(FootThs, {
4817
+ columns: rowColumn,
4818
+ table: table
4819
+ }));
4820
+ });
4821
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("tfoot", null, trs));
4822
+ };
4823
+
4824
+ function _extends() {
4825
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
4826
+ for (var e = 1; e < arguments.length; e++) {
4827
+ var t = arguments[e];
4828
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
4804
4829
  }
4805
- };
4806
- resizeN = ({
4807
- window,
4808
- cursorY,
4809
- startY,
4810
- startHeight,
4811
- titleBarHeight
4812
- }) => {
4813
- let y = cursorY - this.props.thick;
4814
- if (y < 0) y = 0;
4815
- let height = startHeight + (startY - y);
4816
- if (height < titleBarHeight + this.props.thick * 2) {
4817
- height = titleBarHeight + this.props.thick * 2;
4818
- y = startY + startHeight - titleBarHeight - this.props.thick * 2;
4830
+ return n;
4831
+ }, _extends.apply(null, arguments);
4832
+ }
4833
+
4834
+ styled.tbody`
4835
+ th{
4836
+ height:4px;
4837
+ background:#c6c6c6;
4819
4838
  }
4820
- window.style.top = `${y}px`;
4821
- window.style.height = `${height}px`;
4822
- };
4823
- resizeE = ({
4824
- window,
4825
- clientX,
4826
- left,
4827
- titleBarHeight
4828
- }) => {
4829
- let width = clientX - left - this.props.thick;
4830
- if (width < titleBarHeight) width = titleBarHeight;
4831
- window.style.width = `${width + this.props.thick * 2}px`;
4832
- };
4833
- resizeS = ({
4834
- window,
4835
- clientY,
4836
- top,
4837
- titleBarHeight
4838
- }) => {
4839
- let height = clientY - top - this.props.thick;
4840
- if (height < titleBarHeight) height = titleBarHeight;
4841
- window.style.height = `${height + this.props.thick * 2}px`;
4842
- };
4843
- resizeW = ({
4844
- window,
4845
- cursorX,
4846
- startX,
4847
- startWidth,
4848
- titleBarHeight
4849
- }) => {
4850
- let x = cursorX - this.props.thick;
4851
- if (x < 0) x = 0;
4852
- let width = startWidth + (startX - x);
4853
- if (width < titleBarHeight + this.props.thick * 2) {
4854
- width = titleBarHeight + this.props.thick * 2;
4855
- x = startX + startWidth - titleBarHeight - this.props.thick * 2;
4839
+ `;
4840
+
4841
+ ////////////////////////////////////////////////////////////////////////////
4842
+
4843
+ const Ths = ({
4844
+ table,
4845
+ groupData,
4846
+ groupIndex,
4847
+ deep,
4848
+ rowColumn,
4849
+ rowIndex
4850
+ }) => {
4851
+ return rowColumn?.map(({
4852
+ style: _style,
4853
+ align,
4854
+ type,
4855
+ render,
4856
+ ...column
4857
+ }, colIndex) => {
4858
+ const style = flexType(_style, table, {}, {});
4859
+ let content;
4860
+ if (type) {
4861
+ content = 'type';
4862
+ } else if (render) {
4863
+ content = render?.bind(table)({
4864
+ groupData,
4865
+ groupIndex,
4866
+ ths: 111
4867
+ });
4868
+ } else {
4869
+ content = column.label;
4870
+ }
4871
+ // style.textAlign=align
4872
+ return /*#__PURE__*/React__default.createElement("th", {
4873
+ key: colIndex,
4874
+ style: {
4875
+ textAlign: align,
4876
+ ...style
4877
+ },
4878
+ colSpan: column.colSpan,
4879
+ rowSpan: column.isLeaf && deep > rowIndex ? deep - rowIndex + 1 : null
4880
+ }, content);
4881
+ });
4882
+ };
4883
+ const GroupColumns = ({
4884
+ table,
4885
+ columns: _columns,
4886
+ trClassName,
4887
+ groupData,
4888
+ tbodyIndex
4889
+ }) => {
4890
+ const columns = Array.isArray(_columns?.[0]) ? _columns : [_columns];
4891
+ return columns?.map((rowColumn, rowIndex) => {
4892
+ return /*#__PURE__*/React__default.createElement("tr", {
4893
+ className: trClassName,
4894
+ key: rowIndex
4895
+ }, /*#__PURE__*/React__default.createElement(Ths, {
4896
+ table: table,
4897
+ groupData: groupData,
4898
+ groupIndex: tbodyIndex,
4899
+ deep: columns.length - 1,
4900
+ rowColumn: rowColumn,
4901
+ rowIndex: rowIndex
4902
+ }));
4903
+ });
4904
+ };
4905
+ styled.tr`
4906
+ z-index: 1;
4907
+ XXposition: sticky;
4908
+ XXtop: 50px;
4909
+ th{
4910
+ text-align: left;
4911
+ border:1px solid #222222;
4912
+ }
4913
+ `;
4914
+ const GroupHeader = props => {
4915
+ return /*#__PURE__*/React__default.createElement(GroupColumns, _extends({
4916
+ trClassName: 'jr-group-header'
4917
+ }, props));
4918
+ };
4919
+ styled.tr`
4920
+ th{
4921
+ border:1px solid #222222;
4922
+ text-align: left;
4856
4923
  }
4857
- window.style.left = `${x}px`;
4858
- window.style.width = `${width}px`;
4924
+ `;
4925
+ const GroupFooter = props => {
4926
+ return /*#__PURE__*/React__default.createElement(GroupColumns, _extends({
4927
+ trClassName: 'jr-group-footer'
4928
+ }, props));
4929
+ };
4930
+
4931
+ ////////////////////////////////////////////////////////////////////////////
4932
+ const Td = ({
4933
+ column: _column,
4934
+ record,
4935
+ tbodyIndex,
4936
+ trIndex,
4937
+ tdIndex,
4938
+ table
4939
+ }) => {
4940
+ let content;
4941
+ const {
4942
+ style: _style,
4943
+ align,
4944
+ vAlign = 'baseline',
4945
+ type,
4946
+ typeStyle: _typeStyle,
4947
+ render,
4948
+ setValue,
4949
+ getValue,
4950
+ onChange: _onChange,
4951
+ funcProps,
4952
+ ...column
4953
+ } = _column;
4954
+ const onChange = inputValue => {
4955
+ const targetValue = inputValue?.target?.value ?? inputValue;
4956
+ setValue(record, targetValue);
4957
+ table.setValue(table.getValue());
4859
4958
  };
4860
- stop = e => {
4861
- e.preventDefault();
4862
- const {
4863
- height: titleBarHeight
4864
- } = this.props.titleBarRef.current.getBoundingClientRect();
4865
- const {
4866
- x,
4867
- y,
4868
- width,
4869
- height
4870
- } = this.props.windowRef.current.getBoundingClientRect();
4871
- this.props.windowRef.current.style.transition = 'var(--transition-x-y)';
4872
- if (y == 0 && this.data.direction.indexOf('n') > -1) {
4873
- this.props.window.orgHeight = height;
4874
- this.props.windowRef.current.style.height = `${window.innerHeight}px`;
4875
- }
4876
- if (y > window.innerHeight) this.props.windowRef.current.style.top = `${window.innerHeight - titleBarHeight}px`;
4877
- if (x + width - this.props.thick < 0) this.props.windowRef.current.style.left = 0;
4878
- if (x > window.innerWidth) this.props.windowRef.current.style.left = `${window.innerWidth - width}px`;
4879
- document.body.style.cursor = 'default';
4880
- window.removeEventListener('mousemove', this.move);
4881
- window.removeEventListener('mousemove', this.preMove);
4882
- window.removeEventListener('mouseup', this.stop);
4959
+ const value = getValue(record);
4960
+ let style = render ? {} : flexType(_style, table, {
4961
+ value,
4962
+ record
4963
+ }, {});
4964
+ const setStyle = _style => {
4965
+ style = _style;
4883
4966
  };
4884
- move = e => {
4885
- e.preventDefault();
4886
- this.props.windowRef.current.style.transition = 'unset';
4887
- const {
4888
- clientX,
4889
- clientY,
4890
- x: cursorX,
4891
- y: cursorY
4892
- } = e;
4893
- const window = this.props.windowRef.current;
4894
- const {
4895
- left,
4896
- top
4897
- } = window.getBoundingClientRect();
4898
- let {
4899
- x: startX,
4900
- width: startWidth,
4901
- y: startY,
4902
- height: startHeight,
4903
- titleBarHeight
4904
- } = this.data;
4905
- this.directions[this.props.direction].resize({
4906
- window,
4907
- titleBarHeight,
4908
- clientX,
4909
- cursorX,
4910
- startX,
4911
- startWidth,
4912
- left,
4913
- clientY,
4914
- cursorY,
4915
- startY,
4916
- startHeight,
4917
- top
4967
+ setStyle.bind(table);
4968
+ render?.bind(table);
4969
+ if (type) {
4970
+ const typeStyle = flexType(_typeStyle, table, {
4971
+ record
4972
+ }, {});
4973
+ content = /*#__PURE__*/React__default.createElement(type, {
4974
+ onChange: _onChange ? e => {
4975
+ _onChange?.bind(table)(e, {
4976
+ value,
4977
+ onChange,
4978
+ me: content
4979
+ });
4980
+ } : onChange,
4981
+ value,
4982
+ style: typeStyle,
4983
+ render,
4984
+ ...column,
4985
+ ...funcProps?.bind(table)({
4986
+ value
4987
+ })
4918
4988
  });
4989
+ } else if (render) {
4990
+ content = render({
4991
+ index: trIndex,
4992
+ groupIndex: tbodyIndex,
4993
+ value,
4994
+ record,
4995
+ onChange,
4996
+ setStyle
4997
+ });
4998
+ } else {
4999
+ content = value;
5000
+ }
5001
+ return /*#__PURE__*/React__default.createElement("td", {
5002
+ colSpan: style.colSpan,
5003
+ rowSpan: style.rowSpan,
5004
+ style: {
5005
+ textAlign: align,
5006
+ verticalAlign: vAlign,
5007
+ ...style
5008
+ },
5009
+ key: tdIndex
5010
+ }, content);
5011
+ };
5012
+ const Tds = ({
5013
+ leafColumns,
5014
+ record,
5015
+ table,
5016
+ tbodyIndex,
5017
+ trIndex
5018
+ }) => {
5019
+ return leafColumns?.map((column, tdIndex) => {
5020
+ return /*#__PURE__*/React__default.createElement(Td, {
5021
+ column: column,
5022
+ key: tdIndex,
5023
+ record: record,
5024
+ table: table,
5025
+ tbodyIndex: tbodyIndex,
5026
+ trIndex: trIndex,
5027
+ tdIndex: tdIndex
5028
+ });
5029
+ });
5030
+ };
5031
+ ////////////////////////////////////////////////////////////////////////////
5032
+
5033
+ const TBody = ({
5034
+ groupData,
5035
+ groupHeader,
5036
+ leafColumns,
5037
+ groupFooter,
5038
+ table,
5039
+ tbodyIndex
5040
+ }) => {
5041
+ const neededProps = {
5042
+ table,
5043
+ tbodyIndex
4919
5044
  };
4920
- 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;
4924
- window.removeEventListener('mousemove', this.preMove);
4925
- setTimeout(() => {
4926
- window.addEventListener('mousemove', this.move);
4927
- }, 100);
4928
- };
4929
- start = (e, direction) => {
4930
- e.preventDefault();
4931
- const {
4932
- height: titleBarHeight
4933
- } = this.props.titleBarRef.current.getBoundingClientRect();
4934
- let {
4935
- x,
4936
- y,
4937
- width,
4938
- height
4939
- } = this.props.windowRef.current.getBoundingClientRect();
4940
- this.data = {
4941
- x,
4942
- y,
4943
- width,
4944
- height,
4945
- titleBarHeight,
4946
- direction
4947
- };
4948
- document.body.style.cursor = this.directions[this.props.direction].cursor;
4949
- if (this.props.window.orgHeight) {
4950
- window.addEventListener('mousemove', this.preMove);
4951
- } else {
4952
- window.addEventListener('mousemove', this.move);
4953
- }
4954
- window.addEventListener('mouseup', this.stop);
4955
- };
4956
- render() {
4957
- return /*#__PURE__*/React__default.createElement(StyledSlider, {
4958
- $direction: this.directions[this.props.direction],
4959
- $padding: this.props.padding,
4960
- onMouseDown: e => {
4961
- this.start(e, this.props.direction);
5045
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("tbody", {
5046
+ key: `tbody${tbodyIndex}`
5047
+ }, groupData?.length > 0 && /*#__PURE__*/React__default.createElement(GroupHeader, _extends({
5048
+ groupData: groupData,
5049
+ columns: groupHeader
5050
+ }, neededProps)), groupData?.map?.((record, trIndex) => {
5051
+ const onRowClick = table.props.onRowClick?.bind(table);
5052
+ return /*#__PURE__*/React__default.createElement("tr", {
5053
+ key: trIndex,
5054
+ onClick: () => {
5055
+ onRowClick?.({
5056
+ record,
5057
+ index: trIndex,
5058
+ groupIndex: tbodyIndex
5059
+ });
4962
5060
  }
5061
+ }, /*#__PURE__*/React__default.createElement(Tds, _extends({
5062
+ record: record,
5063
+ trIndex: trIndex
5064
+ }, neededProps, {
5065
+ leafColumns: leafColumns
5066
+ })));
5067
+ }), groupData?.length > 0 && /*#__PURE__*/React__default.createElement(GroupFooter, _extends({
5068
+ groupData: groupData,
5069
+ columns: groupFooter
5070
+ }, neededProps))));
5071
+ };
5072
+ const TBodies = ({
5073
+ groupHeader,
5074
+ leafColumns,
5075
+ groupFooter,
5076
+ dataSource: _dataSource,
5077
+ table
5078
+ }) => {
5079
+ // po('--TBodies--')
5080
+ const isGroupDataType = Array.isArray(_dataSource?.[0]);
5081
+ const dataSource = isGroupDataType ? _dataSource : [_dataSource];
5082
+
5083
+ // po('dataSource',dataSource)
5084
+ return dataSource?.map((groupData, tbodyIndex, c) => {
5085
+ return /*#__PURE__*/React__default.createElement(TBody, {
5086
+ key: `tbody${tbodyIndex}`,
5087
+ table: table
5088
+ // dataSource={dataSource}
5089
+ // dataGroup={groupData}
5090
+ ,
5091
+ groupData: groupData,
5092
+ tbodyIndex: tbodyIndex,
5093
+ groupHeader: groupHeader,
5094
+ leafColumns: leafColumns,
5095
+ groupFooter: groupFooter
4963
5096
  });
4964
- }
4965
- }
5097
+ });
5098
+ };
4966
5099
 
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);
5100
+ const StyledJRTable = styled.div`
5101
+ --column-bd-color:#cccccc;
5102
+ --column-b-color:#eeeeee;
5103
+ --column-b-hover-color:#ffffff;
4977
5104
 
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;
5105
+ position: relative;
5106
+ background: var(--column-b-color);
5107
+ border:1px solid var(--column-bd-color);
4991
5108
 
4992
- display: flex;
5109
+ display:flex;
4993
5110
  flex-direction: column;
4994
- overflow: hidden;
5111
+ flex:1;
5112
+ overflow: overlay;
5113
+
5114
+
5115
+
5116
+
5117
+ &.row-highlightable{
5118
+ tbody{
5119
+ tr:not(.jr-group-header,.jr-group-footer):hover{
5120
+ background:var(--column-b-hover-color);
5121
+ cursor: pointer;
5122
+ transition: background-color .8s;
5123
+ td{
5124
+ color:black;
5125
+ transition:color .8s;
5126
+ }
5127
+
5128
+ }
5129
+ }
5130
+ }
5131
+
5132
+ table{
5133
+ Xheight: 100%;
5134
+ min-width:100%;
5135
+ width: max-content;
5136
+ border-spacing: 0;
5137
+
5138
+ thead{
5139
+ position: sticky;
5140
+ top: 0;
5141
+
5142
+ th{
5143
+ position: relative;
5144
+ padding: 2px 6px;
5145
+ background: linear-gradient(180deg, rgba(227, 227, 226, 1) 0%, rgba(255, 255, 255, 1) 25%, rgba(210, 210, 210, 1) 100%);
5146
+ box-shadow: 2px 2px 2px 0 #ffffffd6 inset, -1px -1px 2px 0px #8a847dbf inset;
5147
+ color: #525252;
5148
+ white-space: nowrap;
5149
+ }
5150
+ }
5151
+
5152
+ tfoot{
5153
+ position: sticky;
5154
+ bottom: -1px;
5155
+
5156
+ Xtr:nth-child(1){
5157
+ th{
5158
+ Xborder-top:1px solid var(--column-bd-color);
5159
+ }
5160
+ }
5161
+ Xth:nth-child(1){
5162
+ Xborder-left:1px solid var(--column-bd-color);
5163
+ }
5164
+
5165
+ th{
5166
+ height:32px;
5167
+ padding: 4px;
5168
+ background: #e4e4e4;
5169
+ xbackground: linear-gradient(180deg, rgba(227, 227, 226, 1) 0%, rgba(255, 255, 255, 1) 25%, rgba(210, 210, 210, 1) 100%);
5170
+ xbox-shadow: 2px 2px 2px 0 #ffffffd6 inset, -1px -1px 2px 0px #8a847dbf inset;
5171
+ color: #525252;
5172
+ white-space: nowrap;
5173
+
5174
+ border-left:2px solid #f4f4f4;
5175
+ border-top:2px solid #f4f4f4;
5176
+ border-right:2px solid var(--column-bd-color);
5177
+ border-bottom:2px solid var(--column-bd-color);
5178
+ }
5179
+ }
5180
+
5181
+ tbody{
5182
+ tr{
5183
+ transition: background .3s linear;
5184
+ background:var(--column-b-color);
5185
+ a:#ededed;
5186
+ th{
5187
+ color:#444444;
5188
+ }
5189
+ td{
5190
+ border-bottom: 1px solid var(--column-bd-color);
5191
+ color:#2e2e2e;
5192
+ padding: 4px;
5193
+ }
5194
+ }
5195
+ tr:hover{
5196
+ background:var(--column-b-hover-color);
5197
+
5198
+ }
5199
+
5200
+ tr.jr-group-header
5201
+ ,tr.jr-group-footer{
5202
+ text-align:left;
5203
+ background:#dddbdb;
5204
+
5205
+ th{
5206
+ border-bottom: 1px solid var(--column-bd-color);
5207
+ border-right: 1px solid var(--column-bd-color);
5208
+ padding: 4px 8px;
5209
+ }
5210
+ }
5211
+ }
5212
+ tbody.empty-tbody{
5213
+ td{
5214
+ border:10px solid red;
5215
+ }
5216
+ }
5217
+ }
5218
+
4995
5219
 
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;
5220
+
5221
+
5222
+ > .empty{
5223
+ user-select: none;
5224
+ color:#848484;
5225
+ height:100%;
5003
5226
  flex:1;
5004
- > main {
5005
- background: white;
5006
- Xpadding:var(--padding-child);
5007
- overflow: overlay;
5227
+ display:flex;
5228
+ justify-content: center;
5229
+ align-items: center;
5230
+
5231
+
5232
+ }
5233
+
5234
+ > .empty::after{
5235
+ content:'無資料';
5236
+ position: block;
5237
+ }
5238
+
5239
+ `;
5240
+
5241
+ styled.div`
5242
+ display:flex;
5243
+ flex:1;
5244
+ overflow:hidden;
5245
+
5246
+ > *{
5247
+ Xborder:1px solid gray;
5248
+ }
5249
+ >main{
5250
+ display:flex;
5251
+ flex:1;
5252
+ overflow:overlay;
5253
+ flex-direction: column;
5254
+ > *{
5255
+ XXborder:1px solid gray;
5256
+ XXmin-height:30px;
5257
+ }
5258
+
5259
+ >header{
5260
+ XXborder:1px solid red;
5261
+ XXoverflow: overlay;
5262
+ }
5263
+ >main{
5264
+ display:flex;
5008
5265
  flex:1;
5009
- display: flex;
5266
+ overflow:hidden;
5267
+ }
5268
+ >footer{
5269
+ XXborder:1px solid blue;
5270
+ overflow: overlay;
5010
5271
  }
5272
+
5011
5273
  }
5012
5274
 
5013
- @container (min-width: 700px) {
5014
- &{
5015
- border: 1px solid red;
5275
+ `;
5276
+
5277
+ const StyleJRFields = styled.main`
5278
+ --column-bd-color:#cccccc;
5279
+ --column-b-color:unset;
5280
+ --column-b-hover-color:#ffffff;
5281
+
5282
+ flex-direction: column;
5283
+ flex:1;
5284
+ overflow: overlay;
5285
+
5286
+ color:#525252;
5287
+
5288
+ >.jr-grid{
5289
+ padding: 10px;
5290
+ .jr-column{
5291
+ > .label{
5292
+ color:#525252;
5293
+ text-wrap: nowrap;
5294
+ font-weight: bold;
5295
+ }
5296
+ > .jr-column-value{
5016
5297
  }
5298
+ }
5017
5299
  }
5018
5300
  `;
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)();
5301
+
5302
+ function required(value) {
5303
+ return value == null || value == '' || value.trim?.() == '' ? 'This is required' : true;
5304
+ }
5305
+ function max(value, colum) {
5306
+ 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;
5307
+ }
5308
+ function min(value, colum) {
5309
+ 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;
5310
+ }
5311
+
5312
+ // import JRSubmit from "../JRSubmit";
5313
+ // import { JRWindowHOC } from "../JRWindow/JRWindowHOC";
5314
+ // import { JRFrameHOC } from "../JRFrame/JRFrameHOC";
5315
+
5316
+ function checkMap(_name, inputValue, mapValue, nameList) {
5317
+ if (nameList.length) {
5318
+ const name = nameList.shift();
5319
+ if (typeof mapValue[name] != 'object') {
5320
+ mapValue[name] = {};
5035
5321
  }
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();
5322
+ checkMap(_name, inputValue, mapValue[name], nameList);
5323
+ } else {
5324
+ mapValue[_name] = inputValue;
5064
5325
  }
5065
5326
  }
5327
+ styled.div`
5328
+ overflow: auto;
5329
+ flex:1;
5330
+ `;
5331
+ const StyledGrid = styled.div`
5332
+ display: grid;
5333
+ grid: ${({
5334
+ grid,
5335
+ cols,
5336
+ children
5337
+ }) => grid ? grid : `auto / ${Array(cols ?? 1).fill().map(() => "1fr").join(" ")}`};
5066
5338
 
5067
- const getMapObject = (map, names) => {
5068
- const name = names.shift(names);
5069
- if (names.length) {
5070
- return getMapObject(map?.[name], names);
5339
+ gap: ${({
5340
+ $gap
5341
+ }) => $gap};
5342
+ `;
5343
+ styled.div`
5344
+ `;
5345
+ const StyledColumn = styled.div`
5346
+ flex:1;
5347
+ display: grid;
5348
+
5349
+ ${({
5350
+ $layout,
5351
+ $labelWidth,
5352
+ $hasLabel,
5353
+ $valueWidth
5354
+ }) => {
5355
+ if ($layout == 'v') {
5356
+ return `grid: auto 1fr / 1fr;`;
5071
5357
  } else {
5072
- return map;
5358
+ return `grid: 1fr / ${$hasLabel ? $labelWidth : ''} ${$valueWidth};`;
5073
5359
  }
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);
5360
+ }}
5361
+ `;
5362
+ const StyledColumnLabel = styled.div`
5363
+ ${({
5364
+ $layout
5365
+ }) => {
5366
+ if ($layout == 'v') {
5367
+ return `text-align: start;`;
5082
5368
  } 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 ?? []);
5369
+ return `text-align: end;
5370
+ padding: 3px 8px;
5371
+ `;
5093
5372
  }
5373
+ }}
5094
5374
 
5095
- //------------------------------------------------------------------------------------
5096
- getChecked() {
5097
- return [1, 2, 3, 4];
5098
- }
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
- // }
5375
+ ${({
5376
+ $required
5377
+ }) => {
5378
+ if ($required !== undefined && $required) return `
5379
+ &:not(:empty)::before{
5380
+ padding-right:4px;
5381
+ color:red;
5382
+ content:'*';
5383
+ }
5384
+ `;
5385
+ }}
5386
+
5387
+ ${({
5388
+ $colon
5389
+ }) => {
5390
+ if ($colon) {
5391
+ return `
5392
+ &:not(:empty)::after{
5393
+ content:'${$colon}';
5394
+ }
5395
+ `;
5132
5396
  }
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
- };
5397
+ }}
5398
+
5399
+ `;
5400
+ const StyledColumnValue = styled.main`
5401
+ flex:1;
5402
+ flex-direction: column;
5403
+ overflow: hidden;
5404
+ padding: 4px 0;
5405
+
5406
+ text-align: start;
5407
+ ${({
5408
+ $validateValue
5409
+ }) => {
5410
+ if ($validateValue != null) {
5411
+ return `
5412
+ > * {
5413
+ xborder:1px solid red;
5414
+ }
5415
+ `;
5173
5416
  }
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
5190
- });
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);
5199
- }
5200
- };
5201
- column.getValue = function (record) {
5202
- return _names.reduce((acc, name) => {
5203
- return acc?.[name];
5204
- }, record);
5205
- };
5206
- } else {
5207
- column.setValue = function (record, value) {
5208
- record[column.name] = value;
5209
- };
5210
- column.getValue = function (record) {
5211
- return record[column.name];
5212
- };
5213
- }
5214
- return {
5215
- colSpan: 1
5216
- };
5417
+ }}
5418
+ `;
5419
+ const StyledColumnFooter = styled.div`
5420
+ &:has(.left:empty):has(.right:empty)
5421
+ {
5422
+ border:1px solid blue;
5423
+ display: none;
5217
5424
  }
5425
+
5426
+ ${({
5427
+ $layout
5428
+ }) => {
5429
+ if ($layout == 'v') {
5430
+ return ``;
5431
+ } else {
5432
+ return `grid-column-start:2;`;
5218
5433
  }
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
- }
5434
+ }}
5435
+ height:25px;
5436
+ color:#ff6060;
5437
+
5438
+ display: flex;
5439
+ justify-content: space-between;
5440
+
5441
+ .left:{
5442
+ xflex:1;
5224
5443
  }
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
5233
- });
5234
- return childrenLength;
5444
+ .right{
5445
+ color:gray;
5446
+ xflex:1;
5447
+ }
5448
+ `;
5449
+ class JRFields extends JRWindow {
5450
+ UNSAFE_componentWillMount() {
5451
+ this.#initValidatorValue();
5235
5452
  }
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));
5453
+ reset() {
5454
+ this.clearTestValue();
5455
+ super.reset();
5456
+ }
5457
+ setValue(value, reset) {
5458
+ super.setValue(value, reset);
5459
+ if (reset) {
5460
+ this.clearTestValue();
5240
5461
  }
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
- });
5249
5462
  }
5250
- //------------------------------------------------------------------------------------
5251
- setDataSource(dataSource) {}
5252
- getDataSource() {
5253
- return this.props.dataSourceName ? this.getValue()?.[this.props.dataSourceName] : this.getValue();
5463
+ //Validate-----------------------------------------------------------------------------------
5464
+ #initValidatorValue() {
5465
+ if (this.validateValueFrom == 'state') {
5466
+ this.setState({
5467
+ validatorValue: {}
5468
+ });
5469
+ }
5254
5470
  }
5255
- add(record, index = this.getDataSource()?.length ?? 0, group) {
5256
- //group 還沒有考慮到
5257
-
5258
- if (this.getDataSource()) {
5259
- if (group === undefined) {
5260
- this.getDataSource().splice(index, 0, record); //.push(record)
5471
+ get testValueFrom() {
5472
+ return this.props.testValue === undefined ? 'state' : 'props';
5473
+ }
5474
+ clearTestValue() {
5475
+ this.setTestValue({});
5476
+ }
5477
+ setTestValue(testValue, name) {
5478
+ if (this.testValueFrom == 'state') {
5479
+ if (name) {
5480
+ const newTestValue = this.getTestValue();
5481
+ newTestValue[name] = testValue;
5482
+ this.setState({
5483
+ testValue: {
5484
+ ...this.getTestValue(),
5485
+ ...testValue
5486
+ }
5487
+ });
5261
5488
  } else {
5262
- this.getDataSource()[group].splice(index, 0, record); //.push(record)
5489
+ this.setState({
5490
+ testValue
5491
+ });
5263
5492
  }
5264
- this.setValue(this.getValue());
5493
+ }
5494
+ }
5495
+ getTestValue(fullname) {
5496
+ if (fullname) {
5497
+ return this.state?.testValue?.[fullname];
5265
5498
  } else {
5266
- //未完成. 沒有資料的時候, 要考慮有或沒有dataSourceName的不同處理
5267
- this.setValue({
5268
- [this.props.dataSourceName]: [record]
5499
+ return this.state?.testValue;
5500
+ }
5501
+ }
5502
+ #validateField(column, fullNameArray, testValue, value) {
5503
+ const {
5504
+ name,
5505
+ validators: _validators,
5506
+ columns,
5507
+ type
5508
+ } = column;
5509
+ const fullName = fullNameArray.join('.');
5510
+ const validators = _validators ? [..._validators] : [];
5511
+ if (column.required) {
5512
+ validators.push(required);
5513
+ }
5514
+ if (column.max) {
5515
+ validators.push(max);
5516
+ }
5517
+ if (column.min) {
5518
+ validators.push(min);
5519
+ }
5520
+ if (validators.length) {
5521
+ testValue[fullName] = {
5522
+ isValid: null,
5523
+ msg: []
5524
+ };
5525
+ const promises = [];
5526
+ for (let i = 0; i < validators.length; i++) {
5527
+ const validator = validators[i].bind(this)(value, column);
5528
+ if (validator?.then) {
5529
+ promises.push(validator);
5530
+ } else if (typeof validator == 'string') {
5531
+ promises.push(Promise.reject(validator));
5532
+ break;
5533
+ }
5534
+ }
5535
+ return Promise.all(promises).then(reason => {
5536
+ testValue[fullName].isValid = true;
5537
+ return Promise.resolve(reason);
5538
+ }).catch(reason => {
5539
+ testValue[fullName].msg.push(reason);
5540
+ testValue[fullName].isValid = false;
5541
+ return Promise.reject(reason);
5269
5542
  });
5270
5543
  }
5271
5544
  }
5272
- noData() {
5273
- const data = this.getDataSource();
5274
- return data == null || data.length == 0;
5545
+ #validators(_columns, validators, names, testValue, value) {
5546
+ return _columns?.reduce((aco, column) => {
5547
+ const {
5548
+ name,
5549
+ validators,
5550
+ columns,
5551
+ type
5552
+ } = column;
5553
+ const fullNameArray = name ? [...names, name] : names;
5554
+ fullNameArray.join('.');
5555
+ {
5556
+ // 要的 if(this.getTestValue(fullName)?.isValid==null){//執行過的不再執行
5557
+ const validate = this.#validateField(column, fullNameArray, testValue, name ? value?.[name] : value);
5558
+ if (validate) {
5559
+ aco.push(validate);
5560
+ }
5561
+ }
5562
+ if (columns && type == undefined) {
5563
+ this.#validators(columns, aco, fullNameArray, testValue, name ? value?.[name] : value);
5564
+ }
5565
+ return aco;
5566
+ }, validators);
5275
5567
  }
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() && '無資料'));
5568
+ validate(value) {
5569
+ console.clear();
5570
+ const validators = [];
5571
+ const testValue = this.getTestValue() ?? {};
5572
+ this.#validators(this.getColumns(), validators, [], testValue, value !== undefined ? value : this.getValue());
5573
+ return Promise.all(validators).then(msg => {
5574
+ this.setTestValue(testValue);
5575
+ return Promise.resolve();
5576
+ }).catch(msg => {
5577
+ this.setTestValue(testValue);
5578
+ return Promise.reject();
5579
+ });
5299
5580
  }
5300
- }
5301
5581
 
5302
- const StyleJRFields = styled.main`
5303
- --column-bd-color:#cccccc;
5304
- --column-b-color:unset;
5305
- --column-b-hover-color:#ffffff;
5306
-
5307
- flex-direction: column;
5308
- flex:1;
5309
- overflow: overlay;
5310
- padding: 10px;
5311
-
5312
- color:#525252;
5582
+ //--------------------------------------------------------------------------------------
5583
+ get columnsFrom() {
5584
+ return this.props.initColumns !== undefined ? 'state' : 'props';
5585
+ }
5586
+ getColumns() {
5587
+ return this[this.columnsFrom]?.columns;
5588
+ }
5589
+ //-------------------------------------------------------------------------------------------
5313
5590
 
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
- }
5324
- }
5591
+ createColumn(parentValue, {
5592
+ type,
5593
+ name,
5594
+ colSpan,
5595
+ rowSpan,
5596
+ style,
5597
+ typeStyle: _typeStyle,
5598
+ columnStyle,
5599
+ ...column
5600
+ }, index, parentName, fullnameArray, labelProps) {
5601
+ const value = name ? parentValue?.[name] : parentValue;
5602
+ const gap = column.gap ?? this.props.gap;
5603
+ const label = column.label;
5604
+ const _style = flexType(style, this, {}, {});
5605
+ const _columnStyle = flexType(columnStyle, this, {}, {});
5606
+ if (colSpan) _style.gridColumn = `span ${colSpan}`;
5607
+ if (rowSpan) _style.gridRow = `span ${rowSpan}`;
5608
+ let content;
5609
+ const onChange = inputValue => {
5610
+ const targetValue = inputValue?.target?.value ?? inputValue;
5611
+ try {
5612
+ parentValue[name] = targetValue;
5613
+ this.setValue({
5614
+ ...this.getValue()
5615
+ });
5616
+ } catch (e) {
5617
+ const _value = this.getValue() ?? {};
5618
+ checkMap(name, targetValue, _value, [...parentName]);
5619
+ this.setValue(_value);
5620
+ }
5621
+ const testValue = this.getTestValue() ?? {};
5622
+ this.#validateField(column, fullnameArray, testValue, targetValue)?.then(() => {
5623
+ this.setTestValue(testValue);
5624
+ }).catch(() => {
5625
+ this.setTestValue(testValue);
5626
+ });
5627
+ };
5628
+ const _parentName = [...parentName];
5629
+ if (name !== undefined) {
5630
+ _parentName.push(name);
5325
5631
  }
5326
- `;
5327
-
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] = {};
5632
+ if (type) {
5633
+ const typeStyle = flexType(_typeStyle, this, null);
5634
+ content = /*#__PURE__*/React__default.createElement(StyledColumnValue, {
5635
+ className: 'jr-column-value',
5636
+ style: {
5637
+ gridColumn: label == null ? 'span 2' : null,
5638
+ ..._columnStyle
5639
+ }
5640
+ }, /*#__PURE__*/React__default.createElement(type, {
5641
+ value: value,
5642
+ onChange,
5643
+ record: parentValue,
5644
+ style: {
5645
+ width: '100%',
5646
+ ...typeStyle
5647
+ },
5648
+ ...column
5649
+ }));
5650
+ } else if (column.columns) {
5651
+ content = /*#__PURE__*/React__default.createElement(StyledGrid, {
5652
+ cols: column.cols,
5653
+ className: 'jr-grid',
5654
+ $gap: gap,
5655
+ style: _columnStyle
5656
+ }, this.createColumns(value, column.columns, _parentName, fullnameArray, column.labelProps ?? this.props.labelProps));
5657
+ } else if (name || column.render) {
5658
+ content = /*#__PURE__*/React__default.createElement(StyledColumnValue, {
5659
+ className: 'jr-column-value',
5660
+ style: {
5661
+ gridColumn: label == null ? 'span 2' : null,
5662
+ padding: column.render ? '4px 0' : null
5663
+ }
5664
+ }, column.render ? column.render.bind(this)({
5665
+ onChange,
5666
+ value: value,
5667
+ record: this.getValue()
5668
+ }) : typeof value === 'object' ? JSON.stringify(value) : value);
5333
5669
  }
5334
- checkMap(_name, inputValue, mapValue[name], nameList);
5335
- } else {
5336
- mapValue[_name] = inputValue;
5670
+ const layout = labelProps?.layout;
5671
+ const colon = labelProps?.colon === undefined ? ':' : labelProps.colon;
5672
+ const labelStyle = column.labelProps?.style ?? this.props.labelProps?.style ?? {};
5673
+ return /*#__PURE__*/React__default.createElement(StyledColumn, {
5674
+ $layout: layout,
5675
+ $hasLabel: label != null,
5676
+ key: `f${index}`,
5677
+ style: _style,
5678
+ className: 'jr-column',
5679
+ $labelWidth: column.labelProps?.width ?? this.props.labelProps?.width ?? '120px',
5680
+ $valueWidth: column.valueProps?.width ?? this.props.valueProps?.width ?? '1fr'
5681
+ }, label != null && /*#__PURE__*/React__default.createElement(StyledColumnLabel, {
5682
+ style: labelStyle,
5683
+ $required: column.required,
5684
+ className: 'label',
5685
+ $layout: layout,
5686
+ $colon: colon
5687
+ }, label), content, /*#__PURE__*/React__default.createElement(StyledColumnFooter, {
5688
+ $layout: layout
5689
+ }, /*#__PURE__*/React__default.createElement("div", {
5690
+ className: "left"
5691
+ }, this.getTestValue(_parentName.join('.'))?.msg?.map(msg => {
5692
+ return msg;
5693
+ })), /*#__PURE__*/React__default.createElement("div", {
5694
+ className: "right"
5695
+ })));
5696
+ }
5697
+ createColumns(parentValue, columns, parentName, fullname, labelProps) {
5698
+ return columns?.map((column, index) => {
5699
+ return this.createColumn(parentValue, column, index, parentName, column.name ? [...fullname, column.name] : fullname, labelProps);
5700
+ });
5701
+ }
5702
+ renderMe() {
5703
+ return /*#__PURE__*/React__default.createElement(StyleJRFields, {
5704
+ className: 'jr-fields',
5705
+ style: this.props.typeStyle
5706
+ }, /*#__PURE__*/React__default.createElement(StyledGrid, {
5707
+ cols: this.props.cols,
5708
+ style: this.props.gridStyle,
5709
+ className: 'jr-grid',
5710
+ $gap: this.props.gap
5711
+ }, 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)));
5337
5712
  }
5338
5713
  }
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(" ")}`};
5350
5714
 
5351
- gap: ${({
5352
- $gap
5353
- }) => $gap};
5354
- `;
5355
- styled.div`
5356
- `;
5357
- const StyledColumn = styled.div`
5358
- flex:1;
5359
- display: grid;
5360
-
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
- }}
5715
+ // export const FFields=JRFrameHOC(JRFields)
5716
+ // export const WFields=JRWindowHOC(FFields)
5384
5717
 
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
- }}
5718
+ styled.div`
5719
+ --jr-window-radius:3px;
5720
+ --padding-child:8px;
5721
+ --transition-x-y:height .05s ease-in, width .05s ease-in;
5722
+ xborder:1px solid gray;
5723
+ position: fixed;
5724
+ padding: ${({
5725
+ $thick
5726
+ }) => $thick}px;
5727
+ border-radius: var(--jr-window-radius);
5396
5728
 
5397
- ${({
5398
- $colon
5399
- }) => {
5400
- if ($colon) {
5401
- return `
5402
- &:not(:empty)::after{
5403
- content:'${$colon}';
5404
- }
5405
- `;
5406
- }
5407
- }}
5729
+ top: ${({
5730
+ $y
5731
+ }) => $y}px;
5732
+ left: ${({
5733
+ $x
5734
+ }) => $x}px;
5735
+ width: ${({
5736
+ $width = 300
5737
+ }) => `${$width}px`};
5738
+ height: ${({
5739
+ $height = 300
5740
+ }) => `${$height}px`};
5741
+ overflow: hidden;
5408
5742
 
5409
- `;
5410
- const StyledColumnValue = styled.main`
5411
- flex:1;
5412
- Xdisplay:flex;
5743
+ display: flex;
5413
5744
  flex-direction: column;
5414
5745
  overflow: hidden;
5746
+
5747
+ > main{
5748
+ border-radius: var(--jr-window-radius);
5749
+ box-shadow: 0px 0px 5px 1px gray;
5750
+ Xbackground: white;
5751
+ display: flex;
5752
+ flex-direction: column;
5753
+ overflow: hidden;
5754
+ flex:1;
5755
+ > main {
5756
+ background: white;
5757
+ Xpadding:var(--padding-child);
5758
+ overflow: overlay;
5759
+ flex:1;
5760
+ display: flex;
5761
+ }
5762
+ }
5415
5763
 
5416
- text-align: start;
5417
- ${({
5418
- $validateValue
5419
- }) => {
5420
- if ($validateValue != null) {
5421
- return `
5422
- > * {
5423
- xborder:1px solid red;
5424
- }
5425
- `;
5426
- }
5427
- }}
5764
+ @container (min-width: 700px) {
5765
+ &{
5766
+ border: 1px solid red;
5767
+ }
5768
+ }
5428
5769
  `;
5429
5770
 
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);
5771
+ const getMapObject = (map, names) => {
5772
+ const name = names.shift(names);
5773
+ if (names.length) {
5774
+ return getMapObject(map?.[name], names);
5775
+ } else {
5776
+ return map;
5447
5777
  }
5448
5778
  };
5449
- const StyledColumnFooter = styled.div`
5450
- &:empty{
5451
- display: none;
5779
+ const setMapObject = (map, names, value) => {
5780
+ const name = names.shift(names);
5781
+ if (names?.length) {
5782
+ if (typeof map[name] != 'object') {
5783
+ map[name] = {};
5452
5784
  }
5453
- ${({
5454
- $layout
5455
- }) => {
5456
- if ($layout == 'v') {
5457
- return ``;
5785
+ setMapObject(map[name], names, value);
5458
5786
  } else {
5459
- return `grid-column-start:2;`;
5787
+ map[name] = value;
5460
5788
  }
5461
- }}
5462
- height:25px;
5463
- color:#ff6060;
5464
-
5465
- display: flex;
5466
- justify-content: space-between;
5467
-
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 == '') {
5480
- return {
5481
- msg: this.msg ?? 'This is required'
5482
- };
5789
+ };
5790
+ class JRTable extends JRWindow {
5791
+ constructor(props) {
5792
+ super(props);
5793
+ this.colGroupRef = /*#__PURE__*/React__default.createRef();
5483
5794
  }
5484
- }
5485
- class JRFields extends JRWindow {
5486
5795
  UNSAFE_componentWillMount() {
5487
- this.#initValidateValue();
5796
+ this.setColumns(this.props.columns ?? []);
5488
5797
  }
5489
- reset() {
5490
- this.clearValidateValue();
5491
- super.reset();
5798
+
5799
+ //------------------------------------------------------------------------------------
5800
+ checkableColumn(props) {
5801
+ return {
5802
+ //方法1
5803
+ render({
5804
+ value,
5805
+ onChange
5806
+ }) {
5807
+ return /*#__PURE__*/React__default.createElement("checkbox", {
5808
+ checked: value,
5809
+ onChange: e => {
5810
+ onChange(e.target.checked);
5811
+ }
5812
+ });
5813
+ },
5814
+ align: 'center',
5815
+ name: 'checked',
5816
+ ...props
5817
+ };
5818
+ // return {//方法2
5819
+ // type:Checkbox
5820
+ // ,funcProps({value}){
5821
+ // po('fffffffffffff',value)
5822
+ // return {
5823
+ // align:'center'
5824
+ // ,checked:value
5825
+ // }
5826
+ // }
5827
+ // // ,label:'A'
5828
+ // ,onChange(e,{value,onChange,me}){
5829
+ // onChange(e.target.checked)
5830
+ // }
5831
+ // ,...props
5832
+ // }
5492
5833
  }
5493
- setValue(value, reset) {
5494
- super.setValue(value, reset);
5495
- if (reset) {
5496
- this.clearValidateValue();
5497
- }
5834
+ deletableColumn({
5835
+ name = 'deletable',
5836
+ sendValue,
5837
+ sendName,
5838
+ valueName,
5839
+ ...props
5840
+ }) {
5841
+ return {
5842
+ render({
5843
+ value,
5844
+ onChange
5845
+ }) {
5846
+ return /*#__PURE__*/React__default.createElement("checkbox", {
5847
+ checked: value,
5848
+ onChange: e => {
5849
+ onChange(e.target.checked);
5850
+ }
5851
+ });
5852
+ },
5853
+ align: 'center',
5854
+ name,
5855
+ label() {
5856
+ return /*#__PURE__*/React__default.createElement("button", {
5857
+ onClick: () => {
5858
+ const value = this.props.delete.value ?? this.getDataSource()?.filter(record => record[name]).map(record => sendValue ? record[sendValue] : record);
5859
+ const callback = this.props.delete.callback ?? function (a, b, c) {
5860
+ this.reload();
5861
+ };
5862
+ this.delete({
5863
+ value: sendName ? {
5864
+ [sendName]: value
5865
+ } : value,
5866
+ callback,
5867
+ ...props
5868
+ });
5869
+ }
5870
+ }, "\u522A\u9664");
5871
+ },
5872
+ ...props
5873
+ };
5498
5874
  }
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)]
5875
+ initColumn(column, level, result, leafColumns, names, lastColSpan) {
5876
+ const isBranch = column.type === undefined && column?.columns && column?.columns.length;
5877
+ const _names = column.name ? [...names, column.name] : names;
5878
+ if (isBranch) {
5879
+ if (column.label !== null) result[level].push(column);
5880
+ const c = this.initColumns(column.columns, level + (column.label !== null ? 1 : 0) + (column.rowSpan != null ? column.rowSpan - 1 : 0), result, leafColumns, _names, lastColSpan);
5881
+ column.colSpan = c.colSpan;
5882
+ column.columnNo = lastColSpan;
5883
+ return {
5884
+ colSpan: column.colSpan
5885
+ };
5886
+ } else {
5887
+ column.columnNo = lastColSpan;
5888
+ result[level].push({
5889
+ ...column,
5890
+ isLeaf: true
5891
+ });
5892
+ leafColumns.push(column);
5893
+ column.names = _names;
5894
+ if (_names?.length > 1) {
5895
+ column.setValue = function (record, value) {
5896
+ try {
5897
+ getMapObject(record, [..._names])[column.name] = value;
5898
+ } catch {
5899
+ setMapObject(record, [..._names], value);
5900
+ }
5901
+ };
5902
+ column.getValue = function (record) {
5903
+ return _names.reduce((acc, name) => {
5904
+ return acc?.[name];
5905
+ }, record);
5906
+ };
5907
+ } else {
5908
+ column.setValue = function (record, value) {
5909
+ record[column.name] = value;
5910
+ };
5911
+ column.getValue = function (record) {
5912
+ return record[column.name];
5913
+ };
5914
+ }
5915
+ return {
5916
+ colSpan: 1
5509
5917
  };
5510
5918
  }
5511
5919
  }
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);
5920
+ initColumns(columns, level, result, leafColumns, names, lastColSpan) {
5921
+ for (let i = result.length; i <= level; i++) {
5922
+ if (!result[i]) {
5923
+ result.push([]);
5525
5924
  }
5925
+ }
5926
+ let _lastColSpan = lastColSpan;
5927
+ const childrenLength = columns?.reduce((acc, column) => {
5928
+ const c = this.initColumn(column, level, result, leafColumns, names, _lastColSpan);
5929
+ acc.colSpan += c.colSpan;
5930
+ _lastColSpan += c.colSpan;
5526
5931
  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
5932
+ }, {
5933
+ colSpan: 0
5538
5934
  });
5935
+ return childrenLength;
5539
5936
  }
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
- }
5937
+ setColumns([..._columns]) {
5938
+ if (this.props.checkable) _columns.unshift(this.checkableColumn(this.props.checkable));
5939
+ if (this.props.deletable) {
5940
+ _columns.unshift(this.deletableColumn(this.props.deletable));
5552
5941
  }
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
- });
5942
+ const columns = [];
5943
+ const leafColumns = [];
5944
+ this.initColumns(_columns, 0, columns, leafColumns, [], 0);
5945
+ // po('initColumns',initColumns)
5559
5946
  this.setState({
5560
- validateValue: this.getValidateValue()
5947
+ columns,
5948
+ leafColumns
5561
5949
  });
5562
5950
  }
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;
5951
+ //------------------------------------------------------------------------------------
5952
+ setDataSource(dataSource) {}
5953
+ getDataSource() {
5954
+ return this.props.dataSourceName ? this.getValue()?.[this.props.dataSourceName] : this.getValue();
5597
5955
  }
5598
- //-------------------------------------------------------------------------------------------
5956
+ add(record, index = this.getDataSource()?.length ?? 0, group) {
5957
+ //group 還沒有考慮到
5599
5958
 
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);
5959
+ if (this.getDataSource()) {
5960
+ if (group === undefined) {
5961
+ this.getDataSource().splice(index, 0, record); //.push(record)
5962
+ } else {
5963
+ this.getDataSource()[group].splice(index, 0, record); //.push(record)
5636
5964
  }
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);
5965
+ this.setValue(this.getValue());
5966
+ } else {
5967
+ this.setValue(this.props.dataSourceName ? {
5968
+ [this.props.dataSourceName]: [record]
5969
+ } : [record]);
5678
5970
  }
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
5971
  }
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
- });
5972
+ noData() {
5973
+ const data = this.getDataSource();
5974
+ return data == null || data.length == 0;
5713
5975
  }
5976
+ //------------------------------------------------------------------------------------
5714
5977
  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] : [])));
5978
+ return /*#__PURE__*/React__default.createElement(StyledJRTable, {
5979
+ className: `${this.props.className ?? ''} jr-table ${this.props.onRowClick ? 'row-highlightable' : ''}`
5980
+ }, /*#__PURE__*/React__default.createElement("table", {
5981
+ className: 'jr-table-table'
5982
+ }, /*#__PURE__*/React__default.createElement(TBodies, {
5983
+ table: this,
5984
+ leafColumns: this.state.leafColumns,
5985
+ groupHeader: this.props.groupHeader,
5986
+ groupFooter: this.props.groupFooter,
5987
+ dataSource: this.getDataSource(),
5988
+ onRowClick: this.props.onRowClick
5989
+ }), /*#__PURE__*/React__default.createElement(TFoot, {
5990
+ columns: this.props.footColumns,
5991
+ table: this
5992
+ }), /*#__PURE__*/React__default.createElement(THead, {
5993
+ columns: this.state.columns,
5994
+ leafColumns: this.state.leafColumns,
5995
+ table: this
5996
+ })), this.noData() && /*#__PURE__*/React__default.createElement("div", {
5997
+ className: 'empty'
5998
+ }));
5724
5999
  }
5725
-
5726
- // render(){
5727
- // return this.renderMe()
5728
- // }
5729
6000
  }
5730
6001
 
6002
+ // export const FTable=JRFrameHOC(JRTable)
6003
+ // export const WTable=JRWindowHOC(JRTable)
6004
+
5731
6005
  const StyledJRFrame = styled.div`
5732
6006
  display:flex;
5733
6007
  flex:1;
@@ -5827,4 +6101,73 @@ class JRTestReact extends JRSubmit {
5827
6101
  }
5828
6102
  }
5829
6103
 
5830
- export { JRButton, JRFields, JRFrame, JRSubmit, JRTable, JRTestReact, JRWindow };
6104
+ class AlertWindow extends JRWindow {
6105
+ renderMe() {
6106
+ return this.getValue()?.message;
6107
+ }
6108
+ }
6109
+ const StyledAlert = styled(AlertWindow)`
6110
+ .body{
6111
+ display: flex;
6112
+ align-items: center;
6113
+ padding: 20px;
6114
+ }
6115
+
6116
+ footer{
6117
+ display: flex;
6118
+ justify-content: end;
6119
+ padding: 8px;
6120
+ }
6121
+ `;
6122
+ function JRAlertWindow({
6123
+ title,
6124
+ message,
6125
+ container,
6126
+ ...props
6127
+ }) {
6128
+ const [open, setOpen] = useState(true);
6129
+ return /*#__PURE__*/React__default.createElement(StyledAlert, _extends({
6130
+ initValue: {
6131
+ message
6132
+ },
6133
+ width: 440,
6134
+ height: 180,
6135
+ maskOn: 'play'
6136
+ }, props, {
6137
+ open: open,
6138
+ setOpen: setOpen,
6139
+ popup: true,
6140
+ title: title ?? ''
6141
+ // onOpen={()=>{
6142
+ // po('Open+++++++++++++++++')
6143
+ // }}
6144
+ ,
6145
+ onClose: () => {
6146
+ container.remove();
6147
+ },
6148
+ bottom: function () {
6149
+ return /*#__PURE__*/React__default.createElement("button", {
6150
+ onClick: () => {
6151
+ setOpen(false);
6152
+ }
6153
+ }, "OK");
6154
+ }
6155
+ }), message);
6156
+ }
6157
+ function JRAlert(props) {
6158
+ const body = document.body;
6159
+ const containerId = 'jr-alert-div';
6160
+ let container = document.getElementById(containerId);
6161
+ if (container == null) {
6162
+ container = document.createElement('div');
6163
+ container.id = containerId;
6164
+ body.appendChild(container);
6165
+ }
6166
+ const jrAlerDiv = document.createElement('div');
6167
+ container.appendChild(jrAlerDiv);
6168
+ createRoot(jrAlerDiv).render(/*#__PURE__*/React__default.createElement(JRAlertWindow, _extends({}, props, {
6169
+ container: jrAlerDiv
6170
+ })));
6171
+ }
6172
+
6173
+ export { JRAlert, JRButton, JRFields, JRFrame, JRSubmit, JRTable, JRTestReact, JRWindow };