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 | submitBarProps: () => submitBarProps
|
22 | });
|
23 | module.exports = __toCommonJS(stdin_exports);
|
24 | var import_vue = require("vue");
|
25 | var import_utils = require("../utils");
|
26 | var import_icon = require("../icon");
|
27 | var import_button = require("../button");
|
28 | var import_use_placeholder = require("../composables/use-placeholder");
|
29 | const [name, bem, t] = (0, import_utils.createNamespace)("submit-bar");
|
30 | const submitBarProps = {
|
31 | tip: String,
|
32 | label: String,
|
33 | price: Number,
|
34 | tipIcon: String,
|
35 | loading: Boolean,
|
36 | currency: (0, import_utils.makeStringProp)("\xA5"),
|
37 | disabled: Boolean,
|
38 | textAlign: String,
|
39 | buttonText: String,
|
40 | buttonType: (0, import_utils.makeStringProp)("danger"),
|
41 | buttonColor: String,
|
42 | suffixLabel: String,
|
43 | placeholder: Boolean,
|
44 | decimalLength: (0, import_utils.makeNumericProp)(2),
|
45 | safeAreaInsetBottom: import_utils.truthProp
|
46 | };
|
47 | var stdin_default = (0, import_vue.defineComponent)({
|
48 | name,
|
49 | props: submitBarProps,
|
50 | emits: ["submit"],
|
51 | setup(props, {
|
52 | emit,
|
53 | slots
|
54 | }) {
|
55 | const root = (0, import_vue.ref)();
|
56 | const renderPlaceholder = (0, import_use_placeholder.usePlaceholder)(root, bem);
|
57 | const renderText = () => {
|
58 | const {
|
59 | price,
|
60 | label,
|
61 | currency,
|
62 | textAlign,
|
63 | suffixLabel,
|
64 | decimalLength
|
65 | } = props;
|
66 | if (typeof price === "number") {
|
67 | const pricePair = (price / 100).toFixed(+decimalLength).split(".");
|
68 | const decimal = decimalLength ? `.${pricePair[1]}` : "";
|
69 | return (0, import_vue.createVNode)("div", {
|
70 | "class": bem("text"),
|
71 | "style": {
|
72 | textAlign
|
73 | }
|
74 | }, [(0, import_vue.createVNode)("span", null, [label || t("label")]), (0, import_vue.createVNode)("span", {
|
75 | "class": bem("price")
|
76 | }, [currency, (0, import_vue.createVNode)("span", {
|
77 | "class": bem("price-integer")
|
78 | }, [pricePair[0]]), decimal]), suffixLabel && (0, import_vue.createVNode)("span", {
|
79 | "class": bem("suffix-label")
|
80 | }, [suffixLabel])]);
|
81 | }
|
82 | };
|
83 | const renderTip = () => {
|
84 | var _a;
|
85 | const {
|
86 | tip,
|
87 | tipIcon
|
88 | } = props;
|
89 | if (slots.tip || tip) {
|
90 | return (0, import_vue.createVNode)("div", {
|
91 | "class": bem("tip")
|
92 | }, [tipIcon && (0, import_vue.createVNode)(import_icon.Icon, {
|
93 | "class": bem("tip-icon"),
|
94 | "name": tipIcon
|
95 | }, null), tip && (0, import_vue.createVNode)("span", {
|
96 | "class": bem("tip-text")
|
97 | }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
|
98 | }
|
99 | };
|
100 | const onClickButton = () => emit("submit");
|
101 | const renderButton = () => {
|
102 | if (slots.button) {
|
103 | return slots.button();
|
104 | }
|
105 | return (0, import_vue.createVNode)(import_button.Button, {
|
106 | "round": true,
|
107 | "type": props.buttonType,
|
108 | "text": props.buttonText,
|
109 | "class": bem("button", props.buttonType),
|
110 | "color": props.buttonColor,
|
111 | "loading": props.loading,
|
112 | "disabled": props.disabled,
|
113 | "onClick": onClickButton
|
114 | }, null);
|
115 | };
|
116 | const renderSubmitBar = () => {
|
117 | var _a, _b;
|
118 | return (0, import_vue.createVNode)("div", {
|
119 | "ref": root,
|
120 | "class": [bem(), {
|
121 | "van-safe-area-bottom": props.safeAreaInsetBottom
|
122 | }]
|
123 | }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), (0, import_vue.createVNode)("div", {
|
124 | "class": bem("bar")
|
125 | }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
|
126 | };
|
127 | return () => {
|
128 | if (props.placeholder) {
|
129 | return renderPlaceholder(renderSubmitBar);
|
130 | }
|
131 | return renderSubmitBar();
|
132 | };
|
133 | }
|
134 | });
|