jrs-react 1.2.47 → 1.2.48

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
@@ -3794,6 +3794,7 @@ class JRSubmit extends React__default.Component {
3794
3794
  extraValue,
3795
3795
  sendValue,
3796
3796
  transformValue,
3797
+ responseType = 'json',
3797
3798
  ...params
3798
3799
  }) {
3799
3800
  const _extraValue = extraValue?.bind?.(this)() ?? extraValue;
@@ -3827,7 +3828,9 @@ class JRSubmit extends React__default.Component {
3827
3828
  const headers = {
3828
3829
  authorization: `Bearer ${localStorage.getItem("accessToken")}`
3829
3830
  };
3830
- let params1 = {};
3831
+ let params1 = {
3832
+ responseType
3833
+ };
3831
3834
  const params2 = {};
3832
3835
  if (method == 'get') {
3833
3836
  if (sendValue == null || sendValue) params1.params = payload;
@@ -3964,19 +3967,23 @@ class Slider$2 extends React__default.Component {
3964
3967
  const ref = this.props.contenerRef.current;
3965
3968
  let width = this.frame.x2 - clientX - this.frame.shw;
3966
3969
  if (width < 0) width = 0;
3970
+ po('width', width);
3967
3971
  ref.style.flexBasis = `${width}px`;
3968
3972
  },
3969
3973
  top: ({
3970
3974
  clientY
3971
3975
  }) => {
3976
+ po('top');
3972
3977
  const ref = this.props.contenerRef.current;
3973
3978
  let height = clientY - this.frame.y - this.frame.shh;
3979
+ po('height', height);
3974
3980
  // if(width<0)width=0
3975
3981
  ref.style.flexBasis = `${height}px`;
3976
3982
  },
3977
3983
  bottom: ({
3978
3984
  clientY
3979
3985
  }) => {
3986
+ po('bottom');
3980
3987
  const ref = this.props.contenerRef.current;
3981
3988
  let height = this.frame.w2 - clientY - this.frame.shh;
3982
3989
  // clientY-this.frame.y-this.frame.shh
@@ -3986,6 +3993,7 @@ class Slider$2 extends React__default.Component {
3986
3993
  }
3987
3994
  };
3988
3995
  stop = e => {
3996
+ po('stop', this.stop);
3989
3997
  document.body.style.cursor = 'default';
3990
3998
  window.removeEventListener('mousemove', this.move);
3991
3999
  window.removeEventListener('mouseup', this.stop);
@@ -3996,6 +4004,7 @@ class Slider$2 extends React__default.Component {
3996
4004
  start = ({
3997
4005
  clientX
3998
4006
  }) => {
4007
+ console.clear();
3999
4008
  const ref = this.props.contenerRef.current;
4000
4009
  const {
4001
4010
  x,
@@ -4004,6 +4013,8 @@ class Slider$2 extends React__default.Component {
4004
4013
  height,
4005
4014
  ...other
4006
4015
  } = ref.getBoundingClientRect();
4016
+ po('other', ref.getBoundingClientRect());
4017
+ po('ref.getBoundingClientRect()', this.ref.current.getBoundingClientRect());
4007
4018
  const {
4008
4019
  width: sw,
4009
4020
  height: sh
@@ -4201,20 +4212,10 @@ class JRFrame extends JRSubmit {
4201
4212
  }
4202
4213
  }
4203
4214
 
4204
- function _extends$1() {
4205
- return _extends$1 = Object.assign ? Object.assign.bind() : function (n) {
4206
- for (var e = 1; e < arguments.length; e++) {
4207
- var t = arguments[e];
4208
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
4209
- }
4210
- return n;
4211
- }, _extends$1.apply(null, arguments);
4212
- }
4213
-
4214
4215
  var _path;
4215
- 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); }
4216
+ 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); }
4216
4217
  var SvgX = function SvgX(props) {
4217
- return /*#__PURE__*/React.createElement("svg", _extends({
4218
+ return /*#__PURE__*/React.createElement("svg", _extends$1({
4218
4219
  xmlns: "http://www.w3.org/2000/svg",
4219
4220
  width: 24,
4220
4221
  height: 24,
@@ -4443,8 +4444,6 @@ class TitleBar extends React__default.Component {
4443
4444
  window.removeEventListener('mousemove', this.preMove);
4444
4445
  };
4445
4446
  start(e) {
4446
- po('start', this);
4447
- po('this.props.windowRef', this.props.windowRef);
4448
4447
  e.preventDefault();
4449
4448
  this.moved = false;
4450
4449
  this.pos3 = e.clientX;
@@ -4469,7 +4468,7 @@ class TitleBar extends React__default.Component {
4469
4468
  config: this.props.title ?? '',
4470
4469
  me: this.props.window,
4471
4470
  className: 'title'
4472
- }), /*#__PURE__*/React__default.createElement("nav", null, this.props.jrWindow.props.close ? /*#__PURE__*/React__default.createElement(JRButton, {
4471
+ }), /*#__PURE__*/React__default.createElement("nav", null, this.props.window.props.setOpen ? /*#__PURE__*/React__default.createElement(JRButton, {
4473
4472
  icon: /*#__PURE__*/React__default.createElement(SvgX, null),
4474
4473
  className: 'danger',
4475
4474
  onClick: e => {
@@ -4477,7 +4476,7 @@ class TitleBar extends React__default.Component {
4477
4476
  if (this.props.window.orgBodyOverflow != null) {
4478
4477
  document.body.style.overflow = this.props.window.orgBodyOverflow;
4479
4478
  }
4480
- this.props.jrWindow.props.close();
4479
+ this.props.window.props.setOpen(false);
4481
4480
  },
4482
4481
  onMouseDown: e => {
4483
4482
  e.stopPropagation();
@@ -4953,49 +4952,99 @@ class Backdrop extends JRHTML {
4953
4952
  left: 0
4954
4953
  }
4955
4954
  };
4956
- constructor({
4957
- zIndex,
4958
- fullScreen,
4959
- ...params
4960
- }) {
4955
+ constructor(params) {
4961
4956
  super(params);
4962
- this.backdropConfig.style.zIndex = zIndex;
4963
- this.backdropConfig.personajes = {
4964
- id: params.backdropId
4965
- };
4966
4957
  Object.assign(this.backdropConfig.style, params.backdropStyle);
4967
4958
  }
4968
4959
  show() {
4969
- this.agregarHijo(this.backdropConfig);
4960
+ this.backdrop = this.agregarHijo(this.backdropConfig);
4970
4961
  }
4971
4962
  hide() {
4972
- const backdrop = document.getElementById(this.backdropId);
4973
- if (backdrop) {
4974
- backdrop.parentNode.removeChild(backdrop);
4975
- }
4963
+ this.yo.removeChild(this.yo.children[this.yo.children.length - 1]);
4976
4964
  this.hijos = [];
4977
4965
  }
4978
4966
  }
4979
- class RWindow extends React__default.Component {
4967
+ class JRWindow extends JRFrame {
4968
+ // x=0
4969
+ // y=0
4970
+ // width=300
4971
+ // height=300
4980
4972
  padding = 1;
4981
4973
  thick = 5;
4982
4974
  constructor(props) {
4983
4975
  super(props);
4976
+ this.ref = /*#__PURE__*/React__default.createRef();
4984
4977
  this.titleBarRef = /*#__PURE__*/React__default.createRef();
4985
4978
  }
4979
+ createBackdrop() {
4980
+ if (typeof this.props.backdrop === 'string') {
4981
+ const target = document.getElementById(this.props.backdrop);
4982
+ if (target) {
4983
+ this.backdropTarget = new Backdrop({
4984
+ yo: target,
4985
+ style: {
4986
+ position: 'relative'
4987
+ },
4988
+ backdropStyle: this.props.backdropStyle
4989
+ });
4990
+ }
4991
+ }
4992
+ }
4993
+ addMaskToTarget = target => {
4994
+ this.mask = document.createElement('div');
4995
+ this.mask.style.background = '#868686cc';
4996
+ this.mask.style.position = 'absolute';
4997
+ this.mask.style.top = '0';
4998
+ this.mask.style.left = '0';
4999
+ this.mask.style.right = '0';
5000
+ this.mask.style.bottom = '0';
5001
+ this.mask.style.borderRadius = 'inherit';
5002
+ this.mask.style.height = '10000px';
5003
+ this.mask.style.width = '10000px';
5004
+ target.appendChild(this.mask);
5005
+ };
5006
+ removeMaskFromTarget = () => {
5007
+ this.mask.remove();
5008
+ };
5009
+
5010
+ // backdropOn(on){
5011
+ // const target=(typeof this.props.backdrop)==='object'
5012
+ // ?this.props.backdrop
5013
+ // :typeof this.props.backdrop ==='string'
5014
+ // ?document.getElementById(this.props.backdrop)
5015
+ // :document.body
5016
+ // target?.classList[on?'add':'remove']('withMask')
5017
+ // }
5018
+
4986
5019
  componentDidMount() {
5020
+ super.componentDidMount();
5021
+ this.createBackdrop();
4987
5022
  if (this.props.open) {
4988
- this.props.jrWindow.backdropTarget?.show();
4989
- this.props.onOpen?.bind(this.props.jrWindow)();
5023
+ this.open();
4990
5024
  }
4991
5025
  }
4992
- componentWillUnmount() {
4993
- if (this.props.open) {
4994
- this.props.jrWindow.backdropTarget?.hide();
5026
+ open() {
5027
+ this.backdropTarget?.show();
5028
+ this.props.onOpen?.bind(this)();
5029
+ }
5030
+ close() {
5031
+ this.backdropTarget?.hide();
5032
+ this.props.onClose?.bind(this)();
5033
+ }
5034
+ componentDidUpdate(prevProps, prevState, snapshot) {
5035
+ if (this.props.popup === true) {
5036
+ if (this.props.open && prevProps.open === false) {
5037
+ this.open();
5038
+ } else if (this.props.open === false && prevProps.open) {
5039
+ this.close();
5040
+ }
5041
+ // if(this.props.backdrop && this.props.open!=prevProps.open){
5042
+ // this.backdropOn(this.props.open)
5043
+ // }
4995
5044
  }
4996
5045
  }
4997
5046
  get xw() {
4998
- let width = 700;
5047
+ let width;
4999
5048
  if (this.props.width?.indexOf?.('%') > -1) {
5000
5049
  width = this.props.width.split('%')[0] * window.innerWidth / 100;
5001
5050
  } else {
@@ -5007,7 +5056,7 @@ class RWindow extends React__default.Component {
5007
5056
  };
5008
5057
  }
5009
5058
  get yh() {
5010
- let height = 400;
5059
+ let height;
5011
5060
  if (this.props.height?.indexOf?.('%') > -1) {
5012
5061
  height = this.props.height.split('%')[0] * window.innerHeight / 100;
5013
5062
  } else {
@@ -5018,93 +5067,34 @@ class RWindow extends React__default.Component {
5018
5067
  height
5019
5068
  };
5020
5069
  }
5021
- render() {
5022
- const {
5023
- children,
5024
- title,
5025
- resizable,
5026
- jrWindow,
5027
- ...props
5028
- } = this.props;
5029
- return /*#__PURE__*/React__default.createElement(StyledJRWindow, {
5030
- $zIndex: this.props.zIndex ? this.props.zIndex + 1 : null,
5070
+ renderer() {
5071
+ return this.props.popup === true ? this.props.open ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(StyledJRWindow, {
5072
+ $zIndex: this.props.zIndex,
5073
+ rule: 'dialog',
5074
+ ref: this.ref,
5031
5075
  className: `jr-window ${this.props.className ?? ''}`,
5032
- ref: this.props.windowRef,
5033
5076
  $xw: this.xw,
5034
5077
  $yh: this.yh,
5035
5078
  $thick: this.thick
5036
5079
  }, /*#__PURE__*/React__default.createElement("main", {
5037
5080
  style: {
5038
- zIndex: this.props.zIndex ? this.props.zIndex + 1 : null
5081
+ zIndex: 1
5039
5082
  }
5040
5083
  }, /*#__PURE__*/React__default.createElement(TitleBar, {
5041
5084
  titleBarRef: this.titleBarRef,
5042
- jrWindow: jrWindow,
5043
- windowRef: this.props.windowRef,
5085
+ windowRef: this.ref,
5044
5086
  window: this,
5045
- title: title,
5087
+ title: this.props.title,
5046
5088
  thick: this.thick,
5047
- resizable: resizable
5048
- }), children, this.props.resizable !== false && /*#__PURE__*/React__default.createElement(Sliders, {
5089
+ resizable: this.props.resizable
5090
+ }), /*#__PURE__*/React__default.createElement("main", null, super.renderer()), this.props.resizable !== false && /*#__PURE__*/React__default.createElement(Sliders, {
5049
5091
  thick: this.thick,
5050
- windowRef: this.props.windowRef,
5092
+ windowRef: this.ref,
5051
5093
  window: this,
5052
5094
  titleBarRef: this.titleBarRef
5053
- })), this.props.backdrop === true && /*#__PURE__*/React__default.createElement(StyledBackdrop, {
5095
+ })), this.props.backdrop !== false && typeof this.props.backdrop !== 'string' && /*#__PURE__*/React__default.createElement(StyledBackdrop, {
5054
5096
  $zIndex: this.props.zIndex
5055
- }));
5056
- }
5057
- }
5058
- class JRWindow extends JRFrame {
5059
- constructor(props) {
5060
- super(props);
5061
- this.windowRef = /*#__PURE__*/React__default.createRef();
5062
- this.backdropId = `backdropId-${random(10000, 99999)}`;
5063
- }
5064
- componentDidMount() {
5065
- super.componentDidMount();
5066
- this.createBackdrop();
5067
- }
5068
- componentWillUnmount() {
5069
- if (this.props.open) {
5070
- this.backdropTarget?.hide();
5071
- }
5072
- }
5073
- componentDidUpdate(prevProps, prevState) {
5074
- if (prevProps.open && prevProps.open != this.props.open) {
5075
- this.props.onClose?.bind(this)();
5076
- }
5077
- }
5078
- componentWillUpdate;
5079
- createBackdrop() {
5080
- if (typeof this.props.backdrop === 'string') {
5081
- const target = document.getElementById(this.props.backdrop);
5082
- if (target) {
5083
- this.backdropTarget = new Backdrop({
5084
- yo: target,
5085
- backdropId: this.backdropId,
5086
- fullScreen: this.props.backdrop === true,
5087
- zIndex: this.props.zIndex,
5088
- backdropStyle: this.props.backdropStyle
5089
- });
5090
- if (this.props.open) {
5091
- this.backdropTarget.show();
5092
- }
5093
- }
5094
- }
5095
- }
5096
- renderer() {
5097
- const {
5098
- popup,
5099
- open,
5100
- xzIndex = 1,
5101
- ...props
5102
- } = this.props;
5103
- return popup === true ? open ? /*#__PURE__*/React__default.createElement(RWindow, _extends$1({}, props, {
5104
- jrWindow: this,
5105
- open: open,
5106
- windowRef: this.windowRef
5107
- }), super.renderer()) : '' : super.renderer();
5097
+ }))) : '' : super.renderer();
5108
5098
  }
5109
5099
  }
5110
5100
 
@@ -5300,6 +5290,16 @@ const TFoot = ({
5300
5290
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("tfoot", null, trs));
5301
5291
  };
5302
5292
 
5293
+ function _extends() {
5294
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
5295
+ for (var e = 1; e < arguments.length; e++) {
5296
+ var t = arguments[e];
5297
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
5298
+ }
5299
+ return n;
5300
+ }, _extends.apply(null, arguments);
5301
+ }
5302
+
5303
5303
  styled.tbody`
5304
5304
  th{
5305
5305
  height:4px;
@@ -5380,7 +5380,7 @@ styled.tr`
5380
5380
  }
5381
5381
  `;
5382
5382
  const GroupHeader = props => {
5383
- return /*#__PURE__*/React__default.createElement(GroupColumns, _extends$1({
5383
+ return /*#__PURE__*/React__default.createElement(GroupColumns, _extends({
5384
5384
  trClassName: 'jr-group-header'
5385
5385
  }, props));
5386
5386
  };
@@ -5391,7 +5391,7 @@ styled.tr`
5391
5391
  }
5392
5392
  `;
5393
5393
  const GroupFooter = props => {
5394
- return /*#__PURE__*/React__default.createElement(GroupColumns, _extends$1({
5394
+ return /*#__PURE__*/React__default.createElement(GroupColumns, _extends({
5395
5395
  trClassName: 'jr-group-footer'
5396
5396
  }, props));
5397
5397
  };
@@ -5510,7 +5510,7 @@ const TBody = ({
5510
5510
  };
5511
5511
  return /*#__PURE__*/React__default.createElement("tbody", {
5512
5512
  key: `tbody${tbodyIndex}`
5513
- }, groupData?.length > 0 && /*#__PURE__*/React__default.createElement(GroupHeader, _extends$1({
5513
+ }, groupData?.length > 0 && /*#__PURE__*/React__default.createElement(GroupHeader, _extends({
5514
5514
  groupData: groupData,
5515
5515
  columns: groupHeader
5516
5516
  }, neededProps)), groupData?.map?.((record, trIndex) => {
@@ -5524,13 +5524,13 @@ const TBody = ({
5524
5524
  groupIndex: tbodyIndex
5525
5525
  });
5526
5526
  }
5527
- }, /*#__PURE__*/React__default.createElement(Tds, _extends$1({
5527
+ }, /*#__PURE__*/React__default.createElement(Tds, _extends({
5528
5528
  record: record,
5529
5529
  trIndex: trIndex
5530
5530
  }, neededProps, {
5531
5531
  leafColumns: leafColumns
5532
5532
  })));
5533
- }), groupData?.length > 0 && /*#__PURE__*/React__default.createElement(GroupFooter, _extends$1({
5533
+ }), groupData?.length > 0 && /*#__PURE__*/React__default.createElement(GroupFooter, _extends({
5534
5534
  groupData: groupData,
5535
5535
  columns: groupFooter
5536
5536
  }, neededProps)));
@@ -6013,6 +6013,7 @@ class JRFields extends JRWindow {
6013
6013
  }, validators);
6014
6014
  }
6015
6015
  validate(value) {
6016
+ console.clear();
6016
6017
  const validators = [];
6017
6018
  const testValue = this.getTestValue() ?? {};
6018
6019
  this.#validators(this.getColumns(), validators, [], testValue, value !== undefined ? value : this.getValue());
@@ -6498,7 +6499,7 @@ function JRAlertWindow({
6498
6499
  ...props
6499
6500
  }) {
6500
6501
  const [open, setOpen] = useState(true);
6501
- return /*#__PURE__*/React__default.createElement(StyledAlert, _extends$1({
6502
+ return /*#__PURE__*/React__default.createElement(StyledAlert, _extends({
6502
6503
  initValue: {
6503
6504
  message
6504
6505
  },
@@ -6537,7 +6538,7 @@ function JRAlert(props) {
6537
6538
  }
6538
6539
  const jrAlerDiv = document.createElement('div');
6539
6540
  container.appendChild(jrAlerDiv);
6540
- createRoot(jrAlerDiv).render(/*#__PURE__*/React__default.createElement(JRAlertWindow, _extends$1({}, props, {
6541
+ createRoot(jrAlerDiv).render(/*#__PURE__*/React__default.createElement(JRAlertWindow, _extends({}, props, {
6541
6542
  container: jrAlerDiv
6542
6543
  })));
6543
6544
  }