@faasjs/ant-design 8.0.0-beta.17 → 8.0.0-beta.18
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.cjs +502 -149
- package/dist/index.d.ts +880 -266
- package/dist/index.mjs +502 -149
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
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
3
|
import { BrowserRouterProps, RouteProps } from "react-router-dom";
|
|
4
4
|
import * as react from "react";
|
|
5
5
|
import { CSSProperties, ComponentType, Dispatch, FC, JSX, LazyExoticComponent, ReactElement, ReactNode, SetStateAction, lazy } from "react";
|
|
6
|
-
import
|
|
6
|
+
import { ErrorBoundaryProps, FaasDataInjection as FaasDataInjection$1, FaasDataWrapperProps as FaasDataWrapperProps$1, FaasDataWrapperRef, FaasReactClient, FaasReactClientOptions, faas, useFaas } from "@faasjs/react";
|
|
7
7
|
import { Dayjs } from "dayjs";
|
|
8
8
|
import * as antd_es_form_FormItem0 from "antd/es/form/FormItem";
|
|
9
9
|
import * as antd_es_form0 from "antd/es/form";
|
|
@@ -60,6 +60,8 @@ type FaasActionUnionType = Record<string, any> | string;
|
|
|
60
60
|
* Returns the original type when `T` is a known action path,
|
|
61
61
|
* otherwise falls back to `string`.
|
|
62
62
|
*
|
|
63
|
+
* @template T - Candidate action path type.
|
|
64
|
+
*
|
|
63
65
|
* @example
|
|
64
66
|
* ```typescript
|
|
65
67
|
* type A = FaasAction<'demo'> // 'demo'
|
|
@@ -69,62 +71,181 @@ type FaasActionUnionType = Record<string, any> | string;
|
|
|
69
71
|
type FaasAction<T = any> = T extends FaasActionPaths ? T : string;
|
|
70
72
|
//#endregion
|
|
71
73
|
//#region src/Loading.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* Props for the {@link Loading} component.
|
|
76
|
+
*/
|
|
72
77
|
type LoadingProps = {
|
|
73
|
-
style?: React.CSSProperties;
|
|
78
|
+
/** Inline styles applied to the loading wrapper. */style?: React.CSSProperties;
|
|
79
|
+
/**
|
|
80
|
+
* Ant Design spinner size.
|
|
81
|
+
*
|
|
82
|
+
* @default 'large'
|
|
83
|
+
*/
|
|
74
84
|
size?: 'small' | 'default' | 'large';
|
|
75
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Whether the loading indicator should be shown.
|
|
87
|
+
*
|
|
88
|
+
* @default true
|
|
89
|
+
*/
|
|
90
|
+
loading?: boolean; /** Content rendered when `loading` is `false`. */
|
|
76
91
|
children?: React.ReactNode;
|
|
77
92
|
};
|
|
78
93
|
/**
|
|
79
|
-
*
|
|
94
|
+
* Render an Ant Design loading spinner with an optional content fallback.
|
|
95
|
+
*
|
|
96
|
+
* @param {LoadingProps} props - Loading indicator props and optional wrapped children.
|
|
80
97
|
*
|
|
81
98
|
* @example
|
|
82
99
|
* ```tsx
|
|
83
|
-
*
|
|
100
|
+
* import { Loading } from '@faasjs/ant-design'
|
|
84
101
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
102
|
+
* export function Page({ remoteData }: { remoteData?: string }) {
|
|
103
|
+
* return (
|
|
104
|
+
* <>
|
|
105
|
+
* <Loading />
|
|
106
|
+
* <Loading loading={!remoteData}>
|
|
107
|
+
* <div>{remoteData}</div>
|
|
108
|
+
* </Loading>
|
|
109
|
+
* </>
|
|
110
|
+
* )
|
|
111
|
+
* }
|
|
88
112
|
* ```
|
|
89
113
|
*/
|
|
90
114
|
declare function Loading(props: LoadingProps): react_jsx_runtime0.JSX.Element;
|
|
91
115
|
//#endregion
|
|
92
116
|
//#region src/FaasDataWrapper.d.ts
|
|
117
|
+
/**
|
|
118
|
+
* Partial data injection exposed to wrapped Ant Design components.
|
|
119
|
+
*
|
|
120
|
+
* @template T - Action path or response data type used for inference.
|
|
121
|
+
*/
|
|
93
122
|
type FaasDataInjection<T extends FaasActionUnionType = any> = Partial<FaasDataInjection$1<T>>;
|
|
123
|
+
/**
|
|
124
|
+
* Ant Design wrapper props for the underlying `@faasjs/react` data wrapper.
|
|
125
|
+
*
|
|
126
|
+
* @template T - Action path or response data type used for inference.
|
|
127
|
+
*/
|
|
94
128
|
interface FaasDataWrapperProps<T extends FaasActionUnionType = any> extends FaasDataWrapperProps$1<T> {
|
|
129
|
+
/** Props forwarded to the built-in {@link Loading} fallback. */
|
|
95
130
|
loadingProps?: LoadingProps;
|
|
131
|
+
/** Explicit loading element that overrides the built-in {@link Loading} fallback. */
|
|
96
132
|
loading?: JSX.Element;
|
|
97
133
|
}
|
|
98
134
|
/**
|
|
99
|
-
*
|
|
135
|
+
* Render the `@faasjs/react` data wrapper with an Ant Design loading fallback.
|
|
136
|
+
*
|
|
137
|
+
* When `loading` is not provided, the component renders {@link Loading} with `loadingProps` while
|
|
138
|
+
* the wrapped FaasJS request is pending.
|
|
139
|
+
*
|
|
140
|
+
* @template T - Action path or response data type used for inference.
|
|
141
|
+
* @param {FaasDataWrapperProps<T>} props - Wrapper props including loading fallbacks and request configuration.
|
|
100
142
|
*
|
|
101
143
|
* @example
|
|
102
144
|
* ```tsx
|
|
103
|
-
*
|
|
104
|
-
*
|
|
145
|
+
* import { Alert, Button } from 'antd'
|
|
146
|
+
* import { FaasDataWrapper } from '@faasjs/ant-design'
|
|
147
|
+
*
|
|
148
|
+
* type User = {
|
|
149
|
+
* name: string
|
|
105
150
|
* }
|
|
106
151
|
*
|
|
107
|
-
* function
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
152
|
+
* function UserView(props: {
|
|
153
|
+
* data?: User
|
|
154
|
+
* error?: Error
|
|
155
|
+
* reload?: () => void
|
|
156
|
+
* }) {
|
|
157
|
+
* if (props.error) {
|
|
158
|
+
* return (
|
|
159
|
+
* <Alert
|
|
160
|
+
* type="error"
|
|
161
|
+
* message={props.error.message}
|
|
162
|
+
* action={
|
|
163
|
+
* <Button size="small" onClick={() => props.reload?.()}>
|
|
164
|
+
* Retry
|
|
165
|
+
* </Button>
|
|
166
|
+
* }
|
|
167
|
+
* />
|
|
168
|
+
* )
|
|
169
|
+
* }
|
|
170
|
+
*
|
|
171
|
+
* return <div>Hello, {props.data?.name}</div>
|
|
172
|
+
* }
|
|
173
|
+
*
|
|
174
|
+
* // Render-prop mode
|
|
175
|
+
* export function UserProfile(props: { id: number }) {
|
|
176
|
+
* return (
|
|
177
|
+
* <FaasDataWrapper<User>
|
|
178
|
+
* action="user/get"
|
|
179
|
+
* params={{ id: props.id }}
|
|
180
|
+
* loading={<div>Loading user...</div>}
|
|
181
|
+
* render={({ data, error, reload }) => {
|
|
182
|
+
* if (error) {
|
|
183
|
+
* return (
|
|
184
|
+
* <Alert
|
|
185
|
+
* type="error"
|
|
186
|
+
* message={error.message}
|
|
187
|
+
* action={
|
|
188
|
+
* <Button size="small" onClick={() => reload()}>
|
|
189
|
+
* Retry
|
|
190
|
+
* </Button>
|
|
191
|
+
* }
|
|
192
|
+
* />
|
|
193
|
+
* )
|
|
194
|
+
* }
|
|
195
|
+
*
|
|
196
|
+
* return <div>Hello, {data.name}</div>
|
|
197
|
+
* }}
|
|
198
|
+
* />
|
|
199
|
+
* )
|
|
200
|
+
* }
|
|
201
|
+
*
|
|
202
|
+
* // Children injection mode
|
|
203
|
+
* export function UserProfileWithChildren(props: { id: number }) {
|
|
204
|
+
* return (
|
|
205
|
+
* <FaasDataWrapper<User>
|
|
206
|
+
* action="user/get"
|
|
207
|
+
* params={{ id: props.id }}
|
|
208
|
+
* loading={<div>Loading user...</div>}
|
|
209
|
+
* >
|
|
210
|
+
* <UserView />
|
|
211
|
+
* </FaasDataWrapper>
|
|
212
|
+
* )
|
|
111
213
|
* }
|
|
112
214
|
* ```
|
|
113
215
|
*/
|
|
114
216
|
declare function FaasDataWrapper<T extends FaasActionUnionType = any>(props: FaasDataWrapperProps<T>): JSX.Element;
|
|
115
217
|
/**
|
|
116
|
-
*
|
|
218
|
+
* Wrap a component with {@link FaasDataWrapper} and its Ant Design loading fallback.
|
|
219
|
+
*
|
|
220
|
+
* @template PathOrData - Action path or response data type used for inference.
|
|
221
|
+
* @template TComponentProps - Component props including injected Faas data fields.
|
|
222
|
+
* @param {React.FC<TComponentProps & Record<string, any>>} Component - Component that consumes injected Faas data props.
|
|
223
|
+
* @param {FaasDataWrapperProps<PathOrData>} faasProps - Request configuration forwarded to {@link FaasDataWrapper}.
|
|
224
|
+
* @returns Higher-order component that injects Faas data props.
|
|
117
225
|
*
|
|
118
226
|
* @example
|
|
119
227
|
* ```tsx
|
|
120
|
-
*
|
|
228
|
+
* import { withFaasData } from '@faasjs/ant-design'
|
|
229
|
+
*
|
|
230
|
+
* const UserCard = withFaasData(
|
|
231
|
+
* ({ data, error, reload }) =>
|
|
232
|
+
* error ? (
|
|
233
|
+
* <a onClick={() => reload()}>Retry</a>
|
|
234
|
+
* ) : (
|
|
235
|
+
* <div>{data.name}</div>
|
|
236
|
+
* ),
|
|
237
|
+
* { action: 'user/get', params: { id: 1 } },
|
|
238
|
+
* )
|
|
121
239
|
* ```
|
|
122
240
|
*/
|
|
123
241
|
declare function withFaasData<PathOrData extends FaasActionUnionType, TComponentProps extends Required<FaasDataInjection<PathOrData>> = Required<FaasDataInjection<PathOrData>>>(Component: React.FC<TComponentProps & Record<string, any>>, faasProps: FaasDataWrapperProps<PathOrData>): React.FC<Omit<TComponentProps, keyof FaasDataInjection<PathOrData>>>;
|
|
124
242
|
//#endregion
|
|
125
243
|
//#region src/Config.d.ts
|
|
244
|
+
/**
|
|
245
|
+
* Fully resolved theme object consumed by `@faasjs/ant-design` components.
|
|
246
|
+
*/
|
|
126
247
|
type ResolvedTheme = {
|
|
127
|
-
lang: string;
|
|
248
|
+
/** Current language code used for built-in copy. */lang: string; /** Shared copy used by multiple components. */
|
|
128
249
|
common: {
|
|
129
250
|
blank: string;
|
|
130
251
|
all: string;
|
|
@@ -135,19 +256,19 @@ type ResolvedTheme = {
|
|
|
135
256
|
required: string;
|
|
136
257
|
search: string;
|
|
137
258
|
reset: string;
|
|
138
|
-
};
|
|
259
|
+
}; /** Theme values consumed by the `Blank` component. */
|
|
139
260
|
Blank: {
|
|
140
261
|
text: string;
|
|
141
|
-
};
|
|
262
|
+
}; /** Theme values consumed by the `Form` component. */
|
|
142
263
|
Form: {
|
|
143
264
|
submit: {
|
|
144
265
|
text: string;
|
|
145
266
|
};
|
|
146
|
-
};
|
|
267
|
+
}; /** Theme values consumed by the `Title` component. */
|
|
147
268
|
Title: {
|
|
148
269
|
separator: string;
|
|
149
270
|
suffix: string;
|
|
150
|
-
};
|
|
271
|
+
}; /** Theme values consumed by the `Link` component. */
|
|
151
272
|
Link: {
|
|
152
273
|
target?: string;
|
|
153
274
|
style: CSSProperties;
|
|
@@ -156,11 +277,17 @@ type ResolvedTheme = {
|
|
|
156
277
|
type ConfigContextValue = {
|
|
157
278
|
theme: ResolvedTheme;
|
|
158
279
|
};
|
|
280
|
+
/**
|
|
281
|
+
* Props for the `@faasjs/ant-design` {@link ConfigProvider}.
|
|
282
|
+
*/
|
|
159
283
|
interface ConfigProviderProps {
|
|
284
|
+
/** Optional FaasJS client options used to initialize {@link FaasReactClient}. */
|
|
160
285
|
faasClientOptions?: FaasReactClientOptions;
|
|
286
|
+
/** Descendant components that consume the resolved config context. */
|
|
161
287
|
children: React.ReactNode;
|
|
288
|
+
/** Theme overrides merged with the built-in defaults. */
|
|
162
289
|
theme?: {
|
|
163
|
-
lang?: string;
|
|
290
|
+
/** Language code used to select localized defaults. */lang?: string; /** Common shared copy and labels used across components. */
|
|
164
291
|
common?: {
|
|
165
292
|
blank?: string;
|
|
166
293
|
all?: string;
|
|
@@ -171,85 +298,168 @@ interface ConfigProviderProps {
|
|
|
171
298
|
required?: string;
|
|
172
299
|
search?: string;
|
|
173
300
|
reset?: string;
|
|
174
|
-
};
|
|
301
|
+
}; /** Blank-component theme overrides. */
|
|
175
302
|
Blank?: {
|
|
176
303
|
text?: string;
|
|
177
|
-
};
|
|
304
|
+
}; /** Form-component theme overrides. */
|
|
178
305
|
Form?: {
|
|
179
306
|
submit?: {
|
|
180
307
|
text?: string;
|
|
181
308
|
};
|
|
182
|
-
};
|
|
309
|
+
}; /** Title-component theme overrides. */
|
|
183
310
|
Title?: {
|
|
184
|
-
/**
|
|
311
|
+
/**
|
|
312
|
+
* Separator inserted between title segments.
|
|
313
|
+
*
|
|
314
|
+
* @default ' - '
|
|
315
|
+
*/
|
|
316
|
+
separator?: string; /** Suffix appended to generated page titles. */
|
|
185
317
|
suffix?: string;
|
|
186
|
-
};
|
|
318
|
+
}; /** Link-component theme overrides. */
|
|
187
319
|
Link?: {
|
|
188
|
-
/**
|
|
320
|
+
/**
|
|
321
|
+
* Default target used by the `Link` component when `props.target` is omitted.
|
|
322
|
+
*
|
|
323
|
+
* @default '_blank'
|
|
324
|
+
*/
|
|
325
|
+
target?: string; /** Default inline styles merged into every `Link`. */
|
|
189
326
|
style?: CSSProperties;
|
|
190
327
|
};
|
|
191
328
|
};
|
|
192
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* React context storing the resolved FaasJS Ant Design theme.
|
|
332
|
+
*/
|
|
193
333
|
declare const ConfigContext: react.Context<ConfigContextValue>;
|
|
194
334
|
/**
|
|
195
|
-
*
|
|
335
|
+
* Provide theme overrides and optional FaasJS client initialization for descendants.
|
|
336
|
+
*
|
|
337
|
+
* Theme overrides are merged with the built-in defaults. When `theme.lang` is omitted, the
|
|
338
|
+
* provider infers a default language from `navigator.language`.
|
|
339
|
+
*
|
|
340
|
+
* @param {ConfigProviderProps} props - Theme overrides and optional FaasJS client configuration.
|
|
196
341
|
*
|
|
197
342
|
* @example
|
|
198
343
|
* ```tsx
|
|
199
|
-
* import { ConfigProvider } from '@faasjs/ant-design'
|
|
344
|
+
* import { Blank, ConfigProvider } from '@faasjs/ant-design'
|
|
200
345
|
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
346
|
+
* export function Page() {
|
|
347
|
+
* return (
|
|
348
|
+
* <ConfigProvider theme={{ common: { blank: 'Empty' } }}>
|
|
349
|
+
* <Blank />
|
|
350
|
+
* </ConfigProvider>
|
|
351
|
+
* )
|
|
352
|
+
* }
|
|
204
353
|
* ```
|
|
205
354
|
*/
|
|
206
355
|
declare function ConfigProvider(props: ConfigProviderProps): react_jsx_runtime0.JSX.Element | null;
|
|
356
|
+
/**
|
|
357
|
+
* Read the current `@faasjs/ant-design` config context.
|
|
358
|
+
*
|
|
359
|
+
* @returns Current config context value containing the resolved theme.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```tsx
|
|
363
|
+
* import { Blank, ConfigProvider, useConfigContext } from '@faasjs/ant-design'
|
|
364
|
+
*
|
|
365
|
+
* function EmptyState() {
|
|
366
|
+
* const { theme } = useConfigContext()
|
|
367
|
+
*
|
|
368
|
+
* return <span>{theme.common.blank}</span>
|
|
369
|
+
* }
|
|
370
|
+
*
|
|
371
|
+
* export function Page() {
|
|
372
|
+
* return (
|
|
373
|
+
* <ConfigProvider theme={{ common: { blank: 'N/A' } }}>
|
|
374
|
+
* <EmptyState />
|
|
375
|
+
* </ConfigProvider>
|
|
376
|
+
* )
|
|
377
|
+
* }
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
207
380
|
declare function useConfigContext(): ConfigContextValue;
|
|
208
381
|
//#endregion
|
|
209
382
|
//#region src/ErrorBoundary.d.ts
|
|
210
383
|
/**
|
|
211
384
|
* Styled error boundary.
|
|
385
|
+
*
|
|
386
|
+
* When `errorChildren` is not provided, the fallback UI renders an Ant Design `Alert` containing
|
|
387
|
+
* the captured error message and description.
|
|
388
|
+
*
|
|
389
|
+
* @param {ErrorBoundaryProps} props - Error boundary props forwarded to the underlying React implementation.
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```tsx
|
|
393
|
+
* import { ErrorBoundary } from '@faasjs/ant-design'
|
|
394
|
+
*
|
|
395
|
+
* export function Page() {
|
|
396
|
+
* return (
|
|
397
|
+
* <ErrorBoundary>
|
|
398
|
+
* <DangerousWidget />
|
|
399
|
+
* </ErrorBoundary>
|
|
400
|
+
* )
|
|
401
|
+
* }
|
|
402
|
+
* ```
|
|
212
403
|
*/
|
|
213
404
|
declare function ErrorBoundary(props: ErrorBoundaryProps): react_jsx_runtime0.JSX.Element;
|
|
214
405
|
//#endregion
|
|
215
406
|
//#region src/App.d.ts
|
|
407
|
+
/**
|
|
408
|
+
* Props for the root {@link App} shell.
|
|
409
|
+
*
|
|
410
|
+
* `App` composes the Ant Design provider tree, FaasJS config provider, shared modal and drawer
|
|
411
|
+
* state, and optional browser routing into a single wrapper component.
|
|
412
|
+
*/
|
|
216
413
|
interface AppProps {
|
|
414
|
+
/** Descendant elements rendered inside all configured providers. */
|
|
217
415
|
children: React.ReactNode;
|
|
218
|
-
/**
|
|
416
|
+
/**
|
|
417
|
+
* Props forwarded to Ant Design's `ConfigProvider`.
|
|
418
|
+
*
|
|
419
|
+
* @see https://ant.design/components/config-provider/#API
|
|
420
|
+
*/
|
|
219
421
|
configProviderProps?: ConfigProviderProps$1;
|
|
220
422
|
/**
|
|
221
|
-
* `false` to disable
|
|
423
|
+
* Props forwarded to React Router's `BrowserRouter`, or `false` to disable browser routing.
|
|
222
424
|
*
|
|
223
|
-
*
|
|
425
|
+
* Routing is enabled automatically when running in a browser and this prop is not `false`.
|
|
224
426
|
*
|
|
225
427
|
* @see https://api.reactrouter.com/v7/interfaces/react_router.BrowserRouterProps.html
|
|
226
428
|
*/
|
|
227
429
|
browserRouterProps?: BrowserRouterProps | false;
|
|
228
|
-
/**
|
|
430
|
+
/**
|
|
431
|
+
* Props forwarded to {@link ErrorBoundary}.
|
|
432
|
+
*
|
|
433
|
+
* @see https://faasjs.com/doc/ant-design/#errorboundary
|
|
434
|
+
*/
|
|
229
435
|
errorBoundaryProps?: Omit<ErrorBoundaryProps, 'children'>;
|
|
230
|
-
/**
|
|
436
|
+
/**
|
|
437
|
+
* Props forwarded to {@link ConfigProvider}, or `false` to skip the FaasJS config layer.
|
|
438
|
+
*
|
|
439
|
+
* @see https://faasjs.com/doc/ant-design/#configprovider
|
|
440
|
+
*/
|
|
231
441
|
faasConfigProviderProps?: Omit<ConfigProviderProps, 'children'> | false;
|
|
232
442
|
}
|
|
233
443
|
/**
|
|
234
|
-
*
|
|
444
|
+
* Render the root provider shell for a FaasJS Ant Design application.
|
|
445
|
+
*
|
|
446
|
+
* `App` initializes Ant Design message and notification APIs, exposes hook-managed modal and
|
|
447
|
+
* drawer state through {@link AppContext}, wraps descendants with {@link ErrorBoundary}, and
|
|
448
|
+
* optionally mounts React Router's `BrowserRouter`.
|
|
235
449
|
*
|
|
236
|
-
* -
|
|
237
|
-
* - Integrated Ant Design's [Message](https://ant.design/components/message/) and [Notification](https://ant.design/components/notification/).
|
|
238
|
-
* - Based on FaasJS's [ConfigProvider](https://faasjs.com/doc/ant-design/#configprovider).
|
|
239
|
-
* - Integrated FaasJS's [Modal](https://faasjs.com/doc/ant-design/#usemodal), [Drawer](https://faasjs.com/doc/ant-design/#usedrawer) and [ErrorBoundary](https://faasjs.com/doc/ant-design/#errorboundary).
|
|
240
|
-
* - Integrated React Router's [BrowserRouter](https://api.reactrouter.com/v7/interfaces/react_router.BrowserRouterProps.html).
|
|
450
|
+
* @param {AppProps} props - App shell props including providers, routing, and error handling options.
|
|
241
451
|
*
|
|
242
452
|
* @example
|
|
243
453
|
* ```tsx
|
|
244
454
|
* import { App } from '@faasjs/ant-design'
|
|
245
455
|
*
|
|
246
|
-
* export default function () {
|
|
456
|
+
* export default function Page() {
|
|
247
457
|
* return (
|
|
248
458
|
* <App
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
459
|
+
* configProviderProps={{}}
|
|
460
|
+
* browserRouterProps={{}}
|
|
461
|
+
* errorBoundaryProps={{}}
|
|
462
|
+
* faasConfigProviderProps={{}}
|
|
253
463
|
* >
|
|
254
464
|
* <div>content</div>
|
|
255
465
|
* </App>
|
|
@@ -260,28 +470,46 @@ interface AppProps {
|
|
|
260
470
|
declare function App(props: AppProps): react_jsx_runtime0.JSX.Element;
|
|
261
471
|
//#endregion
|
|
262
472
|
//#region src/Blank.d.ts
|
|
473
|
+
/**
|
|
474
|
+
* Props for the {@link Blank} placeholder component.
|
|
475
|
+
*/
|
|
263
476
|
interface BlankProps {
|
|
477
|
+
/** Value to render when it is present. */
|
|
264
478
|
value?: any;
|
|
479
|
+
/** Placeholder text shown when `value` is empty. */
|
|
265
480
|
text?: string;
|
|
266
481
|
}
|
|
267
482
|
/**
|
|
268
|
-
*
|
|
483
|
+
* Render a disabled placeholder when a value is empty.
|
|
484
|
+
*
|
|
485
|
+
* Empty values include `undefined`, `null`, empty strings, and empty arrays.
|
|
269
486
|
*
|
|
270
|
-
*
|
|
487
|
+
* @param {BlankProps} [options] - Placeholder text and value to render.
|
|
488
|
+
* @returns Rendered value or the configured placeholder text.
|
|
271
489
|
*
|
|
272
490
|
* @example
|
|
273
491
|
* ```tsx
|
|
274
492
|
* import { Blank } from '@faasjs/ant-design'
|
|
275
493
|
*
|
|
276
|
-
*
|
|
494
|
+
* export function FieldPreview() {
|
|
495
|
+
* return <Blank value={undefined} text="Empty" />
|
|
496
|
+
* }
|
|
277
497
|
* ```
|
|
278
498
|
*/
|
|
279
499
|
declare function Blank(options?: BlankProps): JSX.Element;
|
|
280
500
|
//#endregion
|
|
281
501
|
//#region src/FormItem.d.ts
|
|
502
|
+
/**
|
|
503
|
+
* Custom renderer registration for a form item type.
|
|
504
|
+
*
|
|
505
|
+
* @template T - Value type rendered by the custom form item type.
|
|
506
|
+
*/
|
|
282
507
|
type ExtendFormTypeProps<T = any> = {
|
|
283
|
-
children?: UnionFaasItemElement<T>;
|
|
508
|
+
/** Custom element used to render the registered form item type. */children?: UnionFaasItemElement<T>;
|
|
284
509
|
};
|
|
510
|
+
/**
|
|
511
|
+
* Map of custom form item type registrations.
|
|
512
|
+
*/
|
|
285
513
|
type ExtendTypes = {
|
|
286
514
|
[type: string]: ExtendFormTypeProps;
|
|
287
515
|
};
|
|
@@ -296,39 +524,61 @@ type InputTypeMap<T> = {
|
|
|
296
524
|
object: never;
|
|
297
525
|
'object[]': never;
|
|
298
526
|
};
|
|
527
|
+
/**
|
|
528
|
+
* Item definition used by the `FormItem` and `Form` components.
|
|
529
|
+
*
|
|
530
|
+
* @template T - Value type rendered or edited by the form item.
|
|
531
|
+
*/
|
|
299
532
|
interface FormItemProps<T = any> extends BaseItemProps, Omit<FormItemProps$1<T>, 'id' | 'children' | 'render'> {
|
|
533
|
+
/**
|
|
534
|
+
* Built-in FaasJS field type used to choose the default Ant Design input.
|
|
535
|
+
*
|
|
536
|
+
* @default 'string'
|
|
537
|
+
*/
|
|
300
538
|
type?: FaasItemType;
|
|
539
|
+
/** Input props forwarded to the generated Ant Design control. */
|
|
301
540
|
input?: InputTypeMap<T>[FaasItemType];
|
|
541
|
+
/** Maximum item count allowed for list-style field types. */
|
|
302
542
|
maxCount?: number;
|
|
543
|
+
/** Nested field definitions used by `object` and `object[]` item types. */
|
|
303
544
|
object?: FormItemProps[];
|
|
545
|
+
/** Whether the generated field is disabled. */
|
|
304
546
|
disabled?: boolean;
|
|
547
|
+
/** Whether the generated field adds a required validation rule. */
|
|
305
548
|
required?: boolean;
|
|
549
|
+
/** Grid span used by surrounding object-list layouts. */
|
|
306
550
|
col?: number;
|
|
551
|
+
/** Generic custom field renderer or element. */
|
|
307
552
|
children?: UnionFaasItemElement<T> | null;
|
|
553
|
+
/** Form-specific custom field renderer or element. */
|
|
308
554
|
formChildren?: UnionFaasItemElement<T> | null;
|
|
555
|
+
/** Generic custom render callback. */
|
|
309
556
|
render?: UnionFaasItemRender<T> | null;
|
|
557
|
+
/** Form-specific custom render callback. */
|
|
310
558
|
formRender?: UnionFaasItemRender<T> | null;
|
|
559
|
+
/** Validation rules forwarded to Ant Design `Form.Item`. */
|
|
311
560
|
rules?: RuleObject[];
|
|
561
|
+
/** Label override, or `false` to hide the label completely. */
|
|
312
562
|
label?: string | false;
|
|
563
|
+
/** Custom form item type renderers keyed by type name. */
|
|
313
564
|
extendTypes?: ExtendTypes;
|
|
314
|
-
/**
|
|
565
|
+
/** Callback invoked when this field's value changes. */
|
|
315
566
|
onValueChange?: (value: T, values: any, form: FormInstance) => void;
|
|
316
|
-
/**
|
|
567
|
+
/** Predicate used to show or hide the item from the current form values. */
|
|
317
568
|
if?: (values: Record<string, any>) => boolean;
|
|
318
569
|
}
|
|
319
570
|
/**
|
|
320
|
-
*
|
|
571
|
+
* Item shape used to extend `Form` with custom type names.
|
|
321
572
|
*
|
|
322
573
|
* @example
|
|
323
|
-
* ```
|
|
324
|
-
* import type
|
|
574
|
+
* ```tsx
|
|
575
|
+
* import { Form, type ExtendFormItemProps, type FormProps } from '@faasjs/ant-design'
|
|
576
|
+
* import { Input } from 'antd'
|
|
325
577
|
*
|
|
326
|
-
* // define custom type
|
|
327
578
|
* interface ExtendTypes extends ExtendFormItemProps {
|
|
328
579
|
* type: 'password'
|
|
329
580
|
* }
|
|
330
581
|
*
|
|
331
|
-
* // extend form
|
|
332
582
|
* function ExtendForm(props: FormProps<any, ExtendTypes>) {
|
|
333
583
|
* return (
|
|
334
584
|
* <Form
|
|
@@ -338,35 +588,48 @@ interface FormItemProps<T = any> extends BaseItemProps, Omit<FormItemProps$1<T>,
|
|
|
338
588
|
* )
|
|
339
589
|
* }
|
|
340
590
|
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
591
|
+
* export function Page() {
|
|
592
|
+
* return (
|
|
593
|
+
* <ExtendForm
|
|
594
|
+
* items={[
|
|
595
|
+
* {
|
|
596
|
+
* id: 'password',
|
|
597
|
+
* type: 'password',
|
|
598
|
+
* },
|
|
599
|
+
* ]}
|
|
600
|
+
* />
|
|
601
|
+
* )
|
|
602
|
+
* }
|
|
350
603
|
* ```
|
|
351
604
|
*/
|
|
352
605
|
interface ExtendFormItemProps extends Omit<FormItemProps, 'type'> {
|
|
353
606
|
type?: string;
|
|
354
607
|
}
|
|
355
608
|
/**
|
|
356
|
-
*
|
|
609
|
+
* Render a FaasJS-aware Ant Design form field or nested field group.
|
|
610
|
+
*
|
|
611
|
+
* The component derives default labels from `id`, applies required validation messages from the
|
|
612
|
+
* active theme, supports surface-specific union renderers, and can render nested `object` or
|
|
613
|
+
* `object[]` field structures.
|
|
357
614
|
*
|
|
358
|
-
* -
|
|
359
|
-
* -
|
|
615
|
+
* @template T - Value type rendered or edited by the form item.
|
|
616
|
+
* @param {FormItemProps<T>} props - Form item props including field metadata, rules, and custom renderers.
|
|
360
617
|
*
|
|
361
618
|
* @example
|
|
362
619
|
* ```tsx
|
|
363
|
-
*
|
|
364
|
-
*
|
|
620
|
+
* import { FormItem } from '@faasjs/ant-design'
|
|
621
|
+
* import { Input } from 'antd'
|
|
365
622
|
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
623
|
+
* export function AccountFields() {
|
|
624
|
+
* return (
|
|
625
|
+
* <>
|
|
626
|
+
* <FormItem id="name" type="string" />
|
|
627
|
+
* <FormItem id="password">
|
|
628
|
+
* <Input.Password />
|
|
629
|
+
* </FormItem>
|
|
630
|
+
* </>
|
|
631
|
+
* )
|
|
632
|
+
* }
|
|
370
633
|
* ```
|
|
371
634
|
*/
|
|
372
635
|
declare function FormItem<T = any>(props: FormItemProps<T>): react_jsx_runtime0.JSX.Element | null;
|
|
@@ -379,25 +642,52 @@ declare namespace FormItem {
|
|
|
379
642
|
}
|
|
380
643
|
//#endregion
|
|
381
644
|
//#region src/Table.d.ts
|
|
645
|
+
/**
|
|
646
|
+
* Column definition used by the FaasJS Ant Design {@link Table} component.
|
|
647
|
+
*
|
|
648
|
+
* @template T - Row record type rendered by the table.
|
|
649
|
+
*/
|
|
382
650
|
interface TableItemProps<T = any> extends FaasItemProps, Omit<TableColumnProps<T>, 'title' | 'children' | 'render'> {
|
|
651
|
+
/** Use built-in option inference for filters when supported. */
|
|
383
652
|
optionsType?: 'auto';
|
|
653
|
+
/** Generic custom element rendered when no table-specific child overrides it. */
|
|
384
654
|
children?: UnionFaasItemElement<T> | null;
|
|
655
|
+
/** Table-specific custom element. */
|
|
385
656
|
tableChildren?: UnionFaasItemElement<T> | null;
|
|
657
|
+
/** Generic custom render callback. */
|
|
386
658
|
render?: UnionFaasItemRender<T> | null;
|
|
659
|
+
/** Table-specific custom render callback. */
|
|
387
660
|
tableRender?: UnionFaasItemRender<T> | null;
|
|
661
|
+
/** Nested item definitions used by `object` and `object[]` item types. */
|
|
388
662
|
object?: TableItemProps<T>[];
|
|
389
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
* Custom renderer registration for a table item type.
|
|
666
|
+
*
|
|
667
|
+
* @template T - Row record type rendered by the custom table item type.
|
|
668
|
+
*/
|
|
390
669
|
type ExtendTableTypeProps<T = any> = {
|
|
391
|
-
children?: UnionFaasItemElement<T>;
|
|
670
|
+
/** Custom element used to render the registered table item type. */children?: UnionFaasItemElement<T>; /** Custom render callback used when `children` is not provided. */
|
|
392
671
|
render?: UnionFaasItemRender<T>;
|
|
393
672
|
};
|
|
673
|
+
/**
|
|
674
|
+
* Shared fields for extending table item unions.
|
|
675
|
+
*
|
|
676
|
+
* @template T - Row record type rendered by the table.
|
|
677
|
+
*/
|
|
394
678
|
type ExtendTableItemProps<T = any> = BaseItemProps & Omit<TableColumnProps<T>, 'children'>;
|
|
679
|
+
/**
|
|
680
|
+
* Props for the FaasJS Ant Design {@link Table} component.
|
|
681
|
+
*
|
|
682
|
+
* @template T - Row record type rendered by the table.
|
|
683
|
+
* @template ExtendTypes - Additional item prop shape accepted by `items`.
|
|
684
|
+
*/
|
|
395
685
|
type TableProps<T = any, ExtendTypes = any> = {
|
|
396
|
-
items: (TableItemProps | (ExtendTypes & ExtendTableItemProps))[];
|
|
686
|
+
/** Column definitions rendered by the table. */items: (TableItemProps | (ExtendTypes & ExtendTableItemProps))[]; /** Custom type renderers keyed by item type. */
|
|
397
687
|
extendTypes?: {
|
|
398
688
|
[key: string]: ExtendTableTypeProps;
|
|
399
|
-
};
|
|
400
|
-
faasData?: FaasDataWrapperProps<any>;
|
|
689
|
+
}; /** Request config used to fetch table data before rendering. */
|
|
690
|
+
faasData?: FaasDataWrapperProps<any>; /** Change handler that can return rewritten pagination, filter, and sorter state. */
|
|
401
691
|
onChange?: (pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<T> | SorterResult<T>[], extra: TableCurrentDataSource<T>) => {
|
|
402
692
|
pagination: TablePaginationConfig;
|
|
403
693
|
filters: Record<string, FilterValue | null>;
|
|
@@ -405,41 +695,81 @@ type TableProps<T = any, ExtendTypes = any> = {
|
|
|
405
695
|
extra: TableCurrentDataSource<T>;
|
|
406
696
|
};
|
|
407
697
|
} & TableProps$1<T>;
|
|
698
|
+
/**
|
|
699
|
+
* Query params shape expected by table-backed FaasJS endpoints.
|
|
700
|
+
*/
|
|
408
701
|
type TableFaasDataParams = {
|
|
409
|
-
filters?: Record<string, any[]>;
|
|
702
|
+
/** Active filter values keyed by column field. */filters?: Record<string, any[]>; /** Pagination state sent to the endpoint. */
|
|
410
703
|
pagination?: {
|
|
411
|
-
current?: number;
|
|
704
|
+
/** Current page number. */current?: number; /** Requested page size. */
|
|
412
705
|
pageSize?: number;
|
|
413
|
-
};
|
|
706
|
+
}; /** Sorter state sent to the endpoint. */
|
|
414
707
|
sorter?: {
|
|
415
|
-
field: string;
|
|
708
|
+
/** Column field being sorted. */field: string; /** Sort direction. */
|
|
416
709
|
order: 'ascend' | 'descend';
|
|
417
710
|
} | {
|
|
418
|
-
field: string;
|
|
711
|
+
/** Column field being sorted. */field: string; /** Sort direction when active. */
|
|
419
712
|
order?: 'ascend' | 'descend';
|
|
420
713
|
}[];
|
|
421
714
|
};
|
|
715
|
+
/**
|
|
716
|
+
* Paginated response shape expected by {@link Table} when using `faasData`.
|
|
717
|
+
*
|
|
718
|
+
* @template T - Row record type contained in `rows`.
|
|
719
|
+
*/
|
|
422
720
|
type TableFaasDataResponse<T = any> = {
|
|
423
|
-
rows: T[];
|
|
721
|
+
/** Rows rendered by the table. */rows: T[]; /** Pagination state returned by the endpoint. */
|
|
424
722
|
pagination: {
|
|
425
|
-
current: number;
|
|
426
|
-
pageSize: number;
|
|
723
|
+
/** Current page number. */current: number; /** Page size used for the result set. */
|
|
724
|
+
pageSize: number; /** Total number of available rows. */
|
|
427
725
|
total: number;
|
|
428
726
|
};
|
|
429
727
|
};
|
|
430
728
|
/**
|
|
431
|
-
*
|
|
729
|
+
* Render an Ant Design table from FaasJS item metadata.
|
|
730
|
+
*
|
|
731
|
+
* The component can render local `dataSource` rows or resolve remote rows through `faasData`. It
|
|
732
|
+
* also generates default filters and sorters for built-in item types unless you disable them with
|
|
733
|
+
* the corresponding Ant Design column props.
|
|
734
|
+
*
|
|
735
|
+
* @template T - Row record type rendered by the table.
|
|
736
|
+
* @template ExtendTypes - Additional item prop shape accepted by `items`.
|
|
737
|
+
* @param {TableProps<T, ExtendTypes>} props - Table props including columns, data source, and optional Faas data config.
|
|
738
|
+
* @throws {Error} When an entry in `extendTypes` omits both `children` and `render`.
|
|
432
739
|
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
*
|
|
740
|
+
* @example
|
|
741
|
+
* ```tsx
|
|
742
|
+
* import { Table } from '@faasjs/ant-design'
|
|
743
|
+
*
|
|
744
|
+
* const rows = [
|
|
745
|
+
* { id: 1, name: 'Alice', active: true },
|
|
746
|
+
* { id: 2, name: 'Bob', active: false },
|
|
747
|
+
* ]
|
|
748
|
+
*
|
|
749
|
+
* export function UserTable() {
|
|
750
|
+
* return (
|
|
751
|
+
* <Table
|
|
752
|
+
* rowKey="id"
|
|
753
|
+
* dataSource={rows}
|
|
754
|
+
* items={[
|
|
755
|
+
* { id: 'name', title: 'Name' },
|
|
756
|
+
* { id: 'active', type: 'boolean', title: 'Active' },
|
|
757
|
+
* ]}
|
|
758
|
+
* />
|
|
759
|
+
* )
|
|
760
|
+
* }
|
|
761
|
+
* ```
|
|
437
762
|
*/
|
|
438
763
|
declare function Table<T extends Record<string, any>, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): react_jsx_runtime0.JSX.Element | null;
|
|
439
764
|
//#endregion
|
|
440
765
|
//#region src/data.d.ts
|
|
766
|
+
/**
|
|
767
|
+
* Supported built-in field types shared by form, table, and description components.
|
|
768
|
+
*/
|
|
441
769
|
type FaasItemType = 'string' | 'string[]' | 'number' | 'number[]' | 'boolean' | 'date' | 'time' | 'object' | 'object[]';
|
|
442
|
-
/**
|
|
770
|
+
/**
|
|
771
|
+
* Runtime value mapping for each built-in {@link FaasItemType}.
|
|
772
|
+
*/
|
|
443
773
|
type FaasItemTypeValue = {
|
|
444
774
|
string: string;
|
|
445
775
|
'string[]': string[];
|
|
@@ -451,59 +781,117 @@ type FaasItemTypeValue = {
|
|
|
451
781
|
object: any;
|
|
452
782
|
'object[]': any[];
|
|
453
783
|
};
|
|
784
|
+
/**
|
|
785
|
+
* Option item accepted by built-in choice inputs.
|
|
786
|
+
*/
|
|
454
787
|
type BaseOption = string | number | {
|
|
455
|
-
label: string;
|
|
788
|
+
/** Display label rendered by Ant Design controls. */label: string; /** Raw option value submitted or matched by components. */
|
|
456
789
|
value?: any;
|
|
457
790
|
};
|
|
791
|
+
/**
|
|
792
|
+
* Common metadata shared by form, table, and description items.
|
|
793
|
+
*/
|
|
458
794
|
interface BaseItemProps {
|
|
795
|
+
/** Stable field identifier used as the default name and title source. */
|
|
459
796
|
id: string | number;
|
|
797
|
+
/** Human-readable title used for labels and table headers. */
|
|
460
798
|
title?: string;
|
|
799
|
+
/** Shared choice options used by select-like renderers. */
|
|
461
800
|
options?: BaseOption[];
|
|
462
801
|
}
|
|
802
|
+
/**
|
|
803
|
+
* Base item props plus the shared built-in value type selector.
|
|
804
|
+
*/
|
|
463
805
|
interface FaasItemProps extends BaseItemProps {
|
|
464
806
|
/**
|
|
465
|
-
*
|
|
807
|
+
* Built-in FaasJS field type used to normalize and render values.
|
|
808
|
+
*
|
|
466
809
|
* @default 'string'
|
|
467
810
|
*/
|
|
468
811
|
type?: FaasItemType;
|
|
469
812
|
}
|
|
470
813
|
/**
|
|
471
|
-
*
|
|
814
|
+
* Convert a snake_case, kebab-case, or spaced identifier into a title-style label.
|
|
472
815
|
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
* @param id - The identifier string to convert.
|
|
477
|
-
* @returns The converted title case string.
|
|
816
|
+
* @param {string | number} id - Identifier to convert.
|
|
817
|
+
* @returns Generated label string.
|
|
478
818
|
*
|
|
479
819
|
* @example
|
|
480
|
-
* ```
|
|
481
|
-
* idToTitle('example_id')
|
|
820
|
+
* ```ts
|
|
821
|
+
* idToTitle('example_id') // 'Example Id'
|
|
482
822
|
* ```
|
|
483
823
|
*/
|
|
484
824
|
declare function idToTitle(id: string | number): string;
|
|
485
825
|
/**
|
|
486
|
-
*
|
|
826
|
+
* Normalize primitive options into explicit `{ label, value }` objects.
|
|
827
|
+
*
|
|
828
|
+
* String and number options are converted with {@link idToTitle}, while pre-shaped option objects
|
|
829
|
+
* are returned as-is.
|
|
830
|
+
*
|
|
831
|
+
* @param {BaseOption[]} options - Raw option list to normalize.
|
|
832
|
+
* @returns Normalized option list.
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* ```ts
|
|
836
|
+
* import { transferOptions } from '@faasjs/ant-design'
|
|
837
|
+
*
|
|
838
|
+
* transferOptions(['draft', { label: 'Published', value: 'published' }])
|
|
839
|
+
* // [
|
|
840
|
+
* // { label: 'Draft', value: 'draft' },
|
|
841
|
+
* // { label: 'Published', value: 'published' },
|
|
842
|
+
* // ]
|
|
843
|
+
* ```
|
|
487
844
|
*/
|
|
488
845
|
declare function transferOptions(options: BaseOption[]): {
|
|
489
846
|
label: string;
|
|
490
847
|
value?: string | number;
|
|
491
848
|
}[];
|
|
849
|
+
/**
|
|
850
|
+
* Normalize raw values into the runtime shape expected by FaasJS Ant Design components.
|
|
851
|
+
*
|
|
852
|
+
* Primitive strings such as `'null'` and `'undefined'` become `null`, comma-delimited array
|
|
853
|
+
* strings are split into arrays, and date or time values are converted to `dayjs` objects.
|
|
854
|
+
*
|
|
855
|
+
* @param {FaasItemType | null | undefined} type - Target field type.
|
|
856
|
+
* @param {any} value - Raw value to normalize.
|
|
857
|
+
* @returns Normalized value for rendering or form initialization.
|
|
858
|
+
*
|
|
859
|
+
* @example
|
|
860
|
+
* ```ts
|
|
861
|
+
* import { transferValue } from '@faasjs/ant-design'
|
|
862
|
+
*
|
|
863
|
+
* transferValue('number', '42') // 42
|
|
864
|
+
* transferValue('boolean', 'true') // true
|
|
865
|
+
* transferValue('string[]', 'a,b') // ['a', 'b']
|
|
866
|
+
* ```
|
|
867
|
+
*/
|
|
492
868
|
declare function transferValue(type: FaasItemType | null | undefined, value: any): any;
|
|
869
|
+
/**
|
|
870
|
+
* Rendering surfaces supported by union item helpers.
|
|
871
|
+
*/
|
|
493
872
|
type UnionScene = 'form' | 'description' | 'table';
|
|
873
|
+
/**
|
|
874
|
+
* Props injected into custom union item components.
|
|
875
|
+
*
|
|
876
|
+
* @template Value - Current item value type.
|
|
877
|
+
* @template Values - Whole record or row type that contains the value.
|
|
878
|
+
*/
|
|
494
879
|
type UnionFaasItemInjection<Value = any, Values = any> = {
|
|
495
|
-
scene?: UnionScene;
|
|
496
|
-
value?: Value;
|
|
497
|
-
values?: Values;
|
|
880
|
+
/** Rendering surface requesting the injected element. */scene?: UnionScene; /** Current field, cell, or item value. */
|
|
881
|
+
value?: Value; /** Full record or row containing the current value. */
|
|
882
|
+
values?: Values; /** Current row or list index when available. */
|
|
498
883
|
index?: number;
|
|
499
884
|
};
|
|
500
885
|
/**
|
|
501
|
-
*
|
|
886
|
+
* Render callback signature shared by form, description, and table item definitions.
|
|
502
887
|
*
|
|
503
|
-
* @
|
|
504
|
-
* @
|
|
505
|
-
*
|
|
506
|
-
* @param
|
|
888
|
+
* @template Value - Current item value type.
|
|
889
|
+
* @template Values - Whole record or row type that contains the value.
|
|
890
|
+
*
|
|
891
|
+
* @param {Value} value - Current item value.
|
|
892
|
+
* @param {Values} values - Whole record or row containing the value.
|
|
893
|
+
* @param {number} index - Current row or list index.
|
|
894
|
+
* @param {UnionScene} scene - Rendering surface requesting the output.
|
|
507
895
|
*
|
|
508
896
|
* @example
|
|
509
897
|
* ```tsx
|
|
@@ -539,9 +927,10 @@ type UnionFaasItemInjection<Value = any, Values = any> = {
|
|
|
539
927
|
*/
|
|
540
928
|
type UnionFaasItemRender<Value = any, Values = any> = (value: Value, values: Values, index: number, scene: UnionScene) => React.ReactNode;
|
|
541
929
|
/**
|
|
542
|
-
*
|
|
930
|
+
* Custom React component or element accepted by union item definitions.
|
|
543
931
|
*
|
|
544
|
-
*
|
|
932
|
+
* @template Value - Current item value type.
|
|
933
|
+
* @template Values - Whole record or row type that contains the value.
|
|
545
934
|
*
|
|
546
935
|
* @example
|
|
547
936
|
* ```tsx
|
|
@@ -549,7 +938,6 @@ type UnionFaasItemRender<Value = any, Values = any> = (value: Value, values: Val
|
|
|
549
938
|
*
|
|
550
939
|
* const NameComponent: UnionFaasItemElement = ({ scene, value }) => {
|
|
551
940
|
* switch (scene) {
|
|
552
|
-
* switch (scene) {
|
|
553
941
|
* case 'form':
|
|
554
942
|
* return <input />
|
|
555
943
|
* case 'description':
|
|
@@ -562,49 +950,36 @@ type UnionFaasItemRender<Value = any, Values = any> = (value: Value, values: Val
|
|
|
562
950
|
*
|
|
563
951
|
* const items = [
|
|
564
952
|
* {
|
|
565
|
-
*
|
|
566
|
-
*
|
|
953
|
+
* id: 'name',
|
|
954
|
+
* children: NameComponent, // both `NameComponent` and `<NameComponent />` are valid
|
|
567
955
|
* }
|
|
568
956
|
* ]
|
|
569
957
|
*
|
|
570
958
|
* function App() {
|
|
571
|
-
* return
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
959
|
+
* return (
|
|
960
|
+
* <>
|
|
961
|
+
* <Form items={items} />
|
|
962
|
+
* <Description items={items} dataSource={{ name: 'John' }} />
|
|
963
|
+
* <Table items={items} dataSource={[{ name: 'John' }]} />
|
|
964
|
+
* </>
|
|
965
|
+
* )
|
|
576
966
|
* }
|
|
577
967
|
* ```
|
|
578
968
|
*/
|
|
579
969
|
type UnionFaasItemElement<Value = any, Values = any> = ReactElement<UnionFaasItemInjection<Value, Values>> | FC<UnionFaasItemInjection<Value, Values>>;
|
|
580
970
|
/**
|
|
581
|
-
*
|
|
582
|
-
*
|
|
583
|
-
* The UnionFaas item can be used in a form, description, or table.
|
|
971
|
+
* Shared union item contract that can be reused across `Form`, `Description`, and `Table`.
|
|
584
972
|
*
|
|
585
973
|
* ### Render Priority Order
|
|
586
974
|
*
|
|
587
|
-
* 1.
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
* - `tableChildren` for Table
|
|
596
|
-
* 2. Second priority: Generic `children` prop
|
|
597
|
-
* 3. **Custom Render Functions**
|
|
598
|
-
* 1. First priority: Component-specific render functions
|
|
599
|
-
* - `formRender` for Form
|
|
600
|
-
* - `descriptionRender` for Description
|
|
601
|
-
* - `tableRender` for Table
|
|
602
|
-
* 2. Second priority: Generic `render` prop
|
|
603
|
-
* 4. **Extended Types**
|
|
604
|
-
* - Renders based on registered extended type handlers
|
|
605
|
-
* 5. **Default Rendering**
|
|
606
|
-
* - Renders primitive types (string, number, etc.)
|
|
607
|
-
* - Uses default formatting based on data type
|
|
975
|
+
* 1. Component-specific null renderers hide the item for that surface.
|
|
976
|
+
* 2. Component-specific children override generic `children`.
|
|
977
|
+
* 3. Component-specific render callbacks override generic `render`.
|
|
978
|
+
* 4. Registered extended types handle unmatched items.
|
|
979
|
+
* 5. Built-in type renderers handle primitive and object values.
|
|
980
|
+
*
|
|
981
|
+
* @template Value - Current item value type.
|
|
982
|
+
* @template Values - Whole record or row type that contains the value.
|
|
608
983
|
*
|
|
609
984
|
* @example
|
|
610
985
|
* ```tsx
|
|
@@ -642,105 +1017,183 @@ type UnionFaasItemElement<Value = any, Values = any> = ReactElement<UnionFaasIte
|
|
|
642
1017
|
* ```
|
|
643
1018
|
*/
|
|
644
1019
|
interface UnionFaasItemProps<Value = any, Values = any> extends FormItemProps, DescriptionItemProps, TableItemProps {
|
|
1020
|
+
/** Shared custom element rendered when no surface-specific child overrides it. */
|
|
645
1021
|
children?: UnionFaasItemElement<Value, Values> | null;
|
|
1022
|
+
/** Shared render callback used when no surface-specific render overrides it. */
|
|
646
1023
|
render?: UnionFaasItemRender<Value, Values> | null;
|
|
1024
|
+
/** Nested item definitions used by `object` and `object[]` item types. */
|
|
647
1025
|
object?: UnionFaasItemProps<Value, Values>[];
|
|
648
1026
|
}
|
|
649
1027
|
/**
|
|
650
|
-
* Clone a UnionFaasItemElement with
|
|
1028
|
+
* Clone a {@link UnionFaasItemElement} with FaasJS injection props.
|
|
1029
|
+
*
|
|
1030
|
+
* React elements are cloned directly, while component references are first wrapped with
|
|
1031
|
+
* `createElement`.
|
|
1032
|
+
*
|
|
1033
|
+
* @param {UnionFaasItemElement} element - Element or component to clone.
|
|
1034
|
+
* @param {any} props - Injection props such as `scene`, `value`, `values`, and `index`.
|
|
1035
|
+
* @returns Cloned React element ready for rendering.
|
|
1036
|
+
*
|
|
1037
|
+
* @example
|
|
1038
|
+
* ```tsx
|
|
1039
|
+
* import { cloneUnionFaasItemElement, type UnionFaasItemElement } from '@faasjs/ant-design'
|
|
651
1040
|
*
|
|
652
|
-
*
|
|
653
|
-
* If the provided element is a valid React element, it clones it with the new props.
|
|
654
|
-
* Otherwise, it creates a new element from the provided element and props.
|
|
1041
|
+
* const Cell: UnionFaasItemElement<string> = ({ value }) => <span>{value}</span>
|
|
655
1042
|
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
1043
|
+
* const element = cloneUnionFaasItemElement(Cell, {
|
|
1044
|
+
* scene: 'table',
|
|
1045
|
+
* value: 'Hello',
|
|
1046
|
+
* index: 0,
|
|
1047
|
+
* })
|
|
1048
|
+
* ```
|
|
659
1049
|
*/
|
|
660
1050
|
declare function cloneUnionFaasItemElement(element: UnionFaasItemElement, props: any): ReactElement<UnionFaasItemInjection<any, any>, string | react.JSXElementConstructor<any>>;
|
|
661
1051
|
//#endregion
|
|
662
1052
|
//#region src/Description.d.ts
|
|
1053
|
+
/**
|
|
1054
|
+
* Custom renderer registration for a description item type.
|
|
1055
|
+
*
|
|
1056
|
+
* @template T - Value type rendered by the custom description item type.
|
|
1057
|
+
*/
|
|
663
1058
|
interface ExtendDescriptionTypeProps<T = any> {
|
|
1059
|
+
/** Custom element used to render the registered description item type. */
|
|
664
1060
|
children?: UnionFaasItemElement<T>;
|
|
1061
|
+
/** Custom render callback used when `children` is not provided. */
|
|
665
1062
|
render?: UnionFaasItemRender<T>;
|
|
666
1063
|
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Shared fields for extending description item unions.
|
|
1066
|
+
*/
|
|
667
1067
|
type ExtendDescriptionItemProps = BaseItemProps;
|
|
1068
|
+
/**
|
|
1069
|
+
* Item definition used by {@link Description}.
|
|
1070
|
+
*
|
|
1071
|
+
* @template T - Value type rendered by the item.
|
|
1072
|
+
*/
|
|
668
1073
|
interface DescriptionItemProps<T = any> extends FaasItemProps {
|
|
1074
|
+
/** Generic custom element rendered when no description-specific child overrides it. */
|
|
669
1075
|
children?: UnionFaasItemElement<T> | null;
|
|
1076
|
+
/** Description-specific custom element. */
|
|
670
1077
|
descriptionChildren?: UnionFaasItemElement<T> | null;
|
|
1078
|
+
/** Generic custom render callback. */
|
|
671
1079
|
render?: UnionFaasItemRender<T> | null;
|
|
1080
|
+
/** Description-specific custom render callback. */
|
|
672
1081
|
descriptionRender?: UnionFaasItemRender<T> | null;
|
|
1082
|
+
/** Predicate used to hide the item for the current record. */
|
|
673
1083
|
if?: (values: Record<string, any>) => boolean;
|
|
1084
|
+
/** Nested item definitions used by `object` and `object[]` item types. */
|
|
674
1085
|
object?: DescriptionItemProps<T>[];
|
|
675
1086
|
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Props for the {@link Description} component.
|
|
1089
|
+
*
|
|
1090
|
+
* @template T - Data record shape rendered by the component.
|
|
1091
|
+
* @template ExtendItemProps - Additional item prop shape accepted by `items`.
|
|
1092
|
+
*/
|
|
676
1093
|
interface DescriptionProps<T = any, ExtendItemProps = any> extends Omit<DescriptionsProps, 'items'> {
|
|
1094
|
+
/** Callback used to derive the rendered title from the current record. */
|
|
677
1095
|
renderTitle?(this: void, values: T): ReactNode;
|
|
1096
|
+
/** Description item definitions rendered by the component. */
|
|
678
1097
|
items: (DescriptionItemProps | ExtendItemProps)[];
|
|
1098
|
+
/** Custom type renderers keyed by item type. */
|
|
679
1099
|
extendTypes?: {
|
|
680
1100
|
[key: string]: ExtendDescriptionTypeProps;
|
|
681
1101
|
};
|
|
1102
|
+
/** Local data record rendered directly by the component. */
|
|
682
1103
|
dataSource?: T;
|
|
1104
|
+
/** Request config used to fetch the record before rendering. */
|
|
683
1105
|
faasData?: FaasDataWrapperProps<any>;
|
|
684
1106
|
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Props passed to the exported `DescriptionItemContent` helper shape.
|
|
1109
|
+
*
|
|
1110
|
+
* @template T - Value type rendered by the item content.
|
|
1111
|
+
*/
|
|
685
1112
|
interface DescriptionItemContentProps<T = any> {
|
|
1113
|
+
/** Item definition describing how the value should render. */
|
|
686
1114
|
item: DescriptionItemProps;
|
|
1115
|
+
/** Current item value. */
|
|
687
1116
|
value: T;
|
|
1117
|
+
/** Full record containing the current value. */
|
|
688
1118
|
values?: any;
|
|
1119
|
+
/** Custom type renderers keyed by item type. */
|
|
689
1120
|
extendTypes?: {
|
|
690
1121
|
[key: string]: ExtendDescriptionTypeProps;
|
|
691
1122
|
};
|
|
692
1123
|
}
|
|
693
1124
|
/**
|
|
694
|
-
*
|
|
1125
|
+
* Render an Ant Design description list from FaasJS item metadata.
|
|
1126
|
+
*
|
|
1127
|
+
* The component can render a local `dataSource` directly or resolve one through `faasData`, and
|
|
1128
|
+
* it applies the same item type normalization helpers used by the form and table components.
|
|
695
1129
|
*
|
|
696
|
-
* -
|
|
1130
|
+
* @template T - Data record shape rendered by the component.
|
|
1131
|
+
* @param {DescriptionProps<T>} props - Description props including items, data source, and optional Faas data config.
|
|
1132
|
+
* @throws {Error} When an entry in `extendTypes` omits both `children` and `render`.
|
|
697
1133
|
*
|
|
698
1134
|
* @example
|
|
699
1135
|
* ```tsx
|
|
700
1136
|
* import { Description } from '@faasjs/ant-design'
|
|
701
1137
|
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
*
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
1138
|
+
* export function Detail() {
|
|
1139
|
+
* return (
|
|
1140
|
+
* <Description
|
|
1141
|
+
* title="Title"
|
|
1142
|
+
* items={[
|
|
1143
|
+
* {
|
|
1144
|
+
* id: 'id',
|
|
1145
|
+
* title: 'Title',
|
|
1146
|
+
* type: 'string',
|
|
1147
|
+
* },
|
|
1148
|
+
* ]}
|
|
1149
|
+
* dataSource={{ id: 'value' }}
|
|
1150
|
+
* />
|
|
1151
|
+
* )
|
|
1152
|
+
* }
|
|
713
1153
|
* ```
|
|
714
1154
|
*/
|
|
715
|
-
declare function Description<T extends Record<string, any> = any>(
|
|
716
|
-
faasData,
|
|
717
|
-
dataSource,
|
|
718
|
-
renderTitle,
|
|
719
|
-
extendTypes,
|
|
720
|
-
...props
|
|
721
|
-
}: DescriptionProps<T>): react_jsx_runtime0.JSX.Element;
|
|
1155
|
+
declare function Description<T extends Record<string, any> = any>(props: DescriptionProps<T>): react_jsx_runtime0.JSX.Element;
|
|
722
1156
|
declare namespace Description {
|
|
723
1157
|
var displayName: string;
|
|
724
1158
|
}
|
|
725
1159
|
//#endregion
|
|
726
1160
|
//#region src/Drawer.d.ts
|
|
1161
|
+
/**
|
|
1162
|
+
* Props accepted by the hook-managed drawer wrapper.
|
|
1163
|
+
*/
|
|
727
1164
|
interface DrawerProps extends DrawerProps$1 {
|
|
1165
|
+
/** Drawer body content managed by {@link useDrawer}. */
|
|
728
1166
|
children?: JSX.Element | JSX.Element[];
|
|
729
1167
|
}
|
|
1168
|
+
/**
|
|
1169
|
+
* State setter used to update hook-managed drawer props.
|
|
1170
|
+
*/
|
|
730
1171
|
type setDrawerProps = Dispatch<SetStateAction<DrawerProps>>;
|
|
731
1172
|
/**
|
|
732
|
-
*
|
|
1173
|
+
* Create a hook-managed Ant Design drawer instance.
|
|
1174
|
+
*
|
|
1175
|
+
* The returned setter merges partial updates into the current drawer props instead of replacing the
|
|
1176
|
+
* entire state object.
|
|
733
1177
|
*
|
|
1178
|
+
* @param {DrawerProps} [init] - Initial drawer props.
|
|
1179
|
+
* @returns Hook-managed drawer element, current props, and a state-merging setter.
|
|
1180
|
+
*
|
|
1181
|
+
* @example
|
|
734
1182
|
* ```tsx
|
|
1183
|
+
* import { useDrawer } from '@faasjs/ant-design'
|
|
1184
|
+
* import { Button } from 'antd'
|
|
1185
|
+
*
|
|
735
1186
|
* function Example() {
|
|
736
1187
|
* const { drawer, setDrawerProps } = useDrawer()
|
|
737
1188
|
*
|
|
738
|
-
* return
|
|
739
|
-
*
|
|
740
|
-
*
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
1189
|
+
* return (
|
|
1190
|
+
* <>
|
|
1191
|
+
* <Button onClick={() => setDrawerProps({ open: true, title: 'Details', children: <div>Content</div> })}>
|
|
1192
|
+
* Open
|
|
1193
|
+
* </Button>
|
|
1194
|
+
* {drawer}
|
|
1195
|
+
* </>
|
|
1196
|
+
* )
|
|
744
1197
|
* }
|
|
745
1198
|
* ```
|
|
746
1199
|
*/
|
|
@@ -751,16 +1204,21 @@ declare function useDrawer(init?: DrawerProps): {
|
|
|
751
1204
|
};
|
|
752
1205
|
//#endregion
|
|
753
1206
|
//#region src/Form.d.ts
|
|
1207
|
+
/**
|
|
1208
|
+
* Props for the built-in submit button rendered by {@link Form}.
|
|
1209
|
+
*/
|
|
754
1210
|
type FormSubmitProps = {
|
|
755
|
-
/**
|
|
1211
|
+
/** Text rendered by the built-in submit button. */text?: string; /** Additional props forwarded to the built-in submit button. */
|
|
756
1212
|
buttonProps?: ButtonProps;
|
|
757
1213
|
};
|
|
758
1214
|
/**
|
|
759
|
-
* Built-in FaasJS submit handler for Form.
|
|
1215
|
+
* Built-in FaasJS submit handler configuration for {@link Form}.
|
|
1216
|
+
*
|
|
1217
|
+
* @template Values - Form values shape used by submit handlers.
|
|
760
1218
|
*
|
|
761
1219
|
* @example
|
|
762
1220
|
* ```ts
|
|
763
|
-
* {
|
|
1221
|
+
* const faas = {
|
|
764
1222
|
* action: 'user/create',
|
|
765
1223
|
* params: (values) => ({
|
|
766
1224
|
* ...values,
|
|
@@ -773,34 +1231,43 @@ type FormSubmitProps = {
|
|
|
773
1231
|
* ```
|
|
774
1232
|
*/
|
|
775
1233
|
type FormFaasProps<Values extends Record<string, any> = any> = {
|
|
776
|
-
/** Action name
|
|
777
|
-
params?: Record<string, any> | ((values: Record<string, any>) => Record<string, any>); /** Transform form values before sending the request */
|
|
778
|
-
transformValues?: (values: Values) => Record<string, any> | Promise<Record<string, any>>; /**
|
|
779
|
-
onSuccess?: (result: any, values: Record<string, any>) => void; /**
|
|
780
|
-
onError?: (error: any, values: Record<string, any>) => void; /**
|
|
1234
|
+
/** Action name submitted through `faas()`. */action: FaasAction; /** Extra params merged into the submitted payload after `transformValues` runs. */
|
|
1235
|
+
params?: Record<string, any> | ((values: Record<string, any>) => Record<string, any>); /** Transform form values before sending the request. */
|
|
1236
|
+
transformValues?: (values: Values) => Record<string, any> | Promise<Record<string, any>>; /** Callback invoked when the request succeeds. */
|
|
1237
|
+
onSuccess?: (result: any, values: Record<string, any>) => void; /** Callback invoked when the request fails. */
|
|
1238
|
+
onError?: (error: any, values: Record<string, any>) => void; /** Callback invoked after the request settles. */
|
|
781
1239
|
onFinally?: () => void;
|
|
782
1240
|
};
|
|
1241
|
+
/**
|
|
1242
|
+
* Props for the FaasJS Ant Design {@link Form} component.
|
|
1243
|
+
*
|
|
1244
|
+
* @template Values - Form values shape.
|
|
1245
|
+
* @template ExtendItemProps - Additional item prop shape accepted by `items`.
|
|
1246
|
+
*/
|
|
783
1247
|
type FormProps<Values extends Record<string, any> = any, ExtendItemProps extends ExtendFormItemProps = ExtendFormItemProps> = Omit<FormProps$1<Values>, 'onFinish' | 'children' | 'initialValues'> & {
|
|
784
|
-
items?: ((ExtendItemProps extends ExtendFormItemProps ? ExtendItemProps | FormItemProps : FormItemProps) | JSX.Element)[]; /**
|
|
785
|
-
submit?: false | FormSubmitProps;
|
|
786
|
-
beforeItems?: JSX.Element | JSX.Element[];
|
|
787
|
-
footer?: JSX.Element | JSX.Element[];
|
|
788
|
-
extendTypes?: ExtendTypes;
|
|
789
|
-
children?: ReactNode;
|
|
1248
|
+
/** Form item definitions or custom JSX blocks rendered inside the form. */items?: ((ExtendItemProps extends ExtendFormItemProps ? ExtendItemProps | FormItemProps : FormItemProps) | JSX.Element)[]; /** Built-in submit button config, or `false` to disable the generated submit button. */
|
|
1249
|
+
submit?: false | FormSubmitProps; /** Extra content rendered before generated items. */
|
|
1250
|
+
beforeItems?: JSX.Element | JSX.Element[]; /** Extra content rendered after generated items. */
|
|
1251
|
+
footer?: JSX.Element | JSX.Element[]; /** Custom form item type renderers keyed by type name. */
|
|
1252
|
+
extendTypes?: ExtendTypes; /** Additional custom content rendered inside the form. */
|
|
1253
|
+
children?: ReactNode; /** Initial values applied to the underlying Ant Design form. */
|
|
790
1254
|
initialValues?: Partial<Values>;
|
|
791
1255
|
} & ({
|
|
792
|
-
/** Built-in FaasJS submit handler, ignored when onFinish is provided */faas?: FormFaasProps<Values>;
|
|
1256
|
+
/** Built-in FaasJS submit handler, ignored when `onFinish` is provided. */faas?: FormFaasProps<Values>;
|
|
793
1257
|
onFinish?: never;
|
|
794
1258
|
} | {
|
|
795
|
-
faas?: never; /** Custom submit handler
|
|
1259
|
+
faas?: never; /** Custom submit handler used instead of the built-in FaasJS submit flow. */
|
|
796
1260
|
onFinish?: (values: Values) => void | Promise<void>;
|
|
797
1261
|
});
|
|
798
1262
|
/**
|
|
799
|
-
*
|
|
1263
|
+
* Render a data-aware Ant Design form with optional FaasJS submission helpers.
|
|
800
1264
|
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
*
|
|
1265
|
+
* The component normalizes `initialValues` with {@link transferValue}, renders item definitions
|
|
1266
|
+
* through {@link FormItem}, and can either delegate submission to a custom `onFinish` handler or
|
|
1267
|
+
* the built-in FaasJS request flow configured by `faas`.
|
|
1268
|
+
*
|
|
1269
|
+
* @template Values - Form values shape.
|
|
1270
|
+
* @param {FormProps<Values>} props - Form props including items, submit behavior, and FaasJS integration.
|
|
804
1271
|
*
|
|
805
1272
|
* @example
|
|
806
1273
|
* ```tsx
|
|
@@ -856,48 +1323,92 @@ declare namespace Form {
|
|
|
856
1323
|
}
|
|
857
1324
|
//#endregion
|
|
858
1325
|
//#region src/Link.d.ts
|
|
1326
|
+
/**
|
|
1327
|
+
* Props for the navigation-aware {@link Link} component.
|
|
1328
|
+
*/
|
|
859
1329
|
interface LinkProps {
|
|
1330
|
+
/** Target URL or route path. */
|
|
860
1331
|
href: string;
|
|
1332
|
+
/** Explicit link target. Absolute HTTP URLs default to `_blank`. */
|
|
861
1333
|
target?: '_blank';
|
|
1334
|
+
/** Text rendered when `children` is not provided. */
|
|
862
1335
|
text?: string | number;
|
|
1336
|
+
/** Custom link content rendered instead of `text`. */
|
|
863
1337
|
children?: ReactNode;
|
|
1338
|
+
/** Inline styles merged with the theme defaults. */
|
|
864
1339
|
style?: CSSProperties;
|
|
1340
|
+
/** Button mode config, or `true` to render with default Ant Design button props. */
|
|
865
1341
|
button?: ButtonProps | boolean;
|
|
1342
|
+
/** Whether the rendered link or button should take the full width. */
|
|
866
1343
|
block?: boolean;
|
|
867
|
-
/**
|
|
1344
|
+
/** Whether plain-text links should enable the Typography copy action. */
|
|
868
1345
|
copyable?: boolean;
|
|
1346
|
+
/** Custom click handler that overrides the built-in navigation behavior. */
|
|
869
1347
|
onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
870
1348
|
}
|
|
871
1349
|
/**
|
|
872
|
-
*
|
|
1350
|
+
* Render a navigation-aware link or button.
|
|
1351
|
+
*
|
|
1352
|
+
* Internal links are pushed through React Router, while links with `_blank` targets are opened
|
|
1353
|
+
* with `window.open`.
|
|
1354
|
+
*
|
|
1355
|
+
* @param {LinkProps} props - Link props controlling navigation target, rendering mode, and button behavior.
|
|
873
1356
|
*
|
|
874
1357
|
* @example
|
|
875
1358
|
* ```tsx
|
|
876
|
-
*
|
|
877
|
-
* <Link href="/">Home</Link>
|
|
1359
|
+
* import { Link } from '@faasjs/ant-design'
|
|
878
1360
|
*
|
|
879
|
-
*
|
|
880
|
-
*
|
|
1361
|
+
* export function Navigation() {
|
|
1362
|
+
* return (
|
|
1363
|
+
* <>
|
|
1364
|
+
* <Link href="/">Home</Link>
|
|
1365
|
+
* <Link href="/users/new" button={{ type: 'primary' }}>
|
|
1366
|
+
* Create User
|
|
1367
|
+
* </Link>
|
|
1368
|
+
* </>
|
|
1369
|
+
* )
|
|
1370
|
+
* }
|
|
881
1371
|
* ```
|
|
882
1372
|
*/
|
|
883
1373
|
declare function Link(props: LinkProps): react_jsx_runtime0.JSX.Element;
|
|
884
1374
|
//#endregion
|
|
885
1375
|
//#region src/Modal.d.ts
|
|
1376
|
+
/**
|
|
1377
|
+
* Props accepted by the hook-managed modal wrapper.
|
|
1378
|
+
*/
|
|
886
1379
|
interface ModalProps extends ModalProps$1 {
|
|
1380
|
+
/** Modal body content managed by {@link useModal}. */
|
|
887
1381
|
children?: JSX.Element | JSX.Element[] | string;
|
|
888
1382
|
}
|
|
1383
|
+
/**
|
|
1384
|
+
* State setter used to update hook-managed modal props.
|
|
1385
|
+
*/
|
|
889
1386
|
type setModalProps = Dispatch<SetStateAction<ModalProps>>;
|
|
890
1387
|
/**
|
|
891
|
-
*
|
|
1388
|
+
* Create a hook-managed Ant Design modal instance.
|
|
1389
|
+
*
|
|
1390
|
+
* The returned setter merges partial updates into the current modal props instead of replacing the
|
|
1391
|
+
* entire state object.
|
|
892
1392
|
*
|
|
1393
|
+
* @param {ModalProps} [init] - Initial modal props.
|
|
1394
|
+
* @returns Hook-managed modal element, current props, and a state-merging setter.
|
|
1395
|
+
*
|
|
1396
|
+
* @example
|
|
893
1397
|
* ```tsx
|
|
1398
|
+
* import { useModal } from '@faasjs/ant-design'
|
|
1399
|
+
* import { Button } from 'antd'
|
|
1400
|
+
*
|
|
894
1401
|
* function Example() {
|
|
895
1402
|
* const { modal, setModalProps } = useModal()
|
|
896
1403
|
*
|
|
897
|
-
* return
|
|
898
|
-
*
|
|
899
|
-
*
|
|
900
|
-
*
|
|
1404
|
+
* return (
|
|
1405
|
+
* <>
|
|
1406
|
+
* <Button onClick={() => setModalProps({ open: true, title: 'Delete', children: 'Are you sure?' })}>
|
|
1407
|
+
* Open Modal
|
|
1408
|
+
* </Button>
|
|
1409
|
+
* {modal}
|
|
1410
|
+
* </>
|
|
1411
|
+
* )
|
|
901
1412
|
* }
|
|
902
1413
|
* ```
|
|
903
1414
|
*/
|
|
@@ -908,138 +1419,241 @@ declare function useModal(init?: ModalProps): {
|
|
|
908
1419
|
};
|
|
909
1420
|
//#endregion
|
|
910
1421
|
//#region src/Routers.d.ts
|
|
1422
|
+
/**
|
|
1423
|
+
* Default 404 route element that uses the configured localized title.
|
|
1424
|
+
*
|
|
1425
|
+
* @example
|
|
1426
|
+
* ```tsx
|
|
1427
|
+
* import { PageNotFound, Routes } from '@faasjs/ant-design'
|
|
1428
|
+
*
|
|
1429
|
+
* export function AppRoutes() {
|
|
1430
|
+
* return (
|
|
1431
|
+
* <Routes
|
|
1432
|
+
* routes={[{ path: '/', element: <div>Home</div> }]}
|
|
1433
|
+
* notFound={<PageNotFound />}
|
|
1434
|
+
* />
|
|
1435
|
+
* )
|
|
1436
|
+
* }
|
|
1437
|
+
* ```
|
|
1438
|
+
*/
|
|
911
1439
|
declare function PageNotFound(): react_jsx_runtime0.JSX.Element;
|
|
1440
|
+
/**
|
|
1441
|
+
* Props for the lazy-loading {@link Routes} wrapper.
|
|
1442
|
+
*/
|
|
912
1443
|
interface RoutesProps {
|
|
1444
|
+
/** Route records forwarded to React Router, with optional lazy `page` components. */
|
|
913
1445
|
routes: (RouteProps & {
|
|
914
1446
|
page?: LazyExoticComponent<ComponentType<any>>;
|
|
915
1447
|
})[];
|
|
1448
|
+
/** Fallback element rendered while lazy pages are loading. */
|
|
916
1449
|
fallback?: JSX.Element;
|
|
1450
|
+
/** Element rendered for the generated catch-all 404 route. */
|
|
917
1451
|
notFound?: JSX.Element;
|
|
918
1452
|
}
|
|
919
1453
|
/**
|
|
920
|
-
*
|
|
1454
|
+
* Render React Router routes with lazy-page support and a default 404 route.
|
|
1455
|
+
*
|
|
1456
|
+
* The wrapper adds a catch-all route automatically and uses an Ant Design `Skeleton` fallback when
|
|
1457
|
+
* `fallback` is not provided.
|
|
1458
|
+
*
|
|
1459
|
+
* @param {RoutesProps} props - Route definitions and optional fallback or 404 elements.
|
|
921
1460
|
*
|
|
922
1461
|
* @example
|
|
923
1462
|
* ```tsx
|
|
924
1463
|
* import { Routes, lazy } from '@faasjs/ant-design'
|
|
925
1464
|
* import { BrowserRouter } from 'react-router-dom'
|
|
926
1465
|
*
|
|
927
|
-
* export function App
|
|
928
|
-
* return
|
|
929
|
-
* <
|
|
930
|
-
*
|
|
931
|
-
*
|
|
932
|
-
*
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
*
|
|
1466
|
+
* export function App() {
|
|
1467
|
+
* return (
|
|
1468
|
+
* <BrowserRouter>
|
|
1469
|
+
* <Routes
|
|
1470
|
+
* routes={[
|
|
1471
|
+
* {
|
|
1472
|
+
* path: '/',
|
|
1473
|
+
* page: lazy(() => import('./pages/home')),
|
|
1474
|
+
* },
|
|
1475
|
+
* ]}
|
|
1476
|
+
* />
|
|
1477
|
+
* </BrowserRouter>
|
|
1478
|
+
* )
|
|
936
1479
|
* }
|
|
937
1480
|
* ```
|
|
938
1481
|
*/
|
|
939
1482
|
declare function Routes(props: RoutesProps): react_jsx_runtime0.JSX.Element;
|
|
940
1483
|
//#endregion
|
|
941
1484
|
//#region src/Tabs.d.ts
|
|
1485
|
+
/**
|
|
1486
|
+
* Tab item accepted by the FaasJS Ant Design {@link Tabs} wrapper.
|
|
1487
|
+
*/
|
|
942
1488
|
interface TabProps extends Partial<Tab> {
|
|
1489
|
+
/** Stable tab identifier used as the default key and label. */
|
|
943
1490
|
id: string;
|
|
1491
|
+
/** Title used as the default Ant Design tab label. */
|
|
944
1492
|
title?: React.ReactNode;
|
|
1493
|
+
/** Tab panel content. */
|
|
945
1494
|
children: React.ReactNode;
|
|
946
1495
|
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Props for the FaasJS Ant Design {@link Tabs} component.
|
|
1498
|
+
*/
|
|
947
1499
|
interface TabsProps extends Omit<TabsProps$1, 'items'> {
|
|
948
|
-
/**
|
|
1500
|
+
/** Tab definitions. `null` and `false` entries are skipped automatically. */
|
|
949
1501
|
items: (TabProps | null | false)[];
|
|
950
1502
|
}
|
|
951
1503
|
/**
|
|
952
|
-
*
|
|
1504
|
+
* Render an Ant Design tabs wrapper that accepts FaasJS-style tab definitions.
|
|
953
1505
|
*
|
|
954
|
-
*
|
|
955
|
-
*
|
|
956
|
-
* -
|
|
1506
|
+
* Missing `key` and `label` values are derived from each tab's `id` and `title`.
|
|
1507
|
+
*
|
|
1508
|
+
* @param {TabsProps} props - Tabs props including tab items and Ant Design tab options.
|
|
957
1509
|
*
|
|
958
1510
|
* @example
|
|
959
1511
|
* ```tsx
|
|
960
1512
|
* import { Tabs } from '@faasjs/ant-design'
|
|
961
1513
|
*
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
*
|
|
965
|
-
*
|
|
966
|
-
*
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
970
|
-
*
|
|
971
|
-
*
|
|
972
|
-
*
|
|
973
|
-
*
|
|
1514
|
+
* export function Page() {
|
|
1515
|
+
* return (
|
|
1516
|
+
* <Tabs
|
|
1517
|
+
* items={[
|
|
1518
|
+
* {
|
|
1519
|
+
* id: 'id',
|
|
1520
|
+
* children: 'content',
|
|
1521
|
+
* },
|
|
1522
|
+
* 1 === 0 && {
|
|
1523
|
+
* id: 'hidden',
|
|
1524
|
+
* children: 'content',
|
|
1525
|
+
* },
|
|
1526
|
+
* ]}
|
|
1527
|
+
* />
|
|
1528
|
+
* )
|
|
1529
|
+
* }
|
|
974
1530
|
* ```
|
|
975
1531
|
*/
|
|
976
1532
|
declare function Tabs(props: TabsProps): react_jsx_runtime0.JSX.Element;
|
|
977
1533
|
//#endregion
|
|
978
1534
|
//#region src/Title.d.ts
|
|
1535
|
+
/**
|
|
1536
|
+
* Props for the document-title helper component.
|
|
1537
|
+
*/
|
|
979
1538
|
interface TitleProps {
|
|
1539
|
+
/** Title text or title segments used to update `document.title`. */
|
|
980
1540
|
title: string | string[];
|
|
981
|
-
/**
|
|
1541
|
+
/**
|
|
1542
|
+
* Separator used when joining title segments.
|
|
1543
|
+
*
|
|
1544
|
+
* @default ' - '
|
|
1545
|
+
*/
|
|
982
1546
|
separator?: string;
|
|
1547
|
+
/** Suffix appended to the generated document title. */
|
|
983
1548
|
suffix?: string;
|
|
984
|
-
/**
|
|
1549
|
+
/** Whether to render an `h1`, or the props used to style that `h1`. */
|
|
985
1550
|
h1?: boolean | {
|
|
986
1551
|
className?: string;
|
|
987
1552
|
style?: React.CSSProperties;
|
|
988
1553
|
};
|
|
989
|
-
/**
|
|
1554
|
+
/** Whether to render plain text instead of returning `null`. */
|
|
990
1555
|
plain?: boolean;
|
|
991
|
-
/**
|
|
1556
|
+
/** Existing element cloned with a `title` prop. */
|
|
992
1557
|
children?: JSX.Element;
|
|
993
1558
|
}
|
|
994
1559
|
/**
|
|
995
|
-
*
|
|
1560
|
+
* Update `document.title` and optionally render the title inline.
|
|
996
1561
|
*
|
|
997
|
-
*
|
|
1562
|
+
* The component returns `null` by default and is often used only for its side effect.
|
|
998
1563
|
*
|
|
999
|
-
*
|
|
1000
|
-
* // return null
|
|
1001
|
-
* <Title title='hi' /> // => change the document.title to 'hi'
|
|
1002
|
-
* <Title title={['a', 'b']} /> // => change the document.title to 'a - b'
|
|
1564
|
+
* @param {TitleProps} props - Title props controlling document title updates and optional inline rendering.
|
|
1003
1565
|
*
|
|
1004
|
-
*
|
|
1005
|
-
*
|
|
1006
|
-
*
|
|
1566
|
+
* @example
|
|
1567
|
+
* ```tsx
|
|
1568
|
+
* import { Title } from '@faasjs/ant-design'
|
|
1007
1569
|
*
|
|
1008
|
-
*
|
|
1009
|
-
*
|
|
1570
|
+
* export function DetailPage() {
|
|
1571
|
+
* return (
|
|
1572
|
+
* <>
|
|
1573
|
+
* <Title title={['Orders', 'Detail']} h1 />
|
|
1574
|
+
* <div>...</div>
|
|
1575
|
+
* </>
|
|
1576
|
+
* )
|
|
1577
|
+
* }
|
|
1010
1578
|
* ```
|
|
1011
1579
|
*/
|
|
1012
1580
|
declare function Title(props: TitleProps): JSX.Element | null;
|
|
1013
1581
|
//#endregion
|
|
1014
1582
|
//#region src/useApp.d.ts
|
|
1583
|
+
/**
|
|
1584
|
+
* Shared app services exposed by {@link AppContext} and {@link useApp}.
|
|
1585
|
+
*/
|
|
1015
1586
|
interface useAppProps {
|
|
1587
|
+
/** Ant Design message API instance created by the root `App` component. */
|
|
1016
1588
|
message: MessageInstance;
|
|
1589
|
+
/** Ant Design notification API instance created by the root `App` component. */
|
|
1017
1590
|
notification: NotificationInstance;
|
|
1591
|
+
/** Current props of the hook-managed modal element. */
|
|
1018
1592
|
modalProps: ModalProps;
|
|
1593
|
+
/** Setter that merges updates into the hook-managed modal props. */
|
|
1019
1594
|
setModalProps: setModalProps;
|
|
1595
|
+
/** Current props of the hook-managed drawer element. */
|
|
1020
1596
|
drawerProps: DrawerProps;
|
|
1597
|
+
/** Setter that merges updates into the hook-managed drawer props. */
|
|
1021
1598
|
setDrawerProps: setDrawerProps;
|
|
1022
1599
|
}
|
|
1600
|
+
/**
|
|
1601
|
+
* Shared context storing message, notification, modal, and drawer helpers.
|
|
1602
|
+
*/
|
|
1023
1603
|
declare const AppContext: any;
|
|
1024
1604
|
/**
|
|
1025
|
-
*
|
|
1605
|
+
* Read app-level services exposed by the root `App` component.
|
|
1026
1606
|
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1607
|
+
* @template NewT - Narrowed app context shape to read from `AppContext`.
|
|
1608
|
+
* @returns Read-only app context value.
|
|
1029
1609
|
*
|
|
1030
|
-
*
|
|
1610
|
+
* @example
|
|
1611
|
+
* ```tsx
|
|
1612
|
+
* import { App, useApp } from '@faasjs/ant-design'
|
|
1613
|
+
* import { Button } from 'antd'
|
|
1614
|
+
*
|
|
1615
|
+
* function Page() {
|
|
1616
|
+
* const { message, setModalProps } = useApp()
|
|
1617
|
+
*
|
|
1618
|
+
* return (
|
|
1619
|
+
* <Button
|
|
1620
|
+
* onClick={() => {
|
|
1621
|
+
* message.success('Saved')
|
|
1622
|
+
* setModalProps({ open: true, title: 'Done', children: 'Profile updated.' })
|
|
1623
|
+
* }}
|
|
1624
|
+
* >
|
|
1625
|
+
* Save
|
|
1626
|
+
* </Button>
|
|
1627
|
+
* )
|
|
1628
|
+
* }
|
|
1629
|
+
*
|
|
1630
|
+
* export function Root() {
|
|
1631
|
+
* return (
|
|
1632
|
+
* <App>
|
|
1633
|
+
* <Page />
|
|
1634
|
+
* </App>
|
|
1635
|
+
* )
|
|
1636
|
+
* }
|
|
1031
1637
|
* ```
|
|
1032
1638
|
*/
|
|
1033
1639
|
declare function useApp<NewT extends useAppProps = useAppProps>(this: void): Readonly<NewT>;
|
|
1034
1640
|
//#endregion
|
|
1035
1641
|
//#region src/useThemeToken.d.ts
|
|
1036
1642
|
/**
|
|
1037
|
-
*
|
|
1643
|
+
* Read the current Ant Design theme token.
|
|
1644
|
+
*
|
|
1645
|
+
* @returns Ant Design global token object for the active theme.
|
|
1038
1646
|
*
|
|
1039
|
-
*
|
|
1040
|
-
*
|
|
1647
|
+
* @example
|
|
1648
|
+
* ```tsx
|
|
1649
|
+
* import { useThemeToken } from '@faasjs/ant-design'
|
|
1650
|
+
*
|
|
1651
|
+
* function PrimarySwatch() {
|
|
1652
|
+
* const { colorPrimary } = useThemeToken()
|
|
1041
1653
|
*
|
|
1042
|
-
*
|
|
1654
|
+
* return <div style={{ width: 24, height: 24, background: colorPrimary }} />
|
|
1655
|
+
* }
|
|
1656
|
+
* ```
|
|
1043
1657
|
*/
|
|
1044
1658
|
declare function useThemeToken(): GlobalToken;
|
|
1045
1659
|
//#endregion
|