@opentinyvue/vue-button 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/index.d.ts +13 -0
- package/lib/index.js +128 -0
- package/lib/mobile-first.js +139 -0
- package/lib/mobile.js +92 -0
- package/lib/pc.js +99 -0
- package/package.json +22 -0
- package/src/index.d.ts +82 -0
- package/src/mobile-first.vue.d.ts +2 -0
- package/src/mobile.vue.d.ts +2 -0
- package/src/pc.vue.d.ts +2 -0
- package/src/token.d.ts +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 - present TinyVue Authors.
|
|
4
|
+
Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 - present TinyVue Authors.
|
|
3
|
+
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license.
|
|
6
|
+
*
|
|
7
|
+
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
|
|
8
|
+
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
|
|
9
|
+
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
import Button from './src/index';
|
|
13
|
+
export default Button;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
3
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
4
|
+
var t = arguments[e];
|
|
5
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
6
|
+
}
|
|
7
|
+
return n;
|
|
8
|
+
}, _extends.apply(null, arguments);
|
|
9
|
+
}
|
|
10
|
+
import { defineComponent, $prefix, $setup, $props } from "@opentinyvue/vue-common";
|
|
11
|
+
import PcTemplate from "./pc.js";
|
|
12
|
+
import MobileTemplate from "./mobile.js";
|
|
13
|
+
import MobileFirstTemplate from "./mobile-first.js";
|
|
14
|
+
var template = function template2(mode) {
|
|
15
|
+
var _process$env;
|
|
16
|
+
var tinyMode = typeof process === "object" ? (_process$env = process.env) == null ? void 0 : _process$env.TINY_MODE : null;
|
|
17
|
+
if ("pc" === (tinyMode || mode)) {
|
|
18
|
+
return PcTemplate;
|
|
19
|
+
}
|
|
20
|
+
if ("mobile" === (tinyMode || mode)) {
|
|
21
|
+
return MobileTemplate;
|
|
22
|
+
}
|
|
23
|
+
if ("mobile-first" === (tinyMode || mode)) {
|
|
24
|
+
return MobileFirstTemplate;
|
|
25
|
+
}
|
|
26
|
+
return PcTemplate;
|
|
27
|
+
};
|
|
28
|
+
var buttonProps = _extends({}, $props, {
|
|
29
|
+
/** 展示按钮不同的状态,设置为text则展示为文本按钮。可取值为:'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text' */
|
|
30
|
+
type: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: "default"
|
|
33
|
+
},
|
|
34
|
+
/** 设置原生的tabindex属性 */
|
|
35
|
+
tabindex: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: "0"
|
|
38
|
+
},
|
|
39
|
+
/** 按钮左侧展示的图标,接收为Icon组件 */
|
|
40
|
+
icon: {
|
|
41
|
+
type: [Object, String],
|
|
42
|
+
default: ""
|
|
43
|
+
},
|
|
44
|
+
/** 按钮显示的文本 */
|
|
45
|
+
text: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: ""
|
|
48
|
+
},
|
|
49
|
+
/** 设置按钮禁用时间,防止重复提交,单位毫秒 */
|
|
50
|
+
resetTime: {
|
|
51
|
+
type: Number,
|
|
52
|
+
default: 1e3
|
|
53
|
+
},
|
|
54
|
+
/** 对应按钮原生 type 属性 */
|
|
55
|
+
nativeType: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: "button"
|
|
58
|
+
},
|
|
59
|
+
/** 当配置href后,点击按钮则更新 location.href 进行页面跳转 */
|
|
60
|
+
href: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: ""
|
|
63
|
+
},
|
|
64
|
+
/** 定义按钮尺寸 */
|
|
65
|
+
size: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: "",
|
|
68
|
+
validator: function validator(val) {
|
|
69
|
+
return ["large", "medium", "small", "mini", ""].includes(val);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
/** 是否圆角按钮 */
|
|
73
|
+
round: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: void 0
|
|
76
|
+
},
|
|
77
|
+
/** 是否朴素按钮 */
|
|
78
|
+
plain: Boolean,
|
|
79
|
+
/** 是否圆形按钮 */
|
|
80
|
+
circle: Boolean,
|
|
81
|
+
/** 是否加载中状态 */
|
|
82
|
+
loading: Boolean,
|
|
83
|
+
/** 是否被禁用按钮 */
|
|
84
|
+
disabled: Boolean,
|
|
85
|
+
/** 是否默认聚焦 */
|
|
86
|
+
autofocus: Boolean,
|
|
87
|
+
/** 自定义类名, 仅 mobile-first 模板时有效 */
|
|
88
|
+
customClass: {
|
|
89
|
+
type: String,
|
|
90
|
+
default: ""
|
|
91
|
+
},
|
|
92
|
+
/** 设置通栏按钮,宽度充满水平方向, 仅 mobile-first 模板时有效 */
|
|
93
|
+
banner: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
default: false
|
|
96
|
+
},
|
|
97
|
+
/** 是否幽灵按钮 */
|
|
98
|
+
ghost: Boolean,
|
|
99
|
+
/** 点击事件 */
|
|
100
|
+
onClick: {
|
|
101
|
+
type: Function
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
var Button = defineComponent({
|
|
105
|
+
name: $prefix + "Button",
|
|
106
|
+
inject: {
|
|
107
|
+
buttonGroup: {
|
|
108
|
+
default: ""
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
props: buttonProps,
|
|
112
|
+
slots: Object,
|
|
113
|
+
setup: function setup(props, context) {
|
|
114
|
+
return $setup({
|
|
115
|
+
props,
|
|
116
|
+
context,
|
|
117
|
+
template
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
var version = "2.21.0";
|
|
122
|
+
Button.install = function(Vue) {
|
|
123
|
+
Vue.component(Button.name, Button);
|
|
124
|
+
};
|
|
125
|
+
Button.version = version;
|
|
126
|
+
export {
|
|
127
|
+
Button as default
|
|
128
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { renderless, api } from '@opentinyvue/vue-renderless/button/vue';
|
|
2
|
+
import { defineComponent, props, setup } from '@opentinyvue/vue-common';
|
|
3
|
+
import { iconLoading } from '@opentinyvue/vue-icon';
|
|
4
|
+
|
|
5
|
+
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
|
6
|
+
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
|
7
|
+
if (render) {
|
|
8
|
+
options.render = render;
|
|
9
|
+
options.staticRenderFns = staticRenderFns;
|
|
10
|
+
options._compiled = true;
|
|
11
|
+
}
|
|
12
|
+
var hook;
|
|
13
|
+
if (injectStyles) {
|
|
14
|
+
hook = injectStyles;
|
|
15
|
+
}
|
|
16
|
+
if (hook) {
|
|
17
|
+
if (options.functional) {
|
|
18
|
+
options._injectStyles = hook;
|
|
19
|
+
var originalRender = options.render;
|
|
20
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
21
|
+
hook.call(context);
|
|
22
|
+
return originalRender(h, context);
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
var existing = options.beforeCreate;
|
|
26
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
exports: scriptExports,
|
|
31
|
+
options
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var classes = {
|
|
36
|
+
"button": "inline-block text-center overflow-hidden overflow-ellipsis whitespace-nowrap transition-button duration-300 delay-[0ms] active:transition-all active:scale-[0.95] active:ease-[cubic-bezier(0.33,0,0.67,1)]",
|
|
37
|
+
"button-base-width": "sm:max-w-[theme(spacing.36)]",
|
|
38
|
+
"size-default": "h-10 text-sm sm:h-7",
|
|
39
|
+
"size-medium": "h-10 text-sm sm:h-8",
|
|
40
|
+
"size-small": "h-8 text-sm sm:h-7",
|
|
41
|
+
"size-mini": "h-7 sm:h-6 sm:text-xs",
|
|
42
|
+
"type-default": "text-color-text-primary border-color-border hover:border-color-border-hover active:border-color-border-hover sm:cursor-pointer",
|
|
43
|
+
"type-primary": "text-color-text-inverse border-color-brand bg-color-brand hover:border-color-brand-hover hover:bg-color-brand-hover active:border-color-brand-active active:bg-color-brand-active sm:cursor-pointer",
|
|
44
|
+
"type-success": "text-color-text-inverse border-color-success bg-color-success hover:border-color-success-hover hover:bg-color-success-hover active:border-color-success-active active:bg-color-success-active sm:cursor-pointer",
|
|
45
|
+
"type-info": "text-color-text-inverse border-color-info-secondary bg-color-info-secondary hover:border-color-info-secondary-hover hover:bg-color-info-secondary-hover active:border-color-info-secondary-active active:bg-color-info-secondary-active sm:cursor-pointer",
|
|
46
|
+
"type-warning": "text-color-text-inverse border-color-warning bg-color-warning hover:border-color-warning-hover hover:bg-color-warning-hover active:border-color-warning-active active:bg-color-warning-active sm:cursor-pointer",
|
|
47
|
+
"type-danger": "text-color-text-inverse border-color-error bg-color-error hover:border-color-error-hover hover:bg-color-error-hover active:border-color-error-active active:bg-color-error-active sm:cursor-pointer",
|
|
48
|
+
"type-text": "border-none bg-transparent cursor-pointer text-color-text-placeholder active:text-color-text-primary sm:hover:text-color-text-primary sm:active:!text-color-brand-active",
|
|
49
|
+
"type-default-disabled": "text-color-text-disabled bg-color-bg-3 border-transparent hover:cursor-not-allowed",
|
|
50
|
+
"type-primary-disabled": "text-color-text-inverse bg-color-brand-disabled border-transparent hover:cursor-not-allowed",
|
|
51
|
+
"type-success-disabled": "text-color-text-inverse bg-color-success-disabled border-transparent hover:cursor-not-allowed",
|
|
52
|
+
"type-info-disabled": "text-color-text-inverse bg-color-info-secondary-disabled border-transparent hover:cursor-not-allowed",
|
|
53
|
+
"type-warning-disabled": "text-color-text-inverse bg-color-alert-disabled border-transparent hover:cursor-not-allowed",
|
|
54
|
+
"type-danger-disabled": "text-color-text-inverse bg-color-error-disabled border-transparent hover:cursor-not-allowed",
|
|
55
|
+
"type-text-disabled": "text-color-text-disabled hover:cursor-not-allowed",
|
|
56
|
+
"type-default-plain": "text-color-text-primary border-color-border hover:border-color-border-hover active:border-color-border-hover sm:cursor-pointer",
|
|
57
|
+
"type-primary-plain": "text-color-brand border-color-brand hover:text-color-brand-hover hover:border-color-brand-hover active:text-color-brand-active active:border-color-brand-active bg-color-bg-1 sm:cursor-pointer",
|
|
58
|
+
"type-success-plain": "text-color-success border-color-success hover:text-color-success-hover hover:border-color-success-hover active:text-color-success-active active:border-color-success-active bg-color-bg-1 sm:cursor-pointer",
|
|
59
|
+
"type-info-plain": "text-color-info-secondary border-color-info-secondary hover:text-color-info-secondary-hover hover:border-color-info-secondary-hover active:text-color-info-secondary-active active:border-color-info-secondary-active bg-color-bg-1 sm:cursor-pointer",
|
|
60
|
+
"type-warning-plain": "text-color-warning border-color-warning hover:text-color-warning-hover hover:border-color-warning-hover active:text-color-warning-active active:border-color-warning-active bg-color-bg-1 sm:cursor-pointer",
|
|
61
|
+
"type-danger-plain": "text-color-error border-color-error hover:text-color-error-hover hover:border-color-error-hover active:text-color-error-active active:border-color-error-active bg-color-bg-1 sm:cursor-pointer",
|
|
62
|
+
"type-text-plain": "text-color-brand hover:text-color-brand-hover active:text-color-brand-active",
|
|
63
|
+
"type-default-plain-disabled": "text-color-text-disabled bg-color-bg-1 border-color-text-disabled hover:cursor-not-allowed",
|
|
64
|
+
"type-primary-plain-disabled": "text-color-brand-disabled bg-color-bg-1 border-color-brand-disabled hover:cursor-not-allowed",
|
|
65
|
+
"type-success-plain-disabled": "text-color-success-disabled bg-color-bg-1 border-color-success-disabled hover:cursor-not-allowed",
|
|
66
|
+
"type-info-plain-disabled": "text-color-info-secondary-disabled bg-color-bg-1 border-color-info-secondary-disabled hover:cursor-not-allowed",
|
|
67
|
+
"type-warning-plain-disabled": "text-color-alert-disabled bg-color-bg-1 border-color-alert-disabled hover:cursor-not-allowed",
|
|
68
|
+
"type-danger-plain-disabled": "text-color-error-disabled bg-color-bg-1 border-color-error-disabled hover:cursor-not-allowed",
|
|
69
|
+
"type-text-plain-disabled": "text-color-text-disabled hover:cursor-not-allowed",
|
|
70
|
+
"no-round": "rounded",
|
|
71
|
+
"is-round": "rounded-full",
|
|
72
|
+
"is-border": "border-0.5 sm:border",
|
|
73
|
+
"no-circle": "sm:min-w-[theme(spacing.18)] pl-3 pr-3",
|
|
74
|
+
"is-circle": "sm:min-w-[theme(spacing.18)] sm:rounded-full sm:pl-2 sm:pr-2",
|
|
75
|
+
"button-icon": "-mt-0.5 sm:text-base fill-current",
|
|
76
|
+
"button-icon-default": "text-color-icon-primary hover:text-color-icon-hover active:text-color-icon-active",
|
|
77
|
+
"button-icon-disabled": "text-color-icon-disabled hover:cursor-not-allowed",
|
|
78
|
+
"loading-svg": "animate-spin-2 mr-1 fill-current -left-0.5 -right-0.5 -top-0.5 -bottom-0.5",
|
|
79
|
+
"button-link": "text-color-link hover:text-color-link-hover active:color-link-hover active:hover:text-color-link-hover sm:hover:text-color-link-hover",
|
|
80
|
+
"button-banner": " w-[calc(100%-theme(spacing.8))] mx-4"
|
|
81
|
+
};
|
|
82
|
+
var __vue2_script = defineComponent({
|
|
83
|
+
emits: ["click"],
|
|
84
|
+
props: [].concat(props, ["type", "text", "size", "icon", "resetTime", "nativeType", "loading", "disabled", "plain", "autofocus", "round", "circle", "tabindex", "href", "customClass", "banner"]),
|
|
85
|
+
components: {
|
|
86
|
+
IconLoading: iconLoading()
|
|
87
|
+
},
|
|
88
|
+
setup: function setup$1(props2, context) {
|
|
89
|
+
return setup({
|
|
90
|
+
props: props2,
|
|
91
|
+
context,
|
|
92
|
+
renderless,
|
|
93
|
+
api,
|
|
94
|
+
classes
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
var render = function render2() {
|
|
99
|
+
var _vm = this;
|
|
100
|
+
var _h = _vm.$createElement;
|
|
101
|
+
var _c = _vm._self._c || _h;
|
|
102
|
+
return _c("button", _vm._b({
|
|
103
|
+
class: _vm.m(_vm.gcls("button"), _vm.gcls(_vm.banner ? "button-banner" : "button-base-width"), _vm.gcls("size-" + (_vm.size || "default")), _vm.gcls("type-" + (_vm.type || "default") + (_vm.icon ? "-icon" : _vm.state.plain ? "-plain" : "") + (_vm.state.buttonDisabled ? "-disabled" : "")), _vm.gcls(_vm.state.round ? "is-round" : "no-round"), _vm.gcls(_vm.circle ? "is-circle" : "no-circle"), _vm.gcls({
|
|
104
|
+
"is-border": _vm.circle || !(_vm.type === "text" || _vm.icon)
|
|
105
|
+
}), _vm.gcls({
|
|
106
|
+
"button-link": _vm.href
|
|
107
|
+
}), _vm.customClass),
|
|
108
|
+
attrs: {
|
|
109
|
+
"data-tag": "tiny-button",
|
|
110
|
+
"disabled": _vm.state.buttonDisabled || _vm.loading,
|
|
111
|
+
"autofocus": _vm.autofocus,
|
|
112
|
+
"type": _vm.nativeType,
|
|
113
|
+
"tabindex": _vm.tabindex
|
|
114
|
+
},
|
|
115
|
+
on: {
|
|
116
|
+
"click": _vm.handleClick
|
|
117
|
+
}
|
|
118
|
+
}, "button", _vm.a(_vm.$attrs, ["class", "style", "id"], true), false), [_vm.loading ? _c("icon-loading", {
|
|
119
|
+
class: _vm.gcls("loading-svg")
|
|
120
|
+
}) : _vm._e(), _vm.icon && !_vm.loading ? _c(_vm.icon, {
|
|
121
|
+
tag: "component",
|
|
122
|
+
class: [_vm.gcls("button-icon"), _vm.gcls("button-icon-" + (_vm.state.buttonDisabled ? "disabled" : "default"))]
|
|
123
|
+
}) : _vm._e(), _vm._t("default", function() {
|
|
124
|
+
return [_c("span", [_vm._v(_vm._s(_vm.text))])];
|
|
125
|
+
})], 2);
|
|
126
|
+
};
|
|
127
|
+
var staticRenderFns = [];
|
|
128
|
+
var __cssModules = {};
|
|
129
|
+
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
|
|
130
|
+
function __vue2_injectStyles(context) {
|
|
131
|
+
for (var o in __cssModules) {
|
|
132
|
+
this[o] = __cssModules[o];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
var mobileFirst = /* @__PURE__ */ function() {
|
|
136
|
+
return __component__.exports;
|
|
137
|
+
}();
|
|
138
|
+
|
|
139
|
+
export { mobileFirst as default };
|
package/lib/mobile.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { renderless, api } from '@opentinyvue/vue-renderless/button/vue';
|
|
2
|
+
import { defineComponent, props, setup } from '@opentinyvue/vue-common';
|
|
3
|
+
import '@opentinyvue/vue-theme-mobile/button/index.css';
|
|
4
|
+
|
|
5
|
+
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
|
6
|
+
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
|
7
|
+
if (render) {
|
|
8
|
+
options.render = render;
|
|
9
|
+
options.staticRenderFns = staticRenderFns;
|
|
10
|
+
options._compiled = true;
|
|
11
|
+
}
|
|
12
|
+
var hook;
|
|
13
|
+
if (injectStyles) {
|
|
14
|
+
hook = injectStyles;
|
|
15
|
+
}
|
|
16
|
+
if (hook) {
|
|
17
|
+
if (options.functional) {
|
|
18
|
+
options._injectStyles = hook;
|
|
19
|
+
var originalRender = options.render;
|
|
20
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
21
|
+
hook.call(context);
|
|
22
|
+
return originalRender(h, context);
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
var existing = options.beforeCreate;
|
|
26
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
exports: scriptExports,
|
|
31
|
+
options
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var __vue2_script = defineComponent({
|
|
36
|
+
emits: ["click"],
|
|
37
|
+
props: [].concat(props, ["type", "text", "size", "icon", "resetTime", "nativeType", "loading", "disabled", "customClass"]),
|
|
38
|
+
components: {},
|
|
39
|
+
setup: function setup$1(props2, context) {
|
|
40
|
+
return setup({
|
|
41
|
+
props: props2,
|
|
42
|
+
context,
|
|
43
|
+
renderless,
|
|
44
|
+
api
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
var render = function render2() {
|
|
49
|
+
var _vm = this;
|
|
50
|
+
var _h = _vm.$createElement;
|
|
51
|
+
var _c = _vm._self._c || _h;
|
|
52
|
+
return _c("button", _vm._b({
|
|
53
|
+
staticClass: "tiny-mobile-button",
|
|
54
|
+
class: [_vm.type ? "tiny-mobile-button--" + _vm.type : "", _vm.size ? "tiny-mobile-button--" + _vm.size : "", {
|
|
55
|
+
"is-disabled": _vm.state.buttonDisabled,
|
|
56
|
+
"is-loading": _vm.loading
|
|
57
|
+
}],
|
|
58
|
+
attrs: {
|
|
59
|
+
"disabled": _vm.state.buttonDisabled || _vm.loading,
|
|
60
|
+
"type": _vm.nativeType
|
|
61
|
+
},
|
|
62
|
+
on: {
|
|
63
|
+
"click": _vm.handleClick
|
|
64
|
+
}
|
|
65
|
+
}, "button", _vm.a(_vm.$attrs, ["class", "style"], true), false), [_vm.loading ? [_c("div", {
|
|
66
|
+
class: ["tiny-mobile-button-loading", "tiny-mobile-button-loading-" + (_vm.type === "primary" ? "white" : "black")]
|
|
67
|
+
}, [_c("div", {
|
|
68
|
+
staticClass: "tiny-mobile-button-loading-inner"
|
|
69
|
+
})])] : _vm._e(), _vm.icon && !_vm.loading ? _c(_vm.icon, {
|
|
70
|
+
tag: "component",
|
|
71
|
+
class: ["tiny-icon", "is-icon", _vm.text ? "small" : null]
|
|
72
|
+
}) : _vm._e(), _vm._t("default", function() {
|
|
73
|
+
return [_c("span", {
|
|
74
|
+
style: {
|
|
75
|
+
marginLeft: _vm.text && (_vm.icon || _vm.loading) ? "4px" : 0
|
|
76
|
+
}
|
|
77
|
+
}, [_vm._v(_vm._s(_vm.text))])];
|
|
78
|
+
})], 2);
|
|
79
|
+
};
|
|
80
|
+
var staticRenderFns = [];
|
|
81
|
+
var __cssModules = {};
|
|
82
|
+
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
|
|
83
|
+
function __vue2_injectStyles(context) {
|
|
84
|
+
for (var o in __cssModules) {
|
|
85
|
+
this[o] = __cssModules[o];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
var mobile = /* @__PURE__ */ function() {
|
|
89
|
+
return __component__.exports;
|
|
90
|
+
}();
|
|
91
|
+
|
|
92
|
+
export { mobile as default };
|
package/lib/pc.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { renderless, api } from '@opentinyvue/vue-renderless/button/vue';
|
|
2
|
+
import { defineComponent, props, setup } from '@opentinyvue/vue-common';
|
|
3
|
+
import { iconLoadingShadow } from '@opentinyvue/vue-icon';
|
|
4
|
+
import '@opentinyvue/vue-theme/button/index.css';
|
|
5
|
+
|
|
6
|
+
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
|
7
|
+
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
|
8
|
+
if (render) {
|
|
9
|
+
options.render = render;
|
|
10
|
+
options.staticRenderFns = staticRenderFns;
|
|
11
|
+
options._compiled = true;
|
|
12
|
+
}
|
|
13
|
+
var hook;
|
|
14
|
+
if (injectStyles) {
|
|
15
|
+
hook = injectStyles;
|
|
16
|
+
}
|
|
17
|
+
if (hook) {
|
|
18
|
+
if (options.functional) {
|
|
19
|
+
options._injectStyles = hook;
|
|
20
|
+
var originalRender = options.render;
|
|
21
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
22
|
+
hook.call(context);
|
|
23
|
+
return originalRender(h, context);
|
|
24
|
+
};
|
|
25
|
+
} else {
|
|
26
|
+
var existing = options.beforeCreate;
|
|
27
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
exports: scriptExports,
|
|
32
|
+
options
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var __vue2_script = defineComponent({
|
|
37
|
+
emits: ["click"],
|
|
38
|
+
props: [].concat(props, ["type", "text", "size", "icon", "resetTime", "nativeType", "loading", "disabled", "plain", "autofocus", "round", "circle", "tabindex", "customClass", "ghost"]),
|
|
39
|
+
components: {
|
|
40
|
+
IconLoading: iconLoadingShadow()
|
|
41
|
+
},
|
|
42
|
+
setup: function setup$1(props2, context) {
|
|
43
|
+
return setup({
|
|
44
|
+
props: props2,
|
|
45
|
+
context,
|
|
46
|
+
renderless,
|
|
47
|
+
api
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
var render = function render2() {
|
|
52
|
+
var _vm = this;
|
|
53
|
+
var _h = _vm.$createElement;
|
|
54
|
+
var _c = _vm._self._c || _h;
|
|
55
|
+
return _c("button", _vm._b({
|
|
56
|
+
staticClass: "tiny-button",
|
|
57
|
+
class: [_vm.type ? "tiny-button--" + _vm.type : "", _vm.size ? "tiny-button--" + _vm.size : "", {
|
|
58
|
+
"is-disabled": _vm.state.buttonDisabled,
|
|
59
|
+
"is-loading": _vm.loading,
|
|
60
|
+
"is-plain": _vm.state.plain,
|
|
61
|
+
"is-ghost": _vm.ghost,
|
|
62
|
+
"is-round": _vm.state.round,
|
|
63
|
+
"is-circle": _vm.circle,
|
|
64
|
+
"is-icon": _vm.icon && !_vm.loading && (_vm.text || _vm.slots.default),
|
|
65
|
+
"is-only-icon": _vm.icon && !_vm.loading && !(_vm.text || _vm.slots.default)
|
|
66
|
+
}],
|
|
67
|
+
attrs: {
|
|
68
|
+
"disabled": _vm.state.buttonDisabled || _vm.loading,
|
|
69
|
+
"autofocus": _vm.autofocus,
|
|
70
|
+
"type": _vm.nativeType,
|
|
71
|
+
"tabindex": _vm.tabindex
|
|
72
|
+
},
|
|
73
|
+
on: {
|
|
74
|
+
"click": _vm.handleClick
|
|
75
|
+
}
|
|
76
|
+
}, "button", _vm.a(_vm.$attrs, ["class", "style", "title", "id"], true), false), [_vm.loading ? _c("icon-loading", {
|
|
77
|
+
staticClass: "tiny-icon-loading tiny-svg-size"
|
|
78
|
+
}) : _vm._e(), _vm.icon && !_vm.loading ? _c(_vm.icon, {
|
|
79
|
+
tag: "component",
|
|
80
|
+
class: {
|
|
81
|
+
"is-text": _vm.text || _vm.slots.default
|
|
82
|
+
}
|
|
83
|
+
}) : _vm._e(), _vm._t("default", function() {
|
|
84
|
+
return [_c("span", [_vm._v(_vm._s(_vm.text))])];
|
|
85
|
+
})], 2);
|
|
86
|
+
};
|
|
87
|
+
var staticRenderFns = [];
|
|
88
|
+
var __cssModules = {};
|
|
89
|
+
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
|
|
90
|
+
function __vue2_injectStyles(context) {
|
|
91
|
+
for (var o in __cssModules) {
|
|
92
|
+
this[o] = __cssModules[o];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
var pc = /* @__PURE__ */ function() {
|
|
96
|
+
return __component__.exports;
|
|
97
|
+
}();
|
|
98
|
+
|
|
99
|
+
export { pc as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opentinyvue/vue-button",
|
|
3
|
+
"version": "2.21.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"module": "./lib/index.js",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"type": "module",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@opentinyvue/vue-common": "~2.21.0",
|
|
11
|
+
"@opentinyvue/vue-icon": "~2.21.0",
|
|
12
|
+
"@opentinyvue/vue-renderless": "~3.21.0",
|
|
13
|
+
"@opentinyvue/vue-theme-mobile": "~3.21.0",
|
|
14
|
+
"@opentinyvue/vue-theme": "~3.21.0"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"types": "index.d.ts",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "pnpm -w build:ui $npm_package_name",
|
|
20
|
+
"//postversion": "pnpm build"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export declare const buttonProps: {
|
|
2
|
+
/** 展示按钮不同的状态,设置为text则展示为文本按钮。可取值为:'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text' */
|
|
3
|
+
type: {
|
|
4
|
+
type: StringConstructor;
|
|
5
|
+
default: string;
|
|
6
|
+
};
|
|
7
|
+
/** 设置原生的tabindex属性 */
|
|
8
|
+
tabindex: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
/** 按钮左侧展示的图标,接收为Icon组件 */
|
|
13
|
+
icon: {
|
|
14
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
15
|
+
default: string;
|
|
16
|
+
};
|
|
17
|
+
/** 按钮显示的文本 */
|
|
18
|
+
text: {
|
|
19
|
+
type: StringConstructor;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
/** 设置按钮禁用时间,防止重复提交,单位毫秒 */
|
|
23
|
+
resetTime: {
|
|
24
|
+
type: NumberConstructor;
|
|
25
|
+
default: number;
|
|
26
|
+
};
|
|
27
|
+
/** 对应按钮原生 type 属性 */
|
|
28
|
+
nativeType: {
|
|
29
|
+
type: StringConstructor;
|
|
30
|
+
default: string;
|
|
31
|
+
};
|
|
32
|
+
/** 当配置href后,点击按钮则更新 location.href 进行页面跳转 */
|
|
33
|
+
href: {
|
|
34
|
+
type: StringConstructor;
|
|
35
|
+
default: string;
|
|
36
|
+
};
|
|
37
|
+
/** 定义按钮尺寸 */
|
|
38
|
+
size: {
|
|
39
|
+
type: StringConstructor;
|
|
40
|
+
default: string;
|
|
41
|
+
validator(val: string): boolean;
|
|
42
|
+
};
|
|
43
|
+
/** 是否圆角按钮 */
|
|
44
|
+
round: {
|
|
45
|
+
type: BooleanConstructor;
|
|
46
|
+
default: undefined;
|
|
47
|
+
};
|
|
48
|
+
/** 是否朴素按钮 */
|
|
49
|
+
plain: BooleanConstructor;
|
|
50
|
+
/** 是否圆形按钮 */
|
|
51
|
+
circle: BooleanConstructor;
|
|
52
|
+
/** 是否加载中状态 */
|
|
53
|
+
loading: BooleanConstructor;
|
|
54
|
+
/** 是否被禁用按钮 */
|
|
55
|
+
disabled: BooleanConstructor;
|
|
56
|
+
/** 是否默认聚焦 */
|
|
57
|
+
autofocus: BooleanConstructor;
|
|
58
|
+
/** 自定义类名, 仅 mobile-first 模板时有效 */
|
|
59
|
+
customClass: {
|
|
60
|
+
type: StringConstructor;
|
|
61
|
+
default: string;
|
|
62
|
+
};
|
|
63
|
+
/** 设置通栏按钮,宽度充满水平方向, 仅 mobile-first 模板时有效 */
|
|
64
|
+
banner: {
|
|
65
|
+
type: BooleanConstructor;
|
|
66
|
+
default: boolean;
|
|
67
|
+
};
|
|
68
|
+
/** 是否幽灵按钮 */
|
|
69
|
+
ghost: BooleanConstructor;
|
|
70
|
+
/** 点击事件 */
|
|
71
|
+
onClick: {
|
|
72
|
+
type: PropType<(ev: MouseEvent) => void>;
|
|
73
|
+
};
|
|
74
|
+
tiny_mode: StringConstructor;
|
|
75
|
+
tiny_mode_root: BooleanConstructor;
|
|
76
|
+
tiny_template: (ObjectConstructor | FunctionConstructor)[];
|
|
77
|
+
tiny_renderless: FunctionConstructor; /** 是否圆形按钮 */
|
|
78
|
+
tiny_theme: StringConstructor;
|
|
79
|
+
tiny_chart_theme: ObjectConstructor;
|
|
80
|
+
};
|
|
81
|
+
declare const _default: any;
|
|
82
|
+
export default _default;
|
package/src/pc.vue.d.ts
ADDED
package/src/token.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare const classes: {
|
|
2
|
+
button: string;
|
|
3
|
+
'button-base-width': string;
|
|
4
|
+
'size-default': string;
|
|
5
|
+
'size-medium': string;
|
|
6
|
+
'size-small': string;
|
|
7
|
+
'size-mini': string;
|
|
8
|
+
'type-default': string;
|
|
9
|
+
'type-primary': string;
|
|
10
|
+
'type-success': string;
|
|
11
|
+
'type-info': string;
|
|
12
|
+
'type-warning': string;
|
|
13
|
+
'type-danger': string;
|
|
14
|
+
'type-text': string;
|
|
15
|
+
'type-default-disabled': string;
|
|
16
|
+
'type-primary-disabled': string;
|
|
17
|
+
'type-success-disabled': string;
|
|
18
|
+
'type-info-disabled': string;
|
|
19
|
+
'type-warning-disabled': string;
|
|
20
|
+
'type-danger-disabled': string;
|
|
21
|
+
'type-text-disabled': string;
|
|
22
|
+
'type-default-plain': string;
|
|
23
|
+
'type-primary-plain': string;
|
|
24
|
+
'type-success-plain': string;
|
|
25
|
+
'type-info-plain': string;
|
|
26
|
+
'type-warning-plain': string;
|
|
27
|
+
'type-danger-plain': string;
|
|
28
|
+
'type-text-plain': string;
|
|
29
|
+
'type-default-plain-disabled': string;
|
|
30
|
+
'type-primary-plain-disabled': string;
|
|
31
|
+
'type-success-plain-disabled': string;
|
|
32
|
+
'type-info-plain-disabled': string;
|
|
33
|
+
'type-warning-plain-disabled': string;
|
|
34
|
+
'type-danger-plain-disabled': string;
|
|
35
|
+
'type-text-plain-disabled': string;
|
|
36
|
+
'no-round': string;
|
|
37
|
+
'is-round': string;
|
|
38
|
+
'is-border': string;
|
|
39
|
+
'no-circle': string;
|
|
40
|
+
'is-circle': string;
|
|
41
|
+
'button-icon': string;
|
|
42
|
+
'button-icon-default': string;
|
|
43
|
+
'button-icon-disabled': string;
|
|
44
|
+
'loading-svg': string;
|
|
45
|
+
'button-link': string;
|
|
46
|
+
'button-banner': string;
|
|
47
|
+
};
|