@kne/super-select 0.1.3 → 0.1.5

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';
@@ -2396,9 +2396,9 @@ const SelectInput = p => {
2396
2396
  };
2397
2397
  const onSelect = (item, currentSetValue) => {
2398
2398
  (currentSetValue || setValue)(value => {
2399
- const newValue = value.slice(0);
2400
- const index = value.findIndex(currentItem => currentItem.value === item.value);
2401
- if (index === -1 && !checkMaxLength(value, maxLength)) {
2399
+ const newValue = (value || []).slice(0);
2400
+ const index = newValue.findIndex(currentItem => currentItem.value === item.value);
2401
+ if (index === -1 && !checkMaxLength(newValue, maxLength)) {
2402
2402
  return value;
2403
2403
  }
2404
2404
  if (index === -1) {
@@ -2461,15 +2461,14 @@ const SelectInput = p => {
2461
2461
  };
2462
2462
  return /*#__PURE__*/React.createElement(Provider, {
2463
2463
  value: contextProps
2464
- }, isPopup ? /*#__PURE__*/React.createElement(Popover, {
2464
+ }, isPopup ? /*#__PURE__*/React.createElement(Dropdown, {
2465
2465
  open: !disabled && open,
2466
2466
  onOpenChange: setOpen,
2467
2467
  placement: placement,
2468
2468
  arrow: false,
2469
- transitionName: "",
2470
2469
  overlayClassName: classnames(style$3['overlay'], overlayClassName),
2471
2470
  trigger: "click",
2472
- content: /*#__PURE__*/React.createElement("div", {
2471
+ dropdownRender: () => /*#__PURE__*/React.createElement("div", {
2473
2472
  style: {
2474
2473
  '--overlay-width': popupOverlayWidth
2475
2474
  },
@@ -3819,13 +3818,11 @@ var _createAssigner = createAssigner;
3819
3818
  * _.merge(object, other);
3820
3819
  * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
3821
3820
  */
3822
- var merge = _createAssigner(function(object, source, srcIndex) {
3821
+ _createAssigner(function(object, source, srcIndex) {
3823
3822
  _baseMerge(object, source, srcIndex);
3824
3823
  });
3825
3824
 
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"};
3825
+ 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","single-checked":"_2rUrh","is-disabled":"_NbwX5","selected-all":"_vN2Fx","selected-tag":"_6oITk","select-search":"_iAH9D"};
3829
3826
 
3830
3827
  const _excluded = ["children"];
3831
3828
  const SelectList = _ref => {
@@ -3834,22 +3831,37 @@ const SelectList = _ref => {
3834
3831
  } = _ref,
3835
3832
  p = _objectWithoutPropertiesLoose(_ref, _excluded);
3836
3833
  const props = Object.assign({}, {
3837
- renderItem: ({
3838
- item,
3839
- props,
3840
- isSelectedAll,
3841
- value,
3842
- onSelect,
3843
- setValue,
3844
- onOpenChange
3834
+ renderItemContent: ({
3835
+ item
3845
3836
  }) => {
3837
+ return /*#__PURE__*/React.createElement(Flex, {
3838
+ vertical: true,
3839
+ gag: 8,
3840
+ flex: 1
3841
+ }, /*#__PURE__*/React.createElement("div", {
3842
+ className: 'select-list-item-label'
3843
+ }, item.label), item.description && /*#__PURE__*/React.createElement("div", {
3844
+ className: 'select-list-item-description'
3845
+ }, item.description));
3846
+ },
3847
+ renderItem: contextProps => {
3848
+ const {
3849
+ item,
3850
+ props,
3851
+ isSelectedAll,
3852
+ value,
3853
+ onSelect,
3854
+ setValue,
3855
+ onOpenChange
3856
+ } = contextProps;
3846
3857
  const {
3847
3858
  single,
3848
- isPopup
3859
+ isPopup,
3860
+ renderItemContent
3849
3861
  } = props;
3850
3862
  const isChecked = value.some(target => target.value === item.value);
3851
3863
  return /*#__PURE__*/React.createElement(List.Item, {
3852
- className: classnames(style['default-list-item'], {
3864
+ className: classnames(style['default-list-item'], 'select-list-item', {
3853
3865
  [style['is-selected']]: isChecked
3854
3866
  }),
3855
3867
  key: item.value,
@@ -3872,15 +3884,7 @@ const SelectList = _ref => {
3872
3884
  }, !single && /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(Checkbox, {
3873
3885
  checked: isSelectedAll || isChecked,
3874
3886
  disabled: isSelectedAll || item.disabled
3875
- })), /*#__PURE__*/React.createElement(Flex, {
3876
- vertical: true,
3877
- 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", {
3887
+ })), renderItemContent(contextProps), single && /*#__PURE__*/React.createElement("div", {
3884
3888
  className: style['single-checked']
3885
3889
  }, isChecked && /*#__PURE__*/React.createElement(CheckOutlined, null)));
3886
3890
  },
@@ -3929,7 +3933,7 @@ const SelectList = _ref => {
3929
3933
  } = props;
3930
3934
  const components = {
3931
3935
  search: (api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function') && /*#__PURE__*/React.createElement(SearchInput, {
3932
- className: classnames(style['select-search'], 'select-search', {
3936
+ className: classnames(style['select-search'], 'select-list-search', {
3933
3937
  'is-popup': isPopup
3934
3938
  }),
3935
3939
  placeholder: searchPlaceholder,
@@ -3940,15 +3944,17 @@ const SelectList = _ref => {
3940
3944
  simple: isPopup,
3941
3945
  showSearchButton: !isPopup
3942
3946
  }),
3943
- selectedAll: !single && allowSelectedAll && /*#__PURE__*/React.createElement("div", {
3944
- className: classnames(style['selected-all'], 'selected-all', {
3947
+ selectedAll: /*#__PURE__*/React.createElement("div", {
3948
+ className: classnames(style['selected-all'], 'select-list-selected-all', {
3945
3949
  'is-popup': isPopup
3946
3950
  })
3947
- }, /*#__PURE__*/React.createElement(SelectedAll, null)),
3951
+ }, !single && allowSelectedAll && /*#__PURE__*/React.createElement(SelectedAll, null)),
3948
3952
  fetchList: /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
3949
3953
  className: classnames(style['list'], 'select-list', {
3950
3954
  'is-popup': isPopup
3951
3955
  }),
3956
+ searchText: searchText,
3957
+ getSearchProps: getSearchProps,
3952
3958
  api: Object.assign({}, options ? {
3953
3959
  data: {
3954
3960
  options,
@@ -3973,7 +3979,7 @@ const SelectList = _ref => {
3973
3979
  totalCount: options.length
3974
3980
  };
3975
3981
  }
3976
- } : merge_1({}, api, typeof getSearchProps === 'function' && searchText ? getSearchProps(searchText) : {}))
3982
+ } : api)
3977
3983
  }), fetchProps => {
3978
3984
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue);
3979
3985
  return renderList(Object.assign({}, fetchProps, targetProps, {
@@ -3981,7 +3987,7 @@ const SelectList = _ref => {
3981
3987
  }));
3982
3988
  }),
3983
3989
  selectedTag: showSelectedTag && /*#__PURE__*/React.createElement("div", {
3984
- className: classnames(style['selected-tag'], 'selected-tag', {
3990
+ className: classnames(style['selected-tag'], 'select-list-selected-tag', {
3985
3991
  'is-popup': isPopup
3986
3992
  })
3987
3993
  }, /*#__PURE__*/React.createElement(SelectedTagList, null))