@element-plus/nightly 0.0.20220227 → 0.0.20220228

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 (273) hide show
  1. package/README.md +8 -0
  2. package/dist/index.full.js +5 -5
  3. package/dist/index.full.min.js +2 -2
  4. package/dist/index.full.min.js.map +1 -1
  5. package/dist/index.full.min.mjs +2 -2
  6. package/dist/index.full.min.mjs.map +1 -1
  7. package/dist/index.full.mjs +5 -5
  8. package/dist/locale/af.js +1 -1
  9. package/dist/locale/af.min.js +1 -1
  10. package/dist/locale/af.min.mjs +1 -1
  11. package/dist/locale/af.mjs +1 -1
  12. package/dist/locale/ar.js +1 -1
  13. package/dist/locale/ar.min.js +1 -1
  14. package/dist/locale/ar.min.mjs +1 -1
  15. package/dist/locale/ar.mjs +1 -1
  16. package/dist/locale/bg.js +1 -1
  17. package/dist/locale/bg.min.js +1 -1
  18. package/dist/locale/bg.min.mjs +1 -1
  19. package/dist/locale/bg.mjs +1 -1
  20. package/dist/locale/bn.js +1 -1
  21. package/dist/locale/bn.min.js +1 -1
  22. package/dist/locale/bn.min.mjs +1 -1
  23. package/dist/locale/bn.mjs +1 -1
  24. package/dist/locale/ca.js +1 -1
  25. package/dist/locale/ca.min.js +1 -1
  26. package/dist/locale/ca.min.mjs +1 -1
  27. package/dist/locale/ca.mjs +1 -1
  28. package/dist/locale/cs.js +1 -1
  29. package/dist/locale/cs.min.js +1 -1
  30. package/dist/locale/cs.min.mjs +1 -1
  31. package/dist/locale/cs.mjs +1 -1
  32. package/dist/locale/da.js +1 -1
  33. package/dist/locale/da.min.js +1 -1
  34. package/dist/locale/da.min.mjs +1 -1
  35. package/dist/locale/da.mjs +1 -1
  36. package/dist/locale/de.js +1 -1
  37. package/dist/locale/de.min.js +1 -1
  38. package/dist/locale/de.min.mjs +1 -1
  39. package/dist/locale/de.mjs +1 -1
  40. package/dist/locale/el.js +1 -1
  41. package/dist/locale/el.min.js +1 -1
  42. package/dist/locale/el.min.mjs +1 -1
  43. package/dist/locale/el.mjs +1 -1
  44. package/dist/locale/en.js +1 -1
  45. package/dist/locale/en.min.js +1 -1
  46. package/dist/locale/en.min.mjs +1 -1
  47. package/dist/locale/en.mjs +1 -1
  48. package/dist/locale/eo.js +1 -1
  49. package/dist/locale/eo.min.js +1 -1
  50. package/dist/locale/eo.min.mjs +1 -1
  51. package/dist/locale/eo.mjs +1 -1
  52. package/dist/locale/es.js +1 -1
  53. package/dist/locale/es.min.js +1 -1
  54. package/dist/locale/es.min.mjs +1 -1
  55. package/dist/locale/es.mjs +1 -1
  56. package/dist/locale/et.js +1 -1
  57. package/dist/locale/et.min.js +1 -1
  58. package/dist/locale/et.min.mjs +1 -1
  59. package/dist/locale/et.mjs +1 -1
  60. package/dist/locale/eu.js +1 -1
  61. package/dist/locale/eu.min.js +1 -1
  62. package/dist/locale/eu.min.mjs +1 -1
  63. package/dist/locale/eu.mjs +1 -1
  64. package/dist/locale/fa.js +1 -1
  65. package/dist/locale/fa.min.js +1 -1
  66. package/dist/locale/fa.min.mjs +1 -1
  67. package/dist/locale/fa.mjs +1 -1
  68. package/dist/locale/fi.js +1 -1
  69. package/dist/locale/fi.min.js +1 -1
  70. package/dist/locale/fi.min.mjs +1 -1
  71. package/dist/locale/fi.mjs +1 -1
  72. package/dist/locale/fr.js +1 -1
  73. package/dist/locale/fr.min.js +1 -1
  74. package/dist/locale/fr.min.mjs +1 -1
  75. package/dist/locale/fr.mjs +1 -1
  76. package/dist/locale/he.js +1 -1
  77. package/dist/locale/he.min.js +1 -1
  78. package/dist/locale/he.min.mjs +1 -1
  79. package/dist/locale/he.mjs +1 -1
  80. package/dist/locale/hr.js +1 -1
  81. package/dist/locale/hr.min.js +1 -1
  82. package/dist/locale/hr.min.mjs +1 -1
  83. package/dist/locale/hr.mjs +1 -1
  84. package/dist/locale/hu.js +1 -1
  85. package/dist/locale/hu.min.js +1 -1
  86. package/dist/locale/hu.min.mjs +1 -1
  87. package/dist/locale/hu.mjs +1 -1
  88. package/dist/locale/hy-am.js +1 -1
  89. package/dist/locale/hy-am.min.js +1 -1
  90. package/dist/locale/hy-am.min.mjs +1 -1
  91. package/dist/locale/hy-am.mjs +1 -1
  92. package/dist/locale/id.js +1 -1
  93. package/dist/locale/id.min.js +1 -1
  94. package/dist/locale/id.min.mjs +1 -1
  95. package/dist/locale/id.mjs +1 -1
  96. package/dist/locale/it.js +1 -1
  97. package/dist/locale/it.min.js +1 -1
  98. package/dist/locale/it.min.mjs +1 -1
  99. package/dist/locale/it.mjs +1 -1
  100. package/dist/locale/ja.js +1 -1
  101. package/dist/locale/ja.min.js +1 -1
  102. package/dist/locale/ja.min.mjs +1 -1
  103. package/dist/locale/ja.mjs +1 -1
  104. package/dist/locale/kk.js +1 -1
  105. package/dist/locale/kk.min.js +1 -1
  106. package/dist/locale/kk.min.mjs +1 -1
  107. package/dist/locale/kk.mjs +1 -1
  108. package/dist/locale/km.js +1 -1
  109. package/dist/locale/km.min.js +1 -1
  110. package/dist/locale/km.min.mjs +1 -1
  111. package/dist/locale/km.mjs +1 -1
  112. package/dist/locale/ko.js +1 -1
  113. package/dist/locale/ko.min.js +1 -1
  114. package/dist/locale/ko.min.mjs +1 -1
  115. package/dist/locale/ko.mjs +1 -1
  116. package/dist/locale/ku.js +1 -1
  117. package/dist/locale/ku.min.js +1 -1
  118. package/dist/locale/ku.min.mjs +1 -1
  119. package/dist/locale/ku.mjs +1 -1
  120. package/dist/locale/ky.js +1 -1
  121. package/dist/locale/ky.min.js +1 -1
  122. package/dist/locale/ky.min.mjs +1 -1
  123. package/dist/locale/ky.mjs +1 -1
  124. package/dist/locale/lt.js +1 -1
  125. package/dist/locale/lt.min.js +1 -1
  126. package/dist/locale/lt.min.mjs +1 -1
  127. package/dist/locale/lt.mjs +1 -1
  128. package/dist/locale/lv.js +1 -1
  129. package/dist/locale/lv.min.js +1 -1
  130. package/dist/locale/lv.min.mjs +1 -1
  131. package/dist/locale/lv.mjs +1 -1
  132. package/dist/locale/mg.js +1 -1
  133. package/dist/locale/mg.min.js +1 -1
  134. package/dist/locale/mg.min.mjs +1 -1
  135. package/dist/locale/mg.mjs +1 -1
  136. package/dist/locale/mn.js +1 -1
  137. package/dist/locale/mn.min.js +1 -1
  138. package/dist/locale/mn.min.mjs +1 -1
  139. package/dist/locale/mn.mjs +1 -1
  140. package/dist/locale/nb-no.js +1 -1
  141. package/dist/locale/nb-no.min.js +1 -1
  142. package/dist/locale/nb-no.min.mjs +1 -1
  143. package/dist/locale/nb-no.mjs +1 -1
  144. package/dist/locale/nl.js +1 -1
  145. package/dist/locale/nl.min.js +1 -1
  146. package/dist/locale/nl.min.mjs +1 -1
  147. package/dist/locale/nl.mjs +1 -1
  148. package/dist/locale/pa.js +1 -1
  149. package/dist/locale/pa.min.js +1 -1
  150. package/dist/locale/pa.min.mjs +1 -1
  151. package/dist/locale/pa.mjs +1 -1
  152. package/dist/locale/pl.js +1 -1
  153. package/dist/locale/pl.min.js +1 -1
  154. package/dist/locale/pl.min.mjs +1 -1
  155. package/dist/locale/pl.mjs +1 -1
  156. package/dist/locale/pt-br.js +1 -1
  157. package/dist/locale/pt-br.min.js +1 -1
  158. package/dist/locale/pt-br.min.mjs +1 -1
  159. package/dist/locale/pt-br.mjs +1 -1
  160. package/dist/locale/pt.js +1 -1
  161. package/dist/locale/pt.min.js +1 -1
  162. package/dist/locale/pt.min.mjs +1 -1
  163. package/dist/locale/pt.mjs +1 -1
  164. package/dist/locale/ro.js +1 -1
  165. package/dist/locale/ro.min.js +1 -1
  166. package/dist/locale/ro.min.mjs +1 -1
  167. package/dist/locale/ro.mjs +1 -1
  168. package/dist/locale/ru.js +1 -1
  169. package/dist/locale/ru.min.js +1 -1
  170. package/dist/locale/ru.min.mjs +1 -1
  171. package/dist/locale/ru.mjs +1 -1
  172. package/dist/locale/sk.js +1 -1
  173. package/dist/locale/sk.min.js +1 -1
  174. package/dist/locale/sk.min.mjs +1 -1
  175. package/dist/locale/sk.mjs +1 -1
  176. package/dist/locale/sl.js +1 -1
  177. package/dist/locale/sl.min.js +1 -1
  178. package/dist/locale/sl.min.mjs +1 -1
  179. package/dist/locale/sl.mjs +1 -1
  180. package/dist/locale/sr.js +1 -1
  181. package/dist/locale/sr.min.js +1 -1
  182. package/dist/locale/sr.min.mjs +1 -1
  183. package/dist/locale/sr.mjs +1 -1
  184. package/dist/locale/sv.js +1 -1
  185. package/dist/locale/sv.min.js +1 -1
  186. package/dist/locale/sv.min.mjs +1 -1
  187. package/dist/locale/sv.mjs +1 -1
  188. package/dist/locale/ta.js +1 -1
  189. package/dist/locale/ta.min.js +1 -1
  190. package/dist/locale/ta.min.mjs +1 -1
  191. package/dist/locale/ta.mjs +1 -1
  192. package/dist/locale/th.js +1 -1
  193. package/dist/locale/th.min.js +1 -1
  194. package/dist/locale/th.min.mjs +1 -1
  195. package/dist/locale/th.mjs +1 -1
  196. package/dist/locale/tk.js +1 -1
  197. package/dist/locale/tk.min.js +1 -1
  198. package/dist/locale/tk.min.mjs +1 -1
  199. package/dist/locale/tk.mjs +1 -1
  200. package/dist/locale/tr.js +1 -1
  201. package/dist/locale/tr.min.js +1 -1
  202. package/dist/locale/tr.min.mjs +1 -1
  203. package/dist/locale/tr.mjs +1 -1
  204. package/dist/locale/ug-cn.js +1 -1
  205. package/dist/locale/ug-cn.min.js +1 -1
  206. package/dist/locale/ug-cn.min.mjs +1 -1
  207. package/dist/locale/ug-cn.mjs +1 -1
  208. package/dist/locale/uk.js +1 -1
  209. package/dist/locale/uk.min.js +1 -1
  210. package/dist/locale/uk.min.mjs +1 -1
  211. package/dist/locale/uk.mjs +1 -1
  212. package/dist/locale/uz-uz.js +1 -1
  213. package/dist/locale/uz-uz.min.js +1 -1
  214. package/dist/locale/uz-uz.min.mjs +1 -1
  215. package/dist/locale/uz-uz.mjs +1 -1
  216. package/dist/locale/vi.js +1 -1
  217. package/dist/locale/vi.min.js +1 -1
  218. package/dist/locale/vi.min.mjs +1 -1
  219. package/dist/locale/vi.mjs +1 -1
  220. package/dist/locale/zh-cn.js +1 -1
  221. package/dist/locale/zh-cn.min.js +1 -1
  222. package/dist/locale/zh-cn.min.mjs +1 -1
  223. package/dist/locale/zh-cn.mjs +1 -1
  224. package/dist/locale/zh-tw.js +1 -1
  225. package/dist/locale/zh-tw.min.js +1 -1
  226. package/dist/locale/zh-tw.min.mjs +1 -1
  227. package/dist/locale/zh-tw.mjs +1 -1
  228. package/es/components/affix/index.mjs +2 -2
  229. package/es/components/affix/src/affix.mjs +23 -116
  230. package/es/components/affix/src/affix.mjs.map +1 -1
  231. package/es/components/affix/src/affix2.mjs +116 -23
  232. package/es/components/affix/src/affix2.mjs.map +1 -1
  233. package/es/components/alert/index.mjs +2 -2
  234. package/es/components/alert/src/alert.mjs +36 -88
  235. package/es/components/alert/src/alert.mjs.map +1 -1
  236. package/es/components/alert/src/alert2.mjs +88 -36
  237. package/es/components/alert/src/alert2.mjs.map +1 -1
  238. package/es/components/badge/index.mjs +2 -2
  239. package/es/components/badge/src/badge.mjs +17 -52
  240. package/es/components/badge/src/badge.mjs.map +1 -1
  241. package/es/components/badge/src/badge2.mjs +52 -17
  242. package/es/components/badge/src/badge2.mjs.map +1 -1
  243. package/es/components/button/src/button2.mjs +3 -3
  244. package/es/components/button/src/button2.mjs.map +1 -1
  245. package/es/components/index.mjs +3 -3
  246. package/es/index.mjs +3 -3
  247. package/es/version.d.ts +1 -1
  248. package/es/version.mjs +1 -1
  249. package/es/version.mjs.map +1 -1
  250. package/lib/components/affix/index.js +2 -2
  251. package/lib/components/affix/src/affix.js +24 -116
  252. package/lib/components/affix/src/affix.js.map +1 -1
  253. package/lib/components/affix/src/affix2.js +116 -24
  254. package/lib/components/affix/src/affix2.js.map +1 -1
  255. package/lib/components/alert/index.js +2 -2
  256. package/lib/components/alert/src/alert.js +37 -87
  257. package/lib/components/alert/src/alert.js.map +1 -1
  258. package/lib/components/alert/src/alert2.js +87 -37
  259. package/lib/components/alert/src/alert2.js.map +1 -1
  260. package/lib/components/badge/index.js +2 -2
  261. package/lib/components/badge/src/badge.js +17 -52
  262. package/lib/components/badge/src/badge.js.map +1 -1
  263. package/lib/components/badge/src/badge2.js +52 -17
  264. package/lib/components/badge/src/badge2.js.map +1 -1
  265. package/lib/components/button/src/button2.js +3 -3
  266. package/lib/components/button/src/button2.js.map +1 -1
  267. package/lib/components/index.js +3 -3
  268. package/lib/index.js +3 -3
  269. package/lib/version.d.ts +1 -1
  270. package/lib/version.js +1 -1
  271. package/lib/version.js.map +1 -1
  272. package/package.json +5 -5
  273. package/web-types.json +1 -1
@@ -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></slot>\n </div>\n </div>\n</template>\n<script lang=\"ts\" setup>\nimport { computed, onMounted, ref, shallowRef, watch } from 'vue'\nimport { useEventListener, useResizeObserver } from '@vueuse/core'\nimport { getScrollContainer } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { affixEmits, affixProps } from './affix'\n\nimport type { CSSProperties } from 'vue'\n\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>()\n\nconst fixed = ref(false)\nconst height = ref(0) // height of root\nconst width = ref(0) // width of root\nconst scrollTop = ref(0) // scrollTop of documentElement\nconst clientHeight = ref(0) // clientHeight of documentElement\nconst transform = ref(0)\n\nconst rootStyle = computed<CSSProperties>(() => {\n return {\n height: fixed.value ? `${height.value}px` : '',\n width: fixed.value ? `${width.value}px` : '',\n }\n})\n\nconst affixStyle = computed<CSSProperties | undefined>(() => {\n if (!fixed.value) return\n\n const offset = props.offset ? `${props.offset}px` : 0\n const _transform = transform.value ? `translateY(${transform.value}px)` : ''\n\n return {\n height: `${height.value}px`,\n width: `${width.value}px`,\n top: props.position === 'top' ? offset : '',\n bottom: props.position === 'bottom' ? offset : '',\n transform: _transform,\n zIndex: props.zIndex,\n }\n})\n\nconst update = () => {\n if (!root.value || !target.value || !scrollContainer.value) return\n\n const rootRect = root.value.getBoundingClientRect()\n const targetRect = target.value.getBoundingClientRect()\n height.value = rootRect.height\n width.value = rootRect.width\n scrollTop.value =\n scrollContainer.value instanceof Window\n ? document.documentElement.scrollTop\n : scrollContainer.value.scrollTop || 0\n clientHeight.value = document.documentElement.clientHeight\n\n if (props.position === 'top') {\n if (props.target) {\n const difference = targetRect.bottom - props.offset - height.value\n fixed.value = props.offset > rootRect.top && targetRect.bottom > 0\n transform.value = difference < 0 ? difference : 0\n } else {\n fixed.value = props.offset > rootRect.top\n }\n } else {\n if (props.target) {\n const difference =\n clientHeight.value - targetRect.top - props.offset - height.value\n fixed.value =\n clientHeight.value - props.offset < rootRect.bottom &&\n clientHeight.value > targetRect.top\n transform.value = difference < 0 ? -difference : 0\n } else {\n fixed.value = clientHeight.value - props.offset < rootRect.bottom\n }\n }\n}\n\nconst onScroll = () => {\n update()\n\n emit('scroll', {\n scrollTop: scrollTop.value,\n fixed: fixed.value,\n })\n}\n\nwatch(fixed, (fixed) => {\n emit('change', fixed)\n})\n\nonMounted(() => {\n if (props.target) {\n target.value =\n document.querySelector<HTMLElement>(props.target) ?? undefined\n if (!target.value) {\n throw new Error(`Target is not existed: ${props.target}`)\n }\n } else {\n target.value = document.documentElement\n }\n scrollContainer.value = getScrollContainer(root.value!, true)\n})\n\nuseEventListener(scrollContainer, 'scroll', onScroll)\nuseResizeObserver(root, () => update())\nuseResizeObserver(target, () => update())\n\ndefineExpose({\n /** @description update affix status */\n update,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAuBA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;AAOA;;;;;;;;;;;;;;AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;;;;;;;AASA;;;AAIA;;;;;;;;;;;AAaA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"affix.mjs","sources":["../../../../../../packages/components/affix/src/affix.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils'\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 typeof scrollTop === 'number' && typeof fixed === 'boolean',\n change: (fixed: boolean) => typeof fixed === 'boolean',\n}\nexport type AffixEmits = typeof affixEmits\n\nexport type AffixInstance = InstanceType<typeof Affix>\n"],"names":[],"mappings":";;;AACY,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,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;AAC/F,EAAE,MAAM,EAAE,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,SAAS;AAC/C;;;;"}
@@ -1,29 +1,122 @@
1
+ import { defineComponent, shallowRef, ref, computed, watch, onMounted, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createElementVNode, renderSlot } from 'vue';
2
+ import { useEventListener, useResizeObserver } from '@vueuse/core';
1
3
  import '../../../utils/index.mjs';
2
- import { buildProps, definePropType } from '../../../utils/vue/props.mjs';
4
+ import '../../../hooks/index.mjs';
5
+ import { affixProps, affixEmits } from './affix.mjs';
6
+ import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
7
+ import { getScrollContainer } from '../../../utils/dom/scroll.mjs';
3
8
 
4
- const affixProps = buildProps({
5
- zIndex: {
6
- type: definePropType([Number, String]),
7
- default: 100
8
- },
9
- target: {
10
- type: String,
11
- default: ""
12
- },
13
- offset: {
14
- type: Number,
15
- default: 0
16
- },
17
- position: {
18
- type: String,
19
- values: ["top", "bottom"],
20
- default: "top"
9
+ const __default__ = {
10
+ name: "ElAffix"
11
+ };
12
+ const _sfc_main = /* @__PURE__ */ defineComponent({
13
+ ...__default__,
14
+ props: affixProps,
15
+ emits: affixEmits,
16
+ setup(__props, { expose, emit }) {
17
+ const props = __props;
18
+ const ns = useNamespace("affix");
19
+ const target = shallowRef();
20
+ const root = shallowRef();
21
+ const scrollContainer = shallowRef();
22
+ const fixed = ref(false);
23
+ const height = ref(0);
24
+ const width = ref(0);
25
+ const scrollTop = ref(0);
26
+ const clientHeight = ref(0);
27
+ const transform = ref(0);
28
+ const rootStyle = computed(() => {
29
+ return {
30
+ height: fixed.value ? `${height.value}px` : "",
31
+ width: fixed.value ? `${width.value}px` : ""
32
+ };
33
+ });
34
+ const affixStyle = computed(() => {
35
+ if (!fixed.value)
36
+ return;
37
+ const offset = props.offset ? `${props.offset}px` : 0;
38
+ const _transform = transform.value ? `translateY(${transform.value}px)` : "";
39
+ return {
40
+ height: `${height.value}px`,
41
+ width: `${width.value}px`,
42
+ top: props.position === "top" ? offset : "",
43
+ bottom: props.position === "bottom" ? offset : "",
44
+ transform: _transform,
45
+ zIndex: props.zIndex
46
+ };
47
+ });
48
+ const update = () => {
49
+ if (!root.value || !target.value || !scrollContainer.value)
50
+ return;
51
+ const rootRect = root.value.getBoundingClientRect();
52
+ const targetRect = target.value.getBoundingClientRect();
53
+ height.value = rootRect.height;
54
+ width.value = rootRect.width;
55
+ scrollTop.value = scrollContainer.value instanceof Window ? document.documentElement.scrollTop : scrollContainer.value.scrollTop || 0;
56
+ clientHeight.value = document.documentElement.clientHeight;
57
+ if (props.position === "top") {
58
+ if (props.target) {
59
+ const difference = targetRect.bottom - props.offset - height.value;
60
+ fixed.value = props.offset > rootRect.top && targetRect.bottom > 0;
61
+ transform.value = difference < 0 ? difference : 0;
62
+ } else {
63
+ fixed.value = props.offset > rootRect.top;
64
+ }
65
+ } else {
66
+ if (props.target) {
67
+ const difference = clientHeight.value - targetRect.top - props.offset - height.value;
68
+ fixed.value = clientHeight.value - props.offset < rootRect.bottom && clientHeight.value > targetRect.top;
69
+ transform.value = difference < 0 ? -difference : 0;
70
+ } else {
71
+ fixed.value = clientHeight.value - props.offset < rootRect.bottom;
72
+ }
73
+ }
74
+ };
75
+ const onScroll = () => {
76
+ update();
77
+ emit("scroll", {
78
+ scrollTop: scrollTop.value,
79
+ fixed: fixed.value
80
+ });
81
+ };
82
+ watch(fixed, (fixed2) => {
83
+ emit("change", fixed2);
84
+ });
85
+ onMounted(() => {
86
+ var _a;
87
+ if (props.target) {
88
+ target.value = (_a = document.querySelector(props.target)) != null ? _a : void 0;
89
+ if (!target.value) {
90
+ throw new Error(`Target is not existed: ${props.target}`);
91
+ }
92
+ } else {
93
+ target.value = document.documentElement;
94
+ }
95
+ scrollContainer.value = getScrollContainer(root.value, true);
96
+ });
97
+ useEventListener(scrollContainer, "scroll", onScroll);
98
+ useResizeObserver(root, () => update());
99
+ useResizeObserver(target, () => update());
100
+ expose({
101
+ update
102
+ });
103
+ return (_ctx, _cache) => {
104
+ return openBlock(), createElementBlock("div", {
105
+ ref_key: "root",
106
+ ref: root,
107
+ class: normalizeClass(unref(ns).b()),
108
+ style: normalizeStyle(unref(rootStyle))
109
+ }, [
110
+ createElementVNode("div", {
111
+ class: normalizeClass({ [unref(ns).m("fixed")]: fixed.value }),
112
+ style: normalizeStyle(unref(affixStyle))
113
+ }, [
114
+ renderSlot(_ctx.$slots, "default")
115
+ ], 6)
116
+ ], 6);
117
+ };
21
118
  }
22
119
  });
23
- const affixEmits = {
24
- scroll: ({ scrollTop, fixed }) => typeof scrollTop === "number" && typeof fixed === "boolean",
25
- change: (fixed) => typeof fixed === "boolean"
26
- };
27
120
 
28
- export { affixEmits, affixProps };
121
+ export { _sfc_main as default };
29
122
  //# sourceMappingURL=affix2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"affix2.mjs","sources":["../../../../../../packages/components/affix/src/affix.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils'\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 typeof scrollTop === 'number' && typeof fixed === 'boolean',\n change: (fixed: boolean) => typeof fixed === 'boolean',\n}\nexport type AffixEmits = typeof affixEmits\n\nexport type AffixInstance = InstanceType<typeof Affix>\n"],"names":[],"mappings":";;;AACY,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,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;AAC/F,EAAE,MAAM,EAAE,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,SAAS;AAC/C;;;;"}
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></slot>\n </div>\n </div>\n</template>\n<script lang=\"ts\" setup>\nimport { computed, onMounted, ref, shallowRef, watch } from 'vue'\nimport { useEventListener, useResizeObserver } from '@vueuse/core'\nimport { getScrollContainer } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { affixEmits, affixProps } from './affix'\n\nimport type { CSSProperties } from 'vue'\n\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>()\n\nconst fixed = ref(false)\nconst height = ref(0) // height of root\nconst width = ref(0) // width of root\nconst scrollTop = ref(0) // scrollTop of documentElement\nconst clientHeight = ref(0) // clientHeight of documentElement\nconst transform = ref(0)\n\nconst rootStyle = computed<CSSProperties>(() => {\n return {\n height: fixed.value ? `${height.value}px` : '',\n width: fixed.value ? `${width.value}px` : '',\n }\n})\n\nconst affixStyle = computed<CSSProperties | undefined>(() => {\n if (!fixed.value) return\n\n const offset = props.offset ? `${props.offset}px` : 0\n const _transform = transform.value ? `translateY(${transform.value}px)` : ''\n\n return {\n height: `${height.value}px`,\n width: `${width.value}px`,\n top: props.position === 'top' ? offset : '',\n bottom: props.position === 'bottom' ? offset : '',\n transform: _transform,\n zIndex: props.zIndex,\n }\n})\n\nconst update = () => {\n if (!root.value || !target.value || !scrollContainer.value) return\n\n const rootRect = root.value.getBoundingClientRect()\n const targetRect = target.value.getBoundingClientRect()\n height.value = rootRect.height\n width.value = rootRect.width\n scrollTop.value =\n scrollContainer.value instanceof Window\n ? document.documentElement.scrollTop\n : scrollContainer.value.scrollTop || 0\n clientHeight.value = document.documentElement.clientHeight\n\n if (props.position === 'top') {\n if (props.target) {\n const difference = targetRect.bottom - props.offset - height.value\n fixed.value = props.offset > rootRect.top && targetRect.bottom > 0\n transform.value = difference < 0 ? difference : 0\n } else {\n fixed.value = props.offset > rootRect.top\n }\n } else {\n if (props.target) {\n const difference =\n clientHeight.value - targetRect.top - props.offset - height.value\n fixed.value =\n clientHeight.value - props.offset < rootRect.bottom &&\n clientHeight.value > targetRect.top\n transform.value = difference < 0 ? -difference : 0\n } else {\n fixed.value = clientHeight.value - props.offset < rootRect.bottom\n }\n }\n}\n\nconst onScroll = () => {\n update()\n\n emit('scroll', {\n scrollTop: scrollTop.value,\n fixed: fixed.value,\n })\n}\n\nwatch(fixed, (fixed) => {\n emit('change', fixed)\n})\n\nonMounted(() => {\n if (props.target) {\n target.value =\n document.querySelector<HTMLElement>(props.target) ?? undefined\n if (!target.value) {\n throw new Error(`Target is not existed: ${props.target}`)\n }\n } else {\n target.value = document.documentElement\n }\n scrollContainer.value = getScrollContainer(root.value!, true)\n})\n\nuseEventListener(scrollContainer, 'scroll', onScroll)\nuseResizeObserver(root, () => update())\nuseResizeObserver(target, () => update())\n\ndefineExpose({\n /** @description update affix status */\n update,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAuBA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;AAOA;;;;;;;;;;;;;;AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;;;;;;;AASA;;;AAIA;;;;;;;;;;;AAaA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import '../../utils/index.mjs';
2
- import _sfc_main from './src/alert.mjs';
3
- export { alertEffects, alertEmits, alertProps } from './src/alert2.mjs';
2
+ import _sfc_main from './src/alert2.mjs';
3
+ export { alertEffects, alertEmits, alertProps } from './src/alert.mjs';
4
4
  import { withInstall } from '../../utils/vue/install.mjs';
5
5
 
6
6
  const ElAlert = withInstall(_sfc_main);
@@ -1,94 +1,42 @@
1
- import { defineComponent, useSlots, ref, computed, openBlock, createBlock, Transition, unref, withCtx, withDirectives, createElementVNode, normalizeClass, resolveDynamicComponent, createCommentVNode, createElementBlock, renderSlot, createTextVNode, toDisplayString, Fragment, createVNode, vShow } from 'vue';
2
- import { ElIcon } from '../../icon/index.mjs';
3
1
  import '../../../utils/index.mjs';
4
- import '../../../hooks/index.mjs';
5
- import { alertProps, alertEmits } from './alert2.mjs';
6
- import { TypeComponents, TypeComponentsMap } from '../../../utils/vue/icon.mjs';
7
- import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
2
+ import { buildProps } from '../../../utils/vue/props.mjs';
3
+ import { keysOf } from '../../../utils/objects.mjs';
4
+ import { TypeComponentsMap } from '../../../utils/vue/icon.mjs';
8
5
 
9
- const __default__ = {
10
- name: "ElAlert"
11
- };
12
- const _sfc_main = /* @__PURE__ */ defineComponent({
13
- ...__default__,
14
- props: alertProps,
15
- emits: alertEmits,
16
- setup(__props, { emit }) {
17
- const props = __props;
18
- const { Close } = TypeComponents;
19
- const slots = useSlots();
20
- const ns = useNamespace("alert");
21
- const visible = ref(true);
22
- const iconComponent = computed(() => TypeComponentsMap[props.type] || TypeComponentsMap["info"]);
23
- const isBigIcon = computed(() => props.description || { [ns.is("big")]: slots.default });
24
- const isBoldTitle = computed(() => props.description || { [ns.is("bold")]: slots.default });
25
- const close = (evt) => {
26
- visible.value = false;
27
- emit("close", evt);
28
- };
29
- return (_ctx, _cache) => {
30
- return openBlock(), createBlock(Transition, {
31
- name: unref(ns).b("fade")
32
- }, {
33
- default: withCtx(() => [
34
- withDirectives(createElementVNode("div", {
35
- class: normalizeClass([unref(ns).b(), unref(ns).m(_ctx.type), unref(ns).is("center", _ctx.center), unref(ns).is(_ctx.effect)]),
36
- role: "alert"
37
- }, [
38
- _ctx.showIcon && unref(iconComponent) ? (openBlock(), createBlock(unref(ElIcon), {
39
- key: 0,
40
- class: normalizeClass([unref(ns).e("icon"), unref(isBigIcon)])
41
- }, {
42
- default: withCtx(() => [
43
- (openBlock(), createBlock(resolveDynamicComponent(unref(iconComponent))))
44
- ]),
45
- _: 1
46
- }, 8, ["class"])) : createCommentVNode("v-if", true),
47
- createElementVNode("div", {
48
- class: normalizeClass(unref(ns).e("content"))
49
- }, [
50
- _ctx.title || _ctx.$slots.title ? (openBlock(), createElementBlock("span", {
51
- key: 0,
52
- class: normalizeClass([unref(ns).e("title"), unref(isBoldTitle)])
53
- }, [
54
- renderSlot(_ctx.$slots, "title", {}, () => [
55
- createTextVNode(toDisplayString(_ctx.title), 1)
56
- ])
57
- ], 2)) : createCommentVNode("v-if", true),
58
- _ctx.$slots.default || _ctx.description ? (openBlock(), createElementBlock("p", {
59
- key: 1,
60
- class: normalizeClass(unref(ns).e("description"))
61
- }, [
62
- renderSlot(_ctx.$slots, "default", {}, () => [
63
- createTextVNode(toDisplayString(_ctx.description), 1)
64
- ])
65
- ], 2)) : createCommentVNode("v-if", true),
66
- _ctx.closable ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
67
- _ctx.closeText ? (openBlock(), createElementBlock("div", {
68
- key: 0,
69
- class: normalizeClass([unref(ns).e("close-btn"), unref(ns).is("customed")]),
70
- onClick: close
71
- }, toDisplayString(_ctx.closeText), 3)) : (openBlock(), createBlock(unref(ElIcon), {
72
- key: 1,
73
- class: normalizeClass(unref(ns).e("close-btn")),
74
- onClick: close
75
- }, {
76
- default: withCtx(() => [
77
- createVNode(unref(Close))
78
- ]),
79
- _: 1
80
- }, 8, ["class"]))
81
- ], 2112)) : createCommentVNode("v-if", true)
82
- ], 2)
83
- ], 2), [
84
- [vShow, visible.value]
85
- ])
86
- ]),
87
- _: 3
88
- }, 8, ["name"]);
89
- };
6
+ const alertEffects = ["light", "dark"];
7
+ const alertProps = buildProps({
8
+ title: {
9
+ type: String,
10
+ default: ""
11
+ },
12
+ description: {
13
+ type: String,
14
+ default: ""
15
+ },
16
+ type: {
17
+ type: String,
18
+ values: keysOf(TypeComponentsMap),
19
+ default: "info"
20
+ },
21
+ closable: {
22
+ type: Boolean,
23
+ default: true
24
+ },
25
+ closeText: {
26
+ type: String,
27
+ default: ""
28
+ },
29
+ showIcon: Boolean,
30
+ center: Boolean,
31
+ effect: {
32
+ type: String,
33
+ values: alertEffects,
34
+ default: "light"
90
35
  }
91
36
  });
37
+ const alertEmits = {
38
+ close: (evt) => evt instanceof MouseEvent
39
+ };
92
40
 
93
- export { _sfc_main as default };
41
+ export { alertEffects, alertEmits, alertProps };
94
42
  //# sourceMappingURL=alert.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"alert.mjs","sources":["../../../../../../packages/components/alert/src/alert.vue"],"sourcesContent":["<template>\n <transition :name=\"ns.b('fade')\">\n <div\n v-show=\"visible\"\n :class=\"[ns.b(), ns.m(type), ns.is('center', center), ns.is(effect)]\"\n role=\"alert\"\n >\n <el-icon\n v-if=\"showIcon && iconComponent\"\n :class=\"[ns.e('icon'), isBigIcon]\"\n >\n <component :is=\"iconComponent\" />\n </el-icon>\n <div :class=\"ns.e('content')\">\n <span\n v-if=\"title || $slots.title\"\n :class=\"[ns.e('title'), isBoldTitle]\"\n >\n <slot name=\"title\">{{ title }}</slot>\n </span>\n <p v-if=\"$slots.default || description\" :class=\"ns.e('description')\">\n <slot>\n {{ description }}\n </slot>\n </p>\n <template v-if=\"closable\">\n <div\n v-if=\"closeText\"\n :class=\"[ns.e('close-btn'), ns.is('customed')]\"\n @click=\"close\"\n >\n {{ closeText }}\n </div>\n <el-icon v-else :class=\"ns.e('close-btn')\" @click=\"close\">\n <Close />\n </el-icon>\n </template>\n </div>\n </div>\n </transition>\n</template>\n<script lang=\"ts\" setup>\nimport { computed, ref, useSlots } from 'vue'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { TypeComponents, TypeComponentsMap } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { alertProps, alertEmits } from './alert'\n\nconst { Close } = TypeComponents\n\ndefineOptions({\n name: 'ElAlert',\n})\n\nconst props = defineProps(alertProps)\nconst emit = defineEmits(alertEmits)\nconst slots = useSlots()\n\nconst ns = useNamespace('alert')\n\n// state\nconst visible = ref(true)\n\n// computed\nconst iconComponent = computed(\n () => TypeComponentsMap[props.type] || TypeComponentsMap['info']\n)\nconst isBigIcon = computed(\n () => props.description || { [ns.is('big')]: slots.default }\n)\nconst isBoldTitle = computed(\n () => props.description || { [ns.is('bold')]: slots.default }\n)\n\n// methods\nconst close = (evt: MouseEvent) => {\n visible.value = false\n emit('close', evt)\n}\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAgDA;AAQA;AAEA;AAGA;AAGA;AAGA;AAGA;AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"alert.mjs","sources":["../../../../../../packages/components/alert/src/alert.ts"],"sourcesContent":["import { TypeComponentsMap, buildProps, keysOf } from '@element-plus/utils'\nimport type { ExtractPropTypes } from 'vue'\nimport type Alert from './alert.vue'\n\nexport const alertEffects = ['light', 'dark'] as const\n\nexport const alertProps = buildProps({\n title: {\n type: String,\n default: '',\n },\n description: {\n type: String,\n default: '',\n },\n type: {\n type: String,\n values: keysOf(TypeComponentsMap),\n default: 'info',\n },\n closable: {\n type: Boolean,\n default: true,\n },\n closeText: {\n type: String,\n default: '',\n },\n showIcon: Boolean,\n center: Boolean,\n effect: {\n type: String,\n values: alertEffects,\n default: 'light',\n },\n} as const)\nexport type AlertProps = ExtractPropTypes<typeof alertProps>\n\nexport const alertEmits = {\n close: (evt: MouseEvent) => evt instanceof MouseEvent,\n}\nexport type AlertEmits = typeof alertEmits\n\nexport type AlertInstance = InstanceType<typeof Alert>\n"],"names":[],"mappings":";;;;;AACY,MAAC,YAAY,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE;AAClC,MAAC,UAAU,GAAG,UAAU,CAAC;AACrC,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC;AACrC,IAAI,OAAO,EAAE,MAAM;AACnB,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,SAAS,EAAE;AACb,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,MAAM,EAAE,OAAO;AACjB,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,YAAY;AACxB,IAAI,OAAO,EAAE,OAAO;AACpB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,UAAU,GAAG;AAC1B,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,GAAG,YAAY,UAAU;AAC3C;;;;"}
@@ -1,42 +1,94 @@
1
+ import { defineComponent, useSlots, ref, computed, openBlock, createBlock, Transition, unref, withCtx, withDirectives, createElementVNode, normalizeClass, resolveDynamicComponent, createCommentVNode, createElementBlock, renderSlot, createTextVNode, toDisplayString, Fragment, createVNode, vShow } from 'vue';
2
+ import { ElIcon } from '../../icon/index.mjs';
1
3
  import '../../../utils/index.mjs';
2
- import { buildProps } from '../../../utils/vue/props.mjs';
3
- import { keysOf } from '../../../utils/objects.mjs';
4
- import { TypeComponentsMap } from '../../../utils/vue/icon.mjs';
4
+ import '../../../hooks/index.mjs';
5
+ import { alertProps, alertEmits } from './alert.mjs';
6
+ import { TypeComponents, TypeComponentsMap } from '../../../utils/vue/icon.mjs';
7
+ import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
5
8
 
6
- const alertEffects = ["light", "dark"];
7
- const alertProps = buildProps({
8
- title: {
9
- type: String,
10
- default: ""
11
- },
12
- description: {
13
- type: String,
14
- default: ""
15
- },
16
- type: {
17
- type: String,
18
- values: keysOf(TypeComponentsMap),
19
- default: "info"
20
- },
21
- closable: {
22
- type: Boolean,
23
- default: true
24
- },
25
- closeText: {
26
- type: String,
27
- default: ""
28
- },
29
- showIcon: Boolean,
30
- center: Boolean,
31
- effect: {
32
- type: String,
33
- values: alertEffects,
34
- default: "light"
9
+ const __default__ = {
10
+ name: "ElAlert"
11
+ };
12
+ const _sfc_main = /* @__PURE__ */ defineComponent({
13
+ ...__default__,
14
+ props: alertProps,
15
+ emits: alertEmits,
16
+ setup(__props, { emit }) {
17
+ const props = __props;
18
+ const { Close } = TypeComponents;
19
+ const slots = useSlots();
20
+ const ns = useNamespace("alert");
21
+ const visible = ref(true);
22
+ const iconComponent = computed(() => TypeComponentsMap[props.type] || TypeComponentsMap["info"]);
23
+ const isBigIcon = computed(() => props.description || { [ns.is("big")]: slots.default });
24
+ const isBoldTitle = computed(() => props.description || { [ns.is("bold")]: slots.default });
25
+ const close = (evt) => {
26
+ visible.value = false;
27
+ emit("close", evt);
28
+ };
29
+ return (_ctx, _cache) => {
30
+ return openBlock(), createBlock(Transition, {
31
+ name: unref(ns).b("fade")
32
+ }, {
33
+ default: withCtx(() => [
34
+ withDirectives(createElementVNode("div", {
35
+ class: normalizeClass([unref(ns).b(), unref(ns).m(_ctx.type), unref(ns).is("center", _ctx.center), unref(ns).is(_ctx.effect)]),
36
+ role: "alert"
37
+ }, [
38
+ _ctx.showIcon && unref(iconComponent) ? (openBlock(), createBlock(unref(ElIcon), {
39
+ key: 0,
40
+ class: normalizeClass([unref(ns).e("icon"), unref(isBigIcon)])
41
+ }, {
42
+ default: withCtx(() => [
43
+ (openBlock(), createBlock(resolveDynamicComponent(unref(iconComponent))))
44
+ ]),
45
+ _: 1
46
+ }, 8, ["class"])) : createCommentVNode("v-if", true),
47
+ createElementVNode("div", {
48
+ class: normalizeClass(unref(ns).e("content"))
49
+ }, [
50
+ _ctx.title || _ctx.$slots.title ? (openBlock(), createElementBlock("span", {
51
+ key: 0,
52
+ class: normalizeClass([unref(ns).e("title"), unref(isBoldTitle)])
53
+ }, [
54
+ renderSlot(_ctx.$slots, "title", {}, () => [
55
+ createTextVNode(toDisplayString(_ctx.title), 1)
56
+ ])
57
+ ], 2)) : createCommentVNode("v-if", true),
58
+ _ctx.$slots.default || _ctx.description ? (openBlock(), createElementBlock("p", {
59
+ key: 1,
60
+ class: normalizeClass(unref(ns).e("description"))
61
+ }, [
62
+ renderSlot(_ctx.$slots, "default", {}, () => [
63
+ createTextVNode(toDisplayString(_ctx.description), 1)
64
+ ])
65
+ ], 2)) : createCommentVNode("v-if", true),
66
+ _ctx.closable ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
67
+ _ctx.closeText ? (openBlock(), createElementBlock("div", {
68
+ key: 0,
69
+ class: normalizeClass([unref(ns).e("close-btn"), unref(ns).is("customed")]),
70
+ onClick: close
71
+ }, toDisplayString(_ctx.closeText), 3)) : (openBlock(), createBlock(unref(ElIcon), {
72
+ key: 1,
73
+ class: normalizeClass(unref(ns).e("close-btn")),
74
+ onClick: close
75
+ }, {
76
+ default: withCtx(() => [
77
+ createVNode(unref(Close))
78
+ ]),
79
+ _: 1
80
+ }, 8, ["class"]))
81
+ ], 2112)) : createCommentVNode("v-if", true)
82
+ ], 2)
83
+ ], 2), [
84
+ [vShow, visible.value]
85
+ ])
86
+ ]),
87
+ _: 3
88
+ }, 8, ["name"]);
89
+ };
35
90
  }
36
91
  });
37
- const alertEmits = {
38
- close: (evt) => evt instanceof MouseEvent
39
- };
40
92
 
41
- export { alertEffects, alertEmits, alertProps };
93
+ export { _sfc_main as default };
42
94
  //# sourceMappingURL=alert2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"alert2.mjs","sources":["../../../../../../packages/components/alert/src/alert.ts"],"sourcesContent":["import { TypeComponentsMap, buildProps, keysOf } from '@element-plus/utils'\nimport type { ExtractPropTypes } from 'vue'\nimport type Alert from './alert.vue'\n\nexport const alertEffects = ['light', 'dark'] as const\n\nexport const alertProps = buildProps({\n title: {\n type: String,\n default: '',\n },\n description: {\n type: String,\n default: '',\n },\n type: {\n type: String,\n values: keysOf(TypeComponentsMap),\n default: 'info',\n },\n closable: {\n type: Boolean,\n default: true,\n },\n closeText: {\n type: String,\n default: '',\n },\n showIcon: Boolean,\n center: Boolean,\n effect: {\n type: String,\n values: alertEffects,\n default: 'light',\n },\n} as const)\nexport type AlertProps = ExtractPropTypes<typeof alertProps>\n\nexport const alertEmits = {\n close: (evt: MouseEvent) => evt instanceof MouseEvent,\n}\nexport type AlertEmits = typeof alertEmits\n\nexport type AlertInstance = InstanceType<typeof Alert>\n"],"names":[],"mappings":";;;;;AACY,MAAC,YAAY,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE;AAClC,MAAC,UAAU,GAAG,UAAU,CAAC;AACrC,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC;AACrC,IAAI,OAAO,EAAE,MAAM;AACnB,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,SAAS,EAAE;AACb,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,MAAM,EAAE,OAAO;AACjB,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,YAAY;AACxB,IAAI,OAAO,EAAE,OAAO;AACpB,GAAG;AACH,CAAC,EAAE;AACS,MAAC,UAAU,GAAG;AAC1B,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,GAAG,YAAY,UAAU;AAC3C;;;;"}
1
+ {"version":3,"file":"alert2.mjs","sources":["../../../../../../packages/components/alert/src/alert.vue"],"sourcesContent":["<template>\n <transition :name=\"ns.b('fade')\">\n <div\n v-show=\"visible\"\n :class=\"[ns.b(), ns.m(type), ns.is('center', center), ns.is(effect)]\"\n role=\"alert\"\n >\n <el-icon\n v-if=\"showIcon && iconComponent\"\n :class=\"[ns.e('icon'), isBigIcon]\"\n >\n <component :is=\"iconComponent\" />\n </el-icon>\n <div :class=\"ns.e('content')\">\n <span\n v-if=\"title || $slots.title\"\n :class=\"[ns.e('title'), isBoldTitle]\"\n >\n <slot name=\"title\">{{ title }}</slot>\n </span>\n <p v-if=\"$slots.default || description\" :class=\"ns.e('description')\">\n <slot>\n {{ description }}\n </slot>\n </p>\n <template v-if=\"closable\">\n <div\n v-if=\"closeText\"\n :class=\"[ns.e('close-btn'), ns.is('customed')]\"\n @click=\"close\"\n >\n {{ closeText }}\n </div>\n <el-icon v-else :class=\"ns.e('close-btn')\" @click=\"close\">\n <Close />\n </el-icon>\n </template>\n </div>\n </div>\n </transition>\n</template>\n<script lang=\"ts\" setup>\nimport { computed, ref, useSlots } from 'vue'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { TypeComponents, TypeComponentsMap } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { alertProps, alertEmits } from './alert'\n\nconst { Close } = TypeComponents\n\ndefineOptions({\n name: 'ElAlert',\n})\n\nconst props = defineProps(alertProps)\nconst emit = defineEmits(alertEmits)\nconst slots = useSlots()\n\nconst ns = useNamespace('alert')\n\n// state\nconst visible = ref(true)\n\n// computed\nconst iconComponent = computed(\n () => TypeComponentsMap[props.type] || TypeComponentsMap['info']\n)\nconst isBigIcon = computed(\n () => props.description || { [ns.is('big')]: slots.default }\n)\nconst isBoldTitle = computed(\n () => props.description || { [ns.is('bold')]: slots.default }\n)\n\n// methods\nconst close = (evt: MouseEvent) => {\n visible.value = false\n emit('close', evt)\n}\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAgDA;AAQA;AAEA;AAGA;AAGA;AAGA;AAGA;AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import '../../utils/index.mjs';
2
- import _sfc_main from './src/badge.mjs';
3
- export { badgeProps } from './src/badge2.mjs';
2
+ import _sfc_main from './src/badge2.mjs';
3
+ export { badgeProps } from './src/badge.mjs';
4
4
  import { withInstall } from '../../utils/vue/install.mjs';
5
5
 
6
6
  const ElBadge = withInstall(_sfc_main);
@@ -1,58 +1,23 @@
1
- import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, unref, renderSlot, createVNode, Transition, withCtx, withDirectives, createElementVNode, toDisplayString, vShow } from 'vue';
2
- import '../../../hooks/index.mjs';
3
1
  import '../../../utils/index.mjs';
4
- import { badgeProps } from './badge2.mjs';
5
- import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
6
- import { isNumber } from '@vueuse/core';
2
+ import { buildProps } from '../../../utils/vue/props.mjs';
7
3
 
8
- const _hoisted_1 = ["textContent"];
9
- const __default__ = {
10
- name: "ElBadge"
11
- };
12
- const _sfc_main = /* @__PURE__ */ defineComponent({
13
- ...__default__,
14
- props: badgeProps,
15
- setup(__props, { expose }) {
16
- const props = __props;
17
- const ns = useNamespace("badge");
18
- const content = computed(() => {
19
- if (props.isDot)
20
- return "";
21
- if (isNumber(props.value) && isNumber(props.max)) {
22
- return props.max < props.value ? `${props.max}+` : `${props.value}`;
23
- }
24
- return `${props.value}`;
25
- });
26
- expose({
27
- content
28
- });
29
- return (_ctx, _cache) => {
30
- return openBlock(), createElementBlock("div", {
31
- class: normalizeClass(unref(ns).b())
32
- }, [
33
- renderSlot(_ctx.$slots, "default"),
34
- createVNode(Transition, {
35
- name: `${unref(ns).namespace.value}-zoom-in-center`
36
- }, {
37
- default: withCtx(() => [
38
- withDirectives(createElementVNode("sup", {
39
- class: normalizeClass([
40
- unref(ns).e("content"),
41
- unref(ns).em("content", _ctx.type),
42
- unref(ns).is("fixed", !!_ctx.$slots.default),
43
- unref(ns).is("dot", _ctx.isDot)
44
- ]),
45
- textContent: toDisplayString(unref(content))
46
- }, null, 10, _hoisted_1), [
47
- [vShow, !_ctx.hidden && (unref(content) || unref(content) === "0" || _ctx.isDot)]
48
- ])
49
- ]),
50
- _: 1
51
- }, 8, ["name"])
52
- ], 2);
53
- };
4
+ const badgeProps = buildProps({
5
+ value: {
6
+ type: [String, Number],
7
+ default: ""
8
+ },
9
+ max: {
10
+ type: Number,
11
+ default: 99
12
+ },
13
+ isDot: Boolean,
14
+ hidden: Boolean,
15
+ type: {
16
+ type: String,
17
+ values: ["primary", "success", "warning", "info", "danger"],
18
+ default: "danger"
54
19
  }
55
20
  });
56
21
 
57
- export { _sfc_main as default };
22
+ export { badgeProps };
58
23
  //# sourceMappingURL=badge.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"badge.mjs","sources":["../../../../../../packages/components/badge/src/badge.vue"],"sourcesContent":["<template>\n <div :class=\"ns.b()\">\n <slot></slot>\n <transition :name=\"`${ns.namespace.value}-zoom-in-center`\">\n <sup\n v-show=\"!hidden && (content || content === '0' || isDot)\"\n :class=\"[\n ns.e('content'),\n ns.em('content', type),\n ns.is('fixed', !!$slots.default),\n ns.is('dot', isDot),\n ]\"\n v-text=\"content\"\n >\n </sup>\n </transition>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { isNumber } from '@element-plus/utils'\nimport { badgeProps } from './badge'\n\ndefineOptions({\n name: 'ElBadge',\n})\n\nconst props = defineProps(badgeProps)\n\nconst ns = useNamespace('badge')\n\nconst content = computed<string>(() => {\n if (props.isDot) return ''\n\n if (isNumber(props.value) && isNumber(props.max)) {\n return props.max < props.value ? `${props.max}+` : `${props.value}`\n }\n return `${props.value}`\n})\n\ndefineExpose({\n /** @description badge content */\n content,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+BA;AAEA;;;;;;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"badge.mjs","sources":["../../../../../../packages/components/badge/src/badge.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils'\nimport type { ExtractPropTypes } from 'vue'\nimport type Badge from './badge.vue'\n\nexport const badgeProps = buildProps({\n value: {\n type: [String, Number],\n default: '',\n },\n max: {\n type: Number,\n default: 99,\n },\n isDot: Boolean,\n hidden: Boolean,\n type: {\n type: String,\n values: ['primary', 'success', 'warning', 'info', 'danger'],\n default: 'danger',\n },\n} as const)\nexport type BadgeProps = ExtractPropTypes<typeof badgeProps>\n\nexport type BadgeInstance = InstanceType<typeof Badge>\n"],"names":[],"mappings":";;;AACY,MAAC,UAAU,GAAG,UAAU,CAAC;AACrC,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,GAAG,EAAE;AACP,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,KAAK,EAAE,OAAO;AAChB,EAAE,MAAM,EAAE,OAAO;AACjB,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC;AAC/D,IAAI,OAAO,EAAE,QAAQ;AACrB,GAAG;AACH,CAAC;;;;"}