@vavt/react-ui 1.0.4 → 1.2.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/dist/{Anchor-QZROepM_.js → Anchor-CAZPkv56.js} +1 -1
- package/dist/{Anchor-iriRYxEs.cjs → Anchor-CmuV1Ump.cjs} +1 -1
- package/dist/{Announcement-XjJyJ28N.cjs → Announcement-D0hZE2sM.cjs} +1 -1
- package/dist/{Announcement-D_NccvTm.js → Announcement-DzzaTvcO.js} +1 -1
- package/dist/Checkbox-CBMmX-R-.js +86 -0
- package/dist/Checkbox-CzNGP2tH.cjs +1 -0
- package/dist/Checkbox-GJlGNzlH.cjs +1 -0
- package/dist/Checkbox-bHOjYdMp.js +61 -0
- package/dist/{Cron-Go4yIqrd.js → Cron-DIB4GG4y.js} +7 -7
- package/dist/{Cron-3D9GmlYf.cjs → Cron-MhbYMEeJ.cjs} +1 -1
- package/dist/{DatePicker-B-F5q_s_.js → DatePicker--13tW0cw.js} +1 -1
- package/dist/{DatePicker-CoHW85qm.cjs → DatePicker-Bj709smn.cjs} +1 -1
- package/dist/{DateTimePicker-BSBZZ7xV.js → DateTimePicker-Blqs2Bcv.js} +1 -1
- package/dist/{DateTimePicker-CAkdoY--.cjs → DateTimePicker-ZSScsk-j.cjs} +1 -1
- package/dist/{Drawer-D45miZ27.cjs → Drawer-DcbgMkub.cjs} +1 -1
- package/dist/{Drawer-C0toQ-fQ.js → Drawer-yM_r1M0H.js} +2 -2
- package/dist/{Dropdown-BsXYVdt6.cjs → Dropdown-PHqXNiAZ.cjs} +1 -1
- package/dist/{Dropdown-DljKFnvO.js → Dropdown-mYCY-LcF.js} +2 -2
- package/dist/Form-BkyDHPEI.cjs +1 -0
- package/dist/Form-D_Uv-8HG.js +449 -0
- package/dist/{Input-CIB_TY2n.js → Input-BRy5Xuwy.js} +28 -37
- package/dist/Input-C9ESmbJ7.cjs +1 -0
- package/dist/{MessageBox-CTJfdU29.cjs → MessageBox-BSMYQenX.cjs} +1 -1
- package/dist/{MessageBox-B4Qo1vs2.js → MessageBox-DipOfKXI.js} +2 -2
- package/dist/Modal-BOI8r4y1.cjs +1 -0
- package/dist/Modal-De9igZ5e.js +238 -0
- package/dist/{NumberInput-C_vLULbX.js → NumberInput-CB-nKZgs.js} +1 -1
- package/dist/{NumberInput-CYVj89_s.cjs → NumberInput-Dp1vTDkW.cjs} +1 -1
- package/dist/{Pagination-CSI5IzQB.js → Pagination-CpbboRbF.js} +2 -2
- package/dist/{Pagination-ODU-i3gn.cjs → Pagination-DatEegaF.cjs} +1 -1
- package/dist/RadioGroup-DTodR0VJ.cjs +1 -0
- package/dist/RadioGroup-DYjQMXdB.js +136 -0
- package/dist/Select-BHWa_6Q2.js +466 -0
- package/dist/Select-C6O0tmM_.cjs +1 -0
- package/dist/{Slider-BzlZc0p4.js → Slider-CKU03SsT.js} +1 -1
- package/dist/{Slider-DCIUxcBa.cjs → Slider-CU9OS2HB.cjs} +1 -1
- package/dist/{Switch-7yJ-Q_o_.cjs → Switch-CpXDMcPW.cjs} +1 -1
- package/dist/{Switch-DOO2tiYR.js → Switch-CqTFvp-k.js} +1 -1
- package/dist/Table-BNGO_7Rx.cjs +1 -0
- package/dist/Table-Cfs3XJgN.js +531 -0
- package/dist/{Tabs-BhjvKN84.cjs → Tabs-BZ0Zc0bL.cjs} +1 -1
- package/dist/{Tabs-VT6nQ63W.js → Tabs-HWLkyrQR.js} +1 -1
- package/dist/{Textarea-BEd7ToXv.js → Textarea-CA6Vzu7t.js} +1 -1
- package/dist/{Textarea-C2dNYM0F.cjs → Textarea-CEhAvE10.cjs} +1 -1
- package/dist/{TimePicker-CHZsr_jj.js → TimePicker-CYlcUTTM.js} +2 -2
- package/dist/{TimePicker-Cpmvn8tx.cjs → TimePicker-DoGbwfkU.cjs} +1 -1
- package/dist/{Tooltip-Buk5F9f_.js → Tooltip-BKPreZML.js} +2 -2
- package/dist/{Tooltip-CP8rpNYG.cjs → Tooltip-DDjGLjoV.cjs} +1 -1
- package/dist/{Upload-DZC_bt6G.js → Upload-DZ6VaM7r.js} +66 -65
- package/dist/Upload-wHEEoe1c.cjs +1 -0
- package/dist/base.css +1 -1
- package/dist/cjs/Anchor.cjs +1 -1
- package/dist/cjs/Announcement.cjs +1 -1
- package/dist/cjs/Checkbox.cjs +1 -1
- package/dist/cjs/Cron.cjs +1 -1
- package/dist/cjs/DatePicker.cjs +1 -1
- package/dist/cjs/DateTimePicker.cjs +1 -1
- package/dist/cjs/Drawer.cjs +1 -1
- package/dist/cjs/Dropdown.cjs +1 -1
- package/dist/cjs/Form.cjs +1 -1
- package/dist/cjs/Input.cjs +1 -1
- package/dist/cjs/MessageBox.cjs +1 -1
- package/dist/cjs/Modal.cjs +1 -1
- package/dist/cjs/NumberInput.cjs +1 -1
- package/dist/cjs/Pagination.cjs +1 -1
- package/dist/cjs/Radio.cjs +1 -1
- package/dist/cjs/Select.cjs +1 -1
- package/dist/cjs/Slider.cjs +1 -1
- package/dist/cjs/Switch.cjs +1 -1
- package/dist/cjs/Table.cjs +1 -1
- package/dist/cjs/Tabs.cjs +1 -1
- package/dist/cjs/Textarea.cjs +1 -1
- package/dist/cjs/TimePicker.cjs +1 -1
- package/dist/cjs/Tooltip.cjs +1 -1
- package/dist/cjs/Upload.cjs +1 -1
- package/dist/cjs/global.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/css/Alert.css +1 -1
- package/dist/css/Announcement.css +1 -1
- package/dist/css/Button.css +1 -1
- package/dist/css/Card.css +1 -1
- package/dist/css/Checkbox.css +1 -1
- package/dist/css/Cron.css +1 -1
- package/dist/css/DatePicker.css +1 -1
- package/dist/css/DateTimePicker.css +1 -1
- package/dist/css/Drawer.css +1 -1
- package/dist/css/Dropdown.css +1 -1
- package/dist/css/Empty.css +1 -1
- package/dist/css/Form.css +1 -1
- package/dist/css/Input.css +1 -1
- package/dist/css/MessageBox.css +1 -1
- package/dist/css/Modal.css +1 -1
- package/dist/css/NumberInput.css +1 -1
- package/dist/css/Progress.css +1 -1
- package/dist/css/Radio.css +1 -1
- package/dist/css/Select.css +1 -1
- package/dist/css/Sidebar.css +1 -1
- package/dist/css/Switch.css +1 -1
- package/dist/css/Tag.css +1 -1
- package/dist/css/Textarea.css +1 -1
- package/dist/css/TimePicker.css +1 -1
- package/dist/css/Tooltip.css +1 -1
- package/dist/css/Upload.css +1 -1
- package/dist/date-picker-Be_1wA3S.cjs +1 -0
- package/dist/date-picker-CHP0eBuL.js +612 -0
- package/dist/{dialog-shell-DehX3PNh.js → dialog-shell-CdYlPT9f.js} +12 -12
- package/dist/dialog-shell-CzeGytVj.cjs +1 -0
- package/dist/es/Anchor.mjs +1 -1
- package/dist/es/Announcement.mjs +1 -1
- package/dist/es/Checkbox.mjs +1 -1
- package/dist/es/Cron.mjs +1 -1
- package/dist/es/DatePicker.mjs +1 -1
- package/dist/es/DateTimePicker.mjs +1 -1
- package/dist/es/Drawer.mjs +1 -1
- package/dist/es/Dropdown.mjs +1 -1
- package/dist/es/Form.mjs +1 -1
- package/dist/es/Input.mjs +1 -1
- package/dist/es/MessageBox.mjs +1 -1
- package/dist/es/Modal.mjs +1 -1
- package/dist/es/NumberInput.mjs +1 -1
- package/dist/es/Pagination.mjs +1 -1
- package/dist/es/Radio.mjs +1 -1
- package/dist/es/Select.mjs +1 -1
- package/dist/es/Slider.mjs +1 -1
- package/dist/es/Switch.mjs +1 -1
- package/dist/es/Table.mjs +1 -1
- package/dist/es/Tabs.mjs +1 -1
- package/dist/es/Textarea.mjs +1 -1
- package/dist/es/TimePicker.mjs +1 -1
- package/dist/es/Tooltip.mjs +1 -1
- package/dist/es/Upload.mjs +1 -1
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +32 -32
- package/dist/es/register.mjs +1 -1
- package/dist/floating-5PRFyI8D.cjs +1 -0
- package/dist/floating-CqdcJWk2.js +181 -0
- package/dist/index.css +1 -1
- package/dist/registry-BLaletUC.js +83 -0
- package/dist/registry-hU7S5myb.cjs +1 -0
- package/dist/state-BSDh-Ob2.js +22 -0
- package/dist/state-BuUx1onZ.cjs +1 -0
- package/dist/style/Form.cjs +1 -0
- package/dist/style/Form.mjs +1 -0
- package/dist/style/Modal.cjs +1 -0
- package/dist/style/Modal.mjs +1 -0
- package/dist/types/Checkbox/context.d.cts +12 -2
- package/dist/types/Checkbox/context.d.ts +12 -2
- package/dist/types/Checkbox/type.d.cts +33 -3
- package/dist/types/Checkbox/type.d.ts +33 -3
- package/dist/types/Form/FormItem.d.cts +1 -1
- package/dist/types/Form/FormItem.d.ts +1 -1
- package/dist/types/Form/context.d.cts +31 -0
- package/dist/types/Form/context.d.ts +31 -0
- package/dist/types/Form/index.d.cts +2 -2
- package/dist/types/Form/index.d.ts +2 -2
- package/dist/types/Form/type.d.cts +1 -1
- package/dist/types/Form/type.d.ts +1 -1
- package/dist/types/Modal/type.d.cts +3 -3
- package/dist/types/Modal/type.d.ts +3 -3
- package/dist/types/Radio/context.d.cts +12 -2
- package/dist/types/Radio/context.d.ts +12 -2
- package/dist/types/Radio/type.d.cts +33 -3
- package/dist/types/Radio/type.d.ts +33 -3
- package/dist/types/Upload/type.d.cts +4 -0
- package/dist/types/Upload/type.d.ts +4 -0
- package/dist/types/_shared/state.d.cts +3 -0
- package/dist/types/_shared/state.d.ts +3 -0
- package/dist/types/registry.d.cts +1 -1
- package/dist/types/registry.d.ts +1 -1
- package/package.json +1 -1
- package/dist/Checkbox-BCXbK1-8.cjs +0 -1
- package/dist/Checkbox-CQZSg9Xu.cjs +0 -1
- package/dist/Checkbox-CQeqLO0S.js +0 -46
- package/dist/Checkbox-cnXHW9Oz.js +0 -61
- package/dist/Form-7un_DeDk.cjs +0 -1
- package/dist/Form-CwgaAZWr.js +0 -323
- package/dist/Input-CoDZggqc.cjs +0 -1
- package/dist/Modal-i_Do8GsG.cjs +0 -1
- package/dist/Modal-otJ_9ldu.js +0 -210
- package/dist/RadioGroup-BRcNi5Oc.js +0 -98
- package/dist/RadioGroup-q2Aa50NV.cjs +0 -1
- package/dist/Select-BRKxpX-_.cjs +0 -1
- package/dist/Select-QedbJ4pD.js +0 -468
- package/dist/Table-B9NTkptC.js +0 -440
- package/dist/Table-Bqjey5fw.cjs +0 -1
- package/dist/Upload-bxJz2avf.cjs +0 -1
- package/dist/date-picker-BsiNrLZC.js +0 -592
- package/dist/date-picker-DNN0BiRA.cjs +0 -1
- package/dist/dialog-shell-DT1EoKQG.cjs +0 -1
- package/dist/floating-DBAmeQIq.js +0 -157
- package/dist/floating-DXRnx48N.cjs +0 -1
- package/dist/registry-BGNWNSiC.cjs +0 -1
- package/dist/registry-q6UdMOyj.js +0 -83
- package/dist/state-ZBA75xZ_.cjs +0 -1
- package/dist/state-oH-YwB7_.js +0 -15
|
@@ -3,6 +3,10 @@ import type { HTMLAttributes, InputHTMLAttributes, ReactNode } from 'react';
|
|
|
3
3
|
export type RadioSize = 'sm' | 'md' | 'lg';
|
|
4
4
|
/** 单选框绑定的值类型 */
|
|
5
5
|
export type RadioValue = string | number | boolean;
|
|
6
|
+
/** 卡片模式下指示器位置:左上角 (top-left) | 右上角 (top-right) | 行首 (start) | 隐藏 (none) */
|
|
7
|
+
export type RadioIndicatorPlacement = 'top-left' | 'top-right' | 'start' | 'none';
|
|
8
|
+
/** 卡片模式下内容对齐方式:居左 (start) | 居中 (center) */
|
|
9
|
+
export type RadioAlign = 'start' | 'center';
|
|
6
10
|
/** Radio 根原生 input DOM 元素类型 */
|
|
7
11
|
export type RadioRef = HTMLInputElement;
|
|
8
12
|
/** RadioGroup 根 DOM 容器元素类型 */
|
|
@@ -10,7 +14,7 @@ export type RadioGroupRef = HTMLDivElement;
|
|
|
10
14
|
/**
|
|
11
15
|
* Radio 单体组件属性接口
|
|
12
16
|
*/
|
|
13
|
-
export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'value' | 'defaultValue' | 'checked' | 'defaultChecked' | 'onChange'> {
|
|
17
|
+
export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'value' | 'defaultValue' | 'checked' | 'defaultChecked' | 'onChange' | 'title'> {
|
|
14
18
|
/** 受控模式:当前是否处于选中状态 */
|
|
15
19
|
checked?: boolean;
|
|
16
20
|
/** 非受控模式:初始是否处于选中状态,默认为 false */
|
|
@@ -19,10 +23,26 @@ export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
19
23
|
value?: RadioValue;
|
|
20
24
|
/** 单选框标签文本(也可通过 children 传入) */
|
|
21
25
|
label?: ReactNode;
|
|
26
|
+
/** 卡片标题(card 模式或结构化展示时生效) */
|
|
27
|
+
title?: ReactNode;
|
|
28
|
+
/** 卡片辅助描述说明文案 */
|
|
29
|
+
description?: ReactNode;
|
|
30
|
+
/** 卡片右上角或附属扩展内容(如 Badge、Tag 等) */
|
|
31
|
+
extra?: ReactNode;
|
|
22
32
|
/** 是否禁用交互,默认为 false */
|
|
23
33
|
disabled?: boolean;
|
|
24
|
-
/**
|
|
34
|
+
/** 是否采用带边框的紧凑形态,默认为 false */
|
|
25
35
|
bordered?: boolean;
|
|
36
|
+
/** 是否采用大模块卡片交互形态,默认为 false */
|
|
37
|
+
card?: boolean;
|
|
38
|
+
/** 是否显示单选指示器控件;卡片 (card) 模式下默认为 false,普通模式默认为 true */
|
|
39
|
+
indicator?: boolean;
|
|
40
|
+
/** 卡片模式下的指示器位置;当显式开启指示器时默认为 'top-left' */
|
|
41
|
+
indicatorPlacement?: RadioIndicatorPlacement;
|
|
42
|
+
/** 卡片模式下内容对齐方式,默认为 `'start'` */
|
|
43
|
+
align?: RadioAlign;
|
|
44
|
+
/** 是否撑满容器宽度,默认为 false */
|
|
45
|
+
block?: boolean;
|
|
26
46
|
/** 原生表单 name 字段 */
|
|
27
47
|
name?: string;
|
|
28
48
|
/** 控件尺寸大小,默认为 `md` */
|
|
@@ -40,8 +60,18 @@ export interface RadioGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'd
|
|
|
40
60
|
defaultValue?: RadioValue | null;
|
|
41
61
|
/** 是否禁用整组所有单选框,默认为 false */
|
|
42
62
|
disabled?: boolean;
|
|
43
|
-
/**
|
|
63
|
+
/** 整组是否采用带边框紧凑样式,默认为 false */
|
|
44
64
|
bordered?: boolean;
|
|
65
|
+
/** 整组是否采用大模块卡片交互形态,默认为 false */
|
|
66
|
+
card?: boolean;
|
|
67
|
+
/** 整组是否显示单选指示器控件;卡片 (card) 模式下默认为 false,普通模式默认为 true */
|
|
68
|
+
indicator?: boolean;
|
|
69
|
+
/** 整组卡片模式下统一的指示器位置;当显式开启指示器时默认为 'top-left' */
|
|
70
|
+
indicatorPlacement?: RadioIndicatorPlacement;
|
|
71
|
+
/** 整组卡片模式下统一的内容对齐方式,默认为 `'start'` */
|
|
72
|
+
align?: RadioAlign;
|
|
73
|
+
/** 整组是否撑满容器宽度,默认为 false */
|
|
74
|
+
block?: boolean;
|
|
45
75
|
/** 整组下属单选框统一的原生表单 name 字段 */
|
|
46
76
|
name?: string;
|
|
47
77
|
/** 整组统一尺寸大小,默认为 `md` */
|
|
@@ -2,6 +2,8 @@ import type { HTMLAttributes, ReactNode } from 'react';
|
|
|
2
2
|
/** 上传项状态;组件默认只负责选择文件,上传请求由业务通过回调接管。 */
|
|
3
3
|
export type UploadFileStatus = 'ready' | 'uploading' | 'done' | 'error';
|
|
4
4
|
export type UploadListType = 'text' | 'picture';
|
|
5
|
+
/** 上传组件尺寸:小 (sm) | 中等 (md) | 大 (lg) */
|
|
6
|
+
export type UploadSize = 'sm' | 'md' | 'lg';
|
|
5
7
|
/** Upload 展示与表单绑定的文件项。 */
|
|
6
8
|
export interface UploadFile {
|
|
7
9
|
/** 文件项稳定标识;不传入时由组件按选择顺序生成。 */
|
|
@@ -39,6 +41,8 @@ export interface UploadProps extends Omit<HTMLAttributes<HTMLDivElement>, 'child
|
|
|
39
41
|
maxCount?: number;
|
|
40
42
|
listType?: UploadListType;
|
|
41
43
|
showFileList?: boolean;
|
|
44
|
+
/** 控件尺寸,默认为 `md` */
|
|
45
|
+
size?: UploadSize;
|
|
42
46
|
/** 触发器中的主提示文案。 */
|
|
43
47
|
uploadText?: ReactNode;
|
|
44
48
|
/** 触发器下方的补充说明。 */
|
|
@@ -2,6 +2,8 @@ import type { HTMLAttributes, ReactNode } from 'react';
|
|
|
2
2
|
/** 上传项状态;组件默认只负责选择文件,上传请求由业务通过回调接管。 */
|
|
3
3
|
export type UploadFileStatus = 'ready' | 'uploading' | 'done' | 'error';
|
|
4
4
|
export type UploadListType = 'text' | 'picture';
|
|
5
|
+
/** 上传组件尺寸:小 (sm) | 中等 (md) | 大 (lg) */
|
|
6
|
+
export type UploadSize = 'sm' | 'md' | 'lg';
|
|
5
7
|
/** Upload 展示与表单绑定的文件项。 */
|
|
6
8
|
export interface UploadFile {
|
|
7
9
|
/** 文件项稳定标识;不传入时由组件按选择顺序生成。 */
|
|
@@ -39,6 +41,8 @@ export interface UploadProps extends Omit<HTMLAttributes<HTMLDivElement>, 'child
|
|
|
39
41
|
maxCount?: number;
|
|
40
42
|
listType?: UploadListType;
|
|
41
43
|
showFileList?: boolean;
|
|
44
|
+
/** 控件尺寸,默认为 `md` */
|
|
45
|
+
size?: UploadSize;
|
|
42
46
|
/** 触发器中的主提示文案。 */
|
|
43
47
|
uploadText?: ReactNode;
|
|
44
48
|
/** 触发器下方的补充说明。 */
|
|
@@ -11,5 +11,8 @@ export interface ControllableStateOptions<T> {
|
|
|
11
11
|
*
|
|
12
12
|
* setter 接受值或函数,与 React setState 的调用形式一致。onChange 只在下一值与当前解析值不同时触发,
|
|
13
13
|
* 避免受控父组件收到无意义的重复通知;非受控模式则在通知前同步安排内部更新。
|
|
14
|
+
*
|
|
15
|
+
* 通过 ref 缓存最新解析值与 onChange 回调,保证 setValue 具有永久稳定的引用,
|
|
16
|
+
* 避免因值变动或父组件传入内联函数而打破子组件的 useMemo 缓存与 Context 稳定性。
|
|
14
17
|
*/
|
|
15
18
|
export declare const useControllableState: <T>({ value, defaultValue, controlled, onChange }: ControllableStateOptions<T>) => readonly [T, Dispatch<SetStateAction<T>>];
|
|
@@ -11,5 +11,8 @@ export interface ControllableStateOptions<T> {
|
|
|
11
11
|
*
|
|
12
12
|
* setter 接受值或函数,与 React setState 的调用形式一致。onChange 只在下一值与当前解析值不同时触发,
|
|
13
13
|
* 避免受控父组件收到无意义的重复通知;非受控模式则在通知前同步安排内部更新。
|
|
14
|
+
*
|
|
15
|
+
* 通过 ref 缓存最新解析值与 onChange 回调,保证 setValue 具有永久稳定的引用,
|
|
16
|
+
* 避免因值变动或父组件传入内联函数而打破子组件的 useMemo 缓存与 Context 稳定性。
|
|
14
17
|
*/
|
|
15
18
|
export declare const useControllableState: <T>({ value, defaultValue, controlled, onChange }: ControllableStateOptions<T>) => readonly [T, Dispatch<SetStateAction<T>>];
|
|
@@ -24,7 +24,7 @@ export declare const globalComponents: {
|
|
|
24
24
|
readonly VlDropdown: import("react").ForwardRefExoticComponent<import("./Dropdown/index.cjs").DropdownProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
25
25
|
readonly VlEmpty: import("react").ForwardRefExoticComponent<import("./Empty/index.cjs").EmptyProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
26
26
|
readonly VlForm: import("./Form/index.cjs").FormComponent & {
|
|
27
|
-
Item: import("react").
|
|
27
|
+
Item: import("react").NamedExoticComponent<import("./Form/index.cjs").FormItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
28
28
|
};
|
|
29
29
|
readonly VlInput: import("react").ForwardRefExoticComponent<import("./Input/index.cjs").InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
30
30
|
readonly VlLoading: import("react").ForwardRefExoticComponent<import("./Loading/index.cjs").LoadingProps & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/types/registry.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare const globalComponents: {
|
|
|
24
24
|
readonly VlDropdown: import("react").ForwardRefExoticComponent<import("./Dropdown/index.js").DropdownProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
25
25
|
readonly VlEmpty: import("react").ForwardRefExoticComponent<import("./Empty/index.js").EmptyProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
26
26
|
readonly VlForm: import("./Form/index.js").FormComponent & {
|
|
27
|
-
Item: import("react").
|
|
27
|
+
Item: import("react").NamedExoticComponent<import("./Form/index.js").FormItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
28
28
|
};
|
|
29
29
|
readonly VlInput: import("react").ForwardRefExoticComponent<import("./Input/index.js").InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
30
30
|
readonly VlLoading: import("react").ForwardRefExoticComponent<import("./Loading/index.js").LoadingProps & import("react").RefAttributes<HTMLDivElement>>;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-ZBA75xZ_.cjs"),n=require("./refs-DCqd87V8.cjs");let r=require("react"),i=require("react/jsx-runtime");var a=(0,r.createContext)(null),o=a.Provider,s=()=>(0,r.useContext)(a),c=(0,r.forwardRef)((a,o)=>{let{checked:c,defaultChecked:l=!1,value:u,label:d,disabled:f,bordered:p,indeterminate:m=!1,name:h,size:g,className:_,style:v,children:y,onChange:b,...x}=a,S=(0,r.useRef)(null),C=(0,r.useMemo)(()=>n.n(S,o),[o]),w=s(),T=t.t(a,`checked`),[E,D]=t.n({value:!!c,defaultValue:l,controlled:T}),O=w!==null&&u!==void 0?w.value.includes(u):E,k=f??w?.disabled??!1,A=p??w?.bordered??!1,j=h??w?.name,M=g??w?.size??`md`,N=[`vl-checkbox`,M?`size-${M}`:``,k?`is-disabled`:``,A?`is-bordered`:``,O?`is-checked`:``,m?`is-indeterminate`:``,_||``].filter(Boolean).join(` `),P=d!=null||y!=null,F=m?`mixed`:O?`true`:`false`;return e.t(()=>{S.current&&(S.current.indeterminate=!!m)},[m]),(0,i.jsxs)(`label`,{className:N,style:v,children:[(0,i.jsx)(`input`,{ref:C,className:`vl-checkbox__input`,type:`checkbox`,name:j,value:typeof u==`boolean`?String(u):u,checked:O,disabled:k,"aria-checked":F,onChange:()=>{if(k)return;let e=!O;if(w&&u!==void 0){w.toggleValue(u,e),b?.(u,e);return}D(e),b?.(u,e)},...x}),(0,i.jsx)(`span`,{className:`vl-checkbox__control`,"aria-hidden":`true`,children:(0,i.jsx)(`span`,{className:`vl-checkbox__icon`})}),P?(0,i.jsx)(`span`,{className:`vl-checkbox__label`,children:y??d}):null]})});c.displayName=`VlCheckbox`,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./state-ZBA75xZ_.cjs"),t=require("./Checkbox-BCXbK1-8.cjs");let n=require("react"),r=require("react/jsx-runtime");var i=(0,n.forwardRef)((i,a)=>{let{value:o,defaultValue:s=[],disabled:c,bordered:l,name:u,size:d,children:f,className:p,onChange:m,...h}=i,g=e.t(i,`value`),[_,v]=e.n({value:o??[],defaultValue:s,controlled:g,onChange:m}),y=(0,n.useCallback)((e,t)=>{v(n=>t===n.includes(e)?n:t?[...n,e]:n.filter(t=>t!==e))},[v]),b=(0,n.useMemo)(()=>({value:_,disabled:c,bordered:l,name:u,size:d,toggleValue:y}),[_,c,l,u,d,y]),x=[`vl-checkbox-group`,p||``].filter(Boolean).join(` `);return(0,r.jsx)(t.n,{value:b,children:(0,r.jsx)(`div`,{ref:a,className:x,role:`group`,"aria-disabled":c||void 0,...h,children:f})})});i.displayName=`VlCheckboxGroup`;var a=t.t,o=i,s=t.t;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { n as e, t } from "./state-oH-YwB7_.js";
|
|
2
|
-
import { n, t as r } from "./Checkbox-cnXHW9Oz.js";
|
|
3
|
-
import { forwardRef as i, useCallback as a, useMemo as o } from "react";
|
|
4
|
-
import { jsx as s } from "react/jsx-runtime";
|
|
5
|
-
//#region components/Checkbox/CheckboxGroup.tsx
|
|
6
|
-
var c = i((r, i) => {
|
|
7
|
-
let { value: c, defaultValue: l = [], disabled: u, bordered: d, name: f, size: p, children: m, className: h, onChange: g, ..._ } = r, v = t(r, "value"), [y, b] = e({
|
|
8
|
-
value: c ?? [],
|
|
9
|
-
defaultValue: l,
|
|
10
|
-
controlled: v,
|
|
11
|
-
onChange: g
|
|
12
|
-
}), x = a((e, t) => {
|
|
13
|
-
b((n) => t === n.includes(e) ? n : t ? [...n, e] : n.filter((t) => t !== e));
|
|
14
|
-
}, [b]), S = o(() => ({
|
|
15
|
-
value: y,
|
|
16
|
-
disabled: u,
|
|
17
|
-
bordered: d,
|
|
18
|
-
name: f,
|
|
19
|
-
size: p,
|
|
20
|
-
toggleValue: x
|
|
21
|
-
}), [
|
|
22
|
-
y,
|
|
23
|
-
u,
|
|
24
|
-
d,
|
|
25
|
-
f,
|
|
26
|
-
p,
|
|
27
|
-
x
|
|
28
|
-
]), C = ["vl-checkbox-group", h || ""].filter(Boolean).join(" ");
|
|
29
|
-
return /* @__PURE__ */ s(n, {
|
|
30
|
-
value: S,
|
|
31
|
-
children: /* @__PURE__ */ s("div", {
|
|
32
|
-
ref: i,
|
|
33
|
-
className: C,
|
|
34
|
-
role: "group",
|
|
35
|
-
"aria-disabled": u || void 0,
|
|
36
|
-
..._,
|
|
37
|
-
children: m
|
|
38
|
-
})
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
c.displayName = "VlCheckboxGroup";
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region components/Checkbox/index.ts
|
|
44
|
-
var l = r, u = c, d = r;
|
|
45
|
-
//#endregion
|
|
46
|
-
export { l as n, u as r, d as t };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./effect-nifYL_rH.js";
|
|
2
|
-
import { n as t, t as n } from "./state-oH-YwB7_.js";
|
|
3
|
-
import { n as r } from "./refs-D5IYOBaf.js";
|
|
4
|
-
import { createContext as i, forwardRef as a, useContext as o, useMemo as s, useRef as c } from "react";
|
|
5
|
-
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
6
|
-
//#region components/Checkbox/context.ts
|
|
7
|
-
var d = i(null), f = d.Provider, p = () => o(d), m = a((i, a) => {
|
|
8
|
-
let { checked: o, defaultChecked: d = !1, value: f, label: m, disabled: h, bordered: g, indeterminate: _ = !1, name: v, size: y, className: b, style: x, children: S, onChange: C, ...w } = i, T = c(null), E = s(() => r(T, a), [a]), D = p(), O = n(i, "checked"), [k, A] = t({
|
|
9
|
-
value: !!o,
|
|
10
|
-
defaultValue: d,
|
|
11
|
-
controlled: O
|
|
12
|
-
}), j = D !== null && f !== void 0 ? D.value.includes(f) : k, M = h ?? D?.disabled ?? !1, N = g ?? D?.bordered ?? !1, P = v ?? D?.name, F = y ?? D?.size ?? "md", I = [
|
|
13
|
-
"vl-checkbox",
|
|
14
|
-
F ? `size-${F}` : "",
|
|
15
|
-
M ? "is-disabled" : "",
|
|
16
|
-
N ? "is-bordered" : "",
|
|
17
|
-
j ? "is-checked" : "",
|
|
18
|
-
_ ? "is-indeterminate" : "",
|
|
19
|
-
b || ""
|
|
20
|
-
].filter(Boolean).join(" "), L = m != null || S != null, R = _ ? "mixed" : j ? "true" : "false";
|
|
21
|
-
return e(() => {
|
|
22
|
-
T.current && (T.current.indeterminate = !!_);
|
|
23
|
-
}, [_]), /* @__PURE__ */ u("label", {
|
|
24
|
-
className: I,
|
|
25
|
-
style: x,
|
|
26
|
-
children: [
|
|
27
|
-
/* @__PURE__ */ l("input", {
|
|
28
|
-
ref: E,
|
|
29
|
-
className: "vl-checkbox__input",
|
|
30
|
-
type: "checkbox",
|
|
31
|
-
name: P,
|
|
32
|
-
value: typeof f == "boolean" ? String(f) : f,
|
|
33
|
-
checked: j,
|
|
34
|
-
disabled: M,
|
|
35
|
-
"aria-checked": R,
|
|
36
|
-
onChange: () => {
|
|
37
|
-
if (M) return;
|
|
38
|
-
let e = !j;
|
|
39
|
-
if (D && f !== void 0) {
|
|
40
|
-
D.toggleValue(f, e), C?.(f, e);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
A(e), C?.(f, e);
|
|
44
|
-
},
|
|
45
|
-
...w
|
|
46
|
-
}),
|
|
47
|
-
/* @__PURE__ */ l("span", {
|
|
48
|
-
className: "vl-checkbox__control",
|
|
49
|
-
"aria-hidden": "true",
|
|
50
|
-
children: /* @__PURE__ */ l("span", { className: "vl-checkbox__icon" })
|
|
51
|
-
}),
|
|
52
|
-
L ? /* @__PURE__ */ l("span", {
|
|
53
|
-
className: "vl-checkbox__label",
|
|
54
|
-
children: S ?? m
|
|
55
|
-
}) : null
|
|
56
|
-
]
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
m.displayName = "VlCheckbox";
|
|
60
|
-
//#endregion
|
|
61
|
-
export { f as n, m as t };
|
package/dist/Form-7un_DeDk.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-ZBA75xZ_.cjs"),n=require("./refs-DCqd87V8.cjs"),r=require("./id-CF0zOP1G.cjs"),i=require("./focus-D-h8CbGr.cjs");let a=require("react"),o=require("react/jsx-runtime");var s=(0,a.createContext)(null),c=s.Provider,l=()=>(0,a.useContext)(s),u=[`blur`,`submit`],d=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,f=e=>e?Array.isArray(e)?e:[e]:u,p=e=>e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)&&e.length===0,m=(e,t,n,r)=>{let i=t??e;if(n.required&&p(r))return n.message??`请输入${i}`;if(p(r))return;if(n.type&&!(n.type===`array`?Array.isArray(r):n.type===`email`?typeof r==`string`&&d.test(r):typeof r===n.type)||(n.pattern&&(n.pattern.lastIndex=0),n.pattern&&(typeof r!=`string`||!n.pattern.test(r))))return n.message??`${i}格式不正确`;let a=typeof r==`number`?r:typeof r==`string`||Array.isArray(r)?r.length:null;if(n.len!==void 0&&a!==null&&a!==n.len)return n.message??`${i}长度必须为 ${n.len}`;if(n.min!==void 0&&a!==null&&a<n.min)return n.message??`${i}不能小于 ${n.min}`;if(n.max!==void 0&&a!==null&&a>n.max)return n.message??`${i}不能大于 ${n.max}`},h=(0,a.forwardRef)((n,r)=>{let{values:s,defaultValues:l={},layout:u=`vertical`,labelWidth:d,labelAlign:p=u===`horizontal`?`right`:`left`,validateTrigger:h,className:g,style:_,children:v,onValuesChange:y,onFinish:b,onFinishError:x,onFinishFailed:S,noValidate:C=!0,...w}=n,T=t.t(n,`values`),[E,D]=(0,a.useState)(l),O=(0,a.useMemo)(()=>T?s??{}:E,[T,E,s]),k=(0,a.useRef)(O);e.t(()=>{k.current=O},[O]);let[A,j]=(0,a.useState)({}),M=(0,a.useRef)(A),[N,P]=(0,a.useState)({}),[F,I]=(0,a.useState)(!1),L=(0,a.useRef)(!1),R=(0,a.useRef)(null),z=(0,a.useRef)(new Map),B=(0,a.useRef)(new Map),V=(0,a.useMemo)(()=>f(h),[h]),H=(0,a.useCallback)(e=>{M.current=e,j(e)},[]),U=(0,a.useCallback)(e=>(z.current.set(e.name,e),()=>{if(z.current.get(e.name)?.token===e.token){if(z.current.delete(e.name),B.current.delete(e.name),Object.prototype.hasOwnProperty.call(M.current,e.name)){let t={...M.current};delete t[e.name],H(t)}P(t=>{if(!Object.prototype.hasOwnProperty.call(t,e.name))return t;let n={...t};return delete n[e.name],n})}}),[H]),W=(0,a.useCallback)((e,t)=>{let n={...k.current,[e]:t};return k.current=n,T||D(n),y?.({[e]:t},n),n},[T,y]),G=(0,a.useCallback)(async(e,t)=>{let n=z.current.get(e);if(!n)return[];let r=t??k.current,i=r[e],a=Symbol(e);B.current.set(e,a),P(t=>({...t,[e]:!0}));let o=[],{rules:s,label:c}=n.metaRef.current;for(let t of s){let n=m(e,c,t,i);if(n&&o.push(n),t.validator)try{let e=await t.validator(i,r);e&&o.push(t.message??e)}catch(e){let n=e instanceof Error?e.message:`校验失败`;o.push(t.message??n)}}if(z.current.get(e)?.token!==n.token||B.current.get(e)!==a)return o;let l={...M.current};return o.length?l[e]=o:delete l[e],H(l),P(t=>({...t,[e]:!1})),o},[H]),K=(0,a.useCallback)(async()=>{let e=k.current,t=[...z.current.values()],n=await Promise.all(t.map(async t=>{let n=G(t.name,e);return[t,B.current.get(t.name),await n]})),r={...M.current};return n.forEach(([e,t,n])=>{z.current.get(e.name)?.token===e.token&&B.current.get(e.name)===t&&(n.length?r[e.name]=n:delete r[e.name])}),H(r),{valid:Object.keys(r).length===0,values:e,errors:r}},[H,G]),q=(0,a.useCallback)(()=>{if(R.current)return R.current;let e=(async()=>{L.current=!0,I(!0);try{let e=await K();if(e.valid)try{await b?.(e.values)}catch(t){x?.(t,e.values)}else{S?.(e.errors,e.values);let t=[...z.current.keys()].find(t=>e.errors[t]);t&&i.n(z.current.get(t)?.metaRef.current.element??null)}return e}finally{L.current=!1,I(!1)}})();return R.current=e,e.then(()=>{R.current===e&&(R.current=null)},()=>{R.current===e&&(R.current=null)}),e},[b,x,S,K]),J=(0,a.useCallback)(e=>{let t={...k.current,...e};k.current=t,T||D(t),y?.(e,t)},[T,y]),Y=(0,a.useCallback)(()=>{let e={...l},t=k.current;k.current=e,T||D(e);let n=new Set([...Object.keys(t),...Object.keys(e)]),r=Object.fromEntries([...n].filter(n=>!Object.is(t[n],e[n])).map(t=>[t,e[t]]));Object.keys(r).length&&y?.(r,e),H({}),B.current.clear(),P({})},[H,T,l,y]);(0,a.useImperativeHandle)(r,()=>({getValues:()=>k.current,setValues:J,reset:Y,validate:K,submit:q,isSubmitting:()=>L.current,getErrors:()=>M.current}),[Y,J,q,K]);let X=(0,a.useMemo)(()=>({values:O,errors:A,validating:N,defaultValidateTrigger:V,registerField:U,updateField:W,validateField:G}),[V,A,U,W,G,N,O]),Z={..._,...d===void 0?null:{"--vl-form-label-width":typeof d==`number`?`${d}px`:d}},Q=[`vl-form`,`vl-form--${u}`,`vl-form--label-${p}`,F?`is-submitting`:``,g||``].filter(Boolean).join(` `),$=e=>{e.preventDefault(),q()},ee=e=>{e.preventDefault(),Y()};return(0,o.jsx)(c,{value:X,children:(0,o.jsx)(`form`,{...w,className:Q,style:Z,"aria-busy":F||void 0,noValidate:C,onSubmit:$,onReset:ee,children:v})})});h.displayName=`VlForm`;var g=[],_=[],v=[],y=(e,t)=>e?Array.isArray(e)?e:[e]:t,b=(e,t)=>{if(e===`checked`&&typeof t[1]==`boolean`)return t[1];let n=t[0];if(n&&typeof n==`object`&&`target`in n){let t=n.target;if(t)return e===`checked`?t.checked:t.value}return n},x=(0,a.forwardRef)((t,i)=>{let{name:s,label:c,required:u=!1,rules:d=g,help:f,valuePropName:p=`value`,trigger:m=`onChange`,getValueFromEvent:h,validateTrigger:x,className:S,children:C,...w}=t,T=l(),E=T?.registerField,D=C,O=D.props,k=r.t(`vl-form-control`,O.id),A=r.t(`vl-form-label`),j=r.t(`vl-form-help`),M=r.t(`vl-form-error`),N=(0,a.useRef)(null),P=(0,a.useRef)(null),F=(0,a.useRef)(null),I=T?.defaultValidateTrigger??_,L=(0,a.useMemo)(()=>y(x,I),[I,x]),R=(0,a.useMemo)(()=>u&&!d.some(e=>e.required)?[{required:!0},...d]:d,[u,d]),z=u||R.some(e=>e.required),B=s?T?.errors[s]??v:v,V=s?!!T?.validating[s]:!1,H=L.includes(`change`)||B.length>0,[U]=(0,a.useState)(()=>Symbol(`form-field`)),W=(0,a.useRef)({label:void 0,rules:g,element:null});e.t(()=>{W.current.label=typeof c==`string`?c:void 0,W.current.rules=R},[R,c]),(0,a.useEffect)(()=>{if(!(!s||!E))return E({name:s,token:U,metaRef:W})},[U,s,E]),(0,a.useEffect)(()=>{let e=P.current,t=F.current;if(F.current=B,e){if(!B.length){e.classList.remove(`is-shaking`);return}t!==B&&(e.classList.remove(`is-shaking`),e.offsetWidth,e.classList.add(`is-shaking`))}},[B]);let G={id:k,"aria-describedby":[O[`aria-describedby`],B.length?M:void 0,f===void 0?void 0:j].filter(Boolean).join(` `)||void 0,"aria-labelledby":[O[`aria-labelledby`],c===void 0?void 0:A].filter(Boolean).join(` `)||void 0,"aria-invalid":B.length>0||void 0,"aria-busy":V||void 0,ref:e=>{N.current=e,W.current.element=e,n.t(O.ref,e)}};if(s&&T){G[p]=T.values[s];let e=O[m];if(G[m]=(...t)=>{typeof e==`function`&&e(...t);let n=h?h(...t):b(p,t),r=T.updateField(s,n);(H||m===`onBlur`&&L.includes(`blur`))&&T.validateField(s,r)},m!==`onBlur`){let e=O.onBlur;G.onBlur=t=>{typeof e==`function`&&e(t),L.includes(`blur`)&&T.validateField(s)}}}let K=[`vl-form-item`,B.length?`is-error`:``,V?`is-validating`:``,z?`is-required`:``,S||``].filter(Boolean).join(` `),q=V||B.length>0;return(0,o.jsxs)(`div`,{...w,ref:i,className:K,children:[c===void 0?null:(0,o.jsxs)(`label`,{id:A,className:`vl-form-item__label`,htmlFor:k,children:[z?(0,o.jsx)(`span`,{className:`vl-form-item__required`,"aria-hidden":`true`,children:`*`}):null,c]}),(0,o.jsxs)(`div`,{className:`vl-form-item__control`,children:[(0,o.jsxs)(`div`,{className:`vl-form-item__field`,children:[(0,o.jsx)(`div`,{ref:P,className:`vl-form-item__control-input`,children:(0,a.cloneElement)(D,G)}),(0,o.jsxs)(`div`,{className:`vl-form-item__validation${q?``:` is-empty`}`,"aria-hidden":!q||void 0,children:[V?(0,o.jsxs)(`div`,{className:`vl-form-item__status`,role:`status`,"aria-label":`校验中`,children:[(0,o.jsx)(`span`,{className:`vl-form-item__spinner`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{children:`校验中`})]}):null,B.length?(0,o.jsx)(`div`,{id:M,className:`vl-form-item__error`,role:`alert`,children:B.map(e=>(0,o.jsx)(`div`,{children:e},e))}):null]})]}),f===void 0?null:(0,o.jsx)(`div`,{className:`vl-form-item__feedback`,children:(0,o.jsx)(`div`,{id:j,className:`vl-form-item__help`,children:f})})]})]})});x.displayName=`VlFormItem`;var S=Object.assign(h,{Item:x}),C=x;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return S}});
|
package/dist/Form-CwgaAZWr.js
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./effect-nifYL_rH.js";
|
|
2
|
-
import { t } from "./state-oH-YwB7_.js";
|
|
3
|
-
import { t as n } from "./refs-D5IYOBaf.js";
|
|
4
|
-
import { t as r } from "./id-CHixuHb7.js";
|
|
5
|
-
import { n as i } from "./focus-BDDJyKk3.js";
|
|
6
|
-
import { cloneElement as a, createContext as o, forwardRef as s, useCallback as c, useContext as l, useEffect as u, useImperativeHandle as d, useMemo as f, useRef as p, useState as m } from "react";
|
|
7
|
-
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
8
|
-
//#region components/Form/context.ts
|
|
9
|
-
var _ = o(null), v = _.Provider, y = () => l(_), b = ["blur", "submit"], x = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, S = (e) => e ? Array.isArray(e) ? e : [e] : b, C = (e) => e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) && e.length === 0, w = (e, t, n, r) => {
|
|
10
|
-
let i = t ?? e;
|
|
11
|
-
if (n.required && C(r)) return n.message ?? `请输入${i}`;
|
|
12
|
-
if (C(r)) return;
|
|
13
|
-
if (n.type && !(n.type === "array" ? Array.isArray(r) : n.type === "email" ? typeof r == "string" && x.test(r) : typeof r === n.type) || (n.pattern && (n.pattern.lastIndex = 0), n.pattern && (typeof r != "string" || !n.pattern.test(r)))) return n.message ?? `${i}格式不正确`;
|
|
14
|
-
let a = typeof r == "number" ? r : typeof r == "string" || Array.isArray(r) ? r.length : null;
|
|
15
|
-
if (n.len !== void 0 && a !== null && a !== n.len) return n.message ?? `${i}长度必须为 ${n.len}`;
|
|
16
|
-
if (n.min !== void 0 && a !== null && a < n.min) return n.message ?? `${i}不能小于 ${n.min}`;
|
|
17
|
-
if (n.max !== void 0 && a !== null && a > n.max) return n.message ?? `${i}不能大于 ${n.max}`;
|
|
18
|
-
}, T = s((n, r) => {
|
|
19
|
-
let { values: a, defaultValues: o = {}, layout: s = "vertical", labelWidth: l, labelAlign: u = s === "horizontal" ? "right" : "left", validateTrigger: g, className: _, style: y, children: b, onValuesChange: x, onFinish: C, onFinishError: T, onFinishFailed: E, noValidate: D = !0, ...O } = n, k = t(n, "values"), [A, j] = m(o), M = f(() => k ? a ?? {} : A, [
|
|
20
|
-
k,
|
|
21
|
-
A,
|
|
22
|
-
a
|
|
23
|
-
]), N = p(M);
|
|
24
|
-
e(() => {
|
|
25
|
-
N.current = M;
|
|
26
|
-
}, [M]);
|
|
27
|
-
let [P, F] = m({}), I = p(P), [L, R] = m({}), [z, B] = m(!1), V = p(!1), H = p(null), U = p(/* @__PURE__ */ new Map()), W = p(/* @__PURE__ */ new Map()), G = f(() => S(g), [g]), K = c((e) => {
|
|
28
|
-
I.current = e, F(e);
|
|
29
|
-
}, []), q = c((e) => (U.current.set(e.name, e), () => {
|
|
30
|
-
if (U.current.get(e.name)?.token === e.token) {
|
|
31
|
-
if (U.current.delete(e.name), W.current.delete(e.name), Object.prototype.hasOwnProperty.call(I.current, e.name)) {
|
|
32
|
-
let t = { ...I.current };
|
|
33
|
-
delete t[e.name], K(t);
|
|
34
|
-
}
|
|
35
|
-
R((t) => {
|
|
36
|
-
if (!Object.prototype.hasOwnProperty.call(t, e.name)) return t;
|
|
37
|
-
let n = { ...t };
|
|
38
|
-
return delete n[e.name], n;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}), [K]), J = c((e, t) => {
|
|
42
|
-
let n = {
|
|
43
|
-
...N.current,
|
|
44
|
-
[e]: t
|
|
45
|
-
};
|
|
46
|
-
return N.current = n, k || j(n), x?.({ [e]: t }, n), n;
|
|
47
|
-
}, [k, x]), Y = c(async (e, t) => {
|
|
48
|
-
let n = U.current.get(e);
|
|
49
|
-
if (!n) return [];
|
|
50
|
-
let r = t ?? N.current, i = r[e], a = Symbol(e);
|
|
51
|
-
W.current.set(e, a), R((t) => ({
|
|
52
|
-
...t,
|
|
53
|
-
[e]: !0
|
|
54
|
-
}));
|
|
55
|
-
let o = [], { rules: s, label: c } = n.metaRef.current;
|
|
56
|
-
for (let t of s) {
|
|
57
|
-
let n = w(e, c, t, i);
|
|
58
|
-
if (n && o.push(n), t.validator) try {
|
|
59
|
-
let e = await t.validator(i, r);
|
|
60
|
-
e && o.push(t.message ?? e);
|
|
61
|
-
} catch (e) {
|
|
62
|
-
let n = e instanceof Error ? e.message : "校验失败";
|
|
63
|
-
o.push(t.message ?? n);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (U.current.get(e)?.token !== n.token || W.current.get(e) !== a) return o;
|
|
67
|
-
let l = { ...I.current };
|
|
68
|
-
return o.length ? l[e] = o : delete l[e], K(l), R((t) => ({
|
|
69
|
-
...t,
|
|
70
|
-
[e]: !1
|
|
71
|
-
})), o;
|
|
72
|
-
}, [K]), X = c(async () => {
|
|
73
|
-
let e = N.current, t = [...U.current.values()], n = await Promise.all(t.map(async (t) => {
|
|
74
|
-
let n = Y(t.name, e);
|
|
75
|
-
return [
|
|
76
|
-
t,
|
|
77
|
-
W.current.get(t.name),
|
|
78
|
-
await n
|
|
79
|
-
];
|
|
80
|
-
})), r = { ...I.current };
|
|
81
|
-
return n.forEach(([e, t, n]) => {
|
|
82
|
-
U.current.get(e.name)?.token === e.token && W.current.get(e.name) === t && (n.length ? r[e.name] = n : delete r[e.name]);
|
|
83
|
-
}), K(r), {
|
|
84
|
-
valid: Object.keys(r).length === 0,
|
|
85
|
-
values: e,
|
|
86
|
-
errors: r
|
|
87
|
-
};
|
|
88
|
-
}, [K, Y]), Z = c(() => {
|
|
89
|
-
if (H.current) return H.current;
|
|
90
|
-
let e = (async () => {
|
|
91
|
-
V.current = !0, B(!0);
|
|
92
|
-
try {
|
|
93
|
-
let e = await X();
|
|
94
|
-
if (e.valid) try {
|
|
95
|
-
await C?.(e.values);
|
|
96
|
-
} catch (t) {
|
|
97
|
-
T?.(t, e.values);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
E?.(e.errors, e.values);
|
|
101
|
-
let t = [...U.current.keys()].find((t) => e.errors[t]);
|
|
102
|
-
t && i(U.current.get(t)?.metaRef.current.element ?? null);
|
|
103
|
-
}
|
|
104
|
-
return e;
|
|
105
|
-
} finally {
|
|
106
|
-
V.current = !1, B(!1);
|
|
107
|
-
}
|
|
108
|
-
})();
|
|
109
|
-
return H.current = e, e.then(() => {
|
|
110
|
-
H.current === e && (H.current = null);
|
|
111
|
-
}, () => {
|
|
112
|
-
H.current === e && (H.current = null);
|
|
113
|
-
}), e;
|
|
114
|
-
}, [
|
|
115
|
-
C,
|
|
116
|
-
T,
|
|
117
|
-
E,
|
|
118
|
-
X
|
|
119
|
-
]), Q = c((e) => {
|
|
120
|
-
let t = {
|
|
121
|
-
...N.current,
|
|
122
|
-
...e
|
|
123
|
-
};
|
|
124
|
-
N.current = t, k || j(t), x?.(e, t);
|
|
125
|
-
}, [k, x]), $ = c(() => {
|
|
126
|
-
let e = { ...o }, t = N.current;
|
|
127
|
-
N.current = e, k || j(e);
|
|
128
|
-
let n = /* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(e)]), r = Object.fromEntries([...n].filter((n) => !Object.is(t[n], e[n])).map((t) => [t, e[t]]));
|
|
129
|
-
Object.keys(r).length && x?.(r, e), K({}), W.current.clear(), R({});
|
|
130
|
-
}, [
|
|
131
|
-
K,
|
|
132
|
-
k,
|
|
133
|
-
o,
|
|
134
|
-
x
|
|
135
|
-
]);
|
|
136
|
-
d(r, () => ({
|
|
137
|
-
getValues: () => N.current,
|
|
138
|
-
setValues: Q,
|
|
139
|
-
reset: $,
|
|
140
|
-
validate: X,
|
|
141
|
-
submit: Z,
|
|
142
|
-
isSubmitting: () => V.current,
|
|
143
|
-
getErrors: () => I.current
|
|
144
|
-
}), [
|
|
145
|
-
$,
|
|
146
|
-
Q,
|
|
147
|
-
Z,
|
|
148
|
-
X
|
|
149
|
-
]);
|
|
150
|
-
let ee = f(() => ({
|
|
151
|
-
values: M,
|
|
152
|
-
errors: P,
|
|
153
|
-
validating: L,
|
|
154
|
-
defaultValidateTrigger: G,
|
|
155
|
-
registerField: q,
|
|
156
|
-
updateField: J,
|
|
157
|
-
validateField: Y
|
|
158
|
-
}), [
|
|
159
|
-
G,
|
|
160
|
-
P,
|
|
161
|
-
q,
|
|
162
|
-
J,
|
|
163
|
-
Y,
|
|
164
|
-
L,
|
|
165
|
-
M
|
|
166
|
-
]), te = {
|
|
167
|
-
...y,
|
|
168
|
-
...l === void 0 ? null : { "--vl-form-label-width": typeof l == "number" ? `${l}px` : l }
|
|
169
|
-
}, ne = [
|
|
170
|
-
"vl-form",
|
|
171
|
-
`vl-form--${s}`,
|
|
172
|
-
`vl-form--label-${u}`,
|
|
173
|
-
z ? "is-submitting" : "",
|
|
174
|
-
_ || ""
|
|
175
|
-
].filter(Boolean).join(" "), re = (e) => {
|
|
176
|
-
e.preventDefault(), Z();
|
|
177
|
-
}, ie = (e) => {
|
|
178
|
-
e.preventDefault(), $();
|
|
179
|
-
};
|
|
180
|
-
return /* @__PURE__ */ h(v, {
|
|
181
|
-
value: ee,
|
|
182
|
-
children: /* @__PURE__ */ h("form", {
|
|
183
|
-
...O,
|
|
184
|
-
className: ne,
|
|
185
|
-
style: te,
|
|
186
|
-
"aria-busy": z || void 0,
|
|
187
|
-
noValidate: D,
|
|
188
|
-
onSubmit: re,
|
|
189
|
-
onReset: ie,
|
|
190
|
-
children: b
|
|
191
|
-
})
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
T.displayName = "VlForm";
|
|
195
|
-
//#endregion
|
|
196
|
-
//#region components/Form/FormItem.tsx
|
|
197
|
-
var E = [], D = [], O = [], k = (e, t) => e ? Array.isArray(e) ? e : [e] : t, A = (e, t) => {
|
|
198
|
-
if (e === "checked" && typeof t[1] == "boolean") return t[1];
|
|
199
|
-
let n = t[0];
|
|
200
|
-
if (n && typeof n == "object" && "target" in n) {
|
|
201
|
-
let t = n.target;
|
|
202
|
-
if (t) return e === "checked" ? t.checked : t.value;
|
|
203
|
-
}
|
|
204
|
-
return n;
|
|
205
|
-
}, j = s((t, i) => {
|
|
206
|
-
let { name: o, label: s, required: c = !1, rules: l = E, help: d, valuePropName: _ = "value", trigger: v = "onChange", getValueFromEvent: b, validateTrigger: x, className: S, children: C, ...w } = t, T = y(), j = T?.registerField, M = C, N = M.props, P = r("vl-form-control", N.id), F = r("vl-form-label"), I = r("vl-form-help"), L = r("vl-form-error"), R = p(null), z = p(null), B = p(null), V = T?.defaultValidateTrigger ?? D, H = f(() => k(x, V), [V, x]), U = f(() => c && !l.some((e) => e.required) ? [{ required: !0 }, ...l] : l, [c, l]), W = c || U.some((e) => e.required), G = o ? T?.errors[o] ?? O : O, K = o ? !!T?.validating[o] : !1, q = H.includes("change") || G.length > 0, [J] = m(() => Symbol("form-field")), Y = p({
|
|
207
|
-
label: void 0,
|
|
208
|
-
rules: E,
|
|
209
|
-
element: null
|
|
210
|
-
});
|
|
211
|
-
e(() => {
|
|
212
|
-
Y.current.label = typeof s == "string" ? s : void 0, Y.current.rules = U;
|
|
213
|
-
}, [U, s]), u(() => {
|
|
214
|
-
if (!(!o || !j)) return j({
|
|
215
|
-
name: o,
|
|
216
|
-
token: J,
|
|
217
|
-
metaRef: Y
|
|
218
|
-
});
|
|
219
|
-
}, [
|
|
220
|
-
J,
|
|
221
|
-
o,
|
|
222
|
-
j
|
|
223
|
-
]), u(() => {
|
|
224
|
-
let e = z.current, t = B.current;
|
|
225
|
-
if (B.current = G, e) {
|
|
226
|
-
if (!G.length) {
|
|
227
|
-
e.classList.remove("is-shaking");
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
t !== G && (e.classList.remove("is-shaking"), e.offsetWidth, e.classList.add("is-shaking"));
|
|
231
|
-
}
|
|
232
|
-
}, [G]);
|
|
233
|
-
let X = {
|
|
234
|
-
id: P,
|
|
235
|
-
"aria-describedby": [
|
|
236
|
-
N["aria-describedby"],
|
|
237
|
-
G.length ? L : void 0,
|
|
238
|
-
d === void 0 ? void 0 : I
|
|
239
|
-
].filter(Boolean).join(" ") || void 0,
|
|
240
|
-
"aria-labelledby": [N["aria-labelledby"], s === void 0 ? void 0 : F].filter(Boolean).join(" ") || void 0,
|
|
241
|
-
"aria-invalid": G.length > 0 || void 0,
|
|
242
|
-
"aria-busy": K || void 0,
|
|
243
|
-
ref: (e) => {
|
|
244
|
-
R.current = e, Y.current.element = e, n(N.ref, e);
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
if (o && T) {
|
|
248
|
-
X[_] = T.values[o];
|
|
249
|
-
let e = N[v];
|
|
250
|
-
if (X[v] = (...t) => {
|
|
251
|
-
typeof e == "function" && e(...t);
|
|
252
|
-
let n = b ? b(...t) : A(_, t), r = T.updateField(o, n);
|
|
253
|
-
(q || v === "onBlur" && H.includes("blur")) && T.validateField(o, r);
|
|
254
|
-
}, v !== "onBlur") {
|
|
255
|
-
let e = N.onBlur;
|
|
256
|
-
X.onBlur = (t) => {
|
|
257
|
-
typeof e == "function" && e(t), H.includes("blur") && T.validateField(o);
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
let Z = [
|
|
262
|
-
"vl-form-item",
|
|
263
|
-
G.length ? "is-error" : "",
|
|
264
|
-
K ? "is-validating" : "",
|
|
265
|
-
W ? "is-required" : "",
|
|
266
|
-
S || ""
|
|
267
|
-
].filter(Boolean).join(" "), Q = K || G.length > 0;
|
|
268
|
-
return /* @__PURE__ */ g("div", {
|
|
269
|
-
...w,
|
|
270
|
-
ref: i,
|
|
271
|
-
className: Z,
|
|
272
|
-
children: [s === void 0 ? null : /* @__PURE__ */ g("label", {
|
|
273
|
-
id: F,
|
|
274
|
-
className: "vl-form-item__label",
|
|
275
|
-
htmlFor: P,
|
|
276
|
-
children: [W ? /* @__PURE__ */ h("span", {
|
|
277
|
-
className: "vl-form-item__required",
|
|
278
|
-
"aria-hidden": "true",
|
|
279
|
-
children: "*"
|
|
280
|
-
}) : null, s]
|
|
281
|
-
}), /* @__PURE__ */ g("div", {
|
|
282
|
-
className: "vl-form-item__control",
|
|
283
|
-
children: [/* @__PURE__ */ g("div", {
|
|
284
|
-
className: "vl-form-item__field",
|
|
285
|
-
children: [/* @__PURE__ */ h("div", {
|
|
286
|
-
ref: z,
|
|
287
|
-
className: "vl-form-item__control-input",
|
|
288
|
-
children: a(M, X)
|
|
289
|
-
}), /* @__PURE__ */ g("div", {
|
|
290
|
-
className: `vl-form-item__validation${Q ? "" : " is-empty"}`,
|
|
291
|
-
"aria-hidden": !Q || void 0,
|
|
292
|
-
children: [K ? /* @__PURE__ */ g("div", {
|
|
293
|
-
className: "vl-form-item__status",
|
|
294
|
-
role: "status",
|
|
295
|
-
"aria-label": "校验中",
|
|
296
|
-
children: [/* @__PURE__ */ h("span", {
|
|
297
|
-
className: "vl-form-item__spinner",
|
|
298
|
-
"aria-hidden": "true"
|
|
299
|
-
}), /* @__PURE__ */ h("span", { children: "校验中" })]
|
|
300
|
-
}) : null, G.length ? /* @__PURE__ */ h("div", {
|
|
301
|
-
id: L,
|
|
302
|
-
className: "vl-form-item__error",
|
|
303
|
-
role: "alert",
|
|
304
|
-
children: G.map((e) => /* @__PURE__ */ h("div", { children: e }, e))
|
|
305
|
-
}) : null]
|
|
306
|
-
})]
|
|
307
|
-
}), d === void 0 ? null : /* @__PURE__ */ h("div", {
|
|
308
|
-
className: "vl-form-item__feedback",
|
|
309
|
-
children: /* @__PURE__ */ h("div", {
|
|
310
|
-
id: I,
|
|
311
|
-
className: "vl-form-item__help",
|
|
312
|
-
children: d
|
|
313
|
-
})
|
|
314
|
-
})]
|
|
315
|
-
})]
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
j.displayName = "VlFormItem";
|
|
319
|
-
//#endregion
|
|
320
|
-
//#region components/Form/index.ts
|
|
321
|
-
var M = Object.assign(T, { Item: j }), N = j;
|
|
322
|
-
//#endregion
|
|
323
|
-
export { N as n, M as t };
|
package/dist/Input-CoDZggqc.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./icon-DRLyKu8p.cjs"),t=require("./state-ZBA75xZ_.cjs"),n=require("./refs-DCqd87V8.cjs"),r=require("./id-CF0zOP1G.cjs");let i=require("lucide-react"),a=require("react"),o=require("react/jsx-runtime");var s=(0,a.forwardRef)((s,c)=>{let{value:l,defaultValue:u=``,placeholder:d,disabled:f=!1,loading:p=!1,size:m=`md`,type:h=`text`,clearable:g=!1,prefixIcon:_,suffixIcon:v,tips:y,prefix:b,suffix:x,id:S,"aria-describedby":C,className:w,style:T,onClear:E,onInput:D,onChange:O,onFocus:k,onBlur:A,onKeyDown:j,...M}=s,N=(0,a.useRef)(null),P=(0,a.useMemo)(()=>n.n(N,c),[c]),[F,I]=(0,a.useState)(!1),[L,R]=(0,a.useState)(!1),z=t.t(s,`value`),[B,V]=t.n({value:l==null?``:String(l),defaultValue:u==null?``:String(u),controlled:z,onChange:O}),H=r.t(`vl-input`,S),U=r.t(`vl-input-tips`),W=[C,y?U:void 0].filter(Boolean).join(` `)||void 0,G=[`vl-input-wrapper`,y?`has-tips`:``,w||``].filter(Boolean).join(` `),K=[`vl-input`,m?`size-${m}`:``,f?`is-disabled`:``,p?`is-loading`:``,F?`is-focused`:``].filter(Boolean).join(` `),q=(0,a.useMemo)(()=>g&&!f&&!p&&B!==``&&B!=null&&(F||L),[g,f,p,B,F,L]),J=e=>{D?.(e)},Y=e=>{let t=e.target;V(t.value)},X=e=>{I(!0),k?.(e)},Z=e=>{I(!1),A?.(e)},Q=e=>{j?.(e)},$=()=>{V(``),E?.(),N.current?.focus()};return(0,o.jsxs)(`div`,{className:G,style:T,children:[(0,o.jsxs)(`div`,{className:K,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),children:[b?(0,o.jsx)(`div`,{className:`vl-input__prefix`,children:b}):null,_?(0,o.jsx)(`div`,{className:`vl-input__prefix-icon`,children:e.n(_)}):null,(0,o.jsx)(`input`,{ref:P,id:H,className:`vl-input__inner`,type:h,value:B,placeholder:d,disabled:f||p,"aria-busy":p||void 0,"aria-describedby":W,onInput:J,onChange:Y,onFocus:X,onBlur:Z,onKeyDown:Q,...M}),g&&!f&&!p?(0,o.jsx)(`button`,{type:`button`,className:`vl-input__clear${q?` is-visible`:``}`,"aria-label":`清空输入`,"aria-hidden":!q||void 0,tabIndex:q?0:-1,onClick:$,onMouseDown:e=>e.preventDefault(),children:(0,o.jsx)(i.X,{size:16,"aria-hidden":`true`})}):null,v?(0,o.jsx)(`div`,{className:`vl-input__suffix-icon`,children:e.n(v)}):null,x?(0,o.jsx)(`div`,{className:`vl-input__suffix`,children:x}):null]}),y?(0,o.jsx)(`div`,{id:U,className:`vl-input__tips`,children:y}):null]})});s.displayName=`VlInput`;var c=s,l=s;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
package/dist/Modal-i_Do8GsG.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-ZBA75xZ_.cjs"),n=require("./client-BkoqeUs3.cjs"),r=require("./refs-DCqd87V8.cjs"),i=require("./content-DCGQZQp8.cjs"),a=require("./number-B7qJF_ZY.cjs"),o=require("./id-CF0zOP1G.cjs"),s=require("./layer-BgiUZy_t.cjs"),c=require("./dialog-shell-DT1EoKQG.cjs");let ee=require("lucide-react"),l=require("react"),u=require("react/jsx-runtime");var te=-24,d=(0,l.forwardRef)((d,f)=>{let{open:p,defaultOpen:ne=!1,title:m,width:re=520,offsetY:h=te,center:ie=!1,mask:ae=!0,closeOnClickOverlay:oe=!0,closeOnPressEscape:se=!0,showClose:g=!0,lockScroll:ce=!0,destroyOnClose:_=!1,draggable:v=!0,fullscreen:y=!1,zIndex:le,header:b,footer:x,className:ue,style:S,children:de,onClick:fe,onChange:pe,onOpen:C,onClose:w,onAfterClose:me,"aria-label":he,"aria-labelledby":ge,"aria-describedby":_e,...ve}=d,T=n.t(),ye=typeof S?.zIndex==`number`?S.zIndex:void 0,E=s.r({defaultZIndex:s.n.modal,zIndex:le??ye,withMask:!0}),D=(0,l.useRef)(null),be=(0,l.useMemo)(()=>r.n(D,f),[f]),xe=t.t(d,`open`),[O,k]=t.n({value:!!p,defaultValue:ne,controlled:xe,onChange:pe}),[Se,A]=(0,l.useState)(!1),j=(0,l.useRef)({x:0,y:0}),M=(0,l.useRef)(!1),N=(0,l.useRef)(!1),P=(0,l.useRef)({x:0,y:0}),F=(0,l.useRef)(null),I=(0,l.useRef)(!1),L=o.t(`vl-modal-title`),R=(0,l.useCallback)(()=>k(!1),[k]),{isTopLayer:z}=c.r({active:T&&O,containerRef:D,closeOnPressEscape:se,lockScroll:ce,onRequestClose:R}),B=(0,l.useCallback)(e=>{D.current&&(D.current.style.visibility=e?`visible`:`hidden`)},[]),V=(0,l.useCallback)((e,t)=>{j.current={x:e,y:t},D.current&&(D.current.style.left=`${e}px`,D.current.style.top=`${t}px`)},[]),H=(0,l.useCallback)((e,t)=>{let n=e.getBoundingClientRect();return{rect:n,maxX:Math.max(t,window.innerWidth-n.width-t),maxY:Math.max(t,window.innerHeight-n.height-t)}},[]),U=(0,l.useCallback)(()=>{let e=D.current;if(!e)return;if(y){V(0,0);return}let{rect:t,maxX:n,maxY:r}=H(e,16),i=(window.innerHeight-t.height)/2+h;V(Math.round(a.t((window.innerWidth-t.width)/2,16,n)),Math.round(a.t(i,16,r)))},[y,H,h,V]),W=(0,l.useCallback)(()=>{let e=D.current;if(!e)return;let{maxX:t,maxY:n}=H(e,8);V(Math.round(a.t(j.current.x,8,t)),Math.round(a.t(j.current.y,8,n)))},[H,V]),G=(0,l.useCallback)((e,t)=>{let n=D.current;if(!n||y)return;let{maxX:r,maxY:i}=H(n,8),o=a.t(e-P.current.x,8,r),s=a.t(t-P.current.y,8,i);V(Math.round(o),Math.round(s)),M.current=!0},[y,H,V]),K=(0,l.useRef)(G);e.t(()=>{K.current=G},[G]);let q=(0,l.useCallback)(e=>{N.current&&K.current(e.clientX,e.clientY)},[]),J=(0,l.useCallback)(()=>{window.removeEventListener(`pointermove`,q),F.current?.(),F.current=null},[q]),Y=(0,l.useCallback)(()=>{N.current&&(N.current=!1,A(!1),J())},[J]),Ce=e=>{if(!v||y||!O||!z()||e.button!==0||e.target.closest(`.vl-modal__close`))return;let t=D.current;if(!t)return;let n=t.getBoundingClientRect();P.current={x:e.clientX-n.left,y:e.clientY-n.top},N.current=!0,A(!0),F.current=c.n(),window.addEventListener(`pointermove`,q),window.addEventListener(`pointerup`,Y,{once:!0})};(0,l.useEffect)(()=>{let e=I.current;O&&!e?C?.():!O&&e&&w?.(),I.current=O},[O,C,w]),e.t(()=>{!O||!T||(B(!1),y?V(0,0):!_&&M.current?W():U(),B(!0))},[O,T,y,_,U,W,V,B]),(0,l.useEffect)(()=>{O||Y()},[O,Y]),(0,l.useEffect)(()=>{if(!O)return;let e=()=>{N.current||(M.current?W():U())};return window.addEventListener(`resize`,e,{passive:!0}),()=>window.removeEventListener(`resize`,e)},[O,U,W]),(0,l.useEffect)(()=>()=>{window.removeEventListener(`pointerup`,Y),J()},[Y,J]);let we=()=>{oe&&z()&&R()},Te=e=>{e.stopPropagation(),fe?.(e)},Ee=[`vl-modal`,Se?`is-dragging`:``,ie?`is-center`:``,y?`is-fullscreen`:``,ue||``].filter(Boolean).join(` `),De=[`vl-modal__header`,v&&!y?`is-draggable`:``].filter(Boolean).join(` `),X={...S};E.zIndex!==void 0&&(X.zIndex=E.zIndex),y?(X.width=`100vw`,X.height=`100vh`):X.width=a.n(re)??`520px`;let Z=b??(m?(0,u.jsx)(`div`,{id:L,className:`vl-modal__title`,children:m}):null),Q=ge??(!b&&m?L:void 0),$=he??(Q?void 0:typeof m==`string`?m:`对话框`);return(0,u.jsx)(s.t,{layer:E.layer,children:(0,u.jsxs)(c.t,{clientReady:T,open:O,mask:ae,destroyOnClose:_,maskTransitionName:`vl-modal-mask`,transitionName:`vl-modal`,maskClassName:`vl-modal__mask`,panelClassName:Ee,panelStyle:X,maskStyle:E.maskZIndex===void 0?void 0:{zIndex:E.maskZIndex},panelRef:be,role:`dialog`,ariaLabel:$,ariaLabelledBy:Q,ariaDescribedBy:_e,onMaskClick:we,onPanelClick:Te,onAfterLeave:()=>{Y(),_&&(M.current=!1),me?.()},panelProps:ve,children:[i.t(Z)||g?(0,u.jsx)(`div`,{className:De,onPointerDown:Ce,children:(0,u.jsxs)(`div`,{className:`vl-modal__headerInner`,children:[(0,u.jsx)(`div`,{className:`vl-modal__headerMain`,children:Z}),g?(0,u.jsx)(`button`,{type:`button`,className:`vl-modal__close`,"aria-label":`关闭对话框`,onClick:R,children:(0,u.jsx)(ee.X,{size:20,"aria-hidden":`true`})}):null]})}):null,(0,u.jsx)(`div`,{className:`vl-modal__body`,children:de}),i.t(x)?(0,u.jsx)(`div`,{className:`vl-modal__footer`,children:x}):null]})})});d.displayName=`VlModal`;var f=d,p=d;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return p}});
|