jrs-react 1.2.15 → 1.2.17

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.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$1 = ({
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$1 = styled__default["default"].div`
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$1, {
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$1, {
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$1, {
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$1, {
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$1, {
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$1, {
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$1, {
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$1, {
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 StyledJRFrame = styled__default["default"].div`
6033
- display:flex;
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(StyledJRFrame, {
6039
+ return /*#__PURE__*/React__default["default"].createElement(StyledJRTest, {
6090
6040
  style: this.props.style,
6091
6041
  className: `${this.props.className} jr-frame`
6092
- }, /*#__PURE__*/React__default["default"].createElement(FreeType, {
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,11 +6119,208 @@ 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
+ class JRRadio extends JROptions {
6229
+ renderer() {
6230
+ const {
6231
+ valueName = 'value',
6232
+ labelName = 'label',
6233
+ onChange,
6234
+ ...props
6235
+ } = this.props;
6236
+ const options = this.getOptions();
6237
+ return /*#__PURE__*/React__default["default"].createElement(StyledPick, {
6238
+ className: 'jr-radio'
6239
+ }, options?.map((record, key) => {
6240
+ const recordValue = record[valueName];
6241
+ return /*#__PURE__*/React__default["default"].createElement("label", {
6242
+ key: key
6243
+ }, /*#__PURE__*/React__default["default"].createElement("input", {
6244
+ type: 'radio',
6245
+ name: 'radio',
6246
+ checked: this.getValue() == recordValue,
6247
+ onClick: e => {
6248
+ if (this.getValue() == recordValue) {
6249
+ this.setValue(null);
6250
+ e.target.checked = false;
6251
+ } else {
6252
+ this.setValue(recordValue);
6253
+ }
6254
+ }
6255
+ }), record[labelName]);
6256
+ }));
6257
+ }
6258
+ }
6259
+
6260
+ class JRCheckbox extends JROptions {
6261
+ renderer() {
6262
+ const {
6263
+ valueName = 'value',
6264
+ labelName = 'label'
6265
+ } = this.props;
6266
+ const multiple = Array.isArray(this.getOptions() ?? []);
6267
+ const options = multiple ? this.getOptions() : [this.getOptions()];
6268
+ const value = multiple ? [...(this.getValue() ?? [])] : this.getValue();
6269
+ const checked = multiple ? checkValue => {
6270
+ return value.indexOf(checkValue) > -1;
6271
+ } : checkValue => {
6272
+ return checkValue == value;
6273
+ };
6274
+ return /*#__PURE__*/React__default["default"].createElement(StyledPick, {
6275
+ className: 'jr-checkbox'
6276
+ }, options?.map((record, key) => {
6277
+ const recordValue = record[valueName];
6278
+ return /*#__PURE__*/React__default["default"].createElement("label", {
6279
+ key: key
6280
+ }, /*#__PURE__*/React__default["default"].createElement("input", {
6281
+ type: 'checkbox',
6282
+ multiple: multiple,
6283
+ value: recordValue,
6284
+ checked: checked(recordValue),
6285
+ onChange: multiple ? e => {
6286
+ if (e.target.checked) {
6287
+ value.push(recordValue);
6288
+ } else {
6289
+ value.splice(value.indexOf(recordValue), 1);
6290
+ }
6291
+ this.setValue(value.length ? value : null);
6292
+ } : e => {
6293
+ this.setValue(e.target.checked ? recordValue : null);
6294
+ }
6295
+ }), record[labelName]);
6296
+ }));
6297
+ }
6298
+ }
6299
+
6300
+ class JRText extends JRInput {
6301
+ input() {
6302
+ return /*#__PURE__*/React__default["default"].createElement("input", {
6303
+ value: this.props.value ?? '',
6304
+ style: {
6305
+ height: '24px',
6306
+ width: '100%'
6307
+ },
6308
+ onChange: e => {
6309
+ this.setValue(e.target.value);
6310
+ }
6311
+ });
6312
+ }
6313
+ }
6314
+
6200
6315
  exports.JRAlert = JRAlert;
6201
6316
  exports.JRButton = JRButton;
6317
+ exports.JRCheckbox = JRCheckbox;
6202
6318
  exports.JRFields = JRFields;
6203
6319
  exports.JRFrame = JRFrame;
6320
+ exports.JRRadio = JRRadio;
6321
+ exports.JRSelect = JRSelect;
6204
6322
  exports.JRSubmit = JRSubmit;
6205
6323
  exports.JRTable = JRTable;
6206
6324
  exports.JRTestReact = JRTestReact;
6325
+ exports.JRText = JRText;
6207
6326
  exports.JRWindow = JRWindow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jrs-react",
3
- "version": "1.2.15",
3
+ "version": "1.2.17",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.es.js",
package/public/data.json CHANGED
@@ -16,4 +16,14 @@
16
16
  }
17
17
  ,"father":"Lai"
18
18
  ,"mother":"Wong"
19
+
20
+ ,"checkbox": [
21
+ 1,
22
+ 3,
23
+ 5
24
+ ],
25
+ "select": [
26
+ 2
27
+ ]
28
+ ,"radio":1
19
29
  }
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":"John"
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":"John"
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":"John"
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":"John"
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":"John"
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":"John"
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":"John"
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":"John"
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":"John"
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":"John"
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":"John"
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={true}
26
+ popup={false}
23
27
  width={900}
24
- height={800}
28
+ // height={800}
25
29
  title={'Fields'}
26
30
  />
27
31
  </>