jrs-react 1.2.34 → 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
 
@@ -3439,6 +3439,12 @@ const css = `
3439
3439
  z-index: 20000;
3440
3440
  overflow: hidden;
3441
3441
  background:#000000aa;
3442
+ animation: divDelay .3s;
3443
+ @keyframes divDelay {
3444
+ from {background:transparent;visibility:hidden;}
3445
+ 40% {background:transparent;visibility:hidden;}
3446
+ to {background:#000000aa;visibility:visible;}
3447
+ }
3442
3448
 
3443
3449
  .cs-loader-inner {
3444
3450
  transform: translateY(-30%);
@@ -3533,10 +3539,10 @@ const StyledDialogMask = styled.dialog`
3533
3539
 
3534
3540
  &:modal {
3535
3541
  outline: 0;
3536
- animation: myfirst .3s;
3537
- @keyframes myfirst {
3542
+ animation: modalDelay .3s;
3543
+ @keyframes modalDelay {
3538
3544
  from {background:transparent;visibility:hidden;}
3539
- 99% {background:transparent;visibility:hidden;}
3545
+ 40% {background:transparent;visibility:hidden;}
3540
3546
  to {background:#000000aa;visibility:visible;}
3541
3547
  }
3542
3548
  }
@@ -3933,30 +3939,139 @@ class JRSubmit extends React__default.Component {
3933
3939
  }
3934
3940
  }
3935
3941
 
3936
- 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 ({
3937
4041
  tag: Tag,
3938
4042
  config,
3939
4043
  me,
3940
4044
  className
3941
- }) => {
4045
+ }, ref) {
4046
+ let style;
4047
+ const setStyle = function (_style) {
4048
+ style = _style;
4049
+ };
3942
4050
  if (typeof config === 'function') {
3943
- let style;
3944
- const setStyle = function (_style) {
3945
- style = _style;
3946
- };
3947
4051
  const content = config.bind(me)({
3948
4052
  setStyle
3949
4053
  });
3950
4054
  return /*#__PURE__*/React__default.createElement(Tag, {
3951
4055
  className: className,
3952
- 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
3953
4067
  }, content);
3954
4068
  } else if (typeof config === 'string') {
3955
4069
  return /*#__PURE__*/React__default.createElement(Tag, {
3956
- className: className
4070
+ className: className,
4071
+ ref: ref
3957
4072
  }, config);
3958
4073
  }
3959
- };
4074
+ });
3960
4075
  const StyledJRFrame = styled.div`
3961
4076
  color:#525252;
3962
4077
  background:white;
@@ -3995,6 +4110,44 @@ const StyledJRFrame = styled.div`
3995
4110
 
3996
4111
  }
3997
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
+ }
3998
4151
  class JRFrame extends JRSubmit {
3999
4152
  rid = random(99999, 10000);
4000
4153
  mask = this.props.mask ? () => {
@@ -4013,36 +4166,43 @@ class JRFrame extends JRSubmit {
4013
4166
  id: this.props.id,
4014
4167
  style: this.props.style,
4015
4168
  className: `jr-frame ${this.props.popup !== true ? this.props.className : ''}`
4016
- }, /*#__PURE__*/React__default.createElement(FreeType, {
4169
+ }, /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
4017
4170
  tag: "div",
4018
4171
  config: this.props.start,
4019
4172
  me: this,
4020
- className: 'start'
4021
- }), /*#__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, {
4022
4176
  tag: "header",
4023
4177
  config: this.props.top,
4024
- me: this
4025
- }), /*#__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, {
4026
4182
  tag: "div",
4027
4183
  config: this.props.left,
4028
4184
  me: this,
4029
- className: 'left'
4185
+ className: 'left',
4186
+ dir: 'left'
4030
4187
  }), /*#__PURE__*/React__default.createElement("main", {
4031
4188
  className: 'body'
4032
- }, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default.createElement(FreeType, {
4189
+ }, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
4033
4190
  tag: "div",
4034
4191
  config: this.props.right,
4035
4192
  me: this,
4036
- className: 'right'
4037
- })), /*#__PURE__*/React__default.createElement(FreeType, {
4193
+ className: 'right',
4194
+ dir: 'right'
4195
+ })), /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
4038
4196
  tag: "footer",
4039
4197
  config: this.props.bottom,
4040
- me: this
4041
- })), /*#__PURE__*/React__default.createElement(FreeType, {
4198
+ me: this,
4199
+ dir: 'bottom'
4200
+ })), /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
4042
4201
  tag: "div",
4043
4202
  config: this.props.end,
4044
4203
  me: this,
4045
- className: 'end'
4204
+ className: 'end',
4205
+ dir: 'right'
4046
4206
  }), this.mask?.());
4047
4207
  }
4048
4208
  }
@@ -4910,6 +5070,7 @@ class Slider extends React__default.Component {
4910
5070
  this.sliderRef = /*#__PURE__*/React__default.createRef();
4911
5071
  }
4912
5072
  stop = e => {
5073
+ po('stop', this);
4913
5074
  this.sliderRef.current.classList.remove('resizing');
4914
5075
  document.body.style.cursor = 'default';
4915
5076
  window.removeEventListener('mousemove', this.move);
@@ -4918,6 +5079,7 @@ class Slider extends React__default.Component {
4918
5079
  move = ({
4919
5080
  clientX
4920
5081
  }) => {
5082
+ po('move');
4921
5083
  const {
4922
5084
  th,
4923
5085
  selectedCols,
@@ -4935,6 +5097,7 @@ class Slider extends React__default.Component {
4935
5097
  });
4936
5098
  };
4937
5099
  start(thPRef, column) {
5100
+ po('start', this.start);
4938
5101
  const selectedCols = [...this.props.table.colGroupRef.current.children].slice(column.columnNo, column.columnNo + (column.colSpan ?? 1));
4939
5102
  const totalWidth = selectedCols.reduce((aco, {
4940
5103
  offsetWidth
@@ -5897,8 +6060,8 @@ class JRFields extends JRWindow {
5897
6060
  content = /*#__PURE__*/React__default.createElement(StyledColumnValue, {
5898
6061
  className: 'jr-column-value',
5899
6062
  style: {
5900
- gridColumn: label == null ? 'span 2' : null,
5901
- padding: column.render ? '4px 0' : null
6063
+ gridColumn: label == null ? 'span 2' : null
6064
+ // ,padding:column.render?'4px 0':null
5902
6065
  }
5903
6066
  }, column.render ? column.render.bind(this)({
5904
6067
  onChange,
@@ -6396,13 +6559,14 @@ class JRSelect extends JROptions {
6396
6559
  multiple,
6397
6560
  size
6398
6561
  } = this.props;
6562
+ const value = this.getValue() ?? (multiple ? [] : '');
6399
6563
  const options = [...(this.getOptions() ?? [])];
6400
- if (multiple != true && showBlank != false) options.unshift({
6401
- [valueName]: '',
6564
+ if (!multiple && (showBlank != false || value == '')) options.unshift({
6565
+ [valueName]: null,
6402
6566
  [labelName]: ''
6403
6567
  });
6404
6568
  return /*#__PURE__*/React__default.createElement(StyledSelect, {
6405
- value: this.getValue() ?? (multiple ? [] : ''),
6569
+ value: value,
6406
6570
  className: 'jr-select',
6407
6571
  onChange: e => {
6408
6572
  if (multiple) {
@@ -6410,7 +6574,7 @@ class JRSelect extends JROptions {
6410
6574
  this.setValue(selectedIndex.length ? selectedIndex.map(index => options[index][valueName]) : null);
6411
6575
  } else {
6412
6576
  const selectedIndex = e.target.selectedOptions[0].index;
6413
- this.setValue(selectedIndex ? options[selectedIndex][valueName] : null);
6577
+ this.setValue(selectedIndex > -1 ? options[selectedIndex][valueName] : null);
6414
6578
  }
6415
6579
  },
6416
6580
  size: size,
@@ -6420,7 +6584,7 @@ class JRSelect extends JROptions {
6420
6584
  value: record[valueName],
6421
6585
  key: key
6422
6586
  };
6423
- if (multiple && this.getValue()?.indexOf(record[valueName]) > -1 || this.getValue() == record[valueName]) {
6587
+ if (multiple && value?.indexOf(record[valueName]) > -1 || value == record[valueName]) {
6424
6588
  props.className = 'selected';
6425
6589
  }
6426
6590
  return /*#__PURE__*/React__default.createElement(StyledOption, props, record[labelName]);
package/build/index.js CHANGED
@@ -3466,6 +3466,12 @@ const css = `
3466
3466
  z-index: 20000;
3467
3467
  overflow: hidden;
3468
3468
  background:#000000aa;
3469
+ animation: divDelay .3s;
3470
+ @keyframes divDelay {
3471
+ from {background:transparent;visibility:hidden;}
3472
+ 40% {background:transparent;visibility:hidden;}
3473
+ to {background:#000000aa;visibility:visible;}
3474
+ }
3469
3475
 
3470
3476
  .cs-loader-inner {
3471
3477
  transform: translateY(-30%);
@@ -3560,10 +3566,10 @@ const StyledDialogMask = styled__default["default"].dialog`
3560
3566
 
3561
3567
  &:modal {
3562
3568
  outline: 0;
3563
- animation: myfirst .3s;
3564
- @keyframes myfirst {
3569
+ animation: modalDelay .3s;
3570
+ @keyframes modalDelay {
3565
3571
  from {background:transparent;visibility:hidden;}
3566
- 99% {background:transparent;visibility:hidden;}
3572
+ 40% {background:transparent;visibility:hidden;}
3567
3573
  to {background:#000000aa;visibility:visible;}
3568
3574
  }
3569
3575
  }
@@ -3960,30 +3966,139 @@ class JRSubmit extends React__default["default"].Component {
3960
3966
  }
3961
3967
  }
3962
3968
 
3963
- 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 ({
3964
4068
  tag: Tag,
3965
4069
  config,
3966
4070
  me,
3967
4071
  className
3968
- }) => {
4072
+ }, ref) {
4073
+ let style;
4074
+ const setStyle = function (_style) {
4075
+ style = _style;
4076
+ };
3969
4077
  if (typeof config === 'function') {
3970
- let style;
3971
- const setStyle = function (_style) {
3972
- style = _style;
3973
- };
3974
4078
  const content = config.bind(me)({
3975
4079
  setStyle
3976
4080
  });
3977
4081
  return /*#__PURE__*/React__default["default"].createElement(Tag, {
3978
4082
  className: className,
3979
- 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
3980
4094
  }, content);
3981
4095
  } else if (typeof config === 'string') {
3982
4096
  return /*#__PURE__*/React__default["default"].createElement(Tag, {
3983
- className: className
4097
+ className: className,
4098
+ ref: ref
3984
4099
  }, config);
3985
4100
  }
3986
- };
4101
+ });
3987
4102
  const StyledJRFrame = styled__default["default"].div`
3988
4103
  color:#525252;
3989
4104
  background:white;
@@ -4022,6 +4137,44 @@ const StyledJRFrame = styled__default["default"].div`
4022
4137
 
4023
4138
  }
4024
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
+ }
4025
4178
  class JRFrame extends JRSubmit {
4026
4179
  rid = random(99999, 10000);
4027
4180
  mask = this.props.mask ? () => {
@@ -4040,36 +4193,43 @@ class JRFrame extends JRSubmit {
4040
4193
  id: this.props.id,
4041
4194
  style: this.props.style,
4042
4195
  className: `jr-frame ${this.props.popup !== true ? this.props.className : ''}`
4043
- }, /*#__PURE__*/React__default["default"].createElement(FreeType, {
4196
+ }, /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
4044
4197
  tag: "div",
4045
4198
  config: this.props.start,
4046
4199
  me: this,
4047
- className: 'start'
4048
- }), /*#__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, {
4049
4203
  tag: "header",
4050
4204
  config: this.props.top,
4051
- me: this
4052
- }), /*#__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, {
4053
4209
  tag: "div",
4054
4210
  config: this.props.left,
4055
4211
  me: this,
4056
- className: 'left'
4212
+ className: 'left',
4213
+ dir: 'left'
4057
4214
  }), /*#__PURE__*/React__default["default"].createElement("main", {
4058
4215
  className: 'body'
4059
- }, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default["default"].createElement(FreeType, {
4216
+ }, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
4060
4217
  tag: "div",
4061
4218
  config: this.props.right,
4062
4219
  me: this,
4063
- className: 'right'
4064
- })), /*#__PURE__*/React__default["default"].createElement(FreeType, {
4220
+ className: 'right',
4221
+ dir: 'right'
4222
+ })), /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
4065
4223
  tag: "footer",
4066
4224
  config: this.props.bottom,
4067
- me: this
4068
- })), /*#__PURE__*/React__default["default"].createElement(FreeType, {
4225
+ me: this,
4226
+ dir: 'bottom'
4227
+ })), /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
4069
4228
  tag: "div",
4070
4229
  config: this.props.end,
4071
4230
  me: this,
4072
- className: 'end'
4231
+ className: 'end',
4232
+ dir: 'right'
4073
4233
  }), this.mask?.());
4074
4234
  }
4075
4235
  }
@@ -4937,6 +5097,7 @@ class Slider extends React__default["default"].Component {
4937
5097
  this.sliderRef = /*#__PURE__*/React__default["default"].createRef();
4938
5098
  }
4939
5099
  stop = e => {
5100
+ po('stop', this);
4940
5101
  this.sliderRef.current.classList.remove('resizing');
4941
5102
  document.body.style.cursor = 'default';
4942
5103
  window.removeEventListener('mousemove', this.move);
@@ -4945,6 +5106,7 @@ class Slider extends React__default["default"].Component {
4945
5106
  move = ({
4946
5107
  clientX
4947
5108
  }) => {
5109
+ po('move');
4948
5110
  const {
4949
5111
  th,
4950
5112
  selectedCols,
@@ -4962,6 +5124,7 @@ class Slider extends React__default["default"].Component {
4962
5124
  });
4963
5125
  };
4964
5126
  start(thPRef, column) {
5127
+ po('start', this.start);
4965
5128
  const selectedCols = [...this.props.table.colGroupRef.current.children].slice(column.columnNo, column.columnNo + (column.colSpan ?? 1));
4966
5129
  const totalWidth = selectedCols.reduce((aco, {
4967
5130
  offsetWidth
@@ -5924,8 +6087,8 @@ class JRFields extends JRWindow {
5924
6087
  content = /*#__PURE__*/React__default["default"].createElement(StyledColumnValue, {
5925
6088
  className: 'jr-column-value',
5926
6089
  style: {
5927
- gridColumn: label == null ? 'span 2' : null,
5928
- padding: column.render ? '4px 0' : null
6090
+ gridColumn: label == null ? 'span 2' : null
6091
+ // ,padding:column.render?'4px 0':null
5929
6092
  }
5930
6093
  }, column.render ? column.render.bind(this)({
5931
6094
  onChange,
@@ -6423,13 +6586,14 @@ class JRSelect extends JROptions {
6423
6586
  multiple,
6424
6587
  size
6425
6588
  } = this.props;
6589
+ const value = this.getValue() ?? (multiple ? [] : '');
6426
6590
  const options = [...(this.getOptions() ?? [])];
6427
- if (multiple != true && showBlank != false) options.unshift({
6428
- [valueName]: '',
6591
+ if (!multiple && (showBlank != false || value == '')) options.unshift({
6592
+ [valueName]: null,
6429
6593
  [labelName]: ''
6430
6594
  });
6431
6595
  return /*#__PURE__*/React__default["default"].createElement(StyledSelect, {
6432
- value: this.getValue() ?? (multiple ? [] : ''),
6596
+ value: value,
6433
6597
  className: 'jr-select',
6434
6598
  onChange: e => {
6435
6599
  if (multiple) {
@@ -6437,7 +6601,7 @@ class JRSelect extends JROptions {
6437
6601
  this.setValue(selectedIndex.length ? selectedIndex.map(index => options[index][valueName]) : null);
6438
6602
  } else {
6439
6603
  const selectedIndex = e.target.selectedOptions[0].index;
6440
- this.setValue(selectedIndex ? options[selectedIndex][valueName] : null);
6604
+ this.setValue(selectedIndex > -1 ? options[selectedIndex][valueName] : null);
6441
6605
  }
6442
6606
  },
6443
6607
  size: size,
@@ -6447,7 +6611,7 @@ class JRSelect extends JROptions {
6447
6611
  value: record[valueName],
6448
6612
  key: key
6449
6613
  };
6450
- if (multiple && this.getValue()?.indexOf(record[valueName]) > -1 || this.getValue() == record[valueName]) {
6614
+ if (multiple && value?.indexOf(record[valueName]) > -1 || value == record[valueName]) {
6451
6615
  props.className = 'selected';
6452
6616
  }
6453
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.34",
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
  }
@@ -19,6 +19,12 @@ const css=`
19
19
  z-index: 20000;
20
20
  overflow: hidden;
21
21
  background:#000000aa;
22
+ animation: divDelay .3s;
23
+ @keyframes divDelay {
24
+ from {background:transparent;visibility:hidden;}
25
+ 40% {background:transparent;visibility:hidden;}
26
+ to {background:#000000aa;visibility:visible;}
27
+ }
22
28
 
23
29
  .cs-loader-inner {
24
30
  transform: translateY(-30%);
@@ -111,10 +117,10 @@ const StyledDialogMask = styled.dialog`
111
117
 
112
118
  &:modal {
113
119
  outline: 0;
114
- animation: myfirst .3s;
115
- @keyframes myfirst {
120
+ animation: modalDelay .3s;
121
+ @keyframes modalDelay {
116
122
  from {background:transparent;visibility:hidden;}
117
- 99% {background:transparent;visibility:hidden;}
123
+ 40% {background:transparent;visibility:hidden;}
118
124
  to {background:#000000aa;visibility:visible;}
119
125
  }
120
126
  }
@@ -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