@pixelium/web-vue 0.0.2 → 0.0.3-alpha

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 (284) hide show
  1. package/README.md +42 -0
  2. package/README.zh.md +6 -3
  3. package/dist/font.css +1 -1
  4. package/dist/index.d.ts +1602 -248
  5. package/dist/normalize.css +2 -0
  6. package/dist/pixelium-vue-icon-hn.cjs +1 -1
  7. package/dist/pixelium-vue-icon-hn.css +2 -1
  8. package/dist/pixelium-vue-icon-hn.js +8533 -8154
  9. package/dist/pixelium-vue-icon-hn.umd.cjs +1 -1
  10. package/dist/pixelium-vue-icon-pa.cjs +1 -1
  11. package/dist/pixelium-vue-icon-pa.css +2 -1
  12. package/dist/pixelium-vue-icon-pa.js +10625 -10143
  13. package/dist/pixelium-vue-icon-pa.umd.cjs +1 -1
  14. package/dist/pixelium-vue.cjs +2 -2
  15. package/dist/pixelium-vue.css +2 -1
  16. package/dist/pixelium-vue.js +7407 -5852
  17. package/dist/pixelium-vue.umd.cjs +2 -2
  18. package/es/aside/index.css +1 -0
  19. package/es/aside/index.js +46 -151
  20. package/es/auto-complete/draw.d.ts +1 -1
  21. package/es/auto-complete/draw.js +26 -51
  22. package/es/auto-complete/index.css +92 -32
  23. package/es/auto-complete/index.d.ts +12 -15
  24. package/es/auto-complete/index.js +338 -400
  25. package/es/auto-complete/type.d.ts +25 -13
  26. package/es/avatar/css.js +2 -0
  27. package/es/avatar/draw.d.ts +2 -0
  28. package/es/avatar/draw.js +11 -0
  29. package/es/avatar/index.css +49 -0
  30. package/es/avatar/index.d.ts +15 -0
  31. package/es/avatar/index.js +110 -0
  32. package/es/avatar/type.d.ts +34 -0
  33. package/es/button/draw.d.ts +4 -4
  34. package/es/button/draw.js +213 -297
  35. package/es/button/index.css +40 -30
  36. package/es/button/index.d.ts +0 -4
  37. package/es/button/index.js +230 -256
  38. package/es/button/type.d.ts +3 -3
  39. package/es/button-group/index.css +0 -3
  40. package/es/button-group/index.d.ts +1 -2
  41. package/es/button-group/index.js +59 -31
  42. package/es/button-group/type.d.ts +21 -4
  43. package/es/checkbox/css.js +2 -0
  44. package/es/checkbox/draw.d.ts +4 -0
  45. package/es/checkbox/draw.js +46 -0
  46. package/es/checkbox/index.css +85 -0
  47. package/es/checkbox/index.d.ts +31 -0
  48. package/es/checkbox/index.js +206 -0
  49. package/es/checkbox/type.d.ts +88 -0
  50. package/es/checkbox-group/css.js +2 -0
  51. package/es/checkbox-group/index.css +20 -0
  52. package/es/checkbox-group/index.d.ts +23 -0
  53. package/es/checkbox-group/index.js +84 -0
  54. package/es/checkbox-group/type.d.ts +78 -0
  55. package/es/col/index.d.ts +2 -2
  56. package/es/col/index.js +43 -58
  57. package/es/container/index.css +1 -0
  58. package/es/container/index.js +18 -31
  59. package/es/divider/index.js +39 -53
  60. package/es/empty/index.css +4 -4
  61. package/es/empty/index.js +16 -71
  62. package/es/entry.js +102 -0
  63. package/es/footer/index.css +1 -0
  64. package/es/footer/index.js +31 -40
  65. package/es/form/css.js +1 -0
  66. package/es/form/index.d.ts +27 -0
  67. package/es/form/index.js +125 -0
  68. package/es/form/type.d.ts +238 -0
  69. package/es/form/use-form.d.ts +4 -0
  70. package/es/form/use-form.js +48 -0
  71. package/es/form-item/css.js +2 -0
  72. package/es/form-item/index.css +77 -0
  73. package/es/form-item/index.d.ts +37 -0
  74. package/es/form-item/index.js +318 -0
  75. package/es/form-item/type.d.ts +96 -0
  76. package/es/grid/index.js +56 -75
  77. package/es/grid-item/css.js +0 -1
  78. package/es/grid-item/index.d.ts +1 -1
  79. package/es/grid-item/index.js +85 -121
  80. package/es/header/index.css +1 -0
  81. package/es/header/index.js +31 -40
  82. package/es/icon/index.js +44 -55
  83. package/es/icons/css-hn.js +0 -1
  84. package/es/icons/css-pa.js +0 -1
  85. package/es/icons/icon-hn.js +10337 -15986
  86. package/es/icons/icon-pa.js +12573 -17447
  87. package/es/image/css.js +2 -0
  88. package/es/image/index.css +69 -0
  89. package/es/image/index.d.ts +35 -0
  90. package/es/image/index.js +199 -0
  91. package/es/image/type.d.ts +126 -0
  92. package/es/index.css +1 -515
  93. package/es/index.d.ts +22 -2
  94. package/es/index.js +144 -123
  95. package/es/input/draw.d.ts +1 -1
  96. package/es/input/draw.js +26 -51
  97. package/es/input/index.css +85 -33
  98. package/es/input/index.d.ts +9 -16
  99. package/es/input/index.js +319 -423
  100. package/es/input/type.d.ts +3 -3
  101. package/es/input-group/index.css +0 -1
  102. package/es/input-group/index.d.ts +2 -2
  103. package/es/input-group/index.js +66 -37
  104. package/es/input-group/type.d.ts +16 -4
  105. package/es/input-group-label/draw.d.ts +1 -1
  106. package/es/input-group-label/draw.js +26 -51
  107. package/es/input-group-label/index.css +33 -22
  108. package/es/input-group-label/index.d.ts +1 -4
  109. package/es/input-group-label/index.js +104 -127
  110. package/es/input-group-label/type.d.ts +3 -3
  111. package/es/input-number/draw.d.ts +1 -1
  112. package/es/input-number/draw.js +26 -51
  113. package/es/input-number/index.css +90 -35
  114. package/es/input-number/index.d.ts +9 -16
  115. package/es/input-number/index.js +428 -536
  116. package/es/input-number/type.d.ts +3 -3
  117. package/es/input-tag/draw.d.ts +1 -1
  118. package/es/input-tag/draw.js +26 -48
  119. package/es/input-tag/index.css +100 -33
  120. package/es/input-tag/index.d.ts +7 -13
  121. package/es/input-tag/index.js +442 -467
  122. package/es/input-tag/type.d.ts +24 -13
  123. package/es/link/index.js +75 -106
  124. package/es/main/index.css +4 -0
  125. package/es/main/index.d.ts +4 -1
  126. package/es/main/index.js +15 -15
  127. package/es/main/type.d.ts +7 -0
  128. package/es/mask/index.js +94 -115
  129. package/es/message/index.css +1 -1
  130. package/es/message/index.js +168 -346
  131. package/es/message-box/css.js +1 -1
  132. package/es/message-box/index.js +98 -114
  133. package/es/message-box/message-box-wrapped.js +33 -46
  134. package/es/message-box/message-box.js +79 -111
  135. package/es/option-list/index.css +13 -13
  136. package/es/option-list/index.d.ts +4 -31
  137. package/es/option-list/index.js +99 -167
  138. package/es/option-list/type.d.ts +5 -1
  139. package/es/pixelate/pixel.d.ts +5 -0
  140. package/es/pixelate/pixel.js +70 -0
  141. package/es/pixelate/pixelate.worker.d.ts +1 -0
  142. package/es/popover/index.d.ts +13 -99
  143. package/es/popover/index.js +75 -238
  144. package/es/popover/type.d.ts +7 -2
  145. package/es/popup/css.js +1 -0
  146. package/es/popup/index.d.ts +210 -0
  147. package/es/popup/index.js +203 -0
  148. package/es/popup/type.d.ts +105 -0
  149. package/es/popup-content/draw.d.ts +2 -2
  150. package/es/popup-content/draw.js +98 -143
  151. package/es/popup-content/index.css +11 -11
  152. package/es/popup-content/index.d.ts +1 -0
  153. package/es/popup-content/index.js +253 -1576
  154. package/es/popup-content/type.d.ts +1 -0
  155. package/es/popup-trigger/index.d.ts +8 -2
  156. package/es/popup-trigger/index.js +122 -95
  157. package/es/popup-trigger/type.d.ts +4 -1
  158. package/es/popup-wrapper/css.js +2 -0
  159. package/es/popup-wrapper/index.css +14 -0
  160. package/es/popup-wrapper/index.d.ts +18 -0
  161. package/es/popup-wrapper/index.js +67 -0
  162. package/es/popup-wrapper/type.d.ts +9 -0
  163. package/es/radio/css.js +1 -0
  164. package/es/radio/draw.d.ts +4 -0
  165. package/es/radio/draw.js +47 -0
  166. package/es/radio/index.d.ts +30 -0
  167. package/es/radio/index.js +190 -0
  168. package/es/radio/style.css +73 -0
  169. package/es/radio/type.d.ts +76 -0
  170. package/es/radio-group/css.js +2 -0
  171. package/es/radio-group/index.css +20 -0
  172. package/es/radio-group/index.d.ts +23 -0
  173. package/es/radio-group/index.js +77 -0
  174. package/es/radio-group/type.d.ts +77 -0
  175. package/es/row/index.js +56 -70
  176. package/es/select/draw.d.ts +1 -1
  177. package/es/select/draw.js +26 -51
  178. package/es/select/index.css +118 -36
  179. package/es/select/index.d.ts +14 -16
  180. package/es/select/index.js +625 -672
  181. package/es/select/type.d.ts +60 -25
  182. package/es/share/const/event-bus-key.js +1 -6
  183. package/es/share/const/index.d.ts +4 -0
  184. package/es/share/const/index.js +22 -24
  185. package/es/share/const/provide-key.d.ts +5 -0
  186. package/es/share/const/provide-key.js +6 -5
  187. package/es/share/const/style.d.ts +6 -0
  188. package/es/share/const/style.js +7 -0
  189. package/es/share/hook/use-cancelable-delay.d.ts +1 -0
  190. package/es/share/hook/use-cancelable-delay.js +42 -0
  191. package/es/share/hook/use-click-outside-listener.d.ts +1 -1
  192. package/es/share/hook/use-click-outside-listener.js +28 -41
  193. package/es/share/hook/use-composition.js +17 -15
  194. package/es/share/hook/use-controlled-mode.d.ts +3 -3
  195. package/es/share/hook/use-controlled-mode.js +20 -23
  196. package/es/share/hook/use-dark-mode.js +51 -65
  197. package/es/share/hook/use-index-of-children.d.ts +2 -1
  198. package/es/share/hook/use-index-of-children.js +47 -45
  199. package/es/share/hook/use-lazy-load.d.ts +10 -0
  200. package/es/share/hook/use-lazy-load.js +133 -0
  201. package/es/share/hook/use-props-detect.d.ts +2 -0
  202. package/es/share/hook/use-resize-observer.d.ts +1 -2
  203. package/es/share/hook/use-resize-observer.js +28 -20
  204. package/es/share/hook/use-screen-width.js +27 -36
  205. package/es/share/hook/use-smooth-transition.d.ts +2 -0
  206. package/es/share/hook/use-smooth-transition.js +65 -0
  207. package/es/share/hook/use-textarea-height.js +86 -92
  208. package/es/share/hook/use-theme-mode.js +41 -42
  209. package/es/share/hook/use-transition-end.d.ts +2 -0
  210. package/es/share/hook/use-transition-end.js +12 -0
  211. package/es/share/hook/use-watch-global-css-var.js +12 -16
  212. package/es/share/hook/use-window-resize-listener.d.ts +1 -0
  213. package/es/share/hook/use-window-resize-listener.js +15 -0
  214. package/es/share/hook/use-z-index.js +30 -27
  215. package/es/share/style/index.css +5 -0
  216. package/es/share/type/index.d.ts +18 -3
  217. package/es/share/util/color.d.ts +5 -3
  218. package/es/share/util/color.js +156 -149
  219. package/es/share/util/common.d.ts +7 -2
  220. package/es/share/util/common.js +127 -65
  221. package/es/share/util/console.d.ts +3 -3
  222. package/es/share/util/console.js +10 -7
  223. package/es/share/util/dom.d.ts +19 -0
  224. package/es/share/util/dom.js +88 -0
  225. package/es/share/util/env.d.ts +1 -0
  226. package/es/share/util/env.js +5 -4
  227. package/es/share/util/event-bus.js +3 -20
  228. package/es/share/util/lru-cache.js +29 -33
  229. package/es/share/util/pixel.d.ts +4 -0
  230. package/es/share/util/plot.d.ts +8 -3
  231. package/es/share/util/plot.js +457 -229
  232. package/es/share/util/reactivity.d.ts +8 -0
  233. package/es/share/util/reactivity.js +23 -0
  234. package/es/share/util/render.js +31 -41
  235. package/es/share/util/theme.d.ts +3 -0
  236. package/es/share/util/theme.js +77 -57
  237. package/es/slider/css.js +2 -0
  238. package/es/slider/draw.d.ts +25 -0
  239. package/es/slider/draw.js +113 -0
  240. package/es/slider/index.css +119 -0
  241. package/es/slider/index.d.ts +66 -0
  242. package/es/slider/index.js +503 -0
  243. package/es/slider/type.d.ts +162 -0
  244. package/es/slider/util.d.ts +37 -0
  245. package/es/slider/util.js +130 -0
  246. package/es/space/index.css +24 -29
  247. package/es/space/index.js +73 -97
  248. package/es/spin/index.css +18 -17
  249. package/es/spin/index.js +72 -102
  250. package/es/spin/type.d.ts +11 -5
  251. package/es/switch/css.js +2 -0
  252. package/es/switch/draw.d.ts +2 -0
  253. package/es/switch/draw.js +18 -0
  254. package/es/switch/index.css +121 -0
  255. package/es/switch/index.d.ts +42 -0
  256. package/es/switch/index.js +259 -0
  257. package/es/switch/type.d.ts +133 -0
  258. package/es/tag/draw.d.ts +2 -2
  259. package/es/tag/draw.js +80 -127
  260. package/es/tag/index.css +38 -22
  261. package/es/tag/index.d.ts +2 -2
  262. package/es/tag/index.js +121 -190
  263. package/es/tag/type.d.ts +3 -3
  264. package/es/text-outline/css.js +2 -0
  265. package/es/text-outline/index.css +4 -0
  266. package/es/text-outline/index.d.ts +17 -0
  267. package/es/text-outline/index.js +33 -0
  268. package/es/text-outline/type.d.ts +23 -0
  269. package/es/textarea/draw.js +9 -11
  270. package/es/textarea/index.css +37 -23
  271. package/es/textarea/index.d.ts +8 -14
  272. package/es/textarea/index.js +274 -262
  273. package/es/tooltip/index.d.ts +100 -4
  274. package/es/tooltip/index.js +70 -226
  275. package/es/tooltip/type.d.ts +7 -2
  276. package/es/vendor.js +504 -0
  277. package/es/virtual-list/css.js +2 -0
  278. package/es/virtual-list/index.css +25 -0
  279. package/es/virtual-list/index.d.ts +11 -0
  280. package/es/virtual-list/index.js +313 -0
  281. package/es/virtual-list/type.d.ts +26 -0
  282. package/package.json +10 -16
  283. package/es/grid-item/index.css +0 -0
  284. /package/es/message-box/{message-box.css → index.css} +0 -0
@@ -1,42 +1,33 @@
1
1
  import './css.js'
2
- import { defineComponent, computed, createElementBlock, openBlock, normalizeStyle, normalizeClass, unref, renderSlot } from "vue";
3
- import { u as useDarkMode } from "../share/hook/use-dark-mode.js";
4
- import { N, k } from "../aside/index.js";
5
- const _sfc_main = /* @__PURE__ */ defineComponent({
6
- ...{ name: "Footer" },
7
- __name: "index",
8
- props: {
9
- minHeight: null,
10
- bordered: { type: Boolean },
11
- dark: { type: Boolean, default: false }
12
- },
13
- setup(__props) {
14
- const props = __props;
15
- const darkMode = useDarkMode();
16
- const minHeight = computed(() => {
17
- return N(props.minHeight) ? void 0 : k(props.minHeight) ? `${props.minHeight}px` : props.minHeight;
18
- });
19
- return (_ctx, _cache) => {
20
- return openBlock(), createElementBlock(
21
- "footer",
22
- {
23
- class: normalizeClass(["pixelium px-footer", {
24
- "px-footer__dark": !unref(darkMode) && !!props.dark,
25
- "px-footer__bordered": !!props.bordered
26
- }]),
27
- style: normalizeStyle({
28
- minHeight: minHeight.value
29
- })
30
- },
31
- [
32
- renderSlot(_ctx.$slots, "default")
33
- ],
34
- 6
35
- /* CLASS, STYLE */
36
- );
37
- };
38
- }
2
+ import { _ as E, g as A } from "../vendor.js";
3
+ import { t as useDarkMode } from "../share/hook/use-dark-mode.js";
4
+ import { computed, createElementBlock, defineComponent, normalizeClass, normalizeStyle, openBlock, renderSlot, unref } from "vue";
5
+ var footer_default = /* @__PURE__ */ defineComponent({
6
+ name: "Footer",
7
+ __name: "index",
8
+ props: {
9
+ minHeight: null,
10
+ bordered: { type: Boolean },
11
+ dark: {
12
+ type: Boolean,
13
+ default: false
14
+ }
15
+ },
16
+ setup(__props) {
17
+ const props = __props;
18
+ const darkMode = useDarkMode();
19
+ const minHeight = computed(() => {
20
+ return E(props.minHeight) ? void 0 : A(props.minHeight) ? `${props.minHeight}px` : props.minHeight;
21
+ });
22
+ return (_ctx, _cache) => {
23
+ return openBlock(), createElementBlock("footer", {
24
+ class: normalizeClass(["pixelium px-footer", {
25
+ "px-footer__dark": !unref(darkMode) && !!props.dark,
26
+ "px-footer__bordered": !!props.bordered
27
+ }]),
28
+ style: normalizeStyle({ minHeight: minHeight.value })
29
+ }, [renderSlot(_ctx.$slots, "default")], 6);
30
+ };
31
+ }
39
32
  });
40
- export {
41
- _sfc_main as _
42
- };
33
+ export { footer_default as t };
package/es/form/css.js ADDED
@@ -0,0 +1 @@
1
+ import '../index.css'
@@ -0,0 +1,27 @@
1
+ import type { FormExpose, FormProps } from './type';
2
+ declare var __VLS_1: {};
3
+ type __VLS_Slots = {} & {
4
+ default?: (props: typeof __VLS_1) => any;
5
+ };
6
+ declare const __VLS_component: import("vue").DefineComponent<FormProps, FormExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ submit: (form: Record<string | number, any>, event: Event) => any;
8
+ reset: (form: Record<string | number, any>, event: Event) => any;
9
+ }, string, import("vue").PublicProps, Readonly<FormProps> & Readonly<{
10
+ onSubmit?: ((form: Record<string | number, any>, event: Event) => any) | undefined;
11
+ onReset?: ((form: Record<string | number, any>, event: Event) => any) | undefined;
12
+ }>, {
13
+ size: "small" | "medium" | "large";
14
+ disabled: boolean;
15
+ readonly: boolean;
16
+ labelAlign: "left" | "right" | "top";
17
+ showAsterisk: boolean;
18
+ asteriskPlacement: "left" | "right" | "end";
19
+ labelAutoWidth: boolean;
20
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
22
+ export default _default;
23
+ type __VLS_WithSlots<T, S> = T & {
24
+ new (): {
25
+ $slots: S;
26
+ };
27
+ };
@@ -0,0 +1,125 @@
1
+ import './css.js'
2
+ import { B as y, S as Oe, _ as E } from "../vendor.js";
3
+ import { a as FORM_PROVIDE } from "../share/const/provide-key.js";
4
+ import { r as throwError } from "../share/util/console.js";
5
+ import { computed, createElementBlock, defineComponent, nextTick, onMounted, openBlock, provide, ref, renderSlot, toRefs, withKeys, withModifiers } from "vue";
6
+ var form_default = /* @__PURE__ */ defineComponent({
7
+ name: "Form",
8
+ __name: "index",
9
+ props: {
10
+ model: null,
11
+ form: null,
12
+ rules: null,
13
+ disabled: {
14
+ type: Boolean,
15
+ default: false
16
+ },
17
+ readonly: {
18
+ type: Boolean,
19
+ default: false
20
+ },
21
+ size: { default: "medium" },
22
+ labelAlign: { default: "right" },
23
+ showAsterisk: {
24
+ type: Boolean,
25
+ default: true
26
+ },
27
+ asteriskPlacement: { default: "left" },
28
+ labelAutoWidth: {
29
+ type: Boolean,
30
+ default: false
31
+ },
32
+ rowProps: null,
33
+ labelProps: null,
34
+ contentProps: null
35
+ },
36
+ emits: ["submit", "reset"],
37
+ setup(__props, { expose: __expose, emit: __emit }) {
38
+ const props = __props;
39
+ const model = computed(() => {
40
+ if (props.form) return props.form.model.value;
41
+ else if (props.model) return props.model;
42
+ throwError("One of the model or form props must be provided to the Form component.");
43
+ });
44
+ const fields = ref([]);
45
+ const labelWidth = ref([]);
46
+ const maxLabelWidth = computed(() => {
47
+ return Oe(labelWidth.value.map((e) => e.width));
48
+ });
49
+ provide(FORM_PROVIDE, {
50
+ ...toRefs(props),
51
+ model,
52
+ registerField: (fieldItem) => {
53
+ fields.value.push(fieldItem);
54
+ },
55
+ unregisterField: (field) => {
56
+ fields.value = fields.value.filter((f) => f.field !== field);
57
+ },
58
+ collectLabelWidth: (item) => {
59
+ labelWidth.value = labelWidth.value.filter((e) => e.id !== item.id);
60
+ labelWidth.value.push(item);
61
+ },
62
+ removeLabelWidth: (itemId) => {
63
+ labelWidth.value = labelWidth.value.filter((e) => e.id !== itemId);
64
+ },
65
+ maxLabelWidth
66
+ });
67
+ const emits = __emit;
68
+ const filterFieldItem = (fieldItem, field) => E(field) ? true : y(field) ? field === fieldItem.field : field.includes(fieldItem.field);
69
+ const validate = async (field) => {
70
+ const validateObj = {};
71
+ const validate$1 = fields.value.filter((fieldItem) => filterFieldItem(fieldItem, field)).map((fieldItem) => {
72
+ return fieldItem.validate().then((res) => {
73
+ validateObj[fieldItem.field] = {
74
+ status: "fulfilled",
75
+ value: res
76
+ };
77
+ return res;
78
+ }, (err) => {
79
+ validateObj[fieldItem.field] = {
80
+ status: "rejected",
81
+ reason: err
82
+ };
83
+ throw err;
84
+ });
85
+ });
86
+ return {
87
+ isValid: (await Promise.allSettled(validate$1)).every((result) => result.status === "fulfilled" && (result.value.level !== "error" || !result.value.level)),
88
+ results: validateObj
89
+ };
90
+ };
91
+ const formSubmitHandler = (e) => {
92
+ emits("submit", model.value, e);
93
+ };
94
+ const reset = (field) => {
95
+ fields.value.filter((fieldItem) => filterFieldItem(fieldItem, field)).forEach((field$1) => field$1.reset());
96
+ clearValidation(field);
97
+ };
98
+ const formResetHandler = async (e) => {
99
+ reset();
100
+ await nextTick();
101
+ emits("reset", model.value, e);
102
+ };
103
+ const clearValidation = async (field) => {
104
+ fields.value.filter((fieldItem) => filterFieldItem(fieldItem, field)).forEach((field$1) => field$1.clearValidation());
105
+ };
106
+ const expose = {
107
+ validate,
108
+ reset,
109
+ clearValidation
110
+ };
111
+ __expose(expose);
112
+ onMounted(() => {
113
+ if (props.form) props.form.register(expose);
114
+ });
115
+ return (_ctx, _cache) => {
116
+ return openBlock(), createElementBlock("form", {
117
+ class: "px-form pixelium",
118
+ onSubmit: withModifiers(formSubmitHandler, ["stop", "prevent"]),
119
+ onReset: withModifiers(formResetHandler, ["stop"]),
120
+ onKeydown: _cache[0] || (_cache[0] = withKeys(withModifiers(() => {}, ["prevent"]), ["enter"]))
121
+ }, [renderSlot(_ctx.$slots, "default")], 32);
122
+ };
123
+ }
124
+ });
125
+ export { form_default as t };
@@ -0,0 +1,238 @@
1
+ import type { ComputedRef, Ref, ToRefs } from 'vue';
2
+ import type { ColProps } from '../col/type';
3
+ import type { RowProps } from '../row/type';
4
+ import type { LooseRequired } from '../share/type';
5
+ export type RuleLevel = 'error' | 'warning' | 'success' | 'normal';
6
+ export type FieldItem = {
7
+ field: string;
8
+ reset: Function;
9
+ clearValidation: Function;
10
+ validate: () => Promise<{
11
+ message: string;
12
+ level: RuleLevel;
13
+ }>;
14
+ };
15
+ export type FieldType = 'number' | 'string' | 'boolean' | 'array' | 'dict' | 'function' | 'date';
16
+ export type RuleTrigger = 'blur' | 'change' | 'input';
17
+ export type FormProps = {
18
+ /**
19
+ * @property {Record<number | string, any>} [model]
20
+ * @version 0.0.3
21
+ */
22
+ model?: Record<number | string, any>;
23
+ /**
24
+ * @property {FormInstance} [form]
25
+ * @version 0.0.3
26
+ */
27
+ form?: UseFormReturn;
28
+ /**
29
+ * @property {Record<string, RuleItem | RuleItem[]>} [rules]
30
+ * @version 0.0.3
31
+ */
32
+ rules?: Record<string, RuleItem | RuleItem[]>;
33
+ /**
34
+ * @property {boolean} [disabled=false]
35
+ * @version 0.0.3
36
+ */
37
+ disabled?: boolean;
38
+ /**
39
+ * @property {boolean} [readonly=false]
40
+ * @version 0.0.3
41
+ */
42
+ readonly?: boolean;
43
+ /**
44
+ * @property {'small' | 'medium' | 'large'} [size='medium']
45
+ * @version 0.0.3
46
+ */
47
+ size?: 'small' | 'medium' | 'large';
48
+ /**
49
+ * @property {'left' | 'right' | 'top'} [labelAlign='right']
50
+ * @version 0.0.3
51
+ */
52
+ labelAlign?: 'left' | 'right' | 'top';
53
+ /**
54
+ * @property {boolean} [showAsterisk]
55
+ * @version 0.0.3
56
+ */
57
+ showAsterisk?: boolean;
58
+ /**
59
+ * @property {'left' | 'right' | 'end'} [asteriskPlacement='left']
60
+ * @version 0.0.3
61
+ */
62
+ asteriskPlacement?: 'left' | 'right' | 'end';
63
+ /**
64
+ * @property {boolean} [labelAutoWidth=false]
65
+ * @version 0.0.3
66
+ */
67
+ labelAutoWidth?: boolean;
68
+ /**
69
+ * @property {RowProps} [rowProps]
70
+ * @version 0.0.3
71
+ */
72
+ rowProps?: RowProps;
73
+ /**
74
+ * @property {ColProps} [labelProps]
75
+ * @version 0.0.3
76
+ */
77
+ labelProps?: ColProps;
78
+ /**
79
+ * @property {ColProps} [contentProps]
80
+ * @version 0.0.3
81
+ */
82
+ contentProps?: ColProps;
83
+ };
84
+ export interface UseFormReturn<T extends Record<string | number, any> = Record<string | number, any>> {
85
+ /**
86
+ * @property {Ref<Record<string | number, any>>} model
87
+ * @version 0.0.3
88
+ */
89
+ model: Ref<T>;
90
+ /**
91
+ * @property {(field?: string | string[]) => FormValidateResult} validate
92
+ * @version 0.0.3
93
+ */
94
+ validate: (field?: string | string[]) => FormValidateResult;
95
+ /**
96
+ * @property {(field?: string | string[]) => void} reset
97
+ * @version 0.0.3
98
+ */
99
+ reset: (field?: string | string[]) => void;
100
+ /**
101
+ * @property {(field?: string | string[]) => void} clearValidation
102
+ * @version 0.0.3
103
+ */
104
+ clearValidation: (field?: string | string[]) => void;
105
+ /**
106
+ * @ignore
107
+ */
108
+ register: (registerOptions: UseFormRegisterOptions) => void;
109
+ }
110
+ export type FormEvents = {
111
+ /**
112
+ * @event submit
113
+ * @param {Record<number | string, any>} form
114
+ * @param {Event} event
115
+ * @version 0.0.3
116
+ */
117
+ submit: [form: Record<number | string, any>, event: Event];
118
+ /**
119
+ * @event reset
120
+ * @param {Record<number | string, any>} form
121
+ * @param {Event} event
122
+ * @version 0.0.3
123
+ */
124
+ reset: [form: Record<number | string, any>, event: Event];
125
+ };
126
+ export type FormSlots = {
127
+ /**
128
+ * @slot default
129
+ * @version 0.0.3
130
+ */
131
+ default: {};
132
+ };
133
+ export type FormValidateResult = Promise<{
134
+ isValid: boolean;
135
+ results: Record<string, PromiseSettledResult<{
136
+ message: string;
137
+ level: RuleLevel;
138
+ }>>;
139
+ }>;
140
+ export type FormExpose = {
141
+ /**
142
+ * @property {(field?: string | string[]) => FormValidateResult} validate
143
+ * @version 0.0.3
144
+ */
145
+ validate: (field?: string | string[]) => FormValidateResult;
146
+ /**
147
+ * @property {(field?: string | string[]) => void} reset
148
+ * @version 0.0.3
149
+ */
150
+ reset: (field?: string | string[]) => void;
151
+ /**
152
+ * @property {(field?: string | string[]) => void} clearValidation
153
+ * @version 0.0.3
154
+ */
155
+ clearValidation: (field?: string | string[]) => void;
156
+ };
157
+ export type RuleItem = {
158
+ /**
159
+ * @property {boolean} [required=false]
160
+ * @version 0.0.3
161
+ */
162
+ required?: boolean;
163
+ /**
164
+ * @property {string} [message]
165
+ * @version 0.0.3
166
+ */
167
+ message?: string;
168
+ /**
169
+ * @property {RuleTrigger | RuleTrigger[]} [trigger=['change', 'blur']]
170
+ * @version 0.0.3
171
+ */
172
+ trigger?: RuleTrigger | RuleTrigger[];
173
+ /**
174
+ * @property {FieldType | FieldType[]} [type]
175
+ * @version 0.0.3
176
+ */
177
+ type?: FieldType | FieldType[];
178
+ /**
179
+ * @property {number} [max]
180
+ * @version 0.0.3
181
+ */
182
+ max?: number;
183
+ /**
184
+ * @property {number} [min]
185
+ * @version 0.0.3
186
+ */
187
+ min?: number;
188
+ /**
189
+ * @property {number} [maxLength]
190
+ * @version 0.0.3
191
+ */
192
+ maxLength?: number;
193
+ /**
194
+ * @property {number} [minLength]
195
+ * @version 0.0.3
196
+ */
197
+ minLength?: number;
198
+ /**
199
+ * @property {boolean} [email=false]
200
+ * @version 0.0.3
201
+ */
202
+ email?: boolean;
203
+ /**
204
+ * @property {boolean} [url=false]
205
+ * @version 0.0.3
206
+ */
207
+ url?: boolean;
208
+ /**
209
+ * @property {boolean} [numberString=false]
210
+ * @version 0.0.3
211
+ */
212
+ numberString?: boolean;
213
+ /**
214
+ * @property {RuleLevel} [level='error']
215
+ * @version 0.0.3
216
+ */
217
+ level?: RuleLevel;
218
+ /**
219
+ * @property {(value: any, model: Record<number | string, any>) => string | void | Promise<void | string>} [validator]
220
+ * @version 0.0.3
221
+ */
222
+ validator?: (value: any, model: Record<number | string, any>) => string | void | Promise<void | string>;
223
+ };
224
+ export type FormProvide = {
225
+ maxLabelWidth: ComputedRef<number>;
226
+ registerField: (fieldItem: FieldItem) => void;
227
+ unregisterField: (field: string) => void;
228
+ collectLabelWidth: (item: {
229
+ id: string;
230
+ width: number;
231
+ }) => void;
232
+ removeLabelWidth: (itemId: string) => void;
233
+ model: Ref<Record<string | number, any>>;
234
+ } & ToRefs<LooseRequired<Omit<FormProps, 'form' | 'model'>>>;
235
+ export type UseFormRegisterOptions = {
236
+ validate: (field?: string | string[]) => FormValidateResult;
237
+ clearValidation: (field?: string | string[]) => void;
238
+ };
@@ -0,0 +1,4 @@
1
+ import type { UseFormReturn } from './type';
2
+ export declare function useForm<T extends Record<string | number, any> = Record<string | number, any>>(options?: {
3
+ initialValues?: T;
4
+ }): UseFormReturn<T>;
@@ -0,0 +1,48 @@
1
+ import { D as S, I as on, M as f } from "../vendor.js";
2
+ import { n as logWarn } from "../share/util/console.js";
3
+ import { ref } from "vue";
4
+ function useForm(options = {}) {
5
+ const funcRegister = {
6
+ validateFn: null,
7
+ clearValidationFn: null
8
+ };
9
+ const model = ref({ ...options.initialValues });
10
+ const validate = async (field) => {
11
+ if (!funcRegister.validateFn) {
12
+ logWarn("Validation function not registered. Ensure the Form component is properly mounted.");
13
+ return {
14
+ isValid: false,
15
+ results: {}
16
+ };
17
+ }
18
+ return await funcRegister.validateFn(field);
19
+ };
20
+ const register = (registerOptions) => {
21
+ funcRegister.validateFn = registerOptions.validate;
22
+ funcRegister.clearValidationFn = registerOptions.clearValidation;
23
+ };
24
+ const reset = (field) => {
25
+ if (!field) model.value = { ...options.initialValues };
26
+ else {
27
+ const nextModel = { ...model.value };
28
+ (S(field) ? field : [field]).forEach((fieldPath) => {
29
+ on(nextModel, fieldPath, !options.initialValues ? void 0 : f(options.initialValues, fieldPath));
30
+ });
31
+ model.value = nextModel;
32
+ }
33
+ if (funcRegister.clearValidationFn) funcRegister.clearValidationFn(field);
34
+ else logWarn("Clear Validation not registered. Ensure the Form component is properly mounted.");
35
+ };
36
+ const clearValidation = (field) => {
37
+ if (funcRegister.clearValidationFn) funcRegister.clearValidationFn(field);
38
+ else logWarn("Clear Validation function not registered. Ensure the Form component is properly mounted.");
39
+ };
40
+ return {
41
+ model,
42
+ validate,
43
+ register,
44
+ reset,
45
+ clearValidation
46
+ };
47
+ }
48
+ export { useForm as t };
@@ -0,0 +1,2 @@
1
+ import '../index.css'
2
+ import './index.css'
@@ -0,0 +1,77 @@
1
+ .px-form-item-label {
2
+ display: flex;
3
+ min-height: var(--px-medium-size);
4
+ line-height: var(--px-medium-size);
5
+ font-size: 14px;
6
+ }
7
+ .px-form-item-label__auto {
8
+ white-space: nowrap;
9
+ display: inline-flex;
10
+ }
11
+ .px-form-item-label__left {
12
+ justify-content: flex-start;
13
+ }
14
+ .px-form-item-label__right {
15
+ justify-content: flex-end;
16
+ }
17
+ .px-form-item-label__large {
18
+ min-height: var(--px-large-size);
19
+ line-height: var(--px-large-size);
20
+ font-size: 15px;
21
+ }
22
+ .px-form-item-label__small {
23
+ min-height: var(--px-small-size);
24
+ line-height: var(--px-small-size);
25
+ font-size: 12px;
26
+ }
27
+ .px-form-item-label-wrapper__auto {
28
+ box-sizing: content-box;
29
+ flex-basis: 0;
30
+ }
31
+ .px-form-item-addition {
32
+ min-height: 20px;
33
+ width: 100%;
34
+ }
35
+ .px-form-item-tip,
36
+ .px-form-item-extra {
37
+ height: 20px;
38
+ font-size: 12px;
39
+ color: var(--px-neutral-8);
40
+ }
41
+ .px-form-item-asterisk {
42
+ color: var(--px-danger-6);
43
+ }
44
+ .px-form-item-tip__error {
45
+ color: var(--px-danger-6);
46
+ }
47
+ .px-form-item-tip__warning {
48
+ color: var(--px-warning-6);
49
+ }
50
+ .px-form-item-tip__success {
51
+ color: var(--px-success-6);
52
+ }
53
+ .px-form-item-content {
54
+ width: 100%;
55
+ display: flex;
56
+ align-items: center;
57
+ flex-wrap: wrap;
58
+ min-height: var(--px-medium-size);
59
+ font-size: 14px;
60
+ }
61
+ .px-form-item-content > *:first-child {
62
+ flex-grow: 1;
63
+ }
64
+ .px-form-item-content__large {
65
+ min-height: var(--px-large-size);
66
+ font-size: 15px;
67
+ }
68
+ .px-form-item-content__small {
69
+ min-height: var(--px-small-size);
70
+ font-size: 12px;
71
+ }
72
+ .px-form-item-content-wrapper__auto {
73
+ width: 100%;
74
+ flex-basis: 0;
75
+ flex-grow: 1;
76
+ flex-shrink: 1;
77
+ }
@@ -0,0 +1,37 @@
1
+ import type { RuleLevel, RuleTrigger } from '../form/type';
2
+ import type { FormItemProps } from './type';
3
+ declare var __VLS_10: {}, __VLS_16: {}, __VLS_18: {
4
+ message: string;
5
+ level: RuleLevel;
6
+ }, __VLS_20: {};
7
+ type __VLS_Slots = {} & {
8
+ label?: (props: typeof __VLS_10) => any;
9
+ } & {
10
+ default?: (props: typeof __VLS_16) => any;
11
+ } & {
12
+ tip?: (props: typeof __VLS_18) => any;
13
+ } & {
14
+ extra?: (props: typeof __VLS_20) => any;
15
+ };
16
+ declare const __VLS_component: import("vue").DefineComponent<FormItemProps, {
17
+ validate: (trigger?: RuleTrigger) => Promise<{
18
+ message: string;
19
+ level: RuleLevel;
20
+ }>;
21
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormItemProps> & Readonly<{}>, {
22
+ disabled: boolean;
23
+ readonly: boolean;
24
+ labelAlign: "left" | "right" | "top";
25
+ showAsterisk: boolean;
26
+ asteriskPlacement: "left" | "right" | "end";
27
+ rowProps: import("../row/type.ts").RowProps;
28
+ labelProps: import("../col/type.ts").ColProps;
29
+ contentProps: import("../col/type.ts").ColProps;
30
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
32
+ export default _default;
33
+ type __VLS_WithSlots<T, S> = T & {
34
+ new (): {
35
+ $slots: S;
36
+ };
37
+ };