RadioGroup.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. });
  23. module.exports = __toCommonJS(stdin_exports);
  24. var import_vue = require("vue");
  25. var import_vue2 = 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. disabled: Boolean,
  31. iconSize: import_utils.numericProp,
  32. direction: String,
  33. modelValue: import_utils.unknownProp,
  34. checkedColor: String
  35. };
  36. const RADIO_KEY = Symbol(name);
  37. var stdin_default = (0, import_vue2.defineComponent)({
  38. name,
  39. props: radioGroupProps,
  40. emits: ["change", "update:modelValue"],
  41. setup(props, {
  42. emit,
  43. slots
  44. }) {
  45. const {
  46. linkChildren
  47. } = (0, import_use.useChildren)(RADIO_KEY);
  48. const updateValue = (value) => emit("update:modelValue", value);
  49. (0, import_vue2.watch)(() => props.modelValue, (value) => emit("change", value));
  50. linkChildren({
  51. props,
  52. updateValue
  53. });
  54. (0, import_use.useCustomFieldValue)(() => props.modelValue);
  55. return () => {
  56. var _a;
  57. return (0, import_vue.createVNode)("div", {
  58. "class": bem([props.direction]),
  59. "role": "radiogroup"
  60. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  61. };
  62. }
  63. });