RadioGroup.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. var __defProp = Object.defineProperty;
  2. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  3. var __getOwnPropNames = Object.getOwnPropertyNames;
  4. var __hasOwnProp = Object.prototype.hasOwnProperty;
  5. var __export = (target, all) => {
  6. for (var name2 in all)
  7. __defProp(target, name2, { get: all[name2], enumerable: true });
  8. };
  9. var __copyProps = (to, from, except, desc) => {
  10. if (from && typeof from === "object" || typeof from === "function") {
  11. for (let key of __getOwnPropNames(from))
  12. if (!__hasOwnProp.call(to, key) && key !== except)
  13. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  14. }
  15. return to;
  16. };
  17. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  18. var stdin_exports = {};
  19. __export(stdin_exports, {
  20. RADIO_KEY: () => RADIO_KEY,
  21. default: () => stdin_default,
  22. radioGroupProps: () => radioGroupProps
  23. });
  24. module.exports = __toCommonJS(stdin_exports);
  25. var import_vue = require("vue");
  26. var import_utils = require("../utils");
  27. var import_use = require("@vant/use");
  28. const [name, bem] = (0, import_utils.createNamespace)("radio-group");
  29. const radioGroupProps = {
  30. shape: String,
  31. disabled: Boolean,
  32. iconSize: import_utils.numericProp,
  33. direction: String,
  34. modelValue: import_utils.unknownProp,
  35. checkedColor: String
  36. };
  37. const RADIO_KEY = Symbol(name);
  38. var stdin_default = (0, import_vue.defineComponent)({
  39. name,
  40. props: radioGroupProps,
  41. emits: ["change", "update:modelValue"],
  42. setup(props, {
  43. emit,
  44. slots
  45. }) {
  46. const {
  47. linkChildren
  48. } = (0, import_use.useChildren)(RADIO_KEY);
  49. const updateValue = (value) => emit("update:modelValue", value);
  50. (0, import_vue.watch)(() => props.modelValue, (value) => emit("change", value));
  51. linkChildren({
  52. props,
  53. updateValue
  54. });
  55. (0, import_use.useCustomFieldValue)(() => props.modelValue);
  56. return () => {
  57. var _a;
  58. return (0, import_vue.createVNode)("div", {
  59. "class": bem([props.direction]),
  60. "role": "radiogroup"
  61. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  62. };
  63. }
  64. });