1 | var __create = Object.create;
|
2 | var __defProp = Object.defineProperty;
|
3 | var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4 | var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 | var __getProtoOf = Object.getPrototypeOf;
|
6 | var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7 | var __export = (target, all) => {
|
8 | for (var name2 in all)
|
9 | __defProp(target, name2, { get: all[name2], enumerable: true });
|
10 | };
|
11 | var __copyProps = (to, from, except, desc) => {
|
12 | if (from && typeof from === "object" || typeof from === "function") {
|
13 | for (let key of __getOwnPropNames(from))
|
14 | if (!__hasOwnProp.call(to, key) && key !== except)
|
15 | __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16 | }
|
17 | return to;
|
18 | };
|
19 | var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25 | mod
|
26 | ));
|
27 | var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28 | var stdin_exports = {};
|
29 | __export(stdin_exports, {
|
30 | PICKER_GROUP_KEY: () => PICKER_GROUP_KEY,
|
31 | default: () => stdin_default,
|
32 | pickerGroupProps: () => pickerGroupProps
|
33 | });
|
34 | module.exports = __toCommonJS(stdin_exports);
|
35 | var import_vue = require("vue");
|
36 | var import_utils = require("../utils");
|
37 | var import_use = require("@vant/use");
|
38 | var import_use_sync_prop_ref = require("../composables/use-sync-prop-ref");
|
39 | var import_tab = require("../tab");
|
40 | var import_tabs = require("../tabs");
|
41 | var import_PickerToolbar = __toESM(require("../picker/PickerToolbar"));
|
42 | const [name, bem] = (0, import_utils.createNamespace)("picker-group");
|
43 | const PICKER_GROUP_KEY = Symbol(name);
|
44 | const pickerGroupProps = (0, import_utils.extend)({
|
45 | tabs: (0, import_utils.makeArrayProp)(),
|
46 | activeTab: (0, import_utils.makeNumericProp)(0),
|
47 | nextStepText: String,
|
48 | showToolbar: import_utils.truthProp
|
49 | }, import_PickerToolbar.pickerToolbarProps);
|
50 | var stdin_default = (0, import_vue.defineComponent)({
|
51 | name,
|
52 | props: pickerGroupProps,
|
53 | emits: ["confirm", "cancel", "update:activeTab"],
|
54 | setup(props, {
|
55 | emit,
|
56 | slots
|
57 | }) {
|
58 | const activeTab = (0, import_use_sync_prop_ref.useSyncPropRef)(() => props.activeTab, (value) => emit("update:activeTab", value));
|
59 | const {
|
60 | children,
|
61 | linkChildren
|
62 | } = (0, import_use.useChildren)(PICKER_GROUP_KEY);
|
63 | linkChildren();
|
64 | const showNextButton = () => +activeTab.value < props.tabs.length - 1 && props.nextStepText;
|
65 | const onConfirm = () => {
|
66 | if (showNextButton()) {
|
67 | activeTab.value = +activeTab.value + 1;
|
68 | } else {
|
69 | emit("confirm", children.map((item) => item.confirm()));
|
70 | }
|
71 | };
|
72 | const onCancel = () => emit("cancel");
|
73 | return () => {
|
74 | var _a, _b;
|
75 | let childNodes = (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) == null ? void 0 : _b.filter((node) => node.type !== import_vue.Comment).map((node) => {
|
76 | if (node.type === import_vue.Fragment) {
|
77 | return node.children;
|
78 | }
|
79 | return node;
|
80 | });
|
81 | if (childNodes) {
|
82 | childNodes = (0, import_utils.flat)(childNodes);
|
83 | }
|
84 | const confirmButtonText = showNextButton() ? props.nextStepText : props.confirmButtonText;
|
85 | return (0, import_vue.createVNode)("div", {
|
86 | "class": bem()
|
87 | }, [props.showToolbar ? (0, import_vue.createVNode)(import_PickerToolbar.default, {
|
88 | "title": props.title,
|
89 | "cancelButtonText": props.cancelButtonText,
|
90 | "confirmButtonText": confirmButtonText,
|
91 | "onConfirm": onConfirm,
|
92 | "onCancel": onCancel
|
93 | }, (0, import_utils.pick)(slots, import_PickerToolbar.pickerToolbarSlots)) : null, (0, import_vue.createVNode)(import_tabs.Tabs, {
|
94 | "active": activeTab.value,
|
95 | "onUpdate:active": ($event) => activeTab.value = $event,
|
96 | "class": bem("tabs"),
|
97 | "shrink": true,
|
98 | "animated": true,
|
99 | "lazyRender": false
|
100 | }, {
|
101 | default: () => [props.tabs.map((title, index) => (0, import_vue.createVNode)(import_tab.Tab, {
|
102 | "title": title,
|
103 | "titleClass": bem("tab-title")
|
104 | }, {
|
105 | default: () => [childNodes == null ? void 0 : childNodes[index]]
|
106 | }))]
|
107 | })]);
|
108 | };
|
109 | }
|
110 | });
|