@tachybase/components 0.23.8
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/.turbo/turbo-build.log +9 -0
- package/LICENSE +201 -0
- package/lib/__builtins__/dayjs.d.ts +4 -0
- package/lib/__builtins__/dayjs.js +95 -0
- package/lib/__builtins__/hooks/index.d.ts +4 -0
- package/lib/__builtins__/hooks/index.js +27 -0
- package/lib/__builtins__/hooks/useClickAway.d.ts +5 -0
- package/lib/__builtins__/hooks/useClickAway.js +64 -0
- package/lib/__builtins__/hooks/useConfig.d.ts +1 -0
- package/lib/__builtins__/hooks/useConfig.js +31 -0
- package/lib/__builtins__/hooks/usePrefixCls.d.ts +3 -0
- package/lib/__builtins__/hooks/usePrefixCls.js +38 -0
- package/lib/__builtins__/hooks/useToken.d.ts +6 -0
- package/lib/__builtins__/hooks/useToken.js +28 -0
- package/lib/__builtins__/index.d.ts +7 -0
- package/lib/__builtins__/index.js +33 -0
- package/lib/__builtins__/loading.d.ts +1 -0
- package/lib/__builtins__/loading.js +40 -0
- package/lib/__builtins__/pickDataProps.d.ts +1 -0
- package/lib/__builtins__/pickDataProps.js +36 -0
- package/lib/__builtins__/portal.d.ts +10 -0
- package/lib/__builtins__/portal.js +89 -0
- package/lib/__builtins__/render.d.ts +9 -0
- package/lib/__builtins__/render.js +99 -0
- package/lib/__builtins__/sort.d.ts +73 -0
- package/lib/__builtins__/sort.js +126 -0
- package/lib/__builtins__/style.d.ts +23 -0
- package/lib/__builtins__/style.js +88 -0
- package/lib/array-base/index.d.ts +64 -0
- package/lib/array-base/index.js +345 -0
- package/lib/array-base/style.d.ts +2 -0
- package/lib/array-base/style.js +68 -0
- package/lib/array-cards/index.d.ts +5 -0
- package/lib/array-cards/index.js +166 -0
- package/lib/array-cards/style.d.ts +2 -0
- package/lib/array-cards/style.js +37 -0
- package/lib/array-collapse/index.d.ts +10 -0
- package/lib/array-collapse/index.js +199 -0
- package/lib/array-collapse/style.d.ts +2 -0
- package/lib/array-collapse/style.js +33 -0
- package/lib/array-items/index.d.ts +8 -0
- package/lib/array-items/index.js +122 -0
- package/lib/array-items/style.d.ts +2 -0
- package/lib/array-items/style.js +82 -0
- package/lib/array-table/index.d.ts +9 -0
- package/lib/array-table/index.js +376 -0
- package/lib/array-table/style.d.ts +2 -0
- package/lib/array-table/style.js +71 -0
- package/lib/array-tabs/index.d.ts +4 -0
- package/lib/array-tabs/index.js +102 -0
- package/lib/cascader/index.d.ts +12 -0
- package/lib/cascader/index.js +58 -0
- package/lib/checkbox/index.d.ts +5 -0
- package/lib/checkbox/index.js +51 -0
- package/lib/code-mirror/index.d.ts +3 -0
- package/lib/code-mirror/index.js +91 -0
- package/lib/date-picker/index.d.ts +2 -0
- package/lib/date-picker/index.js +70 -0
- package/lib/date-picker/style.d.ts +1 -0
- package/lib/date-picker/style.js +1 -0
- package/lib/editable/index.d.ts +8 -0
- package/lib/editable/index.js +181 -0
- package/lib/editable/style.d.ts +2 -0
- package/lib/editable/style.js +69 -0
- package/lib/form/index.d.ts +12 -0
- package/lib/form/index.js +71 -0
- package/lib/form-button-group/index.d.ts +27 -0
- package/lib/form-button-group/index.js +148 -0
- package/lib/form-button-group/style.d.ts +2 -0
- package/lib/form-button-group/style.js +41 -0
- package/lib/form-collapse/index.d.ts +28 -0
- package/lib/form-collapse/index.js +150 -0
- package/lib/form-dialog/index.d.ts +26 -0
- package/lib/form-dialog/index.js +194 -0
- package/lib/form-drawer/index.d.ts +25 -0
- package/lib/form-drawer/index.js +187 -0
- package/lib/form-grid/index.d.ts +34 -0
- package/lib/form-grid/index.js +108 -0
- package/lib/form-grid/style.d.ts +2 -0
- package/lib/form-grid/style.js +31 -0
- package/lib/form-item/hooks/index.d.ts +2 -0
- package/lib/form-item/hooks/index.js +23 -0
- package/lib/form-item/hooks/useFormItemLayout.d.ts +37 -0
- package/lib/form-item/hooks/useFormItemLayout.js +66 -0
- package/lib/form-item/hooks/useOverflow.d.ts +5 -0
- package/lib/form-item/hooks/useOverflow.js +55 -0
- package/lib/form-item/index.d.ts +11 -0
- package/lib/form-item/index.js +303 -0
- package/lib/form-item/style/animation.d.ts +2 -0
- package/lib/form-item/style/animation.js +57 -0
- package/lib/form-item/style/grid.d.ts +2 -0
- package/lib/form-item/style/grid.js +50 -0
- package/lib/form-item/style/index.d.ts +2 -0
- package/lib/form-item/style/index.js +387 -0
- package/lib/form-item/style/other.d.ts +2 -0
- package/lib/form-item/style/other.js +490 -0
- package/lib/form-item/types.d.ts +35 -0
- package/lib/form-item/types.js +15 -0
- package/lib/form-layout/index.d.ts +74 -0
- package/lib/form-layout/index.js +96 -0
- package/lib/form-layout/useResponsiveFormLayout.d.ts +17 -0
- package/lib/form-layout/useResponsiveFormLayout.js +89 -0
- package/lib/form-step/index.d.ts +27 -0
- package/lib/form-step/index.js +154 -0
- package/lib/form-tab/index.d.ts +19 -0
- package/lib/form-tab/index.js +150 -0
- package/lib/index.d.ts +38 -0
- package/lib/index.js +95 -0
- package/lib/input/index.d.ts +7 -0
- package/lib/input/index.js +57 -0
- package/lib/lightbox/constant.d.ts +21 -0
- package/lib/lightbox/constant.js +79 -0
- package/lib/lightbox/index.d.ts +2 -0
- package/lib/lightbox/index.js +37 -0
- package/lib/lightbox/interface.d.ts +43 -0
- package/lib/lightbox/interface.js +15 -0
- package/lib/lightbox/react-image-lightbox.d.ts +197 -0
- package/lib/lightbox/react-image-lightbox.js +1431 -0
- package/lib/lightbox/style.css +305 -0
- package/lib/lightbox/util.d.ts +7 -0
- package/lib/lightbox/util.js +71 -0
- package/lib/number-picker/index.d.ts +4 -0
- package/lib/number-picker/index.js +32 -0
- package/lib/password/PasswordStrength.d.ts +9 -0
- package/lib/password/PasswordStrength.js +188 -0
- package/lib/password/index.d.ts +7 -0
- package/lib/password/index.js +85 -0
- package/lib/preview-text/index.d.ts +12 -0
- package/lib/preview-text/index.js +263 -0
- package/lib/preview-text/style.d.ts +2 -0
- package/lib/preview-text/style.js +37 -0
- package/lib/radio/index.d.ts +8 -0
- package/lib/radio/index.js +51 -0
- package/lib/reset/index.d.ts +10 -0
- package/lib/reset/index.js +67 -0
- package/lib/select/index.d.ts +4 -0
- package/lib/select/index.js +59 -0
- package/lib/select-table/hooks/index.d.ts +5 -0
- package/lib/select-table/hooks/index.js +29 -0
- package/lib/select-table/hooks/useCheckSlackly.d.ts +16 -0
- package/lib/select-table/hooks/useCheckSlackly.js +57 -0
- package/lib/select-table/hooks/useFilterOptions.d.ts +3 -0
- package/lib/select-table/hooks/useFilterOptions.js +97 -0
- package/lib/select-table/hooks/useFlatOptions.d.ts +3 -0
- package/lib/select-table/hooks/useFlatOptions.js +46 -0
- package/lib/select-table/hooks/useSize.d.ts +9 -0
- package/lib/select-table/hooks/useSize.js +48 -0
- package/lib/select-table/hooks/useTitleAddon.d.ts +7 -0
- package/lib/select-table/hooks/useTitleAddon.js +90 -0
- package/lib/select-table/index.d.ts +27 -0
- package/lib/select-table/index.js +339 -0
- package/lib/select-table/style.d.ts +2 -0
- package/lib/select-table/style.js +33 -0
- package/lib/select-table/utils.d.ts +78 -0
- package/lib/select-table/utils.js +166 -0
- package/lib/space/index.d.ts +4 -0
- package/lib/space/index.js +49 -0
- package/lib/submit/index.d.ts +11 -0
- package/lib/submit/index.js +67 -0
- package/lib/switch/index.d.ts +2 -0
- package/lib/switch/index.js +44 -0
- package/lib/time-picker/index.d.ts +2 -0
- package/lib/time-picker/index.js +60 -0
- package/lib/time-picker/style.d.ts +1 -0
- package/lib/time-picker/style.js +1 -0
- package/lib/transfer/index.d.ts +2 -0
- package/lib/transfer/index.js +56 -0
- package/lib/tree-select/index.d.ts +2 -0
- package/lib/tree-select/index.js +58 -0
- package/lib/upload/index.d.ts +18 -0
- package/lib/upload/index.js +159 -0
- package/lib/upload/placeholder.d.ts +4 -0
- package/lib/upload/placeholder.js +88 -0
- package/package.json +31 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var form_layout_exports = {};
|
|
30
|
+
__export(form_layout_exports, {
|
|
31
|
+
FormLayout: () => FormLayout,
|
|
32
|
+
FormLayoutDeepContext: () => FormLayoutDeepContext,
|
|
33
|
+
FormLayoutShallowContext: () => FormLayoutShallowContext,
|
|
34
|
+
default: () => form_layout_default,
|
|
35
|
+
useFormDeepLayout: () => useFormDeepLayout,
|
|
36
|
+
useFormLayout: () => useFormLayout,
|
|
37
|
+
useFormShallowLayout: () => useFormShallowLayout
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(form_layout_exports);
|
|
40
|
+
var import_react = __toESM(require("react"));
|
|
41
|
+
var import_classnames = __toESM(require("classnames"));
|
|
42
|
+
var import_builtins = require("../__builtins__");
|
|
43
|
+
var import_useResponsiveFormLayout = require("./useResponsiveFormLayout");
|
|
44
|
+
const FormLayoutDeepContext = (0, import_react.createContext)({});
|
|
45
|
+
const FormLayoutShallowContext = (0, import_react.createContext)({});
|
|
46
|
+
const useFormDeepLayout = /* @__PURE__ */ __name(() => (0, import_react.useContext)(FormLayoutDeepContext), "useFormDeepLayout");
|
|
47
|
+
const useFormShallowLayout = /* @__PURE__ */ __name(() => (0, import_react.useContext)(FormLayoutShallowContext), "useFormShallowLayout");
|
|
48
|
+
const useFormLayout = /* @__PURE__ */ __name(() => ({
|
|
49
|
+
...useFormDeepLayout(),
|
|
50
|
+
...useFormShallowLayout()
|
|
51
|
+
}), "useFormLayout");
|
|
52
|
+
const FormLayout = /* @__PURE__ */ __name(({ shallow = true, children, prefixCls, className, style, ...otherProps }) => {
|
|
53
|
+
const { ref, props } = (0, import_useResponsiveFormLayout.useResponsiveFormLayout)(otherProps);
|
|
54
|
+
const deepLayout = useFormDeepLayout();
|
|
55
|
+
const formPrefixCls = (0, import_builtins.usePrefixCls)("form", { prefixCls });
|
|
56
|
+
const layoutPrefixCls = (0, import_builtins.usePrefixCls)("formily-layout", { prefixCls });
|
|
57
|
+
const layoutClassName = (0, import_classnames.default)(
|
|
58
|
+
layoutPrefixCls,
|
|
59
|
+
{
|
|
60
|
+
[`${formPrefixCls}-${props.layout}`]: true,
|
|
61
|
+
[`${formPrefixCls}-rtl`]: props.direction === "rtl",
|
|
62
|
+
[`${formPrefixCls}-${props.size}`]: props.size
|
|
63
|
+
},
|
|
64
|
+
className
|
|
65
|
+
);
|
|
66
|
+
const renderChildren = /* @__PURE__ */ __name(() => {
|
|
67
|
+
const newDeepLayout = {
|
|
68
|
+
...deepLayout
|
|
69
|
+
};
|
|
70
|
+
if (!shallow) {
|
|
71
|
+
Object.assign(newDeepLayout, props);
|
|
72
|
+
} else {
|
|
73
|
+
if (props.size) {
|
|
74
|
+
newDeepLayout.size = props.size;
|
|
75
|
+
}
|
|
76
|
+
if (props.colon) {
|
|
77
|
+
newDeepLayout.colon = props.colon;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return /* @__PURE__ */ import_react.default.createElement(FormLayoutDeepContext.Provider, { value: newDeepLayout }, /* @__PURE__ */ import_react.default.createElement(FormLayoutShallowContext.Provider, { value: shallow ? props : void 0 }, children));
|
|
81
|
+
}, "renderChildren");
|
|
82
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { ref, className: layoutClassName, style }, renderChildren());
|
|
83
|
+
}, "FormLayout");
|
|
84
|
+
FormLayout.useFormDeepLayout = useFormDeepLayout;
|
|
85
|
+
FormLayout.useFormShallowLayout = useFormShallowLayout;
|
|
86
|
+
FormLayout.useFormLayout = useFormLayout;
|
|
87
|
+
var form_layout_default = FormLayout;
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
FormLayout,
|
|
91
|
+
FormLayoutDeepContext,
|
|
92
|
+
FormLayoutShallowContext,
|
|
93
|
+
useFormDeepLayout,
|
|
94
|
+
useFormLayout,
|
|
95
|
+
useFormShallowLayout
|
|
96
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface IProps {
|
|
2
|
+
breakpoints?: number[];
|
|
3
|
+
layout?: 'vertical' | 'horizontal' | 'inline' | ('vertical' | 'horizontal' | 'inline')[];
|
|
4
|
+
labelCol?: number | number[];
|
|
5
|
+
wrapperCol?: number | number[];
|
|
6
|
+
labelAlign?: 'right' | 'left' | ('right' | 'left')[];
|
|
7
|
+
wrapperAlign?: 'right' | 'left' | ('right' | 'left')[];
|
|
8
|
+
[props: string]: any;
|
|
9
|
+
}
|
|
10
|
+
interface IUseResponsiveFormLayout {
|
|
11
|
+
(props: IProps): {
|
|
12
|
+
ref: React.RefObject<HTMLDivElement>;
|
|
13
|
+
props: any;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare const useResponsiveFormLayout: IUseResponsiveFormLayout;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useResponsiveFormLayout_exports = {};
|
|
20
|
+
__export(useResponsiveFormLayout_exports, {
|
|
21
|
+
useResponsiveFormLayout: () => useResponsiveFormLayout
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useResponsiveFormLayout_exports);
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
var import_schema = require("@tachybase/schema");
|
|
26
|
+
const calcBreakpointIndex = /* @__PURE__ */ __name((breakpoints, width) => {
|
|
27
|
+
if (!breakpoints) return;
|
|
28
|
+
for (let i = 0; i < breakpoints.length; i++) {
|
|
29
|
+
if (width <= breakpoints[i]) {
|
|
30
|
+
return i;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}, "calcBreakpointIndex");
|
|
34
|
+
const calcFactor = /* @__PURE__ */ __name((value, breakpointIndex) => {
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
if (breakpointIndex === -1) return value[0];
|
|
37
|
+
return value[breakpointIndex || value.length - 1] ?? value[value.length - 1];
|
|
38
|
+
} else {
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
}, "calcFactor");
|
|
42
|
+
const factor = /* @__PURE__ */ __name((value, breakpointIndex) => (0, import_schema.isValid)(value) ? calcFactor(value, breakpointIndex) : value, "factor");
|
|
43
|
+
const calculateProps = /* @__PURE__ */ __name((target, props) => {
|
|
44
|
+
const { clientWidth } = target;
|
|
45
|
+
const { breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol, ...otherProps } = props;
|
|
46
|
+
const breakpointIndex = calcBreakpointIndex(breakpoints, clientWidth);
|
|
47
|
+
return {
|
|
48
|
+
layout: factor(layout, breakpointIndex),
|
|
49
|
+
labelAlign: factor(labelAlign, breakpointIndex),
|
|
50
|
+
wrapperAlign: factor(wrapperAlign, breakpointIndex),
|
|
51
|
+
labelCol: factor(labelCol, breakpointIndex),
|
|
52
|
+
wrapperCol: factor(wrapperCol, breakpointIndex),
|
|
53
|
+
...otherProps
|
|
54
|
+
};
|
|
55
|
+
}, "calculateProps");
|
|
56
|
+
const useResponsiveFormLayout = /* @__PURE__ */ __name((props) => {
|
|
57
|
+
const ref = (0, import_react.useRef)(null);
|
|
58
|
+
const { breakpoints } = props;
|
|
59
|
+
const [layoutProps, setLayout] = (0, import_react.useState)(props);
|
|
60
|
+
const updateUI = /* @__PURE__ */ __name(() => {
|
|
61
|
+
if (ref.current) {
|
|
62
|
+
setLayout(calculateProps(ref.current, props));
|
|
63
|
+
}
|
|
64
|
+
}, "updateUI");
|
|
65
|
+
(0, import_react.useEffect)(() => {
|
|
66
|
+
const observer = /* @__PURE__ */ __name(() => {
|
|
67
|
+
updateUI();
|
|
68
|
+
}, "observer");
|
|
69
|
+
const resizeObserver = new ResizeObserver(observer);
|
|
70
|
+
if (ref.current) {
|
|
71
|
+
resizeObserver.observe(ref.current);
|
|
72
|
+
}
|
|
73
|
+
updateUI();
|
|
74
|
+
return () => {
|
|
75
|
+
resizeObserver.disconnect();
|
|
76
|
+
};
|
|
77
|
+
}, []);
|
|
78
|
+
if (!(0, import_schema.isArr)(breakpoints)) {
|
|
79
|
+
return { ref, props };
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
ref,
|
|
83
|
+
props: layoutProps
|
|
84
|
+
};
|
|
85
|
+
}, "useResponsiveFormLayout");
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
useResponsiveFormLayout
|
|
89
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Form, Schema, SchemaKey, VoidField } from '@tachybase/schema';
|
|
3
|
+
import { StepProps, StepsProps } from 'antd/lib/steps';
|
|
4
|
+
export interface IFormStep {
|
|
5
|
+
connect: (steps: SchemaStep[], field: VoidField) => void;
|
|
6
|
+
current: number;
|
|
7
|
+
allowNext: boolean;
|
|
8
|
+
allowBack: boolean;
|
|
9
|
+
setCurrent(key: number): void;
|
|
10
|
+
submit: Form['submit'];
|
|
11
|
+
next(): void;
|
|
12
|
+
back(): void;
|
|
13
|
+
}
|
|
14
|
+
export interface IFormStepProps extends StepsProps {
|
|
15
|
+
formStep?: IFormStep;
|
|
16
|
+
}
|
|
17
|
+
type ComposedFormStep = React.FC<React.PropsWithChildren<IFormStepProps>> & {
|
|
18
|
+
StepPane: React.FC<React.PropsWithChildren<StepProps>>;
|
|
19
|
+
createFormStep: (defaultCurrent?: number) => IFormStep;
|
|
20
|
+
};
|
|
21
|
+
type SchemaStep = {
|
|
22
|
+
name: SchemaKey;
|
|
23
|
+
props: any;
|
|
24
|
+
schema: Schema;
|
|
25
|
+
};
|
|
26
|
+
export declare const FormStep: ComposedFormStep;
|
|
27
|
+
export default FormStep;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var form_step_exports = {};
|
|
30
|
+
__export(form_step_exports, {
|
|
31
|
+
FormStep: () => FormStep,
|
|
32
|
+
default: () => form_step_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(form_step_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_schema = require("@tachybase/schema");
|
|
37
|
+
var import_antd = require("antd");
|
|
38
|
+
var import_classnames = __toESM(require("classnames"));
|
|
39
|
+
var import_builtins = require("../__builtins__");
|
|
40
|
+
const parseSteps = /* @__PURE__ */ __name((schema) => {
|
|
41
|
+
const steps = [];
|
|
42
|
+
schema.mapProperties((schema2, name) => {
|
|
43
|
+
var _a;
|
|
44
|
+
if (((_a = schema2["x-component"]) == null ? void 0 : _a.indexOf("StepPane")) > -1) {
|
|
45
|
+
steps.push({
|
|
46
|
+
name,
|
|
47
|
+
props: schema2["x-component-props"],
|
|
48
|
+
schema: schema2
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return steps;
|
|
53
|
+
}, "parseSteps");
|
|
54
|
+
const createFormStep = /* @__PURE__ */ __name((defaultCurrent = 0) => {
|
|
55
|
+
var _a, _b, _c, _d, _e, _f;
|
|
56
|
+
const env = (0, import_schema.define)(
|
|
57
|
+
{
|
|
58
|
+
form: null,
|
|
59
|
+
field: null,
|
|
60
|
+
steps: []
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
form: import_schema.observable.ref,
|
|
64
|
+
field: import_schema.observable.ref,
|
|
65
|
+
steps: import_schema.observable.shallow
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
const setDisplay = (_b = (_a = import_schema.action).bound) == null ? void 0 : _b.call(_a, (target) => {
|
|
69
|
+
const currentStep = env.steps[target];
|
|
70
|
+
env.steps.forEach(({ name }) => {
|
|
71
|
+
var _a2, _b2;
|
|
72
|
+
(_b2 = env.form) == null ? void 0 : _b2.query(`${(_a2 = env.field) == null ? void 0 : _a2.address}.${name}`).take((field) => {
|
|
73
|
+
if (name === currentStep.name) {
|
|
74
|
+
field.setDisplay("visible");
|
|
75
|
+
} else {
|
|
76
|
+
field.setDisplay("hidden");
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
const next = (_d = (_c = import_schema.action).bound) == null ? void 0 : _d.call(_c, () => {
|
|
82
|
+
if (formStep.allowNext) {
|
|
83
|
+
formStep.setCurrent(formStep.current + 1);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const back = (_f = (_e = import_schema.action).bound) == null ? void 0 : _f.call(_e, () => {
|
|
87
|
+
if (formStep.allowBack) {
|
|
88
|
+
formStep.setCurrent(formStep.current - 1);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const formStep = (0, import_schema.model)({
|
|
92
|
+
connect(steps, field) {
|
|
93
|
+
env.steps = steps;
|
|
94
|
+
env.form = field == null ? void 0 : field.form;
|
|
95
|
+
env.field = field;
|
|
96
|
+
},
|
|
97
|
+
current: defaultCurrent,
|
|
98
|
+
setCurrent(key) {
|
|
99
|
+
setDisplay == null ? void 0 : setDisplay(key);
|
|
100
|
+
formStep.current = key;
|
|
101
|
+
},
|
|
102
|
+
get allowNext() {
|
|
103
|
+
return formStep.current < env.steps.length - 1;
|
|
104
|
+
},
|
|
105
|
+
get allowBack() {
|
|
106
|
+
return formStep.current > 0;
|
|
107
|
+
},
|
|
108
|
+
async next() {
|
|
109
|
+
var _a2, _b2;
|
|
110
|
+
try {
|
|
111
|
+
await ((_a2 = env.form) == null ? void 0 : _a2.validate());
|
|
112
|
+
if ((_b2 = env.form) == null ? void 0 : _b2.valid) {
|
|
113
|
+
next == null ? void 0 : next();
|
|
114
|
+
}
|
|
115
|
+
} catch {
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
async back() {
|
|
119
|
+
back == null ? void 0 : back();
|
|
120
|
+
},
|
|
121
|
+
async submit(onSubmit) {
|
|
122
|
+
var _a2, _b2;
|
|
123
|
+
return (_b2 = (_a2 = env.form) == null ? void 0 : _a2.submit) == null ? void 0 : _b2.call(_a2, onSubmit);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return (0, import_schema.markRaw)(formStep);
|
|
127
|
+
}, "createFormStep");
|
|
128
|
+
const FormStep = (0, import_schema.connect)(
|
|
129
|
+
(0, import_schema.observer)(({ formStep, className, ...props }) => {
|
|
130
|
+
var _a;
|
|
131
|
+
const field = (0, import_schema.useField)();
|
|
132
|
+
const prefixCls = (0, import_builtins.usePrefixCls)("formily-step", props);
|
|
133
|
+
const schema = (0, import_schema.useFieldSchema)();
|
|
134
|
+
const steps = parseSteps(schema);
|
|
135
|
+
const current = props.current || (formStep == null ? void 0 : formStep.current) || 0;
|
|
136
|
+
(_a = formStep == null ? void 0 : formStep.connect) == null ? void 0 : _a.call(formStep, steps, field);
|
|
137
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_classnames.default)(prefixCls, className) }, /* @__PURE__ */ import_react.default.createElement(import_antd.Steps, { ...props, style: { marginBottom: 10, ...props.style }, current }, steps.map(({ props: props2 }, key) => {
|
|
138
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd.Steps.Step, { key, ...props2 });
|
|
139
|
+
})), steps.map(({ name, schema: schema2 }, key) => {
|
|
140
|
+
if (key !== current) return;
|
|
141
|
+
return /* @__PURE__ */ import_react.default.createElement(import_schema.RecursionField, { key, name, schema: schema2 });
|
|
142
|
+
}));
|
|
143
|
+
})
|
|
144
|
+
);
|
|
145
|
+
const StepPane = /* @__PURE__ */ __name(({ children }) => {
|
|
146
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.Fragment, null, children);
|
|
147
|
+
}, "StepPane");
|
|
148
|
+
FormStep.StepPane = StepPane;
|
|
149
|
+
FormStep.createFormStep = createFormStep;
|
|
150
|
+
var form_step_default = FormStep;
|
|
151
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
152
|
+
0 && (module.exports = {
|
|
153
|
+
FormStep
|
|
154
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TabPaneProps, TabsProps } from 'antd/lib/tabs';
|
|
3
|
+
export interface IFormTab {
|
|
4
|
+
activeKey?: string;
|
|
5
|
+
setActiveKey(key: string): void;
|
|
6
|
+
}
|
|
7
|
+
export interface IFormTabProps extends TabsProps {
|
|
8
|
+
formTab?: IFormTab;
|
|
9
|
+
}
|
|
10
|
+
export interface IFormTabPaneProps extends TabPaneProps {
|
|
11
|
+
key: string | number;
|
|
12
|
+
}
|
|
13
|
+
type ComposedFormTab = React.FC<React.PropsWithChildren<IFormTabProps>> & {
|
|
14
|
+
TabPane: React.FC<React.PropsWithChildren<IFormTabPaneProps>>;
|
|
15
|
+
TabExtraContent: React.FC<React.PropsWithChildren<IFormTabPaneProps>>;
|
|
16
|
+
createFormTab: (defaultActiveKey?: string) => IFormTab;
|
|
17
|
+
};
|
|
18
|
+
export declare const FormTab: ComposedFormTab;
|
|
19
|
+
export default FormTab;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var form_tab_exports = {};
|
|
30
|
+
__export(form_tab_exports, {
|
|
31
|
+
FormTab: () => FormTab,
|
|
32
|
+
default: () => form_tab_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(form_tab_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_schema = require("@tachybase/schema");
|
|
37
|
+
var import_antd = require("antd");
|
|
38
|
+
var import_classnames = __toESM(require("classnames"));
|
|
39
|
+
var import_builtins = require("../__builtins__");
|
|
40
|
+
const useTabs = /* @__PURE__ */ __name(() => {
|
|
41
|
+
const tabsField = (0, import_schema.useField)();
|
|
42
|
+
const schema = (0, import_schema.useFieldSchema)();
|
|
43
|
+
const tabs = [];
|
|
44
|
+
schema.mapProperties((schema2, name) => {
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
const field = tabsField.query(tabsField.address.concat(name)).take();
|
|
47
|
+
if ((field == null ? void 0 : field.display) === "none" || (field == null ? void 0 : field.display) === "hidden") return;
|
|
48
|
+
if (((_a = schema2["x-component"]) == null ? void 0 : _a.indexOf("TabPane")) > -1) {
|
|
49
|
+
const key = ((_b = field == null ? void 0 : field.componentProps) == null ? void 0 : _b.key) || ((_c = schema2 == null ? void 0 : schema2["x-component-props"]) == null ? void 0 : _c.key) || name;
|
|
50
|
+
tabs.push({
|
|
51
|
+
name,
|
|
52
|
+
props: {
|
|
53
|
+
...schema2 == null ? void 0 : schema2["x-component-props"],
|
|
54
|
+
...field == null ? void 0 : field.componentProps,
|
|
55
|
+
key
|
|
56
|
+
},
|
|
57
|
+
schema: schema2
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return tabs;
|
|
62
|
+
}, "useTabs");
|
|
63
|
+
const useTabExtraContent = /* @__PURE__ */ __name(() => {
|
|
64
|
+
const tabsField = (0, import_schema.useField)();
|
|
65
|
+
const schema = (0, import_schema.useFieldSchema)();
|
|
66
|
+
const tabs = [];
|
|
67
|
+
schema.mapProperties((schema2, name) => {
|
|
68
|
+
var _a, _b, _c;
|
|
69
|
+
const field = tabsField.query(tabsField.address.concat(name)).take();
|
|
70
|
+
if ((field == null ? void 0 : field.display) === "none" || (field == null ? void 0 : field.display) === "hidden") return;
|
|
71
|
+
if (((_a = schema2["x-component"]) == null ? void 0 : _a.indexOf("TabExtraContent")) > -1) {
|
|
72
|
+
const key = ((_b = field == null ? void 0 : field.componentProps) == null ? void 0 : _b.key) || ((_c = schema2 == null ? void 0 : schema2["x-component-props"]) == null ? void 0 : _c.key) || name;
|
|
73
|
+
tabs.push({
|
|
74
|
+
name,
|
|
75
|
+
props: {
|
|
76
|
+
...schema2 == null ? void 0 : schema2["x-component-props"],
|
|
77
|
+
...field == null ? void 0 : field.componentProps,
|
|
78
|
+
key
|
|
79
|
+
},
|
|
80
|
+
schema: schema2
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return tabs;
|
|
85
|
+
}, "useTabExtraContent");
|
|
86
|
+
const FeedbackBadge = (0, import_schema.observer)((props) => {
|
|
87
|
+
const field = (0, import_schema.useField)();
|
|
88
|
+
const errors = field.form.queryFeedbacks({
|
|
89
|
+
type: "error",
|
|
90
|
+
address: `${field.address.concat(props.name)}.*`
|
|
91
|
+
});
|
|
92
|
+
if (errors.length) {
|
|
93
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd.Badge, { size: "small", className: "errors-badge", count: errors.length }, props.tab);
|
|
94
|
+
}
|
|
95
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, props.tab);
|
|
96
|
+
});
|
|
97
|
+
const createFormTab = /* @__PURE__ */ __name((defaultActiveKey) => {
|
|
98
|
+
const formTab = (0, import_schema.model)({
|
|
99
|
+
activeKey: defaultActiveKey,
|
|
100
|
+
setActiveKey(key) {
|
|
101
|
+
formTab.activeKey = key;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return (0, import_schema.markRaw)(formTab);
|
|
105
|
+
}, "createFormTab");
|
|
106
|
+
const FormTab = (0, import_schema.observer)(({ formTab, ...props }) => {
|
|
107
|
+
const tabs = useTabs();
|
|
108
|
+
const tabExtraContent = useTabExtraContent();
|
|
109
|
+
const _formTab = (0, import_react.useMemo)(() => {
|
|
110
|
+
return formTab ? formTab : createFormTab();
|
|
111
|
+
}, []);
|
|
112
|
+
const prefixCls = (0, import_builtins.usePrefixCls)("formily-tab", props);
|
|
113
|
+
const activeKey = props.activeKey || (_formTab == null ? void 0 : _formTab.activeKey);
|
|
114
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
115
|
+
import_antd.Tabs,
|
|
116
|
+
{
|
|
117
|
+
...props,
|
|
118
|
+
tabBarExtraContent: /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, tabExtraContent.map(({ schema, name }, key) => /* @__PURE__ */ import_react.default.createElement(import_schema.RecursionField, { key, schema, name }))),
|
|
119
|
+
className: (0, import_classnames.default)(prefixCls, props.className),
|
|
120
|
+
activeKey,
|
|
121
|
+
onChange: (key) => {
|
|
122
|
+
var _a, _b;
|
|
123
|
+
(_a = props.onChange) == null ? void 0 : _a.call(props, key);
|
|
124
|
+
(_b = _formTab == null ? void 0 : _formTab.setActiveKey) == null ? void 0 : _b.call(_formTab, key);
|
|
125
|
+
},
|
|
126
|
+
items: tabs.map(({ props: props2, schema, name }, key) => {
|
|
127
|
+
return {
|
|
128
|
+
key,
|
|
129
|
+
label: /* @__PURE__ */ import_react.default.createElement(FeedbackBadge, { name, tab: props2.tab }),
|
|
130
|
+
...props2,
|
|
131
|
+
children: /* @__PURE__ */ import_react.default.createElement(import_schema.RecursionField, { schema, name })
|
|
132
|
+
};
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
const TabPane = /* @__PURE__ */ __name(({ children }) => {
|
|
138
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.Fragment, null, children);
|
|
139
|
+
}, "TabPane");
|
|
140
|
+
const TabExtraContent = /* @__PURE__ */ __name(({ children }) => {
|
|
141
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.Fragment, null, children);
|
|
142
|
+
}, "TabExtraContent");
|
|
143
|
+
FormTab.TabPane = TabPane;
|
|
144
|
+
FormTab.TabExtraContent = TabExtraContent;
|
|
145
|
+
FormTab.createFormTab = createFormTab;
|
|
146
|
+
var form_tab_default = FormTab;
|
|
147
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
148
|
+
0 && (module.exports = {
|
|
149
|
+
FormTab
|
|
150
|
+
});
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export * from './__builtins__';
|
|
2
|
+
export * from './array-base';
|
|
3
|
+
export * from './array-cards';
|
|
4
|
+
export * from './array-collapse';
|
|
5
|
+
export * from './array-items';
|
|
6
|
+
export * from './array-table';
|
|
7
|
+
export * from './array-tabs';
|
|
8
|
+
export * from './cascader';
|
|
9
|
+
export * from './checkbox';
|
|
10
|
+
export * from './code-mirror';
|
|
11
|
+
export * from './date-picker';
|
|
12
|
+
export * from './editable';
|
|
13
|
+
export * from './form';
|
|
14
|
+
export * from './form-button-group';
|
|
15
|
+
export * from './form-collapse';
|
|
16
|
+
export * from './form-dialog';
|
|
17
|
+
export * from './form-drawer';
|
|
18
|
+
export * from './form-grid';
|
|
19
|
+
export * from './form-item';
|
|
20
|
+
export * from './form-layout';
|
|
21
|
+
export * from './form-step';
|
|
22
|
+
export * from './form-tab';
|
|
23
|
+
export * from './input';
|
|
24
|
+
export * from './lightbox';
|
|
25
|
+
export * from './number-picker';
|
|
26
|
+
export * from './password';
|
|
27
|
+
export * from './preview-text';
|
|
28
|
+
export * from './radio';
|
|
29
|
+
export * from './reset';
|
|
30
|
+
export * from './select';
|
|
31
|
+
export * from './select-table';
|
|
32
|
+
export * from './space';
|
|
33
|
+
export * from './submit';
|
|
34
|
+
export * from './switch';
|
|
35
|
+
export * from './time-picker';
|
|
36
|
+
export * from './transfer';
|
|
37
|
+
export * from './tree-select';
|
|
38
|
+
export * from './upload';
|