Sidebar.js 2.0 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. SIDEBAR_KEY: () => SIDEBAR_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)("sidebar");
  29. const SIDEBAR_KEY = Symbol(name);
  30. const sidebarProps = {
  31. modelValue: (0, import_utils.makeNumericProp)(0)
  32. };
  33. var stdin_default = (0, import_vue2.defineComponent)({
  34. name,
  35. props: sidebarProps,
  36. emits: ["change", "update:modelValue"],
  37. setup(props, {
  38. emit,
  39. slots
  40. }) {
  41. const {
  42. linkChildren
  43. } = (0, import_use.useChildren)(SIDEBAR_KEY);
  44. const getActive = () => +props.modelValue;
  45. const setActive = (value) => {
  46. if (value !== getActive()) {
  47. emit("update:modelValue", value);
  48. emit("change", value);
  49. }
  50. };
  51. linkChildren({
  52. getActive,
  53. setActive
  54. });
  55. return () => {
  56. var _a;
  57. return (0, import_vue.createVNode)("div", {
  58. "role": "tablist",
  59. "class": bem()
  60. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  61. };
  62. }
  63. });