@tidbcloud/uikit 2.0.2 → 2.0.4

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,20 @@
1
1
  # @tidbcloud/uikit
2
2
 
3
+ ## 2.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(uikit): fix SearchArea components bugs
8
+ - Feat/search area fix ([#448](https://github.com/tidbcloud/tidbcloud-uikit/pull/448))
9
+ - chore: add type checking for UIKit in CI/CD pipeline ([#447](https://github.com/tidbcloud/tidbcloud-uikit/pull/447))
10
+ - feat(story): add RadioCard story demonstrating card-style radio selection ([#446](https://github.com/tidbcloud/tidbcloud-uikit/pull/446))
11
+
12
+ ## 2.0.3
13
+
14
+ ### Patch Changes
15
+
16
+ - fix(SearchArea): allow undefined values in search area type ([#444](https://github.com/tidbcloud/tidbcloud-uikit/pull/444))
17
+
3
18
  ## 2.0.2
4
19
 
5
20
  ### Patch Changes
@@ -17,6 +17,7 @@ export interface FormProps<T extends FieldValues = object> extends BoxProps, Omi
17
17
  stopPropagation?: boolean;
18
18
  preventDefault?: boolean;
19
19
  onSubmit: SubmitHandler<T>;
20
+ onRefresh?: () => void;
20
21
  onError?: () => any;
21
22
  onCancel?: () => void;
22
23
  onFormUnMount?: () => void;
@@ -17,6 +17,7 @@ export interface FormProps<T extends FieldValues = object> extends BoxProps, Omi
17
17
  stopPropagation?: boolean;
18
18
  preventDefault?: boolean;
19
19
  onSubmit: SubmitHandler<T>;
20
+ onRefresh?: () => void;
20
21
  onError?: () => any;
21
22
  onCancel?: () => void;
22
23
  onFormUnMount?: () => void;
@@ -124,6 +124,7 @@ function FormItemRender(props) {
124
124
  {
125
125
  name,
126
126
  value: keyword,
127
+ clearable: true,
127
128
  onChange: (val) => {
128
129
  setKeyword(val);
129
130
  triggerSubmit();
@@ -137,7 +138,7 @@ function FormItemRender(props) {
137
138
  }
138
139
  const DEFAULT_FORM_STATE_KEY = "__fs";
139
140
  function SearchArea(props) {
140
- const { data, onSubmit, recoverFromURLEnabled, defaultValues, formStateQueryKey, ...rest } = props;
141
+ const { data, onSubmit, onRefresh, recoverFromURLEnabled, defaultValues, formStateQueryKey, ...rest } = props;
141
142
  const [resetSeed, setResetSeed] = React.useState(0);
142
143
  const [formState, setFormState] = useURLQueryState.useURLQueryState(formStateQueryKey ?? DEFAULT_FORM_STATE_KEY, defaultValues);
143
144
  const state = recoverFromURLEnabled ? formState : defaultValues;
@@ -150,8 +151,12 @@ function SearchArea(props) {
150
151
  const handleReset = () => {
151
152
  setResetSeed(resetSeed + 1);
152
153
  form.reset(defaultValues);
154
+ onSubmit(form.getValues());
153
155
  recoverFromURLEnabled && setFormState(defaultValues);
154
156
  };
157
+ const handleRefresh = () => {
158
+ onRefresh && onRefresh();
159
+ };
155
160
  React.useEffect(() => {
156
161
  if (recoverFromURLEnabled) {
157
162
  handleSubmit();
@@ -175,7 +180,7 @@ function SearchArea(props) {
175
180
  /* @__PURE__ */ jsxRuntime.jsx(index$1.IconEraser, { size: 16, style: { marginRight: 4 } }),
176
181
  "Clear Filters"
177
182
  ] }) }),
178
- /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { ml: 16, sx: SX_Y_MID, children: /* @__PURE__ */ jsxRuntime.jsx(index.Button, { variant: "subtle", onClick: handleSubmit, children: /* @__PURE__ */ jsxRuntime.jsx(index$1.IconRefreshCw01, { size: 16 }) }) })
183
+ onRefresh && /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { ml: 16, sx: SX_Y_MID, children: /* @__PURE__ */ jsxRuntime.jsx(index.Button, { variant: "subtle", onClick: handleRefresh, children: /* @__PURE__ */ jsxRuntime.jsx(index$1.IconRefreshCw01, { size: 16 }) }) })
179
184
  ] })
180
185
  ] }) }),
181
186
  props.debugEnabled && /* @__PURE__ */ jsxRuntime.jsxs(Box.Box, { sx: { height: 320 }, children: [
@@ -2,7 +2,7 @@ import { FieldValues } from 'react-hook-form';
2
2
  import { BoxProps } from '../../primitive/index.cjs';
3
3
  import { FormProps } from '../Form/index.cjs';
4
4
  import { TimeRange } from '../TimeRangePicker/helpers.cjs';
5
- export type TSearchAreaValue = string | string[] | Date | TimeRange;
5
+ export type TSearchAreaValue = string | string[] | Date | TimeRange | undefined;
6
6
  interface IFormItemBase {
7
7
  name: string;
8
8
  placeholder?: string;
@@ -2,7 +2,7 @@ import { FieldValues } from 'react-hook-form';
2
2
  import { BoxProps } from '../../primitive/index.mjs';
3
3
  import { FormProps } from '../Form/index.mjs';
4
4
  import { TimeRange } from '../TimeRangePicker/helpers.mjs';
5
- export type TSearchAreaValue = string | string[] | Date | TimeRange;
5
+ export type TSearchAreaValue = string | string[] | Date | TimeRange | undefined;
6
6
  interface IFormItemBase {
7
7
  name: string;
8
8
  placeholder?: string;
@@ -122,6 +122,7 @@ function FormItemRender(props) {
122
122
  {
123
123
  name,
124
124
  value: keyword,
125
+ clearable: true,
125
126
  onChange: (val) => {
126
127
  setKeyword(val);
127
128
  triggerSubmit();
@@ -135,7 +136,7 @@ function FormItemRender(props) {
135
136
  }
136
137
  const DEFAULT_FORM_STATE_KEY = "__fs";
137
138
  function SearchArea(props) {
138
- const { data, onSubmit, recoverFromURLEnabled, defaultValues, formStateQueryKey, ...rest } = props;
139
+ const { data, onSubmit, onRefresh, recoverFromURLEnabled, defaultValues, formStateQueryKey, ...rest } = props;
139
140
  const [resetSeed, setResetSeed] = useState(0);
140
141
  const [formState, setFormState] = useURLQueryState(formStateQueryKey ?? DEFAULT_FORM_STATE_KEY, defaultValues);
141
142
  const state = recoverFromURLEnabled ? formState : defaultValues;
@@ -148,8 +149,12 @@ function SearchArea(props) {
148
149
  const handleReset = () => {
149
150
  setResetSeed(resetSeed + 1);
150
151
  form.reset(defaultValues);
152
+ onSubmit(form.getValues());
151
153
  recoverFromURLEnabled && setFormState(defaultValues);
152
154
  };
155
+ const handleRefresh = () => {
156
+ onRefresh && onRefresh();
157
+ };
153
158
  useEffect(() => {
154
159
  if (recoverFromURLEnabled) {
155
160
  handleSubmit();
@@ -173,7 +178,7 @@ function SearchArea(props) {
173
178
  /* @__PURE__ */ jsx(IconEraser, { size: 16, style: { marginRight: 4 } }),
174
179
  "Clear Filters"
175
180
  ] }) }),
176
- /* @__PURE__ */ jsx(Box, { ml: 16, sx: SX_Y_MID, children: /* @__PURE__ */ jsx(Button, { variant: "subtle", onClick: handleSubmit, children: /* @__PURE__ */ jsx(IconRefreshCw01, { size: 16 }) }) })
181
+ onRefresh && /* @__PURE__ */ jsx(Box, { ml: 16, sx: SX_Y_MID, children: /* @__PURE__ */ jsx(Button, { variant: "subtle", onClick: handleRefresh, children: /* @__PURE__ */ jsx(IconRefreshCw01, { size: 16 }) }) })
177
182
  ] })
178
183
  ] }) }),
179
184
  props.debugEnabled && /* @__PURE__ */ jsxs(Box, { sx: { height: 320 }, children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidbcloud/uikit",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "tidbcloud uikit",
5
5
  "type": "module",
6
6
  "main": "dist/primitive/index.cjs",
@@ -136,6 +136,7 @@
136
136
  "test": "test",
137
137
  "copy:raw-icon": "mkdir -p ./dist/icons/raw && cpy 'src/icons/raw/*.svg' ./dist/icons/raw/",
138
138
  "build:icon": "tsx ./scripts/icon.ts",
139
- "build": "vite build && pnpm run copy:raw-icon"
139
+ "build": "vite build && pnpm run copy:raw-icon",
140
+ "type-check": "tsc --noEmit"
140
141
  }
141
142
  }