index14.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. import { g as L, m as O, d as P, r as R, cr as j, cs as U, u as z, c as F, _ as b, bq as X, ct as V, cu as q, cv as G, bU as J, P as B, cw as K } from "./index2.js";
  2. import { defineComponent as w, computed as m, createVNode as d, shallowRef as Q, watchEffect as Y, Fragment as Z } from "vue";
  3. const v = (e, c, l) => {
  4. const r = U(l);
  5. return {
  6. [`${e.componentCls}-${c}`]: {
  7. color: e[`color${l}`],
  8. background: e[`color${r}Bg`],
  9. borderColor: e[`color${r}Border`],
  10. [`&${e.componentCls}-borderless`]: {
  11. borderColor: "transparent"
  12. }
  13. }
  14. };
  15. }, ee = (e) => j(e, (c, l) => {
  16. let {
  17. textColor: r,
  18. lightBorderColor: n,
  19. lightColor: o,
  20. darkColor: t
  21. } = l;
  22. return {
  23. [`${e.componentCls}-${c}`]: {
  24. color: r,
  25. background: o,
  26. borderColor: n,
  27. // Inverse color
  28. "&-inverse": {
  29. color: e.colorTextLightSolid,
  30. background: t,
  31. borderColor: t
  32. },
  33. [`&${e.componentCls}-borderless`]: {
  34. borderColor: "transparent"
  35. }
  36. }
  37. };
  38. }), oe = (e) => {
  39. const {
  40. paddingXXS: c,
  41. lineWidth: l,
  42. tagPaddingHorizontal: r,
  43. componentCls: n
  44. } = e, o = r - l, t = c - l;
  45. return {
  46. // Result
  47. [n]: P(P({}, R(e)), {
  48. display: "inline-block",
  49. height: "auto",
  50. marginInlineEnd: e.marginXS,
  51. paddingInline: o,
  52. fontSize: e.tagFontSize,
  53. lineHeight: `${e.tagLineHeight}px`,
  54. whiteSpace: "nowrap",
  55. background: e.tagDefaultBg,
  56. border: `${e.lineWidth}px ${e.lineType} ${e.colorBorder}`,
  57. borderRadius: e.borderRadiusSM,
  58. opacity: 1,
  59. transition: `all ${e.motionDurationMid}`,
  60. textAlign: "start",
  61. // RTL
  62. [`&${n}-rtl`]: {
  63. direction: "rtl"
  64. },
  65. "&, a, a:hover": {
  66. color: e.tagDefaultColor
  67. },
  68. [`${n}-close-icon`]: {
  69. marginInlineStart: t,
  70. color: e.colorTextDescription,
  71. fontSize: e.tagIconSize,
  72. cursor: "pointer",
  73. transition: `all ${e.motionDurationMid}`,
  74. "&:hover": {
  75. color: e.colorTextHeading
  76. }
  77. },
  78. [`&${n}-has-color`]: {
  79. borderColor: "transparent",
  80. [`&, a, a:hover, ${e.iconCls}-close, ${e.iconCls}-close:hover`]: {
  81. color: e.colorTextLightSolid
  82. }
  83. },
  84. "&-checkable": {
  85. backgroundColor: "transparent",
  86. borderColor: "transparent",
  87. cursor: "pointer",
  88. [`&:not(${n}-checkable-checked):hover`]: {
  89. color: e.colorPrimary,
  90. backgroundColor: e.colorFillSecondary
  91. },
  92. "&:active, &-checked": {
  93. color: e.colorTextLightSolid
  94. },
  95. "&-checked": {
  96. backgroundColor: e.colorPrimary,
  97. "&:hover": {
  98. backgroundColor: e.colorPrimaryHover
  99. }
  100. },
  101. "&:active": {
  102. backgroundColor: e.colorPrimaryActive
  103. }
  104. },
  105. "&-hidden": {
  106. display: "none"
  107. },
  108. // To ensure that a space will be placed between character and `Icon`.
  109. [`> ${e.iconCls} + span, > span + ${e.iconCls}`]: {
  110. marginInlineStart: o
  111. }
  112. }),
  113. [`${n}-borderless`]: {
  114. borderColor: "transparent",
  115. background: e.tagBorderlessBg
  116. }
  117. };
  118. }, D = L("Tag", (e) => {
  119. const {
  120. fontSize: c,
  121. lineHeight: l,
  122. lineWidth: r,
  123. fontSizeIcon: n
  124. } = e, o = Math.round(c * l), t = e.fontSizeSM, g = o - r * 2, C = e.colorFillAlter, s = e.colorText, a = O(e, {
  125. tagFontSize: t,
  126. tagLineHeight: g,
  127. tagDefaultBg: C,
  128. tagDefaultColor: s,
  129. tagIconSize: n - 2 * r,
  130. tagPaddingHorizontal: 8,
  131. tagBorderlessBg: e.colorFillTertiary
  132. });
  133. return [oe(a), ee(a), v(a, "success", "Success"), v(a, "processing", "Info"), v(a, "error", "Error"), v(a, "warning", "Warning")];
  134. }), le = () => ({
  135. prefixCls: String,
  136. checked: {
  137. type: Boolean,
  138. default: void 0
  139. },
  140. onChange: {
  141. type: Function
  142. },
  143. onClick: {
  144. type: Function
  145. },
  146. "onUpdate:checked": Function
  147. }), S = w({
  148. compatConfig: {
  149. MODE: 3
  150. },
  151. name: "ACheckableTag",
  152. inheritAttrs: !1,
  153. props: le(),
  154. // emits: ['update:checked', 'change', 'click'],
  155. setup(e, c) {
  156. let {
  157. slots: l,
  158. emit: r,
  159. attrs: n
  160. } = c;
  161. const {
  162. prefixCls: o
  163. } = z("tag", e), [t, g] = D(o), C = (a) => {
  164. const {
  165. checked: u
  166. } = e;
  167. r("update:checked", !u), r("change", !u), r("click", a);
  168. }, s = m(() => F(o.value, g.value, {
  169. [`${o.value}-checkable`]: !0,
  170. [`${o.value}-checkable-checked`]: e.checked
  171. }));
  172. return () => {
  173. var a;
  174. return t(d("span", b(b({}, n), {}, {
  175. class: [s.value, n.class],
  176. onClick: C
  177. }), [(a = l.default) === null || a === void 0 ? void 0 : a.call(l)]));
  178. };
  179. }
  180. }), re = () => ({
  181. prefixCls: String,
  182. color: {
  183. type: String
  184. },
  185. closable: {
  186. type: Boolean,
  187. default: !1
  188. },
  189. closeIcon: B.any,
  190. /** @deprecated `visible` will be removed in next major version. */
  191. visible: {
  192. type: Boolean,
  193. default: void 0
  194. },
  195. onClose: {
  196. type: Function
  197. },
  198. onClick: K(),
  199. "onUpdate:visible": Function,
  200. icon: B.any,
  201. bordered: {
  202. type: Boolean,
  203. default: !0
  204. }
  205. }), h = w({
  206. compatConfig: {
  207. MODE: 3
  208. },
  209. name: "ATag",
  210. inheritAttrs: !1,
  211. props: re(),
  212. // emits: ['update:visible', 'close'],
  213. slots: Object,
  214. setup(e, c) {
  215. let {
  216. slots: l,
  217. emit: r,
  218. attrs: n
  219. } = c;
  220. const {
  221. prefixCls: o,
  222. direction: t
  223. } = z("tag", e), [g, C] = D(o), s = Q(!0);
  224. process.env.NODE_ENV !== "production" && X(e.visible === void 0, "Tag", '`visible` is deprecated, please use `<Tag v-show="visible" />` instead.'), Y(() => {
  225. e.visible !== void 0 && (s.value = e.visible);
  226. });
  227. const a = (i) => {
  228. i.stopPropagation(), r("update:visible", !1), r("close", i), !i.defaultPrevented && e.visible === void 0 && (s.value = !1);
  229. }, u = m(() => V(e.color) || q(e.color)), H = m(() => F(o.value, C.value, {
  230. [`${o.value}-${e.color}`]: u.value,
  231. [`${o.value}-has-color`]: e.color && !u.value,
  232. [`${o.value}-hidden`]: !s.value,
  233. [`${o.value}-rtl`]: t.value === "rtl",
  234. [`${o.value}-borderless`]: !e.bordered
  235. })), M = (i) => {
  236. r("click", i);
  237. };
  238. return () => {
  239. var i, f, p;
  240. const {
  241. icon: N = (i = l.icon) === null || i === void 0 ? void 0 : i.call(l),
  242. color: $,
  243. closeIcon: y = (f = l.closeIcon) === null || f === void 0 ? void 0 : f.call(l),
  244. closable: _ = !1
  245. } = e, A = () => _ ? y ? d("span", {
  246. class: `${o.value}-close-icon`,
  247. onClick: a
  248. }, [y]) : d(J, {
  249. class: `${o.value}-close-icon`,
  250. onClick: a
  251. }, null) : null, E = {
  252. backgroundColor: $ && !u.value ? $ : void 0
  253. }, T = N || null, I = (p = l.default) === null || p === void 0 ? void 0 : p.call(l), k = T ? d(Z, null, [T, d("span", null, [I])]) : I, W = e.onClick !== void 0, x = d("span", b(b({}, n), {}, {
  254. onClick: M,
  255. class: [H.value, n.class],
  256. style: [E, n.style]
  257. }), [k, A()]);
  258. return g(W ? d(G, null, {
  259. default: () => [x]
  260. }) : x);
  261. };
  262. }
  263. });
  264. h.CheckableTag = S;
  265. h.install = function(e) {
  266. return e.component(h.name, h), e.component(S.name, S), e;
  267. };
  268. export {
  269. h as T
  270. };