index9.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. import { g as oo, m as eo, d as I, r as j, b9 as K, ah as to, E as L, F as ro, I as A, u as H, o as no, c as U, _ as D, bz as ao, a3 as z, P as V, a4 as E, a2 as _, j as io } from "./index2.js";
  2. import { provide as N, inject as X, defineComponent as W, computed as O, ref as F, createVNode as T, watch as lo, nextTick as so } from "vue";
  3. const q = Symbol("radioGroupContextKey"), co = (o) => {
  4. N(q, o);
  5. }, uo = () => X(q, void 0), J = Symbol("radioOptionTypeContextKey"), po = (o) => {
  6. N(J, o);
  7. }, bo = () => X(J, void 0), go = new to("antRadioEffect", {
  8. "0%": {
  9. transform: "scale(1)",
  10. opacity: 0.5
  11. },
  12. "100%": {
  13. transform: "scale(1.6)",
  14. opacity: 0
  15. }
  16. }), ho = (o) => {
  17. const {
  18. componentCls: r,
  19. antCls: n
  20. } = o, t = `${r}-group`;
  21. return {
  22. [t]: I(I({}, j(o)), {
  23. display: "inline-block",
  24. fontSize: 0,
  25. // RTL
  26. [`&${t}-rtl`]: {
  27. direction: "rtl"
  28. },
  29. [`${n}-badge ${n}-badge-count`]: {
  30. zIndex: 1
  31. },
  32. [`> ${n}-badge:not(:first-child) > ${n}-button-wrapper`]: {
  33. borderInlineStart: "none"
  34. }
  35. })
  36. };
  37. }, Co = (o) => {
  38. const {
  39. componentCls: r,
  40. radioWrapperMarginRight: n,
  41. radioCheckedColor: t,
  42. radioSize: e,
  43. motionDurationSlow: d,
  44. motionDurationMid: s,
  45. motionEaseInOut: w,
  46. motionEaseInOutCirc: C,
  47. radioButtonBg: b,
  48. colorBorder: B,
  49. lineWidth: g,
  50. radioDotSize: f,
  51. colorBgContainerDisabled: x,
  52. colorTextDisabled: c,
  53. paddingXS: h,
  54. radioDotDisabledColor: a,
  55. lineType: m,
  56. radioDotDisabledSize: u,
  57. wireframe: p,
  58. colorWhite: y
  59. } = o, i = `${r}-inner`;
  60. return {
  61. [`${r}-wrapper`]: I(I({}, j(o)), {
  62. position: "relative",
  63. display: "inline-flex",
  64. alignItems: "baseline",
  65. marginInlineStart: 0,
  66. marginInlineEnd: n,
  67. cursor: "pointer",
  68. // RTL
  69. [`&${r}-wrapper-rtl`]: {
  70. direction: "rtl"
  71. },
  72. "&-disabled": {
  73. cursor: "not-allowed",
  74. color: o.colorTextDisabled
  75. },
  76. "&::after": {
  77. display: "inline-block",
  78. width: 0,
  79. overflow: "hidden",
  80. content: '"\\a0"'
  81. },
  82. // hashId 在 wrapper 上,只能铺平
  83. [`${r}-checked::after`]: {
  84. position: "absolute",
  85. insetBlockStart: 0,
  86. insetInlineStart: 0,
  87. width: "100%",
  88. height: "100%",
  89. border: `${g}px ${m} ${t}`,
  90. borderRadius: "50%",
  91. visibility: "hidden",
  92. animationName: go,
  93. animationDuration: d,
  94. animationTimingFunction: w,
  95. animationFillMode: "both",
  96. content: '""'
  97. },
  98. [r]: I(I({}, j(o)), {
  99. position: "relative",
  100. display: "inline-block",
  101. outline: "none",
  102. cursor: "pointer",
  103. alignSelf: "center"
  104. }),
  105. [`${r}-wrapper:hover &,
  106. &:hover ${i}`]: {
  107. borderColor: t
  108. },
  109. [`${r}-input:focus-visible + ${i}`]: I({}, K(o)),
  110. [`${r}:hover::after, ${r}-wrapper:hover &::after`]: {
  111. visibility: "visible"
  112. },
  113. [`${r}-inner`]: {
  114. "&::after": {
  115. boxSizing: "border-box",
  116. position: "absolute",
  117. insetBlockStart: "50%",
  118. insetInlineStart: "50%",
  119. display: "block",
  120. width: e,
  121. height: e,
  122. marginBlockStart: e / -2,
  123. marginInlineStart: e / -2,
  124. backgroundColor: p ? t : y,
  125. borderBlockStart: 0,
  126. borderInlineStart: 0,
  127. borderRadius: e,
  128. transform: "scale(0)",
  129. opacity: 0,
  130. transition: `all ${d} ${C}`,
  131. content: '""'
  132. },
  133. boxSizing: "border-box",
  134. position: "relative",
  135. insetBlockStart: 0,
  136. insetInlineStart: 0,
  137. display: "block",
  138. width: e,
  139. height: e,
  140. backgroundColor: b,
  141. borderColor: B,
  142. borderStyle: "solid",
  143. borderWidth: g,
  144. borderRadius: "50%",
  145. transition: `all ${s}`
  146. },
  147. [`${r}-input`]: {
  148. position: "absolute",
  149. insetBlockStart: 0,
  150. insetInlineEnd: 0,
  151. insetBlockEnd: 0,
  152. insetInlineStart: 0,
  153. zIndex: 1,
  154. cursor: "pointer",
  155. opacity: 0
  156. },
  157. // 选中状态
  158. [`${r}-checked`]: {
  159. [i]: {
  160. borderColor: t,
  161. backgroundColor: p ? b : t,
  162. "&::after": {
  163. transform: `scale(${f / e})`,
  164. opacity: 1,
  165. transition: `all ${d} ${C}`
  166. }
  167. }
  168. },
  169. [`${r}-disabled`]: {
  170. cursor: "not-allowed",
  171. [i]: {
  172. backgroundColor: x,
  173. borderColor: B,
  174. cursor: "not-allowed",
  175. "&::after": {
  176. backgroundColor: a
  177. }
  178. },
  179. [`${r}-input`]: {
  180. cursor: "not-allowed"
  181. },
  182. [`${r}-disabled + span`]: {
  183. color: c,
  184. cursor: "not-allowed"
  185. },
  186. [`&${r}-checked`]: {
  187. [i]: {
  188. "&::after": {
  189. transform: `scale(${u / e})`
  190. }
  191. }
  192. }
  193. },
  194. [`span${r} + *`]: {
  195. paddingInlineStart: h,
  196. paddingInlineEnd: h
  197. }
  198. })
  199. };
  200. }, fo = (o) => {
  201. const {
  202. radioButtonColor: r,
  203. controlHeight: n,
  204. componentCls: t,
  205. lineWidth: e,
  206. lineType: d,
  207. colorBorder: s,
  208. motionDurationSlow: w,
  209. motionDurationMid: C,
  210. radioButtonPaddingHorizontal: b,
  211. fontSize: B,
  212. radioButtonBg: g,
  213. fontSizeLG: f,
  214. controlHeightLG: x,
  215. controlHeightSM: c,
  216. paddingXS: h,
  217. borderRadius: a,
  218. borderRadiusSM: m,
  219. borderRadiusLG: u,
  220. radioCheckedColor: p,
  221. radioButtonCheckedBg: y,
  222. radioButtonHoverColor: i,
  223. radioButtonActiveColor: v,
  224. radioSolidCheckedColor: R,
  225. colorTextDisabled: l,
  226. colorBgContainerDisabled: S,
  227. radioDisabledButtonCheckedColor: P,
  228. radioDisabledButtonCheckedBg: G
  229. } = o;
  230. return {
  231. [`${t}-button-wrapper`]: {
  232. position: "relative",
  233. display: "inline-block",
  234. height: n,
  235. margin: 0,
  236. paddingInline: b,
  237. paddingBlock: 0,
  238. color: r,
  239. fontSize: B,
  240. lineHeight: `${n - e * 2}px`,
  241. background: g,
  242. border: `${e}px ${d} ${s}`,
  243. // strange align fix for chrome but works
  244. // https://gw.alipayobjects.com/zos/rmsportal/VFTfKXJuogBAXcvfAUWJ.gif
  245. borderBlockStartWidth: e + 0.02,
  246. borderInlineStartWidth: 0,
  247. borderInlineEndWidth: e,
  248. cursor: "pointer",
  249. transition: [`color ${C}`, `background ${C}`, `border-color ${C}`, `box-shadow ${C}`].join(","),
  250. a: {
  251. color: r
  252. },
  253. [`> ${t}-button`]: {
  254. position: "absolute",
  255. insetBlockStart: 0,
  256. insetInlineStart: 0,
  257. zIndex: -1,
  258. width: "100%",
  259. height: "100%"
  260. },
  261. "&:not(:first-child)": {
  262. "&::before": {
  263. position: "absolute",
  264. insetBlockStart: -e,
  265. insetInlineStart: -e,
  266. display: "block",
  267. boxSizing: "content-box",
  268. width: 1,
  269. height: "100%",
  270. paddingBlock: e,
  271. paddingInline: 0,
  272. backgroundColor: s,
  273. transition: `background-color ${w}`,
  274. content: '""'
  275. }
  276. },
  277. "&:first-child": {
  278. borderInlineStart: `${e}px ${d} ${s}`,
  279. borderStartStartRadius: a,
  280. borderEndStartRadius: a
  281. },
  282. "&:last-child": {
  283. borderStartEndRadius: a,
  284. borderEndEndRadius: a
  285. },
  286. "&:first-child:last-child": {
  287. borderRadius: a
  288. },
  289. [`${t}-group-large &`]: {
  290. height: x,
  291. fontSize: f,
  292. lineHeight: `${x - e * 2}px`,
  293. "&:first-child": {
  294. borderStartStartRadius: u,
  295. borderEndStartRadius: u
  296. },
  297. "&:last-child": {
  298. borderStartEndRadius: u,
  299. borderEndEndRadius: u
  300. }
  301. },
  302. [`${t}-group-small &`]: {
  303. height: c,
  304. paddingInline: h - e,
  305. paddingBlock: 0,
  306. lineHeight: `${c - e * 2}px`,
  307. "&:first-child": {
  308. borderStartStartRadius: m,
  309. borderEndStartRadius: m
  310. },
  311. "&:last-child": {
  312. borderStartEndRadius: m,
  313. borderEndEndRadius: m
  314. }
  315. },
  316. "&:hover": {
  317. position: "relative",
  318. color: p
  319. },
  320. "&:has(:focus-visible)": I({}, K(o)),
  321. [`${t}-inner, input[type='checkbox'], input[type='radio']`]: {
  322. width: 0,
  323. height: 0,
  324. opacity: 0,
  325. pointerEvents: "none"
  326. },
  327. [`&-checked:not(${t}-button-wrapper-disabled)`]: {
  328. zIndex: 1,
  329. color: p,
  330. background: y,
  331. borderColor: p,
  332. "&::before": {
  333. backgroundColor: p
  334. },
  335. "&:first-child": {
  336. borderColor: p
  337. },
  338. "&:hover": {
  339. color: i,
  340. borderColor: i,
  341. "&::before": {
  342. backgroundColor: i
  343. }
  344. },
  345. "&:active": {
  346. color: v,
  347. borderColor: v,
  348. "&::before": {
  349. backgroundColor: v
  350. }
  351. }
  352. },
  353. [`${t}-group-solid &-checked:not(${t}-button-wrapper-disabled)`]: {
  354. color: R,
  355. background: p,
  356. borderColor: p,
  357. "&:hover": {
  358. color: R,
  359. background: i,
  360. borderColor: i
  361. },
  362. "&:active": {
  363. color: R,
  364. background: v,
  365. borderColor: v
  366. }
  367. },
  368. "&-disabled": {
  369. color: l,
  370. backgroundColor: S,
  371. borderColor: s,
  372. cursor: "not-allowed",
  373. "&:first-child, &:hover": {
  374. color: l,
  375. backgroundColor: S,
  376. borderColor: s
  377. }
  378. },
  379. [`&-disabled${t}-button-wrapper-checked`]: {
  380. color: P,
  381. backgroundColor: G,
  382. borderColor: s,
  383. boxShadow: "none"
  384. }
  385. }
  386. };
  387. }, Q = oo("Radio", (o) => {
  388. const {
  389. padding: r,
  390. lineWidth: n,
  391. controlItemBgActiveDisabled: t,
  392. colorTextDisabled: e,
  393. colorBgContainer: d,
  394. fontSizeLG: s,
  395. controlOutline: w,
  396. colorPrimaryHover: C,
  397. colorPrimaryActive: b,
  398. colorText: B,
  399. colorPrimary: g,
  400. marginXS: f,
  401. controlOutlineWidth: x,
  402. colorTextLightSolid: c,
  403. wireframe: h
  404. } = o, a = `0 0 0 ${x}px ${w}`, m = a, u = s, p = 4, y = u - p * 2, i = h ? y : u - (p + n) * 2, v = g, R = B, l = C, S = b, P = r - n, $ = eo(o, {
  405. radioFocusShadow: a,
  406. radioButtonFocusShadow: m,
  407. radioSize: u,
  408. radioDotSize: i,
  409. radioDotDisabledSize: y,
  410. radioCheckedColor: v,
  411. radioDotDisabledColor: e,
  412. radioSolidCheckedColor: c,
  413. radioButtonBg: d,
  414. radioButtonCheckedBg: d,
  415. radioButtonColor: R,
  416. radioButtonHoverColor: l,
  417. radioButtonActiveColor: S,
  418. radioButtonPaddingHorizontal: P,
  419. radioDisabledButtonCheckedBg: t,
  420. radioDisabledButtonCheckedColor: e,
  421. radioWrapperMarginRight: f
  422. });
  423. return [ho($), Co($), fo($)];
  424. });
  425. var vo = function(o, r) {
  426. var n = {};
  427. for (var t in o) Object.prototype.hasOwnProperty.call(o, t) && r.indexOf(t) < 0 && (n[t] = o[t]);
  428. if (o != null && typeof Object.getOwnPropertySymbols == "function") for (var e = 0, t = Object.getOwnPropertySymbols(o); e < t.length; e++)
  429. r.indexOf(t[e]) < 0 && Object.prototype.propertyIsEnumerable.call(o, t[e]) && (n[t[e]] = o[t[e]]);
  430. return n;
  431. };
  432. const Y = () => ({
  433. prefixCls: String,
  434. checked: z(),
  435. disabled: z(),
  436. isGroup: z(),
  437. value: V.any,
  438. name: String,
  439. id: String,
  440. autofocus: z(),
  441. onChange: E(),
  442. onFocus: E(),
  443. onBlur: E(),
  444. onClick: E(),
  445. "onUpdate:checked": E(),
  446. "onUpdate:value": E()
  447. }), k = W({
  448. compatConfig: {
  449. MODE: 3
  450. },
  451. name: "ARadio",
  452. inheritAttrs: !1,
  453. props: Y(),
  454. setup(o, r) {
  455. let {
  456. emit: n,
  457. expose: t,
  458. slots: e,
  459. attrs: d
  460. } = r;
  461. const s = L(), w = ro.useInject(), C = bo(), b = uo(), B = A(), g = O(() => {
  462. var l;
  463. return (l = h.value) !== null && l !== void 0 ? l : B.value;
  464. }), f = F(), {
  465. prefixCls: x,
  466. direction: c,
  467. disabled: h
  468. } = H("radio", o), a = O(() => (b == null ? void 0 : b.optionType.value) === "button" || C === "button" ? `${x.value}-button` : x.value), m = A(), [u, p] = Q(x);
  469. t({
  470. focus: () => {
  471. f.value.focus();
  472. },
  473. blur: () => {
  474. f.value.blur();
  475. }
  476. });
  477. const v = (l) => {
  478. const S = l.target.checked;
  479. n("update:checked", S), n("update:value", S), n("change", l), s.onFieldChange();
  480. }, R = (l) => {
  481. n("change", l), b && b.onChange && b.onChange(l);
  482. };
  483. return () => {
  484. var l;
  485. const S = b, {
  486. prefixCls: P,
  487. id: G = s.id.value
  488. } = o, M = vo(o, ["prefixCls", "id"]), $ = I(I({
  489. prefixCls: a.value,
  490. id: G
  491. }, no(M, ["onUpdate:checked", "onUpdate:value"])), {
  492. disabled: (l = h.value) !== null && l !== void 0 ? l : m.value
  493. });
  494. S ? ($.name = S.name.value, $.onChange = R, $.checked = o.value === S.value.value, $.disabled = g.value || S.disabled.value) : $.onChange = v;
  495. const Z = U({
  496. [`${a.value}-wrapper`]: !0,
  497. [`${a.value}-wrapper-checked`]: $.checked,
  498. [`${a.value}-wrapper-disabled`]: $.disabled,
  499. [`${a.value}-wrapper-rtl`]: c.value === "rtl",
  500. [`${a.value}-wrapper-in-form-item`]: w.isFormItemInput
  501. }, d.class, p.value);
  502. return u(T("label", D(D({}, d), {}, {
  503. class: Z
  504. }), [T(ao, D(D({}, $), {}, {
  505. type: "radio",
  506. ref: f
  507. }), null), e.default && T("span", null, [e.default()])]));
  508. };
  509. }
  510. }), mo = () => ({
  511. prefixCls: String,
  512. value: V.any,
  513. size: _(),
  514. options: io(),
  515. disabled: z(),
  516. name: String,
  517. buttonStyle: _("outline"),
  518. id: String,
  519. optionType: _("default"),
  520. onChange: E(),
  521. "onUpdate:value": E()
  522. }), So = W({
  523. compatConfig: {
  524. MODE: 3
  525. },
  526. name: "ARadioGroup",
  527. inheritAttrs: !1,
  528. props: mo(),
  529. // emits: ['update:value', 'change'],
  530. setup(o, r) {
  531. let {
  532. slots: n,
  533. emit: t,
  534. attrs: e
  535. } = r;
  536. const d = L(), {
  537. prefixCls: s,
  538. direction: w,
  539. size: C
  540. } = H("radio", o), [b, B] = Q(s), g = F(o.value), f = F(!1);
  541. return lo(() => o.value, (c) => {
  542. g.value = c, f.value = !1;
  543. }), co({
  544. onChange: (c) => {
  545. const h = g.value, {
  546. value: a
  547. } = c.target;
  548. "value" in o || (g.value = a), !f.value && a !== h && (f.value = !0, t("update:value", a), t("change", c), d.onFieldChange()), so(() => {
  549. f.value = !1;
  550. });
  551. },
  552. value: g,
  553. disabled: O(() => o.disabled),
  554. name: O(() => o.name),
  555. optionType: O(() => o.optionType)
  556. }), () => {
  557. var c;
  558. const {
  559. options: h,
  560. buttonStyle: a,
  561. id: m = d.id.value
  562. } = o, u = `${s.value}-group`, p = U(u, `${u}-${a}`, {
  563. [`${u}-${C.value}`]: C.value,
  564. [`${u}-rtl`]: w.value === "rtl"
  565. }, e.class, B.value);
  566. let y = null;
  567. return h && h.length > 0 ? y = h.map((i) => {
  568. if (typeof i == "string" || typeof i == "number")
  569. return T(k, {
  570. key: i,
  571. prefixCls: s.value,
  572. disabled: o.disabled,
  573. value: i,
  574. checked: g.value === i
  575. }, {
  576. default: () => [i]
  577. });
  578. const {
  579. value: v,
  580. disabled: R,
  581. label: l
  582. } = i;
  583. return T(k, {
  584. key: `radio-group-value-options-${v}`,
  585. prefixCls: s.value,
  586. disabled: R || o.disabled,
  587. value: v,
  588. checked: g.value === v
  589. }, {
  590. default: () => [l]
  591. });
  592. }) : y = (c = n.default) === null || c === void 0 ? void 0 : c.call(n), b(T("div", D(D({}, e), {}, {
  593. class: p,
  594. id: m
  595. }), [y]));
  596. };
  597. }
  598. }), $o = W({
  599. compatConfig: {
  600. MODE: 3
  601. },
  602. name: "ARadioButton",
  603. inheritAttrs: !1,
  604. props: Y(),
  605. setup(o, r) {
  606. let {
  607. slots: n,
  608. attrs: t
  609. } = r;
  610. const {
  611. prefixCls: e
  612. } = H("radio", o);
  613. return po("button"), () => {
  614. var d;
  615. return T(k, D(D(D({}, t), o), {}, {
  616. prefixCls: e.value
  617. }), {
  618. default: () => [(d = n.default) === null || d === void 0 ? void 0 : d.call(n)]
  619. });
  620. };
  621. }
  622. });
  623. k.Group = So;
  624. k.Button = $o;
  625. k.install = function(o) {
  626. return o.component(k.name, k), o.component(k.Group.name, k.Group), o.component(k.Button.name, k.Button), o;
  627. };
  628. export {
  629. k as R,
  630. So as _
  631. };