@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,677 +1,627 @@
1
1
  import './css.js'
2
- import { defineComponent, useAttrs, getCurrentInstance, ref, inject, computed, shallowRef, watch, useSlots, onMounted, nextTick, createVNode, Fragment, withDirectives, vShow, h } from "vue";
3
- import { u as useResizeObserver } from "../share/hook/use-resize-observer.js";
4
- import { d as drawBorder } from "./draw.js";
5
- import { g as getGlobalThemeColor } from "../share/util/color.js";
6
- import { c as calcPixelSize, a as canvasPreprocess, g as getBorderRadius, b as calcBorderCornerCenter, f as floodFill } from "../share/util/plot.js";
7
- import { u as useDarkMode } from "../share/hook/use-dark-mode.js";
8
- import { u as useComposition } from "../share/hook/use-composition.js";
9
- import { T as TimesCircleSolid, S as SpinnerThirdSolid } from "../auto-complete/index.js";
10
- import { u as useWatchGlobalCssVal } from "../share/hook/use-watch-global-css-var.js";
11
- import { _ as _sfc_main$1 } from "../input-group/index.js";
12
- import { I as INPUT_GROUP_UPDATE } from "../share/const/event-bus-key.js";
13
- import { u as useIndexOfChildren } from "../share/hook/use-index-of-children.js";
14
- import { I as INPUT_GROUP_PROVIDE } from "../share/const/provide-key.js";
15
- import { _ as _sfc_main$3 } from "../popover/index.js";
16
- import { _ as _sfc_main$5 } from "../empty/index.js";
17
- import { _ as _sfc_main$4 } from "../option-list/index.js";
18
- import { d as defaultFilter, a as findSameOption } from "../share/util/common.js";
19
- import { p, d, k, N, P as Pn, e as en, $ } from "../aside/index.js";
20
- import { G as GROUP_OPTION_TYPE, B as BORDER_CORNER_RAD_RANGE } from "../share/const/index.js";
21
- import { u as useClickOutsideListener } from "../share/hook/use-click-outside-listener.js";
22
- import { _ as _sfc_main$2 } from "../tag/index.js";
23
- import { u as useControlledMode } from "../share/hook/use-controlled-mode.js";
24
- const ANIMATION_DURATION = 250;
25
- const _sfc_main = /* @__PURE__ */ defineComponent({
26
- ...{
27
- name: "Select"
28
- },
29
- __name: "index",
30
- props: {
31
- modelValue: null,
32
- defaultValue: null,
33
- options: {
34
- default: () => []
35
- },
36
- placeholder: null,
37
- disabled: {
38
- type: Boolean,
39
- default: false
40
- },
41
- readonly: {
42
- type: Boolean,
43
- default: false
44
- },
45
- clearable: {
46
- type: Boolean,
47
- default: false
48
- },
49
- multiple: {
50
- type: Boolean,
51
- default: false
52
- },
53
- loading: {
54
- type: Boolean,
55
- default: false
56
- },
57
- inputValue: null,
58
- defaultInputValue: null,
59
- filterable: {
60
- type: Boolean,
61
- default: false
62
- },
63
- shouldShowPopover: {
64
- type: Function
65
- },
66
- filter: {
67
- type: Function
68
- },
69
- creatable: {
70
- type: Boolean
71
- },
72
- collapseTags: {
73
- type: Boolean,
74
- default: false
75
- },
76
- maxDisplayTags: null,
77
- collapseTagsPopover: {
78
- type: Boolean,
79
- default: true
80
- },
81
- tagTheme: {
82
- default: "info"
83
- },
84
- tagVariant: {
85
- default: "plain"
86
- },
87
- tagColor: null,
88
- size: {
89
- default: "medium"
90
- },
91
- shape: {
92
- default: "default"
93
- },
94
- borderRadius: null,
95
- status: {
96
- default: "normal"
97
- }
98
- },
99
- emits: ["input", "update:modelValue", "update:inputValue", "change", "inputChange", "clear", "blur", "focus", "select", "tagClose"],
100
- setup(__props, {
101
- expose: __expose,
102
- emit: __emit
103
- }) {
104
- var _a;
105
- const attrs = useAttrs();
106
- const pixelSize = calcPixelSize();
107
- const props = __props;
108
- const emits = __emit;
109
- const [isComposing, compositionStartHandler, compositionUpdateHandler] = useComposition({
110
- afterComposition: (e) => {
111
- nextTick(() => {
112
- inputHandler(e);
113
- });
114
- }
115
- });
116
- const instance = getCurrentInstance();
117
- const innerInputGroup = ref(((_a = instance == null ? void 0 : instance.parent) == null ? void 0 : _a.type) === _sfc_main$1);
118
- const [_, first, last] = innerInputGroup.value ? useIndexOfChildren(INPUT_GROUP_UPDATE) : [ref(0), ref(false), ref(false)];
119
- const inputGroupProps = inject(INPUT_GROUP_PROVIDE);
120
- const borderRadiusComputed = computed(() => {
121
- return innerInputGroup.value && inputGroupProps ? inputGroupProps.borderRadius : props.borderRadius;
122
- });
123
- const sizeComputed = computed(() => {
124
- return innerInputGroup.value && inputGroupProps ? inputGroupProps.size : props.size;
125
- });
126
- const shapeComputed = computed(() => {
127
- return innerInputGroup.value && inputGroupProps ? inputGroupProps.shape : props.shape;
128
- });
129
- const disabledComputed = computed(() => {
130
- return innerInputGroup.value && inputGroupProps ? inputGroupProps.disabled || props.disabled : props.disabled;
131
- });
132
- const modelValueIsFalse = (modelValue2) => {
133
- return Pn(modelValue2) || en(modelValue2) || props.multiple && $(modelValue2) && modelValue2.length === 0;
134
- };
135
- const [modelValue, updateModelValue] = useControlledMode("modelValue", props, emits, {
136
- defaultField: "defaultValue",
137
- transform: (nextValue) => {
138
- if (!props.multiple) {
139
- return nextValue;
140
- } else {
141
- if (N(nextValue)) {
142
- return;
143
- } else if ($(nextValue)) {
144
- return [...nextValue];
145
- } else {
146
- return [nextValue];
147
- }
148
- }
149
- }
150
- });
151
- const [inputValue, updateInputValue] = useControlledMode("inputValue", props, emits, {
152
- defaultField: "defaultInputValue",
153
- transform: (nextValue) => {
154
- return nextValue || "";
155
- }
156
- });
157
- const currentLabelSelectedMultiple = computed(() => {
158
- if (!props.multiple) {
159
- return [];
160
- }
161
- if (!props.options.length) {
162
- return [];
163
- }
164
- if (modelValueIsFalse(modelValue.value)) {
165
- return [];
166
- }
167
- const labelMap = /* @__PURE__ */ new Map();
168
- props.options.forEach((option) => {
169
- if (p(option)) {
170
- labelMap.set(option, option);
171
- } else if ("type" in option && option.type === GROUP_OPTION_TYPE) {
172
- return option.children.some((child) => {
173
- if (p(child)) {
174
- labelMap.set(child, child);
175
- } else {
176
- labelMap.set(child.value, child.label);
177
- }
178
- });
179
- } else {
180
- labelMap.set(option.value, option.label);
181
- }
182
- });
183
- return modelValue.value.map((e) => labelMap.has(e) ? labelMap.get(e) : String(e));
184
- });
185
- const currentLabelSelected = computed(() => {
186
- if (props.multiple) {
187
- return "";
188
- }
189
- if (!props.options.length) {
190
- return "";
191
- }
192
- if (modelValueIsFalse(modelValue.value)) {
193
- return "";
194
- }
195
- let currentLabel = String(modelValue.value);
196
- props.options.some((option) => {
197
- if (p(option)) {
198
- return modelValue.value === option;
199
- } else if ("type" in option && option.type === GROUP_OPTION_TYPE) {
200
- return option.children.some((child) => {
201
- if (p(child)) {
202
- return modelValue.value === child;
203
- } else {
204
- if (child.value === modelValue.value) {
205
- currentLabel = child.label;
206
- return true;
207
- }
208
- return false;
209
- }
210
- });
211
- } else {
212
- if (option.value === modelValue.value) {
213
- currentLabel = option.label;
214
- return true;
215
- }
216
- return false;
217
- }
218
- });
219
- return currentLabel;
220
- });
221
- const wrapperRef = shallowRef(null);
222
- const canvasRef = shallowRef(null);
223
- const inputRef = shallowRef(null);
224
- const popoverRef = shallowRef(null);
225
- const closeRef = shallowRef(null);
226
- watch(() => props.multiple, (val, old) => {
227
- if (val && !old) {
228
- updateModelValue([modelValue.value]);
229
- } else {
230
- updateModelValue(modelValue.value[0] || null);
231
- }
232
- });
233
- const triggerPopover = async () => {
234
- await nextTick();
235
- if (props.shouldShowPopover) {
236
- popoverVisible.value = !!props.shouldShowPopover(inputValue.value || "", optionsFiltered.value);
237
- return;
238
- }
239
- popoverVisible.value = true;
240
- };
241
- const closePopover = async () => {
242
- popoverVisible.value = false;
243
- };
244
- const inputHandler = async (e) => {
245
- e.stopPropagation();
246
- const target = e.target;
247
- const newValue = target.value;
248
- inputValue.value = newValue;
249
- if (isComposing.value) {
250
- return;
251
- }
252
- emits("input", newValue, e);
253
- updateInputValue(newValue);
254
- await emits("update:inputValue", newValue);
255
- triggerPopover();
256
- };
257
- const clearHandler = async () => {
258
- await new Promise((res) => {
259
- setTimeout(() => {
260
- res();
261
- });
262
- });
263
- const nextModelValue = props.multiple ? [] : null;
264
- await updateInputValue("");
265
- await updateModelValue(nextModelValue);
266
- emits("change", nextModelValue);
267
- emits("clear", nextModelValue);
268
- emits("inputChange", "");
269
- };
270
- const changeHandler = (e) => {
271
- e.stopPropagation();
272
- const target = e.target;
273
- emits("inputChange", target.value, e);
274
- };
275
- const focusMode = ref(false);
276
- const focusImpl = () => {
277
- focusMode.value = true;
278
- nextTick(() => {
279
- if (inputRef.value && props.filterable) {
280
- inputRef.value.focus();
281
- if (props.multiple) {
282
- return;
283
- }
284
- const nextInput = modelValueIsFalse(modelValue.value) ? inputValue.value || "" : currentLabelSelected.value;
285
- updateInputValue(nextInput);
286
- }
287
- });
288
- triggerPopover();
289
- emits("focus");
290
- };
291
- const focusInputHandler = (e) => {
292
- var _a2;
293
- if (disabledComputed.value || props.readonly) {
294
- return;
295
- }
296
- const target = e.target;
297
- if (target instanceof HTMLElement || target instanceof SVGElement) {
298
- if ((_a2 = closeRef.value) == null ? void 0 : _a2.$el.contains(target)) {
299
- return;
300
- }
301
- }
302
- focusImpl();
303
- };
304
- const blurSelect = async () => {
305
- var _a2;
306
- focusMode.value = false;
307
- popoverVisible.value = false;
308
- (_a2 = inputRef.value) == null ? void 0 : _a2.blur();
309
- setTimeout(async () => {
310
- await updateInputValue("");
311
- emits("inputChange", "");
312
- }, ANIMATION_DURATION);
313
- emits("blur");
314
- };
315
- useClickOutsideListener([wrapperRef, () => {
316
- var _a2, _b;
317
- return (_b = (_a2 = popoverRef.value) == null ? void 0 : _a2.triggerContent) == null ? void 0 : _b.content;
318
- }], blurSelect);
319
- const hoverFlag = ref(false);
320
- const mouseenterHandler = () => {
321
- hoverFlag.value = true;
322
- };
323
- const mouseleaveHandler = () => {
324
- hoverFlag.value = false;
325
- };
326
- const showClose = computed(() => {
327
- return props.clearable && !disabledComputed.value && !props.readonly;
328
- });
329
- const getNextModelValue = (value) => {
330
- if (!props.multiple) {
331
- return value;
332
- } else {
333
- if ($(modelValue.value)) {
334
- const nextValue = [...modelValue.value];
335
- const idx = nextValue.findIndex((e) => e === value);
336
- if (idx === -1) {
337
- nextValue.push(value);
338
- } else {
339
- nextValue.splice(idx, 1);
340
- }
341
- return nextValue;
342
- } else {
343
- return [value];
344
- }
345
- }
346
- };
347
- const selectHandler = async (value, option, e) => {
348
- await new Promise((res) => {
349
- setTimeout(() => {
350
- res();
351
- });
352
- });
353
- const nextValue = getNextModelValue(value);
354
- const nextInputValue = "";
355
- await updateModelValue(nextValue);
356
- if (!props.multiple) {
357
- focusMode.value = false;
358
- closePopover();
359
- emits("select", nextValue, option, e);
360
- setTimeout(async () => {
361
- await updateInputValue(nextInputValue);
362
- }, ANIMATION_DURATION);
363
- }
364
- };
365
- const slots = useSlots();
366
- const optionsFiltered = computed(() => {
367
- const options = props.options || [];
368
- if (!props.filterable) {
369
- return options;
370
- }
371
- let ans = [];
372
- if (props.filter) {
373
- ans = props.filter(inputValue.value || "", options);
374
- } else {
375
- ans = defaultFilter(inputValue.value || "", options);
376
- }
377
- if (props.multiple) {
378
- if (!modelValueIsFalse(modelValue.value)) {
379
- modelValue.value.forEach((e) => {
380
- const dataInAns4E = findSameOption(e, ans);
381
- const dataInOptions4E = findSameOption(e, options);
382
- if (!dataInAns4E.length) {
383
- if (!dataInOptions4E.length) {
384
- ans.push(e);
385
- } else if (dataInOptions4E.length === 1) {
386
- ans.push(dataInOptions4E[0]);
387
- } else {
388
- const group = dataInOptions4E[1];
389
- const idx = ans.findIndex((e2) => d(e2) && "type" in e2 && e2.type === GROUP_OPTION_TYPE && e2.key === group.key);
390
- if (idx) {
391
- ans[idx].children.push(dataInOptions4E[0]);
392
- } else {
393
- ans.push({
394
- ...group,
395
- children: [dataInOptions4E[0]]
396
- });
397
- }
398
- }
399
- }
400
- });
401
- }
402
- }
403
- if (props.creatable && inputValue.value) {
404
- const flag = findSameOption(inputValue.value, ans, true).length;
405
- if (!flag) {
406
- ans.push(inputValue.value);
407
- }
408
- }
409
- return ans;
410
- });
411
- __expose({
412
- focus: focusImpl,
413
- blur: blurSelect,
414
- clear: () => clearHandler()
415
- });
416
- const popoverVisible = ref(false);
417
- const popoverVisibleUpdateHandler = (value) => {
418
- if (!value) {
419
- popoverVisible.value = value;
420
- }
421
- };
422
- const showPlaceholder = computed(() => {
423
- return modelValueIsFalse(modelValue.value) && (!props.multiple && !currentLabelSelected.value || props.multiple);
424
- });
425
- const tagSize = computed(() => {
426
- return sizeComputed.value === "small" ? "small" : "medium";
427
- });
428
- const tagCanClose = computed(() => {
429
- return !disabledComputed.value && !props.readonly;
430
- });
431
- const tagCloseHandler = async (value, e) => {
432
- const nextValue = [...modelValue.value];
433
- const idx = nextValue.findIndex((e2) => e2 === value);
434
- if (idx === -1) {
435
- return;
436
- }
437
- nextValue.splice(idx, 1);
438
- await updateModelValue(nextValue);
439
- emits("tagClose", value, e);
440
- emits("change", nextValue);
441
- };
442
- const shouldCollapseTags = computed(() => {
443
- return !!props.collapseTags && k(props.maxDisplayTags) && props.maxDisplayTags >= 0;
444
- });
445
- const tagsShowed = computed(() => {
446
- if (!props.multiple) {
447
- return [];
448
- }
449
- if (!props.options.length) {
450
- return [];
451
- }
452
- if (N(modelValue.value)) {
453
- return [];
454
- }
455
- return shouldCollapseTags.value ? modelValue.value.slice(0, props.maxDisplayTags) : modelValue.value;
456
- });
457
- const tagsCollapsed = computed(() => {
458
- if (!props.multiple) {
459
- return [];
460
- }
461
- if (!props.options.length) {
462
- return [];
463
- }
464
- if (N(modelValue.value)) {
465
- return [];
466
- }
467
- return shouldCollapseTags.value ? modelValue.value.slice(props.maxDisplayTags) : [];
468
- });
469
- const darkMode = useDarkMode();
470
- watch([first, last, borderRadiusComputed, shapeComputed, sizeComputed, disabledComputed, () => slots, darkMode, focusMode, hoverFlag], () => {
471
- setTimeout(() => {
472
- drawPixel();
473
- });
474
- });
475
- const drawPixel = () => {
476
- const preprocessData = canvasPreprocess(wrapperRef, canvasRef);
477
- if (!preprocessData) {
478
- return;
479
- }
480
- const {
481
- ctx,
482
- width,
483
- height,
484
- canvas
485
- } = preprocessData;
486
- const pixelSize2 = calcPixelSize();
487
- const borderRadius = getBorderRadius(canvas, pixelSize2, borderRadiusComputed.value, shapeComputed.value, sizeComputed.value || "medium", innerInputGroup.value, first.value, last.value);
488
- const borderColor = props.status !== "normal" ? getGlobalThemeColor(props.status === "error" ? "danger" : props.status, 6) : (hoverFlag.value || focusMode.value) && !disabledComputed.value && !props.readonly ? getGlobalThemeColor("primary", 6) : getGlobalThemeColor("neutral", 10);
489
- const center = calcBorderCornerCenter(borderRadius, width, height, pixelSize2);
490
- const rad = BORDER_CORNER_RAD_RANGE;
491
- drawBorder(ctx, width, height, center, borderRadius, rad, borderColor, pixelSize2, innerInputGroup.value, first.value, last.value);
492
- const backgroundColor = disabledComputed.value ? getGlobalThemeColor("neutral", 6) : getGlobalThemeColor("neutral", 1);
493
- floodFill(ctx, Math.round(width / 2), Math.round(height / 2), backgroundColor);
494
- };
495
- onMounted(() => {
496
- nextTick(() => {
497
- drawPixel();
498
- });
499
- });
500
- useResizeObserver(wrapperRef, drawPixel);
501
- useWatchGlobalCssVal(drawPixel);
502
- const stopHandler = (e) => {
503
- e.stopPropagation();
504
- };
505
- return () => {
506
- const Inner = createVNode(Fragment, null, [slots.prefix && createVNode("div", {
507
- "class": "px-select-prefix-wrapper"
508
- }, [slots.prefix()]), createVNode("div", {
509
- "class": "px-select-content"
510
- }, [props.multiple && tagsShowed.value.map((e, index) => {
511
- return createVNode(_sfc_main$2, {
512
- "key": e,
513
- "size": tagSize.value,
514
- "variant": props.tagVariant,
515
- "theme": props.tagTheme,
516
- "closable": tagCanClose.value,
517
- "disabled": disabledComputed.value,
518
- "color": props.tagColor,
519
- "onClose": (event) => tagCloseHandler(e, event)
520
- }, {
521
- default: () => slots.tag ? slots.tag({
522
- value: e,
523
- label: currentLabelSelectedMultiple.value[index],
524
- index
525
- }) : currentLabelSelectedMultiple.value[index]
526
- });
527
- }), props.multiple && !!tagsCollapsed.value.length && shouldCollapseTags.value && createVNode(Fragment, null, [!props.collapseTagsPopover ? createVNode(_sfc_main$2, {
528
- "size": tagSize.value,
529
- "variant": props.tagVariant,
530
- "theme": props.tagTheme,
531
- "disabled": disabledComputed.value,
532
- "color": props.tagColor
533
- }, {
534
- default: () => slots.tag ? slots.tag({
535
- value: null,
536
- label: `+${tagsCollapsed.value.length}`,
537
- index: -1
538
- }) : `+${tagsCollapsed.value.length}`
539
- }) : createVNode(_sfc_main$3, null, {
540
- default: () => createVNode(_sfc_main$2, {
541
- "size": tagSize.value,
542
- "variant": props.tagVariant,
543
- "theme": props.tagTheme,
544
- "disabled": disabledComputed.value,
545
- "color": props.tagColor
546
- }, {
547
- default: () => slots.tag ? slots.tag({
548
- value: null,
549
- label: `+${tagsCollapsed.value.length}`,
550
- index: -1
551
- }) : `+${tagsCollapsed.value.length}`
552
- }),
553
- content: () => createVNode("div", {
554
- "class": "px-input-tag-content"
555
- }, [tagsCollapsed.value.map((e, index) => {
556
- return createVNode(_sfc_main$2, {
557
- "key": e,
558
- "size": tagSize.value,
559
- "variant": props.tagVariant,
560
- "theme": props.tagTheme,
561
- "disabled": disabledComputed.value,
562
- "color": props.tagColor,
563
- "closable": tagCanClose.value,
564
- "onClose": (event) => tagCloseHandler(e, event)
565
- }, {
566
- default: () => {
567
- const currentIndex = index + Math.floor(props.maxDisplayTags);
568
- return slots.tag ? slots.tag({
569
- value: e,
570
- label: currentLabelSelectedMultiple.value[currentIndex],
571
- index: currentIndex
572
- }) : currentLabelSelectedMultiple.value[currentIndex];
573
- }
574
- });
575
- })])
576
- })]), withDirectives(createVNode("input", {
577
- "ref": inputRef,
578
- "class": "px-select-inner",
579
- "value": inputValue.value,
580
- "disabled": disabledComputed.value || props.readonly,
581
- "onInput": inputHandler,
582
- "onChange": changeHandler,
583
- "onFocus": stopHandler,
584
- "onBlur": stopHandler,
585
- "onCompositionstart": compositionStartHandler,
586
- "onCompositionend": compositionUpdateHandler,
587
- "placeholder": showPlaceholder.value ? props.placeholder : ""
588
- }, null), [[vShow, props.filterable && focusMode.value]]), withDirectives(createVNode("div", {
589
- "class": {
590
- "px-select-placeholder": true
591
- }
592
- }, [props.placeholder]), [[vShow, showPlaceholder.value && (!props.filterable || !focusMode.value)]]), !props.multiple && withDirectives(createVNode("div", {
593
- "class": {
594
- "px-select-label": true,
595
- "px-select-label__disabled": disabledComputed.value
596
- }
597
- }, [currentLabelSelected.value]), [[vShow, !showPlaceholder.value && (!props.filterable || !focusMode.value)]])]), showClose.value && createVNode("div", {
598
- "class": "px-select-close-wrapper"
599
- }, [hoverFlag.value && !modelValueIsFalse(modelValue.value) ? createVNode(TimesCircleSolid, {
600
- "class": "px-select-icon",
601
- "onClick": clearHandler,
602
- "ref": (el) => {
603
- closeRef.value = el;
604
- }
605
- }, null) : createVNode("div", {
606
- "class": "px-select-icon-placeholder"
607
- }, null)]), props.loading && createVNode("div", {
608
- "class": "px-select-loading-wrapper"
609
- }, [createVNode(SpinnerThirdSolid, {
610
- "class": "px-select-icon px-animation__loading"
611
- }, null)]), slots.suffix && createVNode("div", {
612
- "class": "px-select-suffix-wrapper"
613
- }, [slots.suffix()]), createVNode("canvas", {
614
- "ref": canvasRef,
615
- "class": "px-select-canvas"
616
- }, null)]);
617
- const scopeObj = {};
618
- const scopeId = instance == null ? void 0 : instance.vnode.scopeId;
619
- const parentScopeId = instance == null ? void 0 : instance.vnode.scopeId;
620
- if (scopeId) {
621
- scopeObj[scopeId] = "";
622
- }
623
- if (parentScopeId) {
624
- scopeObj[parentScopeId] = "";
625
- }
626
- const Render = createVNode(_sfc_main$3, {
627
- "placement": "bottom",
628
- "offset": 0,
629
- "width-equal": true,
630
- "arrow": false,
631
- "visible": popoverVisible.value,
632
- "onUpdate:visible": popoverVisibleUpdateHandler,
633
- "trigger": "click",
634
- "contentStyle": {
635
- padding: `${pixelSize}px`
636
- },
637
- "ref": popoverRef
638
- }, {
639
- default: () => h("div", {
640
- ref: wrapperRef,
641
- class: ["pixelium px-select", sizeComputed.value && `px-select__${sizeComputed.value}`, shapeComputed.value && `px-select__${shapeComputed.value}`, {
642
- "px-select__inner": innerInputGroup.value
643
- }, {
644
- "px-select__disabled": disabledComputed.value
645
- }],
646
- onClick: focusInputHandler,
647
- onMouseenter: mouseenterHandler,
648
- onMouseleave: mouseleaveHandler,
649
- ...scopeObj,
650
- ...attrs
651
- }, [Inner]),
652
- content: () => optionsFiltered.value.length ? createVNode(_sfc_main$4, {
653
- "options": optionsFiltered.value,
654
- "onSelect": selectHandler,
655
- "activeValues": props.multiple ? modelValue.value : [modelValue.value]
656
- }, {
657
- "group-label": ({
658
- option
659
- }) => slots["group-label"] ? slots["group-label"]({
660
- option
661
- }) : option.label,
662
- option: ({
663
- option
664
- }) => slots.option ? slots.option({
665
- option
666
- }) : p(option) ? option : option.label
667
- }) : createVNode("div", {
668
- "class": "px-select-empty"
669
- }, [createVNode(_sfc_main$5, null, null)])
670
- });
671
- return Render;
672
- };
673
- }
2
+ import { A as d, B as y, D as S, V as spinner_third_solid_default, _ as E, g as A, h as $n, j as en, l as times_circle_solid_default } from "../vendor.js";
3
+ import { i as GROUP_OPTION_TYPE, o as POPUP_CONTENT_DEFAULT_MAX_WIDTH, r as GET_ELEMENT_RENDERED, t as BORDER_CORNER_RAD_RANGE } from "../share/const/index.js";
4
+ import { r as findSameOption, t as defaultFilter } from "../share/util/common.js";
5
+ import { i as canvasPreprocess, l as getBorderRadius, n as calcPixelSize, s as floodFill, t as calcBorderCornerCenter } from "../share/util/plot.js";
6
+ import { n as getGlobalThemeColor } from "../share/util/color.js";
7
+ import { t as useDarkMode } from "../share/hook/use-dark-mode.js";
8
+ import { t as useResizeObserver } from "../share/hook/use-resize-observer.js";
9
+ import { i as INPUT_GROUP_UPDATE } from "../share/const/event-bus-key.js";
10
+ import { t as useWatchGlobalCssVal } from "../share/hook/use-watch-global-css-var.js";
11
+ import { n as useIndexOfChildren } from "../share/hook/use-index-of-children.js";
12
+ import { i as FORM_ITEM_PROVIDE, s as INPUT_GROUP_PROVIDE } from "../share/const/provide-key.js";
13
+ import { t as createProvideComputed } from "../share/util/reactivity.js";
14
+ import { t as useTransitionEnd } from "../share/hook/use-transition-end.js";
15
+ import { t as useComposition } from "../share/hook/use-composition.js";
16
+ import { t as useControlledMode } from "../share/hook/use-controlled-mode.js";
17
+ import { t as tag_default } from "../tag/index.js";
18
+ import { t as useCancelableDelay } from "../share/hook/use-cancelable-delay.js";
19
+ import { t as popover_default } from "../popover/index.js";
20
+ import { t as empty_default } from "../empty/index.js";
21
+ import { t as option_list_default } from "../option-list/index.js";
22
+ import { t as drawBorder } from "./draw.js";
23
+ import { Fragment, computed, createVNode, defineComponent, getCurrentInstance, h, inject, mergeProps, nextTick, onMounted, ref, shallowRef, useAttrs, useSlots, vShow, watch, withDirectives } from "vue";
24
+ var ANIMATION_DURATION = 250;
25
+ var select_default = /* @__PURE__ */ defineComponent({
26
+ name: "Select",
27
+ __name: "index",
28
+ props: {
29
+ modelValue: null,
30
+ defaultValue: null,
31
+ options: { default: () => [] },
32
+ placeholder: null,
33
+ disabled: {
34
+ type: Boolean,
35
+ default: false
36
+ },
37
+ readonly: {
38
+ type: Boolean,
39
+ default: false
40
+ },
41
+ clearable: {
42
+ type: Boolean,
43
+ default: false
44
+ },
45
+ multiple: {
46
+ type: Boolean,
47
+ default: false
48
+ },
49
+ loading: {
50
+ type: Boolean,
51
+ default: false
52
+ },
53
+ inputValue: null,
54
+ defaultInputValue: null,
55
+ filterable: {
56
+ type: Boolean,
57
+ default: false
58
+ },
59
+ shouldShowPopover: { type: Function },
60
+ filter: { type: Function },
61
+ creatable: { type: Boolean },
62
+ collapseTags: {
63
+ type: Boolean,
64
+ default: false
65
+ },
66
+ maxDisplayTags: null,
67
+ collapseTagsPopover: {
68
+ type: Boolean,
69
+ default: true
70
+ },
71
+ virtualScroll: {
72
+ type: Boolean,
73
+ default: false
74
+ },
75
+ virtualListProps: null,
76
+ tagProps: null,
77
+ size: null,
78
+ shape: null,
79
+ borderRadius: null,
80
+ status: { default: "normal" },
81
+ tagTheme: { default: "info" },
82
+ tagVariant: { default: "plain" },
83
+ tagColor: null,
84
+ popoverProps: null,
85
+ optionsDestroyOnHide: {
86
+ type: Boolean,
87
+ default: false
88
+ }
89
+ },
90
+ emits: [
91
+ "input",
92
+ "update:modelValue",
93
+ "update:inputValue",
94
+ "change",
95
+ "inputChange",
96
+ "clear",
97
+ "blur",
98
+ "focus",
99
+ "select",
100
+ "tagClose"
101
+ ],
102
+ setup(__props, { expose: __expose, emit: __emit }) {
103
+ var _instance$parent;
104
+ const attrs = useAttrs();
105
+ const props = __props;
106
+ const emits = __emit;
107
+ const [isComposing, compositionStartHandler, compositionUpdateHandler] = useComposition({ afterComposition: (e) => {
108
+ nextTick(() => {
109
+ inputHandler(e);
110
+ });
111
+ } });
112
+ const instance = getCurrentInstance();
113
+ const innerInputGroup = ref((instance === null || instance === void 0 || (_instance$parent = instance.parent) === null || _instance$parent === void 0 ? void 0 : _instance$parent.type.name) === "InputGroup");
114
+ const [index, first, last] = innerInputGroup.value ? useIndexOfChildren(INPUT_GROUP_UPDATE, (instance$1) => {
115
+ var _instance$vnode$el;
116
+ return instance$1 === null || instance$1 === void 0 || (_instance$vnode$el = instance$1.vnode.el) === null || _instance$vnode$el === void 0 ? void 0 : _instance$vnode$el.nextElementSibling;
117
+ }) : [
118
+ ref(0),
119
+ ref(false),
120
+ ref(false)
121
+ ];
122
+ const inputGroupProvide = inject(INPUT_GROUP_PROVIDE, void 0);
123
+ const formItemProvide = inject(FORM_ITEM_PROVIDE, void 0);
124
+ const borderRadiusComputed = createProvideComputed("borderRadius", [innerInputGroup.value && inputGroupProvide, props]);
125
+ const sizeComputed = createProvideComputed("size", () => [
126
+ innerInputGroup.value && inputGroupProvide,
127
+ props.size && props,
128
+ formItemProvide,
129
+ props
130
+ ], "nullish", (val) => val || "medium");
131
+ const shapeComputed = createProvideComputed("shape", [innerInputGroup.value && inputGroupProvide, props], "nullish", (val) => val || "rect");
132
+ const disabledComputed = createProvideComputed("disabled", [
133
+ innerInputGroup.value && inputGroupProvide,
134
+ formItemProvide,
135
+ props
136
+ ], "or");
137
+ const readonlyComputed = createProvideComputed("readonly", [
138
+ innerInputGroup.value && inputGroupProvide,
139
+ formItemProvide,
140
+ props
141
+ ], "or");
142
+ const statusComputed = createProvideComputed("status", [formItemProvide, props]);
143
+ const nextIsTextButton = computed(() => {
144
+ if (index.value >= 0) {
145
+ var _inputGroupProvide$ch;
146
+ return innerInputGroup.value ? !!((inputGroupProvide === null || inputGroupProvide === void 0 || (_inputGroupProvide$ch = inputGroupProvide.childrenInfo.value.find((e) => e.index === index.value + 1)) === null || _inputGroupProvide$ch === void 0 ? void 0 : _inputGroupProvide$ch.variant) === "text") : false;
147
+ } else return false;
148
+ });
149
+ const modelValueIsFalse = (modelValue$1) => {
150
+ return $n(modelValue$1) || en(modelValue$1) || props.multiple && S(modelValue$1) && modelValue$1.length === 0;
151
+ };
152
+ const [modelValue, updateModelValue] = useControlledMode("modelValue", props, emits, {
153
+ defaultField: "defaultValue",
154
+ transform: (nextValue) => {
155
+ if (!props.multiple) return nextValue;
156
+ else if (E(nextValue)) return;
157
+ else if (S(nextValue)) return [...nextValue];
158
+ else return [nextValue];
159
+ }
160
+ });
161
+ const [inputValue, updateInputValue] = useControlledMode("inputValue", props, emits, {
162
+ defaultField: "defaultInputValue",
163
+ transform: (nextValue) => {
164
+ return nextValue || "";
165
+ }
166
+ });
167
+ const currentLabelSelectedMultiple = computed(() => {
168
+ if (!props.multiple) return [];
169
+ if (!props.options.length) return [];
170
+ if (modelValueIsFalse(modelValue.value)) return [];
171
+ const labelMap = /* @__PURE__ */ new Map();
172
+ props.options.forEach((option) => {
173
+ if (y(option)) labelMap.set(option, option);
174
+ else if ("type" in option && option.type === "group") return option.children.some((child) => {
175
+ if (y(child)) labelMap.set(child, child);
176
+ else labelMap.set(child.value, child.label);
177
+ });
178
+ else labelMap.set(option.value, option.label);
179
+ });
180
+ return modelValue.value.map((e) => labelMap.has(e) ? labelMap.get(e) : String(e));
181
+ });
182
+ const currentLabelSelected = computed(() => {
183
+ if (props.multiple) return "";
184
+ if (!props.options.length) return "";
185
+ if (modelValueIsFalse(modelValue.value)) return "";
186
+ let currentLabel = String(modelValue.value);
187
+ props.options.some((option) => {
188
+ if (y(option)) return modelValue.value === option;
189
+ else if ("type" in option && option.type === "group") return option.children.some((child) => {
190
+ if (y(child)) return modelValue.value === child;
191
+ else {
192
+ if (child.value === modelValue.value) {
193
+ currentLabel = child.label;
194
+ return true;
195
+ }
196
+ return false;
197
+ }
198
+ });
199
+ else {
200
+ if (option.value === modelValue.value) {
201
+ currentLabel = option.label;
202
+ return true;
203
+ }
204
+ return false;
205
+ }
206
+ });
207
+ return currentLabel;
208
+ });
209
+ const wrapperRef = shallowRef(null);
210
+ const contentRef = shallowRef(null);
211
+ const canvasRef = shallowRef(null);
212
+ const inputRef = shallowRef(null);
213
+ const popoverRef = shallowRef(null);
214
+ const closeRef = shallowRef(null);
215
+ watch(() => props.multiple, (val, old) => {
216
+ if (val && !old) updateModelValue([modelValue.value]);
217
+ else updateModelValue(modelValue.value[0] || null);
218
+ });
219
+ const triggerPopover = async () => {
220
+ await nextTick();
221
+ if (props.shouldShowPopover) {
222
+ popoverVisible.value = !!props.shouldShowPopover(inputValue.value || "", optionsFiltered.value);
223
+ return;
224
+ }
225
+ popoverVisible.value = true;
226
+ };
227
+ const closePopover = async () => {
228
+ popoverVisible.value = false;
229
+ };
230
+ const inputHandler = async (e) => {
231
+ e.stopPropagation();
232
+ const newValue = e.target.value;
233
+ inputValue.value = newValue;
234
+ if (isComposing.value) return;
235
+ emits("input", newValue, e);
236
+ updateInputValue(newValue);
237
+ await emits("update:inputValue", newValue);
238
+ triggerPopover();
239
+ };
240
+ const clearHandler = async () => {
241
+ await new Promise((res) => setTimeout(res));
242
+ const nextModelValue = props.multiple ? [] : null;
243
+ await updateInputValue("");
244
+ await updateModelValue(nextModelValue);
245
+ emits("change", nextModelValue);
246
+ emits("clear", nextModelValue);
247
+ emits("inputChange", "");
248
+ formItemProvide === null || formItemProvide === void 0 || formItemProvide.changeHandler();
249
+ };
250
+ const changeHandler = (e) => {
251
+ e.stopPropagation();
252
+ const target = e.target;
253
+ emits("inputChange", target.value, e);
254
+ };
255
+ const [wait, cancel] = useCancelableDelay();
256
+ const focusMode = ref(false);
257
+ const focusImpl = async (e) => {
258
+ if (disabledComputed.value || readonlyComputed.value) return;
259
+ cancel();
260
+ focusMode.value = true;
261
+ nextTick(() => {
262
+ if (inputRef.value && props.filterable) {
263
+ inputRef.value.focus();
264
+ if (props.multiple) return;
265
+ updateInputValue(modelValueIsFalse(modelValue.value) ? inputValue.value || "" : currentLabelSelected.value);
266
+ }
267
+ });
268
+ triggerPopover();
269
+ emits("focus", e);
270
+ };
271
+ const focusInputHandler = async (e) => {
272
+ var _contentRef$value;
273
+ if (disabledComputed.value || readonlyComputed.value) return;
274
+ const target = e.target;
275
+ if (target instanceof HTMLElement || target instanceof SVGElement) {
276
+ var _closeRef$value;
277
+ if ((_closeRef$value = closeRef.value) === null || _closeRef$value === void 0 ? void 0 : _closeRef$value.$el.contains(target)) return;
278
+ }
279
+ (_contentRef$value = contentRef.value) === null || _contentRef$value === void 0 || _contentRef$value.focus();
280
+ };
281
+ const blurSelectImpl = async () => {
282
+ var _inputRef$value, _contentRef$value2;
283
+ const next = await wait();
284
+ if (!next) return next;
285
+ focusMode.value = false;
286
+ closePopover();
287
+ (_inputRef$value = inputRef.value) === null || _inputRef$value === void 0 || _inputRef$value.blur();
288
+ (_contentRef$value2 = contentRef.value) === null || _contentRef$value2 === void 0 || _contentRef$value2.blur();
289
+ setTimeout(async () => {
290
+ await updateInputValue("");
291
+ emits("inputChange", "");
292
+ }, ANIMATION_DURATION);
293
+ return next;
294
+ };
295
+ const blurSelect = async (e) => {
296
+ if (!await blurSelectImpl()) return;
297
+ emits("blur", e);
298
+ formItemProvide === null || formItemProvide === void 0 || formItemProvide.blurHandler();
299
+ };
300
+ const focusoutHandler = (e) => {
301
+ var _popoverRef$value, _wrapperRef$value;
302
+ const relatedTarget = e.relatedTarget;
303
+ if (relatedTarget && ((_popoverRef$value = popoverRef.value) === null || _popoverRef$value === void 0 || (_popoverRef$value = _popoverRef$value.triggerContent) === null || _popoverRef$value === void 0 || (_popoverRef$value = _popoverRef$value.content) === null || _popoverRef$value === void 0 ? void 0 : _popoverRef$value.contains(relatedTarget))) return;
304
+ if (relatedTarget && ((_wrapperRef$value = wrapperRef.value) === null || _wrapperRef$value === void 0 ? void 0 : _wrapperRef$value.contains(relatedTarget))) return;
305
+ blurSelect(e);
306
+ };
307
+ const hoverFlag = ref(false);
308
+ const mouseenterHandler = () => {
309
+ hoverFlag.value = true;
310
+ };
311
+ const mouseleaveHandler = () => {
312
+ hoverFlag.value = false;
313
+ };
314
+ const showClose = computed(() => {
315
+ return props.clearable && !disabledComputed.value && !readonlyComputed.value;
316
+ });
317
+ const getNextModelValue = (value) => {
318
+ if (!props.multiple) return value;
319
+ else if (S(modelValue.value)) {
320
+ const nextValue = [...modelValue.value];
321
+ const idx = nextValue.findIndex((e) => e === value);
322
+ if (idx === -1) nextValue.push(value);
323
+ else nextValue.splice(idx, 1);
324
+ return nextValue;
325
+ } else return [value];
326
+ };
327
+ const selectHandler = async (value, option, e) => {
328
+ await new Promise((res) => setTimeout(res));
329
+ const nextValue = getNextModelValue(value);
330
+ const nextInputValue = "";
331
+ await updateModelValue(nextValue);
332
+ if (!props.multiple) {
333
+ focusMode.value = false;
334
+ closePopover();
335
+ emits("select", nextValue, option, e);
336
+ emits("change", nextValue);
337
+ formItemProvide === null || formItemProvide === void 0 || formItemProvide.changeHandler();
338
+ setTimeout(async () => {
339
+ await updateInputValue(nextInputValue);
340
+ }, ANIMATION_DURATION);
341
+ }
342
+ };
343
+ const slots = useSlots();
344
+ const optionsFiltered = computed(() => {
345
+ const options = props.options || [];
346
+ if (!props.filterable) return options;
347
+ let ans = [];
348
+ if (props.filter) ans = props.filter(inputValue.value || "", options);
349
+ else ans = defaultFilter(inputValue.value || "", options);
350
+ if (props.multiple) {
351
+ if (!modelValueIsFalse(modelValue.value)) modelValue.value.forEach((e) => {
352
+ const dataInAns4E = findSameOption(e, ans);
353
+ const dataInOptions4E = findSameOption(e, options);
354
+ if (!dataInAns4E.length) if (!dataInOptions4E.length) ans.push(e);
355
+ else if (dataInOptions4E.length === 1) ans.push(dataInOptions4E[0]);
356
+ else {
357
+ const group = dataInOptions4E[1];
358
+ const idx = ans.findIndex((e$1) => d(e$1) && "type" in e$1 && e$1.type === "group" && e$1.key === group.key);
359
+ if (idx) ans[idx].children.push(dataInOptions4E[0]);
360
+ else ans.push({
361
+ ...group,
362
+ children: [dataInOptions4E[0]]
363
+ });
364
+ }
365
+ });
366
+ }
367
+ if (props.creatable && inputValue.value) {
368
+ if (!findSameOption(inputValue.value, ans, true).length) ans.push(inputValue.value);
369
+ }
370
+ return ans;
371
+ });
372
+ __expose({
373
+ focus: () => {
374
+ var _contentRef$value3;
375
+ if (disabledComputed.value || readonlyComputed.value) return;
376
+ (_contentRef$value3 = contentRef.value) === null || _contentRef$value3 === void 0 || _contentRef$value3.focus();
377
+ },
378
+ blur: () => {
379
+ blurSelectImpl();
380
+ },
381
+ clear: () => clearHandler(),
382
+ [GET_ELEMENT_RENDERED]: () => wrapperRef.value
383
+ });
384
+ const popoverVisible = ref(false);
385
+ const popoverVisibleUpdateHandler = (value) => {
386
+ if (!value) popoverVisible.value = value;
387
+ };
388
+ const showPlaceholder = computed(() => {
389
+ return modelValueIsFalse(modelValue.value) && (!props.multiple && !currentLabelSelected.value || props.multiple);
390
+ });
391
+ const tagSize = computed(() => {
392
+ return sizeComputed.value === "small" ? "small" : "medium";
393
+ });
394
+ const tagCanClose = computed(() => {
395
+ return !disabledComputed.value && !readonlyComputed.value;
396
+ });
397
+ const tagCloseHandler = async (value, e) => {
398
+ const nextValue = [...modelValue.value];
399
+ const idx = nextValue.findIndex((e$1) => e$1 === value);
400
+ if (idx === -1) return;
401
+ nextValue.splice(idx, 1);
402
+ await updateModelValue(nextValue);
403
+ emits("tagClose", value, e);
404
+ emits("change", nextValue);
405
+ formItemProvide === null || formItemProvide === void 0 || formItemProvide.changeHandler();
406
+ };
407
+ const shouldCollapseTags = computed(() => {
408
+ return !!props.collapseTags && A(props.maxDisplayTags) && props.maxDisplayTags >= 0;
409
+ });
410
+ const tagsShowed = computed(() => {
411
+ if (!props.multiple) return [];
412
+ if (!props.options.length) return [];
413
+ if (E(modelValue.value)) return [];
414
+ return shouldCollapseTags.value ? modelValue.value.slice(0, props.maxDisplayTags) : modelValue.value;
415
+ });
416
+ const tagsCollapsed = computed(() => {
417
+ if (!props.multiple) return [];
418
+ if (!props.options.length) return [];
419
+ if (E(modelValue.value)) return [];
420
+ return shouldCollapseTags.value ? modelValue.value.slice(props.maxDisplayTags) : [];
421
+ });
422
+ watch([
423
+ first,
424
+ last,
425
+ borderRadiusComputed,
426
+ shapeComputed,
427
+ sizeComputed,
428
+ readonlyComputed,
429
+ disabledComputed,
430
+ () => slots,
431
+ useDarkMode(),
432
+ focusMode,
433
+ hoverFlag,
434
+ statusComputed,
435
+ nextIsTextButton
436
+ ], () => {
437
+ drawPixel();
438
+ });
439
+ const drawPixel = () => {
440
+ const preprocessData = canvasPreprocess(wrapperRef, canvasRef);
441
+ if (!preprocessData) return;
442
+ const { ctx, width, height, canvas } = preprocessData;
443
+ const pixelSize = calcPixelSize();
444
+ const borderRadius = getBorderRadius(canvas, pixelSize, borderRadiusComputed.value, shapeComputed.value, sizeComputed.value || "medium", innerInputGroup.value, first.value, last.value);
445
+ 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);
446
+ const center = calcBorderCornerCenter(borderRadius, width, height, pixelSize);
447
+ const rad = BORDER_CORNER_RAD_RANGE;
448
+ if (borderColor) drawBorder(ctx, width, height, center, borderRadius, rad, borderColor, pixelSize, innerInputGroup.value, first.value, last.value, nextIsTextButton.value);
449
+ const backgroundColor = disabledComputed.value ? getGlobalThemeColor("neutral", 6) : getGlobalThemeColor("neutral", 1);
450
+ if (backgroundColor) floodFill(ctx, Math.round(width / 2), Math.round(height / 2), backgroundColor);
451
+ };
452
+ onMounted(() => {
453
+ nextTick(() => {
454
+ drawPixel();
455
+ });
456
+ });
457
+ useResizeObserver(wrapperRef, drawPixel);
458
+ useWatchGlobalCssVal(drawPixel);
459
+ useTransitionEnd(wrapperRef, drawPixel);
460
+ const popoverProps = computed(() => {
461
+ var _props$popoverProps;
462
+ return {
463
+ ...props.popoverProps,
464
+ contentStyle: {
465
+ maxWidth: `400px`,
466
+ ...(_props$popoverProps = props.popoverProps) === null || _props$popoverProps === void 0 ? void 0 : _props$popoverProps.contentStyle
467
+ }
468
+ };
469
+ });
470
+ return () => {
471
+ const Inner = createVNode(Fragment, null, [
472
+ slots.prefix && createVNode("div", { "class": "px-select-prefix-wrapper" }, [slots.prefix()]),
473
+ createVNode("div", {
474
+ "class": "px-select-content",
475
+ "ref": contentRef,
476
+ "tabindex": disabledComputed.value || readonlyComputed.value ? -1 : 0
477
+ }, [
478
+ props.multiple && tagsShowed.value.map((e, index$1) => {
479
+ return createVNode(tag_default, mergeProps({
480
+ "key": e,
481
+ "size": tagSize.value,
482
+ "variant": props.tagVariant,
483
+ "theme": props.tagTheme,
484
+ "closable": tagCanClose.value,
485
+ "disabled": disabledComputed.value,
486
+ "color": props.tagColor
487
+ }, props.tagProps, { "onClose": (event) => tagCloseHandler(e, event) }), { default: () => slots.tag ? slots.tag({
488
+ value: e,
489
+ label: currentLabelSelectedMultiple.value[index$1],
490
+ index: index$1,
491
+ disabled: disabledComputed.value,
492
+ readonly: readonlyComputed.value
493
+ }) : currentLabelSelectedMultiple.value[index$1] });
494
+ }),
495
+ props.multiple && !!tagsCollapsed.value.length && shouldCollapseTags.value && createVNode(Fragment, null, [!props.collapseTagsPopover ? createVNode(tag_default, mergeProps({
496
+ "size": tagSize.value,
497
+ "variant": props.tagVariant,
498
+ "theme": props.tagTheme,
499
+ "disabled": disabledComputed.value,
500
+ "color": props.tagColor
501
+ }, props.tagProps), { default: () => slots.tag ? slots.tag({
502
+ value: null,
503
+ label: `+${tagsCollapsed.value.length}`,
504
+ index: -1,
505
+ disabled: disabledComputed.value,
506
+ readonly: readonlyComputed.value
507
+ }) : `+${tagsCollapsed.value.length}` }) : createVNode(popover_default, popoverProps.value, {
508
+ default: () => createVNode(tag_default, mergeProps({
509
+ "size": tagSize.value,
510
+ "variant": props.tagVariant,
511
+ "theme": props.tagTheme,
512
+ "disabled": disabledComputed.value,
513
+ "color": props.tagColor
514
+ }, props.tagProps), { default: () => slots.tag ? slots.tag({
515
+ value: null,
516
+ label: `+${tagsCollapsed.value.length}`,
517
+ index: -1,
518
+ disabled: disabledComputed.value,
519
+ readonly: readonlyComputed.value
520
+ }) : `+${tagsCollapsed.value.length}` }),
521
+ content: () => createVNode("div", { "class": "px-input-tag-content" }, [tagsCollapsed.value.map((e, index$1) => {
522
+ return createVNode(tag_default, mergeProps({
523
+ "key": e,
524
+ "size": tagSize.value,
525
+ "variant": props.tagVariant,
526
+ "theme": props.tagTheme,
527
+ "disabled": disabledComputed.value,
528
+ "color": props.tagColor,
529
+ "closable": tagCanClose.value
530
+ }, props.tagProps, { "onClose": (event) => tagCloseHandler(e, event) }), { default: () => {
531
+ const currentIndex = index$1 + Math.floor(props.maxDisplayTags);
532
+ return slots.tag ? slots.tag({
533
+ value: e,
534
+ label: currentLabelSelectedMultiple.value[currentIndex],
535
+ index: currentIndex,
536
+ disabled: disabledComputed.value,
537
+ readonly: readonlyComputed.value
538
+ }) : currentLabelSelectedMultiple.value[currentIndex];
539
+ } });
540
+ })])
541
+ })]),
542
+ withDirectives(createVNode("input", {
543
+ "tabindex": -1,
544
+ "ref": inputRef,
545
+ "class": "px-select-inner",
546
+ "value": inputValue.value,
547
+ "disabled": disabledComputed.value || readonlyComputed.value,
548
+ "onInput": inputHandler,
549
+ "onChange": changeHandler,
550
+ "onCompositionstart": compositionStartHandler,
551
+ "onCompositionend": compositionUpdateHandler,
552
+ "placeholder": showPlaceholder.value ? props.placeholder : ""
553
+ }, null), [[vShow, props.filterable && focusMode.value]]),
554
+ withDirectives(createVNode("div", { "class": { "px-select-placeholder": true } }, [props.placeholder]), [[vShow, showPlaceholder.value && (!props.filterable || !focusMode.value)]]),
555
+ !props.multiple && withDirectives(createVNode("div", { "class": {
556
+ "px-select-label": true,
557
+ "px-select-label__disabled": disabledComputed.value
558
+ } }, [slots.label ? slots.label({
559
+ label: currentLabelSelected.value,
560
+ value: modelValue.value,
561
+ disabled: disabledComputed.value,
562
+ readonly: readonlyComputed.value
563
+ }) : currentLabelSelected.value]), [[vShow, !showPlaceholder.value && (!props.filterable || !focusMode.value)]])
564
+ ]),
565
+ showClose.value && createVNode("div", { "class": "px-select-close-wrapper" }, [hoverFlag.value && !modelValueIsFalse(modelValue.value) ? createVNode(times_circle_solid_default, {
566
+ "class": "px-select-icon",
567
+ "onClick": clearHandler,
568
+ "ref": (el) => {
569
+ closeRef.value = el;
570
+ }
571
+ }, null) : createVNode("div", { "class": "px-select-icon-placeholder" }, null)]),
572
+ props.loading && createVNode("div", { "class": "px-select-loading-wrapper" }, [createVNode(spinner_third_solid_default, { "class": "px-select-icon px-animation__loading" }, null)]),
573
+ slots.suffix && createVNode("div", { "class": "px-select-suffix-wrapper" }, [slots.suffix()]),
574
+ createVNode("canvas", {
575
+ "ref": canvasRef,
576
+ "class": "px-select-canvas"
577
+ }, null)
578
+ ]);
579
+ const scopeObj = {};
580
+ const scopeId = instance === null || instance === void 0 ? void 0 : instance.vnode.scopeId;
581
+ const parentScopeId = instance === null || instance === void 0 ? void 0 : instance.vnode.scopeId;
582
+ if (scopeId) scopeObj[scopeId] = "";
583
+ if (parentScopeId) scopeObj[parentScopeId] = "";
584
+ const pixelSize = calcPixelSize();
585
+ return createVNode(popover_default, {
586
+ "placement": "bottom",
587
+ "offset": 0,
588
+ "width-equal": true,
589
+ "arrow": false,
590
+ "visible": popoverVisible.value,
591
+ "onUpdate:visible": popoverVisibleUpdateHandler,
592
+ "trigger": "click",
593
+ "contentStyle": { padding: `${pixelSize}px` },
594
+ "ref": popoverRef,
595
+ "destroyOnHide": props.optionsDestroyOnHide
596
+ }, {
597
+ default: () => h("div", mergeProps({
598
+ ref: wrapperRef,
599
+ class: [
600
+ "pixelium px-select",
601
+ sizeComputed.value && `px-select__${sizeComputed.value}`,
602
+ shapeComputed.value && `px-select__${shapeComputed.value}`,
603
+ { "px-select__inner": innerInputGroup.value },
604
+ { "px-select__disabled": disabledComputed.value }
605
+ ],
606
+ onFocusin: focusImpl,
607
+ onFocusout: focusoutHandler,
608
+ onClick: focusInputHandler,
609
+ onMouseenter: mouseenterHandler,
610
+ onMouseleave: mouseleaveHandler,
611
+ ...scopeObj
612
+ }, attrs), [Inner]),
613
+ content: () => optionsFiltered.value.length ? createVNode(option_list_default, {
614
+ "options": optionsFiltered.value,
615
+ "onSelect": selectHandler,
616
+ "activeValues": props.multiple ? modelValue.value : [modelValue.value],
617
+ "virtualScroll": props.virtualScroll,
618
+ "virtualListProps": props.virtualListProps
619
+ }, {
620
+ "group-label": ({ option }) => slots["group-label"] ? slots["group-label"]({ option }) : option.label,
621
+ option: ({ option }) => slots.option ? slots.option({ option }) : y(option) ? option : option.label
622
+ }) : createVNode("div", { "class": "px-select-empty" }, [createVNode(empty_default, null, null)])
623
+ });
624
+ };
625
+ }
674
626
  });
675
- export {
676
- _sfc_main as _
677
- };
627
+ export { select_default as t };