@kne/super-select 0.1.27 → 0.1.28

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.
@@ -15,6 +15,8 @@ import 'simplebar-react/dist/simplebar.min.css';
15
15
  import SearchInput from '@kne/search-input';
16
16
  import { FetchScrollLoader } from '@kne/scroll-loader';
17
17
  import '@kne/scroll-loader/dist/index.css';
18
+ import { TableView } from '@kne/info-page';
19
+ import '@kne/info-page/dist/index.css';
18
20
  import memoize from 'lodash/memoize';
19
21
  import isNil from 'lodash/isNil';
20
22
  import Fetch from '@kne/react-fetch';
@@ -53,7 +55,8 @@ const locale$1 = {
53
55
  search: '搜索',
54
56
  numberOf: '{number}个',
55
57
  maxLengthError: '最大数量不能超过{maxLength}',
56
- defaultChildren: '下拉内容,需要调用方实现'
58
+ defaultChildren: '下拉内容,需要调用方实现',
59
+ removeAll: '移除全部'
57
60
  };
58
61
 
59
62
  const locale = {
@@ -63,7 +66,8 @@ const locale = {
63
66
  search: 'Search',
64
67
  numberOf: '{number} items',
65
68
  maxLengthError: 'The maximum number cannot exceed {maxLength}',
66
- defaultChildren: 'Dropdown content, to be implemented by the caller'
69
+ defaultChildren: 'Dropdown content, to be implemented by the caller',
70
+ removeAll: 'Remove All'
67
71
  };
68
72
 
69
73
  const _excluded$2 = ["children"];
@@ -683,7 +687,7 @@ const SelectList = forwardRef((_ref, ref) => {
683
687
  });
684
688
  });
685
689
 
686
- var style$1 = {"list":"_DrEYJ","is-popup":"_KgWTX","empty":"_5Tyrt","body":"_704J1","header":"_Vmbrg","col":"_dJmfs","is-selected-all":"_qU5zU","is-selected":"_MzyWg","is-disabled":"_5luTv","right-options":"_UXi-g","no-padding-btn":"_iaCir","tag":"_JkYqS","tag-inner":"_VZlBL","single-checked":"_Eiz-u","select-search":"_temy6","tags-search":"_7phL2","descriptions":"_ttNK9","descriptions-col-label":"_xU-i7","descriptions-col-content":"_SvfzQ","footer":"_lISfA"};
690
+ var style$1 = {"list":"_DrEYJ","is-popup":"_KgWTX","empty":"_5Tyrt","table":"_zE-14","right-options":"_UXi-g","no-padding-btn":"_iaCir","tag":"_JkYqS","tag-inner":"_VZlBL","single-checked":"_Eiz-u","select-search":"_temy6","tags-search":"_7phL2","descriptions":"_ttNK9","descriptions-col-label":"_xU-i7","descriptions-col-content":"_SvfzQ","footer":"_lISfA"};
687
691
 
688
692
  const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select')(forwardRef((p, ref) => {
689
693
  const {
@@ -789,133 +793,73 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
789
793
  [style$1['single-body']]: single
790
794
  }),
791
795
  span: single ? 24 : 16
792
- }, /*#__PURE__*/React.createElement("div", null, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React.createElement(Row, {
793
- wrap: false,
794
- className: classnames(style$1['header'], 'select-table-list-header')
795
- }, !single && /*#__PURE__*/React.createElement(Col, {
796
- className: classnames(style$1['col'], 'select-table-list-col')
797
- }, allowSelectedAll ? /*#__PURE__*/React.createElement(Checkbox, {
798
- checked: isSelectedAll,
799
- onChange: e => {
800
- const checked = e.target.checked;
801
- if (!checked) {
802
- setValue([]);
803
- } else {
804
- setValue([selectedAllValue]);
805
- }
806
- }
807
- }) : /*#__PURE__*/React.createElement(Checkbox, {
808
- style: {
809
- visibility: 'hidden'
810
- }
811
- })), /*#__PURE__*/React.createElement(Col, {
812
- flex: 1
813
- }, /*#__PURE__*/React.createElement(Row, {
814
- wrap: false
815
- }, columns.map(column => {
816
- const {
817
- name,
818
- title,
819
- span
820
- } = column;
821
- return /*#__PURE__*/React.createElement(Col, {
822
- key: name,
823
- span: span,
824
- className: classnames(style$1['col'], 'select-table-list-col')
825
- }, title);
826
- })))), /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
827
- className: classnames(style$1['list'], 'select-table-list-scroll-list', {
828
- 'is-popup': isPopup
829
- }),
830
- searchProps: searchProps,
831
- getSearchProps: getSearchProps,
832
- api: Object.assign({}, options ? {
833
- data: {
834
- options,
835
- searchProps
796
+ }, /*#__PURE__*/React.createElement("div", null, filterRender(Object.assign({}, targetProps))), /*#__PURE__*/React.createElement("div", {
797
+ className: classnames(style$1['table'], 'select-table')
798
+ }, /*#__PURE__*/React.createElement(TableView, {
799
+ columns: columns,
800
+ rowKey: valueKey,
801
+ rowSelection: {
802
+ allowSelectedAll,
803
+ isSelectedAll,
804
+ onIsSelectAllChange: isSelectedAll => {
805
+ setValue(isSelectedAll ? [selectedAllValue] : []);
836
806
  },
837
- loader: ({
838
- data
839
- }) => {
840
- const {
841
- options,
842
- searchProps
843
- } = data;
844
- if (typeof getSearchCallback === 'function') {
845
- const newOptions = options.filter(item => getSearchCallback(searchProps, item, targetProps));
846
- return {
847
- pageData: newOptions
848
- };
807
+ type: single ? 'radio' : 'checkbox',
808
+ selectedRowKeys: (value || []).map(item => item[valueKey]),
809
+ onChange: (selectedRowKeys, selectedRows) => {
810
+ setValue(selectedRows);
811
+ if (isPopup && single) {
812
+ onOpenChange(false);
849
813
  }
850
- return {
851
- pageData: options
852
- };
853
814
  }
854
- } : api),
855
- ref: fetchListRef
856
- }), fetchProps => {
857
- const {
858
- list
859
- } = fetchProps;
860
- const contextProps = Object.assign({}, fetchProps, targetProps, {
861
- isSelectedAll
862
- });
863
- if (!(list && list.length > 0)) {
864
- return props.empty || /*#__PURE__*/React.createElement(Empty, {
865
- className: classnames(style$1['empty'], style$1['body'], 'select-table-list-body')
866
- });
867
- }
868
- return list.map(item => {
869
- const isChecked = value.some(target => target[valueKey] === item[valueKey]);
870
- return /*#__PURE__*/React.createElement(Row, {
871
- wrap: false,
872
- key: item[valueKey],
873
- className: classnames(style$1['body'], 'select-table-list-body', [{
874
- [style$1['is-selected-all']]: isSelectedAll,
875
- [style$1['is-selected']]: isChecked,
876
- [style$1['is-disabled']]: item.disabled
877
- }]),
878
- onClick: () => {
879
- if (item.disabled) {
880
- return;
881
- }
882
- if (isSelectedAll) {
883
- return;
884
- }
885
- if (single) {
886
- setValue([item]);
887
- } else {
888
- onSelect(item);
889
- }
890
- if (isPopup && single) {
891
- onOpenChange(false);
815
+ },
816
+ render: ({
817
+ header,
818
+ renderBody
819
+ }) => {
820
+ return /*#__PURE__*/React.createElement(React.Fragment, null, header, /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
821
+ className: classnames(style$1['list'], 'select-table-list-scroll-list', {
822
+ 'is-popup': isPopup
823
+ }),
824
+ searchProps: searchProps,
825
+ getSearchProps: getSearchProps,
826
+ api: Object.assign({}, options ? {
827
+ data: {
828
+ options,
829
+ searchProps
830
+ },
831
+ loader: ({
832
+ data
833
+ }) => {
834
+ const {
835
+ options,
836
+ searchProps
837
+ } = data;
838
+ if (typeof getSearchCallback === 'function') {
839
+ const newOptions = options.filter(item => getSearchCallback(searchProps, item, targetProps));
840
+ return {
841
+ pageData: newOptions
842
+ };
843
+ }
844
+ return {
845
+ pageData: options
846
+ };
892
847
  }
893
- }
894
- }, !single && /*#__PURE__*/React.createElement(Col, {
895
- className: classnames(style$1['col'], 'select-table-list-col')
896
- }, /*#__PURE__*/React.createElement(Checkbox, {
897
- disabled: item.disabled || isSelectedAll,
898
- checked: isSelectedAll || isChecked
899
- })), /*#__PURE__*/React.createElement(Col, {
900
- flex: 1
901
- }, /*#__PURE__*/React.createElement(Row, {
902
- wrap: false
903
- }, columns.map(column => {
848
+ } : api),
849
+ ref: fetchListRef
850
+ }), fetchProps => {
904
851
  const {
905
- name,
906
- span,
907
- getValueOf
908
- } = column;
909
- return /*#__PURE__*/React.createElement(Col, {
910
- key: name,
911
- span: span,
912
- className: classnames(style$1['col'], 'select-table-list-col')
913
- }, typeof getValueOf === 'function' ? getValueOf(item, contextProps) : get(item, name));
914
- }))), single && /*#__PURE__*/React.createElement(Col, {
915
- className: classnames(style$1['col'], style$1['single-checked'], 'select-table-list-col')
916
- }, isChecked && /*#__PURE__*/React.createElement(CheckOutlined, null)));
917
- });
918
- }), single && footerEl || /*#__PURE__*/React.createElement("div", {
852
+ list
853
+ } = fetchProps;
854
+ if (!(list && list.length > 0)) {
855
+ return props.empty || /*#__PURE__*/React.createElement(Empty, {
856
+ className: classnames(style$1['empty'])
857
+ });
858
+ }
859
+ return renderBody(list);
860
+ }));
861
+ }
862
+ })), single && footerEl || /*#__PURE__*/React.createElement("div", {
919
863
  className: classnames(style$1['footer'], 'select-table-footer')
920
864
  })), !single && /*#__PURE__*/React.createElement(Col, {
921
865
  className: classnames(style$1['right-options'], {
@@ -942,7 +886,9 @@ const SelectTableList = createWithIntlProvider('zh-CN', locale$1, 'super-select'
942
886
  onClick: () => {
943
887
  setValue([]);
944
888
  }
945
- }, "\u79FB\u9664\u5168\u90E8"))), /*#__PURE__*/React.createElement(SimpleBar, null, /*#__PURE__*/React.createElement(Flex, {
889
+ }, formatMessage({
890
+ id: 'removeAll'
891
+ })))), /*#__PURE__*/React.createElement(SimpleBar, null, /*#__PURE__*/React.createElement(Flex, {
946
892
  wrap: true,
947
893
  gap: 8
948
894
  }, value.filter(item => getTagSearchCallback(tagSearchText, item, targetProps)).map(item => {