@element-plus/nightly 0.0.20220901 → 0.0.20220902

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 (307) hide show
  1. package/dist/index.full.js +341 -5764
  2. package/dist/index.full.min.js +37 -63
  3. package/dist/index.full.min.js.map +1 -1
  4. package/dist/index.full.min.mjs +37 -63
  5. package/dist/index.full.min.mjs.map +1 -1
  6. package/dist/index.full.mjs +342 -5764
  7. package/dist/locale/af.js +1 -1
  8. package/dist/locale/af.min.js +1 -1
  9. package/dist/locale/af.min.mjs +1 -1
  10. package/dist/locale/af.mjs +1 -1
  11. package/dist/locale/ar.js +1 -1
  12. package/dist/locale/ar.min.js +1 -1
  13. package/dist/locale/ar.min.mjs +1 -1
  14. package/dist/locale/ar.mjs +1 -1
  15. package/dist/locale/az.js +1 -1
  16. package/dist/locale/az.min.js +1 -1
  17. package/dist/locale/az.min.mjs +1 -1
  18. package/dist/locale/az.mjs +1 -1
  19. package/dist/locale/bg.js +1 -1
  20. package/dist/locale/bg.min.js +1 -1
  21. package/dist/locale/bg.min.mjs +1 -1
  22. package/dist/locale/bg.mjs +1 -1
  23. package/dist/locale/bn.js +1 -1
  24. package/dist/locale/bn.min.js +1 -1
  25. package/dist/locale/bn.min.mjs +1 -1
  26. package/dist/locale/bn.mjs +1 -1
  27. package/dist/locale/ca.js +1 -1
  28. package/dist/locale/ca.min.js +1 -1
  29. package/dist/locale/ca.min.mjs +1 -1
  30. package/dist/locale/ca.mjs +1 -1
  31. package/dist/locale/cs.js +1 -1
  32. package/dist/locale/cs.min.js +1 -1
  33. package/dist/locale/cs.min.mjs +1 -1
  34. package/dist/locale/cs.mjs +1 -1
  35. package/dist/locale/da.js +1 -1
  36. package/dist/locale/da.min.js +1 -1
  37. package/dist/locale/da.min.mjs +1 -1
  38. package/dist/locale/da.mjs +1 -1
  39. package/dist/locale/de.js +1 -1
  40. package/dist/locale/de.min.js +1 -1
  41. package/dist/locale/de.min.mjs +1 -1
  42. package/dist/locale/de.mjs +1 -1
  43. package/dist/locale/el.js +1 -1
  44. package/dist/locale/el.min.js +1 -1
  45. package/dist/locale/el.min.mjs +1 -1
  46. package/dist/locale/el.mjs +1 -1
  47. package/dist/locale/en.js +1 -1
  48. package/dist/locale/en.min.js +1 -1
  49. package/dist/locale/en.min.mjs +1 -1
  50. package/dist/locale/en.mjs +1 -1
  51. package/dist/locale/eo.js +1 -1
  52. package/dist/locale/eo.min.js +1 -1
  53. package/dist/locale/eo.min.mjs +1 -1
  54. package/dist/locale/eo.mjs +1 -1
  55. package/dist/locale/es.js +1 -1
  56. package/dist/locale/es.min.js +1 -1
  57. package/dist/locale/es.min.mjs +1 -1
  58. package/dist/locale/es.mjs +1 -1
  59. package/dist/locale/et.js +1 -1
  60. package/dist/locale/et.min.js +1 -1
  61. package/dist/locale/et.min.mjs +1 -1
  62. package/dist/locale/et.mjs +1 -1
  63. package/dist/locale/eu.js +1 -1
  64. package/dist/locale/eu.min.js +1 -1
  65. package/dist/locale/eu.min.mjs +1 -1
  66. package/dist/locale/eu.mjs +1 -1
  67. package/dist/locale/fa.js +1 -1
  68. package/dist/locale/fa.min.js +1 -1
  69. package/dist/locale/fa.min.mjs +1 -1
  70. package/dist/locale/fa.mjs +1 -1
  71. package/dist/locale/fi.js +1 -1
  72. package/dist/locale/fi.min.js +1 -1
  73. package/dist/locale/fi.min.mjs +1 -1
  74. package/dist/locale/fi.mjs +1 -1
  75. package/dist/locale/fr.js +1 -1
  76. package/dist/locale/fr.min.js +1 -1
  77. package/dist/locale/fr.min.mjs +1 -1
  78. package/dist/locale/fr.mjs +1 -1
  79. package/dist/locale/he.js +1 -1
  80. package/dist/locale/he.min.js +1 -1
  81. package/dist/locale/he.min.mjs +1 -1
  82. package/dist/locale/he.mjs +1 -1
  83. package/dist/locale/hr.js +1 -1
  84. package/dist/locale/hr.min.js +1 -1
  85. package/dist/locale/hr.min.mjs +1 -1
  86. package/dist/locale/hr.mjs +1 -1
  87. package/dist/locale/hu.js +1 -1
  88. package/dist/locale/hu.min.js +1 -1
  89. package/dist/locale/hu.min.mjs +1 -1
  90. package/dist/locale/hu.mjs +1 -1
  91. package/dist/locale/hy-am.js +1 -1
  92. package/dist/locale/hy-am.min.js +1 -1
  93. package/dist/locale/hy-am.min.mjs +1 -1
  94. package/dist/locale/hy-am.mjs +1 -1
  95. package/dist/locale/id.js +1 -1
  96. package/dist/locale/id.min.js +1 -1
  97. package/dist/locale/id.min.mjs +1 -1
  98. package/dist/locale/id.mjs +1 -1
  99. package/dist/locale/it.js +1 -1
  100. package/dist/locale/it.min.js +1 -1
  101. package/dist/locale/it.min.mjs +1 -1
  102. package/dist/locale/it.mjs +1 -1
  103. package/dist/locale/ja.js +1 -1
  104. package/dist/locale/ja.min.js +1 -1
  105. package/dist/locale/ja.min.mjs +1 -1
  106. package/dist/locale/ja.mjs +1 -1
  107. package/dist/locale/kk.js +1 -1
  108. package/dist/locale/kk.min.js +1 -1
  109. package/dist/locale/kk.min.mjs +1 -1
  110. package/dist/locale/kk.mjs +1 -1
  111. package/dist/locale/km.js +1 -1
  112. package/dist/locale/km.min.js +1 -1
  113. package/dist/locale/km.min.mjs +1 -1
  114. package/dist/locale/km.mjs +1 -1
  115. package/dist/locale/ko.js +1 -1
  116. package/dist/locale/ko.min.js +1 -1
  117. package/dist/locale/ko.min.mjs +1 -1
  118. package/dist/locale/ko.mjs +1 -1
  119. package/dist/locale/ku.js +1 -1
  120. package/dist/locale/ku.min.js +1 -1
  121. package/dist/locale/ku.min.mjs +1 -1
  122. package/dist/locale/ku.mjs +1 -1
  123. package/dist/locale/ky.js +1 -1
  124. package/dist/locale/ky.min.js +1 -1
  125. package/dist/locale/ky.min.mjs +1 -1
  126. package/dist/locale/ky.mjs +1 -1
  127. package/dist/locale/lt.js +1 -1
  128. package/dist/locale/lt.min.js +1 -1
  129. package/dist/locale/lt.min.mjs +1 -1
  130. package/dist/locale/lt.mjs +1 -1
  131. package/dist/locale/lv.js +1 -1
  132. package/dist/locale/lv.min.js +1 -1
  133. package/dist/locale/lv.min.mjs +1 -1
  134. package/dist/locale/lv.mjs +1 -1
  135. package/dist/locale/mg.js +1 -1
  136. package/dist/locale/mg.min.js +1 -1
  137. package/dist/locale/mg.min.mjs +1 -1
  138. package/dist/locale/mg.mjs +1 -1
  139. package/dist/locale/mn.js +1 -1
  140. package/dist/locale/mn.min.js +1 -1
  141. package/dist/locale/mn.min.mjs +1 -1
  142. package/dist/locale/mn.mjs +1 -1
  143. package/dist/locale/nb-no.js +1 -1
  144. package/dist/locale/nb-no.min.js +1 -1
  145. package/dist/locale/nb-no.min.mjs +1 -1
  146. package/dist/locale/nb-no.mjs +1 -1
  147. package/dist/locale/nl.js +1 -1
  148. package/dist/locale/nl.min.js +1 -1
  149. package/dist/locale/nl.min.mjs +1 -1
  150. package/dist/locale/nl.mjs +1 -1
  151. package/dist/locale/pa.js +1 -1
  152. package/dist/locale/pa.min.js +1 -1
  153. package/dist/locale/pa.min.mjs +1 -1
  154. package/dist/locale/pa.mjs +1 -1
  155. package/dist/locale/pl.js +1 -1
  156. package/dist/locale/pl.min.js +1 -1
  157. package/dist/locale/pl.min.mjs +1 -1
  158. package/dist/locale/pl.mjs +1 -1
  159. package/dist/locale/pt-br.js +1 -1
  160. package/dist/locale/pt-br.min.js +1 -1
  161. package/dist/locale/pt-br.min.mjs +1 -1
  162. package/dist/locale/pt-br.mjs +1 -1
  163. package/dist/locale/pt.js +1 -1
  164. package/dist/locale/pt.min.js +1 -1
  165. package/dist/locale/pt.min.mjs +1 -1
  166. package/dist/locale/pt.mjs +1 -1
  167. package/dist/locale/ro.js +1 -1
  168. package/dist/locale/ro.min.js +1 -1
  169. package/dist/locale/ro.min.mjs +1 -1
  170. package/dist/locale/ro.mjs +1 -1
  171. package/dist/locale/ru.js +1 -1
  172. package/dist/locale/ru.min.js +1 -1
  173. package/dist/locale/ru.min.mjs +1 -1
  174. package/dist/locale/ru.mjs +1 -1
  175. package/dist/locale/sk.js +1 -1
  176. package/dist/locale/sk.min.js +1 -1
  177. package/dist/locale/sk.min.mjs +1 -1
  178. package/dist/locale/sk.mjs +1 -1
  179. package/dist/locale/sl.js +1 -1
  180. package/dist/locale/sl.min.js +1 -1
  181. package/dist/locale/sl.min.mjs +1 -1
  182. package/dist/locale/sl.mjs +1 -1
  183. package/dist/locale/sr.js +1 -1
  184. package/dist/locale/sr.min.js +1 -1
  185. package/dist/locale/sr.min.mjs +1 -1
  186. package/dist/locale/sr.mjs +1 -1
  187. package/dist/locale/sv.js +1 -1
  188. package/dist/locale/sv.min.js +1 -1
  189. package/dist/locale/sv.min.mjs +1 -1
  190. package/dist/locale/sv.mjs +1 -1
  191. package/dist/locale/ta.js +1 -1
  192. package/dist/locale/ta.min.js +1 -1
  193. package/dist/locale/ta.min.mjs +1 -1
  194. package/dist/locale/ta.mjs +1 -1
  195. package/dist/locale/th.js +1 -1
  196. package/dist/locale/th.min.js +1 -1
  197. package/dist/locale/th.min.mjs +1 -1
  198. package/dist/locale/th.mjs +1 -1
  199. package/dist/locale/tk.js +1 -1
  200. package/dist/locale/tk.min.js +1 -1
  201. package/dist/locale/tk.min.mjs +1 -1
  202. package/dist/locale/tk.mjs +1 -1
  203. package/dist/locale/tr.js +1 -1
  204. package/dist/locale/tr.min.js +1 -1
  205. package/dist/locale/tr.min.mjs +1 -1
  206. package/dist/locale/tr.mjs +1 -1
  207. package/dist/locale/ug-cn.js +1 -1
  208. package/dist/locale/ug-cn.min.js +1 -1
  209. package/dist/locale/ug-cn.min.mjs +1 -1
  210. package/dist/locale/ug-cn.mjs +1 -1
  211. package/dist/locale/uk.js +1 -1
  212. package/dist/locale/uk.min.js +1 -1
  213. package/dist/locale/uk.min.mjs +1 -1
  214. package/dist/locale/uk.mjs +1 -1
  215. package/dist/locale/uz-uz.js +1 -1
  216. package/dist/locale/uz-uz.min.js +1 -1
  217. package/dist/locale/uz-uz.min.mjs +1 -1
  218. package/dist/locale/uz-uz.mjs +1 -1
  219. package/dist/locale/vi.js +1 -1
  220. package/dist/locale/vi.min.js +1 -1
  221. package/dist/locale/vi.min.mjs +1 -1
  222. package/dist/locale/vi.mjs +1 -1
  223. package/dist/locale/zh-cn.js +1 -1
  224. package/dist/locale/zh-cn.min.js +1 -1
  225. package/dist/locale/zh-cn.min.mjs +1 -1
  226. package/dist/locale/zh-cn.mjs +1 -1
  227. package/dist/locale/zh-tw.js +1 -1
  228. package/dist/locale/zh-tw.min.js +1 -1
  229. package/dist/locale/zh-tw.min.mjs +1 -1
  230. package/dist/locale/zh-tw.mjs +1 -1
  231. package/es/components/affix/index.mjs +2 -2
  232. package/es/components/affix/src/affix.mjs +26 -115
  233. package/es/components/affix/src/affix.mjs.map +1 -1
  234. package/es/components/affix/src/affix2.mjs +115 -26
  235. package/es/components/affix/src/affix2.mjs.map +1 -1
  236. package/es/components/button/index.mjs +2 -2
  237. package/es/components/button/src/button-group.mjs +1 -1
  238. package/es/components/button/src/button.mjs +118 -53
  239. package/es/components/button/src/button.mjs.map +1 -1
  240. package/es/components/button/src/button2.mjs +53 -118
  241. package/es/components/button/src/button2.mjs.map +1 -1
  242. package/es/components/cascader/index.d.ts +68 -68
  243. package/es/components/cascader/src/index.vue.d.ts +34 -34
  244. package/es/components/cascader-panel/index.mjs +1 -1
  245. package/es/components/cascader-panel/src/config.d.ts +1 -2
  246. package/es/components/cascader-panel/src/config.mjs +1 -2
  247. package/es/components/cascader-panel/src/config.mjs.map +1 -1
  248. package/es/components/cascader-panel/src/index.mjs +2 -2
  249. package/es/components/cascader-panel/src/index.mjs.map +1 -1
  250. package/es/components/cascader-panel/src/index.vue.d.ts +3 -3
  251. package/es/components/cascader-panel/src/node.d.ts +1 -4
  252. package/es/components/cascader-panel/src/node.mjs +1 -6
  253. package/es/components/cascader-panel/src/node.mjs.map +1 -1
  254. package/es/components/cascader-panel/src/types.d.ts +2 -27
  255. package/es/components/cascader-panel/src/types.mjs +1 -6
  256. package/es/components/cascader-panel/src/types.mjs.map +1 -1
  257. package/es/components/date-picker/src/date-picker-com/basic-date-table.mjs +1 -1
  258. package/es/components/date-picker/src/date-picker-com/basic-date-table.mjs.map +1 -1
  259. package/es/components/index.mjs +3 -3
  260. package/es/components/popconfirm/src/popconfirm.mjs +1 -1
  261. package/es/components/tree-v2/src/composables/useTree.mjs +2 -2
  262. package/es/components/tree-v2/src/composables/useTree.mjs.map +1 -1
  263. package/es/index.mjs +3 -3
  264. package/es/version.d.ts +1 -1
  265. package/es/version.mjs +1 -1
  266. package/es/version.mjs.map +1 -1
  267. package/lib/components/affix/index.js +2 -2
  268. package/lib/components/affix/src/affix.js +27 -115
  269. package/lib/components/affix/src/affix.js.map +1 -1
  270. package/lib/components/affix/src/affix2.js +115 -27
  271. package/lib/components/affix/src/affix2.js.map +1 -1
  272. package/lib/components/button/index.js +2 -2
  273. package/lib/components/button/src/button-group.js +1 -1
  274. package/lib/components/button/src/button.js +118 -56
  275. package/lib/components/button/src/button.js.map +1 -1
  276. package/lib/components/button/src/button2.js +56 -118
  277. package/lib/components/button/src/button2.js.map +1 -1
  278. package/lib/components/cascader/index.d.ts +68 -68
  279. package/lib/components/cascader/src/index.vue.d.ts +34 -34
  280. package/lib/components/cascader-panel/index.js +0 -1
  281. package/lib/components/cascader-panel/index.js.map +1 -1
  282. package/lib/components/cascader-panel/src/config.d.ts +1 -2
  283. package/lib/components/cascader-panel/src/config.js +1 -2
  284. package/lib/components/cascader-panel/src/config.js.map +1 -1
  285. package/lib/components/cascader-panel/src/index.js +1 -1
  286. package/lib/components/cascader-panel/src/index.js.map +1 -1
  287. package/lib/components/cascader-panel/src/index.vue.d.ts +3 -3
  288. package/lib/components/cascader-panel/src/node.d.ts +1 -4
  289. package/lib/components/cascader-panel/src/node.js +0 -6
  290. package/lib/components/cascader-panel/src/node.js.map +1 -1
  291. package/lib/components/cascader-panel/src/types.d.ts +2 -27
  292. package/lib/components/cascader-panel/src/types.js +0 -6
  293. package/lib/components/cascader-panel/src/types.js.map +1 -1
  294. package/lib/components/date-picker/src/date-picker-com/basic-date-table.js +2 -2
  295. package/lib/components/date-picker/src/date-picker-com/basic-date-table.js.map +1 -1
  296. package/lib/components/index.js +2 -3
  297. package/lib/components/index.js.map +1 -1
  298. package/lib/components/popconfirm/src/popconfirm.js +1 -1
  299. package/lib/components/tree-v2/src/composables/useTree.js +2 -2
  300. package/lib/components/tree-v2/src/composables/useTree.js.map +1 -1
  301. package/lib/index.js +2 -3
  302. package/lib/index.js.map +1 -1
  303. package/lib/version.d.ts +1 -1
  304. package/lib/version.js +1 -1
  305. package/lib/version.js.map +1 -1
  306. package/package.json +2 -2
  307. package/web-types.json +1 -1
@@ -1,121 +1,32 @@
1
- import { defineComponent, shallowRef, ref, computed, watch, onMounted, watchEffect, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createElementVNode, renderSlot } from 'vue';
2
- import { useWindowSize, useElementBounding, useEventListener } from '@vueuse/core';
3
1
  import '../../../utils/index.mjs';
4
- import '../../../hooks/index.mjs';
5
- import { affixProps, affixEmits } from './affix2.mjs';
6
- import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
7
- import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
8
- import { throwError } from '../../../utils/error.mjs';
9
- import { getScrollContainer } from '../../../utils/dom/scroll.mjs';
2
+ import '../../../constants/index.mjs';
3
+ import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
4
+ import { isNumber, isBoolean } from '@vueuse/core';
5
+ import { CHANGE_EVENT } from '../../../constants/event.mjs';
10
6
 
11
- const __default__ = {
12
- name: "ElAffix"
13
- };
14
- const _sfc_main = /* @__PURE__ */ defineComponent({
15
- ...__default__,
16
- props: affixProps,
17
- emits: affixEmits,
18
- setup(__props, { expose, emit }) {
19
- const props = __props;
20
- const COMPONENT_NAME = "ElAffix";
21
- const ns = useNamespace("affix");
22
- const target = shallowRef();
23
- const root = shallowRef();
24
- const scrollContainer = shallowRef();
25
- const { height: windowHeight } = useWindowSize();
26
- const {
27
- height: rootHeight,
28
- width: rootWidth,
29
- top: rootTop,
30
- bottom: rootBottom,
31
- update: updateRoot
32
- } = useElementBounding(root);
33
- const targetRect = useElementBounding(target);
34
- const fixed = ref(false);
35
- const scrollTop = ref(0);
36
- const transform = ref(0);
37
- const rootStyle = computed(() => {
38
- return {
39
- height: fixed.value ? `${rootHeight.value}px` : "",
40
- width: fixed.value ? `${rootWidth.value}px` : ""
41
- };
42
- });
43
- const affixStyle = computed(() => {
44
- if (!fixed.value)
45
- return {};
46
- const offset = props.offset ? `${props.offset}px` : 0;
47
- return {
48
- height: `${rootHeight.value}px`,
49
- width: `${rootWidth.value}px`,
50
- top: props.position === "top" ? offset : "",
51
- bottom: props.position === "bottom" ? offset : "",
52
- transform: transform.value ? `translateY(${transform.value}px)` : "",
53
- zIndex: props.zIndex
54
- };
55
- });
56
- const update = () => {
57
- if (!scrollContainer.value)
58
- return;
59
- scrollTop.value = scrollContainer.value instanceof Window ? document.documentElement.scrollTop : scrollContainer.value.scrollTop || 0;
60
- if (props.position === "top") {
61
- if (props.target) {
62
- const difference = targetRect.bottom.value - props.offset - rootHeight.value;
63
- fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0;
64
- transform.value = difference < 0 ? difference : 0;
65
- } else {
66
- fixed.value = props.offset > rootTop.value;
67
- }
68
- } else if (props.target) {
69
- const difference = windowHeight.value - targetRect.top.value - props.offset - rootHeight.value;
70
- fixed.value = windowHeight.value - props.offset < rootBottom.value && windowHeight.value > targetRect.top.value;
71
- transform.value = difference < 0 ? -difference : 0;
72
- } else {
73
- fixed.value = windowHeight.value - props.offset < rootBottom.value;
74
- }
75
- };
76
- const handleScroll = () => {
77
- emit("scroll", {
78
- scrollTop: scrollTop.value,
79
- fixed: fixed.value
80
- });
81
- };
82
- watch(fixed, (val) => emit("change", val));
83
- onMounted(() => {
84
- var _a;
85
- if (props.target) {
86
- target.value = (_a = document.querySelector(props.target)) != null ? _a : void 0;
87
- if (!target.value)
88
- throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`);
89
- } else {
90
- target.value = document.documentElement;
91
- }
92
- scrollContainer.value = getScrollContainer(root.value, true);
93
- updateRoot();
94
- });
95
- useEventListener(scrollContainer, "scroll", handleScroll);
96
- watchEffect(update);
97
- expose({
98
- update,
99
- updateRoot
100
- });
101
- return (_ctx, _cache) => {
102
- return openBlock(), createElementBlock("div", {
103
- ref_key: "root",
104
- ref: root,
105
- class: normalizeClass(unref(ns).b()),
106
- style: normalizeStyle(unref(rootStyle))
107
- }, [
108
- createElementVNode("div", {
109
- class: normalizeClass({ [unref(ns).m("fixed")]: fixed.value }),
110
- style: normalizeStyle(unref(affixStyle))
111
- }, [
112
- renderSlot(_ctx.$slots, "default")
113
- ], 6)
114
- ], 6);
115
- };
7
+ const affixProps = buildProps({
8
+ zIndex: {
9
+ type: definePropType([Number, String]),
10
+ default: 100
11
+ },
12
+ target: {
13
+ type: String,
14
+ default: ""
15
+ },
16
+ offset: {
17
+ type: Number,
18
+ default: 0
19
+ },
20
+ position: {
21
+ type: String,
22
+ values: ["top", "bottom"],
23
+ default: "top"
116
24
  }
117
25
  });
118
- var Affix = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/affix/src/affix.vue"]]);
26
+ const affixEmits = {
27
+ scroll: ({ scrollTop, fixed }) => isNumber(scrollTop) && isBoolean(fixed),
28
+ [CHANGE_EVENT]: (fixed) => isBoolean(fixed)
29
+ };
119
30
 
120
- export { Affix as default };
31
+ export { affixEmits, affixProps };
121
32
  //# sourceMappingURL=affix.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"affix.mjs","sources":["../../../../../../packages/components/affix/src/affix.vue"],"sourcesContent":["<template>\n <div ref=\"root\" :class=\"ns.b()\" :style=\"rootStyle\">\n <div :class=\"{ [ns.m('fixed')]: fixed }\" :style=\"affixStyle\">\n <slot />\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'\nimport {\n useElementBounding,\n useEventListener,\n useWindowSize,\n} from '@vueuse/core'\nimport { getScrollContainer, throwError } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { affixEmits, affixProps } from './affix'\nimport type { CSSProperties } from 'vue'\n\nconst COMPONENT_NAME = 'ElAffix'\ndefineOptions({\n name: 'ElAffix',\n})\n\nconst props = defineProps(affixProps)\nconst emit = defineEmits(affixEmits)\n\nconst ns = useNamespace('affix')\n\nconst target = shallowRef<HTMLElement>()\nconst root = shallowRef<HTMLDivElement>()\nconst scrollContainer = shallowRef<HTMLElement | Window>()\nconst { height: windowHeight } = useWindowSize()\nconst {\n height: rootHeight,\n width: rootWidth,\n top: rootTop,\n bottom: rootBottom,\n update: updateRoot,\n} = useElementBounding(root)\nconst targetRect = useElementBounding(target)\n\nconst fixed = ref(false)\nconst scrollTop = ref(0)\nconst transform = ref(0)\n\nconst rootStyle = computed<CSSProperties>(() => {\n return {\n height: fixed.value ? `${rootHeight.value}px` : '',\n width: fixed.value ? `${rootWidth.value}px` : '',\n }\n})\n\nconst affixStyle = computed<CSSProperties>(() => {\n if (!fixed.value) return {}\n\n const offset = props.offset ? `${props.offset}px` : 0\n return {\n height: `${rootHeight.value}px`,\n width: `${rootWidth.value}px`,\n top: props.position === 'top' ? offset : '',\n bottom: props.position === 'bottom' ? offset : '',\n transform: transform.value ? `translateY(${transform.value}px)` : '',\n zIndex: props.zIndex,\n }\n})\n\nconst update = () => {\n if (!scrollContainer.value) return\n\n scrollTop.value =\n scrollContainer.value instanceof Window\n ? document.documentElement.scrollTop\n : scrollContainer.value.scrollTop || 0\n\n if (props.position === 'top') {\n if (props.target) {\n const difference =\n targetRect.bottom.value - props.offset - rootHeight.value\n fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0\n transform.value = difference < 0 ? difference : 0\n } else {\n fixed.value = props.offset > rootTop.value\n }\n } else if (props.target) {\n const difference =\n windowHeight.value -\n targetRect.top.value -\n props.offset -\n rootHeight.value\n fixed.value =\n windowHeight.value - props.offset < rootBottom.value &&\n windowHeight.value > targetRect.top.value\n transform.value = difference < 0 ? -difference : 0\n } else {\n fixed.value = windowHeight.value - props.offset < rootBottom.value\n }\n}\n\nconst handleScroll = () => {\n emit('scroll', {\n scrollTop: scrollTop.value,\n fixed: fixed.value,\n })\n}\n\nwatch(fixed, (val) => emit('change', val))\n\nonMounted(() => {\n if (props.target) {\n target.value =\n document.querySelector<HTMLElement>(props.target) ?? undefined\n if (!target.value)\n throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`)\n } else {\n target.value = document.documentElement\n }\n scrollContainer.value = getScrollContainer(root.value!, true)\n updateRoot()\n})\n\nuseEventListener(scrollContainer, 'scroll', handleScroll)\nwatchEffect(update)\n\ndefineExpose({\n /** @description update affix status */\n update,\n /** @description update rootRect info */\n updateRoot,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,IAAA,MAAA,cAAA,GAAA,SAAA,CAAA;AAQA,IAAA,MAAA,EAAA,GAAA,aAAA,OAAA,CAAA,CAAA;AAEA,IAAA,MAAA,SAAA,UAAA,EAAA,CAAA;AACA,IAAA,MAAA,OAAA,UAAA,EAAA,CAAA;AACA,IAAA,MAAA,kBAAA,UAAA,EAAA,CAAA;AACA,IAAA,MAAA,EAAA,MAAA,EAAA,YAAA,EAAA,GAAA,aAAA,EAAA,CAAA;AACA,IAAA,MAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,MACA,KAAA,EAAA,SAAA;AAAA,MACA,GAAA,EAAA,OAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,KAAA,GACA,mBAAA,IAAA,CAAA,CAAA;AACA,IAAA,MAAA,UAAA,GAAA,mBAAA,MAAA,CAAA,CAAA;AAEA,IAAA,MAAA,KAAA,GAAA,IAAA,KAAA,CAAA,CAAA;AACA,IAAA,MAAA,SAAA,GAAA,IAAA,CAAA,CAAA,CAA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KAAA;AAAA,OACA,CAAA,CAAA;AAAA,KACA,CAAA;AAEA,IAAA,KAAA,CAAA,OAAA,CAAA,GAAA,KAAA,IAAA,CAAA,QAAA,EAAA,GAAA,CAAA,CAAA,CAAA;AAEA,IAAA,SAAA,CAAA,MAAA;AACA,MAAA,IAAA;AACA,MAAA,IAAA,KAAA,CACA,MAAA,EAAA;AACA,QAAA,MAAA,CAAA,KAAA,GAAA,CAAA,EAAA,GAAA,QAAA,CAAA,aAAA,CAAA,KAAA,CAAA,MAAA,CAAA,KAAA,IAAA,GAAA,EAAA,GAAA,KAAA,CAAA,CAAA;AACA,QAAA,IAAA,CAAA,MAAA,CAAA,KAAA;AAAA,UACA,UAAA,CAAA,cAAA,EAAA,CAAA,uBAAA,EAAA,KAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA;AACA,OAAA,MAAA;AAAA,QACA,MAAA,CAAA,KAAA,GAAA,QAAA,CAAA,eAAA,CAAA;AACA,OAAA;AACA,MAAA,eAAA,CAAA,KAAA,GAAA,kBAAA,CAAA,IAAA,CAAA,KAAA,EAAA,IAAA,CAAA,CAAA;AAAA,MACA,UAAA,EAAA,CAAA;AAEA,KAAA,CAAA,CAAA;AACA,IAAA,gBAAA,CAAA,eAAA,EAAA,QAAA,EAAA,YAAA,CAAA,CAAA;AAEA,IAAA,WAAA,CAAA,MAAA,CAAA,CAAA;AAAA,IAEA,MAAA,CAAA;AAAA,MAEA,MAAA;AAAA,MACA,UAAA;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"affix.mjs","sources":["../../../../../../packages/components/affix/src/affix.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n isBoolean,\n isNumber,\n} from '@element-plus/utils'\nimport { CHANGE_EVENT } from '@element-plus/constants'\nimport type { ExtractPropTypes } from 'vue'\nimport type { ZIndexProperty } from 'csstype'\nimport type Affix from './affix.vue'\n\nexport const affixProps = buildProps({\n zIndex: {\n type: definePropType<ZIndexProperty>([Number, String]),\n default: 100,\n },\n target: {\n type: String,\n default: '',\n },\n offset: {\n type: Number,\n default: 0,\n },\n position: {\n type: String,\n values: ['top', 'bottom'],\n default: 'top',\n },\n} as const)\nexport type AffixProps = ExtractPropTypes<typeof affixProps>\n\nexport const affixEmits = {\n scroll: ({ scrollTop, fixed }: { scrollTop: number; fixed: boolean }) =>\n isNumber(scrollTop) && isBoolean(fixed),\n [CHANGE_EVENT]: (fixed: boolean) => isBoolean(fixed),\n}\nexport type AffixEmits = typeof affixEmits\n\nexport type AffixInstance = InstanceType<typeof Affix>\n"],"names":[],"mappings":";;;;;;AAOY,MAAC,UAAU,GAAG,UAAU,CAAC;AACrC,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1C,IAAI,OAAO,EAAE,GAAG;AAChB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,CAAC;AACd,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC;AAC7B,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,UAAU,GAAG;AAC1B,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC;AAC3E,EAAE,CAAC,YAAY,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK,CAAC;AAC7C;;;;"}
@@ -1,32 +1,121 @@
1
+ import { defineComponent, shallowRef, ref, computed, watch, onMounted, watchEffect, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createElementVNode, renderSlot } from 'vue';
2
+ import { useWindowSize, useElementBounding, useEventListener } from '@vueuse/core';
1
3
  import '../../../utils/index.mjs';
2
- import '../../../constants/index.mjs';
3
- import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
4
- import { isNumber, isBoolean } from '@vueuse/core';
5
- import { CHANGE_EVENT } from '../../../constants/event.mjs';
4
+ import '../../../hooks/index.mjs';
5
+ import { affixProps, affixEmits } from './affix.mjs';
6
+ import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
7
+ import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
8
+ import { throwError } from '../../../utils/error.mjs';
9
+ import { getScrollContainer } from '../../../utils/dom/scroll.mjs';
6
10
 
7
- const affixProps = buildProps({
8
- zIndex: {
9
- type: definePropType([Number, String]),
10
- default: 100
11
- },
12
- target: {
13
- type: String,
14
- default: ""
15
- },
16
- offset: {
17
- type: Number,
18
- default: 0
19
- },
20
- position: {
21
- type: String,
22
- values: ["top", "bottom"],
23
- default: "top"
11
+ const __default__ = {
12
+ name: "ElAffix"
13
+ };
14
+ const _sfc_main = /* @__PURE__ */ defineComponent({
15
+ ...__default__,
16
+ props: affixProps,
17
+ emits: affixEmits,
18
+ setup(__props, { expose, emit }) {
19
+ const props = __props;
20
+ const COMPONENT_NAME = "ElAffix";
21
+ const ns = useNamespace("affix");
22
+ const target = shallowRef();
23
+ const root = shallowRef();
24
+ const scrollContainer = shallowRef();
25
+ const { height: windowHeight } = useWindowSize();
26
+ const {
27
+ height: rootHeight,
28
+ width: rootWidth,
29
+ top: rootTop,
30
+ bottom: rootBottom,
31
+ update: updateRoot
32
+ } = useElementBounding(root);
33
+ const targetRect = useElementBounding(target);
34
+ const fixed = ref(false);
35
+ const scrollTop = ref(0);
36
+ const transform = ref(0);
37
+ const rootStyle = computed(() => {
38
+ return {
39
+ height: fixed.value ? `${rootHeight.value}px` : "",
40
+ width: fixed.value ? `${rootWidth.value}px` : ""
41
+ };
42
+ });
43
+ const affixStyle = computed(() => {
44
+ if (!fixed.value)
45
+ return {};
46
+ const offset = props.offset ? `${props.offset}px` : 0;
47
+ return {
48
+ height: `${rootHeight.value}px`,
49
+ width: `${rootWidth.value}px`,
50
+ top: props.position === "top" ? offset : "",
51
+ bottom: props.position === "bottom" ? offset : "",
52
+ transform: transform.value ? `translateY(${transform.value}px)` : "",
53
+ zIndex: props.zIndex
54
+ };
55
+ });
56
+ const update = () => {
57
+ if (!scrollContainer.value)
58
+ return;
59
+ scrollTop.value = scrollContainer.value instanceof Window ? document.documentElement.scrollTop : scrollContainer.value.scrollTop || 0;
60
+ if (props.position === "top") {
61
+ if (props.target) {
62
+ const difference = targetRect.bottom.value - props.offset - rootHeight.value;
63
+ fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0;
64
+ transform.value = difference < 0 ? difference : 0;
65
+ } else {
66
+ fixed.value = props.offset > rootTop.value;
67
+ }
68
+ } else if (props.target) {
69
+ const difference = windowHeight.value - targetRect.top.value - props.offset - rootHeight.value;
70
+ fixed.value = windowHeight.value - props.offset < rootBottom.value && windowHeight.value > targetRect.top.value;
71
+ transform.value = difference < 0 ? -difference : 0;
72
+ } else {
73
+ fixed.value = windowHeight.value - props.offset < rootBottom.value;
74
+ }
75
+ };
76
+ const handleScroll = () => {
77
+ emit("scroll", {
78
+ scrollTop: scrollTop.value,
79
+ fixed: fixed.value
80
+ });
81
+ };
82
+ watch(fixed, (val) => emit("change", val));
83
+ onMounted(() => {
84
+ var _a;
85
+ if (props.target) {
86
+ target.value = (_a = document.querySelector(props.target)) != null ? _a : void 0;
87
+ if (!target.value)
88
+ throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`);
89
+ } else {
90
+ target.value = document.documentElement;
91
+ }
92
+ scrollContainer.value = getScrollContainer(root.value, true);
93
+ updateRoot();
94
+ });
95
+ useEventListener(scrollContainer, "scroll", handleScroll);
96
+ watchEffect(update);
97
+ expose({
98
+ update,
99
+ updateRoot
100
+ });
101
+ return (_ctx, _cache) => {
102
+ return openBlock(), createElementBlock("div", {
103
+ ref_key: "root",
104
+ ref: root,
105
+ class: normalizeClass(unref(ns).b()),
106
+ style: normalizeStyle(unref(rootStyle))
107
+ }, [
108
+ createElementVNode("div", {
109
+ class: normalizeClass({ [unref(ns).m("fixed")]: fixed.value }),
110
+ style: normalizeStyle(unref(affixStyle))
111
+ }, [
112
+ renderSlot(_ctx.$slots, "default")
113
+ ], 6)
114
+ ], 6);
115
+ };
24
116
  }
25
117
  });
26
- const affixEmits = {
27
- scroll: ({ scrollTop, fixed }) => isNumber(scrollTop) && isBoolean(fixed),
28
- [CHANGE_EVENT]: (fixed) => isBoolean(fixed)
29
- };
118
+ var Affix = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/affix/src/affix.vue"]]);
30
119
 
31
- export { affixEmits, affixProps };
120
+ export { Affix as default };
32
121
  //# sourceMappingURL=affix2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"affix2.mjs","sources":["../../../../../../packages/components/affix/src/affix.ts"],"sourcesContent":["import {\n buildProps,\n definePropType,\n isBoolean,\n isNumber,\n} from '@element-plus/utils'\nimport { CHANGE_EVENT } from '@element-plus/constants'\nimport type { ExtractPropTypes } from 'vue'\nimport type { ZIndexProperty } from 'csstype'\nimport type Affix from './affix.vue'\n\nexport const affixProps = buildProps({\n zIndex: {\n type: definePropType<ZIndexProperty>([Number, String]),\n default: 100,\n },\n target: {\n type: String,\n default: '',\n },\n offset: {\n type: Number,\n default: 0,\n },\n position: {\n type: String,\n values: ['top', 'bottom'],\n default: 'top',\n },\n} as const)\nexport type AffixProps = ExtractPropTypes<typeof affixProps>\n\nexport const affixEmits = {\n scroll: ({ scrollTop, fixed }: { scrollTop: number; fixed: boolean }) =>\n isNumber(scrollTop) && isBoolean(fixed),\n [CHANGE_EVENT]: (fixed: boolean) => isBoolean(fixed),\n}\nexport type AffixEmits = typeof affixEmits\n\nexport type AffixInstance = InstanceType<typeof Affix>\n"],"names":[],"mappings":";;;;;;AAOY,MAAC,UAAU,GAAG,UAAU,CAAC;AACrC,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1C,IAAI,OAAO,EAAE,GAAG;AAChB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,CAAC;AACd,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC;AAC7B,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,UAAU,GAAG;AAC1B,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC;AAC3E,EAAE,CAAC,YAAY,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK,CAAC;AAC7C;;;;"}
1
+ {"version":3,"file":"affix2.mjs","sources":["../../../../../../packages/components/affix/src/affix.vue"],"sourcesContent":["<template>\n <div ref=\"root\" :class=\"ns.b()\" :style=\"rootStyle\">\n <div :class=\"{ [ns.m('fixed')]: fixed }\" :style=\"affixStyle\">\n <slot />\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, onMounted, ref, shallowRef, watch, watchEffect } from 'vue'\nimport {\n useElementBounding,\n useEventListener,\n useWindowSize,\n} from '@vueuse/core'\nimport { getScrollContainer, throwError } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { affixEmits, affixProps } from './affix'\nimport type { CSSProperties } from 'vue'\n\nconst COMPONENT_NAME = 'ElAffix'\ndefineOptions({\n name: 'ElAffix',\n})\n\nconst props = defineProps(affixProps)\nconst emit = defineEmits(affixEmits)\n\nconst ns = useNamespace('affix')\n\nconst target = shallowRef<HTMLElement>()\nconst root = shallowRef<HTMLDivElement>()\nconst scrollContainer = shallowRef<HTMLElement | Window>()\nconst { height: windowHeight } = useWindowSize()\nconst {\n height: rootHeight,\n width: rootWidth,\n top: rootTop,\n bottom: rootBottom,\n update: updateRoot,\n} = useElementBounding(root)\nconst targetRect = useElementBounding(target)\n\nconst fixed = ref(false)\nconst scrollTop = ref(0)\nconst transform = ref(0)\n\nconst rootStyle = computed<CSSProperties>(() => {\n return {\n height: fixed.value ? `${rootHeight.value}px` : '',\n width: fixed.value ? `${rootWidth.value}px` : '',\n }\n})\n\nconst affixStyle = computed<CSSProperties>(() => {\n if (!fixed.value) return {}\n\n const offset = props.offset ? `${props.offset}px` : 0\n return {\n height: `${rootHeight.value}px`,\n width: `${rootWidth.value}px`,\n top: props.position === 'top' ? offset : '',\n bottom: props.position === 'bottom' ? offset : '',\n transform: transform.value ? `translateY(${transform.value}px)` : '',\n zIndex: props.zIndex,\n }\n})\n\nconst update = () => {\n if (!scrollContainer.value) return\n\n scrollTop.value =\n scrollContainer.value instanceof Window\n ? document.documentElement.scrollTop\n : scrollContainer.value.scrollTop || 0\n\n if (props.position === 'top') {\n if (props.target) {\n const difference =\n targetRect.bottom.value - props.offset - rootHeight.value\n fixed.value = props.offset > rootTop.value && targetRect.bottom.value > 0\n transform.value = difference < 0 ? difference : 0\n } else {\n fixed.value = props.offset > rootTop.value\n }\n } else if (props.target) {\n const difference =\n windowHeight.value -\n targetRect.top.value -\n props.offset -\n rootHeight.value\n fixed.value =\n windowHeight.value - props.offset < rootBottom.value &&\n windowHeight.value > targetRect.top.value\n transform.value = difference < 0 ? -difference : 0\n } else {\n fixed.value = windowHeight.value - props.offset < rootBottom.value\n }\n}\n\nconst handleScroll = () => {\n emit('scroll', {\n scrollTop: scrollTop.value,\n fixed: fixed.value,\n })\n}\n\nwatch(fixed, (val) => emit('change', val))\n\nonMounted(() => {\n if (props.target) {\n target.value =\n document.querySelector<HTMLElement>(props.target) ?? undefined\n if (!target.value)\n throwError(COMPONENT_NAME, `Target is not existed: ${props.target}`)\n } else {\n target.value = document.documentElement\n }\n scrollContainer.value = getScrollContainer(root.value!, true)\n updateRoot()\n})\n\nuseEventListener(scrollContainer, 'scroll', handleScroll)\nwatchEffect(update)\n\ndefineExpose({\n /** @description update affix status */\n update,\n /** @description update rootRect info */\n updateRoot,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,IAAA,MAAA,cAAA,GAAA,SAAA,CAAA;AAQA,IAAA,MAAA,EAAA,GAAA,aAAA,OAAA,CAAA,CAAA;AAEA,IAAA,MAAA,SAAA,UAAA,EAAA,CAAA;AACA,IAAA,MAAA,OAAA,UAAA,EAAA,CAAA;AACA,IAAA,MAAA,kBAAA,UAAA,EAAA,CAAA;AACA,IAAA,MAAA,EAAA,MAAA,EAAA,YAAA,EAAA,GAAA,aAAA,EAAA,CAAA;AACA,IAAA,MAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,MACA,KAAA,EAAA,SAAA;AAAA,MACA,GAAA,EAAA,OAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,MACA,MAAA,EAAA,UAAA;AAAA,KAAA,GACA,mBAAA,IAAA,CAAA,CAAA;AACA,IAAA,MAAA,UAAA,GAAA,mBAAA,MAAA,CAAA,CAAA;AAEA,IAAA,MAAA,KAAA,GAAA,IAAA,KAAA,CAAA,CAAA;AACA,IAAA,MAAA,SAAA,GAAA,IAAA,CAAA,CAAA,CAAA;AACA,IAAA,MAAA,SAAA,GAAA,IAAA,CAAA,CAAA,CAAA;AAEA,IAAA,MAAA,SAAA,GAAA,SAAA,MAAA;AACA,MAAA,OAAA;AAAA,QACA,MAAA,EAAA,KAAA,CAAA,KAAA,GAAA,CAAA,EAAA,WAAA,KAAA,CAAA,EAAA,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A,IAAA,KAAA,CACA,MAAA,EAAA;AACA,QAAA,MAAA,CAAA,KAAA,GAAA,CAAA,EAAA,GAAA,QAAA,CAAA,aAAA,CAAA,KAAA,CAAA,MAAA,CAAA,KAAA,IAAA,GAAA,EAAA,GAAA,KAAA,CAAA,CAAA;AACA,QAAA,IAAA,CAAA,MAAA,CAAA,KAAA;AAAA,UACA,UAAA,CAAA,cAAA,EAAA,CAAA,uBAAA,EAAA,KAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA;AACA,OAAA,MAAA;AAAA,QACA,MAAA,CAAA,KAAA,GAAA,QAAA,CAAA,eAAA,CAAA;AACA,OAAA;AACA,MAAA,eAAA,CAAA,KAAA,GAAA,kBAAA,CAAA,IAAA,CAAA,KAAA,EAAA,IAAA,CAAA,CAAA;AAAA,MACA,UAAA,EAAA,CAAA;AAEA,KAAA,CAAA,CAAA;AACA,IAAA,gBAAA,CAAA,eAAA,EAAA,QAAA,EAAA,YAAA,CAAA,CAAA;AAEA,IAAA,WAAA,CAAA,MAAA,CAAA,CAAA;AAAA,IAEA,MAAA,CAAA;AAAA,MAEA,MAAA;AAAA,MACA,UAAA;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import '../../utils/index.mjs';
2
- import Button from './src/button2.mjs';
2
+ import Button from './src/button.mjs';
3
3
  import ButtonGroup from './src/button-group2.mjs';
4
- export { buttonEmits, buttonNativeTypes, buttonProps, buttonTypes } from './src/button.mjs';
4
+ export { buttonEmits, buttonNativeTypes, buttonProps, buttonTypes } from './src/button2.mjs';
5
5
  import { withInstall, withNoopInstall } from '../../utils/vue/install.mjs';
6
6
 
7
7
  const ElButton = withInstall(Button, {
@@ -1,4 +1,4 @@
1
- import { buttonProps } from './button.mjs';
1
+ import { buttonProps } from './button2.mjs';
2
2
 
3
3
  const buttonGroupProps = {
4
4
  size: buttonProps.size,
@@ -1,59 +1,124 @@
1
+ import { defineComponent, useSlots, computed, inject, ref, Text, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, Fragment, renderSlot, createBlock, withCtx, resolveDynamicComponent, createCommentVNode } from 'vue';
2
+ import { ElIcon } from '../../icon/index.mjs';
1
3
  import '../../../hooks/index.mjs';
2
- import '../../../utils/index.mjs';
3
- import { Loading } from '@element-plus/icons-vue';
4
- import { buildProps } from '../../../utils/vue/props/runtime.mjs';
5
- import { useSizeProp } from '../../../hooks/use-common-props/index.mjs';
6
- import { iconPropType } from '../../../utils/vue/icon.mjs';
4
+ import '../../../tokens/index.mjs';
5
+ import { buttonProps, buttonEmits } from './button2.mjs';
6
+ import { useButtonCustomStyle } from './button-custom.mjs';
7
+ import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
8
+ import { useDeprecated } from '../../../hooks/use-deprecated/index.mjs';
9
+ import { buttonGroupContextKey } from '../../../tokens/button.mjs';
10
+ import { useGlobalConfig } from '../../../hooks/use-global-config/index.mjs';
11
+ import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
12
+ import { useFormItem } from '../../../hooks/use-form-item/index.mjs';
13
+ import { useSize, useDisabled } from '../../../hooks/use-common-props/index.mjs';
7
14
 
8
- const buttonTypes = [
9
- "default",
10
- "primary",
11
- "success",
12
- "warning",
13
- "info",
14
- "danger",
15
- "text",
16
- ""
17
- ];
18
- const buttonNativeTypes = ["button", "submit", "reset"];
19
- const buttonProps = buildProps({
20
- size: useSizeProp,
21
- disabled: Boolean,
22
- type: {
23
- type: String,
24
- values: buttonTypes,
25
- default: ""
26
- },
27
- icon: {
28
- type: iconPropType
29
- },
30
- nativeType: {
31
- type: String,
32
- values: buttonNativeTypes,
33
- default: "button"
34
- },
35
- loading: Boolean,
36
- loadingIcon: {
37
- type: iconPropType,
38
- default: () => Loading
39
- },
40
- plain: Boolean,
41
- text: Boolean,
42
- link: Boolean,
43
- bg: Boolean,
44
- autofocus: Boolean,
45
- round: Boolean,
46
- circle: Boolean,
47
- color: String,
48
- dark: Boolean,
49
- autoInsertSpace: {
50
- type: Boolean,
51
- default: void 0
15
+ const _hoisted_1 = ["aria-disabled", "disabled", "autofocus", "type"];
16
+ const __default__ = {
17
+ name: "ElButton"
18
+ };
19
+ const _sfc_main = /* @__PURE__ */ defineComponent({
20
+ ...__default__,
21
+ props: buttonProps,
22
+ emits: buttonEmits,
23
+ setup(__props, { expose, emit }) {
24
+ const props = __props;
25
+ const slots = useSlots();
26
+ useDeprecated({
27
+ from: "type.text",
28
+ replacement: "type.link",
29
+ version: "3.0.0",
30
+ scope: "props",
31
+ ref: "https://element-plus.org/en-US/component/button.html#button-attributes"
32
+ }, computed(() => props.type === "text"));
33
+ const buttonGroupContext = inject(buttonGroupContextKey, void 0);
34
+ const globalConfig = useGlobalConfig("button");
35
+ const ns = useNamespace("button");
36
+ const { form } = useFormItem();
37
+ const _size = useSize(computed(() => buttonGroupContext == null ? void 0 : buttonGroupContext.size));
38
+ const _disabled = useDisabled();
39
+ const _ref = ref();
40
+ const _type = computed(() => props.type || (buttonGroupContext == null ? void 0 : buttonGroupContext.type) || "");
41
+ const autoInsertSpace = computed(() => {
42
+ var _a, _b, _c;
43
+ return (_c = (_b = props.autoInsertSpace) != null ? _b : (_a = globalConfig.value) == null ? void 0 : _a.autoInsertSpace) != null ? _c : false;
44
+ });
45
+ const shouldAddSpace = computed(() => {
46
+ var _a;
47
+ const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots);
48
+ if (autoInsertSpace.value && (defaultSlot == null ? void 0 : defaultSlot.length) === 1) {
49
+ const slot = defaultSlot[0];
50
+ if ((slot == null ? void 0 : slot.type) === Text) {
51
+ const text = slot.children;
52
+ return /^\p{Unified_Ideograph}{2}$/u.test(text.trim());
53
+ }
54
+ }
55
+ return false;
56
+ });
57
+ const buttonStyle = useButtonCustomStyle(props);
58
+ const handleClick = (evt) => {
59
+ if (props.nativeType === "reset") {
60
+ form == null ? void 0 : form.resetFields();
61
+ }
62
+ emit("click", evt);
63
+ };
64
+ expose({
65
+ ref: _ref,
66
+ size: _size,
67
+ type: _type,
68
+ disabled: _disabled,
69
+ shouldAddSpace
70
+ });
71
+ return (_ctx, _cache) => {
72
+ return openBlock(), createElementBlock("button", {
73
+ ref_key: "_ref",
74
+ ref: _ref,
75
+ class: normalizeClass([
76
+ unref(ns).b(),
77
+ unref(ns).m(unref(_type)),
78
+ unref(ns).m(unref(_size)),
79
+ unref(ns).is("disabled", unref(_disabled)),
80
+ unref(ns).is("loading", _ctx.loading),
81
+ unref(ns).is("plain", _ctx.plain),
82
+ unref(ns).is("round", _ctx.round),
83
+ unref(ns).is("circle", _ctx.circle),
84
+ unref(ns).is("text", _ctx.text),
85
+ unref(ns).is("link", _ctx.link),
86
+ unref(ns).is("has-bg", _ctx.bg)
87
+ ]),
88
+ "aria-disabled": unref(_disabled) || _ctx.loading,
89
+ disabled: unref(_disabled) || _ctx.loading,
90
+ autofocus: _ctx.autofocus,
91
+ type: _ctx.nativeType,
92
+ style: normalizeStyle(unref(buttonStyle)),
93
+ onClick: handleClick
94
+ }, [
95
+ _ctx.loading ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
96
+ _ctx.$slots.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }) : (openBlock(), createBlock(unref(ElIcon), {
97
+ key: 1,
98
+ class: normalizeClass(unref(ns).is("loading"))
99
+ }, {
100
+ default: withCtx(() => [
101
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.loadingIcon)))
102
+ ]),
103
+ _: 1
104
+ }, 8, ["class"]))
105
+ ], 64)) : _ctx.icon || _ctx.$slots.icon ? (openBlock(), createBlock(unref(ElIcon), { key: 1 }, {
106
+ default: withCtx(() => [
107
+ _ctx.icon ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon), { key: 0 })) : renderSlot(_ctx.$slots, "icon", { key: 1 })
108
+ ]),
109
+ _: 3
110
+ })) : createCommentVNode("v-if", true),
111
+ _ctx.$slots.default ? (openBlock(), createElementBlock("span", {
112
+ key: 2,
113
+ class: normalizeClass({ [unref(ns).em("text", "expand")]: unref(shouldAddSpace) })
114
+ }, [
115
+ renderSlot(_ctx.$slots, "default")
116
+ ], 2)) : createCommentVNode("v-if", true)
117
+ ], 14, _hoisted_1);
118
+ };
52
119
  }
53
120
  });
54
- const buttonEmits = {
55
- click: (evt) => evt instanceof MouseEvent
56
- };
121
+ var Button = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/button/src/button.vue"]]);
57
122
 
58
- export { buttonEmits, buttonNativeTypes, buttonProps, buttonTypes };
123
+ export { Button as default };
59
124
  //# sourceMappingURL=button.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"button.mjs","sources":["../../../../../../packages/components/button/src/button.ts"],"sourcesContent":["import { useSizeProp } from '@element-plus/hooks'\nimport { buildProps, iconPropType } from '@element-plus/utils'\nimport { Loading } from '@element-plus/icons-vue'\nimport type { ExtractPropTypes } from 'vue'\nimport type button from './button.vue'\n\nexport const buttonTypes = [\n 'default',\n 'primary',\n 'success',\n 'warning',\n 'info',\n 'danger',\n /**\n * @deprecated\n * Text type will be deprecated in the next major version (3.0.0)\n */\n 'text',\n '',\n] as const\nexport const buttonNativeTypes = ['button', 'submit', 'reset'] as const\n\nexport const buttonProps = buildProps({\n size: useSizeProp,\n disabled: Boolean,\n type: {\n type: String,\n values: buttonTypes,\n default: '',\n },\n icon: {\n type: iconPropType,\n },\n nativeType: {\n type: String,\n values: buttonNativeTypes,\n default: 'button',\n },\n loading: Boolean,\n loadingIcon: {\n type: iconPropType,\n default: () => Loading,\n },\n plain: Boolean,\n text: Boolean,\n link: Boolean,\n bg: Boolean,\n autofocus: Boolean,\n round: Boolean,\n circle: Boolean,\n color: String,\n dark: Boolean,\n autoInsertSpace: {\n type: Boolean,\n default: undefined,\n },\n} as const)\nexport const buttonEmits = {\n click: (evt: MouseEvent) => evt instanceof MouseEvent,\n}\n\nexport type ButtonProps = ExtractPropTypes<typeof buttonProps>\nexport type ButtonEmits = typeof buttonEmits\n\nexport type ButtonType = ButtonProps['type']\nexport type ButtonNativeType = ButtonProps['nativeType']\n\nexport type ButtonInstance = InstanceType<typeof button>\n\nexport interface ButtonConfigContext {\n autoInsertSpace?: boolean\n}\n"],"names":[],"mappings":";;;;;;;AAGY,MAAC,WAAW,GAAG;AAC3B,EAAE,SAAS;AACX,EAAE,SAAS;AACX,EAAE,SAAS;AACX,EAAE,SAAS;AACX,EAAE,MAAM;AACR,EAAE,QAAQ;AACV,EAAE,MAAM;AACR,EAAE,EAAE;AACJ,EAAE;AACU,MAAC,iBAAiB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE;AACnD,MAAC,WAAW,GAAG,UAAU,CAAC;AACtC,EAAE,IAAI,EAAE,WAAW;AACnB,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,WAAW;AACvB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,YAAY;AACtB,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,iBAAiB;AAC7B,IAAI,OAAO,EAAE,QAAQ;AACrB,GAAG;AACH,EAAE,OAAO,EAAE,OAAO;AAClB,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAE,YAAY;AACtB,IAAI,OAAO,EAAE,MAAM,OAAO;AAC1B,GAAG;AACH,EAAE,KAAK,EAAE,OAAO;AAChB,EAAE,IAAI,EAAE,OAAO;AACf,EAAE,IAAI,EAAE,OAAO;AACf,EAAE,EAAE,EAAE,OAAO;AACb,EAAE,SAAS,EAAE,OAAO;AACpB,EAAE,KAAK,EAAE,OAAO;AAChB,EAAE,MAAM,EAAE,OAAO;AACjB,EAAE,KAAK,EAAE,MAAM;AACf,EAAE,IAAI,EAAE,OAAO;AACf,EAAE,eAAe,EAAE;AACnB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,KAAK,CAAC;AACnB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,WAAW,GAAG;AAC3B,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,GAAG,YAAY,UAAU;AAC3C;;;;"}
1
+ {"version":3,"file":"button.mjs","sources":["../../../../../../packages/components/button/src/button.vue"],"sourcesContent":["<template>\n <button\n ref=\"_ref\"\n :class=\"[\n ns.b(),\n ns.m(_type),\n ns.m(_size),\n ns.is('disabled', _disabled),\n ns.is('loading', loading),\n ns.is('plain', plain),\n ns.is('round', round),\n ns.is('circle', circle),\n ns.is('text', text),\n ns.is('link', link),\n ns.is('has-bg', bg),\n ]\"\n :aria-disabled=\"_disabled || loading\"\n :disabled=\"_disabled || loading\"\n :autofocus=\"autofocus\"\n :type=\"nativeType\"\n :style=\"buttonStyle\"\n @click=\"handleClick\"\n >\n <template v-if=\"loading\">\n <slot v-if=\"$slots.loading\" name=\"loading\" />\n <el-icon v-else :class=\"ns.is('loading')\">\n <component :is=\"loadingIcon\" />\n </el-icon>\n </template>\n <el-icon v-else-if=\"icon || $slots.icon\">\n <component :is=\"icon\" v-if=\"icon\" />\n <slot v-else name=\"icon\" />\n </el-icon>\n <span\n v-if=\"$slots.default\"\n :class=\"{ [ns.em('text', 'expand')]: shouldAddSpace }\"\n >\n <slot />\n </span>\n </button>\n</template>\n\n<script lang=\"ts\" setup>\nimport { Text, computed, inject, ref, useSlots } from 'vue'\nimport { ElIcon } from '@element-plus/components/icon'\nimport {\n useDeprecated,\n useDisabled,\n useFormItem,\n useGlobalConfig,\n useNamespace,\n useSize,\n} from '@element-plus/hooks'\nimport { buttonGroupContextKey } from '@element-plus/tokens'\nimport { buttonEmits, buttonProps } from './button'\nimport { useButtonCustomStyle } from './button-custom'\n\ndefineOptions({\n name: 'ElButton',\n})\n\nconst props = defineProps(buttonProps)\nconst emit = defineEmits(buttonEmits)\nconst slots = useSlots()\n\nuseDeprecated(\n {\n from: 'type.text',\n replacement: 'type.link',\n version: '3.0.0',\n scope: 'props',\n ref: 'https://element-plus.org/en-US/component/button.html#button-attributes',\n },\n computed(() => props.type === 'text')\n)\n\nconst buttonGroupContext = inject(buttonGroupContextKey, undefined)\nconst globalConfig = useGlobalConfig('button')\nconst ns = useNamespace('button')\nconst { form } = useFormItem()\nconst _size = useSize(computed(() => buttonGroupContext?.size))\nconst _disabled = useDisabled()\nconst _ref = ref<HTMLButtonElement>()\n\nconst _type = computed(() => props.type || buttonGroupContext?.type || '')\nconst autoInsertSpace = computed(\n () => props.autoInsertSpace ?? globalConfig.value?.autoInsertSpace ?? false\n)\n\n// add space between two characters in Chinese\nconst shouldAddSpace = computed(() => {\n const defaultSlot = slots.default?.()\n if (autoInsertSpace.value && defaultSlot?.length === 1) {\n const slot = defaultSlot[0]\n if (slot?.type === Text) {\n const text = slot.children as string\n return /^\\p{Unified_Ideograph}{2}$/u.test(text.trim())\n }\n }\n return false\n})\n\nconst buttonStyle = useButtonCustomStyle(props)\n\nconst handleClick = (evt: MouseEvent) => {\n if (props.nativeType === 'reset') {\n form?.resetFields()\n }\n emit('click', evt)\n}\n\ndefineExpose({\n /** @description button html element */\n ref: _ref,\n /** @description button size */\n size: _size,\n /** @description button type */\n type: _type,\n /** @description button disabled */\n disabled: _disabled,\n /** @description whether adding space */\n shouldAddSpace,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+DA,IAAA,MAAA,QAAA,QAAA,EAAA,CAAA;AAEA,IACA,aAAA,CAAA;AAAA,MACA,IAAA,EAAA,WAAA;AAAA,MACA,WAAA,EAAA,WAAA;AAAA,MACA,OAAA,EAAA,OAAA;AAAA,MACA,KAAA,EAAA,OAAA;AAAA,MACA,GAAA,EAAA,wEAAA;AAAA,OAEA,QAAA,CAAA,MAAA,KAAA,CAAA,IAAA,KAAA,MAAA,CACA,CAAA,CAAA;AAEA,IAAA,MAAA,kBAAA,GAAA,MAAA,CAAA,q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