@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,252 @@
1
+ import {
2
+ useControllable
3
+ } from "./chunk-G7NN4A6J.js";
4
+ import {
5
+ WdIcon_default
6
+ } from "./chunk-Q34U2HES.js";
7
+
8
+ // .lib-build/WdPagination.ts
9
+ import { defineComponent as _defineComponent } from "vue";
10
+ import { toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, unref as _unref, createVNode as _createVNode, createElementVNode as _createElementVNode, renderList as _renderList, normalizeClass as _normalizeClass } from "vue";
11
+ import { computed, ref } from "vue";
12
+ var _hoisted_1 = {
13
+ key: 0,
14
+ class: "wd-pagination__total"
15
+ };
16
+ var _hoisted_2 = ["disabled"];
17
+ var _hoisted_3 = { class: "wd-pagination__simple-text" };
18
+ var _hoisted_4 = ["disabled"];
19
+ var _hoisted_5 = ["disabled"];
20
+ var _hoisted_6 = {
21
+ key: 0,
22
+ class: "wd-pagination__dots"
23
+ };
24
+ var _hoisted_7 = ["aria-current", "onClick"];
25
+ var _hoisted_8 = ["disabled"];
26
+ var _hoisted_9 = {
27
+ key: 3,
28
+ class: "wd-pagination__size"
29
+ };
30
+ var _hoisted_10 = ["value"];
31
+ var _hoisted_11 = ["value"];
32
+ var WdPagination_default = /* @__PURE__ */ _defineComponent({
33
+ ...{ name: "WdPagination" },
34
+ __name: "WdPagination",
35
+ props: {
36
+ modelValue: { type: Number, required: false },
37
+ defaultValue: { type: Number, required: false, default: 1 },
38
+ total: { type: Number, required: false, default: 0 },
39
+ pageSize: { type: Number, required: false, default: 10 },
40
+ simple: { type: Boolean, required: false, default: false },
41
+ showTotal: { type: Boolean, required: false, default: false },
42
+ showSizeChanger: { type: Boolean, required: false, default: false },
43
+ pageSizes: { type: Array, required: false, default: () => [10, 20, 50] },
44
+ compact: { type: Boolean, required: false, default: true }
45
+ },
46
+ emits: ["update:modelValue", "update:pageSize", "change"],
47
+ setup(__props, { emit: __emit }) {
48
+ const props = __props;
49
+ const emit = __emit;
50
+ const { value: page, set: setPage } = useControllable({
51
+ modelValue: computed(() => props.modelValue),
52
+ defaultValue: computed(() => props.defaultValue),
53
+ fallback: 1,
54
+ onChange: (v) => emit("update:modelValue", v)
55
+ });
56
+ const animReady = ref(false);
57
+ const size = ref(props.pageSize);
58
+ const pageCount = computed(() => Math.max(0, Math.ceil(props.total / size.value)));
59
+ const current = computed(() => Math.min(Math.max(1, page.value), Math.max(1, pageCount.value)));
60
+ const range = computed(() => {
61
+ const n = pageCount.value;
62
+ const cur = current.value;
63
+ if (!props.compact || n <= 7) return Array.from({ length: n }, (_, i) => i + 1);
64
+ const pages = [1];
65
+ const left = Math.max(2, cur - 1);
66
+ const right = Math.min(n - 1, cur + 1);
67
+ if (left > 2) pages.push("...");
68
+ for (let i = left; i <= right; i++) pages.push(i);
69
+ if (right < n - 1) pages.push("...");
70
+ pages.push(n);
71
+ return pages;
72
+ });
73
+ function go(p) {
74
+ if (pageCount.value <= 0) return;
75
+ animReady.value = true;
76
+ const v = Math.min(Math.max(1, p), pageCount.value);
77
+ if (v === page.value) return;
78
+ setPage(v);
79
+ emit("change", v, size.value);
80
+ }
81
+ function changeSize(e) {
82
+ const v = Number(e.target.value);
83
+ size.value = v;
84
+ emit("update:pageSize", v);
85
+ const max = Math.max(1, Math.ceil(props.total / v));
86
+ const p = Math.min(current.value, max);
87
+ setPage(p);
88
+ emit("change", p, v);
89
+ }
90
+ const from = computed(() => pageCount.value > 0 ? (current.value - 1) * size.value + 1 : 0);
91
+ const to = computed(() => pageCount.value > 0 ? Math.min(current.value * size.value, props.total) : 0);
92
+ return (_ctx, _cache) => {
93
+ return pageCount.value > 0 || __props.showTotal ? (_openBlock(), _createElementBlock(
94
+ "nav",
95
+ {
96
+ key: 0,
97
+ class: _normalizeClass(["wd-pagination", { "wd-pagination--anim-ready": animReady.value }]),
98
+ "aria-label": "\u5206\u9875"
99
+ },
100
+ [
101
+ __props.showTotal ? (_openBlock(), _createElementBlock("span", _hoisted_1, [
102
+ __props.total > 0 ? (_openBlock(), _createElementBlock(
103
+ _Fragment,
104
+ { key: 0 },
105
+ [
106
+ _createTextVNode(
107
+ "\u7B2C " + _toDisplayString(from.value) + "\u2013" + _toDisplayString(to.value) + " \u6761 / \u5171 " + _toDisplayString(__props.total) + " \u6761",
108
+ 1
109
+ /* TEXT */
110
+ )
111
+ ],
112
+ 64
113
+ /* STABLE_FRAGMENT */
114
+ )) : (_openBlock(), _createElementBlock(
115
+ _Fragment,
116
+ { key: 1 },
117
+ [
118
+ _createTextVNode("\u5171 0 \u6761")
119
+ ],
120
+ 64
121
+ /* STABLE_FRAGMENT */
122
+ ))
123
+ ])) : _createCommentVNode("v-if", true),
124
+ _createCommentVNode(" \u7B80\u6D01\u6A21\u5F0F "),
125
+ __props.simple && pageCount.value > 0 ? (_openBlock(), _createElementBlock(
126
+ _Fragment,
127
+ { key: 1 },
128
+ [
129
+ _createElementVNode("button", {
130
+ type: "button",
131
+ class: "wd-pagination__btn",
132
+ "data-wd-hover": "",
133
+ disabled: current.value <= 1,
134
+ "aria-label": "\u4E0A\u4E00\u9875",
135
+ onClick: _cache[0] || (_cache[0] = ($event) => go(current.value - 1))
136
+ }, [
137
+ _createVNode(_unref(WdIcon_default), {
138
+ name: "chevron-left",
139
+ size: 14
140
+ })
141
+ ], 8, _hoisted_2),
142
+ _createElementVNode(
143
+ "span",
144
+ _hoisted_3,
145
+ _toDisplayString(current.value) + " / " + _toDisplayString(pageCount.value),
146
+ 1
147
+ /* TEXT */
148
+ ),
149
+ _createElementVNode("button", {
150
+ type: "button",
151
+ class: "wd-pagination__btn",
152
+ "data-wd-hover": "",
153
+ disabled: current.value >= pageCount.value,
154
+ "aria-label": "\u4E0B\u4E00\u9875",
155
+ onClick: _cache[1] || (_cache[1] = ($event) => go(current.value + 1))
156
+ }, [
157
+ _createVNode(_unref(WdIcon_default), {
158
+ name: "chevron-right",
159
+ size: 14
160
+ })
161
+ ], 8, _hoisted_4)
162
+ ],
163
+ 64
164
+ /* STABLE_FRAGMENT */
165
+ )) : pageCount.value > 0 ? (_openBlock(), _createElementBlock(
166
+ _Fragment,
167
+ { key: 2 },
168
+ [
169
+ _createCommentVNode(" \u5B8C\u6574\u6A21\u5F0F "),
170
+ _createElementVNode("button", {
171
+ type: "button",
172
+ class: "wd-pagination__btn",
173
+ "data-wd-hover": "",
174
+ disabled: current.value <= 1,
175
+ "aria-label": "\u4E0A\u4E00\u9875",
176
+ onClick: _cache[2] || (_cache[2] = ($event) => go(current.value - 1))
177
+ }, [
178
+ _createVNode(_unref(WdIcon_default), {
179
+ name: "chevron-left",
180
+ size: 14
181
+ })
182
+ ], 8, _hoisted_5),
183
+ (_openBlock(true), _createElementBlock(
184
+ _Fragment,
185
+ null,
186
+ _renderList(range.value, (p, i) => {
187
+ return _openBlock(), _createElementBlock(
188
+ _Fragment,
189
+ { key: i },
190
+ [
191
+ p === "..." ? (_openBlock(), _createElementBlock("span", _hoisted_6, "\u2026")) : (_openBlock(), _createElementBlock("button", {
192
+ key: 1,
193
+ type: "button",
194
+ class: _normalizeClass(["wd-pagination__btn", { "wd-pagination__btn--active": p === current.value }]),
195
+ "data-wd-hover": "",
196
+ "aria-current": p === current.value ? "page" : void 0,
197
+ onClick: ($event) => go(p)
198
+ }, _toDisplayString(p), 11, _hoisted_7))
199
+ ],
200
+ 64
201
+ /* STABLE_FRAGMENT */
202
+ );
203
+ }),
204
+ 128
205
+ /* KEYED_FRAGMENT */
206
+ )),
207
+ _createElementVNode("button", {
208
+ type: "button",
209
+ class: "wd-pagination__btn",
210
+ "data-wd-hover": "",
211
+ disabled: current.value >= pageCount.value,
212
+ "aria-label": "\u4E0B\u4E00\u9875",
213
+ onClick: _cache[3] || (_cache[3] = ($event) => go(current.value + 1))
214
+ }, [
215
+ _createVNode(_unref(WdIcon_default), {
216
+ name: "chevron-right",
217
+ size: 14
218
+ })
219
+ ], 8, _hoisted_8)
220
+ ],
221
+ 64
222
+ /* STABLE_FRAGMENT */
223
+ )) : _createCommentVNode("v-if", true),
224
+ __props.showSizeChanger && pageCount.value > 0 ? (_openBlock(), _createElementBlock("label", _hoisted_9, [
225
+ _createElementVNode("select", {
226
+ value: size.value,
227
+ onChange: changeSize
228
+ }, [
229
+ (_openBlock(true), _createElementBlock(
230
+ _Fragment,
231
+ null,
232
+ _renderList(__props.pageSizes, (s) => {
233
+ return _openBlock(), _createElementBlock("option", {
234
+ key: s,
235
+ value: s
236
+ }, _toDisplayString(s) + " \u6761/\u9875", 9, _hoisted_11);
237
+ }),
238
+ 128
239
+ /* KEYED_FRAGMENT */
240
+ ))
241
+ ], 40, _hoisted_10)
242
+ ])) : _createCommentVNode("v-if", true)
243
+ ],
244
+ 2
245
+ /* CLASS */
246
+ )) : _createCommentVNode("v-if", true);
247
+ };
248
+ }
249
+ });
250
+ export {
251
+ WdPagination_default as WdPagination
252
+ };
@@ -0,0 +1,214 @@
1
+ import {
2
+ popDuration
3
+ } from "./chunk-HAKYCUAR.js";
4
+ import {
5
+ nextZIndex
6
+ } from "./chunk-5HYOQ52I.js";
7
+ import {
8
+ useDismiss
9
+ } from "./chunk-WFXLDBP2.js";
10
+ import {
11
+ WdIcon_default
12
+ } from "./chunk-Q34U2HES.js";
13
+
14
+ // .lib-build/WdPopconfirm.ts
15
+ import { defineComponent as _defineComponent } from "vue";
16
+ import { renderSlot as _renderSlot, mergeProps as _mergeProps, createElementVNode as _createElementVNode, createCommentVNode as _createCommentVNode, unref as _unref, createVNode as _createVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, normalizeClass as _normalizeClass, vShow as _vShow, withModifiers as _withModifiers, normalizeStyle as _normalizeStyle, withDirectives as _withDirectives, Teleport as _Teleport, createBlock as _createBlock, Fragment as _Fragment } from "vue";
17
+ import { computed, nextTick, onBeforeUnmount, ref, watch } from "vue";
18
+ var _hoisted_1 = ["aria-label", "aria-hidden"];
19
+ var _hoisted_2 = { class: "wd-popconfirm__title" };
20
+ var _hoisted_3 = {
21
+ key: 0,
22
+ class: "wd-popconfirm__icon",
23
+ "aria-hidden": "true"
24
+ };
25
+ var _hoisted_4 = {
26
+ key: 0,
27
+ class: "wd-popconfirm__desc"
28
+ };
29
+ var _hoisted_5 = { class: "wd-popconfirm__actions" };
30
+ var WdPopconfirm_default = /* @__PURE__ */ _defineComponent({
31
+ ...{ name: "WdPopconfirm" },
32
+ __name: "WdPopconfirm",
33
+ props: {
34
+ title: { type: String, required: false, default: "\u786E\u5B9A\u6267\u884C\u6B64\u64CD\u4F5C\uFF1F" },
35
+ description: { type: String, required: false, default: "" },
36
+ okText: { type: String, required: false, default: "\u786E\u5B9A" },
37
+ cancelText: { type: String, required: false, default: "\u53D6\u6D88" },
38
+ variant: { type: String, required: false, default: "default" },
39
+ placement: { type: String, required: false, default: "top" },
40
+ disabled: { type: Boolean, required: false, default: false },
41
+ width: { type: Number, required: false, default: 240 }
42
+ },
43
+ emits: ["confirm", "cancel"],
44
+ setup(__props, { emit: __emit }) {
45
+ const POP_DURATION = popDuration();
46
+ const props = __props;
47
+ const emit = __emit;
48
+ const open = ref(false);
49
+ const mounted = ref(false);
50
+ const trigger = ref(null);
51
+ const bubble = ref(null);
52
+ const pos = ref({ top: 0, left: 0 });
53
+ function place() {
54
+ const t = trigger.value?.getBoundingClientRect();
55
+ if (!t) return;
56
+ const sx = window.scrollX ?? window.pageXOffset ?? 0;
57
+ const sy = window.scrollY ?? window.pageYOffset ?? 0;
58
+ const vv = window.visualViewport;
59
+ const vw = vv?.width ?? window.innerWidth;
60
+ const w = props.width;
61
+ let left = t.left + sx + t.width / 2 - w / 2;
62
+ const minLeft = sx + 8;
63
+ const maxLeft = sx + vw - w - 8;
64
+ left = Math.max(minLeft, Math.min(left, Math.max(minLeft, maxLeft)));
65
+ const gap = 10;
66
+ const top = props.placement === "top" ? t.top + sy - gap : t.bottom + sy + gap;
67
+ pos.value = { top, left };
68
+ }
69
+ useDismiss([bubble, trigger], hide, open);
70
+ async function show() {
71
+ if (props.disabled) return;
72
+ mounted.value = true;
73
+ await nextTick();
74
+ place();
75
+ requestAnimationFrame(() => {
76
+ open.value = true;
77
+ bubble.value?.querySelector("[data-ok]")?.focus?.();
78
+ });
79
+ setTimeout(() => {
80
+ if (!open.value) open.value = true;
81
+ }, 60);
82
+ }
83
+ function hide() {
84
+ open.value = false;
85
+ }
86
+ function confirm() {
87
+ hide();
88
+ emit("confirm");
89
+ }
90
+ function cancel() {
91
+ hide();
92
+ emit("cancel");
93
+ }
94
+ function onKey(e) {
95
+ if (open.value && e.key === "Escape") hide();
96
+ }
97
+ watch(open, (v) => {
98
+ if (v) {
99
+ window.addEventListener("scroll", place, true);
100
+ window.addEventListener("resize", place);
101
+ } else {
102
+ window.removeEventListener("scroll", place, true);
103
+ window.removeEventListener("resize", place);
104
+ }
105
+ });
106
+ document.addEventListener("keydown", onKey);
107
+ onBeforeUnmount(() => {
108
+ document.removeEventListener("keydown", onKey);
109
+ window.removeEventListener("scroll", place, true);
110
+ window.removeEventListener("resize", place);
111
+ });
112
+ const z = ref();
113
+ const bubbleStyle = computed(() => ({
114
+ top: pos.value.top + "px",
115
+ left: pos.value.left + "px",
116
+ width: props.width + "px",
117
+ zIndex: z.value,
118
+ transform: props.placement === "top" ? "translateY(-100%)" : void 0
119
+ }));
120
+ watch(open, (v) => {
121
+ if (v) z.value = nextZIndex();
122
+ });
123
+ return (_ctx, _cache) => {
124
+ return _openBlock(), _createElementBlock(
125
+ _Fragment,
126
+ null,
127
+ [
128
+ _createElementVNode(
129
+ "span",
130
+ _mergeProps({
131
+ ref_key: "trigger",
132
+ ref: trigger
133
+ }, _ctx.$attrs, {
134
+ class: "wd-popconfirm",
135
+ onClick: _cache[0] || (_cache[0] = ($event) => open.value ? hide() : show())
136
+ }),
137
+ [
138
+ _renderSlot(_ctx.$slots, "default")
139
+ ],
140
+ 16
141
+ /* FULL_PROPS */
142
+ ),
143
+ (_openBlock(), _createBlock(_Teleport, { to: "body" }, [
144
+ _createCommentVNode("\n \u4E0D\u7528 <Transition>\uFF1A\u5B83\u7684 enter \u9636\u6BB5\u4F9D\u8D56 nextFrame\uFF0C\u52A8\u753B\u65F6\u949F\u505C\u6446\u65F6\n \uFF08\u540E\u53F0\u6807\u7B7E\u9875 / \u65E0\u5934\u6E32\u67D3 / \u7CFB\u7EDF\u51CF\u5F31\u52A8\u6548\uFF09\u4E0D\u4F1A\u63A8\u8FDB\uFF0Center-from \u7C7B\n \u4F1A\u6C38\u4E45\u6B8B\u7559\u5E76\u53E0\u52A0 leave \u7C7B\uFF0C\u5BFC\u81F4\u5143\u7D20\u5361\u5728\u534A\u900F\u660E\u4E14\u65E0\u6CD5\u9500\u6BC1\u3002\n \u6539\u4E3A\u5E38\u9A7B\u8282\u70B9 + .is-open \u7C7B\u9A71\u52A8 CSS \u8FC7\u6E21\uFF0C\u72B6\u6001\u59CB\u7EC8\u7531\u6211\u4EEC\u638C\u63E1\u3002\n "),
145
+ _withDirectives(_createElementVNode("div", {
146
+ ref_key: "bubble",
147
+ ref: bubble,
148
+ class: _normalizeClass(["wd-popconfirm__bubble", { "is-open": open.value }]),
149
+ style: _normalizeStyle(bubbleStyle.value),
150
+ role: "group",
151
+ "aria-label": __props.title,
152
+ "aria-hidden": !open.value,
153
+ onClick: _cache[1] || (_cache[1] = _withModifiers(() => {
154
+ }, ["stop"]))
155
+ }, [
156
+ _createElementVNode("div", _hoisted_2, [
157
+ __props.variant === "danger" ? (_openBlock(), _createElementBlock("span", _hoisted_3, [
158
+ _createVNode(_unref(WdIcon_default), {
159
+ name: "warning-circle",
160
+ size: 14
161
+ })
162
+ ])) : _createCommentVNode("v-if", true),
163
+ _createTextVNode(
164
+ " " + _toDisplayString(__props.title),
165
+ 1
166
+ /* TEXT */
167
+ )
168
+ ]),
169
+ __props.description ? (_openBlock(), _createElementBlock(
170
+ "p",
171
+ _hoisted_4,
172
+ _toDisplayString(__props.description),
173
+ 1
174
+ /* TEXT */
175
+ )) : _createCommentVNode("v-if", true),
176
+ _createElementVNode("div", _hoisted_5, [
177
+ _createElementVNode(
178
+ "button",
179
+ {
180
+ type: "button",
181
+ class: "wd-btn wd-btn--tint wd-btn--sm",
182
+ onClick: cancel
183
+ },
184
+ _toDisplayString(__props.cancelText),
185
+ 1
186
+ /* TEXT */
187
+ ),
188
+ _createElementVNode(
189
+ "button",
190
+ {
191
+ type: "button",
192
+ "data-ok": "",
193
+ class: _normalizeClass(["wd-btn wd-btn--sm wd-btn--primary", { "wd-popconfirm__ok--danger": __props.variant === "danger" }]),
194
+ onClick: confirm
195
+ },
196
+ _toDisplayString(__props.okText),
197
+ 3
198
+ /* TEXT, CLASS */
199
+ )
200
+ ])
201
+ ], 14, _hoisted_1), [
202
+ [_vShow, mounted.value]
203
+ ])
204
+ ]))
205
+ ],
206
+ 64
207
+ /* STABLE_FRAGMENT */
208
+ );
209
+ };
210
+ }
211
+ });
212
+ export {
213
+ WdPopconfirm_default as WdPopconfirm
214
+ };
@@ -0,0 +1,203 @@
1
+ import {
2
+ useOverlayLayer
3
+ } from "./chunk-5HYOQ52I.js";
4
+ import {
5
+ useAnchoredPosition,
6
+ useDismiss
7
+ } from "./chunk-WFXLDBP2.js";
8
+ import {
9
+ WdIcon_default
10
+ } from "./chunk-Q34U2HES.js";
11
+
12
+ // .lib-build/WdPopover.ts
13
+ import { defineComponent as _defineComponent } from "vue";
14
+ import { renderSlot as _renderSlot, toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, mergeProps as _mergeProps, unref as _unref, createVNode as _createVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, Teleport as _Teleport, createBlock as _createBlock, Fragment as _Fragment } from "vue";
15
+ import { computed, nextTick, ref, watch } from "vue";
16
+ var _hoisted_1 = {
17
+ type: "button",
18
+ class: "wd-popover__default-trigger"
19
+ };
20
+ var _hoisted_2 = ["data-placement", "aria-label"];
21
+ var _hoisted_3 = {
22
+ key: 0,
23
+ class: "wd-popover__head"
24
+ };
25
+ var _hoisted_4 = { class: "wd-popover__title" };
26
+ var _hoisted_5 = { class: "wd-popover__body" };
27
+ var WdPopover_default = /* @__PURE__ */ _defineComponent({
28
+ ...{ name: "WdPopover" },
29
+ __name: "WdPopover",
30
+ props: {
31
+ trigger: { type: String, required: false, default: "click" },
32
+ title: { type: String, required: false, default: "" },
33
+ placement: { type: String, required: false, default: "bottom-start" },
34
+ gap: { type: Number, required: false, default: 8 },
35
+ width: { type: Number, required: false, default: void 0 },
36
+ closable: { type: Boolean, required: false, default: false },
37
+ disabled: { type: Boolean, required: false, default: false },
38
+ closeOnContent: { type: Boolean, required: false, default: false }
39
+ },
40
+ emits: ["update:open", "open", "close"],
41
+ setup(__props, { emit: __emit }) {
42
+ const props = __props;
43
+ const emit = __emit;
44
+ const open = ref(false);
45
+ const anchorEl = ref(null);
46
+ const panelEl = ref(null);
47
+ const mounted = ref(false);
48
+ const { pos, actual } = useAnchoredPosition(open, anchorEl, panelEl, {
49
+ placement: props.placement,
50
+ gap: props.gap,
51
+ width: props.width
52
+ });
53
+ const style = computed(() => ({
54
+ top: pos.value.top + "px",
55
+ left: pos.value.left + "px"
56
+ }));
57
+ function show() {
58
+ if (props.disabled || open.value) return;
59
+ mounted.value = true;
60
+ open.value = true;
61
+ emit("open");
62
+ emit("update:open", true);
63
+ }
64
+ function hide() {
65
+ if (!open.value) return;
66
+ open.value = false;
67
+ emit("close");
68
+ emit("update:open", false);
69
+ }
70
+ function toggle() {
71
+ if (props.disabled) return;
72
+ if (open.value) hide();
73
+ else show();
74
+ }
75
+ let hoverTimer = 0;
76
+ function onEnter() {
77
+ if (props.trigger !== "hover") return;
78
+ clearTimeout(hoverTimer);
79
+ show();
80
+ }
81
+ function onLeave() {
82
+ if (props.trigger !== "hover") return;
83
+ clearTimeout(hoverTimer);
84
+ hoverTimer = window.setTimeout(() => {
85
+ if (panelEl.value?.matches(":hover")) return;
86
+ hide();
87
+ }, 120);
88
+ }
89
+ function onClick() {
90
+ if (props.trigger === "click") toggle();
91
+ }
92
+ function onPanelClick(e) {
93
+ if (!props.closeOnContent) return;
94
+ const t = e.target;
95
+ if (t.closest('button, a, input, select, textarea, [role="button"]')) return;
96
+ hide();
97
+ }
98
+ watch(
99
+ () => props.disabled,
100
+ (v) => {
101
+ if (v) hide();
102
+ }
103
+ );
104
+ useDismiss([anchorEl, panelEl], hide, open);
105
+ useOverlayLayer(open, panelEl, () => {
106
+ hide();
107
+ return true;
108
+ });
109
+ watch(open, async (v) => {
110
+ if (v) {
111
+ await nextTick();
112
+ nextTick(() => {
113
+ });
114
+ return;
115
+ }
116
+ window.setTimeout(() => {
117
+ if (!open.value) mounted.value = false;
118
+ }, 200);
119
+ });
120
+ function onKeydown(e) {
121
+ if (e.key === "Escape" && open.value) hide();
122
+ }
123
+ return (_ctx, _cache) => {
124
+ return _openBlock(), _createElementBlock(
125
+ _Fragment,
126
+ null,
127
+ [
128
+ _createElementVNode(
129
+ "span",
130
+ _mergeProps({
131
+ ref_key: "anchorEl",
132
+ ref: anchorEl
133
+ }, _ctx.$attrs, {
134
+ class: "wd-popover",
135
+ onMouseenter: onEnter,
136
+ onMouseleave: onLeave,
137
+ onClick,
138
+ onKeydown
139
+ }),
140
+ [
141
+ _renderSlot(_ctx.$slots, "trigger", {}, () => [
142
+ _createElementVNode(
143
+ "button",
144
+ _hoisted_1,
145
+ _toDisplayString(__props.title || "\u8BE6\u60C5"),
146
+ 1
147
+ /* TEXT */
148
+ )
149
+ ])
150
+ ],
151
+ 16
152
+ /* FULL_PROPS */
153
+ ),
154
+ (_openBlock(), _createBlock(_Teleport, { to: "body" }, [
155
+ mounted.value ? (_openBlock(), _createElementBlock("div", {
156
+ key: 0,
157
+ ref_key: "panelEl",
158
+ ref: panelEl,
159
+ class: _normalizeClass(["wd-popover__panel", { "is-open": open.value }]),
160
+ style: _normalizeStyle(style.value),
161
+ "data-placement": _unref(actual),
162
+ role: "group",
163
+ "aria-label": __props.title || void 0,
164
+ onMouseenter: onEnter,
165
+ onMouseleave: onLeave,
166
+ onClick: onPanelClick
167
+ }, [
168
+ __props.title || __props.closable ? (_openBlock(), _createElementBlock("div", _hoisted_3, [
169
+ _createElementVNode(
170
+ "span",
171
+ _hoisted_4,
172
+ _toDisplayString(__props.title),
173
+ 1
174
+ /* TEXT */
175
+ ),
176
+ __props.closable ? (_openBlock(), _createElementBlock("button", {
177
+ key: 0,
178
+ type: "button",
179
+ class: "wd-popover__close",
180
+ "aria-label": "\u5173\u95ED",
181
+ onClick: hide
182
+ }, [
183
+ _createVNode(_unref(WdIcon_default), {
184
+ name: "close",
185
+ size: 14
186
+ })
187
+ ])) : _createCommentVNode("v-if", true)
188
+ ])) : _createCommentVNode("v-if", true),
189
+ _createElementVNode("div", _hoisted_5, [
190
+ _renderSlot(_ctx.$slots, "default")
191
+ ])
192
+ ], 46, _hoisted_2)) : _createCommentVNode("v-if", true)
193
+ ]))
194
+ ],
195
+ 64
196
+ /* STABLE_FRAGMENT */
197
+ );
198
+ };
199
+ }
200
+ });
201
+ export {
202
+ WdPopover_default as WdPopover
203
+ };