@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,187 @@
|
|
|
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_drawer_exports = {};
|
|
30
|
+
__export(form_drawer_exports, {
|
|
31
|
+
FormDrawer: () => FormDrawer,
|
|
32
|
+
default: () => form_drawer_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(form_drawer_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_schema = require("@tachybase/schema");
|
|
37
|
+
var import_antd = require("antd");
|
|
38
|
+
var import_react_dom = require("react-dom");
|
|
39
|
+
var import_builtins = require("../__builtins__");
|
|
40
|
+
const isDrawerTitle = /* @__PURE__ */ __name((props) => {
|
|
41
|
+
return (0, import_schema.isNum)(props) || (0, import_schema.isStr)(props) || (0, import_schema.isBool)(props) || import_react.default.isValidElement(props);
|
|
42
|
+
}, "isDrawerTitle");
|
|
43
|
+
const getDrawerProps = /* @__PURE__ */ __name((props) => {
|
|
44
|
+
if (isDrawerTitle(props)) {
|
|
45
|
+
return {
|
|
46
|
+
title: props
|
|
47
|
+
};
|
|
48
|
+
} else {
|
|
49
|
+
return props;
|
|
50
|
+
}
|
|
51
|
+
}, "getDrawerProps");
|
|
52
|
+
function FormDrawer(title, id, renderer) {
|
|
53
|
+
if ((0, import_schema.isFn)(id) || import_react.default.isValidElement(id)) {
|
|
54
|
+
renderer = id;
|
|
55
|
+
id = "form-drawer";
|
|
56
|
+
}
|
|
57
|
+
const env = {
|
|
58
|
+
host: document.createElement("div"),
|
|
59
|
+
openMiddlewares: [],
|
|
60
|
+
form: null,
|
|
61
|
+
promise: null
|
|
62
|
+
};
|
|
63
|
+
const root = (0, import_builtins.createPortalRoot)(env.host, id);
|
|
64
|
+
const props = getDrawerProps(title);
|
|
65
|
+
const drawer = {
|
|
66
|
+
width: "40%",
|
|
67
|
+
...props,
|
|
68
|
+
onClose: /* @__PURE__ */ __name((e) => {
|
|
69
|
+
var _a;
|
|
70
|
+
if (((_a = props == null ? void 0 : props.onClose) == null ? void 0 : _a.call(props, e)) !== false) {
|
|
71
|
+
formDrawer.close();
|
|
72
|
+
}
|
|
73
|
+
}, "onClose"),
|
|
74
|
+
afterOpenChange: /* @__PURE__ */ __name((open) => {
|
|
75
|
+
var _a;
|
|
76
|
+
(_a = props == null ? void 0 : props.afterOpenChange) == null ? void 0 : _a.call(props, open);
|
|
77
|
+
if (open) return;
|
|
78
|
+
root.unmount();
|
|
79
|
+
}, "afterOpenChange")
|
|
80
|
+
};
|
|
81
|
+
const DrawerContent = (0, import_schema.observer)(() => {
|
|
82
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.Fragment, null, (0, import_schema.isFn)(renderer) ? renderer(env.form) : renderer);
|
|
83
|
+
});
|
|
84
|
+
const renderDrawer = /* @__PURE__ */ __name((open = true) => {
|
|
85
|
+
const { form } = env;
|
|
86
|
+
if (!form) return null;
|
|
87
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd.Drawer, { ...drawer, open }, /* @__PURE__ */ import_react.default.createElement(import_schema.FormProvider, { form }, /* @__PURE__ */ import_react.default.createElement(DrawerContent, null)));
|
|
88
|
+
}, "renderDrawer");
|
|
89
|
+
document.body.appendChild(env.host);
|
|
90
|
+
const formDrawer = {
|
|
91
|
+
forOpen: /* @__PURE__ */ __name((middleware) => {
|
|
92
|
+
if ((0, import_schema.isFn)(middleware)) {
|
|
93
|
+
env.openMiddlewares.push(middleware);
|
|
94
|
+
}
|
|
95
|
+
return formDrawer;
|
|
96
|
+
}, "forOpen"),
|
|
97
|
+
open: /* @__PURE__ */ __name((props2) => {
|
|
98
|
+
if (env.promise) return env.promise;
|
|
99
|
+
env.promise = new Promise((resolve, reject) => {
|
|
100
|
+
const run = /* @__PURE__ */ __name(async () => {
|
|
101
|
+
try {
|
|
102
|
+
props2 = await (0, import_builtins.loading)(drawer.loadingText, () => (0, import_schema.applyMiddleware)(props2, env.openMiddlewares));
|
|
103
|
+
env.form = env.form || (0, import_schema.createForm)({
|
|
104
|
+
...props2,
|
|
105
|
+
effects(form) {
|
|
106
|
+
var _a;
|
|
107
|
+
(0, import_schema.onFormSubmitSuccess)(() => {
|
|
108
|
+
resolve((0, import_schema.toJS)(form.values));
|
|
109
|
+
formDrawer.close();
|
|
110
|
+
});
|
|
111
|
+
(_a = props2 == null ? void 0 : props2.effects) == null ? void 0 : _a.call(props2, form);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
} catch (e) {
|
|
115
|
+
reject(e);
|
|
116
|
+
}
|
|
117
|
+
}, "run");
|
|
118
|
+
run();
|
|
119
|
+
root.render(() => renderDrawer(false));
|
|
120
|
+
setTimeout(() => {
|
|
121
|
+
root.render(() => renderDrawer(true));
|
|
122
|
+
}, 16);
|
|
123
|
+
});
|
|
124
|
+
return env.promise;
|
|
125
|
+
}, "open"),
|
|
126
|
+
close: /* @__PURE__ */ __name(() => {
|
|
127
|
+
if (!env.host) return;
|
|
128
|
+
root.render(() => renderDrawer(false));
|
|
129
|
+
}, "close")
|
|
130
|
+
};
|
|
131
|
+
return formDrawer;
|
|
132
|
+
}
|
|
133
|
+
__name(FormDrawer, "FormDrawer");
|
|
134
|
+
const DrawerExtra = /* @__PURE__ */ __name((props) => {
|
|
135
|
+
const ref = (0, import_react.useRef)(null);
|
|
136
|
+
const [extra, setExtra] = (0, import_react.useState)();
|
|
137
|
+
const extraRef = (0, import_react.useRef)();
|
|
138
|
+
const prefixCls = (0, import_builtins.usePrefixCls)("drawer");
|
|
139
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
const content = (_b = (_a = ref.current) == null ? void 0 : _a.closest(`.${prefixCls}-content`)) == null ? void 0 : _b.querySelector(`.${prefixCls}-header`);
|
|
142
|
+
if (content) {
|
|
143
|
+
if (!extraRef.current) {
|
|
144
|
+
extraRef.current = content.querySelector(`.${prefixCls}-extra`);
|
|
145
|
+
if (!extraRef.current) {
|
|
146
|
+
extraRef.current = document.createElement("div");
|
|
147
|
+
extraRef.current.classList.add(`${prefixCls}-extra`);
|
|
148
|
+
content.appendChild(extraRef.current);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
setExtra(extraRef.current);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
extraRef.current = extra;
|
|
155
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { ref, style: { display: "none" } }, extra && (0, import_react_dom.createPortal)(props.children, extra));
|
|
156
|
+
}, "DrawerExtra");
|
|
157
|
+
const DrawerFooter = /* @__PURE__ */ __name((props) => {
|
|
158
|
+
const ref = (0, import_react.useRef)(null);
|
|
159
|
+
const [footer, setFooter] = (0, import_react.useState)();
|
|
160
|
+
const footerRef = (0, import_react.useRef)();
|
|
161
|
+
const prefixCls = (0, import_builtins.usePrefixCls)("drawer");
|
|
162
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
163
|
+
var _a;
|
|
164
|
+
const content = (_a = ref.current) == null ? void 0 : _a.closest(`.${prefixCls}-content`);
|
|
165
|
+
if (content) {
|
|
166
|
+
if (!footerRef.current) {
|
|
167
|
+
footerRef.current = content.querySelector(`.${prefixCls}-footer`);
|
|
168
|
+
if (!footerRef.current) {
|
|
169
|
+
footerRef.current = document.createElement("div");
|
|
170
|
+
footerRef.current.classList.add(`${prefixCls}-footer`);
|
|
171
|
+
content.appendChild(footerRef.current);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
setFooter(footerRef.current);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
footerRef.current = footer;
|
|
178
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { ref, style: { display: "none" } }, footer && (0, import_react_dom.createPortal)(props.children, footer));
|
|
179
|
+
}, "DrawerFooter");
|
|
180
|
+
FormDrawer.Extra = DrawerExtra;
|
|
181
|
+
FormDrawer.Footer = DrawerFooter;
|
|
182
|
+
FormDrawer.Portal = (0, import_builtins.createPortalProvider)("form-drawer");
|
|
183
|
+
var form_drawer_default = FormDrawer;
|
|
184
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
185
|
+
0 && (module.exports = {
|
|
186
|
+
FormDrawer
|
|
187
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid, IGridOptions } from '@tachybase/schema';
|
|
3
|
+
export interface IFormGridProps extends IGridOptions {
|
|
4
|
+
grid?: Grid<HTMLElement>;
|
|
5
|
+
prefixCls?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
export interface IGridColumnProps {
|
|
10
|
+
gridSpan?: number;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const createFormGrid: (props: IFormGridProps) => Grid<HTMLElement>;
|
|
15
|
+
export declare const useFormGrid: () => Grid<HTMLElement>;
|
|
16
|
+
export declare const GridColumn: React.FC<React.PropsWithChildren<IGridColumnProps>>;
|
|
17
|
+
export declare const FormGrid: React.NamedExoticComponent<Omit<{
|
|
18
|
+
children?: React.ReactNode | undefined;
|
|
19
|
+
}, "children" | "ref" | keyof IFormGridProps> & IFormGridProps & {
|
|
20
|
+
children?: React.ReactNode | undefined;
|
|
21
|
+
} & {
|
|
22
|
+
ref?: React.RefAttributes<any>;
|
|
23
|
+
}> & {
|
|
24
|
+
readonly type: import("@tachybase/schema").ReactFC<IFormGridProps & {
|
|
25
|
+
children?: React.ReactNode | undefined;
|
|
26
|
+
} & {
|
|
27
|
+
ref?: React.RefAttributes<any>;
|
|
28
|
+
}>;
|
|
29
|
+
} & {
|
|
30
|
+
createFormGrid: (props: IFormGridProps) => Grid<HTMLElement>;
|
|
31
|
+
useFormGrid: () => Grid<HTMLElement>;
|
|
32
|
+
GridColumn: React.FC<React.PropsWithChildren<IGridColumnProps>>;
|
|
33
|
+
};
|
|
34
|
+
export default FormGrid;
|
|
@@ -0,0 +1,108 @@
|
|
|
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_grid_exports = {};
|
|
30
|
+
__export(form_grid_exports, {
|
|
31
|
+
FormGrid: () => FormGrid,
|
|
32
|
+
GridColumn: () => GridColumn,
|
|
33
|
+
createFormGrid: () => createFormGrid,
|
|
34
|
+
default: () => form_grid_default,
|
|
35
|
+
useFormGrid: () => useFormGrid
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(form_grid_exports);
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
39
|
+
var import_schema = require("@tachybase/schema");
|
|
40
|
+
var import_classnames = __toESM(require("classnames"));
|
|
41
|
+
var import_builtins = require("../__builtins__");
|
|
42
|
+
var import_form_layout = require("../form-layout");
|
|
43
|
+
var import_style = __toESM(require("./style"));
|
|
44
|
+
const FormGridContext = import_react.default.createContext(null);
|
|
45
|
+
const createFormGrid = /* @__PURE__ */ __name((props) => {
|
|
46
|
+
return (0, import_schema.markRaw)(new import_schema.Grid(props));
|
|
47
|
+
}, "createFormGrid");
|
|
48
|
+
const useFormGrid = /* @__PURE__ */ __name(() => (0, import_react.useContext)(FormGridContext), "useFormGrid");
|
|
49
|
+
const InternalFormGrid = (0, import_schema.observer)(
|
|
50
|
+
({ children, className, style, ...props }) => {
|
|
51
|
+
const layout = (0, import_form_layout.useFormLayout)();
|
|
52
|
+
const options = {
|
|
53
|
+
columnGap: (layout == null ? void 0 : layout.gridColumnGap) ?? 8,
|
|
54
|
+
rowGap: (layout == null ? void 0 : layout.gridRowGap) ?? 4,
|
|
55
|
+
...props
|
|
56
|
+
};
|
|
57
|
+
const grid = (0, import_react.useMemo)(() => (0, import_schema.markRaw)((options == null ? void 0 : options.grid) ? options.grid : new import_schema.Grid(options)), [import_schema.Grid.id(options)]);
|
|
58
|
+
const ref = (0, import_react.useRef)(null);
|
|
59
|
+
const prefixCls = (0, import_builtins.usePrefixCls)("formily-grid", props);
|
|
60
|
+
const [wrapSSR, hashId] = (0, import_style.default)(prefixCls);
|
|
61
|
+
const dataProps = (0, import_builtins.pickDataProps)(props);
|
|
62
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
63
|
+
if (ref.current) {
|
|
64
|
+
return grid.connect(ref.current);
|
|
65
|
+
}
|
|
66
|
+
}, [grid]);
|
|
67
|
+
return /* @__PURE__ */ import_react.default.createElement(FormGridContext.Provider, { value: grid }, wrapSSR(
|
|
68
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
...dataProps,
|
|
72
|
+
className: (0, import_classnames.default)(`${prefixCls}-layout`, hashId, className),
|
|
73
|
+
style: {
|
|
74
|
+
...style,
|
|
75
|
+
gridTemplateColumns: grid.templateColumns,
|
|
76
|
+
gap: grid.gap
|
|
77
|
+
},
|
|
78
|
+
ref
|
|
79
|
+
},
|
|
80
|
+
children
|
|
81
|
+
)
|
|
82
|
+
));
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
forwardRef: true
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
const GridColumn = (0, import_schema.observer)(
|
|
89
|
+
({ gridSpan, children, ...props }) => {
|
|
90
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { ...props, style: props.style, "data-grid-span": gridSpan }, children);
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
GridColumn.defaultProps = {
|
|
94
|
+
gridSpan: 1
|
|
95
|
+
};
|
|
96
|
+
const FormGrid = Object.assign(InternalFormGrid, {
|
|
97
|
+
createFormGrid,
|
|
98
|
+
useFormGrid,
|
|
99
|
+
GridColumn
|
|
100
|
+
});
|
|
101
|
+
var form_grid_default = FormGrid;
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
FormGrid,
|
|
105
|
+
GridColumn,
|
|
106
|
+
createFormGrid,
|
|
107
|
+
useFormGrid
|
|
108
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var style_exports = {};
|
|
19
|
+
__export(style_exports, {
|
|
20
|
+
default: () => style_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(style_exports);
|
|
23
|
+
var import_builtins = require("./../__builtins__");
|
|
24
|
+
var style_default = (0, import_builtins.genStyleHook)("form-grid", (token) => {
|
|
25
|
+
const { componentCls } = token;
|
|
26
|
+
return {
|
|
27
|
+
[`${componentCls}-layout`]: {
|
|
28
|
+
display: "grid"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var hooks_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
17
|
+
__reExport(hooks_exports, require("./useOverflow"), module.exports);
|
|
18
|
+
__reExport(hooks_exports, require("./useFormItemLayout"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./useOverflow"),
|
|
22
|
+
...require("./useFormItemLayout")
|
|
23
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IFormItemProps } from '../types';
|
|
3
|
+
export declare const useFormItemLayout: (props: IFormItemProps) => {
|
|
4
|
+
layout: "inline" | "horizontal" | "vertical";
|
|
5
|
+
colon: boolean;
|
|
6
|
+
labelAlign: "left" | "right";
|
|
7
|
+
labelWrap: boolean;
|
|
8
|
+
labelWidth: string | number;
|
|
9
|
+
wrapperWidth: string | number;
|
|
10
|
+
labelCol: number;
|
|
11
|
+
wrapperCol: number;
|
|
12
|
+
wrapperAlign: "left" | "right";
|
|
13
|
+
wrapperWrap: boolean;
|
|
14
|
+
fullness: boolean;
|
|
15
|
+
size: "default" | "small" | "large";
|
|
16
|
+
inset: boolean;
|
|
17
|
+
asterisk: boolean;
|
|
18
|
+
bordered: boolean;
|
|
19
|
+
feedbackIcon: React.ReactNode;
|
|
20
|
+
feedbackLayout: (string & {}) | "none" | "loose" | "terse" | "popover";
|
|
21
|
+
tooltipLayout: "text" | "icon";
|
|
22
|
+
tooltipIcon: string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element;
|
|
23
|
+
className?: string;
|
|
24
|
+
style?: React.CSSProperties;
|
|
25
|
+
prefixCls?: string;
|
|
26
|
+
label?: React.ReactNode;
|
|
27
|
+
tooltip?: React.ReactNode;
|
|
28
|
+
labelStyle?: React.CSSProperties;
|
|
29
|
+
wrapperStyle?: React.CSSProperties;
|
|
30
|
+
addonBefore?: React.ReactNode;
|
|
31
|
+
addonAfter?: React.ReactNode;
|
|
32
|
+
extra?: React.ReactNode;
|
|
33
|
+
feedbackText?: React.ReactNode;
|
|
34
|
+
feedbackStatus?: "error" | "warning" | "success" | "pending" | (string & {});
|
|
35
|
+
getPopupContainer?: (node: HTMLElement) => HTMLElement;
|
|
36
|
+
gridSpan?: number;
|
|
37
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
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 useFormItemLayout_exports = {};
|
|
30
|
+
__export(useFormItemLayout_exports, {
|
|
31
|
+
useFormItemLayout: () => useFormItemLayout
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useFormItemLayout_exports);
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
var import_icons = require("@ant-design/icons");
|
|
36
|
+
var import_form_layout = require("../../form-layout");
|
|
37
|
+
const useFormItemLayout = /* @__PURE__ */ __name((props) => {
|
|
38
|
+
const layout = (0, import_form_layout.useFormLayout)();
|
|
39
|
+
const layoutType = props.layout ?? layout.layout ?? "horizontal";
|
|
40
|
+
return {
|
|
41
|
+
...props,
|
|
42
|
+
layout: layoutType,
|
|
43
|
+
colon: props.colon ?? layout.colon,
|
|
44
|
+
labelAlign: layoutType === "vertical" ? props.labelAlign ?? "left" : props.labelAlign ?? layout.labelAlign ?? "right",
|
|
45
|
+
labelWrap: props.labelWrap ?? layout.labelWrap,
|
|
46
|
+
labelWidth: props.labelWidth ?? layout.labelWidth,
|
|
47
|
+
wrapperWidth: props.wrapperWidth ?? layout.wrapperWidth,
|
|
48
|
+
labelCol: props.labelCol ?? layout.labelCol,
|
|
49
|
+
wrapperCol: props.wrapperCol ?? layout.wrapperCol,
|
|
50
|
+
wrapperAlign: props.wrapperAlign ?? layout.wrapperAlign,
|
|
51
|
+
wrapperWrap: props.wrapperWrap ?? layout.wrapperWrap,
|
|
52
|
+
fullness: props.fullness ?? layout.fullness,
|
|
53
|
+
size: props.size ?? layout.size,
|
|
54
|
+
inset: props.inset ?? layout.inset,
|
|
55
|
+
asterisk: props.asterisk,
|
|
56
|
+
bordered: props.bordered ?? layout.bordered,
|
|
57
|
+
feedbackIcon: props.feedbackIcon,
|
|
58
|
+
feedbackLayout: props.feedbackLayout ?? layout.feedbackLayout ?? "loose",
|
|
59
|
+
tooltipLayout: props.tooltipLayout ?? layout.tooltipLayout ?? "icon",
|
|
60
|
+
tooltipIcon: props.tooltipIcon ?? layout.tooltipIcon ?? /* @__PURE__ */ import_react.default.createElement(import_icons.QuestionCircleOutlined, null)
|
|
61
|
+
};
|
|
62
|
+
}, "useFormItemLayout");
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
useFormItemLayout
|
|
66
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
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 useOverflow_exports = {};
|
|
20
|
+
__export(useOverflow_exports, {
|
|
21
|
+
useOverflow: () => useOverflow
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useOverflow_exports);
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
var import_form_layout = require("../../form-layout");
|
|
26
|
+
function useOverflow() {
|
|
27
|
+
const [overflow, setOverflow] = (0, import_react.useState)(false);
|
|
28
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
29
|
+
const contentRef = (0, import_react.useRef)(null);
|
|
30
|
+
const layout = (0, import_form_layout.useFormLayout)();
|
|
31
|
+
const labelCol = JSON.stringify(layout.labelCol);
|
|
32
|
+
(0, import_react.useEffect)(() => {
|
|
33
|
+
requestAnimationFrame(() => {
|
|
34
|
+
if (containerRef.current && contentRef.current) {
|
|
35
|
+
const contentWidth = contentRef.current.getBoundingClientRect().width;
|
|
36
|
+
const containerWidth = containerRef.current.getBoundingClientRect().width;
|
|
37
|
+
if (contentWidth && containerWidth && containerWidth < contentWidth) {
|
|
38
|
+
if (!overflow) setOverflow(true);
|
|
39
|
+
} else {
|
|
40
|
+
if (overflow) setOverflow(false);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}, [labelCol]);
|
|
45
|
+
return {
|
|
46
|
+
overflow,
|
|
47
|
+
containerRef,
|
|
48
|
+
contentRef
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
__name(useOverflow, "useOverflow");
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
useOverflow
|
|
55
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ReactFC } from '@tachybase/schema';
|
|
3
|
+
import { IFormItemProps } from './types';
|
|
4
|
+
export * from './hooks';
|
|
5
|
+
export * from './types';
|
|
6
|
+
type ComposeFormItem = ReactFC<IFormItemProps> & {
|
|
7
|
+
BaseItem: ReactFC<IFormItemProps>;
|
|
8
|
+
};
|
|
9
|
+
export declare const BaseItem: React.FC<React.PropsWithChildren<IFormItemProps>>;
|
|
10
|
+
export declare const FormItem: ComposeFormItem;
|
|
11
|
+
export default FormItem;
|