hys-ui 0.1.1 → 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 (225) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/README.md +3 -1
  3. package/dist/components/HysAccordion/HysAccordion.vue.js +1 -1
  4. package/dist/components/HysAccordion/HysAccordion2.vue.js +181 -47
  5. package/dist/components/HysAutocomplete/HysAutocomplete.vue.js +7 -0
  6. package/dist/components/HysAutocomplete/HysAutocomplete2.vue.js +627 -0
  7. package/dist/components/HysAvatar/HysAvatar.vue.js +5 -35
  8. package/dist/components/HysAvatar/HysAvatar2.vue.js +221 -2
  9. package/dist/components/HysAvatarGroup/HysAvatarGroup.vue.js +7 -0
  10. package/dist/components/HysAvatarGroup/HysAvatarGroup2.vue.js +252 -0
  11. package/dist/components/HysBadge/HysBadge.vue.js +2 -2
  12. package/dist/components/HysBadge/HysBadge2.vue.js +154 -27
  13. package/dist/components/HysBreadcrumb/HysBreadcrumb.vue.js +5 -38
  14. package/dist/components/HysBreadcrumb/HysBreadcrumb2.vue.js +74 -2
  15. package/dist/components/HysButton/HysButton.vue.js +2 -2
  16. package/dist/components/HysButton/HysButton2.vue.js +29 -28
  17. package/dist/components/HysCalendar/HysCalendar.vue.js +5 -92
  18. package/dist/components/HysCalendar/HysCalendar2.vue.js +803 -2
  19. package/dist/components/HysCard/HysCard.vue.js +2 -2
  20. package/dist/components/HysCard/HysCard2.vue.js +175 -42
  21. package/dist/components/HysCascader/HysCascader.vue.js +5 -194
  22. package/dist/components/HysCascader/HysCascader2.vue.js +760 -2
  23. package/dist/components/HysCascader/HysCascaderColumn.vue.js +7 -0
  24. package/dist/components/HysCascader/HysCascaderColumn2.vue.js +232 -0
  25. package/dist/components/HysCheckbox/HysCheckbox.vue.js +3 -3
  26. package/dist/components/HysCheckbox/HysCheckbox2.vue.js +180 -65
  27. package/dist/components/HysCheckboxGroup/HysCheckboxGroup.vue.js +7 -0
  28. package/dist/components/HysCheckboxGroup/HysCheckboxGroup2.vue.js +237 -0
  29. package/dist/components/HysColorPicker/HysColorPicker.vue.js +2 -2
  30. package/dist/components/HysColorPicker/HysColorPicker2.vue.js +107 -106
  31. package/dist/components/HysDataGrid/HysDataGrid.vue.js +1 -1
  32. package/dist/components/HysDataGrid/HysDataGrid2.vue.js +399 -392
  33. package/dist/components/HysDatePicker/HysDatePicker.vue.js +268 -139
  34. package/dist/components/HysDatePicker/HysDatePickerControl.vue.js +7 -0
  35. package/dist/components/HysDatePicker/HysDatePickerControl2.vue.js +807 -0
  36. package/dist/components/HysDatePicker/HysDatePickerPanel.vue.js +7 -0
  37. package/dist/components/HysDatePicker/HysDatePickerPanel2.vue.js +357 -0
  38. package/dist/components/HysDateRangePicker/HysDateRangePicker.vue.js +268 -158
  39. package/dist/components/HysDivider/HysDivider.vue.js +2 -2
  40. package/dist/components/HysDivider/HysDivider2.vue.js +33 -13
  41. package/dist/components/HysFileManager/HysFileManager.vue.js +3 -3
  42. package/dist/components/HysFileManager/HysFileManager2.vue.js +43 -42
  43. package/dist/components/HysForm/HysForm.vue.js +3 -3
  44. package/dist/components/HysForm/HysForm2.vue.js +578 -92
  45. package/dist/components/HysFormItem/HysFormItem.vue.js +5 -85
  46. package/dist/components/HysFormItem/HysFormItem2.vue.js +521 -2
  47. package/dist/components/HysGantt/HysGantt.vue.js +1 -1
  48. package/dist/components/HysGantt/HysGantt2.vue.js +1369 -272
  49. package/dist/components/HysInput/HysInput.vue.js +2 -2
  50. package/dist/components/HysInput/HysInput2.vue.js +467 -120
  51. package/dist/components/HysMention/HysMention.vue.js +2 -2
  52. package/dist/components/HysMention/HysMention2.vue.js +89 -88
  53. package/dist/components/HysNumberInput/HysNumberInput.vue.js +2 -2
  54. package/dist/components/HysNumberInput/HysNumberInput2.vue.js +561 -79
  55. package/dist/components/HysOrgTree/HysOrgTree.vue.js +29 -26
  56. package/dist/components/HysPagination/HysPagination.vue.js +1 -1
  57. package/dist/components/HysPagination/HysPagination2.vue.js +2 -0
  58. package/dist/components/HysPermissionMatrix/HysPermissionMatrix.vue.js +2 -2
  59. package/dist/components/HysPermissionMatrix/HysPermissionMatrix2.vue.js +52 -51
  60. package/dist/components/HysRadio/HysRadio.vue.js +7 -0
  61. package/dist/components/HysRadio/HysRadio2.vue.js +180 -0
  62. package/dist/components/HysRadioGroup/HysRadioGroup.vue.js +2 -2
  63. package/dist/components/HysRadioGroup/HysRadioGroup2.vue.js +190 -65
  64. package/dist/components/HysRating/HysRating.vue.js +1 -1
  65. package/dist/components/HysRating/HysRating2.vue.js +288 -68
  66. package/dist/components/HysRichTextEditor/HysRichTextEditor.vue.js +1 -1
  67. package/dist/components/HysRichTextEditor/HysRichTextEditor2.vue.js +70 -69
  68. package/dist/components/HysSearch/HysSearch.vue.js +37 -36
  69. package/dist/components/HysSegmented/HysSegmented.vue.js +5 -63
  70. package/dist/components/HysSegmented/HysSegmented2.vue.js +273 -2
  71. package/dist/components/HysSelect/HysSelect.vue.js +3 -2
  72. package/dist/components/HysSelect/HysSelect2.vue.js +859 -185
  73. package/dist/components/HysSkeleton/HysSkeleton.vue.js +2 -2
  74. package/dist/components/HysSkeleton/HysSkeleton2.vue.js +126 -29
  75. package/dist/components/HysSlider/HysSlider.vue.js +2 -2
  76. package/dist/components/HysSlider/HysSlider2.vue.js +532 -59
  77. package/dist/components/HysSlider/SliderTooltip.vue.js +7 -0
  78. package/dist/components/HysSlider/SliderTooltip2.vue.js +156 -0
  79. package/dist/components/HysSteps/HysSteps.vue.js +1 -1
  80. package/dist/components/HysSteps/HysSteps2.vue.js +110 -36
  81. package/dist/components/HysSwitch/HysSwitch.vue.js +2 -2
  82. package/dist/components/HysSwitch/HysSwitch2.vue.js +232 -50
  83. package/dist/components/HysTable/HysTable.vue.js +2 -2
  84. package/dist/components/HysTable/HysTable2.vue.js +1473 -88
  85. package/dist/components/HysTable/HysTableFilterOptions.vue.js +7 -0
  86. package/dist/components/HysTable/HysTableFilterOptions2.vue.js +133 -0
  87. package/dist/components/HysTabs/HysTabs.vue.js +2 -2
  88. package/dist/components/HysTabs/HysTabs2.vue.js +262 -68
  89. package/dist/components/HysTagInput/HysTagInput.vue.js +43 -42
  90. package/dist/components/HysTextarea/HysTextarea.vue.js +138 -77
  91. package/dist/components/HysTransfer/HysTransfer.vue.js +5 -223
  92. package/dist/components/HysTransfer/HysTransfer2.vue.js +416 -2
  93. package/dist/components/HysTransfer/HysTransferPanel.vue.js +7 -0
  94. package/dist/components/HysTransfer/HysTransferPanel2.vue.js +454 -0
  95. package/dist/components/HysTree/HysTree.vue.js +2 -3
  96. package/dist/components/HysTree/HysTree2.vue.js +641 -302
  97. package/dist/components/HysTreeSelect/HysTreeSelect.vue.js +5 -136
  98. package/dist/components/HysTreeSelect/HysTreeSelect2.vue.js +558 -2
  99. package/dist/components/HysTreeSelect/HysTreeSelectPanel.vue.js +7 -0
  100. package/dist/components/HysTreeSelect/HysTreeSelectPanel2.vue.js +323 -0
  101. package/dist/components/HysUpload/HysUpload.vue.js +2 -2
  102. package/dist/components/HysUpload/HysUpload2.vue.js +77 -76
  103. package/dist/composables/autocomplete.js +50 -0
  104. package/dist/composables/avatar.js +57 -0
  105. package/dist/composables/calendar.js +96 -0
  106. package/dist/composables/cascader.js +79 -0
  107. package/dist/composables/choice.js +38 -0
  108. package/dist/composables/choiceModel.js +67 -0
  109. package/dist/composables/datePicker.js +227 -0
  110. package/dist/composables/formContext.js +92 -7
  111. package/dist/composables/formLayout.js +57 -0
  112. package/dist/composables/formValidation.js +240 -0
  113. package/dist/composables/ganttConflicts.js +143 -0
  114. package/dist/composables/numberInput.js +91 -0
  115. package/dist/composables/rating.js +16 -0
  116. package/dist/composables/selectOptions.js +54 -0
  117. package/dist/composables/table.js +150 -0
  118. package/dist/composables/textInput.js +34 -0
  119. package/dist/composables/transfer.js +63 -0
  120. package/dist/composables/tree.js +118 -0
  121. package/dist/composables/treeSelect.js +71 -0
  122. package/dist/composables/useCascader.js +438 -0
  123. package/dist/composables/useDatePicker.js +425 -0
  124. package/dist/composables/useFloating.js +97 -51
  125. package/dist/composables/useGanttDependencies.js +306 -0
  126. package/dist/composables/useGanttHistory.js +157 -0
  127. package/dist/composables/useGanttLabelResize.js +100 -0
  128. package/dist/composables/useTable.js +474 -0
  129. package/dist/composables/useTextareaSize.js +72 -0
  130. package/dist/composables/useTransfer.js +257 -0
  131. package/dist/composables/useTree.js +439 -0
  132. package/dist/composables/useTreeSelect.js +361 -0
  133. package/dist/index.js +149 -139
  134. package/dist/style.css +1 -1
  135. package/dist/types/components/HysAccordion/HysAccordion.vue.d.ts +61 -22
  136. package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +201 -0
  137. package/dist/types/components/HysAvatar/HysAvatar.vue.d.ts +28 -15
  138. package/dist/types/components/HysAvatarGroup/HysAvatarGroup.vue.d.ts +99 -0
  139. package/dist/types/components/HysBadge/HysBadge.vue.d.ts +41 -4
  140. package/dist/types/components/HysBreadcrumb/HysBreadcrumb.vue.d.ts +38 -10
  141. package/dist/types/components/HysButton/HysButton.vue.d.ts +0 -1
  142. package/dist/types/components/HysCalendar/HysCalendar.vue.d.ts +119 -31
  143. package/dist/types/components/HysCard/HysCard.vue.d.ts +55 -7
  144. package/dist/types/components/HysCascader/HysCascader.vue.d.ts +129 -41
  145. package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +55 -0
  146. package/dist/types/components/HysCheckbox/HysCheckbox.vue.d.ts +50 -39
  147. package/dist/types/components/HysCheckboxGroup/HysCheckboxGroup.vue.d.ts +73 -0
  148. package/dist/types/components/HysDataGrid/HysDataGrid.vue.d.ts +1 -1
  149. package/dist/types/components/HysDatePicker/HysDatePicker.vue.d.ts +66 -14
  150. package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +90 -0
  151. package/dist/types/components/HysDatePicker/HysDatePickerPanel.vue.d.ts +93 -0
  152. package/dist/types/components/HysDateRangePicker/HysDateRangePicker.vue.d.ts +66 -14
  153. package/dist/types/components/HysDivider/HysDivider.vue.d.ts +8 -3
  154. package/dist/types/components/HysFileManager/HysFileManager.vue.d.ts +2 -2
  155. package/dist/types/components/HysForm/HysForm.vue.d.ts +110 -18
  156. package/dist/types/components/HysFormItem/HysFormItem.vue.d.ts +108 -2
  157. package/dist/types/components/HysGantt/HysGantt.vue.d.ts +82 -4
  158. package/dist/types/components/HysInput/HysInput.vue.d.ts +52 -29
  159. package/dist/types/components/HysMention/HysMention.vue.d.ts +2 -2
  160. package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +93 -35
  161. package/dist/types/components/HysOrgTree/HysOrgTree.vue.d.ts +1 -0
  162. package/dist/types/components/HysPagination/HysPagination.vue.d.ts +1 -1
  163. package/dist/types/components/HysPermissionMatrix/HysPermissionMatrix.vue.d.ts +2 -2
  164. package/dist/types/components/HysPopover/HysPopover.vue.d.ts +3 -3
  165. package/dist/types/components/HysProgress/HysProgress.vue.d.ts +1 -1
  166. package/dist/types/components/HysRadio/HysRadio.vue.d.ts +56 -0
  167. package/dist/types/components/HysRadioGroup/HysRadioGroup.vue.d.ts +34 -12
  168. package/dist/types/components/HysRating/HysRating.vue.d.ts +85 -5
  169. package/dist/types/components/HysRichTextEditor/HysRichTextEditor.vue.d.ts +4 -4
  170. package/dist/types/components/HysSearch/HysSearch.vue.d.ts +2 -2
  171. package/dist/types/components/HysSegmented/HysSegmented.vue.d.ts +64 -32
  172. package/dist/types/components/HysSelect/HysSelect.vue.d.ts +120 -20
  173. package/dist/types/components/HysSkeleton/HysSkeleton.vue.d.ts +30 -2
  174. package/dist/types/components/HysSlider/HysSlider.vue.d.ts +66 -9
  175. package/dist/types/components/HysSlider/SliderTooltip.vue.d.ts +22 -0
  176. package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +1 -1
  177. package/dist/types/components/HysSteps/HysSteps.vue.d.ts +64 -9
  178. package/dist/types/components/HysSwitch/HysSwitch.vue.d.ts +76 -17
  179. package/dist/types/components/HysTable/HysTable.vue.d.ts +206 -32
  180. package/dist/types/components/HysTable/HysTableFilterOptions.vue.d.ts +18 -0
  181. package/dist/types/components/HysTabs/HysTabs.vue.d.ts +76 -23
  182. package/dist/types/components/HysTagInput/HysTagInput.vue.d.ts +5 -5
  183. package/dist/types/components/HysTextarea/HysTextarea.vue.d.ts +44 -27
  184. package/dist/types/components/HysToast/HysToast.vue.d.ts +3 -3
  185. package/dist/types/components/HysTour/HysTour.vue.d.ts +2 -2
  186. package/dist/types/components/HysTransfer/HysTransfer.vue.d.ts +55 -40
  187. package/dist/types/components/HysTransfer/HysTransferPanel.vue.d.ts +105 -0
  188. package/dist/types/components/HysTree/HysTree.vue.d.ts +140 -73
  189. package/dist/types/components/HysTreeSelect/HysTreeSelect.vue.d.ts +102 -23
  190. package/dist/types/components/HysTreeSelect/HysTreeSelectPanel.vue.d.ts +56 -0
  191. package/dist/types/composables/autocomplete.d.ts +106 -0
  192. package/dist/types/composables/avatar.d.ts +70 -0
  193. package/dist/types/composables/calendar.d.ts +66 -0
  194. package/dist/types/composables/cascader.d.ts +192 -0
  195. package/dist/types/composables/choice.d.ts +110 -0
  196. package/dist/types/composables/choiceModel.d.ts +11 -0
  197. package/dist/types/composables/datePicker.d.ts +247 -0
  198. package/dist/types/composables/formContext.d.ts +133 -8
  199. package/dist/types/composables/formLayout.d.ts +11 -0
  200. package/dist/types/composables/formValidation.d.ts +13 -0
  201. package/dist/types/composables/gantt.d.ts +68 -0
  202. package/dist/types/composables/ganttConflicts.d.ts +30 -0
  203. package/dist/types/composables/numberInput.d.ts +45 -0
  204. package/dist/types/composables/rating.d.ts +18 -0
  205. package/dist/types/composables/segmented.d.ts +15 -0
  206. package/dist/types/composables/selectOptions.d.ts +44 -0
  207. package/dist/types/composables/slider.d.ts +21 -0
  208. package/dist/types/composables/table.d.ts +309 -0
  209. package/dist/types/composables/textInput.d.ts +76 -0
  210. package/dist/types/composables/transfer.d.ts +180 -0
  211. package/dist/types/composables/tree.d.ts +237 -0
  212. package/dist/types/composables/treeSelect.d.ts +167 -0
  213. package/dist/types/composables/useCascader.d.ts +162 -0
  214. package/dist/types/composables/useDatePicker.d.ts +79 -0
  215. package/dist/types/composables/useFloating.d.ts +8 -5
  216. package/dist/types/composables/useGanttDependencies.d.ts +83 -0
  217. package/dist/types/composables/useGanttHistory.d.ts +42 -0
  218. package/dist/types/composables/useGanttLabelResize.d.ts +23 -0
  219. package/dist/types/composables/useTable.d.ts +60 -0
  220. package/dist/types/composables/useTextareaSize.d.ts +3 -0
  221. package/dist/types/composables/useTransfer.d.ts +58 -0
  222. package/dist/types/composables/useTree.d.ts +77 -0
  223. package/dist/types/composables/useTreeSelect.d.ts +117 -0
  224. package/dist/types/index.d.ts +33 -7
  225. package/package.json +2 -1
@@ -1,222 +1,896 @@
1
- import { defineComponent as Q, ref as p, useId as Y, computed as I, watch as m, nextTick as q, openBlock as s, createElementBlock as n, mergeProps as F, unref as i, createElementVNode as L, renderSlot as C, Fragment as D, renderList as K, toDisplayString as z, createBlock as E, withModifiers as Z, createVNode as _, createCommentVNode as V, Teleport as ee, withDirectives as le, vModelText as ae, createTextVNode as H, normalizeClass as te } from "vue";
2
- import { LoaderCircle as ie, ChevronDown as se, X as oe, Check as ue } from "lucide-vue-next";
3
- import { useHysRootAttrs as re } from "../../config.js";
4
- import { useFloating as ne } from "../../composables/useFloating.js";
5
- const de = ["aria-label", "disabled", "aria-expanded", "aria-controls", "aria-activedescendant"], ce = { class: "hys-ui-select-label" }, ve = ["title"], ye = ["aria-controls", "aria-activedescendant"], fe = ["id", "aria-multiselectable"], he = {
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
- }, be = ["id", "data-active", "aria-selected", "disabled", "onPointerenter", "onClick"], pe = ["title"], me = {
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
- }, Ve = /* @__PURE__ */ Q({
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 },
24
- popupMatchWidth: { type: Boolean },
60
+ remoteMethod: {},
61
+ debounce: { default: 0 },
62
+ searchValue: {},
25
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 },
26
81
  emptyText: { default: "暂无选项" },
27
- 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: {}
28
91
  },
29
- emits: ["update:modelValue", "change", "clear", "search", "visibleChange"],
30
- setup(d, { expose: R, emit: X }) {
31
- const t = d, k = X, N = re(), g = p(), B = p(), P = p(), y = p(""), o = p(0), f = Y(), { open: v, style: j, show: G, close: h, update: J } = ne(g, B, { placement: "bottom-start", matchWidth: () => t.popupMatchWidth ? !0 : "min" }), x = I(() => t.multiple || Array.isArray(t.modelValue)), u = I(() => Array.isArray(t.modelValue) ? t.modelValue : [t.modelValue].filter(Boolean)), T = p(/* @__PURE__ */ new Map());
32
- m(() => [t.options, u.value], () => {
33
- const e = T.value, a = /* @__PURE__ */ new Map();
34
- for (const l of t.options) a.set(l.value, l);
35
- for (const l of u.value) !a.has(l) && e.has(l) && a.set(l, e.get(l));
36
- T.value = a;
37
- }, { immediate: !0, deep: !0 });
38
- const w = I(() => u.value.map((e) => T.value.get(e) ?? { value: e, label: e })), r = I(() => t.remote ? t.options : t.options.filter((e) => !y.value || (t.filterMethod ? t.filterMethod(y.value, e) : e.label.toLocaleLowerCase().includes(y.value.toLocaleLowerCase()))));
39
- function $(e) {
40
- k("update:modelValue", e), k("change", e);
41
- }
42
- function S(e) {
43
- const a = r.value[e];
44
- !a || a.disabled || t.disabled || t.loading || (x.value ? $(u.value.includes(a.value) ? u.value.filter((l) => l !== a.value) : [...u.value, a.value]) : ($(a.value), h(!0)));
45
- }
46
- function O() {
47
- var e;
48
- t.disabled || ($(x.value ? [] : ""), k("clear"), (e = g.value) == null || e.focus());
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();
49
108
  }
50
- async function M() {
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
+ };
148
+ }
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));
278
+ }
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");
337
+ return;
338
+ }
339
+ aa(a);
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) {
51
357
  var a;
52
- if (t.disabled) return;
53
- if (v.value) {
54
- h();
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)
55
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);
395
+ }
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
+ }
56
422
  }
57
- y.value = "";
58
- const e = r.value.findIndex((l) => u.value.includes(l.value) && !l.disabled);
59
- o.value = e >= 0 ? e : r.value.findIndex((l) => !l.disabled), await G(), t.filterable && ((a = P.value) == null || a.focus());
60
- }
61
- async function W(e) {
62
- var a, l, c;
63
- if (!(t.disabled || e.isComposing || e.keyCode === 229))
64
- if (["ArrowDown", "ArrowUp", "Home", "End"].includes(e.key)) {
65
- if (e.preventDefault(), !v.value) await M();
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");
66
448
  else {
67
- const b = e.key === "ArrowUp" ? -1 : 1;
68
- let A = e.key === "Home" ? -1 : e.key === "End" ? r.value.length : o.value;
69
- for (let U = 0; U < r.value.length; U++)
70
- if (A = (A + (e.key === "End" ? -1 : b) + r.value.length) % r.value.length, !r.value[A].disabled) {
71
- o.value = A;
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;
72
461
  break;
73
462
  }
74
463
  }
75
- await q(), (l = (a = B.value) == null ? void 0 : a.querySelector('[data-active="true"]')) == null || l.scrollIntoView({ block: "nearest" });
76
- } else e.key === "Enter" || e.key === " " && !t.filterable ? (e.preventDefault(), v.value ? S(o.value) : await M()) : e.key === "Tab" && h(!!((c = B.value) != null && c.contains(document.activeElement)));
77
- }
78
- return m(y, (e) => {
79
- o.value = r.value.findIndex((a) => !a.disabled), k("search", e);
80
- }), m(r, (e) => {
81
- (!e[o.value] || e[o.value].disabled) && (o.value = e.findIndex((a) => !a.disabled)), v.value && q(J);
82
- }, { deep: !0 }), m(() => t.popupMatchWidth, () => {
83
- v.value && (h(), M());
84
- }), m(v, (e) => k("visibleChange", e)), m(() => t.disabled, (e) => {
85
- e && h();
86
- }), R({ focus: () => {
87
- var e;
88
- return (e = g.value) == null ? void 0 : e.focus();
89
- }, 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(() => {
90
553
  var e;
91
- return (e = g.value) == null ? void 0 : e.blur();
92
- }, close: () => h() }), (e, a) => (s(), n("div", F(i(N), {
93
- class: ["hys-ui-select-wrap", "hys-ui-select-" + d.size]
94
- }), [
95
- L("button", {
96
- ref_key: "trigger",
97
- ref: g,
98
- type: "button",
99
- class: "hys-ui-select",
100
- "aria-label": d.ariaLabel,
101
- disabled: d.disabled,
102
- role: "combobox",
103
- "aria-haspopup": "listbox",
104
- "aria-expanded": i(v),
105
- "aria-controls": i(v) ? i(f) : void 0,
106
- "aria-activedescendant": i(v) ? i(f) + "-" + o.value : void 0,
107
- onClick: M,
108
- onKeydown: W
109
- }, [
110
- L("span", ce, [
111
- C(e.$slots, "label", { selected: w.value }, () => {
112
- var l, c;
113
- return [
114
- x.value && w.value.length ? (s(!0), n(D, { key: 0 }, K(w.value, (b) => (s(), n("span", {
115
- key: b.value,
116
- class: "hys-ui-select-tag"
117
- }, z(b.label), 1))), 128)) : (s(), n("span", {
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
622
+ }), [
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), {
118
683
  key: 1,
119
- class: "hys-ui-select-single-label",
120
- title: (l = w.value[0]) == null ? void 0 : l.label
121
- }, z(((c = w.value[0]) == null ? void 0 : c.label) || d.placeholder), 9, ve))
122
- ];
123
- }, !0)
124
- ]),
125
- d.loading ? (s(), E(i(ie), {
126
- key: 0,
127
- class: "hys-ui-icon-spin",
128
- size: 16
129
- })) : (s(), E(i(se), {
130
- key: 1,
131
- class: "hys-ui-select-chevron",
132
- size: 16,
133
- "aria-hidden": "true"
134
- }))
135
- ], 40, de),
136
- d.clearable && u.value.length && !d.disabled ? (s(), n("button", {
137
- key: 0,
138
- type: "button",
139
- class: "hys-ui-select-clear",
140
- "aria-label": "清空选择",
141
- onClick: Z(O, ["stop"])
142
- }, [
143
- _(i(oe), { size: 13 })
144
- ])) : V("", !0),
145
- (s(), E(ee, { to: "body" }, [
146
- i(v) ? (s(), n("div", F({
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", {
147
692
  key: 0,
148
- ref_key: "panel",
149
- ref: B
150
- }, i(N), {
151
- class: "hys-ui-select-options hys-ui-floating-surface",
152
- style: i(j),
153
- onKeydown: W
154
- }), [
155
- d.filterable ? le((s(), n("input", {
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({
156
716
  key: 0,
157
- ref_key: "searchInput",
158
- ref: P,
159
- "onUpdate:modelValue": a[0] || (a[0] = (l) => y.value = l),
160
- class: "hys-ui-select-search",
161
- placeholder: "搜索选项…",
162
- "aria-label": "搜索选项",
163
- "aria-controls": i(f),
164
- "aria-activedescendant": i(f) + "-" + o.value
165
- }, null, 8, ye)), [
166
- [ae, y.value]
167
- ]) : V("", !0),
168
- L("div", {
169
- id: i(f),
170
- role: "listbox",
171
- "aria-multiselectable": x.value || void 0
172
- }, [
173
- d.loading ? (s(), n("p", he, [
174
- C(e.$slots, "loading", {}, () => [
175
- a[1] || (a[1] = H("加载中…", -1))
176
- ], !0)
177
- ])) : (s(), n(D, { key: 1 }, [
178
- (s(!0), n(D, null, K(r.value, (l, c) => (s(), n("button", {
179
- id: i(f) + "-" + c,
180
- key: l.value,
181
- type: "button",
182
- role: "option",
183
- class: te(["hys-ui-select-option", { "hys-ui-selected": u.value.includes(l.value), "hys-ui-active": o.value === c && !l.disabled }]),
184
- "data-active": o.value === c,
185
- "aria-selected": u.value.includes(l.value),
186
- disabled: l.disabled,
187
- onPointerenter: (b) => !l.disabled && (o.value = c),
188
- onClick: (b) => S(c)
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
772
+ }, () => [
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"
189
789
  }, [
190
- L("span", {
191
- class: "hys-ui-select-option-label",
192
- title: l.label
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"
193
801
  }, [
194
- C(e.$slots, "option", {
195
- option: l,
196
- selected: u.value.includes(l.value)
197
- }, () => [
198
- H(z(l.label), 1)
199
- ], !0)
200
- ], 8, pe),
201
- u.value.includes(l.value) ? (s(), E(i(ue), {
202
- key: 0,
203
- size: 15,
204
- "aria-hidden": "true"
205
- })) : V("", !0)
206
- ], 42, be))), 128)),
207
- r.value.length ? V("", !0) : (s(), n("p", me, [
208
- C(e.$slots, "empty", {}, () => [
209
- H(z(d.emptyText), 1)
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)
210
878
  ], !0)
211
879
  ]))
212
- ], 64))
213
- ], 8, fe),
214
- C(e.$slots, "footer", {}, void 0, !0)
215
- ], 16)) : V("", !0)
216
- ]))
217
- ], 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
+ };
218
892
  }
219
893
  });
220
894
  export {
221
- Ve as default
895
+ Ct as default
222
896
  };