@kne/super-select 0.1.1 → 0.1.3

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.
@@ -2335,7 +2335,8 @@ const SelectInput = p => {
2335
2335
  }, p, {
2336
2336
  locale
2337
2337
  });
2338
- const [value, setValue] = useControlValue(props);
2338
+ const [stateValue, setValue] = useControlValue(props);
2339
+ const value = stateValue || [];
2339
2340
  const [searchText, setSearchText] = useState('');
2340
2341
  const [open, setOpen] = useState(false);
2341
2342
  const [hover, setHover] = useState(false);
@@ -2410,7 +2411,7 @@ const SelectInput = p => {
2410
2411
  };
2411
2412
  const inputInnerRender = (props = {}) => /*#__PURE__*/React.createElement(Flex, _extends({}, props, {
2412
2413
  ref: inputRef,
2413
- className: classnames(className, style$3['select-input'], {
2414
+ className: classnames(className, style$3['select-input'], 'select-input', {
2414
2415
  [style$3['wrap']]: labelWrap,
2415
2416
  [style$3['disabled']]: disabled
2416
2417
  }),
@@ -2422,8 +2423,8 @@ const SelectInput = p => {
2422
2423
  setHover(false);
2423
2424
  }
2424
2425
  }), /*#__PURE__*/React.createElement("div", {
2425
- className: style$3['select-input-inner']
2426
- }, (value || []).length > 0 ? single || value[0].value === selectedAllValue.value ? value[0].label : value.map(item => {
2426
+ className: classnames(style$3['select-input-inner'], 'select-input-inner')
2427
+ }, value.length > 0 ? single || value[0].value === selectedAllValue.value ? value[0].label : value.map(item => {
2427
2428
  return /*#__PURE__*/React.createElement(Tag, {
2428
2429
  key: item.value,
2429
2430
  closable: true,
@@ -2434,10 +2435,10 @@ const SelectInput = p => {
2434
2435
  }
2435
2436
  }, item.label);
2436
2437
  }) : /*#__PURE__*/React.createElement("span", {
2437
- className: style$3['placeholder']
2438
+ className: classnames(style$3['placeholder'], 'select-input-placeholder')
2438
2439
  }, placeholder)), /*#__PURE__*/React.createElement("div", {
2439
- className: style$3['select-input-icon']
2440
- }, !disabled && allowClear && hover && (value || []).length > 0 ? /*#__PURE__*/React.createElement(CloseCircleFilled, {
2440
+ className: classnames(style$3['select-input-icon'], 'select-input-icon')
2441
+ }, !disabled && allowClear && hover && value.length > 0 ? /*#__PURE__*/React.createElement(CloseCircleFilled, {
2441
2442
  onClick: e => {
2442
2443
  e.stopPropagation();
2443
2444
  setValue([]);
@@ -2445,7 +2446,7 @@ const SelectInput = p => {
2445
2446
  }) : /*#__PURE__*/React.createElement(DownOutlined, null)));
2446
2447
  const contextProps = {
2447
2448
  props,
2448
- value,
2449
+ value: value,
2449
2450
  setValue,
2450
2451
  searchText,
2451
2452
  setSearchText,
@@ -2834,7 +2835,7 @@ function get(object, path, defaultValue) {
2834
2835
 
2835
2836
  var get_1 = get;
2836
2837
 
2837
- var style$2 = {"selected-all":"_prlgN","selected-all-outer":"_h6RBS"};
2838
+ var style$2 = {"selected-all":"_prlgN"};
2838
2839
 
2839
2840
  const SelectedAll = () => {
2840
2841
  const {
@@ -2850,11 +2851,9 @@ const SelectedAll = () => {
2850
2851
  unit: number => locale.numberOf.replace('%s', number)
2851
2852
  }, props);
2852
2853
  const isSelectedAll = computedIsSelectAll(value, selectedAllValue);
2853
- return /*#__PURE__*/React.createElement("div", {
2854
- className: style$2['selected-all-outer']
2855
- }, /*#__PURE__*/React.createElement(Flex, {
2854
+ return /*#__PURE__*/React.createElement(Flex, {
2856
2855
  justify: "space-between",
2857
- className: style$2['selected-all']
2856
+ className: classnames(style$2['selected-all'], 'selected-all')
2858
2857
  }, /*#__PURE__*/React.createElement(Flex, {
2859
2858
  gap: 8
2860
2859
  }, /*#__PURE__*/React.createElement("span", null, locale.selected, ":"), /*#__PURE__*/React.createElement("span", null, isSelectedAll ? selectedAllValue.label : typeof unit === 'function' ? unit(value.length) : value.length)), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Checkbox, {
@@ -2867,13 +2866,13 @@ const SelectedAll = () => {
2867
2866
  setValue([selectedAllValue]);
2868
2867
  }
2869
2868
  }
2870
- }, locale.selectAll))));
2869
+ }, locale.selectAll)));
2871
2870
  };
2872
2871
  const computedIsSelectAll = (value, selectedAllValue) => {
2873
2872
  return (value == null ? void 0 : value.length) === 1 && get_1(value, '[0].value') === selectedAllValue.value;
2874
2873
  };
2875
2874
 
2876
- var style$1 = {"label":"_l3KoW","tag-list":"_CCPzb","tag-list-outer":"_epbhk","tag-container":"_dKZHi","tag-container-inner":"_oijCI"};
2875
+ var style$1 = {"label":"_l3KoW","tag-list":"_CCPzb","tag-container":"_dKZHi","tag-container-inner":"_oijCI"};
2877
2876
 
2878
2877
  const SelectedTagList = () => {
2879
2878
  const {
@@ -2886,14 +2885,12 @@ const SelectedTagList = () => {
2886
2885
  single,
2887
2886
  maxLength
2888
2887
  } = Object.assign({}, props);
2889
- return /*#__PURE__*/React.createElement("div", {
2890
- className: style$1['tag-list-outer']
2891
- }, /*#__PURE__*/React.createElement(Flex, {
2892
- className: style$1['tag-list'],
2888
+ return /*#__PURE__*/React.createElement(Flex, {
2889
+ className: classnames(style$1['tag-list'], 'selected-tag-list'),
2893
2890
  gap: 8
2894
2891
  }, /*#__PURE__*/React.createElement("div", {
2895
2892
  className: style$1['label']
2896
- }, locale.selected, !single && `(${value.length}${Number.isInteger(maxLength) ? `/${maxLength}` : ''})`, ":"), /*#__PURE__*/React.createElement(SimpleBar, {
2893
+ }, locale.selected, !single && value.length > 0 && `(${value.length}${Number.isInteger(maxLength) ? `/${maxLength}` : ''})`, ":"), /*#__PURE__*/React.createElement(SimpleBar, {
2897
2894
  className: style$1['tag-container']
2898
2895
  }, /*#__PURE__*/React.createElement(Flex, {
2899
2896
  gap: 8,
@@ -2909,7 +2906,7 @@ const SelectedTagList = () => {
2909
2906
  onRemove(item);
2910
2907
  }
2911
2908
  }, item.label);
2912
- })))));
2909
+ }))));
2913
2910
  };
2914
2911
 
2915
2912
  var defineProperty = (function() {
@@ -3828,7 +3825,7 @@ var merge = _createAssigner(function(object, source, srcIndex) {
3828
3825
 
3829
3826
  var merge_1 = merge;
3830
3827
 
3831
- var style = {"list":"_IsXdU","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"};
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"};
3832
3829
 
3833
3830
  const _excluded = ["children"];
3834
3831
  const SelectList = _ref => {
@@ -3837,11 +3834,11 @@ const SelectList = _ref => {
3837
3834
  } = _ref,
3838
3835
  p = _objectWithoutPropertiesLoose(_ref, _excluded);
3839
3836
  const props = Object.assign({}, {
3840
- renderList: ({
3837
+ renderItem: ({
3838
+ item,
3841
3839
  props,
3842
3840
  isSelectedAll,
3843
3841
  value,
3844
- list,
3845
3842
  onSelect,
3846
3843
  setValue,
3847
3844
  onOpenChange
@@ -3850,50 +3847,61 @@ const SelectList = _ref => {
3850
3847
  single,
3851
3848
  isPopup
3852
3849
  } = props;
3850
+ const isChecked = value.some(target => target.value === item.value);
3851
+ return /*#__PURE__*/React.createElement(List.Item, {
3852
+ className: classnames(style['default-list-item'], {
3853
+ [style['is-selected']]: isChecked
3854
+ }),
3855
+ key: item.value,
3856
+ onClick: () => {
3857
+ if (item.disabled) {
3858
+ return;
3859
+ }
3860
+ if (isSelectedAll) {
3861
+ return;
3862
+ }
3863
+ if (single) {
3864
+ setValue([item]);
3865
+ } else {
3866
+ onSelect(item);
3867
+ }
3868
+ if (isPopup && single) {
3869
+ onOpenChange(false);
3870
+ }
3871
+ }
3872
+ }, !single && /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(Checkbox, {
3873
+ checked: isSelectedAll || isChecked,
3874
+ 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", {
3884
+ className: style['single-checked']
3885
+ }, isChecked && /*#__PURE__*/React.createElement(CheckOutlined, null)));
3886
+ },
3887
+ renderList: contextProps => {
3888
+ const {
3889
+ props,
3890
+ isSelectedAll,
3891
+ list
3892
+ } = contextProps;
3893
+ const {
3894
+ renderItem
3895
+ } = props;
3853
3896
  return /*#__PURE__*/React.createElement(List, {
3854
3897
  className: classnames(style['default-list'], {
3855
3898
  [style['is-selected-all']]: isSelectedAll
3856
3899
  }),
3857
3900
  size: "small",
3858
3901
  dataSource: list,
3859
- renderItem: item => {
3860
- const isChecked = value.some(target => target.value === item.value);
3861
- return /*#__PURE__*/React.createElement(List.Item, {
3862
- className: classnames(style['default-list-item'], {
3863
- [style['is-selected']]: isChecked
3864
- }),
3865
- key: item.value,
3866
- onClick: () => {
3867
- if (item.disabled) {
3868
- return;
3869
- }
3870
- if (isSelectedAll) {
3871
- return;
3872
- }
3873
- if (single) {
3874
- setValue([item]);
3875
- } else {
3876
- onSelect(item);
3877
- }
3878
- if (isPopup && single) {
3879
- onOpenChange(false);
3880
- }
3881
- }
3882
- }, !single && /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(Checkbox, {
3883
- checked: isSelectedAll || isChecked,
3884
- disabled: isSelectedAll || item.disabled
3885
- })), /*#__PURE__*/React.createElement(Flex, {
3886
- vertical: true,
3887
- gag: 8,
3888
- flex: 1
3889
- }, /*#__PURE__*/React.createElement("div", {
3890
- className: style['default-item-label']
3891
- }, item.label), item.description && /*#__PURE__*/React.createElement("div", {
3892
- className: style['default-item-description']
3893
- }, item.description)), single && /*#__PURE__*/React.createElement("div", {
3894
- className: style['single-checked']
3895
- }, isChecked && /*#__PURE__*/React.createElement(CheckOutlined, null)));
3896
- }
3902
+ renderItem: item => renderItem(Object.assign({}, contextProps, {
3903
+ item
3904
+ }))
3897
3905
  });
3898
3906
  }
3899
3907
  }, p);
@@ -3921,6 +3929,9 @@ const SelectList = _ref => {
3921
3929
  } = props;
3922
3930
  const components = {
3923
3931
  search: (api && typeof getSearchProps === 'function' || options && typeof getSearchCallback === 'function') && /*#__PURE__*/React.createElement(SearchInput, {
3932
+ className: classnames(style['select-search'], 'select-search', {
3933
+ 'is-popup': isPopup
3934
+ }),
3924
3935
  placeholder: searchPlaceholder,
3925
3936
  value: searchText,
3926
3937
  onSearch: value => {
@@ -3929,9 +3940,15 @@ const SelectList = _ref => {
3929
3940
  simple: isPopup,
3930
3941
  showSearchButton: !isPopup
3931
3942
  }),
3932
- selectedAll: !single && allowSelectedAll && /*#__PURE__*/React.createElement(SelectedAll, null),
3943
+ selectedAll: !single && allowSelectedAll && /*#__PURE__*/React.createElement("div", {
3944
+ className: classnames(style['selected-all'], 'selected-all', {
3945
+ 'is-popup': isPopup
3946
+ })
3947
+ }, /*#__PURE__*/React.createElement(SelectedAll, null)),
3933
3948
  fetchList: /*#__PURE__*/React.createElement(FetchScrollLoader, _extends({}, props, {
3934
- className: style['list'],
3949
+ className: classnames(style['list'], 'select-list', {
3950
+ 'is-popup': isPopup
3951
+ }),
3935
3952
  api: Object.assign({}, options ? {
3936
3953
  data: {
3937
3954
  options,
@@ -3963,10 +3980,16 @@ const SelectList = _ref => {
3963
3980
  isSelectedAll
3964
3981
  }));
3965
3982
  }),
3966
- selectedTag: showSelectedTag && /*#__PURE__*/React.createElement(SelectedTagList, null)
3983
+ selectedTag: showSelectedTag && /*#__PURE__*/React.createElement("div", {
3984
+ className: classnames(style['selected-tag'], 'selected-tag', {
3985
+ 'is-popup': isPopup
3986
+ })
3987
+ }, /*#__PURE__*/React.createElement(SelectedTagList, null))
3967
3988
  };
3968
3989
  if (typeof children === 'function') {
3969
- return children(components);
3990
+ return children(Object.assign({}, targetProps, {
3991
+ components
3992
+ }));
3970
3993
  }
3971
3994
  return /*#__PURE__*/React.createElement(Flex, {
3972
3995
  vertical: true