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