hys-ui 0.2.0 → 0.4.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 (261) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +68 -59
  3. package/dist/components/HysAlert/HysAlert.vue.js +5 -54
  4. package/dist/components/HysAlert/HysAlert2.vue.js +159 -2
  5. package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +5 -41
  6. package/dist/components/HysAnimatedNumber/HysAnimatedNumber2.vue.js +146 -2
  7. package/dist/components/HysAutocomplete/HysAutocomplete.vue.js +2 -2
  8. package/dist/components/HysAutocomplete/HysAutocomplete2.vue.js +285 -273
  9. package/dist/components/HysAvatarGroup/HysAvatarGroup.vue.js +1 -1
  10. package/dist/components/HysAvatarGroup/HysAvatarGroup2.vue.js +102 -98
  11. package/dist/components/HysBreadcrumb/HysBreadcrumb.vue.js +1 -1
  12. package/dist/components/HysBreadcrumb/HysBreadcrumb2.vue.js +273 -59
  13. package/dist/components/HysButton/HysButton.vue.js +2 -2
  14. package/dist/components/HysButton/HysButton2.vue.js +227 -60
  15. package/dist/components/HysButtonGroup/HysButtonGroup.vue.js +7 -0
  16. package/dist/components/HysButtonGroup/HysButtonGroup2.vue.js +51 -0
  17. package/dist/components/HysCalendar/HysCalendar.vue.js +3 -3
  18. package/dist/components/HysCalendar/HysCalendar2.vue.js +237 -225
  19. package/dist/components/HysCascader/HysCascader.vue.js +2 -2
  20. package/dist/components/HysCascader/HysCascader2.vue.js +337 -324
  21. package/dist/components/HysColorPicker/HysColorPanel.vue.js +7 -0
  22. package/dist/components/HysColorPicker/HysColorPanel2.vue.js +238 -0
  23. package/dist/components/HysColorPicker/HysColorPicker.vue.js +2 -2
  24. package/dist/components/HysColorPicker/HysColorPicker2.vue.js +239 -217
  25. package/dist/components/HysCommandPalette/HysCommandPalette.vue.js +90 -76
  26. package/dist/components/HysContextMenu/HysContextMenu.vue.js +5 -89
  27. package/dist/components/HysContextMenu/HysContextMenu2.vue.js +247 -2
  28. package/dist/components/HysContextMenu/HysMenuPanel.vue.js +7 -0
  29. package/dist/components/HysContextMenu/HysMenuPanel2.vue.js +208 -0
  30. package/dist/components/HysContextMenu/HysMenuSlot.js +10 -0
  31. package/dist/components/HysDataGrid/HysDataGrid.vue.js +1 -1
  32. package/dist/components/HysDataGrid/HysDataGrid2.vue.js +1008 -559
  33. package/dist/components/HysDatePicker/HysDatePicker.vue.js +2 -0
  34. package/dist/components/HysDatePicker/HysDatePickerControl.vue.js +2 -2
  35. package/dist/components/HysDatePicker/HysDatePickerControl2.vue.js +539 -526
  36. package/dist/components/HysDateRangePicker/HysDateRangePicker.vue.js +5 -3
  37. package/dist/components/HysDrawer/HysDrawer.vue.js +1 -1
  38. package/dist/components/HysDrawer/HysDrawer2.vue.js +434 -84
  39. package/dist/components/HysEmpty/HysEmpty.vue.js +5 -41
  40. package/dist/components/HysEmpty/HysEmpty2.vue.js +181 -2
  41. package/dist/components/HysFormItem/HysFormItem.vue.js +2 -2
  42. package/dist/components/HysFormItem/HysFormItem2.vue.js +171 -164
  43. package/dist/components/HysGantt/HysGantt.vue.js +1 -1
  44. package/dist/components/HysGantt/HysGantt2.vue.js +810 -795
  45. package/dist/components/HysMention/HysMention.vue.js +1 -1
  46. package/dist/components/HysMention/HysMention2.vue.js +1092 -142
  47. package/dist/components/HysModal/HysModal.vue.js +2 -2
  48. package/dist/components/HysModal/HysModal2.vue.js +491 -85
  49. package/dist/components/HysPagination/HysPagination.vue.js +2 -2
  50. package/dist/components/HysPagination/HysPagination2.vue.js +243 -180
  51. package/dist/components/HysPopover/HysPopover.vue.js +5 -91
  52. package/dist/components/HysPopover/HysPopover2.vue.js +120 -2
  53. package/dist/components/HysProgress/HysProgress.vue.js +2 -2
  54. package/dist/components/HysProgress/HysProgress2.vue.js +319 -52
  55. package/dist/components/HysSearch/HysSearch.vue.js +5 -82
  56. package/dist/components/HysSearch/HysSearch2.vue.js +176 -2
  57. package/dist/components/HysSelect/HysSelect.vue.js +2 -2
  58. package/dist/components/HysSelect/HysSelect2.vue.js +755 -590
  59. package/dist/components/HysSlider/HysSlider.vue.js +2 -2
  60. package/dist/components/HysSlider/HysSlider2.vue.js +192 -188
  61. package/dist/components/HysSlider/SliderTooltip.vue.js +2 -2
  62. package/dist/components/HysSlider/SliderTooltip2.vue.js +103 -89
  63. package/dist/components/HysSplitPane/HysSplitPane.vue.js +315 -58
  64. package/dist/components/HysSplitPane/HysSplitPane3.vue.js +5 -0
  65. package/dist/components/HysTable/HysTable.vue.js +2 -2
  66. package/dist/components/HysTable/HysTable2.vue.js +1416 -1127
  67. package/dist/components/HysTagInput/HysTagInput.vue.js +5 -82
  68. package/dist/components/HysTagInput/HysTagInput2.vue.js +396 -2
  69. package/dist/components/HysTimeline/HysTimeline.vue.js +2 -2
  70. package/dist/components/HysTimeline/HysTimeline2.vue.js +243 -24
  71. package/dist/components/HysTooltip/HysTooltip.vue.js +5 -64
  72. package/dist/components/HysTooltip/HysTooltip2.vue.js +110 -2
  73. package/dist/components/HysTour/HysTour.vue.js +291 -63
  74. package/dist/components/HysTour/HysTour3.vue.js +5 -0
  75. package/dist/components/HysTransfer/HysTransfer.vue.js +2 -2
  76. package/dist/components/HysTransfer/HysTransfer2.vue.js +237 -207
  77. package/dist/components/HysTransfer/HysTransferPanel.vue.js +1 -1
  78. package/dist/components/HysTransfer/HysTransferPanel2.vue.js +320 -271
  79. package/dist/components/HysTree/HysTree.vue.js +2 -2
  80. package/dist/components/HysTree/HysTree2.vue.js +195 -184
  81. package/dist/components/HysTreeSelect/HysTreeSelect.vue.js +4 -4
  82. package/dist/components/HysTreeSelect/HysTreeSelect2.vue.js +389 -377
  83. package/dist/components/HysUpload/HysUpload.vue.js +2 -2
  84. package/dist/components/HysUpload/HysUpload2.vue.js +459 -125
  85. package/dist/components/HysVirtualTable/HysVirtualTable.vue.js +5 -94
  86. package/dist/components/HysVirtualTable/HysVirtualTable2.vue.js +656 -2
  87. package/dist/composables/buttonGroup.js +12 -0
  88. package/dist/composables/color.js +97 -0
  89. package/dist/composables/dataGrid.js +68 -0
  90. package/dist/composables/drawer.js +17 -0
  91. package/dist/composables/feedback.js +14 -0
  92. package/dist/composables/floatingPosition.js +18 -0
  93. package/dist/composables/mentionDocument.js +79 -0
  94. package/dist/composables/mentionEditor.js +58 -0
  95. package/dist/composables/menu.js +96 -0
  96. package/dist/composables/modal.js +14 -0
  97. package/dist/composables/overlayManager.js +48 -18
  98. package/dist/composables/progress.js +94 -0
  99. package/dist/composables/selectOptions.js +44 -38
  100. package/dist/composables/splitPaneSizes.js +58 -0
  101. package/dist/composables/table.js +128 -105
  102. package/dist/composables/tagInput.js +16 -0
  103. package/dist/composables/timeline.js +19 -0
  104. package/dist/composables/transfer.js +19 -17
  105. package/dist/composables/upload.js +55 -0
  106. package/dist/composables/uploadRequest.js +58 -0
  107. package/dist/composables/useAlert.js +124 -0
  108. package/dist/composables/useColorPicker.js +402 -0
  109. package/dist/composables/useContextMenu.js +514 -0
  110. package/dist/composables/useDataGridRemote.js +67 -0
  111. package/dist/composables/useDialog.js +86 -43
  112. package/dist/composables/useDrawerPush.js +33 -0
  113. package/dist/composables/useDrawerResize.js +221 -0
  114. package/dist/composables/useFloating.js +118 -80
  115. package/dist/composables/useHysModal.js +185 -0
  116. package/dist/composables/useMentionCaret.js +81 -0
  117. package/dist/composables/useMentionList.js +81 -0
  118. package/dist/composables/useMentionModel.js +90 -0
  119. package/dist/composables/useMentionOptions.js +421 -0
  120. package/dist/composables/useModal.js +295 -0
  121. package/dist/composables/useModalInteraction.js +394 -0
  122. package/dist/composables/usePopupSurface.js +458 -0
  123. package/dist/composables/useSplitPaneDrag.js +52 -0
  124. package/dist/composables/useSplitPaneStorage.js +38 -0
  125. package/dist/composables/useTable.js +344 -312
  126. package/dist/composables/useTableSticky.js +79 -0
  127. package/dist/composables/useTagInput.js +313 -0
  128. package/dist/composables/useTourLayout.js +129 -0
  129. package/dist/composables/useTransferMotion.js +185 -0
  130. package/dist/composables/useUpload.js +472 -0
  131. package/dist/composables/useUploadModel.js +65 -0
  132. package/dist/composables/useUploadRequests.js +266 -0
  133. package/dist/composables/useVirtualTableLayout.js +277 -0
  134. package/dist/composables/virtualTable.js +43 -0
  135. package/dist/config.js +11 -11
  136. package/dist/index.js +175 -153
  137. package/dist/internal/MultiSplitPane.vue.js +305 -0
  138. package/dist/internal/MultiSplitPane2.vue.js +4 -0
  139. package/dist/internal/PopupReference.js +39 -0
  140. package/dist/internal/PopupSurfacePanel.vue.js +7 -0
  141. package/dist/internal/PopupSurfacePanel2.vue.js +92 -0
  142. package/dist/motion/PopupMotion.js +105 -0
  143. package/dist/motion/popup.js +10 -0
  144. package/dist/style.css +1 -1
  145. package/dist/types/components/HysAlert/HysAlert.vue.d.ts +32 -22
  146. package/dist/types/components/HysAnimatedNumber/HysAnimatedNumber.vue.d.ts +61 -7
  147. package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +7 -7
  148. package/dist/types/components/HysAvatarGroup/HysAvatarGroup.vue.d.ts +6 -1
  149. package/dist/types/components/HysBadge/HysBadge.vue.d.ts +3 -3
  150. package/dist/types/components/HysBreadcrumb/HysBreadcrumb.vue.d.ts +54 -31
  151. package/dist/types/components/HysButton/HysButton.vue.d.ts +82 -22
  152. package/dist/types/components/HysButtonGroup/HysButtonGroup.vue.d.ts +30 -0
  153. package/dist/types/components/HysCalendar/HysCalendar.vue.d.ts +3 -2
  154. package/dist/types/components/HysCascader/HysCascader.vue.d.ts +7 -7
  155. package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +2 -2
  156. package/dist/types/components/HysColorPicker/HysColorPanel.vue.d.ts +58 -0
  157. package/dist/types/components/HysColorPicker/HysColorPicker.vue.d.ts +63 -10
  158. package/dist/types/components/HysCommandPalette/HysCommandPalette.vue.d.ts +2 -1
  159. package/dist/types/components/HysContextMenu/HysContextMenu.vue.d.ts +50 -34
  160. package/dist/types/components/HysContextMenu/HysMenuPanel.vue.d.ts +79 -0
  161. package/dist/types/components/HysContextMenu/HysMenuSlot.d.ts +8 -0
  162. package/dist/types/components/HysDataGrid/HysDataGrid.vue.d.ts +65 -118
  163. package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +3 -3
  164. package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +92 -35
  165. package/dist/types/components/HysEmpty/HysEmpty.vue.d.ts +24 -20
  166. package/dist/types/components/HysFileManager/HysFileManager.vue.d.ts +2 -2
  167. package/dist/types/components/HysGantt/HysGantt.vue.d.ts +2 -1
  168. package/dist/types/components/HysMention/HysMention.vue.d.ts +91 -39
  169. package/dist/types/components/HysModal/HysModal.vue.d.ts +111 -34
  170. package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +2 -2
  171. package/dist/types/components/HysPagination/HysPagination.vue.d.ts +55 -4
  172. package/dist/types/components/HysPopover/HysPopover.vue.d.ts +41 -29
  173. package/dist/types/components/HysProgress/HysProgress.vue.d.ts +18 -24
  174. package/dist/types/components/HysRating/HysRating.vue.d.ts +1 -1
  175. package/dist/types/components/HysResizablePanel/HysResizablePanel.vue.d.ts +2 -2
  176. package/dist/types/components/HysSearch/HysSearch.vue.d.ts +45 -7
  177. package/dist/types/components/HysSelect/HysSelect.vue.d.ts +19 -5
  178. package/dist/types/components/HysSlider/HysSlider.vue.d.ts +5 -4
  179. package/dist/types/components/HysSlider/SliderTooltip.vue.d.ts +3 -1
  180. package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +125 -14
  181. package/dist/types/components/HysSteps/HysSteps.vue.d.ts +1 -1
  182. package/dist/types/components/HysTable/HysTable.vue.d.ts +1742 -5
  183. package/dist/types/components/HysTabs/HysTabs.vue.d.ts +2 -2
  184. package/dist/types/components/HysTagInput/HysTagInput.vue.d.ts +47 -25
  185. package/dist/types/components/HysTimeline/HysTimeline.vue.d.ts +19 -32
  186. package/dist/types/components/HysTooltip/HysTooltip.vue.d.ts +39 -19
  187. package/dist/types/components/HysTour/HysTour.vue.d.ts +46 -8
  188. package/dist/types/components/HysTransfer/HysTransfer.vue.d.ts +2 -2
  189. package/dist/types/components/HysTransfer/HysTransferPanel.vue.d.ts +5 -3
  190. package/dist/types/components/HysTree/HysTree.vue.d.ts +2 -2
  191. package/dist/types/components/HysUpload/HysUpload.vue.d.ts +55 -67
  192. package/dist/types/components/HysVirtualTable/HysVirtualTable.vue.d.ts +71 -40
  193. package/dist/types/composables/autocomplete.d.ts +3 -0
  194. package/dist/types/composables/avatar.d.ts +3 -0
  195. package/dist/types/composables/buttonGroup.d.ts +9 -0
  196. package/dist/types/composables/cascader.d.ts +3 -0
  197. package/dist/types/composables/color.d.ts +97 -0
  198. package/dist/types/composables/dataGrid.d.ts +100 -0
  199. package/dist/types/composables/datePicker.d.ts +3 -0
  200. package/dist/types/composables/drawer.d.ts +102 -0
  201. package/dist/types/composables/feedback.d.ts +98 -0
  202. package/dist/types/composables/floatingPosition.d.ts +14 -0
  203. package/dist/types/composables/formContext.d.ts +2 -0
  204. package/dist/types/composables/mention.d.ts +284 -0
  205. package/dist/types/composables/mentionDocument.d.ts +15 -0
  206. package/dist/types/composables/mentionEditor.d.ts +7 -0
  207. package/dist/types/composables/menu.d.ts +183 -0
  208. package/dist/types/composables/modal.d.ts +185 -0
  209. package/dist/types/composables/overlayManager.d.ts +7 -3
  210. package/dist/types/composables/popupSurface.d.ts +83 -0
  211. package/dist/types/composables/progress.d.ts +92 -0
  212. package/dist/types/composables/selectOptions.d.ts +7 -0
  213. package/dist/types/composables/splitPaneSizes.d.ts +11 -0
  214. package/dist/types/composables/table.d.ts +119 -6
  215. package/dist/types/composables/tagInput.d.ts +96 -0
  216. package/dist/types/composables/timeline.d.ts +82 -0
  217. package/dist/types/composables/tour.d.ts +68 -0
  218. package/dist/types/composables/transfer.d.ts +7 -0
  219. package/dist/types/composables/tree.d.ts +3 -0
  220. package/dist/types/composables/treeSelect.d.ts +3 -0
  221. package/dist/types/composables/upload.d.ts +202 -0
  222. package/dist/types/composables/uploadRequest.d.ts +3 -0
  223. package/dist/types/composables/useAlert.d.ts +21 -0
  224. package/dist/types/composables/useCascader.d.ts +1 -1
  225. package/dist/types/composables/useColorPicker.d.ts +101 -0
  226. package/dist/types/composables/useContextMenu.d.ts +81 -0
  227. package/dist/types/composables/useDataGridRemote.d.ts +15 -0
  228. package/dist/types/composables/useDialog.d.ts +16 -3
  229. package/dist/types/composables/useDrawerPush.d.ts +6 -0
  230. package/dist/types/composables/useDrawerResize.d.ts +27 -0
  231. package/dist/types/composables/useFloating.d.ts +22 -3
  232. package/dist/types/composables/useHysModal.d.ts +44 -0
  233. package/dist/types/composables/useMentionCaret.d.ts +6 -0
  234. package/dist/types/composables/useMentionList.d.ts +23 -0
  235. package/dist/types/composables/useMentionModel.d.ts +14 -0
  236. package/dist/types/composables/useMentionOptions.d.ts +26 -0
  237. package/dist/types/composables/useModal.d.ts +62 -0
  238. package/dist/types/composables/useModalInteraction.d.ts +27 -0
  239. package/dist/types/composables/usePopupSurface.d.ts +3341 -0
  240. package/dist/types/composables/useSplitPaneDrag.d.ts +14 -0
  241. package/dist/types/composables/useSplitPaneStorage.d.ts +4 -0
  242. package/dist/types/composables/useTable.d.ts +7 -3
  243. package/dist/types/composables/useTableSticky.d.ts +22 -0
  244. package/dist/types/composables/useTagInput.d.ts +66 -0
  245. package/dist/types/composables/useTourLayout.d.ts +33 -0
  246. package/dist/types/composables/useTransferMotion.d.ts +36 -0
  247. package/dist/types/composables/useUpload.d.ts +94 -0
  248. package/dist/types/composables/useUploadModel.d.ts +14 -0
  249. package/dist/types/composables/useUploadRequests.d.ts +38 -0
  250. package/dist/types/composables/useVirtualTableLayout.d.ts +51 -0
  251. package/dist/types/composables/virtualTable.d.ts +126 -0
  252. package/dist/types/config.d.ts +1 -0
  253. package/dist/types/index.d.ts +53 -3
  254. package/dist/types/internal/MultiSplitPane.vue.d.ts +54 -0
  255. package/dist/types/internal/PopupReference.d.ts +18 -0
  256. package/dist/types/internal/PopupSurfacePanel.vue.d.ts +37 -0
  257. package/dist/types/motion/PopupMotion.d.ts +59 -0
  258. package/dist/types/motion/popup.d.ts +12 -0
  259. package/package.json +3 -2
  260. package/dist/components/HysSplitPane/HysSplitPane2.vue.js +0 -4
  261. package/dist/components/HysTour/HysTour2.vue.js +0 -4
@@ -0,0 +1,58 @@
1
+ import { uploadFailure as i } from "./upload.js";
2
+ function m(e) {
3
+ const r = new XMLHttpRequest(), l = new FormData();
4
+ for (const [t, a] of Object.entries(e.data))
5
+ for (const d of Array.isArray(a) ? a : [a])
6
+ d !== void 0 && l.append(
7
+ t,
8
+ d instanceof Blob ? d : d === null ? "" : String(d)
9
+ );
10
+ l.append(
11
+ e.name,
12
+ e.body,
13
+ e.body instanceof File && e.body !== e.file.raw ? e.body.name : e.file.name
14
+ );
15
+ let n = !1;
16
+ const s = () => {
17
+ e.signal.removeEventListener("abort", u), r.upload.onprogress = null, r.onload = r.onerror = r.ontimeout = r.onabort = null;
18
+ }, o = (t, a) => {
19
+ n || (n = !0, s(), !e.signal.aborted && (t ? e.onError(t) : e.onSuccess(a)));
20
+ }, c = (t, a) => Object.assign(i(t, a), {
21
+ status: r.status,
22
+ response: f(),
23
+ url: e.action,
24
+ method: e.method
25
+ });
26
+ function f() {
27
+ const t = r.responseText;
28
+ if (t)
29
+ try {
30
+ return JSON.parse(t);
31
+ } catch {
32
+ return t;
33
+ }
34
+ }
35
+ function u() {
36
+ n || (n = !0, s(), r.abort());
37
+ }
38
+ r.open(e.method, e.action, !0), r.withCredentials = e.withCredentials, r.timeout = e.timeout;
39
+ for (const [t, a] of Object.entries(e.headers))
40
+ r.setRequestHeader(t, a);
41
+ if (r.upload.onprogress = (t) => {
42
+ !n && !e.signal.aborted && t.lengthComputable && t.total > 0 && e.onProgress(t.loaded / t.total * 100);
43
+ }, r.onload = () => {
44
+ r.status >= 200 && r.status < 300 ? o(void 0, f()) : o(c("上传请求失败(" + r.status + ")", "http"));
45
+ }, r.onerror = () => o(c("网络连接失败", "network")), r.ontimeout = () => o(c("上传请求超时", "timeout")), r.onabort = () => {
46
+ n = !0, s();
47
+ }, e.signal.addEventListener("abort", u, { once: !0 }), e.signal.aborted)
48
+ return u(), u;
49
+ try {
50
+ r.send(l);
51
+ } catch (t) {
52
+ o(t);
53
+ }
54
+ return u;
55
+ }
56
+ export {
57
+ m as uploadRequest
58
+ };
@@ -0,0 +1,124 @@
1
+ import { useAttrs as W, ref as h, computed as y, watch as w, onMounted as z, onActivated as F, onDeactivated as G, onBeforeUnmount as I, nextTick as D } from "vue";
2
+ import { useHysRootAttrs as J } from "../config.js";
3
+ import { feedbackNumber as K } from "./feedback.js";
4
+ function Y(t, u) {
5
+ const o = W(), E = J(), P = h(), m = h(t.defaultVisible ?? !0), a = h(!0), s = h(!1), L = h(!1), i = y(
6
+ () => t.visible ?? t.modelValue ?? m.value
7
+ ), A = y(
8
+ () => t.tone ?? (t.banner ? "warning" : "info")
9
+ ), S = y(
10
+ () => !a.value || L.value || E.value["data-hys-motion"] === "off" || t.transition === "none" ? 0 : K(t.transitionDuration, 180, 0, 1500)
11
+ );
12
+ let l = 0, f, v, r, C = !1;
13
+ const g = /* @__PURE__ */ new WeakMap();
14
+ function c() {
15
+ l++, f = void 0, v == null || v.abort(), v = void 0, s.value = !1;
16
+ }
17
+ const k = () => L.value = !!(r != null && r.matches);
18
+ function R() {
19
+ var e;
20
+ C || !a.value || (r ?? (r = (e = window.matchMedia) == null ? void 0 : e.call(window, "(prefers-reduced-motion: reduce)")), k(), r == null || r.addEventListener("change", k), C = !0);
21
+ }
22
+ function V() {
23
+ c(), r == null || r.removeEventListener("change", k), C = !1;
24
+ }
25
+ function M(e) {
26
+ m.value = e, f = e, u("update:visible", e), u("update:modelValue", e);
27
+ }
28
+ async function q(e = "api", n) {
29
+ if (!a.value || !i.value || t.disabled || s.value)
30
+ return !1;
31
+ const d = ++l, b = new AbortController();
32
+ v = b, s.value = !0;
33
+ const B = { reason: e, event: n, signal: b.signal };
34
+ u("closeRequest", B);
35
+ try {
36
+ return d !== l || b.signal.aborted || t.beforeClose && await t.beforeClose(B) === !1 || d !== l || b.signal.aborted || !a.value || !i.value || t.disabled ? !1 : (M(!1), u("close"), await D(), d === l && a.value && !i.value);
37
+ } catch (x) {
38
+ return d === l && a.value && !b.signal.aborted && u(
39
+ "closeError",
40
+ x instanceof Error ? x : new Error(String(x))
41
+ ), !1;
42
+ } finally {
43
+ d === l && (f = void 0, s.value = !1, v = void 0);
44
+ }
45
+ }
46
+ async function j() {
47
+ if (!a.value || t.disabled) return !1;
48
+ c();
49
+ const e = l;
50
+ return i.value ? !0 : (M(!0), await D(), e === l && (f = void 0), e === l && a.value && i.value);
51
+ }
52
+ w(
53
+ () => [t.visible, t.modelValue],
54
+ () => {
55
+ f !== void 0 && i.value === f || c();
56
+ },
57
+ { flush: "sync" }
58
+ ), w(
59
+ i,
60
+ (e) => {
61
+ a.value && u("visibleChange", e);
62
+ },
63
+ { flush: "sync" }
64
+ ), w(
65
+ () => t.title,
66
+ () => {
67
+ c(), m.value = !0;
68
+ }
69
+ ), w(
70
+ () => [t.disabled, t.beforeClose],
71
+ () => c(),
72
+ { flush: "sync" }
73
+ );
74
+ function H(e) {
75
+ g.set(e, l);
76
+ const n = e;
77
+ n.style.setProperty(
78
+ "--hys-ui-alert-height",
79
+ n.getBoundingClientRect().height + "px"
80
+ ), n.setAttribute("aria-hidden", "true"), n.removeAttribute("role"), n.inert = !0;
81
+ }
82
+ function N(e) {
83
+ g.get(e) === l && a.value && !i.value && u("afterClose"), g.delete(e);
84
+ }
85
+ function T(e) {
86
+ const n = e;
87
+ n.style.removeProperty("--hys-ui-alert-height"), o["aria-hidden"] !== void 0 ? n.setAttribute("aria-hidden", String(o["aria-hidden"])) : n.removeAttribute("aria-hidden"), n.inert = o.inert === !0 || o.inert === "", n.setAttribute(
88
+ "role",
89
+ typeof o.role == "string" ? o.role : A.value === "danger" ? "alert" : "status"
90
+ ), g.delete(e);
91
+ }
92
+ z(R), F(() => {
93
+ a.value = !0, R();
94
+ }), G(() => {
95
+ a.value = !1, V();
96
+ }), I(() => {
97
+ a.value = !1, V();
98
+ });
99
+ const U = y(() => ({
100
+ tone: A.value,
101
+ visible: i.value,
102
+ closing: s.value,
103
+ disabled: !!t.disabled,
104
+ close: () => q()
105
+ }));
106
+ return {
107
+ skin: E,
108
+ element: P,
109
+ live: a,
110
+ visible: i,
111
+ tone: A,
112
+ duration: S,
113
+ closing: s,
114
+ scope: U,
115
+ close: q,
116
+ show: j,
117
+ beforeLeave: H,
118
+ afterLeave: N,
119
+ restore: T
120
+ };
121
+ }
122
+ export {
123
+ Y as useAlert
124
+ };
@@ -0,0 +1,402 @@
1
+ import { useAttrs as Re, inject as N, ref as A, useId as se, shallowRef as Ve, computed as b, watch as O, onMounted as He, onActivated as Oe, onDeactivated as Se, onBeforeUnmount as Ke, nextTick as J } from "vue";
2
+ import { fieldKey as Me, formKey as Fe, useHysControlState as ze } from "./formContext.js";
3
+ import { useChoiceModel as Ge, useChoiceNativeReset as Ue } from "./choiceModel.js";
4
+ import { useFloating as We } from "./useFloating.js";
5
+ import { overlayOwnerKey as je } from "./overlayManager.js";
6
+ import { formatColor as pe, colorCss as fe, parseColor as T, sameColor as Be, colorClamp as S } from "./color.js";
7
+ function _e(t, s) {
8
+ const ce = Re(), i = N(Me, void 0), k = N(Fe, void 0), G = N(je, void 0), E = ze(t), U = A(), W = A(), Q = A(), D = A(), u = A(!0), h = A(""), d = A({ h: 0, s: 0, v: 0, a: 1 }), y = A(!1), q = A(!1), ve = se(), de = se();
9
+ let C = 0, he = t.defaultValue ?? "", P = 0, K, j = 0, p = 0;
10
+ const f = Ve(), R = Ge(
11
+ t,
12
+ () => he,
13
+ Object.is,
14
+ () => {
15
+ C++, m(!1), v();
16
+ }
17
+ ), c = b(() => R.current.value ?? ""), g = b(() => E.disabled.value || !!t.readonly), Z = b(() => t.format ?? (t.showAlpha ? "rgb" : "hex")), L = b(
18
+ () => y.value ? pe(d.value, Z.value, !!t.showAlpha) : ""
19
+ ), me = b(() => fe(d.value)), V = b(
20
+ () => !!T(h.value) || !h.value.trim() && (!c.value || !!t.clearable)
21
+ ), M = b(
22
+ () => !Be(
23
+ y.value ? d.value : void 0,
24
+ T(c.value)
25
+ )
26
+ ), ye = b(
27
+ () => {
28
+ var e, a;
29
+ return t.error || !V.value || (e = i == null ? void 0 : i.invalid) != null && e.value ? "error" : t.status ?? ((a = i == null ? void 0 : i.status) == null ? void 0 : a.value);
30
+ }
31
+ ), r = We(W, D, {
32
+ get placement() {
33
+ return t.placement ?? "bottom-start";
34
+ },
35
+ get strategy() {
36
+ return t.appendTo === !1 || _.value !== document.body ? "absolute" : "fixed";
37
+ },
38
+ width: () => t.popupWidth ?? 288,
39
+ closeOnTab: !0,
40
+ requestOpen(e, a) {
41
+ return !e && a && f.value ? (m(!0), !1) : (s("update:open", e), t.open === void 0);
42
+ }
43
+ }), we = b(
44
+ () => u.value && (t.inline || r.open.value)
45
+ ), _ = b(() => {
46
+ const e = t.appendTo;
47
+ if (e === !1 || !e) return document.body;
48
+ if (e instanceof HTMLElement) return e;
49
+ try {
50
+ return document.querySelector(e) ?? document.body;
51
+ } catch {
52
+ return document.body;
53
+ }
54
+ }), be = [
55
+ "#3867f5",
56
+ "#8955ea",
57
+ "#ec4899",
58
+ "#ef4444",
59
+ "#f59e0b",
60
+ "#22a06b",
61
+ "#06b6d4",
62
+ "#172a4d",
63
+ "#ffffff",
64
+ "#000000"
65
+ ], ge = b(
66
+ () => (t.presets ?? be).flatMap((e, a) => {
67
+ const l = T(e);
68
+ return l ? [
69
+ {
70
+ value: e,
71
+ color: fe(l),
72
+ parsed: l,
73
+ key: a + ":" + e
74
+ }
75
+ ] : [];
76
+ })
77
+ );
78
+ function v() {
79
+ const e = T(c.value);
80
+ y.value = !!e, e && (d.value = { ...e }), h.value = c.value;
81
+ }
82
+ v();
83
+ function B(e) {
84
+ var a;
85
+ e === "change" && (k != null && k.model.value) && !p || t.validateEvent !== !1 && !(k != null && k.resetting.value) && ((a = i == null ? void 0 : i.validate) == null || a.call(i, e));
86
+ }
87
+ async function x(e = !1) {
88
+ if (!u.value || g.value) return !1;
89
+ const a = L.value, l = ++j, n = C;
90
+ if (!a && !t.clearable && c.value) return !1;
91
+ if (a === c.value)
92
+ return e && B("change"), !0;
93
+ f.value && (f.value.lastRequest = a);
94
+ const o = await R.commit(
95
+ a,
96
+ (w) => s("update:modelValue", w),
97
+ (w) => s("change", w)
98
+ );
99
+ return !u.value || l !== j || n !== C ? !1 : !o && !f.value ? (v(), !1) : (o && e && B("change"), o);
100
+ }
101
+ async function X(e) {
102
+ if (!u.value || g.value) return !1;
103
+ const a = T(e);
104
+ return a ? (d.value = { ...a }, y.value = !0, h.value = L.value, s("activeChange", L.value), t.immediate === !1 ? !0 : x(!0)) : !e.trim() && t.clearable ? F() : (s("invalid", e), !1);
105
+ }
106
+ async function Ce() {
107
+ if (!u.value || g.value) return !1;
108
+ const e = h.value.trim();
109
+ return e ? X(e) : t.clearable ? F() : (v(), !1);
110
+ }
111
+ function $(e, a = !1) {
112
+ !u.value || g.value || (d.value = e, y.value = !0, h.value = L.value, s("activeChange", L.value), t.immediate !== !1 && x(a));
113
+ }
114
+ async function ee() {
115
+ if (!u.value || g.value || !V.value)
116
+ return V.value || s("invalid", h.value), !1;
117
+ const e = T(h.value);
118
+ e ? (d.value = { ...e }, y.value = !0) : y.value = !1;
119
+ const a = await x(!0);
120
+ return a && (s("confirm", c.value), await z(!1)), a;
121
+ }
122
+ async function F() {
123
+ if (!u.value || g.value || !t.clearable) return !1;
124
+ C++, m(!1), y.value = !1, h.value = "";
125
+ const e = await x(!0);
126
+ return e && s("clear"), e;
127
+ }
128
+ function ae() {
129
+ u.value && (C++, m(!1), v(), s("cancel"), z(!1));
130
+ }
131
+ async function Y() {
132
+ var e, a;
133
+ return !u.value || E.disabled.value || (G == null ? void 0 : G.value) === !1 ? !1 : t.inline ? !0 : (await r.show(), await J(), r.open.value ? ((a = (e = D.value) == null ? void 0 : e.querySelector("[role=slider]")) == null || a.focus({ preventScroll: !0 }), !0) : !1);
134
+ }
135
+ async function z(e = !0) {
136
+ return t.inline ? !1 : (r.close(e), await J(), !r.open.value);
137
+ }
138
+ function te(e) {
139
+ var a;
140
+ if (u.value && !E.disabled.value) {
141
+ const l = t.inline ? (a = D.value) == null ? void 0 : a.querySelector('[role="slider"]') : Q.value ?? W.value;
142
+ l == null || l.focus(e);
143
+ }
144
+ }
145
+ function ke() {
146
+ const e = document.activeElement;
147
+ le(e) && (e == null || e.blur());
148
+ }
149
+ function le(e) {
150
+ var a, l;
151
+ return !!e && (!!((a = U.value) != null && a.contains(e)) || !!((l = D.value) != null && l.contains(e)));
152
+ }
153
+ function Ae(e) {
154
+ q.value || (q.value = !0, s("focus", e));
155
+ }
156
+ function Ee(e) {
157
+ J(() => {
158
+ !u.value || le(document.activeElement) || q.value && (q.value = !1, s("blur", e), B("blur"));
159
+ });
160
+ }
161
+ function ue(e, a) {
162
+ const l = f.value;
163
+ if (!l || g.value || !u.value) return;
164
+ const n = S((e - l.rect.left) / l.rect.width), o = { ...d.value };
165
+ l.kind === "palette" ? (o.s = n, o.v = 1 - S((a - l.rect.top) / l.rect.height)) : l.kind === "hue" ? o.h = n * 359 : o.a = n, !(["h", "s", "v", "a"].every(
166
+ (w) => Math.abs(
167
+ o[w] - d.value[w]
168
+ ) < 1e-7
169
+ ) && y.value) && $(o);
170
+ }
171
+ function ne() {
172
+ P && cancelAnimationFrame(P), P = 0;
173
+ const e = K;
174
+ K = void 0, e && ue(e.x, e.y);
175
+ }
176
+ function I() {
177
+ m(!1), v();
178
+ }
179
+ function Pe() {
180
+ document.addEventListener("keydown", re, !0), window.addEventListener("resize", I), window.addEventListener("scroll", I, !0), window.addEventListener("blur", I);
181
+ }
182
+ function ie() {
183
+ document.removeEventListener("keydown", re, !0), window.removeEventListener("resize", I), window.removeEventListener("scroll", I, !0), window.removeEventListener("blur", I);
184
+ }
185
+ function re(e) {
186
+ e.key === "Escape" && f.value && (e.preventDefault(), e.stopPropagation(), m(!0));
187
+ }
188
+ function Le(e, a) {
189
+ var H;
190
+ if (!u.value || g.value || e.button !== 0 || e.isPrimary === !1)
191
+ return;
192
+ const l = e.currentTarget, n = l.getBoundingClientRect();
193
+ if (!n.width || !n.height) return;
194
+ e.preventDefault(), m(!1), l.focus({ preventScroll: !0 });
195
+ const o = (H = i == null ? void 0 : i.deferChangeValidation) == null ? void 0 : H.call(i);
196
+ let w = !1;
197
+ o && p++, f.value = {
198
+ node: l,
199
+ id: e.pointerId,
200
+ kind: a,
201
+ rect: n,
202
+ value: c.value,
203
+ color: { ...d.value },
204
+ hasColor: y.value,
205
+ lastRequest: c.value,
206
+ releaseValidation() {
207
+ !w && o && (p--, o()), w = !0;
208
+ }
209
+ };
210
+ try {
211
+ l.setPointerCapture(e.pointerId);
212
+ } catch {
213
+ }
214
+ Pe(), ue(e.clientX, e.clientY);
215
+ }
216
+ function qe(e) {
217
+ !f.value || f.value.id !== e.pointerId || (K = { x: e.clientX, y: e.clientY }, P || (P = requestAnimationFrame(ne)));
218
+ }
219
+ async function xe(e) {
220
+ const a = f.value;
221
+ if (!(!a || a.id !== e.pointerId)) {
222
+ ne(), f.value = void 0, ie();
223
+ try {
224
+ a.node.hasPointerCapture(a.id) && a.node.releasePointerCapture(a.id);
225
+ } catch {
226
+ }
227
+ try {
228
+ t.immediate !== !1 && await x(!0);
229
+ } finally {
230
+ a.releaseValidation();
231
+ }
232
+ }
233
+ }
234
+ async function m(e) {
235
+ const a = f.value;
236
+ if (P && cancelAnimationFrame(P), P = 0, K = void 0, f.value = void 0, ie(), !!a) {
237
+ try {
238
+ a.node.hasPointerCapture(a.id) && a.node.releasePointerCapture(a.id);
239
+ } catch {
240
+ }
241
+ try {
242
+ e && u.value && !g.value && (d.value = { ...a.color }, y.value = a.hasColor, h.value = a.value, s("activeChange", L.value), t.immediate !== !1 && (c.value === a.lastRequest || c.value === a.value) && !await R.commit(
243
+ a.value,
244
+ (n) => s("update:modelValue", n),
245
+ (n) => s("change", n)
246
+ ) && c.value !== a.value && v());
247
+ } finally {
248
+ a.releaseValidation();
249
+ }
250
+ }
251
+ }
252
+ function Ie(e) {
253
+ var a;
254
+ ((a = f.value) == null ? void 0 : a.id) === e.pointerId && m(!0);
255
+ }
256
+ function Te(e, a) {
257
+ if (g.value || !u.value || e.isComposing || ![
258
+ "ArrowLeft",
259
+ "ArrowRight",
260
+ "ArrowUp",
261
+ "ArrowDown",
262
+ "Home",
263
+ "End",
264
+ "PageUp",
265
+ "PageDown"
266
+ ].includes(e.key))
267
+ return;
268
+ e.preventDefault();
269
+ const l = { ...d.value }, n = e.shiftKey || e.key.startsWith("Page") ? 10 : 1, o = ["ArrowLeft", "ArrowDown", "PageDown"].includes(e.key);
270
+ if (a === "palette")
271
+ e.key === "Home" ? l.s = 0 : e.key === "End" ? l.s = 1 : ["ArrowLeft", "ArrowRight"].includes(e.key) ? l.s = S(
272
+ l.s + (e.key === "ArrowLeft" ? -n : n) / 100
273
+ ) : l.v = S(l.v + (o ? -n : n) / 100);
274
+ else {
275
+ const w = a === "hue" ? "h" : "a", H = a === "hue" ? 359 : 1;
276
+ l[w] = e.key === "Home" ? 0 : e.key === "End" ? H : S(
277
+ l[w] + (o ? -n : n) * (a === "hue" ? 1 : 0.01),
278
+ 0,
279
+ H
280
+ );
281
+ }
282
+ $(l, !0);
283
+ }
284
+ O(
285
+ () => t.open,
286
+ async (e) => {
287
+ !u.value || t.inline || (e && !E.disabled.value ? await r.show(!0) : e === !1 && r.close(!1, !0));
288
+ },
289
+ { flush: "post" }
290
+ ), O(r.open, (e) => {
291
+ e ? (t.immediate !== !1 || !M.value && h.value === c.value) && v() : (C++, m(!1), v()), s("visibleChange", e);
292
+ }), O(
293
+ c,
294
+ () => {
295
+ !f.value && !M.value && v();
296
+ },
297
+ { flush: "post" }
298
+ ), O(
299
+ () => [
300
+ E.disabled.value,
301
+ t.readonly,
302
+ t.inline,
303
+ t.appendTo,
304
+ t.showAlpha,
305
+ t.format,
306
+ t.immediate,
307
+ t.placement,
308
+ t.popupWidth
309
+ ],
310
+ () => {
311
+ C++, m(!1), v(), E.disabled.value && r.close(!1, !0), t.inline ? r.close(!1, !0) : r.open.value && r.schedule();
312
+ },
313
+ { flush: "sync" }
314
+ ), Ue(
315
+ U,
316
+ () => {
317
+ C++, m(!1), R.reset(), v(), r.close(!1, !0);
318
+ },
319
+ void 0,
320
+ () => t.form
321
+ ), O(
322
+ () => k == null ? void 0 : k.resetting.value,
323
+ (e) => {
324
+ e && (C++, m(!1), R.reset(), v(), r.close(!1, !0));
325
+ },
326
+ { flush: "sync" }
327
+ );
328
+ function oe() {
329
+ u.value = !1, C++, j++, m(!1), r.close(!1, !0), q.value = !1;
330
+ }
331
+ He(() => {
332
+ t.autofocus && te(), t.inline || (t.open ? r.show(!0) : t.defaultOpen && t.open === void 0 && Y());
333
+ }), Oe(() => {
334
+ u.value = !0, v();
335
+ }), Se(oe), Ke(oe);
336
+ const De = b(() => ({
337
+ value: c.value,
338
+ draft: h.value,
339
+ color: { ...d.value },
340
+ disabled: E.disabled.value,
341
+ readonly: !!t.readonly,
342
+ valid: V.value,
343
+ dirty: M.value,
344
+ setColor: X,
345
+ confirm: ee,
346
+ cancel: ae,
347
+ clear: F,
348
+ show: Y,
349
+ hide: z
350
+ }));
351
+ return {
352
+ attrs: ce,
353
+ field: i,
354
+ control: E,
355
+ element: U,
356
+ trigger: W,
357
+ input: Q,
358
+ panel: D,
359
+ live: u,
360
+ draft: h,
361
+ working: d,
362
+ hasColor: y,
363
+ focused: q,
364
+ errorId: ve,
365
+ panelId: de,
366
+ value: c,
367
+ locked: g,
368
+ format: Z,
369
+ serialized: L,
370
+ css: me,
371
+ valid: V,
372
+ dirty: M,
373
+ status: ye,
374
+ floating: r,
375
+ open: we,
376
+ teleportTo: _,
377
+ presets: ge,
378
+ context: De,
379
+ gesture: f,
380
+ sync: v,
381
+ publish: x,
382
+ setColor: X,
383
+ commitText: Ce,
384
+ confirm: ee,
385
+ clear: F,
386
+ cancel: ae,
387
+ show: Y,
388
+ hide: z,
389
+ focus: te,
390
+ blur: ke,
391
+ focusIn: Ae,
392
+ focusOut: Ee,
393
+ start: Le,
394
+ move: qe,
395
+ end: xe,
396
+ pointerCancel: Ie,
397
+ keyboard: Te
398
+ };
399
+ }
400
+ export {
401
+ _e as useColorPicker
402
+ };