knight-ui 1.0.4 → 1.0.6
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/README.md +33 -2
- package/component/feedback/Popconfirm.d.ts +1 -1
- package/component/input/Form.d.ts +3 -0
- package/component/input/Input.d.ts +5 -7
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1541,25 +1541,56 @@ import { Tooltip, Button } from "knight-ui";
|
|
|
1541
1541
|
|
|
1542
1542
|
```tsx
|
|
1543
1543
|
import { Popconfirm, Button } from "knight-ui";
|
|
1544
|
+
import { IconAlertTriangle } from "knight-ui";
|
|
1544
1545
|
|
|
1546
|
+
// 基础用法 (默认 position="bottom", trigger="click")
|
|
1545
1547
|
<Popconfirm
|
|
1546
1548
|
title="确定删除?"
|
|
1547
1549
|
content="删除后不可恢复"
|
|
1548
|
-
trigger="click"
|
|
1549
1550
|
onConfirm={() => console.log("confirmed")}
|
|
1550
1551
|
onCancel={() => console.log("cancelled")}
|
|
1551
1552
|
>
|
|
1552
1553
|
<Button type="danger">删除</Button>
|
|
1553
1554
|
</Popconfirm>
|
|
1555
|
+
|
|
1556
|
+
// 自定义按钮文字 + 图标
|
|
1557
|
+
<Popconfirm title="确定保存?" content="保存后覆盖原有数据"
|
|
1558
|
+
icon={<IconAlertTriangle size="extraLarge" color="var(--ku-color-warning)" />}
|
|
1559
|
+
okText="保存" cancelText="取消"
|
|
1560
|
+
onConfirm={() => console.log("saved")}>
|
|
1561
|
+
<Button type="warning">保存</Button>
|
|
1562
|
+
</Popconfirm>
|
|
1563
|
+
|
|
1564
|
+
// 8 方向弹出 (position)
|
|
1565
|
+
<Popconfirm title="确认?" position="leftTop" onConfirm={() => {}}>
|
|
1566
|
+
<Button>左上弹出</Button>
|
|
1567
|
+
</Popconfirm>
|
|
1568
|
+
<Popconfirm title="确认?" position="rightBottom" onConfirm={() => {}}>
|
|
1569
|
+
<Button>右下弹出</Button>
|
|
1570
|
+
</Popconfirm>
|
|
1571
|
+
|
|
1572
|
+
// hover 触发 + 带箭头
|
|
1573
|
+
<Popconfirm title="提示" content="悬停即可查看" trigger="hover" showArrow position="top"
|
|
1574
|
+
onConfirm={() => {}}>
|
|
1575
|
+
<Button type="secondary">悬停触发</Button>
|
|
1576
|
+
</Popconfirm>
|
|
1554
1577
|
```
|
|
1555
1578
|
|
|
1556
1579
|
| 属性 | 类型 | 默认值 | 说明 |
|
|
1557
1580
|
|---|---|---|---|
|
|
1558
1581
|
| `title` | `React.ReactNode` | — | 标题 |
|
|
1559
1582
|
| `content` | `React.ReactNode` | — | 内容 |
|
|
1560
|
-
| `
|
|
1583
|
+
| `position` | `"top" \| "bottom" \| "left" \| "right" \| "leftTop" \| "rightTop" \| "leftBottom" \| "rightBottom"` | `"bottom"` | 弹出位置(命名规则: 第一个词=左右, 第二个词=上下) |
|
|
1584
|
+
| `trigger` | `"click" \| "hover" \| "focus" \| "custom"` | `"click"` | 触发方式 |
|
|
1585
|
+
| `icon` | `React.ReactNode` | — | 自定义图标 |
|
|
1586
|
+
| `showArrow` | `boolean` | `false` | 显示箭头 |
|
|
1587
|
+
| `okText / cancelText` | `string` | `"确认" / "取消"` | 按钮文字 |
|
|
1588
|
+
| `okButtonProps / cancelButtonProps` | `ButtonHTMLAttributes` | — | 按钮额外属性 |
|
|
1589
|
+
| `visible / defaultVisible` | `boolean` | — | 受控/非受控显示 |
|
|
1590
|
+
| `offset` | `number` | `4` | 弹出偏移距离 |
|
|
1561
1591
|
| `onConfirm` | `(e) => void` | — | 确认回调 |
|
|
1562
1592
|
| `onCancel` | `(e) => void` | — | 取消回调 |
|
|
1593
|
+
| `onVisibleChange` | `(visible: boolean) => void` | — | 显示状态变化回调 |
|
|
1563
1594
|
|
|
1564
1595
|
### Calendar 日历
|
|
1565
1596
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AbstractUI, type UIProps, type UIState } from "../../base";
|
|
3
|
-
type PopconfirmPosition = "top" | "
|
|
3
|
+
type PopconfirmPosition = "top" | "bottom" | "left" | "right" | "leftTop" | "rightTop" | "leftBottom" | "rightBottom";
|
|
4
4
|
type PopconfirmTrigger = "click" | "hover" | "focus" | "custom";
|
|
5
5
|
/**
|
|
6
6
|
* 气泡确认框。
|
|
@@ -28,6 +28,7 @@ interface FormContextValue {
|
|
|
28
28
|
labelWidth: number;
|
|
29
29
|
disabled: boolean;
|
|
30
30
|
validating: boolean;
|
|
31
|
+
formKey: number;
|
|
31
32
|
}
|
|
32
33
|
declare class FormField extends AbstractUI<FormFieldProps, FormFieldState> {
|
|
33
34
|
static displayName: string;
|
|
@@ -83,6 +84,7 @@ export declare class Form extends AbstractUI<FormProps, FormState> {
|
|
|
83
84
|
private registerField;
|
|
84
85
|
private updateField;
|
|
85
86
|
private getValues;
|
|
87
|
+
private bumpFormKey;
|
|
86
88
|
private setValues;
|
|
87
89
|
private addField;
|
|
88
90
|
private removeField;
|
|
@@ -112,5 +114,6 @@ export interface FormProps extends UIProps {
|
|
|
112
114
|
}
|
|
113
115
|
interface FormState extends UIState {
|
|
114
116
|
validating: boolean;
|
|
117
|
+
formKey: number;
|
|
115
118
|
}
|
|
116
119
|
export {};
|
|
@@ -4,13 +4,12 @@ import type { ValidateStatus } from "../types";
|
|
|
4
4
|
declare class TextArea extends AbstractUI<TextAreaProps, TextAreaState> {
|
|
5
5
|
static displayName: string;
|
|
6
6
|
private textareaRef;
|
|
7
|
+
private _isComposing;
|
|
7
8
|
constructor(props: TextAreaProps);
|
|
8
|
-
componentDidUpdate(prevProps: Readonly<TextAreaProps>, _prevState: Readonly<TextAreaState>): void;
|
|
9
9
|
focus(): void;
|
|
10
10
|
protected OnRenderContent(): React.ReactElement;
|
|
11
11
|
}
|
|
12
12
|
export interface TextAreaProps extends UIProps {
|
|
13
|
-
/** 受控值(提供后组件变为受控模式) */
|
|
14
13
|
value?: string;
|
|
15
14
|
defaultValue?: string;
|
|
16
15
|
placeholder?: string;
|
|
@@ -21,24 +20,24 @@ export interface TextAreaProps extends UIProps {
|
|
|
21
20
|
onChange?: (value: string, event?: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
22
21
|
}
|
|
23
22
|
interface TextAreaState extends UIState {
|
|
24
|
-
value: string;
|
|
25
23
|
focused: boolean;
|
|
26
24
|
}
|
|
27
25
|
/**
|
|
28
|
-
*
|
|
26
|
+
* 输入框。
|
|
27
|
+
* - 受控模式: 传入 value,值完全由父组件控制
|
|
28
|
+
* - 非受控模式: 传入 defaultValue,浏览器原生管理输入内容,IME 无干扰
|
|
29
29
|
*/
|
|
30
30
|
export declare class Input extends AbstractUI<InputProps, InputState> {
|
|
31
31
|
static TextArea: typeof TextArea;
|
|
32
32
|
private inputRef;
|
|
33
|
+
private _isComposing;
|
|
33
34
|
constructor(props: InputProps);
|
|
34
|
-
componentDidUpdate(prevProps: Readonly<InputProps>, _prevState: Readonly<InputState>): void;
|
|
35
35
|
focus(): void;
|
|
36
36
|
blur(): void;
|
|
37
37
|
protected OnRenderContent(): React.ReactElement;
|
|
38
38
|
}
|
|
39
39
|
export interface InputProps extends UIProps {
|
|
40
40
|
type?: "text" | "password";
|
|
41
|
-
/** 受控值(提供后组件变为受控模式) */
|
|
42
41
|
value?: string;
|
|
43
42
|
defaultValue?: string;
|
|
44
43
|
placeholder?: string;
|
|
@@ -55,7 +54,6 @@ export interface InputProps extends UIProps {
|
|
|
55
54
|
onChange?: (value: string, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
56
55
|
}
|
|
57
56
|
interface InputState extends UIState {
|
|
58
|
-
value: string;
|
|
59
57
|
showPassword: boolean;
|
|
60
58
|
focused: boolean;
|
|
61
59
|
}
|