first commit

This commit is contained in:
lingxiao865
2026-02-10 08:05:03 +08:00
commit c5af079d8c
1094 changed files with 97530 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
"use strict";
const props = {
/** 禁用输入框 */
disableInput: Boolean,
/** 禁用全部操作 */
disabled: {
type: Boolean,
default: void 0
},
/** 输入框宽度,默认单位 `px` */
inputWidth: {
type: Number
},
/** 是否整型 */
integer: {
type: Boolean,
default: true
},
/** 最大值 */
max: {
type: Number,
default: 100
},
/** 最小值 */
min: {
type: Number,
default: 0
},
/** 组件尺寸 */
size: {
type: String,
default: "medium",
validator(val) {
if (!val)
return true;
return ["small", "medium", "large"].includes(val);
}
},
/** 步长 */
step: {
type: Number,
default: 1
},
/** 组件风格 */
theme: {
type: String,
default: "normal",
validator(val) {
if (!val)
return true;
return ["normal", "filled", "outline"].includes(val);
}
},
/** 值 */
value: {
type: [String, Number],
default: 0
},
/** 值,非受控属性 */
defaultValue: {
type: [String, Number],
default: 0
},
/** 输入框失去焦点时触发 */
onBlur: {
type: Function,
default: () => ({})
},
/** 数值发生变更时触发 */
onChange: {
type: Function,
default: () => ({})
},
/** 输入框聚焦时触发 */
onFocus: {
type: Function,
default: () => ({})
},
/** 数值超出限制时触发 */
onOverlimit: {
type: Function,
default: () => ({})
}
};
exports.props = props;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/stepper/props.js.map

View File

@@ -0,0 +1,184 @@
"use strict";
const uni_modules_tdesignUniapp_components_common_src_instantiationDecorator = require("../common/src/instantiationDecorator.js");
const uni_modules_tdesignUniapp_components_common_config = require("../common/config.js");
const uni_modules_tdesignUniapp_components_common_utils = require("../common/utils.js");
const uni_modules_tdesignUniapp_components_stepper_props = require("./props.js");
const uni_modules_tdesignUniapp_components_common_utils_wxs = require("../common/utils.wxs.js");
const common_vendor = require("../../../../common/vendor.js");
const TIcon = () => "../icon/icon.js";
const name = `${uni_modules_tdesignUniapp_components_common_config.prefix}-stepper`;
const _sfc_main = uni_modules_tdesignUniapp_components_common_src_instantiationDecorator.uniComponent({
name,
options: {
styleIsolation: "shared"
},
controlledProps: [
{
key: "value",
event: "change"
}
],
externalClasses: [
`${uni_modules_tdesignUniapp_components_common_config.prefix}-class`,
`${uni_modules_tdesignUniapp_components_common_config.prefix}-class-input`,
`${uni_modules_tdesignUniapp_components_common_config.prefix}-class-minus`,
`${uni_modules_tdesignUniapp_components_common_config.prefix}-class-plus`
],
components: {
TIcon
},
props: {
...uni_modules_tdesignUniapp_components_stepper_props.props
},
data() {
return {
currentValue: 0,
classPrefix: name,
prefix: uni_modules_tdesignUniapp_components_common_config.prefix,
tools: uni_modules_tdesignUniapp_components_common_utils_wxs.tools,
disablePlus: false,
disableMinus: false
};
},
watch: {
value(v) {
this.preValue = Number(v);
this.updateCurrentValue(this.format(this.preValue));
}
},
mounted() {
const { value, defaultValue, min } = this;
const cur = uni_modules_tdesignUniapp_components_common_utils.coalesce(value, defaultValue);
this.updateCurrentValue(cur ? Number(cur) : min);
},
methods: {
isDisabled(type) {
const { min, max, disabled } = this;
const { currentValue } = this;
if (disabled) {
return true;
}
if (type === "minus" && currentValue <= min) {
return true;
}
if (type === "plus" && currentValue >= max) {
return true;
}
return false;
},
getLen(num) {
const numStr = num.toString();
return numStr.indexOf(".") === -1 ? 0 : numStr.split(".")[1].length;
},
add(a, b) {
const maxLen = Math.max(this.getLen(a), this.getLen(b));
const base = 10 ** maxLen;
return Math.round(a * base + b * base) / base;
},
format(value) {
const { min, max, step } = this;
const len = Math.max(this.getLen(step), this.getLen(value));
return Math.max(Math.min(max, value, Number.MAX_SAFE_INTEGER), min, Number.MIN_SAFE_INTEGER).toFixed(len);
},
setValue(value) {
const newValue = Number(this.format(value));
this.updateCurrentValue(newValue);
if (this.preValue === newValue)
return;
this.preValue = newValue;
this._trigger("change", { value: newValue });
},
minusValue() {
if (this.isDisabled("minus")) {
this.$emit("overlimit", { type: "minus" });
return false;
}
const { currentValue, step } = this;
this.setValue(this.add(currentValue, -step));
},
plusValue() {
if (this.isDisabled("plus")) {
this.$emit("overlimit", { type: "plus" });
return false;
}
const { currentValue, step } = this;
this.setValue(this.add(currentValue, step));
},
filterIllegalChar(value) {
const v = String(value).replace(/[^0-9.]/g, "");
const indexOfDot = v.indexOf(".");
if (this.integer && indexOfDot !== -1) {
return v.split(".")[0];
}
if (!this.integer && indexOfDot !== -1 && indexOfDot !== v.lastIndexOf(".")) {
return v.split(".", 2).join(".");
}
return v;
},
updateCurrentValue(value) {
this.currentValue = value;
},
handleFocus(e) {
const { value } = e.detail;
this.$emit("focus", { value });
},
handleInput(e) {
const { value } = e.detail;
if (value === "") {
return;
}
const formatted = this.filterIllegalChar(value);
const newValue = this.format(formatted);
this.updateCurrentValue(this.integer ? newValue : formatted);
if (this.integer || /\.\d+/.test(formatted)) {
this.setValue(formatted);
}
},
handleBlur(e) {
const { value: rawValue } = e.detail;
const value = this.format(rawValue);
this.setValue(value);
this.$emit("blur", { value });
}
}
});
if (!Array) {
const _easycom_t_icon2 = common_vendor.resolveComponent("t-icon");
_easycom_t_icon2();
}
const _easycom_t_icon = () => "../icon/icon.js";
if (!Math) {
_easycom_t_icon();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.p({
name: "remove"
}),
b: common_vendor.n(_ctx.classPrefix + "__minus " + _ctx.classPrefix + "__minus--" + _ctx.theme + " " + _ctx.classPrefix + "__icon--" + _ctx.size + " " + (_ctx.disabled || _ctx.disableMinus || _ctx.currentValue <= _ctx.min ? _ctx.classPrefix + "--" + _ctx.theme + "-disabled" : "") + " " + _ctx.tClassMinus),
c: "减少" + _ctx.step,
d: _ctx.disabled || _ctx.disableMinus || _ctx.currentValue <= _ctx.min,
e: common_vendor.o((...args) => _ctx.minusValue && _ctx.minusValue(...args)),
f: common_vendor.s(_ctx.inputWidth ? "width:" + _ctx.inputWidth + "px;" : ""),
g: common_vendor.n(_ctx.classPrefix + "__input " + _ctx.classPrefix + "__input--" + _ctx.size + " " + _ctx.tClassInput),
h: _ctx.disabled || _ctx.disableInput,
i: _ctx.integer ? "number" : "digit",
j: _ctx.currentValue,
k: common_vendor.o((...args) => _ctx.handleInput && _ctx.handleInput(...args)),
l: common_vendor.o((...args) => _ctx.handleFocus && _ctx.handleFocus(...args)),
m: common_vendor.o((...args) => _ctx.handleBlur && _ctx.handleBlur(...args)),
n: common_vendor.n(_ctx.classPrefix + "__input--" + _ctx.theme + " " + (_ctx.disabled || _ctx.disableInput ? _ctx.classPrefix + "--" + _ctx.theme + "-disabled" : "")),
o: common_vendor.p({
name: "add"
}),
p: common_vendor.n(_ctx.classPrefix + "__plus " + _ctx.classPrefix + "__plus--" + _ctx.theme + " " + _ctx.classPrefix + "__icon--" + _ctx.size + " " + (_ctx.disabled || _ctx.disablePlus || _ctx.currentValue >= _ctx.max ? _ctx.classPrefix + "--" + _ctx.theme + "-disabled" : "") + " " + _ctx.tClassPlus),
q: "增加" + _ctx.step,
r: _ctx.disabled || _ctx.disablePlus || _ctx.currentValue >= _ctx.max,
s: common_vendor.o((...args) => _ctx.plusValue && _ctx.plusValue(...args)),
t: common_vendor.s(_ctx.tools._style([_ctx.customStyle])),
v: common_vendor.n(_ctx.classPrefix + " " + _ctx.classPrefix + "--" + _ctx.size + " " + _ctx.tClass)
};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-5e12fbd0"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/stepper/stepper.js.map

View File

@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"t-icon": "../icon/icon"
}
}

View File

@@ -0,0 +1 @@
<view style="{{t}}" class="{{['data-v-5e12fbd0', v]}}"><view class="{{['data-v-5e12fbd0', b]}}" aria-label="{{c}}" aria-role="button" aria-disabled="{{d}}" catchtap="{{e}}"><t-icon wx:if="{{a}}" class="data-v-5e12fbd0" u-i="5e12fbd0-0" bind:__l="__l" u-p="{{a}}"/></view><view class="{{['data-v-5e12fbd0', n]}}"><block wx:if="{{r0}}"><input style="{{f}}" class="{{['data-v-5e12fbd0', g]}}" disabled="{{h}}" type="{{i}}" value="{{j}}" bindinput="{{k}}" bindfocus="{{l}}" bindblur="{{m}}"></input></block></view><view class="{{['data-v-5e12fbd0', p]}}" aria-label="{{q}}" aria-role="button" aria-disabled="{{r}}" catchtap="{{s}}"><t-icon wx:if="{{o}}" class="data-v-5e12fbd0" u-i="5e12fbd0-1" bind:__l="__l" u-p="{{o}}"/></view></view>

View File

@@ -0,0 +1,105 @@
.t-stepper.data-v-5e12fbd0 {
display: flex;
align-items: center;
color: var(--td-stepper-input-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
}
.t-stepper__input.data-v-5e12fbd0 {
margin: 0 8rpx;
text-align: center;
vertical-align: top;
height: inherit;
min-height: inherit;
}
.t-stepper__minus.data-v-5e12fbd0,
.t-stepper__plus.data-v-5e12fbd0 {
padding: 8rpx;
box-sizing: border-box;
}
.t-stepper__input.data-v-5e12fbd0,
.t-stepper__minus-icon.data-v-5e12fbd0,
.t-stepper__plus-icon.data-v-5e12fbd0 {
color: inherit;
}
.t-stepper__input--normal.data-v-5e12fbd0,
.t-stepper__input--filled.data-v-5e12fbd0,
.t-stepper__input--outline.data-v-5e12fbd0 {
height: inherit;
box-sizing: border-box;
}
.t-stepper--small.data-v-5e12fbd0 {
height: 40rpx;
font-size: 20rpx;
}
.t-stepper--medium.data-v-5e12fbd0 {
height: 48rpx;
font-size: 24rpx;
}
.t-stepper--large.data-v-5e12fbd0 {
height: 56rpx;
font-size: 32rpx;
}
.t-stepper__input--small.data-v-5e12fbd0 {
width: 68rpx;
}
.t-stepper__input--medium.data-v-5e12fbd0 {
height: 48rpx;
width: 76rpx;
}
.t-stepper__input--large.data-v-5e12fbd0 {
width: 90rpx;
}
.t-stepper__icon--small.data-v-5e12fbd0 {
width: 40rpx;
height: 40rpx;
font-size: 24rpx;
}
.t-stepper__icon--medium.data-v-5e12fbd0 {
width: 48rpx;
height: 48rpx;
font-size: 32rpx;
}
.t-stepper__icon--large.data-v-5e12fbd0 {
width: 56rpx;
height: 56rpx;
font-size: 40rpx;
}
.t-stepper__minus--outline.data-v-5e12fbd0,
.t-stepper__plus--outline.data-v-5e12fbd0 {
border: 2rpx solid var(--td-stepper-border-color, var(--td-component-border, var(--td-gray-color-4, #dcdcdc)));
}
.t-stepper__input--outline.data-v-5e12fbd0 {
border: none;
border-top: 2rpx solid var(--td-stepper-border-color, var(--td-component-border, var(--td-gray-color-4, #dcdcdc)));
border-bottom: 2rpx solid var(--td-stepper-border-color, var(--td-component-border, var(--td-gray-color-4, #dcdcdc)));
}
.t-stepper__minus--outline.data-v-5e12fbd0,
.t-stepper__minus--filled.data-v-5e12fbd0 {
border-radius: 0;
border-top-left-radius: var(--td-stepper-border-radius, var(--td-radius-small, 6rpx));
border-bottom-left-radius: var(--td-stepper-border-radius, var(--td-radius-small, 6rpx));
}
.t-stepper__plus--outline.data-v-5e12fbd0,
.t-stepper__plus--filled.data-v-5e12fbd0 {
border-radius: 0;
border-top-right-radius: var(--td-stepper-border-radius, var(--td-radius-small, 6rpx));
border-bottom-right-radius: var(--td-stepper-border-radius, var(--td-radius-small, 6rpx));
}
.t-stepper__minus--filled.data-v-5e12fbd0,
.t-stepper__plus--filled.data-v-5e12fbd0 {
background-color: var(--td-bg-color-secondarycontainer, var(--td-gray-color-1, #f3f3f3));
}
.t-stepper__input--filled.data-v-5e12fbd0 {
background-color: var(--td-bg-color-secondarycontainer, var(--td-gray-color-1, #f3f3f3));
margin: 0 8rpx;
}
.t-stepper__input--filled .t-stepper__input.data-v-5e12fbd0 {
margin: 0;
}
.t-stepper--normal-disabled.data-v-5e12fbd0 {
color: var(--td-stepper-input-disabled-color, var(--td-text-color-disabled, var(--td-font-gray-4, rgba(0, 0, 0, 0.26))));
}
.t-stepper--filled-disabled.data-v-5e12fbd0,
.t-stepper--outline-disabled.data-v-5e12fbd0 {
color: var(--td-stepper-input-disabled-color, var(--td-text-color-disabled, var(--td-font-gray-4, rgba(0, 0, 0, 0.26))));
background-color: var(--td-stepper-input-disabled-bg, var(--td-bg-color-component-disabled, var(--td-gray-color-2, #eeeeee)));
}