@w-run/wdesign-ui 0.0.0-stage → 1.1.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 (214) hide show
  1. package/README.md +255 -2
  2. package/dist/index.d.ts +1013 -0
  3. package/dist/parts/WdAffix.js +159 -0
  4. package/dist/parts/WdAiMessage.js +277 -0
  5. package/dist/parts/WdAlert.js +92 -0
  6. package/dist/parts/WdAnchor.js +159 -0
  7. package/dist/parts/WdAudioPlayer.js +1024 -0
  8. package/dist/parts/WdAvatar.js +6 -0
  9. package/dist/parts/WdAvatarGroup.js +46 -0
  10. package/dist/parts/WdBacktop.js +120 -0
  11. package/dist/parts/WdBadge.js +61 -0
  12. package/dist/parts/WdBento.js +40 -0
  13. package/dist/parts/WdBentoItem.js +43 -0
  14. package/dist/parts/WdBottomSheet.js +263 -0
  15. package/dist/parts/WdBreadcrumb.js +64 -0
  16. package/dist/parts/WdButton.js +94 -0
  17. package/dist/parts/WdCalendar.js +11 -0
  18. package/dist/parts/WdCard.js +113 -0
  19. package/dist/parts/WdCarousel.js +365 -0
  20. package/dist/parts/WdCascader.js +386 -0
  21. package/dist/parts/WdCheckbox.js +81 -0
  22. package/dist/parts/WdCollapse.js +135 -0
  23. package/dist/parts/WdColorPicker.js +592 -0
  24. package/dist/parts/WdCommand.js +357 -0
  25. package/dist/parts/WdContainer.js +37 -0
  26. package/dist/parts/WdCountdown.js +163 -0
  27. package/dist/parts/WdDanmaku.js +6 -0
  28. package/dist/parts/WdDatePicker.js +169 -0
  29. package/dist/parts/WdDateTimePicker.js +162 -0
  30. package/dist/parts/WdDescriptions.js +146 -0
  31. package/dist/parts/WdDivider.js +64 -0
  32. package/dist/parts/WdDrawer.js +176 -0
  33. package/dist/parts/WdDropdown.js +140 -0
  34. package/dist/parts/WdEmpty.js +79 -0
  35. package/dist/parts/WdExplorer.js +336 -0
  36. package/dist/parts/WdFileList.js +177 -0
  37. package/dist/parts/WdForm.js +111 -0
  38. package/dist/parts/WdFormItem.js +156 -0
  39. package/dist/parts/WdGrid.js +40 -0
  40. package/dist/parts/WdGroup.js +68 -0
  41. package/dist/parts/WdImagePreview.js +274 -0
  42. package/dist/parts/WdInput.js +10 -0
  43. package/dist/parts/WdInputNumber.js +253 -0
  44. package/dist/parts/WdListItem.js +60 -0
  45. package/dist/parts/WdLoading.js +128 -0
  46. package/dist/parts/WdMarkdown.js +172 -0
  47. package/dist/parts/WdMarquee.js +80 -0
  48. package/dist/parts/WdMasonry.js +40 -0
  49. package/dist/parts/WdMediaCard.js +302 -0
  50. package/dist/parts/WdMentions.js +277 -0
  51. package/dist/parts/WdModal.js +149 -0
  52. package/dist/parts/WdNav.js +311 -0
  53. package/dist/parts/WdNotification.js +112 -0
  54. package/dist/parts/WdOtp.js +107 -0
  55. package/dist/parts/WdPagination.js +252 -0
  56. package/dist/parts/WdPopconfirm.js +214 -0
  57. package/dist/parts/WdPopover.js +203 -0
  58. package/dist/parts/WdPostItem.js +84 -0
  59. package/dist/parts/WdProgress.js +48 -0
  60. package/dist/parts/WdProgressRing.js +101 -0
  61. package/dist/parts/WdPullRefresh.js +167 -0
  62. package/dist/parts/WdQRCode.js +1909 -0
  63. package/dist/parts/WdRadioGroup.js +95 -0
  64. package/dist/parts/WdRate.js +128 -0
  65. package/dist/parts/WdResult.js +86 -0
  66. package/dist/parts/WdScrollbar.js +186 -0
  67. package/dist/parts/WdSegmented.js +11 -0
  68. package/dist/parts/WdSelect.js +465 -0
  69. package/dist/parts/WdSkeleton.js +69 -0
  70. package/dist/parts/WdSlider.js +100 -0
  71. package/dist/parts/WdSortableList.js +291 -0
  72. package/dist/parts/WdSpace.js +46 -0
  73. package/dist/parts/WdSparkline.js +148 -0
  74. package/dist/parts/WdSpinner.js +6 -0
  75. package/dist/parts/WdSplitter.js +183 -0
  76. package/dist/parts/WdStatBar.js +202 -0
  77. package/dist/parts/WdStatistic.js +131 -0
  78. package/dist/parts/WdSteps.js +110 -0
  79. package/dist/parts/WdSwitch.js +63 -0
  80. package/dist/parts/WdTabBar.js +84 -0
  81. package/dist/parts/WdTable.js +589 -0
  82. package/dist/parts/WdTabs.js +219 -0
  83. package/dist/parts/WdTag.js +6 -0
  84. package/dist/parts/WdTagInput.js +181 -0
  85. package/dist/parts/WdTimePicker.js +12 -0
  86. package/dist/parts/WdTimeline.js +145 -0
  87. package/dist/parts/WdTooltip.js +108 -0
  88. package/dist/parts/WdTour.js +264 -0
  89. package/dist/parts/WdTransfer.js +446 -0
  90. package/dist/parts/WdTree.js +322 -0
  91. package/dist/parts/WdUpload.js +309 -0
  92. package/dist/parts/WdVideoPlayer.js +1006 -0
  93. package/dist/parts/WdVirtualList.js +169 -0
  94. package/dist/parts/WdWatermark.js +150 -0
  95. package/dist/parts/chunk-3LVE72ZK.js +361 -0
  96. package/dist/parts/chunk-5HYOQ52I.js +101 -0
  97. package/dist/parts/chunk-7M3MUL3B.js +275 -0
  98. package/dist/parts/chunk-AOTJ63HN.js +15 -0
  99. package/dist/parts/chunk-AXEF2U2A.js +41 -0
  100. package/dist/parts/chunk-CY3QOSFP.js +645 -0
  101. package/dist/parts/chunk-G7NN4A6J.js +40 -0
  102. package/dist/parts/chunk-HAKYCUAR.js +9 -0
  103. package/dist/parts/chunk-JDE4AHBR.js +160 -0
  104. package/dist/parts/chunk-LT3NTWIT.js +117 -0
  105. package/dist/parts/chunk-OGHYFT7B.js +387 -0
  106. package/dist/parts/chunk-Q34U2HES.js +261 -0
  107. package/dist/parts/chunk-RLSVPJHM.js +10 -0
  108. package/dist/parts/chunk-U2CDKD2T.js +30 -0
  109. package/dist/parts/chunk-UYUNYHZD.js +40 -0
  110. package/dist/parts/chunk-VUJL2HGD.js +23 -0
  111. package/dist/parts/chunk-WCFG5KNT.js +51 -0
  112. package/dist/parts/chunk-WDDAALPI.js +42 -0
  113. package/dist/parts/chunk-WFXLDBP2.js +149 -0
  114. package/dist/style/affix.css +566 -0
  115. package/dist/style/ai-msg.css +746 -0
  116. package/dist/style/alert.css +636 -0
  117. package/dist/style/anchor.css +630 -0
  118. package/dist/style/audio.css +1954 -0
  119. package/dist/style/avatar.css +651 -0
  120. package/dist/style/backtop.css +625 -0
  121. package/dist/style/badge.css +632 -0
  122. package/dist/style/bento.css +763 -0
  123. package/dist/style/bottom-sheet.css +776 -0
  124. package/dist/style/breadcrumb.css +629 -0
  125. package/dist/style/button.css +829 -0
  126. package/dist/style/calendar.css +1512 -0
  127. package/dist/style/card.css +748 -0
  128. package/dist/style/carousel.css +670 -0
  129. package/dist/style/cascader.css +862 -0
  130. package/dist/style/checkbox.css +706 -0
  131. package/dist/style/chevron.css +575 -0
  132. package/dist/style/collapse.css +648 -0
  133. package/dist/style/colorpicker.css +876 -0
  134. package/dist/style/command.css +760 -0
  135. package/dist/style/container.css +550 -0
  136. package/dist/style/countdown.css +722 -0
  137. package/dist/style/danmaku.css +644 -0
  138. package/dist/style/datepicker.css +683 -0
  139. package/dist/style/datetime-picker.css +714 -0
  140. package/dist/style/descriptions.css +712 -0
  141. package/dist/style/divider.css +604 -0
  142. package/dist/style/dot.css +585 -0
  143. package/dist/style/drawer.css +743 -0
  144. package/dist/style/dropdown.css +645 -0
  145. package/dist/style/empty.css +657 -0
  146. package/dist/style/explorer.css +944 -0
  147. package/dist/style/file-list.css +664 -0
  148. package/dist/style/flip.css +600 -0
  149. package/dist/style/form.css +638 -0
  150. package/dist/style/grid.css +618 -0
  151. package/dist/style/group.css +1022 -0
  152. package/dist/style/icon-btn.css +641 -0
  153. package/dist/style/image-preview.css +725 -0
  154. package/dist/style/input-number.css +680 -0
  155. package/dist/style/input.css +682 -0
  156. package/dist/style/list.css +630 -0
  157. package/dist/style/loading.css +667 -0
  158. package/dist/style/markdown.css +884 -0
  159. package/dist/style/marquee.css +678 -0
  160. package/dist/style/masonry.css +614 -0
  161. package/dist/style/media-card.css +1229 -0
  162. package/dist/style/mentions.css +690 -0
  163. package/dist/style/modal.css +775 -0
  164. package/dist/style/nav.css +1046 -0
  165. package/dist/style/notification.css +601 -0
  166. package/dist/style/otp.css +699 -0
  167. package/dist/style/pagination.css +680 -0
  168. package/dist/style/popconfirm.css +645 -0
  169. package/dist/style/popover.css +740 -0
  170. package/dist/style/post-item.css +676 -0
  171. package/dist/style/progress-ring.css +640 -0
  172. package/dist/style/progress.css +576 -0
  173. package/dist/style/pull-refresh.css +637 -0
  174. package/dist/style/qrcode.css +613 -0
  175. package/dist/style/radio.css +705 -0
  176. package/dist/style/rate.css +637 -0
  177. package/dist/style/result.css +597 -0
  178. package/dist/style/scroll-reveal.css +613 -0
  179. package/dist/style/scrollbar.css +644 -0
  180. package/dist/style/segmented-picker.css +679 -0
  181. package/dist/style/segmented.css +894 -0
  182. package/dist/style/select.css +937 -0
  183. package/dist/style/skeleton.css +590 -0
  184. package/dist/style/slider.css +642 -0
  185. package/dist/style/sortable.css +714 -0
  186. package/dist/style/space.css +568 -0
  187. package/dist/style/sparkline.css +606 -0
  188. package/dist/style/spinner.css +586 -0
  189. package/dist/style/splitter.css +711 -0
  190. package/dist/style/stat-bar.css +767 -0
  191. package/dist/style/statistic.css +589 -0
  192. package/dist/style/steps.css +724 -0
  193. package/dist/style/switch.css +676 -0
  194. package/dist/style/tab-bar.css +647 -0
  195. package/dist/style/table.css +1229 -0
  196. package/dist/style/tabs.css +756 -0
  197. package/dist/style/tag-input.css +710 -0
  198. package/dist/style/tag.css +682 -0
  199. package/dist/style/time-picker.css +749 -0
  200. package/dist/style/timeline.css +1082 -0
  201. package/dist/style/toast.css +598 -0
  202. package/dist/style/tooltip.css +604 -0
  203. package/dist/style/tour.css +683 -0
  204. package/dist/style/transfer.css +858 -0
  205. package/dist/style/tree.css +786 -0
  206. package/dist/style/typography.css +947 -0
  207. package/dist/style/upload.css +758 -0
  208. package/dist/style/vlist.css +591 -0
  209. package/dist/style/vplayer.css +1588 -0
  210. package/dist/style/watermark.css +570 -0
  211. package/dist/wdesign-ui.css +21093 -0
  212. package/dist/wdesign-ui.esm.js +20265 -0
  213. package/package.json +134 -4
  214. package/tokens.json +385 -0
@@ -0,0 +1,94 @@
1
+ import {
2
+ WdIcon_default
3
+ } from "./chunk-Q34U2HES.js";
4
+
5
+ // .lib-build/WdButton.ts
6
+ import { defineComponent as _defineComponent } from "vue";
7
+ import { openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, Fragment as _Fragment, renderSlot as _renderSlot, unref as _unref, createBlock as _createBlock, normalizeClass as _normalizeClass } from "vue";
8
+ import { computed } from "vue";
9
+ var _hoisted_1 = ["type", "disabled", "aria-busy"];
10
+ var _hoisted_2 = {
11
+ key: 0,
12
+ class: "wd-btn__spinner",
13
+ "aria-hidden": "true"
14
+ };
15
+ var WdButton_default = /* @__PURE__ */ _defineComponent({
16
+ ...{ name: "WdButton" },
17
+ __name: "WdButton",
18
+ props: {
19
+ variant: { type: String, required: false, default: "primary" },
20
+ size: { type: String, required: false, default: "md" },
21
+ disabled: { type: Boolean, required: false, default: false },
22
+ iconOnly: { type: Boolean, required: false, default: false },
23
+ block: { type: Boolean, required: false, default: false },
24
+ loading: { type: Boolean, required: false, default: false },
25
+ loadingText: { type: String, required: false, default: "" },
26
+ type: { type: String, required: false, default: "button" },
27
+ arrow: { type: Boolean, required: false, default: false }
28
+ },
29
+ emits: ["click"],
30
+ setup(__props, { emit: __emit }) {
31
+ const props = __props;
32
+ const arrowSize = computed(() => {
33
+ if (!props.iconOnly) return 15;
34
+ return props.size === "lg" ? 22 : props.size === "sm" ? 17 : 20;
35
+ });
36
+ const emit = __emit;
37
+ const classes = computed(() => [
38
+ "wd-btn",
39
+ `wd-btn--${props.variant}`,
40
+ `wd-btn--${props.size}`,
41
+ {
42
+ "wd-btn--icon": props.iconOnly,
43
+ "wd-btn--block": props.block,
44
+ "wd-btn--loading": props.loading
45
+ }
46
+ ]);
47
+ function onClick(e) {
48
+ if (props.loading || props.disabled) return;
49
+ emit("click", e);
50
+ }
51
+ return (_ctx, _cache) => {
52
+ return _openBlock(), _createElementBlock("button", {
53
+ "data-wd-hover": "",
54
+ class: _normalizeClass(classes.value),
55
+ type: __props.type,
56
+ disabled: __props.disabled || __props.loading,
57
+ "aria-busy": __props.loading || void 0,
58
+ onClick
59
+ }, [
60
+ __props.loading ? (_openBlock(), _createElementBlock("span", _hoisted_2)) : _createCommentVNode("v-if", true),
61
+ __props.loading && __props.loadingText ? (_openBlock(), _createElementBlock(
62
+ _Fragment,
63
+ { key: 1 },
64
+ [
65
+ _createTextVNode(
66
+ _toDisplayString(__props.loadingText),
67
+ 1
68
+ /* TEXT */
69
+ )
70
+ ],
71
+ 64
72
+ /* STABLE_FRAGMENT */
73
+ )) : (_openBlock(), _createElementBlock(
74
+ _Fragment,
75
+ { key: 2 },
76
+ [
77
+ _renderSlot(_ctx.$slots, "default"),
78
+ __props.arrow ? (_openBlock(), _createBlock(_unref(WdIcon_default), {
79
+ key: 0,
80
+ class: "wd-btn__arrow",
81
+ name: "arrow-up-right",
82
+ size: arrowSize.value
83
+ }, null, 8, ["size"])) : _createCommentVNode("v-if", true)
84
+ ],
85
+ 64
86
+ /* STABLE_FRAGMENT */
87
+ ))
88
+ ], 10, _hoisted_1);
89
+ };
90
+ }
91
+ });
92
+ export {
93
+ WdButton_default as WdButton
94
+ };
@@ -0,0 +1,11 @@
1
+ import {
2
+ WdCalendar_default
3
+ } from "./chunk-CY3QOSFP.js";
4
+ import "./chunk-WDDAALPI.js";
5
+ import "./chunk-WFXLDBP2.js";
6
+ import "./chunk-VUJL2HGD.js";
7
+ import "./chunk-UYUNYHZD.js";
8
+ import "./chunk-Q34U2HES.js";
9
+ export {
10
+ WdCalendar_default as WdCalendar
11
+ };
@@ -0,0 +1,113 @@
1
+ // .lib-build/WdCard.ts
2
+ import { defineComponent as _defineComponent } from "vue";
3
+ import { renderSlot as _renderSlot, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass } from "vue";
4
+ import { computed, useSlots } from "vue";
5
+ var _hoisted_1 = {
6
+ key: 0,
7
+ class: "wd-card__header"
8
+ };
9
+ var _hoisted_2 = ["src"];
10
+ var _hoisted_3 = {
11
+ key: 0,
12
+ class: "wd-card__headtext"
13
+ };
14
+ var _hoisted_4 = {
15
+ key: 0,
16
+ class: "wd-card__title"
17
+ };
18
+ var _hoisted_5 = {
19
+ key: 1,
20
+ class: "wd-card__meta"
21
+ };
22
+ var _hoisted_6 = {
23
+ key: 1,
24
+ class: "wd-card__extra"
25
+ };
26
+ var _hoisted_7 = { class: "wd-card__body" };
27
+ var _hoisted_8 = {
28
+ key: 1,
29
+ class: "wd-card__footer"
30
+ };
31
+ var WdCard_default = /* @__PURE__ */ _defineComponent({
32
+ ...{ name: "WdCard" },
33
+ __name: "WdCard",
34
+ props: {
35
+ variant: { type: String, required: false, default: "default" },
36
+ padding: { type: String, required: false, default: "md" },
37
+ hoverable: { type: Boolean, required: false, default: false },
38
+ title: { type: String, required: false, default: "" },
39
+ meta: { type: String, required: false, default: "" },
40
+ cover: { type: String, required: false, default: "" }
41
+ },
42
+ setup(__props) {
43
+ const props = __props;
44
+ const slots = useSlots();
45
+ const hasHeader = computed(
46
+ () => !!(props.title || props.meta || slots.header || slots.cover || props.cover)
47
+ );
48
+ const hasFooter = computed(() => !!slots.footer);
49
+ const classes = computed(() => [
50
+ "wd-card",
51
+ props.variant !== "default" ? `wd-card--${props.variant}` : "",
52
+ props.padding !== "md" ? `wd-card--pad-${props.padding}` : "",
53
+ props.hoverable ? "wd-card--hoverable" : "",
54
+ hasHeader.value ? "wd-card--with-header" : "",
55
+ hasFooter.value ? "wd-card--with-footer" : ""
56
+ ]);
57
+ return (_ctx, _cache) => {
58
+ return _openBlock(), _createElementBlock(
59
+ "div",
60
+ {
61
+ class: _normalizeClass(classes.value),
62
+ "data-wd-hover": ""
63
+ },
64
+ [
65
+ hasHeader.value ? (_openBlock(), _createElementBlock("div", _hoisted_1, [
66
+ _renderSlot(_ctx.$slots, "cover", {}, () => [
67
+ __props.cover ? (_openBlock(), _createElementBlock("img", {
68
+ key: 0,
69
+ class: "wd-card__cover",
70
+ src: __props.cover,
71
+ alt: "",
72
+ loading: "lazy"
73
+ }, null, 8, _hoisted_2)) : _createCommentVNode("v-if", true)
74
+ ]),
75
+ __props.title || __props.meta || _ctx.$slots.header ? (_openBlock(), _createElementBlock("div", _hoisted_3, [
76
+ _renderSlot(_ctx.$slots, "header", {}, () => [
77
+ __props.title ? (_openBlock(), _createElementBlock(
78
+ "div",
79
+ _hoisted_4,
80
+ _toDisplayString(__props.title),
81
+ 1
82
+ /* TEXT */
83
+ )) : _createCommentVNode("v-if", true),
84
+ __props.meta ? (_openBlock(), _createElementBlock(
85
+ "div",
86
+ _hoisted_5,
87
+ _toDisplayString(__props.meta),
88
+ 1
89
+ /* TEXT */
90
+ )) : _createCommentVNode("v-if", true)
91
+ ])
92
+ ])) : _createCommentVNode("v-if", true),
93
+ _createCommentVNode(" \u53F3\u4FA7\u52A8\u4F5C\u533A\uFF1A#extra \u653E\u300C\u66F4\u591A\u300D\u6309\u94AE\u3001\u6807\u7B7E\u8FD9\u7C7B\u8DDF\u6807\u9898\u540C\u6392\u7684\u4E1C\u897F "),
94
+ _ctx.$slots.extra ? (_openBlock(), _createElementBlock("div", _hoisted_6, [
95
+ _renderSlot(_ctx.$slots, "extra")
96
+ ])) : _createCommentVNode("v-if", true)
97
+ ])) : _createCommentVNode("v-if", true),
98
+ _createElementVNode("div", _hoisted_7, [
99
+ _renderSlot(_ctx.$slots, "default")
100
+ ]),
101
+ hasFooter.value ? (_openBlock(), _createElementBlock("div", _hoisted_8, [
102
+ _renderSlot(_ctx.$slots, "footer")
103
+ ])) : _createCommentVNode("v-if", true)
104
+ ],
105
+ 2
106
+ /* CLASS */
107
+ );
108
+ };
109
+ }
110
+ });
111
+ export {
112
+ WdCard_default as WdCard
113
+ };
@@ -0,0 +1,365 @@
1
+ import {
2
+ useControllable
3
+ } from "./chunk-G7NN4A6J.js";
4
+ import {
5
+ WdIcon_default
6
+ } from "./chunk-Q34U2HES.js";
7
+
8
+ // .lib-build/WdCarousel.ts
9
+ import { defineComponent as _defineComponent } from "vue";
10
+ import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, renderSlot as _renderSlot, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, unref as _unref, createVNode as _createVNode, withModifiers as _withModifiers, normalizeClass as _normalizeClass } from "vue";
11
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
12
+ var _hoisted_1 = ["src", "alt", "onError"];
13
+ var _hoisted_2 = { class: "wd-carousel__label" };
14
+ var _hoisted_3 = {
15
+ key: 2,
16
+ class: "wd-carousel__dots"
17
+ };
18
+ var _hoisted_4 = ["aria-label", "onClick"];
19
+ var SETTLE_MS = 500;
20
+ var THRESHOLD = 40;
21
+ var WdCarousel_default = /* @__PURE__ */ _defineComponent({
22
+ ...{ name: "WdCarousel" },
23
+ __name: "WdCarousel",
24
+ props: {
25
+ items: { type: Array, required: false, default: () => [] },
26
+ height: { type: Number, required: false, default: 260 },
27
+ autoplay: { type: Number, required: false, default: 0 },
28
+ showDots: { type: Boolean, required: false, default: true },
29
+ modelValue: { type: Number, required: false },
30
+ defaultValue: { type: Number, required: false, default: 0 },
31
+ showArrows: { type: Boolean, required: false, default: true },
32
+ loop: { type: Boolean, required: false, default: true },
33
+ pauseOnHover: { type: Boolean, required: false, default: true }
34
+ },
35
+ emits: ["update:modelValue", "change"],
36
+ setup(__props, { emit: __emit }) {
37
+ const props = __props;
38
+ const emit = __emit;
39
+ const { value: page, set: setPage } = useControllable({
40
+ modelValue: computed(() => props.modelValue),
41
+ defaultValue: computed(() => props.defaultValue),
42
+ fallback: 0,
43
+ onChange: (v) => emit("update:modelValue", v)
44
+ });
45
+ const MAX_ITEM = (v) => Math.max(0, Math.min(Math.round(v), n() - 1));
46
+ const PALETTE = ["var(--wd-tint-2)", "var(--wd-success-soft)", "var(--wd-warning-soft)", "var(--wd-field)"];
47
+ const root = ref(null);
48
+ const failed = ref(/* @__PURE__ */ new Set());
49
+ const n = () => props.items.length;
50
+ const looping = () => props.loop && n() > 1;
51
+ const slides = computed(() => {
52
+ const list = props.items;
53
+ if (!list.length) return [];
54
+ if (!looping()) return list.map((it, i) => ({ it, real: i, key: "r" + i }));
55
+ return [
56
+ { it: list[list.length - 1], real: list.length - 1, key: "c-head" },
57
+ ...list.map((it, i) => ({ it, real: i, key: "r" + i })),
58
+ { it: list[0], real: 0, key: "c-tail" }
59
+ ];
60
+ });
61
+ const pos = ref(looping() ? 1 : 0);
62
+ const animating = ref(true);
63
+ const dragX = ref(0);
64
+ const current = computed(() => {
65
+ const total = n() || 1;
66
+ return ((pos.value - (looping() ? 1 : 0)) % total + total) % total;
67
+ });
68
+ function emitIndex() {
69
+ const i = current.value;
70
+ setPage(i);
71
+ emit("change", i);
72
+ }
73
+ watch(
74
+ () => page.value,
75
+ (v) => {
76
+ if (!n()) return;
77
+ const target = MAX_ITEM(v);
78
+ if (target === current.value) return;
79
+ jumpTo((looping() ? 1 : 0) + target);
80
+ }
81
+ );
82
+ const trackStyle = computed(() => ({
83
+ transform: `translateX(calc(-${pos.value * 100}% + ${dragX.value}px))`,
84
+ transition: animating.value ? void 0 : "none"
85
+ }));
86
+ function go(i) {
87
+ if (!n()) return;
88
+ animating.value = true;
89
+ pos.value = (looping() ? 1 : 0) + MAX_ITEM(i);
90
+ scheduleSettle();
91
+ restart();
92
+ emitIndex();
93
+ }
94
+ function next() {
95
+ if (!n()) return;
96
+ animating.value = true;
97
+ pos.value += 1;
98
+ if (!looping()) pos.value = pos.value % n();
99
+ scheduleSettle();
100
+ restart();
101
+ emitIndex();
102
+ }
103
+ function prev() {
104
+ if (!n()) return;
105
+ animating.value = true;
106
+ pos.value -= 1;
107
+ if (!looping()) pos.value = (pos.value + n()) % n();
108
+ scheduleSettle();
109
+ restart();
110
+ emitIndex();
111
+ }
112
+ let settleTimer = null;
113
+ function scheduleSettle() {
114
+ if (settleTimer) window.clearTimeout(settleTimer);
115
+ if (!looping()) return;
116
+ settleTimer = window.setTimeout(normalize, SETTLE_MS);
117
+ }
118
+ function normalize() {
119
+ if (!looping()) return;
120
+ if (pos.value === 0) jumpTo(n());
121
+ else if (pos.value === n() + 1) jumpTo(1);
122
+ }
123
+ function onTransitionEnd() {
124
+ if (settleTimer) {
125
+ window.clearTimeout(settleTimer);
126
+ settleTimer = null;
127
+ }
128
+ normalize();
129
+ }
130
+ function jumpTo(target) {
131
+ animating.value = false;
132
+ pos.value = target;
133
+ requestAnimationFrame(() => requestAnimationFrame(() => {
134
+ animating.value = true;
135
+ }));
136
+ }
137
+ let timer = null;
138
+ function restart() {
139
+ stop();
140
+ if (props.autoplay > 0 && n() > 1) timer = window.setInterval(next, props.autoplay);
141
+ }
142
+ function stop() {
143
+ if (timer) {
144
+ window.clearInterval(timer);
145
+ timer = null;
146
+ }
147
+ }
148
+ function onKeydown(e) {
149
+ if (e.key === "ArrowLeft") {
150
+ e.preventDefault();
151
+ prev();
152
+ } else if (e.key === "ArrowRight") {
153
+ e.preventDefault();
154
+ next();
155
+ }
156
+ }
157
+ onMounted(() => {
158
+ pos.value = looping() ? 1 : 0;
159
+ restart();
160
+ });
161
+ onBeforeUnmount(() => {
162
+ stop();
163
+ detach();
164
+ if (settleTimer) window.clearTimeout(settleTimer);
165
+ });
166
+ let startX = 0, startY = 0, swiping = false, decided = false;
167
+ function onDown(e) {
168
+ if (n() < 2) return;
169
+ if (e.pointerType === "mouse" && e.button !== 0) return;
170
+ swiping = true;
171
+ decided = false;
172
+ startX = e.clientX;
173
+ startY = e.clientY;
174
+ try {
175
+ e.currentTarget.setPointerCapture?.(e.pointerId);
176
+ } catch {
177
+ }
178
+ window.addEventListener("pointermove", onMove, { passive: false });
179
+ window.addEventListener("pointerup", onUp);
180
+ window.addEventListener("pointercancel", onUp);
181
+ }
182
+ function onMove(e) {
183
+ if (!swiping) return;
184
+ const dx = e.clientX - startX, dy = e.clientY - startY;
185
+ if (!decided) {
186
+ if (Math.abs(dx) < 6 && Math.abs(dy) < 6) return;
187
+ if (Math.abs(dy) > Math.abs(dx)) {
188
+ end(false);
189
+ return;
190
+ }
191
+ decided = true;
192
+ stop();
193
+ }
194
+ if (e.cancelable) e.preventDefault();
195
+ dragX.value = dx;
196
+ }
197
+ function onUp(e) {
198
+ if (!swiping) return;
199
+ const dx = e.clientX - startX;
200
+ if (decided && Math.abs(dx) > THRESHOLD) {
201
+ if (dx < 0) next();
202
+ else prev();
203
+ }
204
+ end(true);
205
+ }
206
+ function end(again) {
207
+ swiping = false;
208
+ decided = false;
209
+ dragX.value = 0;
210
+ detach();
211
+ if (again) restart();
212
+ }
213
+ function detach() {
214
+ window.removeEventListener("pointermove", onMove);
215
+ window.removeEventListener("pointerup", onUp);
216
+ window.removeEventListener("pointercancel", onUp);
217
+ }
218
+ return (_ctx, _cache) => {
219
+ return _openBlock(), _createElementBlock(
220
+ "div",
221
+ {
222
+ ref_key: "root",
223
+ ref: root,
224
+ class: "wd-carousel",
225
+ style: _normalizeStyle({ height: __props.height + "px" }),
226
+ tabindex: "0",
227
+ role: "region",
228
+ "aria-roledescription": "\u8F6E\u64AD",
229
+ onMouseenter: _cache[3] || (_cache[3] = ($event) => __props.pauseOnHover && stop()),
230
+ onMouseleave: _cache[4] || (_cache[4] = ($event) => __props.pauseOnHover && restart()),
231
+ onFocusin: _cache[5] || (_cache[5] = ($event) => __props.pauseOnHover && stop()),
232
+ onFocusout: _cache[6] || (_cache[6] = ($event) => __props.pauseOnHover && restart()),
233
+ onKeydown,
234
+ onPointerdown: onDown
235
+ },
236
+ [
237
+ _createElementVNode(
238
+ "div",
239
+ {
240
+ class: "wd-carousel__track",
241
+ style: _normalizeStyle(trackStyle.value),
242
+ onTransitionend: onTransitionEnd
243
+ },
244
+ [
245
+ (_openBlock(true), _createElementBlock(
246
+ _Fragment,
247
+ null,
248
+ _renderList(slides.value, (s) => {
249
+ return _openBlock(), _createElementBlock(
250
+ "div",
251
+ {
252
+ key: s.key,
253
+ class: "wd-carousel__slide",
254
+ style: _normalizeStyle({ background: PALETTE[s.real % PALETTE.length] })
255
+ },
256
+ [
257
+ _renderSlot(_ctx.$slots, "item", {
258
+ item: s.it,
259
+ index: s.real
260
+ }, () => [
261
+ s.it.src && !failed.value.has(s.real) ? (_openBlock(), _createElementBlock("img", {
262
+ key: 0,
263
+ src: s.it.src,
264
+ alt: s.it.alt || "",
265
+ class: "wd-carousel__img",
266
+ draggable: "false",
267
+ onError: ($event) => failed.value.add(s.real)
268
+ }, null, 40, _hoisted_1)) : (_openBlock(), _createElementBlock(
269
+ _Fragment,
270
+ { key: 1 },
271
+ [
272
+ _createCommentVNode("\n \u56FE\u52A0\u8F7D\u5931\u8D25\u5C31\u9000\u56DE\u6587\u5B57\u6807\u7B7E \u2014\u2014 \u7EC4\u4EF6\u672C\u6765\u5C31\u6709\u8FD9\u4E2A\u964D\u7EA7\uFF08\u6CA1\u7ED9 src \u65F6\u663E\u793A label\uFF09\uFF0C\n \u53EA\u662F\u4E4B\u524D\u300C\u6709 src \u4F46\u52A0\u8F7D\u5931\u8D25\u300D\u8D70\u4E0D\u5230\u90A3\u6761\u5206\u652F\u3002\n \u8F6E\u64AD\u56FE\u6302\u4E86\u662F\u6574\u5C4F\u7070\u767D\uFF0C\u6BD4\u5355\u5F20\u56FE\u6302\u7740\u66F4\u96BE\u770B\u3002\n "),
273
+ _createElementVNode(
274
+ "span",
275
+ _hoisted_2,
276
+ _toDisplayString(failed.value.has(s.real) ? s.it.label || "\u56FE\u7247\u52A0\u8F7D\u5931\u8D25" : s.it.label || `Slide ${s.real + 1}`),
277
+ 1
278
+ /* TEXT */
279
+ )
280
+ ],
281
+ 2112
282
+ /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
283
+ ))
284
+ ])
285
+ ],
286
+ 4
287
+ /* STYLE */
288
+ );
289
+ }),
290
+ 128
291
+ /* KEYED_FRAGMENT */
292
+ ))
293
+ ],
294
+ 36
295
+ /* STYLE, NEED_HYDRATION */
296
+ ),
297
+ __props.showArrows && __props.items.length > 1 ? (_openBlock(), _createElementBlock(
298
+ "button",
299
+ {
300
+ key: 0,
301
+ type: "button",
302
+ class: "wd-icon-btn wd-carousel__arrow wd-carousel__arrow--prev",
303
+ "aria-label": "\u4E0A\u4E00\u5F20",
304
+ onPointerdown: _cache[0] || (_cache[0] = _withModifiers(() => {
305
+ }, ["stop"])),
306
+ onClick: prev
307
+ },
308
+ [
309
+ _createVNode(_unref(WdIcon_default), {
310
+ name: "chevron-left",
311
+ size: 15
312
+ })
313
+ ],
314
+ 32
315
+ /* NEED_HYDRATION */
316
+ )) : _createCommentVNode("v-if", true),
317
+ __props.showArrows && __props.items.length > 1 ? (_openBlock(), _createElementBlock(
318
+ "button",
319
+ {
320
+ key: 1,
321
+ type: "button",
322
+ class: "wd-icon-btn wd-carousel__arrow wd-carousel__arrow--next",
323
+ "aria-label": "\u4E0B\u4E00\u5F20",
324
+ onPointerdown: _cache[1] || (_cache[1] = _withModifiers(() => {
325
+ }, ["stop"])),
326
+ onClick: next
327
+ },
328
+ [
329
+ _createVNode(_unref(WdIcon_default), {
330
+ name: "chevron-right",
331
+ size: 15
332
+ })
333
+ ],
334
+ 32
335
+ /* NEED_HYDRATION */
336
+ )) : _createCommentVNode("v-if", true),
337
+ __props.showDots && __props.items.length > 1 ? (_openBlock(), _createElementBlock("div", _hoisted_3, [
338
+ (_openBlock(true), _createElementBlock(
339
+ _Fragment,
340
+ null,
341
+ _renderList(__props.items, (_, i) => {
342
+ return _openBlock(), _createElementBlock("button", {
343
+ key: i,
344
+ type: "button",
345
+ class: _normalizeClass(["wd-carousel__dot", { "wd-carousel__dot--active": i === current.value }]),
346
+ "aria-label": `\u7B2C ${i + 1} \u5F20`,
347
+ onPointerdown: _cache[2] || (_cache[2] = _withModifiers(() => {
348
+ }, ["stop"])),
349
+ onClick: ($event) => go(i)
350
+ }, null, 42, _hoisted_4);
351
+ }),
352
+ 128
353
+ /* KEYED_FRAGMENT */
354
+ ))
355
+ ])) : _createCommentVNode("v-if", true)
356
+ ],
357
+ 36
358
+ /* STYLE, NEED_HYDRATION */
359
+ );
360
+ };
361
+ }
362
+ });
363
+ export {
364
+ WdCarousel_default as WdCarousel
365
+ };