@sheinx/hooks 3.3.0-beta.1 → 3.3.0-beta.10
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +5 -2
- package/cjs/components/use-datepicker/use-date.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-date.js +1 -11
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.js +1 -0
- package/cjs/components/use-datepicker/use-datepicker-range.d.ts +2 -0
- package/cjs/components/use-datepicker/use-datepicker-range.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-range.js +12 -2
- package/cjs/components/use-datepicker/util.d.ts +1 -0
- package/cjs/components/use-datepicker/util.d.ts.map +1 -1
- package/cjs/components/use-datepicker/util.js +15 -1
- package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.d.ts +1 -0
- package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.js +2 -1
- package/cjs/components/use-form/use-form.d.ts +6 -0
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +37 -4
- package/cjs/components/use-form/use-form.type.d.ts +3 -0
- package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
- package/cjs/components/use-pagination/use-pagination.d.ts +1 -1
- package/cjs/components/use-pagination/use-pagination.d.ts.map +1 -1
- package/cjs/components/use-pagination/use-pagination.js +7 -5
- package/cjs/components/use-table/use-table.type.d.ts +2 -2
- package/cjs/utils/flat.d.ts +14 -0
- package/cjs/utils/flat.d.ts.map +1 -0
- package/cjs/utils/flat.js +94 -0
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.d.ts.map +1 -1
- package/cjs/utils/index.js +8 -1
- package/cjs/utils/render.d.ts +1 -1
- package/cjs/utils/render.d.ts.map +1 -1
- package/cjs/utils/render.js +2 -2
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +5 -2
- package/esm/components/use-datepicker/use-date.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-date.js +1 -11
- package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.js +1 -0
- package/esm/components/use-datepicker/use-datepicker-range.d.ts +2 -0
- package/esm/components/use-datepicker/use-datepicker-range.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-range.js +12 -2
- package/esm/components/use-datepicker/util.d.ts +1 -0
- package/esm/components/use-datepicker/util.d.ts.map +1 -1
- package/esm/components/use-datepicker/util.js +15 -1
- package/esm/components/use-form/use-form-fieldset/use-form-fieldset.d.ts +1 -0
- package/esm/components/use-form/use-form-fieldset/use-form-fieldset.d.ts.map +1 -1
- package/esm/components/use-form/use-form-fieldset/use-form-fieldset.js +2 -1
- package/esm/components/use-form/use-form.d.ts +6 -0
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +37 -4
- package/esm/components/use-form/use-form.type.d.ts +3 -0
- package/esm/components/use-form/use-form.type.d.ts.map +1 -1
- package/esm/components/use-pagination/use-pagination.d.ts +1 -1
- package/esm/components/use-pagination/use-pagination.d.ts.map +1 -1
- package/esm/components/use-pagination/use-pagination.js +7 -5
- package/esm/components/use-table/use-table.type.d.ts +2 -2
- package/esm/utils/flat.d.ts +14 -0
- package/esm/utils/flat.d.ts.map +1 -0
- package/esm/utils/flat.js +85 -0
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +3 -1
- package/esm/utils/render.d.ts +1 -1
- package/esm/utils/render.d.ts.map +1 -1
- package/esm/utils/render.js +2 -2
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,MAAM,MAA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AAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAQD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB,wBAsO3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -24,7 +24,7 @@ var horizontalPosition = ['left-bottom', 'left-top', 'right-bottom', 'right-top'
|
|
24
24
|
var verticalPosition = ['bottom-left', 'bottom-right', 'top-left', 'top-right', 'bottom', 'top'];
|
25
25
|
var hideStyle = {
|
26
26
|
pointerEvents: 'none',
|
27
|
-
position: '
|
27
|
+
position: 'fixed',
|
28
28
|
zIndex: -1000,
|
29
29
|
opacity: 0
|
30
30
|
};
|
@@ -171,7 +171,10 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
171
171
|
if (adjust) {
|
172
172
|
// 调节左右溢出
|
173
173
|
if (overRight > 0) {
|
174
|
+
var toRightDistance = bodyRect.right - rect.right;
|
174
175
|
style.left -= overRight;
|
176
|
+
// 扣除触发器距离页面右侧的距离,以保证从右侧弹出的窗口最右边对齐触发器最右边
|
177
|
+
style.left -= toRightDistance;
|
175
178
|
}
|
176
179
|
if (overLeft > 0) {
|
177
180
|
style.left += overLeft;
|
@@ -258,7 +261,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
258
261
|
setStyle(newStyle);
|
259
262
|
}
|
260
263
|
});
|
261
|
-
(0, _react.useEffect)(updateStyle, [show, position, absolute, updateKey]);
|
264
|
+
(0, _react.useEffect)(updateStyle, [show, position, absolute, updateKey, fixedWidth]);
|
262
265
|
return style;
|
263
266
|
};
|
264
267
|
var _default = exports.default = usePositionStyle;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-date.d.ts","sourceRoot":"","sources":["use-date.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAU/C,QAAA,MAAM,OAAO,UAAW,YAAY;;;;;;;;;;wBAmBX,IAAI;2BA6CD,IAAI;yBAgBN,IAAI;
|
1
|
+
{"version":3,"file":"use-date.d.ts","sourceRoot":"","sources":["use-date.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAU/C,QAAA,MAAM,OAAO,UAAW,YAAY;;;;;;;;;;wBAmBX,IAAI;2BA6CD,IAAI;yBAgBN,IAAI;0BAiDH,IAAI;+BArEC,IAAI;+BA+CJ,IAAI;0BAnBT,IAAI;2BAIH,IAAI;;gCAIC,IAAI;;CAgFpC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -99,17 +99,7 @@ var useDate = function useDate(props) {
|
|
99
99
|
return _util.default.getDateInfo(date, 'week', options);
|
100
100
|
};
|
101
101
|
var getDateWithTime = function getDateWithTime(date) {
|
102
|
-
|
103
|
-
max = props.max;
|
104
|
-
var timeDate = props.value || props.defaultTime && _util.default.cloneTime(date, props.defaultTime, _util.default.TIME_FORMAT, options);
|
105
|
-
var newDate = _util.default.toDate(date);
|
106
|
-
if (timeDate) {
|
107
|
-
newDate = _util.default.setTime(newDate, timeDate, options);
|
108
|
-
}
|
109
|
-
// only can select day with the same day of min/max
|
110
|
-
if (min && _util.default.compareAsc(newDate, min) < 0) newDate = _util.default.setTime(newDate, min, options);
|
111
|
-
if (max && _util.default.compareAsc(newDate, max) > 0) newDate = _util.default.setTime(newDate, max, options);
|
112
|
-
return newDate;
|
102
|
+
return _util.default.getDateWithTime(date, props.value, props.defaultTime, props.min, props.max, options);
|
113
103
|
};
|
114
104
|
var handleDayClick = function handleDayClick(date) {
|
115
105
|
var _props$onChange;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-datepicker-format.d.ts","sourceRoot":"","sources":["use-datepicker-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AAkEtC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"use-datepicker-format.d.ts","sourceRoot":"","sources":["use-datepicker-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AAkEtC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;yBA4Ic,gBAAgB;iCA8BR,MAAM,SAAS,MAAM;yCA7HrD,OAAO,GAAG,KAAK,GAAG,SAAS,QAAQ,MAAM,UAAU,IAAI,KAAK,OAAO;uCAWvE,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC,QAC3B,MAAM;kBACG,MAAM,SAAS;mBAAS,GAAG;;+BAQH,IAAI,YAAY,OAAO,GAAG,KAAK,GAAG,SAAS;;CAwKvF,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
@@ -141,6 +141,7 @@ var useDatePickerFormat = function useDatePickerFormat(props) {
|
|
141
141
|
});
|
142
142
|
var setCurrentArrWithParams = (0, _usePersistFn.usePersistFn)(function (arg, type, quick) {
|
143
143
|
setCurrentArr(arg);
|
144
|
+
if (!type && !quick) return;
|
144
145
|
setParams({
|
145
146
|
type: type,
|
146
147
|
quick: quick
|
@@ -16,6 +16,8 @@ declare const useRangePick: (props: useRangeProps) => {
|
|
16
16
|
setTargetEnd: (date?: Date) => void;
|
17
17
|
startDisabled: (date: Date) => boolean;
|
18
18
|
endDisabled: (date: Date) => boolean;
|
19
|
+
getStartDobule: (date: Date) => Date;
|
20
|
+
getEndDobule: (date: Date) => Date;
|
19
21
|
};
|
20
22
|
};
|
21
23
|
export default useRangePick;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-datepicker-range.d.ts","sourceRoot":"","sources":["use-datepicker-range.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAK5D,QAAA,MAAM,YAAY,UAAW,aAAa;;;;;;;;;
|
1
|
+
{"version":3,"file":"use-datepicker-range.d.ts","sourceRoot":"","sources":["use-datepicker-range.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAK5D,QAAA,MAAM,YAAY,UAAW,aAAa;;;;;;;;;6BA0FC,IAAI,YAAY,OAAO;2BAKzB,IAAI,YAAY,OAAO;gCAblB,IAAI,WAAW,GAAG,EAAE;8BAItB,IAAI,WAAW,GAAG,EAAE;gCAclB,IAAI;8BA4BN,IAAI;8BAqBJ,IAAI;4BAeN,IAAI;+BA5DD,IAAI;6BAYN,IAAI;;CAuH9C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
@@ -44,7 +44,7 @@ var useRangePick = function useRangePick(props) {
|
|
44
44
|
newArr[1] = rangeMax;
|
45
45
|
}
|
46
46
|
} else if (date.getTime() > newArr[1].getTime()) {
|
47
|
-
var a = _util.default.cloneTime(new Date(date), defaultTimeArr[1], 'HH:mm:ss', options);
|
47
|
+
var a = _util.default.cloneTime(new Date(date), arr[1] || defaultTimeArr[1], 'HH:mm:ss', options);
|
48
48
|
newArr[1] = a.getTime() > date.getTime() ? a : new Date(date);
|
49
49
|
}
|
50
50
|
}
|
@@ -112,6 +112,14 @@ var useRangePick = function useRangePick(props) {
|
|
112
112
|
var setTargetStart = (0, _usePersistFn.usePersistFn)(function (date) {
|
113
113
|
setTargetArr([date, undefined]);
|
114
114
|
});
|
115
|
+
var getStartDobule = (0, _usePersistFn.usePersistFn)(function (date) {
|
116
|
+
var end = _util.default.getDateWithTime(date, props.dateArr[1], defaultTimeArr[1], endMin, endMax, options);
|
117
|
+
return end;
|
118
|
+
});
|
119
|
+
var getEndDobule = (0, _usePersistFn.usePersistFn)(function (date) {
|
120
|
+
var start = _util.default.getDateWithTime(date, props.dateArr[1], defaultTimeArr[1], startMin, startMax, options);
|
121
|
+
return start;
|
122
|
+
});
|
115
123
|
var setTargetEnd = (0, _usePersistFn.usePersistFn)(function (date) {
|
116
124
|
setTargetArr([undefined, date]);
|
117
125
|
});
|
@@ -168,7 +176,9 @@ var useRangePick = function useRangePick(props) {
|
|
168
176
|
setTargetStart: setTargetStart,
|
169
177
|
setTargetEnd: setTargetEnd,
|
170
178
|
startDisabled: startDisabled,
|
171
|
-
endDisabled: endDisabled
|
179
|
+
endDisabled: endDisabled,
|
180
|
+
getStartDobule: getStartDobule,
|
181
|
+
getEndDobule: getEndDobule
|
172
182
|
});
|
173
183
|
var minDate = min ? _util.default.toDate(min, options) : undefined;
|
174
184
|
var maxDate = max ? _util.default.toDate(max, options) : undefined;
|
@@ -77,6 +77,7 @@ declare const _default: {
|
|
77
77
|
transDateWithZone: typeof transDateWithZone;
|
78
78
|
getStartYear: typeof getStartYear;
|
79
79
|
isValidString: typeof isValidString;
|
80
|
+
getDateWithTime: (date: Date, value: Date | undefined, defaultTime: string | number | Date | undefined, min: Date | undefined, max: Date | undefined, options: DateOptions) => Date;
|
80
81
|
};
|
81
82
|
export default _default;
|
82
83
|
//# source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EAAE,IAAI,EACV,KAAK,EAAE,IAAI,GAAG,SAAS,EACvB,WAAW,EAAE,IAAI,GAAG,SAAS,EAC7B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,iBAWrB;AAED,iBAAS,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,QAMjD;AAED,iBAAS,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,oBAAS,EAAE,OAAO,EAAE,WAAW,WAQxF;AAcD,iBAAS,iBAAiB,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,eAInF;AAED,iBAAS,SAAS,CAChB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,KAAK,MAAM,CAAC,EACxD,OAAO,EAAE,WAAW,UAKrB;AAED,iBAAS,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,UAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBD,wBAsCE"}
|
@@ -358,6 +358,19 @@ function formatted(date, fmt, options) {
|
|
358
358
|
function getStartYear(date, options) {
|
359
359
|
return Math.floor(getDateInfo(date, 'year', options) / 10) * 10;
|
360
360
|
}
|
361
|
+
|
362
|
+
// 如果有 value 取 value 的 time 否则取 defaultTime
|
363
|
+
var getDateWithTime = function getDateWithTime(date, value, defaultTime, min, max, options) {
|
364
|
+
var timeDate = value || defaultTime && cloneTime(date, defaultTime, TIME_FORMAT, options);
|
365
|
+
var newDate = toDate(date);
|
366
|
+
if (timeDate) {
|
367
|
+
newDate = setTime(newDate, timeDate, options);
|
368
|
+
}
|
369
|
+
// only can select day with the same day of min/max
|
370
|
+
if (min && compareAsc(newDate, min) < 0) newDate = setTime(newDate, min, options);
|
371
|
+
if (max && compareAsc(newDate, max) > 0) newDate = setTime(newDate, max, options);
|
372
|
+
return newDate;
|
373
|
+
};
|
361
374
|
var _default = exports.default = {
|
362
375
|
clearHMS: clearHMS,
|
363
376
|
addDays: addDays,
|
@@ -394,5 +407,6 @@ var _default = exports.default = {
|
|
394
407
|
compatibleFmt: compatibleFmt,
|
395
408
|
transDateWithZone: transDateWithZone,
|
396
409
|
getStartYear: getStartYear,
|
397
|
-
isValidString: isValidString
|
410
|
+
isValidString: isValidString,
|
411
|
+
getDateWithTime: getDateWithTime
|
398
412
|
};
|
@@ -10,6 +10,7 @@ export declare const useFormFieldSet: <T>(props: BaseFormFieldSetProps<T>) => {
|
|
10
10
|
error: Error | undefined;
|
11
11
|
value: T | undefined;
|
12
12
|
onChange: (v: T, ...other: any[]) => void;
|
13
|
+
name: string | (string[] & string);
|
13
14
|
};
|
14
15
|
export default useFormFieldSet;
|
15
16
|
//# sourceMappingURL=use-form-fieldset.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-fieldset.d.ts","sourceRoot":"","sources":["use-form-fieldset.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAKjE,eAAO,MAAM,eAAe
|
1
|
+
{"version":3,"file":"use-form-fieldset.d.ts","sourceRoot":"","sources":["use-form-fieldset.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAKjE,eAAO,MAAM,eAAe;;;;;;;;;;;CA2B3B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -36,7 +36,8 @@ var useFormFieldSet = exports.useFormFieldSet = function useFormFieldSet(props)
|
|
36
36
|
ProviderValue: ProviderValue,
|
37
37
|
error: error,
|
38
38
|
value: value,
|
39
|
-
onChange: onChange
|
39
|
+
onChange: onChange,
|
40
|
+
name: name
|
40
41
|
};
|
41
42
|
};
|
42
43
|
var _default = exports.default = useFormFieldSet;
|
@@ -20,6 +20,9 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
20
20
|
getErrors: () => ObjectType<Error | undefined>;
|
21
21
|
clearValidate: (names?: string[]) => void;
|
22
22
|
validateFields: (fields?: string | string[], config?: any) => Promise<true>;
|
23
|
+
validateFieldset: (name: string) => void;
|
24
|
+
insertError: (name: string, index: number, error?: Error) => void;
|
25
|
+
spliceError: (name: string, index: number) => void;
|
23
26
|
};
|
24
27
|
};
|
25
28
|
formFunc: {
|
@@ -35,6 +38,9 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
|
|
35
38
|
getErrors: () => ObjectType<Error | undefined>;
|
36
39
|
clearValidate: (names?: string[]) => void;
|
37
40
|
validateFields: (fields?: string | string[], config?: any) => Promise<true>;
|
41
|
+
validateFieldset: (name: string) => void;
|
42
|
+
insertError: (name: string, index: number, error?: Error) => void;
|
43
|
+
spliceError: (name: string, index: number) => void;
|
38
44
|
};
|
39
45
|
};
|
40
46
|
export default useForm;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAyBA,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAmK8B;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;aAAE;8BARzB,MAAM;oCAuDD,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCAiI5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBA1CpB;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE;0BARzB,MAAM;gCAuDD,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCArEN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;iCAiI5D,MAAM;4BAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CA4P9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -10,6 +10,8 @@ var _Provider = require("./Provider");
|
|
10
10
|
var _useLatestObj = _interopRequireDefault(require("../../common/use-latest-obj"));
|
11
11
|
var _usePersistFn = _interopRequireDefault(require("../../common/use-persist-fn"));
|
12
12
|
var _attribute = require("../../utils/attribute");
|
13
|
+
var _flat = require("../../utils/flat");
|
14
|
+
var _useDefaultValue = require("../../common/use-default-value");
|
13
15
|
var _immer = require("../../utils/immer");
|
14
16
|
var _utils = require("../../utils");
|
15
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -48,6 +50,7 @@ var useForm = function useForm(props) {
|
|
48
50
|
removeUndefined: removeUndefined,
|
49
51
|
forceSet: true
|
50
52
|
};
|
53
|
+
var preValue = (0, _useDefaultValue.usePrevious)(props.value);
|
51
54
|
var formRef = React.useRef();
|
52
55
|
var _React$useRef = React.useRef({
|
53
56
|
defaultValues: {},
|
@@ -93,6 +96,15 @@ var useForm = function useForm(props) {
|
|
93
96
|
update();
|
94
97
|
});
|
95
98
|
};
|
99
|
+
var updateFieldsets = (0, _usePersistFn.default)(function (name) {
|
100
|
+
var na = "".concat(name, "[");
|
101
|
+
var no = "".concat(name, ".");
|
102
|
+
context.names.forEach(function (key) {
|
103
|
+
if (key.startsWith(na) || key.startsWith(no)) {
|
104
|
+
update(key);
|
105
|
+
}
|
106
|
+
});
|
107
|
+
});
|
96
108
|
var handleSubmitError = function handleSubmitError(err) {
|
97
109
|
onError === null || onError === void 0 || onError(err);
|
98
110
|
if (!props.scrollToError) return;
|
@@ -210,6 +222,14 @@ var useForm = function useForm(props) {
|
|
210
222
|
context.errors[name] = e;
|
211
223
|
update(name);
|
212
224
|
});
|
225
|
+
var insertError = (0, _usePersistFn.default)(function (name, index, error) {
|
226
|
+
(0, _flat.insertValue)(context.errors, name, index, error);
|
227
|
+
updateFieldsets(name);
|
228
|
+
});
|
229
|
+
var spliceError = (0, _usePersistFn.default)(function (name, index) {
|
230
|
+
(0, _flat.spliceValue)(context.errors, name, index);
|
231
|
+
updateFieldsets(name);
|
232
|
+
});
|
213
233
|
var submit = (0, _usePersistFn.default)(function () {
|
214
234
|
var withValidate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
215
235
|
if (disabled) return;
|
@@ -266,6 +286,17 @@ var useForm = function useForm(props) {
|
|
266
286
|
other === null || other === void 0 || (_other$onSubmit = other.onSubmit) === null || _other$onSubmit === void 0 || _other$onSubmit.call(other, e);
|
267
287
|
};
|
268
288
|
};
|
289
|
+
var validateFieldset = function validateFieldset(name) {
|
290
|
+
var na = "".concat(name, "[");
|
291
|
+
var no = "".concat(name, ".");
|
292
|
+
var fields = [];
|
293
|
+
context.names.forEach(function (key) {
|
294
|
+
if (key.startsWith(na) || key.startsWith(no)) {
|
295
|
+
fields.push(key);
|
296
|
+
}
|
297
|
+
});
|
298
|
+
validateFields(fields).catch(function () {});
|
299
|
+
};
|
269
300
|
var getDefaultValue = function getDefaultValue() {
|
270
301
|
var v = (0, _immer.produce)(defaultValue, function (draft) {
|
271
302
|
Object.keys(context.defaultValues).forEach(function (key) {
|
@@ -371,7 +402,10 @@ var useForm = function useForm(props) {
|
|
371
402
|
setError: setError,
|
372
403
|
getErrors: getErrors,
|
373
404
|
clearValidate: clearValidate,
|
374
|
-
validateFields: validateFields
|
405
|
+
validateFields: validateFields,
|
406
|
+
validateFieldset: validateFieldset,
|
407
|
+
insertError: insertError,
|
408
|
+
spliceError: spliceError
|
375
409
|
});
|
376
410
|
var formConfig = React.useMemo(function () {
|
377
411
|
return {
|
@@ -387,8 +421,8 @@ var useForm = function useForm(props) {
|
|
387
421
|
var updateValue = function updateValue() {
|
388
422
|
if (props.value !== context.lastValue && props.value !== context.value) {
|
389
423
|
context.value = (0, _utils.deepClone)(props.value) || emptyObj;
|
390
|
-
context.lastValue = props.value;
|
391
424
|
}
|
425
|
+
context.lastValue = props.value;
|
392
426
|
};
|
393
427
|
updateValue();
|
394
428
|
React.useEffect(function () {
|
@@ -411,14 +445,13 @@ var useForm = function useForm(props) {
|
|
411
445
|
if (props.value === context.value) return;
|
412
446
|
if (initValidate && !context.resetTime) {
|
413
447
|
var keys = Object.keys(context.validateMap).filter(function (key) {
|
414
|
-
var oldValue = (0, _utils.deepGet)(
|
448
|
+
var oldValue = (0, _utils.deepGet)(preValue || emptyObj, key);
|
415
449
|
var newValue = (0, _utils.deepGet)(context.value || emptyObj, key);
|
416
450
|
return !(0, _utils.shallowEqual)(oldValue, newValue);
|
417
451
|
});
|
418
452
|
validateFields(keys).catch(function () {});
|
419
453
|
}
|
420
454
|
update();
|
421
|
-
context.lastValue = props.value;
|
422
455
|
context.resetTime = 0;
|
423
456
|
}, [props.value]);
|
424
457
|
React.useEffect(function () {
|
@@ -80,6 +80,9 @@ export interface FormFunc {
|
|
80
80
|
validateFields: (fields?: string | string[], config?: {
|
81
81
|
ignoreBind?: boolean;
|
82
82
|
}) => Promise<true>;
|
83
|
+
validateFieldset: (name: string) => void;
|
84
|
+
insertError: (name: string, index: number, error?: Error) => void;
|
85
|
+
spliceError: (name: string, index: number) => void;
|
83
86
|
}
|
84
87
|
interface FormRuleObject<T> {
|
85
88
|
[key: string]: FormRuleObject<T> | FormItemRule<T>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.type.d.ts","sourceRoot":"","sources":["use-form.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;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@ -4,7 +4,7 @@ declare const usePagination: (props: BasePaginationProps) => {
|
|
4
4
|
current: number | undefined;
|
5
5
|
pageSize: number;
|
6
6
|
total: number;
|
7
|
-
onChange: (
|
7
|
+
onChange: (c: number, size?: number) => void;
|
8
8
|
getRootProps: <TOther extends ObjectType = ObjectType>(externalProps?: TOther) => {
|
9
9
|
[x: string]: (event: any) => void;
|
10
10
|
} & TOther & {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-pagination.d.ts","sourceRoot":"","sources":["use-pagination.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
1
|
+
{"version":3,"file":"use-pagination.d.ts","sourceRoot":"","sources":["use-pagination.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,QAAA,MAAM,aAAa,UAAW,mBAAmB;;;;kBAiBT,MAAM,SAAS,MAAM;;;;;;;CAiC5D,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
exports.default = void 0;
|
8
8
|
var _react = require("react");
|
9
9
|
var _utils = require("../../utils");
|
10
|
+
var _usePersistFn = require("../../common/use-persist-fn");
|
10
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
11
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
12
13
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
@@ -38,14 +39,15 @@ var usePagination = function usePagination(props) {
|
|
38
39
|
(0, _react.useEffect)(function () {
|
39
40
|
if (pageSizeProp !== pageSize) setPageSize(pageSizeProp);
|
40
41
|
}, [pageSizeProp]);
|
41
|
-
var handleChange = function
|
42
|
-
|
42
|
+
var handleChange = (0, _usePersistFn.usePersistFn)(function (c, size) {
|
43
|
+
if (c === current && size === undefined) return;
|
44
|
+
setCurrent(c);
|
43
45
|
setPageSize(size || pageSizeProp);
|
44
46
|
if (onChange) {
|
45
|
-
var sizeChange = pageSize !== size;
|
46
|
-
onChange(
|
47
|
+
var sizeChange = size !== undefined && pageSize !== size;
|
48
|
+
onChange(c, size || pageSize, sizeChange);
|
47
49
|
}
|
48
|
-
};
|
50
|
+
});
|
49
51
|
var getRootProps = function getRootProps() {
|
50
52
|
var externalProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
51
53
|
var externalEventHandlers = (0, _utils.extractEventHandlers)(externalProps);
|
@@ -239,8 +239,8 @@ export interface TableColumnItem<DataItem> {
|
|
239
239
|
*/
|
240
240
|
style?: React.CSSProperties;
|
241
241
|
/**
|
242
|
-
* @cn
|
243
|
-
* @en Click event of column
|
242
|
+
* @cn 可展开元素点击事件仅当(仅该列为行展开列,并且传入 expandKeys 的时候生效)
|
243
|
+
* @en Click event of expandable element only when (only this column is row-expand column and expandKeys is passed in)
|
244
244
|
*/
|
245
245
|
onClick?: (d: DataItem, isExpand: boolean) => void;
|
246
246
|
/**
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export type insertObject = {
|
2
|
+
[x: string]: any;
|
3
|
+
};
|
4
|
+
export declare function insertPoint(name: string): string;
|
5
|
+
export type Result = {
|
6
|
+
[x: string]: any;
|
7
|
+
};
|
8
|
+
export declare function flatten(data: Result, skipArray?: boolean): Result;
|
9
|
+
export declare function insertValue(obj: insertObject, name: string, index: number, value: any): void;
|
10
|
+
export type SpliceValue = {
|
11
|
+
[x: string]: any;
|
12
|
+
};
|
13
|
+
export declare function spliceValue(obj: SpliceValue, name: keyof SpliceValue & string, index: number): void;
|
14
|
+
//# sourceMappingURL=flat.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"flat.d.ts","sourceRoot":"","sources":["flat.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAClB,CAAC;AAEF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAGvC;AAED,MAAM,MAAM,MAAM,GAAG;IACnB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAClB,CAAC;AAEF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,UAuCxD;AACD,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,QAmBrF;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAClB,CAAC;AAEF,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,WAAW,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,QAyB5F"}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.flatten = flatten;
|
7
|
+
exports.insertPoint = insertPoint;
|
8
|
+
exports.insertValue = insertValue;
|
9
|
+
exports.spliceValue = spliceValue;
|
10
|
+
var _is = require("./is");
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
14
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
15
|
+
function insertPoint(name) {
|
16
|
+
var reg = /(\[\d+\])/gi;
|
17
|
+
return name.replace(reg, function (s, m, i) {
|
18
|
+
return s.replace(m, i === 0 ? m : ".".concat(m));
|
19
|
+
});
|
20
|
+
}
|
21
|
+
function flatten(data, skipArray) {
|
22
|
+
if ((0, _is.isEmpty)(data)) return data;
|
23
|
+
var result = {};
|
24
|
+
function recurse(cur, prop) {
|
25
|
+
if (Object(cur) !== cur || typeof cur === 'function' || cur instanceof Date || cur instanceof Error || skipArray && Array.isArray(cur)) {
|
26
|
+
if (!(cur === undefined && /\[\d+\]$/.test(prop))) {
|
27
|
+
result[prop] = cur;
|
28
|
+
}
|
29
|
+
} else if (Array.isArray(cur)) {
|
30
|
+
if (cur.length === 0) {
|
31
|
+
result[prop] = [];
|
32
|
+
} else {
|
33
|
+
for (var i = 0, l = cur.length; i < l; i++) {
|
34
|
+
recurse(cur[i], prop ? "".concat(prop, "[").concat(i, "]") : "[".concat(i, "]"));
|
35
|
+
}
|
36
|
+
}
|
37
|
+
} else {
|
38
|
+
var empty = true;
|
39
|
+
if (_typeof(cur) === 'object') {
|
40
|
+
// eslint-disable-next-line
|
41
|
+
for (var p in cur) {
|
42
|
+
empty = false;
|
43
|
+
recurse(cur[p], prop ? "".concat(prop, ".").concat(p) : p);
|
44
|
+
}
|
45
|
+
if (empty) {
|
46
|
+
result[prop] = {};
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
recurse(data, '');
|
52
|
+
return result;
|
53
|
+
}
|
54
|
+
function insertValue(obj, name, index, value) {
|
55
|
+
Object.keys(obj).filter(function (n) {
|
56
|
+
return n.indexOf("".concat(name, "[")) === 0;
|
57
|
+
}).sort().reverse().forEach(function (n) {
|
58
|
+
// const reg = new RegExp(`${name}\\[(\\d+)\\]`)
|
59
|
+
var reg = new RegExp("".concat(name.replace(/\[/g, '\\[').replace(/\]/g, '\\]'), "\\[(\\d+)\\]"));
|
60
|
+
var match = reg.exec(n);
|
61
|
+
var i = parseInt(match[1], 10);
|
62
|
+
if (i < index) return;
|
63
|
+
var newName = n.replace(reg, "".concat(name, "[").concat(i + 1, "]"));
|
64
|
+
if (obj[n]) obj[newName] = obj[n];
|
65
|
+
delete obj[n];
|
66
|
+
});
|
67
|
+
var newValue = flatten(_defineProperty({}, "".concat(name, "[").concat(index, "]"), value));
|
68
|
+
Object.keys(newValue).forEach(function (k) {
|
69
|
+
if (newValue[k] !== undefined) obj[k] = newValue[k];
|
70
|
+
});
|
71
|
+
}
|
72
|
+
function spliceValue(obj, name, index) {
|
73
|
+
var names = Object.keys(obj).filter(function (n) {
|
74
|
+
return n === name || n.indexOf("".concat(name, "[")) === 0;
|
75
|
+
}).sort();
|
76
|
+
names.forEach(function (n) {
|
77
|
+
if (n === name && !Array.isArray(obj[name])) return;
|
78
|
+
if (n === name && Array.isArray(obj[name])) {
|
79
|
+
obj[name].splice(index, 1);
|
80
|
+
return;
|
81
|
+
}
|
82
|
+
var reg = new RegExp("".concat(name.replace(/\[/g, '\\[').replace(/\]/g, '\\]'), "\\[(\\d+)\\]"));
|
83
|
+
var match = reg.exec(n);
|
84
|
+
var i = parseInt(match[1], 10);
|
85
|
+
if (i < index) return;
|
86
|
+
if (i === index) {
|
87
|
+
delete obj[n];
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
var newName = n.replace(reg, "".concat(name, "[").concat(i - 1, "]"));
|
91
|
+
obj[newName] = obj[n];
|
92
|
+
delete obj[n];
|
93
|
+
});
|
94
|
+
}
|
package/cjs/utils/index.d.ts
CHANGED
package/cjs/utils/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC"}
|
package/cjs/utils/index.js
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
4
5
|
value: true
|
5
6
|
});
|
6
7
|
var _exportNames = {
|
7
|
-
extractEventHandlers: true
|
8
|
+
extractEventHandlers: true,
|
9
|
+
flat: true
|
8
10
|
};
|
9
11
|
Object.defineProperty(exports, "extractEventHandlers", {
|
10
12
|
enumerable: true,
|
@@ -12,6 +14,7 @@ Object.defineProperty(exports, "extractEventHandlers", {
|
|
12
14
|
return _extractEventHandlers.default;
|
13
15
|
}
|
14
16
|
});
|
17
|
+
exports.flat = void 0;
|
15
18
|
var _is = require("./is");
|
16
19
|
Object.keys(_is).forEach(function (key) {
|
17
20
|
if (key === "default" || key === "__esModule") return;
|
@@ -265,4 +268,8 @@ Object.keys(_immer).forEach(function (key) {
|
|
265
268
|
}
|
266
269
|
});
|
267
270
|
});
|
271
|
+
var _flat = _interopRequireWildcard(require("./flat"));
|
272
|
+
exports.flat = _flat;
|
273
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
274
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
268
275
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/cjs/utils/render.d.ts
CHANGED
@@ -2,5 +2,5 @@ import React from 'react';
|
|
2
2
|
import { KeygenType } from '../common/type';
|
3
3
|
export type renderFunc<T extends any[]> = (...args: T) => React.ReactNode;
|
4
4
|
export declare const render: <T extends any[]>(r: string | renderFunc<T> | undefined, ...args: T) => any;
|
5
|
-
export declare function getKey<T>(gen: KeygenType<T> | undefined, d: T, index?: number): string | number;
|
5
|
+
export declare function getKey<T>(gen: KeygenType<T> | undefined, d: T, index?: number, ignoreError?: boolean): string | number;
|
6
6
|
//# sourceMappingURL=render.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;AAE1E,eAAO,MAAM,MAAM,6EAIlB,CAAC;AAQF,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;AAE1E,eAAO,MAAM,MAAM,6EAIlB,CAAC;AAQF,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,mBAMpG"}
|
package/cjs/utils/render.js
CHANGED
@@ -20,9 +20,9 @@ function $getKey(gen, d, index) {
|
|
20
20
|
if (typeof gen === 'function') return gen(d, index);
|
21
21
|
return index;
|
22
22
|
}
|
23
|
-
function getKey(gen, d, index) {
|
23
|
+
function getKey(gen, d, index, ignoreError) {
|
24
24
|
var key = $getKey(gen, d, index);
|
25
|
-
if (typeof key !== 'string' && typeof key !== 'number') {
|
25
|
+
if (typeof key !== 'string' && typeof key !== 'number' && !ignoreError) {
|
26
26
|
console.error(new Error("keygen result expect a string or a number, get '".concat(_typeof(key), "'")));
|
27
27
|
}
|
28
28
|
return key;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MA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