Sidebar.mjs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { defineComponent, createVNode as _createVNode } from "vue";
  2. import { makeNumericProp, createNamespace } from "../utils/index.mjs";
  3. import { useChildren } from "@vant/use";
  4. const [name, bem] = createNamespace("sidebar");
  5. const SIDEBAR_KEY = Symbol(name);
  6. const sidebarProps = {
  7. modelValue: makeNumericProp(0)
  8. };
  9. var stdin_default = defineComponent({
  10. name,
  11. props: sidebarProps,
  12. emits: ["change", "update:modelValue"],
  13. setup(props, {
  14. emit,
  15. slots
  16. }) {
  17. const {
  18. linkChildren
  19. } = useChildren(SIDEBAR_KEY);
  20. const getActive = () => +props.modelValue;
  21. const setActive = (value) => {
  22. if (value !== getActive()) {
  23. emit("update:modelValue", value);
  24. emit("change", value);
  25. }
  26. };
  27. linkChildren({
  28. getActive,
  29. setActive
  30. });
  31. return () => {
  32. var _a;
  33. return _createVNode("div", {
  34. "role": "tablist",
  35. "class": bem()
  36. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  37. };
  38. }
  39. });
  40. export {
  41. SIDEBAR_KEY,
  42. stdin_default as default,
  43. sidebarProps
  44. };