first commit

This commit is contained in:
PC-202306242200\Administrator
2026-03-28 23:10:55 +08:00
commit 1c24452b6c
1735 changed files with 150474 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
"use strict";
const uni_modules_wotDesignUni_components_common_props = require("../common/props.js");
const uni_modules_wotDesignUni_components_common_util = require("../common/util.js");
const pickerViewProps = {
...uni_modules_wotDesignUni_components_common_props.baseProps,
/**
* 加载状态
*/
loading: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(false),
/**
* 加载的颜色,只能使用十六进制的色值写法,且不能使用缩写
*/
loadingColor: uni_modules_wotDesignUni_components_common_props.makeStringProp("#4D80F0"),
/**
* picker内部滚筒高
*/
columnsHeight: uni_modules_wotDesignUni_components_common_props.makeNumberProp(217),
/**
* picker item的高度
*/
itemHeight: uni_modules_wotDesignUni_components_common_props.makeNumberProp(35),
/**
* 选项对象中value对应的 key
*/
valueKey: uni_modules_wotDesignUni_components_common_props.makeStringProp("value"),
/**
* 选项对象中,展示的文本对应的 key
*/
labelKey: uni_modules_wotDesignUni_components_common_props.makeStringProp("label"),
/**
* 是否在手指松开时立即触发picker-view的 change 事件。若不开启则会在滚动动画结束后触发 change 事件1.2.25版本起提供,仅微信小程序和支付宝小程序支持。
*/
immediateChange: uni_modules_wotDesignUni_components_common_props.makeBooleanProp(false),
/**
* 选中项,如果为多列选择器,则其类型应为数组
*/
modelValue: {
type: [String, Number, Boolean, Array, Array, Array],
default: "",
required: true
},
/**
* 选择器数据,可以为字符串数组,也可以为对象数组,如果为二维数组,则为多列选择器
*/
columns: uni_modules_wotDesignUni_components_common_props.makeArrayProp(),
/**
* 接收 pickerView 实例、选中项、当前修改列的下标、resolve 作为入参,根据选中项和列下标进行判断,通过 pickerView 实例暴露出来的 setColumnData 方法修改其他列的数据源。
*/
columnChange: Function
};
function formatArray(array, valueKey, labelKey) {
let tempArray = uni_modules_wotDesignUni_components_common_util.isArray(array) ? array : [array];
const firstLevelTypeList = new Set(array.map(uni_modules_wotDesignUni_components_common_util.getType));
if (firstLevelTypeList.size !== 1 && firstLevelTypeList.has("object")) {
throw Error("The columns are correct");
}
if (!uni_modules_wotDesignUni_components_common_util.isArray(array[0])) {
tempArray = [tempArray];
}
const result = tempArray.map((col) => {
return col.map((row) => {
if (!uni_modules_wotDesignUni_components_common_util.isObj(row)) {
return {
[valueKey]: row,
[labelKey]: row
};
}
if (!row.hasOwnProperty(valueKey) && !row.hasOwnProperty(labelKey)) {
throw Error("Can't find valueKey and labelKey in columns");
}
if (!row.hasOwnProperty(labelKey)) {
row[labelKey] = row[valueKey];
}
if (!row.hasOwnProperty(valueKey)) {
row[valueKey] = row[labelKey];
}
return row;
});
});
return result;
}
exports.formatArray = formatArray;
exports.pickerViewProps = pickerViewProps;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/wd-picker-view/types.js.map

View File

@@ -0,0 +1,255 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_wotDesignUni_components_common_util = require("../common/util.js");
const uni_modules_wotDesignUni_components_wdPickerView_types = require("./types.js");
if (!Math) {
wdLoading();
}
const wdLoading = () => "../wd-loading/wd-loading.js";
const __default__ = {
name: "wd-picker-view",
options: {
virtualHost: true,
addGlobalClass: true,
styleIsolation: "shared"
}
};
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
...__default__,
props: uni_modules_wotDesignUni_components_wdPickerView_types.pickerViewProps,
emits: ["change", "pickstart", "pickend", "update:modelValue"],
setup(__props, { expose: __expose, emit: __emit }) {
const props = __props;
const emit = __emit;
const formatColumns = common_vendor.ref([]);
const selectedIndex = common_vendor.ref([]);
common_vendor.watch(
[() => props.modelValue, () => props.columns],
(newValue, oldValue) => {
if (!uni_modules_wotDesignUni_components_common_util.isEqual(oldValue[1], newValue[1])) {
if (uni_modules_wotDesignUni_components_common_util.isArray(newValue[1]) && newValue[1].length > 0) {
formatColumns.value = uni_modules_wotDesignUni_components_wdPickerView_types.formatArray(newValue[1], props.valueKey, props.labelKey);
} else {
formatColumns.value = [];
selectedIndex.value = [];
}
}
if (uni_modules_wotDesignUni_components_common_util.isDef(newValue[0])) {
selectWithValue(newValue[0]);
}
},
{
deep: true,
immediate: true
}
);
const { proxy } = common_vendor.getCurrentInstance();
function selectWithValue(value) {
if (formatColumns.value.length === 0) {
selectedIndex.value = [];
return;
}
if (value === "" || !uni_modules_wotDesignUni_components_common_util.isDef(value) || uni_modules_wotDesignUni_components_common_util.isArray(value) && value.length === 0) {
value = formatColumns.value.map((col) => {
return col[0][props.valueKey];
});
}
const valueType = uni_modules_wotDesignUni_components_common_util.getType(value);
const type = ["string", "number", "boolean", "array"];
if (type.indexOf(valueType) === -1)
common_vendor.index.__f__("error", "at uni_modules/wot-design-uni/components/wd-picker-view/wd-picker-view.vue:99", `value must be one of ${type.toString()}`);
value = uni_modules_wotDesignUni_components_common_util.isArray(value) ? value : [value];
value = value.slice(0, formatColumns.value.length);
let selected = uni_modules_wotDesignUni_components_common_util.deepClone(selectedIndex.value);
value.forEach((target, col) => {
let row = formatColumns.value[col].findIndex((row2) => {
return row2[props.valueKey].toString() === target.toString();
});
row = row === -1 ? 0 : row;
selected = correctSelectedIndex(col, row, selected);
});
selectedIndex.value = selected.slice(0, value.length);
}
function correctSelected(value) {
let selected = uni_modules_wotDesignUni_components_common_util.deepClone(value);
value.forEach((row, col) => {
row = uni_modules_wotDesignUni_components_common_util.range(row, 0, formatColumns.value[col].length - 1);
selected = correctSelectedIndex(col, row, selected);
});
return selected;
}
function correctSelectedIndex(columnIndex, rowIndex, selected) {
const col = formatColumns.value[columnIndex];
if (!col || !col[rowIndex]) {
throw Error(`The value to select with Col:${columnIndex} Row:${rowIndex} is incorrect`);
}
const select = uni_modules_wotDesignUni_components_common_util.deepClone(selected);
select[columnIndex] = rowIndex;
if (col[rowIndex].disabled) {
const prev = col.slice(0, rowIndex).reverse().findIndex((s) => !s.disabled);
const next = col.slice(rowIndex + 1).findIndex((s) => !s.disabled);
if (prev !== -1) {
select[columnIndex] = rowIndex - 1 - prev;
} else if (next !== -1) {
select[columnIndex] = rowIndex + 1 + next;
} else if (select[columnIndex] === void 0) {
select[columnIndex] = 0;
}
}
return select;
}
function onChange({ detail: { value } }) {
value = value.map((v) => {
return Number(v || 0);
});
const index = getChangeDiff(value);
selectedIndex.value = uni_modules_wotDesignUni_components_common_util.deepClone(value);
common_vendor.nextTick$1(() => {
selectedIndex.value = correctSelected(value);
if (props.columnChange) {
if (props.columnChange.length < 4) {
props.columnChange(proxy.$.exposed, getSelects(), index || 0, () => {
});
handleChange(index || 0);
} else {
props.columnChange(proxy.$.exposed, getSelects(), index || 0, () => {
handleChange(index || 0);
});
}
} else {
handleChange(index || 0);
}
});
}
function getChangeColumn(now, origin) {
if (!now || !origin)
return -1;
const index = now.findIndex((row, index2) => row !== origin[index2]);
return index;
}
function getChangeDiff(value) {
value = value.slice(0, formatColumns.value.length);
const origin = uni_modules_wotDesignUni_components_common_util.deepClone(selectedIndex.value);
let selected = uni_modules_wotDesignUni_components_common_util.deepClone(selectedIndex.value);
value.forEach((row, col) => {
row = uni_modules_wotDesignUni_components_common_util.range(row, 0, formatColumns.value[col].length - 1);
if (row === origin[col])
return;
selected = correctSelectedIndex(col, row, selected);
});
const diffCol = getChangeColumn(selected, origin);
if (diffCol === -1)
return;
const diffRow = selected[diffCol];
return selected.length === 1 ? diffRow : diffCol;
}
function handleChange(index) {
const value = getValues();
if (uni_modules_wotDesignUni_components_common_util.isEqual(value, props.modelValue))
return;
emit("update:modelValue", value);
setTimeout(() => {
emit("change", {
picker: proxy.$.exposed,
value,
index
});
}, 0);
}
function getSelects() {
const selects = selectedIndex.value.map((row, col) => formatColumns.value[col][row]);
if (selects.length === 1) {
return selects[0];
}
return selects;
}
function getValues() {
const { valueKey } = props;
const values = selectedIndex.value.map((row, col) => {
return formatColumns.value[col][row][valueKey];
});
if (values.length === 1) {
return values[0];
}
return values;
}
function getLabels() {
const { labelKey } = props;
return selectedIndex.value.map((row, col) => formatColumns.value[col][row][labelKey]);
}
function getColumnIndex(columnIndex) {
return selectedIndex.value[columnIndex];
}
function getColumnData(columnIndex) {
return formatColumns.value[columnIndex];
}
function setColumnData(columnIndex, data, rowIndex = 0) {
formatColumns.value[columnIndex] = uni_modules_wotDesignUni_components_wdPickerView_types.formatArray(data, props.valueKey, props.labelKey).reduce((acc, val) => acc.concat(val), []);
selectedIndex.value = correctSelectedIndex(columnIndex, rowIndex, selectedIndex.value);
}
function getColumnsData() {
return uni_modules_wotDesignUni_components_common_util.deepClone(formatColumns.value);
}
function getSelectedIndex() {
return selectedIndex.value;
}
function resetColumns(columns) {
if (uni_modules_wotDesignUni_components_common_util.isArray(columns) && columns.length) {
formatColumns.value = uni_modules_wotDesignUni_components_wdPickerView_types.formatArray(columns, props.valueKey, props.labelKey);
}
}
function onPickStart() {
emit("pickstart");
}
function onPickEnd() {
emit("pickend");
}
__expose({
getSelects,
getValues,
setColumnData,
getColumnsData,
getColumnData,
getColumnIndex,
getLabels,
getSelectedIndex,
resetColumns
});
return (_ctx, _cache) => {
return common_vendor.e({
a: _ctx.loading
}, _ctx.loading ? {
b: common_vendor.p({
color: _ctx.loadingColor
})
} : {}, {
c: common_vendor.f(formatColumns.value, (col, colIndex, i0) => {
return {
a: common_vendor.f(col, (row, rowIndex, i1) => {
return {
a: common_vendor.t(row[_ctx.labelKey]),
b: rowIndex,
c: common_vendor.n(`wd-picker-view-column__item ${row["disabled"] ? "wd-picker-view-column__item--disabled" : ""} ${selectedIndex.value[colIndex] == rowIndex ? "wd-picker-view-column__item--active" : ""}`)
};
}),
b: colIndex
};
}),
d: common_vendor.s(`line-height: ${_ctx.itemHeight}px;`),
e: `height: ${_ctx.itemHeight}px;`,
f: common_vendor.s(`height: ${_ctx.columnsHeight - 20}px;`),
g: selectedIndex.value,
h: _ctx.immediateChange,
i: common_vendor.o(onChange),
j: common_vendor.o(onPickStart),
k: common_vendor.o(onPickEnd),
l: common_vendor.s(`height: ${_ctx.columnsHeight - 20}px;`),
m: common_vendor.n(`wd-picker-view ${_ctx.customClass}`),
n: common_vendor.s(_ctx.customStyle)
});
};
}
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c3bc94ff"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wot-design-uni/components/wd-picker-view/wd-picker-view.js.map

View File

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

View File

@@ -0,0 +1 @@
<view class="{{['data-v-c3bc94ff', m]}}" style="{{n}}"><view wx:if="{{a}}" class="wd-picker-view__loading data-v-c3bc94ff"><wd-loading wx:if="{{b}}" class="data-v-c3bc94ff" u-i="c3bc94ff-0" bind:__l="__l" u-p="{{b}}"/></view><view class="data-v-c3bc94ff" style="{{l}}"><block wx:if="{{r0}}"><picker-view class="data-v-c3bc94ff" mask-class="wd-picker-view__mask" indicator-class="wd-picker-view__roller" indicator-style="{{e}}" style="{{f}}" value="{{g}}" immediate-change="{{h}}" bindchange="{{i}}" bindpickstart="{{j}}" bindpickend="{{k}}"><picker-view-column wx:for="{{c}}" wx:for-item="col" wx:key="b" class="wd-picker-view-column data-v-c3bc94ff"><view wx:for="{{col.a}}" wx:for-item="row" wx:key="b" class="{{['data-v-c3bc94ff', row.c]}}" style="{{d}}">{{row.a}}</view></picker-view-column></picker-view></block></view></view>

View File

@@ -0,0 +1,237 @@
/* 水平间距 */
/* 水平间距 */
/**
* 混合宏
*/
/**
* SCSS 配置项命名空间以及BEM
*/
/**
* 辅助函数
*/
/**
* SCSS 配置项命名空间以及BEM
*/
/* 转换成字符串 */
/* 判断是否存在 Modifier */
/* 判断是否存在伪类 */
/**
* 主题色切换
* @params $theme-color 主题色
* @params $type 变暗dark 变亮 'light'
* @params $mix-color 自己设置的混色
*/
/**
* 颜色结果切换, 如果开启线性渐变色 使用渐变色,如果没有开启,那么使用主题色
* @params $open-linear 是否开启线性渐变色
* @params $deg 渐变色角度
* @params $theme-color 当前配色
* @params [Array] $set 主题色明暗设置,与 $color-list 数量对应
* @params [Array] $color-list 渐变色顺序, $color-list 和 $per-list 数量相同
* @params [Array] $per-list 渐变色比例
*/
/**
* BEM定义块b)
*/
/* 定义元素e对于伪类会自动将 e 嵌套在 伪类 底下 */
/* 此方法用于生成穿透样式 */
/* 定义元素e对于伪类会自动将 e 嵌套在 伪类 底下 */
/* 定义状态m */
/* 定义状态m */
/* 对于需要需要嵌套在 m 底下的 e调用这个混合宏一般在切换整个组件的状态如切换颜色的时候 */
/* 状态,生成 is-$state 类名 */
/**
* 常用混合宏
*/
/* 单行超出隐藏 */
/* 多行超出隐藏 */
/* 清除浮动 */
/* 0.5px 边框 指定方向*/
/* 0.5px 边框 环绕 */
/**
* 三角形实现尖角样式,适用于背景透明情况
* @param $size 三角形高,底边为 $size * 2
* @param $bg 三角形背景颜色
*/
/**
* 正方形实现尖角样式,适用于背景不透明情况
* @param $size 正方形边长
* @param $bg 正方形背景颜色
* @param $z-index z-index属性值不得大于外部包裹器
* @param $box-shadow 阴影
*/
/**
* 辅助函数
*/
/**
* SCSS 配置项命名空间以及BEM
*/
/* 转换成字符串 */
/* 判断是否存在 Modifier */
/* 判断是否存在伪类 */
/**
* 主题色切换
* @params $theme-color 主题色
* @params $type 变暗dark 变亮 'light'
* @params $mix-color 自己设置的混色
*/
/**
* 颜色结果切换, 如果开启线性渐变色 使用渐变色,如果没有开启,那么使用主题色
* @params $open-linear 是否开启线性渐变色
* @params $deg 渐变色角度
* @params $theme-color 当前配色
* @params [Array] $set 主题色明暗设置,与 $color-list 数量对应
* @params [Array] $color-list 渐变色顺序, $color-list 和 $per-list 数量相同
* @params [Array] $per-list 渐变色比例
*/
/**
* UI规范基础变量
*/
/*----------------------------------------- Theme color. start ----------------------------------------*/
/* 主题颜色 */
/* 辅助色 */
/* 文字颜色(默认浅色背景下 */
/* 暗黑模式 */
/* 图形颜色 */
/*----------------------------------------- Theme color. end -------------------------------------------*/
/*-------------------------------- Theme color application size. start --------------------------------*/
/* 文字字号 */
/* 文字字重 */
/* 尺寸 */
/*-------------------------------- Theme color application size. end --------------------------------*/
/* component var */
/* action-sheet */
/* badge */
/* button */
/* cell */
/* calendar */
/* checkbox */
/* collapse */
/* divider */
/* drop-menu */
/* input-number */
/* input */
/* textarea */
/* loadmore */
/* message-box */
/* notice-bar */
/* pagination */
/* picker */
/* col-picker */
/* overlay */
/* popup */
/* progress */
/* radio */
/* search */
/* slider */
/* sort-button */
/* steps */
/* switch */
/* tabs */
/* tag */
/* toast */
/* loading */
/* tooltip */
/* popover */
/* grid-item */
/* statustip */
/* card */
/* upload */
/* curtain */
/* notify */
/* skeleton */
/* circle */
/* swiper */
/* swiper-nav */
/* segmented */
/* tabbar */
/* tabbar-item */
/* navbar */
/* navbar-capsule */
/* table */
/* sidebar */
/* sidebar-item */
/* fab */
/* count-down */
/* keyboard */
/* number-keyboard */
/* passwod-input */
/* form-item */
/* backtop */
/* index-bar */
/* text */
/* video-preview */
/* img-cropper */
/* floating-panel */
/* signature */
.wot-theme-dark .wd-picker-view__columns.data-v-c3bc94ff {
background: var(--wot-dark-background2, #1b1b1b);
}
.wot-theme-dark .wd-picker-view.data-v-c3bc94ff .wd-picker-view__roller {
background: var(--wot-dark-background4, #323233);
}
.wot-theme-dark .wd-picker-view-column.data-v-c3bc94ff {
color: var(--wot-dark-color, var(--wot-color-white, white));
}
.wot-theme-dark .wd-picker-view-column__item--disabled.data-v-c3bc94ff {
color: var(--wot-dark-color-gray, var(--wot-color-secondary, #595959));
}
.wd-picker-view.data-v-c3bc94ff {
position: relative;
padding: 10px 0;
}
.wd-picker-view__columns.data-v-c3bc94ff {
position: relative;
display: flex;
background: var(--wot-picker-bg, var(--wot-color-white, white));
overflow: hidden;
align-items: center;
}
.data-v-c3bc94ff .wd-picker-view__mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: var(--wot-picker-mask, linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.25))) linear-gradient(0deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.25));
background-position: top, bottom;
background-repeat: no-repeat;
z-index: 2;
pointer-events: none;
filter: blur(4px);
}
.wd-picker-view__loading.data-v-c3bc94ff {
position: absolute;
display: flex;
top: 0;
right: 0;
bottom: 0;
left: 0;
align-items: center;
justify-content: center;
z-index: 3;
background: var(--wot-picker-loading-bg, rgba(var(--wot-color-white, white), 0.8));
}
.data-v-c3bc94ff .wd-picker-view__roller {
background: whitesmoke;
z-index: 0;
}
.data-v-c3bc94ff .wd-picker-view__roller::before,.data-v-c3bc94ff .wd-picker-view__roller::after {
display: none;
}
.wd-picker-view-column.data-v-c3bc94ff {
flex: 1;
font-size: var(--wot-picker-column-fs, 16px);
color: var(--wot-picker-column-color, rgba(0, 0, 0, 0.85));
text-align: center;
transition-timing-function: cubic-bezier(0.28, 0.8, 0.63, 1);
}
.wd-picker-view-column__item.data-v-c3bc94ff {
padding: var(--wot-picker-column-padding, 0 var(--wot-size-side-padding-small, 6px));
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.wd-picker-view-column__item--disabled.data-v-c3bc94ff {
color: var(--wot-picker-column-disabled-color, rgba(0, 0, 0, 0.25));
}