@faasjs/ant-design 0.0.3-beta.24 → 0.0.3-beta.26

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
@@ -71,6 +71,8 @@ Form are based on [Ant Design's Form.Item component](https://ant.design/componen
71
71
  - [ExtendTableItemProps](#extendtableitemprops)
72
72
  - [ExtendTableTypeProps](#extendtabletypeprops)
73
73
  - [ExtendTypes](#extendtypes)
74
+ - [FaasDataInjection](#faasdatainjection)
75
+ - [FaasDataWrapperProps](#faasdatawrapperprops)
74
76
  - [FaasItemType](#faasitemtype)
75
77
  - [FaasItemTypeValue](#faasitemtypevalue)
76
78
  - [TableProps](#tableprops)
@@ -86,9 +88,11 @@ Form are based on [Ant Design's Form.Item component](https://ant.design/componen
86
88
  - [Blank](#blank)
87
89
  - [ConfigProvider](#configprovider)
88
90
  - [Description](#description)
91
+ - [FaasDataWrapper](#faasdatawrapper)
89
92
  - [Form](#form)
90
93
  - [FormItem](#formitem)
91
94
  - [Link](#link)
95
+ - [Loading](#loading)
92
96
  - [PageNotFound](#pagenotfound)
93
97
  - [Routes](#routes)
94
98
  - [Table](#table)
@@ -166,6 +170,61 @@ ___
166
170
 
167
171
  ___
168
172
 
173
+ ### FaasDataInjection
174
+
175
+ Ƭ **FaasDataInjection**<`Data`\>: `Object`
176
+
177
+ Injects FaasData props.
178
+
179
+ #### Type parameters
180
+
181
+ | Name | Type |
182
+ | :------ | :------ |
183
+ | `Data` | `any` |
184
+
185
+ #### Type declaration
186
+
187
+ | Name | Type |
188
+ | :------ | :------ |
189
+ | `action` | `string` \| `any` |
190
+ | `data` | `Data` |
191
+ | `error` | `any` |
192
+ | `loading` | `boolean` |
193
+ | `params` | `Record`<`string`, `any`\> |
194
+ | `promise` | `Promise`<`Response`<`Data`\>\> |
195
+ | `setData` | `React.Dispatch`<`React.SetStateAction`<`Data`\>\> |
196
+ | `setError` | `React.Dispatch`<`React.SetStateAction`<`any`\>\> |
197
+ | `setLoading` | `React.Dispatch`<`React.SetStateAction`<`boolean`\>\> |
198
+ | `setPromise` | `React.Dispatch`<`React.SetStateAction`<`Promise`<`Response`<`Data`\>\>\>\> |
199
+ | `reload` | (`params?`: `Record`<`string`, `any`\>) => `Promise`<`Response`<`Data`\>\> |
200
+
201
+ ___
202
+
203
+ ### FaasDataWrapperProps
204
+
205
+ Ƭ **FaasDataWrapperProps**<`PathOrData`\>: `Object`
206
+
207
+ #### Type parameters
208
+
209
+ | Name | Type |
210
+ | :------ | :------ |
211
+ | `PathOrData` | extends `FaasAction` |
212
+
213
+ #### Type declaration
214
+
215
+ | Name | Type | Description |
216
+ | :------ | :------ | :------ |
217
+ | `action` | `string` | - |
218
+ | `children?` | `JSX.Element` | - |
219
+ | `data?` | `FaasData`<`PathOrData`\> | use custom data, should work with setData |
220
+ | `fallback?` | `JSX.Element` \| ``false`` | - |
221
+ | `params?` | `FaasParams`<`PathOrData`\> | - |
222
+ | `setData?` | `React.Dispatch`<`React.SetStateAction`<`FaasData`<`PathOrData`\>\>\> | use custom setData, should work with data |
223
+ | `onDataChange?` | (`args`: [`FaasDataInjection`](#faasdatainjection)<`FaasData`<`PathOrData`\>\>) => `void` | - |
224
+ | `render?` | (`args`: [`FaasDataInjection`](#faasdatainjection)<`FaasData`<`PathOrData`\>\>) => `Element` \| `Element`[] | - |
225
+
226
+ ___
227
+
169
228
  ### FaasItemType
170
229
 
171
230
  Ƭ **FaasItemType**: ``"string"`` \| ``"string[]"`` \| ``"number"`` \| ``"number[]"`` \| ``"boolean"`` \| ``"date"`` \| ``"time"`` \| ``"object"`` \| ``"object[]"``
@@ -196,7 +255,7 @@ ___
196
255
 
197
256
  ### TableProps
198
257
 
199
- Ƭ **TableProps**<`T`, `ExtendTypes`\>: { `extendTypes?`: { `[key: string]`: [`ExtendTableTypeProps`](#extendtabletypeprops); } ; `faasData?`: `FaasDataWrapperProps`<`T`\> ; `items`: ([`TableItemProps`](interfaces/TableItemProps.md) \| `ExtendTypes` & [`ExtendTableItemProps`](#extendtableitemprops))[] ; `onChange?`: (`pagination`: `TablePaginationConfig`, `filters`: `Record`<`string`, `FilterValue` \| ``null``\>, `sorter`: `SorterResult`<`T`\> \| `SorterResult`<`T`\>[], `extra`: `TableCurrentDataSource`<`T`\>) => { `extra`: `TableCurrentDataSource`<`T`\> ; `filters`: `Record`<`string`, `FilterValue` \| ``null``\> ; `pagination`: `TablePaginationConfig` ; `sorter`: `SorterResult`<`T`\> \| `SorterResult`<`T`\>[] } } & `AntdTableProps`<`T`\>
258
+ Ƭ **TableProps**<`T`, `ExtendTypes`\>: { `extendTypes?`: { `[key: string]`: [`ExtendTableTypeProps`](#extendtabletypeprops); } ; `faasData?`: [`FaasDataWrapperProps`](#faasdatawrapperprops)<`T`\> ; `items`: ([`TableItemProps`](interfaces/TableItemProps.md) \| `ExtendTypes` & [`ExtendTableItemProps`](#extendtableitemprops))[] ; `onChange?`: (`pagination`: `TablePaginationConfig`, `filters`: `Record`<`string`, `FilterValue` \| ``null``\>, `sorter`: `SorterResult`<`T`\> \| `SorterResult`<`T`\>[], `extra`: `TableCurrentDataSource`<`T`\>) => { `extra`: `TableCurrentDataSource`<`T`\> ; `filters`: `Record`<`string`, `FilterValue` \| ``null``\> ; `pagination`: `TablePaginationConfig` ; `sorter`: `SorterResult`<`T`\> \| `SorterResult`<`T`\>[] } } & `AntdTableProps`<`T`\>
200
259
 
201
260
  #### Type parameters
202
261
 
@@ -257,6 +316,8 @@ ___
257
316
 
258
317
  ▸ **Blank**(`options?`): `JSX.Element`
259
318
 
319
+ Blank component.
320
+
260
321
  If value is undefined or null, return text, otherwise return value.
261
322
 
262
323
  #### Parameters
@@ -309,6 +370,8 @@ ___
309
370
 
310
371
  ▸ **Description**<`T`\>(`props`): `Element`
311
372
 
373
+ Description component.
374
+
312
375
  #### Type parameters
313
376
 
314
377
  | Name | Type |
@@ -327,6 +390,30 @@ ___
327
390
 
328
391
  ___
329
392
 
393
+ ### FaasDataWrapper
394
+
395
+ ▸ **FaasDataWrapper**<`T`\>(`props`): `JSX.Element`
396
+
397
+ FaasDataWrapper component with Loading and ErrorBoundary
398
+
399
+ #### Type parameters
400
+
401
+ | Name | Type |
402
+ | :------ | :------ |
403
+ | `T` | `any` |
404
+
405
+ #### Parameters
406
+
407
+ | Name | Type |
408
+ | :------ | :------ |
409
+ | `props` | [`FaasDataWrapperProps`](#faasdatawrapperprops)<`T`\> |
410
+
411
+ #### Returns
412
+
413
+ `JSX.Element`
414
+
415
+ ___
416
+
330
417
  ### Form
331
418
 
332
419
  ▸ **Form**<`Values`\>(`props`): `Element`
@@ -393,12 +480,14 @@ ___
393
480
 
394
481
  ▸ **Link**(`«destructured»`): `Element`
395
482
 
483
+ Link component with button.
484
+
396
485
  ```ts
397
486
  // pure link
398
487
  <Link href="/">Home</Link>
399
488
 
400
489
  // link with button
401
- <Link href="/" button={{type:'primary'}}>Home</Link>
490
+ <Link href="/" button={{ type:'primary' }}>Home</Link>
402
491
  ```
403
492
 
404
493
  #### Parameters
@@ -413,6 +502,26 @@ ___
413
502
 
414
503
  ___
415
504
 
505
+ ### Loading
506
+
507
+ ▸ **Loading**(`props`): `Element`
508
+
509
+ Loading component based on Spin
510
+
511
+ #### Parameters
512
+
513
+ | Name | Type |
514
+ | :------ | :------ |
515
+ | `props` | `Object` |
516
+ | `props.size?` | ``"small"`` \| ``"default"`` \| ``"large"`` |
517
+ | `props.style?` | `CSSProperties` |
518
+
519
+ #### Returns
520
+
521
+ `Element`
522
+
523
+ ___
524
+
416
525
  ### PageNotFound
417
526
 
418
527
  ▸ **PageNotFound**(): `Element`
package/dist/index.d.ts CHANGED
@@ -4,6 +4,9 @@ import { Dayjs } from 'dayjs';
4
4
  import { DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, SelectProps, DatePickerProps, TimePickerProps, FormInstance, FormProps as FormProps$1, ButtonProps, ModalProps as ModalProps$1, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1 } from 'antd';
5
5
  export { Drawer, Modal } from 'antd';
6
6
  import { FaasDataWrapperProps } from '@faasjs/react';
7
+ export { FaasDataInjection, FaasDataWrapperProps } from '@faasjs/react';
8
+ import * as rc_field_form_es_useWatch from 'rc-field-form/es/useWatch';
9
+ import * as antd_es_form_hooks_useFormInstance from 'antd/es/form/hooks/useFormInstance';
7
10
  import * as antd_es_form_Form from 'antd/es/form/Form';
8
11
  import { RuleObject } from 'rc-field-form/lib/interface';
9
12
  import { RouteProps } from 'react-router-dom';
@@ -14,6 +17,8 @@ interface BlankProps {
14
17
  text?: string;
15
18
  }
16
19
  /**
20
+ * Blank component.
21
+ *
17
22
  * If value is undefined or null, return text, otherwise return value.
18
23
  *
19
24
  * @param options {object}
@@ -114,6 +119,11 @@ declare function transferOptions(options: BaseOption[]): {
114
119
  }[];
115
120
  declare function transferValue(type: FaasItemType, value: any): any;
116
121
 
122
+ /**
123
+ * FaasDataWrapper component with Loading and ErrorBoundary
124
+ */
125
+ declare function FaasDataWrapper<T = any>(props: FaasDataWrapperProps<T>): JSX.Element;
126
+
117
127
  interface ExtendDescriptionTypeProps {
118
128
  children?: JSX.Element;
119
129
  render?: (value: any, values: any) => JSX.Element;
@@ -142,6 +152,9 @@ interface DescriptionItemContentProps<T = any> {
142
152
  [key: string]: ExtendDescriptionTypeProps;
143
153
  };
144
154
  }
155
+ /**
156
+ * Description component.
157
+ */
145
158
  declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
146
159
 
147
160
  interface DrawerProps extends DrawerProps$1 {
@@ -150,6 +163,7 @@ interface DrawerProps extends DrawerProps$1 {
150
163
  type setDrawerProps = (changes: Partial<DrawerProps>) => void;
151
164
  /**
152
165
  * Hook style drawer.
166
+ *
153
167
  * @param init initial props
154
168
  *
155
169
  * ```ts
@@ -209,6 +223,11 @@ interface FormItemProps<T = any> extends FaasItemProps, Omit<FormItemProps$1<T>,
209
223
  * ```
210
224
  */
211
225
  declare function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
226
+ declare namespace FormItem {
227
+ var useStatus: () => {
228
+ status?: "" | "error" | "warning" | "success" | "validating";
229
+ };
230
+ }
212
231
 
213
232
  interface FormProps<Values extends Record<string, any> = any, ExtendItemProps = any> extends Omit<FormProps$1<Values>, 'onFinish' | 'children' | 'initialValues'> {
214
233
  items?: (FormItemProps | ExtendItemProps | JSX.Element)[];
@@ -262,6 +281,8 @@ interface FormProps<Values extends Record<string, any> = any, ExtendItemProps =
262
281
  declare function Form<Values = any>(props: FormProps<Values>): JSX.Element;
263
282
  declare namespace Form {
264
283
  var useForm: typeof antd_es_form_Form.useForm;
284
+ var useFormInstance: typeof antd_es_form_hooks_useFormInstance.default;
285
+ var useWatch: typeof rc_field_form_es_useWatch.default;
265
286
  }
266
287
 
267
288
  interface LinkProps {
@@ -273,6 +294,8 @@ interface LinkProps {
273
294
  button?: ButtonProps;
274
295
  }
275
296
  /**
297
+ * Link component with button.
298
+ *
276
299
  * ```ts
277
300
  * // pure link
278
301
  * <Link href="/">Home</Link>
@@ -283,6 +306,14 @@ interface LinkProps {
283
306
  */
284
307
  declare function Link({ href, target, text, children, style, button, }: LinkProps): JSX.Element;
285
308
 
309
+ /**
310
+ * Loading component based on Spin
311
+ */
312
+ declare function Loading(props: {
313
+ style?: React.CSSProperties;
314
+ size?: 'small' | 'default' | 'large';
315
+ }): JSX.Element;
316
+
286
317
  interface ModalProps extends ModalProps$1 {
287
318
  children?: JSX.Element | JSX.Element[] | string;
288
319
  }
@@ -400,4 +431,4 @@ interface TitleProps {
400
431
  */
401
432
  declare function Title(props: TitleProps): JSX.Element;
402
433
 
403
- export { BaseItemProps, BaseOption, Blank, BlankProps, ConfigContext, ConfigProvider, ConfigProviderProps, Description, DescriptionItemContentProps, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, ExtendTypes, FaasItemProps, FaasItemType, FaasItemTypeValue, Form, FormItem, FormItemProps, FormProps, Link, LinkProps, ModalProps, PageNotFound, Routes, RoutesProps, Table, TableItemProps, TableProps, Title, TitleProps, setDrawerProps, setModalProps, transferOptions, transferValue, useConfigContext, useDrawer, useModal };
434
+ export { BaseItemProps, BaseOption, Blank, BlankProps, ConfigContext, ConfigProvider, ConfigProviderProps, Description, DescriptionItemContentProps, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, ExtendTypes, FaasDataWrapper, FaasItemProps, FaasItemType, FaasItemTypeValue, Form, FormItem, FormItemProps, FormProps, Link, LinkProps, Loading, ModalProps, PageNotFound, Routes, RoutesProps, Table, TableItemProps, TableProps, Title, TitleProps, setDrawerProps, setModalProps, transferOptions, transferValue, useConfigContext, useDrawer, useModal };