@faasjs/ant-design 0.0.4-beta.15 → 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 +49 -39
- package/dist/index.d.ts +49 -39
- package/dist/index.js +57 -57
- package/dist/index.mjs +59 -59
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -75,45 +75,6 @@ declare function useDrawer(init?: DrawerProps): {
|
|
|
75
75
|
|
|
76
76
|
declare function ErrorBoundary(props: ErrorBoundaryProps): react_jsx_runtime.JSX.Element;
|
|
77
77
|
|
|
78
|
-
interface AppProps {
|
|
79
|
-
children: React.ReactNode;
|
|
80
|
-
styleProviderProps?: StyleProviderProps;
|
|
81
|
-
configProviderProps?: ConfigProviderProps$1;
|
|
82
|
-
browserRouterProps?: BrowserRouterProps;
|
|
83
|
-
errorBoundaryProps?: Omit<ErrorBoundaryProps, 'children'>;
|
|
84
|
-
}
|
|
85
|
-
interface useAppProps {
|
|
86
|
-
message: MessageInstance;
|
|
87
|
-
notification: NotificationInstance;
|
|
88
|
-
setModalProps: (changes: Partial<ModalProps>) => void;
|
|
89
|
-
setDrawerProps: (changes: Partial<DrawerProps>) => void;
|
|
90
|
-
}
|
|
91
|
-
declare function App(props: AppProps): react_jsx_runtime.JSX.Element;
|
|
92
|
-
declare namespace App {
|
|
93
|
-
var useApp: typeof useApp;
|
|
94
|
-
}
|
|
95
|
-
declare function useApp(): useAppProps;
|
|
96
|
-
|
|
97
|
-
interface BlankProps {
|
|
98
|
-
value?: any;
|
|
99
|
-
text?: string;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Blank component.
|
|
103
|
-
*
|
|
104
|
-
* If value is undefined or null, return text, otherwise return value.
|
|
105
|
-
*
|
|
106
|
-
* @param options {object}
|
|
107
|
-
* @param options.value {any}
|
|
108
|
-
* @param options.text {string} Default is 'Empty'
|
|
109
|
-
* @returns {JSX.Element}
|
|
110
|
-
*
|
|
111
|
-
* ```ts
|
|
112
|
-
* <Blank value={undefined} text="Empty" />
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
declare function Blank(options?: BlankProps): JSX.Element;
|
|
116
|
-
|
|
117
78
|
interface ConfigProviderProps {
|
|
118
79
|
lang?: string;
|
|
119
80
|
common?: {
|
|
@@ -166,6 +127,55 @@ declare function ConfigProvider({ config, children, }: {
|
|
|
166
127
|
}): react_jsx_runtime.JSX.Element;
|
|
167
128
|
declare function useConfigContext(): ConfigProviderProps;
|
|
168
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
|
+
|
|
169
179
|
type ExtendFormTypeProps<T = any> = {
|
|
170
180
|
children?: UnionFaasItemElement<T>;
|
|
171
181
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -75,45 +75,6 @@ declare function useDrawer(init?: DrawerProps): {
|
|
|
75
75
|
|
|
76
76
|
declare function ErrorBoundary(props: ErrorBoundaryProps): react_jsx_runtime.JSX.Element;
|
|
77
77
|
|
|
78
|
-
interface AppProps {
|
|
79
|
-
children: React.ReactNode;
|
|
80
|
-
styleProviderProps?: StyleProviderProps;
|
|
81
|
-
configProviderProps?: ConfigProviderProps$1;
|
|
82
|
-
browserRouterProps?: BrowserRouterProps;
|
|
83
|
-
errorBoundaryProps?: Omit<ErrorBoundaryProps, 'children'>;
|
|
84
|
-
}
|
|
85
|
-
interface useAppProps {
|
|
86
|
-
message: MessageInstance;
|
|
87
|
-
notification: NotificationInstance;
|
|
88
|
-
setModalProps: (changes: Partial<ModalProps>) => void;
|
|
89
|
-
setDrawerProps: (changes: Partial<DrawerProps>) => void;
|
|
90
|
-
}
|
|
91
|
-
declare function App(props: AppProps): react_jsx_runtime.JSX.Element;
|
|
92
|
-
declare namespace App {
|
|
93
|
-
var useApp: typeof useApp;
|
|
94
|
-
}
|
|
95
|
-
declare function useApp(): useAppProps;
|
|
96
|
-
|
|
97
|
-
interface BlankProps {
|
|
98
|
-
value?: any;
|
|
99
|
-
text?: string;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Blank component.
|
|
103
|
-
*
|
|
104
|
-
* If value is undefined or null, return text, otherwise return value.
|
|
105
|
-
*
|
|
106
|
-
* @param options {object}
|
|
107
|
-
* @param options.value {any}
|
|
108
|
-
* @param options.text {string} Default is 'Empty'
|
|
109
|
-
* @returns {JSX.Element}
|
|
110
|
-
*
|
|
111
|
-
* ```ts
|
|
112
|
-
* <Blank value={undefined} text="Empty" />
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
declare function Blank(options?: BlankProps): JSX.Element;
|
|
116
|
-
|
|
117
78
|
interface ConfigProviderProps {
|
|
118
79
|
lang?: string;
|
|
119
80
|
common?: {
|
|
@@ -166,6 +127,55 @@ declare function ConfigProvider({ config, children, }: {
|
|
|
166
127
|
}): react_jsx_runtime.JSX.Element;
|
|
167
128
|
declare function useConfigContext(): ConfigProviderProps;
|
|
168
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
|
+
|
|
169
179
|
type ExtendFormTypeProps<T = any> = {
|
|
170
180
|
children?: UnionFaasItemElement<T>;
|
|
171
181
|
};
|
package/dist/index.js
CHANGED
|
@@ -77,57 +77,6 @@ function ErrorChildren(props) {
|
|
|
77
77
|
function ErrorBoundary(props) {
|
|
78
78
|
return /* @__PURE__ */ jsxRuntime.jsx(react.ErrorBoundary, { errorChildren: /* @__PURE__ */ jsxRuntime.jsx(ErrorChildren, {}), ...props });
|
|
79
79
|
}
|
|
80
|
-
var AppContext = react$1.createContext({
|
|
81
|
-
message: {},
|
|
82
|
-
notification: {},
|
|
83
|
-
setModalProps: () => void 0,
|
|
84
|
-
setDrawerProps: () => void 0
|
|
85
|
-
});
|
|
86
|
-
function RoutesApp(props) {
|
|
87
|
-
const location = reactRouterDom.useLocation();
|
|
88
|
-
const { setDrawerProps, setModalProps } = useApp();
|
|
89
|
-
react$1.useEffect(() => {
|
|
90
|
-
console.debug("location", location);
|
|
91
|
-
setDrawerProps({ open: false });
|
|
92
|
-
setModalProps({ open: false });
|
|
93
|
-
}, [location]);
|
|
94
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.children });
|
|
95
|
-
}
|
|
96
|
-
function App(props) {
|
|
97
|
-
const [messageApi, messageContextHolder] = antd.message.useMessage();
|
|
98
|
-
const [notificationApi, notificationContextHolder] = antd.notification.useNotification();
|
|
99
|
-
const { modal, setModalProps } = useModal();
|
|
100
|
-
const { drawer, setDrawerProps } = useDrawer();
|
|
101
|
-
const memoizedContextValue = react$1.useMemo(
|
|
102
|
-
() => ({
|
|
103
|
-
message: messageApi,
|
|
104
|
-
notification: notificationApi,
|
|
105
|
-
setModalProps,
|
|
106
|
-
setDrawerProps
|
|
107
|
-
}),
|
|
108
|
-
[messageApi, notificationApi, setModalProps, setDrawerProps]
|
|
109
|
-
);
|
|
110
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
111
|
-
cssinjs.StyleProvider,
|
|
112
|
-
{
|
|
113
|
-
...Object.assign(props.styleProviderProps || {}, {
|
|
114
|
-
hashPriority: "high",
|
|
115
|
-
transformers: [cssinjs.legacyLogicalPropertiesTransformer]
|
|
116
|
-
}),
|
|
117
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(antd.ConfigProvider, { ...props.configProviderProps, children: /* @__PURE__ */ jsxRuntime.jsx(AppContext.Provider, { value: memoizedContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.BrowserRouter, { ...props.browserRouterProps, children: [
|
|
118
|
-
messageContextHolder,
|
|
119
|
-
notificationContextHolder,
|
|
120
|
-
modal,
|
|
121
|
-
drawer,
|
|
122
|
-
/* @__PURE__ */ jsxRuntime.jsx(RoutesApp, { children: props.children })
|
|
123
|
-
] }) }) }) })
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
function useApp() {
|
|
128
|
-
return react$1.useContext(AppContext);
|
|
129
|
-
}
|
|
130
|
-
App.useApp = useApp;
|
|
131
80
|
var isZH = /^zh/i.test(navigator.language);
|
|
132
81
|
var zh = {
|
|
133
82
|
lang: "zh",
|
|
@@ -167,7 +116,7 @@ var baseConfig = {
|
|
|
167
116
|
Link: { style: {} }
|
|
168
117
|
};
|
|
169
118
|
var ConfigContext = react$1.createContext(baseConfig);
|
|
170
|
-
function
|
|
119
|
+
function ConfigProvider({
|
|
171
120
|
config,
|
|
172
121
|
children
|
|
173
122
|
}) {
|
|
@@ -194,6 +143,57 @@ function ConfigProvider2({
|
|
|
194
143
|
function useConfigContext() {
|
|
195
144
|
return react$1.useContext(ConfigContext);
|
|
196
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;
|
|
197
197
|
function Blank(options) {
|
|
198
198
|
const { Blank: Blank2 } = useConfigContext();
|
|
199
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;
|
|
@@ -278,7 +278,7 @@ function DescriptionItemContent(props) {
|
|
|
278
278
|
}, [props]);
|
|
279
279
|
if (!computedProps)
|
|
280
280
|
return null;
|
|
281
|
-
if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type])
|
|
281
|
+
if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type]) {
|
|
282
282
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
283
283
|
return react$1.cloneElement(
|
|
284
284
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
@@ -288,15 +288,15 @@ function DescriptionItemContent(props) {
|
|
|
288
288
|
values: computedProps.values
|
|
289
289
|
}
|
|
290
290
|
);
|
|
291
|
-
|
|
291
|
+
if (computedProps.extendTypes[computedProps.item.type].render)
|
|
292
292
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: computedProps.extendTypes[computedProps.item.type].render(
|
|
293
293
|
computedProps.value,
|
|
294
294
|
computedProps.values,
|
|
295
295
|
0,
|
|
296
296
|
"description"
|
|
297
297
|
) });
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
throw Error(`${computedProps.item.type} requires children or render`);
|
|
299
|
+
}
|
|
300
300
|
if (computedProps.item.descriptionChildren === null)
|
|
301
301
|
return null;
|
|
302
302
|
if (computedProps.item.descriptionChildren)
|
|
@@ -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
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, Alert, Space } from 'antd';
|
|
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';
|
|
@@ -74,57 +74,6 @@ function ErrorChildren(props) {
|
|
|
74
74
|
function ErrorBoundary(props) {
|
|
75
75
|
return /* @__PURE__ */ jsx(ErrorBoundary$1, { errorChildren: /* @__PURE__ */ jsx(ErrorChildren, {}), ...props });
|
|
76
76
|
}
|
|
77
|
-
var AppContext = createContext({
|
|
78
|
-
message: {},
|
|
79
|
-
notification: {},
|
|
80
|
-
setModalProps: () => void 0,
|
|
81
|
-
setDrawerProps: () => void 0
|
|
82
|
-
});
|
|
83
|
-
function RoutesApp(props) {
|
|
84
|
-
const location = useLocation();
|
|
85
|
-
const { setDrawerProps, setModalProps } = useApp();
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
console.debug("location", location);
|
|
88
|
-
setDrawerProps({ open: false });
|
|
89
|
-
setModalProps({ open: false });
|
|
90
|
-
}, [location]);
|
|
91
|
-
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
92
|
-
}
|
|
93
|
-
function App(props) {
|
|
94
|
-
const [messageApi, messageContextHolder] = message.useMessage();
|
|
95
|
-
const [notificationApi, notificationContextHolder] = notification.useNotification();
|
|
96
|
-
const { modal, setModalProps } = useModal();
|
|
97
|
-
const { drawer, setDrawerProps } = useDrawer();
|
|
98
|
-
const memoizedContextValue = useMemo(
|
|
99
|
-
() => ({
|
|
100
|
-
message: messageApi,
|
|
101
|
-
notification: notificationApi,
|
|
102
|
-
setModalProps,
|
|
103
|
-
setDrawerProps
|
|
104
|
-
}),
|
|
105
|
-
[messageApi, notificationApi, setModalProps, setDrawerProps]
|
|
106
|
-
);
|
|
107
|
-
return /* @__PURE__ */ jsx(
|
|
108
|
-
StyleProvider,
|
|
109
|
-
{
|
|
110
|
-
...Object.assign(props.styleProviderProps || {}, {
|
|
111
|
-
hashPriority: "high",
|
|
112
|
-
transformers: [legacyLogicalPropertiesTransformer]
|
|
113
|
-
}),
|
|
114
|
-
children: /* @__PURE__ */ jsx(ConfigProvider, { ...props.configProviderProps, children: /* @__PURE__ */ jsx(AppContext.Provider, { value: memoizedContextValue, children: /* @__PURE__ */ jsx(ErrorBoundary, { ...props.errorBoundaryProps, children: /* @__PURE__ */ jsxs(BrowserRouter, { ...props.browserRouterProps, children: [
|
|
115
|
-
messageContextHolder,
|
|
116
|
-
notificationContextHolder,
|
|
117
|
-
modal,
|
|
118
|
-
drawer,
|
|
119
|
-
/* @__PURE__ */ jsx(RoutesApp, { children: props.children })
|
|
120
|
-
] }) }) }) })
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
function useApp() {
|
|
125
|
-
return useContext(AppContext);
|
|
126
|
-
}
|
|
127
|
-
App.useApp = useApp;
|
|
128
77
|
var isZH = /^zh/i.test(navigator.language);
|
|
129
78
|
var zh = {
|
|
130
79
|
lang: "zh",
|
|
@@ -164,7 +113,7 @@ var baseConfig = {
|
|
|
164
113
|
Link: { style: {} }
|
|
165
114
|
};
|
|
166
115
|
var ConfigContext = createContext(baseConfig);
|
|
167
|
-
function
|
|
116
|
+
function ConfigProvider({
|
|
168
117
|
config,
|
|
169
118
|
children
|
|
170
119
|
}) {
|
|
@@ -191,6 +140,57 @@ function ConfigProvider2({
|
|
|
191
140
|
function useConfigContext() {
|
|
192
141
|
return useContext(ConfigContext);
|
|
193
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;
|
|
194
194
|
function Blank(options) {
|
|
195
195
|
const { Blank: Blank2 } = useConfigContext();
|
|
196
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;
|
|
@@ -275,7 +275,7 @@ function DescriptionItemContent(props) {
|
|
|
275
275
|
}, [props]);
|
|
276
276
|
if (!computedProps)
|
|
277
277
|
return null;
|
|
278
|
-
if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type])
|
|
278
|
+
if ((_a = computedProps.extendTypes) == null ? void 0 : _a[computedProps.item.type]) {
|
|
279
279
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
280
280
|
return cloneElement(
|
|
281
281
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
@@ -285,15 +285,15 @@ function DescriptionItemContent(props) {
|
|
|
285
285
|
values: computedProps.values
|
|
286
286
|
}
|
|
287
287
|
);
|
|
288
|
-
|
|
288
|
+
if (computedProps.extendTypes[computedProps.item.type].render)
|
|
289
289
|
return /* @__PURE__ */ jsx(Fragment, { children: computedProps.extendTypes[computedProps.item.type].render(
|
|
290
290
|
computedProps.value,
|
|
291
291
|
computedProps.values,
|
|
292
292
|
0,
|
|
293
293
|
"description"
|
|
294
294
|
) });
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
throw Error(`${computedProps.item.type} requires children or render`);
|
|
296
|
+
}
|
|
297
297
|
if (computedProps.item.descriptionChildren === null)
|
|
298
298
|
return null;
|
|
299
299
|
if (computedProps.item.descriptionChildren)
|
|
@@ -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": "*",
|