index6.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. import { g as n, m as t, d as e, a3 as l, r as a, aU as d } from "./index2.js";
  2. const s = new l("antCheckboxEffect", {
  3. "0%": {
  4. transform: "scale(1)",
  5. opacity: 0.5
  6. },
  7. "100%": {
  8. transform: "scale(1.6)",
  9. opacity: 0
  10. }
  11. }), c = (r) => {
  12. const {
  13. checkboxCls: o
  14. } = r, i = `${o}-wrapper`;
  15. return [
  16. // ===================== Basic =====================
  17. {
  18. // Group
  19. [`${o}-group`]: e(e({}, a(r)), {
  20. display: "inline-flex",
  21. flexWrap: "wrap",
  22. columnGap: r.marginXS,
  23. // Group > Grid
  24. [`> ${r.antCls}-row`]: {
  25. flex: 1
  26. }
  27. }),
  28. // Wrapper
  29. [i]: e(e({}, a(r)), {
  30. display: "inline-flex",
  31. alignItems: "baseline",
  32. cursor: "pointer",
  33. // Fix checkbox & radio in flex align #30260
  34. "&:after": {
  35. display: "inline-block",
  36. width: 0,
  37. overflow: "hidden",
  38. content: "'\\a0'"
  39. },
  40. // Checkbox near checkbox
  41. [`& + ${i}`]: {
  42. marginInlineStart: 0
  43. },
  44. [`&${i}-in-form-item`]: {
  45. 'input[type="checkbox"]': {
  46. width: 14,
  47. height: 14
  48. // FIXME: magic
  49. }
  50. }
  51. }),
  52. // Wrapper > Checkbox
  53. [o]: e(e({}, a(r)), {
  54. position: "relative",
  55. whiteSpace: "nowrap",
  56. lineHeight: 1,
  57. cursor: "pointer",
  58. // To make alignment right when `controlHeight` is changed
  59. // Ref: https://github.com/ant-design/ant-design/issues/41564
  60. alignSelf: "center",
  61. // Wrapper > Checkbox > input
  62. [`${o}-input`]: {
  63. position: "absolute",
  64. // Since baseline align will get additional space offset,
  65. // we need to move input to top to make it align with text.
  66. // Ref: https://github.com/ant-design/ant-design/issues/38926#issuecomment-1486137799
  67. inset: 0,
  68. zIndex: 1,
  69. cursor: "pointer",
  70. opacity: 0,
  71. margin: 0,
  72. [`&:focus-visible + ${o}-inner`]: e({}, d(r))
  73. },
  74. // Wrapper > Checkbox > inner
  75. [`${o}-inner`]: {
  76. boxSizing: "border-box",
  77. position: "relative",
  78. top: 0,
  79. insetInlineStart: 0,
  80. display: "block",
  81. width: r.checkboxSize,
  82. height: r.checkboxSize,
  83. direction: "ltr",
  84. backgroundColor: r.colorBgContainer,
  85. border: `${r.lineWidth}px ${r.lineType} ${r.colorBorder}`,
  86. borderRadius: r.borderRadiusSM,
  87. borderCollapse: "separate",
  88. transition: `all ${r.motionDurationSlow}`,
  89. "&:after": {
  90. boxSizing: "border-box",
  91. position: "absolute",
  92. top: "50%",
  93. insetInlineStart: "21.5%",
  94. display: "table",
  95. width: r.checkboxSize / 14 * 5,
  96. height: r.checkboxSize / 14 * 8,
  97. border: `${r.lineWidthBold}px solid ${r.colorWhite}`,
  98. borderTop: 0,
  99. borderInlineStart: 0,
  100. transform: "rotate(45deg) scale(0) translate(-50%,-50%)",
  101. opacity: 0,
  102. content: '""',
  103. transition: `all ${r.motionDurationFast} ${r.motionEaseInBack}, opacity ${r.motionDurationFast}`
  104. }
  105. },
  106. // Wrapper > Checkbox + Text
  107. "& + span": {
  108. paddingInlineStart: r.paddingXS,
  109. paddingInlineEnd: r.paddingXS
  110. }
  111. })
  112. },
  113. // ================= Indeterminate =================
  114. {
  115. [o]: {
  116. "&-indeterminate": {
  117. // Wrapper > Checkbox > inner
  118. [`${o}-inner`]: {
  119. "&:after": {
  120. top: "50%",
  121. insetInlineStart: "50%",
  122. width: r.fontSizeLG / 2,
  123. height: r.fontSizeLG / 2,
  124. backgroundColor: r.colorPrimary,
  125. border: 0,
  126. transform: "translate(-50%, -50%) scale(1)",
  127. opacity: 1,
  128. content: '""'
  129. }
  130. }
  131. }
  132. }
  133. },
  134. // ===================== Hover =====================
  135. {
  136. // Wrapper
  137. [`${i}:hover ${o}:after`]: {
  138. visibility: "visible"
  139. },
  140. // Wrapper & Wrapper > Checkbox
  141. [`
  142. ${i}:not(${i}-disabled),
  143. ${o}:not(${o}-disabled)
  144. `]: {
  145. [`&:hover ${o}-inner`]: {
  146. borderColor: r.colorPrimary
  147. }
  148. },
  149. [`${i}:not(${i}-disabled)`]: {
  150. [`&:hover ${o}-checked:not(${o}-disabled) ${o}-inner`]: {
  151. backgroundColor: r.colorPrimaryHover,
  152. borderColor: "transparent"
  153. },
  154. [`&:hover ${o}-checked:not(${o}-disabled):after`]: {
  155. borderColor: r.colorPrimaryHover
  156. }
  157. }
  158. },
  159. // ==================== Checked ====================
  160. {
  161. // Wrapper > Checkbox
  162. [`${o}-checked`]: {
  163. [`${o}-inner`]: {
  164. backgroundColor: r.colorPrimary,
  165. borderColor: r.colorPrimary,
  166. "&:after": {
  167. opacity: 1,
  168. transform: "rotate(45deg) scale(1) translate(-50%,-50%)",
  169. transition: `all ${r.motionDurationMid} ${r.motionEaseOutBack} ${r.motionDurationFast}`
  170. }
  171. },
  172. // Checked Effect
  173. "&:after": {
  174. position: "absolute",
  175. top: 0,
  176. insetInlineStart: 0,
  177. width: "100%",
  178. height: "100%",
  179. borderRadius: r.borderRadiusSM,
  180. visibility: "hidden",
  181. border: `${r.lineWidthBold}px solid ${r.colorPrimary}`,
  182. animationName: s,
  183. animationDuration: r.motionDurationSlow,
  184. animationTimingFunction: "ease-in-out",
  185. animationFillMode: "backwards",
  186. content: '""',
  187. transition: `all ${r.motionDurationSlow}`
  188. }
  189. },
  190. [`
  191. ${i}-checked:not(${i}-disabled),
  192. ${o}-checked:not(${o}-disabled)
  193. `]: {
  194. [`&:hover ${o}-inner`]: {
  195. backgroundColor: r.colorPrimaryHover,
  196. borderColor: "transparent"
  197. },
  198. [`&:hover ${o}:after`]: {
  199. borderColor: r.colorPrimaryHover
  200. }
  201. }
  202. },
  203. // ==================== Disable ====================
  204. {
  205. // Wrapper
  206. [`${i}-disabled`]: {
  207. cursor: "not-allowed"
  208. },
  209. // Wrapper > Checkbox
  210. [`${o}-disabled`]: {
  211. // Wrapper > Checkbox > input
  212. [`&, ${o}-input`]: {
  213. cursor: "not-allowed",
  214. // Disabled for native input to enable Tooltip event handler
  215. // ref: https://github.com/ant-design/ant-design/issues/39822#issuecomment-1365075901
  216. pointerEvents: "none"
  217. },
  218. // Wrapper > Checkbox > inner
  219. [`${o}-inner`]: {
  220. background: r.colorBgContainerDisabled,
  221. borderColor: r.colorBorder,
  222. "&:after": {
  223. borderColor: r.colorTextDisabled
  224. }
  225. },
  226. "&:after": {
  227. display: "none"
  228. },
  229. "& + span": {
  230. color: r.colorTextDisabled
  231. },
  232. [`&${o}-indeterminate ${o}-inner::after`]: {
  233. background: r.colorTextDisabled
  234. }
  235. }
  236. }
  237. ];
  238. };
  239. function b(r, o) {
  240. const i = t(o, {
  241. checkboxCls: `.${r}`,
  242. checkboxSize: o.controlInteractiveSize
  243. });
  244. return [c(i)];
  245. }
  246. const $ = n("Checkbox", (r, o) => {
  247. let {
  248. prefixCls: i
  249. } = o;
  250. return [b(i, r)];
  251. });
  252. export {
  253. b as g,
  254. $ as u
  255. };