@faasjs/ant-design 8.0.0-beta.20 → 8.0.0-beta.22

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.ts CHANGED
@@ -20,22 +20,6 @@ import { NotificationInstance } from "antd/es/notification/interface.js";
20
20
  //#region ../types/src/index.d.ts
21
21
  /**
22
22
  * Interface for defining FaasJS actions.
23
- *
24
- * @example
25
- * ```typescript
26
- * declare module '@faasjs/types' {
27
- * interface FaasActions {
28
- * demo: {
29
- * Params: {
30
- * key: string
31
- * }
32
- * Data: {
33
- * value: string
34
- * }
35
- * }
36
- * }
37
- * }
38
- * ```
39
23
  */
40
24
  interface FaasActions {
41
25
  /**
@@ -51,7 +35,7 @@ interface FaasActions {
51
35
  */
52
36
  type FaasActionPaths = Exclude<Extract<keyof FaasActions, string>, 'faasjsActionsPlaceholder'>;
53
37
  /**
54
- * Union type accepted by action helpers.
38
+ * Union type accepted by action helpers when callers pass either an action path or inferred data shape.
55
39
  */
56
40
  type FaasActionUnionType = Record<string, any> | string;
57
41
  /**
@@ -61,12 +45,6 @@ type FaasActionUnionType = Record<string, any> | string;
61
45
  * otherwise falls back to `string`.
62
46
  *
63
47
  * @template T - Candidate action path type.
64
- *
65
- * @example
66
- * ```typescript
67
- * type A = FaasAction<'demo'> // 'demo'
68
- * type B = FaasAction<number> // string
69
- * ```
70
48
  */
71
49
  type FaasAction<T = any> = T extends FaasActionPaths ? T : string;
72
50
  //#endregion
@@ -328,7 +306,34 @@ interface ConfigProviderProps {
328
306
  };
329
307
  }
330
308
  /**
331
- * React context storing the resolved FaasJS Ant Design theme.
309
+ * Low-level React context that stores the resolved theme from {@link ConfigProvider}.
310
+ *
311
+ * Most app code should call {@link useConfigContext} instead of reading this context directly.
312
+ *
313
+ * @example
314
+ * ```tsx
315
+ * import { ConfigContext, ConfigProvider } from '@faasjs/ant-design'
316
+ * import { useContext } from 'react'
317
+ *
318
+ * function OrdersHeader() {
319
+ * const { theme } = useContext(ConfigContext)
320
+ *
321
+ * return <h1>{`Orders - ${theme.Title.suffix}`}</h1>
322
+ * }
323
+ *
324
+ * export function OrdersPage() {
325
+ * return (
326
+ * <ConfigProvider
327
+ * theme={{
328
+ * common: { blank: 'No orders yet' },
329
+ * Title: { suffix: 'Acme Admin' },
330
+ * }}
331
+ * >
332
+ * <OrdersHeader />
333
+ * </ConfigProvider>
334
+ * )
335
+ * }
336
+ * ```
332
337
  */
333
338
  declare const ConfigContext: _$react.Context<ConfigContextValue>;
334
339
  /**
@@ -343,10 +348,19 @@ declare const ConfigContext: _$react.Context<ConfigContextValue>;
343
348
  * ```tsx
344
349
  * import { Blank, ConfigProvider } from '@faasjs/ant-design'
345
350
  *
346
- * export function Page() {
351
+ * function OrdersEmptyState() {
352
+ * return <Blank />
353
+ * }
354
+ *
355
+ * export function OrdersPage() {
347
356
  * return (
348
- * <ConfigProvider theme={{ common: { blank: 'Empty' } }}>
349
- * <Blank />
357
+ * <ConfigProvider
358
+ * theme={{
359
+ * common: { blank: 'No orders yet' },
360
+ * Title: { suffix: 'Acme Admin' },
361
+ * }}
362
+ * >
363
+ * <OrdersEmptyState />
350
364
  * </ConfigProvider>
351
365
  * )
352
366
  * }
@@ -360,18 +374,28 @@ declare function ConfigProvider(props: ConfigProviderProps): _$react_jsx_runtime
360
374
  *
361
375
  * @example
362
376
  * ```tsx
363
- * import { Blank, ConfigProvider, useConfigContext } from '@faasjs/ant-design'
377
+ * import { ConfigProvider, useConfigContext } from '@faasjs/ant-design'
364
378
  *
365
- * function EmptyState() {
379
+ * function OrdersSummary() {
366
380
  * const { theme } = useConfigContext()
367
381
  *
368
- * return <span>{theme.common.blank}</span>
382
+ * return (
383
+ * <>
384
+ * <h1>{`Orders - ${theme.Title.suffix}`}</h1>
385
+ * <p>{theme.common.blank}</p>
386
+ * </>
387
+ * )
369
388
  * }
370
389
  *
371
- * export function Page() {
390
+ * export function OrdersPage() {
372
391
  * return (
373
- * <ConfigProvider theme={{ common: { blank: 'N/A' } }}>
374
- * <EmptyState />
392
+ * <ConfigProvider
393
+ * theme={{
394
+ * common: { blank: 'No orders yet' },
395
+ * Title: { suffix: 'Acme Admin' },
396
+ * }}
397
+ * >
398
+ * <OrdersSummary />
375
399
  * </ConfigProvider>
376
400
  * )
377
401
  * }
@@ -416,7 +440,7 @@ interface AppProps {
416
440
  /**
417
441
  * Props forwarded to Ant Design's `ConfigProvider`.
418
442
  *
419
- * @see https://ant.design/components/config-provider/#API
443
+ * @see [Ant Design ConfigProvider API](https://ant.design/components/config-provider/#API)
420
444
  */
421
445
  configProviderProps?: ConfigProviderProps$1;
422
446
  /**
@@ -424,19 +448,19 @@ interface AppProps {
424
448
  *
425
449
  * Routing is enabled automatically when running in a browser and this prop is not `false`.
426
450
  *
427
- * @see https://api.reactrouter.com/v7/interfaces/react_router.BrowserRouterProps.html
451
+ * @see [React Router BrowserRouterProps](https://api.reactrouter.com/v7/interfaces/react_router.BrowserRouterProps.html)
428
452
  */
429
453
  browserRouterProps?: BrowserRouterProps | false;
430
454
  /**
431
455
  * Props forwarded to {@link ErrorBoundary}.
432
456
  *
433
- * @see https://faasjs.com/doc/ant-design/#errorboundary
457
+ * @see [FaasJS Ant Design ErrorBoundary docs](https://faasjs.com/doc/ant-design/#errorboundary)
434
458
  */
435
459
  errorBoundaryProps?: Omit<ErrorBoundaryProps, 'children'>;
436
460
  /**
437
461
  * Props forwarded to {@link ConfigProvider}, or `false` to skip the FaasJS config layer.
438
462
  *
439
- * @see https://faasjs.com/doc/ant-design/#configprovider
463
+ * @see [FaasJS Ant Design ConfigProvider docs](https://faasjs.com/doc/ant-design/#configprovider)
440
464
  */
441
465
  faasConfigProviderProps?: Omit<ConfigProviderProps, 'children'> | false;
442
466
  }
@@ -569,38 +593,6 @@ interface FormItemProps<T = any> extends BaseItemProps, Omit<FormItemProps$1<T>,
569
593
  }
570
594
  /**
571
595
  * Item shape used to extend `Form` with custom type names.
572
- *
573
- * @example
574
- * ```tsx
575
- * import { Form, type ExtendFormItemProps, type FormProps } from '@faasjs/ant-design'
576
- * import { Input } from 'antd'
577
- *
578
- * interface ExtendTypes extends ExtendFormItemProps {
579
- * type: 'password'
580
- * }
581
- *
582
- * function ExtendForm(props: FormProps<any, ExtendTypes>) {
583
- * return (
584
- * <Form
585
- * {...props}
586
- * extendTypes={{ password: { children: <Input.Password /> } }}
587
- * />
588
- * )
589
- * }
590
- *
591
- * export function Page() {
592
- * return (
593
- * <ExtendForm
594
- * items={[
595
- * {
596
- * id: 'password',
597
- * type: 'password',
598
- * },
599
- * ]}
600
- * />
601
- * )
602
- * }
603
- * ```
604
596
  */
605
597
  interface ExtendFormItemProps extends Omit<FormItemProps, 'type'> {
606
598
  type?: string;
@@ -892,38 +884,6 @@ type UnionFaasItemInjection<Value = any, Values = any> = {
892
884
  * @param {Values} values - Whole record or row containing the value.
893
885
  * @param {number} index - Current row or list index.
894
886
  * @param {UnionScene} scene - Rendering surface requesting the output.
895
- *
896
- * @example
897
- * ```tsx
898
- * import { type UnionFaasItemRender, Form, Description, Table } from '@faasjs/ant-design'
899
- *
900
- * const nameReader: UnionFaasItemRender = (value, values, index, scene) => {
901
- * switch (scene) {
902
- * case 'form':
903
- * return <input />
904
- * case 'description':
905
- * case 'table':
906
- * return <span>{value}</span>
907
- * default:
908
- * return null
909
- * }
910
- * }
911
- *
912
- * const items = [
913
- * {
914
- * id: 'name',
915
- * render: nameReader,
916
- * }
917
- * ]
918
- *
919
- * function App() {
920
- * return <>
921
- * <Form items={items} /> // Will render an input
922
- * <Description items={items} dataSource={{ name: 'John' }} /> // Will render a span
923
- * <Table items={items} dataSource={[{ name: 'John' }]} /> // Will render a span
924
- * </>
925
- * }
926
- * ```
927
887
  */
928
888
  type UnionFaasItemRender<Value = any, Values = any> = (value: Value, values: Values, index: number, scene: UnionScene) => React.ReactNode;
929
889
  /**
@@ -931,40 +891,6 @@ type UnionFaasItemRender<Value = any, Values = any> = (value: Value, values: Val
931
891
  *
932
892
  * @template Value - Current item value type.
933
893
  * @template Values - Whole record or row type that contains the value.
934
- *
935
- * @example
936
- * ```tsx
937
- * import { type UnionFaasItemElement, Form, Description, Table } from '@faasjs/ant-design'
938
- *
939
- * const NameComponent: UnionFaasItemElement = ({ scene, value }) => {
940
- * switch (scene) {
941
- * case 'form':
942
- * return <input />
943
- * case 'description':
944
- * case 'table':
945
- * return <span>{value}</span>
946
- * default:
947
- * return null
948
- * }
949
- * }
950
- *
951
- * const items = [
952
- * {
953
- * id: 'name',
954
- * children: NameComponent, // both `NameComponent` and `<NameComponent />` are valid
955
- * }
956
- * ]
957
- *
958
- * function App() {
959
- * return (
960
- * <>
961
- * <Form items={items} />
962
- * <Description items={items} dataSource={{ name: 'John' }} />
963
- * <Table items={items} dataSource={[{ name: 'John' }]} />
964
- * </>
965
- * )
966
- * }
967
- * ```
968
894
  */
969
895
  type UnionFaasItemElement<Value = any, Values = any> = ReactElement<UnionFaasItemInjection<Value, Values>> | FC<UnionFaasItemInjection<Value, Values>>;
970
896
  /**
@@ -980,41 +906,6 @@ type UnionFaasItemElement<Value = any, Values = any> = ReactElement<UnionFaasIte
980
906
  *
981
907
  * @template Value - Current item value type.
982
908
  * @template Values - Whole record or row type that contains the value.
983
- *
984
- * @example
985
- * ```tsx
986
- * import { type UnionFaasItemProps, Form, Table, Description } from '@faasjs/ant-design'
987
- *
988
- * const item: UnionFaasItemProps[] = [
989
- * {
990
- * id: 'id',
991
- * formChildren: null, // Don't show in form, only in description and table
992
- * },
993
- * {
994
- * id: 'name',
995
- * required: true, // Required in form
996
- * },
997
- * {
998
- * id: 'age',
999
- * type: 'number', // Number type in form, description and table
1000
- * options: ['< 18', '>= 18'], // Options in form and table
1001
- * }
1002
- * ]
1003
- *
1004
- * const data = {
1005
- * id: '1',
1006
- * name: 'John',
1007
- * age: '>= 18',
1008
- * }
1009
- *
1010
- * function App() {
1011
- * return <>
1012
- * <Form items={item} /> // Use in form
1013
- * <Description items={item} dataSource={data} /> // Use in description
1014
- * <Table items={item} dataSource={[ data ]} /> // Use in table
1015
- * </>
1016
- * }
1017
- * ```
1018
909
  */
1019
910
  interface UnionFaasItemProps<Value = any, Values = any> extends FormItemProps, DescriptionItemProps, TableItemProps {
1020
911
  /** Shared custom element rendered when no surface-specific child overrides it. */
@@ -1215,20 +1106,6 @@ type FormSubmitProps = {
1215
1106
  * Built-in FaasJS submit handler configuration for {@link Form}.
1216
1107
  *
1217
1108
  * @template Values - Form values shape used by submit handlers.
1218
- *
1219
- * @example
1220
- * ```ts
1221
- * const faas = {
1222
- * action: 'user/create',
1223
- * params: (values) => ({
1224
- * ...values,
1225
- * role: values.role || 'user',
1226
- * }),
1227
- * onSuccess: (result) => {
1228
- * console.log(result)
1229
- * },
1230
- * }
1231
- * ```
1232
1109
  */
1233
1110
  type FormFaasProps<Values extends Record<string, any> = any> = {
1234
1111
  /** Action name submitted through `faas()`. */action: FaasAction; /** Extra params merged into the submitted payload after `transformValues` runs. */
@@ -1599,12 +1476,18 @@ interface useAppProps {
1599
1476
  }
1600
1477
  /**
1601
1478
  * Shared context storing message, notification, modal, and drawer helpers.
1479
+ *
1480
+ * @example
1481
+ * ```ts
1482
+ * const { message } = AppContext.use()
1483
+ * ```
1602
1484
  */
1603
1485
  declare const AppContext: any;
1604
1486
  /**
1605
1487
  * Read app-level services exposed by the root `App` component.
1606
1488
  *
1607
1489
  * @template NewT - Narrowed app context shape to read from `AppContext`.
1490
+ * @param {void} this - Explicit void receiver that keeps the hook unbound.
1608
1491
  * @returns Read-only app context value.
1609
1492
  *
1610
1493
  * @example
package/dist/index.mjs CHANGED
@@ -199,7 +199,34 @@ const baseTheme = {
199
199
  Link: { style: {} }
200
200
  };
201
201
  /**
202
- * React context storing the resolved FaasJS Ant Design theme.
202
+ * Low-level React context that stores the resolved theme from {@link ConfigProvider}.
203
+ *
204
+ * Most app code should call {@link useConfigContext} instead of reading this context directly.
205
+ *
206
+ * @example
207
+ * ```tsx
208
+ * import { ConfigContext, ConfigProvider } from '@faasjs/ant-design'
209
+ * import { useContext } from 'react'
210
+ *
211
+ * function OrdersHeader() {
212
+ * const { theme } = useContext(ConfigContext)
213
+ *
214
+ * return <h1>{`Orders - ${theme.Title.suffix}`}</h1>
215
+ * }
216
+ *
217
+ * export function OrdersPage() {
218
+ * return (
219
+ * <ConfigProvider
220
+ * theme={{
221
+ * common: { blank: 'No orders yet' },
222
+ * Title: { suffix: 'Acme Admin' },
223
+ * }}
224
+ * >
225
+ * <OrdersHeader />
226
+ * </ConfigProvider>
227
+ * )
228
+ * }
229
+ * ```
203
230
  */
204
231
  const ConfigContext = createContext({ theme: baseTheme });
205
232
  /**
@@ -214,10 +241,19 @@ const ConfigContext = createContext({ theme: baseTheme });
214
241
  * ```tsx
215
242
  * import { Blank, ConfigProvider } from '@faasjs/ant-design'
216
243
  *
217
- * export function Page() {
244
+ * function OrdersEmptyState() {
245
+ * return <Blank />
246
+ * }
247
+ *
248
+ * export function OrdersPage() {
218
249
  * return (
219
- * <ConfigProvider theme={{ common: { blank: 'Empty' } }}>
220
- * <Blank />
250
+ * <ConfigProvider
251
+ * theme={{
252
+ * common: { blank: 'No orders yet' },
253
+ * Title: { suffix: 'Acme Admin' },
254
+ * }}
255
+ * >
256
+ * <OrdersEmptyState />
221
257
  * </ConfigProvider>
222
258
  * )
223
259
  * }
@@ -248,18 +284,28 @@ function ConfigProvider(props) {
248
284
  *
249
285
  * @example
250
286
  * ```tsx
251
- * import { Blank, ConfigProvider, useConfigContext } from '@faasjs/ant-design'
287
+ * import { ConfigProvider, useConfigContext } from '@faasjs/ant-design'
252
288
  *
253
- * function EmptyState() {
289
+ * function OrdersSummary() {
254
290
  * const { theme } = useConfigContext()
255
291
  *
256
- * return <span>{theme.common.blank}</span>
292
+ * return (
293
+ * <>
294
+ * <h1>{`Orders - ${theme.Title.suffix}`}</h1>
295
+ * <p>{theme.common.blank}</p>
296
+ * </>
297
+ * )
257
298
  * }
258
299
  *
259
- * export function Page() {
300
+ * export function OrdersPage() {
260
301
  * return (
261
- * <ConfigProvider theme={{ common: { blank: 'N/A' } }}>
262
- * <EmptyState />
302
+ * <ConfigProvider
303
+ * theme={{
304
+ * common: { blank: 'No orders yet' },
305
+ * Title: { suffix: 'Acme Admin' },
306
+ * }}
307
+ * >
308
+ * <OrdersSummary />
263
309
  * </ConfigProvider>
264
310
  * )
265
311
  * }
@@ -422,6 +468,11 @@ function useModal(init) {
422
468
  //#region src/useApp.ts
423
469
  /**
424
470
  * Shared context storing message, notification, modal, and drawer helpers.
471
+ *
472
+ * @example
473
+ * ```ts
474
+ * const { message } = AppContext.use()
475
+ * ```
425
476
  */
426
477
  const AppContext = createSplittingContext([
427
478
  "message",
@@ -435,6 +486,7 @@ const AppContext = createSplittingContext([
435
486
  * Read app-level services exposed by the root `App` component.
436
487
  *
437
488
  * @template NewT - Narrowed app context shape to read from `AppContext`.
489
+ * @param {void} this - Explicit void receiver that keeps the hook unbound.
438
490
  * @returns Read-only app context value.
439
491
  *
440
492
  * @example
@@ -1855,34 +1907,22 @@ function FaasDataTable({ props, columns, data, params, reload, loading }) {
1855
1907
  if (!data || Array.isArray(data)) return;
1856
1908
  setCurrentColumns((prev) => {
1857
1909
  const newColumns = [...prev];
1858
- for (const column of newColumns) {
1859
- if (data.options?.[column.id]) {
1860
- column.options = transferOptions(data.options[column.id]);
1861
- column.filters = column.options.map((v) => ({
1862
- text: v.label,
1863
- value: v.value
1864
- })).concat({
1865
- text: /* @__PURE__ */ jsx(Blank, {}),
1866
- value: null
1867
- });
1868
- column.render = (value) => processValue(column, value);
1869
- if (column.filterDropdown) delete column.filterDropdown;
1870
- continue;
1871
- }
1872
- if (column.optionsType === "auto" && !column.options && !column.filters) {
1873
- const filters = uniqBy(props.dataSource, column.id).map((v) => ({
1874
- text: v[column.id],
1875
- value: v[column.id]
1876
- }));
1877
- if (filters.length) column.filters = filters.concat({
1878
- text: /* @__PURE__ */ jsx(Blank, {}),
1879
- value: null
1880
- });
1881
- }
1910
+ for (const column of newColumns) if (data.options?.[column.id]) {
1911
+ column.options = transferOptions(data.options[column.id]);
1912
+ column.filters = column.options.map((v) => ({
1913
+ text: v.label,
1914
+ value: v.value
1915
+ })).concat({
1916
+ text: /* @__PURE__ */ jsx(Blank, {}),
1917
+ value: null
1918
+ });
1919
+ column.render = (value) => processValue(column, value);
1920
+ if (column.filterDropdown) delete column.filterDropdown;
1921
+ continue;
1882
1922
  }
1883
1923
  return newColumns;
1884
1924
  });
1885
- }, [data, props.dataSource]);
1925
+ }, [data]);
1886
1926
  if (!data) return /* @__PURE__ */ jsx(Table$1, {
1887
1927
  ...props,
1888
1928
  ...typeof loading === "undefined" ? {} : { loading },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "8.0.0-beta.20",
3
+ "version": "8.0.0-beta.22",
4
4
  "homepage": "https://faasjs.com/doc/ant-design",
5
5
  "bugs": {
6
6
  "url": "https://github.com/faasjs/faasjs/issues"
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@ant-design/icons": "*",
30
- "@faasjs/react": ">=8.0.0-beta.20",
30
+ "@faasjs/react": ">=8.0.0-beta.22",
31
31
  "@types/lodash-es": "*",
32
32
  "@types/react": "^19.0.0",
33
33
  "@types/react-dom": "^19.0.0",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@ant-design/icons": "*",
42
- "@faasjs/react": ">=8.0.0-beta.20",
42
+ "@faasjs/react": ">=8.0.0-beta.22",
43
43
  "antd": "^6.0.0",
44
44
  "lodash-es": "*",
45
45
  "react": "^19.0.0",