@ldkj/web-ui 0.19.0 → 0.20.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.
@@ -1,2 +1 @@
1
1
  export * from "./input";
2
- export * from "./useInputValue";
@@ -1,14 +1,45 @@
1
1
  import * as React from "react";
2
2
  import { type SxProps } from "@/styling";
3
- export type InputProps = React.ComponentPropsWithoutRef<"input"> & {
3
+ export type InputSlotProps = {
4
+ children?: React.ReactNode;
5
+ };
6
+ export type InputAddonProps = InputSlotProps & {
7
+ position?: "before" | "after";
8
+ };
9
+ export type InputProps = Omit<React.ComponentPropsWithoutRef<"input">, "prefix"> & {
10
+ addonAfter?: React.ReactNode;
11
+ addonBefore?: React.ReactNode;
4
12
  class?: string;
13
+ prefix?: React.ReactNode;
14
+ suffix?: React.ReactNode;
5
15
  sx?: SxProps;
6
16
  };
7
- /**
8
- * Input 是基础文本输入框组件,支持原生 input 属性、`class` 别名与本库 `sx` 样式系统。
9
- */
10
- declare const Input: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & {
17
+ export declare const Input: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "prefix"> & {
18
+ addonAfter?: React.ReactNode;
19
+ addonBefore?: React.ReactNode;
11
20
  class?: string;
21
+ prefix?: React.ReactNode;
22
+ suffix?: React.ReactNode;
12
23
  sx?: SxProps;
13
- } & React.RefAttributes<HTMLInputElement>>;
14
- export { Input };
24
+ } & React.RefAttributes<HTMLInputElement>> & {
25
+ Addon: {
26
+ (props: InputAddonProps): import("react/jsx-runtime").JSX.Element;
27
+ displayName: string;
28
+ };
29
+ AddonAfter: {
30
+ (props: InputSlotProps): import("react/jsx-runtime").JSX.Element;
31
+ displayName: string;
32
+ };
33
+ AddonBefore: {
34
+ (props: InputSlotProps): import("react/jsx-runtime").JSX.Element;
35
+ displayName: string;
36
+ };
37
+ Prefix: {
38
+ (props: InputSlotProps): import("react/jsx-runtime").JSX.Element;
39
+ displayName: string;
40
+ };
41
+ Suffix: {
42
+ (props: InputSlotProps): import("react/jsx-runtime").JSX.Element;
43
+ displayName: string;
44
+ };
45
+ };
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { type InputProps } from "@/components/form/input";
3
- export type InputNumberValueChangeReason = "input" | "commit";
3
+ export type InputNumberValueChangeReason = "input" | "commit" | "set";
4
4
  export type InputNumberValueChangeMeta = {
5
5
  reason: InputNumberValueChangeReason;
6
6
  valueAsString: string;
7
- event: React.ChangeEvent<HTMLInputElement> | React.FocusEvent<HTMLInputElement>;
7
+ event?: React.ChangeEvent<HTMLInputElement> | React.FocusEvent<HTMLInputElement> | React.KeyboardEvent<HTMLInputElement>;
8
8
  };
9
9
  export type InputNumberProps = Omit<InputProps, "type" | "inputMode"> & {
10
10
  min?: number;
@@ -16,6 +16,32 @@ export type InputNumberProps = Omit<InputProps, "type" | "inputMode"> & {
16
16
  precision?: number;
17
17
  /** 返回解析后的数值;空值或非法临时值返回 `null`。 */
18
18
  onValueChange?: (value: number | null, meta: InputNumberValueChangeMeta) => void;
19
+ /** 输入值提交时触发,默认在失焦或按下 Enter 时提交。 */
20
+ onValueCommit?: (value: number | null, meta: InputNumberValueChangeMeta) => void;
21
+ };
22
+ export type NumberInputValue = string | number | null;
23
+ export type UseNumberInputOptions = NormalizeOptions & {
24
+ value?: NumberInputValue;
25
+ defaultValue?: string | number | null;
26
+ onValueChange?: (value: number | null, meta: InputNumberValueChangeMeta) => void;
27
+ onValueCommit?: (value: number | null, meta: InputNumberValueChangeMeta) => void;
28
+ };
29
+ export type UseNumberInputGetInputProps = Omit<InputProps, "defaultValue" | "inputMode" | "max" | "min" | "onBlur" | "onChange" | "onKeyDown" | "step" | "type" | "value"> & {
30
+ disabled?: boolean;
31
+ readOnly?: boolean;
32
+ onBlur?: React.FocusEventHandler<HTMLInputElement>;
33
+ onChange?: React.ChangeEventHandler<HTMLInputElement>;
34
+ onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
35
+ };
36
+ export type UseNumberInputResult = {
37
+ value: string;
38
+ numberValue: number | null;
39
+ setValue: (value: NumberInputValue) => void;
40
+ commitValue: (value?: NumberInputValue) => {
41
+ value: number | null;
42
+ valueAsString: string;
43
+ };
44
+ getInputProps: (props?: UseNumberInputGetInputProps) => InputProps;
19
45
  };
20
46
  export type UseInputNumberStateOptions = NormalizeOptions & {
21
47
  defaultValue?: string | number | null;
@@ -29,8 +55,11 @@ export type UseInputNumberStateResult = {
29
55
  };
30
56
  type NormalizeOptions = Pick<InputNumberProps, "clampOnBlur" | "max" | "min" | "precision" | "step">;
31
57
  /**
32
- * 管理 InputNumber 的字符串输入态与解析后的数字值。
33
- * 它会自动同步 `clampOnBlur` 产生的提交值,避免业务侧手写 commit 分支。
58
+ * 提供数字输入的 headless 行为层,统一管理字符串展示值、解析值和提交归一化。
59
+ */
60
+ export declare function useNumberInput(options?: UseNumberInputOptions): UseNumberInputResult;
61
+ /**
62
+ * @deprecated 优先使用 `useNumberInput`,通过 `getInputProps()` 组合输入控件。
34
63
  */
35
64
  export declare function useInputNumberState(options?: UseInputNumberStateOptions): UseInputNumberStateResult;
36
65
  /**
@@ -47,5 +76,7 @@ export declare const InputNumber: React.ForwardRefExoticComponent<Omit<InputProp
47
76
  precision?: number;
48
77
  /** 返回解析后的数值;空值或非法临时值返回 `null`。 */
49
78
  onValueChange?: (value: number | null, meta: InputNumberValueChangeMeta) => void;
79
+ /** 输入值提交时触发,默认在失焦或按下 Enter 时提交。 */
80
+ onValueCommit?: (value: number | null, meta: InputNumberValueChangeMeta) => void;
50
81
  } & React.RefAttributes<HTMLInputElement>>;
51
82
  export {};
@@ -1,13 +1,14 @@
1
1
  import * as React from "react";
2
2
  export type ProgressType = "line" | "circle";
3
3
  export type ProgressStatus = "normal" | "success" | "warning" | "exception";
4
+ export type ProgressSize = "xs" | "sm" | "md" | "lg" | "xl" | number;
4
5
  export type ProgressProps = React.HTMLAttributes<HTMLDivElement> & {
5
6
  value?: number;
6
7
  max?: number;
7
8
  showInfo?: boolean;
8
9
  type?: ProgressType;
9
10
  status?: ProgressStatus;
10
- size?: number;
11
+ size?: ProgressSize;
11
12
  strokeWidth?: number;
12
13
  strokeColor?: string;
13
14
  trailColor?: string;