UNPKG

3.14 kBJavaScriptView Raw
1var __defProp = Object.defineProperty;
2var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3var __getOwnPropNames = Object.getOwnPropertyNames;
4var __hasOwnProp = Object.prototype.hasOwnProperty;
5var __export = (target, all) => {
6 for (var name2 in all)
7 __defProp(target, name2, { get: all[name2], enumerable: true });
8};
9var __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};
17var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18var stdin_exports = {};
19__export(stdin_exports, {
20 default: () => stdin_default,
21 pickerToolbarPropKeys: () => pickerToolbarPropKeys,
22 pickerToolbarProps: () => pickerToolbarProps,
23 pickerToolbarSlots: () => pickerToolbarSlots
24});
25module.exports = __toCommonJS(stdin_exports);
26var import_vue = require("vue");
27var import_utils = require("./utils");
28var import_utils2 = require("../utils");
29const [name] = (0, import_utils2.createNamespace)("picker-toolbar");
30const pickerToolbarProps = {
31 title: String,
32 cancelButtonText: String,
33 confirmButtonText: String
34};
35const pickerToolbarSlots = ["cancel", "confirm", "title", "toolbar"];
36const pickerToolbarPropKeys = Object.keys(pickerToolbarProps);
37var stdin_default = (0, import_vue.defineComponent)({
38 name,
39 props: pickerToolbarProps,
40 emits: ["confirm", "cancel"],
41 setup(props, {
42 emit,
43 slots
44 }) {
45 const renderTitle = () => {
46 if (slots.title) {
47 return slots.title();
48 }
49 if (props.title) {
50 return (0, import_vue.createVNode)("div", {
51 "class": [(0, import_utils.bem)("title"), "van-ellipsis"]
52 }, [props.title]);
53 }
54 };
55 const onCancel = () => emit("cancel");
56 const onConfirm = () => emit("confirm");
57 const renderCancel = () => {
58 var _a;
59 const text = (_a = props.cancelButtonText) != null ? _a : (0, import_utils.t)("cancel");
60 if (!slots.cancel && !text) {
61 return;
62 }
63 return (0, import_vue.createVNode)("button", {
64 "type": "button",
65 "class": [(0, import_utils.bem)("cancel"), import_utils2.HAPTICS_FEEDBACK],
66 "onClick": onCancel
67 }, [slots.cancel ? slots.cancel() : text]);
68 };
69 const renderConfirm = () => {
70 var _a;
71 const text = (_a = props.confirmButtonText) != null ? _a : (0, import_utils.t)("confirm");
72 if (!slots.confirm && !text) {
73 return;
74 }
75 return (0, import_vue.createVNode)("button", {
76 "type": "button",
77 "class": [(0, import_utils.bem)("confirm"), import_utils2.HAPTICS_FEEDBACK],
78 "onClick": onConfirm
79 }, [slots.confirm ? slots.confirm() : text]);
80 };
81 return () => (0, import_vue.createVNode)("div", {
82 "class": (0, import_utils.bem)("toolbar")
83 }, [slots.toolbar ? slots.toolbar() : [renderCancel(), renderTitle(), renderConfirm()]]);
84 }
85});