RadioGroup.mjs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { createVNode as _createVNode } from "vue";
  2. import { watch, defineComponent } from "vue";
  3. import { unknownProp, numericProp, createNamespace } from "../utils/index.mjs";
  4. import { useChildren, useCustomFieldValue } from "@vant/use";
  5. const [name, bem] = createNamespace("radio-group");
  6. const radioGroupProps = {
  7. disabled: Boolean,
  8. iconSize: numericProp,
  9. direction: String,
  10. modelValue: unknownProp,
  11. checkedColor: String
  12. };
  13. const RADIO_KEY = Symbol(name);
  14. var stdin_default = defineComponent({
  15. name,
  16. props: radioGroupProps,
  17. emits: ["change", "update:modelValue"],
  18. setup(props, {
  19. emit,
  20. slots
  21. }) {
  22. const {
  23. linkChildren
  24. } = useChildren(RADIO_KEY);
  25. const updateValue = (value) => emit("update:modelValue", value);
  26. watch(() => props.modelValue, (value) => emit("change", value));
  27. linkChildren({
  28. props,
  29. updateValue
  30. });
  31. useCustomFieldValue(() => props.modelValue);
  32. return () => {
  33. var _a;
  34. return _createVNode("div", {
  35. "class": bem([props.direction]),
  36. "role": "radiogroup"
  37. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  38. };
  39. }
  40. });
  41. export {
  42. RADIO_KEY,
  43. stdin_default as default
  44. };