jrs-react 1.2.15 → 1.2.16
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 +164 -95
- package/build/index.js +165 -94
- package/package.json +1 -1
- package/public/data.json +10 -0
- package/public/list.json +24 -11
- package/src/app/App.jsx +3 -8
- package/src/app/fields/FieldsApp.jsx +6 -2
- package/src/app/fields/fieldsConfig.jsx +100 -3
- package/src/app/input/InputApp.jsx +43 -0
- package/src/components/JRInput/JRCheckbox.jsx +49 -0
- package/src/components/JRInput/JRRadio.jsx +43 -0
- package/src/components/JRInput/JRSelect.jsx +55 -10
- package/src/components/JROptions.jsx +24 -0
- package/src/components/JRSubmit.jsx +2 -0
- package/src/components/JRTest.jsx +4 -47
- package/src/index.js +4 -0
package/build/index.es.js
CHANGED
|
@@ -3517,6 +3517,8 @@ class JRSubmit extends React__default.Component {
|
|
|
3517
3517
|
const fullnamList = fullname.split('.');
|
|
3518
3518
|
return this.#getValueByName(fullnamList, this[this.from]?.value);
|
|
3519
3519
|
} else {
|
|
3520
|
+
// po('ssssssssssssssssssssssssssssssssssssssssss')
|
|
3521
|
+
// 忘記為甚麼這樣寫了 XDD
|
|
3520
3522
|
return flexType(this[this.from]?.value, this, null, null);
|
|
3521
3523
|
}
|
|
3522
3524
|
}
|
|
@@ -3672,7 +3674,7 @@ class JRSubmit extends React__default.Component {
|
|
|
3672
3674
|
}
|
|
3673
3675
|
}
|
|
3674
3676
|
|
|
3675
|
-
const FreeType
|
|
3677
|
+
const FreeType = ({
|
|
3676
3678
|
tag: Tag,
|
|
3677
3679
|
config,
|
|
3678
3680
|
me,
|
|
@@ -3696,7 +3698,7 @@ const FreeType$1 = ({
|
|
|
3696
3698
|
}, config);
|
|
3697
3699
|
}
|
|
3698
3700
|
};
|
|
3699
|
-
const StyledJRFrame
|
|
3701
|
+
const StyledJRFrame = styled.div`
|
|
3700
3702
|
display:flex;
|
|
3701
3703
|
flex:1;
|
|
3702
3704
|
overflow:hidden;
|
|
@@ -3739,36 +3741,36 @@ const StyledJRFrame$1 = styled.div`
|
|
|
3739
3741
|
`;
|
|
3740
3742
|
class JRFrame extends JRSubmit {
|
|
3741
3743
|
renderer() {
|
|
3742
|
-
return /*#__PURE__*/React__default.createElement(StyledJRFrame
|
|
3744
|
+
return /*#__PURE__*/React__default.createElement(StyledJRFrame, {
|
|
3743
3745
|
id: this.props.id,
|
|
3744
3746
|
style: this.props.style,
|
|
3745
3747
|
className: `${this.props.className} jr-frame`
|
|
3746
|
-
}, /*#__PURE__*/React__default.createElement(FreeType
|
|
3748
|
+
}, /*#__PURE__*/React__default.createElement(FreeType, {
|
|
3747
3749
|
tag: "div",
|
|
3748
3750
|
config: this.props.start,
|
|
3749
3751
|
me: this,
|
|
3750
3752
|
className: 'start'
|
|
3751
|
-
}), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeType
|
|
3753
|
+
}), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeType, {
|
|
3752
3754
|
tag: "header",
|
|
3753
3755
|
config: this.props.top,
|
|
3754
3756
|
me: this
|
|
3755
|
-
}), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeType
|
|
3757
|
+
}), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeType, {
|
|
3756
3758
|
tag: "div",
|
|
3757
3759
|
config: this.props.left,
|
|
3758
3760
|
me: this,
|
|
3759
3761
|
className: 'left'
|
|
3760
3762
|
}), /*#__PURE__*/React__default.createElement("main", {
|
|
3761
3763
|
className: 'body'
|
|
3762
|
-
}, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default.createElement(FreeType
|
|
3764
|
+
}, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default.createElement(FreeType, {
|
|
3763
3765
|
tag: "div",
|
|
3764
3766
|
config: this.props.right,
|
|
3765
3767
|
me: this,
|
|
3766
3768
|
className: 'right'
|
|
3767
|
-
})), /*#__PURE__*/React__default.createElement(FreeType
|
|
3769
|
+
})), /*#__PURE__*/React__default.createElement(FreeType, {
|
|
3768
3770
|
tag: "footer",
|
|
3769
3771
|
config: this.props.bottom,
|
|
3770
3772
|
me: this
|
|
3771
|
-
})), /*#__PURE__*/React__default.createElement(FreeType
|
|
3773
|
+
})), /*#__PURE__*/React__default.createElement(FreeType, {
|
|
3772
3774
|
tag: "div",
|
|
3773
3775
|
config: this.props.end,
|
|
3774
3776
|
me: this,
|
|
@@ -4043,7 +4045,7 @@ class TitleBar extends React__default.Component {
|
|
|
4043
4045
|
this.start(e);
|
|
4044
4046
|
},
|
|
4045
4047
|
onDoubleClick: this.adjustScreen
|
|
4046
|
-
}, /*#__PURE__*/React__default.createElement(FreeType
|
|
4048
|
+
}, /*#__PURE__*/React__default.createElement(FreeType, {
|
|
4047
4049
|
tag: "div",
|
|
4048
4050
|
config: this.props.title ?? '',
|
|
4049
4051
|
me: this.props.window,
|
|
@@ -6002,95 +6004,15 @@ class JRTable extends JRWindow {
|
|
|
6002
6004
|
// export const FTable=JRFrameHOC(JRTable)
|
|
6003
6005
|
// export const WTable=JRWindowHOC(JRTable)
|
|
6004
6006
|
|
|
6005
|
-
const
|
|
6006
|
-
|
|
6007
|
-
flex:1;
|
|
6008
|
-
overflow:hidden;
|
|
6009
|
-
|
|
6010
|
-
> *{
|
|
6011
|
-
Xborder:1px solid gray;
|
|
6012
|
-
}
|
|
6013
|
-
>main{
|
|
6014
|
-
display:flex;
|
|
6015
|
-
flex:1;
|
|
6016
|
-
overflow:overlay;
|
|
6017
|
-
flex-direction: column;
|
|
6018
|
-
> *{
|
|
6019
|
-
XXborder:1px solid gray;
|
|
6020
|
-
min-height:30px;
|
|
6021
|
-
}
|
|
6022
|
-
|
|
6023
|
-
>header{
|
|
6024
|
-
XXborder:1px solid red;
|
|
6025
|
-
XXoverflow: overlay;
|
|
6026
|
-
}
|
|
6027
|
-
>main{
|
|
6028
|
-
display:flex;
|
|
6029
|
-
flex:1;
|
|
6030
|
-
overflow:hidden;
|
|
6031
|
-
}
|
|
6032
|
-
>footer{
|
|
6033
|
-
XXborder:1px solid blue;
|
|
6034
|
-
overflow: overlay;
|
|
6035
|
-
}
|
|
6036
|
-
|
|
6037
|
-
}
|
|
6038
|
-
|
|
6007
|
+
const StyledJRTest = styled.div`
|
|
6008
|
+
|
|
6039
6009
|
`;
|
|
6040
|
-
const FreeType = ({
|
|
6041
|
-
tag: Tag,
|
|
6042
|
-
config,
|
|
6043
|
-
me,
|
|
6044
|
-
className
|
|
6045
|
-
}) => {
|
|
6046
|
-
if (typeof config === 'function') {
|
|
6047
|
-
let style;
|
|
6048
|
-
const setStyle = function (_style) {
|
|
6049
|
-
style = _style;
|
|
6050
|
-
};
|
|
6051
|
-
const content = config.bind(me)({
|
|
6052
|
-
setStyle
|
|
6053
|
-
});
|
|
6054
|
-
return /*#__PURE__*/React__default.createElement(Tag, {
|
|
6055
|
-
className: className,
|
|
6056
|
-
style: style
|
|
6057
|
-
}, content);
|
|
6058
|
-
}
|
|
6059
|
-
};
|
|
6060
6010
|
class JRTestReact extends JRSubmit {
|
|
6061
6011
|
renderer() {
|
|
6062
|
-
return /*#__PURE__*/React__default.createElement(
|
|
6012
|
+
return /*#__PURE__*/React__default.createElement(StyledJRTest, {
|
|
6063
6013
|
style: this.props.style,
|
|
6064
6014
|
className: `${this.props.className} jr-frame`
|
|
6065
|
-
}
|
|
6066
|
-
tag: "div",
|
|
6067
|
-
config: this.props.start,
|
|
6068
|
-
me: this,
|
|
6069
|
-
className: 'start'
|
|
6070
|
-
}), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeType, {
|
|
6071
|
-
tag: "header",
|
|
6072
|
-
config: this.props.top,
|
|
6073
|
-
me: this
|
|
6074
|
-
}), /*#__PURE__*/React__default.createElement("main", null, /*#__PURE__*/React__default.createElement(FreeType, {
|
|
6075
|
-
tag: "div",
|
|
6076
|
-
config: this.props.left,
|
|
6077
|
-
me: this,
|
|
6078
|
-
className: 'left'
|
|
6079
|
-
}), this.renderMe(), /*#__PURE__*/React__default.createElement(FreeType, {
|
|
6080
|
-
tag: "div",
|
|
6081
|
-
config: this.props.right,
|
|
6082
|
-
me: this,
|
|
6083
|
-
className: 'right'
|
|
6084
|
-
})), /*#__PURE__*/React__default.createElement(FreeType, {
|
|
6085
|
-
tag: "footer",
|
|
6086
|
-
config: this.props.bottom,
|
|
6087
|
-
me: this
|
|
6088
|
-
})), /*#__PURE__*/React__default.createElement(FreeType, {
|
|
6089
|
-
tag: "div",
|
|
6090
|
-
config: this.props.end,
|
|
6091
|
-
me: this,
|
|
6092
|
-
className: 'end'
|
|
6093
|
-
}));
|
|
6015
|
+
});
|
|
6094
6016
|
}
|
|
6095
6017
|
renderMe() {
|
|
6096
6018
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -6170,4 +6092,151 @@ function JRAlert(props) {
|
|
|
6170
6092
|
})));
|
|
6171
6093
|
}
|
|
6172
6094
|
|
|
6173
|
-
|
|
6095
|
+
const StyledInput = styled.div`
|
|
6096
|
+
display:flex;
|
|
6097
|
+
input:focus{
|
|
6098
|
+
outline: none;
|
|
6099
|
+
}
|
|
6100
|
+
`;
|
|
6101
|
+
class JRInput extends React__default.Component {
|
|
6102
|
+
setValue(value) {
|
|
6103
|
+
this.props?.onChange?.(value);
|
|
6104
|
+
}
|
|
6105
|
+
render() {
|
|
6106
|
+
return /*#__PURE__*/React__default.createElement(StyledInput, null, this.input());
|
|
6107
|
+
}
|
|
6108
|
+
}
|
|
6109
|
+
|
|
6110
|
+
class JROptions extends JRSubmit {
|
|
6111
|
+
get optionsFrom() {
|
|
6112
|
+
return this.props.options === undefined ? 'state' : 'props';
|
|
6113
|
+
}
|
|
6114
|
+
setOptions(options) {
|
|
6115
|
+
if (this.props.setOptions) {
|
|
6116
|
+
this.props.setOptions(options);
|
|
6117
|
+
} else {
|
|
6118
|
+
this.setState({
|
|
6119
|
+
options: options
|
|
6120
|
+
});
|
|
6121
|
+
}
|
|
6122
|
+
}
|
|
6123
|
+
getOptions() {
|
|
6124
|
+
return this[this.optionsFrom]?.options;
|
|
6125
|
+
}
|
|
6126
|
+
setRes(isSuccess, response, config) {
|
|
6127
|
+
if (isSuccess) {
|
|
6128
|
+
const options = config.formatValue?.bind(this)(response.data) ?? response.data;
|
|
6129
|
+
response.data = options;
|
|
6130
|
+
this.setOptions(options);
|
|
6131
|
+
}
|
|
6132
|
+
}
|
|
6133
|
+
}
|
|
6134
|
+
|
|
6135
|
+
const StyledOption = styled.option`
|
|
6136
|
+
`;
|
|
6137
|
+
const StyledSelect = styled.select`
|
|
6138
|
+
${({
|
|
6139
|
+
size,
|
|
6140
|
+
multiple
|
|
6141
|
+
}) => `${size == 1 || size == undefined && multiple != true ? 'height:30px;' : ''}`}
|
|
6142
|
+
width: 100%;
|
|
6143
|
+
|
|
6144
|
+
option{
|
|
6145
|
+
padding: 4px;
|
|
6146
|
+
height: 25px;
|
|
6147
|
+
display: flex;
|
|
6148
|
+
align-items: center;
|
|
6149
|
+
}
|
|
6150
|
+
`;
|
|
6151
|
+
class JRSelect extends JROptions {
|
|
6152
|
+
renderer() {
|
|
6153
|
+
const {
|
|
6154
|
+
showBlank,
|
|
6155
|
+
valueName = 'id',
|
|
6156
|
+
labelName = 'name',
|
|
6157
|
+
multiple,
|
|
6158
|
+
size
|
|
6159
|
+
} = this.props;
|
|
6160
|
+
const options = [...(this.getOptions() ?? [])];
|
|
6161
|
+
if (multiple != true && showBlank != false) options.unshift({
|
|
6162
|
+
[valueName]: '',
|
|
6163
|
+
[labelName]: ''
|
|
6164
|
+
});
|
|
6165
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(StyledSelect, {
|
|
6166
|
+
value: this.getValue() ?? (multiple ? [] : ''),
|
|
6167
|
+
className: 'jr-select',
|
|
6168
|
+
onChange: e => {
|
|
6169
|
+
if (multiple) {
|
|
6170
|
+
const selectedIndex = [...e.target.selectedOptions].map(option => option.index);
|
|
6171
|
+
this.setValue(selectedIndex.length ? selectedIndex.map(index => options[index][valueName]) : null);
|
|
6172
|
+
} else {
|
|
6173
|
+
const selectedIndex = e.target.selectedOptions[0].index;
|
|
6174
|
+
this.setValue(selectedIndex ? options[selectedIndex][valueName] : null);
|
|
6175
|
+
}
|
|
6176
|
+
},
|
|
6177
|
+
size: size,
|
|
6178
|
+
multiple: multiple
|
|
6179
|
+
}, options.map((record, key) => {
|
|
6180
|
+
const props = {
|
|
6181
|
+
value: record[valueName],
|
|
6182
|
+
key: key
|
|
6183
|
+
};
|
|
6184
|
+
if (multiple && this.getValue()?.indexOf(record[valueName]) > -1 || this.getValue() == record[valueName]) {
|
|
6185
|
+
props.className = 'selected';
|
|
6186
|
+
}
|
|
6187
|
+
return /*#__PURE__*/React__default.createElement(StyledOption, props, record[labelName]);
|
|
6188
|
+
})));
|
|
6189
|
+
}
|
|
6190
|
+
}
|
|
6191
|
+
|
|
6192
|
+
const StyledPick = styled.div`
|
|
6193
|
+
>label{
|
|
6194
|
+
white-space: nowrap;
|
|
6195
|
+
display: inline-flex;
|
|
6196
|
+
align-items: center;
|
|
6197
|
+
height: 30px;
|
|
6198
|
+
padding-right: 12px;
|
|
6199
|
+
}
|
|
6200
|
+
`;
|
|
6201
|
+
|
|
6202
|
+
class JRCheckbox extends JROptions {
|
|
6203
|
+
renderer() {
|
|
6204
|
+
const {
|
|
6205
|
+
valueName = 'value',
|
|
6206
|
+
labelName = 'label'
|
|
6207
|
+
} = this.props;
|
|
6208
|
+
const multiple = Array.isArray(this.getOptions() ?? []);
|
|
6209
|
+
const options = multiple ? this.getOptions() : [this.getOptions()];
|
|
6210
|
+
const value = multiple ? [...(this.getValue() ?? [])] : this.getValue();
|
|
6211
|
+
const checked = multiple ? checkValue => {
|
|
6212
|
+
return value.indexOf(checkValue) > -1;
|
|
6213
|
+
} : checkValue => {
|
|
6214
|
+
return checkValue == value;
|
|
6215
|
+
};
|
|
6216
|
+
return /*#__PURE__*/React__default.createElement(StyledPick, {
|
|
6217
|
+
className: 'jr-checkbox'
|
|
6218
|
+
}, options?.map((record, key) => {
|
|
6219
|
+
const recordValue = record[valueName];
|
|
6220
|
+
return /*#__PURE__*/React__default.createElement("label", {
|
|
6221
|
+
key: key
|
|
6222
|
+
}, /*#__PURE__*/React__default.createElement("input", {
|
|
6223
|
+
type: 'checkbox',
|
|
6224
|
+
multiple: multiple,
|
|
6225
|
+
value: recordValue,
|
|
6226
|
+
checked: checked(recordValue),
|
|
6227
|
+
onChange: multiple ? e => {
|
|
6228
|
+
if (e.target.checked) {
|
|
6229
|
+
value.push(recordValue);
|
|
6230
|
+
} else {
|
|
6231
|
+
value.splice(value.indexOf(recordValue), 1);
|
|
6232
|
+
}
|
|
6233
|
+
this.setValue(value.length ? value : null);
|
|
6234
|
+
} : e => {
|
|
6235
|
+
this.setValue(e.target.checked ? recordValue : null);
|
|
6236
|
+
}
|
|
6237
|
+
}), record[labelName]);
|
|
6238
|
+
}));
|
|
6239
|
+
}
|
|
6240
|
+
}
|
|
6241
|
+
|
|
6242
|
+
export { JRAlert, JRButton, JRCheckbox, JRFields, JRFrame, JRSelect, JRSubmit, JRTable, JRTestReact, JRWindow };
|
package/build/index.js
CHANGED
|
@@ -3544,6 +3544,8 @@ class JRSubmit extends React__default["default"].Component {
|
|
|
3544
3544
|
const fullnamList = fullname.split('.');
|
|
3545
3545
|
return this.#getValueByName(fullnamList, this[this.from]?.value);
|
|
3546
3546
|
} else {
|
|
3547
|
+
// po('ssssssssssssssssssssssssssssssssssssssssss')
|
|
3548
|
+
// 忘記為甚麼這樣寫了 XDD
|
|
3547
3549
|
return flexType(this[this.from]?.value, this, null, null);
|
|
3548
3550
|
}
|
|
3549
3551
|
}
|
|
@@ -3699,7 +3701,7 @@ class JRSubmit extends React__default["default"].Component {
|
|
|
3699
3701
|
}
|
|
3700
3702
|
}
|
|
3701
3703
|
|
|
3702
|
-
const FreeType
|
|
3704
|
+
const FreeType = ({
|
|
3703
3705
|
tag: Tag,
|
|
3704
3706
|
config,
|
|
3705
3707
|
me,
|
|
@@ -3723,7 +3725,7 @@ const FreeType$1 = ({
|
|
|
3723
3725
|
}, config);
|
|
3724
3726
|
}
|
|
3725
3727
|
};
|
|
3726
|
-
const StyledJRFrame
|
|
3728
|
+
const StyledJRFrame = styled__default["default"].div`
|
|
3727
3729
|
display:flex;
|
|
3728
3730
|
flex:1;
|
|
3729
3731
|
overflow:hidden;
|
|
@@ -3766,36 +3768,36 @@ const StyledJRFrame$1 = styled__default["default"].div`
|
|
|
3766
3768
|
`;
|
|
3767
3769
|
class JRFrame extends JRSubmit {
|
|
3768
3770
|
renderer() {
|
|
3769
|
-
return /*#__PURE__*/React__default["default"].createElement(StyledJRFrame
|
|
3771
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledJRFrame, {
|
|
3770
3772
|
id: this.props.id,
|
|
3771
3773
|
style: this.props.style,
|
|
3772
3774
|
className: `${this.props.className} jr-frame`
|
|
3773
|
-
}, /*#__PURE__*/React__default["default"].createElement(FreeType
|
|
3775
|
+
}, /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
3774
3776
|
tag: "div",
|
|
3775
3777
|
config: this.props.start,
|
|
3776
3778
|
me: this,
|
|
3777
3779
|
className: 'start'
|
|
3778
|
-
}), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeType
|
|
3780
|
+
}), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
3779
3781
|
tag: "header",
|
|
3780
3782
|
config: this.props.top,
|
|
3781
3783
|
me: this
|
|
3782
|
-
}), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeType
|
|
3784
|
+
}), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
3783
3785
|
tag: "div",
|
|
3784
3786
|
config: this.props.left,
|
|
3785
3787
|
me: this,
|
|
3786
3788
|
className: 'left'
|
|
3787
3789
|
}), /*#__PURE__*/React__default["default"].createElement("main", {
|
|
3788
3790
|
className: 'body'
|
|
3789
|
-
}, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default["default"].createElement(FreeType
|
|
3791
|
+
}, this.renderMe?.() ?? this.props.children), /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
3790
3792
|
tag: "div",
|
|
3791
3793
|
config: this.props.right,
|
|
3792
3794
|
me: this,
|
|
3793
3795
|
className: 'right'
|
|
3794
|
-
})), /*#__PURE__*/React__default["default"].createElement(FreeType
|
|
3796
|
+
})), /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
3795
3797
|
tag: "footer",
|
|
3796
3798
|
config: this.props.bottom,
|
|
3797
3799
|
me: this
|
|
3798
|
-
})), /*#__PURE__*/React__default["default"].createElement(FreeType
|
|
3800
|
+
})), /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
3799
3801
|
tag: "div",
|
|
3800
3802
|
config: this.props.end,
|
|
3801
3803
|
me: this,
|
|
@@ -4070,7 +4072,7 @@ class TitleBar extends React__default["default"].Component {
|
|
|
4070
4072
|
this.start(e);
|
|
4071
4073
|
},
|
|
4072
4074
|
onDoubleClick: this.adjustScreen
|
|
4073
|
-
}, /*#__PURE__*/React__default["default"].createElement(FreeType
|
|
4075
|
+
}, /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
4074
4076
|
tag: "div",
|
|
4075
4077
|
config: this.props.title ?? '',
|
|
4076
4078
|
me: this.props.window,
|
|
@@ -6029,95 +6031,15 @@ class JRTable extends JRWindow {
|
|
|
6029
6031
|
// export const FTable=JRFrameHOC(JRTable)
|
|
6030
6032
|
// export const WTable=JRWindowHOC(JRTable)
|
|
6031
6033
|
|
|
6032
|
-
const
|
|
6033
|
-
|
|
6034
|
-
flex:1;
|
|
6035
|
-
overflow:hidden;
|
|
6036
|
-
|
|
6037
|
-
> *{
|
|
6038
|
-
Xborder:1px solid gray;
|
|
6039
|
-
}
|
|
6040
|
-
>main{
|
|
6041
|
-
display:flex;
|
|
6042
|
-
flex:1;
|
|
6043
|
-
overflow:overlay;
|
|
6044
|
-
flex-direction: column;
|
|
6045
|
-
> *{
|
|
6046
|
-
XXborder:1px solid gray;
|
|
6047
|
-
min-height:30px;
|
|
6048
|
-
}
|
|
6049
|
-
|
|
6050
|
-
>header{
|
|
6051
|
-
XXborder:1px solid red;
|
|
6052
|
-
XXoverflow: overlay;
|
|
6053
|
-
}
|
|
6054
|
-
>main{
|
|
6055
|
-
display:flex;
|
|
6056
|
-
flex:1;
|
|
6057
|
-
overflow:hidden;
|
|
6058
|
-
}
|
|
6059
|
-
>footer{
|
|
6060
|
-
XXborder:1px solid blue;
|
|
6061
|
-
overflow: overlay;
|
|
6062
|
-
}
|
|
6063
|
-
|
|
6064
|
-
}
|
|
6065
|
-
|
|
6034
|
+
const StyledJRTest = styled__default["default"].div`
|
|
6035
|
+
|
|
6066
6036
|
`;
|
|
6067
|
-
const FreeType = ({
|
|
6068
|
-
tag: Tag,
|
|
6069
|
-
config,
|
|
6070
|
-
me,
|
|
6071
|
-
className
|
|
6072
|
-
}) => {
|
|
6073
|
-
if (typeof config === 'function') {
|
|
6074
|
-
let style;
|
|
6075
|
-
const setStyle = function (_style) {
|
|
6076
|
-
style = _style;
|
|
6077
|
-
};
|
|
6078
|
-
const content = config.bind(me)({
|
|
6079
|
-
setStyle
|
|
6080
|
-
});
|
|
6081
|
-
return /*#__PURE__*/React__default["default"].createElement(Tag, {
|
|
6082
|
-
className: className,
|
|
6083
|
-
style: style
|
|
6084
|
-
}, content);
|
|
6085
|
-
}
|
|
6086
|
-
};
|
|
6087
6037
|
class JRTestReact extends JRSubmit {
|
|
6088
6038
|
renderer() {
|
|
6089
|
-
return /*#__PURE__*/React__default["default"].createElement(
|
|
6039
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledJRTest, {
|
|
6090
6040
|
style: this.props.style,
|
|
6091
6041
|
className: `${this.props.className} jr-frame`
|
|
6092
|
-
}
|
|
6093
|
-
tag: "div",
|
|
6094
|
-
config: this.props.start,
|
|
6095
|
-
me: this,
|
|
6096
|
-
className: 'start'
|
|
6097
|
-
}), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
6098
|
-
tag: "header",
|
|
6099
|
-
config: this.props.top,
|
|
6100
|
-
me: this
|
|
6101
|
-
}), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
6102
|
-
tag: "div",
|
|
6103
|
-
config: this.props.left,
|
|
6104
|
-
me: this,
|
|
6105
|
-
className: 'left'
|
|
6106
|
-
}), this.renderMe(), /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
6107
|
-
tag: "div",
|
|
6108
|
-
config: this.props.right,
|
|
6109
|
-
me: this,
|
|
6110
|
-
className: 'right'
|
|
6111
|
-
})), /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
6112
|
-
tag: "footer",
|
|
6113
|
-
config: this.props.bottom,
|
|
6114
|
-
me: this
|
|
6115
|
-
})), /*#__PURE__*/React__default["default"].createElement(FreeType, {
|
|
6116
|
-
tag: "div",
|
|
6117
|
-
config: this.props.end,
|
|
6118
|
-
me: this,
|
|
6119
|
-
className: 'end'
|
|
6120
|
-
}));
|
|
6042
|
+
});
|
|
6121
6043
|
}
|
|
6122
6044
|
renderMe() {
|
|
6123
6045
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -6197,10 +6119,159 @@ function JRAlert(props) {
|
|
|
6197
6119
|
})));
|
|
6198
6120
|
}
|
|
6199
6121
|
|
|
6122
|
+
const StyledInput = styled__default["default"].div`
|
|
6123
|
+
display:flex;
|
|
6124
|
+
input:focus{
|
|
6125
|
+
outline: none;
|
|
6126
|
+
}
|
|
6127
|
+
`;
|
|
6128
|
+
class JRInput extends React__default["default"].Component {
|
|
6129
|
+
setValue(value) {
|
|
6130
|
+
this.props?.onChange?.(value);
|
|
6131
|
+
}
|
|
6132
|
+
render() {
|
|
6133
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledInput, null, this.input());
|
|
6134
|
+
}
|
|
6135
|
+
}
|
|
6136
|
+
|
|
6137
|
+
class JROptions extends JRSubmit {
|
|
6138
|
+
get optionsFrom() {
|
|
6139
|
+
return this.props.options === undefined ? 'state' : 'props';
|
|
6140
|
+
}
|
|
6141
|
+
setOptions(options) {
|
|
6142
|
+
if (this.props.setOptions) {
|
|
6143
|
+
this.props.setOptions(options);
|
|
6144
|
+
} else {
|
|
6145
|
+
this.setState({
|
|
6146
|
+
options: options
|
|
6147
|
+
});
|
|
6148
|
+
}
|
|
6149
|
+
}
|
|
6150
|
+
getOptions() {
|
|
6151
|
+
return this[this.optionsFrom]?.options;
|
|
6152
|
+
}
|
|
6153
|
+
setRes(isSuccess, response, config) {
|
|
6154
|
+
if (isSuccess) {
|
|
6155
|
+
const options = config.formatValue?.bind(this)(response.data) ?? response.data;
|
|
6156
|
+
response.data = options;
|
|
6157
|
+
this.setOptions(options);
|
|
6158
|
+
}
|
|
6159
|
+
}
|
|
6160
|
+
}
|
|
6161
|
+
|
|
6162
|
+
const StyledOption = styled__default["default"].option`
|
|
6163
|
+
`;
|
|
6164
|
+
const StyledSelect = styled__default["default"].select`
|
|
6165
|
+
${({
|
|
6166
|
+
size,
|
|
6167
|
+
multiple
|
|
6168
|
+
}) => `${size == 1 || size == undefined && multiple != true ? 'height:30px;' : ''}`}
|
|
6169
|
+
width: 100%;
|
|
6170
|
+
|
|
6171
|
+
option{
|
|
6172
|
+
padding: 4px;
|
|
6173
|
+
height: 25px;
|
|
6174
|
+
display: flex;
|
|
6175
|
+
align-items: center;
|
|
6176
|
+
}
|
|
6177
|
+
`;
|
|
6178
|
+
class JRSelect extends JROptions {
|
|
6179
|
+
renderer() {
|
|
6180
|
+
const {
|
|
6181
|
+
showBlank,
|
|
6182
|
+
valueName = 'id',
|
|
6183
|
+
labelName = 'name',
|
|
6184
|
+
multiple,
|
|
6185
|
+
size
|
|
6186
|
+
} = this.props;
|
|
6187
|
+
const options = [...(this.getOptions() ?? [])];
|
|
6188
|
+
if (multiple != true && showBlank != false) options.unshift({
|
|
6189
|
+
[valueName]: '',
|
|
6190
|
+
[labelName]: ''
|
|
6191
|
+
});
|
|
6192
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(StyledSelect, {
|
|
6193
|
+
value: this.getValue() ?? (multiple ? [] : ''),
|
|
6194
|
+
className: 'jr-select',
|
|
6195
|
+
onChange: e => {
|
|
6196
|
+
if (multiple) {
|
|
6197
|
+
const selectedIndex = [...e.target.selectedOptions].map(option => option.index);
|
|
6198
|
+
this.setValue(selectedIndex.length ? selectedIndex.map(index => options[index][valueName]) : null);
|
|
6199
|
+
} else {
|
|
6200
|
+
const selectedIndex = e.target.selectedOptions[0].index;
|
|
6201
|
+
this.setValue(selectedIndex ? options[selectedIndex][valueName] : null);
|
|
6202
|
+
}
|
|
6203
|
+
},
|
|
6204
|
+
size: size,
|
|
6205
|
+
multiple: multiple
|
|
6206
|
+
}, options.map((record, key) => {
|
|
6207
|
+
const props = {
|
|
6208
|
+
value: record[valueName],
|
|
6209
|
+
key: key
|
|
6210
|
+
};
|
|
6211
|
+
if (multiple && this.getValue()?.indexOf(record[valueName]) > -1 || this.getValue() == record[valueName]) {
|
|
6212
|
+
props.className = 'selected';
|
|
6213
|
+
}
|
|
6214
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledOption, props, record[labelName]);
|
|
6215
|
+
})));
|
|
6216
|
+
}
|
|
6217
|
+
}
|
|
6218
|
+
|
|
6219
|
+
const StyledPick = styled__default["default"].div`
|
|
6220
|
+
>label{
|
|
6221
|
+
white-space: nowrap;
|
|
6222
|
+
display: inline-flex;
|
|
6223
|
+
align-items: center;
|
|
6224
|
+
height: 30px;
|
|
6225
|
+
padding-right: 12px;
|
|
6226
|
+
}
|
|
6227
|
+
`;
|
|
6228
|
+
|
|
6229
|
+
class JRCheckbox extends JROptions {
|
|
6230
|
+
renderer() {
|
|
6231
|
+
const {
|
|
6232
|
+
valueName = 'value',
|
|
6233
|
+
labelName = 'label'
|
|
6234
|
+
} = this.props;
|
|
6235
|
+
const multiple = Array.isArray(this.getOptions() ?? []);
|
|
6236
|
+
const options = multiple ? this.getOptions() : [this.getOptions()];
|
|
6237
|
+
const value = multiple ? [...(this.getValue() ?? [])] : this.getValue();
|
|
6238
|
+
const checked = multiple ? checkValue => {
|
|
6239
|
+
return value.indexOf(checkValue) > -1;
|
|
6240
|
+
} : checkValue => {
|
|
6241
|
+
return checkValue == value;
|
|
6242
|
+
};
|
|
6243
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledPick, {
|
|
6244
|
+
className: 'jr-checkbox'
|
|
6245
|
+
}, options?.map((record, key) => {
|
|
6246
|
+
const recordValue = record[valueName];
|
|
6247
|
+
return /*#__PURE__*/React__default["default"].createElement("label", {
|
|
6248
|
+
key: key
|
|
6249
|
+
}, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
6250
|
+
type: 'checkbox',
|
|
6251
|
+
multiple: multiple,
|
|
6252
|
+
value: recordValue,
|
|
6253
|
+
checked: checked(recordValue),
|
|
6254
|
+
onChange: multiple ? e => {
|
|
6255
|
+
if (e.target.checked) {
|
|
6256
|
+
value.push(recordValue);
|
|
6257
|
+
} else {
|
|
6258
|
+
value.splice(value.indexOf(recordValue), 1);
|
|
6259
|
+
}
|
|
6260
|
+
this.setValue(value.length ? value : null);
|
|
6261
|
+
} : e => {
|
|
6262
|
+
this.setValue(e.target.checked ? recordValue : null);
|
|
6263
|
+
}
|
|
6264
|
+
}), record[labelName]);
|
|
6265
|
+
}));
|
|
6266
|
+
}
|
|
6267
|
+
}
|
|
6268
|
+
|
|
6200
6269
|
exports.JRAlert = JRAlert;
|
|
6201
6270
|
exports.JRButton = JRButton;
|
|
6271
|
+
exports.JRCheckbox = JRCheckbox;
|
|
6202
6272
|
exports.JRFields = JRFields;
|
|
6203
6273
|
exports.JRFrame = JRFrame;
|
|
6274
|
+
exports.JRSelect = JRSelect;
|
|
6204
6275
|
exports.JRSubmit = JRSubmit;
|
|
6205
6276
|
exports.JRTable = JRTable;
|
|
6206
6277
|
exports.JRTestReact = JRTestReact;
|
package/package.json
CHANGED
package/public/data.json
CHANGED
package/public/list.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"name":"Joren"
|
|
4
|
+
,"id":1
|
|
4
5
|
,"phone":"097459999"
|
|
5
6
|
,"address":{
|
|
6
7
|
"no":"23"
|
|
@@ -10,6 +11,7 @@
|
|
|
10
11
|
}
|
|
11
12
|
,{
|
|
12
13
|
"name":"John"
|
|
14
|
+
,"id":2
|
|
13
15
|
,"phone":"0124873737"
|
|
14
16
|
,"address":{
|
|
15
17
|
"no":"36"
|
|
@@ -18,7 +20,8 @@
|
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
,{
|
|
21
|
-
"name":"
|
|
23
|
+
"name":"Oliver"
|
|
24
|
+
,"id":3
|
|
22
25
|
,"phone":"0124873737"
|
|
23
26
|
,"address":{
|
|
24
27
|
"no":"36"
|
|
@@ -27,7 +30,8 @@
|
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
,{
|
|
30
|
-
"name":"
|
|
33
|
+
"name":"Harry"
|
|
34
|
+
,"id":4
|
|
31
35
|
,"phone":"0124873737"
|
|
32
36
|
,"address":{
|
|
33
37
|
"no":"36"
|
|
@@ -36,7 +40,8 @@
|
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
,{
|
|
39
|
-
"name":"
|
|
43
|
+
"name":"Jacob"
|
|
44
|
+
,"id":5
|
|
40
45
|
,"phone":"0124873737"
|
|
41
46
|
,"address":{
|
|
42
47
|
"no":"36"
|
|
@@ -45,7 +50,8 @@
|
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
,{
|
|
48
|
-
"name":"
|
|
53
|
+
"name":"Charlie"
|
|
54
|
+
,"id":6
|
|
49
55
|
,"phone":"0124873737"
|
|
50
56
|
,"address":{
|
|
51
57
|
"no":"36"
|
|
@@ -54,7 +60,8 @@
|
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
,{
|
|
57
|
-
"name":"
|
|
63
|
+
"name":"Thomas"
|
|
64
|
+
,"id":7
|
|
58
65
|
,"phone":"0124873737"
|
|
59
66
|
,"address":{
|
|
60
67
|
"no":"36"
|
|
@@ -63,7 +70,8 @@
|
|
|
63
70
|
}
|
|
64
71
|
}
|
|
65
72
|
,{
|
|
66
|
-
"name":"
|
|
73
|
+
"name":"George"
|
|
74
|
+
,"id":8
|
|
67
75
|
,"phone":"0124873737"
|
|
68
76
|
,"address":{
|
|
69
77
|
"no":"36"
|
|
@@ -72,7 +80,8 @@
|
|
|
72
80
|
}
|
|
73
81
|
}
|
|
74
82
|
,{
|
|
75
|
-
"name":"
|
|
83
|
+
"name":"Oscar"
|
|
84
|
+
,"id":9
|
|
76
85
|
,"phone":"0124873737"
|
|
77
86
|
,"address":{
|
|
78
87
|
"no":"36"
|
|
@@ -81,7 +90,8 @@
|
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
92
|
,{
|
|
84
|
-
"name":"
|
|
93
|
+
"name":"James"
|
|
94
|
+
,"id":10
|
|
85
95
|
,"phone":"0124873737"
|
|
86
96
|
,"address":{
|
|
87
97
|
"no":"36"
|
|
@@ -90,7 +100,8 @@
|
|
|
90
100
|
}
|
|
91
101
|
}
|
|
92
102
|
,{
|
|
93
|
-
"name":"
|
|
103
|
+
"name":"William"
|
|
104
|
+
,"id":11
|
|
94
105
|
,"phone":"0124873737"
|
|
95
106
|
,"address":{
|
|
96
107
|
"no":"36"
|
|
@@ -99,7 +110,8 @@
|
|
|
99
110
|
}
|
|
100
111
|
}
|
|
101
112
|
,{
|
|
102
|
-
"name":"
|
|
113
|
+
"name":"Emily"
|
|
114
|
+
,"id":12
|
|
103
115
|
,"phone":"0124873737"
|
|
104
116
|
,"address":{
|
|
105
117
|
"no":"36"
|
|
@@ -108,7 +120,8 @@
|
|
|
108
120
|
}
|
|
109
121
|
}
|
|
110
122
|
,{
|
|
111
|
-
"name":"
|
|
123
|
+
"name":"Isla"
|
|
124
|
+
,"id":13
|
|
112
125
|
,"phone":"0124873737"
|
|
113
126
|
,"address":{
|
|
114
127
|
"no":"36"
|
package/src/app/App.jsx
CHANGED
|
@@ -7,10 +7,11 @@ import AxiosApp from './axios/AxiosApp'
|
|
|
7
7
|
import AlertApp from './alert/AlertApp'
|
|
8
8
|
import { po } from '../components/JRUtils'
|
|
9
9
|
import TestApp from './test'
|
|
10
|
+
import InputApp from './input/InputApp'
|
|
10
11
|
|
|
11
12
|
function App() {
|
|
12
13
|
const apps={
|
|
13
|
-
TableApp,FieldsApp,WindowApp,AxiosApp,AlertApp,TestApp
|
|
14
|
+
TableApp,FieldsApp,WindowApp,AxiosApp,AlertApp,InputApp,TestApp
|
|
14
15
|
}
|
|
15
16
|
return <BrowserRouter>
|
|
16
17
|
{
|
|
@@ -24,14 +25,8 @@ function App() {
|
|
|
24
25
|
return <Route path={`/${key}`} element={<App/>} key={key}/>
|
|
25
26
|
})
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
<Route path="/table" element={<TableApp/>}/>
|
|
29
|
-
<Route path="/fields" element={<FieldsApp/>}/>
|
|
30
|
-
<Route path="/window" element={<WindowApp/>}/>
|
|
31
|
-
<Route path="/axios" element={<AxiosApp/>}/>
|
|
32
|
-
<Route path="/alert" element={<AlertApp/>}/>
|
|
33
28
|
</Routes>
|
|
34
|
-
<div id='play' style={{width:'500px',height:'500px',border:'1px solid gray'}}> </div>
|
|
29
|
+
{/* <div id='play' style={{width:'500px',height:'500px',border:'1px solid gray'}}> </div> */}
|
|
35
30
|
</BrowserRouter>
|
|
36
31
|
}
|
|
37
32
|
|
|
@@ -16,12 +16,16 @@ const StyledJRFields=styled(JRFields)`
|
|
|
16
16
|
export default function FieldsApp() {
|
|
17
17
|
return <>
|
|
18
18
|
<JRFields
|
|
19
|
+
initValue={{
|
|
20
|
+
checkbox:[1,3,5]
|
|
21
|
+
,select:[2]
|
|
22
|
+
}}
|
|
19
23
|
{...devFields}
|
|
20
24
|
{...withSomeButton}
|
|
21
25
|
open={true}
|
|
22
|
-
popup={
|
|
26
|
+
popup={false}
|
|
23
27
|
width={900}
|
|
24
|
-
height={800}
|
|
28
|
+
// height={800}
|
|
25
29
|
title={'Fields'}
|
|
26
30
|
/>
|
|
27
31
|
</>
|
|
@@ -5,6 +5,8 @@ import JRText from "../../components/JRInput/JRText";
|
|
|
5
5
|
import JRTable from "../../components/JRTable/JRTable";
|
|
6
6
|
import { po } from "../../components/JRUtils";
|
|
7
7
|
import styled from "styled-components";
|
|
8
|
+
import JRCheckbox from "../../components/JRInput/JRCheckbox";
|
|
9
|
+
import { JRRadio } from "../../components/JRInput/JRRadio";
|
|
8
10
|
|
|
9
11
|
export const fieldsConfig={
|
|
10
12
|
popup:true
|
|
@@ -208,11 +210,45 @@ export const normalFields={
|
|
|
208
210
|
}
|
|
209
211
|
]
|
|
210
212
|
}
|
|
213
|
+
,{
|
|
214
|
+
name:'select'
|
|
215
|
+
,label:'Select'
|
|
216
|
+
,type:JRSelect
|
|
217
|
+
,valueName:'id'
|
|
218
|
+
,get:{
|
|
219
|
+
url:'list.json'
|
|
220
|
+
,autoRun:true
|
|
221
|
+
}
|
|
222
|
+
,multiple:true
|
|
223
|
+
,required:true
|
|
224
|
+
}
|
|
225
|
+
,{}
|
|
226
|
+
,{
|
|
227
|
+
name:'isMember'
|
|
228
|
+
,label:'Is member'
|
|
229
|
+
,type:JRCheckbox
|
|
230
|
+
,option:{
|
|
231
|
+
value:1
|
|
232
|
+
,label:'yes'
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
,{
|
|
236
|
+
name:'checkbox'
|
|
237
|
+
,label:'Checkbox'
|
|
238
|
+
,type:JRCheckbox
|
|
239
|
+
,valueName:'id'
|
|
240
|
+
,get:{
|
|
241
|
+
url:'list.json'
|
|
242
|
+
,autoRun:true
|
|
243
|
+
}
|
|
244
|
+
,required:true
|
|
245
|
+
}
|
|
211
246
|
]
|
|
212
247
|
,cols:2
|
|
213
248
|
,style:{
|
|
214
249
|
border:'1px solid gray'
|
|
215
250
|
}
|
|
251
|
+
|
|
216
252
|
}
|
|
217
253
|
////////////////////////////////////////////////////////////
|
|
218
254
|
const StyledDiv=styled.div`
|
|
@@ -251,7 +287,7 @@ export const withSomeButton={
|
|
|
251
287
|
onClick={()=>{
|
|
252
288
|
this.validate()
|
|
253
289
|
.then(()=>{
|
|
254
|
-
|
|
290
|
+
alert('is valid')
|
|
255
291
|
})
|
|
256
292
|
.catch(()=>{
|
|
257
293
|
|
|
@@ -305,7 +341,7 @@ export const labelLayout={
|
|
|
305
341
|
export const devFields={
|
|
306
342
|
get:{
|
|
307
343
|
url:'data.json'
|
|
308
|
-
,autoRun:true
|
|
344
|
+
// ,autoRun:true
|
|
309
345
|
,callback(success,res){
|
|
310
346
|
po('success,data',success,res)
|
|
311
347
|
// setTimeout(()=>{
|
|
@@ -357,7 +393,68 @@ export const devFields={
|
|
|
357
393
|
,border:'1px solid black'
|
|
358
394
|
,borderRadius: '3px'
|
|
359
395
|
}
|
|
396
|
+
,colSpan:2
|
|
397
|
+
}
|
|
398
|
+
,{
|
|
399
|
+
name:'isMember'
|
|
400
|
+
,label:'Is member'
|
|
401
|
+
,type:JRCheckbox
|
|
402
|
+
,options:{
|
|
403
|
+
value:1
|
|
404
|
+
,label:'yes'
|
|
405
|
+
}
|
|
406
|
+
,required:true
|
|
407
|
+
}
|
|
408
|
+
,{
|
|
409
|
+
name:'selectSingle'
|
|
410
|
+
,label:'Select'
|
|
411
|
+
,type:JRSelect
|
|
412
|
+
,valueName:'id'
|
|
413
|
+
,labelName:'name'
|
|
414
|
+
,get:{
|
|
415
|
+
url:'list.json'
|
|
416
|
+
,autoRun:true
|
|
417
|
+
}
|
|
418
|
+
,required:true
|
|
419
|
+
}
|
|
420
|
+
,{
|
|
421
|
+
name:'checkbox'
|
|
422
|
+
,label:'Checkbox'
|
|
423
|
+
,type:JRCheckbox
|
|
424
|
+
,valueName:'id'
|
|
425
|
+
,labelName:'name'
|
|
426
|
+
,get:{
|
|
427
|
+
url:'list.json'
|
|
428
|
+
,autoRun:true
|
|
429
|
+
}
|
|
430
|
+
,required:true
|
|
431
|
+
}
|
|
432
|
+
,{
|
|
433
|
+
name:'select'
|
|
434
|
+
,label:'Select'
|
|
435
|
+
,type:JRSelect
|
|
436
|
+
,valueName:'id'
|
|
437
|
+
,labelName:'name'
|
|
438
|
+
,get:{
|
|
439
|
+
url:'list.json'
|
|
440
|
+
,autoRun:true
|
|
441
|
+
}
|
|
442
|
+
,multiple:true
|
|
443
|
+
,required:true
|
|
444
|
+
}
|
|
445
|
+
,{
|
|
446
|
+
name:'radio'
|
|
447
|
+
,label:'Radio'
|
|
448
|
+
,type:JRRadio
|
|
449
|
+
,valueName:'id'
|
|
450
|
+
,labelName:'name'
|
|
451
|
+
,get:{
|
|
452
|
+
url:'list.json'
|
|
453
|
+
,autoRun:true
|
|
454
|
+
}
|
|
455
|
+
,multiple:true
|
|
456
|
+
,required:true
|
|
360
457
|
}
|
|
361
458
|
]
|
|
362
|
-
,cols:
|
|
459
|
+
,cols:2
|
|
363
460
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import JRFields from "../../components/JRFields/JRFields";
|
|
3
|
+
import { required } from "../../components/JRFields/Validators";
|
|
4
|
+
import JRSelect from "../../components/JRInput/JRSelect";
|
|
5
|
+
export default function InputApp() {
|
|
6
|
+
const [selectedValue,setSelectedValue]=useState()
|
|
7
|
+
return <div>
|
|
8
|
+
<JRSelect
|
|
9
|
+
get={{
|
|
10
|
+
url:'list.json'
|
|
11
|
+
,autoRun:true
|
|
12
|
+
}}
|
|
13
|
+
value={selectedValue}
|
|
14
|
+
onChange={(value)=>{
|
|
15
|
+
setSelectedValue(value)
|
|
16
|
+
}}
|
|
17
|
+
size={6}
|
|
18
|
+
multiple={true}
|
|
19
|
+
valueName={'name'}
|
|
20
|
+
/>
|
|
21
|
+
[{selectedValue}]
|
|
22
|
+
<JRFields
|
|
23
|
+
valueName={'phone'}
|
|
24
|
+
columns={[
|
|
25
|
+
{name:'name',label:'Name'
|
|
26
|
+
,type:JRSelect
|
|
27
|
+
,get:{
|
|
28
|
+
url:'list.json'
|
|
29
|
+
,autoRun:true
|
|
30
|
+
}
|
|
31
|
+
,showBlank:true
|
|
32
|
+
,multiple:true
|
|
33
|
+
,valueName:'name'
|
|
34
|
+
// ,size:5
|
|
35
|
+
,required:true
|
|
36
|
+
}
|
|
37
|
+
]}
|
|
38
|
+
bottom={function(){
|
|
39
|
+
return JSON.stringify(this.getValue())
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import JROptions from "../JROptions";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { StyledPick } from "./JRRadio";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default class JRCheckbox extends JROptions{
|
|
8
|
+
renderer(){
|
|
9
|
+
const {valueName='value',labelName='label'}=this.props
|
|
10
|
+
const multiple=Array.isArray(this.getOptions()??[])
|
|
11
|
+
const options=multiple?this.getOptions():[this.getOptions()]
|
|
12
|
+
const value=multiple?[...this.getValue()??[]]:this.getValue()
|
|
13
|
+
const checked=multiple
|
|
14
|
+
?(checkValue)=>{
|
|
15
|
+
return value.indexOf(checkValue)>-1
|
|
16
|
+
}
|
|
17
|
+
:(checkValue)=>{
|
|
18
|
+
return checkValue==value
|
|
19
|
+
}
|
|
20
|
+
return <StyledPick className={'jr-checkbox'}>
|
|
21
|
+
{
|
|
22
|
+
options?.map((record,key)=>{
|
|
23
|
+
const recordValue=record[valueName]
|
|
24
|
+
return <label key={key}>
|
|
25
|
+
<input
|
|
26
|
+
type={'checkbox'}
|
|
27
|
+
multiple={multiple}
|
|
28
|
+
value={recordValue}
|
|
29
|
+
checked={checked(recordValue)}
|
|
30
|
+
onChange={multiple
|
|
31
|
+
?(e)=>{
|
|
32
|
+
if(e.target.checked){
|
|
33
|
+
value.push(recordValue)
|
|
34
|
+
}else{
|
|
35
|
+
value.splice(value.indexOf(recordValue),1)
|
|
36
|
+
}
|
|
37
|
+
this.setValue(value.length?value:null)
|
|
38
|
+
}
|
|
39
|
+
:(e)=>{
|
|
40
|
+
this.setValue(e.target.checked?recordValue:null)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/>{record[labelName]}
|
|
44
|
+
</label>
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
</StyledPick>
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import JROptions from "../JROptions";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const StyledPick=styled.div`
|
|
7
|
+
>label{
|
|
8
|
+
white-space: nowrap;
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
height: 30px;
|
|
12
|
+
padding-right: 12px;
|
|
13
|
+
}
|
|
14
|
+
`
|
|
15
|
+
export class JRRadio extends JROptions{
|
|
16
|
+
renderer(){
|
|
17
|
+
const {valueName='value',labelName='label',onChange,...props}=this.props
|
|
18
|
+
const options=this.getOptions()
|
|
19
|
+
return <StyledPick className={'jr-radio'}>
|
|
20
|
+
{
|
|
21
|
+
options?.map((record,key)=>{
|
|
22
|
+
const recordValue=record[valueName]
|
|
23
|
+
return <label key={key}>
|
|
24
|
+
<input
|
|
25
|
+
type={'radio'}
|
|
26
|
+
name={'radio'}
|
|
27
|
+
checked={this.getValue()==recordValue}
|
|
28
|
+
onClick={(e)=>{
|
|
29
|
+
if(this.getValue()==recordValue){
|
|
30
|
+
this.setValue(null)
|
|
31
|
+
e.target.checked=false
|
|
32
|
+
}else{
|
|
33
|
+
this.setValue(recordValue)
|
|
34
|
+
}
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
{record[labelName]}
|
|
38
|
+
</label>
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
</StyledPick>
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,19 +1,64 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { po } from "../JRUtils";
|
|
3
3
|
import JRInput from "./JRInput";
|
|
4
|
+
import JROptions from "../JROptions";
|
|
5
|
+
import styled from "styled-components";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const StyledOption=styled.option`
|
|
8
|
+
`
|
|
9
|
+
const StyledSelect=styled.select`
|
|
10
|
+
${({size,multiple})=>`${size==1 || (size==undefined && multiple!=true)?'height:30px;':''}`}
|
|
11
|
+
width: 100%;
|
|
12
|
+
|
|
13
|
+
option{
|
|
14
|
+
padding: 4px;
|
|
15
|
+
height: 25px;
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
}
|
|
19
|
+
`
|
|
20
|
+
export default class JRSelect extends JROptions{
|
|
21
|
+
renderer(){
|
|
22
|
+
const {showBlank,valueName='id',labelName='name',multiple,size}=this.props
|
|
23
|
+
const options=[...this.getOptions()??[]]
|
|
24
|
+
if(multiple!=true && showBlank!=false)options.unshift({[valueName]:'',[labelName]:''})
|
|
25
|
+
return <>
|
|
26
|
+
<StyledSelect
|
|
27
|
+
value={this.getValue()??(multiple?[]:'')}
|
|
28
|
+
className={'jr-select'}
|
|
12
29
|
onChange={(e)=>{
|
|
13
|
-
|
|
30
|
+
if(multiple){
|
|
31
|
+
const selectedIndex=[...e.target.selectedOptions].map((option)=>option.index)
|
|
32
|
+
this.setValue(selectedIndex.length
|
|
33
|
+
?selectedIndex.map((index)=>options[index][valueName])
|
|
34
|
+
:null
|
|
35
|
+
)
|
|
36
|
+
}else{
|
|
37
|
+
const selectedIndex=e.target.selectedOptions[0].index
|
|
38
|
+
this.setValue(selectedIndex?options[selectedIndex][valueName]:null)
|
|
39
|
+
}
|
|
14
40
|
}}
|
|
41
|
+
size={size}
|
|
42
|
+
multiple={multiple}
|
|
15
43
|
>
|
|
16
|
-
|
|
17
|
-
|
|
44
|
+
{
|
|
45
|
+
options.map((record,key)=>{
|
|
46
|
+
const props={
|
|
47
|
+
value:record[valueName]
|
|
48
|
+
,key:key
|
|
49
|
+
}
|
|
50
|
+
if(
|
|
51
|
+
(multiple && this.getValue()?.indexOf(record[valueName])>-1)
|
|
52
|
+
|| this.getValue()==record[valueName]
|
|
53
|
+
){
|
|
54
|
+
props.className='selected'
|
|
55
|
+
}
|
|
56
|
+
return <StyledOption {...props}>
|
|
57
|
+
{record[labelName]}
|
|
58
|
+
</StyledOption>
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
</StyledSelect>
|
|
62
|
+
</>
|
|
18
63
|
}
|
|
19
64
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import JRSubmit from "./JRSubmit"
|
|
2
|
+
|
|
3
|
+
export default class JROptions extends JRSubmit {
|
|
4
|
+
get optionsFrom(){
|
|
5
|
+
return this.props.options===undefined?'state':'props'
|
|
6
|
+
}
|
|
7
|
+
setOptions(options){
|
|
8
|
+
if(this.props.setOptions){
|
|
9
|
+
this.props.setOptions(options)
|
|
10
|
+
}else{
|
|
11
|
+
this.setState({options: options})
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
getOptions(){
|
|
15
|
+
return this[this.optionsFrom]?.options
|
|
16
|
+
}
|
|
17
|
+
setRes(isSuccess,response,config){
|
|
18
|
+
if (isSuccess ) {
|
|
19
|
+
const options=config.formatValue?.bind(this)(response.data)??response.data
|
|
20
|
+
response.data=options
|
|
21
|
+
this.setOptions(options)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -142,6 +142,8 @@ export default class JRSubmit extends React.Component {
|
|
|
142
142
|
const fullnamList=fullname.split('.')
|
|
143
143
|
return this.#getValueByName(fullnamList,this[this.from]?.value)
|
|
144
144
|
}else{
|
|
145
|
+
// po('ssssssssssssssssssssssssssssssssssssssssss')
|
|
146
|
+
// 忘記為甚麼這樣寫了 XDD
|
|
145
147
|
return flexType(this[this.from]?.value,this,null,null)
|
|
146
148
|
}
|
|
147
149
|
}
|
|
@@ -2,40 +2,8 @@ import React from 'react'
|
|
|
2
2
|
import styled from "styled-components";
|
|
3
3
|
import JRSubmit from './JRSubmit'
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
flex:1;
|
|
8
|
-
overflow:hidden;
|
|
9
|
-
|
|
10
|
-
> *{
|
|
11
|
-
Xborder:1px solid gray;
|
|
12
|
-
}
|
|
13
|
-
>main{
|
|
14
|
-
display:flex;
|
|
15
|
-
flex:1;
|
|
16
|
-
overflow:overlay;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
> *{
|
|
19
|
-
XXborder:1px solid gray;
|
|
20
|
-
min-height:30px;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
>header{
|
|
24
|
-
XXborder:1px solid red;
|
|
25
|
-
XXoverflow: overlay;
|
|
26
|
-
}
|
|
27
|
-
>main{
|
|
28
|
-
display:flex;
|
|
29
|
-
flex:1;
|
|
30
|
-
overflow:hidden;
|
|
31
|
-
}
|
|
32
|
-
>footer{
|
|
33
|
-
XXborder:1px solid blue;
|
|
34
|
-
overflow: overlay;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
5
|
+
const StyledJRTest=styled.div`
|
|
6
|
+
|
|
39
7
|
`
|
|
40
8
|
|
|
41
9
|
const FreeType=({tag:Tag,config,me,className})=>{
|
|
@@ -51,19 +19,8 @@ const FreeType=({tag:Tag,config,me,className})=>{
|
|
|
51
19
|
|
|
52
20
|
export default class JRTestReact extends JRSubmit {
|
|
53
21
|
renderer(){
|
|
54
|
-
return <
|
|
55
|
-
|
|
56
|
-
<main>
|
|
57
|
-
<FreeType tag='header' config={this.props.top} me={this}/>
|
|
58
|
-
<main>
|
|
59
|
-
<FreeType tag='div' config={this.props.left} me={this} className={'left'}/>
|
|
60
|
-
{this.renderMe()}
|
|
61
|
-
<FreeType tag='div' config={this.props.right} me={this} className={'right'}/>
|
|
62
|
-
</main>
|
|
63
|
-
<FreeType tag='footer' config={this.props.bottom} me={this}/>
|
|
64
|
-
</main>
|
|
65
|
-
<FreeType tag='div' config={this.props.end} me={this} className={'end'}/>
|
|
66
|
-
</StyledJRFrame>
|
|
22
|
+
return <StyledJRTest style={this.props.style} className={`${this.props.className} jr-frame`} >
|
|
23
|
+
</StyledJRTest>
|
|
67
24
|
}
|
|
68
25
|
renderMe(){
|
|
69
26
|
return <div style={{flex:1}}>Render me</div>
|
package/src/index.js
CHANGED
|
@@ -6,9 +6,13 @@ import JRFields from './components/JRFields/JRFields'
|
|
|
6
6
|
import JRTestReact from './components/JRTest'
|
|
7
7
|
import JRButton from './components/JRInput/JRButton'
|
|
8
8
|
import JRAlert from './components/JRAlert'
|
|
9
|
+
import JRSelect from './components/JRInput/JRSelect'
|
|
10
|
+
import JRCheckbox from './components/JRInput/JRCheckbox'
|
|
9
11
|
|
|
10
12
|
export {
|
|
11
13
|
JRTestReact
|
|
12
14
|
,JRSubmit,JRFrame,JRWindow,JRTable,JRFields,JRAlert
|
|
13
15
|
,JRButton
|
|
16
|
+
,JRSelect,JRCheckbox
|
|
17
|
+
|
|
14
18
|
}
|