@faasjs/ant-design 0.0.4-beta.14 → 0.0.4-beta.16
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/dist/index.d.mts +51 -40
- package/dist/index.d.ts +51 -40
- package/dist/index.js +77 -77
- package/dist/index.mjs +80 -80
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FaasDataInjection as FaasDataInjection$1, FaasDataWrapperProps as FaasDataWrapperProps$1
|
|
1
|
+
import { ErrorBoundaryProps, FaasDataInjection as FaasDataInjection$1, FaasDataWrapperProps as FaasDataWrapperProps$1 } from '@faasjs/react';
|
|
2
2
|
export { ErrorBoundaryProps, faas, useFaas } from '@faasjs/react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ConfigProviderProps as ConfigProviderProps$1 } from 'antd/es/config-provider';
|
|
@@ -73,43 +73,7 @@ declare function useDrawer(init?: DrawerProps): {
|
|
|
73
73
|
setDrawerProps(changes: Partial<DrawerProps>): void;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
children: React.ReactNode;
|
|
78
|
-
styleProviderProps?: StyleProviderProps;
|
|
79
|
-
configProviderProps?: ConfigProviderProps$1;
|
|
80
|
-
browserRouterProps?: BrowserRouterProps;
|
|
81
|
-
}
|
|
82
|
-
interface useAppProps {
|
|
83
|
-
message: MessageInstance;
|
|
84
|
-
notification: NotificationInstance;
|
|
85
|
-
setModalProps: (changes: Partial<ModalProps>) => void;
|
|
86
|
-
setDrawerProps: (changes: Partial<DrawerProps>) => void;
|
|
87
|
-
}
|
|
88
|
-
declare function App(props: AppProps): react_jsx_runtime.JSX.Element;
|
|
89
|
-
declare namespace App {
|
|
90
|
-
var useApp: typeof useApp;
|
|
91
|
-
}
|
|
92
|
-
declare function useApp(): useAppProps;
|
|
93
|
-
|
|
94
|
-
interface BlankProps {
|
|
95
|
-
value?: any;
|
|
96
|
-
text?: string;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Blank component.
|
|
100
|
-
*
|
|
101
|
-
* If value is undefined or null, return text, otherwise return value.
|
|
102
|
-
*
|
|
103
|
-
* @param options {object}
|
|
104
|
-
* @param options.value {any}
|
|
105
|
-
* @param options.text {string} Default is 'Empty'
|
|
106
|
-
* @returns {JSX.Element}
|
|
107
|
-
*
|
|
108
|
-
* ```ts
|
|
109
|
-
* <Blank value={undefined} text="Empty" />
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
declare function Blank(options?: BlankProps): JSX.Element;
|
|
76
|
+
declare function ErrorBoundary(props: ErrorBoundaryProps): react_jsx_runtime.JSX.Element;
|
|
113
77
|
|
|
114
78
|
interface ConfigProviderProps {
|
|
115
79
|
lang?: string;
|
|
@@ -163,6 +127,55 @@ declare function ConfigProvider({ config, children, }: {
|
|
|
163
127
|
}): react_jsx_runtime.JSX.Element;
|
|
164
128
|
declare function useConfigContext(): ConfigProviderProps;
|
|
165
129
|
|
|
130
|
+
interface AppProps {
|
|
131
|
+
children: React.ReactNode;
|
|
132
|
+
styleProviderProps?: StyleProviderProps;
|
|
133
|
+
configProviderProps?: ConfigProviderProps$1;
|
|
134
|
+
browserRouterProps?: BrowserRouterProps;
|
|
135
|
+
errorBoundaryProps?: Omit<ErrorBoundaryProps, 'children'>;
|
|
136
|
+
faasConfigProviderProps?: Omit<ConfigProviderProps, 'children'>;
|
|
137
|
+
}
|
|
138
|
+
interface useAppProps {
|
|
139
|
+
message: MessageInstance;
|
|
140
|
+
notification: NotificationInstance;
|
|
141
|
+
setModalProps: (changes: Partial<ModalProps>) => void;
|
|
142
|
+
setDrawerProps: (changes: Partial<DrawerProps>) => void;
|
|
143
|
+
}
|
|
144
|
+
declare function App(props: AppProps): react_jsx_runtime.JSX.Element;
|
|
145
|
+
declare namespace App {
|
|
146
|
+
var useApp: typeof useApp;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get app context.
|
|
150
|
+
*
|
|
151
|
+
* ```ts
|
|
152
|
+
* import { useApp } from '@faasjs/ant-design'
|
|
153
|
+
*
|
|
154
|
+
* const { message, notification, setModalProps, setDrawerProps } = useApp()
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare function useApp(): useAppProps;
|
|
158
|
+
|
|
159
|
+
interface BlankProps {
|
|
160
|
+
value?: any;
|
|
161
|
+
text?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Blank component.
|
|
165
|
+
*
|
|
166
|
+
* If value is undefined or null, return text, otherwise return value.
|
|
167
|
+
*
|
|
168
|
+
* @param options {object}
|
|
169
|
+
* @param options.value {any}
|
|
170
|
+
* @param options.text {string} Default is 'Empty'
|
|
171
|
+
* @returns {JSX.Element}
|
|
172
|
+
*
|
|
173
|
+
* ```ts
|
|
174
|
+
* <Blank value={undefined} text="Empty" />
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
declare function Blank(options?: BlankProps): JSX.Element;
|
|
178
|
+
|
|
166
179
|
type ExtendFormTypeProps<T = any> = {
|
|
167
180
|
children?: UnionFaasItemElement<T>;
|
|
168
181
|
};
|
|
@@ -377,8 +390,6 @@ interface UnionFaasItemProps<Value = any, Values = any> extends FormItemProps, D
|
|
|
377
390
|
object?: UnionFaasItemProps<Value, Values>[];
|
|
378
391
|
}
|
|
379
392
|
|
|
380
|
-
declare function ErrorBoundary(props: ErrorBoundaryProps): react_jsx_runtime.JSX.Element;
|
|
381
|
-
|
|
382
393
|
type FormSubmitProps = {
|
|
383
394
|
/** Default: Submit */
|
|
384
395
|
text?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FaasDataInjection as FaasDataInjection$1, FaasDataWrapperProps as FaasDataWrapperProps$1
|
|
1
|
+
import { ErrorBoundaryProps, FaasDataInjection as FaasDataInjection$1, FaasDataWrapperProps as FaasDataWrapperProps$1 } from '@faasjs/react';
|
|
2
2
|
export { ErrorBoundaryProps, faas, useFaas } from '@faasjs/react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ConfigProviderProps as ConfigProviderProps$1 } from 'antd/es/config-provider';
|
|
@@ -73,43 +73,7 @@ declare function useDrawer(init?: DrawerProps): {
|
|
|
73
73
|
setDrawerProps(changes: Partial<DrawerProps>): void;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
children: React.ReactNode;
|
|
78
|
-
styleProviderProps?: StyleProviderProps;
|
|
79
|
-
configProviderProps?: ConfigProviderProps$1;
|
|
80
|
-
browserRouterProps?: BrowserRouterProps;
|
|
81
|
-
}
|
|
82
|
-
interface useAppProps {
|
|
83
|
-
message: MessageInstance;
|
|
84
|
-
notification: NotificationInstance;
|
|
85
|
-
setModalProps: (changes: Partial<ModalProps>) => void;
|
|
86
|
-
setDrawerProps: (changes: Partial<DrawerProps>) => void;
|
|
87
|
-
}
|
|
88
|
-
declare function App(props: AppProps): react_jsx_runtime.JSX.Element;
|
|
89
|
-
declare namespace App {
|
|
90
|
-
var useApp: typeof useApp;
|
|
91
|
-
}
|
|
92
|
-
declare function useApp(): useAppProps;
|
|
93
|
-
|
|
94
|
-
interface BlankProps {
|
|
95
|
-
value?: any;
|
|
96
|
-
text?: string;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Blank component.
|
|
100
|
-
*
|
|
101
|
-
* If value is undefined or null, return text, otherwise return value.
|
|
102
|
-
*
|
|
103
|
-
* @param options {object}
|
|
104
|
-
* @param options.value {any}
|
|
105
|
-
* @param options.text {string} Default is 'Empty'
|
|
106
|
-
* @returns {JSX.Element}
|
|
107
|
-
*
|
|
108
|
-
* ```ts
|
|
109
|
-
* <Blank value={undefined} text="Empty" />
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
declare function Blank(options?: BlankProps): JSX.Element;
|
|
76
|
+
declare function ErrorBoundary(props: ErrorBoundaryProps): react_jsx_runtime.JSX.Element;
|
|
113
77
|
|
|
114
78
|
interface ConfigProviderProps {
|
|
115
79
|
lang?: string;
|
|
@@ -163,6 +127,55 @@ declare function ConfigProvider({ config, children, }: {
|
|
|
163
127
|
}): react_jsx_runtime.JSX.Element;
|
|
164
128
|
declare function useConfigContext(): ConfigProviderProps;
|
|
165
129
|
|
|
130
|
+
interface AppProps {
|
|
131
|
+
children: React.ReactNode;
|
|
132
|
+
styleProviderProps?: StyleProviderProps;
|
|
133
|
+
configProviderProps?: ConfigProviderProps$1;
|
|
134
|
+
browserRouterProps?: BrowserRouterProps;
|
|
135
|
+
errorBoundaryProps?: Omit<ErrorBoundaryProps, 'children'>;
|
|
136
|
+
faasConfigProviderProps?: Omit<ConfigProviderProps, 'children'>;
|
|
137
|
+
}
|
|
138
|
+
interface useAppProps {
|
|
139
|
+
message: MessageInstance;
|
|
140
|
+
notification: NotificationInstance;
|
|
141
|
+
setModalProps: (changes: Partial<ModalProps>) => void;
|
|
142
|
+
setDrawerProps: (changes: Partial<DrawerProps>) => void;
|
|
143
|
+
}
|
|
144
|
+
declare function App(props: AppProps): react_jsx_runtime.JSX.Element;
|
|
145
|
+
declare namespace App {
|
|
146
|
+
var useApp: typeof useApp;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get app context.
|
|
150
|
+
*
|
|
151
|
+
* ```ts
|
|
152
|
+
* import { useApp } from '@faasjs/ant-design'
|
|
153
|
+
*
|
|
154
|
+
* const { message, notification, setModalProps, setDrawerProps } = useApp()
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare function useApp(): useAppProps;
|
|
158
|
+
|
|
159
|
+
interface BlankProps {
|
|
160
|
+
value?: any;
|
|
161
|
+
text?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Blank component.
|
|
165
|
+
*
|
|
166
|
+
* If value is undefined or null, return text, otherwise return value.
|
|
167
|
+
*
|
|
168
|
+
* @param options {object}
|
|
169
|
+
* @param options.value {any}
|
|
170
|
+
* @param options.text {string} Default is 'Empty'
|
|
171
|
+
* @returns {JSX.Element}
|
|
172
|
+
*
|
|
173
|
+
* ```ts
|
|
174
|
+
* <Blank value={undefined} text="Empty" />
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
declare function Blank(options?: BlankProps): JSX.Element;
|
|
178
|
+
|
|
166
179
|
type ExtendFormTypeProps<T = any> = {
|
|
167
180
|
children?: UnionFaasItemElement<T>;
|
|
168
181
|
};
|
|
@@ -377,8 +390,6 @@ interface UnionFaasItemProps<Value = any, Values = any> extends FormItemProps, D
|
|
|
377
390
|
object?: UnionFaasItemProps<Value, Values>[];
|
|
378
391
|
}
|
|
379
392
|
|
|
380
|
-
declare function ErrorBoundary(props: ErrorBoundaryProps): react_jsx_runtime.JSX.Element;
|
|
381
|
-
|
|
382
393
|
type FormSubmitProps = {
|
|
383
394
|
/** Default: Submit */
|
|
384
395
|
text?: string;
|
package/dist/index.js
CHANGED
|
@@ -55,57 +55,28 @@ function useDrawer(init) {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
message: {},
|
|
60
|
-
notification: {},
|
|
61
|
-
setModalProps: () => void 0,
|
|
62
|
-
setDrawerProps: () => void 0
|
|
63
|
-
});
|
|
64
|
-
function RoutesApp(props) {
|
|
65
|
-
const location = reactRouterDom.useLocation();
|
|
66
|
-
const { setDrawerProps, setModalProps } = useApp();
|
|
67
|
-
react$1.useEffect(() => {
|
|
68
|
-
console.debug("location", location);
|
|
69
|
-
setDrawerProps({ open: false });
|
|
70
|
-
setModalProps({ open: false });
|
|
71
|
-
}, [location]);
|
|
72
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.children });
|
|
73
|
-
}
|
|
74
|
-
function App(props) {
|
|
75
|
-
const [messageApi, messageContextHolder] = antd.message.useMessage();
|
|
76
|
-
const [notificationApi, notificationContextHolder] = antd.notification.useNotification();
|
|
77
|
-
const { modal, setModalProps } = useModal();
|
|
78
|
-
const { drawer, setDrawerProps } = useDrawer();
|
|
79
|
-
const memoizedContextValue = react$1.useMemo(
|
|
80
|
-
() => ({
|
|
81
|
-
message: messageApi,
|
|
82
|
-
notification: notificationApi,
|
|
83
|
-
setModalProps,
|
|
84
|
-
setDrawerProps
|
|
85
|
-
}),
|
|
86
|
-
[messageApi, notificationApi, setModalProps, setDrawerProps]
|
|
87
|
-
);
|
|
58
|
+
function ErrorChildren(props) {
|
|
88
59
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
89
|
-
|
|
60
|
+
antd.Alert,
|
|
90
61
|
{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
62
|
+
type: "error",
|
|
63
|
+
message: props.errorMessage,
|
|
64
|
+
description: /* @__PURE__ */ jsxRuntime.jsx(
|
|
65
|
+
"pre",
|
|
66
|
+
{
|
|
67
|
+
style: {
|
|
68
|
+
fontSize: "0.9em",
|
|
69
|
+
overflowX: "auto"
|
|
70
|
+
},
|
|
71
|
+
children: props.errorDescription
|
|
72
|
+
}
|
|
73
|
+
)
|
|
102
74
|
}
|
|
103
75
|
);
|
|
104
76
|
}
|
|
105
|
-
function
|
|
106
|
-
return react
|
|
77
|
+
function ErrorBoundary(props) {
|
|
78
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.ErrorBoundary, { errorChildren: /* @__PURE__ */ jsxRuntime.jsx(ErrorChildren, {}), ...props });
|
|
107
79
|
}
|
|
108
|
-
App.useApp = useApp;
|
|
109
80
|
var isZH = /^zh/i.test(navigator.language);
|
|
110
81
|
var zh = {
|
|
111
82
|
lang: "zh",
|
|
@@ -145,7 +116,7 @@ var baseConfig = {
|
|
|
145
116
|
Link: { style: {} }
|
|
146
117
|
};
|
|
147
118
|
var ConfigContext = react$1.createContext(baseConfig);
|
|
148
|
-
function
|
|
119
|
+
function ConfigProvider({
|
|
149
120
|
config,
|
|
150
121
|
children
|
|
151
122
|
}) {
|
|
@@ -172,6 +143,57 @@ function ConfigProvider2({
|
|
|
172
143
|
function useConfigContext() {
|
|
173
144
|
return react$1.useContext(ConfigContext);
|
|
174
145
|
}
|
|
146
|
+
var AppContext = react$1.createContext({
|
|
147
|
+
message: {},
|
|
148
|
+
notification: {},
|
|
149
|
+
setModalProps: () => void 0,
|
|
150
|
+
setDrawerProps: () => void 0
|
|
151
|
+
});
|
|
152
|
+
function RoutesApp(props) {
|
|
153
|
+
const location = reactRouterDom.useLocation();
|
|
154
|
+
const { setDrawerProps, setModalProps } = useApp();
|
|
155
|
+
react$1.useEffect(() => {
|
|
156
|
+
console.debug("location", location);
|
|
157
|
+
setDrawerProps({ open: false });
|
|
158
|
+
setModalProps({ open: false });
|
|
159
|
+
}, [location]);
|
|
160
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.children });
|
|
161
|
+
}
|
|
162
|
+
function App(props) {
|
|
163
|
+
const [messageApi, messageContextHolder] = antd.message.useMessage();
|
|
164
|
+
const [notificationApi, notificationContextHolder] = antd.notification.useNotification();
|
|
165
|
+
const { modal, setModalProps } = useModal();
|
|
166
|
+
const { drawer, setDrawerProps } = useDrawer();
|
|
167
|
+
const memoizedContextValue = react$1.useMemo(
|
|
168
|
+
() => ({
|
|
169
|
+
message: messageApi,
|
|
170
|
+
notification: notificationApi,
|
|
171
|
+
setModalProps,
|
|
172
|
+
setDrawerProps
|
|
173
|
+
}),
|
|
174
|
+
[messageApi, notificationApi, setModalProps, setDrawerProps]
|
|
175
|
+
);
|
|
176
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
177
|
+
cssinjs.StyleProvider,
|
|
178
|
+
{
|
|
179
|
+
...Object.assign(props.styleProviderProps || {}, {
|
|
180
|
+
hashPriority: "high",
|
|
181
|
+
transformers: [cssinjs.legacyLogicalPropertiesTransformer]
|
|
182
|
+
}),
|
|
183
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(antd.ConfigProvider, { ...props.configProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(AppContext.Provider, { value: memoizedContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { config: props.faasConfigProviderProps || {}, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.BrowserRouter, { ...props.browserRouterProps, children: [
|
|
184
|
+
messageContextHolder,
|
|
185
|
+
notificationContextHolder,
|
|
186
|
+
modal,
|
|
187
|
+
drawer,
|
|
188
|
+
/* @__PURE__ */ jsxRuntime.jsx(RoutesApp, { children: props.children })
|
|
189
|
+
] }) }) }) }) })
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
function useApp() {
|
|
194
|
+
return react$1.useContext(AppContext);
|
|
195
|
+
}
|
|
196
|
+
App.useApp = useApp;
|
|
175
197
|
function Blank(options) {
|
|
176
198
|
const { Blank: Blank2 } = useConfigContext();
|
|
177
199
|
return !options || lodashEs.isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { disabled: true, children: (options == null ? void 0 : options.text) || Blank2.text }) : options.value;
|
|
@@ -256,7 +278,7 @@ function DescriptionItemContent(props) {
|
|
|
256
278
|
}, [props]);
|
|
257
279
|
if (!computedProps)
|
|
258
280
|
return null;
|
|
259
|
-
if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type])
|
|
281
|
+
if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type]) {
|
|
260
282
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
261
283
|
return react$1.cloneElement(
|
|
262
284
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
@@ -266,15 +288,15 @@ function DescriptionItemContent(props) {
|
|
|
266
288
|
values: computedProps.values
|
|
267
289
|
}
|
|
268
290
|
);
|
|
269
|
-
|
|
291
|
+
if (computedProps.extendTypes[computedProps.item.type].render)
|
|
270
292
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: computedProps.extendTypes[computedProps.item.type].render(
|
|
271
293
|
computedProps.value,
|
|
272
294
|
computedProps.values,
|
|
273
295
|
0,
|
|
274
296
|
"description"
|
|
275
297
|
) });
|
|
276
|
-
|
|
277
|
-
|
|
298
|
+
throw Error(`${computedProps.item.type} requires children or render`);
|
|
299
|
+
}
|
|
278
300
|
if (computedProps.item.descriptionChildren === null)
|
|
279
301
|
return null;
|
|
280
302
|
if (computedProps.item.descriptionChildren)
|
|
@@ -396,28 +418,6 @@ function Description(props) {
|
|
|
396
418
|
}
|
|
397
419
|
);
|
|
398
420
|
}
|
|
399
|
-
function ErrorChildren(props) {
|
|
400
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
401
|
-
antd.Alert,
|
|
402
|
-
{
|
|
403
|
-
type: "error",
|
|
404
|
-
message: props.errorMessage,
|
|
405
|
-
description: /* @__PURE__ */ jsxRuntime.jsx(
|
|
406
|
-
"pre",
|
|
407
|
-
{
|
|
408
|
-
style: {
|
|
409
|
-
fontSize: "0.9em",
|
|
410
|
-
overflowX: "auto"
|
|
411
|
-
},
|
|
412
|
-
children: props.errorDescription
|
|
413
|
-
}
|
|
414
|
-
)
|
|
415
|
-
}
|
|
416
|
-
);
|
|
417
|
-
}
|
|
418
|
-
function ErrorBoundary(props) {
|
|
419
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.ErrorBoundary, { errorChildren: /* @__PURE__ */ jsxRuntime.jsx(ErrorChildren, {}), ...props });
|
|
420
|
-
}
|
|
421
421
|
function processProps(propsCopy, config) {
|
|
422
422
|
if (!propsCopy.title)
|
|
423
423
|
propsCopy.title = lodashEs.upperFirst(propsCopy.id);
|
|
@@ -1450,7 +1450,7 @@ function Table(props) {
|
|
|
1450
1450
|
antd.Table,
|
|
1451
1451
|
{
|
|
1452
1452
|
...props,
|
|
1453
|
-
rowKey: props.rowKey ||
|
|
1453
|
+
rowKey: props.rowKey || "id",
|
|
1454
1454
|
columns,
|
|
1455
1455
|
dataSource: props.dataSource
|
|
1456
1456
|
}
|
|
@@ -1507,7 +1507,7 @@ function FaasDataTable({
|
|
|
1507
1507
|
{
|
|
1508
1508
|
...props,
|
|
1509
1509
|
loading: props.loading,
|
|
1510
|
-
rowKey: props.rowKey ||
|
|
1510
|
+
rowKey: props.rowKey || "id",
|
|
1511
1511
|
columns: currentColumns,
|
|
1512
1512
|
dataSource: []
|
|
1513
1513
|
}
|
|
@@ -1518,7 +1518,7 @@ function FaasDataTable({
|
|
|
1518
1518
|
{
|
|
1519
1519
|
...props,
|
|
1520
1520
|
loading: props.loading,
|
|
1521
|
-
rowKey: props.rowKey ||
|
|
1521
|
+
rowKey: props.rowKey || "id",
|
|
1522
1522
|
columns: currentColumns,
|
|
1523
1523
|
dataSource: data
|
|
1524
1524
|
}
|
|
@@ -1528,7 +1528,7 @@ function FaasDataTable({
|
|
|
1528
1528
|
{
|
|
1529
1529
|
...props,
|
|
1530
1530
|
loading: props.loading,
|
|
1531
|
-
rowKey: props.rowKey ||
|
|
1531
|
+
rowKey: props.rowKey || "id",
|
|
1532
1532
|
columns: currentColumns,
|
|
1533
1533
|
dataSource: data.rows,
|
|
1534
1534
|
pagination: {
|
|
@@ -1611,7 +1611,7 @@ Object.defineProperty(exports, 'lazy', {
|
|
|
1611
1611
|
exports.App = App;
|
|
1612
1612
|
exports.Blank = Blank;
|
|
1613
1613
|
exports.ConfigContext = ConfigContext;
|
|
1614
|
-
exports.ConfigProvider =
|
|
1614
|
+
exports.ConfigProvider = ConfigProvider;
|
|
1615
1615
|
exports.Description = Description;
|
|
1616
1616
|
exports.ErrorBoundary = ErrorBoundary;
|
|
1617
1617
|
exports.FaasDataWrapper = FaasDataWrapper;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ErrorBoundary as ErrorBoundary$1, FaasDataWrapper as FaasDataWrapper$1, faas } from '@faasjs/react';
|
|
2
2
|
export { faas, useFaas } from '@faasjs/react';
|
|
3
|
-
import { Form as Form$1, Modal, Drawer, message, notification, ConfigProvider, Typography, Spin, Descriptions, Input, Button, Row, Col, TimePicker, DatePicker, Switch, Select, InputNumber, Radio, Result, Skeleton, Table as Table$1, Tabs as Tabs$1,
|
|
3
|
+
import { Form as Form$1, Modal, Drawer, message, notification, ConfigProvider as ConfigProvider$1, Typography, Spin, Descriptions, Input, Button, Row, Col, TimePicker, DatePicker, Switch, Select, InputNumber, Radio, Result, Skeleton, Table as Table$1, Tabs as Tabs$1, Alert, Space } from 'antd';
|
|
4
4
|
export { Drawer, Modal } from 'antd';
|
|
5
5
|
import { StyleProvider, legacyLogicalPropertiesTransformer } from '@ant-design/cssinjs';
|
|
6
|
-
import { createContext, useState,
|
|
6
|
+
import { createContext, useState, useEffect, useContext, useMemo, cloneElement, useCallback, isValidElement, Suspense } from 'react';
|
|
7
7
|
export { lazy } from 'react';
|
|
8
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
9
|
import { BrowserRouter, useNavigate, Link as Link$1, Routes as Routes$1, Route, useLocation } from 'react-router-dom';
|
|
@@ -52,57 +52,28 @@ function useDrawer(init) {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
message: {},
|
|
57
|
-
notification: {},
|
|
58
|
-
setModalProps: () => void 0,
|
|
59
|
-
setDrawerProps: () => void 0
|
|
60
|
-
});
|
|
61
|
-
function RoutesApp(props) {
|
|
62
|
-
const location = useLocation();
|
|
63
|
-
const { setDrawerProps, setModalProps } = useApp();
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
console.debug("location", location);
|
|
66
|
-
setDrawerProps({ open: false });
|
|
67
|
-
setModalProps({ open: false });
|
|
68
|
-
}, [location]);
|
|
69
|
-
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
70
|
-
}
|
|
71
|
-
function App(props) {
|
|
72
|
-
const [messageApi, messageContextHolder] = message.useMessage();
|
|
73
|
-
const [notificationApi, notificationContextHolder] = notification.useNotification();
|
|
74
|
-
const { modal, setModalProps } = useModal();
|
|
75
|
-
const { drawer, setDrawerProps } = useDrawer();
|
|
76
|
-
const memoizedContextValue = useMemo(
|
|
77
|
-
() => ({
|
|
78
|
-
message: messageApi,
|
|
79
|
-
notification: notificationApi,
|
|
80
|
-
setModalProps,
|
|
81
|
-
setDrawerProps
|
|
82
|
-
}),
|
|
83
|
-
[messageApi, notificationApi, setModalProps, setDrawerProps]
|
|
84
|
-
);
|
|
55
|
+
function ErrorChildren(props) {
|
|
85
56
|
return /* @__PURE__ */ jsx(
|
|
86
|
-
|
|
57
|
+
Alert,
|
|
87
58
|
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
59
|
+
type: "error",
|
|
60
|
+
message: props.errorMessage,
|
|
61
|
+
description: /* @__PURE__ */ jsx(
|
|
62
|
+
"pre",
|
|
63
|
+
{
|
|
64
|
+
style: {
|
|
65
|
+
fontSize: "0.9em",
|
|
66
|
+
overflowX: "auto"
|
|
67
|
+
},
|
|
68
|
+
children: props.errorDescription
|
|
69
|
+
}
|
|
70
|
+
)
|
|
99
71
|
}
|
|
100
72
|
);
|
|
101
73
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
74
|
+
function ErrorBoundary(props) {
|
|
75
|
+
return /* @__PURE__ */ jsx(ErrorBoundary$1, { errorChildren: /* @__PURE__ */ jsx(ErrorChildren, {}), ...props });
|
|
104
76
|
}
|
|
105
|
-
App.useApp = useApp;
|
|
106
77
|
var isZH = /^zh/i.test(navigator.language);
|
|
107
78
|
var zh = {
|
|
108
79
|
lang: "zh",
|
|
@@ -142,7 +113,7 @@ var baseConfig = {
|
|
|
142
113
|
Link: { style: {} }
|
|
143
114
|
};
|
|
144
115
|
var ConfigContext = createContext(baseConfig);
|
|
145
|
-
function
|
|
116
|
+
function ConfigProvider({
|
|
146
117
|
config,
|
|
147
118
|
children
|
|
148
119
|
}) {
|
|
@@ -169,6 +140,57 @@ function ConfigProvider2({
|
|
|
169
140
|
function useConfigContext() {
|
|
170
141
|
return useContext(ConfigContext);
|
|
171
142
|
}
|
|
143
|
+
var AppContext = createContext({
|
|
144
|
+
message: {},
|
|
145
|
+
notification: {},
|
|
146
|
+
setModalProps: () => void 0,
|
|
147
|
+
setDrawerProps: () => void 0
|
|
148
|
+
});
|
|
149
|
+
function RoutesApp(props) {
|
|
150
|
+
const location = useLocation();
|
|
151
|
+
const { setDrawerProps, setModalProps } = useApp();
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
console.debug("location", location);
|
|
154
|
+
setDrawerProps({ open: false });
|
|
155
|
+
setModalProps({ open: false });
|
|
156
|
+
}, [location]);
|
|
157
|
+
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
158
|
+
}
|
|
159
|
+
function App(props) {
|
|
160
|
+
const [messageApi, messageContextHolder] = message.useMessage();
|
|
161
|
+
const [notificationApi, notificationContextHolder] = notification.useNotification();
|
|
162
|
+
const { modal, setModalProps } = useModal();
|
|
163
|
+
const { drawer, setDrawerProps } = useDrawer();
|
|
164
|
+
const memoizedContextValue = useMemo(
|
|
165
|
+
() => ({
|
|
166
|
+
message: messageApi,
|
|
167
|
+
notification: notificationApi,
|
|
168
|
+
setModalProps,
|
|
169
|
+
setDrawerProps
|
|
170
|
+
}),
|
|
171
|
+
[messageApi, notificationApi, setModalProps, setDrawerProps]
|
|
172
|
+
);
|
|
173
|
+
return /* @__PURE__ */ jsx(
|
|
174
|
+
StyleProvider,
|
|
175
|
+
{
|
|
176
|
+
...Object.assign(props.styleProviderProps || {}, {
|
|
177
|
+
hashPriority: "high",
|
|
178
|
+
transformers: [legacyLogicalPropertiesTransformer]
|
|
179
|
+
}),
|
|
180
|
+
children: /* @__PURE__ */ jsx(ConfigProvider$1, { ...props.configProviderProps, children: /* @__PURE__ */ jsx(AppContext.Provider, { value: memoizedContextValue, children: /* @__PURE__ */ jsx(ConfigProvider, { config: props.faasConfigProviderProps || {}, children: /* @__PURE__ */ jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxs(BrowserRouter, { ...props.browserRouterProps, children: [
|
|
181
|
+
messageContextHolder,
|
|
182
|
+
notificationContextHolder,
|
|
183
|
+
modal,
|
|
184
|
+
drawer,
|
|
185
|
+
/* @__PURE__ */ jsx(RoutesApp, { children: props.children })
|
|
186
|
+
] }) }) }) }) })
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
function useApp() {
|
|
191
|
+
return useContext(AppContext);
|
|
192
|
+
}
|
|
193
|
+
App.useApp = useApp;
|
|
172
194
|
function Blank(options) {
|
|
173
195
|
const { Blank: Blank2 } = useConfigContext();
|
|
174
196
|
return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx(Typography.Text, { disabled: true, children: (options == null ? void 0 : options.text) || Blank2.text }) : options.value;
|
|
@@ -253,7 +275,7 @@ function DescriptionItemContent(props) {
|
|
|
253
275
|
}, [props]);
|
|
254
276
|
if (!computedProps)
|
|
255
277
|
return null;
|
|
256
|
-
if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type])
|
|
278
|
+
if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type]) {
|
|
257
279
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
258
280
|
return cloneElement(
|
|
259
281
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
@@ -263,15 +285,15 @@ function DescriptionItemContent(props) {
|
|
|
263
285
|
values: computedProps.values
|
|
264
286
|
}
|
|
265
287
|
);
|
|
266
|
-
|
|
288
|
+
if (computedProps.extendTypes[computedProps.item.type].render)
|
|
267
289
|
return /* @__PURE__ */ jsx(Fragment, { children: computedProps.extendTypes[computedProps.item.type].render(
|
|
268
290
|
computedProps.value,
|
|
269
291
|
computedProps.values,
|
|
270
292
|
0,
|
|
271
293
|
"description"
|
|
272
294
|
) });
|
|
273
|
-
|
|
274
|
-
|
|
295
|
+
throw Error(`${computedProps.item.type} requires children or render`);
|
|
296
|
+
}
|
|
275
297
|
if (computedProps.item.descriptionChildren === null)
|
|
276
298
|
return null;
|
|
277
299
|
if (computedProps.item.descriptionChildren)
|
|
@@ -393,28 +415,6 @@ function Description(props) {
|
|
|
393
415
|
}
|
|
394
416
|
);
|
|
395
417
|
}
|
|
396
|
-
function ErrorChildren(props) {
|
|
397
|
-
return /* @__PURE__ */ jsx(
|
|
398
|
-
Alert,
|
|
399
|
-
{
|
|
400
|
-
type: "error",
|
|
401
|
-
message: props.errorMessage,
|
|
402
|
-
description: /* @__PURE__ */ jsx(
|
|
403
|
-
"pre",
|
|
404
|
-
{
|
|
405
|
-
style: {
|
|
406
|
-
fontSize: "0.9em",
|
|
407
|
-
overflowX: "auto"
|
|
408
|
-
},
|
|
409
|
-
children: props.errorDescription
|
|
410
|
-
}
|
|
411
|
-
)
|
|
412
|
-
}
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
function ErrorBoundary(props) {
|
|
416
|
-
return /* @__PURE__ */ jsx(ErrorBoundary$1, { errorChildren: /* @__PURE__ */ jsx(ErrorChildren, {}), ...props });
|
|
417
|
-
}
|
|
418
418
|
function processProps(propsCopy, config) {
|
|
419
419
|
if (!propsCopy.title)
|
|
420
420
|
propsCopy.title = upperFirst(propsCopy.id);
|
|
@@ -1447,7 +1447,7 @@ function Table(props) {
|
|
|
1447
1447
|
Table$1,
|
|
1448
1448
|
{
|
|
1449
1449
|
...props,
|
|
1450
|
-
rowKey: props.rowKey ||
|
|
1450
|
+
rowKey: props.rowKey || "id",
|
|
1451
1451
|
columns,
|
|
1452
1452
|
dataSource: props.dataSource
|
|
1453
1453
|
}
|
|
@@ -1504,7 +1504,7 @@ function FaasDataTable({
|
|
|
1504
1504
|
{
|
|
1505
1505
|
...props,
|
|
1506
1506
|
loading: props.loading,
|
|
1507
|
-
rowKey: props.rowKey ||
|
|
1507
|
+
rowKey: props.rowKey || "id",
|
|
1508
1508
|
columns: currentColumns,
|
|
1509
1509
|
dataSource: []
|
|
1510
1510
|
}
|
|
@@ -1515,7 +1515,7 @@ function FaasDataTable({
|
|
|
1515
1515
|
{
|
|
1516
1516
|
...props,
|
|
1517
1517
|
loading: props.loading,
|
|
1518
|
-
rowKey: props.rowKey ||
|
|
1518
|
+
rowKey: props.rowKey || "id",
|
|
1519
1519
|
columns: currentColumns,
|
|
1520
1520
|
dataSource: data
|
|
1521
1521
|
}
|
|
@@ -1525,7 +1525,7 @@ function FaasDataTable({
|
|
|
1525
1525
|
{
|
|
1526
1526
|
...props,
|
|
1527
1527
|
loading: props.loading,
|
|
1528
|
-
rowKey: props.rowKey ||
|
|
1528
|
+
rowKey: props.rowKey || "id",
|
|
1529
1529
|
columns: currentColumns,
|
|
1530
1530
|
dataSource: data.rows,
|
|
1531
1531
|
pagination: {
|
|
@@ -1585,4 +1585,4 @@ function Title(props) {
|
|
|
1585
1585
|
return null;
|
|
1586
1586
|
}
|
|
1587
1587
|
|
|
1588
|
-
export { App, Blank, ConfigContext,
|
|
1588
|
+
export { App, Blank, ConfigContext, ConfigProvider, Description, ErrorBoundary, FaasDataWrapper, Form, FormItem, Link, Loading, PageNotFound, Routes, Table, Tabs, Title, transferOptions, transferValue, useApp, useConfigContext, useDrawer, useModal };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "0.0.4-beta.
|
|
3
|
+
"version": "0.0.4-beta.16",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"lodash-es": "*"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@faasjs/react": "0.0.4-beta.
|
|
29
|
+
"@faasjs/react": "0.0.4-beta.16",
|
|
30
30
|
"antd": "*",
|
|
31
31
|
"react": "*",
|
|
32
32
|
"react-dom": "*",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@testing-library/jest-dom": "*",
|
|
38
38
|
"@testing-library/react": "*",
|
|
39
39
|
"@testing-library/user-event": "*",
|
|
40
|
-
"@faasjs/react": "0.0.4-beta.
|
|
40
|
+
"@faasjs/react": "0.0.4-beta.16",
|
|
41
41
|
"antd": "*",
|
|
42
42
|
"react": "*",
|
|
43
43
|
"react-dom": "*",
|