hys-ui 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/CHANGELOG.md +137 -1
  2. package/README.md +18 -6
  3. package/dist/components/HysAccordion/HysAccordion.vue.js +1 -1
  4. package/dist/components/HysAccordion/HysAccordion2.vue.js +181 -47
  5. package/dist/components/HysAlert/HysAlert.vue.js +14 -14
  6. package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +23 -20
  7. package/dist/components/HysAutocomplete/HysAutocomplete.vue.js +7 -0
  8. package/dist/components/HysAutocomplete/HysAutocomplete2.vue.js +627 -0
  9. package/dist/components/HysAvatar/HysAvatar.vue.js +5 -35
  10. package/dist/components/HysAvatar/HysAvatar2.vue.js +221 -2
  11. package/dist/components/HysAvatarGroup/HysAvatarGroup.vue.js +7 -0
  12. package/dist/components/HysAvatarGroup/HysAvatarGroup2.vue.js +252 -0
  13. package/dist/components/HysBadge/HysBadge.vue.js +2 -2
  14. package/dist/components/HysBadge/HysBadge2.vue.js +154 -26
  15. package/dist/components/HysBreadcrumb/HysBreadcrumb.vue.js +5 -38
  16. package/dist/components/HysBreadcrumb/HysBreadcrumb2.vue.js +74 -2
  17. package/dist/components/HysButton/HysButton.vue.js +2 -2
  18. package/dist/components/HysButton/HysButton2.vue.js +29 -28
  19. package/dist/components/HysCalendar/HysCalendar.vue.js +5 -84
  20. package/dist/components/HysCalendar/HysCalendar2.vue.js +803 -2
  21. package/dist/components/HysCard/HysCard.vue.js +1 -1
  22. package/dist/components/HysCard/HysCard2.vue.js +177 -44
  23. package/dist/components/HysCascader/HysCascader.vue.js +5 -182
  24. package/dist/components/HysCascader/HysCascader2.vue.js +760 -2
  25. package/dist/components/HysCascader/HysCascaderColumn.vue.js +7 -0
  26. package/dist/components/HysCascader/HysCascaderColumn2.vue.js +232 -0
  27. package/dist/components/HysCheckbox/HysCheckbox.vue.js +5 -39
  28. package/dist/components/HysCheckbox/HysCheckbox2.vue.js +200 -2
  29. package/dist/components/HysCheckboxGroup/HysCheckboxGroup.vue.js +7 -0
  30. package/dist/components/HysCheckboxGroup/HysCheckboxGroup2.vue.js +237 -0
  31. package/dist/components/HysColorPicker/HysColorPicker.vue.js +2 -2
  32. package/dist/components/HysColorPicker/HysColorPicker2.vue.js +107 -106
  33. package/dist/components/HysCommandPalette/HysCommandPalette.vue.js +52 -51
  34. package/dist/components/HysCommentEditor/HysCommentEditor.vue.js +17 -17
  35. package/dist/components/HysDataGrid/HysDataGrid.vue.js +1 -1
  36. package/dist/components/HysDataGrid/HysDataGrid2.vue.js +397 -390
  37. package/dist/components/HysDatePicker/HysDatePicker.vue.js +268 -139
  38. package/dist/components/HysDatePicker/HysDatePickerControl.vue.js +7 -0
  39. package/dist/components/HysDatePicker/HysDatePickerControl2.vue.js +807 -0
  40. package/dist/components/HysDatePicker/HysDatePickerPanel.vue.js +7 -0
  41. package/dist/components/HysDatePicker/HysDatePickerPanel2.vue.js +357 -0
  42. package/dist/components/HysDateRangePicker/HysDateRangePicker.vue.js +268 -158
  43. package/dist/components/HysDivider/HysDivider.vue.js +2 -2
  44. package/dist/components/HysDivider/HysDivider2.vue.js +33 -13
  45. package/dist/components/HysDrawer/HysDrawer.vue.js +1 -1
  46. package/dist/components/HysDrawer/HysDrawer2.vue.js +55 -54
  47. package/dist/components/HysFileManager/HysFileManager.vue.js +5 -63
  48. package/dist/components/HysFileManager/HysFileManager2.vue.js +86 -2
  49. package/dist/components/HysForm/HysForm.vue.js +3 -3
  50. package/dist/components/HysForm/HysForm2.vue.js +580 -92
  51. package/dist/components/HysFormItem/HysFormItem.vue.js +5 -69
  52. package/dist/components/HysFormItem/HysFormItem2.vue.js +521 -2
  53. package/dist/components/HysGantt/HysGantt.vue.js +5 -264
  54. package/dist/components/HysGantt/HysGantt2.vue.js +1399 -2
  55. package/dist/components/HysInput/HysInput.vue.js +2 -2
  56. package/dist/components/HysInput/HysInput2.vue.js +468 -120
  57. package/dist/components/HysMention/HysMention.vue.js +2 -2
  58. package/dist/components/HysMention/HysMention2.vue.js +89 -88
  59. package/dist/components/HysModal/HysModal.vue.js +2 -2
  60. package/dist/components/HysModal/HysModal2.vue.js +35 -35
  61. package/dist/components/HysNotificationCenter/HysNotificationCenter.vue.js +37 -36
  62. package/dist/components/HysNumberInput/HysNumberInput.vue.js +2 -2
  63. package/dist/components/HysNumberInput/HysNumberInput2.vue.js +561 -70
  64. package/dist/components/HysOrgTree/HysOrgTree.vue.js +41 -36
  65. package/dist/components/HysPagination/HysPagination.vue.js +2 -2
  66. package/dist/components/HysPagination/HysPagination2.vue.js +93 -91
  67. package/dist/components/HysPermissionMatrix/HysPermissionMatrix.vue.js +5 -41
  68. package/dist/components/HysPermissionMatrix/HysPermissionMatrix2.vue.js +101 -2
  69. package/dist/components/HysRadio/HysRadio.vue.js +7 -0
  70. package/dist/components/HysRadio/HysRadio2.vue.js +180 -0
  71. package/dist/components/HysRadioGroup/HysRadioGroup.vue.js +5 -40
  72. package/dist/components/HysRadioGroup/HysRadioGroup2.vue.js +205 -2
  73. package/dist/components/HysRating/HysRating.vue.js +1 -1
  74. package/dist/components/HysRating/HysRating2.vue.js +288 -68
  75. package/dist/components/HysResizablePanel/HysResizablePanel.vue.js +46 -28
  76. package/dist/components/HysRichTextEditor/HysRichTextEditor.vue.js +2 -2
  77. package/dist/components/HysRichTextEditor/HysRichTextEditor2.vue.js +87 -67
  78. package/dist/components/HysSearch/HysSearch.vue.js +50 -38
  79. package/dist/components/HysSegmented/HysSegmented.vue.js +5 -58
  80. package/dist/components/HysSegmented/HysSegmented2.vue.js +273 -2
  81. package/dist/components/HysSelect/HysSelect.vue.js +3 -2
  82. package/dist/components/HysSelect/HysSelect2.vue.js +859 -164
  83. package/dist/components/HysSkeleton/HysSkeleton.vue.js +2 -2
  84. package/dist/components/HysSkeleton/HysSkeleton2.vue.js +126 -29
  85. package/dist/components/HysSlider/HysSlider.vue.js +2 -2
  86. package/dist/components/HysSlider/HysSlider2.vue.js +532 -59
  87. package/dist/components/HysSlider/SliderTooltip.vue.js +7 -0
  88. package/dist/components/HysSlider/SliderTooltip2.vue.js +156 -0
  89. package/dist/components/HysSplitPane/HysSplitPane.vue.js +48 -42
  90. package/dist/components/HysSteps/HysSteps.vue.js +2 -2
  91. package/dist/components/HysSteps/HysSteps2.vue.js +111 -36
  92. package/dist/components/HysSwitch/HysSwitch.vue.js +2 -2
  93. package/dist/components/HysSwitch/HysSwitch2.vue.js +235 -42
  94. package/dist/components/HysTable/HysTable.vue.js +1 -1
  95. package/dist/components/HysTable/HysTable2.vue.js +1471 -82
  96. package/dist/components/HysTable/HysTableFilterOptions.vue.js +7 -0
  97. package/dist/components/HysTable/HysTableFilterOptions2.vue.js +133 -0
  98. package/dist/components/HysTabs/HysTabs.vue.js +2 -2
  99. package/dist/components/HysTabs/HysTabs2.vue.js +262 -66
  100. package/dist/components/HysTagInput/HysTagInput.vue.js +43 -42
  101. package/dist/components/HysTextarea/HysTextarea.vue.js +137 -66
  102. package/dist/components/HysToast/HysToast.vue.js +2 -2
  103. package/dist/components/HysToast/HysToast2.vue.js +121 -38
  104. package/dist/components/HysTour/HysTour.vue.js +47 -42
  105. package/dist/components/HysTransfer/HysTransfer.vue.js +5 -207
  106. package/dist/components/HysTransfer/HysTransfer2.vue.js +416 -2
  107. package/dist/components/HysTransfer/HysTransferPanel.vue.js +7 -0
  108. package/dist/components/HysTransfer/HysTransferPanel2.vue.js +454 -0
  109. package/dist/components/HysTree/HysTree.vue.js +2 -3
  110. package/dist/components/HysTree/HysTree2.vue.js +641 -301
  111. package/dist/components/HysTreeSelect/HysTreeSelect.vue.js +5 -129
  112. package/dist/components/HysTreeSelect/HysTreeSelect2.vue.js +558 -2
  113. package/dist/components/HysTreeSelect/HysTreeSelectPanel.vue.js +7 -0
  114. package/dist/components/HysTreeSelect/HysTreeSelectPanel2.vue.js +323 -0
  115. package/dist/components/HysUpload/HysUpload.vue.js +2 -2
  116. package/dist/components/HysUpload/HysUpload2.vue.js +97 -78
  117. package/dist/composables/autocomplete.js +50 -0
  118. package/dist/composables/avatar.js +57 -0
  119. package/dist/composables/calendar.js +96 -0
  120. package/dist/composables/cascader.js +79 -0
  121. package/dist/composables/choice.js +38 -0
  122. package/dist/composables/choiceModel.js +67 -0
  123. package/dist/composables/datePicker.js +227 -0
  124. package/dist/composables/formContext.js +94 -3
  125. package/dist/composables/formLayout.js +57 -0
  126. package/dist/composables/formValidation.js +240 -0
  127. package/dist/composables/ganttConflicts.js +143 -0
  128. package/dist/composables/numberInput.js +91 -0
  129. package/dist/composables/rating.js +16 -0
  130. package/dist/composables/selectOptions.js +54 -0
  131. package/dist/composables/table.js +150 -0
  132. package/dist/composables/textInput.js +34 -0
  133. package/dist/composables/toastEscape.js +16 -0
  134. package/dist/composables/transfer.js +63 -0
  135. package/dist/composables/tree.js +118 -0
  136. package/dist/composables/treeSelect.js +71 -0
  137. package/dist/composables/useCascader.js +438 -0
  138. package/dist/composables/useDatePicker.js +425 -0
  139. package/dist/composables/useDialog.js +16 -16
  140. package/dist/composables/useFloating.js +98 -52
  141. package/dist/composables/useGanttDependencies.js +306 -0
  142. package/dist/composables/useGanttHistory.js +157 -0
  143. package/dist/composables/useGanttLabelResize.js +100 -0
  144. package/dist/composables/useHysToast.js +148 -0
  145. package/dist/composables/useTable.js +474 -0
  146. package/dist/composables/useTextareaSize.js +72 -0
  147. package/dist/composables/useTransfer.js +257 -0
  148. package/dist/composables/useTree.js +439 -0
  149. package/dist/composables/useTreeSelect.js +361 -0
  150. package/dist/config.js +18 -15
  151. package/dist/index.js +149 -136
  152. package/dist/style.css +1 -1
  153. package/dist/types/components/HysAccordion/HysAccordion.vue.d.ts +61 -22
  154. package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +201 -0
  155. package/dist/types/components/HysAvatar/HysAvatar.vue.d.ts +28 -15
  156. package/dist/types/components/HysAvatarGroup/HysAvatarGroup.vue.d.ts +99 -0
  157. package/dist/types/components/HysBadge/HysBadge.vue.d.ts +41 -4
  158. package/dist/types/components/HysBreadcrumb/HysBreadcrumb.vue.d.ts +38 -10
  159. package/dist/types/components/HysButton/HysButton.vue.d.ts +0 -1
  160. package/dist/types/components/HysCalendar/HysCalendar.vue.d.ts +119 -29
  161. package/dist/types/components/HysCard/HysCard.vue.d.ts +57 -5
  162. package/dist/types/components/HysCascader/HysCascader.vue.d.ts +129 -41
  163. package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +55 -0
  164. package/dist/types/components/HysCheckbox/HysCheckbox.vue.d.ts +55 -27
  165. package/dist/types/components/HysCheckboxGroup/HysCheckboxGroup.vue.d.ts +73 -0
  166. package/dist/types/components/HysDataGrid/HysDataGrid.vue.d.ts +1 -1
  167. package/dist/types/components/HysDatePicker/HysDatePicker.vue.d.ts +66 -14
  168. package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +90 -0
  169. package/dist/types/components/HysDatePicker/HysDatePickerPanel.vue.d.ts +93 -0
  170. package/dist/types/components/HysDateRangePicker/HysDateRangePicker.vue.d.ts +66 -14
  171. package/dist/types/components/HysDivider/HysDivider.vue.d.ts +8 -3
  172. package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +1 -0
  173. package/dist/types/components/HysFileManager/HysFileManager.vue.d.ts +8 -4
  174. package/dist/types/components/HysForm/HysForm.vue.d.ts +110 -18
  175. package/dist/types/components/HysFormItem/HysFormItem.vue.d.ts +108 -2
  176. package/dist/types/components/HysGantt/HysGantt.vue.d.ts +88 -4
  177. package/dist/types/components/HysInput/HysInput.vue.d.ts +52 -29
  178. package/dist/types/components/HysMention/HysMention.vue.d.ts +2 -2
  179. package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +93 -33
  180. package/dist/types/components/HysOrgTree/HysOrgTree.vue.d.ts +4 -1
  181. package/dist/types/components/HysPagination/HysPagination.vue.d.ts +1 -1
  182. package/dist/types/components/HysPermissionMatrix/HysPermissionMatrix.vue.d.ts +8 -1
  183. package/dist/types/components/HysPopover/HysPopover.vue.d.ts +3 -3
  184. package/dist/types/components/HysProgress/HysProgress.vue.d.ts +1 -1
  185. package/dist/types/components/HysRadio/HysRadio.vue.d.ts +56 -0
  186. package/dist/types/components/HysRadioGroup/HysRadioGroup.vue.d.ts +62 -17
  187. package/dist/types/components/HysRating/HysRating.vue.d.ts +85 -5
  188. package/dist/types/components/HysResizablePanel/HysResizablePanel.vue.d.ts +6 -0
  189. package/dist/types/components/HysRichTextEditor/HysRichTextEditor.vue.d.ts +4 -4
  190. package/dist/types/components/HysSearch/HysSearch.vue.d.ts +2 -2
  191. package/dist/types/components/HysSegmented/HysSegmented.vue.d.ts +64 -32
  192. package/dist/types/components/HysSelect/HysSelect.vue.d.ts +120 -14
  193. package/dist/types/components/HysSkeleton/HysSkeleton.vue.d.ts +30 -2
  194. package/dist/types/components/HysSlider/HysSlider.vue.d.ts +66 -9
  195. package/dist/types/components/HysSlider/SliderTooltip.vue.d.ts +22 -0
  196. package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +6 -0
  197. package/dist/types/components/HysSteps/HysSteps.vue.d.ts +65 -9
  198. package/dist/types/components/HysSwitch/HysSwitch.vue.d.ts +76 -17
  199. package/dist/types/components/HysTable/HysTable.vue.d.ts +206 -32
  200. package/dist/types/components/HysTable/HysTableFilterOptions.vue.d.ts +18 -0
  201. package/dist/types/components/HysTabs/HysTabs.vue.d.ts +76 -23
  202. package/dist/types/components/HysTagInput/HysTagInput.vue.d.ts +5 -5
  203. package/dist/types/components/HysTextarea/HysTextarea.vue.d.ts +44 -27
  204. package/dist/types/components/HysToast/HysToast.vue.d.ts +55 -7
  205. package/dist/types/components/HysTour/HysTour.vue.d.ts +5 -3
  206. package/dist/types/components/HysTransfer/HysTransfer.vue.d.ts +55 -30
  207. package/dist/types/components/HysTransfer/HysTransferPanel.vue.d.ts +105 -0
  208. package/dist/types/components/HysTree/HysTree.vue.d.ts +140 -73
  209. package/dist/types/components/HysTreeSelect/HysTreeSelect.vue.d.ts +102 -23
  210. package/dist/types/components/HysTreeSelect/HysTreeSelectPanel.vue.d.ts +56 -0
  211. package/dist/types/composables/autocomplete.d.ts +106 -0
  212. package/dist/types/composables/avatar.d.ts +70 -0
  213. package/dist/types/composables/calendar.d.ts +66 -0
  214. package/dist/types/composables/cascader.d.ts +192 -0
  215. package/dist/types/composables/choice.d.ts +110 -0
  216. package/dist/types/composables/choiceModel.d.ts +11 -0
  217. package/dist/types/composables/datePicker.d.ts +247 -0
  218. package/dist/types/composables/formContext.d.ts +138 -8
  219. package/dist/types/composables/formLayout.d.ts +11 -0
  220. package/dist/types/composables/formValidation.d.ts +13 -0
  221. package/dist/types/composables/gantt.d.ts +68 -0
  222. package/dist/types/composables/ganttConflicts.d.ts +30 -0
  223. package/dist/types/composables/numberInput.d.ts +45 -0
  224. package/dist/types/composables/rating.d.ts +18 -0
  225. package/dist/types/composables/segmented.d.ts +15 -0
  226. package/dist/types/composables/selectOptions.d.ts +44 -0
  227. package/dist/types/composables/slider.d.ts +21 -0
  228. package/dist/types/composables/table.d.ts +309 -0
  229. package/dist/types/composables/textInput.d.ts +76 -0
  230. package/dist/types/composables/toastEscape.d.ts +1 -0
  231. package/dist/types/composables/transfer.d.ts +180 -0
  232. package/dist/types/composables/tree.d.ts +237 -0
  233. package/dist/types/composables/treeSelect.d.ts +167 -0
  234. package/dist/types/composables/useCascader.d.ts +162 -0
  235. package/dist/types/composables/useDatePicker.d.ts +79 -0
  236. package/dist/types/composables/useFloating.d.ts +8 -5
  237. package/dist/types/composables/useGanttDependencies.d.ts +83 -0
  238. package/dist/types/composables/useGanttHistory.d.ts +42 -0
  239. package/dist/types/composables/useGanttLabelResize.d.ts +23 -0
  240. package/dist/types/composables/useHysToast.d.ts +50 -0
  241. package/dist/types/composables/useTable.d.ts +60 -0
  242. package/dist/types/composables/useTextareaSize.d.ts +3 -0
  243. package/dist/types/composables/useTransfer.d.ts +58 -0
  244. package/dist/types/composables/useTree.d.ts +77 -0
  245. package/dist/types/composables/useTreeSelect.d.ts +117 -0
  246. package/dist/types/index.d.ts +38 -7
  247. package/package.json +47 -11
@@ -1,201 +1,896 @@
1
- import { defineComponent as G, ref as p, useId as J, computed as x, watch as I, openBlock as s, createElementBlock as o, mergeProps as q, unref as i, createElementVNode as H, renderSlot as k, Fragment as A, renderList as F, toDisplayString as L, createTextVNode as z, createBlock as E, withModifiers as O, createVNode as Q, createCommentVNode as g, Teleport as Y, withDirectives as Z, vModelText as _, normalizeClass as ee, nextTick as ae } from "vue";
2
- import { LoaderCircle as le, ChevronDown as te, X as ie, Check as se } from "lucide-vue-next";
3
- import { useHysRootAttrs as oe } from "../../config.js";
4
- import { useFloating as ue } from "../../composables/useFloating.js";
5
- const re = ["aria-label", "disabled", "aria-expanded", "aria-controls", "aria-activedescendant"], ne = { class: "hys-ui-select-label" }, de = ["aria-controls", "aria-activedescendant"], ce = ["id", "aria-multiselectable"], ve = {
1
+ import { defineComponent as Va, useAttrs as za, inject as La, ref as w, useId as $a, shallowRef as pe, computed as r, watch as I, nextTick as z, onMounted as Ea, onUpdated as Fa, onActivated as Ha, onDeactivated as ja, onBeforeUnmount as Wa, openBlock as c, createElementBlock as v, mergeProps as qe, unref as s, createElementVNode as U, withModifiers as Ae, renderSlot as x, Fragment as le, renderList as Pe, toDisplayString as Q, createVNode as Oe, createCommentVNode as L, createTextVNode as J, normalizeClass as va, createBlock as Re, Teleport as Ka, normalizeStyle as he } from "vue";
2
+ import { X as fa, LoaderCircle as qa, ChevronDown as Pa, Plus as Ra, Check as Da } from "lucide-vue-next";
3
+ import { fieldKey as Na, useHysControlState as Ia, formValue as Ua } from "../../composables/formContext.js";
4
+ import { useHysRootAttrs as Qa } from "../../config.js";
5
+ import { useFloating as Ya } from "../../composables/useFloating.js";
6
+ import { normalizeSelectOptions as Xa, selectKeyFactory as Ga } from "../../composables/selectOptions.js";
7
+ const Ja = ["disabled"], Za = ["id", "tabindex", "aria-label", "aria-expanded", "aria-disabled", "aria-readonly", "aria-required", "aria-invalid", "aria-describedby", "aria-controls", "aria-activedescendant"], _a = { class: "hys-ui-select-label" }, et = ["title"], at = ["disabled", "aria-label", "onClick"], tt = ["title"], lt = ["title"], ot = {
6
8
  key: 0,
7
- class: "hys-ui-floating-empty"
8
- }, ye = ["id", "data-active", "aria-selected", "disabled", "onPointerenter", "onClick"], fe = {
9
+ class: "hys-ui-select-suffix"
10
+ }, it = ["name", "value", "disabled"], ut = ["data-size", "data-placement"], st = {
11
+ key: 0,
12
+ class: "hys-ui-select-header"
13
+ }, nt = ["value", "aria-controls", "aria-activedescendant"], rt = ["id", "aria-label", "aria-multiselectable", "aria-busy"], ct = {
9
14
  key: 0,
15
+ class: "hys-ui-floating-empty",
16
+ role: "status"
17
+ }, dt = {
18
+ key: 1,
19
+ class: "hys-ui-floating-empty",
20
+ role: "status"
21
+ }, vt = ["id", "data-active", "aria-label", "aria-description", "aria-selected", "aria-setsize", "aria-posinset", "disabled", "onPointerenter", "onClick"], ft = ["title"], pt = {
22
+ key: 0,
23
+ class: "hys-ui-select-create-label"
24
+ }, ht = {
25
+ key: 3,
10
26
  class: "hys-ui-floating-empty"
11
- }, ke = /* @__PURE__ */ G({
27
+ }, yt = {
28
+ key: 2,
29
+ class: "hys-ui-select-footer"
30
+ }, Ct = /* @__PURE__ */ Va({
31
+ inheritAttrs: !1,
12
32
  __name: "HysSelect",
13
33
  props: {
14
34
  modelValue: {},
15
- options: {},
35
+ defaultValue: {},
36
+ options: { default: () => [] },
37
+ fieldNames: { default: () => ({}) },
38
+ valueKey: { default: "value" },
16
39
  disabled: { type: Boolean },
40
+ readonly: { type: Boolean },
17
41
  ariaLabel: {},
18
42
  placeholder: { default: "请选择" },
19
43
  multiple: { type: Boolean },
20
44
  filterable: { type: Boolean },
21
45
  clearable: { type: Boolean },
46
+ emptyValues: { default: () => ["", null, void 0] },
47
+ clearValue: { type: [String, Number, Boolean, Object, null], default: "" },
48
+ fallbackOption: { type: [Boolean, Function] },
49
+ multipleLimit: { default: 0 },
50
+ maxTagCount: {},
51
+ maxTagTextLength: {},
52
+ removable: { type: Boolean, default: !0 },
53
+ clearSearchAfterSelect: { type: Boolean, default: !1 },
54
+ allowCreate: { type: Boolean },
55
+ createOption: {},
56
+ tokenSeparators: {},
57
+ clearCreatedOnClear: { type: Boolean, default: !0 },
22
58
  loading: { type: Boolean },
23
59
  remote: { type: Boolean },
60
+ remoteMethod: {},
61
+ debounce: { default: 0 },
62
+ searchValue: {},
63
+ filterMethod: {},
64
+ filterSort: {},
65
+ open: { type: Boolean, default: void 0 },
66
+ defaultOpen: { type: Boolean },
67
+ showOnFocus: { type: Boolean },
68
+ retainSearch: { type: Boolean },
69
+ defaultActiveFirst: { type: Boolean, default: !0 },
70
+ keyboard: { type: Boolean, default: !0 },
71
+ popupMatchWidth: { type: Boolean },
72
+ popupWidth: {},
73
+ placement: { default: "bottom-start" },
74
+ appendTo: { type: [String, Boolean], default: "body" },
75
+ popupClass: {},
76
+ popupStyle: {},
77
+ listHeight: { default: 240 },
78
+ virtual: { type: Boolean, default: !0 },
79
+ itemHeight: {},
80
+ overscan: { default: 4 },
24
81
  emptyText: { default: "暂无选项" },
25
- size: { default: "md" }
82
+ noMatchText: { default: "没有匹配选项" },
83
+ loadingText: { default: "加载中…" },
84
+ size: {},
85
+ status: {},
86
+ showArrow: { type: Boolean, default: !0 },
87
+ showCheckmark: { type: Boolean, default: !0 },
88
+ bordered: { type: Boolean, default: !0 },
89
+ autofocus: { type: Boolean },
90
+ name: {}
26
91
  },
27
- emits: ["update:modelValue", "change", "clear", "search", "visibleChange"],
28
- setup(u, { expose: K, emit: R }) {
29
- const t = u, b = R, M = oe(), h = p(), w = p(), N = p(), y = p(""), n = p(0), f = J(), { open: v, style: W, show: X, close: m } = ue(h, w, { placement: "bottom-start", matchWidth: !0 }), C = x(() => t.multiple || Array.isArray(t.modelValue)), d = x(() => Array.isArray(t.modelValue) ? t.modelValue : [t.modelValue].filter(Boolean)), V = x(() => t.options.filter((e) => d.value.includes(e.value))), c = x(() => t.remote ? t.options : t.options.filter((e) => !y.value || e.label.toLocaleLowerCase().includes(y.value.toLocaleLowerCase())));
30
- function T(e) {
31
- b("update:modelValue", e), b("change", e);
92
+ emits: ["update:modelValue", "change", "clear", "update:open", "visibleChange", "update:searchValue", "search", "select", "deselect", "removeTag", "create", "reject", "searchError", "focus", "blur", "popupScroll", "reachEnd"],
93
+ setup(d, { expose: pa, emit: ha }) {
94
+ const l = d, f = ha, ya = za(), De = Qa(), $ = La(Na, void 0), {
95
+ disabled: m,
96
+ size: B,
97
+ label: Ne
98
+ } = Ia(l), b = w(), H = w(), A = w(), Z = w(), oe = $a(), Ve = w("");
99
+ function Ie() {
100
+ var o;
101
+ const e = (o = b.value) == null ? void 0 : o.closest("label");
102
+ if (!e) {
103
+ Ve.value = "";
104
+ return;
105
+ }
106
+ const a = e.cloneNode(!0);
107
+ a.querySelectorAll(".hys-ui-select-wrap").forEach((i) => i.remove()), Ve.value = (a.textContent ?? "").replace(/\s+/g, " ").trim();
32
108
  }
33
- function S(e) {
34
- const l = c.value[e];
35
- !l || l.disabled || t.disabled || t.loading || (C.value ? T(d.value.includes(l.value) ? d.value.filter((a) => a !== l.value) : [...d.value, l.value]) : (T(l.value), m(!0)));
109
+ const Ue = pe(l.defaultValue ?? null), _ = r(
110
+ () => l.modelValue !== void 0 ? l.modelValue : Ue.value
111
+ ), j = r(() => l.multiple || Array.isArray(_.value)), n = Ga(() => l.valueKey), g = r(() => {
112
+ const e = Array.isArray(_.value) ? _.value.filter((o) => o != null) : _.value == null || l.emptyValues.some((o) => Object.is(o, _.value)) ? [] : [_.value], a = /* @__PURE__ */ new Set();
113
+ return e.filter((o) => {
114
+ const i = n(o);
115
+ return a.has(i) ? !1 : (a.add(i), !0);
116
+ });
117
+ }), W = r(() => new Set(g.value.map(n))), K = pe([]), q = pe(/* @__PURE__ */ new Map()), ye = pe(), me = w(!1), ie = pe(), Qe = w(""), be = w(l.searchValue ?? ""), ge = w(!1), k = r(() => l.searchValue ?? Qe.value), ue = r(() => l.filterable || l.allowCreate), Ye = r(
118
+ () => Xa(
119
+ ye.value ?? l.options,
120
+ l.fieldNames,
121
+ n
122
+ )
123
+ ), se = r(
124
+ () => Ye.value.flatMap((e) => e.option ? [e.option] : [])
125
+ );
126
+ I(
127
+ [se, g, K],
128
+ () => {
129
+ const e = q.value, a = /* @__PURE__ */ new Map();
130
+ for (const o of [...K.value, ...se.value])
131
+ a.set(n(o.value), o);
132
+ for (const o of g.value) {
133
+ const i = n(o);
134
+ !a.has(i) && e.has(i) && a.set(i, e.get(i));
135
+ }
136
+ q.value = a;
137
+ },
138
+ { immediate: !0 }
139
+ );
140
+ function Xe(e) {
141
+ if (l.fallbackOption !== !1)
142
+ return typeof l.fallbackOption == "function" ? l.fallbackOption(e) : {
143
+ value: e,
144
+ label: String(
145
+ typeof e == "object" ? e.label ?? e.name ?? e[l.valueKey] ?? "未命名选项" : e
146
+ )
147
+ };
36
148
  }
37
- function j() {
38
- var e;
39
- t.disabled || (T(C.value ? [] : ""), b("clear"), (e = h.value) == null || e.focus());
149
+ const M = r(
150
+ () => g.value.flatMap((e) => {
151
+ const a = q.value.get(n(e)) ?? Xe(e);
152
+ return a ? [a] : [];
153
+ })
154
+ ), Ge = r(
155
+ () => M.value.slice(
156
+ 0,
157
+ l.maxTagCount === void 0 ? void 0 : Math.max(0, l.maxTagCount)
158
+ )
159
+ ), ke = r(
160
+ () => M.value.slice(Ge.value.length)
161
+ ), P = r(() => l.loading || me.value), ze = r(
162
+ () => j.value && l.multipleLimit > 0 && g.value.length >= l.multipleLimit
163
+ ), xe = r(
164
+ () => {
165
+ var e, a;
166
+ return l.status ?? ((e = $ == null ? void 0 : $.invalid) != null && e.value ? "error" : (a = $ == null ? void 0 : $.status) == null ? void 0 : a.value);
167
+ }
168
+ ), ee = r(
169
+ () => B.value === "sm" ? 14 : B.value === "lg" ? 18 : 16
170
+ ), E = r(
171
+ () => Math.max(
172
+ 24,
173
+ l.itemHeight ?? (B.value === "sm" ? 34 : B.value === "lg" ? 50 : 42)
174
+ )
175
+ ), Le = r(() => {
176
+ const e = k.value.trim();
177
+ if (!(!l.allowCreate || !e || [...se.value, ...K.value].some(
178
+ (a) => a.label === e || n(a.value) === n(e)
179
+ )))
180
+ return { value: e, label: e };
181
+ }), T = r(() => {
182
+ let e = Ye.value.filter((u) => u.option).concat(
183
+ K.value.filter(
184
+ (u) => !se.value.some(
185
+ (t) => n(t.value) === n(u.value)
186
+ )
187
+ ).map((u) => ({ key: n(u.value), option: u, index: -1 }))
188
+ );
189
+ !l.remote && !l.remoteMethod && (e = e.filter(
190
+ (u) => !k.value || (l.filterMethod ? l.filterMethod(k.value, u.option) : u.option.label.toLocaleLowerCase().includes(k.value.toLocaleLowerCase()))
191
+ )), l.filterSort && (e = [...e].sort(
192
+ (u, t) => l.filterSort(u.option, t.option)
193
+ )), Le.value && (e = [
194
+ {
195
+ key: "create:" + n(Le.value.value),
196
+ option: Le.value,
197
+ created: !0,
198
+ index: -1
199
+ },
200
+ ...e
201
+ ]);
202
+ const a = [];
203
+ let o, i = 0;
204
+ for (const u of e)
205
+ u.group !== o && (o = u.group, o && a.push({ key: "group:" + o + ":" + i, index: -1, group: o })), a.push({ ...u, index: i++ });
206
+ return a;
207
+ }), ma = r(
208
+ () => T.value.filter((e) => e.option).length
209
+ ), S = w(), Te = w(0), $e = w(0), O = r(
210
+ () => l.virtual && T.value.length > 100
211
+ ), ne = r(
212
+ () => Math.min(
213
+ 800,
214
+ Math.max(80, Number.isFinite(l.listHeight) ? l.listHeight : 240)
215
+ )
216
+ ), Je = r(() => Math.max(1, Math.min(30, l.overscan))), Ee = r(
217
+ () => O.value ? Math.max(
218
+ 0,
219
+ Math.min(
220
+ Math.max(0, T.value.length - 1),
221
+ Math.floor(Te.value / E.value) - Je.value
222
+ )
223
+ ) : 0
224
+ ), Ze = r(
225
+ () => O.value ? T.value.slice(
226
+ Ee.value,
227
+ Ee.value + Math.ceil(ne.value / E.value) + Je.value * 2
228
+ ) : T.value
229
+ ), re = r(
230
+ () => T.value.find((e) => e.key === S.value)
231
+ ), _e = r(
232
+ () => {
233
+ var e;
234
+ return !P.value && ((e = re.value) != null && e.option) && (!O.value || Ze.value.some((a) => a.key === S.value)) ? oe + "-" + re.value.index : void 0;
235
+ }
236
+ ), ba = r(() => {
237
+ var o;
238
+ if (!O.value || l.popupMatchWidth || l.popupWidth !== void 0)
239
+ return l.popupWidth;
240
+ const e = B.value === "sm" ? 12 : B.value === "lg" ? 15 : 14;
241
+ let a = 0;
242
+ for (const i of T.value) {
243
+ const u = ((o = i.option) == null ? void 0 : o.label) ?? i.group ?? "";
244
+ let t = 0;
245
+ for (const y of u) t += y.charCodeAt(0) > 255 ? 1 : 0.58;
246
+ a = Math.max(a, t * e);
247
+ }
248
+ return Math.max($e.value, a + 52);
249
+ });
250
+ let R = !0, ce = !1, de = 0, ae, Fe, Y, He = 0, Ce, Me = "";
251
+ const {
252
+ open: h,
253
+ style: ga,
254
+ placement: ka,
255
+ show: xa,
256
+ close: V,
257
+ update: Se,
258
+ restoringFocus: Ta
259
+ } = Ya(b, H, {
260
+ get placement() {
261
+ return l.placement;
262
+ },
263
+ matchWidth: () => l.popupMatchWidth ? !0 : "min",
264
+ width: () => ba.value,
265
+ requestOpen: (e) => (f("update:open", e), l.open === void 0 ? void 0 : !1)
266
+ }), Ca = r(() => ({
267
+ ...l.popupStyle,
268
+ ...ga.value,
269
+ maxHeight: "min(60dvh, calc(100dvh - 20px))",
270
+ overflowY: "hidden",
271
+ "--hys-ui-select-stride": E.value + "px",
272
+ "--hys-ui-select-list-height": ne.value + "px"
273
+ })), Ma = () => Object.fromEntries(
274
+ Object.entries(ya).filter(([e]) => !["class", "style"].includes(e))
275
+ ), X = (e) => !!e.disabled || l.readonly || P.value || m.value || ze.value && !W.value.has(n(e.value));
276
+ function ea() {
277
+ return T.value.filter((e) => e.option && !X(e.option));
40
278
  }
41
- async function $() {
42
- var e;
43
- if (!t.disabled) {
44
- if (v.value) {
45
- m();
279
+ function we(e = !1) {
280
+ var i;
281
+ const a = ea(), o = a.find(
282
+ (u) => W.value.has(n(u.option.value))
283
+ );
284
+ S.value = (i = o ?? (l.defaultActiveFirst ? e ? a.at(-1) : a[0] : void 0)) == null ? void 0 : i.key;
285
+ }
286
+ async function G() {
287
+ var a, o;
288
+ const e = T.value.findIndex(
289
+ (i) => i.key === S.value
290
+ );
291
+ if (!(e < 0)) {
292
+ if (O.value && A.value) {
293
+ const i = e * E.value, u = i + E.value, t = A.value.clientHeight || ne.value;
294
+ i < A.value.scrollTop ? A.value.scrollTop = i : u > A.value.scrollTop + t && (A.value.scrollTop = u - t), Te.value = A.value.scrollTop;
295
+ }
296
+ await z(), O.value || (o = (a = H.value) == null ? void 0 : a.querySelector('[data-active="true"]')) == null || o.scrollIntoView({ block: "nearest" });
297
+ }
298
+ }
299
+ function te(e) {
300
+ const a = Array.isArray(e) ? e : e == null || l.emptyValues.some((i) => Object.is(i, e)) ? [] : [e];
301
+ if (a.length === g.value.length && a.every((i, u) => n(i) === n(g.value[u])))
302
+ return;
303
+ l.modelValue === void 0 && (Ue.value = e);
304
+ const o = a.flatMap((i) => {
305
+ const u = q.value.get(n(i)) ?? Xe(i);
306
+ return u ? [u] : [];
307
+ });
308
+ f("update:modelValue", e), f("change", e, j.value ? o : o[0]);
309
+ }
310
+ function ve(e) {
311
+ be.value = e, l.searchValue === void 0 && (Qe.value = e), f("update:searchValue", e);
312
+ }
313
+ function aa(e) {
314
+ q.value.has(n(e.value)) || (K.value = [...K.value, e], q.value = new Map(q.value).set(
315
+ n(e.value),
316
+ e
317
+ ), f("create", e));
318
+ }
319
+ function ta(e) {
320
+ try {
321
+ const a = l.createOption ? l.createOption(e) : { label: e, value: e };
322
+ return a ? { ...a, label: String(a.label) } : void 0;
323
+ } catch {
324
+ f("reject", e, "create");
325
+ return;
326
+ }
327
+ }
328
+ async function la(e) {
329
+ var u;
330
+ if (!(e != null && e.option) || X(e.option)) return;
331
+ let a = e.option;
332
+ if (e.created) {
333
+ const t = ta(a.label);
334
+ if (!t) return;
335
+ if (a = q.value.get(n(t.value)) ?? t, ze.value && !W.value.has(n(a.value))) {
336
+ f("reject", a.value, "limit");
46
337
  return;
47
338
  }
48
- y.value = "", n.value = Math.max(0, c.value.findIndex((l) => d.value.includes(l.value) && !l.disabled)), await X(), t.filterable && ((e = N.value) == null || e.focus());
339
+ aa(a);
49
340
  }
341
+ const o = n(a.value), i = W.value.has(o);
342
+ if (j.value) {
343
+ if (i)
344
+ te(g.value.filter((t) => n(t) !== o)), f("deselect", a.value, a);
345
+ else {
346
+ if (ze.value) {
347
+ f("reject", a.value, "limit");
348
+ return;
349
+ }
350
+ te([...g.value, a.value]), f("select", a.value, a);
351
+ }
352
+ l.clearSearchAfterSelect && ve(""), await z(), h.value && ue.value && ((u = Z.value) == null || u.focus());
353
+ } else
354
+ te(a.value), f("select", a.value, a), V(!0);
355
+ }
356
+ function je(e) {
357
+ var a;
358
+ m.value || l.readonly || e.disabled || !l.removable || (te(g.value.filter((o) => n(o) !== n(e.value))), f("removeTag", e.value, e), f("deselect", e.value, e), (a = b.value) == null || a.focus());
359
+ }
360
+ function Sa() {
361
+ var e, a;
362
+ m.value || l.readonly || (fe(), te(j.value ? [] : l.clearValue), l.clearCreatedOnClear && (K.value = []), ve(""), f("clear"), h.value && ue.value ? (e = Z.value) == null || e.focus() : (a = b.value) == null || a.focus());
363
+ }
364
+ async function F(e = !1, a = !1) {
365
+ var o;
366
+ !R || m.value || (!l.retainSearch && !l.searchValue && ve(""), we(e), await xa(a), await z(), h.value && (ue.value && ((o = Z.value) == null || o.focus()), await G()));
367
+ }
368
+ function oa() {
369
+ h.value ? V() : F();
370
+ }
371
+ function fe() {
372
+ de++, clearTimeout(Fe), Fe = void 0, ae == null || ae.abort(), ae = void 0, me.value = !1;
373
+ }
374
+ function Be(e, a = !1) {
375
+ if (fe(), !l.remoteMethod || !h.value || !R || m.value)
376
+ return;
377
+ const o = de, i = new AbortController();
378
+ ae = i, me.value = !0, ie.value = void 0;
379
+ const u = async () => {
380
+ try {
381
+ const t = await l.remoteMethod(e, {
382
+ signal: i.signal
383
+ });
384
+ if (!R || i.signal.aborted || o !== de || !h.value)
385
+ return;
386
+ Array.isArray(t) && (ye.value = t);
387
+ } catch (t) {
388
+ if (i.signal.aborted || o !== de || !R) return;
389
+ ie.value = t, ye.value = [], f("searchError", t, e);
390
+ } finally {
391
+ o === de && (me.value = !1, ae = void 0, await z(), h.value && (we(), Se(), G()));
392
+ }
393
+ };
394
+ a || l.debounce <= 0 ? u() : Fe = setTimeout(u, l.debounce);
50
395
  }
51
- async function P(e) {
52
- var l, a, r;
53
- if (!t.disabled)
54
- if (["ArrowDown", "ArrowUp", "Home", "End"].includes(e.key)) {
55
- if (e.preventDefault(), !v.value) await $();
396
+ function We() {
397
+ Be(k.value, !0);
398
+ }
399
+ function wa(e) {
400
+ var p;
401
+ if (m.value || l.readonly || P.value || !j.value || !l.allowCreate || !((p = l.tokenSeparators) != null && p.length))
402
+ return !1;
403
+ let a = [e], o = !1;
404
+ for (const C of l.tokenSeparators)
405
+ C && (a.some((D) => D.includes(C)) && (o = !0), a = a.flatMap((D) => D.split(C)));
406
+ if (!o) return !1;
407
+ const i = a.pop() ?? "", u = [...g.value], t = new Set(u.map(n));
408
+ let y = !1;
409
+ for (const C of a.map((D) => D.trim()).filter(Boolean)) {
410
+ const D = [...se.value, ...K.value].find(
411
+ (da) => da.label === C || n(da.value) === n(C)
412
+ ), N = D ?? ta(C);
413
+ if (!N) continue;
414
+ const ca = n(N.value);
415
+ if (!(t.has(ca) || N.disabled)) {
416
+ if (l.multipleLimit > 0 && u.length >= l.multipleLimit) {
417
+ f("reject", N.value, "limit");
418
+ continue;
419
+ }
420
+ D || aa(N), t.add(ca), u.push(N.value), y = !0, f("select", N.value, N);
421
+ }
422
+ }
423
+ return y && te(u), ve(i), !0;
424
+ }
425
+ function ia(e) {
426
+ if (m.value) return;
427
+ const a = e.target.value;
428
+ be.value = a, !ge.value && (wa(a) || ve(a));
429
+ }
430
+ function Ba(e) {
431
+ ge.value = !1, ia(e);
432
+ }
433
+ async function ua(e) {
434
+ var i, u;
435
+ if (m.value || !l.keyboard || e.isComposing || ge.value || e.keyCode === 229 || e.target.closest(
436
+ ".hys-ui-select-tag button,.hys-ui-select-clear"
437
+ ))
438
+ return;
439
+ const a = e.target === Z.value, o = e.target;
440
+ if (!(o !== b.value && !a && !o.matches('[role="option"]') && o.closest(
441
+ 'button,input,textarea,select,a,[role="button"],[contenteditable="true"]'
442
+ ))) {
443
+ if (["ArrowDown", "ArrowUp", "Home", "End", "PageDown", "PageUp"].includes(
444
+ e.key
445
+ )) {
446
+ if (e.preventDefault(), !h.value)
447
+ await F(e.key === "ArrowUp" || e.key === "End");
56
448
  else {
57
- const D = e.key === "ArrowUp" ? -1 : 1;
58
- let B = e.key === "Home" ? -1 : e.key === "End" ? c.value.length : n.value;
59
- for (let U = 0; U < c.value.length; U++)
60
- if (B = (B + (e.key === "End" ? -1 : D) + c.value.length) % c.value.length, !c.value[B].disabled) {
61
- n.value = B;
449
+ const t = T.value, y = ["ArrowUp", "End", "PageUp"].includes(e.key) ? -1 : 1;
450
+ let p = e.key === "Home" ? -1 : e.key === "End" ? t.length : t.findIndex((C) => C.key === S.value);
451
+ e.key.startsWith("Page") && (p = Math.max(
452
+ -1,
453
+ Math.min(
454
+ t.length,
455
+ p + y * (Math.max(1, Math.floor(ne.value / E.value)) - 1)
456
+ )
457
+ ));
458
+ for (let C = 0; C < t.length; C++)
459
+ if (p = (p + y + t.length) % t.length, t[p].option && !X(t[p].option)) {
460
+ S.value = t[p].key;
62
461
  break;
63
462
  }
64
463
  }
65
- await ae(), (a = (l = w.value) == null ? void 0 : l.querySelector('[data-active="true"]')) == null || a.scrollIntoView({ block: "nearest" });
66
- } else e.key === "Enter" || e.key === " " && !t.filterable ? (e.preventDefault(), v.value ? S(n.value) : await $()) : e.key === "Tab" && m(!!((r = w.value) != null && r.contains(document.activeElement)));
67
- }
68
- return I(y, (e) => {
69
- n.value = Math.max(0, c.value.findIndex((l) => !l.disabled)), b("search", e);
70
- }), I(v, (e) => b("visibleChange", e)), I(() => t.disabled, (e) => {
71
- e && m();
72
- }), K({ focus: () => {
73
- var e;
74
- return (e = h.value) == null ? void 0 : e.focus();
75
- }, blur: () => {
464
+ await G();
465
+ } else if (e.key === "Enter" || e.key === " " && !a)
466
+ e.preventDefault(), h.value ? await la(re.value) : await F();
467
+ else if (e.key === "Tab")
468
+ V(!!((i = H.value) != null && i.contains(document.activeElement)));
469
+ else if (e.key === "Backspace" && j.value && !k.value) {
470
+ const t = [...M.value].reverse().find((y) => !y.disabled);
471
+ t && l.removable && (e.preventDefault(), je(t), a && (await z(), (u = Z.value) == null || u.focus()));
472
+ } else if (!ue.value && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
473
+ Me += e.key.toLocaleLowerCase(), clearTimeout(Ce), Ce = setTimeout(() => {
474
+ Me = "";
475
+ }, 600), h.value || await F();
476
+ const t = ea().find(
477
+ (y) => y.option.label.toLocaleLowerCase().startsWith(Me)
478
+ );
479
+ t && (S.value = t.key, await G());
480
+ }
481
+ }
482
+ }
483
+ function sa(e) {
484
+ ce || (ce = !0, f("focus", e)), l.showOnFocus && !h.value && !Ta.value && e.target === b.value && F();
485
+ }
486
+ function na(e) {
487
+ z(() => {
488
+ var o, i;
489
+ const a = document.activeElement;
490
+ ce && !((o = b.value) != null && o.contains(a)) && !((i = H.value) != null && i.contains(a)) && (ce = !1, f("blur", e));
491
+ });
492
+ }
493
+ function Aa(e) {
494
+ const a = e.target;
495
+ Te.value = a.scrollTop, f("popupScroll", e), a.scrollTop + a.clientHeight >= a.scrollHeight - 2 && f("reachEnd");
496
+ }
497
+ function Ke() {
498
+ Y == null || Y.disconnect(), Y = void 0, cancelAnimationFrame(He);
499
+ }
500
+ function Oa() {
501
+ if (Ke(), !h.value || !R) return;
502
+ const e = () => {
503
+ cancelAnimationFrame(He), He = requestAnimationFrame(() => {
504
+ var a;
505
+ $e.value = ((a = b.value) == null ? void 0 : a.clientWidth) ?? 0, Se();
506
+ });
507
+ };
508
+ typeof ResizeObserver < "u" && (Y = new ResizeObserver(e), b.value && Y.observe(b.value), H.value && Y.observe(H.value));
509
+ }
510
+ I(k, (e) => {
511
+ be.value = e, S.value = void 0, Te.value = 0, A.value && (A.value.scrollTop = 0), we(), f("search", e), Be(e), h.value && z(G);
512
+ }), I(T, () => {
513
+ var a;
514
+ const e = !((a = re.value) != null && a.option) || X(re.value.option);
515
+ e && we(), h.value && z(() => {
516
+ Se(), e && G();
517
+ });
518
+ }), I(
519
+ [
520
+ g,
521
+ B,
522
+ () => l.popupMatchWidth,
523
+ () => l.popupWidth,
524
+ () => l.placement
525
+ ],
526
+ () => {
527
+ h.value && z(Se);
528
+ }
529
+ ), I(h, (e) => {
530
+ var a;
531
+ f("visibleChange", e), e ? ($e.value = ((a = b.value) == null ? void 0 : a.clientWidth) ?? 0, z(Oa), Be(k.value)) : (Ke(), fe(), clearTimeout(Ce), Me = "");
532
+ }), I(
533
+ () => l.open,
534
+ (e) => {
535
+ R && (e ? F(!1, !0) : e === !1 && V(!1, !0));
536
+ }
537
+ ), I(
538
+ m,
539
+ (e) => {
540
+ e && (V(!1, !0), fe(), f("update:open", !1));
541
+ },
542
+ { flush: "sync" }
543
+ ), I(
544
+ () => l.remoteMethod,
545
+ () => {
546
+ ye.value = void 0, ie.value = void 0, h.value && Be(k.value);
547
+ }
548
+ );
549
+ function ra() {
550
+ R = !1, V(!1, !0), Ke(), fe(), clearTimeout(Ce), ce = !1;
551
+ }
552
+ return Ea(() => {
76
553
  var e;
77
- return (e = h.value) == null ? void 0 : e.blur();
78
- }, close: () => m() }), (e, l) => (s(), o("div", q(i(M), {
79
- class: ["hys-ui-select-wrap", "hys-ui-select-" + u.size]
80
- }), [
81
- H("button", {
82
- ref_key: "trigger",
83
- ref: h,
84
- type: "button",
85
- class: "hys-ui-select",
86
- "aria-label": u.ariaLabel,
87
- disabled: u.disabled,
88
- role: "combobox",
89
- "aria-haspopup": "listbox",
90
- "aria-expanded": i(v),
91
- "aria-controls": i(v) ? i(f) : void 0,
92
- "aria-activedescendant": i(v) ? i(f) + "-" + n.value : void 0,
93
- onClick: $,
94
- onKeydown: P
95
- }, [
96
- H("span", ne, [
97
- k(e.$slots, "label", { selected: V.value }, () => {
98
- var a;
99
- return [
100
- C.value && V.value.length ? (s(!0), o(A, { key: 0 }, F(V.value, (r) => (s(), o("span", {
101
- key: r.value,
102
- class: "hys-ui-select-tag"
103
- }, L(r.label), 1))), 128)) : (s(), o(A, { key: 1 }, [
104
- z(L(((a = V.value[0]) == null ? void 0 : a.label) || u.placeholder), 1)
105
- ], 64))
106
- ];
107
- }, !0)
108
- ]),
109
- u.loading ? (s(), E(i(le), {
110
- key: 0,
111
- class: "hys-ui-icon-spin",
112
- size: 16
113
- })) : (s(), E(i(te), {
114
- key: 1,
115
- class: "hys-ui-select-chevron",
116
- size: 16,
117
- "aria-hidden": "true"
118
- }))
119
- ], 40, re),
120
- u.clearable && d.value.length && !u.disabled ? (s(), o("button", {
121
- key: 0,
122
- type: "button",
123
- class: "hys-ui-select-clear",
124
- "aria-label": "清空选择",
125
- onClick: O(j, ["stop"])
126
- }, [
127
- Q(i(ie), { size: 13 })
128
- ])) : g("", !0),
129
- (s(), E(Y, { to: "body" }, [
130
- i(v) ? (s(), o("div", q({
131
- key: 0,
132
- ref_key: "panel",
133
- ref: w
134
- }, i(M), {
135
- class: "hys-ui-select-options hys-ui-floating-surface",
136
- style: i(W),
137
- onKeydown: P
554
+ Ie(), l.autofocus && !m.value && ((e = b.value) == null || e.focus()), (l.open ?? l.defaultOpen) && F(!1, !0);
555
+ }), Fa(Ie), Ha(() => {
556
+ R = !0, l.open && F(!1, !0);
557
+ }), ja(ra), Wa(ra), pa({
558
+ focus: () => {
559
+ var e;
560
+ m.value || (e = b.value) == null || e.focus();
561
+ },
562
+ blur: () => {
563
+ var a, o;
564
+ const e = document.activeElement;
565
+ e && ((a = b.value) != null && a.contains(e) || (o = H.value) != null && o.contains(e)) && e.blur(), V();
566
+ },
567
+ open: () => F(),
568
+ close: () => V(),
569
+ scrollTo: (e) => {
570
+ S.value = n(e), G();
571
+ },
572
+ retry: We,
573
+ selected: M,
574
+ query: k,
575
+ isOpen: h
576
+ }), (e, a) => {
577
+ var o, i, u;
578
+ return c(), v("div", qe(s(De), {
579
+ class: ["hys-ui-select-wrap", [e.$attrs.class, "hys-ui-select-" + s(B)]],
580
+ style: e.$attrs.style
581
+ }), [
582
+ U("button", {
583
+ hidden: "",
584
+ type: "button",
585
+ tabindex: "-1",
586
+ "aria-hidden": "true",
587
+ disabled: s(m),
588
+ onClick: a[0] || (a[0] = Ae((t) => {
589
+ var y;
590
+ (y = b.value) == null || y.focus(), oa();
591
+ }, ["prevent"]))
592
+ }, null, 8, Ja),
593
+ U("div", qe({
594
+ ref_key: "trigger",
595
+ ref: b
596
+ }, Ma(), {
597
+ class: ["hys-ui-select", {
598
+ "hys-ui-select-disabled": s(m),
599
+ "hys-ui-select-borderless": !d.bordered,
600
+ "hys-ui-select-error": xe.value === "error",
601
+ "hys-ui-select-warning": xe.value === "warning",
602
+ "hys-ui-select-success": xe.value === "success"
603
+ }],
604
+ id: e.$attrs.id || ((o = s($)) == null ? void 0 : o.id.value) || void 0,
605
+ "data-hys-ui-field-managed": "",
606
+ role: "combobox",
607
+ tabindex: s(m) ? -1 : 0,
608
+ "aria-label": d.ariaLabel || s(Ne) || Ve.value || M.value.map((t) => t.label).join("、") || d.placeholder,
609
+ "aria-haspopup": "listbox",
610
+ "aria-expanded": s(h),
611
+ "aria-disabled": s(m) || void 0,
612
+ "aria-readonly": d.readonly || void 0,
613
+ "aria-required": ((i = s($)) == null ? void 0 : i.required.value) || void 0,
614
+ "aria-invalid": xe.value === "error" || !1,
615
+ "aria-describedby": [e.$attrs["aria-describedby"], (u = s($)) == null ? void 0 : u.describedBy.value].filter(Boolean).join(" ") || void 0,
616
+ "aria-controls": s(h) ? s(oe) : void 0,
617
+ "aria-activedescendant": s(h) ? _e.value : void 0,
618
+ onClick: a[1] || (a[1] = Ae((t) => !t.target.closest("button") && oa(), ["prevent"])),
619
+ onKeydown: ua,
620
+ onFocusin: sa,
621
+ onFocusout: na
138
622
  }), [
139
- u.filterable ? Z((s(), o("input", {
623
+ U("span", _a, [
624
+ x(e.$slots, "label", { selected: M.value }, () => {
625
+ var t, y;
626
+ return [
627
+ j.value && M.value.length ? (c(), v(le, { key: 0 }, [
628
+ (c(!0), v(le, null, Pe(Ge.value, (p) => (c(), v("span", {
629
+ key: s(n)(p.value),
630
+ class: "hys-ui-select-tag"
631
+ }, [
632
+ x(e.$slots, "tag", {
633
+ option: p,
634
+ remove: () => je(p),
635
+ disabled: s(m) || d.readonly || p.disabled
636
+ }, () => [
637
+ U("span", {
638
+ class: "hys-ui-select-tag-text",
639
+ title: p.label
640
+ }, Q(d.maxTagTextLength && p.label.length > d.maxTagTextLength ? p.label.slice(0, d.maxTagTextLength) + "…" : p.label), 9, et),
641
+ d.removable && !d.readonly && !p.disabled ? (c(), v("button", {
642
+ key: 0,
643
+ type: "button",
644
+ disabled: s(m),
645
+ "aria-label": "移除 " + p.label,
646
+ onClick: Ae((C) => je(p), ["stop"])
647
+ }, [
648
+ x(e.$slots, "remove-icon", {}, () => [
649
+ Oe(s(fa), {
650
+ size: ee.value - 3
651
+ }, null, 8, ["size"])
652
+ ], !0)
653
+ ], 8, at)) : L("", !0)
654
+ ], !0)
655
+ ]))), 128)),
656
+ ke.value.length ? (c(), v("span", {
657
+ key: 0,
658
+ class: "hys-ui-select-tag hys-ui-select-more",
659
+ title: ke.value.map((p) => p.label).join("、")
660
+ }, [
661
+ x(e.$slots, "max-tag", { omitted: ke.value }, () => [
662
+ J("+" + Q(ke.value.length), 1)
663
+ ], !0)
664
+ ], 8, tt)) : L("", !0)
665
+ ], 64)) : (c(), v("span", {
666
+ key: 1,
667
+ class: va(["hys-ui-select-single-label", { "hys-ui-select-placeholder": !M.value.length }]),
668
+ title: (t = M.value[0]) == null ? void 0 : t.label
669
+ }, Q(((y = M.value[0]) == null ? void 0 : y.label) ?? d.placeholder), 11, lt))
670
+ ];
671
+ }, !0)
672
+ ]),
673
+ d.showArrow || P.value ? (c(), v("span", ot, [
674
+ x(e.$slots, "suffix", {
675
+ open: s(h),
676
+ loading: P.value
677
+ }, () => [
678
+ P.value ? (c(), Re(s(qa), {
679
+ key: 0,
680
+ class: "hys-ui-icon-spin",
681
+ size: ee.value
682
+ }, null, 8, ["size"])) : (c(), Re(s(Pa), {
683
+ key: 1,
684
+ class: "hys-ui-select-chevron",
685
+ size: ee.value,
686
+ "aria-hidden": "true"
687
+ }, null, 8, ["size"]))
688
+ ], !0)
689
+ ])) : L("", !0)
690
+ ], 16, Za),
691
+ d.clearable && g.value.length && !s(m) && !d.readonly ? (c(), v("button", {
692
+ key: 0,
693
+ type: "button",
694
+ class: "hys-ui-select-clear",
695
+ "aria-label": "清空选择",
696
+ onClick: Ae(Sa, ["stop"])
697
+ }, [
698
+ x(e.$slots, "clear-icon", {}, () => [
699
+ Oe(s(fa), {
700
+ size: ee.value - 2
701
+ }, null, 8, ["size"])
702
+ ], !0)
703
+ ])) : L("", !0),
704
+ d.name ? (c(!0), v(le, { key: 1 }, Pe(g.value, (t, y) => (c(), v("input", {
705
+ key: y,
706
+ type: "hidden",
707
+ name: d.name,
708
+ value: String(typeof t == "object" ? s(Ua)(t, d.valueKey) ?? "" : t),
709
+ disabled: s(m)
710
+ }, null, 8, it))), 128)) : L("", !0),
711
+ (c(), Re(Ka, {
712
+ to: d.appendTo === !1 ? "body" : d.appendTo,
713
+ disabled: d.appendTo === !1
714
+ }, [
715
+ s(h) ? (c(), v("div", qe({
140
716
  key: 0,
141
- ref_key: "searchInput",
142
- ref: N,
143
- "onUpdate:modelValue": l[0] || (l[0] = (a) => y.value = a),
144
- class: "hys-ui-select-search",
145
- placeholder: "搜索选项…",
146
- "aria-label": "搜索选项",
147
- "aria-controls": i(f),
148
- "aria-activedescendant": i(f) + "-" + n.value
149
- }, null, 8, de)), [
150
- [_, y.value]
151
- ]) : g("", !0),
152
- H("div", {
153
- id: i(f),
154
- role: "listbox",
155
- "aria-multiselectable": C.value || void 0
156
- }, [
157
- u.loading ? (s(), o("p", ve, [
158
- k(e.$slots, "loading", {}, () => [
159
- l[1] || (l[1] = z("加载中…", -1))
160
- ], !0)
161
- ])) : (s(), o(A, { key: 1 }, [
162
- (s(!0), o(A, null, F(c.value, (a, r) => (s(), o("button", {
163
- id: i(f) + "-" + r,
164
- key: a.value,
165
- type: "button",
166
- role: "option",
167
- class: ee(["hys-ui-select-option", { "hys-ui-selected": d.value.includes(a.value), "hys-ui-active": n.value === r && !a.disabled }]),
168
- "data-active": n.value === r,
169
- "aria-selected": d.value.includes(a.value),
170
- disabled: a.disabled,
171
- onPointerenter: (D) => !a.disabled && (n.value = r),
172
- onClick: (D) => S(r)
173
- }, [
174
- k(e.$slots, "option", {
175
- option: a,
176
- selected: d.value.includes(a.value)
717
+ ref_key: "panel",
718
+ ref: H
719
+ }, s(De), {
720
+ class: ["hys-ui-select-options hys-ui-floating-surface", ["hys-ui-select-popup-" + s(B), d.popupClass]],
721
+ "data-size": s(B),
722
+ "data-placement": s(ka),
723
+ style: Ca.value,
724
+ onKeydown: ua,
725
+ onFocusin: sa,
726
+ onFocusout: na
727
+ }), [
728
+ e.$slots.header ? (c(), v("div", st, [
729
+ x(e.$slots, "header", {
730
+ query: k.value,
731
+ selected: M.value,
732
+ close: () => s(V)()
733
+ }, void 0, !0)
734
+ ])) : L("", !0),
735
+ ue.value ? (c(), v("input", {
736
+ key: 1,
737
+ ref_key: "searchInput",
738
+ ref: Z,
739
+ value: be.value,
740
+ class: "hys-ui-select-search",
741
+ placeholder: "搜索选项…",
742
+ "aria-label": "搜索选项",
743
+ "aria-controls": s(oe),
744
+ "aria-activedescendant": _e.value,
745
+ "aria-autocomplete": "list",
746
+ onInput: ia,
747
+ onCompositionstart: a[2] || (a[2] = (t) => ge.value = !0),
748
+ onCompositionend: Ba
749
+ }, null, 40, nt)) : L("", !0),
750
+ U("div", {
751
+ id: s(oe),
752
+ ref_key: "viewport",
753
+ ref: A,
754
+ role: "listbox",
755
+ "aria-label": d.ariaLabel || s(Ne) || "可选项",
756
+ "aria-multiselectable": j.value || void 0,
757
+ "aria-busy": P.value || void 0,
758
+ class: "hys-ui-select-list",
759
+ style: he({
760
+ maxHeight: "min(" + ne.value + "px, 45dvh)"
761
+ }),
762
+ onScroll: Aa
763
+ }, [
764
+ P.value ? (c(), v("p", ct, [
765
+ x(e.$slots, "loading", {}, () => [
766
+ J(Q(d.loadingText), 1)
767
+ ], !0)
768
+ ])) : ie.value ? (c(), v("div", dt, [
769
+ x(e.$slots, "error", {
770
+ error: ie.value,
771
+ retry: We
177
772
  }, () => [
178
- z(L(a.label), 1)
179
- ], !0),
180
- d.value.includes(a.value) ? (s(), E(i(se), {
181
- key: 0,
182
- size: 15,
183
- "aria-hidden": "true"
184
- })) : g("", !0)
185
- ], 42, ye))), 128)),
186
- c.value.length ? g("", !0) : (s(), o("p", fe, [
187
- k(e.$slots, "empty", {}, () => [
188
- z(L(u.emptyText), 1)
773
+ a[3] || (a[3] = J("加载失败,", -1)),
774
+ U("button", {
775
+ type: "button",
776
+ class: "hys-ui-select-retry",
777
+ onClick: We
778
+ }, " 重试 ")
779
+ ], !0)
780
+ ])) : T.value.length ? (c(), v("div", {
781
+ key: 2,
782
+ style: he(
783
+ O.value ? {
784
+ height: T.value.length * E.value + "px",
785
+ position: "relative"
786
+ } : void 0
787
+ ),
788
+ role: "presentation"
789
+ }, [
790
+ U("div", {
791
+ style: he(
792
+ O.value ? {
793
+ position: "absolute",
794
+ top: 0,
795
+ left: 0,
796
+ right: 0,
797
+ transform: "translateY(" + Ee.value * E.value + "px)"
798
+ } : void 0
799
+ ),
800
+ role: "presentation"
801
+ }, [
802
+ (c(!0), v(le, null, Pe(Ze.value, (t) => (c(), v(le, {
803
+ key: t.key
804
+ }, [
805
+ t.option ? (c(), v("button", {
806
+ key: 1,
807
+ id: s(oe) + "-" + t.index,
808
+ type: "button",
809
+ role: "option",
810
+ tabindex: "-1",
811
+ class: va(["hys-ui-select-option", {
812
+ "hys-ui-selected": W.value.has(
813
+ s(n)(t.option.value)
814
+ ),
815
+ "hys-ui-active": S.value === t.key && !X(t.option),
816
+ "hys-ui-select-created": t.created
817
+ }]),
818
+ style: he(
819
+ O.value ? {
820
+ height: "calc(var(--hys-ui-select-stride) - var(--hys-ui-select-option-gap))",
821
+ minHeight: 0
822
+ } : void 0
823
+ ),
824
+ "data-active": S.value === t.key,
825
+ "aria-label": t.created ? "创建 " + t.option.label : t.option.label,
826
+ "aria-description": t.group,
827
+ "aria-selected": W.value.has(s(n)(t.option.value)),
828
+ "aria-setsize": ma.value,
829
+ "aria-posinset": t.index + 1,
830
+ disabled: X(t.option),
831
+ onPointerenter: (y) => !X(t.option) && (S.value = t.key),
832
+ onClick: (y) => la(t)
833
+ }, [
834
+ U("span", {
835
+ class: "hys-ui-select-option-label",
836
+ title: t.option.label
837
+ }, [
838
+ x(e.$slots, "option", {
839
+ option: t.option,
840
+ selected: W.value.has(s(n)(t.option.value)),
841
+ created: !!t.created
842
+ }, () => [
843
+ t.created ? (c(), v("span", pt, [
844
+ Oe(s(Ra), { size: ee.value }, null, 8, ["size"]),
845
+ J("创建 " + Q(t.option.label), 1)
846
+ ])) : (c(), v(le, { key: 1 }, [
847
+ J(Q(t.option.label), 1)
848
+ ], 64))
849
+ ], !0)
850
+ ], 8, ft),
851
+ d.showCheckmark && W.value.has(s(n)(t.option.value)) ? x(e.$slots, "selected-icon", {
852
+ option: t.option
853
+ }, () => [
854
+ Oe(s(Da), {
855
+ size: ee.value - 1,
856
+ "aria-hidden": "true"
857
+ }, null, 8, ["size"])
858
+ ], !0, 0) : L("", !0)
859
+ ], 46, vt)) : (c(), v("div", {
860
+ key: 0,
861
+ class: "hys-ui-select-group",
862
+ style: he(
863
+ O.value ? { height: E.value + "px" } : void 0
864
+ ),
865
+ role: "presentation"
866
+ }, [
867
+ x(e.$slots, "group", {
868
+ label: t.group
869
+ }, () => [
870
+ J(Q(t.group), 1)
871
+ ], !0)
872
+ ], 4))
873
+ ], 64))), 128))
874
+ ], 4)
875
+ ], 4)) : (c(), v("p", ht, [
876
+ x(e.$slots, "empty", { query: k.value }, () => [
877
+ J(Q(k.value ? d.noMatchText : d.emptyText), 1)
189
878
  ], !0)
190
879
  ]))
191
- ], 64))
192
- ], 8, ce),
193
- k(e.$slots, "footer", {}, void 0, !0)
194
- ], 16)) : g("", !0)
195
- ]))
196
- ], 16));
880
+ ], 44, rt),
881
+ e.$slots.footer ? (c(), v("div", yt, [
882
+ x(e.$slots, "footer", {
883
+ query: k.value,
884
+ selected: M.value,
885
+ close: () => s(V)()
886
+ }, void 0, !0)
887
+ ])) : L("", !0)
888
+ ], 16, ut)) : L("", !0)
889
+ ], 8, ["to", "disabled"]))
890
+ ], 16);
891
+ };
197
892
  }
198
893
  });
199
894
  export {
200
- ke as default
895
+ Ct as default
201
896
  };