PickerToolbar.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. default: () => stdin_default,
  21. pickerToolbarPropKeys: () => pickerToolbarPropKeys,
  22. pickerToolbarProps: () => pickerToolbarProps,
  23. pickerToolbarSlots: () => pickerToolbarSlots
  24. });
  25. module.exports = __toCommonJS(stdin_exports);
  26. var import_vue = require("vue");
  27. var import_vue2 = require("vue");
  28. var import_utils = require("./utils");
  29. var import_utils2 = require("../utils");
  30. const [name] = (0, import_utils2.createNamespace)("picker-toolbar");
  31. const pickerToolbarProps = {
  32. title: String,
  33. cancelButtonText: String,
  34. confirmButtonText: String
  35. };
  36. const pickerToolbarSlots = ["cancel", "confirm", "title", "toolbar"];
  37. const pickerToolbarPropKeys = Object.keys(pickerToolbarProps);
  38. var stdin_default = (0, import_vue2.defineComponent)({
  39. name,
  40. props: pickerToolbarProps,
  41. emits: ["confirm", "cancel"],
  42. setup(props, {
  43. emit,
  44. slots
  45. }) {
  46. const renderTitle = () => {
  47. if (slots.title) {
  48. return slots.title();
  49. }
  50. if (props.title) {
  51. return (0, import_vue.createVNode)("div", {
  52. "class": [(0, import_utils.bem)("title"), "van-ellipsis"]
  53. }, [props.title]);
  54. }
  55. };
  56. const onCancel = () => emit("cancel");
  57. const onConfirm = () => emit("confirm");
  58. const renderCancel = () => {
  59. const text = props.cancelButtonText || (0, import_utils.t)("cancel");
  60. return (0, import_vue.createVNode)("button", {
  61. "type": "button",
  62. "class": [(0, import_utils.bem)("cancel"), import_utils2.HAPTICS_FEEDBACK],
  63. "onClick": onCancel
  64. }, [slots.cancel ? slots.cancel() : text]);
  65. };
  66. const renderConfirm = () => {
  67. const text = props.confirmButtonText || (0, import_utils.t)("confirm");
  68. return (0, import_vue.createVNode)("button", {
  69. "type": "button",
  70. "class": [(0, import_utils.bem)("confirm"), import_utils2.HAPTICS_FEEDBACK],
  71. "onClick": onConfirm
  72. }, [slots.confirm ? slots.confirm() : text]);
  73. };
  74. return () => (0, import_vue.createVNode)("div", {
  75. "class": (0, import_utils.bem)("toolbar")
  76. }, [slots.toolbar ? slots.toolbar() : [renderCancel(), renderTitle(), renderConfirm()]]);
  77. }
  78. });