@w-run/wdesign-ui 1.0.0 → 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 (213) hide show
  1. package/README.md +208 -127
  2. package/dist/index.d.ts +1010 -80
  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 +572 -13
  116. package/dist/style/alert.css +577 -5
  117. package/dist/style/anchor.css +630 -0
  118. package/dist/style/audio.css +658 -67
  119. package/dist/style/avatar.css +575 -12
  120. package/dist/style/backtop.css +625 -0
  121. package/dist/style/badge.css +595 -11
  122. package/dist/style/bento.css +763 -0
  123. package/dist/style/bottom-sheet.css +776 -0
  124. package/dist/style/breadcrumb.css +579 -4
  125. package/dist/style/button.css +631 -36
  126. package/dist/style/calendar.css +1512 -0
  127. package/dist/style/card.css +683 -6
  128. package/dist/style/carousel.css +573 -4
  129. package/dist/style/cascader.css +862 -0
  130. package/dist/style/checkbox.css +584 -7
  131. package/dist/style/chevron.css +543 -1
  132. package/dist/style/collapse.css +586 -7
  133. package/dist/style/colorpicker.css +876 -0
  134. package/dist/style/command.css +572 -13
  135. package/dist/style/container.css +543 -0
  136. package/dist/style/countdown.css +722 -0
  137. package/dist/style/danmaku.css +644 -0
  138. package/dist/style/datepicker.css +606 -128
  139. package/dist/style/datetime-picker.css +714 -0
  140. package/dist/style/descriptions.css +604 -11
  141. package/dist/style/divider.css +544 -2
  142. package/dist/style/dot.css +556 -1
  143. package/dist/style/drawer.css +609 -11
  144. package/dist/style/dropdown.css +565 -3
  145. package/dist/style/empty.css +624 -3
  146. package/dist/style/explorer.css +632 -24
  147. package/dist/style/file-list.css +577 -5
  148. package/dist/style/flip.css +600 -0
  149. package/dist/style/form.css +550 -8
  150. package/dist/style/grid.css +614 -0
  151. package/dist/style/group.css +560 -16
  152. package/dist/style/icon-btn.css +570 -4
  153. package/dist/style/image-preview.css +652 -8
  154. package/dist/style/input-number.css +680 -0
  155. package/dist/style/input.css +571 -8
  156. package/dist/style/list.css +553 -4
  157. package/dist/style/loading.css +667 -0
  158. package/dist/style/markdown.css +592 -20
  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 +626 -15
  164. package/dist/style/nav.css +1046 -0
  165. package/dist/style/notification.css +556 -7
  166. package/dist/style/otp.css +567 -7
  167. package/dist/style/pagination.css +571 -11
  168. package/dist/style/popconfirm.css +568 -10
  169. package/dist/style/popover.css +645 -15
  170. package/dist/style/post-item.css +548 -6
  171. package/dist/style/progress-ring.css +640 -0
  172. package/dist/style/progress.css +543 -1
  173. package/dist/style/pull-refresh.css +637 -0
  174. package/dist/style/qrcode.css +613 -0
  175. package/dist/style/radio.css +584 -5
  176. package/dist/style/rate.css +594 -1
  177. package/dist/style/result.css +546 -3
  178. package/dist/style/scroll-reveal.css +613 -0
  179. package/dist/style/scrollbar.css +644 -0
  180. package/dist/style/segmented-picker.css +573 -14
  181. package/dist/style/segmented.css +711 -7
  182. package/dist/style/select.css +682 -26
  183. package/dist/style/skeleton.css +559 -0
  184. package/dist/style/slider.css +565 -4
  185. package/dist/style/sortable.css +593 -7
  186. package/dist/style/space.css +543 -0
  187. package/dist/style/sparkline.css +606 -0
  188. package/dist/style/spinner.css +559 -0
  189. package/dist/style/splitter.css +711 -0
  190. package/dist/style/stat-bar.css +767 -0
  191. package/dist/style/statistic.css +552 -7
  192. package/dist/style/steps.css +633 -9
  193. package/dist/style/switch.css +585 -4
  194. package/dist/style/tab-bar.css +647 -0
  195. package/dist/style/table.css +886 -36
  196. package/dist/style/tabs.css +599 -10
  197. package/dist/style/tag-input.css +710 -0
  198. package/dist/style/tag.css +603 -18
  199. package/dist/style/time-picker.css +749 -0
  200. package/dist/style/timeline.css +575 -14
  201. package/dist/style/toast.css +567 -6
  202. package/dist/style/tooltip.css +564 -5
  203. package/dist/style/tour.css +683 -0
  204. package/dist/style/transfer.css +858 -0
  205. package/dist/style/tree.css +613 -16
  206. package/dist/style/typography.css +884 -3
  207. package/dist/style/upload.css +602 -13
  208. package/dist/style/vlist.css +543 -1
  209. package/dist/style/vplayer.css +799 -57
  210. package/dist/style/watermark.css +570 -0
  211. package/dist/wdesign-ui.css +18055 -7262
  212. package/dist/wdesign-ui.esm.js +8976 -5044
  213. package/package.json +99 -13
@@ -0,0 +1,169 @@
1
+ // .lib-build/WdVirtualList.ts
2
+ import { defineComponent as _defineComponent } from "vue";
3
+ import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass } from "vue";
4
+ import { computed, nextTick, onMounted, ref, watch } from "vue";
5
+ var _hoisted_1 = {
6
+ key: 1,
7
+ class: "wd-vlist__empty"
8
+ };
9
+ var REACH_SLACK = 2;
10
+ var WdVirtualList_default = /* @__PURE__ */ _defineComponent({
11
+ ...{ name: "WdVirtualList" },
12
+ __name: "WdVirtualList",
13
+ props: {
14
+ items: { type: Array, required: false, default: () => [] },
15
+ itemHeight: { type: Number, required: false, default: 40 },
16
+ height: { type: Number, required: false, default: 400 },
17
+ buffer: { type: Number, required: false, default: 4 },
18
+ itemKey: { type: String, required: false, default: "" },
19
+ emptyText: { type: String, required: false, default: "\u6682\u65E0\u6570\u636E" },
20
+ hideScrollbar: { type: Boolean, required: false, default: false }
21
+ },
22
+ emits: ["scroll", "reach-end"],
23
+ setup(__props, { expose: __expose, emit: __emit }) {
24
+ const props = __props;
25
+ const emit = __emit;
26
+ const viewport = ref(null);
27
+ const scrollTop = ref(0);
28
+ const totalHeight = computed(() => props.items.length * props.itemHeight);
29
+ const range = computed(() => {
30
+ const h = props.height;
31
+ const start = Math.floor(scrollTop.value / props.itemHeight);
32
+ const visible = Math.ceil(h / props.itemHeight);
33
+ const from = Math.max(0, start - props.buffer);
34
+ const to = Math.min(props.items.length, start + visible + props.buffer);
35
+ return { from, to };
36
+ });
37
+ const visibleItems = computed(
38
+ () => props.items.slice(range.value.from, range.value.to).map((item, i) => ({
39
+ item,
40
+ index: range.value.from + i
41
+ }))
42
+ );
43
+ const offsetY = computed(() => range.value.from * props.itemHeight);
44
+ let armed = true;
45
+ function onScroll(e) {
46
+ const el = e.target;
47
+ scrollTop.value = el.scrollTop;
48
+ emit("scroll", el.scrollTop);
49
+ const atBottom = el.scrollTop + el.clientHeight >= el.scrollHeight - REACH_SLACK;
50
+ if (!atBottom) {
51
+ armed = true;
52
+ } else if (armed) {
53
+ armed = false;
54
+ emit("reachEnd");
55
+ }
56
+ }
57
+ function keyOf(item, index) {
58
+ if (props.itemKey && item && typeof item === "object") {
59
+ const v = item[props.itemKey];
60
+ if (v !== void 0) return v;
61
+ }
62
+ return index;
63
+ }
64
+ function scrollToIndex(index, align = "start") {
65
+ const el = viewport.value;
66
+ if (!el) return;
67
+ const max = Math.max(0, totalHeight.value - props.height);
68
+ let top = index * props.itemHeight;
69
+ if (align === "center") top -= (props.height - props.itemHeight) / 2;
70
+ else if (align === "end") top -= props.height - props.itemHeight;
71
+ el.scrollTop = Math.min(max, Math.max(0, top));
72
+ }
73
+ function scrollToTop() {
74
+ if (viewport.value) viewport.value.scrollTop = 0;
75
+ }
76
+ watch(
77
+ () => props.items.length,
78
+ async () => {
79
+ await nextTick();
80
+ const el = viewport.value;
81
+ if (!el) return;
82
+ const max = Math.max(0, totalHeight.value - props.height);
83
+ if (el.scrollTop > max) el.scrollTop = max;
84
+ }
85
+ );
86
+ onMounted(() => {
87
+ if (viewport.value) scrollTop.value = viewport.value.scrollTop;
88
+ });
89
+ __expose({ scrollToIndex, scrollToTop });
90
+ return (_ctx, _cache) => {
91
+ return _openBlock(), _createElementBlock(
92
+ "div",
93
+ {
94
+ ref_key: "viewport",
95
+ ref: viewport,
96
+ class: _normalizeClass(["wd-vlist", { "wd-vlist--hide-scrollbar": __props.hideScrollbar }]),
97
+ style: _normalizeStyle({ height: typeof __props.height === "number" ? __props.height + "px" : __props.height }),
98
+ onScrollPassive: onScroll
99
+ },
100
+ [
101
+ __props.items.length ? (_openBlock(), _createElementBlock(
102
+ "div",
103
+ {
104
+ key: 0,
105
+ class: "wd-vlist__phantom",
106
+ style: _normalizeStyle({ height: totalHeight.value + "px" })
107
+ },
108
+ [
109
+ _createElementVNode(
110
+ "div",
111
+ {
112
+ class: "wd-vlist__window",
113
+ style: _normalizeStyle({ transform: `translateY(${offsetY.value}px)` })
114
+ },
115
+ [
116
+ (_openBlock(true), _createElementBlock(
117
+ _Fragment,
118
+ null,
119
+ _renderList(visibleItems.value, (entry) => {
120
+ return _openBlock(), _createElementBlock(
121
+ "div",
122
+ {
123
+ key: keyOf(entry.item, entry.index),
124
+ class: "wd-vlist__item",
125
+ style: _normalizeStyle({ height: __props.itemHeight + "px" })
126
+ },
127
+ [
128
+ _renderSlot(_ctx.$slots, "default", {
129
+ item: entry.item,
130
+ index: entry.index
131
+ }, () => [
132
+ _createTextVNode(
133
+ _toDisplayString(entry.item),
134
+ 1
135
+ /* TEXT */
136
+ )
137
+ ])
138
+ ],
139
+ 4
140
+ /* STYLE */
141
+ );
142
+ }),
143
+ 128
144
+ /* KEYED_FRAGMENT */
145
+ ))
146
+ ],
147
+ 4
148
+ /* STYLE */
149
+ )
150
+ ],
151
+ 4
152
+ /* STYLE */
153
+ )) : (_openBlock(), _createElementBlock(
154
+ "div",
155
+ _hoisted_1,
156
+ _toDisplayString(__props.emptyText),
157
+ 1
158
+ /* TEXT */
159
+ ))
160
+ ],
161
+ 38
162
+ /* CLASS, STYLE, NEED_HYDRATION */
163
+ );
164
+ };
165
+ }
166
+ });
167
+ export {
168
+ WdVirtualList_default as WdVirtualList
169
+ };
@@ -0,0 +1,150 @@
1
+ // .lib-build/WdWatermark.ts
2
+ import { defineComponent as _defineComponent } from "vue";
3
+ import { renderSlot as _renderSlot, createCommentVNode as _createCommentVNode, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
4
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
5
+ var WdWatermark_default = /* @__PURE__ */ _defineComponent({
6
+ ...{ name: "WdWatermark" },
7
+ __name: "WdWatermark",
8
+ props: {
9
+ text: { type: [String, Array], required: false, default: "" },
10
+ image: { type: String, required: false, default: "" },
11
+ fontSize: { type: Number, required: false, default: 14 },
12
+ color: { type: String, required: false, default: "rgba(0, 0, 0, 0.08)" },
13
+ gap: { type: Number, required: false, default: 80 },
14
+ rotate: { type: Number, required: false, default: -22 },
15
+ offset: { type: Number, required: false, default: 12 },
16
+ zIndex: { type: Number, required: false, default: 9 }
17
+ },
18
+ setup(__props) {
19
+ const props = __props;
20
+ const root = ref(null);
21
+ const bg = ref("");
22
+ function render() {
23
+ if (typeof document === "undefined") return;
24
+ const el = root.value;
25
+ if (!el) return;
26
+ const w = el.clientWidth;
27
+ const h = el.clientHeight;
28
+ if (w === 0 || h === 0) return;
29
+ const lines = Array.isArray(props.text) ? props.text : props.text ? [props.text] : [];
30
+ if (!props.image && lines.length === 0) {
31
+ bg.value = "";
32
+ return;
33
+ }
34
+ const dpr = Math.min(window.devicePixelRatio || 1, 2);
35
+ const gap = Math.max(20, props.gap);
36
+ const fs = Math.max(8, props.fontSize);
37
+ const canvas = document.createElement("canvas");
38
+ const ctx = canvas.getContext("2d");
39
+ if (!ctx) return;
40
+ let cellW;
41
+ let cellH;
42
+ let draw;
43
+ if (props.image) {
44
+ const img = new Image();
45
+ img.crossOrigin = "anonymous";
46
+ img.onload = () => {
47
+ const size = gap;
48
+ canvas.width = size * dpr;
49
+ canvas.height = size * dpr;
50
+ canvas.style.width = size + "px";
51
+ canvas.style.height = size + "px";
52
+ ctx.scale(dpr, dpr);
53
+ ctx.globalAlpha = 0.15;
54
+ ctx.drawImage(img, 0, 0, size, size);
55
+ bg.value = canvas.toDataURL("image/png");
56
+ };
57
+ img.src = props.image;
58
+ return;
59
+ }
60
+ ctx.font = `600 ${fs}px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`;
61
+ const maxLineW = Math.max(...lines.map((l) => ctx.measureText(l).width));
62
+ const lineH = fs * 1.5;
63
+ const blockW = maxLineW;
64
+ const blockH = lineH * lines.length;
65
+ const rot = Math.abs(props.rotate) * Math.PI / 180;
66
+ const cos = Math.cos(rot);
67
+ const sin = Math.sin(rot);
68
+ cellW = Math.ceil(blockW * cos + blockH * sin) + gap;
69
+ cellH = Math.ceil(blockW * sin + blockH * cos) + gap;
70
+ canvas.width = cellW * dpr;
71
+ canvas.height = cellH * dpr;
72
+ canvas.style.width = cellW + "px";
73
+ canvas.style.height = cellH + "px";
74
+ ctx.scale(dpr, dpr);
75
+ ctx.translate(cellW / 2, cellH / 2);
76
+ ctx.rotate(props.rotate * Math.PI / 180);
77
+ ctx.fillStyle = props.color;
78
+ ctx.textAlign = "center";
79
+ ctx.textBaseline = "middle";
80
+ ctx.font = `600 ${fs}px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`;
81
+ const startY = -blockH / 2 + lineH / 2;
82
+ lines.forEach((line, i) => {
83
+ ctx.fillText(line, 0, startY + i * lineH);
84
+ });
85
+ bg.value = canvas.toDataURL("image/png");
86
+ }
87
+ let ro = null;
88
+ let timer = 0;
89
+ function scheduleRender() {
90
+ clearTimeout(timer);
91
+ timer = window.setTimeout(render, 60);
92
+ }
93
+ onMounted(() => {
94
+ render();
95
+ if (typeof ResizeObserver !== "undefined" && root.value) {
96
+ ro = new ResizeObserver(() => scheduleRender());
97
+ ro.observe(root.value);
98
+ }
99
+ });
100
+ watch(
101
+ () => [props.text, props.image, props.fontSize, props.color, props.gap, props.rotate],
102
+ () => scheduleRender(),
103
+ { deep: true }
104
+ );
105
+ onBeforeUnmount(() => {
106
+ ro?.disconnect();
107
+ clearTimeout(timer);
108
+ });
109
+ const bgStyle = computed(() => {
110
+ if (!bg.value) return {};
111
+ return {
112
+ backgroundImage: `url(${bg.value})`,
113
+ backgroundRepeat: "repeat",
114
+ backgroundPosition: `${props.offset}px ${props.offset}px`,
115
+ zIndex: String(props.zIndex)
116
+ };
117
+ });
118
+ return (_ctx, _cache) => {
119
+ return _openBlock(), _createElementBlock(
120
+ "div",
121
+ {
122
+ ref_key: "root",
123
+ ref: root,
124
+ class: "wd-watermark"
125
+ },
126
+ [
127
+ _renderSlot(_ctx.$slots, "default"),
128
+ _createCommentVNode("\n \u6C34\u5370\u5C42\uFF1A\n \xB7 pointer-events: none \u2014\u2014 \u7EDD\u4E0D\u80FD\u6321\u4F4F\u4E0B\u65B9\u7684\u4EA4\u4E92\n \xB7 \u6CA1\u6709 include \u5230\u65E0\u969C\u788D\u6811 \u2014\u2014 \u6C34\u5370\u662F\u7EAF\u89C6\u89C9\u4FE1\u606F\uFF0C\u8BFB\u5C4F\u4E0D\u8BE5\u8BFB\n \xB7 background-image \u5E73\u94FA\uFF0C\u800C\u975E DOM \u8282\u70B9\u94FA\u6EE1\n "),
129
+ bg.value ? (_openBlock(), _createElementBlock(
130
+ "div",
131
+ {
132
+ key: 0,
133
+ class: "wd-watermark__layer",
134
+ style: _normalizeStyle(bgStyle.value),
135
+ "aria-hidden": "true"
136
+ },
137
+ null,
138
+ 4
139
+ /* STYLE */
140
+ )) : _createCommentVNode("v-if", true)
141
+ ],
142
+ 512
143
+ /* NEED_PATCH */
144
+ );
145
+ };
146
+ }
147
+ });
148
+ export {
149
+ WdWatermark_default as WdWatermark
150
+ };
@@ -0,0 +1,361 @@
1
+ import {
2
+ useOverlayLayer
3
+ } from "./chunk-5HYOQ52I.js";
4
+ import {
5
+ useAnchoredPosition,
6
+ useDismiss
7
+ } from "./chunk-WFXLDBP2.js";
8
+ import {
9
+ useFormItemA11y
10
+ } from "./chunk-VUJL2HGD.js";
11
+ import {
12
+ WdIcon_default
13
+ } from "./chunk-Q34U2HES.js";
14
+
15
+ // .lib-build/WdSegmented.ts
16
+ import { defineComponent as _defineComponent } from "vue";
17
+ import { unref as _unref, createElementVNode as _createElementVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, createVNode as _createVNode, toDisplayString as _toDisplayString, createCommentVNode as _createCommentVNode, normalizeClass as _normalizeClass, createBlock as _createBlock, normalizeStyle as _normalizeStyle, Teleport as _Teleport, mergeProps as _mergeProps } from "vue";
18
+ import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
19
+ var _hoisted_1 = ["aria-hidden"];
20
+ var _hoisted_2 = ["aria-selected", "tabindex", "aria-label", "onClick"];
21
+ var _hoisted_3 = {
22
+ key: 0,
23
+ class: "wd-segmented__icon"
24
+ };
25
+ var _hoisted_4 = {
26
+ key: 0,
27
+ class: "wd-segmented__badge"
28
+ };
29
+ var _hoisted_5 = {
30
+ key: 1,
31
+ class: "wd-segmented__label"
32
+ };
33
+ var _hoisted_6 = {
34
+ key: 0,
35
+ class: "wd-segmented-picker"
36
+ };
37
+ var _hoisted_7 = ["aria-expanded"];
38
+ var _hoisted_8 = { class: "wd-segmented-picker__label" };
39
+ var _hoisted_9 = { class: "wd-segmented-picker__meta" };
40
+ var _hoisted_10 = ["data-placement"];
41
+ var _hoisted_11 = ["aria-selected", "onClick"];
42
+ var WdSegmented_default = /* @__PURE__ */ _defineComponent({
43
+ ...{ name: "WdSegmented" },
44
+ __name: "WdSegmented",
45
+ props: {
46
+ modelValue: { type: [String, Number], required: false, default: "" },
47
+ options: { type: Array, required: false, default: () => [] },
48
+ block: { type: Boolean, required: false, default: false },
49
+ tone: { type: String, required: false, default: "light" },
50
+ overflow: { type: String, required: false, default: "wrap" },
51
+ overflowMax: { type: Number, required: false, default: 15 },
52
+ layout: { type: String, required: false, default: "inline" },
53
+ iconOnly: { type: Boolean, required: false, default: false }
54
+ },
55
+ emits: ["update:modelValue"],
56
+ setup(__props, { emit: __emit }) {
57
+ const formA11y = useFormItemA11y();
58
+ const props = __props;
59
+ const emit = __emit;
60
+ const items = computed(
61
+ () => props.options.map(
62
+ (o) => typeof o === "string" ? { label: o, value: o, icon: void 0, activeIcon: void 0, badge: void 0 } : { icon: void 0, activeIcon: void 0, badge: void 0, ...o }
63
+ )
64
+ );
65
+ const activeLabel = computed(
66
+ () => items.value.find((o) => o.value === props.modelValue)?.label ?? ""
67
+ );
68
+ const wrap = ref();
69
+ const track = ref();
70
+ const slider = ref();
71
+ const mode = ref("flat");
72
+ const canLeft = ref(false);
73
+ const canRight = ref(false);
74
+ const dropdownOpen = ref(false);
75
+ const pickerPanel = ref(null);
76
+ const { pos: pickerPos, actual: pickerPlace } = useAnchoredPosition(
77
+ dropdownOpen,
78
+ wrap,
79
+ pickerPanel,
80
+ { placement: "bottom-start", gap: 6 }
81
+ );
82
+ useDismiss([wrap, pickerPanel], () => {
83
+ dropdownOpen.value = false;
84
+ }, dropdownOpen);
85
+ useOverlayLayer(dropdownOpen, wrap, () => {
86
+ dropdownOpen.value = false;
87
+ return true;
88
+ });
89
+ const sliderSettled = ref(false);
90
+ function updateSlider() {
91
+ const t = track.value;
92
+ const s = slider.value;
93
+ if (!t || !s || mode.value === "dropdown") return;
94
+ const active = t.querySelector(".wd-segmented__item--active");
95
+ if (!active) return;
96
+ if (!sliderSettled.value) {
97
+ s.classList.add("is-initial");
98
+ place(active, s);
99
+ const settle = () => {
100
+ if (sliderSettled.value) return;
101
+ s.classList.remove("is-initial");
102
+ sliderSettled.value = true;
103
+ };
104
+ requestAnimationFrame(settle);
105
+ setTimeout(settle, 60);
106
+ return;
107
+ }
108
+ place(active, s);
109
+ }
110
+ function place(active, s) {
111
+ s.style.transform = `translate(${active.offsetLeft - s.offsetLeft}px, ${active.offsetTop - s.offsetTop}px)`;
112
+ s.style.width = `${active.offsetWidth}px`;
113
+ s.style.height = `${active.offsetHeight}px`;
114
+ }
115
+ function measure() {
116
+ const w = wrap.value;
117
+ const t = track.value;
118
+ if (!t || !w) return;
119
+ if (props.overflow === "wrap") {
120
+ mode.value = "flat";
121
+ } else if (props.overflow === "scroll") {
122
+ mode.value = "scroll";
123
+ } else {
124
+ const cs = getComputedStyle(t);
125
+ const pad = (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
126
+ const gap = parseFloat(cs.columnGap) || parseFloat(cs.gap) || 0;
127
+ const kids = Array.from(t.querySelectorAll(".wd-segmented__item"));
128
+ const content = kids.reduce((sum, k) => sum + k.offsetWidth, 0) + gap * Math.max(0, kids.length - 1) + pad;
129
+ const wcs = getComputedStyle(w);
130
+ const available = w.clientWidth - (parseFloat(wcs.paddingLeft) || 0) - (parseFloat(wcs.paddingRight) || 0);
131
+ if (content <= available + 1) mode.value = "flat";
132
+ else if (kids.length > props.overflowMax) mode.value = "dropdown";
133
+ else mode.value = "scroll";
134
+ }
135
+ nextTick(() => {
136
+ updateSlider();
137
+ updateFades();
138
+ });
139
+ }
140
+ function updateFades() {
141
+ const t = track.value;
142
+ if (!t || mode.value !== "scroll") {
143
+ canLeft.value = false;
144
+ canRight.value = false;
145
+ return;
146
+ }
147
+ const max = t.scrollWidth - t.clientWidth;
148
+ canLeft.value = t.scrollLeft > 1;
149
+ canRight.value = max > 1 && t.scrollLeft < max - 1;
150
+ }
151
+ function scrollActiveIntoView() {
152
+ const t = track.value;
153
+ if (!t || mode.value !== "scroll") return;
154
+ const align = () => {
155
+ const active = t.querySelector(".wd-segmented__item--active");
156
+ if (!active) return;
157
+ const pad = 8;
158
+ const left = active.offsetLeft - pad;
159
+ const right = active.offsetLeft + active.offsetWidth + pad;
160
+ if (left < t.scrollLeft) t.scrollTo({ left, behavior: "smooth" });
161
+ else if (right > t.scrollLeft + t.clientWidth) t.scrollTo({ left: right - t.clientWidth, behavior: "smooth" });
162
+ };
163
+ align();
164
+ t.addEventListener("scrollend", align, { once: true });
165
+ }
166
+ function pick(v) {
167
+ emit("update:modelValue", v);
168
+ dropdownOpen.value = false;
169
+ }
170
+ function onKey(e) {
171
+ }
172
+ let ro;
173
+ onMounted(async () => {
174
+ await nextTick();
175
+ measure();
176
+ window.addEventListener("resize", measure);
177
+ document.addEventListener("keydown", onKey);
178
+ if (typeof ResizeObserver !== "undefined" && wrap.value) {
179
+ ro = new ResizeObserver(() => measure());
180
+ ro.observe(wrap.value);
181
+ }
182
+ });
183
+ onBeforeUnmount(() => {
184
+ window.removeEventListener("resize", measure);
185
+ document.removeEventListener("keydown", onKey);
186
+ ro?.disconnect();
187
+ });
188
+ watch(
189
+ () => props.modelValue,
190
+ () => nextTick(() => {
191
+ updateSlider();
192
+ scrollActiveIntoView();
193
+ })
194
+ );
195
+ watch(
196
+ items,
197
+ () => nextTick(() => {
198
+ measure();
199
+ })
200
+ );
201
+ return (_ctx, _cache) => {
202
+ return _openBlock(), _createElementBlock(
203
+ "div",
204
+ _mergeProps({
205
+ ref_key: "wrap",
206
+ ref: wrap,
207
+ class: ["wd-segmented-wrap", {
208
+ "wd-segmented-wrap--auto": __props.overflow === "auto",
209
+ "wd-segmented-wrap--scroll": mode.value === "scroll",
210
+ "wd-segmented-wrap--measuring": mode.value === "dropdown",
211
+ "wd-segmented-wrap--fade-l": canLeft.value,
212
+ "wd-segmented-wrap--fade-r": canRight.value
213
+ }]
214
+ }, _unref(formA11y).attrs.value),
215
+ [
216
+ _createElementVNode("div", {
217
+ ref_key: "track",
218
+ ref: track,
219
+ class: _normalizeClass(["wd-segmented", {
220
+ "wd-segmented--block": __props.block,
221
+ "wd-segmented--dark": __props.tone === "dark",
222
+ "wd-segmented--stack": __props.layout === "stack",
223
+ "wd-segmented--icon-only": __props.iconOnly
224
+ }]),
225
+ "aria-hidden": mode.value === "dropdown",
226
+ role: "tablist",
227
+ onScroll: updateFades
228
+ }, [
229
+ _createElementVNode(
230
+ "span",
231
+ {
232
+ ref_key: "slider",
233
+ ref: slider,
234
+ class: "wd-segmented__slider"
235
+ },
236
+ null,
237
+ 512
238
+ /* NEED_PATCH */
239
+ ),
240
+ (_openBlock(true), _createElementBlock(
241
+ _Fragment,
242
+ null,
243
+ _renderList(items.value, (o) => {
244
+ return _openBlock(), _createElementBlock("button", {
245
+ key: o.value,
246
+ type: "button",
247
+ role: "tab",
248
+ class: _normalizeClass(["wd-segmented__item", { "wd-segmented__item--active": o.value === __props.modelValue }]),
249
+ "aria-selected": o.value === __props.modelValue,
250
+ tabindex: mode.value === "dropdown" ? -1 : 0,
251
+ "aria-label": __props.iconOnly ? o.label : void 0,
252
+ onClick: ($event) => emit("update:modelValue", o.value)
253
+ }, [
254
+ o.icon ? (_openBlock(), _createElementBlock("span", _hoisted_3, [
255
+ _createVNode(_unref(WdIcon_default), {
256
+ name: o.value === __props.modelValue && o.activeIcon ? o.activeIcon : o.icon,
257
+ size: 22
258
+ }, null, 8, ["name"]),
259
+ o.badge ? (_openBlock(), _createElementBlock(
260
+ "i",
261
+ _hoisted_4,
262
+ _toDisplayString(o.badge),
263
+ 1
264
+ /* TEXT */
265
+ )) : _createCommentVNode("v-if", true)
266
+ ])) : _createCommentVNode("v-if", true),
267
+ !__props.iconOnly ? (_openBlock(), _createElementBlock(
268
+ "span",
269
+ _hoisted_5,
270
+ _toDisplayString(o.label),
271
+ 1
272
+ /* TEXT */
273
+ )) : _createCommentVNode("v-if", true)
274
+ ], 10, _hoisted_2);
275
+ }),
276
+ 128
277
+ /* KEYED_FRAGMENT */
278
+ ))
279
+ ], 42, _hoisted_1),
280
+ _createCommentVNode(" \u9009\u9879\u8FC7\u591A\uFF1A\u964D\u7EA7\u4E3A\u4E0B\u62C9\u7B5B\u9009 "),
281
+ mode.value === "dropdown" ? (_openBlock(), _createElementBlock("div", _hoisted_6, [
282
+ _createElementVNode("button", {
283
+ type: "button",
284
+ class: "wd-segmented-picker__trigger",
285
+ "aria-haspopup": "listbox",
286
+ "aria-expanded": dropdownOpen.value,
287
+ onClick: _cache[0] || (_cache[0] = ($event) => dropdownOpen.value = !dropdownOpen.value)
288
+ }, [
289
+ _createElementVNode(
290
+ "span",
291
+ _hoisted_8,
292
+ _toDisplayString(activeLabel.value),
293
+ 1
294
+ /* TEXT */
295
+ ),
296
+ _createElementVNode(
297
+ "span",
298
+ _hoisted_9,
299
+ _toDisplayString(items.value.length) + " \u9879",
300
+ 1
301
+ /* TEXT */
302
+ ),
303
+ _createVNode(_unref(WdIcon_default), {
304
+ class: _normalizeClass(["wd-segmented-picker__caret", { "is-open": dropdownOpen.value }]),
305
+ name: "chevron-down",
306
+ size: 16
307
+ }, null, 8, ["class"])
308
+ ], 8, _hoisted_7),
309
+ (_openBlock(), _createBlock(_Teleport, { to: "body" }, [
310
+ dropdownOpen.value ? (_openBlock(), _createElementBlock("div", {
311
+ key: 0,
312
+ ref_key: "pickerPanel",
313
+ ref: pickerPanel,
314
+ class: "wd-segmented-picker__panel",
315
+ role: "listbox",
316
+ "data-placement": _unref(pickerPlace),
317
+ style: _normalizeStyle({ top: _unref(pickerPos).top + "px", left: _unref(pickerPos).left + "px" })
318
+ }, [
319
+ (_openBlock(true), _createElementBlock(
320
+ _Fragment,
321
+ null,
322
+ _renderList(items.value, (o) => {
323
+ return _openBlock(), _createElementBlock("button", {
324
+ key: o.value,
325
+ type: "button",
326
+ role: "option",
327
+ "aria-selected": o.value === __props.modelValue,
328
+ class: _normalizeClass(["wd-segmented-picker__option", { "wd-segmented-picker__option--active": o.value === __props.modelValue }]),
329
+ onClick: ($event) => pick(o.value)
330
+ }, [
331
+ _createElementVNode(
332
+ "span",
333
+ null,
334
+ _toDisplayString(o.label),
335
+ 1
336
+ /* TEXT */
337
+ ),
338
+ o.value === __props.modelValue ? (_openBlock(), _createBlock(_unref(WdIcon_default), {
339
+ key: 0,
340
+ name: "check",
341
+ size: 15
342
+ })) : _createCommentVNode("v-if", true)
343
+ ], 10, _hoisted_11);
344
+ }),
345
+ 128
346
+ /* KEYED_FRAGMENT */
347
+ ))
348
+ ], 12, _hoisted_10)) : _createCommentVNode("v-if", true)
349
+ ]))
350
+ ])) : _createCommentVNode("v-if", true)
351
+ ],
352
+ 16
353
+ /* FULL_PROPS */
354
+ );
355
+ };
356
+ }
357
+ });
358
+
359
+ export {
360
+ WdSegmented_default
361
+ };