first commit
This commit is contained in:
66
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/bus.js
vendored
Normal file
66
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/bus.js
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
class Bus {
|
||||
constructor() {
|
||||
this.listeners = /* @__PURE__ */ new Map();
|
||||
this.emitted = /* @__PURE__ */ new Map();
|
||||
this.onceListeners = /* @__PURE__ */ new Map();
|
||||
}
|
||||
on(evtName, listener) {
|
||||
const target = this.listeners.get(evtName) || [];
|
||||
target.push(listener);
|
||||
this.listeners.set(evtName, target);
|
||||
if (this.emitted.has(evtName)) {
|
||||
listener(...this.emitted.get(evtName));
|
||||
}
|
||||
}
|
||||
once(evtName, listener) {
|
||||
if (this.emitted.has(evtName)) {
|
||||
listener(...this.emitted.get(evtName));
|
||||
return;
|
||||
}
|
||||
const onceWrapper = (...args) => {
|
||||
listener(...args);
|
||||
this.off(evtName, onceWrapper);
|
||||
};
|
||||
const onceMap = this.onceListeners.get(evtName) || /* @__PURE__ */ new Map();
|
||||
onceMap.set(listener, onceWrapper);
|
||||
this.onceListeners.set(evtName, onceMap);
|
||||
this.on(evtName, onceWrapper);
|
||||
}
|
||||
emit(evtName, ...args) {
|
||||
this.emitted.set(evtName, args);
|
||||
const listeners = this.listeners.get(evtName) || [];
|
||||
[...listeners].forEach((func) => func(...args));
|
||||
}
|
||||
off(evtName, listener) {
|
||||
if (listener) {
|
||||
const onceMap = this.onceListeners.get(evtName);
|
||||
if (onceMap && onceMap.has(listener)) {
|
||||
const wrapper = onceMap.get(listener);
|
||||
this._removeListener(evtName, wrapper);
|
||||
onceMap.delete(listener);
|
||||
return;
|
||||
}
|
||||
this._removeListener(evtName, listener);
|
||||
} else {
|
||||
this.listeners.delete(evtName);
|
||||
this.onceListeners.delete(evtName);
|
||||
this.emitted.delete(evtName);
|
||||
}
|
||||
}
|
||||
// 私有方法:从指定事件中移除单个监听器
|
||||
_removeListener(evtName, listener) {
|
||||
const listeners = this.listeners.get(evtName);
|
||||
if (!listeners)
|
||||
return;
|
||||
const index = listeners.indexOf(listener);
|
||||
if (index > -1) {
|
||||
listeners.splice(index, 1);
|
||||
if (listeners.length === 0) {
|
||||
this.listeners.delete(evtName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Bus = Bus;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/bus.js.map
|
||||
4
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/config.js
vendored
Normal file
4
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/config.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
const prefix = "t";
|
||||
exports.prefix = prefix;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/config.js.map
|
||||
46
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/functional/mixin.js
vendored
Normal file
46
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/functional/mixin.js
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
function formatPropKey(key) {
|
||||
return key.replace(/^(\w)/, (a, b) => `data${b.toUpperCase()}`);
|
||||
}
|
||||
function getPropsWatch(props) {
|
||||
const watchProps = Object.keys(props).reduce((acc, item) => {
|
||||
acc[item] = {
|
||||
handler(val) {
|
||||
this[formatPropKey(item)] = val;
|
||||
}
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
return watchProps;
|
||||
}
|
||||
function getPropsData(context, props) {
|
||||
const propsData = Object.keys(props).reduce((acc, item) => {
|
||||
acc[formatPropKey(item)] = context[item];
|
||||
return acc;
|
||||
}, {});
|
||||
return propsData;
|
||||
}
|
||||
function setPropsToData(data) {
|
||||
Object.keys(data).forEach((key) => {
|
||||
this[formatPropKey(key)] = data[key];
|
||||
});
|
||||
}
|
||||
function getFunctionalMixin(dialogProps) {
|
||||
return {
|
||||
data() {
|
||||
return {
|
||||
...getPropsData(this, dialogProps)
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
...getPropsWatch(dialogProps)
|
||||
},
|
||||
methods: {
|
||||
setData(data) {
|
||||
setPropsToData.call(this, data);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.getFunctionalMixin = getFunctionalMixin;
|
||||
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/functional/mixin.js.map
|
||||
2
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/relation/index.js
vendored
Normal file
2
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/relation/index.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/relation/index.js.map
|
||||
23
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/relation/parent-map.js
vendored
Normal file
23
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/relation/parent-map.js
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
const RELATION_MAP = {
|
||||
CollapsePanel: "Collapse",
|
||||
TabPanel: "Tabs",
|
||||
StepItem: "Steps",
|
||||
TabBarItem: "TabBar",
|
||||
SideBarItem: "SideBar",
|
||||
GridItem: "Grid",
|
||||
DropdownItem: "DropdownMenu",
|
||||
Radio: "RadioGroup",
|
||||
Checkbox: "CheckboxGroup",
|
||||
Cell: "CellGroup",
|
||||
Avatar: "AvatarGroup",
|
||||
PickerItem: "Picker",
|
||||
IndexesAnchor: "Indexes",
|
||||
SwiperNav: "Swiper",
|
||||
Col: "Row",
|
||||
BackTop: "PullDownRefresh",
|
||||
FormItem: "Form",
|
||||
FormKey: "FormKey"
|
||||
};
|
||||
exports.RELATION_MAP = RELATION_MAP;
|
||||
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/relation/parent-map.js.map
|
||||
89
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/relation/relation.js
vendored
Normal file
89
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/relation/relation.js
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
function ChildrenMixin(parent, options = {}) {
|
||||
const indexKey = options.indexKey || "index";
|
||||
return {
|
||||
inject: {
|
||||
[parent]: {
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
// 会造成循环引用
|
||||
// parent() {
|
||||
// if (this.disableBindRelation) {
|
||||
// return null;
|
||||
// }
|
||||
// return this[parent];
|
||||
// },
|
||||
[indexKey]() {
|
||||
const that = this;
|
||||
that.bindRelation();
|
||||
if (that[parent]) {
|
||||
return that[parent].children.indexOf(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
disableBindRelation(val) {
|
||||
const that = this;
|
||||
if (!val) {
|
||||
that.bindRelation();
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const that = this;
|
||||
that.bindRelation();
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
beforeUnmount() {
|
||||
const that = this;
|
||||
that.onBeforeMount();
|
||||
},
|
||||
methods: {
|
||||
bindRelation() {
|
||||
var _a, _b, _c;
|
||||
if (!this[parent] || this[parent].children && this[parent].children.indexOf(this) !== -1) {
|
||||
return;
|
||||
}
|
||||
const children = [...this[parent].children || [], this];
|
||||
this[parent].children = children;
|
||||
(_a = this.innerAfterLinked) == null ? void 0 : _a.call(this, this);
|
||||
(_c = (_b = this[parent]).innerAfterLinked) == null ? void 0 : _c.call(_b, this);
|
||||
},
|
||||
onBeforeMount() {
|
||||
var _a, _b, _c, _d;
|
||||
const that = this;
|
||||
if (that[parent]) {
|
||||
that[parent].children = that[parent].children.filter((item) => item !== that);
|
||||
(_b = (_a = this[parent]).innerAfterUnLinked) == null ? void 0 : _b.call(_a, this);
|
||||
(_c = this.innerAfterUnLinked) == null ? void 0 : _c.call(this, this);
|
||||
(_d = that == null ? void 0 : that.destroyCallback) == null ? void 0 : _d.call(that);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function ParentMixin(parent) {
|
||||
return {
|
||||
provide() {
|
||||
return {
|
||||
[parent]: this
|
||||
};
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 会造成循环引用
|
||||
// children: [],
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.ChildrenMixin = ChildrenMixin;
|
||||
exports.ParentMixin = ParentMixin;
|
||||
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/relation/relation.js.map
|
||||
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
function getRegExp() {
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
args.unshift(RegExp);
|
||||
return new (Function.prototype.bind.apply(RegExp, args))();
|
||||
}
|
||||
exports.getRegExp = getRegExp;
|
||||
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/runtime/wxs-polyfill.js.map
|
||||
2
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/src/control.js
vendored
Normal file
2
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/src/control.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/src/control.js.map
|
||||
2
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/src/flatTool.js
vendored
Normal file
2
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/src/flatTool.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/src/flatTool.js.map
|
||||
3
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/src/index.js
vendored
Normal file
3
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/src/index.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
require("./instantiationDecorator.js");
|
||||
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/src/index.js.map
|
||||
@@ -0,0 +1,185 @@
|
||||
"use strict";
|
||||
const uni_modules_tdesignUniapp_components_common_validator = require("../validator.js");
|
||||
const uni_modules_tdesignUniapp_components_common_version = require("../version.js");
|
||||
const uni_modules_tdesignUniapp_components_common_utils = require("../utils.js");
|
||||
const getInnerControlledValue = (key) => `data${key.replace(/^(\w)/, (e, t) => t.toUpperCase())}`;
|
||||
const getDefaultKey = (key) => `default${key.replace(/^(\w)/, (e, t) => t.toUpperCase())}`;
|
||||
const ARIAL_PROPS = [
|
||||
{ key: "ariaHidden", type: Boolean },
|
||||
{ key: "ariaRole", type: String },
|
||||
{ key: "ariaLabel", type: String },
|
||||
{ key: "ariaLabelledby", type: String },
|
||||
{ key: "ariaDescribedby", type: String },
|
||||
{ key: "ariaBusy", type: Boolean }
|
||||
];
|
||||
const getPropsDefault = (type, disableBoolean = false) => {
|
||||
if (type === Boolean && !disableBoolean) {
|
||||
return false;
|
||||
}
|
||||
if (type === String) {
|
||||
return "";
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
const COMMON_PROPS = {
|
||||
...ARIAL_PROPS.reduce((acc, item) => ({
|
||||
...acc,
|
||||
[item.key]: {
|
||||
type: item.type,
|
||||
default: getPropsDefault(item.type)
|
||||
}
|
||||
}), {}),
|
||||
customStyle: { type: [String, Object], default: "" }
|
||||
};
|
||||
const toComponent = function(options) {
|
||||
if (!options.properties && options.props) {
|
||||
options.properties = options.props;
|
||||
}
|
||||
if (options.properties) {
|
||||
Object.keys(options.properties).forEach((k) => {
|
||||
let opt = options.properties[k];
|
||||
if (!uni_modules_tdesignUniapp_components_common_validator.isPlainObject(opt)) {
|
||||
opt = { type: opt };
|
||||
}
|
||||
options.properties[k] = opt;
|
||||
});
|
||||
}
|
||||
if (!options.methods)
|
||||
options.methods = {};
|
||||
if (!options.lifetimes)
|
||||
options.lifetimes = {};
|
||||
const oldCreated = options.created;
|
||||
const { controlledProps = [] } = options;
|
||||
options.created = function(...args) {
|
||||
if (oldCreated) {
|
||||
oldCreated.apply(this, args);
|
||||
}
|
||||
controlledProps.forEach(({ key }) => {
|
||||
const defaultKey = getDefaultKey(key);
|
||||
const tDataKey = getInnerControlledValue(key);
|
||||
this[tDataKey] = this[key];
|
||||
if (this[key] == null) {
|
||||
this._selfControlled = true;
|
||||
}
|
||||
if (this[key] == null && this[defaultKey] != null) {
|
||||
this[tDataKey] = this[defaultKey];
|
||||
}
|
||||
});
|
||||
};
|
||||
options.methods._trigger = function(evtName, detail, opts) {
|
||||
const target = controlledProps.find((item) => item.event === evtName);
|
||||
if (target) {
|
||||
const { key } = target;
|
||||
if (this._selfControlled) {
|
||||
const tDataKey = getInnerControlledValue(key);
|
||||
this[tDataKey] = detail[key];
|
||||
}
|
||||
this.$emit(
|
||||
`update:${key}`,
|
||||
detail[key],
|
||||
opts
|
||||
);
|
||||
}
|
||||
this.$emit(
|
||||
evtName,
|
||||
detail,
|
||||
opts
|
||||
);
|
||||
};
|
||||
return options;
|
||||
};
|
||||
function sortPropsType(type) {
|
||||
if (!Array.isArray(type)) {
|
||||
return type;
|
||||
}
|
||||
type.sort((a, b) => {
|
||||
if (a === Boolean) {
|
||||
return -1;
|
||||
}
|
||||
if (b === Boolean) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return type;
|
||||
}
|
||||
function filterProps(props, controlledProps) {
|
||||
const newProps = {};
|
||||
const emits = [];
|
||||
const reg = /^on[A-Z][a-z]/;
|
||||
const controlledKeys = Object.values(controlledProps).map((item) => item.key);
|
||||
const unControlledKeys = controlledKeys.map((key) => getDefaultKey(key));
|
||||
Object.keys(props).forEach((key) => {
|
||||
const curType = props[key].type || props[key];
|
||||
if (reg.test(key) && props[key].type === Function) {
|
||||
const str = key.replace(/^on/, "");
|
||||
const eventName = str.charAt(0).toLowerCase() + str.slice(1);
|
||||
emits.push(...[uni_modules_tdesignUniapp_components_common_utils.hyphenate(eventName), eventName]);
|
||||
} else if (controlledKeys.indexOf(key) > -1 || unControlledKeys.indexOf(key) > -1) {
|
||||
const newType = Array.isArray(curType) ? curType : [curType];
|
||||
newProps[key] = {
|
||||
type: [null, ...newType],
|
||||
default: null
|
||||
};
|
||||
} else if ([Boolean, String].indexOf(props[key].type) > -1 && props[key].default === void 0) {
|
||||
newProps[key] = {
|
||||
...props[key],
|
||||
default: getPropsDefault(props[key].type, true)
|
||||
};
|
||||
} else {
|
||||
newProps[key] = {
|
||||
...typeof props[key] === "object" ? props[key] : {},
|
||||
type: sortPropsType(curType)
|
||||
};
|
||||
}
|
||||
});
|
||||
return {
|
||||
newProps,
|
||||
emits
|
||||
};
|
||||
}
|
||||
const getEmitsByControlledProps = (controlledProps) => Object.values(controlledProps).map((item) => `update:${item.key}`);
|
||||
const uniComponent = function(info) {
|
||||
const { newProps, emits } = filterProps(info.props || {}, info.controlledProps || {});
|
||||
info.props = {
|
||||
...getExternalClasses(info),
|
||||
...newProps,
|
||||
...COMMON_PROPS
|
||||
};
|
||||
info.emits = Array.from(/* @__PURE__ */ new Set([
|
||||
...info.emits || [],
|
||||
...getEmitsByControlledProps(info.controlledProps || {}),
|
||||
...emits
|
||||
]));
|
||||
info.options = {
|
||||
...info.options || {},
|
||||
multipleSlots: true
|
||||
};
|
||||
if (uni_modules_tdesignUniapp_components_common_version.canUseVirtualHost() && info.options.virtualHost == null) {
|
||||
info.options.virtualHost = true;
|
||||
}
|
||||
if (!info.options.styleIsolation) {
|
||||
info.options.styleIsolation = "shared";
|
||||
}
|
||||
if (info.name) {
|
||||
info.name = uni_modules_tdesignUniapp_components_common_utils.toPascal(info.name);
|
||||
}
|
||||
const obj = toComponent(info);
|
||||
return obj;
|
||||
};
|
||||
function getExternalClasses(info) {
|
||||
if (!info.externalClasses) {
|
||||
return {};
|
||||
}
|
||||
const { externalClasses } = info;
|
||||
const list = Array.isArray(externalClasses) ? externalClasses : [externalClasses];
|
||||
return list.reduce((acc, item) => ({
|
||||
...acc,
|
||||
[uni_modules_tdesignUniapp_components_common_utils.toCamel(item)]: {
|
||||
type: String,
|
||||
default: ""
|
||||
}
|
||||
}), {});
|
||||
}
|
||||
exports.uniComponent = uniComponent;
|
||||
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/src/instantiationDecorator.js.map
|
||||
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/src/superComponent.js.map
|
||||
188
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/utils.js
vendored
Normal file
188
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/utils.js
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_tdesignUniapp_components_common_config = require("./config.js");
|
||||
const uni_modules_tdesignUniapp_components_common_validator = require("./validator.js");
|
||||
const uni_modules_tdesignUniapp_components_common_wechat = require("./wechat.js");
|
||||
const systemInfo = uni_modules_tdesignUniapp_components_common_wechat.getWindowInfo();
|
||||
const appBaseInfo = uni_modules_tdesignUniapp_components_common_wechat.getAppBaseInfo();
|
||||
const deviceInfo = uni_modules_tdesignUniapp_components_common_wechat.getDeviceInfo();
|
||||
function coalesce(...args) {
|
||||
for (let i = 0; i < args.length; i += 1) {
|
||||
if (args[i] !== null && args[i] !== void 0) {
|
||||
return args[i];
|
||||
}
|
||||
}
|
||||
return args[args.length - 1];
|
||||
}
|
||||
const classNames = function(...args) {
|
||||
const hasOwn = {}.hasOwnProperty;
|
||||
const classes = [];
|
||||
args.forEach((arg) => {
|
||||
if (!arg)
|
||||
return;
|
||||
const argType = typeof arg;
|
||||
if (argType === "string" || argType === "number") {
|
||||
classes.push(arg);
|
||||
} else if (Array.isArray(arg) && arg.length) {
|
||||
const inner = classNames(...arg);
|
||||
if (inner) {
|
||||
classes.push(inner);
|
||||
}
|
||||
} else if (argType === "object") {
|
||||
for (const key in arg) {
|
||||
if (hasOwn.call(arg, key) && arg[key]) {
|
||||
classes.push(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return classes.join(" ");
|
||||
};
|
||||
const styles = function(styleObj) {
|
||||
return Object.keys(styleObj).map((styleKey) => `${styleKey}: ${styleObj[styleKey]}`).join("; ");
|
||||
};
|
||||
const getRect = function(context, selector, needAll = false, useH5Origin = false) {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.createSelectorQuery().in(context)[needAll ? "selectAll" : "select"](selector).boundingClientRect((rect) => {
|
||||
if (rect) {
|
||||
resolve(rect);
|
||||
} else {
|
||||
reject(rect);
|
||||
}
|
||||
}).exec();
|
||||
});
|
||||
};
|
||||
(deviceInfo == null ? void 0 : deviceInfo.environment) === "wxwork";
|
||||
["mac", "windows"].includes(deviceInfo == null ? void 0 : deviceInfo.platform);
|
||||
const addUnit = function(value) {
|
||||
if (!uni_modules_tdesignUniapp_components_common_validator.isDef(value)) {
|
||||
return void 0;
|
||||
}
|
||||
value = String(value);
|
||||
return uni_modules_tdesignUniapp_components_common_validator.isNumeric(value) ? `${value}px` : value;
|
||||
};
|
||||
const getCharacterLength = (type, char, max) => {
|
||||
const str = String(coalesce(char, ""));
|
||||
if (str.length === 0) {
|
||||
return {
|
||||
length: 0,
|
||||
characters: ""
|
||||
};
|
||||
}
|
||||
if (type === "maxcharacter") {
|
||||
let len = 0;
|
||||
for (let i = 0; i < str.length; i += 1) {
|
||||
let currentStringLength = 0;
|
||||
if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
|
||||
currentStringLength = 2;
|
||||
} else {
|
||||
currentStringLength = 1;
|
||||
}
|
||||
if (len + currentStringLength > max) {
|
||||
return {
|
||||
length: len,
|
||||
characters: str.slice(0, i)
|
||||
};
|
||||
}
|
||||
len += currentStringLength;
|
||||
}
|
||||
return {
|
||||
length: len,
|
||||
characters: str
|
||||
};
|
||||
}
|
||||
if (type === "maxlength") {
|
||||
const length = str.length > max ? max : str.length;
|
||||
return {
|
||||
length,
|
||||
characters: str.slice(0, length)
|
||||
};
|
||||
}
|
||||
return {
|
||||
length: str.length,
|
||||
characters: str
|
||||
};
|
||||
};
|
||||
const unitConvert = (value) => {
|
||||
if (typeof value === "string") {
|
||||
if (value.includes("rpx")) {
|
||||
return parseInt(value, 10) * coalesce(systemInfo == null ? void 0 : systemInfo.screenWidth, 750) / 750;
|
||||
}
|
||||
return parseInt(value, 10);
|
||||
}
|
||||
return coalesce(value, 0);
|
||||
};
|
||||
const setIcon = (iconName, icon, defaultIcon) => {
|
||||
if (icon) {
|
||||
if (typeof icon === "string") {
|
||||
return {
|
||||
[`${iconName}Name`]: icon,
|
||||
[`${iconName}Data`]: {}
|
||||
};
|
||||
}
|
||||
if (typeof icon === "object") {
|
||||
return {
|
||||
[`${iconName}Name`]: "",
|
||||
[`${iconName}Data`]: icon
|
||||
};
|
||||
}
|
||||
return {
|
||||
[`${iconName}Name`]: defaultIcon,
|
||||
[`${iconName}Data`]: {}
|
||||
};
|
||||
}
|
||||
return {
|
||||
[`${iconName}Name`]: "",
|
||||
[`${iconName}Data`]: {}
|
||||
};
|
||||
};
|
||||
const toCamel = (str) => str.replace(/-(\w)/g, (match, m1) => m1.toUpperCase());
|
||||
const toPascal = (name) => name.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
||||
function hyphenate(str) {
|
||||
const hyphenateRE = /\B([A-Z])/g;
|
||||
return str.replace(hyphenateRE, "-$1").toLowerCase();
|
||||
}
|
||||
const getCurrentPage = function() {
|
||||
const pages = getCurrentPages();
|
||||
return pages[pages.length - 1];
|
||||
};
|
||||
const uniqueFactory = (compName) => {
|
||||
let number = 0;
|
||||
return () => {
|
||||
const uniqueId = `${uni_modules_tdesignUniapp_components_common_config.prefix}_${compName}_${number}`;
|
||||
number += 1;
|
||||
return uniqueId;
|
||||
};
|
||||
};
|
||||
const calcIcon = (icon, defaultIcon) => {
|
||||
if (icon && (uni_modules_tdesignUniapp_components_common_validator.isBoolean(icon) && defaultIcon || uni_modules_tdesignUniapp_components_common_validator.isString(icon))) {
|
||||
return { name: uni_modules_tdesignUniapp_components_common_validator.isBoolean(icon) ? defaultIcon : icon };
|
||||
}
|
||||
if (uni_modules_tdesignUniapp_components_common_validator.isObject(icon)) {
|
||||
return icon;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
const nextTick = () => new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, 33);
|
||||
});
|
||||
exports.addUnit = addUnit;
|
||||
exports.appBaseInfo = appBaseInfo;
|
||||
exports.calcIcon = calcIcon;
|
||||
exports.classNames = classNames;
|
||||
exports.coalesce = coalesce;
|
||||
exports.getCharacterLength = getCharacterLength;
|
||||
exports.getCurrentPage = getCurrentPage;
|
||||
exports.getRect = getRect;
|
||||
exports.hyphenate = hyphenate;
|
||||
exports.nextTick = nextTick;
|
||||
exports.setIcon = setIcon;
|
||||
exports.styles = styles;
|
||||
exports.systemInfo = systemInfo;
|
||||
exports.toCamel = toCamel;
|
||||
exports.toPascal = toPascal;
|
||||
exports.uniqueFactory = uniqueFactory;
|
||||
exports.unitConvert = unitConvert;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/utils.js.map
|
||||
106
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/utils.wxs.js
vendored
Normal file
106
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/utils.wxs.js
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
const uni_modules_tdesignUniapp_components_common_runtime_wxsPolyfill = require("./runtime/wxs-polyfill.js");
|
||||
function addUnit(value) {
|
||||
const REGEXP = uni_modules_tdesignUniapp_components_common_runtime_wxsPolyfill.getRegExp("^-?\\d+(.\\d+)?$");
|
||||
if (value == null) {
|
||||
return void 0;
|
||||
}
|
||||
return REGEXP.test(`${value}`) ? `${value}px` : value;
|
||||
}
|
||||
function isString(string) {
|
||||
return typeof string === "string";
|
||||
}
|
||||
function isArray(array) {
|
||||
return Array.isArray(array);
|
||||
}
|
||||
function isObject(x) {
|
||||
const type = typeof x;
|
||||
return x !== null && (type === "object" || type === "function");
|
||||
}
|
||||
function isBoolean(value) {
|
||||
return typeof value === "boolean";
|
||||
}
|
||||
const isNoEmptyObj = function(obj) {
|
||||
return isObject(obj) && JSON.stringify(obj) !== "{}";
|
||||
};
|
||||
function includes(arr, value) {
|
||||
if (!arr || !isArray(arr))
|
||||
return false;
|
||||
let i = 0;
|
||||
const len = arr.length;
|
||||
for (; i < len; i++) {
|
||||
if (arr[i] === value)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function cls(base, arr) {
|
||||
const res = [base];
|
||||
let i = 0;
|
||||
for (let size = arr.length; i < size; i++) {
|
||||
const item = arr[i];
|
||||
if (item && Array.isArray(item)) {
|
||||
const key = arr[i][0];
|
||||
const value = arr[i][1];
|
||||
if (value) {
|
||||
res.push(`${base}--${key}`);
|
||||
}
|
||||
} else if (typeof item === "string" || typeof item === "number") {
|
||||
if (item) {
|
||||
res.push(`${base}--${item}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res.join(" ");
|
||||
}
|
||||
function getBadgeAriaLabel(options) {
|
||||
const maxCount = options.maxCount || 99;
|
||||
if (options.dot) {
|
||||
return "有新的消息";
|
||||
}
|
||||
if (options.count === "...") {
|
||||
return "有很多消息";
|
||||
}
|
||||
if (isNaN(options.count)) {
|
||||
return options.count;
|
||||
}
|
||||
const str1 = `有${maxCount}+条消息`;
|
||||
const str2 = `有${options.count}条消息`;
|
||||
return Number(options.count) > maxCount ? str1 : str2;
|
||||
}
|
||||
function endsWith(str, endStr) {
|
||||
return str.slice(-endStr.length) === endStr ? str : str + endStr;
|
||||
}
|
||||
function keys(obj) {
|
||||
return JSON.stringify(obj).replace(uni_modules_tdesignUniapp_components_common_runtime_wxsPolyfill.getRegExp('{|}|"', "g"), "").split(",").map((item) => item.split(":")[0]);
|
||||
}
|
||||
function kebabCase(str) {
|
||||
return str.replace(uni_modules_tdesignUniapp_components_common_runtime_wxsPolyfill.getRegExp("[A-Z]", "g"), (ele) => `-${ele}`).toLowerCase();
|
||||
}
|
||||
function _style(styles) {
|
||||
if (isArray(styles)) {
|
||||
return styles.filter((item) => item != null && item !== "").map((item) => isArray(item) || isObject(item) ? _style(item) : endsWith(item, ";")).join(" ");
|
||||
}
|
||||
if (isObject(styles)) {
|
||||
return keys(styles).filter((key) => styles[key] != null && styles[key] !== "").map((key) => [kebabCase(key), [styles[key]]].join(":")).join(";");
|
||||
}
|
||||
return styles;
|
||||
}
|
||||
function isValidIconName(str) {
|
||||
return uni_modules_tdesignUniapp_components_common_runtime_wxsPolyfill.getRegExp("^[A-Za-z0-9-_]+$").test(str);
|
||||
}
|
||||
const tools = {
|
||||
addUnit,
|
||||
isString,
|
||||
isArray,
|
||||
isObject,
|
||||
isBoolean,
|
||||
isNoEmptyObj,
|
||||
includes,
|
||||
cls,
|
||||
getBadgeAriaLabel,
|
||||
_style,
|
||||
isValidIconName
|
||||
};
|
||||
exports.tools = tools;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/utils.wxs.js.map
|
||||
27
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/validator.js
vendored
Normal file
27
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/validator.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
const isString = (val) => typeof val === "string";
|
||||
const isNull = (value) => value === null;
|
||||
const isUndefined = (value) => value === void 0;
|
||||
function isDef(value) {
|
||||
return !isUndefined(value) && !isNull(value);
|
||||
}
|
||||
function isNumeric(value) {
|
||||
return !Number.isNaN(Number(value));
|
||||
}
|
||||
function isBoolean(value) {
|
||||
return typeof value === "boolean";
|
||||
}
|
||||
function isObject(x) {
|
||||
const type = typeof x;
|
||||
return x !== null && (type === "object" || type === "function");
|
||||
}
|
||||
function isPlainObject(val) {
|
||||
return val !== null && typeof val === "object" && Object.prototype.toString.call(val) === "[object Object]";
|
||||
}
|
||||
exports.isBoolean = isBoolean;
|
||||
exports.isDef = isDef;
|
||||
exports.isNumeric = isNumeric;
|
||||
exports.isObject = isObject;
|
||||
exports.isPlainObject = isPlainObject;
|
||||
exports.isString = isString;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/validator.js.map
|
||||
43
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/version.js
vendored
Normal file
43
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/version.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
const uni_modules_tdesignUniapp_components_common_wechat = require("./wechat.js");
|
||||
let systemInfo;
|
||||
function getSystemInfo() {
|
||||
if (systemInfo == null) {
|
||||
systemInfo = uni_modules_tdesignUniapp_components_common_wechat.getAppBaseInfo();
|
||||
}
|
||||
return systemInfo;
|
||||
}
|
||||
function compareVersion(v1, v2) {
|
||||
v1 = v1.split(".");
|
||||
v2 = v2.split(".");
|
||||
const len = Math.max(v1.length, v2.length);
|
||||
while (v1.length < len) {
|
||||
v1.push("0");
|
||||
}
|
||||
while (v2.length < len) {
|
||||
v2.push("0");
|
||||
}
|
||||
for (let i = 0; i < len; i += 1) {
|
||||
const num1 = parseInt(v1[i], 10);
|
||||
const num2 = parseInt(v2[i], 10);
|
||||
if (num1 > num2) {
|
||||
return 1;
|
||||
}
|
||||
if (num1 < num2) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function judgeByVersion(version) {
|
||||
const currentSDKVersion = getSystemInfo().SDKVersion;
|
||||
return compareVersion(currentSDKVersion, version) >= 0;
|
||||
}
|
||||
function canUseVirtualHost() {
|
||||
let result = false;
|
||||
result = judgeByVersion("2.19.2");
|
||||
return result;
|
||||
}
|
||||
exports.canUseVirtualHost = canUseVirtualHost;
|
||||
exports.compareVersion = compareVersion;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/version.js.map
|
||||
17
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/wechat.js
vendored
Normal file
17
unpackage/dist/dev/mp-weixin/uni_modules/tdesign-uniapp/components/common/wechat.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const getObserver = (context, selector) => new Promise((resolve) => {
|
||||
common_vendor.index.createIntersectionObserver(context, {
|
||||
nativeMode: true
|
||||
}).relativeToViewport().observe(selector, (res) => {
|
||||
resolve(res);
|
||||
});
|
||||
});
|
||||
const getWindowInfo = () => common_vendor.index.getWindowInfo ? common_vendor.index.getWindowInfo() || common_vendor.index.getSystemInfoSync() : common_vendor.index.getSystemInfoSync();
|
||||
const getAppBaseInfo = () => common_vendor.index.getAppBaseInfo ? common_vendor.index.getAppBaseInfo() || common_vendor.index.getSystemInfoSync() : common_vendor.index.getSystemInfoSync();
|
||||
const getDeviceInfo = () => common_vendor.index.getDeviceInfo ? common_vendor.index.getDeviceInfo() || common_vendor.index.getSystemInfoSync() : common_vendor.index.getSystemInfoSync();
|
||||
exports.getAppBaseInfo = getAppBaseInfo;
|
||||
exports.getDeviceInfo = getDeviceInfo;
|
||||
exports.getObserver = getObserver;
|
||||
exports.getWindowInfo = getWindowInfo;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/wechat.js.map
|
||||
Reference in New Issue
Block a user