@faasjs/ant-design 6.4.1 → 6.4.3
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/README.md +1 -0
- package/dist/index.cjs +38 -34
- package/dist/index.d.ts +30 -23
- package/dist/index.mjs +39 -36
- package/package.json +3 -3
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -54,7 +54,7 @@ var ConfigContext = react$1.createContext({
|
|
|
54
54
|
theme: baseTheme
|
|
55
55
|
});
|
|
56
56
|
function ConfigProvider(props) {
|
|
57
|
-
const [
|
|
57
|
+
const [theme2, setTheme] = react$1.useState(baseTheme);
|
|
58
58
|
react.useEqualEffect(() => {
|
|
59
59
|
const lang = props.theme?.lang || (!props.theme?.lang && /^zh/i.test(navigator.language) ? "zh" : "en");
|
|
60
60
|
if (lang === "zh") {
|
|
@@ -73,8 +73,8 @@ function ConfigProvider(props) {
|
|
|
73
73
|
} else setTheme(lodashEs.defaultsDeep(props.theme, baseTheme));
|
|
74
74
|
if (props.faasClientOptions) react.FaasReactClient(props.faasClientOptions);
|
|
75
75
|
}, [props.theme]);
|
|
76
|
-
if (!
|
|
77
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ConfigContext.Provider, { value: { theme }, children: props.children });
|
|
76
|
+
if (!theme2) return null;
|
|
77
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ConfigContext.Provider, { value: { theme: theme2 }, children: props.children });
|
|
78
78
|
}
|
|
79
79
|
function useConfigContext() {
|
|
80
80
|
return react$1.useContext(ConfigContext);
|
|
@@ -237,8 +237,8 @@ var useApp = AppContext.use;
|
|
|
237
237
|
App.useApp = useApp;
|
|
238
238
|
App.whyDidYouRender = true;
|
|
239
239
|
function Blank(options) {
|
|
240
|
-
const { theme } = useConfigContext();
|
|
241
|
-
return !options || options.value === undefined || options.value === null || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { disabled: true, children: options?.text ||
|
|
240
|
+
const { theme: theme2 } = useConfigContext();
|
|
241
|
+
return !options || options.value === undefined || options.value === null || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { disabled: true, children: options?.text || theme2.Blank.text }) : options.value;
|
|
242
242
|
}
|
|
243
243
|
Blank.whyDidYouRender = true;
|
|
244
244
|
function upperFirst(str) {
|
|
@@ -342,7 +342,7 @@ function DescriptionItemContent(props) {
|
|
|
342
342
|
setComputedProps(propsCopy);
|
|
343
343
|
}, [props]);
|
|
344
344
|
if (!computedProps) return null;
|
|
345
|
-
if (computedProps.item.descriptionChildren === null || computedProps.item.children === null)
|
|
345
|
+
if (computedProps.item.descriptionChildren === null || computedProps.item.children === null || computedProps.item.descriptionRender === null || computedProps.item.render === null)
|
|
346
346
|
return null;
|
|
347
347
|
const children = computedProps.item.descriptionChildren || computedProps.item.children;
|
|
348
348
|
if (children)
|
|
@@ -463,7 +463,9 @@ function Description({
|
|
|
463
463
|
{
|
|
464
464
|
...props,
|
|
465
465
|
title: typeof renderTitle === "function" ? renderTitle(dataSource) : props.title,
|
|
466
|
-
items: props.items.filter(
|
|
466
|
+
items: props.items.filter(
|
|
467
|
+
(item) => item && !(item.descriptionChildren === null || item.children === null || item.descriptionRender === null || item.render === null) && (!item.if || item.if(dataSource))
|
|
468
|
+
).map((item) => ({
|
|
467
469
|
...item,
|
|
468
470
|
key: item.id,
|
|
469
471
|
label: item.title || upperFirst(item.id),
|
|
@@ -529,7 +531,7 @@ function processProps(propsCopy, config) {
|
|
|
529
531
|
function FormItem(props) {
|
|
530
532
|
const [computedProps, setComputedProps] = react$1.useState();
|
|
531
533
|
const [extendTypes, setExtendTypes] = react$1.useState();
|
|
532
|
-
const { theme } = useConfigContext();
|
|
534
|
+
const { theme: theme2 } = useConfigContext();
|
|
533
535
|
const [hidden, setHidden] = react$1.useState(props.hidden || false);
|
|
534
536
|
react$1.useEffect(() => {
|
|
535
537
|
const { extendTypes: extendTypes2, ...propsCopy } = { ...props };
|
|
@@ -549,12 +551,12 @@ function FormItem(props) {
|
|
|
549
551
|
delete propsCopy.if;
|
|
550
552
|
delete propsCopy.hidden;
|
|
551
553
|
}
|
|
552
|
-
setComputedProps(processProps(propsCopy,
|
|
554
|
+
setComputedProps(processProps(propsCopy, theme2.common));
|
|
553
555
|
}, [props]);
|
|
554
556
|
if (!computedProps) return null;
|
|
555
557
|
if (hidden)
|
|
556
558
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, noStyle: true, rules: [], children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { type: "hidden", hidden: true }) });
|
|
557
|
-
if (computedProps.formChildren === null || computedProps.children === null)
|
|
559
|
+
if (computedProps.formChildren === null || computedProps.children === null || computedProps.formRender === null || computedProps.render === null)
|
|
558
560
|
return null;
|
|
559
561
|
const children = computedProps.formChildren || computedProps.children;
|
|
560
562
|
if (children)
|
|
@@ -719,7 +721,7 @@ function FormItem(props) {
|
|
|
719
721
|
danger: true,
|
|
720
722
|
type: "link",
|
|
721
723
|
onClick: () => remove(field.name),
|
|
722
|
-
children:
|
|
724
|
+
children: theme2.common.delete
|
|
723
725
|
}
|
|
724
726
|
)
|
|
725
727
|
] }) }),
|
|
@@ -734,7 +736,7 @@ function FormItem(props) {
|
|
|
734
736
|
onClick: () => add(),
|
|
735
737
|
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusOutlined, {}),
|
|
736
738
|
children: [
|
|
737
|
-
|
|
739
|
+
theme2.common.add,
|
|
738
740
|
" ",
|
|
739
741
|
computedProps.label
|
|
740
742
|
]
|
|
@@ -882,11 +884,11 @@ Form.List = antd.Form.List;
|
|
|
882
884
|
Form.ErrorList = antd.Form.ErrorList;
|
|
883
885
|
Form.Provider = antd.Form.Provider;
|
|
884
886
|
function Link(props) {
|
|
885
|
-
const { theme } = useConfigContext();
|
|
887
|
+
const { theme: theme2 } = useConfigContext();
|
|
886
888
|
const navigate = reactRouterDom.useNavigate();
|
|
887
|
-
const target = props.target ||
|
|
889
|
+
const target = props.target || theme2.Link?.target || (props.href.startsWith("http") ? "_blank" : undefined);
|
|
888
890
|
let computedStyle = {
|
|
889
|
-
...
|
|
891
|
+
...theme2.Link.style || {},
|
|
890
892
|
cursor: "pointer",
|
|
891
893
|
...props.style
|
|
892
894
|
};
|
|
@@ -936,8 +938,8 @@ function Link(props) {
|
|
|
936
938
|
}
|
|
937
939
|
Link.whyDidYouRender = true;
|
|
938
940
|
function PageNotFound() {
|
|
939
|
-
const { theme } = useConfigContext();
|
|
940
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.Result, { status: "404", title:
|
|
941
|
+
const { theme: theme2 } = useConfigContext();
|
|
942
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Result, { status: "404", title: theme2.common.pageNotFound });
|
|
941
943
|
}
|
|
942
944
|
function Routes(props) {
|
|
943
945
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
|
|
@@ -980,7 +982,7 @@ function processValue(item, value) {
|
|
|
980
982
|
}
|
|
981
983
|
function Table(props) {
|
|
982
984
|
const [columns, setColumns] = react$1.useState();
|
|
983
|
-
const { theme } = useConfigContext();
|
|
985
|
+
const { theme: theme2 } = useConfigContext();
|
|
984
986
|
const generateFilterDropdown = (item) => {
|
|
985
987
|
if (item.filterDropdown && item.filterDropdown !== true) return;
|
|
986
988
|
if (item.options.length < 11) {
|
|
@@ -1006,7 +1008,7 @@ function Table(props) {
|
|
|
1006
1008
|
allowClear: true,
|
|
1007
1009
|
showSearch: true,
|
|
1008
1010
|
style: { width: "100%" },
|
|
1009
|
-
placeholder: `${
|
|
1011
|
+
placeholder: `${theme2.common.search} ${item.title}`,
|
|
1010
1012
|
value: selectedKeys,
|
|
1011
1013
|
onChange: (v) => {
|
|
1012
1014
|
setSelectedKeys(v?.length ? v : []);
|
|
@@ -1025,7 +1027,9 @@ function Table(props) {
|
|
|
1025
1027
|
return item;
|
|
1026
1028
|
};
|
|
1027
1029
|
react$1.useEffect(() => {
|
|
1028
|
-
const items = lodashEs.cloneDeep(props.items)
|
|
1030
|
+
const items = lodashEs.cloneDeep(props.items).filter(
|
|
1031
|
+
(item) => !(item.tableChildren === null || item.children === null || item.tableRender === null || item.render === null)
|
|
1032
|
+
);
|
|
1029
1033
|
for (const item of items) {
|
|
1030
1034
|
if (!item.key) item.key = item.id;
|
|
1031
1035
|
if (!item.dataIndex) item.dataIndex = item.id;
|
|
@@ -1042,11 +1046,6 @@ function Table(props) {
|
|
|
1042
1046
|
});
|
|
1043
1047
|
generateFilterDropdown(item);
|
|
1044
1048
|
}
|
|
1045
|
-
const isNull = item.tableChildren === null || item.children === null;
|
|
1046
|
-
if (isNull) {
|
|
1047
|
-
item.render = () => null;
|
|
1048
|
-
continue;
|
|
1049
|
-
}
|
|
1050
1049
|
const children = item.tableChildren || item.children;
|
|
1051
1050
|
if (children) {
|
|
1052
1051
|
item.render = (value, values) => cloneUnionFaasItemElement(children, {
|
|
@@ -1096,7 +1095,7 @@ function Table(props) {
|
|
|
1096
1095
|
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1097
1096
|
antd.Input.Search,
|
|
1098
1097
|
{
|
|
1099
|
-
placeholder: `${
|
|
1098
|
+
placeholder: `${theme2.common.search} ${item.title}`,
|
|
1100
1099
|
allowClear: true,
|
|
1101
1100
|
onSearch: (v) => {
|
|
1102
1101
|
if (v) {
|
|
@@ -1132,7 +1131,7 @@ function Table(props) {
|
|
|
1132
1131
|
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1133
1132
|
antd.Input.Search,
|
|
1134
1133
|
{
|
|
1135
|
-
placeholder: `${
|
|
1134
|
+
placeholder: `${theme2.common.search} ${item.title}`,
|
|
1136
1135
|
allowClear: true,
|
|
1137
1136
|
onSearch: (v) => {
|
|
1138
1137
|
if (v) {
|
|
@@ -1166,7 +1165,7 @@ function Table(props) {
|
|
|
1166
1165
|
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1167
1166
|
antd.Input.Search,
|
|
1168
1167
|
{
|
|
1169
|
-
placeholder: `${
|
|
1168
|
+
placeholder: `${theme2.common.search} ${item.title}`,
|
|
1170
1169
|
allowClear: true,
|
|
1171
1170
|
onSearch: (v) => {
|
|
1172
1171
|
if (v) {
|
|
@@ -1200,7 +1199,7 @@ function Table(props) {
|
|
|
1200
1199
|
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1201
1200
|
antd.Input.Search,
|
|
1202
1201
|
{
|
|
1203
|
-
placeholder: `${
|
|
1202
|
+
placeholder: `${theme2.common.search} ${item.title}`,
|
|
1204
1203
|
allowClear: true,
|
|
1205
1204
|
onSearch: (v) => {
|
|
1206
1205
|
if (v) {
|
|
@@ -1258,7 +1257,7 @@ function Table(props) {
|
|
|
1258
1257
|
confirm();
|
|
1259
1258
|
},
|
|
1260
1259
|
children: [
|
|
1261
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { children:
|
|
1260
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { children: theme2.common.all }),
|
|
1262
1261
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "true", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1263
1262
|
icons.CheckOutlined,
|
|
1264
1263
|
{
|
|
@@ -1277,7 +1276,7 @@ function Table(props) {
|
|
|
1277
1276
|
}
|
|
1278
1277
|
}
|
|
1279
1278
|
) }),
|
|
1280
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "null", children:
|
|
1279
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Radio.Button, { value: "null", children: theme2.common.blank })
|
|
1281
1280
|
]
|
|
1282
1281
|
}
|
|
1283
1282
|
);
|
|
@@ -1544,11 +1543,11 @@ function Tabs(props) {
|
|
|
1544
1543
|
}
|
|
1545
1544
|
Tabs.whyDidYouRender = true;
|
|
1546
1545
|
function Title(props) {
|
|
1547
|
-
const { theme } = useConfigContext();
|
|
1546
|
+
const { theme: theme2 } = useConfigContext();
|
|
1548
1547
|
react$1.useEffect(() => {
|
|
1549
1548
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1550
|
-
document.title = title.concat(props.suffix ||
|
|
1551
|
-
}, [props,
|
|
1549
|
+
document.title = title.concat(props.suffix || theme2.Title.suffix).filter((t) => !!t).join(props.separator || theme2.Title.separator);
|
|
1550
|
+
}, [props, theme2.Title]);
|
|
1552
1551
|
if (props.h1) {
|
|
1553
1552
|
if (typeof props.h1 === "boolean")
|
|
1554
1553
|
return /* @__PURE__ */ jsxRuntime.jsx("h1", { children: Array.isArray(props.title) ? props.title[0] : props.title });
|
|
@@ -1561,6 +1560,10 @@ function Title(props) {
|
|
|
1561
1560
|
return null;
|
|
1562
1561
|
}
|
|
1563
1562
|
Title.whyDidYouRender = true;
|
|
1563
|
+
function useThemeToken() {
|
|
1564
|
+
const config = antd.theme.useToken();
|
|
1565
|
+
return config.token;
|
|
1566
|
+
}
|
|
1564
1567
|
|
|
1565
1568
|
Object.defineProperty(exports, "faas", {
|
|
1566
1569
|
enumerable: true,
|
|
@@ -1600,4 +1603,5 @@ exports.useApp = useApp;
|
|
|
1600
1603
|
exports.useConfigContext = useConfigContext;
|
|
1601
1604
|
exports.useDrawer = useDrawer;
|
|
1602
1605
|
exports.useModal = useModal;
|
|
1606
|
+
exports.useThemeToken = useThemeToken;
|
|
1603
1607
|
exports.withFaasData = withFaasData;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { FaasReactClientOptions, ErrorBoundaryProps, FaasDataInjection as FaasDa
|
|
|
2
2
|
export { ErrorBoundaryProps, faas, useFaas } from '@faasjs/react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { StyleProviderProps } from '@ant-design/cssinjs';
|
|
5
|
-
import { DrawerProps as DrawerProps$1, ModalProps as ModalProps$1, ConfigProviderProps as ConfigProviderProps$1, DescriptionsProps, FormItemProps as FormItemProps$1, FormInstance, InputProps, SelectProps, RadioProps, InputNumberProps, SwitchProps, DatePickerProps, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, FormProps as FormProps$1, ButtonProps, TabsProps as TabsProps$1 } from 'antd';
|
|
5
|
+
import { DrawerProps as DrawerProps$1, ModalProps as ModalProps$1, ConfigProviderProps as ConfigProviderProps$1, DescriptionsProps, FormItemProps as FormItemProps$1, FormInstance, InputProps, SelectProps, RadioProps, InputNumberProps, SwitchProps, DatePickerProps, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, FormProps as FormProps$1, ButtonProps, TabsProps as TabsProps$1, GlobalToken } from 'antd';
|
|
6
6
|
import { MessageInstance } from 'antd/es/message/interface';
|
|
7
7
|
import { NotificationInstance } from 'antd/es/notification/interface';
|
|
8
8
|
import { BrowserRouterProps, RouteProps } from 'react-router-dom';
|
|
@@ -302,10 +302,10 @@ interface ExtendDescriptionTypeProps<T = any> {
|
|
|
302
302
|
}
|
|
303
303
|
type ExtendDescriptionItemProps = BaseItemProps;
|
|
304
304
|
interface DescriptionItemProps<T = any> extends FaasItemProps {
|
|
305
|
-
children?: UnionFaasItemElement<T
|
|
306
|
-
descriptionChildren?: UnionFaasItemElement<T
|
|
307
|
-
render?: UnionFaasItemRender<T
|
|
308
|
-
descriptionRender?: UnionFaasItemRender<T
|
|
305
|
+
children?: UnionFaasItemElement<T> | null;
|
|
306
|
+
descriptionChildren?: UnionFaasItemElement<T> | null;
|
|
307
|
+
render?: UnionFaasItemRender<T> | null;
|
|
308
|
+
descriptionRender?: UnionFaasItemRender<T> | null;
|
|
309
309
|
if?: (values: Record<string, any>) => boolean;
|
|
310
310
|
object?: DescriptionItemProps<T>[];
|
|
311
311
|
}
|
|
@@ -379,10 +379,10 @@ interface FormItemProps<T = any> extends BaseItemProps, Omit<FormItemProps$1<T>,
|
|
|
379
379
|
disabled?: boolean;
|
|
380
380
|
required?: boolean;
|
|
381
381
|
col?: number;
|
|
382
|
-
children?: UnionFaasItemElement<T
|
|
383
|
-
formChildren?: UnionFaasItemElement<T
|
|
384
|
-
render?: UnionFaasItemRender<T
|
|
385
|
-
formRender?: UnionFaasItemRender<T
|
|
382
|
+
children?: UnionFaasItemElement<T> | null;
|
|
383
|
+
formChildren?: UnionFaasItemElement<T> | null;
|
|
384
|
+
render?: UnionFaasItemRender<T> | null;
|
|
385
|
+
formRender?: UnionFaasItemRender<T> | null;
|
|
386
386
|
rules?: RuleObject[];
|
|
387
387
|
label?: string | false;
|
|
388
388
|
extendTypes?: ExtendTypes;
|
|
@@ -456,10 +456,10 @@ declare namespace FormItem {
|
|
|
456
456
|
|
|
457
457
|
interface TableItemProps<T = any> extends FaasItemProps, Omit<TableColumnProps<T>, 'title' | 'children' | 'render'> {
|
|
458
458
|
optionsType?: 'auto';
|
|
459
|
-
children?: UnionFaasItemElement<T
|
|
460
|
-
tableChildren?: UnionFaasItemElement<T
|
|
461
|
-
render?: UnionFaasItemRender<T
|
|
462
|
-
tableRender?: UnionFaasItemRender<T
|
|
459
|
+
children?: UnionFaasItemElement<T> | null;
|
|
460
|
+
tableChildren?: UnionFaasItemElement<T> | null;
|
|
461
|
+
render?: UnionFaasItemRender<T> | null;
|
|
462
|
+
tableRender?: UnionFaasItemRender<T> | null;
|
|
463
463
|
object?: TableItemProps<T>[];
|
|
464
464
|
}
|
|
465
465
|
type ExtendTableTypeProps<T = any> = {
|
|
@@ -582,9 +582,6 @@ type UnionFaasItemRender<Value = any, Values = any> = (value: Value, values: Val
|
|
|
582
582
|
/**
|
|
583
583
|
* Represents a React element that is used in the UnionFaasItem context.
|
|
584
584
|
*
|
|
585
|
-
* @template Value - The type of the value associated with the element. Defaults to `any`.
|
|
586
|
-
* @template Values - The type of the values associated with the element. Defaults to `any`.
|
|
587
|
-
*
|
|
588
585
|
* This type can either be a React element with the specified injection types or `null`.
|
|
589
586
|
*
|
|
590
587
|
* @example
|
|
@@ -628,10 +625,10 @@ type UnionFaasItemElement<Value = any, Values = any> = ReactElement<UnionFaasIte
|
|
|
628
625
|
*
|
|
629
626
|
* ### Render Priority Order
|
|
630
627
|
*
|
|
631
|
-
* 1. **Null Rendering**
|
|
632
|
-
* 1. Returns `null` if specific children props are null:
|
|
633
|
-
* - `formChildren` / `descriptionChildren` / `tableChildren`
|
|
634
|
-
* 2. Returns `null` if `children` prop is null
|
|
628
|
+
* 1. **Null Rendering** (Notice: it also doesn't render column in table and description)
|
|
629
|
+
* 1. Returns `null` if specific children or render props are null:
|
|
630
|
+
* - `formChildren` / `descriptionChildren` / `tableChildren` / `formRender` / `descriptionRender` / `tableRender`
|
|
631
|
+
* 2. Returns `null` if `children` or `render` prop is null
|
|
635
632
|
* 2. **Children Rendering**
|
|
636
633
|
* 1. First priority: Component-specific children
|
|
637
634
|
* - `formChildren` for Form
|
|
@@ -686,8 +683,8 @@ type UnionFaasItemElement<Value = any, Values = any> = ReactElement<UnionFaasIte
|
|
|
686
683
|
* ```
|
|
687
684
|
*/
|
|
688
685
|
interface UnionFaasItemProps<Value = any, Values = any> extends FormItemProps, DescriptionItemProps, TableItemProps {
|
|
689
|
-
children?: UnionFaasItemElement<
|
|
690
|
-
render?: UnionFaasItemRender<Value, Values
|
|
686
|
+
children?: UnionFaasItemElement<Value, Values> | null;
|
|
687
|
+
render?: UnionFaasItemRender<Value, Values> | null;
|
|
691
688
|
object?: UnionFaasItemProps<Value, Values>[];
|
|
692
689
|
}
|
|
693
690
|
/**
|
|
@@ -907,4 +904,14 @@ declare namespace Title {
|
|
|
907
904
|
var whyDidYouRender: boolean;
|
|
908
905
|
}
|
|
909
906
|
|
|
910
|
-
|
|
907
|
+
/**
|
|
908
|
+
* Hook to retrieve the theme token from the Ant Design theme configuration.
|
|
909
|
+
*
|
|
910
|
+
* This function uses the `theme.useToken` method to get the current theme configuration
|
|
911
|
+
* and returns the `token` property from the configuration.
|
|
912
|
+
*
|
|
913
|
+
* @returns {GlobalToken} The theme token from the Ant Design theme configuration.
|
|
914
|
+
*/
|
|
915
|
+
declare function useThemeToken(): GlobalToken;
|
|
916
|
+
|
|
917
|
+
export { App, type AppProps, type BaseItemProps, type BaseOption, Blank, type BlankProps, ConfigContext, ConfigProvider, type ConfigProviderProps, Description, type DescriptionItemContentProps, type DescriptionItemProps, type DescriptionProps, Drawer, type DrawerProps, ErrorBoundary, type ExtendDescriptionItemProps, type ExtendDescriptionTypeProps, type ExtendFormItemProps, type ExtendFormTypeProps, type ExtendTableItemProps, type ExtendTableTypeProps, type ExtendTypes, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, type FaasItemProps, type FaasItemType, type FaasItemTypeValue, Form, FormItem, type FormItemProps, type FormProps, type FormSubmitProps, Link, type LinkProps, Loading, type LoadingProps, Modal, type ModalProps, PageNotFound, Routes, type RoutesProps, type TabProps, Table, type TableItemProps, type TableProps, Tabs, type TabsProps, Title, type TitleProps, type UnionFaasItemElement, type UnionFaasItemInjection, type UnionFaasItemProps, type UnionFaasItemRender, type UnionScene, cloneUnionFaasItemElement, type setDrawerProps, type setModalProps, transferOptions, transferValue, upperFirst, useApp, type useAppProps, useConfigContext, useDrawer, useModal, useThemeToken, withFaasData };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createSplittingContext, useEqualEffect, FaasReactClient, useEqualCallback, ErrorBoundary as ErrorBoundary$1, useEqualMemo, OptionalWrapper, FaasDataWrapper as FaasDataWrapper$1, withFaasData as withFaasData$1, faas } from '@faasjs/react';
|
|
2
2
|
export { faas, useFaas } from '@faasjs/react';
|
|
3
3
|
import { legacyLogicalPropertiesTransformer, StyleProvider } from '@ant-design/cssinjs';
|
|
4
|
-
import { Form as Form$1, Drawer as Drawer$1, Modal as Modal$1, message, notification, ConfigProvider as ConfigProvider$1, Typography, Spin, Descriptions, Input, Button, Row, Col, DatePicker, Switch, Select, InputNumber, Radio, Result, Skeleton, Table as Table$1, Tabs as Tabs$1, Alert, Space } from 'antd';
|
|
4
|
+
import { Form as Form$1, Drawer as Drawer$1, Modal as Modal$1, message, notification, ConfigProvider as ConfigProvider$1, Typography, Spin, Descriptions, Input, Button, Row, Col, DatePicker, Switch, Select, InputNumber, Radio, Result, Skeleton, Table as Table$1, Tabs as Tabs$1, theme, Alert, Space } from 'antd';
|
|
5
5
|
import { BrowserRouter, useNavigate, Routes as Routes$1, Route, useLocation } from 'react-router-dom';
|
|
6
6
|
import { defaultsDeep, cloneDeep, isNil, uniqBy } from 'lodash-es';
|
|
7
7
|
import { createContext, useState, useContext, cloneElement, isValidElement, createElement, useEffect, Suspense } from 'react';
|
|
@@ -50,7 +50,7 @@ var ConfigContext = createContext({
|
|
|
50
50
|
theme: baseTheme
|
|
51
51
|
});
|
|
52
52
|
function ConfigProvider(props) {
|
|
53
|
-
const [
|
|
53
|
+
const [theme2, setTheme] = useState(baseTheme);
|
|
54
54
|
useEqualEffect(() => {
|
|
55
55
|
const lang = props.theme?.lang || (!props.theme?.lang && /^zh/i.test(navigator.language) ? "zh" : "en");
|
|
56
56
|
if (lang === "zh") {
|
|
@@ -69,8 +69,8 @@ function ConfigProvider(props) {
|
|
|
69
69
|
} else setTheme(defaultsDeep(props.theme, baseTheme));
|
|
70
70
|
if (props.faasClientOptions) FaasReactClient(props.faasClientOptions);
|
|
71
71
|
}, [props.theme]);
|
|
72
|
-
if (!
|
|
73
|
-
return /* @__PURE__ */ jsx(ConfigContext.Provider, { value: { theme }, children: props.children });
|
|
72
|
+
if (!theme2) return null;
|
|
73
|
+
return /* @__PURE__ */ jsx(ConfigContext.Provider, { value: { theme: theme2 }, children: props.children });
|
|
74
74
|
}
|
|
75
75
|
function useConfigContext() {
|
|
76
76
|
return useContext(ConfigContext);
|
|
@@ -233,8 +233,8 @@ var useApp = AppContext.use;
|
|
|
233
233
|
App.useApp = useApp;
|
|
234
234
|
App.whyDidYouRender = true;
|
|
235
235
|
function Blank(options) {
|
|
236
|
-
const { theme } = useConfigContext();
|
|
237
|
-
return !options || options.value === undefined || options.value === null || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx(Typography.Text, { disabled: true, children: options?.text ||
|
|
236
|
+
const { theme: theme2 } = useConfigContext();
|
|
237
|
+
return !options || options.value === undefined || options.value === null || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx(Typography.Text, { disabled: true, children: options?.text || theme2.Blank.text }) : options.value;
|
|
238
238
|
}
|
|
239
239
|
Blank.whyDidYouRender = true;
|
|
240
240
|
function upperFirst(str) {
|
|
@@ -338,7 +338,7 @@ function DescriptionItemContent(props) {
|
|
|
338
338
|
setComputedProps(propsCopy);
|
|
339
339
|
}, [props]);
|
|
340
340
|
if (!computedProps) return null;
|
|
341
|
-
if (computedProps.item.descriptionChildren === null || computedProps.item.children === null)
|
|
341
|
+
if (computedProps.item.descriptionChildren === null || computedProps.item.children === null || computedProps.item.descriptionRender === null || computedProps.item.render === null)
|
|
342
342
|
return null;
|
|
343
343
|
const children = computedProps.item.descriptionChildren || computedProps.item.children;
|
|
344
344
|
if (children)
|
|
@@ -459,7 +459,9 @@ function Description({
|
|
|
459
459
|
{
|
|
460
460
|
...props,
|
|
461
461
|
title: typeof renderTitle === "function" ? renderTitle(dataSource) : props.title,
|
|
462
|
-
items: props.items.filter(
|
|
462
|
+
items: props.items.filter(
|
|
463
|
+
(item) => item && !(item.descriptionChildren === null || item.children === null || item.descriptionRender === null || item.render === null) && (!item.if || item.if(dataSource))
|
|
464
|
+
).map((item) => ({
|
|
463
465
|
...item,
|
|
464
466
|
key: item.id,
|
|
465
467
|
label: item.title || upperFirst(item.id),
|
|
@@ -525,7 +527,7 @@ function processProps(propsCopy, config) {
|
|
|
525
527
|
function FormItem(props) {
|
|
526
528
|
const [computedProps, setComputedProps] = useState();
|
|
527
529
|
const [extendTypes, setExtendTypes] = useState();
|
|
528
|
-
const { theme } = useConfigContext();
|
|
530
|
+
const { theme: theme2 } = useConfigContext();
|
|
529
531
|
const [hidden, setHidden] = useState(props.hidden || false);
|
|
530
532
|
useEffect(() => {
|
|
531
533
|
const { extendTypes: extendTypes2, ...propsCopy } = { ...props };
|
|
@@ -545,12 +547,12 @@ function FormItem(props) {
|
|
|
545
547
|
delete propsCopy.if;
|
|
546
548
|
delete propsCopy.hidden;
|
|
547
549
|
}
|
|
548
|
-
setComputedProps(processProps(propsCopy,
|
|
550
|
+
setComputedProps(processProps(propsCopy, theme2.common));
|
|
549
551
|
}, [props]);
|
|
550
552
|
if (!computedProps) return null;
|
|
551
553
|
if (hidden)
|
|
552
554
|
return /* @__PURE__ */ jsx(Form$1.Item, { ...computedProps, noStyle: true, rules: [], children: /* @__PURE__ */ jsx(Input, { type: "hidden", hidden: true }) });
|
|
553
|
-
if (computedProps.formChildren === null || computedProps.children === null)
|
|
555
|
+
if (computedProps.formChildren === null || computedProps.children === null || computedProps.formRender === null || computedProps.render === null)
|
|
554
556
|
return null;
|
|
555
557
|
const children = computedProps.formChildren || computedProps.children;
|
|
556
558
|
if (children)
|
|
@@ -715,7 +717,7 @@ function FormItem(props) {
|
|
|
715
717
|
danger: true,
|
|
716
718
|
type: "link",
|
|
717
719
|
onClick: () => remove(field.name),
|
|
718
|
-
children:
|
|
720
|
+
children: theme2.common.delete
|
|
719
721
|
}
|
|
720
722
|
)
|
|
721
723
|
] }) }),
|
|
@@ -730,7 +732,7 @@ function FormItem(props) {
|
|
|
730
732
|
onClick: () => add(),
|
|
731
733
|
icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
|
|
732
734
|
children: [
|
|
733
|
-
|
|
735
|
+
theme2.common.add,
|
|
734
736
|
" ",
|
|
735
737
|
computedProps.label
|
|
736
738
|
]
|
|
@@ -878,11 +880,11 @@ Form.List = Form$1.List;
|
|
|
878
880
|
Form.ErrorList = Form$1.ErrorList;
|
|
879
881
|
Form.Provider = Form$1.Provider;
|
|
880
882
|
function Link(props) {
|
|
881
|
-
const { theme } = useConfigContext();
|
|
883
|
+
const { theme: theme2 } = useConfigContext();
|
|
882
884
|
const navigate = useNavigate();
|
|
883
|
-
const target = props.target ||
|
|
885
|
+
const target = props.target || theme2.Link?.target || (props.href.startsWith("http") ? "_blank" : undefined);
|
|
884
886
|
let computedStyle = {
|
|
885
|
-
...
|
|
887
|
+
...theme2.Link.style || {},
|
|
886
888
|
cursor: "pointer",
|
|
887
889
|
...props.style
|
|
888
890
|
};
|
|
@@ -932,8 +934,8 @@ function Link(props) {
|
|
|
932
934
|
}
|
|
933
935
|
Link.whyDidYouRender = true;
|
|
934
936
|
function PageNotFound() {
|
|
935
|
-
const { theme } = useConfigContext();
|
|
936
|
-
return /* @__PURE__ */ jsx(Result, { status: "404", title:
|
|
937
|
+
const { theme: theme2 } = useConfigContext();
|
|
938
|
+
return /* @__PURE__ */ jsx(Result, { status: "404", title: theme2.common.pageNotFound });
|
|
937
939
|
}
|
|
938
940
|
function Routes(props) {
|
|
939
941
|
return /* @__PURE__ */ jsxs(Routes$1, { children: [
|
|
@@ -976,7 +978,7 @@ function processValue(item, value) {
|
|
|
976
978
|
}
|
|
977
979
|
function Table(props) {
|
|
978
980
|
const [columns, setColumns] = useState();
|
|
979
|
-
const { theme } = useConfigContext();
|
|
981
|
+
const { theme: theme2 } = useConfigContext();
|
|
980
982
|
const generateFilterDropdown = (item) => {
|
|
981
983
|
if (item.filterDropdown && item.filterDropdown !== true) return;
|
|
982
984
|
if (item.options.length < 11) {
|
|
@@ -1002,7 +1004,7 @@ function Table(props) {
|
|
|
1002
1004
|
allowClear: true,
|
|
1003
1005
|
showSearch: true,
|
|
1004
1006
|
style: { width: "100%" },
|
|
1005
|
-
placeholder: `${
|
|
1007
|
+
placeholder: `${theme2.common.search} ${item.title}`,
|
|
1006
1008
|
value: selectedKeys,
|
|
1007
1009
|
onChange: (v) => {
|
|
1008
1010
|
setSelectedKeys(v?.length ? v : []);
|
|
@@ -1021,7 +1023,9 @@ function Table(props) {
|
|
|
1021
1023
|
return item;
|
|
1022
1024
|
};
|
|
1023
1025
|
useEffect(() => {
|
|
1024
|
-
const items = cloneDeep(props.items)
|
|
1026
|
+
const items = cloneDeep(props.items).filter(
|
|
1027
|
+
(item) => !(item.tableChildren === null || item.children === null || item.tableRender === null || item.render === null)
|
|
1028
|
+
);
|
|
1025
1029
|
for (const item of items) {
|
|
1026
1030
|
if (!item.key) item.key = item.id;
|
|
1027
1031
|
if (!item.dataIndex) item.dataIndex = item.id;
|
|
@@ -1038,11 +1042,6 @@ function Table(props) {
|
|
|
1038
1042
|
});
|
|
1039
1043
|
generateFilterDropdown(item);
|
|
1040
1044
|
}
|
|
1041
|
-
const isNull = item.tableChildren === null || item.children === null;
|
|
1042
|
-
if (isNull) {
|
|
1043
|
-
item.render = () => null;
|
|
1044
|
-
continue;
|
|
1045
|
-
}
|
|
1046
1045
|
const children = item.tableChildren || item.children;
|
|
1047
1046
|
if (children) {
|
|
1048
1047
|
item.render = (value, values) => cloneUnionFaasItemElement(children, {
|
|
@@ -1092,7 +1091,7 @@ function Table(props) {
|
|
|
1092
1091
|
}) => /* @__PURE__ */ jsx(
|
|
1093
1092
|
Input.Search,
|
|
1094
1093
|
{
|
|
1095
|
-
placeholder: `${
|
|
1094
|
+
placeholder: `${theme2.common.search} ${item.title}`,
|
|
1096
1095
|
allowClear: true,
|
|
1097
1096
|
onSearch: (v) => {
|
|
1098
1097
|
if (v) {
|
|
@@ -1128,7 +1127,7 @@ function Table(props) {
|
|
|
1128
1127
|
}) => /* @__PURE__ */ jsx(
|
|
1129
1128
|
Input.Search,
|
|
1130
1129
|
{
|
|
1131
|
-
placeholder: `${
|
|
1130
|
+
placeholder: `${theme2.common.search} ${item.title}`,
|
|
1132
1131
|
allowClear: true,
|
|
1133
1132
|
onSearch: (v) => {
|
|
1134
1133
|
if (v) {
|
|
@@ -1162,7 +1161,7 @@ function Table(props) {
|
|
|
1162
1161
|
}) => /* @__PURE__ */ jsx(
|
|
1163
1162
|
Input.Search,
|
|
1164
1163
|
{
|
|
1165
|
-
placeholder: `${
|
|
1164
|
+
placeholder: `${theme2.common.search} ${item.title}`,
|
|
1166
1165
|
allowClear: true,
|
|
1167
1166
|
onSearch: (v) => {
|
|
1168
1167
|
if (v) {
|
|
@@ -1196,7 +1195,7 @@ function Table(props) {
|
|
|
1196
1195
|
}) => /* @__PURE__ */ jsx(
|
|
1197
1196
|
Input.Search,
|
|
1198
1197
|
{
|
|
1199
|
-
placeholder: `${
|
|
1198
|
+
placeholder: `${theme2.common.search} ${item.title}`,
|
|
1200
1199
|
allowClear: true,
|
|
1201
1200
|
onSearch: (v) => {
|
|
1202
1201
|
if (v) {
|
|
@@ -1254,7 +1253,7 @@ function Table(props) {
|
|
|
1254
1253
|
confirm();
|
|
1255
1254
|
},
|
|
1256
1255
|
children: [
|
|
1257
|
-
/* @__PURE__ */ jsx(Radio.Button, { children:
|
|
1256
|
+
/* @__PURE__ */ jsx(Radio.Button, { children: theme2.common.all }),
|
|
1258
1257
|
/* @__PURE__ */ jsx(Radio.Button, { value: "true", children: /* @__PURE__ */ jsx(
|
|
1259
1258
|
CheckOutlined,
|
|
1260
1259
|
{
|
|
@@ -1273,7 +1272,7 @@ function Table(props) {
|
|
|
1273
1272
|
}
|
|
1274
1273
|
}
|
|
1275
1274
|
) }),
|
|
1276
|
-
/* @__PURE__ */ jsx(Radio.Button, { value: "null", children:
|
|
1275
|
+
/* @__PURE__ */ jsx(Radio.Button, { value: "null", children: theme2.common.blank })
|
|
1277
1276
|
]
|
|
1278
1277
|
}
|
|
1279
1278
|
);
|
|
@@ -1540,11 +1539,11 @@ function Tabs(props) {
|
|
|
1540
1539
|
}
|
|
1541
1540
|
Tabs.whyDidYouRender = true;
|
|
1542
1541
|
function Title(props) {
|
|
1543
|
-
const { theme } = useConfigContext();
|
|
1542
|
+
const { theme: theme2 } = useConfigContext();
|
|
1544
1543
|
useEffect(() => {
|
|
1545
1544
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1546
|
-
document.title = title.concat(props.suffix ||
|
|
1547
|
-
}, [props,
|
|
1545
|
+
document.title = title.concat(props.suffix || theme2.Title.suffix).filter((t) => !!t).join(props.separator || theme2.Title.separator);
|
|
1546
|
+
}, [props, theme2.Title]);
|
|
1548
1547
|
if (props.h1) {
|
|
1549
1548
|
if (typeof props.h1 === "boolean")
|
|
1550
1549
|
return /* @__PURE__ */ jsx("h1", { children: Array.isArray(props.title) ? props.title[0] : props.title });
|
|
@@ -1557,5 +1556,9 @@ function Title(props) {
|
|
|
1557
1556
|
return null;
|
|
1558
1557
|
}
|
|
1559
1558
|
Title.whyDidYouRender = true;
|
|
1559
|
+
function useThemeToken() {
|
|
1560
|
+
const config = theme.useToken();
|
|
1561
|
+
return config.token;
|
|
1562
|
+
}
|
|
1560
1563
|
|
|
1561
|
-
export { App, Blank, ConfigContext, ConfigProvider, Description, Drawer, ErrorBoundary, FaasDataWrapper, Form, FormItem, Link, Loading, Modal, PageNotFound, Routes, Table, Tabs, Title, cloneUnionFaasItemElement, transferOptions, transferValue, upperFirst, useApp, useConfigContext, useDrawer, useModal, withFaasData };
|
|
1564
|
+
export { App, Blank, ConfigContext, ConfigProvider, Description, Drawer, ErrorBoundary, FaasDataWrapper, Form, FormItem, Link, Loading, Modal, PageNotFound, Routes, Table, Tabs, Title, cloneUnionFaasItemElement, transferOptions, transferValue, upperFirst, useApp, useConfigContext, useDrawer, useModal, useThemeToken, withFaasData };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@faasjs/react": "6.4.
|
|
33
|
+
"@faasjs/react": "6.4.3",
|
|
34
34
|
"antd": "*",
|
|
35
35
|
"@ant-design/icons": "*",
|
|
36
36
|
"lodash-es": "*",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/lodash-es": "*",
|
|
43
|
-
"@faasjs/react": "6.4.
|
|
43
|
+
"@faasjs/react": "6.4.3",
|
|
44
44
|
"antd": "*",
|
|
45
45
|
"@ant-design/icons": "*",
|
|
46
46
|
"lodash-es": "*",
|