@kne/super-select 0.1.4 → 0.1.6

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.
@@ -3,7 +3,7 @@ import { createContext } from '@kne/global-context';
3
3
  import useResize from '@kne/use-resize';
4
4
  import useControlValue from '@kne/use-control-value';
5
5
  import classnames from 'classnames';
6
- import { Modal, App, Popover, Flex, Tag, Checkbox, List } from 'antd';
6
+ import { Modal, App, Dropdown, Flex, Tag, Checkbox, List } from 'antd';
7
7
  import { CloseCircleFilled, DownOutlined, CheckOutlined } from '@ant-design/icons';
8
8
  import SimpleBar from 'simplebar-react';
9
9
  import 'simplebar-react/dist/simplebar.min.css';
@@ -2240,7 +2240,7 @@ function isEqual(value, other) {
2240
2240
 
2241
2241
  var isEqual_1 = isEqual;
2242
2242
 
2243
- var style$3 = {"select-input":"_d8lGc","disabled":"_3kjwO","wrap":"_dsTM2","select-input-inner":"_NQoX9","large":"_T8ZX8","small":"_1B72H","select-input-icon":"_g8QC-","placeholder":"_r3q69","overlay-content":"_zEqGe","overlay":"_ybN30"};
2243
+ var style$3 = {"select-input":"_d8lGc","disabled":"_3kjwO","wrap":"_dsTM2","select-input-inner":"_NQoX9","large":"_T8ZX8","small":"_1B72H","select-input-icon":"_g8QC-","placeholder":"_r3q69","overlay-content":"_zEqGe","overlay":"_ybN30","select-input-prefix":"_4Pw75","select-input-suffix":"_Wd4pE"};
2244
2244
 
2245
2245
  const _excluded$1 = ["children"];
2246
2246
  const numberToPx = val => {
@@ -2307,6 +2307,8 @@ const SelectInput = p => {
2307
2307
  labelWrap: true,
2308
2308
  showSelectedTag: true,
2309
2309
  allowClear: true,
2310
+ prefix: null,
2311
+ suffix: null,
2310
2312
  extra: null,
2311
2313
  renderModal: contextProps => {
2312
2314
  const {
@@ -2346,6 +2348,8 @@ const SelectInput = p => {
2346
2348
  });
2347
2349
  const {
2348
2350
  children,
2351
+ prefix,
2352
+ suffix,
2349
2353
  className,
2350
2354
  maxLength,
2351
2355
  overlayClassName,
@@ -2422,7 +2426,12 @@ const SelectInput = p => {
2422
2426
  onMouseOut: () => {
2423
2427
  setHover(false);
2424
2428
  }
2425
- }), /*#__PURE__*/React.createElement("div", {
2429
+ }), prefix && /*#__PURE__*/React.createElement("span", {
2430
+ className: classnames(style$3['select-input-prefix'], 'select-input-prefix'),
2431
+ onClick: e => {
2432
+ e.stopPropagation();
2433
+ }
2434
+ }, prefix), /*#__PURE__*/React.createElement("div", {
2426
2435
  className: classnames(style$3['select-input-inner'], 'select-input-inner')
2427
2436
  }, value.length > 0 ? single || value[0].value === selectedAllValue.value ? value[0].label : value.map(item => {
2428
2437
  return /*#__PURE__*/React.createElement(Tag, {
@@ -2443,7 +2452,12 @@ const SelectInput = p => {
2443
2452
  e.stopPropagation();
2444
2453
  setValue([]);
2445
2454
  }
2446
- }) : /*#__PURE__*/React.createElement(DownOutlined, null)));
2455
+ }) : /*#__PURE__*/React.createElement(DownOutlined, null)), suffix && /*#__PURE__*/React.createElement("span", {
2456
+ className: classnames(style$3['select-input-suffix'], 'select-input-suffix'),
2457
+ onClick: e => {
2458
+ e.stopPropagation();
2459
+ }
2460
+ }, suffix));
2447
2461
  const contextProps = {
2448
2462
  props,
2449
2463
  value: value,
@@ -2461,15 +2475,14 @@ const SelectInput = p => {
2461
2475
  };
2462
2476
  return /*#__PURE__*/React.createElement(Provider, {
2463
2477
  value: contextProps
2464
- }, isPopup ? /*#__PURE__*/React.createElement(Popover, {
2478
+ }, isPopup ? /*#__PURE__*/React.createElement(Dropdown, {
2465
2479
  open: !disabled && open,
2466
2480
  onOpenChange: setOpen,
2467
2481
  placement: placement,
2468
2482
  arrow: false,
2469
- transitionName: "",
2470
2483
  overlayClassName: classnames(style$3['overlay'], overlayClassName),
2471
2484
  trigger: "click",
2472
- content: /*#__PURE__*/React.createElement("div", {
2485
+ dropdownRender: () => /*#__PURE__*/React.createElement("div", {
2473
2486
  style: {
2474
2487
  '--overlay-width': popupOverlayWidth
2475
2488
  },
@@ -2872,7 +2885,7 @@ const computedIsSelectAll = (value, selectedAllValue) => {
2872
2885
  return (value == null ? void 0 : value.length) === 1 && get_1(value, '[0].value') === selectedAllValue.value;
2873
2886
  };
2874
2887
 
2875
- var style$1 = {"label":"_l3KoW","tag-list":"_CCPzb","tag-container":"_dKZHi","tag-container-inner":"_oijCI"};
2888
+ var style$1 = {"label":"_l3KoW","tag-list":"_CCPzb","tag-container":"_dKZHi","tag-container-inner":"_oijCI","tag":"_WmnnS","tag-inner":"_TMcFl"};
2876
2889
 
2877
2890
  const SelectedTagList = () => {
2878
2891
  const {
@@ -2898,6 +2911,7 @@ const SelectedTagList = () => {
2898
2911
  className: style$1['tag-container-inner']
2899
2912
  }, value.map(item => {
2900
2913
  return /*#__PURE__*/React.createElement(Tag, {
2914
+ className: style$1['tag'],
2901
2915
  key: item.value,
2902
2916
  closable: true,
2903
2917
  bordered: false,
@@ -2905,7 +2919,9 @@ const SelectedTagList = () => {
2905
2919
  e.preventDefault();
2906
2920
  onRemove(item);
2907
2921
  }
2908
- }, item.label);
2922
+ }, /*#__PURE__*/React.createElement("span", {
2923
+ className: style$1['tag-inner']
2924
+ }, item.label));
2909
2925
  }))));
2910
2926
  };
2911
2927
 
@@ -3819,13 +3835,11 @@ var _createAssigner = createAssigner;
3819
3835
  * _.merge(object, other);
3820
3836
  * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
3821
3837
  */
3822
- var merge = _createAssigner(function(object, source, srcIndex) {
3838
+ _createAssigner(function(object, source, srcIndex) {
3823
3839
  _baseMerge(object, source, srcIndex);
3824
3840
  });
3825
3841
 
3826
- var merge_1 = merge;
3827
-
3828
- var style = {"list":"_IsXdU","is-popup":"_-dvpa","default-list":"_QD1Mz","is-selected-all":"_M-mOy","item-label":"_LLTTB","list-item":"_PKNDm","default-list-item":"_KtOsz","is-selected":"_TQhBB","default-item-label":"_gLh9e","default-item-des":"_GodU-","single-checked":"_2rUrh","is-disabled":"_NbwX5","default-item-description":"_yjSTl","selected-all":"_vN2Fx","selected-tag":"_6oITk","select-search":"_iAH9D"};
3842
+ var style = {"list":"_IsXdU","is-popup":"_-dvpa","default-list":"_QD1Mz","is-selected-all":"_M-mOy","default-list-item":"_KtOsz","is-selected":"_TQhBB","single-checked":"_2rUrh","is-disabled":"_NbwX5","selected-all":"_vN2Fx","selected-tag":"_6oITk","select-search":"_iAH9D"};
3829
3843
 
3830
3844
  const _excluded = ["children"];
3831
3845
  const SelectList = _ref => {
@@ -3834,22 +3848,33 @@ const SelectList = _ref => {
3834
3848
  } = _ref,
3835
3849
  p = _objectWithoutPropertiesLoose(_ref, _excluded);
3836
3850
  const props = Object.assign({}, {
3837
- renderItem: ({
3838
- item,
3839
- props,
3840
- isSelectedAll,
3841
- value,
3842
- onSelect,
3843
- setValue,
3844
- onOpenChange
3851
+ renderItemContent: ({
3852
+ item
3845
3853
  }) => {
3854
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
3855
+ className: 'select-list-item-label'
3856
+ }, item.label), item.description && /*#__PURE__*/React.createElement("div", {
3857
+ className: 'select-list-item-description'
3858
+ }, item.description));
3859
+ },
3860
+ renderItem: contextProps => {
3861
+ const {
3862
+ item,
3863
+ props,
3864
+ isSelectedAll,
3865
+ value,
3866
+ onSelect,
3867
+ setValue,
3868
+ onOpenChange
3869
+ } = contextProps;
3846
3870
  const {
3847
3871
  single,
3848
- isPopup
3872
+ isPopup,
3873
+ renderItemContent
3849
3874
  } = props;
3850
3875
  const isChecked = value.some(target => target.value === item.value);
3851
3876
  return /*#__PURE__*/React.createElement(List.Item, {
3852
- className: classnames(style['default-list-item'], {
3877
+ className: classnames(style['default-list-item'], 'select-list-item', {
3853
3878
  [style['is-selected']]: isChecked
3854
3879
  }),
3855
3880
  key: item.value,
@@ -3875,12 +3900,9 @@ const SelectList = _ref => {
3875
3900
  })), /*#__PURE__*/React.createElement(Flex, {
3876
3901
  vertical: true,
3877
3902
  gag: 8,
3878
- flex: 1
3879
- }, /*#__PURE__*/React.createElement("div", {
3880
- className: style['default-item-label']
3881
- }, item.label), item.description && /*#__PURE__*/React.createElement("div", {
3882
- className: style['default-item-description']
3883
- }, item.description)), single && /*#__PURE__*/React.createElement("div", {
3903
+ flex: 1,
3904
+ className: 'select-list-item-content'
3905
+ }, renderItemContent(contextProps)), single && /*#__PURE__*/React.createElement("div", {
3884
3906
  className: style['single-checked']
3885
3907
  }, isChecked && /*#__PURE__*/React.createElement(CheckOutlined, null)));
3886
3908
  },
@@ -3929,7 +3951,7 @@ const SelectList = _ref => {
3929
3951
  } = props;
3930
3952
  const components = {
3931
3953
  search: (api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function') && /*#__PURE__*/React.createElement(SearchInput, {
3932
- className: classnames(style['select-search'], 'select-search', {
3954
+ className: classnames(style['select-search'], 'select-list-search', {
3933
3955
  'is-popup': isPopup
3934
3956
  }),
3935
3957
  placeholder: searchPlaceholder,
@@ -3940,15 +3962,17 @@ const SelectList = _ref => {
3940
3962
  simple: isPopup,
3941
3963
  showSearchButton: !isPopup
3942
3964
  }),
3943
- selectedAll: !single && allowSelectedAll && /*#__PURE__*/React.createElement("div", {
3944
- className: classnames(style['selected-all'], 'selected-all', {
3965
+ selectedAll: /*#__PURE__*/React.createElement("div", {
3966
+ className: classnames(style['selected-all'], 'select-list-selected-all', {
3945
3967
  'is-popup': isPopup
3946
3968
  })
3947
- }, /*#__PURE__*/React.createElement(SelectedAll, null)),
3969
+ }, !single && allowSelectedAll && /*#__PURE__*/React.createElement(SelectedAll, null)),
3948
3970
  fetchList: /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
3949
- className: classnames(style['list'], 'select-list', {
3971
+ className: classnames(style['list'], 'select-list-scroll-list', {
3950
3972
  'is-popup': isPopup
3951
3973
  }),
3974
+ searchText: searchText,
3975
+ getSearchProps: getSearchProps,
3952
3976
  api: Object.assign({}, options ? {
3953
3977
  data: {
3954
3978
  options,
@@ -3957,6 +3981,7 @@ const SelectList = _ref => {
3957
3981
  loader: ({
3958
3982
  data
3959
3983
  }) => {
3984
+ console.log(data);
3960
3985
  const {
3961
3986
  options,
3962
3987
  searchText
@@ -3964,16 +3989,14 @@ const SelectList = _ref => {
3964
3989
  if (typeof getSearchCallback === 'function') {
3965
3990
  const newOptions = options.filter(item => getSearchCallback(searchText, item));
3966
3991
  return {
3967
- pageData: newOptions,
3968
- totalCount: newOptions.length
3992
+ pageData: newOptions
3969
3993
  };
3970
3994
  }
3971
3995
  return {
3972
- pageData: options,
3973
- totalCount: options.length
3996
+ pageData: options
3974
3997
  };
3975
3998
  }
3976
- } : merge_1({}, api, typeof getSearchProps === 'function' && searchText ? getSearchProps(searchText) : {}))
3999
+ } : api)
3977
4000
  }), fetchProps => {
3978
4001
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue);
3979
4002
  return renderList(Object.assign({}, fetchProps, targetProps, {
@@ -3981,7 +4004,7 @@ const SelectList = _ref => {
3981
4004
  }));
3982
4005
  }),
3983
4006
  selectedTag: showSelectedTag && /*#__PURE__*/React.createElement("div", {
3984
- className: classnames(style['selected-tag'], 'selected-tag', {
4007
+ className: classnames(style['selected-tag'], 'select-list-selected-tag', {
3985
4008
  'is-popup': isPopup
3986
4009
  })
3987
4010
  }, /*#__PURE__*/React.createElement(SelectedTagList, null))