jrs-react 1.1.13 → 1.1.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.js CHANGED
@@ -6058,25 +6058,6 @@ const flexType = (type, me, payload, doElse) => {
6058
6058
  const result = typeof type === 'function' ? type?.bind(me)(payload) : type ?? doElse;
6059
6059
  return result;
6060
6060
  };
6061
- const whatType = ({
6062
- type,
6063
- typeStyle: _typeStyle,
6064
- render,
6065
- ...config
6066
- }, me, doElse) => {
6067
- if (type) {
6068
- // const style=flexType(typeStyle,me,{},{})
6069
- // return 'type'
6070
- const typeStyle = typeof _typeStyle === 'function' ? _typeStyle?.bind(me)() : _typeStyle;
6071
- return /*#__PURE__*/React.createElement(type, {
6072
- style: typeStyle
6073
- });
6074
- } else if (render) {
6075
- return render.bind(me)();
6076
- } else {
6077
- return doElse;
6078
- }
6079
- };
6080
6061
 
6081
6062
  /******************************************************************************
6082
6063
  Copyright (c) Microsoft Corporation.
@@ -7432,60 +7413,23 @@ const StyledJRFrame = dt.div`
7432
7413
 
7433
7414
  `;
7434
7415
 
7435
- const FreeType = ({
7436
- tag: Tag,
7437
- config,
7438
- me,
7439
- className
7440
- }) => {
7441
- if (typeof config === 'function') {
7442
- let style;
7443
- const setStyle = function (_style) {
7444
- style = _style;
7445
- };
7446
- const content = config.bind(me)({
7447
- setStyle
7448
- });
7449
- return /*#__PURE__*/React.createElement(Tag, {
7450
- className: className,
7451
- style: style
7452
- }, content);
7453
- }
7454
- };
7416
+ // const FreeType=({tag:Tag,config,me,className})=>{
7417
+ // if(typeof config==='function'){
7418
+ // let style
7419
+ // const setStyle=function(_style){
7420
+ // style=_style
7421
+ // }
7422
+ // const content=config.bind(me)({setStyle})
7423
+ // return <Tag className={className} style={style}>{content}</Tag>
7424
+ // }
7425
+ // }
7426
+
7455
7427
  class JRFrame extends JRSubmit {
7456
7428
  renderer() {
7457
7429
  return /*#__PURE__*/React.createElement(StyledJRFrame, {
7458
7430
  style: this.props.style,
7459
7431
  className: `${this.props.className} jr-frame`
7460
- }, /*#__PURE__*/React.createElement(FreeType, {
7461
- tag: "div",
7462
- config: this.props.start,
7463
- me: this,
7464
- className: 'start'
7465
- }), /*#__PURE__*/React.createElement("main", null, /*#__PURE__*/React.createElement(FreeType, {
7466
- tag: "header",
7467
- config: this.props.top,
7468
- me: this
7469
- }), /*#__PURE__*/React.createElement("main", null, /*#__PURE__*/React.createElement(FreeType, {
7470
- tag: "div",
7471
- config: this.props.left,
7472
- me: this,
7473
- className: 'left'
7474
- }), this.renderMe(), /*#__PURE__*/React.createElement(FreeType, {
7475
- tag: "div",
7476
- config: this.props.right,
7477
- me: this,
7478
- className: 'right'
7479
- })), /*#__PURE__*/React.createElement(FreeType, {
7480
- tag: "footer",
7481
- config: this.props.bottom,
7482
- me: this
7483
- })), /*#__PURE__*/React.createElement(FreeType, {
7484
- tag: "div",
7485
- config: this.props.end,
7486
- me: this,
7487
- className: 'end'
7488
- }));
7432
+ }, this.renderMe());
7489
7433
  }
7490
7434
  renderMe() {
7491
7435
  return /*#__PURE__*/React.createElement("div", {
@@ -7496,853 +7440,16 @@ class JRFrame extends JRSubmit {
7496
7440
  }
7497
7441
  }
7498
7442
 
7499
- const StyledSlider = dt.div`
7500
- position: absolute;
7501
- top: 0;
7502
- right: 0;
7503
- height:100%;
7504
- width:6px;
7505
- user-select: none;
7506
- &.resizing:hover,&.resizing{
7507
- border-right:1px dashed black;
7508
- }
7509
- &:hover{
7510
- cursor: col-resize;
7511
- border-right:1px dashed gray;
7512
- }
7513
- `;
7514
- class Slider extends React.Component {
7515
- constructor() {
7516
- super();
7517
- this.sliderRef = /*#__PURE__*/React.createRef();
7518
- }
7519
- stop = e => {
7520
- this.sliderRef.current.classList.remove('resizing');
7521
- document.body.style.cursor = 'default';
7522
- window.removeEventListener('mousemove', this.move);
7523
- window.removeEventListener('mouseup', this.stop);
7524
- };
7525
- move = ({
7526
- clientX
7527
- }) => {
7528
- const {
7529
- th,
7530
- selectedCols,
7531
- widthRates
7532
- } = this.data;
7533
- const {
7534
- left
7535
- } = th.getBoundingClientRect();
7536
- const min = left + 10;
7537
- const x = clientX >= min ? clientX : min;
7538
- const width = x - left;
7539
- selectedCols.forEach((col, index) => {
7540
- const _width = Math.round(width / 100 * widthRates[index]);
7541
- col.style.width = _width + 'px';
7542
- });
7543
- };
7544
- start(thPRef, column) {
7545
- const selectedCols = [...this.props.table.colGroupRef.current.children].slice(column.columnNo, column.columnNo + (column.colSpan ?? 1));
7546
- const totalWidth = selectedCols.reduce((aco, {
7547
- offsetWidth
7548
- }) => aco + offsetWidth, 0);
7549
- const widthRates = selectedCols.map(({
7550
- offsetWidth
7551
- }) => {
7552
- return 100 * (offsetWidth / totalWidth);
7553
- });
7554
- this.data = {
7555
- selectedCols,
7556
- th: thPRef.current,
7557
- widthRates
7558
- };
7559
- this.sliderRef.current.classList.add('resizing');
7560
- document.body.style.cursor = 'col-resize';
7561
- window.addEventListener('mousemove', this.move);
7562
- window.addEventListener('mouseup', this.stop);
7563
- }
7564
- render() {
7565
- const column = this.props.column;
7566
- return /*#__PURE__*/React.createElement(StyledSlider, {
7567
- ref: this.sliderRef,
7568
- onMouseDown: e => {
7569
- this.start(this.props.thRef, column);
7570
- }
7571
- });
7572
- }
7573
- }
7574
-
7575
- const Colgroup = ({
7576
- leafColumns,
7577
- colGroupRef
7578
- }) => {
7579
- return /*#__PURE__*/React.createElement("colgroup", {
7580
- ref: colGroupRef
7581
- }, leafColumns?.map((_column, index) => {
7582
- const {
7583
- width,
7584
- ...column
7585
- } = _column;
7586
- const style = {
7587
- width
7588
- };
7589
- return /*#__PURE__*/React.createElement("col", {
7590
- style: style,
7591
- key: index
7592
- });
7593
- }));
7594
- };
7595
- const Ths$1 = ({
7596
- deep,
7597
- rowColumn,
7598
- rowIndex,
7599
- table
7600
- }) => {
7601
- return rowColumn?.map((column, colIndex) => {
7602
- const thRef = /*#__PURE__*/React.createRef();
7603
- return /*#__PURE__*/React.createElement("th", {
7604
- key: colIndex,
7605
- ref: thRef,
7606
- colSpan: column.colSpan,
7607
- rowSpan: column.rowSpan ?? (column.isLeaf && deep > rowIndex ? deep - rowIndex + 1 : null)
7608
- }, flexType(column.label, table), table.props.resizableColumns === true && /*#__PURE__*/React.createElement(Slider, {
7609
- table: table,
7610
- thRef: thRef,
7611
- column: column
7612
- }));
7613
- });
7614
- };
7615
- const HeadTrs = ({
7616
- columns: _columns,
7617
- trClassName,
7618
- table
7619
- }) => {
7620
- const columns = Array.isArray(_columns?.[0]) ? _columns : [_columns];
7621
- return columns?.map((rowColumn, rowIndex) => {
7622
- return /*#__PURE__*/React.createElement("tr", {
7623
- className: trClassName,
7624
- key: rowIndex
7625
- }, /*#__PURE__*/React.createElement(Ths$1, {
7626
- deep: columns.length - 1,
7627
- rowColumn: rowColumn,
7628
- rowIndex: rowIndex,
7629
- table: table
7630
- }));
7631
- });
7632
- };
7633
- const THead = ({
7634
- columns,
7635
- leafColumns,
7636
- table
7637
- }) => {
7638
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement(HeadTrs, {
7639
- columns: columns,
7640
- table: table
7641
- })), /*#__PURE__*/React.createElement(Colgroup, {
7642
- leafColumns: leafColumns,
7643
- colGroupRef: table.colGroupRef
7644
- }));
7645
- };
7646
- const FootThs = ({
7647
- table,
7648
- groupData,
7649
- groupIndex,
7650
- deep,
7651
- columns,
7652
- rowIndex
7653
- }) => {
7654
- return columns?.map((column, colIndex) => {
7655
- // let content
7656
- // if(type){
7657
- // content='type'
7658
- // }else if(render){
7659
-
7660
- // content=render?.bind(table)({groupData,groupIndex,ths:111})
7661
- // }else{
7662
- // content=column.label
7663
- // }
7664
- let style = flexType(column.style, table, {}, {});
7665
- const content = whatType(column, table, column.label);
7666
- return /*#__PURE__*/React.createElement("th", {
7667
- style: style,
7668
- colSpan: column.colSpan,
7669
- rowSpan: column.rowSpan
7670
- }, content);
7671
- });
7672
- };
7673
- const TFoot = ({
7674
- table,
7675
- columns
7676
- }) => {
7677
- const trs = columns?.map((rowColumn, rowIndex) => {
7678
- return /*#__PURE__*/React.createElement("tr", {
7679
- key: rowIndex
7680
- }, /*#__PURE__*/React.createElement(FootThs, {
7681
- columns: rowColumn,
7682
- table: table
7683
- }));
7684
- });
7685
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("tfoot", null, trs));
7686
- };
7687
-
7688
- function _extends() {
7689
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
7690
- for (var e = 1; e < arguments.length; e++) {
7691
- var t = arguments[e];
7692
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
7693
- }
7694
- return n;
7695
- }, _extends.apply(null, arguments);
7696
- }
7697
-
7698
- dt.tbody`
7699
- th{
7700
- height:4px;
7701
- background:#c6c6c6;
7702
- }
7703
- `;
7704
-
7705
- ////////////////////////////////////////////////////////////////////////////
7706
-
7707
- const Ths = ({
7708
- table,
7709
- groupData,
7710
- groupIndex,
7711
- deep,
7712
- rowColumn,
7713
- rowIndex
7714
- }) => {
7715
- return rowColumn?.map(({
7716
- style: _style,
7717
- align,
7718
- type,
7719
- render,
7720
- ...column
7721
- }, colIndex) => {
7722
- const style = flexType(_style, table, {}, {});
7723
- let content;
7724
- if (type) {
7725
- content = 'type';
7726
- } else if (render) {
7727
- content = render?.bind(table)({
7728
- groupData,
7729
- groupIndex,
7730
- ths: 111
7731
- });
7732
- } else {
7733
- content = column.label;
7734
- }
7735
- // style.textAlign=align
7736
- return /*#__PURE__*/React.createElement("th", {
7737
- key: colIndex,
7738
- style: {
7739
- textAlign: align,
7740
- ...style
7741
- },
7742
- colSpan: column.colSpan,
7743
- rowSpan: column.isLeaf && deep > rowIndex ? deep - rowIndex + 1 : null
7744
- }, content);
7745
- });
7746
- };
7747
- const GroupColumns = ({
7748
- table,
7749
- columns: _columns,
7750
- trClassName,
7751
- groupData,
7752
- tbodyIndex
7753
- }) => {
7754
- const columns = Array.isArray(_columns?.[0]) ? _columns : [_columns];
7755
- return columns?.map((rowColumn, rowIndex) => {
7756
- return /*#__PURE__*/React.createElement("tr", {
7757
- className: trClassName,
7758
- key: rowIndex
7759
- }, /*#__PURE__*/React.createElement(Ths, {
7760
- table: table,
7761
- groupData: groupData,
7762
- groupIndex: tbodyIndex,
7763
- deep: columns.length - 1,
7764
- rowColumn: rowColumn,
7765
- rowIndex: rowIndex
7766
- }));
7767
- });
7768
- };
7769
- dt.tr`
7770
- z-index: 1;
7771
- XXposition: sticky;
7772
- XXtop: 50px;
7773
- th{
7774
- text-align: left;
7775
- border:1px solid #222222;
7776
- }
7777
- `;
7778
- const GroupHeader = props => {
7779
- return /*#__PURE__*/React.createElement(GroupColumns, _extends({
7780
- trClassName: 'jr-group-header'
7781
- }, props));
7782
- };
7783
- dt.tr`
7784
- th{
7785
- border:1px solid #222222;
7786
- text-align: left;
7787
- }
7788
- `;
7789
- const GroupFooter = props => {
7790
- return /*#__PURE__*/React.createElement(GroupColumns, _extends({
7791
- trClassName: 'jr-group-footer'
7792
- }, props));
7793
- };
7794
-
7795
- ////////////////////////////////////////////////////////////////////////////
7796
- const Td = ({
7797
- column: _column,
7798
- record,
7799
- tbodyIndex,
7800
- trIndex,
7801
- tdIndex,
7802
- table
7803
- }) => {
7804
- let content;
7805
- const {
7806
- style: _style,
7807
- align,
7808
- vAlign = 'baseline',
7809
- type,
7810
- typeStyle: _typeStyle,
7811
- render,
7812
- setValue,
7813
- getValue,
7814
- onChange: _onChange,
7815
- funcProps,
7816
- ...column
7817
- } = _column;
7818
- const onChange = inputValue => {
7819
- const targetValue = inputValue?.target?.value ?? inputValue;
7820
- setValue(record, targetValue);
7821
- table.setValue(table.getValue());
7822
- };
7823
- const value = getValue(record);
7824
- let style = render ? {} : flexType(_style, table, {
7825
- value,
7826
- record
7827
- }, {});
7828
- const setStyle = _style => {
7829
- style = _style;
7830
- };
7831
- setStyle.bind(undefined);
7832
- render?.bind(table);
7833
- if (type) {
7834
- const typeStyle = flexType(_typeStyle, table, {
7835
- record
7836
- }, {});
7837
- content = /*#__PURE__*/React.createElement(type, {
7838
- onChange: _onChange ? e => {
7839
- _onChange?.bind(undefined)(e, {
7840
- value,
7841
- onChange,
7842
- me: content
7843
- });
7844
- } : onChange,
7845
- value,
7846
- style: typeStyle,
7847
- render,
7848
- ...column,
7849
- ...funcProps?.bind(undefined)({
7850
- value
7851
- })
7852
- });
7853
- } else if (render) {
7854
- content = render({
7855
- index: trIndex,
7856
- groupIndex: tbodyIndex,
7857
- value,
7858
- record,
7859
- onChange,
7860
- setStyle
7861
- });
7862
- } else {
7863
- content = value;
7864
- }
7865
- return /*#__PURE__*/React.createElement("td", {
7866
- colSpan: style.colSpan,
7867
- rowSpan: style.rowSpan,
7868
- style: {
7869
- textAlign: align,
7870
- verticalAlign: vAlign,
7871
- ...style
7872
- },
7873
- key: tdIndex
7874
- }, content);
7875
- };
7876
- const Tds = ({
7877
- leafColumns,
7878
- record,
7879
- table,
7880
- tbodyIndex,
7881
- trIndex
7882
- }) => {
7883
- return leafColumns?.map((column, tdIndex) => {
7884
- return /*#__PURE__*/React.createElement(Td, {
7885
- column: column,
7886
- key: tdIndex,
7887
- record: record,
7888
- table: table,
7889
- tbodyIndex: tbodyIndex,
7890
- trIndex: trIndex,
7891
- tdIndex: tdIndex
7892
- });
7893
- });
7894
- };
7895
- ////////////////////////////////////////////////////////////////////////////
7896
-
7897
- const TBody = ({
7898
- groupData,
7899
- groupHeader,
7900
- leafColumns,
7901
- groupFooter,
7902
- table,
7903
- tbodyIndex
7904
- }) => {
7905
- const neededProps = {
7906
- table,
7907
- tbodyIndex
7908
- };
7909
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("tbody", {
7910
- key: `tbody${tbodyIndex}`
7911
- }, groupData?.length > 0 && /*#__PURE__*/React.createElement(GroupHeader, _extends({
7912
- groupData: groupData,
7913
- columns: groupHeader
7914
- }, neededProps)), groupData?.map((record, trIndex) => {
7915
- const onRowClick = table.props.onRowClick?.bind(table);
7916
- return /*#__PURE__*/React.createElement("tr", {
7917
- key: trIndex,
7918
- onClick: () => {
7919
- onRowClick?.({
7920
- record,
7921
- index: trIndex,
7922
- groupIndex: tbodyIndex
7923
- });
7924
- }
7925
- }, /*#__PURE__*/React.createElement(Tds, _extends({
7926
- record: record,
7927
- trIndex: trIndex
7928
- }, neededProps, {
7929
- leafColumns: leafColumns
7930
- })));
7931
- }), groupData?.length > 0 && /*#__PURE__*/React.createElement(GroupFooter, _extends({
7932
- groupData: groupData,
7933
- columns: groupFooter
7934
- }, neededProps))));
7935
- };
7936
- const TBodies = ({
7937
- groupHeader,
7938
- leafColumns,
7939
- groupFooter,
7940
- dataSource: _dataSource,
7941
- table
7942
- }) => {
7943
- // po('--TBodies--')
7944
- const isGroupDataType = Array.isArray(_dataSource?.[0]);
7945
- const dataSource = isGroupDataType ? _dataSource : [_dataSource];
7946
-
7947
- // po('dataSource',dataSource)
7948
- return dataSource?.map((groupData, tbodyIndex, c) => {
7949
- return /*#__PURE__*/React.createElement(TBody, {
7950
- key: `tbody${tbodyIndex}`,
7951
- table: table
7952
- // dataSource={dataSource}
7953
- // dataGroup={groupData}
7954
- ,
7955
- groupData: groupData,
7956
- tbodyIndex: tbodyIndex,
7957
- groupHeader: groupHeader,
7958
- leafColumns: leafColumns,
7959
- groupFooter: groupFooter
7960
- });
7961
- });
7962
- };
7963
-
7964
- const StyledJRTable = dt.div`
7965
- --column-bd-color:#cccccc;
7966
- --column-b-color:#eeeeee;
7967
- --column-b-hover-color:#ffffff;
7968
-
7969
- position: relative;
7970
- background: var(--column-b-color);
7971
- border:1px solid var(--column-bd-color);
7972
-
7973
- display:flex;
7974
- flex-direction: column;
7975
- flex:1;
7976
- overflow: overlay;
7977
-
7978
-
7979
-
7980
-
7981
- &.row-highlightable{
7982
- tbody{
7983
- tr:not(.jr-group-header,.jr-group-footer):hover{
7984
- background:var(--column-b-hover-color);
7985
- cursor: pointer;
7986
- transition: background-color .8s;
7987
- td{
7988
- color:black;
7989
- transition:color .8s;
7990
- }
7991
-
7992
- }
7993
- }
7994
- }
7995
-
7996
- table{
7997
- Xheight: 100%;
7998
- min-width:100%;
7999
- width: max-content;
8000
- border-spacing: 0;
8001
-
8002
- thead{
8003
- position: sticky;
8004
- top: 0;
8005
-
8006
- th{
8007
- position: relative;
8008
- height:32px;
8009
- padding: 4px;
8010
- background: linear-gradient(180deg, rgba(227, 227, 226, 1) 0%, rgba(255, 255, 255, 1) 25%, rgba(210, 210, 210, 1) 100%);
8011
- box-shadow: 2px 2px 2px 0 #ffffffd6 inset, -1px -1px 2px 0px #8a847dbf inset;
8012
- color: #525252;
8013
- white-space: nowrap;
8014
- }
8015
- }
8016
-
8017
- tfoot{
8018
- position: sticky;
8019
- bottom: -1px;
8020
-
8021
- Xtr:nth-child(1){
8022
- th{
8023
- Xborder-top:1px solid var(--column-bd-color);
8024
- }
8025
- }
8026
- Xth:nth-child(1){
8027
- Xborder-left:1px solid var(--column-bd-color);
8028
- }
8029
-
8030
- th{
8031
- height:32px;
8032
- padding: 4px;
8033
- background: #e4e4e4;
8034
- xbackground: linear-gradient(180deg, rgba(227, 227, 226, 1) 0%, rgba(255, 255, 255, 1) 25%, rgba(210, 210, 210, 1) 100%);
8035
- xbox-shadow: 2px 2px 2px 0 #ffffffd6 inset, -1px -1px 2px 0px #8a847dbf inset;
8036
- color: #525252;
8037
- white-space: nowrap;
8038
-
8039
- border-left:2px solid #f4f4f4;
8040
- border-top:2px solid #f4f4f4;
8041
- border-right:2px solid var(--column-bd-color);
8042
- border-bottom:2px solid var(--column-bd-color);
8043
- }
8044
- }
8045
-
8046
- tbody{
8047
- tr{
8048
- transition: background .3s linear;
8049
- background:var(--column-b-color);
8050
- a:#ededed;
8051
- th{
8052
- color:#444444;
8053
- }
8054
- td{
8055
- border-bottom: 1px solid var(--column-bd-color);
8056
- color:#2e2e2e;
8057
- padding: 4px;
8058
- }
8059
- }
8060
- tr:hover{
8061
- background:var(--column-b-hover-color);
8062
-
8063
- }
8064
-
8065
- tr.jr-group-header
8066
- ,tr.jr-group-footer{
8067
- text-align:left;
8068
- background:#dddbdb;
8069
-
8070
- th{
8071
- border-bottom: 1px solid var(--column-bd-color);
8072
- border-right: 1px solid var(--column-bd-color);
8073
- padding: 4px 8px;
8074
- }
8075
- }
8076
- }
8077
- tbody.empty-tbody{
8078
- td{
8079
- border:10px solid red;
8080
- }
8081
- }
8082
- }
8083
-
8084
-
8085
-
8086
-
8087
- > .empty{
8088
- user-select: none;
8089
- color:#848484;
8090
- height:100%;
8091
- flex:1;
8092
- display:flex;
8093
- justify-content: center;
8094
- align-items: center;
8095
- }
8096
- `;
8097
-
8098
- // import JRFrame from "../JRFrame/JRFrame";
8099
-
8100
- const getMapObject = (map, names) => {
8101
- const name = names.shift(names);
8102
- if (names.length) {
8103
- return getMapObject(map?.[name], names);
8104
- } else {
8105
- return map;
8106
- }
8107
- };
8108
- const setMapObject = (map, names, value) => {
8109
- const name = names.shift(names);
8110
- if (names?.length) {
8111
- if (typeof map[name] != 'object') {
8112
- map[name] = {};
8113
- }
8114
- setMapObject(map[name], names, value);
8115
- } else {
8116
- map[name] = value;
8117
- }
8118
- };
8119
- class JRTable extends JRSubmit {
8120
- constructor(props) {
8121
- super(props);
8122
- this.colGroupRef = /*#__PURE__*/React.createRef();
8123
- }
8124
- UNSAFE_componentWillMount() {
8125
- this.setColumns(this.props.columns);
8126
- }
8127
-
8128
- //------------------------------------------------------------------------------------
8129
- getChecked() {
8130
- return [1, 2, 3, 4];
8131
- }
8132
- checkableColumn(props) {
8133
- return {
8134
- //方法1
8135
- render({
8136
- value,
8137
- onChange
8138
- }) {
8139
- return /*#__PURE__*/React.createElement("checkbox", {
8140
- checked: value,
8141
- onChange: e => {
8142
- onChange(e.target.checked);
8143
- }
8144
- });
8145
- },
8146
- align: 'center',
8147
- name: 'checked',
8148
- ...props
8149
- };
8150
- // return {//方法2
8151
- // type:Checkbox
8152
- // ,funcProps({value}){
8153
- // po('fffffffffffff',value)
8154
- // return {
8155
- // align:'center'
8156
- // ,checked:value
8157
- // }
8158
- // }
8159
- // // ,label:'A'
8160
- // ,onChange(e,{value,onChange,me}){
8161
- // onChange(e.target.checked)
8162
- // }
8163
- // ,...props
8164
- // }
8165
- }
8166
- deletableColumn({
8167
- name = 'deletable',
8168
- sendValue,
8169
- sendName,
8170
- valueName,
8171
- ...props
8172
- }) {
8173
- return {
8174
- render({
8175
- value,
8176
- onChange
8177
- }) {
8178
- return /*#__PURE__*/React.createElement("checkbox", {
8179
- checked: value,
8180
- onChange: e => {
8181
- onChange(e.target.checked);
8182
- }
8183
- });
8184
- },
8185
- align: 'center',
8186
- name,
8187
- label() {
8188
- return /*#__PURE__*/React.createElement("button", {
8189
- onClick: () => {
8190
- const value = this.props.delete.value ?? this.getDataSource()?.filter(record => record[name]).map(record => sendValue ? record[sendValue] : record);
8191
- const callback = this.props.delete.callback ?? function (a, b, c) {
8192
- this.reload();
8193
- };
8194
- this.delete({
8195
- value: sendName ? {
8196
- [sendName]: value
8197
- } : value,
8198
- callback,
8199
- ...props
8200
- });
8201
- }
8202
- }, "\u522A\u9664");
8203
- },
8204
- ...props
8205
- };
8206
- }
8207
- initColumn(column, level, result, leafColumns, names, lastColSpan) {
8208
- const isBranch = column.type === undefined && column?.columns && column?.columns.length;
8209
- const _names = column.name ? [...names, column.name] : names;
8210
- if (isBranch) {
8211
- if (column.label !== null) result[level].push(column);
8212
- const c = this.initColumns(column.columns, level + (column.label !== null ? 1 : 0) + (column.rowSpan != null ? column.rowSpan - 1 : 0), result, leafColumns, _names, lastColSpan);
8213
- column.colSpan = c.colSpan;
8214
- column.columnNo = lastColSpan;
8215
- return {
8216
- colSpan: column.colSpan
8217
- };
8218
- } else {
8219
- column.columnNo = lastColSpan;
8220
- result[level].push({
8221
- ...column,
8222
- isLeaf: true
8223
- });
8224
- leafColumns.push(column);
8225
- column.names = _names;
8226
- if (_names?.length > 1) {
8227
- column.setValue = function (record, value) {
8228
- try {
8229
- getMapObject(record, [..._names])[column.name] = value;
8230
- } catch {
8231
- setMapObject(record, [..._names], value);
8232
- }
8233
- };
8234
- column.getValue = function (record) {
8235
- return _names.reduce((acc, name) => {
8236
- return acc?.[name];
8237
- }, record);
8238
- };
8239
- } else {
8240
- column.setValue = function (record, value) {
8241
- record[column.name] = value;
8242
- };
8243
- column.getValue = function (record) {
8244
- return record[column.name];
8245
- };
8246
- }
8247
- return {
8248
- colSpan: 1
8249
- };
8250
- }
8251
- }
8252
- initColumns(columns, level, result, leafColumns, names, lastColSpan) {
8253
- for (let i = result.length; i <= level; i++) {
8254
- if (!result[i]) {
8255
- result.push([]);
8256
- }
8257
- }
8258
- let _lastColSpan = lastColSpan;
8259
- const childrenLength = columns?.reduce((acc, column) => {
8260
- const c = this.initColumn(column, level, result, leafColumns, names, _lastColSpan);
8261
- acc.colSpan += c.colSpan;
8262
- _lastColSpan += c.colSpan;
8263
- return acc;
8264
- }, {
8265
- colSpan: 0
8266
- });
8267
- return childrenLength;
8268
- }
8269
- setColumns([..._columns]) {
8270
- if (this.props.checkable) _columns.unshift(this.checkableColumn(this.props.checkable));
8271
- if (this.props.deletable) {
8272
- _columns.unshift(this.deletableColumn(this.props.deletable));
8273
- }
8274
- const columns = [];
8275
- const leafColumns = [];
8276
- this.initColumns(_columns, 0, columns, leafColumns, [], 0);
8277
- // po('initColumns',initColumns)
8278
- this.setState({
8279
- columns,
8280
- leafColumns
8281
- });
8282
- }
8283
- //------------------------------------------------------------------------------------
8284
- setDataSource(dataSource) {}
8285
- getDataSource() {
8286
- return this.props.dataSourceName ? this.getValue()?.[this.props.dataSourceName] : this.getValue();
8287
- }
8288
- add(record, index = this.getDataSource()?.length ?? 0, group) {
8289
- //group 還沒有考慮到
8290
-
8291
- if (this.getDataSource()) {
8292
- if (group === undefined) {
8293
- this.getDataSource().splice(index, 0, record); //.push(record)
8294
- } else {
8295
- this.getDataSource()[group].splice(index, 0, record); //.push(record)
8296
- }
8297
- this.setValue(this.getValue());
8298
- } else {
8299
- //未完成. 沒有資料的時候, 要考慮有或沒有dataSourceName的不同處理
8300
- this.setValue({
8301
- [this.props.dataSourceName]: [record]
8302
- });
8303
- }
8304
- }
8305
- noData() {
8306
- const data = this.getDataSource();
8307
- return data == null || data.length == 0;
8308
- }
8309
- //------------------------------------------------------------------------------------
8310
- renderMe() {
8311
- return /*#__PURE__*/React.createElement(StyledJRTable, {
8312
- className: `${this.props.className ?? ''} jr-table ${this.props.onRowClick ? 'row-highlightable' : ''}`
8313
- }, /*#__PURE__*/React.createElement("table", {
8314
- className: 'jr-table-table'
8315
- }, /*#__PURE__*/React.createElement(TBodies, {
8316
- table: this,
8317
- leafColumns: this.state.leafColumns,
8318
- groupHeader: this.props.groupHeader,
8319
- groupFooter: this.props.groupFooter,
8320
- dataSource: this.getDataSource(),
8321
- onRowClick: this.props.onRowClick
8322
- }), /*#__PURE__*/React.createElement(TFoot, {
8323
- columns: this.props.footColumns,
8324
- table: this
8325
- }), /*#__PURE__*/React.createElement(THead, {
8326
- columns: this.state.columns,
8327
- leafColumns: this.state.leafColumns,
8328
- table: this
8329
- })), /*#__PURE__*/React.createElement("div", {
8330
- className: 'empty'
8331
- }, this.noData() && '無資料'));
8332
- }
8333
- }
8334
-
8335
7443
  function JRTest() {
8336
7444
  return 'I am JRTest string';
8337
7445
  }
8338
- class JRTestReact extends React.Component {
8339
- render() {
8340
- return /*#__PURE__*/React.createElement("div", null, "JRTestReact");
7446
+ class JRTestReact extends JRSubmit {
7447
+ renderer() {
7448
+ return /*#__PURE__*/React.createElement("div", null, "JRTestReact extends JRSubmit");
8341
7449
  }
8342
7450
  }
8343
7451
 
8344
7452
  exports.JRFrame = JRFrame;
8345
7453
  exports.JRSubmit = JRSubmit;
8346
- exports.JRTable = JRTable;
8347
7454
  exports.JRTest = JRTest;
8348
7455
  exports.JRTestReact = JRTestReact;