@sheinx/hooks 3.8.0-beta.4 → 3.8.0-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/common/use-filter/use-filter.d.ts.map +1 -1
- package/cjs/common/use-filter/use-filter.js +4 -1
- package/cjs/common/use-position-style/check-border.d.ts +1 -0
- package/cjs/common/use-position-style/check-border.d.ts.map +1 -1
- package/cjs/common/use-position-style/check-border.js +2 -2
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +10 -4
- package/cjs/components/use-check/use-check.d.ts.map +1 -1
- package/cjs/components/use-check/use-check.js +10 -2
- package/cjs/components/use-datepicker/use-date.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-date.js +12 -4
- package/cjs/components/use-datepicker/use-date.type.d.ts +2 -1
- package/cjs/components/use-datepicker/use-date.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts +2 -1
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.js +22 -5
- package/cjs/components/use-datepicker/use-datepicker-range.js +2 -2
- package/cjs/components/use-datepicker/use-time.d.ts +10 -8
- package/cjs/components/use-datepicker/use-time.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-time.js +19 -5
- package/cjs/components/use-datepicker/use-time.type.d.ts +5 -1
- package/cjs/components/use-datepicker/use-time.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/util.d.ts +7 -1
- package/cjs/components/use-datepicker/util.d.ts.map +1 -1
- package/cjs/components/use-datepicker/util.js +21 -2
- package/cjs/components/use-form/Provider.d.ts.map +1 -1
- package/cjs/components/use-form/Provider.js +7 -2
- package/cjs/components/use-form/form-schema-context.d.ts +6 -0
- package/cjs/components/use-form/form-schema-context.d.ts.map +1 -0
- package/cjs/components/use-form/form-schema-context.js +16 -0
- package/cjs/components/use-form/index.d.ts +2 -0
- package/cjs/components/use-form/index.d.ts.map +1 -1
- package/cjs/components/use-form/index.js +21 -1
- package/cjs/components/use-form/use-form-context.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-context.js +11 -5
- package/cjs/components/use-form/use-form-context.type.d.ts +6 -0
- package/cjs/components/use-form/use-form-context.type.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-control/use-form-control.js +12 -3
- package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts +8 -2
- package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts +8 -0
- package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-item/form-item-context.d.ts +1 -0
- package/cjs/components/use-form/use-form-item/form-item-context.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-item/form-item-context.js +2 -1
- package/cjs/components/use-form/use-form-item/index.d.ts +1 -0
- package/cjs/components/use-form/use-form-item/index.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-item/index.js +7 -0
- package/cjs/components/use-form/use-form-item/use-form-item.d.ts +1 -1
- package/cjs/components/use-form/use-form-schema/form-schema-builder.d.ts +50 -0
- package/cjs/components/use-form/use-form-schema/form-schema-builder.d.ts.map +1 -0
- package/cjs/components/use-form/use-form-schema/form-schema-builder.js +373 -0
- package/cjs/components/use-form/use-form-schema/index.d.ts +3 -0
- package/cjs/components/use-form/use-form-schema/index.d.ts.map +1 -0
- package/cjs/components/use-form/use-form-schema/index.js +13 -0
- package/cjs/components/use-form/use-form.d.ts +4 -0
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +22 -11
- package/cjs/components/use-form/use-form.type.d.ts +46 -39
- package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
- package/cjs/components/use-input/use-input.d.ts.map +1 -1
- package/cjs/components/use-input/use-input.js +4 -1
- package/cjs/components/use-pagination/use-pagination.d.ts.map +1 -1
- package/cjs/components/use-pagination/use-pagination.js +2 -1
- package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
- package/cjs/components/use-popup/use-popup.js +7 -4
- package/cjs/components/use-select/use-select.type.d.ts +27 -18
- package/cjs/components/use-select/use-select.type.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-virtual.d.ts +6 -1
- package/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-virtual.js +5 -4
- package/cjs/components/use-table/use-table.type.d.ts +70 -92
- package/cjs/components/use-table/use-table.type.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree-node.d.ts +7 -1
- package/cjs/components/use-tree/use-tree-node.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree-node.js +19 -1
- package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree.js +26 -19
- package/cjs/components/use-tree/use-tree.type.d.ts +7 -1
- package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/cjs/utils/dom/document.d.ts +4 -0
- package/cjs/utils/dom/document.d.ts.map +1 -1
- package/cjs/utils/dom/document.js +19 -2
- package/cjs/utils/dom/element.d.ts +1 -0
- package/cjs/utils/dom/element.d.ts.map +1 -1
- package/cjs/utils/dom/element.js +5 -1
- package/cjs/utils/highlight.d.ts.map +1 -1
- package/cjs/utils/highlight.js +24 -11
- package/cjs/utils/lazyload.d.ts.map +1 -1
- package/cjs/utils/lazyload.js +33 -1
- package/cjs/utils/object.d.ts +6 -0
- package/cjs/utils/object.d.ts.map +1 -1
- package/cjs/utils/object.js +21 -1
- package/cjs/utils/shallow-equal.d.ts +1 -0
- package/cjs/utils/shallow-equal.d.ts.map +1 -1
- package/cjs/utils/shallow-equal.js +9 -0
- package/esm/common/use-filter/use-filter.d.ts.map +1 -1
- package/esm/common/use-filter/use-filter.js +4 -1
- package/esm/common/use-position-style/check-border.d.ts +1 -0
- package/esm/common/use-position-style/check-border.d.ts.map +1 -1
- package/esm/common/use-position-style/check-border.js +2 -2
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +11 -5
- package/esm/components/use-check/use-check.d.ts.map +1 -1
- package/esm/components/use-check/use-check.js +10 -2
- package/esm/components/use-datepicker/use-date.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-date.js +12 -4
- package/esm/components/use-datepicker/use-date.type.d.ts +2 -1
- package/esm/components/use-datepicker/use-date.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.d.ts +2 -1
- package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.js +19 -5
- package/esm/components/use-datepicker/use-datepicker-range.js +2 -2
- package/esm/components/use-datepicker/use-time.d.ts +10 -8
- package/esm/components/use-datepicker/use-time.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-time.js +19 -5
- package/esm/components/use-datepicker/use-time.type.d.ts +5 -1
- package/esm/components/use-datepicker/use-time.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/util.d.ts +7 -1
- package/esm/components/use-datepicker/util.d.ts.map +1 -1
- package/esm/components/use-datepicker/util.js +21 -2
- package/esm/components/use-form/Provider.d.ts.map +1 -1
- package/esm/components/use-form/Provider.js +7 -2
- package/esm/components/use-form/form-schema-context.d.ts +6 -0
- package/esm/components/use-form/form-schema-context.d.ts.map +1 -0
- package/esm/components/use-form/form-schema-context.js +8 -0
- package/esm/components/use-form/index.d.ts +2 -0
- package/esm/components/use-form/index.d.ts.map +1 -1
- package/esm/components/use-form/index.js +3 -1
- package/esm/components/use-form/use-form-context.d.ts.map +1 -1
- package/esm/components/use-form/use-form-context.js +11 -5
- package/esm/components/use-form/use-form-context.type.d.ts +6 -0
- package/esm/components/use-form/use-form-context.type.d.ts.map +1 -1
- package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/esm/components/use-form/use-form-control/use-form-control.js +12 -3
- package/esm/components/use-form/use-form-control/use-form-control.type.d.ts +8 -2
- package/esm/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
- package/esm/components/use-form/use-form-flow/use-form-datum.d.ts +8 -0
- package/esm/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
- package/esm/components/use-form/use-form-item/form-item-context.d.ts +1 -0
- package/esm/components/use-form/use-form-item/form-item-context.d.ts.map +1 -1
- package/esm/components/use-form/use-form-item/form-item-context.js +2 -1
- package/esm/components/use-form/use-form-item/index.d.ts +1 -0
- package/esm/components/use-form/use-form-item/index.d.ts.map +1 -1
- package/esm/components/use-form/use-form-item/index.js +2 -1
- package/esm/components/use-form/use-form-item/use-form-item.d.ts +1 -1
- package/esm/components/use-form/use-form-schema/form-schema-builder.d.ts +50 -0
- package/esm/components/use-form/use-form-schema/form-schema-builder.d.ts.map +1 -0
- package/esm/components/use-form/use-form-schema/form-schema-builder.js +367 -0
- package/esm/components/use-form/use-form-schema/index.d.ts +3 -0
- package/esm/components/use-form/use-form-schema/index.d.ts.map +1 -0
- package/esm/components/use-form/use-form-schema/index.js +2 -0
- package/esm/components/use-form/use-form.d.ts +4 -0
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +22 -11
- package/esm/components/use-form/use-form.type.d.ts +46 -39
- package/esm/components/use-form/use-form.type.d.ts.map +1 -1
- package/esm/components/use-input/use-input.d.ts.map +1 -1
- package/esm/components/use-input/use-input.js +4 -1
- package/esm/components/use-pagination/use-pagination.d.ts.map +1 -1
- package/esm/components/use-pagination/use-pagination.js +2 -1
- package/esm/components/use-popup/use-popup.d.ts.map +1 -1
- package/esm/components/use-popup/use-popup.js +7 -4
- package/esm/components/use-select/use-select.type.d.ts +27 -18
- package/esm/components/use-select/use-select.type.d.ts.map +1 -1
- package/esm/components/use-table/use-table-virtual.d.ts +6 -1
- package/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/esm/components/use-table/use-table-virtual.js +5 -4
- package/esm/components/use-table/use-table.type.d.ts +70 -92
- package/esm/components/use-table/use-table.type.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree-node.d.ts +7 -1
- package/esm/components/use-tree/use-tree-node.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree-node.js +19 -1
- package/esm/components/use-tree/use-tree.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree.js +26 -19
- package/esm/components/use-tree/use-tree.type.d.ts +7 -1
- package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/esm/utils/dom/document.d.ts +4 -0
- package/esm/utils/dom/document.d.ts.map +1 -1
- package/esm/utils/dom/document.js +18 -1
- package/esm/utils/dom/element.d.ts +1 -0
- package/esm/utils/dom/element.d.ts.map +1 -1
- package/esm/utils/dom/element.js +4 -0
- package/esm/utils/highlight.d.ts.map +1 -1
- package/esm/utils/highlight.js +24 -10
- package/esm/utils/lazyload.d.ts.map +1 -1
- package/esm/utils/lazyload.js +33 -1
- package/esm/utils/object.d.ts +6 -0
- package/esm/utils/object.d.ts.map +1 -1
- package/esm/utils/object.js +20 -0
- package/esm/utils/shallow-equal.d.ts +1 -0
- package/esm/utils/shallow-equal.d.ts.map +1 -1
- package/esm/utils/shallow-equal.js +8 -0
- package/package.json +3 -3
@@ -1,5 +1,8 @@
|
|
1
1
|
import useLatestObj from "../../common/use-latest-obj";
|
2
2
|
import dateUtil from "./util";
|
3
|
+
var getStepIndex = function getStepIndex(index, step) {
|
4
|
+
return Math.floor(index / step);
|
5
|
+
};
|
3
6
|
var useTime = function useTime(props) {
|
4
7
|
var options = props.options,
|
5
8
|
mi = props.min,
|
@@ -12,13 +15,24 @@ var useTime = function useTime(props) {
|
|
12
15
|
_props$secondStep = props.secondStep,
|
13
16
|
secondStep = _props$secondStep === void 0 ? 1 : _props$secondStep,
|
14
17
|
staticMin = props.staticMin,
|
15
|
-
staticMax = props.staticMax
|
18
|
+
staticMax = props.staticMax,
|
19
|
+
position = props.position,
|
20
|
+
rangeDate = props.rangeDate;
|
16
21
|
var min = dateUtil.resetTimeByFormat(mi, format, options);
|
17
22
|
var max = dateUtil.resetTimeByFormat(ma, format, options);
|
18
23
|
var current = props.value || dateUtil.newDate(undefined, options);
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
if (!props.value && typeof props.defaultTime === 'string' && /^\d{1,2}(:\d{2}(:\d{2})?)?$/.test(props.defaultTime)) {
|
25
|
+
var today = new Date();
|
26
|
+
var todayStr = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
|
27
|
+
var timesStr = props.defaultTime.split(':');
|
28
|
+
var hStr = timesStr[0];
|
29
|
+
var mStr = timesStr[1] || '00';
|
30
|
+
var sStr = timesStr[2] || '00';
|
31
|
+
var timeStr = hStr + ':' + mStr + ':' + sStr;
|
32
|
+
var dayStr = todayStr + ' ' + timeStr;
|
33
|
+
var val = new Date(dayStr);
|
34
|
+
if (val) current = val;
|
35
|
+
}
|
22
36
|
var time = {
|
23
37
|
hour: dateUtil.getDateInfo(current, 'hour', options),
|
24
38
|
minute: dateUtil.getDateInfo(current, 'minute', options),
|
@@ -38,7 +52,7 @@ var useTime = function useTime(props) {
|
|
38
52
|
disabledTime = props.disabledTime;
|
39
53
|
if (disabledTime) {
|
40
54
|
var _time = dateUtil.format(date, dateUtil.TIME_FORMAT, options);
|
41
|
-
if (typeof disabledTime === 'function') return disabledTime(_time);
|
55
|
+
if (typeof disabledTime === 'function') return disabledTime(_time, position, rangeDate === null || rangeDate === void 0 ? void 0 : rangeDate[0], rangeDate === null || rangeDate === void 0 ? void 0 : rangeDate[1]);
|
42
56
|
return disabledTime === _time;
|
43
57
|
}
|
44
58
|
var isDis = disabled && typeof disabled === 'function' ? disabled(date) : false;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { DateTimeType } from "./util";
|
1
2
|
export interface UseTimeProps {
|
2
3
|
format: string;
|
3
4
|
options: {
|
@@ -11,9 +12,12 @@ export interface UseTimeProps {
|
|
11
12
|
staticMin?: Date;
|
12
13
|
staticMax?: Date;
|
13
14
|
disabled?: boolean | ((date: Date) => boolean);
|
14
|
-
disabledTime?: string | ((time: string) => boolean);
|
15
|
+
disabledTime?: string | ((time: string, type?: 'start' | 'end', value0?: Date, value1?: Date) => boolean);
|
15
16
|
minuteStep?: number;
|
16
17
|
hourStep?: number;
|
17
18
|
secondStep?: number;
|
19
|
+
position?: 'start' | 'end';
|
20
|
+
rangeDate?: Array<Date | undefined>;
|
21
|
+
defaultTime?: DateTimeType;
|
18
22
|
}
|
19
23
|
//# sourceMappingURL=use-time.type.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-time.type.d.ts","sourceRoot":"","sources":["use-time.type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE;QACP,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAChC,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC;IAC/C,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;
|
1
|
+
{"version":3,"file":"use-time.type.d.ts","sourceRoot":"","sources":["use-time.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE;QACP,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAChC,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC;IAC/C,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC;IAC1G,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,YAAY,CAAC;CAC5B"}
|
@@ -20,7 +20,13 @@ declare function isSameWeek(date1: Date, date2: Date, options: DateOptions): boo
|
|
20
20
|
declare function isSameQuarter(date1: Date, date2: Date, options: DateOptions): boolean;
|
21
21
|
declare function isSameYear(date1: Date, date2: Date, options: DateOptions): boolean;
|
22
22
|
declare function isValid(date: DateTimeType): boolean;
|
23
|
-
|
23
|
+
/**
|
24
|
+
* @param date 日期字符串
|
25
|
+
* @param fmt 日期格式
|
26
|
+
* @param isLoose 是否为宽松模式
|
27
|
+
* @returns 是否为有效日期
|
28
|
+
*/
|
29
|
+
declare function isValidString(date: string, fmt: string, isLoose?: boolean): boolean;
|
24
30
|
declare function parse(d: string, fmt?: string, options?: DateOptions): Date;
|
25
31
|
declare function toDate(day: DateTimeType, options?: DateOptions): Date;
|
26
32
|
declare function getDaysOfMonth(dirtyDate: DateTimeType, options: DateOptions): Date[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":"AAgBA,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,I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E,IAAI,EAAE,OAAO,EAAE,WAAW,UAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBD,wBAsCE"}
|
@@ -155,8 +155,18 @@ function isValid(date) {
|
|
155
155
|
if (!(date instanceof Date)) return false;
|
156
156
|
return dayjs(date).isValid();
|
157
157
|
}
|
158
|
-
|
158
|
+
|
159
|
+
/**
|
160
|
+
* @param date 日期字符串
|
161
|
+
* @param fmt 日期格式
|
162
|
+
* @param isLoose 是否为宽松模式
|
163
|
+
* @returns 是否为有效日期
|
164
|
+
*/
|
165
|
+
function isValidString(date, fmt, isLoose) {
|
159
166
|
if (!date) return false;
|
167
|
+
if (isLoose) {
|
168
|
+
return dayjs(date).isValid();
|
169
|
+
}
|
160
170
|
return dayjs(date, fmt, true).isValid();
|
161
171
|
}
|
162
172
|
function parse(d, fmt, options) {
|
@@ -206,7 +216,16 @@ function toDate(day, options) {
|
|
206
216
|
if (!day) return new Date('');
|
207
217
|
if (day instanceof Date) return dayjs(day).toDate();
|
208
218
|
if (typeof day === 'number') return new Date(day);
|
209
|
-
if (typeof day === 'string')
|
219
|
+
if (typeof day === 'string') {
|
220
|
+
// 当 day 只有时间部分,没有日期部分时
|
221
|
+
if (/^\d{1,2}(:\d{2}(:\d{2})?)?$/.test(day)) {
|
222
|
+
var today = new Date();
|
223
|
+
var todayStr = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
|
224
|
+
var dayStr = todayStr + ' ' + day;
|
225
|
+
return transDateWithZone(dayjs(dayStr).toDate(), options, true);
|
226
|
+
}
|
227
|
+
return transDateWithZone(dayjs(day).toDate(), options, true);
|
228
|
+
}
|
210
229
|
return dayjs(day).toDate();
|
211
230
|
}
|
212
231
|
function getDaysOfMonth(dirtyDate, options) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["Provider.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["Provider.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,eAAO,MAAM,QAAQ,UAAW,aAAa,4CAa5C,CAAC"}
|
@@ -2,6 +2,7 @@ import { FormBindContext } from "./form-bind-context";
|
|
2
2
|
import { FormFuncContext } from "./form-func-context";
|
3
3
|
import { FormConfigContext } from "./form-config-context";
|
4
4
|
import FieldSetContext from "./use-form-fieldset/fieldset-context";
|
5
|
+
import { FormSchemaContext } from "./form-schema-context";
|
5
6
|
import * as React from 'react';
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
7
8
|
var topPath = {
|
@@ -12,7 +13,8 @@ export var Provider = function Provider(props) {
|
|
12
13
|
var children = props.children,
|
13
14
|
formConfig = props.formConfig,
|
14
15
|
formValue = props.formValue,
|
15
|
-
formFunc = props.formFunc
|
16
|
+
formFunc = props.formFunc,
|
17
|
+
formSchema = props.formSchema;
|
16
18
|
return /*#__PURE__*/_jsx(FormFuncContext.Provider, {
|
17
19
|
value: formFunc,
|
18
20
|
children: /*#__PURE__*/_jsx(FormBindContext.Provider, {
|
@@ -21,7 +23,10 @@ export var Provider = function Provider(props) {
|
|
21
23
|
value: topPath,
|
22
24
|
children: /*#__PURE__*/_jsx(FormConfigContext.Provider, {
|
23
25
|
value: formConfig,
|
24
|
-
children:
|
26
|
+
children: /*#__PURE__*/_jsx(FormSchemaContext.Provider, {
|
27
|
+
value: formSchema,
|
28
|
+
children: children
|
29
|
+
})
|
25
30
|
})
|
26
31
|
})
|
27
32
|
})
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { SchemaBuilder } from './use-form-schema/form-schema-builder';
|
3
|
+
export type FormSchemaContextValueType = SchemaBuilder;
|
4
|
+
export declare const FormSchemaContext: React.Context<SchemaBuilder | null>;
|
5
|
+
export declare const useFormSchema: () => SchemaBuilder | null;
|
6
|
+
//# sourceMappingURL=form-schema-context.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"form-schema-context.d.ts","sourceRoot":"","sources":["form-schema-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAEtE,MAAM,MAAM,0BAA0B,GAAG,aAAa,CAAA;AAEtD,eAAO,MAAM,iBAAiB,qCAA+D,CAAC;AAC9F,eAAO,MAAM,aAAa,4BAA4C,CAAC"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
import * as React from 'react';
|
4
|
+
export var FormSchemaContext = /*#__PURE__*/React.createContext(null);
|
5
|
+
export var useFormSchema = function useFormSchema() {
|
6
|
+
return React.useContext(FormSchemaContext);
|
7
|
+
};
|
8
|
+
FormSchemaContext.displayName = 'FormSchemaContext';
|
@@ -3,8 +3,10 @@ export * from './use-form-item';
|
|
3
3
|
export * from './use-form-fieldset';
|
4
4
|
export * from './use-form-flow';
|
5
5
|
export * from './use-form-context';
|
6
|
+
export * from './use-form-schema';
|
6
7
|
export { default, default as useForm } from './use-form';
|
7
8
|
export { useFormConfig } from './form-config-context';
|
8
9
|
export { useFormFunc } from './form-func-context';
|
10
|
+
export { useFormSchema } from './form-schema-context';
|
9
11
|
export type { BaseFormProps, FormCommonConfig, FormLabelConfig } from './use-form.type';
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
@@ -4,6 +4,8 @@ export * from "./use-form-item";
|
|
4
4
|
export * from "./use-form-fieldset";
|
5
5
|
export * from "./use-form-flow";
|
6
6
|
export * from "./use-form-context";
|
7
|
+
export * from "./use-form-schema";
|
7
8
|
export { default, default as useForm } from "./use-form";
|
8
9
|
export { useFormConfig } from "./form-config-context";
|
9
|
-
export { useFormFunc } from "./form-func-context";
|
10
|
+
export { useFormFunc } from "./form-func-context";
|
11
|
+
export { useFormSchema } from "./form-schema-context";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-context.d.ts","sourceRoot":"","sources":["use-form-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,eAAO,MAAM,WAAW,oBAA+B,CAAC;AAExD,wBAAgB,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,
|
1
|
+
{"version":3,"file":"use-form-context.d.ts","sourceRoot":"","sources":["use-form-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,eAAO,MAAM,WAAW,oBAA+B,CAAC;AAExD,wBAAgB,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAG7E;AAED,wBAAgB,eAAe,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAG/C"}
|
@@ -1,11 +1,17 @@
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
4
|
+
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; }
|
5
|
+
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; } }
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
1
7
|
import React from 'react';
|
2
8
|
export var FormContext = /*#__PURE__*/React.createContext({});
|
3
9
|
export function useFormRef() {
|
4
|
-
var
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
return [
|
10
|
+
var _React$useState = React.useState({}),
|
11
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
12
|
+
formRef = _React$useState2[0],
|
13
|
+
setFormRef = _React$useState2[1];
|
14
|
+
return [formRef, setFormRef];
|
9
15
|
}
|
10
16
|
export function useFormInstance() {
|
11
17
|
var formCtx = React.useContext(FormContext);
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { SchemaProperty } from './use-form-schema/form-schema-builder';
|
1
2
|
export interface FormRef<Value = any> {
|
2
3
|
/**
|
3
4
|
* @en return form value
|
@@ -51,5 +52,10 @@ export interface FormRef<Value = any> {
|
|
51
52
|
* @cn 滚动到指定字段
|
52
53
|
*/
|
53
54
|
scrollToField: (name: string, scrollIntoViewOptions?: ScrollIntoViewOptions) => void;
|
55
|
+
/**
|
56
|
+
* @en get form schema
|
57
|
+
* @cn 获取表单的 schema
|
58
|
+
*/
|
59
|
+
getFormSchema: () => SchemaProperty | undefined;
|
54
60
|
}
|
55
61
|
//# sourceMappingURL=use-form-context.type.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-context.type.d.ts","sourceRoot":"","sources":["use-form-context.type.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,OAAO,CAAC,KAAK,GAAG,GAAG;IAClC;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,GAAG,KAAK,CAAC;IACzC;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IACzD;;;OAGG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC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AAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACtE;;;OAGG;IACH,uBAAuB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACrE;;;OAGG;IACH,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;OAGG;IACH,GAAG,EAAE,CAAC,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7C;;;OAGG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,qBAAqB,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAErF;;;OAGG;IACH,aAAa,EAAE,MAAM,cAAc,GAAG,SAAS,CAAC;CACjD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,oBAAoB,EAAsB,MAAM,yBAAyB,CAAC;AA4BnF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;
|
1
|
+
{"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,oBAAoB,EAAsB,MAAM,yBAAyB,CAAC;AA4BnF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBA0JpC,CAAC,YAAY,GAAG,EAAE;;;;;EA4DrD"}
|
@@ -48,7 +48,8 @@ export default function useFormControl(props) {
|
|
48
48
|
defaultValue = props.defaultValue,
|
49
49
|
rules = props.rules,
|
50
50
|
onError = props.onError,
|
51
|
-
getValidateProps = props.getValidateProps
|
51
|
+
getValidateProps = props.getValidateProps,
|
52
|
+
clearToUndefined = props.clearToUndefined;
|
52
53
|
var _useFieldSetConsumer = useFieldSetConsumer({
|
53
54
|
name: props.name,
|
54
55
|
bind: props.bind
|
@@ -106,7 +107,11 @@ export default function useFormControl(props) {
|
|
106
107
|
var nextValue = [];
|
107
108
|
name.forEach(function (n, index) {
|
108
109
|
if (_value[index] === undefined && dv[index] !== undefined) {
|
109
|
-
|
110
|
+
if (clearToUndefined) {
|
111
|
+
nextValue[index] = undefined;
|
112
|
+
} else {
|
113
|
+
nextValue[index] = dv[index];
|
114
|
+
}
|
110
115
|
} else {
|
111
116
|
nextValue[index] = _value[index];
|
112
117
|
}
|
@@ -120,7 +125,11 @@ export default function useFormControl(props) {
|
|
120
125
|
}
|
121
126
|
if (!shallowEqual(_value2, latestInfo.valueState)) {
|
122
127
|
if (_value2 === undefined && defaultValue !== undefined) {
|
123
|
-
|
128
|
+
if (clearToUndefined) {
|
129
|
+
setValueState(undefined);
|
130
|
+
} else {
|
131
|
+
setValueState(defaultValue);
|
132
|
+
}
|
124
133
|
} else {
|
125
134
|
setValueState(_value2);
|
126
135
|
}
|
@@ -24,14 +24,20 @@ export interface BaseFormControlProps<T> {
|
|
24
24
|
*/
|
25
25
|
onError: ((error: Error | undefined) => void) | undefined;
|
26
26
|
/**
|
27
|
-
* @en
|
28
|
-
* @cn
|
27
|
+
* @en Array of field names that should be re-validated when current field's value changes. Enables field linkage validation for dependent fields. Commonly used in scenarios like password confirmation, related dropdown selections, or interdependent form calculations
|
28
|
+
* @cn 当前字段值改变时需要重新校验的字段名称数组。启用字段间的联动校验功能。常用于密码确认、关联下拉选择或相互依赖的表单计算等场景
|
29
29
|
*/
|
30
30
|
bind: string[] | undefined;
|
31
31
|
/**
|
32
32
|
* @private 内部属性 for validate
|
33
33
|
*/
|
34
34
|
getValidateProps: (() => ObjectType) | undefined;
|
35
|
+
/**
|
36
|
+
* @en If set to true, the form will not automatically delete the data after the component is uninstalled
|
37
|
+
* @cn 设置为 true 组件后,有defaultValue时,允许undefined作为最终值
|
38
|
+
* @version 3.8.0
|
39
|
+
*/
|
40
|
+
clearToUndefined?: boolean;
|
35
41
|
}
|
36
42
|
export interface FormControlContext {
|
37
43
|
mounted: boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-control.type.d.ts","sourceRoot":"","sources":["use-form-control.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB;;;OAGG;IACH,YAAY,EAAE,CAAC,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC5D;;;OAGG;IACH,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC;;;;OAIG;IACH,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACnC;;OAEG;IACH,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC1D;;;OAGG;IACH,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC3B;;OAEG;IACH,gBAAgB,EAAE,CAAC,MAAM,UAAU,CAAC,GAAG,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"use-form-control.type.d.ts","sourceRoot":"","sources":["use-form-control.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB;;;OAGG;IACH,YAAY,EAAE,CAAC,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC5D;;;OAGG;IACH,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC;;;;OAIG;IACH,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACnC;;OAEG;IACH,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC1D;;;OAGG;IACH,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC3B;;OAEG;IACH,gBAAgB,EAAE,CAAC,MAAM,UAAU,CAAC,GAAG,SAAS,CAAC;IAEjD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;CAClB"}
|
@@ -1,7 +1,15 @@
|
|
1
1
|
export interface FormDatum {
|
2
|
+
/**
|
3
|
+
* @en Set form field values. Accepts either an object to set multiple fields at once, or a field name with value to set a single field. Field names support nested paths like "user.name" or "items[0].price". Changes trigger form validation and re-render of affected Flow components
|
4
|
+
* @cn 设置表单字段值。可以接收对象以批量设置多个字段,或接收字段名和值以设置单个字段。字段名支持嵌套路径如 "user.name" 或 "items[0].price"。更改会触发表单校验和相关 Flow 组件的重新渲染
|
5
|
+
*/
|
2
6
|
set: (vals: {
|
3
7
|
[name: string]: any;
|
4
8
|
} | string, value?: any) => void;
|
9
|
+
/**
|
10
|
+
* @en Get form field value by name. When no name is provided, returns the entire form data object. Supports nested paths like "user.name" or "items[0].price" to access deeply nested values
|
11
|
+
* @cn 根据名称获取表单字段值。未提供名称时返回整个表单数据对象。支持嵌套路径如 "user.name" 或 "items[0].price" 来访问深层嵌套的值
|
12
|
+
*/
|
5
13
|
get: (name?: string) => any;
|
6
14
|
}
|
7
15
|
declare const useFormDatum: () => FormDatum | undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AAED,QAAA,MAAM,YAAY,6BAgBjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
1
|
+
{"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE;;;OAGG;IACH,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AAED,QAAA,MAAM,YAAY,6BAgBjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"form-item-context.d.ts","sourceRoot":"","sources":["form-item-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,eAAe,yCAE1B,CAAC"}
|
1
|
+
{"version":3,"file":"form-item-context.d.ts","sourceRoot":"","sources":["form-item-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,eAAe,yCAE1B,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
@@ -3,7 +3,7 @@ import type { FormItemContextValueType } from './form-item-context';
|
|
3
3
|
declare const UseFormItem: () => {
|
4
4
|
Provider: React.Provider<FormItemContextValueType>;
|
5
5
|
ProviderValue: FormItemContextValueType;
|
6
|
-
errors:
|
6
|
+
errors: Error[];
|
7
7
|
labelConfig: import("..").FormCommonConfig;
|
8
8
|
attributes: Record<string, string>;
|
9
9
|
showError: boolean;
|
@@ -0,0 +1,50 @@
|
|
1
|
+
interface SchemaMeta {
|
2
|
+
type?: string;
|
3
|
+
required?: boolean;
|
4
|
+
title?: string;
|
5
|
+
format?: string;
|
6
|
+
items?: any;
|
7
|
+
enum?: any[] | {
|
8
|
+
anyOf?: any[];
|
9
|
+
oneOf?: any[];
|
10
|
+
};
|
11
|
+
description?: string;
|
12
|
+
[key: string]: any;
|
13
|
+
}
|
14
|
+
export interface SchemaProperty {
|
15
|
+
type?: string;
|
16
|
+
properties?: Record<string, SchemaProperty>;
|
17
|
+
items?: SchemaProperty;
|
18
|
+
required?: string[];
|
19
|
+
title?: string;
|
20
|
+
description?: string;
|
21
|
+
format?: string;
|
22
|
+
enum?: any;
|
23
|
+
[key: string]: any;
|
24
|
+
}
|
25
|
+
export declare class SchemaBuilder {
|
26
|
+
private schema;
|
27
|
+
constructor(formName: string);
|
28
|
+
updateSchema({ path, meta }: {
|
29
|
+
path: string;
|
30
|
+
meta: SchemaMeta;
|
31
|
+
}): void;
|
32
|
+
/**
|
33
|
+
* 根据组件信息构建 schema meta
|
34
|
+
*/
|
35
|
+
buildSchemaFromComponent(params: {
|
36
|
+
componentElement: any;
|
37
|
+
rules?: any[];
|
38
|
+
label?: string;
|
39
|
+
finalFieldId?: string;
|
40
|
+
separator?: string;
|
41
|
+
}): SchemaMeta;
|
42
|
+
parsePath(path?: string): string[] | null;
|
43
|
+
mergeSchema(currentSchema: SchemaProperty, pathSegments: string[], meta: SchemaMeta): void;
|
44
|
+
handleArraySegment(currentSchema: SchemaProperty, remainingSegments: string[], meta: SchemaMeta): void;
|
45
|
+
handleObjectProperty(currentSchema: SchemaProperty, propertyName: string, remainingSegments: string[], meta: SchemaMeta): void;
|
46
|
+
handleRequired(parentSchema: SchemaProperty, propertyName: string, isRequired: boolean): void;
|
47
|
+
getFormSchema(): SchemaProperty;
|
48
|
+
}
|
49
|
+
export {};
|
50
|
+
//# sourceMappingURL=form-schema-builder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"form-schema-builder.d.ts","sourceRoot":"","sources":["form-schema-builder.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,IAAI,CAAC,E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