@faasjs/ant-design 3.3.0 → 3.5.0

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
@@ -52,6 +52,7 @@ type FaasItemProps = {
52
52
  - [Title](functions/Title.md)
53
53
  - [transferOptions](functions/transferOptions.md)
54
54
  - [transferValue](functions/transferValue.md)
55
+ - [upperFirst](functions/upperFirst.md)
55
56
  - [useApp](functions/useApp.md)
56
57
  - [useConfigContext](functions/useConfigContext.md)
57
58
  - [useDrawer](functions/useDrawer.md)
package/dist/index.d.mts CHANGED
@@ -201,7 +201,7 @@ interface useAppProps {
201
201
  */
202
202
  declare function App(props: AppProps): react_jsx_runtime.JSX.Element;
203
203
  declare namespace App {
204
- var useApp: () => Readonly<useAppProps>;
204
+ var useApp: <NewT extends useAppProps = useAppProps>() => Readonly<useAppProps | NewT>;
205
205
  var whyDidYouRender: boolean;
206
206
  }
207
207
  /**
@@ -213,7 +213,7 @@ declare namespace App {
213
213
  * const { message, notification, setModalProps, setDrawerProps } = useApp()
214
214
  * ```
215
215
  */
216
- declare const useApp: () => Readonly<useAppProps>;
216
+ declare const useApp: <NewT extends useAppProps = useAppProps>() => Readonly<useAppProps | NewT>;
217
217
 
218
218
  interface BlankProps {
219
219
  value?: any;
@@ -519,6 +519,7 @@ interface FaasItemProps extends BaseItemProps {
519
519
  */
520
520
  type?: FaasItemType;
521
521
  }
522
+ declare function upperFirst(str: string): string;
522
523
  /**
523
524
  * convert string[] or number[] to { label, value }[]
524
525
  */
@@ -746,4 +747,4 @@ declare namespace Title {
746
747
  var whyDidYouRender: boolean;
747
748
  }
748
749
 
749
- 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, type setDrawerProps, type setModalProps, transferOptions, transferValue, useApp, type useAppProps, useConfigContext, useDrawer, useModal, withFaasData };
750
+ 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, type setDrawerProps, type setModalProps, transferOptions, transferValue, upperFirst, useApp, type useAppProps, useConfigContext, useDrawer, useModal, withFaasData };
package/dist/index.d.ts CHANGED
@@ -201,7 +201,7 @@ interface useAppProps {
201
201
  */
202
202
  declare function App(props: AppProps): react_jsx_runtime.JSX.Element;
203
203
  declare namespace App {
204
- var useApp: () => Readonly<useAppProps>;
204
+ var useApp: <NewT extends useAppProps = useAppProps>() => Readonly<useAppProps | NewT>;
205
205
  var whyDidYouRender: boolean;
206
206
  }
207
207
  /**
@@ -213,7 +213,7 @@ declare namespace App {
213
213
  * const { message, notification, setModalProps, setDrawerProps } = useApp()
214
214
  * ```
215
215
  */
216
- declare const useApp: () => Readonly<useAppProps>;
216
+ declare const useApp: <NewT extends useAppProps = useAppProps>() => Readonly<useAppProps | NewT>;
217
217
 
218
218
  interface BlankProps {
219
219
  value?: any;
@@ -519,6 +519,7 @@ interface FaasItemProps extends BaseItemProps {
519
519
  */
520
520
  type?: FaasItemType;
521
521
  }
522
+ declare function upperFirst(str: string): string;
522
523
  /**
523
524
  * convert string[] or number[] to { label, value }[]
524
525
  */
@@ -746,4 +747,4 @@ declare namespace Title {
746
747
  var whyDidYouRender: boolean;
747
748
  }
748
749
 
749
- 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, type setDrawerProps, type setModalProps, transferOptions, transferValue, useApp, type useAppProps, useConfigContext, useDrawer, useModal, withFaasData };
750
+ 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, type setDrawerProps, type setModalProps, transferOptions, transferValue, upperFirst, useApp, type useAppProps, useConfigContext, useDrawer, useModal, withFaasData };
package/dist/index.js CHANGED
@@ -169,7 +169,7 @@ var AppContext = react.createSplittingContext({
169
169
  function RoutesApp(props) {
170
170
  const location = reactRouterDom.useLocation();
171
171
  const { drawerProps, setDrawerProps, modalProps, setModalProps } = useApp();
172
- react$1.useEffect(() => {
172
+ react.useEqualEffect(() => {
173
173
  console.debug("location", location);
174
174
  if (drawerProps.open) setDrawerProps({ open: false });
175
175
  if (modalProps.open) setModalProps({ open: false });
@@ -181,7 +181,7 @@ function App(props) {
181
181
  const [notificationApi, notificationContextHolder] = antd.notification.useNotification();
182
182
  const { modal, modalProps, setModalProps } = useModal();
183
183
  const { drawer, drawerProps, setDrawerProps } = useDrawer();
184
- const styleProviderProps = react$1.useMemo(
184
+ const styleProviderProps = react.useEqualMemo(
185
185
  () => ({
186
186
  ...props.styleProviderProps,
187
187
  hashPriority: "high",
@@ -239,14 +239,17 @@ App.useApp = useApp;
239
239
  App.whyDidYouRender = true;
240
240
  function Blank(options) {
241
241
  const { theme } = useConfigContext();
242
- 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?.text || theme.Blank.text }) : options.value;
242
+ return !options || options.value === void 0 || options.value === null || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsxRuntime.jsx(antd.Typography.Text, { disabled: true, children: options?.text || theme.Blank.text }) : options.value;
243
243
  }
244
244
  Blank.whyDidYouRender = true;
245
+ function upperFirst(str) {
246
+ return str.charAt(0).toUpperCase() + str.slice(1);
247
+ }
245
248
  function transferOptions(options) {
246
249
  if (!options) return [];
247
250
  return options.map(
248
251
  (item) => typeof item === "object" ? item : {
249
- label: lodashEs.upperFirst(item.toString()),
252
+ label: upperFirst(item.toString()),
250
253
  value: item
251
254
  }
252
255
  );
@@ -317,7 +320,7 @@ function DescriptionItemContent(props) {
317
320
  react$1.useEffect(() => {
318
321
  const propsCopy = { ...props };
319
322
  if (!propsCopy.item.title)
320
- propsCopy.item.title = lodashEs.upperFirst(propsCopy.item.id);
323
+ propsCopy.item.title = upperFirst(propsCopy.item.id);
321
324
  if (!propsCopy.item.type) propsCopy.item.type = "string";
322
325
  if (propsCopy.item.options?.length) {
323
326
  propsCopy.item.options = transferOptions(propsCopy.item.options);
@@ -454,11 +457,11 @@ function Description(props) {
454
457
  antd.Descriptions,
455
458
  {
456
459
  ...props,
457
- title: lodashEs.isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
460
+ title: typeof props.renderTitle === "function" ? props.renderTitle(props.dataSource) : props.title,
458
461
  items: props.items.filter((item) => item && (!item.if || item.if(props.dataSource))).map((item) => ({
459
462
  ...item,
460
463
  key: item.id,
461
- label: item.title || lodashEs.upperFirst(item.id),
464
+ label: item.title || upperFirst(item.id),
462
465
  children: /* @__PURE__ */ jsxRuntime.jsx(
463
466
  DescriptionItemContent,
464
467
  {
@@ -477,7 +480,7 @@ function isOptionsProps(item) {
477
480
  return item && Array.isArray(item.options);
478
481
  }
479
482
  function processProps(propsCopy, config) {
480
- if (!propsCopy.title) propsCopy.title = lodashEs.upperFirst(propsCopy.id);
483
+ if (!propsCopy.title) propsCopy.title = upperFirst(propsCopy.id);
481
484
  if (!propsCopy.label && propsCopy.label !== false)
482
485
  propsCopy.label = propsCopy.title;
483
486
  if (!propsCopy.name) propsCopy.name = propsCopy.id;
@@ -1023,7 +1026,7 @@ function Table(props) {
1023
1026
  for (const item of items) {
1024
1027
  if (!item.key) item.key = item.id;
1025
1028
  if (!item.dataIndex) item.dataIndex = item.id;
1026
- if (!item.title) item.title = lodashEs.upperFirst(item.id);
1029
+ if (!item.title) item.title = upperFirst(item.id);
1027
1030
  if (!item.type) item.type = "string";
1028
1031
  if (item.options?.length) {
1029
1032
  item.options = transferOptions(item.options);
@@ -1578,6 +1581,7 @@ exports.Tabs = Tabs;
1578
1581
  exports.Title = Title;
1579
1582
  exports.transferOptions = transferOptions;
1580
1583
  exports.transferValue = transferValue;
1584
+ exports.upperFirst = upperFirst;
1581
1585
  exports.useApp = useApp;
1582
1586
  exports.useConfigContext = useConfigContext;
1583
1587
  exports.useDrawer = useDrawer;
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { createSplittingContext, useEqualCallback, ErrorBoundary as ErrorBoundary$1, useEqualEffect, FaasReactClient, OptionalWrapper, FaasDataWrapper as FaasDataWrapper$1, withFaasData as withFaasData$1, faas } from '@faasjs/react';
1
+ import { createSplittingContext, useEqualCallback, ErrorBoundary as ErrorBoundary$1, useEqualEffect, FaasReactClient, 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 { Form as Form$1, Modal as Modal$1, Drawer as Drawer$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
4
  import { legacyLogicalPropertiesTransformer, StyleProvider } from '@ant-design/cssinjs';
5
- import { createContext, useState, useContext, useMemo, useEffect, cloneElement, Suspense } from 'react';
5
+ import { createContext, useState, useContext, useEffect, cloneElement, Suspense } from 'react';
6
6
  export { lazy } from 'react';
7
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
8
  import { BrowserRouter, useNavigate, Routes as Routes$1, Route, useLocation } from 'react-router-dom';
9
- import { defaultsDeep, isNil, upperFirst, isFunction, cloneDeep, uniqBy } from 'lodash-es';
9
+ import { defaultsDeep, cloneDeep, isNil, uniqBy } from 'lodash-es';
10
10
  import dayjs2 from 'dayjs';
11
11
  import { PlusOutlined, MinusCircleOutlined, CheckOutlined, CloseOutlined } from '@ant-design/icons';
12
12
 
@@ -165,7 +165,7 @@ var AppContext = createSplittingContext({
165
165
  function RoutesApp(props) {
166
166
  const location = useLocation();
167
167
  const { drawerProps, setDrawerProps, modalProps, setModalProps } = useApp();
168
- useEffect(() => {
168
+ useEqualEffect(() => {
169
169
  console.debug("location", location);
170
170
  if (drawerProps.open) setDrawerProps({ open: false });
171
171
  if (modalProps.open) setModalProps({ open: false });
@@ -177,7 +177,7 @@ function App(props) {
177
177
  const [notificationApi, notificationContextHolder] = notification.useNotification();
178
178
  const { modal, modalProps, setModalProps } = useModal();
179
179
  const { drawer, drawerProps, setDrawerProps } = useDrawer();
180
- const styleProviderProps = useMemo(
180
+ const styleProviderProps = useEqualMemo(
181
181
  () => ({
182
182
  ...props.styleProviderProps,
183
183
  hashPriority: "high",
@@ -235,9 +235,12 @@ App.useApp = useApp;
235
235
  App.whyDidYouRender = true;
236
236
  function Blank(options) {
237
237
  const { theme } = useConfigContext();
238
- return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx(Typography.Text, { disabled: true, children: options?.text || theme.Blank.text }) : options.value;
238
+ return !options || options.value === void 0 || options.value === null || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx(Typography.Text, { disabled: true, children: options?.text || theme.Blank.text }) : options.value;
239
239
  }
240
240
  Blank.whyDidYouRender = true;
241
+ function upperFirst(str) {
242
+ return str.charAt(0).toUpperCase() + str.slice(1);
243
+ }
241
244
  function transferOptions(options) {
242
245
  if (!options) return [];
243
246
  return options.map(
@@ -450,7 +453,7 @@ function Description(props) {
450
453
  Descriptions,
451
454
  {
452
455
  ...props,
453
- title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
456
+ title: typeof props.renderTitle === "function" ? props.renderTitle(props.dataSource) : props.title,
454
457
  items: props.items.filter((item) => item && (!item.if || item.if(props.dataSource))).map((item) => ({
455
458
  ...item,
456
459
  key: item.id,
@@ -1542,4 +1545,4 @@ function Title(props) {
1542
1545
  }
1543
1546
  Title.whyDidYouRender = true;
1544
1547
 
1545
- export { App, Blank, ConfigContext, ConfigProvider, Description, Drawer, ErrorBoundary, FaasDataWrapper, Form, FormItem, Link, Loading, Modal, PageNotFound, Routes, Table, Tabs, Title, transferOptions, transferValue, useApp, useConfigContext, useDrawer, useModal, withFaasData };
1548
+ export { App, Blank, ConfigContext, ConfigProvider, Description, Drawer, ErrorBoundary, FaasDataWrapper, Form, FormItem, Link, Loading, Modal, PageNotFound, Routes, Table, Tabs, Title, transferOptions, transferValue, upperFirst, useApp, useConfigContext, useDrawer, useModal, withFaasData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -34,7 +34,7 @@
34
34
  "dist"
35
35
  ],
36
36
  "peerDependencies": {
37
- "@faasjs/react": "3.3.0",
37
+ "@faasjs/react": "3.5.0",
38
38
  "antd": "*",
39
39
  "@ant-design/icons": "*",
40
40
  "lodash-es": "*",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/lodash-es": "*",
47
- "@faasjs/react": "3.3.0",
47
+ "@faasjs/react": "3.5.0",
48
48
  "antd": "*",
49
49
  "@ant-design/icons": "*",
50
50
  "lodash-es": "*",