react-ui-basics 0.0.231 → 0.0.233

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-ui-basics",
3
- "version": "0.0.231",
3
+ "version": "0.0.233",
4
4
  "description": "",
5
5
  "module": "index.js",
6
6
  "_main": "index.cjs.js",
@@ -147,10 +147,10 @@ class AutocompleteSelect extends PureComponent {
147
147
  this.updateListPosition()
148
148
  }
149
149
 
150
- initSelected = ({value, mode, allowCustom}, {filterValue = ''}) => {
150
+ initSelected = ({value, mode, allowCustom, withFilter}, {filterValue = ''}) => {
151
151
  this.setState({
152
152
  selected: prepareSelected(value),
153
- filterValue: allowCustom && isString(value) && !isMultipleSelect(mode) ? value : filterValue,
153
+ filterValue: allowCustom && withFilter && isString(value) && !isMultipleSelect(mode) ? value : filterValue,
154
154
  });
155
155
  };
156
156
 
@@ -390,13 +390,15 @@ class AutocompleteSelect extends PureComponent {
390
390
  }
391
391
 
392
392
  onClickOutside = () => {
393
- const {allowCustom, required, onFilterInputChange, mode, selectCustomOnClickOutside} = __props(this);
393
+ const {allowCustom, required, onFilterInputChange, mode, selectCustomOnClickOutside, withFilter} = __props(this);
394
394
  let {filterValue, selected} = __state(this);
395
395
  if (allowCustom && selectCustomOnClickOutside && (!!filterValue || !required)) {
396
396
  selected = this.onSelect()
397
397
  }
398
398
 
399
- filterValue = (!isMultipleSelect(mode) && Object.values(selected)[0]) || ''
399
+ filterValue = (!isMultipleSelect(mode) && withFilter && Object.values(selected)[0]) || ''
400
+ filterValue = isString(filterValue) ? filterValue : ''
401
+
400
402
  this.setState({isActive: false, filterValue});
401
403
  onFilterInputChange && onFilterInputChange(filterValue);
402
404
 
@@ -410,8 +412,9 @@ class AutocompleteSelect extends PureComponent {
410
412
  onSelect = (selectedId) => {
411
413
  const {mode, required, allowCustom, onSelect, onChange, default: defaultValue} = __props(this);
412
414
  const {filterValue, selected: currentSelection} = __state(this);
413
- const {labels = {}, onFilterInputChange} = __props(this);
415
+ const {labels = {}, onFilterInputChange, withFilter} = __props(this);
414
416
 
417
+ // debugger
415
418
  if (selectedId == null && (!!filterValue || !required) && allowCustom && (!this.input || !this.input.check()))
416
419
  selectedId = filterValue.trim();
417
420
 
@@ -452,16 +455,16 @@ class AutocompleteSelect extends PureComponent {
452
455
  customValue = label
453
456
  }
454
457
 
455
- let filterValueWithCustom = isMultiSelect ? '' : customValue;
458
+ let nextFilterValue = (!isMultipleSelect(mode) && withFilter && Object.values(selected)[0]) || ''
456
459
  this.setState({
457
460
  isActive: isActive,
458
461
  selected: selected,
459
- filterValue: filterValueWithCustom,
462
+ filterValue: nextFilterValue,
460
463
  errored,
461
464
  });
462
465
 
463
- if (filterValueWithCustom !== filterValue)
464
- orNoop(onFilterInputChange)(filterValueWithCustom)
466
+ if (nextFilterValue !== filterValue)
467
+ orNoop(onFilterInputChange)(nextFilterValue)
465
468
 
466
469
  if (isActive && this.input)
467
470
  this.input.getInput().focus()
@@ -504,6 +507,8 @@ class AutocompleteSelect extends PureComponent {
504
507
  const data = __state(this).data || __props(this).data || []
505
508
  if (data.indexOf(value) !== -1) {
506
509
  this.list.selected(value)
510
+ } else {
511
+ this.list.reset()
507
512
  }
508
513
 
509
514
  __props(this).onFilterInputChange?.(value);
package/src/TextField.tsx CHANGED
@@ -13,7 +13,7 @@ export interface TextAreaProps {
13
13
  autoComplete?: string,
14
14
  placeholder?: string,
15
15
  label?: string | ReactElement,
16
- check?: (value: string) => boolean,
16
+ check?: (value: string) => boolean | string | ReactElement,
17
17
  onClick?: MouseEventHandler<HTMLInputElement>,
18
18
  onMouseUp?: MouseEventHandler<HTMLInputElement>,
19
19
  onKeyDown?: KeyboardEventHandler<HTMLInputElement>,