提交
This commit is contained in:
42
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/index.axml
generated
vendored
Normal file
42
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/index.axml
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<ant-picker
|
||||
className="ant-cascader-picker {{className || ''}}"
|
||||
style="{{style}}"
|
||||
animationType="{{animationType}}"
|
||||
popClassName="ant-cascader-picker-popup {{popClassName || ''}}"
|
||||
popStyle="{{popStyle}}"
|
||||
visible="{{visible}}"
|
||||
options="{{columns}}"
|
||||
value="{{currentValue}}"
|
||||
disabled="{{disabled}}"
|
||||
title="{{title}}"
|
||||
placeholder="{{placeholder}}"
|
||||
okText="{{okText}}"
|
||||
cancelText="{{cancelText}}"
|
||||
maskStyle="{{maskStyle}}"
|
||||
maskClassName="{{maskClassName}}"
|
||||
indicatorStyle="{{indicatorStyle}}"
|
||||
indicatorClassName="{{indicatorClassName}}"
|
||||
onChange="onChange"
|
||||
onCancel="onCancel"
|
||||
onOk="onOk"
|
||||
formattedValueText="{{formattedValueText}}"
|
||||
onVisibleChange="onVisibleChange"
|
||||
maskClosable="{{maskClosable}}"
|
||||
>
|
||||
<slot
|
||||
name="content"
|
||||
slot="content"
|
||||
></slot>
|
||||
<slot
|
||||
name="title"
|
||||
slot="title"
|
||||
></slot>
|
||||
<slot
|
||||
name="prefix"
|
||||
slot="prefix"
|
||||
></slot>
|
||||
<slot
|
||||
name="suffix"
|
||||
slot="suffix"
|
||||
></slot>
|
||||
</ant-picker>
|
1
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/index.d.ts
generated
vendored
Normal file
1
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/index.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
189
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/index.js
generated
vendored
Normal file
189
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/index.js
generated
vendored
Normal file
@ -0,0 +1,189 @@
|
||||
import { __awaiter, __generator } from "tslib";
|
||||
import { Component, getValueFromProps, triggerEvent, triggerEventOnly, triggerEventValues, } from '../../_util/simply';
|
||||
import { resolveEventValue, resolveEventValues } from '../../_util/platform';
|
||||
import { CascaderDefaultProps } from './props';
|
||||
import equal from 'fast-deep-equal';
|
||||
import mixinValue from '../../mixins/value';
|
||||
Component(CascaderDefaultProps, {
|
||||
// visible受控判断
|
||||
isVisibleControlled: function () {
|
||||
return 'visible' in getValueFromProps(this);
|
||||
},
|
||||
initColumns: function () {
|
||||
var _a = getValueFromProps(this, [
|
||||
'options',
|
||||
'visible',
|
||||
'defaultVisible',
|
||||
'value',
|
||||
'defaultValue',
|
||||
]), options = _a[0], visible = _a[1], defaultVisible = _a[2], value = _a[3], defaultValue = _a[4];
|
||||
var realValue = value || defaultValue || [];
|
||||
var columns = this.getterColumns(realValue, options);
|
||||
// 首次无需校验value有效性,onOk时会校验
|
||||
this.setData({
|
||||
columns: columns,
|
||||
visible: this.isVisibleControlled() ? visible : defaultVisible,
|
||||
currentValue: realValue,
|
||||
formattedValueText: this.onFormat(),
|
||||
});
|
||||
},
|
||||
getterColumns: function (value, options) {
|
||||
var getColumns = function (options, value, columns) {
|
||||
var _a;
|
||||
if (columns === void 0) { columns = []; }
|
||||
columns.push(options.map(function (v) { return ({ value: v.value, label: v.label }); }));
|
||||
var currentOption = options.find(function (v) { return v.value === (value === null || value === void 0 ? void 0 : value[columns.length - 1]); }) ||
|
||||
options[0];
|
||||
if (((_a = currentOption === null || currentOption === void 0 ? void 0 : currentOption.children) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
||||
return getColumns(currentOption.children, value, columns);
|
||||
}
|
||||
return columns;
|
||||
};
|
||||
return getColumns(options, value);
|
||||
},
|
||||
// 获取有效value,若从x项开始在columns里找不到,则从此项开始都选第一条
|
||||
getValidValue: function (value, columns) {
|
||||
var result = [];
|
||||
var _loop_1 = function (i) {
|
||||
if (!columns[i].some(function (v) { return (v === null || v === void 0 ? void 0 : v.value) === (value === null || value === void 0 ? void 0 : value[i]); })) {
|
||||
result.push.apply(result, columns.slice(i).map(function (v) { var _a; return (_a = v === null || v === void 0 ? void 0 : v[0]) === null || _a === void 0 ? void 0 : _a.value; }));
|
||||
return "break";
|
||||
}
|
||||
else {
|
||||
result[i] = value[i];
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < columns.length; i++) {
|
||||
var state_1 = _loop_1(i);
|
||||
if (state_1 === "break")
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
getOptionByValue: function (value) {
|
||||
var _a;
|
||||
var options = getValueFromProps(this, 'options');
|
||||
if (!((value === null || value === void 0 ? void 0 : value.length) > 0))
|
||||
return null;
|
||||
var result = [];
|
||||
var item = options.find(function (v) { return v.value === value[0]; });
|
||||
var _loop_2 = function (i) {
|
||||
if (!item) {
|
||||
return { value: null };
|
||||
}
|
||||
result.push({
|
||||
value: item.value,
|
||||
label: item.label,
|
||||
});
|
||||
item = (_a = item.children) === null || _a === void 0 ? void 0 : _a.find(function (v) { return v.value === value[i + 1]; });
|
||||
};
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
var state_2 = _loop_2(i);
|
||||
if (typeof state_2 === "object")
|
||||
return state_2.value;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
onChange: function (selectedVal) {
|
||||
var selectedValue = resolveEventValues(selectedVal)[0];
|
||||
var options = getValueFromProps(this, 'options');
|
||||
var columns = this.data.columns;
|
||||
var newColumns = this.getterColumns(selectedValue, options);
|
||||
// columns没变化说明selectedValue在范围内,无需重置
|
||||
var newData = {};
|
||||
if (!equal(columns, newColumns)) {
|
||||
selectedValue = this.getValidValue(selectedValue, newColumns);
|
||||
newData.columns = newColumns;
|
||||
}
|
||||
newData.currentValue = selectedValue;
|
||||
this.setData(newData);
|
||||
triggerEventValues(this, 'change', [
|
||||
selectedValue,
|
||||
this.getOptionByValue(selectedValue),
|
||||
]);
|
||||
},
|
||||
onOk: function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var currentValue, options, newColumns, validValue;
|
||||
return __generator(this, function (_a) {
|
||||
currentValue = this.data.currentValue;
|
||||
options = getValueFromProps(this, 'options');
|
||||
newColumns = this.getterColumns(currentValue, options);
|
||||
validValue = this.getValidValue(currentValue, newColumns);
|
||||
if (!this.isControlled()) {
|
||||
this.update(validValue);
|
||||
}
|
||||
triggerEventValues(this, 'ok', [
|
||||
validValue,
|
||||
this.getOptionByValue(validValue),
|
||||
]);
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
},
|
||||
onVisibleChange: function (visible) {
|
||||
var _this = this;
|
||||
var options = getValueFromProps(this, 'options');
|
||||
var columns = this.data.columns;
|
||||
var realValue = this.getValue();
|
||||
if (!this.isVisibleControlled() && visible) {
|
||||
var newColumns_1 = this.getterColumns(realValue, options);
|
||||
if (!equal(columns, newColumns_1)) {
|
||||
this.setData({ columns: newColumns_1 }, function () {
|
||||
_this.setData({
|
||||
currentValue: _this.getValidValue(realValue, newColumns_1),
|
||||
formattedValueText: _this.onFormat(),
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
triggerEvent(this, 'visibleChange', resolveEventValue(visible));
|
||||
},
|
||||
defaultFormat: function (value, options) {
|
||||
if (options) {
|
||||
return options.map(function (v) { return v.label; }).join('');
|
||||
}
|
||||
return '';
|
||||
},
|
||||
onFormat: function () {
|
||||
var realValue = this.getValue();
|
||||
var onFormat = getValueFromProps(this, 'onFormat');
|
||||
var formatValueByProps = onFormat && onFormat(realValue, this.getOptionByValue(realValue));
|
||||
if (formatValueByProps !== undefined && formatValueByProps !== null) {
|
||||
return formatValueByProps;
|
||||
}
|
||||
return this.defaultFormat(realValue, this.getOptionByValue(realValue));
|
||||
},
|
||||
onCancel: function (e) {
|
||||
triggerEventOnly(this, 'cancel', e);
|
||||
},
|
||||
}, {
|
||||
currentValue: [],
|
||||
columns: [],
|
||||
formattedValueText: '',
|
||||
visible: false,
|
||||
}, [mixinValue()], {
|
||||
onInit: function () {
|
||||
this.initColumns();
|
||||
},
|
||||
didUpdate: function (prevProps, prevData) {
|
||||
var options = getValueFromProps(this, 'options');
|
||||
if (!equal(options, prevProps.options)) {
|
||||
var currentValue = this.data.currentValue;
|
||||
var newColumns = this.getterColumns(currentValue, options);
|
||||
this.setData({
|
||||
columns: newColumns,
|
||||
});
|
||||
}
|
||||
if (!this.isEqualValue(prevData)) {
|
||||
var realValue = this.getValue();
|
||||
var newColumns = this.getterColumns(realValue, options);
|
||||
var currentValue = this.getValidValue(realValue, newColumns);
|
||||
this.setData({ currentValue: currentValue, formattedValueText: this.onFormat() });
|
||||
}
|
||||
var visible = getValueFromProps(this, 'visible');
|
||||
if (this.isVisibleControlled() && !equal(prevProps.visible, visible)) {
|
||||
this.setData({ visible: visible });
|
||||
}
|
||||
},
|
||||
});
|
6
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/index.json
generated
vendored
Normal file
6
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/index.json
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"ant-picker": "../index"
|
||||
}
|
||||
}
|
0
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/index.less
generated
vendored
Normal file
0
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/index.less
generated
vendored
Normal file
107
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/props.d.ts
generated
vendored
Normal file
107
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/props.d.ts
generated
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
import { IBaseProps } from '../../_util/base';
|
||||
export interface ICascaderOption {
|
||||
label: string;
|
||||
value: any;
|
||||
children?: ICascaderOption[];
|
||||
}
|
||||
/**
|
||||
* @description 级联组件,基于Picker封装
|
||||
*/
|
||||
export interface ICascaderProps extends IBaseProps {
|
||||
visible?: boolean;
|
||||
defaultVisible?: boolean;
|
||||
/**
|
||||
* @desciption 动画类型
|
||||
* @default "transform"
|
||||
*/
|
||||
animationType: 'transform' | 'position';
|
||||
/**
|
||||
* @description 当前数据
|
||||
*/
|
||||
value: any[];
|
||||
/**
|
||||
* @description 默认值
|
||||
*/
|
||||
defaultValue: any[];
|
||||
/**
|
||||
* @description 可选项数据
|
||||
*/
|
||||
options: ICascaderOption[];
|
||||
/**
|
||||
* @description 提示文案
|
||||
* @default '请选择'
|
||||
*/
|
||||
placeholder: string;
|
||||
/**
|
||||
* @description 取消文案
|
||||
* @default "取消"
|
||||
*/
|
||||
cancelText: string;
|
||||
/**
|
||||
* @description 是否禁用
|
||||
*/
|
||||
disabled?: boolean;
|
||||
/**
|
||||
* @description 标题
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* @description 确定按钮文案
|
||||
* @default "确定"
|
||||
*/
|
||||
okText: string;
|
||||
/**
|
||||
*@description 选中框样式
|
||||
* 版本要求: 支付宝小程序基础库 1.10.0 及以上
|
||||
*/
|
||||
indicatorStyle?: string;
|
||||
/**
|
||||
*@description 选中框类名
|
||||
* 版本要求: 支付宝小程序基础库 1.10.0 及以上
|
||||
*/
|
||||
indicatorClassName?: string;
|
||||
/**
|
||||
* @description 蒙层的样式。
|
||||
* 版本要求: 支付宝小程序基础库 1.10.0 及以上
|
||||
*/
|
||||
maskStyle?: string;
|
||||
/**
|
||||
* @description 蒙层的类名。
|
||||
* 版本要求: 支付宝小程序基础库 1.10.0 及以上
|
||||
*/
|
||||
maskClassName?: string;
|
||||
/**
|
||||
* @description 点击确认回调
|
||||
*/
|
||||
onOk?: (value: any[], selectedOptions: ICascaderOption[], e: Record<string, any>) => void;
|
||||
/**
|
||||
* @description 点击取消回调
|
||||
*/
|
||||
onCancel?: (e: Record<string, any>) => void;
|
||||
/**
|
||||
* @description 选中值的文本显示格式
|
||||
*/
|
||||
onFormat?: (value: any[], selectedOptions: ICascaderOption[]) => string;
|
||||
/**
|
||||
* @description 切换显示隐藏
|
||||
*/
|
||||
onVisibleChange?: (visible: boolean, e: Record<string, any>) => void;
|
||||
/**
|
||||
* @description 发生滚动即触发, 与 onChange 点击 ok 后触发不同
|
||||
*/
|
||||
onChange?: (value: any[], selectedOptions: ICascaderOption[], e: Record<string, any>) => void;
|
||||
/**
|
||||
* @description 点击蒙层是否可以关闭
|
||||
* @default false
|
||||
*/
|
||||
maskClosable: boolean;
|
||||
/**
|
||||
* @description 弹出框类名
|
||||
*/
|
||||
popClassName: string;
|
||||
/**
|
||||
* @description 弹出框样式
|
||||
*/
|
||||
popStyle: string;
|
||||
}
|
||||
export declare const CascaderDefaultProps: Partial<ICascaderProps>;
|
17
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/props.js
generated
vendored
Normal file
17
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/props.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
export var CascaderDefaultProps = {
|
||||
visible: null,
|
||||
defaultVisible: null,
|
||||
animationType: 'transform',
|
||||
value: null,
|
||||
defaultValue: null,
|
||||
options: [],
|
||||
placeholder: '请选择',
|
||||
cancelText: '取消',
|
||||
disabled: false,
|
||||
title: '',
|
||||
okText: '确定',
|
||||
maskClosable: true,
|
||||
popClassName: '',
|
||||
popStyle: '',
|
||||
onFormat: null,
|
||||
};
|
3
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/utils.d.ts
generated
vendored
Normal file
3
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/utils.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export declare function defaultFormat(value: any, options: any): any;
|
||||
export declare function getterColumns(value: any, options?: any[]): any;
|
||||
export declare function getValidValue(value: any, columns: any): any[];
|
39
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/utils.js
generated
vendored
Normal file
39
甲情_甲意/miniprogram/node_modules/antd-mini/less/Picker/CascaderPicker/utils.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
export function defaultFormat(value, options) {
|
||||
if (options) {
|
||||
return options.map(function (v) { return v.label; }).join('');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
export function getterColumns(value, options) {
|
||||
if (options === void 0) { options = []; }
|
||||
var getColumns = function (options, value, columns) {
|
||||
var _a;
|
||||
if (columns === void 0) { columns = []; }
|
||||
columns.push(options.map(function (v) { return ({ value: v.value, label: v.label }); }));
|
||||
var currentOption = options.find(function (v) { return v.value === (value === null || value === void 0 ? void 0 : value[columns.length - 1]); }) ||
|
||||
options[0];
|
||||
if (((_a = currentOption === null || currentOption === void 0 ? void 0 : currentOption.children) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
||||
return getColumns(currentOption.children, value, columns);
|
||||
}
|
||||
return columns;
|
||||
};
|
||||
return getColumns(options, value);
|
||||
}
|
||||
export function getValidValue(value, columns) {
|
||||
var result = [];
|
||||
var _loop_1 = function (i) {
|
||||
if (!columns[i].some(function (v) { return v.value === (value === null || value === void 0 ? void 0 : value[i]); })) {
|
||||
result.push.apply(result, columns.slice(i).map(function (v) { var _a; return (_a = v[0]) === null || _a === void 0 ? void 0 : _a.value; }));
|
||||
return "break";
|
||||
}
|
||||
else {
|
||||
result[i] = value[i];
|
||||
}
|
||||
};
|
||||
for (var i = 0; i < columns.length; i++) {
|
||||
var state_1 = _loop_1(i);
|
||||
if (state_1 === "break")
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
Reference in New Issue
Block a user