rsuite 5.59.3-alpha.1 → 5.60.0

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.
Files changed (73) hide show
  1. package/Animation/styles/fade.less +1 -1
  2. package/Animation/styles/index.css +1 -1
  3. package/CHANGELOG.md +16 -0
  4. package/TagInput/styles/index.css +24 -24
  5. package/TagPicker/styles/index.css +24 -24
  6. package/TagPicker/styles/index.less +11 -10
  7. package/cjs/Form/Form.d.ts +13 -9
  8. package/cjs/Form/Form.js +55 -11
  9. package/cjs/Form/FormContext.d.ts +2 -2
  10. package/cjs/Form/hooks/useFormRef.d.ts +9 -7
  11. package/cjs/Form/hooks/useFormRef.js +5 -32
  12. package/cjs/Form/hooks/useFormValidate.d.ts +6 -4
  13. package/cjs/Form/hooks/useFormValidate.js +18 -12
  14. package/cjs/Form/hooks/useFormValue.d.ts +8 -1
  15. package/cjs/Form/hooks/useFormValue.js +7 -1
  16. package/cjs/InputPicker/InputAutosize.js +2 -2
  17. package/cjs/InputPicker/InputPicker.d.ts +5 -7
  18. package/cjs/InputPicker/InputPicker.js +119 -151
  19. package/cjs/InputPicker/InputPickerContext.d.ts +11 -3
  20. package/cjs/InputPicker/InputPickerContext.js +7 -1
  21. package/cjs/InputPicker/hooks/useData.d.ts +17 -0
  22. package/cjs/InputPicker/hooks/useData.js +44 -0
  23. package/cjs/InputPicker/hooks/useInput.d.ts +21 -0
  24. package/cjs/InputPicker/hooks/useInput.js +46 -0
  25. package/cjs/InputPicker/hooks/useMaxWidth.d.ts +4 -0
  26. package/cjs/InputPicker/hooks/useMaxWidth.js +25 -0
  27. package/cjs/InputPicker/index.d.ts +2 -1
  28. package/cjs/InputPicker/utils.d.ts +1 -0
  29. package/cjs/InputPicker/utils.js +17 -0
  30. package/cjs/TagInput/index.js +2 -2
  31. package/cjs/TagPicker/index.js +2 -2
  32. package/dist/rsuite-no-reset-rtl.css +25 -25
  33. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  34. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  35. package/dist/rsuite-no-reset.css +25 -25
  36. package/dist/rsuite-no-reset.min.css +1 -1
  37. package/dist/rsuite-no-reset.min.css.map +1 -1
  38. package/dist/rsuite-rtl.css +25 -25
  39. package/dist/rsuite-rtl.min.css +1 -1
  40. package/dist/rsuite-rtl.min.css.map +1 -1
  41. package/dist/rsuite.css +25 -25
  42. package/dist/rsuite.js +53 -9
  43. package/dist/rsuite.js.map +1 -1
  44. package/dist/rsuite.min.css +1 -1
  45. package/dist/rsuite.min.css.map +1 -1
  46. package/dist/rsuite.min.js +1 -1
  47. package/dist/rsuite.min.js.map +1 -1
  48. package/esm/Form/Form.d.ts +13 -9
  49. package/esm/Form/Form.js +55 -11
  50. package/esm/Form/FormContext.d.ts +2 -2
  51. package/esm/Form/hooks/useFormRef.d.ts +9 -7
  52. package/esm/Form/hooks/useFormRef.js +5 -32
  53. package/esm/Form/hooks/useFormValidate.d.ts +6 -4
  54. package/esm/Form/hooks/useFormValidate.js +18 -12
  55. package/esm/Form/hooks/useFormValue.d.ts +8 -1
  56. package/esm/Form/hooks/useFormValue.js +7 -1
  57. package/esm/InputPicker/InputAutosize.js +2 -2
  58. package/esm/InputPicker/InputPicker.d.ts +5 -7
  59. package/esm/InputPicker/InputPicker.js +111 -143
  60. package/esm/InputPicker/InputPickerContext.d.ts +11 -3
  61. package/esm/InputPicker/InputPickerContext.js +4 -0
  62. package/esm/InputPicker/hooks/useData.d.ts +17 -0
  63. package/esm/InputPicker/hooks/useData.js +38 -0
  64. package/esm/InputPicker/hooks/useInput.d.ts +21 -0
  65. package/esm/InputPicker/hooks/useInput.js +40 -0
  66. package/esm/InputPicker/hooks/useMaxWidth.d.ts +4 -0
  67. package/esm/InputPicker/hooks/useMaxWidth.js +19 -0
  68. package/esm/InputPicker/index.d.ts +2 -1
  69. package/esm/InputPicker/utils.d.ts +1 -0
  70. package/esm/InputPicker/utils.js +12 -0
  71. package/esm/TagInput/index.js +2 -2
  72. package/esm/TagPicker/index.js +2 -2
  73. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { FormHTMLAttributes } from 'react';
2
2
  import { Schema } from 'schema-typed';
3
3
  import FormControl from '../FormControl';
4
4
  import FormControlLabel from '../FormControlLabel';
@@ -7,9 +7,9 @@ import FormGroup from '../FormGroup';
7
7
  import FormHelpText from '../FormHelpText';
8
8
  import { WithAsProps, TypeAttributes, RsRefForwardingComponent } from '../@types/common';
9
9
  import { FormInstance } from './hooks/useFormRef';
10
- export interface FormProps<T = Record<string, any>, errorMsgType = any, E = {
11
- [P in keyof T]?: errorMsgType;
12
- }> extends WithAsProps, Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onChange' | 'onSubmit' | 'onError'> {
10
+ export interface FormProps<V = Record<string, any>, M = any, E = {
11
+ [P in keyof V]?: M;
12
+ }> extends WithAsProps, Omit<FormHTMLAttributes<HTMLFormElement>, 'onChange' | 'onSubmit' | 'onError' | 'onReset'> {
13
13
  /**
14
14
  * Set the left and right columns of the layout of the elements within the form。
15
15
  *
@@ -23,11 +23,11 @@ export interface FormProps<T = Record<string, any>, errorMsgType = any, E = {
23
23
  /**
24
24
  * Current value of the input. Creates a controlled component
25
25
  */
26
- formValue?: T | null;
26
+ formValue?: V | null;
27
27
  /**
28
28
  * Initial value
29
29
  */
30
- formDefaultValue?: T | null;
30
+ formDefaultValue?: V | null;
31
31
  /**
32
32
  * Error message of form
33
33
  */
@@ -77,7 +77,7 @@ export interface FormProps<T = Record<string, any>, errorMsgType = any, E = {
77
77
  /**
78
78
  * Callback fired when data changing
79
79
  */
80
- onChange?: (formValue: T, event?: React.SyntheticEvent) => void;
80
+ onChange?: (formValue: V, event?: React.SyntheticEvent) => void;
81
81
  /**
82
82
  * Callback fired when error checking
83
83
  */
@@ -87,9 +87,13 @@ export interface FormProps<T = Record<string, any>, errorMsgType = any, E = {
87
87
  */
88
88
  onCheck?: (formError: E) => void;
89
89
  /**
90
- * Callback fired when form submit
90
+ * Callback fired when form submit,only when the form data is validated will trigger
91
91
  */
92
- onSubmit?: (checkPassed: boolean, event: React.FormEvent<HTMLFormElement>) => void;
92
+ onSubmit?: (formValue: V | null, event?: React.FormEvent<HTMLFormElement>) => void;
93
+ /**
94
+ * Callback fired when form reset
95
+ */
96
+ onReset?: (formValue: V | null, event?: React.FormEvent<HTMLFormElement>) => void;
93
97
  }
94
98
  export interface FormComponent extends RsRefForwardingComponent<'form', FormProps & {
95
99
  ref?: React.Ref<FormInstance>;
package/esm/Form/Form.js CHANGED
@@ -16,6 +16,7 @@ import useSchemaModel from './hooks/useSchemaModel';
16
16
  import useFormValidate from './hooks/useFormValidate';
17
17
  import useFormValue from './hooks/useFormValue';
18
18
  import useFormClassNames from './hooks/useFormClassNames';
19
+ import useFormRef from './hooks/useFormRef';
19
20
  var defaultSchema = SchemaModel({});
20
21
 
21
22
  /**
@@ -46,10 +47,11 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
46
47
  children = props.children,
47
48
  disabled = props.disabled,
48
49
  onSubmit = props.onSubmit,
50
+ onReset = props.onReset,
49
51
  onCheck = props.onCheck,
50
52
  onError = props.onError,
51
53
  onChange = props.onChange,
52
- rest = _objectWithoutPropertiesLoose(props, ["checkTrigger", "classPrefix", "errorFromContext", "formDefaultValue", "formValue", "formError", "fluid", "nestedField", "layout", "model", "readOnly", "plaintext", "className", "children", "disabled", "onSubmit", "onCheck", "onError", "onChange"]);
54
+ rest = _objectWithoutPropertiesLoose(props, ["checkTrigger", "classPrefix", "errorFromContext", "formDefaultValue", "formValue", "formError", "fluid", "nestedField", "layout", "model", "readOnly", "plaintext", "className", "children", "disabled", "onSubmit", "onReset", "onCheck", "onError", "onChange"]);
53
55
  var _useSchemaModel = useSchemaModel(formModel),
54
56
  getCombinedModel = _useSchemaModel.getCombinedModel,
55
57
  pushFieldRule = _useSchemaModel.pushFieldRule,
@@ -60,9 +62,9 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
60
62
  }),
61
63
  formValue = _useFormValue.formValue,
62
64
  onRemoveValue = _useFormValue.onRemoveValue,
63
- setFieldValue = _useFormValue.setFieldValue;
65
+ setFieldValue = _useFormValue.setFieldValue,
66
+ resetFormValue = _useFormValue.resetFormValue;
64
67
  var formValidateProps = {
65
- ref: ref,
66
68
  formValue: formValue,
67
69
  getCombinedModel: getCombinedModel,
68
70
  onCheck: onCheck,
@@ -74,7 +76,12 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
74
76
  setFieldError = _useFormValidate.setFieldError,
75
77
  onRemoveError = _useFormValidate.onRemoveError,
76
78
  check = _useFormValidate.check,
77
- formRef = _useFormValidate.formRef;
79
+ checkAsync = _useFormValidate.checkAsync,
80
+ checkForField = _useFormValidate.checkForField,
81
+ checkForFieldAsync = _useFormValidate.checkForFieldAsync,
82
+ cleanErrors = _useFormValidate.cleanErrors,
83
+ resetErrors = _useFormValidate.resetErrors,
84
+ cleanErrorForField = _useFormValidate.cleanErrorForField;
78
85
  var classes = useFormClassNames({
79
86
  classPrefix: classPrefix,
80
87
  className: className,
@@ -84,22 +91,58 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
84
91
  plaintext: plaintext,
85
92
  disabled: disabled
86
93
  });
87
- var removeFieldValue = useEventCallback(function (name) {
88
- var formValue = onRemoveValue(name);
89
- onChange === null || onChange === void 0 ? void 0 : onChange(formValue);
94
+ var submit = useEventCallback(function (event) {
95
+ // Check the form before submitting
96
+ if (check()) {
97
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formValue, event);
98
+ }
90
99
  });
91
- var removeFieldError = useEventCallback(function (name) {
92
- onRemoveError(name);
100
+ var reset = useEventCallback(function (event) {
101
+ resetErrors();
102
+ onReset === null || onReset === void 0 ? void 0 : onReset(resetFormValue(), event);
93
103
  });
94
104
  var handleSubmit = useEventCallback(function (event) {
95
105
  var _event$preventDefault, _event$stopPropagatio;
96
106
  event === null || event === void 0 ? void 0 : (_event$preventDefault = event.preventDefault) === null || _event$preventDefault === void 0 ? void 0 : _event$preventDefault.call(event);
97
107
  event === null || event === void 0 ? void 0 : (_event$stopPropagatio = event.stopPropagation) === null || _event$stopPropagatio === void 0 ? void 0 : _event$stopPropagatio.call(event);
108
+
109
+ // Prevent submission when the form is disabled, readOnly, or plaintext
98
110
  if (disabled || readOnly || plaintext) {
99
111
  return;
100
112
  }
101
- var checkResult = check();
102
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(checkResult, event);
113
+ submit();
114
+ });
115
+ var handleReset = useEventCallback(function (event) {
116
+ var _event$preventDefault2, _event$stopPropagatio2;
117
+ event === null || event === void 0 ? void 0 : (_event$preventDefault2 = event.preventDefault) === null || _event$preventDefault2 === void 0 ? void 0 : _event$preventDefault2.call(event);
118
+ event === null || event === void 0 ? void 0 : (_event$stopPropagatio2 = event.stopPropagation) === null || _event$stopPropagatio2 === void 0 ? void 0 : _event$stopPropagatio2.call(event);
119
+
120
+ // Prevent reset when the form is disabled, readOnly, or plaintext
121
+ if (disabled || readOnly || plaintext) {
122
+ return;
123
+ }
124
+ reset(event);
125
+ });
126
+ var imperativeMethods = {
127
+ check: check,
128
+ checkForField: checkForField,
129
+ checkAsync: checkAsync,
130
+ checkForFieldAsync: checkForFieldAsync,
131
+ cleanErrors: cleanErrors,
132
+ cleanErrorForField: cleanErrorForField,
133
+ reset: reset,
134
+ resetErrors: resetErrors,
135
+ submit: submit
136
+ };
137
+ var formRef = useFormRef(ref, {
138
+ imperativeMethods: imperativeMethods
139
+ });
140
+ var removeFieldValue = useEventCallback(function (name) {
141
+ var formValue = onRemoveValue(name);
142
+ onChange === null || onChange === void 0 ? void 0 : onChange(formValue);
143
+ });
144
+ var removeFieldError = useEventCallback(function (name) {
145
+ onRemoveError(name);
103
146
  });
104
147
  var onFieldError = useEventCallback(function (name, checkResult) {
105
148
  setFieldError(name, checkResult);
@@ -131,6 +174,7 @@ var Form = /*#__PURE__*/React.forwardRef(function (props, ref) {
131
174
  return /*#__PURE__*/React.createElement("form", _extends({}, rest, {
132
175
  ref: formRef,
133
176
  onSubmit: handleSubmit,
177
+ onReset: handleReset,
134
178
  className: classes
135
179
  }), /*#__PURE__*/React.createElement(FormProvider, {
136
180
  value: formContextValue
@@ -3,8 +3,8 @@ import { TypeAttributes } from '../@types/common';
3
3
  import type { Schema, CheckResult } from 'schema-typed';
4
4
  import type { FieldRuleType } from './hooks/useSchemaModel';
5
5
  declare type RecordAny = Record<string, any>;
6
- interface TrulyFormContextValue<T = RecordAny, errorMsgType = any, E = {
7
- [P in keyof T]?: errorMsgType;
6
+ interface TrulyFormContextValue<T = RecordAny, M = any, E = {
7
+ [P in keyof T]?: M;
8
8
  }> {
9
9
  formError: E;
10
10
  nestedField: boolean;
@@ -31,6 +31,14 @@ export interface FormImperativeMethods<T = Record<string, any>, M = string, E =
31
31
  * All error messages are reset, and an initial value can be set
32
32
  */
33
33
  resetErrors: (formError?: E) => void;
34
+ /**
35
+ * Reset form data to initial value and clear all error messages
36
+ */
37
+ reset: () => void;
38
+ /**
39
+ * Submit form data and verify
40
+ */
41
+ submit: () => void;
34
42
  }
35
43
  export interface FormInstance<T = Record<string, any>, M = string, E = {
36
44
  [P in keyof T]?: M;
@@ -43,13 +51,7 @@ export interface FormInstance<T = Record<string, any>, M = string, E = {
43
51
  interface FormRefProps<T = Record<string, any>, M = string, E = {
44
52
  [P in keyof T]?: M;
45
53
  }> {
46
- formError: E;
47
- nestedField?: boolean;
48
- setFormError: (formError: E) => void;
49
- check: (callback?: (formError: E) => void) => boolean;
50
- checkForField: (fieldName: keyof T, callback?: (checkResult: CheckResult<M>) => void) => boolean;
51
- checkAsync: () => Promise<any>;
52
- checkForFieldAsync: (fieldName: keyof T) => Promise<CheckResult>;
54
+ imperativeMethods: FormImperativeMethods<T, M, E>;
53
55
  }
54
56
  export default function useFormRef(ref: React.Ref<FormInstance>, props: FormRefProps): import("react").RefObject<HTMLFormElement>;
55
57
  export {};
@@ -1,40 +1,13 @@
1
1
  'use client';
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
3
  import { useRef, useImperativeHandle } from 'react';
3
- import omit from 'lodash/omit';
4
- import useEventCallback from '../../utils/useEventCallback';
5
- import { nameToPath } from '../../FormControl/utils';
6
4
  export default function useFormRef(ref, props) {
7
5
  var rootRef = useRef(null);
8
- var formError = props.formError,
9
- setFormError = props.setFormError,
10
- nestedField = props.nestedField,
11
- check = props.check,
12
- checkForField = props.checkForField,
13
- checkAsync = props.checkAsync,
14
- checkForFieldAsync = props.checkForFieldAsync;
15
- var cleanErrors = useEventCallback(function () {
16
- setFormError({});
17
- });
18
- var resetErrors = useEventCallback(function (formError) {
19
- if (formError === void 0) {
20
- formError = {};
21
- }
22
- setFormError(formError);
23
- });
24
- var cleanErrorForField = useEventCallback(function (fieldName) {
25
- setFormError(omit(formError, [nestedField ? nameToPath(fieldName) : fieldName]));
26
- });
6
+ var imperativeMethods = props.imperativeMethods;
27
7
  useImperativeHandle(ref, function () {
28
- return {
29
- root: rootRef.current,
30
- check: check,
31
- checkForField: checkForField,
32
- checkAsync: checkAsync,
33
- checkForFieldAsync: checkForFieldAsync,
34
- cleanErrors: cleanErrors,
35
- cleanErrorForField: cleanErrorForField,
36
- resetErrors: resetErrors
37
- };
8
+ return _extends({
9
+ root: rootRef.current
10
+ }, imperativeMethods);
38
11
  });
39
12
  return rootRef;
40
13
  }
@@ -1,9 +1,6 @@
1
- /// <reference types="react" />
2
1
  /// <reference types="lodash" />
3
2
  import type { CheckResult } from 'schema-typed';
4
- import { FormInstance } from './useFormRef';
5
3
  export interface FormErrorProps {
6
- ref: React.Ref<FormInstance>;
7
4
  formValue: any;
8
5
  getCombinedModel: () => any;
9
6
  onCheck?: (formError: any) => void;
@@ -11,9 +8,14 @@ export interface FormErrorProps {
11
8
  nestedField?: boolean;
12
9
  }
13
10
  export default function useFormValidate(formError: any, props: FormErrorProps): {
14
- formRef: import("react").RefObject<HTMLFormElement>;
15
11
  formError: any;
16
12
  check: (...args: any[]) => any;
13
+ checkForField: (...args: any[]) => any;
14
+ checkAsync: (...args: any[]) => any;
15
+ checkForFieldAsync: (...args: any[]) => any;
16
+ cleanErrors: (...args: any[]) => any;
17
+ resetErrors: (...args: any[]) => any;
18
+ cleanErrorForField: (...args: any[]) => any;
17
19
  setFieldError: (fieldName: string, checkResult: string | CheckResult) => any;
18
20
  onRemoveError: (name: string) => import("lodash").Omit<any, string>;
19
21
  };
@@ -6,10 +6,8 @@ import set from 'lodash/set';
6
6
  import { useControlled } from '../../utils';
7
7
  import { nameToPath } from '../../FormControl/utils';
8
8
  import useEventCallback from '../../utils/useEventCallback';
9
- import useFormRef from './useFormRef';
10
9
  export default function useFormValidate(formError, props) {
11
- var ref = props.ref,
12
- formValue = props.formValue,
10
+ var formValue = props.formValue,
13
11
  getCombinedModel = props.getCombinedModel,
14
12
  onCheck = props.onCheck,
15
13
  onError = props.onError,
@@ -133,19 +131,27 @@ export default function useFormValidate(formError, props) {
133
131
  onCheck === null || onCheck === void 0 ? void 0 : onCheck(nextFormError);
134
132
  return nextFormError;
135
133
  }, [formError, nestedField, onCheck, onError, setFormError]);
136
- var formRef = useFormRef(ref, {
137
- check: check,
138
- checkForField: checkForField,
139
- checkAsync: checkAsync,
140
- checkForFieldAsync: checkForFieldAsync,
141
- formError: formError,
142
- setFormError: setFormError,
143
- nestedField: nestedField
134
+ var cleanErrors = useEventCallback(function () {
135
+ setFormError({});
136
+ });
137
+ var resetErrors = useEventCallback(function (formError) {
138
+ if (formError === void 0) {
139
+ formError = {};
140
+ }
141
+ setFormError(formError);
142
+ });
143
+ var cleanErrorForField = useEventCallback(function (fieldName) {
144
+ setFormError(omit(formError, [nestedField ? nameToPath(fieldName) : fieldName]));
144
145
  });
145
146
  return {
146
- formRef: formRef,
147
147
  formError: realFormError,
148
148
  check: check,
149
+ checkForField: checkForField,
150
+ checkAsync: checkAsync,
151
+ checkForFieldAsync: checkForFieldAsync,
152
+ cleanErrors: cleanErrors,
153
+ resetErrors: resetErrors,
154
+ cleanErrorForField: cleanErrorForField,
149
155
  setFieldError: setFieldError,
150
156
  onRemoveError: onRemoveError
151
157
  };
@@ -1,7 +1,14 @@
1
1
  /// <reference types="lodash" />
2
- export default function useFormValue(controlledValue: any, props: any): {
2
+ declare type RecordAny = Record<string, any>;
3
+ interface UseFormValueProps<V = RecordAny> {
4
+ formDefaultValue: V;
5
+ nestedField: boolean;
6
+ }
7
+ export default function useFormValue<V>(controlledValue: any, props: UseFormValueProps<V>): {
3
8
  formValue: any;
4
9
  setFormValue: (value: any) => void;
5
10
  setFieldValue: (fieldName: string, fieldValue: any) => any;
6
11
  onRemoveValue: (name: string) => import("lodash").Omit<any, string>;
12
+ resetFormValue: (nextValue?: V) => V;
7
13
  };
14
+ export {};
@@ -28,10 +28,16 @@ export default function useFormValue(controlledValue, props) {
28
28
  setFormValue(formValue);
29
29
  return formValue;
30
30
  }, [setFormValue]);
31
+ var resetFormValue = useCallback(function (nextValue) {
32
+ var value = nextValue || formDefaultValue;
33
+ setFormValue(value);
34
+ return value;
35
+ }, [formDefaultValue, setFormValue]);
31
36
  return {
32
37
  formValue: formValue,
33
38
  setFormValue: setFormValue,
34
39
  setFieldValue: setFieldValue,
35
- onRemoveValue: onRemoveValue
40
+ onRemoveValue: onRemoveValue,
41
+ resetFormValue: resetFormValue
36
42
  };
37
43
  }
@@ -42,9 +42,9 @@ var useInputWidth = function useInputWidth(props, sizerRef, placeholderRef) {
42
42
  }
43
43
  var width;
44
44
  if (placeholder && !value && placeholderRef.current) {
45
- width = Math.max(sizerRef.current.scrollWidth, placeholderRef.current.scrollWidth) + 2;
45
+ width = Math.max(sizerRef.current.scrollWidth, placeholderRef.current.scrollWidth) + 10;
46
46
  } else {
47
- width = sizerRef.current.scrollWidth + 2;
47
+ width = sizerRef.current.scrollWidth + 10;
48
48
  }
49
49
  if (width < minWidth) {
50
50
  width = minWidth;
@@ -1,24 +1,22 @@
1
1
  import React from 'react';
2
2
  import { PickerComponent, PickerToggleProps } from '../internals/Picker';
3
+ import { type InputItemDataType } from './hooks/useData';
3
4
  import type { ItemDataType, FormControlPickerProps } from '../@types/common';
4
5
  import type { InputPickerLocale } from '../locales';
5
6
  import type { SelectProps } from '../SelectPicker';
6
- export interface InputItemDataType extends ItemDataType {
7
- create?: boolean;
8
- }
9
7
  export declare type ValueType = any;
10
- export interface InputPickerProps<T = ValueType> extends FormControlPickerProps<T, InputPickerLocale, InputItemDataType>, SelectProps<T>, Pick<PickerToggleProps, 'caretAs' | 'loading'> {
8
+ export interface InputPickerProps<V = ValueType> extends FormControlPickerProps<V, InputPickerLocale, InputItemDataType>, SelectProps<V>, Pick<PickerToggleProps, 'caretAs' | 'loading'> {
11
9
  tabIndex?: number;
12
10
  /** Settings can create new options */
13
11
  creatable?: boolean;
14
12
  /** Option to cache value when searching asynchronously */
15
- cacheData?: InputItemDataType[];
13
+ cacheData?: InputItemDataType<V>[];
16
14
  /** The `onBlur` attribute for the `input` element. */
17
15
  onBlur?: React.FocusEventHandler;
18
16
  /** The `onFocus` attribute for the `input` element. */
19
17
  onFocus?: React.FocusEventHandler;
20
18
  /** Called when the option is created */
21
- onCreate?: (value: ValueType, item: ItemDataType, event: React.SyntheticEvent) => void;
19
+ onCreate?: (value: V, item: ItemDataType, event: React.SyntheticEvent) => void;
22
20
  /**
23
21
  * Customize whether to display "Create option" action with given textbox value
24
22
  *
@@ -27,7 +25,7 @@ export interface InputPickerProps<T = ValueType> extends FormControlPickerProps<
27
25
  * @param searchKeyword Value of the textbox
28
26
  * @param filteredData The items filtered by the searchKeyword
29
27
  */
30
- shouldDisplayCreateOption?: (searchKeyword: string, filteredData: InputItemDataType[]) => boolean;
28
+ shouldDisplayCreateOption?: (searchKeyword: string, filteredData: InputItemDataType<V>[]) => boolean;
31
29
  }
32
30
  /**
33
31
  * Single item selector with text box input.