@ldkj/web-ui 0.18.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.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 ldkj
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ldkj
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -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 {};
@@ -5,5 +5,19 @@ export type AlertProps = React.HTMLAttributes<HTMLDivElement> & {
5
5
  variant?: AlertVariant;
6
6
  title?: React.ReactNode;
7
7
  description?: React.ReactNode;
8
+ /** Custom leading icon. Pass showIcon to use the built-in tone marker. */
9
+ icon?: React.ReactNode;
10
+ /** Whether to render the leading icon area. */
11
+ showIcon?: boolean;
12
+ /** Optional trailing action, such as a retry button or detail link. */
13
+ action?: React.ReactNode;
14
+ /** Render a close button. */
15
+ closable?: boolean;
16
+ /** Controlled visibility. */
17
+ open?: boolean;
18
+ /** Fired after the close button is clicked. */
19
+ onClose?: () => void;
20
+ /** Controlled visibility callback. */
21
+ onOpenChange?: (open: boolean) => void;
8
22
  };
9
- export declare function Alert(props: AlertProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare function Alert(props: AlertProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,11 +1,29 @@
1
1
  import * as React from "react";
2
- export type DrawerProps = {
2
+ export type DrawerPlacement = "left" | "right" | "top" | "bottom";
3
+ export type DrawerProps = React.HTMLAttributes<HTMLDivElement> & {
3
4
  open: boolean;
4
5
  title?: React.ReactNode;
5
6
  width?: number | string;
7
+ height?: number | string;
8
+ placement?: DrawerPlacement;
6
9
  className?: string;
7
10
  class?: string;
11
+ overlayClassName?: string;
12
+ bodyClassName?: string;
13
+ footer?: React.ReactNode;
8
14
  children?: React.ReactNode;
9
15
  onOpenChange?: (open: boolean) => void;
16
+ /** Enables slide/fade transitions. Set false when a test or host app needs instant state changes. */
17
+ animated?: boolean;
18
+ /** Transition duration in ms. */
19
+ animationDuration?: number;
20
+ /** Locks document scrolling while the drawer is open. */
21
+ lockScroll?: boolean;
22
+ /** Close when clicking the mask. */
23
+ maskClosable?: boolean;
24
+ /** Close when pressing Escape. */
25
+ closeOnEsc?: boolean;
26
+ /** Keep content mounted after close. */
27
+ destroyOnClose?: boolean;
10
28
  };
11
29
  export declare function Drawer(props: DrawerProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,3 +1,19 @@
1
- export declare function Loading({ text }: {
2
- text?: string;
3
- }): import("react/jsx-runtime").JSX.Element;
1
+ import * as React from "react";
2
+ import { type SpinProps } from "@/components/interact/spin";
3
+ export type LoadingVariant = "inline" | "block" | "overlay" | "fullscreen";
4
+ export type LoadingProps = React.HTMLAttributes<HTMLDivElement> & {
5
+ /** Loading text. Set to null to hide text while keeping the spinner. */
6
+ text?: React.ReactNode;
7
+ /** Layout mode for inline hints, blocks, overlays, or full-screen masks. */
8
+ variant?: LoadingVariant;
9
+ /** Spinner size. Numbers are treated as px. */
10
+ size?: SpinProps["size"];
11
+ /** Spinner tone. */
12
+ tone?: SpinProps["tone"];
13
+ /** Set to false to hide loading state without unmounting wrapped children. */
14
+ spinning?: boolean;
15
+ /** Delay in ms before showing the loading indicator. */
16
+ delay?: number;
17
+ class?: string;
18
+ };
19
+ export declare function Loading(props: LoadingProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,8 +1,18 @@
1
1
  import * as React from "react";
2
+ export type ProgressType = "line" | "circle";
3
+ export type ProgressStatus = "normal" | "success" | "warning" | "exception";
4
+ export type ProgressSize = "xs" | "sm" | "md" | "lg" | "xl" | number;
2
5
  export type ProgressProps = React.HTMLAttributes<HTMLDivElement> & {
3
6
  value?: number;
4
7
  max?: number;
5
8
  showInfo?: boolean;
9
+ type?: ProgressType;
10
+ status?: ProgressStatus;
11
+ size?: ProgressSize;
12
+ strokeWidth?: number;
13
+ strokeColor?: string;
14
+ trailColor?: string;
15
+ format?: (percent: number, value: number, max: number) => React.ReactNode;
6
16
  class?: string;
7
17
  };
8
18
  export declare function Progress(props: ProgressProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,16 @@
1
1
  import * as React from "react";
2
+ export type SpinTone = "primary" | "muted" | "success" | "warning" | "danger";
2
3
  export type SpinProps = React.HTMLAttributes<HTMLSpanElement> & {
3
- size?: number;
4
+ /** Spinner size. Numbers are treated as px. */
5
+ size?: number | string;
6
+ /** Ring stroke width. Numbers are treated as px. */
7
+ strokeWidth?: number | string;
8
+ /** Color tone for the active ring segment. */
9
+ tone?: SpinTone;
10
+ /** Accessible label announced by screen readers. */
11
+ label?: string;
12
+ /** Set to false to suppress the spinner without branching in user code. */
13
+ spinning?: boolean;
4
14
  class?: string;
5
15
  };
6
- export declare function Spin(props: SpinProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function Spin(props: SpinProps): import("react/jsx-runtime").JSX.Element | null;