@sheinx/hooks 3.3.0-beta.1 → 3.3.0-beta.11
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 +11 -6
- package/cjs/components/use-table/use-table-layout.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-layout.js +1 -1
- 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 +11 -6
- package/esm/components/use-table/use-table-layout.d.ts.map +1 -1
- package/esm/components/use-table/use-table-layout.js +2 -2
- 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":"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,MAAM,OAAO,CAAC;AAMnD,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,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,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,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"}
|
@@ -14,7 +14,7 @@ var horizontalPosition = ['left-bottom', 'left-top', 'right-bottom', 'right-top'
|
|
14
14
|
var verticalPosition = ['bottom-left', 'bottom-right', 'top-left', 'top-right', 'bottom', 'top'];
|
15
15
|
var hideStyle = {
|
16
16
|
pointerEvents: 'none',
|
17
|
-
position: '
|
17
|
+
position: 'fixed',
|
18
18
|
zIndex: -1000,
|
19
19
|
opacity: 0
|
20
20
|
};
|
@@ -161,7 +161,10 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
161
161
|
if (adjust) {
|
162
162
|
// 调节左右溢出
|
163
163
|
if (overRight > 0) {
|
164
|
+
var toRightDistance = bodyRect.right - rect.right;
|
164
165
|
style.left -= overRight;
|
166
|
+
// 扣除触发器距离页面右侧的距离,以保证从右侧弹出的窗口最右边对齐触发器最右边
|
167
|
+
style.left -= toRightDistance;
|
165
168
|
}
|
166
169
|
if (overLeft > 0) {
|
167
170
|
style.left += overLeft;
|
@@ -248,7 +251,7 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
248
251
|
setStyle(newStyle);
|
249
252
|
}
|
250
253
|
});
|
251
|
-
useEffect(updateStyle, [show, position, absolute, updateKey]);
|
254
|
+
useEffect(updateStyle, [show, position, absolute, updateKey, fixedWidth]);
|
252
255
|
return style;
|
253
256
|
};
|
254
257
|
export 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"}
|
@@ -93,17 +93,7 @@ var useDate = function useDate(props) {
|
|
93
93
|
return utils.getDateInfo(date, 'week', options);
|
94
94
|
};
|
95
95
|
var getDateWithTime = function getDateWithTime(date) {
|
96
|
-
|
97
|
-
max = props.max;
|
98
|
-
var timeDate = props.value || props.defaultTime && utils.cloneTime(date, props.defaultTime, utils.TIME_FORMAT, options);
|
99
|
-
var newDate = utils.toDate(date);
|
100
|
-
if (timeDate) {
|
101
|
-
newDate = utils.setTime(newDate, timeDate, options);
|
102
|
-
}
|
103
|
-
// only can select day with the same day of min/max
|
104
|
-
if (min && utils.compareAsc(newDate, min) < 0) newDate = utils.setTime(newDate, min, options);
|
105
|
-
if (max && utils.compareAsc(newDate, max) > 0) newDate = utils.setTime(newDate, max, options);
|
106
|
-
return newDate;
|
96
|
+
return utils.getDateWithTime(date, props.value, props.defaultTime, props.min, props.max, options);
|
107
97
|
};
|
108
98
|
var handleDayClick = function handleDayClick(date) {
|
109
99
|
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"}
|
@@ -134,6 +134,7 @@ var useDatePickerFormat = function useDatePickerFormat(props) {
|
|
134
134
|
});
|
135
135
|
var setCurrentArrWithParams = usePersistFn(function (arg, type, quick) {
|
136
136
|
setCurrentArr(arg);
|
137
|
+
if (!type && !quick) return;
|
137
138
|
setParams({
|
138
139
|
type: type,
|
139
140
|
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"}
|
@@ -37,7 +37,7 @@ var useRangePick = function useRangePick(props) {
|
|
37
37
|
newArr[1] = rangeMax;
|
38
38
|
}
|
39
39
|
} else if (date.getTime() > newArr[1].getTime()) {
|
40
|
-
var a = utils.cloneTime(new Date(date), defaultTimeArr[1], 'HH:mm:ss', options);
|
40
|
+
var a = utils.cloneTime(new Date(date), arr[1] || defaultTimeArr[1], 'HH:mm:ss', options);
|
41
41
|
newArr[1] = a.getTime() > date.getTime() ? a : new Date(date);
|
42
42
|
}
|
43
43
|
}
|
@@ -105,6 +105,14 @@ var useRangePick = function useRangePick(props) {
|
|
105
105
|
var setTargetStart = usePersistFn(function (date) {
|
106
106
|
setTargetArr([date, undefined]);
|
107
107
|
});
|
108
|
+
var getStartDobule = usePersistFn(function (date) {
|
109
|
+
var end = utils.getDateWithTime(date, props.dateArr[1], defaultTimeArr[1], endMin, endMax, options);
|
110
|
+
return end;
|
111
|
+
});
|
112
|
+
var getEndDobule = usePersistFn(function (date) {
|
113
|
+
var start = utils.getDateWithTime(date, props.dateArr[1], defaultTimeArr[1], startMin, startMax, options);
|
114
|
+
return start;
|
115
|
+
});
|
108
116
|
var setTargetEnd = usePersistFn(function (date) {
|
109
117
|
setTargetArr([undefined, date]);
|
110
118
|
});
|
@@ -161,7 +169,9 @@ var useRangePick = function useRangePick(props) {
|
|
161
169
|
setTargetStart: setTargetStart,
|
162
170
|
setTargetEnd: setTargetEnd,
|
163
171
|
startDisabled: startDisabled,
|
164
|
-
endDisabled: endDisabled
|
172
|
+
endDisabled: endDisabled,
|
173
|
+
getStartDobule: getStartDobule,
|
174
|
+
getEndDobule: getEndDobule
|
165
175
|
});
|
166
176
|
var minDate = min ? utils.toDate(min, options) : undefined;
|
167
177
|
var maxDate = max ? utils.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
|
//# sourceMappingURL=util.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAC9D,MAAM,MAAM,IAAI,GACZ,MAAM,GACN,OAAO,GACP,SAAS,GACT,MAAM,GACN,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,MAAM,CAAC;AACX,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;AAKjD,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAqBD,eAAO,MAAM,aAAa,SAAU,MAAM,uBAmBzC,CAAC;AAOF,iBAAS,iBAAiB,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,GAAE,WAAgB,EAAE,IAAI,UAAQ,QAa3E;AAED,iBAAS,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,QAKhE;AAED,iBAAS,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,QAKlE;AAED,iBAAS,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,QAKnE;AAED,iBAAS,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,QAKjE;AAED,iBAAS,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO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AE,YAAY,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,QAKpF;AAED,iBAAS,yBAAyB,CAChC,IAAI,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"}
|
@@ -352,6 +352,19 @@ function formatted(date, fmt, options) {
|
|
352
352
|
function getStartYear(date, options) {
|
353
353
|
return Math.floor(getDateInfo(date, 'year', options) / 10) * 10;
|
354
354
|
}
|
355
|
+
|
356
|
+
// 如果有 value 取 value 的 time 否则取 defaultTime
|
357
|
+
var getDateWithTime = function getDateWithTime(date, value, defaultTime, min, max, options) {
|
358
|
+
var timeDate = value || defaultTime && cloneTime(date, defaultTime, TIME_FORMAT, options);
|
359
|
+
var newDate = toDate(date);
|
360
|
+
if (timeDate) {
|
361
|
+
newDate = setTime(newDate, timeDate, options);
|
362
|
+
}
|
363
|
+
// only can select day with the same day of min/max
|
364
|
+
if (min && compareAsc(newDate, min) < 0) newDate = setTime(newDate, min, options);
|
365
|
+
if (max && compareAsc(newDate, max) > 0) newDate = setTime(newDate, max, options);
|
366
|
+
return newDate;
|
367
|
+
};
|
355
368
|
export default {
|
356
369
|
clearHMS: clearHMS,
|
357
370
|
addDays: addDays,
|
@@ -388,5 +401,6 @@ export default {
|
|
388
401
|
compatibleFmt: compatibleFmt,
|
389
402
|
transDateWithZone: transDateWithZone,
|
390
403
|
getStartYear: getStartYear,
|
391
|
-
isValidString: isValidString
|
404
|
+
isValidString: isValidString,
|
405
|
+
getDateWithTime: getDateWithTime
|
392
406
|
};
|
@@ -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"}
|
@@ -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"}
|
@@ -12,6 +12,8 @@ import { Provider } from "./Provider";
|
|
12
12
|
import useLatestObj from "../../common/use-latest-obj";
|
13
13
|
import usePersistFn from "../../common/use-persist-fn";
|
14
14
|
import { getDataAttributeName } from "../../utils/attribute";
|
15
|
+
import { insertValue, spliceValue } from "../../utils/flat";
|
16
|
+
import { usePrevious } from "../../common/use-default-value";
|
15
17
|
var globalKey = '__global__&&@@';
|
16
18
|
import { current, produce } from "../../utils/immer";
|
17
19
|
import { deepGet, deepRemove, deepSet, docScroll, extractEventHandlers, isArray, isObject, shallowEqual, wrapFormError, deepClone } from "../../utils";
|
@@ -39,6 +41,7 @@ var useForm = function useForm(props) {
|
|
39
41
|
removeUndefined: removeUndefined,
|
40
42
|
forceSet: true
|
41
43
|
};
|
44
|
+
var preValue = usePrevious(props.value);
|
42
45
|
var formRef = React.useRef();
|
43
46
|
var _React$useRef = React.useRef({
|
44
47
|
defaultValues: {},
|
@@ -84,6 +87,15 @@ var useForm = function useForm(props) {
|
|
84
87
|
update();
|
85
88
|
});
|
86
89
|
};
|
90
|
+
var updateFieldsets = usePersistFn(function (name) {
|
91
|
+
var na = "".concat(name, "[");
|
92
|
+
var no = "".concat(name, ".");
|
93
|
+
context.names.forEach(function (key) {
|
94
|
+
if (key.startsWith(na) || key.startsWith(no)) {
|
95
|
+
update(key);
|
96
|
+
}
|
97
|
+
});
|
98
|
+
});
|
87
99
|
var handleSubmitError = function handleSubmitError(err) {
|
88
100
|
onError === null || onError === void 0 || onError(err);
|
89
101
|
if (!props.scrollToError) return;
|
@@ -201,6 +213,14 @@ var useForm = function useForm(props) {
|
|
201
213
|
context.errors[name] = e;
|
202
214
|
update(name);
|
203
215
|
});
|
216
|
+
var insertError = usePersistFn(function (name, index, error) {
|
217
|
+
insertValue(context.errors, name, index, error);
|
218
|
+
updateFieldsets(name);
|
219
|
+
});
|
220
|
+
var spliceError = usePersistFn(function (name, index) {
|
221
|
+
spliceValue(context.errors, name, index);
|
222
|
+
updateFieldsets(name);
|
223
|
+
});
|
204
224
|
var submit = usePersistFn(function () {
|
205
225
|
var withValidate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
206
226
|
if (disabled) return;
|
@@ -257,6 +277,17 @@ var useForm = function useForm(props) {
|
|
257
277
|
other === null || other === void 0 || (_other$onSubmit = other.onSubmit) === null || _other$onSubmit === void 0 || _other$onSubmit.call(other, e);
|
258
278
|
};
|
259
279
|
};
|
280
|
+
var validateFieldset = function validateFieldset(name) {
|
281
|
+
var na = "".concat(name, "[");
|
282
|
+
var no = "".concat(name, ".");
|
283
|
+
var fields = [];
|
284
|
+
context.names.forEach(function (key) {
|
285
|
+
if (key.startsWith(na) || key.startsWith(no)) {
|
286
|
+
fields.push(key);
|
287
|
+
}
|
288
|
+
});
|
289
|
+
validateFields(fields).catch(function () {});
|
290
|
+
};
|
260
291
|
var getDefaultValue = function getDefaultValue() {
|
261
292
|
var v = produce(defaultValue, function (draft) {
|
262
293
|
Object.keys(context.defaultValues).forEach(function (key) {
|
@@ -362,7 +393,10 @@ var useForm = function useForm(props) {
|
|
362
393
|
setError: setError,
|
363
394
|
getErrors: getErrors,
|
364
395
|
clearValidate: clearValidate,
|
365
|
-
validateFields: validateFields
|
396
|
+
validateFields: validateFields,
|
397
|
+
validateFieldset: validateFieldset,
|
398
|
+
insertError: insertError,
|
399
|
+
spliceError: spliceError
|
366
400
|
});
|
367
401
|
var formConfig = React.useMemo(function () {
|
368
402
|
return {
|
@@ -378,8 +412,8 @@ var useForm = function useForm(props) {
|
|
378
412
|
var updateValue = function updateValue() {
|
379
413
|
if (props.value !== context.lastValue && props.value !== context.value) {
|
380
414
|
context.value = deepClone(props.value) || emptyObj;
|
381
|
-
context.lastValue = props.value;
|
382
415
|
}
|
416
|
+
context.lastValue = props.value;
|
383
417
|
};
|
384
418
|
updateValue();
|
385
419
|
React.useEffect(function () {
|
@@ -402,14 +436,13 @@ var useForm = function useForm(props) {
|
|
402
436
|
if (props.value === context.value) return;
|
403
437
|
if (initValidate && !context.resetTime) {
|
404
438
|
var keys = Object.keys(context.validateMap).filter(function (key) {
|
405
|
-
var oldValue = deepGet(
|
439
|
+
var oldValue = deepGet(preValue || emptyObj, key);
|
406
440
|
var newValue = deepGet(context.value || emptyObj, key);
|
407
441
|
return !shallowEqual(oldValue, newValue);
|
408
442
|
});
|
409
443
|
validateFields(keys).catch(function () {});
|
410
444
|
}
|
411
445
|
update();
|
412
|
-
context.lastValue = props.value;
|
413
446
|
context.resetTime = 0;
|
414
447
|
}, [props.value]);
|
415
448
|
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;AAElC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,KAAK,IAAI,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I,aAAa,CAAC,CAAC,CAAC,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG;IACxB,aAAa,EAAE,UAAU,CAAC;IAC1B,WAAW,EAAE,UAAU,CAAC;IAExB,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAEvB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC;IACtC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,UAAU,GAAG,SAAS,CAAC;IAElC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IAEjB,SAAS,EAAE,UAAU,CAAC;IAEtB,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACrC,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IACtC,YAAY,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,UAAU,CACzE,mBAAmB,EACnB,MAAM,CACP,CAAC"}
|
@@ -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;;;;kBAqBT,MAAM,SAAS,MAAM;;;;;;;CAiC5D,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
@@ -12,6 +12,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
13
13
|
import { useEffect, useState } from 'react';
|
14
14
|
import { extractEventHandlers } from "../../utils";
|
15
|
+
import { usePersistFn } from "../../common/use-persist-fn";
|
15
16
|
var usePagination = function usePagination(props) {
|
16
17
|
var totalProp = props.total,
|
17
18
|
pageSizeProp = props.pageSize,
|
@@ -32,14 +33,18 @@ var usePagination = function usePagination(props) {
|
|
32
33
|
useEffect(function () {
|
33
34
|
if (pageSizeProp !== pageSize) setPageSize(pageSizeProp);
|
34
35
|
}, [pageSizeProp]);
|
35
|
-
|
36
|
-
|
36
|
+
useEffect(function () {
|
37
|
+
if (currentProp !== undefined && currentProp !== current) setCurrent(currentProp);
|
38
|
+
}, [currentProp]);
|
39
|
+
var handleChange = usePersistFn(function (c, size) {
|
40
|
+
if (c === current && size === undefined) return;
|
41
|
+
setCurrent(c);
|
37
42
|
setPageSize(size || pageSizeProp);
|
38
43
|
if (onChange) {
|
39
|
-
var sizeChange = pageSize !== size;
|
40
|
-
onChange(
|
44
|
+
var sizeChange = size !== undefined && pageSize !== size;
|
45
|
+
onChange(c, size || pageSize, sizeChange);
|
41
46
|
}
|
42
|
-
};
|
47
|
+
});
|
43
48
|
var getRootProps = function getRootProps() {
|
44
49
|
var externalProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
45
50
|
var externalEventHandlers = extractEventHandlers(externalProps);
|
@@ -50,7 +55,7 @@ var usePagination = function usePagination(props) {
|
|
50
55
|
return _objectSpread({}, mergedEventHandlers);
|
51
56
|
};
|
52
57
|
return {
|
53
|
-
current:
|
58
|
+
current: current,
|
54
59
|
pageSize: pageSize,
|
55
60
|
total: total,
|
56
61
|
onChange: handleChange,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAKjD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;CA+N5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
@@ -14,7 +14,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
14
14
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
15
15
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
17
|
-
import React, { useEffect, useRef
|
17
|
+
import React, { useEffect, useRef } from 'react';
|
18
18
|
import useLatestObj from "../../common/use-latest-obj";
|
19
19
|
import usePersistFn from "../../common/use-persist-fn";
|
20
20
|
import usePrevious from "../../common/use-previous";
|
@@ -319,7 +319,7 @@ var useTableLayout = function useTableLayout(props) {
|
|
319
319
|
(_cancelFunc = cancelFunc) === null || _cancelFunc === void 0 || _cancelFunc();
|
320
320
|
};
|
321
321
|
}, [scrollRef.current]);
|
322
|
-
|
322
|
+
useEffect(function () {
|
323
323
|
if (adjust) {
|
324
324
|
getColgroup(adjust === 'drag');
|
325
325
|
setAdjust(false);
|
@@ -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,85 @@
|
|
1
|
+
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; }
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
3
|
+
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); }
|
4
|
+
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); }
|
5
|
+
import { isEmpty } from "./is";
|
6
|
+
export function insertPoint(name) {
|
7
|
+
var reg = /(\[\d+\])/gi;
|
8
|
+
return name.replace(reg, function (s, m, i) {
|
9
|
+
return s.replace(m, i === 0 ? m : ".".concat(m));
|
10
|
+
});
|
11
|
+
}
|
12
|
+
export function flatten(data, skipArray) {
|
13
|
+
if (isEmpty(data)) return data;
|
14
|
+
var result = {};
|
15
|
+
function recurse(cur, prop) {
|
16
|
+
if (Object(cur) !== cur || typeof cur === 'function' || cur instanceof Date || cur instanceof Error || skipArray && Array.isArray(cur)) {
|
17
|
+
if (!(cur === undefined && /\[\d+\]$/.test(prop))) {
|
18
|
+
result[prop] = cur;
|
19
|
+
}
|
20
|
+
} else if (Array.isArray(cur)) {
|
21
|
+
if (cur.length === 0) {
|
22
|
+
result[prop] = [];
|
23
|
+
} else {
|
24
|
+
for (var i = 0, l = cur.length; i < l; i++) {
|
25
|
+
recurse(cur[i], prop ? "".concat(prop, "[").concat(i, "]") : "[".concat(i, "]"));
|
26
|
+
}
|
27
|
+
}
|
28
|
+
} else {
|
29
|
+
var empty = true;
|
30
|
+
if (_typeof(cur) === 'object') {
|
31
|
+
// eslint-disable-next-line
|
32
|
+
for (var p in cur) {
|
33
|
+
empty = false;
|
34
|
+
recurse(cur[p], prop ? "".concat(prop, ".").concat(p) : p);
|
35
|
+
}
|
36
|
+
if (empty) {
|
37
|
+
result[prop] = {};
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
recurse(data, '');
|
43
|
+
return result;
|
44
|
+
}
|
45
|
+
export function insertValue(obj, name, index, value) {
|
46
|
+
Object.keys(obj).filter(function (n) {
|
47
|
+
return n.indexOf("".concat(name, "[")) === 0;
|
48
|
+
}).sort().reverse().forEach(function (n) {
|
49
|
+
// const reg = new RegExp(`${name}\\[(\\d+)\\]`)
|
50
|
+
var reg = new RegExp("".concat(name.replace(/\[/g, '\\[').replace(/\]/g, '\\]'), "\\[(\\d+)\\]"));
|
51
|
+
var match = reg.exec(n);
|
52
|
+
var i = parseInt(match[1], 10);
|
53
|
+
if (i < index) return;
|
54
|
+
var newName = n.replace(reg, "".concat(name, "[").concat(i + 1, "]"));
|
55
|
+
if (obj[n]) obj[newName] = obj[n];
|
56
|
+
delete obj[n];
|
57
|
+
});
|
58
|
+
var newValue = flatten(_defineProperty({}, "".concat(name, "[").concat(index, "]"), value));
|
59
|
+
Object.keys(newValue).forEach(function (k) {
|
60
|
+
if (newValue[k] !== undefined) obj[k] = newValue[k];
|
61
|
+
});
|
62
|
+
}
|
63
|
+
export function spliceValue(obj, name, index) {
|
64
|
+
var names = Object.keys(obj).filter(function (n) {
|
65
|
+
return n === name || n.indexOf("".concat(name, "[")) === 0;
|
66
|
+
}).sort();
|
67
|
+
names.forEach(function (n) {
|
68
|
+
if (n === name && !Array.isArray(obj[name])) return;
|
69
|
+
if (n === name && Array.isArray(obj[name])) {
|
70
|
+
obj[name].splice(index, 1);
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
var reg = new RegExp("".concat(name.replace(/\[/g, '\\[').replace(/\]/g, '\\]'), "\\[(\\d+)\\]"));
|
74
|
+
var match = reg.exec(n);
|
75
|
+
var i = parseInt(match[1], 10);
|
76
|
+
if (i < index) return;
|
77
|
+
if (i === index) {
|
78
|
+
delete obj[n];
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
var newName = n.replace(reg, "".concat(name, "[").concat(i - 1, "]"));
|
82
|
+
obj[newName] = obj[n];
|
83
|
+
delete obj[n];
|
84
|
+
});
|
85
|
+
}
|
package/esm/utils/index.d.ts
CHANGED
package/esm/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/esm/utils/index.js
CHANGED
package/esm/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
|