@pixelium/web-vue 0.0.2-fix → 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 -5854
  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 -675
  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,267 +1,279 @@
1
1
  import './css.js'
2
- import { defineComponent, shallowRef, computed, ref, watch, onMounted, nextTick, createElementBlock, openBlock, normalizeClass, createElementVNode, unref, withModifiers, normalizeStyle, createCommentVNode, createVNode, renderSlot, toDisplayString } from "vue";
3
- import { u as useResizeObserver } from "../share/hook/use-resize-observer.js";
4
- import { d as draw } from "./draw.js";
5
- import { g as getGlobalThemeColor } from "../share/util/color.js";
6
- import { u as useDarkMode } from "../share/hook/use-dark-mode.js";
7
- import { u as useComposition } from "../share/hook/use-composition.js";
8
- import { T as TimesCircleSolid, S as SpinnerThirdSolid } from "../auto-complete/index.js";
9
- import { a as Ne, N } from "../aside/index.js";
10
- import { u as useWatchGlobalCssVal } from "../share/hook/use-watch-global-css-var.js";
11
- import { u as useTextareaHeight } from "../share/hook/use-textarea-height.js";
12
- import { a as canvasPreprocess, c as calcPixelSize } from "../share/util/plot.js";
13
- import { u as useControlledMode } from "../share/hook/use-controlled-mode.js";
14
- const _hoisted_1 = ["value", "placeholder", "disabled", "autofocus", "rows"];
15
- const _hoisted_2 = { class: "px-textarea-addition-wrapper" };
16
- const _hoisted_3 = {
17
- key: 0,
18
- class: "px-textarea-close-wrapper"
2
+ import { O as Ue, V as spinner_third_solid_default, _ as E, l as times_circle_solid_default } from "../vendor.js";
3
+ import { i as canvasPreprocess, n as calcPixelSize } from "../share/util/plot.js";
4
+ import { n as getGlobalThemeColor } from "../share/util/color.js";
5
+ import { t as useDarkMode } from "../share/hook/use-dark-mode.js";
6
+ import { t as useResizeObserver } from "../share/hook/use-resize-observer.js";
7
+ import { t as useWatchGlobalCssVal } from "../share/hook/use-watch-global-css-var.js";
8
+ import { i as FORM_ITEM_PROVIDE } from "../share/const/provide-key.js";
9
+ import { t as createProvideComputed } from "../share/util/reactivity.js";
10
+ import { t as useTransitionEnd } from "../share/hook/use-transition-end.js";
11
+ import { t as useComposition } from "../share/hook/use-composition.js";
12
+ import { t as useControlledMode } from "../share/hook/use-controlled-mode.js";
13
+ import { t as draw } from "./draw.js";
14
+ import { t as useTextareaHeight } from "../share/hook/use-textarea-height.js";
15
+ import { computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, inject, nextTick, normalizeClass, normalizeStyle, onMounted, openBlock, ref, renderSlot, shallowRef, toDisplayString, unref, watch, withModifiers } from "vue";
16
+ var _hoisted_1 = [
17
+ "value",
18
+ "placeholder",
19
+ "disabled",
20
+ "autofocus",
21
+ "rows"
22
+ ];
23
+ var _hoisted_2 = { class: "px-textarea-addition-wrapper" };
24
+ var _hoisted_3 = {
25
+ key: 0,
26
+ class: "px-textarea-close-wrapper"
19
27
  };
20
- const _hoisted_4 = {
21
- key: 1,
22
- class: "px-textarea-count-wrapper"
28
+ var _hoisted_4 = {
29
+ key: 1,
30
+ class: "px-textarea-count-wrapper"
23
31
  };
24
- const _hoisted_5 = {
25
- key: 2,
26
- class: "px-textarea-loading-wrapper"
32
+ var _hoisted_5 = {
33
+ key: 2,
34
+ class: "px-textarea-loading-wrapper"
27
35
  };
28
- const _sfc_main = /* @__PURE__ */ defineComponent({
29
- ...{
30
- name: "Textarea"
31
- },
32
- __name: "index",
33
- props: {
34
- modelValue: null,
35
- defaultValue: null,
36
- rows: null,
37
- minRows: { default: 1 },
38
- maxRows: { default: Infinity },
39
- autoResize: { type: Boolean, default: false },
40
- resize: { type: Boolean, default: true },
41
- placeholder: null,
42
- disabled: { type: Boolean, default: false },
43
- readonly: { type: Boolean, default: false },
44
- clearable: { type: Boolean, default: false },
45
- loading: { type: Boolean, default: false },
46
- size: { default: "medium" },
47
- maxLength: null,
48
- showCount: { type: Boolean, default: false },
49
- countGraphemes: { type: Function },
50
- sliceGraphemes: { type: Function },
51
- status: { default: "normal" },
52
- autofocus: { type: Boolean }
53
- },
54
- emits: ["input", "update:modelValue", "change", "clear", "blur", "focus"],
55
- setup(__props, { expose: __expose, emit: __emit }) {
56
- const props = __props;
57
- const emits = __emit;
58
- const [isComposing, compositionStartHandler, compositionUpdateHandler] = useComposition({
59
- afterComposition: (e) => {
60
- nextTick(() => {
61
- inputHandler(e);
62
- });
63
- }
64
- });
65
- const [modelValue, updateModelValue] = useControlledMode("modelValue", props, emits, {
66
- defaultField: "defaultValue",
67
- transform: (e) => {
68
- return e || "";
69
- }
70
- });
71
- const wrapperRef = shallowRef(null);
72
- const canvasRef = shallowRef(null);
73
- const inputRef = shallowRef(null);
74
- const [height, minHeight, maxHeight, refreshHeight] = useTextareaHeight(inputRef, props);
75
- const currentLength = computed(() => {
76
- return modelValue.value ? props.countGraphemes ? props.countGraphemes(modelValue.value) : modelValue.value.length : 0;
77
- });
78
- const inputHandler = async (e) => {
79
- const target = e.target;
80
- let newValue = target.value;
81
- modelValue.value = newValue;
82
- if (isComposing.value) {
83
- return;
84
- }
85
- if (props.maxLength) {
86
- if (props.countGraphemes && props.sliceGraphemes) {
87
- await nextTick();
88
- newValue = props.sliceGraphemes(newValue, props.maxLength);
89
- } else {
90
- newValue = newValue.slice(0, props.maxLength);
91
- }
92
- }
93
- modelValue.value = newValue;
94
- emits("input", newValue, e);
95
- updateModelValue(newValue);
96
- };
97
- const clearHandler = async () => {
98
- await updateModelValue("");
99
- emits("change", "");
100
- emits("clear", "");
101
- };
102
- const changeHandler = (e) => {
103
- const target = e.target;
104
- refreshHeight();
105
- emits("change", target.value, e);
106
- };
107
- const focusMode = ref(false);
108
- const setHeight = () => {
109
- if (props.autoResize && inputRef.value && height.value) {
110
- inputRef.value.style.height = height.value + "px";
111
- }
112
- };
113
- watch(height, () => {
114
- setHeight();
115
- });
116
- const blurHandler = () => {
117
- setHeight();
118
- focusMode.value = false;
119
- };
120
- const focusHandler = () => {
121
- setHeight();
122
- focusMode.value = true;
123
- };
124
- const showClose = computed(() => {
125
- return props.clearable && focusMode.value && !props.disabled && !props.readonly && !!modelValue.value;
126
- });
127
- const focusInputHandler = () => {
128
- var _a;
129
- (_a = inputRef.value) == null ? void 0 : _a.focus();
130
- };
131
- const hoverFlag = ref(false);
132
- const mouseenterHandler = () => {
133
- hoverFlag.value = true;
134
- };
135
- const mouseleaveHandler = () => {
136
- hoverFlag.value = false;
137
- };
138
- __expose({
139
- focus: () => {
140
- var _a;
141
- (_a = inputRef.value) == null ? void 0 : _a.focus();
142
- },
143
- blur: () => {
144
- var _a;
145
- (_a = inputRef.value) == null ? void 0 : _a.blur();
146
- },
147
- clear: () => clearHandler(),
148
- select: () => {
149
- var _a;
150
- (_a = inputRef.value) == null ? void 0 : _a.select();
151
- }
152
- });
153
- const darkMode = useDarkMode();
154
- watch([() => props.size, () => props.disabled, darkMode, hoverFlag, focusMode], () => {
155
- setTimeout(() => {
156
- drawPixelDebounce();
157
- });
158
- });
159
- const drawPixel = () => {
160
- const preprocessData = canvasPreprocess(wrapperRef, canvasRef);
161
- if (!preprocessData) {
162
- return;
163
- }
164
- const { ctx, width, height: height2 } = preprocessData;
165
- const pixelSize = calcPixelSize();
166
- const borderColor = props.status !== "normal" ? getGlobalThemeColor(props.status === "error" ? "danger" : props.status, 6) : (hoverFlag.value || focusMode.value) && !props.disabled && !props.readonly ? getGlobalThemeColor("primary", 6) : getGlobalThemeColor("neutral", 10);
167
- const backgroundColor = props.disabled ? getGlobalThemeColor("neutral", 6) : getGlobalThemeColor("neutral", 1);
168
- draw(ctx, width, height2, borderColor, backgroundColor, pixelSize);
169
- };
170
- const drawPixelDebounce = Ne(drawPixel, 0, {
171
- maxWait: 50
172
- });
173
- onMounted(() => {
174
- nextTick(() => {
175
- drawPixel();
176
- });
177
- setTimeout(() => {
178
- setHeight();
179
- });
180
- });
181
- useResizeObserver(wrapperRef, drawPixelDebounce);
182
- useWatchGlobalCssVal(drawPixelDebounce);
183
- return (_ctx, _cache) => {
184
- return openBlock(), createElementBlock(
185
- "div",
186
- {
187
- class: normalizeClass(["pixelium px-textarea", {
188
- [`px-textarea__${props.size}`]: !!props.size,
189
- "px-textarea__disabled": !!props.disabled,
190
- "px-textarea__resize": !!props.resize
191
- }]),
192
- ref_key: "wrapperRef",
193
- ref: wrapperRef,
194
- onClick: focusInputHandler,
195
- onMouseenter: mouseenterHandler,
196
- onMouseleave: mouseleaveHandler
197
- },
198
- [
199
- createElementVNode("textarea", {
200
- class: "px-textarea-inner",
201
- value: unref(modelValue),
202
- ref_key: "inputRef",
203
- ref: inputRef,
204
- placeholder: props.placeholder,
205
- disabled: props.disabled || props.readonly,
206
- autofocus: __props.autofocus,
207
- rows: props.rows,
208
- style: normalizeStyle({
209
- minHeight: unref(minHeight) ? unref(minHeight) + "px" : void 0,
210
- maxHeight: unref(maxHeight) ? unref(maxHeight) + "px" : void 0
211
- }),
212
- onInput: withModifiers(inputHandler, ["stop"]),
213
- onChange: withModifiers(changeHandler, ["stop"]),
214
- onBlur: blurHandler,
215
- onFocus: focusHandler,
216
- onCompositionstart: _cache[0] || (_cache[0] = //@ts-ignore
217
- (...args) => unref(compositionStartHandler) && unref(compositionStartHandler)(...args)),
218
- onCompositionend: _cache[1] || (_cache[1] = //@ts-ignore
219
- (...args) => unref(compositionUpdateHandler) && unref(compositionUpdateHandler)(...args))
220
- }, null, 44, _hoisted_1),
221
- createElementVNode("div", _hoisted_2, [
222
- showClose.value ? (openBlock(), createElementBlock("div", _hoisted_3, [
223
- createVNode(unref(TimesCircleSolid), {
224
- class: "px-textarea-icon",
225
- onClick: clearHandler
226
- })
227
- ])) : createCommentVNode("v-if", true),
228
- props.showCount ? (openBlock(), createElementBlock("div", _hoisted_4, [
229
- renderSlot(_ctx.$slots, "count", {
230
- value: unref(modelValue),
231
- count: currentLength.value,
232
- maxLength: props.maxLength
233
- }, () => [
234
- createElementVNode(
235
- "span",
236
- null,
237
- toDisplayString(currentLength.value) + toDisplayString(unref(N)(props.maxLength) ? "" : " / " + props.maxLength),
238
- 1
239
- /* TEXT */
240
- )
241
- ])
242
- ])) : createCommentVNode("v-if", true),
243
- props.loading ? (openBlock(), createElementBlock("div", _hoisted_5, [
244
- createVNode(unref(SpinnerThirdSolid), { class: "px-textarea-icon px-animation__loading" })
245
- ])) : createCommentVNode("v-if", true)
246
- ]),
247
- createElementVNode(
248
- "canvas",
249
- {
250
- class: "px-textarea-canvas",
251
- ref_key: "canvasRef",
252
- ref: canvasRef
253
- },
254
- null,
255
- 512
256
- /* NEED_PATCH */
257
- )
258
- ],
259
- 34
260
- /* CLASS, NEED_HYDRATION */
261
- );
262
- };
263
- }
36
+ var textarea_default = /* @__PURE__ */ defineComponent({
37
+ name: "Textarea",
38
+ __name: "index",
39
+ props: {
40
+ modelValue: null,
41
+ defaultValue: null,
42
+ rows: null,
43
+ minRows: { default: 1 },
44
+ maxRows: { default: Infinity },
45
+ autoResize: {
46
+ type: Boolean,
47
+ default: false
48
+ },
49
+ resize: {
50
+ type: Boolean,
51
+ default: true
52
+ },
53
+ placeholder: null,
54
+ disabled: {
55
+ type: Boolean,
56
+ default: false
57
+ },
58
+ readonly: {
59
+ type: Boolean,
60
+ default: false
61
+ },
62
+ clearable: {
63
+ type: Boolean,
64
+ default: false
65
+ },
66
+ loading: {
67
+ type: Boolean,
68
+ default: false
69
+ },
70
+ size: null,
71
+ maxLength: null,
72
+ showCount: {
73
+ type: Boolean,
74
+ default: false
75
+ },
76
+ countGraphemes: { type: Function },
77
+ sliceGraphemes: { type: Function },
78
+ status: { default: "normal" },
79
+ autofocus: { type: Boolean }
80
+ },
81
+ emits: [
82
+ "input",
83
+ "update:modelValue",
84
+ "change",
85
+ "clear",
86
+ "blur",
87
+ "focus"
88
+ ],
89
+ setup(__props, { expose: __expose, emit: __emit }) {
90
+ const props = __props;
91
+ const formItemProvide = inject(FORM_ITEM_PROVIDE, void 0);
92
+ const emits = __emit;
93
+ const [isComposing, compositionStartHandler, compositionUpdateHandler] = useComposition({ afterComposition: (e) => {
94
+ nextTick(() => {
95
+ inputHandler(e);
96
+ });
97
+ } });
98
+ const [modelValue, updateModelValue] = useControlledMode("modelValue", props, emits, {
99
+ defaultField: "defaultValue",
100
+ transform: (e) => {
101
+ return e || "";
102
+ }
103
+ });
104
+ const disabledComputed = createProvideComputed("disabled", [formItemProvide, props], "or");
105
+ const readonlyComputed = createProvideComputed("readonly", [formItemProvide, props], "or");
106
+ const sizeComputed = createProvideComputed("size", () => [
107
+ props.size && props,
108
+ formItemProvide,
109
+ props
110
+ ], "nullish", (val) => val || "medium");
111
+ const statusComputed = createProvideComputed("status", [formItemProvide, props]);
112
+ const wrapperRef = shallowRef(null);
113
+ const canvasRef = shallowRef(null);
114
+ const inputRef = shallowRef(null);
115
+ const [height, minHeight, maxHeight, refreshHeight] = useTextareaHeight(inputRef, props);
116
+ const currentLength = computed(() => {
117
+ return modelValue.value ? props.countGraphemes ? props.countGraphemes(modelValue.value) : modelValue.value.length : 0;
118
+ });
119
+ const inputHandler = async (e) => {
120
+ let newValue = e.target.value;
121
+ modelValue.value = newValue;
122
+ if (isComposing.value) return;
123
+ if (props.maxLength) if (props.countGraphemes && props.sliceGraphemes) {
124
+ await nextTick();
125
+ newValue = props.sliceGraphemes(newValue, props.maxLength);
126
+ } else newValue = newValue.slice(0, props.maxLength);
127
+ modelValue.value = newValue;
128
+ emits("input", newValue, e);
129
+ updateModelValue(newValue);
130
+ formItemProvide === null || formItemProvide === void 0 || formItemProvide.inputHandler();
131
+ };
132
+ const clearHandler = async () => {
133
+ await updateModelValue("");
134
+ emits("change", "");
135
+ emits("clear", "");
136
+ formItemProvide === null || formItemProvide === void 0 || formItemProvide.changeHandler();
137
+ };
138
+ const changeHandler = (e) => {
139
+ const target = e.target;
140
+ refreshHeight();
141
+ emits("change", target.value, e);
142
+ formItemProvide === null || formItemProvide === void 0 || formItemProvide.changeHandler();
143
+ };
144
+ const focusMode = ref(false);
145
+ const setHeight = () => {
146
+ if (props.autoResize && inputRef.value && height.value) inputRef.value.style.height = height.value + "px";
147
+ };
148
+ watch(height, () => {
149
+ setHeight();
150
+ });
151
+ const blurHandler = (e) => {
152
+ setHeight();
153
+ focusMode.value = false;
154
+ emits("blur", e);
155
+ formItemProvide === null || formItemProvide === void 0 || formItemProvide.blurHandler();
156
+ };
157
+ const focusHandler = (e) => {
158
+ setHeight();
159
+ focusMode.value = true;
160
+ emits("focus", e);
161
+ };
162
+ const showClose = computed(() => {
163
+ return props.clearable && focusMode.value && !disabledComputed.value && !readonlyComputed.value && !!modelValue.value;
164
+ });
165
+ const focusInputHandler = () => {
166
+ var _inputRef$value;
167
+ (_inputRef$value = inputRef.value) === null || _inputRef$value === void 0 || _inputRef$value.focus();
168
+ };
169
+ const hoverFlag = ref(false);
170
+ const mouseenterHandler = () => {
171
+ hoverFlag.value = true;
172
+ };
173
+ const mouseleaveHandler = () => {
174
+ hoverFlag.value = false;
175
+ };
176
+ __expose({
177
+ focus: () => {
178
+ var _inputRef$value2;
179
+ (_inputRef$value2 = inputRef.value) === null || _inputRef$value2 === void 0 || _inputRef$value2.focus();
180
+ },
181
+ blur: () => {
182
+ var _inputRef$value3;
183
+ (_inputRef$value3 = inputRef.value) === null || _inputRef$value3 === void 0 || _inputRef$value3.blur();
184
+ },
185
+ clear: () => clearHandler(),
186
+ select: () => {
187
+ var _inputRef$value4;
188
+ (_inputRef$value4 = inputRef.value) === null || _inputRef$value4 === void 0 || _inputRef$value4.select();
189
+ }
190
+ });
191
+ watch([
192
+ sizeComputed,
193
+ disabledComputed,
194
+ readonlyComputed,
195
+ useDarkMode(),
196
+ hoverFlag,
197
+ focusMode,
198
+ statusComputed
199
+ ], () => {
200
+ setTimeout(() => {
201
+ drawPixelDebounce();
202
+ });
203
+ });
204
+ const drawPixel = () => {
205
+ const preprocessData = canvasPreprocess(wrapperRef, canvasRef);
206
+ if (!preprocessData) return;
207
+ const { ctx, width, height: height$1 } = preprocessData;
208
+ const pixelSize = calcPixelSize();
209
+ const borderColor = statusComputed.value !== "normal" ? getGlobalThemeColor(statusComputed.value === "error" ? "danger" : statusComputed.value, 6) : (hoverFlag.value || focusMode.value) && !disabledComputed.value && !readonlyComputed.value ? getGlobalThemeColor("primary", 6) : getGlobalThemeColor("neutral", 10);
210
+ const backgroundColor = disabledComputed.value ? getGlobalThemeColor("neutral", 6) : getGlobalThemeColor("neutral", 1);
211
+ if (borderColor && backgroundColor) draw(ctx, width, height$1, borderColor, backgroundColor, pixelSize);
212
+ };
213
+ const drawPixelDebounce = Ue(drawPixel, 0, { maxWait: 50 });
214
+ onMounted(() => {
215
+ nextTick(() => {
216
+ drawPixel();
217
+ });
218
+ setTimeout(() => {
219
+ setHeight();
220
+ });
221
+ });
222
+ useResizeObserver(wrapperRef, drawPixelDebounce);
223
+ useWatchGlobalCssVal(drawPixelDebounce);
224
+ useTransitionEnd(wrapperRef, drawPixel);
225
+ return (_ctx, _cache) => {
226
+ return openBlock(), createElementBlock("div", {
227
+ class: normalizeClass(["pixelium px-textarea", {
228
+ [`px-textarea__${unref(sizeComputed)}`]: !!unref(sizeComputed),
229
+ "px-textarea__disabled": !!unref(disabledComputed),
230
+ "px-textarea__resize": !!props.resize
231
+ }]),
232
+ ref_key: "wrapperRef",
233
+ ref: wrapperRef,
234
+ onClick: focusInputHandler,
235
+ onMouseenter: mouseenterHandler,
236
+ onMouseleave: mouseleaveHandler,
237
+ onFocusout: blurHandler,
238
+ onFocusin: focusHandler
239
+ }, [
240
+ createElementVNode("textarea", {
241
+ class: "px-textarea-inner",
242
+ value: unref(modelValue),
243
+ ref_key: "inputRef",
244
+ ref: inputRef,
245
+ placeholder: props.placeholder,
246
+ disabled: unref(disabledComputed) || unref(readonlyComputed),
247
+ autofocus: __props.autofocus,
248
+ rows: props.rows,
249
+ style: normalizeStyle({
250
+ minHeight: unref(minHeight) ? unref(minHeight) + "px" : void 0,
251
+ maxHeight: unref(maxHeight) ? unref(maxHeight) + "px" : void 0
252
+ }),
253
+ onInput: withModifiers(inputHandler, ["stop"]),
254
+ onChange: withModifiers(changeHandler, ["stop"]),
255
+ onCompositionstart: _cache[0] || (_cache[0] = (...args) => unref(compositionStartHandler) && unref(compositionStartHandler)(...args)),
256
+ onCompositionend: _cache[1] || (_cache[1] = (...args) => unref(compositionUpdateHandler) && unref(compositionUpdateHandler)(...args))
257
+ }, null, 44, _hoisted_1),
258
+ createElementVNode("div", _hoisted_2, [
259
+ showClose.value ? (openBlock(), createElementBlock("div", _hoisted_3, [createVNode(unref(times_circle_solid_default), {
260
+ class: "px-textarea-icon",
261
+ onClick: clearHandler
262
+ })])) : createCommentVNode("v-if", true),
263
+ props.showCount ? (openBlock(), createElementBlock("div", _hoisted_4, [renderSlot(_ctx.$slots, "count", {
264
+ value: unref(modelValue),
265
+ count: currentLength.value,
266
+ maxLength: props.maxLength
267
+ }, () => [createElementVNode("span", null, toDisplayString(currentLength.value) + toDisplayString(unref(E)(props.maxLength) ? "" : " / " + props.maxLength), 1)])])) : createCommentVNode("v-if", true),
268
+ props.loading ? (openBlock(), createElementBlock("div", _hoisted_5, [createVNode(unref(spinner_third_solid_default), { class: "px-textarea-icon px-animation__loading" })])) : createCommentVNode("v-if", true)
269
+ ]),
270
+ createElementVNode("canvas", {
271
+ class: "px-textarea-canvas",
272
+ ref_key: "canvasRef",
273
+ ref: canvasRef
274
+ }, null, 512)
275
+ ], 34);
276
+ };
277
+ }
264
278
  });
265
- export {
266
- _sfc_main as _
267
- };
279
+ export { textarea_default as t };