PickerGroup.mjs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
  2. import { defineComponent } from "vue";
  3. import { extend, makeArrayProp, createNamespace } from "../utils/index.mjs";
  4. import { useChildren } from "@vant/use";
  5. import { Tab } from "../tab/index.mjs";
  6. import { Tabs } from "../tabs/index.mjs";
  7. import Toolbar, { pickerToolbarProps } from "../picker/PickerToolbar.mjs";
  8. const [name, bem] = createNamespace("picker-group");
  9. const PICKER_GROUP_KEY = Symbol(name);
  10. const pickerGroupProps = extend({
  11. tabs: makeArrayProp()
  12. }, pickerToolbarProps);
  13. var stdin_default = defineComponent({
  14. name,
  15. props: pickerGroupProps,
  16. emits: ["confirm", "cancel"],
  17. setup(props, {
  18. emit,
  19. slots
  20. }) {
  21. const {
  22. children,
  23. linkChildren
  24. } = useChildren(PICKER_GROUP_KEY);
  25. linkChildren();
  26. const onConfirm = () => {
  27. emit("confirm", children.map((item) => item.confirm()));
  28. };
  29. const onCancel = () => emit("cancel");
  30. return () => {
  31. var _a;
  32. const childNodes = (_a = slots.default) == null ? void 0 : _a.call(slots);
  33. return _createVNode("div", {
  34. "class": bem()
  35. }, [_createVNode(Toolbar, _mergeProps(props, {
  36. "onConfirm": onConfirm,
  37. "onCancel": onCancel
  38. }), null), _createVNode(Tabs, {
  39. "shrink": true,
  40. "class": bem("tabs"),
  41. "animated": true
  42. }, {
  43. default: () => [props.tabs.map((title, index) => _createVNode(Tab, {
  44. "title": title,
  45. "titleClass": bem("tab-title")
  46. }, {
  47. default: () => [childNodes == null ? void 0 : childNodes[index]]
  48. }))]
  49. })]);
  50. };
  51. }
  52. });
  53. export {
  54. PICKER_GROUP_KEY,
  55. stdin_default as default,
  56. pickerGroupProps
  57. };