antd-mini-rpx
Advanced tools
Comparing version 0.0.19 to 0.0.20-alpha.0
@@ -25,3 +25,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
*/ | ||
onChange?: (v: V) => void; | ||
onChange?: (v: V, e: Record<string,any>) => void; | ||
} | ||
@@ -37,7 +37,7 @@ export interface IBaseFormItemProps<V = any> extends IBaseFormItemPropsWithOutFocus<V> { | ||
*/ | ||
onFocus?: (v: V) => void; | ||
onFocus?: (v: V, e: Record<string,any>) => void; | ||
/** | ||
* @description 失去焦点时触发回调 | ||
*/ | ||
onBlur?: (v: V) => void; | ||
onBlur?: (v: V, e: Record<string,any>) => void; | ||
} | ||
@@ -44,0 +44,0 @@ export declare type IconType = string; |
@@ -5,5 +5,6 @@ "use strict"; | ||
function fmtEvent(props, e) { | ||
if (e === void 0) { e = {}; } | ||
var dataset = {}; | ||
for (var key in props) { | ||
if ((/data-/gi).test(key)) { | ||
if (/data-/gi.test(key)) { | ||
dataset[key.replace(/data-/gi, '')] = props[key]; | ||
@@ -10,0 +11,0 @@ } |
@@ -11,4 +11,4 @@ import { IBaseProps } from '../_base'; | ||
*/ | ||
type?: 'dot' | 'number' | 'text' | 'bubble'; | ||
/** | ||
type?: 'dot' | 'number' | 'text' | 'bubble'; | ||
/** | ||
* @description 数字内容,超过 99 会自动变成 99+ | ||
@@ -25,4 +25,22 @@ */ | ||
*/ | ||
placement?: 'top-left' | 'top-center' | 'top-right' | 'left' | 'right' | 'bottom-left' | 'bottom-center' | 'bottom-right' ; | ||
position?: | ||
| 'top-left' | ||
| 'top-center' | ||
| 'top-right' | ||
| 'left' | ||
| 'right' | ||
| 'bottom-left' | ||
| 'bottom-center' | ||
| 'bottom-right'; | ||
/** | ||
* @description 水平方向偏移量(字符串类型,需要带上像素单位) | ||
* @default "-50%" | ||
*/ | ||
offsetX?: string; | ||
/** | ||
* @description 垂直方向偏移量(字符串类型,需要带上像素单位) | ||
* @default "-50%" | ||
*/ | ||
offsetY?: number; | ||
/** | ||
* @description 是否有描边 | ||
@@ -29,0 +47,0 @@ * @default false |
@@ -8,2 +8,3 @@ "use strict"; | ||
var form_1 = tslib_1.__importDefault(require("../mixins/form")); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
Component({ | ||
@@ -59,3 +60,3 @@ props: props_1.CheckboxGroupDefaultProps, | ||
if (this.props.onChange) { | ||
this.props.onChange.call(this, val); | ||
this.props.onChange.call(this, val, (0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -62,0 +63,0 @@ }, |
@@ -6,2 +6,3 @@ "use strict"; | ||
var controlled_1 = tslib_1.__importDefault(require("../mixins/controlled")); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
Component({ | ||
@@ -32,5 +33,5 @@ props: props_1.ChecklistDefaultProps, | ||
} | ||
this.cOnChange(value, items); | ||
this.cOnChange(value, items, (0, fmtEvent_1.default)(this.props)); | ||
} | ||
}, | ||
}); |
{ | ||
"component": true, | ||
"usingComponents": { | ||
"header": "./ContainerHeader" | ||
"header": "./ContainerHeader/index" | ||
} | ||
} |
@@ -9,2 +9,3 @@ "use strict"; | ||
var util_1 = require("./util"); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
Component({ | ||
@@ -85,16 +86,27 @@ mixins: [(0, form_1.default)({ trigger: 'onOk' })], | ||
setCurrentValue: function () { | ||
this.setData({ | ||
currentValue: this.getCurrentValueWithCValue(), | ||
}); | ||
this.generateData(); | ||
var _this = this; | ||
var currentValue = this.getCurrentValueWithCValue(); | ||
var newColumns = this.generateData(currentValue); | ||
if (!(0, fast_deep_equal_1.default)(newColumns, this.data.columns)) { | ||
this.setData({ | ||
columns: newColumns | ||
}, function () { | ||
_this.setData({ | ||
currentValue: currentValue | ||
}); | ||
}); | ||
} | ||
else { | ||
this.setData({ | ||
currentValue: currentValue | ||
}); | ||
} | ||
}, | ||
// 生成选项数据,didmound、picker change、打开弹窗触发 | ||
generateData: function () { | ||
generateData: function (currentValue) { | ||
var precision = this.props.precision; | ||
var _a = this.data, columns = _a.columns, currentValue = _a.currentValue; | ||
var min = this.getMin(); | ||
var max = this.getMax(); | ||
if (max < min) { | ||
this.setData({ columns: [] }); | ||
return; | ||
return []; | ||
} | ||
@@ -109,7 +121,6 @@ var currentPickerDay = (0, dayjs_1.default)(); | ||
var newColumns = (0, util_1.getRangeData)(precision, min, max, currentPickerDay); | ||
if (!(0, fast_deep_equal_1.default)(columns, newColumns)) { | ||
this.setData({ columns: newColumns }); | ||
} | ||
return newColumns; | ||
}, | ||
onChange: function (selectedIndex) { | ||
var _this = this; | ||
selectedIndex = (0, util_1.getValidValue)(selectedIndex); | ||
@@ -128,8 +139,21 @@ var _a = this.props, onPickerChange = _a.onPickerChange, format = _a.format, precision = _a.precision; | ||
} | ||
this.setData({ currentValue: selectedIndex }); | ||
this.generateData(); | ||
if (onPickerChange) { | ||
var date_1 = (0, util_1.getDateByValue)(selectedIndex); | ||
onPickerChange(date_1, (0, dayjs_1.default)(date_1).format(format), selectedIndex); | ||
var newColumns = this.generateData(selectedIndex); | ||
if (!(0, fast_deep_equal_1.default)(newColumns, this.data.columns)) { | ||
this.setData({ | ||
columns: newColumns | ||
}, function () { | ||
_this.setData({ currentValue: selectedIndex }); | ||
if (onPickerChange) { | ||
var date_1 = (0, util_1.getDateByValue)(selectedIndex); | ||
onPickerChange(date_1, (0, dayjs_1.default)(date_1).format(format), selectedIndex, (0, fmtEvent_1.default)(_this.props)); | ||
} | ||
}); | ||
} | ||
else { | ||
this.setData({ currentValue: selectedIndex }); | ||
if (onPickerChange) { | ||
var date_2 = (0, util_1.getDateByValue)(selectedIndex); | ||
onPickerChange(date_2, (0, dayjs_1.default)(date_2).format(format), selectedIndex, (0, fmtEvent_1.default)(this.props)); | ||
} | ||
} | ||
}, | ||
@@ -139,3 +163,3 @@ onDismiss: function () { | ||
if (onDismiss) { | ||
onDismiss(); | ||
onDismiss((0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -149,3 +173,3 @@ }, | ||
if (this.props.onOk) { | ||
this.props.onOk(date, (0, dayjs_1.default)(date).format(format), currentValue); | ||
this.props.onOk(date, (0, dayjs_1.default)(date).format(format), currentValue, (0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -166,3 +190,3 @@ }, | ||
if (onTriggerPicker) { | ||
onTriggerPicker(visible); | ||
onTriggerPicker(visible, (0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -169,0 +193,0 @@ }, |
@@ -44,3 +44,3 @@ import { IBaseFormItemPropsWithOutFocus } from '../_base'; | ||
*/ | ||
placeholder?: string; | ||
placeholder?: string; | ||
/** | ||
@@ -54,7 +54,12 @@ * @description 是否受控 | ||
*/ | ||
onOk?: (date: PickerValue, dateStr: string, dateArr: number[]) => void; | ||
onOk?: ( | ||
date: PickerValue, | ||
dateStr: string, | ||
dateArr: number[], | ||
e: Record<string, any> | ||
) => void; | ||
/** | ||
* @description 点击取消回调 | ||
*/ | ||
onDismiss?: () => void; | ||
onDismiss?: (e: Record<string, any>) => void; | ||
/** | ||
@@ -66,3 +71,4 @@ * @description 发生滚动即触发, 与 onChange 点击 ok 后触发不同 | ||
dateStr: string, | ||
dateArr: number[] | ||
dateArr: number[], | ||
e: Record<string, any> | ||
) => void; | ||
@@ -83,4 +89,4 @@ /** | ||
*/ | ||
onTriggerPicker?: (visible) => void; | ||
onTriggerPicker?: (visible, e: Record<string, any>) => void; | ||
} | ||
export declare const DatePickerDefaultProps: Partial<IDatePickerProps>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ var props_1 = require("./props"); | ||
var context_1 = require("../context"); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../../_util/fmtEvent")); | ||
Component({ | ||
@@ -27,3 +29,3 @@ props: props_1.FilterItemDefaultProps, | ||
if (show && onOpen) { | ||
onOpen(); | ||
onOpen((0, fmtEvent_1.default)(_this.props)); | ||
} | ||
@@ -60,2 +62,3 @@ }; | ||
return; | ||
var event = (0, fmtEvent_1.default)(this.props); | ||
if (this.props.type === 'multiple') { | ||
@@ -66,3 +69,3 @@ this.setData({ | ||
}); | ||
this.props.onChange(v); | ||
this.props.onChange(v, event); | ||
return; | ||
@@ -75,3 +78,3 @@ } | ||
// 单选 | ||
this.props.onChange(v); | ||
this.props.onChange(v, event); | ||
this.setActive(v.length > 0); | ||
@@ -89,2 +92,3 @@ // 箭头动画 | ||
confirmSelector: function () { | ||
var event = (0, fmtEvent_1.default)(this.props); | ||
// 多选 | ||
@@ -97,3 +101,3 @@ if (typeof this.props.onChange !== 'function') | ||
}); | ||
this.props.onChange(this.data.curValue); | ||
this.props.onChange(this.data.curValue, event); | ||
this.setActive(this.data.curValue.length > 0); | ||
@@ -100,0 +104,0 @@ // 箭头动画 |
@@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
*/ | ||
onChange?: (v: any) => void; | ||
onChange?: (v: any, e: Record<string,any>) => void; | ||
/** | ||
* @description 面板展开是触发,以便用户可以滚动定位 | ||
*/ | ||
onOpen?: () => void; | ||
onOpen?: (e: Record<string,any>) => void; | ||
/** | ||
@@ -27,0 +27,0 @@ * @description type=default type=multiple 有效,为 selector 所需数据 |
@@ -7,2 +7,3 @@ "use strict"; | ||
var form_1 = tslib_1.__importDefault(require("../mixins/form")); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
var store_1 = require("../Form/store"); | ||
@@ -32,3 +33,3 @@ Component({ | ||
var value = e.detail.value; | ||
onBlur(value); | ||
onBlur(value, (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -42,3 +43,3 @@ }, | ||
var value = e.detail.value; | ||
onConfirm(value); | ||
onConfirm(value, (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -52,3 +53,3 @@ }, | ||
var value = e.detail.value; | ||
onFocus(value); | ||
onFocus(value, (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -60,3 +61,3 @@ }, | ||
var value = e.detail.value; | ||
this.cOnChange(value); | ||
this.cOnChange(value, (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -73,7 +74,7 @@ }, | ||
}, | ||
onClear: function () { | ||
onClear: function (e) { | ||
this.hideClear(); | ||
var _a = this.props, onClear = _a.onClear, controlled = _a.controlled; | ||
if (onClear) { | ||
onClear(''); | ||
onClear('', (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -80,0 +81,0 @@ if (!controlled) { |
@@ -34,3 +34,3 @@ "use strict"; | ||
exports.default = (function (propsValue) { | ||
if (propsValue === void 0) { propsValue = "value"; } | ||
if (propsValue === void 0) { propsValue = 'value'; } | ||
return ({ | ||
@@ -56,15 +56,23 @@ data: { | ||
methods: { | ||
cOnChange: function (v, v1) { | ||
cOnChange: function (v) { | ||
var _a, _b; | ||
var args = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
args[_i - 1] = arguments[_i]; | ||
} | ||
if (!this.props.controlled) { | ||
this.cTrigger(v); | ||
} | ||
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, v, v1); | ||
(_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call.apply(_b, tslib_1.__spreadArray([_a, v], args, false)); | ||
}, | ||
cOnInput: function (v, v1) { | ||
cOnInput: function (v) { | ||
var _a, _b; | ||
var args = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
args[_i - 1] = arguments[_i]; | ||
} | ||
if (!this.props.controlled) { | ||
this.cTrigger(v); | ||
} | ||
(_b = (_a = this.props).onInput) === null || _b === void 0 ? void 0 : _b.call(_a, v, v1); | ||
(_b = (_a = this.props).onInput) === null || _b === void 0 ? void 0 : _b.call.apply(_b, tslib_1.__spreadArray([_a, v], args, false)); | ||
}, | ||
@@ -71,0 +79,0 @@ }, |
@@ -6,8 +6,8 @@ "use strict"; | ||
var props_1 = require("./props"); | ||
var computed_1 = tslib_1.__importDefault(require("../mixins/computed")); | ||
var controlled_1 = tslib_1.__importDefault(require("../mixins/controlled")); | ||
var form_1 = tslib_1.__importDefault(require("../mixins/form")); | ||
var utils_1 = require("./utils"); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
Component({ | ||
mixins: [computed_1.default, (0, controlled_1.default)(), (0, form_1.default)({ trigger: 'onOk' })], | ||
mixins: [(0, controlled_1.default)(), (0, form_1.default)({ trigger: 'onOk' })], | ||
props: props_1.PickerDefaultProps, | ||
@@ -21,22 +21,52 @@ data: { | ||
single: false, | ||
isChangingPickerView: false, | ||
didMount: function () { | ||
var _this = this; | ||
var columns = this.getterColumns(); | ||
this.setData({ | ||
columns: columns | ||
}, function () { | ||
var formatValue = _this.getterFormatText(); | ||
var selectedIndex = _this.getterSelectedIndex(); | ||
_this.setData({ | ||
formatValue: formatValue, | ||
selectedIndex: selectedIndex | ||
}); | ||
}); | ||
}, | ||
didUpdate: function (prevProps, prevData) { | ||
var _a = this.data, visible = _a.visible, columns = _a.columns, cValue = _a.cValue; | ||
var prevColumns = prevData.columns, prevCValue = prevData.cValue; | ||
if (visible) { | ||
if (!(0, fast_deep_equal_1.default)(prevColumns, columns) || !(0, fast_deep_equal_1.default)(prevCValue, cValue)) { | ||
this.tempSelectedIndex = this.getterSelectedIndex(); | ||
} | ||
var _this = this; | ||
var cValue = this.data.cValue; | ||
var prevCValue = prevData.cValue; | ||
if (!(0, fast_deep_equal_1.default)(prevProps.data, this.props.data)) { | ||
var newColums = this.getterColumns(); | ||
this.setData({ | ||
columns: newColums | ||
}, function () { | ||
// 如果是在滚动过程中columns发生变化,以onChange里抛出的selectedIndex为准 | ||
if (!_this.isChangingPickerView) { | ||
_this.tempSelectedIndex = null; | ||
var selectedIndex = _this.getterSelectedIndex(); | ||
_this.setData({ | ||
selectedIndex: selectedIndex | ||
}); | ||
} | ||
_this.isChangingPickerView = false; | ||
}); | ||
} | ||
if (!(0, fast_deep_equal_1.default)(cValue, prevCValue)) { | ||
var selectedIndex = this.getterSelectedIndex(); | ||
this.tempSelectedIndex = null; | ||
this.setData({ | ||
selectedIndex: selectedIndex, | ||
}); | ||
} | ||
var formatValue = this.getterFormatText(); | ||
if (formatValue !== this.data.formatValue) { | ||
this.setData({ | ||
formatValue: formatValue | ||
}); | ||
} | ||
}, | ||
methods: { | ||
computed: function () { | ||
var columns = this.getterColumns(); | ||
var formatValue = this.getterFormatText(); | ||
var selectedIndex = this.getterSelectedIndex(); | ||
return { | ||
formatValue: formatValue, | ||
selectedIndex: selectedIndex, | ||
columns: columns, | ||
}; | ||
}, | ||
getterColumns: function () { | ||
@@ -104,3 +134,3 @@ var columns = []; | ||
if (onTriggerPicker) { | ||
onTriggerPicker(visible); | ||
onTriggerPicker(visible, (0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -115,3 +145,3 @@ }, | ||
if (onDismiss) { | ||
return onDismiss(); | ||
return onDismiss((0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -123,28 +153,46 @@ }, | ||
this.tempSelectedIndex = selectedIndex; | ||
this.isChangingPickerView = true; | ||
var _a = (0, utils_1.getMatchedItemByIndex)(this.data.columns, this.tempSelectedIndex, this.single), matchedColumn = _a.matchedColumn, matchedValues = _a.matchedValues; | ||
if (onChange) { | ||
onChange.call(this, matchedValues, matchedColumn); | ||
onChange.call(this, matchedValues, matchedColumn, (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
}, | ||
onOk: function () { | ||
var result; | ||
if (this.tempSelectedIndex) { | ||
result = (0, utils_1.getMatchedItemByIndex)(this.data.columns, this.tempSelectedIndex, this.single); | ||
} | ||
else { | ||
result = (0, utils_1.getMatchedItemByValue)(this.data.columns, this.data.cValue, this.single); | ||
} | ||
var matchedColumn = result.matchedColumn, matchedValues = result.matchedValues; | ||
this.setData({ | ||
cValue: matchedValues, | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var result, matchedColumn, matchedValues, isContinue; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (this.tempSelectedIndex) { | ||
result = (0, utils_1.getMatchedItemByIndex)(this.data.columns, this.tempSelectedIndex, this.single); | ||
} | ||
else { | ||
result = (0, utils_1.getMatchedItemByValue)(this.data.columns, this.data.cValue, this.single); | ||
} | ||
matchedColumn = result.matchedColumn, matchedValues = result.matchedValues; | ||
this.setData({ | ||
visible: false, | ||
}); | ||
this.triggerPicker(false); | ||
if (!this.props.onBeforeOk) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.props.onBeforeOk(matchedValues, matchedColumn, (0, fmtEvent_1.default)(this.props))]; | ||
case 1: | ||
isContinue = _a.sent(); | ||
if (!isContinue) { | ||
return [2 /*return*/]; | ||
} | ||
_a.label = 2; | ||
case 2: | ||
this.setData({ | ||
cValue: matchedValues, | ||
}); | ||
if (this.props.onOk) { | ||
this.props.onOk.call(this, matchedValues, matchedColumn, (0, fmtEvent_1.default)(this.props)); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
if (this.props.onOk) { | ||
this.props.onOk.call(this, matchedValues, matchedColumn); | ||
} | ||
this.triggerPicker(false); | ||
this.setData({ | ||
visible: false, | ||
}); | ||
}, | ||
}, | ||
}); |
@@ -7,3 +7,3 @@ import { IBaseFormItemPropsWithOutFocus } from '../_base'; | ||
} | ||
export declare type PickerValue = string| number| (string | number)[]; | ||
export declare type PickerValue = string | number | (string | number)[]; | ||
/** | ||
@@ -47,26 +47,38 @@ * @description 选择器,包括一个或多个不同值的可滚动列表,每个值可以在视图的中心以较暗的文本形式显示。当用户激活 **Picker** 后,将会从底部弹出。 | ||
/** | ||
* @description 点击确认前回调 | ||
*/ | ||
onBeforeOk?: ( | ||
value: PickerValue, | ||
column: PickerData, | ||
e: Record<string, any> | ||
) => boolean; | ||
/** | ||
* @description 点击确认回调 | ||
*/ | ||
onOk?: (value: PickerValue, column: PickerData) => void; | ||
onOk?: ( | ||
value: PickerValue, | ||
column: PickerData, | ||
e: Record<string, any> | ||
) => void; | ||
/** | ||
* @description 点击取消回调 | ||
*/ | ||
onDismiss?: () => void; | ||
onDismiss?: (e: Record<string, any>) => void; | ||
/** | ||
* @description 发生滚动即触发, 与 onChange 点击 ok 后触发不同 | ||
*/ | ||
onChange?: (value: PickerValue, column:PickerData) => void; | ||
onChange?: ( | ||
value: PickerValue, | ||
column: PickerData, | ||
e: Record<string, any> | ||
) => void; | ||
/** | ||
* @description 选中值的文本显示格式 | ||
*/ | ||
onFormat?: ( | ||
value: PickerValue, | ||
column: PickerValue, | ||
data | ||
) => string; | ||
onFormat?: (value: PickerValue, column: PickerValue, data) => string; | ||
/** | ||
* @description 切换显示隐藏 | ||
*/ | ||
onTriggerPicker?: (visible) => void; | ||
onTriggerPicker?: (visible: boolean, e: Record<string,any>) => void; | ||
} | ||
export declare const PickerDefaultProps: Partial<IPickerProps>; |
@@ -71,2 +71,3 @@ "use strict"; | ||
function getMatchedItemByIndex(columns, selectedIndex, single) { | ||
var _a; | ||
var matchedValues = []; | ||
@@ -84,2 +85,6 @@ var matchedColumn = []; | ||
index = compareValue; | ||
// 当column变化时, picker-view onChange 里抛出来的selectedIndex有可能不正确 | ||
if (((_a = columns === null || columns === void 0 ? void 0 : columns[i]) === null || _a === void 0 ? void 0 : _a[compareValue]) === undefined) { | ||
index = 0; | ||
} | ||
if (index === -1) { | ||
@@ -86,0 +91,0 @@ index = 0; |
@@ -8,2 +8,3 @@ "use strict"; | ||
var form_1 = tslib_1.__importDefault(require("../mixins/form")); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
Component({ | ||
@@ -21,3 +22,3 @@ props: props_1.RadioGroupDefaultProps, | ||
context_1.componentContext.onUpdate(key, function (v) { | ||
_this.cOnChange(v); | ||
_this.cOnChange(v, (0, fmtEvent_1.default)(_this.props)); | ||
}); | ||
@@ -24,0 +25,0 @@ }, |
@@ -10,2 +10,3 @@ "use strict"; | ||
var util_1 = require("../DatePicker/util"); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
Component({ | ||
@@ -123,5 +124,6 @@ mixins: [computed_1.default, (0, form_1.default)({ trigger: 'onOk' })], | ||
setCurrentValue: function () { | ||
var _this = this; | ||
var _visible = this._visible; // 隐藏状态下从CValue触发,展开状态使用当前数据 | ||
var precision = this.props.precision; | ||
var _a = this.data, cValue = _a.cValue, pickerType = _a.pickerType; | ||
var _a = this.data, cValue = _a.cValue, pickerType = _a.pickerType, columns = _a.columns; | ||
var _b = this.data, currentStartDate = _b.currentStartDate, currentEndDate = _b.currentEndDate; | ||
@@ -161,4 +163,11 @@ var currentStartDateByCValue = (cValue === null || cValue === void 0 ? void 0 : cValue[0]) || null; | ||
var currentValue = (0, util_1.getValueByDate)(pickerType === 'start' ? currentStartDate : currentEndDate, precision); | ||
this.setData({ currentStartDate: currentStartDate, currentEndDate: currentEndDate, currentValue: currentValue }); | ||
this.generateData(); | ||
var newColumns = this.generateData(currentValue); | ||
if (!(0, fast_deep_equal_1.default)(newColumns, columns)) { | ||
this.setData({ columns: newColumns }, function () { | ||
_this.setData({ currentStartDate: currentStartDate, currentEndDate: currentEndDate, currentValue: currentValue }); | ||
}); | ||
} | ||
else { | ||
this.setData({ currentStartDate: currentStartDate, currentEndDate: currentEndDate, currentValue: currentValue }); | ||
} | ||
}, | ||
@@ -168,10 +177,8 @@ /** | ||
*/ | ||
generateData: function () { | ||
generateData: function (currentValue) { | ||
var precision = this.props.precision; | ||
var _a = this.data, columns = _a.columns, currentValue = _a.currentValue; | ||
var min = this.getMin(); | ||
var max = this.getMax(); | ||
if (max < min) { | ||
this.setData({ columns: [] }); | ||
return; | ||
return []; | ||
} | ||
@@ -186,7 +193,6 @@ var currentPickerDay = (0, dayjs_1.default)(); | ||
var newColumns = (0, util_1.getRangeData)(precision, min, max, currentPickerDay); | ||
if (!(0, fast_deep_equal_1.default)(columns, newColumns)) { | ||
this.setData({ columns: newColumns }); | ||
} | ||
return newColumns; | ||
}, | ||
onChange: function (selectedIndex) { | ||
var _this = this; | ||
selectedIndex = (0, util_1.getValidValue)(selectedIndex); | ||
@@ -205,3 +211,3 @@ var _a = this.props, onPickerChange = _a.onPickerChange, format = _a.format, precision = _a.precision; | ||
} | ||
var pickerType = this.data.pickerType; | ||
var _b = this.data, pickerType = _b.pickerType, columns = _b.columns; | ||
var newData = { | ||
@@ -216,7 +222,19 @@ currentValue: selectedIndex, | ||
} | ||
this.setData(newData); | ||
this.generateData(); | ||
if (onPickerChange) { | ||
onPickerChange(pickerType, date, (0, dayjs_1.default)(date).format(format), selectedIndex); | ||
var newColumns = this.generateData(selectedIndex); | ||
if (!(0, fast_deep_equal_1.default)(newColumns, columns)) { | ||
this.setData({ | ||
columns: newColumns, | ||
}, function () { | ||
_this.setData(newData); | ||
if (onPickerChange) { | ||
onPickerChange(pickerType, date, (0, dayjs_1.default)(date).format(format), selectedIndex, (0, fmtEvent_1.default)(_this.props)); | ||
} | ||
}); | ||
} | ||
else { | ||
this.setData(newData); | ||
if (onPickerChange) { | ||
onPickerChange(pickerType, date, (0, dayjs_1.default)(date).format(format), selectedIndex, (0, fmtEvent_1.default)(this.props)); | ||
} | ||
} | ||
}, | ||
@@ -226,3 +244,3 @@ onDismiss: function () { | ||
if (onDismiss) { | ||
onDismiss(); | ||
onDismiss((0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -236,3 +254,3 @@ }, | ||
if (this.props.onOk) { | ||
this.props.onOk(cValue, cValue.map(function (v) { return (0, dayjs_1.default)(v).format(format); }), cValue.map(function (v) { return (0, util_1.getValueByDate)(v, precision); })); | ||
this.props.onOk(cValue, cValue.map(function (v) { return (0, dayjs_1.default)(v).format(format); }), cValue.map(function (v) { return (0, util_1.getValueByDate)(v, precision); }), (0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -261,3 +279,3 @@ }, | ||
if (onTriggerPicker) { | ||
onTriggerPicker(visible); | ||
onTriggerPicker(visible, (0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -264,0 +282,0 @@ this._visible = visible; |
@@ -44,3 +44,3 @@ import { IBaseFormItemPropsWithOutFocus } from '../_base'; | ||
*/ | ||
placeholder?: string; | ||
placeholder?: string; | ||
/** | ||
@@ -57,3 +57,4 @@ * @description 是否受控 | ||
dateStr: [string, string], | ||
dateArr: [number[], number[]] | ||
dateArr: [number[], number[]], | ||
e: Record<string, any> | ||
) => void; | ||
@@ -63,3 +64,3 @@ /** | ||
*/ | ||
onDismiss?: () => void; | ||
onDismiss?: (e: Record<string, any>) => void; | ||
/** | ||
@@ -72,3 +73,4 @@ * @description 发生滚动即触发, 与 onChange 点击 ok 后触发不同 | ||
dateStr: string, | ||
dateArr: number[] | ||
dateArr: number[], | ||
e: Record<string, any> | ||
) => void; | ||
@@ -93,3 +95,3 @@ /** | ||
*/ | ||
onTriggerPicker?: (visible) => void; | ||
onTriggerPicker?: (visible, e: Record<string, any>) => void; | ||
/** | ||
@@ -96,0 +98,0 @@ * @description 显示连接符 |
@@ -6,2 +6,3 @@ "use strict"; | ||
var controlled_1 = tslib_1.__importDefault(require("../mixins/controlled")); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
Component({ | ||
@@ -18,3 +19,3 @@ mixins: [(0, controlled_1.default)()], | ||
var value = e.detail.value; | ||
onSubmit(value); | ||
onSubmit(value, (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -26,3 +27,3 @@ }, | ||
var value = e.detail.value; | ||
this.cOnInput(value); | ||
this.cOnInput(value, (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -33,3 +34,3 @@ }, | ||
if (onClear) { | ||
onClear(''); | ||
onClear('', (0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -49,12 +50,12 @@ this.clearcValue(); | ||
if (onCancel) { | ||
onCancel(''); | ||
onCancel('', (0, fmtEvent_1.default)(this.props)); | ||
} | ||
this.clearcValue(); | ||
}, | ||
onBizIconTap: function () { | ||
onBizIconTap: function (e) { | ||
if (typeof this.props.onBizIconTap === 'function') { | ||
this.props.onBizIconTap(); | ||
this.props.onBizIconTap((0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
else if (typeof this.props.onVoiceTap === 'function') { | ||
this.props.onVoiceTap(); | ||
this.props.onVoiceTap((0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -69,3 +70,3 @@ }, | ||
var value = e.detail.value; | ||
onFocus(value); | ||
onFocus(value, (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -80,3 +81,3 @@ }, | ||
var value = e.detail.value; | ||
onBlur(value); | ||
onBlur(value, (0, fmtEvent_1.default)(this.props, e)); | ||
} | ||
@@ -83,0 +84,0 @@ }, |
@@ -75,3 +75,3 @@ import { IBaseFormItemProps } from '../_base'; | ||
*/ | ||
onBizIconTap?: () => void; | ||
onBizIconTap?: (e: Record<string,any>) => void; | ||
@@ -81,7 +81,7 @@ /** | ||
*/ | ||
onCancel?: (v: string) => void; | ||
onCancel?: (v: string, e: Record<string,any>) => void; | ||
/** | ||
* @description 点击删除回调 | ||
*/ | ||
onClear?: (v: string) => void; | ||
onClear?: (v: string, e: Record<string,any>) => void; | ||
@@ -91,3 +91,3 @@ /** | ||
*/ | ||
onInput?: (v: string) => void; | ||
onInput?: (v: string, e: Record<string,any>) => void; | ||
@@ -97,3 +97,3 @@ /** | ||
*/ | ||
onSubmit?: (v: string) => void; | ||
onSubmit?: (v: string, e: Record<string,any>) => void; | ||
@@ -104,5 +104,5 @@ /** | ||
*/ | ||
onVoiceTap?: () => void; | ||
onVoiceTap?: (e: Record<string,any>) => void; | ||
} | ||
export declare const SearchBarDefaultProps: Partial<ISearchBarProps>; |
@@ -7,2 +7,3 @@ "use strict"; | ||
var form_1 = tslib_1.__importDefault(require("../mixins/form")); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
var getFixedValue = function (value, multiple) { | ||
@@ -27,2 +28,3 @@ var fixedValue = []; | ||
var _a; | ||
var event = (0, fmtEvent_1.default)(this.props); | ||
var _b = e.currentTarget.dataset, disabled = _b.disabled, value = _b.value; | ||
@@ -37,3 +39,3 @@ var _c = this.props, multiple = _c.multiple, items = _c.items, maxSelectedCount = _c.maxSelectedCount, minSelectedCount = _c.minSelectedCount, onSelectMax = _c.onSelectMax, onSelectMin = _c.onSelectMin; | ||
if (onSelectMax) { | ||
onSelectMax(value, items.find(function (v) { return v.value === value; })); | ||
onSelectMax(value, items.find(function (v) { return v.value === value; }), event); | ||
} | ||
@@ -47,3 +49,3 @@ return; | ||
if (onSelectMin) { | ||
onSelectMin(value, items.find(function (v) { return v.value === value; })); | ||
onSelectMin(value, items.find(function (v) { return v.value === value; }), event); | ||
} | ||
@@ -72,3 +74,3 @@ return; | ||
var selectedItems = nextValue_1.map(function (v) { var _a; return (_a = items.filter(function (item) { return item.value === v; })) === null || _a === void 0 ? void 0 : _a[0]; }); | ||
this.cOnChange(nextValue_1, selectedItems); | ||
this.cOnChange(nextValue_1, selectedItems, event); | ||
} | ||
@@ -87,3 +89,3 @@ else { | ||
var selectedItem = ((_a = items.filter(function (item) { return item.value === nextValue_1; })) === null || _a === void 0 ? void 0 : _a[0]) || null; | ||
this.cOnChange(nextValue_1, selectedItem); | ||
this.cOnChange(nextValue_1, selectedItem, event); | ||
} | ||
@@ -90,0 +92,0 @@ } |
@@ -67,8 +67,8 @@ import { IBaseFormItemPropsWithOutFocus } from '../_base'; | ||
*/ | ||
onSelectMax(value: string, item: ISelectorItem): void; | ||
onSelectMax(value: string, item: ISelectorItem, e: Record<string, any>): void; | ||
/** | ||
* @description 触发最小限制 | ||
*/ | ||
onSelectMin(value: string, item: ISelectorItem): void; | ||
onSelectMin(value: string, item: ISelectorItem, e: Record<string, any>): void; | ||
} | ||
export declare const SelectorDefaultProps: Partial<ISelectorProps>; |
@@ -9,2 +9,3 @@ "use strict"; | ||
var form_1 = tslib_1.__importDefault(require("../mixins/form")); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
Component({ | ||
@@ -61,3 +62,3 @@ mixins: [computed_1.default, (0, controlled_1.default)(), (0, form_1.default)()], | ||
var value = e.detail.value; | ||
(_b = (_a = this.props).onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, value); | ||
(_b = (_a = this.props).onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, value, (0, fmtEvent_1.default)(this.props, e)); | ||
}, | ||
@@ -64,0 +65,0 @@ onBlur: function (e) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var props_1 = require("./props"); | ||
var fmtEvent_1 = tslib_1.__importDefault(require("../_util/fmtEvent")); | ||
Component({ | ||
@@ -24,7 +26,8 @@ props: props_1.TermsDefaultProps, | ||
if (onChange) { | ||
var event = (0, fmtEvent_1.default)(this.props); | ||
if (_getCurrentField) { | ||
return onChange.call(this.props, v); | ||
return onChange.call(this.props, v, event); | ||
} | ||
else { | ||
return onChange(v); | ||
return onChange(v, event); | ||
} | ||
@@ -35,3 +38,3 @@ } | ||
if (typeof this.props.onMainBtnTap === 'function') { | ||
this.props.onMainBtnTap(); | ||
this.props.onMainBtnTap((0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -41,3 +44,3 @@ }, | ||
if (typeof this.props.onSubBtnTap === 'function') { | ||
this.props.onSubBtnTap(); | ||
this.props.onSubBtnTap((0, fmtEvent_1.default)(this.props)); | ||
} | ||
@@ -44,0 +47,0 @@ }, |
@@ -20,3 +20,2 @@ | ||
* @description 说明文本 | ||
* @default 同意《用户授权协议》 | ||
*/ | ||
@@ -26,3 +25,3 @@ term?: string; | ||
* @description 主按钮文本 | ||
* @default 提交 | ||
* @default '提交' | ||
*/ | ||
@@ -34,3 +33,11 @@ mainButtonText?: string; | ||
addonButtonText?: string; | ||
/** | ||
* @description 点击主按钮 | ||
*/ | ||
onMainBtnTap?(e: Record<string,any>): void; | ||
/** | ||
* @description 点击辅助按钮 | ||
*/ | ||
onSubBtnTap?(e: Record<string,any>): void; | ||
} | ||
export declare const TermsDefaultProps: Partial<ITermsProps>; |
{ | ||
"name": "antd-mini-rpx", | ||
"version": "0.0.19", | ||
"version": "0.0.20-alpha.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "minidev dev --no-source-map", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
573282
508
10495