@vavt/react-ui 1.1.0 → 1.2.1

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.
Files changed (171) hide show
  1. package/dist/{Anchor-QZROepM_.js → Anchor-CAZPkv56.js} +1 -1
  2. package/dist/{Anchor-iriRYxEs.cjs → Anchor-CmuV1Ump.cjs} +1 -1
  3. package/dist/{Announcement-XjJyJ28N.cjs → Announcement-D0hZE2sM.cjs} +1 -1
  4. package/dist/{Announcement-D_NccvTm.js → Announcement-DzzaTvcO.js} +1 -1
  5. package/dist/Checkbox-CBMmX-R-.js +86 -0
  6. package/dist/Checkbox-CzNGP2tH.cjs +1 -0
  7. package/dist/Checkbox-GJlGNzlH.cjs +1 -0
  8. package/dist/Checkbox-bHOjYdMp.js +61 -0
  9. package/dist/{Cron-Go4yIqrd.js → Cron-DIB4GG4y.js} +7 -7
  10. package/dist/{Cron-3D9GmlYf.cjs → Cron-MhbYMEeJ.cjs} +1 -1
  11. package/dist/{DatePicker-D75NqBYX.js → DatePicker--13tW0cw.js} +1 -1
  12. package/dist/{DatePicker-D3tdU7GY.cjs → DatePicker-Bj709smn.cjs} +1 -1
  13. package/dist/{DateTimePicker-CG-yv54X.js → DateTimePicker-Blqs2Bcv.js} +1 -1
  14. package/dist/{DateTimePicker-CCe5NUkC.cjs → DateTimePicker-ZSScsk-j.cjs} +1 -1
  15. package/dist/{Drawer-CeBlbSjY.cjs → Drawer-DcbgMkub.cjs} +1 -1
  16. package/dist/{Drawer-CgaSQfT_.js → Drawer-yM_r1M0H.js} +1 -1
  17. package/dist/{Dropdown-BsXYVdt6.cjs → Dropdown-PHqXNiAZ.cjs} +1 -1
  18. package/dist/{Dropdown-DljKFnvO.js → Dropdown-mYCY-LcF.js} +2 -2
  19. package/dist/Form-BkyDHPEI.cjs +1 -0
  20. package/dist/Form-D_Uv-8HG.js +449 -0
  21. package/dist/{Input-CIB_TY2n.js → Input-BRy5Xuwy.js} +28 -37
  22. package/dist/Input-C9ESmbJ7.cjs +1 -0
  23. package/dist/{MessageBox-nHLRzRJS.cjs → MessageBox-D7Ib1f7K.cjs} +1 -1
  24. package/dist/{MessageBox-DlAv_jQm.js → MessageBox-DDP6UWFU.js} +2 -2
  25. package/dist/{Modal-CAZ8vap0.cjs → Modal-DPxZEr2v.cjs} +1 -1
  26. package/dist/Modal-Du7aVdWl.js +239 -0
  27. package/dist/{NumberInput-C_vLULbX.js → NumberInput-CB-nKZgs.js} +1 -1
  28. package/dist/{NumberInput-CYVj89_s.cjs → NumberInput-Dp1vTDkW.cjs} +1 -1
  29. package/dist/{Pagination-CSI5IzQB.js → Pagination-CpbboRbF.js} +2 -2
  30. package/dist/{Pagination-ODU-i3gn.cjs → Pagination-DatEegaF.cjs} +1 -1
  31. package/dist/RadioGroup-DTodR0VJ.cjs +1 -0
  32. package/dist/RadioGroup-DYjQMXdB.js +136 -0
  33. package/dist/Select-BHWa_6Q2.js +466 -0
  34. package/dist/Select-C6O0tmM_.cjs +1 -0
  35. package/dist/{Slider-BzlZc0p4.js → Slider-CKU03SsT.js} +1 -1
  36. package/dist/{Slider-DCIUxcBa.cjs → Slider-CU9OS2HB.cjs} +1 -1
  37. package/dist/{Switch-7yJ-Q_o_.cjs → Switch-CpXDMcPW.cjs} +1 -1
  38. package/dist/{Switch-DOO2tiYR.js → Switch-CqTFvp-k.js} +1 -1
  39. package/dist/Table-BNGO_7Rx.cjs +1 -0
  40. package/dist/Table-Cfs3XJgN.js +531 -0
  41. package/dist/{Tabs-BhjvKN84.cjs → Tabs-BZ0Zc0bL.cjs} +1 -1
  42. package/dist/{Tabs-VT6nQ63W.js → Tabs-HWLkyrQR.js} +1 -1
  43. package/dist/Tag-4iZGcfrg.cjs +1 -0
  44. package/dist/Tag-TeYTDdHt.js +51 -0
  45. package/dist/{Textarea-BEd7ToXv.js → Textarea-CA6Vzu7t.js} +1 -1
  46. package/dist/{Textarea-C2dNYM0F.cjs → Textarea-CEhAvE10.cjs} +1 -1
  47. package/dist/{TimePicker-CHZsr_jj.js → TimePicker-CYlcUTTM.js} +2 -2
  48. package/dist/{TimePicker-Cpmvn8tx.cjs → TimePicker-DoGbwfkU.cjs} +1 -1
  49. package/dist/{Tooltip-Buk5F9f_.js → Tooltip-BKPreZML.js} +2 -2
  50. package/dist/{Tooltip-CP8rpNYG.cjs → Tooltip-DDjGLjoV.cjs} +1 -1
  51. package/dist/{Upload-CVIzg2Px.js → Upload-DZ6VaM7r.js} +1 -1
  52. package/dist/{Upload-CIOunhpr.cjs → Upload-wHEEoe1c.cjs} +1 -1
  53. package/dist/cjs/Anchor.cjs +1 -1
  54. package/dist/cjs/Announcement.cjs +1 -1
  55. package/dist/cjs/Checkbox.cjs +1 -1
  56. package/dist/cjs/Cron.cjs +1 -1
  57. package/dist/cjs/DatePicker.cjs +1 -1
  58. package/dist/cjs/DateTimePicker.cjs +1 -1
  59. package/dist/cjs/Drawer.cjs +1 -1
  60. package/dist/cjs/Dropdown.cjs +1 -1
  61. package/dist/cjs/Form.cjs +1 -1
  62. package/dist/cjs/Input.cjs +1 -1
  63. package/dist/cjs/MessageBox.cjs +1 -1
  64. package/dist/cjs/Modal.cjs +1 -1
  65. package/dist/cjs/NumberInput.cjs +1 -1
  66. package/dist/cjs/Pagination.cjs +1 -1
  67. package/dist/cjs/Radio.cjs +1 -1
  68. package/dist/cjs/Select.cjs +1 -1
  69. package/dist/cjs/Slider.cjs +1 -1
  70. package/dist/cjs/Switch.cjs +1 -1
  71. package/dist/cjs/Table.cjs +1 -1
  72. package/dist/cjs/Tabs.cjs +1 -1
  73. package/dist/cjs/Tag.cjs +1 -1
  74. package/dist/cjs/Textarea.cjs +1 -1
  75. package/dist/cjs/TimePicker.cjs +1 -1
  76. package/dist/cjs/Tooltip.cjs +1 -1
  77. package/dist/cjs/Upload.cjs +1 -1
  78. package/dist/cjs/global.cjs +1 -1
  79. package/dist/cjs/index.cjs +1 -1
  80. package/dist/cjs/register.cjs +1 -1
  81. package/dist/css/Checkbox.css +1 -1
  82. package/dist/css/Form.css +1 -1
  83. package/dist/css/Input.css +1 -1
  84. package/dist/css/MessageBox.css +1 -1
  85. package/dist/css/Modal.css +1 -1
  86. package/dist/css/Radio.css +1 -1
  87. package/dist/css/Select.css +1 -1
  88. package/dist/css/Tag.css +1 -1
  89. package/dist/{date-picker-pwA2wCag.cjs → date-picker-Be_1wA3S.cjs} +1 -1
  90. package/dist/{date-picker-BH--Nh7g.js → date-picker-CHP0eBuL.js} +4 -4
  91. package/dist/es/Anchor.mjs +1 -1
  92. package/dist/es/Announcement.mjs +1 -1
  93. package/dist/es/Checkbox.mjs +1 -1
  94. package/dist/es/Cron.mjs +1 -1
  95. package/dist/es/DatePicker.mjs +1 -1
  96. package/dist/es/DateTimePicker.mjs +1 -1
  97. package/dist/es/Drawer.mjs +1 -1
  98. package/dist/es/Dropdown.mjs +1 -1
  99. package/dist/es/Form.mjs +1 -1
  100. package/dist/es/Input.mjs +1 -1
  101. package/dist/es/MessageBox.mjs +1 -1
  102. package/dist/es/Modal.mjs +1 -1
  103. package/dist/es/NumberInput.mjs +1 -1
  104. package/dist/es/Pagination.mjs +1 -1
  105. package/dist/es/Radio.mjs +1 -1
  106. package/dist/es/Select.mjs +1 -1
  107. package/dist/es/Slider.mjs +1 -1
  108. package/dist/es/Switch.mjs +1 -1
  109. package/dist/es/Table.mjs +1 -1
  110. package/dist/es/Tabs.mjs +1 -1
  111. package/dist/es/Tag.mjs +1 -1
  112. package/dist/es/Textarea.mjs +1 -1
  113. package/dist/es/TimePicker.mjs +1 -1
  114. package/dist/es/Tooltip.mjs +1 -1
  115. package/dist/es/Upload.mjs +1 -1
  116. package/dist/es/global.mjs +1 -1
  117. package/dist/es/index.mjs +25 -25
  118. package/dist/es/register.mjs +1 -1
  119. package/dist/floating-5PRFyI8D.cjs +1 -0
  120. package/dist/floating-CqdcJWk2.js +181 -0
  121. package/dist/index.css +1 -1
  122. package/dist/registry-BqfLh5B_.cjs +1 -0
  123. package/dist/{registry-macDoSyW.js → registry-C8ZL-n-l.js} +24 -24
  124. package/dist/state-BSDh-Ob2.js +22 -0
  125. package/dist/state-BuUx1onZ.cjs +1 -0
  126. package/dist/types/Checkbox/context.d.cts +12 -2
  127. package/dist/types/Checkbox/context.d.ts +12 -2
  128. package/dist/types/Checkbox/type.d.cts +33 -3
  129. package/dist/types/Checkbox/type.d.ts +33 -3
  130. package/dist/types/Form/FormItem.d.cts +1 -1
  131. package/dist/types/Form/FormItem.d.ts +1 -1
  132. package/dist/types/Form/context.d.cts +31 -0
  133. package/dist/types/Form/context.d.ts +31 -0
  134. package/dist/types/Form/index.d.cts +2 -2
  135. package/dist/types/Form/index.d.ts +2 -2
  136. package/dist/types/Form/type.d.cts +0 -2
  137. package/dist/types/Form/type.d.ts +0 -2
  138. package/dist/types/Radio/context.d.cts +12 -2
  139. package/dist/types/Radio/context.d.ts +12 -2
  140. package/dist/types/Radio/type.d.cts +33 -3
  141. package/dist/types/Radio/type.d.ts +33 -3
  142. package/dist/types/Tag/index.d.cts +1 -1
  143. package/dist/types/Tag/index.d.ts +1 -1
  144. package/dist/types/Tag/type.d.cts +5 -0
  145. package/dist/types/Tag/type.d.ts +5 -0
  146. package/dist/types/_shared/state.d.cts +3 -0
  147. package/dist/types/_shared/state.d.ts +3 -0
  148. package/dist/types/registry.d.cts +1 -1
  149. package/dist/types/registry.d.ts +1 -1
  150. package/package.json +1 -1
  151. package/dist/Checkbox-BCXbK1-8.cjs +0 -1
  152. package/dist/Checkbox-CQZSg9Xu.cjs +0 -1
  153. package/dist/Checkbox-CQeqLO0S.js +0 -46
  154. package/dist/Checkbox-cnXHW9Oz.js +0 -61
  155. package/dist/Form-BfXRwX6y.js +0 -353
  156. package/dist/Form-QpWOfQpR.cjs +0 -1
  157. package/dist/Input-CoDZggqc.cjs +0 -1
  158. package/dist/Modal-DnLKpKvW.js +0 -238
  159. package/dist/RadioGroup-BRcNi5Oc.js +0 -98
  160. package/dist/RadioGroup-q2Aa50NV.cjs +0 -1
  161. package/dist/Select-BRKxpX-_.cjs +0 -1
  162. package/dist/Select-QedbJ4pD.js +0 -468
  163. package/dist/Table-BFqTvxt1.js +0 -440
  164. package/dist/Table-D4csqW47.cjs +0 -1
  165. package/dist/Tag-Cf9M_HT6.cjs +0 -1
  166. package/dist/Tag-CkfqoSwA.js +0 -42
  167. package/dist/floating-DBAmeQIq.js +0 -157
  168. package/dist/floating-DXRnx48N.cjs +0 -1
  169. package/dist/registry-BO2ao8Jc.cjs +0 -1
  170. package/dist/state-ZBA75xZ_.cjs +0 -1
  171. package/dist/state-oH-YwB7_.js +0 -15
@@ -1,5 +1,5 @@
1
1
  import Tag from './Tag.js';
2
2
  /** Tag 标签组件 */
3
3
  export declare const VlTag: import("react").ForwardRefExoticComponent<import("./type.js").TagProps & import("react").RefAttributes<HTMLElement>>;
4
- export type { TagProps, TagStatus, TagSize, TagRef } from './type.js';
4
+ export type { TagProps, TagStatus, TagSize, TagRef, TagIcon } from './type.js';
5
5
  export default Tag;
@@ -1,10 +1,13 @@
1
1
  import type { ElementType, HTMLAttributes, MouseEvent } from 'react';
2
+ import type { DecorativeIcon } from '../_shared/icon.cjs';
2
3
  /** 标签语义状态:默认/中性 (default) | 主题色 (primary) | 成功 (success) | 警告 (warning) | 错误 (error) | 信息 (info) */
3
4
  export type TagStatus = 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info';
4
5
  /** 标签尺寸:小 (sm) | 中等 (md) | 大 (lg) */
5
6
  export type TagSize = 'sm' | 'md' | 'lg';
6
7
  /** Tag 根 DOM 元素类型 */
7
8
  export type TagRef = HTMLElement;
9
+ /** Tag 图标组件或节点类型 */
10
+ export type TagIcon = DecorativeIcon;
8
11
  /**
9
12
  * Tag 组件属性接口
10
13
  */
@@ -13,6 +16,8 @@ export interface TagProps extends HTMLAttributes<HTMLElement> {
13
16
  status?: TagStatus;
14
17
  /** 标签尺寸大小,默认为 `md` */
15
18
  size?: TagSize;
19
+ /** 标签前置图标 */
20
+ icon?: TagIcon;
16
21
  /** 是否支持关闭/移除,开启后展示关闭图标,默认为 false */
17
22
  closable?: boolean;
18
23
  /** 是否处于禁用状态,禁用后阻止关闭交互,默认为 false */
@@ -1,10 +1,13 @@
1
1
  import type { ElementType, HTMLAttributes, MouseEvent } from 'react';
2
+ import type { DecorativeIcon } from '../_shared/icon.js';
2
3
  /** 标签语义状态:默认/中性 (default) | 主题色 (primary) | 成功 (success) | 警告 (warning) | 错误 (error) | 信息 (info) */
3
4
  export type TagStatus = 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info';
4
5
  /** 标签尺寸:小 (sm) | 中等 (md) | 大 (lg) */
5
6
  export type TagSize = 'sm' | 'md' | 'lg';
6
7
  /** Tag 根 DOM 元素类型 */
7
8
  export type TagRef = HTMLElement;
9
+ /** Tag 图标组件或节点类型 */
10
+ export type TagIcon = DecorativeIcon;
8
11
  /**
9
12
  * Tag 组件属性接口
10
13
  */
@@ -13,6 +16,8 @@ export interface TagProps extends HTMLAttributes<HTMLElement> {
13
16
  status?: TagStatus;
14
17
  /** 标签尺寸大小,默认为 `md` */
15
18
  size?: TagSize;
19
+ /** 标签前置图标 */
20
+ icon?: TagIcon;
16
21
  /** 是否支持关闭/移除,开启后展示关闭图标,默认为 false */
17
22
  closable?: boolean;
18
23
  /** 是否处于禁用状态,禁用后阻止关闭交互,默认为 false */
@@ -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").ForwardRefExoticComponent<import("./Form/index.cjs").FormItemProps & import("react").RefAttributes<HTMLDivElement>>;
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>>;
@@ -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").ForwardRefExoticComponent<import("./Form/index.js").FormItemProps & import("react").RefAttributes<HTMLDivElement>>;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@vavt/react-ui",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "author": "zbf <zbfcqtl@gmail.com>",
5
5
  "license": "MIT",
6
6
  "description": "A modern React component library",
@@ -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 };
@@ -1,353 +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 { t as a } from "./Tooltip-Buk5F9f_.js";
7
- import { cloneElement as o, createContext as s, forwardRef as c, useCallback as l, useContext as u, useEffect as d, useImperativeHandle as f, useMemo as p, useRef as m, useState as h } from "react";
8
- import { jsx as g, jsxs as _ } from "react/jsx-runtime";
9
- //#region components/Form/context.ts
10
- var v = s(null), y = v.Provider, ee = () => u(v), b = ["blur", "submit"], x = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, te = (e) => e ? Array.isArray(e) ? e : [e] : b, S = (e) => e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) && e.length === 0, C = (e, t, n, r) => {
11
- let i = t ?? e;
12
- if (n.required && S(r)) return n.message ?? `请输入${i}`;
13
- if (S(r)) return;
14
- 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}格式不正确`;
15
- let a = typeof r == "number" ? r : typeof r == "string" || Array.isArray(r) ? r.length : null;
16
- if (n.len !== void 0 && a !== null && a !== n.len) return n.message ?? `${i}长度必须为 ${n.len}`;
17
- if (n.min !== void 0 && a !== null && a < n.min) return n.message ?? `${i}不能小于 ${n.min}`;
18
- if (n.max !== void 0 && a !== null && a > n.max) return n.message ?? `${i}不能大于 ${n.max}`;
19
- }, w = c((n, r) => {
20
- let { values: a, defaultValues: o = {}, layout: s = "vertical", labelWidth: c, feedbackWidth: u, labelAlign: d = s === "horizontal" ? "right" : "left", validateTrigger: _, className: v, style: ee, children: b, onValuesChange: x, onFinish: S, onFinishError: w, onFinishFailed: T, noValidate: E = !0, ...D } = n, O = t(n, "values"), [k, A] = h(o), j = p(() => O ? a ?? {} : k, [
21
- O,
22
- k,
23
- a
24
- ]), M = m(j);
25
- e(() => {
26
- M.current = j;
27
- }, [j]);
28
- let [N, P] = h({}), F = m(N), [I, L] = h({}), [R, z] = h(!1), B = m(!1), V = m(null), H = m(/* @__PURE__ */ new Map()), U = m(/* @__PURE__ */ new Map()), W = p(() => te(_), [_]), G = l((e) => {
29
- F.current = e, P(e);
30
- }, []), K = l((e) => (H.current.set(e.name, e), () => {
31
- if (H.current.get(e.name)?.token === e.token) {
32
- if (H.current.delete(e.name), U.current.delete(e.name), Object.prototype.hasOwnProperty.call(F.current, e.name)) {
33
- let t = { ...F.current };
34
- delete t[e.name], G(t);
35
- }
36
- L((t) => {
37
- if (!Object.prototype.hasOwnProperty.call(t, e.name)) return t;
38
- let n = { ...t };
39
- return delete n[e.name], n;
40
- });
41
- }
42
- }), [G]), q = l((e, t) => {
43
- let n = {
44
- ...M.current,
45
- [e]: t
46
- };
47
- return M.current = n, O || A(n), x?.({ [e]: t }, n), n;
48
- }, [O, x]), J = l(async (e, t) => {
49
- let n = H.current.get(e);
50
- if (!n) return [];
51
- let r = t ?? M.current, i = r[e], a = Symbol(e);
52
- U.current.set(e, a), L((t) => ({
53
- ...t,
54
- [e]: !0
55
- }));
56
- let o = [], { rules: s, label: c } = n.metaRef.current;
57
- for (let t of s) {
58
- let n = C(e, c, t, i);
59
- if (n && o.push(n), t.validator) try {
60
- let e = await t.validator(i, r);
61
- e && o.push(t.message ?? e);
62
- } catch (e) {
63
- let n = e instanceof Error ? e.message : "校验失败";
64
- o.push(t.message ?? n);
65
- }
66
- }
67
- if (H.current.get(e)?.token !== n.token || U.current.get(e) !== a) return o;
68
- let l = { ...F.current };
69
- return o.length ? l[e] = o : delete l[e], G(l), L((t) => ({
70
- ...t,
71
- [e]: !1
72
- })), o;
73
- }, [G]), Y = l(async () => {
74
- let e = M.current, t = [...H.current.values()], n = await Promise.all(t.map(async (t) => {
75
- let n = J(t.name, e);
76
- return [
77
- t,
78
- U.current.get(t.name),
79
- await n
80
- ];
81
- })), r = { ...F.current };
82
- return n.forEach(([e, t, n]) => {
83
- H.current.get(e.name)?.token === e.token && U.current.get(e.name) === t && (n.length ? r[e.name] = n : delete r[e.name]);
84
- }), G(r), {
85
- valid: Object.keys(r).length === 0,
86
- values: e,
87
- errors: r
88
- };
89
- }, [G, J]), X = l(() => {
90
- if (V.current) return V.current;
91
- let e = (async () => {
92
- B.current = !0, z(!0);
93
- try {
94
- let e = await Y();
95
- if (e.valid) try {
96
- await S?.(e.values);
97
- } catch (t) {
98
- w?.(t, e.values);
99
- }
100
- else {
101
- T?.(e.errors, e.values);
102
- let t = [...H.current.keys()].find((t) => e.errors[t]);
103
- t && i(H.current.get(t)?.metaRef.current.element ?? null);
104
- }
105
- return e;
106
- } finally {
107
- B.current = !1, z(!1);
108
- }
109
- })();
110
- return V.current = e, e.then(() => {
111
- V.current === e && (V.current = null);
112
- }, () => {
113
- V.current === e && (V.current = null);
114
- }), e;
115
- }, [
116
- S,
117
- w,
118
- T,
119
- Y
120
- ]), Z = l((e) => {
121
- let t = {
122
- ...M.current,
123
- ...e
124
- };
125
- M.current = t, O || A(t), x?.(e, t);
126
- }, [O, x]), Q = l(() => {
127
- let e = { ...o }, t = M.current;
128
- M.current = e, O || A(e);
129
- 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]]));
130
- Object.keys(r).length && x?.(r, e), G({}), U.current.clear(), L({});
131
- }, [
132
- G,
133
- O,
134
- o,
135
- x
136
- ]);
137
- f(r, () => ({
138
- getValues: () => M.current,
139
- setValues: Z,
140
- reset: Q,
141
- validate: Y,
142
- submit: X,
143
- isSubmitting: () => B.current,
144
- getErrors: () => F.current
145
- }), [
146
- Q,
147
- Z,
148
- X,
149
- Y
150
- ]);
151
- let $ = p(() => ({
152
- values: j,
153
- errors: N,
154
- validating: I,
155
- defaultValidateTrigger: W,
156
- registerField: K,
157
- updateField: q,
158
- validateField: J
159
- }), [
160
- W,
161
- N,
162
- K,
163
- q,
164
- J,
165
- I,
166
- j
167
- ]), ne = {
168
- ...ee,
169
- ...c === void 0 ? null : { "--vl-form-label-width": typeof c == "number" ? `${c}px` : c },
170
- ...u === void 0 ? null : { "--vl-form-feedback-width": typeof u == "number" ? `${u}px` : u }
171
- }, re = [
172
- "vl-form",
173
- `vl-form--${s}`,
174
- `vl-form--label-${d}`,
175
- R ? "is-submitting" : "",
176
- v || ""
177
- ].filter(Boolean).join(" "), ie = (e) => {
178
- e.preventDefault(), X();
179
- }, ae = (e) => {
180
- e.preventDefault(), Q();
181
- };
182
- return /* @__PURE__ */ g(y, {
183
- value: $,
184
- children: /* @__PURE__ */ g("form", {
185
- ...D,
186
- className: re,
187
- style: ne,
188
- "aria-busy": R || void 0,
189
- noValidate: E,
190
- onSubmit: ie,
191
- onReset: ae,
192
- children: b
193
- })
194
- });
195
- });
196
- w.displayName = "VlForm";
197
- //#endregion
198
- //#region components/Form/FormItem.tsx
199
- var T = [], E = [], D = [], O = (e, t) => e ? Array.isArray(e) ? e : [e] : t, k = (e, t) => {
200
- if (e === "checked" && typeof t[1] == "boolean") return t[1];
201
- let n = t[0];
202
- if (n && typeof n == "object" && "target" in n) {
203
- let t = n.target;
204
- if (t) return e === "checked" ? t.checked : t.value;
205
- }
206
- return n;
207
- }, A = ({ id: t, content: n }) => {
208
- let r = m(null), [i, o] = h(!1), s = l(() => {
209
- let e = r.current;
210
- e && o(e.scrollWidth > e.clientWidth);
211
- }, []);
212
- return e(() => {
213
- s();
214
- let e = r.current, t = typeof ResizeObserver > "u" ? null : new ResizeObserver(s);
215
- return e && t?.observe(e), window.addEventListener("resize", s, { passive: !0 }), () => {
216
- t?.disconnect(), window.removeEventListener("resize", s);
217
- };
218
- }, [n, s]), /* @__PURE__ */ g(a, {
219
- id: t,
220
- className: "vl-form-item__help-tooltip",
221
- content: n,
222
- disabled: !i,
223
- children: /* @__PURE__ */ g("div", {
224
- ref: r,
225
- className: "vl-form-item__help is-text",
226
- tabIndex: i ? 0 : void 0,
227
- children: n
228
- })
229
- });
230
- }, j = c((t, i) => {
231
- let { name: a, label: s, required: c = !1, rules: l = T, help: u, valuePropName: f = "value", trigger: v = "onChange", getValueFromEvent: y, validateTrigger: b, className: x, children: te, ...S } = t, C = ee(), w = C?.registerField, j = te, M = j.props, N = r("vl-form-control", M.id), P = r("vl-form-label"), F = r("vl-form-help"), I = r("vl-form-error"), L = m(null), R = m(null), z = m(null), B = C?.defaultValidateTrigger ?? E, V = p(() => O(b, B), [B, b]), H = p(() => c && !l.some((e) => e.required) ? [{ required: !0 }, ...l] : l, [c, l]), U = c || H.some((e) => e.required), W = u != null && typeof u != "boolean" && u !== "", G = a ? C?.errors[a] ?? D : D, K = a ? !!C?.validating[a] : !1, q = V.includes("change") || G.length > 0, [J] = h(() => Symbol("form-field")), Y = m({
232
- label: void 0,
233
- rules: T,
234
- element: null
235
- });
236
- e(() => {
237
- Y.current.label = typeof s == "string" ? s : void 0, Y.current.rules = H;
238
- }, [H, s]), d(() => {
239
- if (!(!a || !w)) return w({
240
- name: a,
241
- token: J,
242
- metaRef: Y
243
- });
244
- }, [
245
- J,
246
- a,
247
- w
248
- ]), d(() => {
249
- let e = R.current, t = z.current;
250
- if (z.current = G, e) {
251
- if (!G.length) {
252
- e.classList.remove("is-shaking");
253
- return;
254
- }
255
- t !== G && (e.classList.remove("is-shaking"), e.offsetWidth, e.classList.add("is-shaking"));
256
- }
257
- }, [G]);
258
- let X = {
259
- id: N,
260
- "aria-describedby": [
261
- M["aria-describedby"],
262
- G.length ? I : void 0,
263
- W ? F : void 0
264
- ].filter(Boolean).join(" ") || void 0,
265
- "aria-labelledby": [M["aria-labelledby"], s === void 0 ? void 0 : P].filter(Boolean).join(" ") || void 0,
266
- "aria-invalid": G.length > 0 || void 0,
267
- "aria-busy": K || void 0,
268
- ref: (e) => {
269
- L.current = e, Y.current.element = e, n(M.ref, e);
270
- }
271
- };
272
- if (a && C) {
273
- X[f] = C.values[a];
274
- let e = M[v];
275
- if (X[v] = (...t) => {
276
- typeof e == "function" && e(...t);
277
- let n = y ? y(...t) : k(f, t), r = C.updateField(a, n);
278
- (q || v === "onBlur" && V.includes("blur")) && C.validateField(a, r);
279
- }, v !== "onBlur") {
280
- let e = M.onBlur;
281
- X.onBlur = (t) => {
282
- typeof e == "function" && e(t), V.includes("blur") && C.validateField(a);
283
- };
284
- }
285
- }
286
- let Z = o(j, X), Q = [
287
- "vl-form-item",
288
- s === void 0 ? "" : "has-label",
289
- W ? "has-help" : "",
290
- G.length ? "is-error" : "",
291
- K ? "is-validating" : "",
292
- U ? "is-required" : "",
293
- x || ""
294
- ].filter(Boolean).join(" "), $ = K || G.length > 0;
295
- return /* @__PURE__ */ _("div", {
296
- ...S,
297
- ref: i,
298
- className: Q,
299
- children: [s === void 0 ? null : /* @__PURE__ */ _("label", {
300
- id: P,
301
- className: "vl-form-item__label",
302
- htmlFor: N,
303
- children: [U ? /* @__PURE__ */ g("span", {
304
- className: "vl-form-item__required",
305
- "aria-hidden": "true",
306
- children: "*"
307
- }) : null, s]
308
- }), /* @__PURE__ */ _("div", {
309
- className: "vl-form-item__control",
310
- children: [/* @__PURE__ */ _("div", {
311
- className: "vl-form-item__field",
312
- children: [/* @__PURE__ */ g("div", {
313
- ref: R,
314
- className: "vl-form-item__control-input",
315
- children: Z
316
- }), a ? /* @__PURE__ */ _("div", {
317
- className: `vl-form-item__validation${$ ? "" : " is-empty"}`,
318
- "aria-hidden": !$ || void 0,
319
- children: [K ? /* @__PURE__ */ _("div", {
320
- className: "vl-form-item__status",
321
- role: "status",
322
- "aria-label": "校验中",
323
- children: [/* @__PURE__ */ g("span", {
324
- className: "vl-form-item__spinner",
325
- "aria-hidden": "true"
326
- }), /* @__PURE__ */ g("span", { children: "校验中" })]
327
- }) : null, G.length ? /* @__PURE__ */ g("div", {
328
- id: I,
329
- className: "vl-form-item__error",
330
- role: "alert",
331
- children: G.map((e) => /* @__PURE__ */ g("div", { children: e }, e))
332
- }) : null]
333
- }) : null]
334
- }), W ? /* @__PURE__ */ g("div", {
335
- className: "vl-form-item__feedback",
336
- children: typeof u == "string" || typeof u == "number" ? /* @__PURE__ */ g(A, {
337
- id: F,
338
- content: u
339
- }) : /* @__PURE__ */ g("div", {
340
- id: F,
341
- className: "vl-form-item__help",
342
- children: u
343
- })
344
- }) : null]
345
- })]
346
- });
347
- });
348
- j.displayName = "VlFormItem";
349
- //#endregion
350
- //#region components/Form/index.ts
351
- var M = Object.assign(w, { Item: j }), N = j;
352
- //#endregion
353
- export { N as n, M as t };
@@ -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"),a=require("./Tooltip-CP8rpNYG.cjs");let o=require("react"),s=require("react/jsx-runtime");var c=(0,o.createContext)(null),l=c.Provider,u=()=>(0,o.useContext)(c),d=[`blur`,`submit`],f=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,p=e=>e?Array.isArray(e)?e:[e]:d,m=e=>e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)&&e.length===0,h=(e,t,n,r)=>{let i=t??e;if(n.required&&m(r))return n.message??`请输入${i}`;if(m(r))return;if(n.type&&!(n.type===`array`?Array.isArray(r):n.type===`email`?typeof r==`string`&&f.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}`},g=(0,o.forwardRef)((n,r)=>{let{values:a,defaultValues:c={},layout:u=`vertical`,labelWidth:d,feedbackWidth:f,labelAlign:m=u===`horizontal`?`right`:`left`,validateTrigger:g,className:_,style:v,children:y,onValuesChange:b,onFinish:x,onFinishError:S,onFinishFailed:C,noValidate:w=!0,...T}=n,E=t.t(n,`values`),[D,O]=(0,o.useState)(c),k=(0,o.useMemo)(()=>E?a??{}:D,[E,D,a]),A=(0,o.useRef)(k);e.t(()=>{A.current=k},[k]);let[j,M]=(0,o.useState)({}),N=(0,o.useRef)(j),[P,F]=(0,o.useState)({}),[I,L]=(0,o.useState)(!1),R=(0,o.useRef)(!1),z=(0,o.useRef)(null),B=(0,o.useRef)(new Map),V=(0,o.useRef)(new Map),H=(0,o.useMemo)(()=>p(g),[g]),U=(0,o.useCallback)(e=>{N.current=e,M(e)},[]),W=(0,o.useCallback)(e=>(B.current.set(e.name,e),()=>{if(B.current.get(e.name)?.token===e.token){if(B.current.delete(e.name),V.current.delete(e.name),Object.prototype.hasOwnProperty.call(N.current,e.name)){let t={...N.current};delete t[e.name],U(t)}F(t=>{if(!Object.prototype.hasOwnProperty.call(t,e.name))return t;let n={...t};return delete n[e.name],n})}}),[U]),G=(0,o.useCallback)((e,t)=>{let n={...A.current,[e]:t};return A.current=n,E||O(n),b?.({[e]:t},n),n},[E,b]),K=(0,o.useCallback)(async(e,t)=>{let n=B.current.get(e);if(!n)return[];let r=t??A.current,i=r[e],a=Symbol(e);V.current.set(e,a),F(t=>({...t,[e]:!0}));let o=[],{rules:s,label:c}=n.metaRef.current;for(let t of s){let n=h(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(B.current.get(e)?.token!==n.token||V.current.get(e)!==a)return o;let l={...N.current};return o.length?l[e]=o:delete l[e],U(l),F(t=>({...t,[e]:!1})),o},[U]),q=(0,o.useCallback)(async()=>{let e=A.current,t=[...B.current.values()],n=await Promise.all(t.map(async t=>{let n=K(t.name,e);return[t,V.current.get(t.name),await n]})),r={...N.current};return n.forEach(([e,t,n])=>{B.current.get(e.name)?.token===e.token&&V.current.get(e.name)===t&&(n.length?r[e.name]=n:delete r[e.name])}),U(r),{valid:Object.keys(r).length===0,values:e,errors:r}},[U,K]),J=(0,o.useCallback)(()=>{if(z.current)return z.current;let e=(async()=>{R.current=!0,L(!0);try{let e=await q();if(e.valid)try{await x?.(e.values)}catch(t){S?.(t,e.values)}else{C?.(e.errors,e.values);let t=[...B.current.keys()].find(t=>e.errors[t]);t&&i.n(B.current.get(t)?.metaRef.current.element??null)}return e}finally{R.current=!1,L(!1)}})();return z.current=e,e.then(()=>{z.current===e&&(z.current=null)},()=>{z.current===e&&(z.current=null)}),e},[x,S,C,q]),Y=(0,o.useCallback)(e=>{let t={...A.current,...e};A.current=t,E||O(t),b?.(e,t)},[E,b]),X=(0,o.useCallback)(()=>{let e={...c},t=A.current;A.current=e,E||O(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&&b?.(r,e),U({}),V.current.clear(),F({})},[U,E,c,b]);(0,o.useImperativeHandle)(r,()=>({getValues:()=>A.current,setValues:Y,reset:X,validate:q,submit:J,isSubmitting:()=>R.current,getErrors:()=>N.current}),[X,Y,J,q]);let Z=(0,o.useMemo)(()=>({values:k,errors:j,validating:P,defaultValidateTrigger:H,registerField:W,updateField:G,validateField:K}),[H,j,W,G,K,P,k]),Q={...v,...d===void 0?null:{"--vl-form-label-width":typeof d==`number`?`${d}px`:d},...f===void 0?null:{"--vl-form-feedback-width":typeof f==`number`?`${f}px`:f}},$=[`vl-form`,`vl-form--${u}`,`vl-form--label-${m}`,I?`is-submitting`:``,_||``].filter(Boolean).join(` `),ee=e=>{e.preventDefault(),J()},te=e=>{e.preventDefault(),X()};return(0,s.jsx)(l,{value:Z,children:(0,s.jsx)(`form`,{...T,className:$,style:Q,"aria-busy":I||void 0,noValidate:w,onSubmit:ee,onReset:te,children:y})})});g.displayName=`VlForm`;var _=[],v=[],y=[],b=(e,t)=>e?Array.isArray(e)?e:[e]:t,x=(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},S=({id:t,content:n})=>{let r=(0,o.useRef)(null),[i,c]=(0,o.useState)(!1),l=(0,o.useCallback)(()=>{let e=r.current;e&&c(e.scrollWidth>e.clientWidth)},[]);return e.t(()=>{l();let e=r.current,t=typeof ResizeObserver>`u`?null:new ResizeObserver(l);return e&&t?.observe(e),window.addEventListener(`resize`,l,{passive:!0}),()=>{t?.disconnect(),window.removeEventListener(`resize`,l)}},[n,l]),(0,s.jsx)(a.t,{id:t,className:`vl-form-item__help-tooltip`,content:n,disabled:!i,children:(0,s.jsx)(`div`,{ref:r,className:`vl-form-item__help is-text`,tabIndex:i?0:void 0,children:n})})},C=(0,o.forwardRef)((t,i)=>{let{name:a,label:c,required:l=!1,rules:d=_,help:f,valuePropName:p=`value`,trigger:m=`onChange`,getValueFromEvent:h,validateTrigger:g,className:C,children:w,...T}=t,E=u(),D=E?.registerField,O=w,k=O.props,A=r.t(`vl-form-control`,k.id),j=r.t(`vl-form-label`),M=r.t(`vl-form-help`),N=r.t(`vl-form-error`),P=(0,o.useRef)(null),F=(0,o.useRef)(null),I=(0,o.useRef)(null),L=E?.defaultValidateTrigger??v,R=(0,o.useMemo)(()=>b(g,L),[L,g]),z=(0,o.useMemo)(()=>l&&!d.some(e=>e.required)?[{required:!0},...d]:d,[l,d]),B=l||z.some(e=>e.required),V=f!=null&&typeof f!=`boolean`&&f!==``,H=a?E?.errors[a]??y:y,U=a?!!E?.validating[a]:!1,W=R.includes(`change`)||H.length>0,[G]=(0,o.useState)(()=>Symbol(`form-field`)),K=(0,o.useRef)({label:void 0,rules:_,element:null});e.t(()=>{K.current.label=typeof c==`string`?c:void 0,K.current.rules=z},[z,c]),(0,o.useEffect)(()=>{if(!(!a||!D))return D({name:a,token:G,metaRef:K})},[G,a,D]),(0,o.useEffect)(()=>{let e=F.current,t=I.current;if(I.current=H,e){if(!H.length){e.classList.remove(`is-shaking`);return}t!==H&&(e.classList.remove(`is-shaking`),e.offsetWidth,e.classList.add(`is-shaking`))}},[H]);let q={id:A,"aria-describedby":[k[`aria-describedby`],H.length?N:void 0,V?M:void 0].filter(Boolean).join(` `)||void 0,"aria-labelledby":[k[`aria-labelledby`],c===void 0?void 0:j].filter(Boolean).join(` `)||void 0,"aria-invalid":H.length>0||void 0,"aria-busy":U||void 0,ref:e=>{P.current=e,K.current.element=e,n.t(k.ref,e)}};if(a&&E){q[p]=E.values[a];let e=k[m];if(q[m]=(...t)=>{typeof e==`function`&&e(...t);let n=h?h(...t):x(p,t),r=E.updateField(a,n);(W||m===`onBlur`&&R.includes(`blur`))&&E.validateField(a,r)},m!==`onBlur`){let e=k.onBlur;q.onBlur=t=>{typeof e==`function`&&e(t),R.includes(`blur`)&&E.validateField(a)}}}let J=(0,o.cloneElement)(O,q),Y=[`vl-form-item`,c===void 0?``:`has-label`,V?`has-help`:``,H.length?`is-error`:``,U?`is-validating`:``,B?`is-required`:``,C||``].filter(Boolean).join(` `),X=U||H.length>0;return(0,s.jsxs)(`div`,{...T,ref:i,className:Y,children:[c===void 0?null:(0,s.jsxs)(`label`,{id:j,className:`vl-form-item__label`,htmlFor:A,children:[B?(0,s.jsx)(`span`,{className:`vl-form-item__required`,"aria-hidden":`true`,children:`*`}):null,c]}),(0,s.jsxs)(`div`,{className:`vl-form-item__control`,children:[(0,s.jsxs)(`div`,{className:`vl-form-item__field`,children:[(0,s.jsx)(`div`,{ref:F,className:`vl-form-item__control-input`,children:J}),a?(0,s.jsxs)(`div`,{className:`vl-form-item__validation${X?``:` is-empty`}`,"aria-hidden":!X||void 0,children:[U?(0,s.jsxs)(`div`,{className:`vl-form-item__status`,role:`status`,"aria-label":`校验中`,children:[(0,s.jsx)(`span`,{className:`vl-form-item__spinner`,"aria-hidden":`true`}),(0,s.jsx)(`span`,{children:`校验中`})]}):null,H.length?(0,s.jsx)(`div`,{id:N,className:`vl-form-item__error`,role:`alert`,children:H.map(e=>(0,s.jsx)(`div`,{children:e},e))}):null]}):null]}),V?(0,s.jsx)(`div`,{className:`vl-form-item__feedback`,children:typeof f==`string`||typeof f==`number`?(0,s.jsx)(S,{id:M,content:f}):(0,s.jsx)(`div`,{id:M,className:`vl-form-item__help`,children:f})}):null]})]})});C.displayName=`VlFormItem`;var w=Object.assign(g,{Item:C}),T=C;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return w}});
@@ -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}});