jrs-react 1.2.35 → 1.2.37
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 +211 -46
- package/build/index.js +210 -45
- package/package.json +1 -1
- package/src/components/JRAlert/JRAlert.jsx +1 -1
- package/src/components/JRFields/JRFields.jsx +1 -1
- package/src/components/JRFrame/JRFrame.jsx +45 -17
- package/src/components/JRFrame/Slider.jsx +79 -0
- package/src/components/JRInput/JRSelect.jsx +8 -5
- package/src/components/JRTable/Slider.jsx +7 -0
- package/src/components/JRWindow/JRWindow.jsx +24 -16
- package/src/components/JRWindow/TitleBar.jsx +3 -5
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,141 @@ class JRSubmit extends React__default.Component {
|
|
|
3939
3939
|
}
|
|
3940
3940
|
}
|
|
3941
3941
|
|
|
3942
|
-
const
|
|
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'){
|
|
4069
|
+
// return <Tag className={className} ref={ref}>{config}</Tag>
|
|
4070
|
+
} else {
|
|
3961
4071
|
return /*#__PURE__*/React__default.createElement(Tag, {
|
|
3962
|
-
className: className
|
|
4072
|
+
className: className,
|
|
4073
|
+
ref: ref
|
|
3963
4074
|
}, config);
|
|
3964
4075
|
}
|
|
3965
|
-
};
|
|
4076
|
+
});
|
|
3966
4077
|
const StyledJRFrame = styled.div`
|
|
3967
4078
|
color:#525252;
|
|
3968
4079
|
background:white;
|
|
@@ -4001,6 +4112,44 @@ const StyledJRFrame = styled.div`
|
|
|
4001
4112
|
|
|
4002
4113
|
}
|
|
4003
4114
|
`;
|
|
4115
|
+
function FreeTypeWithSlider({
|
|
4116
|
+
tag,
|
|
4117
|
+
config,
|
|
4118
|
+
me,
|
|
4119
|
+
className,
|
|
4120
|
+
dir
|
|
4121
|
+
}) {
|
|
4122
|
+
if (config) {
|
|
4123
|
+
if (config.resizable) {
|
|
4124
|
+
const ref = useRef();
|
|
4125
|
+
const arr = [/*#__PURE__*/React__default.createElement(FreeType, {
|
|
4126
|
+
tag: tag,
|
|
4127
|
+
config: config,
|
|
4128
|
+
me: me,
|
|
4129
|
+
className: className,
|
|
4130
|
+
ref: ref,
|
|
4131
|
+
key: 'frame'
|
|
4132
|
+
}), /*#__PURE__*/React__default.createElement(Slider$2, {
|
|
4133
|
+
contenerRef: ref,
|
|
4134
|
+
dir: dir,
|
|
4135
|
+
key: 'slider'
|
|
4136
|
+
})];
|
|
4137
|
+
po('right', dir);
|
|
4138
|
+
if (['right'].indexOf(dir) > -1 || ['bottom'].indexOf(dir) > -1) {
|
|
4139
|
+
return arr.reverse();
|
|
4140
|
+
} else {
|
|
4141
|
+
return arr;
|
|
4142
|
+
}
|
|
4143
|
+
} else {
|
|
4144
|
+
return /*#__PURE__*/React__default.createElement(FreeType, {
|
|
4145
|
+
tag: tag,
|
|
4146
|
+
config: config,
|
|
4147
|
+
me: me,
|
|
4148
|
+
className: className
|
|
4149
|
+
});
|
|
4150
|
+
}
|
|
4151
|
+
}
|
|
4152
|
+
}
|
|
4004
4153
|
class JRFrame extends JRSubmit {
|
|
4005
4154
|
rid = random(99999, 10000);
|
|
4006
4155
|
mask = this.props.mask ? () => {
|
|
@@ -4019,36 +4168,43 @@ class JRFrame extends JRSubmit {
|
|
|
4019
4168
|
id: this.props.id,
|
|
4020
4169
|
style: this.props.style,
|
|
4021
4170
|
className: `jr-frame ${this.props.popup !== true ? this.props.className : ''}`
|
|
4022
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
4171
|
+
}, /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
|
|
4023
4172
|
tag: "div",
|
|
4024
4173
|
config: this.props.start,
|
|
4025
4174
|
me: this,
|
|
4026
|
-
className: 'start'
|
|
4027
|
-
|
|
4175
|
+
className: 'start',
|
|
4176
|
+
dir: 'left'
|
|
4177
|
+
}), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
|
|
4028
4178
|
tag: "header",
|
|
4029
4179
|
config: this.props.top,
|
|
4030
|
-
me: this
|
|
4031
|
-
|
|
4180
|
+
me: this,
|
|
4181
|
+
className: 'header',
|
|
4182
|
+
dir: 'top'
|
|
4183
|
+
}), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
|
|
4032
4184
|
tag: "div",
|
|
4033
4185
|
config: this.props.left,
|
|
4034
4186
|
me: this,
|
|
4035
|
-
className: 'left'
|
|
4187
|
+
className: 'left',
|
|
4188
|
+
dir: 'left'
|
|
4036
4189
|
}), /*#__PURE__*/React__default.createElement("main", {
|
|
4037
4190
|
className: 'body'
|
|
4038
|
-
}, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default.createElement(
|
|
4191
|
+
}, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
|
|
4039
4192
|
tag: "div",
|
|
4040
4193
|
config: this.props.right,
|
|
4041
4194
|
me: this,
|
|
4042
|
-
className: 'right'
|
|
4043
|
-
|
|
4195
|
+
className: 'right',
|
|
4196
|
+
dir: 'right'
|
|
4197
|
+
})), /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
|
|
4044
4198
|
tag: "footer",
|
|
4045
4199
|
config: this.props.bottom,
|
|
4046
|
-
me: this
|
|
4047
|
-
|
|
4200
|
+
me: this,
|
|
4201
|
+
dir: 'bottom'
|
|
4202
|
+
})), /*#__PURE__*/React__default.createElement(FreeTypeWithSlider, {
|
|
4048
4203
|
tag: "div",
|
|
4049
4204
|
config: this.props.end,
|
|
4050
4205
|
me: this,
|
|
4051
|
-
className: 'end'
|
|
4206
|
+
className: 'end',
|
|
4207
|
+
dir: 'right'
|
|
4052
4208
|
}), this.mask?.());
|
|
4053
4209
|
}
|
|
4054
4210
|
}
|
|
@@ -4219,7 +4375,7 @@ class TitleBar extends React__default.Component {
|
|
|
4219
4375
|
width,
|
|
4220
4376
|
height
|
|
4221
4377
|
} = this.props.windowRef.current.getBoundingClientRect();
|
|
4222
|
-
if (y < 1 - this.props.thick) this.fullScreen(e);
|
|
4378
|
+
if (y < 1 - this.props.thick && this.props.resizable != false) this.fullScreen(e);
|
|
4223
4379
|
if (y > window.innerHeight - titleBarHeight) this.props.windowRef.current.style.top = `${window.innerHeight - titleBarHeight}px`;
|
|
4224
4380
|
if (x + width - this.props.thick < 0) this.props.windowRef.current.style.left = 0;
|
|
4225
4381
|
if (x > window.innerWidth) this.props.windowRef.current.style.left = `${window.innerWidth - width}px`;
|
|
@@ -4303,7 +4459,7 @@ class TitleBar extends React__default.Component {
|
|
|
4303
4459
|
onMouseDown: e => {
|
|
4304
4460
|
this.start(e);
|
|
4305
4461
|
},
|
|
4306
|
-
onDoubleClick: this.adjustScreen
|
|
4462
|
+
onDoubleClick: this.props.resizable != false ? this.adjustScreen : null
|
|
4307
4463
|
}, /*#__PURE__*/React__default.createElement(FreeType, {
|
|
4308
4464
|
tag: "div",
|
|
4309
4465
|
config: this.props.title ?? '',
|
|
@@ -4771,7 +4927,7 @@ z-index:1;
|
|
|
4771
4927
|
}) => $x}px;
|
|
4772
4928
|
width: ${({
|
|
4773
4929
|
$width = 300
|
|
4774
|
-
}) => `${$width}px`};
|
|
4930
|
+
}) => typeof $width === 'string' ? '50%' : `${$width}px`};
|
|
4775
4931
|
height: ${({
|
|
4776
4932
|
$height = 300
|
|
4777
4933
|
}) => `${$height}px`};
|
|
@@ -4860,18 +5016,22 @@ class JRWindow extends JRFrame {
|
|
|
4860
5016
|
}
|
|
4861
5017
|
}
|
|
4862
5018
|
init() {
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
5019
|
+
po('window', window.innerWidth);
|
|
5020
|
+
if (this.props.width?.indexOf?.('%') > -1) {
|
|
5021
|
+
this.width = this.props.width.split('%')[0] * window.innerWidth / 100;
|
|
5022
|
+
} else {
|
|
5023
|
+
this.width = window.innerWidth >= (this.props.width ?? this.width) ? this.props.width ?? this.width : window.innerWidth;
|
|
5024
|
+
}
|
|
5025
|
+
this.x = this.props.x ?? (window.innerWidth - this.width) / 2;
|
|
5026
|
+
if (this.props.height?.indexOf?.('%') > -1) {
|
|
5027
|
+
this.height = this.props.height.split('%')[0] * window.innerHeight / 100;
|
|
5028
|
+
} else {
|
|
5029
|
+
this.height = window.innerHeight >= (this.props.height ?? this.height) ? this.props.height ?? this.height : window.innerHeight;
|
|
5030
|
+
}
|
|
5031
|
+
this.y = this.props.y ?? (window.innerHeight - this.height) / 2;
|
|
4867
5032
|
}
|
|
4868
5033
|
renderer() {
|
|
4869
|
-
return this.props.popup === true ? this.props.open ? /*#__PURE__*/React__default.createElement(StyledJRWindow
|
|
4870
|
-
|
|
4871
|
-
// role="dialog"
|
|
4872
|
-
// aria-labelledby="dialog1Title"
|
|
4873
|
-
// aria-describedby="dialog1Desc"
|
|
4874
|
-
, {
|
|
5034
|
+
return this.props.popup === true ? this.props.open ? /*#__PURE__*/React__default.createElement(StyledJRWindow, {
|
|
4875
5035
|
rule: 'dialog',
|
|
4876
5036
|
ref: this.ref,
|
|
4877
5037
|
className: `jr-window ${this.props.className ?? ''}`,
|
|
@@ -4885,8 +5045,9 @@ class JRWindow extends JRFrame {
|
|
|
4885
5045
|
windowRef: this.ref,
|
|
4886
5046
|
window: this,
|
|
4887
5047
|
title: this.props.title,
|
|
4888
|
-
thick: this.thick
|
|
4889
|
-
|
|
5048
|
+
thick: this.thick,
|
|
5049
|
+
resizable: this.props.resizable
|
|
5050
|
+
}), /*#__PURE__*/React__default.createElement("main", null, super.renderer())), this.props.resizable !== false && /*#__PURE__*/React__default.createElement(Sliders, {
|
|
4890
5051
|
thick: this.thick,
|
|
4891
5052
|
windowRef: this.ref,
|
|
4892
5053
|
window: this,
|
|
@@ -4916,6 +5077,7 @@ class Slider extends React__default.Component {
|
|
|
4916
5077
|
this.sliderRef = /*#__PURE__*/React__default.createRef();
|
|
4917
5078
|
}
|
|
4918
5079
|
stop = e => {
|
|
5080
|
+
po('stop', this);
|
|
4919
5081
|
this.sliderRef.current.classList.remove('resizing');
|
|
4920
5082
|
document.body.style.cursor = 'default';
|
|
4921
5083
|
window.removeEventListener('mousemove', this.move);
|
|
@@ -4924,6 +5086,7 @@ class Slider extends React__default.Component {
|
|
|
4924
5086
|
move = ({
|
|
4925
5087
|
clientX
|
|
4926
5088
|
}) => {
|
|
5089
|
+
po('move');
|
|
4927
5090
|
const {
|
|
4928
5091
|
th,
|
|
4929
5092
|
selectedCols,
|
|
@@ -4941,6 +5104,7 @@ class Slider extends React__default.Component {
|
|
|
4941
5104
|
});
|
|
4942
5105
|
};
|
|
4943
5106
|
start(thPRef, column) {
|
|
5107
|
+
po('start', this.start);
|
|
4944
5108
|
const selectedCols = [...this.props.table.colGroupRef.current.children].slice(column.columnNo, column.columnNo + (column.colSpan ?? 1));
|
|
4945
5109
|
const totalWidth = selectedCols.reduce((aco, {
|
|
4946
5110
|
offsetWidth
|
|
@@ -5903,8 +6067,8 @@ class JRFields extends JRWindow {
|
|
|
5903
6067
|
content = /*#__PURE__*/React__default.createElement(StyledColumnValue, {
|
|
5904
6068
|
className: 'jr-column-value',
|
|
5905
6069
|
style: {
|
|
5906
|
-
gridColumn: label == null ? 'span 2' : null
|
|
5907
|
-
padding:
|
|
6070
|
+
gridColumn: label == null ? 'span 2' : null
|
|
6071
|
+
// ,padding:column.render?'4px 0':null
|
|
5908
6072
|
}
|
|
5909
6073
|
}, column.render ? column.render.bind(this)({
|
|
5910
6074
|
onChange,
|
|
@@ -6297,7 +6461,7 @@ function JRAlertWindow({
|
|
|
6297
6461
|
},
|
|
6298
6462
|
width: 440,
|
|
6299
6463
|
height: 180,
|
|
6300
|
-
maskOn: '
|
|
6464
|
+
maskOn: 'root'
|
|
6301
6465
|
}, props, {
|
|
6302
6466
|
open: open,
|
|
6303
6467
|
setOpen: setOpen,
|
|
@@ -6402,13 +6566,14 @@ class JRSelect extends JROptions {
|
|
|
6402
6566
|
multiple,
|
|
6403
6567
|
size
|
|
6404
6568
|
} = this.props;
|
|
6569
|
+
const value = this.getValue() ?? (multiple ? [] : '');
|
|
6405
6570
|
const options = [...(this.getOptions() ?? [])];
|
|
6406
|
-
if (multiple
|
|
6407
|
-
[valueName]:
|
|
6571
|
+
if (!multiple && (showBlank != false || value == '')) options.unshift({
|
|
6572
|
+
[valueName]: null,
|
|
6408
6573
|
[labelName]: ''
|
|
6409
6574
|
});
|
|
6410
6575
|
return /*#__PURE__*/React__default.createElement(StyledSelect, {
|
|
6411
|
-
value:
|
|
6576
|
+
value: value,
|
|
6412
6577
|
className: 'jr-select',
|
|
6413
6578
|
onChange: e => {
|
|
6414
6579
|
if (multiple) {
|
|
@@ -6416,7 +6581,7 @@ class JRSelect extends JROptions {
|
|
|
6416
6581
|
this.setValue(selectedIndex.length ? selectedIndex.map(index => options[index][valueName]) : null);
|
|
6417
6582
|
} else {
|
|
6418
6583
|
const selectedIndex = e.target.selectedOptions[0].index;
|
|
6419
|
-
this.setValue(selectedIndex ? options[selectedIndex][valueName] : null);
|
|
6584
|
+
this.setValue(selectedIndex > -1 ? options[selectedIndex][valueName] : null);
|
|
6420
6585
|
}
|
|
6421
6586
|
},
|
|
6422
6587
|
size: size,
|
|
@@ -6426,7 +6591,7 @@ class JRSelect extends JROptions {
|
|
|
6426
6591
|
value: record[valueName],
|
|
6427
6592
|
key: key
|
|
6428
6593
|
};
|
|
6429
|
-
if (multiple &&
|
|
6594
|
+
if (multiple && value?.indexOf(record[valueName]) > -1 || value == record[valueName]) {
|
|
6430
6595
|
props.className = 'selected';
|
|
6431
6596
|
}
|
|
6432
6597
|
return /*#__PURE__*/React__default.createElement(StyledOption, props, record[labelName]);
|
package/build/index.js
CHANGED
|
@@ -3966,30 +3966,141 @@ class JRSubmit extends React__default["default"].Component {
|
|
|
3966
3966
|
}
|
|
3967
3967
|
}
|
|
3968
3968
|
|
|
3969
|
-
const
|
|
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'){
|
|
4096
|
+
// return <Tag className={className} ref={ref}>{config}</Tag>
|
|
4097
|
+
} else {
|
|
3988
4098
|
return /*#__PURE__*/React__default["default"].createElement(Tag, {
|
|
3989
|
-
className: className
|
|
4099
|
+
className: className,
|
|
4100
|
+
ref: ref
|
|
3990
4101
|
}, config);
|
|
3991
4102
|
}
|
|
3992
|
-
};
|
|
4103
|
+
});
|
|
3993
4104
|
const StyledJRFrame = styled__default["default"].div`
|
|
3994
4105
|
color:#525252;
|
|
3995
4106
|
background:white;
|
|
@@ -4028,6 +4139,44 @@ const StyledJRFrame = styled__default["default"].div`
|
|
|
4028
4139
|
|
|
4029
4140
|
}
|
|
4030
4141
|
`;
|
|
4142
|
+
function FreeTypeWithSlider({
|
|
4143
|
+
tag,
|
|
4144
|
+
config,
|
|
4145
|
+
me,
|
|
4146
|
+
className,
|
|
4147
|
+
dir
|
|
4148
|
+
}) {
|
|
4149
|
+
if (config) {
|
|
4150
|
+
if (config.resizable) {
|
|
4151
|
+
const ref = React.useRef();
|
|
4152
|
+
const arr = [/*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
4153
|
+
tag: tag,
|
|
4154
|
+
config: config,
|
|
4155
|
+
me: me,
|
|
4156
|
+
className: className,
|
|
4157
|
+
ref: ref,
|
|
4158
|
+
key: 'frame'
|
|
4159
|
+
}), /*#__PURE__*/React__default["default"].createElement(Slider$2, {
|
|
4160
|
+
contenerRef: ref,
|
|
4161
|
+
dir: dir,
|
|
4162
|
+
key: 'slider'
|
|
4163
|
+
})];
|
|
4164
|
+
po('right', dir);
|
|
4165
|
+
if (['right'].indexOf(dir) > -1 || ['bottom'].indexOf(dir) > -1) {
|
|
4166
|
+
return arr.reverse();
|
|
4167
|
+
} else {
|
|
4168
|
+
return arr;
|
|
4169
|
+
}
|
|
4170
|
+
} else {
|
|
4171
|
+
return /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
4172
|
+
tag: tag,
|
|
4173
|
+
config: config,
|
|
4174
|
+
me: me,
|
|
4175
|
+
className: className
|
|
4176
|
+
});
|
|
4177
|
+
}
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4031
4180
|
class JRFrame extends JRSubmit {
|
|
4032
4181
|
rid = random(99999, 10000);
|
|
4033
4182
|
mask = this.props.mask ? () => {
|
|
@@ -4046,36 +4195,43 @@ class JRFrame extends JRSubmit {
|
|
|
4046
4195
|
id: this.props.id,
|
|
4047
4196
|
style: this.props.style,
|
|
4048
4197
|
className: `jr-frame ${this.props.popup !== true ? this.props.className : ''}`
|
|
4049
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
4198
|
+
}, /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
|
|
4050
4199
|
tag: "div",
|
|
4051
4200
|
config: this.props.start,
|
|
4052
4201
|
me: this,
|
|
4053
|
-
className: 'start'
|
|
4054
|
-
|
|
4202
|
+
className: 'start',
|
|
4203
|
+
dir: 'left'
|
|
4204
|
+
}), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
|
|
4055
4205
|
tag: "header",
|
|
4056
4206
|
config: this.props.top,
|
|
4057
|
-
me: this
|
|
4058
|
-
|
|
4207
|
+
me: this,
|
|
4208
|
+
className: 'header',
|
|
4209
|
+
dir: 'top'
|
|
4210
|
+
}), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
|
|
4059
4211
|
tag: "div",
|
|
4060
4212
|
config: this.props.left,
|
|
4061
4213
|
me: this,
|
|
4062
|
-
className: 'left'
|
|
4214
|
+
className: 'left',
|
|
4215
|
+
dir: 'left'
|
|
4063
4216
|
}), /*#__PURE__*/React__default["default"].createElement("main", {
|
|
4064
4217
|
className: 'body'
|
|
4065
|
-
}, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default["default"].createElement(
|
|
4218
|
+
}, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
|
|
4066
4219
|
tag: "div",
|
|
4067
4220
|
config: this.props.right,
|
|
4068
4221
|
me: this,
|
|
4069
|
-
className: 'right'
|
|
4070
|
-
|
|
4222
|
+
className: 'right',
|
|
4223
|
+
dir: 'right'
|
|
4224
|
+
})), /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
|
|
4071
4225
|
tag: "footer",
|
|
4072
4226
|
config: this.props.bottom,
|
|
4073
|
-
me: this
|
|
4074
|
-
|
|
4227
|
+
me: this,
|
|
4228
|
+
dir: 'bottom'
|
|
4229
|
+
})), /*#__PURE__*/React__default["default"].createElement(FreeTypeWithSlider, {
|
|
4075
4230
|
tag: "div",
|
|
4076
4231
|
config: this.props.end,
|
|
4077
4232
|
me: this,
|
|
4078
|
-
className: 'end'
|
|
4233
|
+
className: 'end',
|
|
4234
|
+
dir: 'right'
|
|
4079
4235
|
}), this.mask?.());
|
|
4080
4236
|
}
|
|
4081
4237
|
}
|
|
@@ -4246,7 +4402,7 @@ class TitleBar extends React__default["default"].Component {
|
|
|
4246
4402
|
width,
|
|
4247
4403
|
height
|
|
4248
4404
|
} = this.props.windowRef.current.getBoundingClientRect();
|
|
4249
|
-
if (y < 1 - this.props.thick) this.fullScreen(e);
|
|
4405
|
+
if (y < 1 - this.props.thick && this.props.resizable != false) this.fullScreen(e);
|
|
4250
4406
|
if (y > window.innerHeight - titleBarHeight) this.props.windowRef.current.style.top = `${window.innerHeight - titleBarHeight}px`;
|
|
4251
4407
|
if (x + width - this.props.thick < 0) this.props.windowRef.current.style.left = 0;
|
|
4252
4408
|
if (x > window.innerWidth) this.props.windowRef.current.style.left = `${window.innerWidth - width}px`;
|
|
@@ -4330,7 +4486,7 @@ class TitleBar extends React__default["default"].Component {
|
|
|
4330
4486
|
onMouseDown: e => {
|
|
4331
4487
|
this.start(e);
|
|
4332
4488
|
},
|
|
4333
|
-
onDoubleClick: this.adjustScreen
|
|
4489
|
+
onDoubleClick: this.props.resizable != false ? this.adjustScreen : null
|
|
4334
4490
|
}, /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
4335
4491
|
tag: "div",
|
|
4336
4492
|
config: this.props.title ?? '',
|
|
@@ -4798,7 +4954,7 @@ z-index:1;
|
|
|
4798
4954
|
}) => $x}px;
|
|
4799
4955
|
width: ${({
|
|
4800
4956
|
$width = 300
|
|
4801
|
-
}) => `${$width}px`};
|
|
4957
|
+
}) => typeof $width === 'string' ? '50%' : `${$width}px`};
|
|
4802
4958
|
height: ${({
|
|
4803
4959
|
$height = 300
|
|
4804
4960
|
}) => `${$height}px`};
|
|
@@ -4887,18 +5043,22 @@ class JRWindow extends JRFrame {
|
|
|
4887
5043
|
}
|
|
4888
5044
|
}
|
|
4889
5045
|
init() {
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
5046
|
+
po('window', window.innerWidth);
|
|
5047
|
+
if (this.props.width?.indexOf?.('%') > -1) {
|
|
5048
|
+
this.width = this.props.width.split('%')[0] * window.innerWidth / 100;
|
|
5049
|
+
} else {
|
|
5050
|
+
this.width = window.innerWidth >= (this.props.width ?? this.width) ? this.props.width ?? this.width : window.innerWidth;
|
|
5051
|
+
}
|
|
5052
|
+
this.x = this.props.x ?? (window.innerWidth - this.width) / 2;
|
|
5053
|
+
if (this.props.height?.indexOf?.('%') > -1) {
|
|
5054
|
+
this.height = this.props.height.split('%')[0] * window.innerHeight / 100;
|
|
5055
|
+
} else {
|
|
5056
|
+
this.height = window.innerHeight >= (this.props.height ?? this.height) ? this.props.height ?? this.height : window.innerHeight;
|
|
5057
|
+
}
|
|
5058
|
+
this.y = this.props.y ?? (window.innerHeight - this.height) / 2;
|
|
4894
5059
|
}
|
|
4895
5060
|
renderer() {
|
|
4896
|
-
return this.props.popup === true ? this.props.open ? /*#__PURE__*/React__default["default"].createElement(StyledJRWindow
|
|
4897
|
-
|
|
4898
|
-
// role="dialog"
|
|
4899
|
-
// aria-labelledby="dialog1Title"
|
|
4900
|
-
// aria-describedby="dialog1Desc"
|
|
4901
|
-
, {
|
|
5061
|
+
return this.props.popup === true ? this.props.open ? /*#__PURE__*/React__default["default"].createElement(StyledJRWindow, {
|
|
4902
5062
|
rule: 'dialog',
|
|
4903
5063
|
ref: this.ref,
|
|
4904
5064
|
className: `jr-window ${this.props.className ?? ''}`,
|
|
@@ -4912,8 +5072,9 @@ class JRWindow extends JRFrame {
|
|
|
4912
5072
|
windowRef: this.ref,
|
|
4913
5073
|
window: this,
|
|
4914
5074
|
title: this.props.title,
|
|
4915
|
-
thick: this.thick
|
|
4916
|
-
|
|
5075
|
+
thick: this.thick,
|
|
5076
|
+
resizable: this.props.resizable
|
|
5077
|
+
}), /*#__PURE__*/React__default["default"].createElement("main", null, super.renderer())), this.props.resizable !== false && /*#__PURE__*/React__default["default"].createElement(Sliders, {
|
|
4917
5078
|
thick: this.thick,
|
|
4918
5079
|
windowRef: this.ref,
|
|
4919
5080
|
window: this,
|
|
@@ -4943,6 +5104,7 @@ class Slider extends React__default["default"].Component {
|
|
|
4943
5104
|
this.sliderRef = /*#__PURE__*/React__default["default"].createRef();
|
|
4944
5105
|
}
|
|
4945
5106
|
stop = e => {
|
|
5107
|
+
po('stop', this);
|
|
4946
5108
|
this.sliderRef.current.classList.remove('resizing');
|
|
4947
5109
|
document.body.style.cursor = 'default';
|
|
4948
5110
|
window.removeEventListener('mousemove', this.move);
|
|
@@ -4951,6 +5113,7 @@ class Slider extends React__default["default"].Component {
|
|
|
4951
5113
|
move = ({
|
|
4952
5114
|
clientX
|
|
4953
5115
|
}) => {
|
|
5116
|
+
po('move');
|
|
4954
5117
|
const {
|
|
4955
5118
|
th,
|
|
4956
5119
|
selectedCols,
|
|
@@ -4968,6 +5131,7 @@ class Slider extends React__default["default"].Component {
|
|
|
4968
5131
|
});
|
|
4969
5132
|
};
|
|
4970
5133
|
start(thPRef, column) {
|
|
5134
|
+
po('start', this.start);
|
|
4971
5135
|
const selectedCols = [...this.props.table.colGroupRef.current.children].slice(column.columnNo, column.columnNo + (column.colSpan ?? 1));
|
|
4972
5136
|
const totalWidth = selectedCols.reduce((aco, {
|
|
4973
5137
|
offsetWidth
|
|
@@ -5930,8 +6094,8 @@ class JRFields extends JRWindow {
|
|
|
5930
6094
|
content = /*#__PURE__*/React__default["default"].createElement(StyledColumnValue, {
|
|
5931
6095
|
className: 'jr-column-value',
|
|
5932
6096
|
style: {
|
|
5933
|
-
gridColumn: label == null ? 'span 2' : null
|
|
5934
|
-
padding:
|
|
6097
|
+
gridColumn: label == null ? 'span 2' : null
|
|
6098
|
+
// ,padding:column.render?'4px 0':null
|
|
5935
6099
|
}
|
|
5936
6100
|
}, column.render ? column.render.bind(this)({
|
|
5937
6101
|
onChange,
|
|
@@ -6324,7 +6488,7 @@ function JRAlertWindow({
|
|
|
6324
6488
|
},
|
|
6325
6489
|
width: 440,
|
|
6326
6490
|
height: 180,
|
|
6327
|
-
maskOn: '
|
|
6491
|
+
maskOn: 'root'
|
|
6328
6492
|
}, props, {
|
|
6329
6493
|
open: open,
|
|
6330
6494
|
setOpen: setOpen,
|
|
@@ -6429,13 +6593,14 @@ class JRSelect extends JROptions {
|
|
|
6429
6593
|
multiple,
|
|
6430
6594
|
size
|
|
6431
6595
|
} = this.props;
|
|
6596
|
+
const value = this.getValue() ?? (multiple ? [] : '');
|
|
6432
6597
|
const options = [...(this.getOptions() ?? [])];
|
|
6433
|
-
if (multiple
|
|
6434
|
-
[valueName]:
|
|
6598
|
+
if (!multiple && (showBlank != false || value == '')) options.unshift({
|
|
6599
|
+
[valueName]: null,
|
|
6435
6600
|
[labelName]: ''
|
|
6436
6601
|
});
|
|
6437
6602
|
return /*#__PURE__*/React__default["default"].createElement(StyledSelect, {
|
|
6438
|
-
value:
|
|
6603
|
+
value: value,
|
|
6439
6604
|
className: 'jr-select',
|
|
6440
6605
|
onChange: e => {
|
|
6441
6606
|
if (multiple) {
|
|
@@ -6443,7 +6608,7 @@ class JRSelect extends JROptions {
|
|
|
6443
6608
|
this.setValue(selectedIndex.length ? selectedIndex.map(index => options[index][valueName]) : null);
|
|
6444
6609
|
} else {
|
|
6445
6610
|
const selectedIndex = e.target.selectedOptions[0].index;
|
|
6446
|
-
this.setValue(selectedIndex ? options[selectedIndex][valueName] : null);
|
|
6611
|
+
this.setValue(selectedIndex > -1 ? options[selectedIndex][valueName] : null);
|
|
6447
6612
|
}
|
|
6448
6613
|
},
|
|
6449
6614
|
size: size,
|
|
@@ -6453,7 +6618,7 @@ class JRSelect extends JROptions {
|
|
|
6453
6618
|
value: record[valueName],
|
|
6454
6619
|
key: key
|
|
6455
6620
|
};
|
|
6456
|
-
if (multiple &&
|
|
6621
|
+
if (multiple && value?.indexOf(record[valueName]) > -1 || value == record[valueName]) {
|
|
6457
6622
|
props.className = 'selected';
|
|
6458
6623
|
}
|
|
6459
6624
|
return /*#__PURE__*/React__default["default"].createElement(StyledOption, props, record[labelName]);
|
package/package.json
CHANGED
|
@@ -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,28 @@
|
|
|
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
|
-
}else if(
|
|
15
|
-
|
|
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>
|
|
18
|
+
// }else if(typeof config==='string'){
|
|
19
|
+
// return <Tag className={className} ref={ref}>{config}</Tag>
|
|
20
|
+
}else{
|
|
21
|
+
return <Tag className={className} ref={ref}>{config}</Tag>
|
|
16
22
|
}
|
|
23
|
+
})
|
|
24
|
+
|
|
17
25
|
|
|
18
|
-
}
|
|
19
26
|
|
|
20
27
|
const StyledJRFrame=styled.div`
|
|
21
28
|
color:#525252;
|
|
@@ -55,6 +62,27 @@ const StyledJRFrame=styled.div`
|
|
|
55
62
|
|
|
56
63
|
}
|
|
57
64
|
`
|
|
65
|
+
|
|
66
|
+
function FreeTypeWithSlider({tag,config,me,className,dir}){
|
|
67
|
+
if(config){
|
|
68
|
+
if(config.resizable){
|
|
69
|
+
const ref=useRef()
|
|
70
|
+
const arr=[
|
|
71
|
+
<FreeType tag={tag} config={config} me={me} className={className} ref={ref} key={'frame'}/>
|
|
72
|
+
,<Slider contenerRef={ref} dir={dir} key={'slider'}/>
|
|
73
|
+
]
|
|
74
|
+
po('right',dir)
|
|
75
|
+
if(['right'].indexOf(dir)>-1 || ['bottom'].indexOf(dir)>-1 ){
|
|
76
|
+
return arr.reverse()
|
|
77
|
+
}else{
|
|
78
|
+
return arr
|
|
79
|
+
}
|
|
80
|
+
}else{
|
|
81
|
+
|
|
82
|
+
return <FreeType tag={tag} config={config} me={me} className={className}/>
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
58
86
|
export default class JRFrame extends JRSubmit {
|
|
59
87
|
rid=random(99999,10000)
|
|
60
88
|
mask=this.props.mask
|
|
@@ -74,19 +102,19 @@ export default class JRFrame extends JRSubmit {
|
|
|
74
102
|
return <StyledJRFrame id={this.props.id} style={this.props.style}
|
|
75
103
|
className={`jr-frame ${(this.props.popup!==true )? this.props.className:''}`}
|
|
76
104
|
>
|
|
77
|
-
<
|
|
105
|
+
<FreeTypeWithSlider tag='div' config={this.props.start} me={this} className={'start'} dir={'left'}/>
|
|
78
106
|
<main>
|
|
79
|
-
<
|
|
107
|
+
<FreeTypeWithSlider tag='header' config={this.props.top} me={this} className={'header'} dir={'top'}/>
|
|
80
108
|
<main>
|
|
81
|
-
<
|
|
109
|
+
<FreeTypeWithSlider tag='div' config={this.props.left} me={this} className={'left'} dir={'left'}/>
|
|
82
110
|
<main className={'body'}>
|
|
83
111
|
{this.renderMe?.() ?? this.props.children}
|
|
84
112
|
</main>
|
|
85
|
-
<
|
|
113
|
+
<FreeTypeWithSlider tag='div' config={this.props.right} me={this} className={'right'} dir={'right'}/>
|
|
86
114
|
</main>
|
|
87
|
-
<
|
|
115
|
+
<FreeTypeWithSlider tag='footer' config={this.props.bottom} me={this} dir={'bottom'}/>
|
|
88
116
|
</main>
|
|
89
|
-
<
|
|
117
|
+
<FreeTypeWithSlider tag='div' config={this.props.end} me={this} className={'end'} dir={'right'}/>
|
|
90
118
|
{this.mask?.()}
|
|
91
119
|
</StyledJRFrame>
|
|
92
120
|
}
|
|
@@ -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
|
|
27
|
+
if(!multiple && (showBlank!=false || value==''))options.unshift({[valueName]:null,[labelName]:''})
|
|
28
|
+
|
|
27
29
|
return <StyledSelect
|
|
28
|
-
value={
|
|
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 &&
|
|
53
|
-
||
|
|
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
|
|
|
@@ -21,7 +21,7 @@ z-index:1;
|
|
|
21
21
|
|
|
22
22
|
top: ${({$y})=>$y}px;
|
|
23
23
|
left: ${({$x})=>$x}px;
|
|
24
|
-
width: ${({$width=300})
|
|
24
|
+
width: ${({$width=300})=>typeof $width === 'string'? '50%' : `${$width}px`};
|
|
25
25
|
height: ${({$height=300})=>`${$height}px`};
|
|
26
26
|
overflow: hidden;
|
|
27
27
|
|
|
@@ -120,21 +120,26 @@ export default class JRWindow extends JRFrame {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
init(){
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
po('window',window.innerWidth)
|
|
124
|
+
if(this.props.width?.indexOf?.('%')>-1){
|
|
125
|
+
this.width=(this.props.width.split('%')[0]*window.innerWidth)/100
|
|
126
|
+
}else{
|
|
127
|
+
this.width=window.innerWidth>=(this.props.width??this.width)?(this.props.width??this.width):window.innerWidth
|
|
128
|
+
}
|
|
129
|
+
this.x=this.props.x??((window.innerWidth-(this.width))/2)
|
|
130
|
+
|
|
131
|
+
if(this.props.height?.indexOf?.('%')>-1){
|
|
132
|
+
this.height=(this.props.height.split('%')[0]*window.innerHeight)/100
|
|
133
|
+
}else{
|
|
134
|
+
this.height=window.innerHeight>=(this.props.height??this.height)?(this.props.height??this.height):window.innerHeight
|
|
135
|
+
}
|
|
136
|
+
this.y=this.props.y??(window.innerHeight-(this.height))/2
|
|
127
137
|
}
|
|
128
138
|
|
|
129
139
|
renderer(){
|
|
130
140
|
return this.props.popup===true
|
|
131
141
|
?this.props.open
|
|
132
142
|
?<StyledJRWindow
|
|
133
|
-
|
|
134
|
-
// role="dialog"
|
|
135
|
-
// aria-labelledby="dialog1Title"
|
|
136
|
-
// aria-describedby="dialog1Desc"
|
|
137
|
-
|
|
138
143
|
rule={'dialog'}
|
|
139
144
|
ref={this.ref}
|
|
140
145
|
className={`jr-window ${this.props.className??''}`}
|
|
@@ -151,17 +156,20 @@ export default class JRWindow extends JRFrame {
|
|
|
151
156
|
window={this}
|
|
152
157
|
title={this.props.title}
|
|
153
158
|
thick={this.thick}
|
|
159
|
+
resizable={this.props.resizable}
|
|
154
160
|
/>
|
|
155
161
|
<main>
|
|
156
162
|
{super.renderer()}
|
|
157
163
|
</main>
|
|
158
164
|
</main>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
{this.props.resizable !== false
|
|
166
|
+
&& <Sliders
|
|
167
|
+
thick={this.thick}
|
|
168
|
+
windowRef={this.ref}
|
|
169
|
+
window={this}
|
|
170
|
+
titleBarRef={this.titleBarRef}
|
|
171
|
+
/>
|
|
172
|
+
}
|
|
165
173
|
</StyledJRWindow>
|
|
166
174
|
:''
|
|
167
175
|
:super.renderer()
|
|
@@ -2,10 +2,8 @@ import styled from "styled-components";
|
|
|
2
2
|
import { po } from "../JRUtils";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { FreeType } from "../JRFrame/JRFrame";
|
|
5
|
-
import { IconX
|
|
6
|
-
import { background } from "storybook/internal/theming";
|
|
5
|
+
import { IconX} from "../../assets/icon";
|
|
7
6
|
import JRButton from "../JRInput/JRButton";
|
|
8
|
-
import { browser } from "globals";
|
|
9
7
|
|
|
10
8
|
const StyledTitle=styled.div`
|
|
11
9
|
overflow: hidden;
|
|
@@ -137,7 +135,7 @@ export default class TitleBar extends React.Component{
|
|
|
137
135
|
const {height:titleBarHeight}=this.props.titleBarRef.current.getBoundingClientRect()
|
|
138
136
|
const {x,y,width,height}=this.props.windowRef.current.getBoundingClientRect()
|
|
139
137
|
|
|
140
|
-
if(y<1-this.props.thick)this.fullScreen(e)
|
|
138
|
+
if(y<1-this.props.thick && this.props.resizable!=false)this.fullScreen(e)
|
|
141
139
|
if(y>window.innerHeight-titleBarHeight)this.props.windowRef.current.style.top = `${window.innerHeight-titleBarHeight}px`
|
|
142
140
|
if(x+width-this.props.thick<0)this.props.windowRef.current.style.left = 0
|
|
143
141
|
if(x>window.innerWidth)this.props.windowRef.current.style.left = `${window.innerWidth-width}px`
|
|
@@ -221,7 +219,7 @@ export default class TitleBar extends React.Component{
|
|
|
221
219
|
onMouseDown={(e)=>{
|
|
222
220
|
this.start(e)
|
|
223
221
|
}}
|
|
224
|
-
onDoubleClick={this.adjustScreen}
|
|
222
|
+
onDoubleClick={this.props.resizable!=false?this.adjustScreen:null}
|
|
225
223
|
>
|
|
226
224
|
<FreeType tag='div' config={this.props.title??''} me={this.props.window} className={'title'}/>
|
|
227
225
|
<nav>
|