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.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$1 = ({
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$1 = styled.div`
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$1, {
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$1, {
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$1, {
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$1, {
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$1, {
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$1, {
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$1, {
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$1, {
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 StyledJRFrame = styled.div`
6006
- display:flex;
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(StyledJRFrame, {
6012
+ return /*#__PURE__*/React__default.createElement(StyledJRTest, {
6063
6013
  style: this.props.style,
6064
6014
  className: `${this.props.className} jr-frame`
6065
- }, /*#__PURE__*/React__default.createElement(FreeType, {
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,197 @@ function JRAlert(props) {
6170
6092
  })));
6171
6093
  }
6172
6094
 
6173
- export { JRAlert, JRButton, JRFields, JRFrame, JRSubmit, JRTable, JRTestReact, JRWindow };
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
+ class JRRadio extends JROptions {
6202
+ renderer() {
6203
+ const {
6204
+ valueName = 'value',
6205
+ labelName = 'label',
6206
+ onChange,
6207
+ ...props
6208
+ } = this.props;
6209
+ const options = this.getOptions();
6210
+ return /*#__PURE__*/React__default.createElement(StyledPick, {
6211
+ className: 'jr-radio'
6212
+ }, options?.map((record, key) => {
6213
+ const recordValue = record[valueName];
6214
+ return /*#__PURE__*/React__default.createElement("label", {
6215
+ key: key
6216
+ }, /*#__PURE__*/React__default.createElement("input", {
6217
+ type: 'radio',
6218
+ name: 'radio',
6219
+ checked: this.getValue() == recordValue,
6220
+ onClick: e => {
6221
+ if (this.getValue() == recordValue) {
6222
+ this.setValue(null);
6223
+ e.target.checked = false;
6224
+ } else {
6225
+ this.setValue(recordValue);
6226
+ }
6227
+ }
6228
+ }), record[labelName]);
6229
+ }));
6230
+ }
6231
+ }
6232
+
6233
+ class JRCheckbox extends JROptions {
6234
+ renderer() {
6235
+ const {
6236
+ valueName = 'value',
6237
+ labelName = 'label'
6238
+ } = this.props;
6239
+ const multiple = Array.isArray(this.getOptions() ?? []);
6240
+ const options = multiple ? this.getOptions() : [this.getOptions()];
6241
+ const value = multiple ? [...(this.getValue() ?? [])] : this.getValue();
6242
+ const checked = multiple ? checkValue => {
6243
+ return value.indexOf(checkValue) > -1;
6244
+ } : checkValue => {
6245
+ return checkValue == value;
6246
+ };
6247
+ return /*#__PURE__*/React__default.createElement(StyledPick, {
6248
+ className: 'jr-checkbox'
6249
+ }, options?.map((record, key) => {
6250
+ const recordValue = record[valueName];
6251
+ return /*#__PURE__*/React__default.createElement("label", {
6252
+ key: key
6253
+ }, /*#__PURE__*/React__default.createElement("input", {
6254
+ type: 'checkbox',
6255
+ multiple: multiple,
6256
+ value: recordValue,
6257
+ checked: checked(recordValue),
6258
+ onChange: multiple ? e => {
6259
+ if (e.target.checked) {
6260
+ value.push(recordValue);
6261
+ } else {
6262
+ value.splice(value.indexOf(recordValue), 1);
6263
+ }
6264
+ this.setValue(value.length ? value : null);
6265
+ } : e => {
6266
+ this.setValue(e.target.checked ? recordValue : null);
6267
+ }
6268
+ }), record[labelName]);
6269
+ }));
6270
+ }
6271
+ }
6272
+
6273
+ class JRText extends JRInput {
6274
+ input() {
6275
+ return /*#__PURE__*/React__default.createElement("input", {
6276
+ value: this.props.value ?? '',
6277
+ style: {
6278
+ height: '24px',
6279
+ width: '100%'
6280
+ },
6281
+ onChange: e => {
6282
+ this.setValue(e.target.value);
6283
+ }
6284
+ });
6285
+ }
6286
+ }
6287
+
6288
+ export { JRAlert, JRButton, JRCheckbox, JRFields, JRFrame, JRRadio, JRSelect, JRSubmit, JRTable, JRTestReact, JRText, JRWindow };