jrs-react 1.2.35 → 1.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { useState } from 'react';
2
+ import React__default, { forwardRef, useRef, useState } from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { createRoot } from 'react-dom/client';
5
5
 
@@ -3939,30 +3939,139 @@ class JRSubmit extends React__default.Component {
3939
3939
  }
3940
3940
  }
3941
3941
 
3942
- const FreeType = ({
3942
+ const StyledSlider$2 = styled.div`
3943
+ background:#2d2d2d;
3944
+ flex-basis:11px;
3945
+ user-select: none;
3946
+ cursor: ${({
3947
+ $dir
3948
+ }) => $dir === 'left' || $dir === 'right' ? 'col-resize' : 'row-resize'} ;
3949
+ `;
3950
+ class Slider$2 extends React__default.Component {
3951
+ ref = /*#__PURE__*/React__default.createRef();
3952
+ resize = {
3953
+ left: ({
3954
+ clientX
3955
+ }) => {
3956
+ const ref = this.props.contenerRef.current;
3957
+ let width = clientX - this.frame.x - this.frame.shw;
3958
+ if (width < 0) width = 0;
3959
+ ref.style.flexBasis = `${width}px`;
3960
+ },
3961
+ right: ({
3962
+ clientX
3963
+ }) => {
3964
+ const ref = this.props.contenerRef.current;
3965
+ let width = this.frame.x2 - clientX - this.frame.shw;
3966
+ if (width < 0) width = 0;
3967
+ po('width', width);
3968
+ ref.style.flexBasis = `${width}px`;
3969
+ },
3970
+ top: ({
3971
+ clientY
3972
+ }) => {
3973
+ po('top');
3974
+ const ref = this.props.contenerRef.current;
3975
+ let height = clientY - this.frame.y - this.frame.shh;
3976
+ po('height', height);
3977
+ // if(width<0)width=0
3978
+ ref.style.flexBasis = `${height}px`;
3979
+ },
3980
+ bottom: ({
3981
+ clientY
3982
+ }) => {
3983
+ po('bottom');
3984
+ const ref = this.props.contenerRef.current;
3985
+ let height = this.frame.w2 - clientY - this.frame.shh;
3986
+ // clientY-this.frame.y-this.frame.shh
3987
+ // po('height',height)
3988
+ // // if(width<0)width=0
3989
+ ref.style.flexBasis = `${height}px`;
3990
+ }
3991
+ };
3992
+ stop = e => {
3993
+ po('stop', this.stop);
3994
+ document.body.style.cursor = 'default';
3995
+ window.removeEventListener('mousemove', this.move);
3996
+ window.removeEventListener('mouseup', this.stop);
3997
+ };
3998
+ move = e => {
3999
+ this.resize[this.props.dir](e);
4000
+ };
4001
+ start = ({
4002
+ clientX
4003
+ }) => {
4004
+ console.clear();
4005
+ const ref = this.props.contenerRef.current;
4006
+ const {
4007
+ x,
4008
+ y,
4009
+ width,
4010
+ height,
4011
+ ...other
4012
+ } = ref.getBoundingClientRect();
4013
+ po('other', ref.getBoundingClientRect());
4014
+ po('ref.getBoundingClientRect()', this.ref.current.getBoundingClientRect());
4015
+ const {
4016
+ width: sw,
4017
+ height: sh
4018
+ } = this.ref.current.getBoundingClientRect();
4019
+ this.frame = {
4020
+ x,
4021
+ y,
4022
+ shw: sw / 2,
4023
+ shh: sh / 2,
4024
+ x2: x + width,
4025
+ w2: y + height
4026
+ };
4027
+ document.body.style.cursor = 'col-resize';
4028
+ window.addEventListener('mousemove', this.move);
4029
+ window.addEventListener('mouseup', this.stop);
4030
+ };
4031
+ render() {
4032
+ return /*#__PURE__*/React__default.createElement(StyledSlider$2, {
4033
+ onMouseDown: this.start,
4034
+ ref: this.ref,
4035
+ $dir: this.props.dir
4036
+ });
4037
+ }
4038
+ }
4039
+
4040
+ const FreeType = /*#__PURE__*/forwardRef(function ({
3943
4041
  tag: Tag,
3944
4042
  config,
3945
4043
  me,
3946
4044
  className
3947
- }) => {
4045
+ }, ref) {
4046
+ let style;
4047
+ const setStyle = function (_style) {
4048
+ style = _style;
4049
+ };
3948
4050
  if (typeof config === 'function') {
3949
- let style;
3950
- const setStyle = function (_style) {
3951
- style = _style;
3952
- };
3953
4051
  const content = config.bind(me)({
3954
4052
  setStyle
3955
4053
  });
3956
4054
  return /*#__PURE__*/React__default.createElement(Tag, {
3957
4055
  className: className,
3958
- style: style
4056
+ style: style,
4057
+ ref: ref
4058
+ }, content);
4059
+ } else if (config?.render) {
4060
+ const content = config.render.bind(me)({
4061
+ setStyle
4062
+ });
4063
+ return /*#__PURE__*/React__default.createElement(Tag, {
4064
+ className: className,
4065
+ style: style,
4066
+ ref: ref
3959
4067
  }, content);
3960
4068
  } else if (typeof config === 'string') {
3961
4069
  return /*#__PURE__*/React__default.createElement(Tag, {
3962
- className: className
4070
+ className: className,
4071
+ ref: ref
3963
4072
  }, config);
3964
4073
  }
3965
- };
4074
+ });
3966
4075
  const StyledJRFrame = styled.div`
3967
4076
  color:#525252;
3968
4077
  background:white;
@@ -4001,6 +4110,44 @@ const StyledJRFrame = styled.div`
4001
4110
 
4002
4111
  }
4003
4112
  `;
4113
+ function FreeTypeWithSlider({
4114
+ tag,
4115
+ config,
4116
+ me,
4117
+ className,
4118
+ dir
4119
+ }) {
4120
+ if (config) {
4121
+ if (config.resizable) {
4122
+ const ref = useRef();
4123
+ const arr = [/*#__PURE__*/React__default.createElement(FreeType, {
4124
+ tag: tag,
4125
+ config: config,
4126
+ me: me,
4127
+ className: className,
4128
+ ref: ref,
4129
+ key: 'frame'
4130
+ }), /*#__PURE__*/React__default.createElement(Slider$2, {
4131
+ contenerRef: ref,
4132
+ dir: dir,
4133
+ key: 'slider'
4134
+ })];
4135
+ po('right', dir);
4136
+ if (['right'].indexOf(dir) > -1 || ['bottom'].indexOf(dir) > -1) {
4137
+ return arr.reverse();
4138
+ } else {
4139
+ return arr;
4140
+ }
4141
+ } else {
4142
+ return /*#__PURE__*/React__default.createElement(FreeType, {
4143
+ tag: tag,
4144
+ config: config,
4145
+ me: me,
4146
+ className: className
4147
+ });
4148
+ }
4149
+ }
4150
+ }
4004
4151
  class JRFrame extends JRSubmit {
4005
4152
  rid = random(99999, 10000);
4006
4153
  mask = this.props.mask ? () => {
@@ -4019,36 +4166,43 @@ class JRFrame extends JRSubmit {
4019
4166
  id: this.props.id,
4020
4167
  style: this.props.style,
4021
4168
  className: `jr-frame ${this.props.popup !== true ? this.props.className : ''}`
4022
- }, /*#__PURE__*/React__default.createElement(FreeType, {
4169
+ }, /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
4023
4170
  tag: "div",
4024
4171
  config: this.props.start,
4025
4172
  me: this,
4026
- className: 'start'
4027
- }), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeType, {
4173
+ className: 'start',
4174
+ dir: 'left'
4175
+ }), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
4028
4176
  tag: "header",
4029
4177
  config: this.props.top,
4030
- me: this
4031
- }), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeType, {
4178
+ me: this,
4179
+ className: 'header',
4180
+ dir: 'top'
4181
+ }), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
4032
4182
  tag: "div",
4033
4183
  config: this.props.left,
4034
4184
  me: this,
4035
- className: 'left'
4185
+ className: 'left',
4186
+ dir: 'left'
4036
4187
  }), /*#__PURE__*/React__default.createElement("main", {
4037
4188
  className: 'body'
4038
- }, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default.createElement(FreeType, {
4189
+ }, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
4039
4190
  tag: "div",
4040
4191
  config: this.props.right,
4041
4192
  me: this,
4042
- className: 'right'
4043
- })), /*#__PURE__*/React__default.createElement(FreeType, {
4193
+ className: 'right',
4194
+ dir: 'right'
4195
+ })), /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
4044
4196
  tag: "footer",
4045
4197
  config: this.props.bottom,
4046
- me: this
4047
- })), /*#__PURE__*/React__default.createElement(FreeType, {
4198
+ me: this,
4199
+ dir: 'bottom'
4200
+ })), /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
4048
4201
  tag: "div",
4049
4202
  config: this.props.end,
4050
4203
  me: this,
4051
- className: 'end'
4204
+ className: 'end',
4205
+ dir: 'right'
4052
4206
  }), this.mask?.());
4053
4207
  }
4054
4208
  }
@@ -4916,6 +5070,7 @@ class Slider extends React__default.Component {
4916
5070
  this.sliderRef = /*#__PURE__*/React__default.createRef();
4917
5071
  }
4918
5072
  stop = e => {
5073
+ po('stop', this);
4919
5074
  this.sliderRef.current.classList.remove('resizing');
4920
5075
  document.body.style.cursor = 'default';
4921
5076
  window.removeEventListener('mousemove', this.move);
@@ -4924,6 +5079,7 @@ class Slider extends React__default.Component {
4924
5079
  move = ({
4925
5080
  clientX
4926
5081
  }) => {
5082
+ po('move');
4927
5083
  const {
4928
5084
  th,
4929
5085
  selectedCols,
@@ -4941,6 +5097,7 @@ class Slider extends React__default.Component {
4941
5097
  });
4942
5098
  };
4943
5099
  start(thPRef, column) {
5100
+ po('start', this.start);
4944
5101
  const selectedCols = [...this.props.table.colGroupRef.current.children].slice(column.columnNo, column.columnNo + (column.colSpan ?? 1));
4945
5102
  const totalWidth = selectedCols.reduce((aco, {
4946
5103
  offsetWidth
@@ -5903,8 +6060,8 @@ class JRFields extends JRWindow {
5903
6060
  content = /*#__PURE__*/React__default.createElement(StyledColumnValue, {
5904
6061
  className: 'jr-column-value',
5905
6062
  style: {
5906
- gridColumn: label == null ? 'span 2' : null,
5907
- padding: column.render ? '4px 0' : null
6063
+ gridColumn: label == null ? 'span 2' : null
6064
+ // ,padding:column.render?'4px 0':null
5908
6065
  }
5909
6066
  }, column.render ? column.render.bind(this)({
5910
6067
  onChange,
@@ -6402,13 +6559,14 @@ class JRSelect extends JROptions {
6402
6559
  multiple,
6403
6560
  size
6404
6561
  } = this.props;
6562
+ const value = this.getValue() ?? (multiple ? [] : '');
6405
6563
  const options = [...(this.getOptions() ?? [])];
6406
- if (multiple != true && showBlank != false) options.unshift({
6407
- [valueName]: '',
6564
+ if (!multiple && (showBlank != false || value == '')) options.unshift({
6565
+ [valueName]: null,
6408
6566
  [labelName]: ''
6409
6567
  });
6410
6568
  return /*#__PURE__*/React__default.createElement(StyledSelect, {
6411
- value: this.getValue() ?? (multiple ? [] : ''),
6569
+ value: value,
6412
6570
  className: 'jr-select',
6413
6571
  onChange: e => {
6414
6572
  if (multiple) {
@@ -6416,7 +6574,7 @@ class JRSelect extends JROptions {
6416
6574
  this.setValue(selectedIndex.length ? selectedIndex.map(index => options[index][valueName]) : null);
6417
6575
  } else {
6418
6576
  const selectedIndex = e.target.selectedOptions[0].index;
6419
- this.setValue(selectedIndex ? options[selectedIndex][valueName] : null);
6577
+ this.setValue(selectedIndex > -1 ? options[selectedIndex][valueName] : null);
6420
6578
  }
6421
6579
  },
6422
6580
  size: size,
@@ -6426,7 +6584,7 @@ class JRSelect extends JROptions {
6426
6584
  value: record[valueName],
6427
6585
  key: key
6428
6586
  };
6429
- if (multiple && this.getValue()?.indexOf(record[valueName]) > -1 || this.getValue() == record[valueName]) {
6587
+ if (multiple && value?.indexOf(record[valueName]) > -1 || value == record[valueName]) {
6430
6588
  props.className = 'selected';
6431
6589
  }
6432
6590
  return /*#__PURE__*/React__default.createElement(StyledOption, props, record[labelName]);
package/build/index.js CHANGED
@@ -3966,30 +3966,139 @@ class JRSubmit extends React__default["default"].Component {
3966
3966
  }
3967
3967
  }
3968
3968
 
3969
- const FreeType = ({
3969
+ const StyledSlider$2 = styled__default["default"].div`
3970
+ background:#2d2d2d;
3971
+ flex-basis:11px;
3972
+ user-select: none;
3973
+ cursor: ${({
3974
+ $dir
3975
+ }) => $dir === 'left' || $dir === 'right' ? 'col-resize' : 'row-resize'} ;
3976
+ `;
3977
+ class Slider$2 extends React__default["default"].Component {
3978
+ ref = /*#__PURE__*/React__default["default"].createRef();
3979
+ resize = {
3980
+ left: ({
3981
+ clientX
3982
+ }) => {
3983
+ const ref = this.props.contenerRef.current;
3984
+ let width = clientX - this.frame.x - this.frame.shw;
3985
+ if (width < 0) width = 0;
3986
+ ref.style.flexBasis = `${width}px`;
3987
+ },
3988
+ right: ({
3989
+ clientX
3990
+ }) => {
3991
+ const ref = this.props.contenerRef.current;
3992
+ let width = this.frame.x2 - clientX - this.frame.shw;
3993
+ if (width < 0) width = 0;
3994
+ po('width', width);
3995
+ ref.style.flexBasis = `${width}px`;
3996
+ },
3997
+ top: ({
3998
+ clientY
3999
+ }) => {
4000
+ po('top');
4001
+ const ref = this.props.contenerRef.current;
4002
+ let height = clientY - this.frame.y - this.frame.shh;
4003
+ po('height', height);
4004
+ // if(width<0)width=0
4005
+ ref.style.flexBasis = `${height}px`;
4006
+ },
4007
+ bottom: ({
4008
+ clientY
4009
+ }) => {
4010
+ po('bottom');
4011
+ const ref = this.props.contenerRef.current;
4012
+ let height = this.frame.w2 - clientY - this.frame.shh;
4013
+ // clientY-this.frame.y-this.frame.shh
4014
+ // po('height',height)
4015
+ // // if(width<0)width=0
4016
+ ref.style.flexBasis = `${height}px`;
4017
+ }
4018
+ };
4019
+ stop = e => {
4020
+ po('stop', this.stop);
4021
+ document.body.style.cursor = 'default';
4022
+ window.removeEventListener('mousemove', this.move);
4023
+ window.removeEventListener('mouseup', this.stop);
4024
+ };
4025
+ move = e => {
4026
+ this.resize[this.props.dir](e);
4027
+ };
4028
+ start = ({
4029
+ clientX
4030
+ }) => {
4031
+ console.clear();
4032
+ const ref = this.props.contenerRef.current;
4033
+ const {
4034
+ x,
4035
+ y,
4036
+ width,
4037
+ height,
4038
+ ...other
4039
+ } = ref.getBoundingClientRect();
4040
+ po('other', ref.getBoundingClientRect());
4041
+ po('ref.getBoundingClientRect()', this.ref.current.getBoundingClientRect());
4042
+ const {
4043
+ width: sw,
4044
+ height: sh
4045
+ } = this.ref.current.getBoundingClientRect();
4046
+ this.frame = {
4047
+ x,
4048
+ y,
4049
+ shw: sw / 2,
4050
+ shh: sh / 2,
4051
+ x2: x + width,
4052
+ w2: y + height
4053
+ };
4054
+ document.body.style.cursor = 'col-resize';
4055
+ window.addEventListener('mousemove', this.move);
4056
+ window.addEventListener('mouseup', this.stop);
4057
+ };
4058
+ render() {
4059
+ return /*#__PURE__*/React__default["default"].createElement(StyledSlider$2, {
4060
+ onMouseDown: this.start,
4061
+ ref: this.ref,
4062
+ $dir: this.props.dir
4063
+ });
4064
+ }
4065
+ }
4066
+
4067
+ const FreeType = /*#__PURE__*/React.forwardRef(function ({
3970
4068
  tag: Tag,
3971
4069
  config,
3972
4070
  me,
3973
4071
  className
3974
- }) => {
4072
+ }, ref) {
4073
+ let style;
4074
+ const setStyle = function (_style) {
4075
+ style = _style;
4076
+ };
3975
4077
  if (typeof config === 'function') {
3976
- let style;
3977
- const setStyle = function (_style) {
3978
- style = _style;
3979
- };
3980
4078
  const content = config.bind(me)({
3981
4079
  setStyle
3982
4080
  });
3983
4081
  return /*#__PURE__*/React__default["default"].createElement(Tag, {
3984
4082
  className: className,
3985
- style: style
4083
+ style: style,
4084
+ ref: ref
4085
+ }, content);
4086
+ } else if (config?.render) {
4087
+ const content = config.render.bind(me)({
4088
+ setStyle
4089
+ });
4090
+ return /*#__PURE__*/React__default["default"].createElement(Tag, {
4091
+ className: className,
4092
+ style: style,
4093
+ ref: ref
3986
4094
  }, content);
3987
4095
  } else if (typeof config === 'string') {
3988
4096
  return /*#__PURE__*/React__default["default"].createElement(Tag, {
3989
- className: className
4097
+ className: className,
4098
+ ref: ref
3990
4099
  }, config);
3991
4100
  }
3992
- };
4101
+ });
3993
4102
  const StyledJRFrame = styled__default["default"].div`
3994
4103
  color:#525252;
3995
4104
  background:white;
@@ -4028,6 +4137,44 @@ const StyledJRFrame = styled__default["default"].div`
4028
4137
 
4029
4138
  }
4030
4139
  `;
4140
+ function FreeTypeWithSlider({
4141
+ tag,
4142
+ config,
4143
+ me,
4144
+ className,
4145
+ dir
4146
+ }) {
4147
+ if (config) {
4148
+ if (config.resizable) {
4149
+ const ref = React.useRef();
4150
+ const arr = [/*#__PURE__*/React__default["default"].createElement(FreeType, {
4151
+ tag: tag,
4152
+ config: config,
4153
+ me: me,
4154
+ className: className,
4155
+ ref: ref,
4156
+ key: 'frame'
4157
+ }), /*#__PURE__*/React__default["default"].createElement(Slider$2, {
4158
+ contenerRef: ref,
4159
+ dir: dir,
4160
+ key: 'slider'
4161
+ })];
4162
+ po('right', dir);
4163
+ if (['right'].indexOf(dir) > -1 || ['bottom'].indexOf(dir) > -1) {
4164
+ return arr.reverse();
4165
+ } else {
4166
+ return arr;
4167
+ }
4168
+ } else {
4169
+ return /*#__PURE__*/React__default["default"].createElement(FreeType, {
4170
+ tag: tag,
4171
+ config: config,
4172
+ me: me,
4173
+ className: className
4174
+ });
4175
+ }
4176
+ }
4177
+ }
4031
4178
  class JRFrame extends JRSubmit {
4032
4179
  rid = random(99999, 10000);
4033
4180
  mask = this.props.mask ? () => {
@@ -4046,36 +4193,43 @@ class JRFrame extends JRSubmit {
4046
4193
  id: this.props.id,
4047
4194
  style: this.props.style,
4048
4195
  className: `jr-frame ${this.props.popup !== true ? this.props.className : ''}`
4049
- }, /*#__PURE__*/React__default["default"].createElement(FreeType, {
4196
+ }, /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
4050
4197
  tag: "div",
4051
4198
  config: this.props.start,
4052
4199
  me: this,
4053
- className: 'start'
4054
- }), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeType, {
4200
+ className: 'start',
4201
+ dir: 'left'
4202
+ }), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
4055
4203
  tag: "header",
4056
4204
  config: this.props.top,
4057
- me: this
4058
- }), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeType, {
4205
+ me: this,
4206
+ className: 'header',
4207
+ dir: 'top'
4208
+ }), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
4059
4209
  tag: "div",
4060
4210
  config: this.props.left,
4061
4211
  me: this,
4062
- className: 'left'
4212
+ className: 'left',
4213
+ dir: 'left'
4063
4214
  }), /*#__PURE__*/React__default["default"].createElement("main", {
4064
4215
  className: 'body'
4065
- }, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default["default"].createElement(FreeType, {
4216
+ }, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
4066
4217
  tag: "div",
4067
4218
  config: this.props.right,
4068
4219
  me: this,
4069
- className: 'right'
4070
- })), /*#__PURE__*/React__default["default"].createElement(FreeType, {
4220
+ className: 'right',
4221
+ dir: 'right'
4222
+ })), /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
4071
4223
  tag: "footer",
4072
4224
  config: this.props.bottom,
4073
- me: this
4074
- })), /*#__PURE__*/React__default["default"].createElement(FreeType, {
4225
+ me: this,
4226
+ dir: 'bottom'
4227
+ })), /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
4075
4228
  tag: "div",
4076
4229
  config: this.props.end,
4077
4230
  me: this,
4078
- className: 'end'
4231
+ className: 'end',
4232
+ dir: 'right'
4079
4233
  }), this.mask?.());
4080
4234
  }
4081
4235
  }
@@ -4943,6 +5097,7 @@ class Slider extends React__default["default"].Component {
4943
5097
  this.sliderRef = /*#__PURE__*/React__default["default"].createRef();
4944
5098
  }
4945
5099
  stop = e => {
5100
+ po('stop', this);
4946
5101
  this.sliderRef.current.classList.remove('resizing');
4947
5102
  document.body.style.cursor = 'default';
4948
5103
  window.removeEventListener('mousemove', this.move);
@@ -4951,6 +5106,7 @@ class Slider extends React__default["default"].Component {
4951
5106
  move = ({
4952
5107
  clientX
4953
5108
  }) => {
5109
+ po('move');
4954
5110
  const {
4955
5111
  th,
4956
5112
  selectedCols,
@@ -4968,6 +5124,7 @@ class Slider extends React__default["default"].Component {
4968
5124
  });
4969
5125
  };
4970
5126
  start(thPRef, column) {
5127
+ po('start', this.start);
4971
5128
  const selectedCols = [...this.props.table.colGroupRef.current.children].slice(column.columnNo, column.columnNo + (column.colSpan ?? 1));
4972
5129
  const totalWidth = selectedCols.reduce((aco, {
4973
5130
  offsetWidth
@@ -5930,8 +6087,8 @@ class JRFields extends JRWindow {
5930
6087
  content = /*#__PURE__*/React__default["default"].createElement(StyledColumnValue, {
5931
6088
  className: 'jr-column-value',
5932
6089
  style: {
5933
- gridColumn: label == null ? 'span 2' : null,
5934
- padding: column.render ? '4px 0' : null
6090
+ gridColumn: label == null ? 'span 2' : null
6091
+ // ,padding:column.render?'4px 0':null
5935
6092
  }
5936
6093
  }, column.render ? column.render.bind(this)({
5937
6094
  onChange,
@@ -6429,13 +6586,14 @@ class JRSelect extends JROptions {
6429
6586
  multiple,
6430
6587
  size
6431
6588
  } = this.props;
6589
+ const value = this.getValue() ?? (multiple ? [] : '');
6432
6590
  const options = [...(this.getOptions() ?? [])];
6433
- if (multiple != true && showBlank != false) options.unshift({
6434
- [valueName]: '',
6591
+ if (!multiple && (showBlank != false || value == '')) options.unshift({
6592
+ [valueName]: null,
6435
6593
  [labelName]: ''
6436
6594
  });
6437
6595
  return /*#__PURE__*/React__default["default"].createElement(StyledSelect, {
6438
- value: this.getValue() ?? (multiple ? [] : ''),
6596
+ value: value,
6439
6597
  className: 'jr-select',
6440
6598
  onChange: e => {
6441
6599
  if (multiple) {
@@ -6443,7 +6601,7 @@ class JRSelect extends JROptions {
6443
6601
  this.setValue(selectedIndex.length ? selectedIndex.map(index => options[index][valueName]) : null);
6444
6602
  } else {
6445
6603
  const selectedIndex = e.target.selectedOptions[0].index;
6446
- this.setValue(selectedIndex ? options[selectedIndex][valueName] : null);
6604
+ this.setValue(selectedIndex > -1 ? options[selectedIndex][valueName] : null);
6447
6605
  }
6448
6606
  },
6449
6607
  size: size,
@@ -6453,7 +6611,7 @@ class JRSelect extends JROptions {
6453
6611
  value: record[valueName],
6454
6612
  key: key
6455
6613
  };
6456
- if (multiple && this.getValue()?.indexOf(record[valueName]) > -1 || this.getValue() == record[valueName]) {
6614
+ if (multiple && value?.indexOf(record[valueName]) > -1 || value == record[valueName]) {
6457
6615
  props.className = 'selected';
6458
6616
  }
6459
6617
  return /*#__PURE__*/React__default["default"].createElement(StyledOption, props, record[labelName]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jrs-react",
3
- "version": "1.2.35",
3
+ "version": "1.2.36",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.es.js",
@@ -387,7 +387,7 @@ export default class JRFields extends JRWindow {
387
387
  content=<StyledColumnValue className={'jr-column-value'}
388
388
  style={{
389
389
  gridColumn:label==null?'span 2':null
390
- ,padding:column.render?'4px 0':null
390
+ // ,padding:column.render?'4px 0':null
391
391
  }}
392
392
  >
393
393
  {
@@ -1,21 +1,26 @@
1
- import React from "react";
1
+ import React, { forwardRef, useRef } from "react";
2
2
  import styled from "styled-components";
3
3
  import JRSubmit from "../JRSubmit";
4
- import { random } from "../JRUtils";
4
+ import { po, random } from "../JRUtils";
5
+ import Slider from "./Slider";
5
6
 
6
- export const FreeType=({tag:Tag,config,me,className})=>{
7
+ export const FreeType=forwardRef(function({tag:Tag,config,me,className}, ref){
8
+ let style
9
+ const setStyle=function(_style){
10
+ style=_style
11
+ }
7
12
  if(typeof config==='function'){
8
- let style
9
- const setStyle=function(_style){
10
- style=_style
11
- }
12
13
  const content=config.bind(me)({setStyle})
13
- return <Tag className={className} style={style}>{content}</Tag>
14
+ return <Tag className={className} style={style} ref={ref}>{content}</Tag>
15
+ }else if(config?.render){
16
+ const content=config.render.bind(me)({setStyle})
17
+ return <Tag className={className} style={style} ref={ref}>{content}</Tag>
14
18
  }else if(typeof config==='string'){
15
- return <Tag className={className}>{config}</Tag>
19
+ return <Tag className={className} ref={ref}>{config}</Tag>
16
20
  }
21
+ })
22
+
17
23
 
18
- }
19
24
 
20
25
  const StyledJRFrame=styled.div`
21
26
  color:#525252;
@@ -55,6 +60,27 @@ const StyledJRFrame=styled.div`
55
60
 
56
61
  }
57
62
  `
63
+
64
+ function FreeTypeWithSlider({tag,config,me,className,dir}){
65
+ if(config){
66
+ if(config.resizable){
67
+ const ref=useRef()
68
+ const arr=[
69
+ <FreeType tag={tag} config={config} me={me} className={className} ref={ref} key={'frame'}/>
70
+ ,<Slider contenerRef={ref} dir={dir} key={'slider'}/>
71
+ ]
72
+ po('right',dir)
73
+ if(['right'].indexOf(dir)>-1 || ['bottom'].indexOf(dir)>-1 ){
74
+ return arr.reverse()
75
+ }else{
76
+ return arr
77
+ }
78
+ }else{
79
+
80
+ return <FreeType tag={tag} config={config} me={me} className={className}/>
81
+ }
82
+ }
83
+ }
58
84
  export default class JRFrame extends JRSubmit {
59
85
  rid=random(99999,10000)
60
86
  mask=this.props.mask
@@ -74,19 +100,19 @@ export default class JRFrame extends JRSubmit {
74
100
  return <StyledJRFrame id={this.props.id} style={this.props.style}
75
101
  className={`jr-frame ${(this.props.popup!==true )? this.props.className:''}`}
76
102
  >
77
- <FreeType tag='div' config={this.props.start} me={this} className={'start'}/>
103
+ <FreeTypeWithSlider tag='div' config={this.props.start} me={this} className={'start'} dir={'left'}/>
78
104
  <main>
79
- <FreeType tag='header' config={this.props.top} me={this}/>
105
+ <FreeTypeWithSlider tag='header' config={this.props.top} me={this} className={'header'} dir={'top'}/>
80
106
  <main>
81
- <FreeType tag='div' config={this.props.left} me={this} className={'left'}/>
107
+ <FreeTypeWithSlider tag='div' config={this.props.left} me={this} className={'left'} dir={'left'}/>
82
108
  <main className={'body'}>
83
109
  {this.renderMe?.() ?? this.props.children}
84
110
  </main>
85
- <FreeType tag='div' config={this.props.right} me={this} className={'right'}/>
111
+ <FreeTypeWithSlider tag='div' config={this.props.right} me={this} className={'right'} dir={'right'}/>
86
112
  </main>
87
- <FreeType tag='footer' config={this.props.bottom} me={this}/>
113
+ <FreeTypeWithSlider tag='footer' config={this.props.bottom} me={this} dir={'bottom'}/>
88
114
  </main>
89
- <FreeType tag='div' config={this.props.end} me={this} className={'end'}/>
115
+ <FreeTypeWithSlider tag='div' config={this.props.end} me={this} className={'end'} dir={'right'}/>
90
116
  {this.mask?.()}
91
117
  </StyledJRFrame>
92
118
  }
@@ -0,0 +1,79 @@
1
+ import React from "react";
2
+ import styled from "styled-components";
3
+ import { po } from "../JRUtils";
4
+
5
+ const StyledSlider=styled.div`
6
+ background:#2d2d2d;
7
+ flex-basis:11px;
8
+ user-select: none;
9
+ cursor: ${({$dir})=>$dir==='left'||$dir==='right'?'col-resize':'row-resize'} ;
10
+ `
11
+ export default class Slider extends React.Component {
12
+ ref=React.createRef()
13
+
14
+ resize={
15
+ left:({clientX})=>{
16
+ const ref=this.props.contenerRef.current
17
+ let width=clientX-this.frame.x-this.frame.shw
18
+ if(width<0)width=0
19
+ ref.style.flexBasis=`${width}px`
20
+ }
21
+ ,right:({clientX})=>{
22
+ const ref=this.props.contenerRef.current
23
+ let width=this.frame.x2-clientX-this.frame.shw
24
+ if(width<0)width=0
25
+ po('width',width)
26
+ ref.style.flexBasis=`${width}px`
27
+ }
28
+ ,top:({clientY})=>{
29
+ po('top')
30
+ const ref=this.props.contenerRef.current
31
+ let height=clientY-this.frame.y-this.frame.shh
32
+ po('height',height)
33
+ // if(width<0)width=0
34
+ ref.style.flexBasis=`${height}px`
35
+ }
36
+ ,bottom:({clientY})=>{
37
+ po('bottom')
38
+ const ref=this.props.contenerRef.current
39
+ let height=this.frame.w2-clientY-this.frame.shh
40
+ // clientY-this.frame.y-this.frame.shh
41
+ // po('height',height)
42
+ // // if(width<0)width=0
43
+ ref.style.flexBasis=`${height}px`
44
+ }
45
+ }
46
+ stop=(e)=>{
47
+ po('stop',this.stop)
48
+ document.body.style.cursor='default'
49
+ window.removeEventListener('mousemove',this.move)
50
+ window.removeEventListener('mouseup',this.stop)
51
+ }
52
+ move=(e)=>{
53
+ this.resize[this.props.dir](e)
54
+ }
55
+ start=({clientX})=>{
56
+ console.clear()
57
+ const ref=this.props.contenerRef.current
58
+ const {x,y,width,height,...other}=ref.getBoundingClientRect()
59
+ po('other',ref.getBoundingClientRect())
60
+ po('ref.getBoundingClientRect()',this.ref.current.getBoundingClientRect())
61
+ const {width:sw,height:sh}=this.ref.current.getBoundingClientRect()
62
+ this.frame={
63
+ x,y
64
+ ,shw:sw/2
65
+ ,shh:sh/2
66
+ ,x2:x+width
67
+ ,w2:y+height
68
+ }
69
+
70
+ document.body.style.cursor='col-resize'
71
+ window.addEventListener('mousemove',this.move)
72
+ window.addEventListener('mouseup',this.stop)
73
+ }
74
+
75
+ render(){
76
+ return <StyledSlider onMouseDown={this.start} ref={this.ref} $dir={this.props.dir}>
77
+ </StyledSlider>
78
+ }
79
+ }
@@ -22,10 +22,12 @@ const StyledSelect=styled.select`
22
22
  export default class JRSelect extends JROptions{
23
23
  renderer(){
24
24
  const {showBlank,valueName='value',labelName='label',multiple,size}=this.props
25
+ const value=this.getValue()??(multiple?[]:'')
25
26
  const options=[...this.getOptions()??[]]
26
- if(multiple!=true && showBlank!=false)options.unshift({[valueName]:'',[labelName]:''})
27
+ if(!multiple && (showBlank!=false || value==''))options.unshift({[valueName]:null,[labelName]:''})
28
+
27
29
  return <StyledSelect
28
- value={this.getValue()??(multiple?[]:'')}
30
+ value={value}
29
31
  className={'jr-select'}
30
32
  onChange={(e)=>{
31
33
  if(multiple){
@@ -35,8 +37,9 @@ export default class JRSelect extends JROptions{
35
37
  :null
36
38
  )
37
39
  }else{
40
+
38
41
  const selectedIndex=e.target.selectedOptions[0].index
39
- this.setValue(selectedIndex?options[selectedIndex][valueName]:null)
42
+ this.setValue(selectedIndex>-1 ?options[selectedIndex][valueName]:null)
40
43
  }
41
44
  }}
42
45
  size={size}
@@ -49,8 +52,8 @@ export default class JRSelect extends JROptions{
49
52
  ,key:key
50
53
  }
51
54
  if(
52
- (multiple && this.getValue()?.indexOf(record[valueName])>-1)
53
- || this.getValue()==record[valueName]
55
+ (multiple && value?.indexOf(record[valueName])>-1)
56
+ || value==record[valueName]
54
57
  ){
55
58
  props.className='selected'
56
59
  }
@@ -1,5 +1,6 @@
1
1
  import React from "react"
2
2
  import styled from "styled-components"
3
+ import { po } from "../JRUtils";
3
4
 
4
5
  const StyledSlider=styled.div`
5
6
  position: absolute;
@@ -23,12 +24,15 @@ export default class Slider extends React.Component {
23
24
  }
24
25
 
25
26
  stop=(e)=>{
27
+ po('stop',this)
26
28
  this.sliderRef.current.classList.remove('resizing');
27
29
  document.body.style.cursor='default'
28
30
  window.removeEventListener('mousemove',this.move)
31
+
29
32
  window.removeEventListener('mouseup',this.stop)
30
33
  }
31
34
  move=({clientX})=>{
35
+ po('move')
32
36
  const {th,selectedCols,widthRates}=this.data
33
37
  const {left}=th.getBoundingClientRect()
34
38
 
@@ -44,6 +48,7 @@ export default class Slider extends React.Component {
44
48
  })
45
49
  }
46
50
  start(thPRef,column){
51
+ po('start',this.start)
47
52
  const selectedCols=[...this.props.table.colGroupRef.current.children].slice(column.columnNo,column.columnNo+(column.colSpan??1))
48
53
  const totalWidth=selectedCols.reduce((aco,{offsetWidth})=>aco+offsetWidth,0)
49
54
  const widthRates=selectedCols.map(({offsetWidth})=>{
@@ -60,6 +65,8 @@ export default class Slider extends React.Component {
60
65
  document.body.style.cursor='col-resize'
61
66
  window.addEventListener('mousemove',this.move)
62
67
  window.addEventListener('mouseup',this.stop)
68
+
69
+
63
70
 
64
71
  }
65
72