@vavt/react-ui 1.0.4 → 1.1.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/{DatePicker-CoHW85qm.cjs → DatePicker-D3tdU7GY.cjs} +1 -1
- package/dist/{DatePicker-B-F5q_s_.js → DatePicker-D75NqBYX.js} +1 -1
- package/dist/{DateTimePicker-CAkdoY--.cjs → DateTimePicker-CCe5NUkC.cjs} +1 -1
- package/dist/{DateTimePicker-BSBZZ7xV.js → DateTimePicker-CG-yv54X.js} +1 -1
- package/dist/{Drawer-D45miZ27.cjs → Drawer-CeBlbSjY.cjs} +1 -1
- package/dist/{Drawer-C0toQ-fQ.js → Drawer-CgaSQfT_.js} +1 -1
- package/dist/Form-BfXRwX6y.js +353 -0
- package/dist/Form-QpWOfQpR.cjs +1 -0
- package/dist/{MessageBox-B4Qo1vs2.js → MessageBox-DlAv_jQm.js} +1 -1
- package/dist/{MessageBox-CTJfdU29.cjs → MessageBox-nHLRzRJS.cjs} +1 -1
- package/dist/Modal-CAZ8vap0.cjs +1 -0
- package/dist/Modal-DnLKpKvW.js +238 -0
- package/dist/{Table-B9NTkptC.js → Table-BFqTvxt1.js} +10 -10
- package/dist/{Table-Bqjey5fw.cjs → Table-D4csqW47.cjs} +1 -1
- package/dist/Upload-CIOunhpr.cjs +1 -0
- package/dist/{Upload-DZC_bt6G.js → Upload-CVIzg2Px.js} +65 -64
- package/dist/base.css +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/Form.cjs +1 -1
- package/dist/cjs/MessageBox.cjs +1 -1
- package/dist/cjs/Modal.cjs +1 -1
- package/dist/cjs/Table.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-BH--Nh7g.js +612 -0
- package/dist/date-picker-pwA2wCag.cjs +1 -0
- package/dist/{dialog-shell-DehX3PNh.js → dialog-shell-CdYlPT9f.js} +12 -12
- package/dist/dialog-shell-CzeGytVj.cjs +1 -0
- package/dist/es/DatePicker.mjs +1 -1
- package/dist/es/DateTimePicker.mjs +1 -1
- package/dist/es/Drawer.mjs +1 -1
- package/dist/es/Form.mjs +1 -1
- package/dist/es/MessageBox.mjs +1 -1
- package/dist/es/Modal.mjs +1 -1
- package/dist/es/Table.mjs +1 -1
- package/dist/es/Upload.mjs +1 -1
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +22 -22
- package/dist/es/register.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/registry-BO2ao8Jc.cjs +1 -0
- package/dist/{registry-q6UdMOyj.js → registry-macDoSyW.js} +34 -34
- 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/Form/type.d.cts +3 -1
- package/dist/types/Form/type.d.ts +3 -1
- package/dist/types/Modal/type.d.cts +3 -3
- package/dist/types/Modal/type.d.ts +3 -3
- package/dist/types/Upload/type.d.cts +4 -0
- package/dist/types/Upload/type.d.ts +4 -0
- package/package.json +1 -1
- package/dist/Form-7un_DeDk.cjs +0 -1
- package/dist/Form-CwgaAZWr.js +0 -323
- package/dist/Modal-i_Do8GsG.cjs +0 -1
- package/dist/Modal-otJ_9ldu.js +0 -210
- 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/registry-BGNWNSiC.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./Alert-tPSJmCXK.cjs"),t=require("./Anchor-iriRYxEs.cjs"),n=require("./Announcement-XjJyJ28N.cjs"),r=require("./Button-qURrKHQ0.cjs"),i=require("./Card-BkZhLXQ5.cjs"),a=require("./Checkbox-CQZSg9Xu.cjs"),o=require("./Col-qcq7T83y.cjs"),s=require("./Transition-X_89ga-e.cjs"),c=require("./Input-CoDZggqc.cjs"),l=require("./Tabs-BhjvKN84.cjs"),u=require("./NumberInput-CYVj89_s.cjs"),d=require("./Cron-3D9GmlYf.cjs"),f=require("./Dropdown-BsXYVdt6.cjs"),p=require("./DatePicker-D3tdU7GY.cjs"),m=require("./DateTimePicker-CCe5NUkC.cjs"),h=require("./Divider-BnmUNmy2.cjs"),g=require("./Drawer-CeBlbSjY.cjs"),_=require("./Empty-Dny96c3p.cjs"),v=require("./Form-QpWOfQpR.cjs"),y=require("./Tooltip-CP8rpNYG.cjs"),b=require("./Loading-C2pY-4fA.cjs"),x=require("./Scrollbar-CEQT6Ao_.cjs"),S=require("./Modal-CAZ8vap0.cjs"),C=require("./MessageBox-nHLRzRJS.cjs"),w=require("./Select-BRKxpX-_.cjs"),T=require("./Pagination-ODU-i3gn.cjs"),E=require("./Progress-DTAjlgwZ.cjs"),D=require("./cjs/Radio.cjs"),O=require("./cjs/Row.cjs"),k=require("./Sidebar-BPXVnP7y.cjs"),A=require("./Slider-DCIUxcBa.cjs"),j=require("./Space-DJGRG2rt.cjs"),M=require("./Switch-7yJ-Q_o_.cjs"),N=require("./Table-D4csqW47.cjs"),P=require("./Tag-Cf9M_HT6.cjs"),F=require("./Textarea-C2dNYM0F.cjs"),I=require("./Timeline-ROggEQnD.cjs"),L=require("./TimePicker-Cpmvn8tx.cjs"),R=require("./Upload-CIOunhpr.cjs");var z={VlAlert:e.n,VlAnchor:t.n,VlAnnouncement:n.n,VlButton:r.n,VlCard:i.n,VlCheckbox:a.n,VlCol:o.n,VlCron:d.n,VlDatePicker:p.n,VlDateTimePicker:m.n,VlDivider:h.n,VlDrawer:g.n,VlDropdown:f.n,VlEmpty:_.n,VlForm:v.t,VlInput:c.n,VlLoading:b.n,VlMessageBox:C.t,VlModal:S.n,VlNumberInput:u.n,VlPagination:T.n,VlProgress:E.n,VlRadio:D.VlRadio,VlRow:O.VlRow,VlScrollbar:x.n,VlSelect:w.n,VlSidebar:k.n,VlSlider:A.n,VlSpace:j.n,VlSwitch:M.n,VlTable:N.n,VlTabs:l.n,VlTag:P.n,VlTextarea:F.n,VlTimeline:I.n,VlTimePicker:L.n,VlTooltip:y.n,VlTransition:s.n,VlUpload:R.n},B=(e=globalThis)=>(Object.assign(e,z),z);Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return z}});
|
|
@@ -11,32 +11,32 @@ import { n as l } from "./Tabs-VT6nQ63W.js";
|
|
|
11
11
|
import { n as u } from "./NumberInput-C_vLULbX.js";
|
|
12
12
|
import { n as d } from "./Cron-Go4yIqrd.js";
|
|
13
13
|
import { n as f } from "./Dropdown-DljKFnvO.js";
|
|
14
|
-
import { n as p } from "./DatePicker-
|
|
15
|
-
import { n as m } from "./DateTimePicker-
|
|
14
|
+
import { n as p } from "./DatePicker-D75NqBYX.js";
|
|
15
|
+
import { n as m } from "./DateTimePicker-CG-yv54X.js";
|
|
16
16
|
import { n as h } from "./Divider-BXNZyvHY.js";
|
|
17
|
-
import { n as g } from "./Drawer-
|
|
17
|
+
import { n as g } from "./Drawer-CgaSQfT_.js";
|
|
18
18
|
import { n as _ } from "./Empty-MmxZitR8.js";
|
|
19
|
-
import { t as v } from "./Form-
|
|
20
|
-
import { n as y } from "./
|
|
21
|
-
import { n as b } from "./
|
|
22
|
-
import {
|
|
23
|
-
import { n as S } from "./
|
|
24
|
-
import {
|
|
25
|
-
import { n as w } from "./
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import { n as k } from "./
|
|
31
|
-
import { n as A } from "./
|
|
32
|
-
import { n as j } from "./
|
|
33
|
-
import { n as M } from "./
|
|
34
|
-
import { n as N } from "./Table-
|
|
19
|
+
import { t as v } from "./Form-BfXRwX6y.js";
|
|
20
|
+
import { n as y } from "./Tooltip-Buk5F9f_.js";
|
|
21
|
+
import { n as b } from "./Loading-CL0wUgYK.js";
|
|
22
|
+
import { n as x } from "./Scrollbar-BdMGZrYi.js";
|
|
23
|
+
import { n as S } from "./Modal-DnLKpKvW.js";
|
|
24
|
+
import { t as C } from "./MessageBox-DlAv_jQm.js";
|
|
25
|
+
import { n as w } from "./Select-QedbJ4pD.js";
|
|
26
|
+
import { n as T } from "./Pagination-CSI5IzQB.js";
|
|
27
|
+
import { n as E } from "./Progress-D2C6LCml.js";
|
|
28
|
+
import { VlRadio as D } from "./es/Radio.mjs";
|
|
29
|
+
import { VlRow as O } from "./es/Row.mjs";
|
|
30
|
+
import { n as k } from "./Sidebar-u980T-QB.js";
|
|
31
|
+
import { n as A } from "./Slider-BzlZc0p4.js";
|
|
32
|
+
import { n as j } from "./Space-gnVH7rEt.js";
|
|
33
|
+
import { n as M } from "./Switch-DOO2tiYR.js";
|
|
34
|
+
import { n as N } from "./Table-BFqTvxt1.js";
|
|
35
35
|
import { n as P } from "./Tag-CkfqoSwA.js";
|
|
36
36
|
import { n as F } from "./Textarea-BEd7ToXv.js";
|
|
37
37
|
import { n as I } from "./Timeline-euWvUS4e.js";
|
|
38
38
|
import { n as L } from "./TimePicker-CHZsr_jj.js";
|
|
39
|
-
import { n as R } from "./Upload-
|
|
39
|
+
import { n as R } from "./Upload-CVIzg2Px.js";
|
|
40
40
|
//#region components/registry.ts
|
|
41
41
|
var z = {
|
|
42
42
|
VlAlert: e,
|
|
@@ -55,27 +55,27 @@ var z = {
|
|
|
55
55
|
VlEmpty: _,
|
|
56
56
|
VlForm: v,
|
|
57
57
|
VlInput: c,
|
|
58
|
-
VlLoading:
|
|
59
|
-
VlMessageBox:
|
|
60
|
-
VlModal:
|
|
58
|
+
VlLoading: b,
|
|
59
|
+
VlMessageBox: C,
|
|
60
|
+
VlModal: S,
|
|
61
61
|
VlNumberInput: u,
|
|
62
|
-
VlPagination:
|
|
63
|
-
VlProgress:
|
|
64
|
-
VlRadio:
|
|
65
|
-
VlRow:
|
|
66
|
-
VlScrollbar:
|
|
67
|
-
VlSelect:
|
|
68
|
-
VlSidebar:
|
|
69
|
-
VlSlider:
|
|
70
|
-
VlSpace:
|
|
71
|
-
VlSwitch:
|
|
62
|
+
VlPagination: T,
|
|
63
|
+
VlProgress: E,
|
|
64
|
+
VlRadio: D,
|
|
65
|
+
VlRow: O,
|
|
66
|
+
VlScrollbar: x,
|
|
67
|
+
VlSelect: w,
|
|
68
|
+
VlSidebar: k,
|
|
69
|
+
VlSlider: A,
|
|
70
|
+
VlSpace: j,
|
|
71
|
+
VlSwitch: M,
|
|
72
72
|
VlTable: N,
|
|
73
73
|
VlTabs: l,
|
|
74
74
|
VlTag: P,
|
|
75
75
|
VlTextarea: F,
|
|
76
76
|
VlTimeline: I,
|
|
77
77
|
VlTimePicker: L,
|
|
78
|
-
VlTooltip:
|
|
78
|
+
VlTooltip: y,
|
|
79
79
|
VlTransition: s,
|
|
80
80
|
VlUpload: R
|
|
81
81
|
}, B = (e = globalThis) => (Object.assign(e, z), z);
|
package/dist/style/Form.cjs
CHANGED
package/dist/style/Form.mjs
CHANGED
package/dist/style/Modal.cjs
CHANGED
package/dist/style/Modal.mjs
CHANGED
|
@@ -56,6 +56,8 @@ export interface FormProps<V extends FormValues = FormValues> extends Omit<FormH
|
|
|
56
56
|
layout?: FormLayout;
|
|
57
57
|
/** 标签文本统一宽度(如 `100px` 或 `100`) */
|
|
58
58
|
labelWidth?: number | string;
|
|
59
|
+
/** horizontal 布局下右侧辅助反馈列的宽度(如 `180px` 或 `180`) */
|
|
60
|
+
feedbackWidth?: number | string;
|
|
59
61
|
/** 标签对齐方式,默认为 `right`(水平布局下) */
|
|
60
62
|
labelAlign?: 'left' | 'right';
|
|
61
63
|
/** 全局默认的校验触发时机,默认为 `['change', 'blur']` */
|
|
@@ -81,7 +83,7 @@ export interface FormItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'chi
|
|
|
81
83
|
required?: boolean;
|
|
82
84
|
/** 当前字段专属的校验规则列表 */
|
|
83
85
|
rules?: FormRule[];
|
|
84
|
-
/**
|
|
86
|
+
/** 额外的辅助说明文本;宽屏 horizontal 显示在控件右侧,其余布局显示在控件下方。纯文本溢出时自动省略并支持 Tooltip。 */
|
|
85
87
|
help?: ReactNode;
|
|
86
88
|
/** 子控件绑定值的属性名,默认为 `'value'`(如 Checkbox 可指定为 `'checked'`) */
|
|
87
89
|
valuePropName?: string;
|
|
@@ -56,6 +56,8 @@ export interface FormProps<V extends FormValues = FormValues> extends Omit<FormH
|
|
|
56
56
|
layout?: FormLayout;
|
|
57
57
|
/** 标签文本统一宽度(如 `100px` 或 `100`) */
|
|
58
58
|
labelWidth?: number | string;
|
|
59
|
+
/** horizontal 布局下右侧辅助反馈列的宽度(如 `180px` 或 `180`) */
|
|
60
|
+
feedbackWidth?: number | string;
|
|
59
61
|
/** 标签对齐方式,默认为 `right`(水平布局下) */
|
|
60
62
|
labelAlign?: 'left' | 'right';
|
|
61
63
|
/** 全局默认的校验触发时机,默认为 `['change', 'blur']` */
|
|
@@ -81,7 +83,7 @@ export interface FormItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'chi
|
|
|
81
83
|
required?: boolean;
|
|
82
84
|
/** 当前字段专属的校验规则列表 */
|
|
83
85
|
rules?: FormRule[];
|
|
84
|
-
/**
|
|
86
|
+
/** 额外的辅助说明文本;宽屏 horizontal 显示在控件右侧,其余布局显示在控件下方。纯文本溢出时自动省略并支持 Tooltip。 */
|
|
85
87
|
help?: ReactNode;
|
|
86
88
|
/** 子控件绑定值的属性名,默认为 `'value'`(如 Checkbox 可指定为 `'checked'`) */
|
|
87
89
|
valuePropName?: string;
|
|
@@ -11,9 +11,9 @@ export interface ModalProps extends Omit<HTMLAttributes<HTMLElement>, 'onChange'
|
|
|
11
11
|
title?: ReactNode;
|
|
12
12
|
/** 弹窗宽度(如 520 或 `'520px'`),默认为 520 */
|
|
13
13
|
width?: number | string;
|
|
14
|
-
/**
|
|
15
|
-
offsetY?: number;
|
|
16
|
-
/** 是否在视口垂直方向严格居中(忽略
|
|
14
|
+
/** 垂直方向的偏移量(px 或 vh,如 20 或 '-5vh');负值向上,正值向下,默认为 0(默认顶部距离视口 25vh) */
|
|
15
|
+
offsetY?: number | string;
|
|
16
|
+
/** 是否在视口垂直方向严格居中(忽略 25vh 默认顶部高度)并居中展示内容,默认为 false */
|
|
17
17
|
center?: boolean;
|
|
18
18
|
/** 是否展示背景半透明遮罩层,默认为 true */
|
|
19
19
|
mask?: boolean;
|
|
@@ -11,9 +11,9 @@ export interface ModalProps extends Omit<HTMLAttributes<HTMLElement>, 'onChange'
|
|
|
11
11
|
title?: ReactNode;
|
|
12
12
|
/** 弹窗宽度(如 520 或 `'520px'`),默认为 520 */
|
|
13
13
|
width?: number | string;
|
|
14
|
-
/**
|
|
15
|
-
offsetY?: number;
|
|
16
|
-
/** 是否在视口垂直方向严格居中(忽略
|
|
14
|
+
/** 垂直方向的偏移量(px 或 vh,如 20 或 '-5vh');负值向上,正值向下,默认为 0(默认顶部距离视口 25vh) */
|
|
15
|
+
offsetY?: number | string;
|
|
16
|
+
/** 是否在视口垂直方向严格居中(忽略 25vh 默认顶部高度)并居中展示内容,默认为 false */
|
|
17
17
|
center?: boolean;
|
|
18
18
|
/** 是否展示背景半透明遮罩层,默认为 true */
|
|
19
19
|
mask?: boolean;
|
|
@@ -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
|
/** 触发器下方的补充说明。 */
|
package/package.json
CHANGED
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/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}});
|