@faasjs/ant-design 8.0.0-beta.14 → 8.0.0-beta.15

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 CHANGED
@@ -1,44 +1,5 @@
1
1
  # @faasjs/ant-design
2
2
 
3
- UI components based on [FaasJS](https://faasjs.com), [Ant Design](https://ant.design) and [React Router](https://reactrouter.com).
4
-
5
- [![License: MIT](https://img.shields.io/npm/l/@faasjs/ant-design.svg)](https://github.com/faasjs/faasjs/blob/main/packages/ant-design/LICENSE)
6
- [![NPM Version](https://img.shields.io/npm/v/@faasjs/ant-design.svg)](https://www.npmjs.com/package/@faasjs/ant-design)
7
-
8
- ## Features
9
-
10
- - [App](https://faasjs.com/doc/ant-design/functions/App.html) component with Ant Design & FaasJS.
11
- - [UnionFaasItemElement](https://faasjs.com/doc/ant-design/type-aliases/UnionFaasItemElement.html) and [UnionFaasItemRender](https://faasjs.com/doc/ant-design/type-aliases/UnionFaasItemRender.html) for custom union rendering.
12
-
13
- ## Install
14
-
15
- ```sh
16
- npm install @faasjs/ant-design
17
- ```
18
-
19
- ## Usage
20
-
21
- In `@faasjs/ant-design`, we use `FaasItemProps` to provide data structures for components.
22
-
23
- ```ts
24
- type FaasItemType =
25
- | 'string'
26
- | 'string[]'
27
- | 'number'
28
- | 'number[]'
29
- | 'boolean'
30
- | 'date'
31
- | 'time'
32
- | 'object'
33
- | 'object[]'
34
-
35
- type FaasItemProps = {
36
- type: FaasItemTypes
37
- id: string
38
- title?: string
39
- }
40
- ```
41
-
42
3
  ## Functions
43
4
 
44
5
  - [App](functions/App.md)
package/dist/index.cjs CHANGED
@@ -47,7 +47,7 @@ function Loading(props) {
47
47
  if (props.loading === false) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: props.children });
48
48
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
49
49
  style: {
50
- ...props.style || {},
50
+ ...props.style,
51
51
  ...!props.size || props.size === "large" ? {
52
52
  margin: "20vh auto",
53
53
  textAlign: "center"
@@ -470,7 +470,7 @@ function cloneUnionFaasItemElement(element, props) {
470
470
  //#region src/Description.tsx
471
471
  function DescriptionItemContent(props) {
472
472
  const [computedProps, setComputedProps] = (0, react.useState)();
473
- (0, react.useEffect)(() => {
473
+ (0, _faasjs_react.useEqualEffect)(() => {
474
474
  const propsCopy = { ...props };
475
475
  propsCopy.item.title = propsCopy.item.title ?? idToTitle(propsCopy.item.id);
476
476
  if (!propsCopy.item.type) propsCopy.item.type = "string";
@@ -651,7 +651,7 @@ function FormItem(props) {
651
651
  const [extendTypes, setExtendTypes] = (0, react.useState)();
652
652
  const { theme } = useConfigContext();
653
653
  const [hidden, setHidden] = (0, react.useState)(props.hidden || false);
654
- (0, react.useEffect)(() => {
654
+ (0, _faasjs_react.useEqualEffect)(() => {
655
655
  const { extendTypes, ...propsCopy } = { ...props };
656
656
  if (extendTypes) setExtendTypes(extendTypes);
657
657
  if (propsCopy.if) {
@@ -668,7 +668,11 @@ function FormItem(props) {
668
668
  delete propsCopy.hidden;
669
669
  }
670
670
  setComputedProps(processProps(propsCopy, theme.common));
671
- }, [props]);
671
+ }, [
672
+ hidden,
673
+ props,
674
+ theme.common
675
+ ]);
672
676
  if (!computedProps) return null;
673
677
  const itemType = computedProps.type ?? "string";
674
678
  if (hidden) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Form.Item, {
@@ -900,19 +904,21 @@ function Form(props) {
900
904
  const [extendTypes, setExtendTypes] = (0, react.useState)();
901
905
  const [form] = antd.Form.useForm(props.form);
902
906
  const [initialValues, setInitialValues] = (0, react.useState)(props.initialValues || Object.create(null));
903
- (0, react.useEffect)(() => {
907
+ (0, _faasjs_react.useEqualEffect)(() => {
904
908
  const { submit, ...propsCopy } = {
905
909
  ...props,
906
910
  form
907
911
  };
912
+ let nextInitialValues = propsCopy.initialValues;
908
913
  if (typeof submit !== "undefined") setSubmit(submit);
909
914
  if (propsCopy.initialValues && propsCopy.items?.length) {
910
915
  for (const key in propsCopy.initialValues) propsCopy.initialValues[key] = transferValue(propsCopy.items.find((item) => isFormItemProps(item) && item.id === key)?.type, propsCopy.initialValues[key]);
916
+ nextInitialValues = propsCopy.initialValues;
911
917
  setInitialValues(propsCopy.initialValues);
912
918
  delete propsCopy.initialValues;
913
919
  }
914
920
  if (propsCopy.items?.length) {
915
- for (const item of propsCopy.items) if (isFormItemProps(item) && item.if) item.hidden = !item.if(initialValues || Object.create(null));
921
+ for (const item of propsCopy.items) if (isFormItemProps(item) && item.if) item.hidden = !item.if(nextInitialValues || Object.create(null));
916
922
  }
917
923
  const submitTo = typeof submit === "object" ? submit.to : void 0;
918
924
  if (propsCopy.onFinish) {
@@ -951,7 +957,7 @@ function Form(props) {
951
957
  delete propsCopy.extendTypes;
952
958
  }
953
959
  setComputedProps(propsCopy);
954
- }, [props]);
960
+ }, [form, props]);
955
961
  const onValuesChange = (0, _faasjs_react.useEqualCallback)((changedValues, allValues) => {
956
962
  console.debug("Form:onValuesChange", changedValues, allValues);
957
963
  if (props.onValuesChange) props.onValuesChange(changedValues, allValues);
@@ -961,12 +967,12 @@ function Form(props) {
961
967
  if (item?.onValueChange) item.onValueChange(changedValues[key], allValues, form);
962
968
  }
963
969
  }, [computedProps]);
964
- (0, react.useEffect)(() => {
970
+ (0, _faasjs_react.useEqualEffect)(() => {
965
971
  if (!initialValues) return;
966
972
  console.debug("Form:initialValues", initialValues);
967
973
  form.setFieldsValue(initialValues);
968
974
  setInitialValues(null);
969
- }, [computedProps]);
975
+ }, [form, initialValues]);
970
976
  if (!computedProps) return null;
971
977
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(antd.Form, {
972
978
  ...computedProps,
@@ -1017,7 +1023,7 @@ function Link(props) {
1017
1023
  const navigate = (0, react_router_dom.useNavigate)();
1018
1024
  const target = props.target || theme.Link?.target || (props.href.startsWith("http") ? "_blank" : void 0);
1019
1025
  let computedStyle = {
1020
- ...theme.Link.style || {},
1026
+ ...theme.Link.style,
1021
1027
  cursor: "pointer",
1022
1028
  ...props.style
1023
1029
  };
@@ -1031,8 +1037,16 @@ function Link(props) {
1031
1037
  ...buttonProps,
1032
1038
  style: computedStyle,
1033
1039
  onClick: (e) => {
1034
- props.onClick ? props.onClick(e) : target === "_blank" ? window.open(props.href) : navigate(props.href);
1035
1040
  e.preventDefault();
1041
+ if (props.onClick) {
1042
+ props.onClick(e);
1043
+ return;
1044
+ }
1045
+ if (target === "_blank") {
1046
+ window.open(props.href);
1047
+ return;
1048
+ }
1049
+ navigate(props.href);
1036
1050
  },
1037
1051
  children: props.children ?? props.text
1038
1052
  });
@@ -1132,7 +1146,8 @@ function processValue(item, value) {
1132
1146
  function Table(props) {
1133
1147
  const [columns, setColumns] = (0, react.useState)();
1134
1148
  const { theme } = useConfigContext();
1135
- const generateFilterDropdown = (item) => {
1149
+ const { all, blank, search } = theme.common;
1150
+ const generateFilterDropdown = (0, react.useCallback)((item) => {
1136
1151
  if (item.filterDropdown && item.filterDropdown !== true) return;
1137
1152
  if (!item.options?.length) return;
1138
1153
  if (item.options.length < 11) {
@@ -1153,7 +1168,7 @@ function Table(props) {
1153
1168
  allowClear: true,
1154
1169
  showSearch: true,
1155
1170
  style: { width: "100%" },
1156
- placeholder: `${theme.common.search} ${item.title}`,
1171
+ placeholder: `${search} ${item.title}`,
1157
1172
  value: selectedKeys,
1158
1173
  onChange: (v) => {
1159
1174
  setSelectedKeys(v?.length ? v : []);
@@ -1161,18 +1176,19 @@ function Table(props) {
1161
1176
  },
1162
1177
  mode: "multiple",
1163
1178
  filterOption: (input, option) => {
1164
- if (!input || !option || !option.label) return true;
1179
+ if (!input || !option) return true;
1180
+ if (typeof option.label !== "string") return option.value === input;
1165
1181
  input = input.trim();
1166
- return option.value === input || option.label.toString().toLowerCase().includes(input.toLowerCase());
1182
+ return option.value === input || option.label.toLowerCase().includes(input.toLowerCase());
1167
1183
  }
1168
1184
  })
1169
1185
  });
1170
1186
  return item;
1171
- };
1172
- (0, react.useEffect)(() => {
1187
+ }, [search]);
1188
+ (0, _faasjs_react.useEqualEffect)(() => {
1173
1189
  const items = (0, lodash_es.cloneDeep)(props.items).filter((item) => !(item.tableChildren === null || item.children === null || item.tableRender === null || item.render === null));
1174
1190
  const createTextSearchFilterDropdown = (item, transformValue) => ({ setSelectedKeys, confirm, clearFilters }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Input.Search, {
1175
- placeholder: `${theme.common.search} ${item.title}`,
1191
+ placeholder: `${search} ${item.title}`,
1176
1192
  allowClear: true,
1177
1193
  onSearch: (v) => {
1178
1194
  if (v) setSelectedKeys(transformValue ? [transformValue(v)] : [v]);
@@ -1270,7 +1286,7 @@ function Table(props) {
1270
1286
  }
1271
1287
  break;
1272
1288
  case "number[]":
1273
- if (!item.render) item.render = (value) => processValue(item, value).join(", ");
1289
+ if (!item.render) item.render = (value) => processValue(item, value);
1274
1290
  if (item.filterDropdown !== false) {
1275
1291
  if (!item.onFilter && !props.faasData) item.onFilter = (value, row) => {
1276
1292
  if (value === null && (!row[item.id] || !row[item.id].length)) return true;
@@ -1289,7 +1305,7 @@ function Table(props) {
1289
1305
  color: "#ff4d4f"
1290
1306
  } });
1291
1307
  if (item.filterDropdown !== false) {
1292
- if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, selectedKeys, confirm }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(antd.Radio.Group, {
1308
+ if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, selectedKeys, confirm: confirmFilter }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(antd.Radio.Group, {
1293
1309
  style: { padding: 8 },
1294
1310
  buttonStyle: "solid",
1295
1311
  value: JSON.stringify(selectedKeys[0]),
@@ -1299,10 +1315,10 @@ function Table(props) {
1299
1315
  false: false,
1300
1316
  null: null
1301
1317
  }[e.target.value]] : []);
1302
- confirm();
1318
+ confirmFilter();
1303
1319
  },
1304
1320
  children: [
1305
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Radio.Button, { children: theme.common.all }),
1321
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Radio.Button, { children: all }),
1306
1322
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Radio.Button, {
1307
1323
  value: "true",
1308
1324
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ant_design_icons.CheckOutlined, { style: {
@@ -1319,7 +1335,7 @@ function Table(props) {
1319
1335
  }),
1320
1336
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Radio.Button, {
1321
1337
  value: "null",
1322
- children: theme.common.blank
1338
+ children: blank
1323
1339
  })
1324
1340
  ]
1325
1341
  });
@@ -1343,7 +1359,9 @@ function Table(props) {
1343
1359
  };
1344
1360
  if (item.filterDropdown !== false) {
1345
1361
  if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.DatePicker.RangePicker, { onChange: (dates) => {
1346
- setSelectedKeys(dates?.[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
1362
+ const start = dates?.[0];
1363
+ const end = dates?.[1];
1364
+ setSelectedKeys(start && end ? [[start.startOf("day").toISOString(), end.endOf("day").toISOString()]] : []);
1347
1365
  confirm();
1348
1366
  } });
1349
1367
  if (!item.onFilter && !props.faasData) item.onFilter = (value, row) => {
@@ -1377,8 +1395,16 @@ function Table(props) {
1377
1395
  }
1378
1396
  }
1379
1397
  setColumns(items);
1380
- }, [props.items]);
1381
- (0, react.useEffect)(() => {
1398
+ }, [
1399
+ all,
1400
+ blank,
1401
+ generateFilterDropdown,
1402
+ props.extendTypes,
1403
+ props.faasData,
1404
+ props.items,
1405
+ search
1406
+ ]);
1407
+ (0, _faasjs_react.useEqualEffect)(() => {
1382
1408
  if (!props.dataSource || !columns) return;
1383
1409
  for (const column of columns) if (column.optionsType === "auto" && !column.options && !column.filters) {
1384
1410
  const options = (0, lodash_es.uniqBy)(props.dataSource, column.id).map((v) => ({
@@ -1394,7 +1420,11 @@ function Table(props) {
1394
1420
  return newColumns;
1395
1421
  });
1396
1422
  }
1397
- }, [props.dataSource, columns]);
1423
+ }, [
1424
+ props.dataSource,
1425
+ columns,
1426
+ generateFilterDropdown
1427
+ ]);
1398
1428
  if (!columns) return null;
1399
1429
  if (props.dataSource) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Table, {
1400
1430
  ...props,
@@ -1416,7 +1446,7 @@ function Table(props) {
1416
1446
  }
1417
1447
  function FaasDataTable({ props, columns, data, params, reload, loading }) {
1418
1448
  const [currentColumns, setCurrentColumns] = (0, react.useState)(columns);
1419
- (0, react.useEffect)(() => {
1449
+ (0, _faasjs_react.useEqualEffect)(() => {
1420
1450
  if (!data || Array.isArray(data)) return;
1421
1451
  setCurrentColumns((prev) => {
1422
1452
  const newColumns = [...prev];
@@ -1553,7 +1583,7 @@ function Tabs(props) {
1553
1583
  */
1554
1584
  function Title(props) {
1555
1585
  const { theme } = useConfigContext();
1556
- (0, react.useEffect)(() => {
1586
+ (0, _faasjs_react.useEqualEffect)(() => {
1557
1587
  const title = Array.isArray(props.title) ? props.title : [props.title];
1558
1588
  document.title = title.concat(props.suffix || theme.Title.suffix).filter((t) => !!t).join(props.separator || theme.Title.separator);
1559
1589
  }, [props, theme.Title]);
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { ErrorBoundaryProps, FaasDataInjection as FaasDataInjection$1, FaasDataWrapperProps as FaasDataWrapperProps$1, FaasDataWrapperRef, FaasReactClient, FaasReactClientOptions, faas, useFaas } from "@faasjs/react";
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
2
  import { ButtonProps, ConfigProviderProps as ConfigProviderProps$1, DatePickerProps, DescriptionsProps, Drawer, DrawerProps as DrawerProps$1, FormInstance, FormItemProps as FormItemProps$1, FormProps as FormProps$1, GlobalToken, InputNumberProps, InputProps, Modal, ModalProps as ModalProps$1, RadioProps, SelectProps, SwitchProps, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, TabsProps as TabsProps$1 } from "antd";
3
+ import { MessageInstance } from "antd/es/message/interface";
4
+ import { NotificationInstance } from "antd/es/notification/interface";
3
5
  import { BrowserRouterProps, RouteProps } from "react-router-dom";
4
6
  import * as react from "react";
5
7
  import { CSSProperties, ComponentType, Dispatch, FC, JSX, LazyExoticComponent, ReactElement, ReactNode, SetStateAction, lazy } from "react";
6
- import * as react_jsx_runtime0 from "react/jsx-runtime";
8
+ import { ErrorBoundaryProps, FaasDataInjection as FaasDataInjection$1, FaasDataWrapperProps as FaasDataWrapperProps$1, FaasDataWrapperRef, FaasReactClient, FaasReactClientOptions, faas, useFaas } from "@faasjs/react";
7
9
  import { Dayjs } from "dayjs";
8
- import { MessageInstance } from "antd/es/message/interface";
9
- import { NotificationInstance } from "antd/es/notification/interface";
10
10
  import * as antd_es_form_FormItem0 from "antd/es/form/FormItem";
11
11
  import * as antd_es_form0 from "antd/es/form";
12
12
  import { RuleObject } from "antd/es/form";
@@ -53,7 +53,7 @@ type FaasActionPaths = Exclude<Extract<keyof FaasActions, string>, 'faasjsAction
53
53
  /**
54
54
  * Union type accepted by action helpers.
55
55
  */
56
- type FaasActionUnionType = FaasActionPaths | Record<string, any> | string;
56
+ type FaasActionUnionType = Record<string, any> | string;
57
57
  /**
58
58
  * Infer the action path type.
59
59
  *
@@ -319,7 +319,7 @@ interface useAppProps {
319
319
  */
320
320
  declare function App(props: AppProps): react_jsx_runtime0.JSX.Element;
321
321
  declare namespace App {
322
- var useApp: <NewT extends useAppProps = useAppProps>() => Readonly<NewT>;
322
+ var useApp: any;
323
323
  }
324
324
  /**
325
325
  * Get app context.
@@ -330,7 +330,7 @@ declare namespace App {
330
330
  * const { message, notification, setModalProps, setDrawerProps } = useApp()
331
331
  * ```
332
332
  */
333
- declare const useApp: <NewT extends useAppProps = useAppProps>() => Readonly<NewT>;
333
+ declare const useApp: any;
334
334
  //#endregion
335
335
  //#region src/Blank.d.ts
336
336
  interface BlankProps {
@@ -747,7 +747,7 @@ interface DescriptionItemProps<T = any> extends FaasItemProps {
747
747
  object?: DescriptionItemProps<T>[];
748
748
  }
749
749
  interface DescriptionProps<T = any, ExtendItemProps = any> extends Omit<DescriptionsProps, 'items'> {
750
- renderTitle?(values: T): ReactNode;
750
+ renderTitle?(this: void, values: T): ReactNode;
751
751
  items: (DescriptionItemProps | ExtendItemProps)[];
752
752
  extendTypes?: {
753
753
  [key: string]: ExtendDescriptionTypeProps;
@@ -825,7 +825,7 @@ type FormSubmitProps = {
825
825
  * ```
826
826
  */
827
827
  to?: {
828
- action: FaasAction | string; /** params will overwrite form values before submit */
828
+ action: FaasAction; /** params will overwrite form values before submit */
829
829
  params?: Record<string, any>;
830
830
  then?: (result: any) => void;
831
831
  catch?: (error: any) => void;
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { ErrorBoundary as ErrorBoundary$1, FaasDataWrapper as FaasDataWrapper$1,
2
2
  import { Alert, Button, Col, ConfigProvider as ConfigProvider$1, DatePicker, Descriptions, Drawer, Form as Form$1, Input, InputNumber, Modal, Radio, Result, Row, Select, Skeleton, Space, Spin, Switch, Table as Table$1, Tabs as Tabs$1, Typography, message, notification, theme } from "antd";
3
3
  import { BrowserRouter, Route, Routes as Routes$1, useLocation, useNavigate } from "react-router-dom";
4
4
  import { cloneDeep, defaultsDeep, isNil, uniqBy } from "lodash-es";
5
- import { Suspense, cloneElement, createContext, createElement, isValidElement, lazy, useContext, useEffect, useState } from "react";
5
+ import { Suspense, cloneElement, createContext, createElement, isValidElement, lazy, useCallback, useContext, useState } from "react";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { CheckOutlined, CloseOutlined, MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
8
8
  import dayjs from "dayjs";
@@ -23,7 +23,7 @@ function Loading(props) {
23
23
  if (props.loading === false) return /* @__PURE__ */ jsx(Fragment, { children: props.children });
24
24
  return /* @__PURE__ */ jsx("div", {
25
25
  style: {
26
- ...props.style || {},
26
+ ...props.style,
27
27
  ...!props.size || props.size === "large" ? {
28
28
  margin: "20vh auto",
29
29
  textAlign: "center"
@@ -446,7 +446,7 @@ function cloneUnionFaasItemElement(element, props) {
446
446
  //#region src/Description.tsx
447
447
  function DescriptionItemContent(props) {
448
448
  const [computedProps, setComputedProps] = useState();
449
- useEffect(() => {
449
+ useEqualEffect(() => {
450
450
  const propsCopy = { ...props };
451
451
  propsCopy.item.title = propsCopy.item.title ?? idToTitle(propsCopy.item.id);
452
452
  if (!propsCopy.item.type) propsCopy.item.type = "string";
@@ -627,7 +627,7 @@ function FormItem(props) {
627
627
  const [extendTypes, setExtendTypes] = useState();
628
628
  const { theme } = useConfigContext();
629
629
  const [hidden, setHidden] = useState(props.hidden || false);
630
- useEffect(() => {
630
+ useEqualEffect(() => {
631
631
  const { extendTypes, ...propsCopy } = { ...props };
632
632
  if (extendTypes) setExtendTypes(extendTypes);
633
633
  if (propsCopy.if) {
@@ -644,7 +644,11 @@ function FormItem(props) {
644
644
  delete propsCopy.hidden;
645
645
  }
646
646
  setComputedProps(processProps(propsCopy, theme.common));
647
- }, [props]);
647
+ }, [
648
+ hidden,
649
+ props,
650
+ theme.common
651
+ ]);
648
652
  if (!computedProps) return null;
649
653
  const itemType = computedProps.type ?? "string";
650
654
  if (hidden) return /* @__PURE__ */ jsx(Form$1.Item, {
@@ -876,19 +880,21 @@ function Form(props) {
876
880
  const [extendTypes, setExtendTypes] = useState();
877
881
  const [form] = Form$1.useForm(props.form);
878
882
  const [initialValues, setInitialValues] = useState(props.initialValues || Object.create(null));
879
- useEffect(() => {
883
+ useEqualEffect(() => {
880
884
  const { submit, ...propsCopy } = {
881
885
  ...props,
882
886
  form
883
887
  };
888
+ let nextInitialValues = propsCopy.initialValues;
884
889
  if (typeof submit !== "undefined") setSubmit(submit);
885
890
  if (propsCopy.initialValues && propsCopy.items?.length) {
886
891
  for (const key in propsCopy.initialValues) propsCopy.initialValues[key] = transferValue(propsCopy.items.find((item) => isFormItemProps(item) && item.id === key)?.type, propsCopy.initialValues[key]);
892
+ nextInitialValues = propsCopy.initialValues;
887
893
  setInitialValues(propsCopy.initialValues);
888
894
  delete propsCopy.initialValues;
889
895
  }
890
896
  if (propsCopy.items?.length) {
891
- for (const item of propsCopy.items) if (isFormItemProps(item) && item.if) item.hidden = !item.if(initialValues || Object.create(null));
897
+ for (const item of propsCopy.items) if (isFormItemProps(item) && item.if) item.hidden = !item.if(nextInitialValues || Object.create(null));
892
898
  }
893
899
  const submitTo = typeof submit === "object" ? submit.to : void 0;
894
900
  if (propsCopy.onFinish) {
@@ -927,7 +933,7 @@ function Form(props) {
927
933
  delete propsCopy.extendTypes;
928
934
  }
929
935
  setComputedProps(propsCopy);
930
- }, [props]);
936
+ }, [form, props]);
931
937
  const onValuesChange = useEqualCallback((changedValues, allValues) => {
932
938
  console.debug("Form:onValuesChange", changedValues, allValues);
933
939
  if (props.onValuesChange) props.onValuesChange(changedValues, allValues);
@@ -937,12 +943,12 @@ function Form(props) {
937
943
  if (item?.onValueChange) item.onValueChange(changedValues[key], allValues, form);
938
944
  }
939
945
  }, [computedProps]);
940
- useEffect(() => {
946
+ useEqualEffect(() => {
941
947
  if (!initialValues) return;
942
948
  console.debug("Form:initialValues", initialValues);
943
949
  form.setFieldsValue(initialValues);
944
950
  setInitialValues(null);
945
- }, [computedProps]);
951
+ }, [form, initialValues]);
946
952
  if (!computedProps) return null;
947
953
  return /* @__PURE__ */ jsxs(Form$1, {
948
954
  ...computedProps,
@@ -993,7 +999,7 @@ function Link(props) {
993
999
  const navigate = useNavigate();
994
1000
  const target = props.target || theme.Link?.target || (props.href.startsWith("http") ? "_blank" : void 0);
995
1001
  let computedStyle = {
996
- ...theme.Link.style || {},
1002
+ ...theme.Link.style,
997
1003
  cursor: "pointer",
998
1004
  ...props.style
999
1005
  };
@@ -1007,8 +1013,16 @@ function Link(props) {
1007
1013
  ...buttonProps,
1008
1014
  style: computedStyle,
1009
1015
  onClick: (e) => {
1010
- props.onClick ? props.onClick(e) : target === "_blank" ? window.open(props.href) : navigate(props.href);
1011
1016
  e.preventDefault();
1017
+ if (props.onClick) {
1018
+ props.onClick(e);
1019
+ return;
1020
+ }
1021
+ if (target === "_blank") {
1022
+ window.open(props.href);
1023
+ return;
1024
+ }
1025
+ navigate(props.href);
1012
1026
  },
1013
1027
  children: props.children ?? props.text
1014
1028
  });
@@ -1108,7 +1122,8 @@ function processValue(item, value) {
1108
1122
  function Table(props) {
1109
1123
  const [columns, setColumns] = useState();
1110
1124
  const { theme } = useConfigContext();
1111
- const generateFilterDropdown = (item) => {
1125
+ const { all, blank, search } = theme.common;
1126
+ const generateFilterDropdown = useCallback((item) => {
1112
1127
  if (item.filterDropdown && item.filterDropdown !== true) return;
1113
1128
  if (!item.options?.length) return;
1114
1129
  if (item.options.length < 11) {
@@ -1129,7 +1144,7 @@ function Table(props) {
1129
1144
  allowClear: true,
1130
1145
  showSearch: true,
1131
1146
  style: { width: "100%" },
1132
- placeholder: `${theme.common.search} ${item.title}`,
1147
+ placeholder: `${search} ${item.title}`,
1133
1148
  value: selectedKeys,
1134
1149
  onChange: (v) => {
1135
1150
  setSelectedKeys(v?.length ? v : []);
@@ -1137,18 +1152,19 @@ function Table(props) {
1137
1152
  },
1138
1153
  mode: "multiple",
1139
1154
  filterOption: (input, option) => {
1140
- if (!input || !option || !option.label) return true;
1155
+ if (!input || !option) return true;
1156
+ if (typeof option.label !== "string") return option.value === input;
1141
1157
  input = input.trim();
1142
- return option.value === input || option.label.toString().toLowerCase().includes(input.toLowerCase());
1158
+ return option.value === input || option.label.toLowerCase().includes(input.toLowerCase());
1143
1159
  }
1144
1160
  })
1145
1161
  });
1146
1162
  return item;
1147
- };
1148
- useEffect(() => {
1163
+ }, [search]);
1164
+ useEqualEffect(() => {
1149
1165
  const items = cloneDeep(props.items).filter((item) => !(item.tableChildren === null || item.children === null || item.tableRender === null || item.render === null));
1150
1166
  const createTextSearchFilterDropdown = (item, transformValue) => ({ setSelectedKeys, confirm, clearFilters }) => /* @__PURE__ */ jsx(Input.Search, {
1151
- placeholder: `${theme.common.search} ${item.title}`,
1167
+ placeholder: `${search} ${item.title}`,
1152
1168
  allowClear: true,
1153
1169
  onSearch: (v) => {
1154
1170
  if (v) setSelectedKeys(transformValue ? [transformValue(v)] : [v]);
@@ -1246,7 +1262,7 @@ function Table(props) {
1246
1262
  }
1247
1263
  break;
1248
1264
  case "number[]":
1249
- if (!item.render) item.render = (value) => processValue(item, value).join(", ");
1265
+ if (!item.render) item.render = (value) => processValue(item, value);
1250
1266
  if (item.filterDropdown !== false) {
1251
1267
  if (!item.onFilter && !props.faasData) item.onFilter = (value, row) => {
1252
1268
  if (value === null && (!row[item.id] || !row[item.id].length)) return true;
@@ -1265,7 +1281,7 @@ function Table(props) {
1265
1281
  color: "#ff4d4f"
1266
1282
  } });
1267
1283
  if (item.filterDropdown !== false) {
1268
- if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, selectedKeys, confirm }) => /* @__PURE__ */ jsxs(Radio.Group, {
1284
+ if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, selectedKeys, confirm: confirmFilter }) => /* @__PURE__ */ jsxs(Radio.Group, {
1269
1285
  style: { padding: 8 },
1270
1286
  buttonStyle: "solid",
1271
1287
  value: JSON.stringify(selectedKeys[0]),
@@ -1275,10 +1291,10 @@ function Table(props) {
1275
1291
  false: false,
1276
1292
  null: null
1277
1293
  }[e.target.value]] : []);
1278
- confirm();
1294
+ confirmFilter();
1279
1295
  },
1280
1296
  children: [
1281
- /* @__PURE__ */ jsx(Radio.Button, { children: theme.common.all }),
1297
+ /* @__PURE__ */ jsx(Radio.Button, { children: all }),
1282
1298
  /* @__PURE__ */ jsx(Radio.Button, {
1283
1299
  value: "true",
1284
1300
  children: /* @__PURE__ */ jsx(CheckOutlined, { style: {
@@ -1295,7 +1311,7 @@ function Table(props) {
1295
1311
  }),
1296
1312
  /* @__PURE__ */ jsx(Radio.Button, {
1297
1313
  value: "null",
1298
- children: theme.common.blank
1314
+ children: blank
1299
1315
  })
1300
1316
  ]
1301
1317
  });
@@ -1319,7 +1335,9 @@ function Table(props) {
1319
1335
  };
1320
1336
  if (item.filterDropdown !== false) {
1321
1337
  if (typeof item.filterDropdown === "undefined") item.filterDropdown = ({ setSelectedKeys, confirm }) => /* @__PURE__ */ jsx(DatePicker.RangePicker, { onChange: (dates) => {
1322
- setSelectedKeys(dates?.[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
1338
+ const start = dates?.[0];
1339
+ const end = dates?.[1];
1340
+ setSelectedKeys(start && end ? [[start.startOf("day").toISOString(), end.endOf("day").toISOString()]] : []);
1323
1341
  confirm();
1324
1342
  } });
1325
1343
  if (!item.onFilter && !props.faasData) item.onFilter = (value, row) => {
@@ -1353,8 +1371,16 @@ function Table(props) {
1353
1371
  }
1354
1372
  }
1355
1373
  setColumns(items);
1356
- }, [props.items]);
1357
- useEffect(() => {
1374
+ }, [
1375
+ all,
1376
+ blank,
1377
+ generateFilterDropdown,
1378
+ props.extendTypes,
1379
+ props.faasData,
1380
+ props.items,
1381
+ search
1382
+ ]);
1383
+ useEqualEffect(() => {
1358
1384
  if (!props.dataSource || !columns) return;
1359
1385
  for (const column of columns) if (column.optionsType === "auto" && !column.options && !column.filters) {
1360
1386
  const options = uniqBy(props.dataSource, column.id).map((v) => ({
@@ -1370,7 +1396,11 @@ function Table(props) {
1370
1396
  return newColumns;
1371
1397
  });
1372
1398
  }
1373
- }, [props.dataSource, columns]);
1399
+ }, [
1400
+ props.dataSource,
1401
+ columns,
1402
+ generateFilterDropdown
1403
+ ]);
1374
1404
  if (!columns) return null;
1375
1405
  if (props.dataSource) return /* @__PURE__ */ jsx(Table$1, {
1376
1406
  ...props,
@@ -1392,7 +1422,7 @@ function Table(props) {
1392
1422
  }
1393
1423
  function FaasDataTable({ props, columns, data, params, reload, loading }) {
1394
1424
  const [currentColumns, setCurrentColumns] = useState(columns);
1395
- useEffect(() => {
1425
+ useEqualEffect(() => {
1396
1426
  if (!data || Array.isArray(data)) return;
1397
1427
  setCurrentColumns((prev) => {
1398
1428
  const newColumns = [...prev];
@@ -1529,7 +1559,7 @@ function Tabs(props) {
1529
1559
  */
1530
1560
  function Title(props) {
1531
1561
  const { theme } = useConfigContext();
1532
- useEffect(() => {
1562
+ useEqualEffect(() => {
1533
1563
  const title = Array.isArray(props.title) ? props.title : [props.title];
1534
1564
  document.title = title.concat(props.suffix || theme.Title.suffix).filter((t) => !!t).join(props.separator || theme.Title.separator);
1535
1565
  }, [props, theme.Title]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "8.0.0-beta.14",
3
+ "version": "8.0.0-beta.15",
4
4
  "homepage": "https://faasjs.com/doc/ant-design",
5
5
  "bugs": {
6
6
  "url": "https://github.com/faasjs/faasjs/issues"
@@ -26,12 +26,9 @@
26
26
  "require": "./dist/index.cjs"
27
27
  }
28
28
  },
29
- "scripts": {
30
- "build": "tsdown src/index.ts --config ../../tsdown.config.ts --dts.eager --no-sourcemap --no-dts.sourcemap"
31
- },
32
29
  "devDependencies": {
33
30
  "@ant-design/icons": "*",
34
- "@faasjs/react": ">=8.0.0-beta.14",
31
+ "@faasjs/react": ">=8.0.0-beta.15",
35
32
  "@types/lodash-es": "*",
36
33
  "@types/react": "^19.0.0",
37
34
  "@types/react-dom": "^19.0.0",
@@ -43,7 +40,7 @@
43
40
  },
44
41
  "peerDependencies": {
45
42
  "@ant-design/icons": "*",
46
- "@faasjs/react": ">=8.0.0-beta.14",
43
+ "@faasjs/react": ">=8.0.0-beta.15",
47
44
  "antd": "^6.0.0",
48
45
  "lodash-es": "*",
49
46
  "react": "^19.0.0",