Sidebar.mjs 1.1 KB

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