@tidbcloud/uikit 2.0.0 → 2.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @tidbcloud/uikit
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(uikit): bug fix of SearchArea component
8
+ - feat: fix input reset bug ([#440](https://github.com/tidbcloud/tidbcloud-uikit/pull/440))
9
+
3
10
  ## 2.0.0
4
11
 
5
12
  ### Major Changes
@@ -49,7 +49,9 @@ function FormItemRender(props) {
49
49
  {
50
50
  name,
51
51
  value: keyword,
52
- onChange: (e) => setKeyword(e.target.value),
52
+ onChange: (e) => {
53
+ setKeyword(e.target.value);
54
+ },
53
55
  placeholder: placeholder ?? "",
54
56
  onKeyDown: onKeyDownHandler,
55
57
  rightSection: !!keyword && /* @__PURE__ */ jsxRuntime.jsx(
@@ -59,6 +61,8 @@ function FormItemRender(props) {
59
61
  size: 14,
60
62
  onClick: () => {
61
63
  setKeyword("");
64
+ props.form.setValue(name, "");
65
+ triggerSubmit();
62
66
  }
63
67
  }
64
68
  ),
@@ -131,7 +135,7 @@ function FormItemRender(props) {
131
135
  return null;
132
136
  }
133
137
  }
134
- const DEFAULT_FORM_STATE_KEY = "__fs__";
138
+ const DEFAULT_FORM_STATE_KEY = "__fs";
135
139
  function SearchArea(props) {
136
140
  const { data, onSubmit, recoverFromURLEnabled, defaultValues, formStateQueryKey, ...rest } = props;
137
141
  const [resetSeed, setResetSeed] = React.useState(0);
@@ -158,6 +162,7 @@ function SearchArea(props) {
158
162
  data.map((x) => /* @__PURE__ */ jsxRuntime.jsx(
159
163
  FormItemRender,
160
164
  {
165
+ form,
161
166
  data: x,
162
167
  onSubmit: handleSubmit,
163
168
  defaultValue: state[x.name],
@@ -46,6 +46,6 @@ export interface SearchAreaProps<T extends FieldValues> extends FormProps<T> {
46
46
  /**
47
47
  * Please use `formStateQueryKey` instead if you have multiple <SearchArea /> components in the same page
48
48
  */
49
- export declare const DEFAULT_FORM_STATE_KEY = "__fs__";
49
+ export declare const DEFAULT_FORM_STATE_KEY = "__fs";
50
50
  export declare function SearchArea<T extends object>(props: SearchAreaProps<T>): import("react/jsx-runtime.js").JSX.Element;
51
51
  export {};
@@ -46,6 +46,6 @@ export interface SearchAreaProps<T extends FieldValues> extends FormProps<T> {
46
46
  /**
47
47
  * Please use `formStateQueryKey` instead if you have multiple <SearchArea /> components in the same page
48
48
  */
49
- export declare const DEFAULT_FORM_STATE_KEY = "__fs__";
49
+ export declare const DEFAULT_FORM_STATE_KEY = "__fs";
50
50
  export declare function SearchArea<T extends object>(props: SearchAreaProps<T>): import("react/jsx-runtime.js").JSX.Element;
51
51
  export {};
@@ -47,7 +47,9 @@ function FormItemRender(props) {
47
47
  {
48
48
  name,
49
49
  value: keyword,
50
- onChange: (e) => setKeyword(e.target.value),
50
+ onChange: (e) => {
51
+ setKeyword(e.target.value);
52
+ },
51
53
  placeholder: placeholder ?? "",
52
54
  onKeyDown: onKeyDownHandler,
53
55
  rightSection: !!keyword && /* @__PURE__ */ jsx(
@@ -57,6 +59,8 @@ function FormItemRender(props) {
57
59
  size: 14,
58
60
  onClick: () => {
59
61
  setKeyword("");
62
+ props.form.setValue(name, "");
63
+ triggerSubmit();
60
64
  }
61
65
  }
62
66
  ),
@@ -129,7 +133,7 @@ function FormItemRender(props) {
129
133
  return null;
130
134
  }
131
135
  }
132
- const DEFAULT_FORM_STATE_KEY = "__fs__";
136
+ const DEFAULT_FORM_STATE_KEY = "__fs";
133
137
  function SearchArea(props) {
134
138
  const { data, onSubmit, recoverFromURLEnabled, defaultValues, formStateQueryKey, ...rest } = props;
135
139
  const [resetSeed, setResetSeed] = useState(0);
@@ -156,6 +160,7 @@ function SearchArea(props) {
156
160
  data.map((x) => /* @__PURE__ */ jsx(
157
161
  FormItemRender,
158
162
  {
163
+ form,
159
164
  data: x,
160
165
  onSubmit: handleSubmit,
161
166
  defaultValue: state[x.name],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidbcloud/uikit",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "tidbcloud uikit",
5
5
  "type": "module",
6
6
  "main": "dist/primitive/index.cjs",