rsuite 5.36.0 → 5.37.1

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.
@@ -36,6 +36,15 @@ export interface InputPickerProps<T = ValueType> extends FormControlPickerProps<
36
36
  onFocus?: React.FocusEventHandler;
37
37
  /** Called when the option is created */
38
38
  onCreate?: (value: ValueType, item: ItemDataType, event: React.SyntheticEvent) => void;
39
+ /**
40
+ * Customize whether to display "Create option" action with given textbox value
41
+ *
42
+ * By default, InputPicker hides "Create option" action when textbox value matches any filtered item's [valueKey] property
43
+ *
44
+ * @param searchKeyword Value of the textbox
45
+ * @param filteredData The items filtered by the searchKeyword
46
+ */
47
+ shouldDisplayCreateOption?: (searchKeyword: string, filteredData: InputItemDataType[]) => boolean;
39
48
  }
40
49
  declare const InputPicker: PickerComponent<InputPickerProps>;
41
50
  export default InputPicker;
@@ -66,6 +66,7 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
66
66
  _props$menuMaxHeight = props.menuMaxHeight,
67
67
  menuMaxHeight = _props$menuMaxHeight === void 0 ? 320 : _props$menuMaxHeight,
68
68
  creatable = props.creatable,
69
+ shouldDisplayCreateOption = props.shouldDisplayCreateOption,
69
70
  valueProp = props.value,
70
71
  _props$valueKey = props.valueKey,
71
72
  valueKey = _props$valueKey === void 0 ? 'value' : _props$valueKey,
@@ -97,7 +98,7 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
97
98
  searchBy = props.searchBy,
98
99
  _props$placement = props.placement,
99
100
  placement = _props$placement === void 0 ? 'bottomStart' : _props$placement,
100
- rest = _objectWithoutPropertiesLoose(props, ["as", "appearance", "cleanable", "cacheData", "classPrefix", "data", "disabled", "readOnly", "plaintext", "defaultValue", "defaultOpen", "disabledItemValues", "locale", "toggleAs", "style", "searchable", "open", "placeholder", "groupBy", "menuClassName", "menuStyle", "menuAutoWidth", "menuMaxHeight", "creatable", "value", "valueKey", "virtualized", "labelKey", "listProps", "id", "tabIndex", "sort", "renderMenu", "renderExtraFooter", "renderValue", "renderMenuItem", "renderMenuGroup", "onEnter", "onEntered", "onExit", "onExited", "onChange", "onClean", "onCreate", "onSearch", "onSelect", "onOpen", "onClose", "onBlur", "onFocus", "searchBy", "placement"]);
101
+ rest = _objectWithoutPropertiesLoose(props, ["as", "appearance", "cleanable", "cacheData", "classPrefix", "data", "disabled", "readOnly", "plaintext", "defaultValue", "defaultOpen", "disabledItemValues", "locale", "toggleAs", "style", "searchable", "open", "placeholder", "groupBy", "menuClassName", "menuStyle", "menuAutoWidth", "menuMaxHeight", "creatable", "shouldDisplayCreateOption", "value", "valueKey", "virtualized", "labelKey", "listProps", "id", "tabIndex", "sort", "renderMenu", "renderExtraFooter", "renderValue", "renderMenuItem", "renderMenuGroup", "onEnter", "onEntered", "onExit", "onExited", "onChange", "onClean", "onCreate", "onSearch", "onSelect", "onOpen", "onClose", "onBlur", "onFocus", "searchBy", "placement"]);
101
102
 
102
103
  var _useContext = useContext(InputPickerContext),
103
104
  multi = _useContext.multi,
@@ -597,9 +598,9 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
597
598
 
598
599
  var items = filterNodesOfTree(getAllData(), checkShouldDisplay);
599
600
 
600
- if (creatable && searchKeyword && !items.find(function (item) {
601
+ if (creatable && (typeof shouldDisplayCreateOption === 'function' ? shouldDisplayCreateOption(searchKeyword, items) : searchKeyword && !items.find(function (item) {
601
602
  return item[valueKey] === searchKeyword;
602
- })) {
603
+ }))) {
603
604
  items = [].concat(items, [createOption(searchKeyword)]);
604
605
  } // Create a tree structure data when set `groupBy`
605
606
 
@@ -17,6 +17,7 @@ export interface PickerToggleProps extends ToggleButtonProps {
17
17
  tabIndex?: number;
18
18
  loading?: boolean;
19
19
  editable?: boolean;
20
+ name?: string;
20
21
  inputPlaceholder?: string;
21
22
  inputMask?: (string | RegExp)[];
22
23
  onInputChange?: (value: string, event: React.ChangeEvent) => void;
@@ -56,7 +56,8 @@ var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
56
56
  _props$caretAs = props.caretAs,
57
57
  caretAs = _props$caretAs === void 0 ? caretComponent : _props$caretAs,
58
58
  label = props.label,
59
- rest = _objectWithoutPropertiesLoose(props, ["active", "as", "classPrefix", "children", "caret", "className", "disabled", "readOnly", "plaintext", "hasValue", "editable", "loading", "cleanable", "tabIndex", "id", "value", "inputPlaceholder", "inputValue", "inputMask", "onInputChange", "onInputPressEnter", "onInputBlur", "onInputFocus", "onClean", "onFocus", "onBlur", "placement", "caretComponent", "caretAs", "label"]);
59
+ name = props.name,
60
+ rest = _objectWithoutPropertiesLoose(props, ["active", "as", "classPrefix", "children", "caret", "className", "disabled", "readOnly", "plaintext", "hasValue", "editable", "loading", "cleanable", "tabIndex", "id", "value", "inputPlaceholder", "inputValue", "inputMask", "onInputChange", "onInputPressEnter", "onInputBlur", "onInputFocus", "onClean", "onFocus", "onBlur", "placement", "caretComponent", "caretAs", "label", "name"]);
60
61
 
61
62
  var inputRef = useRef(null);
62
63
  var comboboxRef = useRef(null);
@@ -150,11 +151,12 @@ var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
150
151
  var renderInput = useCallback(function (ref, props) {
151
152
  return /*#__PURE__*/React.createElement("input", _extends({
152
153
  ref: mergeRefs(inputRef, ref),
154
+ name: name,
153
155
  style: {
154
156
  pointerEvents: editable ? undefined : 'none'
155
157
  }
156
158
  }, props));
157
- }, [editable]);
159
+ }, [editable, name]);
158
160
  var ToggleCaret = useToggleCaret(placement);
159
161
  var Caret = caretAs !== null && caretAs !== void 0 ? caretAs : ToggleCaret;
160
162
 
@@ -73,8 +73,9 @@ export function usePickerClassName(props) {
73
73
  withClassPrefix = _useClassNames.withClassPrefix,
74
74
  merge = _useClassNames.merge;
75
75
 
76
- var classes = merge(className, withClassPrefix(name, appearance, 'toggle-wrapper', (_withClassPrefix = {}, _withClassPrefix["placement-" + kebabCase(placementPolyfill(placement))] = placement, _withClassPrefix['read-only'] = readOnly, _withClassPrefix['has-value'] = hasValue, _withClassPrefix.cleanable = cleanable, _withClassPrefix.block = block, _withClassPrefix.disabled = disabled, _withClassPrefix.countable = countable, _withClassPrefix.plaintext = plaintext, _withClassPrefix)));
77
- var usedClassNamePropKeys = Object.keys(omit(props, [].concat(Object.keys(rest || {}), ['disabled', 'readOnly', 'plaintext'])));
76
+ var classes = merge(className, withClassPrefix(name, appearance, 'toggle-wrapper', (_withClassPrefix = {}, _withClassPrefix["placement-" + kebabCase(placementPolyfill(placement))] = placement, _withClassPrefix['read-only'] = readOnly, _withClassPrefix['has-value'] = hasValue, _withClassPrefix.cleanable = cleanable, _withClassPrefix.block = block, _withClassPrefix.disabled = disabled, _withClassPrefix.countable = countable, _withClassPrefix.plaintext = plaintext, _withClassPrefix))); // Those props that're used for composing the className
77
+
78
+ var usedClassNamePropKeys = Object.keys(omit(props, [].concat(Object.keys(rest || {}), ['disabled', 'readOnly', 'plaintext', 'name'])));
78
79
  return [classes, usedClassNamePropKeys];
79
80
  }
80
81
 
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { UploadTriggerProps } from './UploadTrigger';
3
3
  import { WithAsProps } from '../@types/common';
4
4
  import { UploaderLocale } from '../locales';
5
+ import type { ErrorStatus } from '../utils/ajaxUpload';
5
6
  export interface FileType {
6
7
  /** File Name */
7
8
  name?: string;
@@ -86,8 +87,8 @@ export interface UploaderProps extends WithAsProps, Omit<UploadTriggerProps, 'on
86
87
  onReupload?: (file: FileType) => void;
87
88
  /** In the file list, click the callback function for the uploaded file */
88
89
  onPreview?: (file: FileType, event: React.SyntheticEvent) => void;
89
- /** Upload callback function with erro */
90
- onError?: (status: any, file: FileType, event: ProgressEvent, xhr: XMLHttpRequest) => void;
90
+ /** Upload callback function with error */
91
+ onError?: (status: ErrorStatus, file: FileType, event: ProgressEvent, xhr: XMLHttpRequest) => void;
91
92
  /** callback function after successful upload */
92
93
  onSuccess?: (response: any, file: FileType, event: ProgressEvent, xhr: XMLHttpRequest) => void;
93
94
  /** Callback functions that upload progress change */
@@ -1,4 +1,4 @@
1
- interface ErrorStatus {
1
+ export interface ErrorStatus {
2
2
  type: 'timeout' | 'server_error' | 'xhr_error';
3
3
  response?: any;
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsuite",
3
- "version": "5.36.0",
3
+ "version": "5.37.1",
4
4
  "description": "A suite of react components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -38,7 +38,7 @@
38
38
  "prop-types": "^15.8.1",
39
39
  "react-use-set": "^1.0.0",
40
40
  "react-window": "^1.8.8",
41
- "rsuite-table": "^5.10.6",
41
+ "rsuite-table": "^5.11.0",
42
42
  "schema-typed": "^2.1.3"
43
43
  },
44
44
  "peerDependencies": {