@form-eng/react-aria 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/dist/index.d.mts +91 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +723 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +675 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @form-eng/react-aria
|
|
2
|
+
|
|
3
|
+
React Aria Components adapter for `@form-eng/core`. Provides accessible field components using [React Aria Components](https://react-spectrum.adobe.com/react-aria/) for best-in-class ARIA patterns.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @form-eng/react-aria @form-eng/core react react-dom react-hook-form react-aria-components
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { FormEngine, RulesEngineProvider, InjectedFieldProvider } from "@form-eng/core";
|
|
15
|
+
import { createReactAriaFieldRegistry } from "@form-eng/react-aria";
|
|
16
|
+
|
|
17
|
+
const fields = createReactAriaFieldRegistry();
|
|
18
|
+
|
|
19
|
+
function App() {
|
|
20
|
+
return (
|
|
21
|
+
<RulesEngineProvider>
|
|
22
|
+
<InjectedFieldProvider fields={fields}>
|
|
23
|
+
<FormEngine config={formConfig} entityData={data} />
|
|
24
|
+
</InjectedFieldProvider>
|
|
25
|
+
</RulesEngineProvider>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Field Implementations
|
|
31
|
+
|
|
32
|
+
| Field | Implementation |
|
|
33
|
+
|-------|---------------|
|
|
34
|
+
| Textbox | React Aria `TextField` + `Input` |
|
|
35
|
+
| Number | React Aria `NumberField` + `Input` |
|
|
36
|
+
| Toggle | React Aria `Switch` |
|
|
37
|
+
| Dropdown | React Aria `Select` + `ListBox` + `Popover` |
|
|
38
|
+
| SimpleDropdown | React Aria `Select` + `ListBox` + `Popover` |
|
|
39
|
+
| MultiSelect | `<select multiple>` (semantic HTML) |
|
|
40
|
+
| DateControl | `<input type="date">` (semantic HTML) |
|
|
41
|
+
| Slider | React Aria `Slider` + `SliderTrack` + `SliderThumb` |
|
|
42
|
+
| RadioGroup | React Aria `RadioGroup` + `Radio` |
|
|
43
|
+
| CheckboxGroup | React Aria `CheckboxGroup` + `Checkbox` |
|
|
44
|
+
| Textarea | React Aria `TextField` + `TextArea` (inline) + native `<dialog>` (modal) |
|
|
45
|
+
| DynamicFragment | `<input type="hidden">` |
|
|
46
|
+
| ReadOnly | `<span>` |
|
|
47
|
+
|
|
48
|
+
## Styling
|
|
49
|
+
|
|
50
|
+
This adapter ships with **no styles**. React Aria Components expose `data-*` render props and CSS class names for custom styling. All fields emit `data-field-type` and `data-field-state` attributes:
|
|
51
|
+
|
|
52
|
+
```css
|
|
53
|
+
[data-field-type="Toggle"] { /* ... */ }
|
|
54
|
+
[data-field-state="error"] { /* ... */ }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Accessibility
|
|
58
|
+
|
|
59
|
+
React Aria Components provide built-in accessibility features including keyboard navigation, focus management, and ARIA attributes. This adapter has the highest native Tier 1 coverage (10/13 fields use React Aria components natively).
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { IFieldProps, Dictionary } from '@form-eng/core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { FieldError } from 'react-hook-form';
|
|
5
|
+
export { GetFieldDataTestId, formatDateTime, getFieldState } from '@form-eng/core/adapter-utils';
|
|
6
|
+
|
|
7
|
+
interface ITextboxProps {
|
|
8
|
+
ellipsifyTextCharacters?: number;
|
|
9
|
+
placeHolder?: string;
|
|
10
|
+
multiline?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const Textbox: (props: IFieldProps<ITextboxProps>) => react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
declare const NumberFieldComponent: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
15
|
+
|
|
16
|
+
declare const Toggle: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
interface IDropdownProps {
|
|
19
|
+
placeHolder?: string;
|
|
20
|
+
setDefaultKeyIfOnlyOneOption?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare const Dropdown: (props: IFieldProps<IDropdownProps>) => react_jsx_runtime.JSX.Element;
|
|
23
|
+
|
|
24
|
+
declare const MultiSelect: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
25
|
+
|
|
26
|
+
declare const DateControl: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
27
|
+
|
|
28
|
+
interface ISliderProps {
|
|
29
|
+
max?: number;
|
|
30
|
+
min?: number;
|
|
31
|
+
step?: number;
|
|
32
|
+
}
|
|
33
|
+
declare const Slider: (props: IFieldProps<ISliderProps>) => react_jsx_runtime.JSX.Element;
|
|
34
|
+
|
|
35
|
+
declare const DynamicFragment: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
36
|
+
|
|
37
|
+
interface ISimpleDropdownProps {
|
|
38
|
+
dropdownOptions?: string[];
|
|
39
|
+
placeHolder?: string;
|
|
40
|
+
}
|
|
41
|
+
declare const SimpleDropdown: (props: IFieldProps<ISimpleDropdownProps>) => react_jsx_runtime.JSX.Element;
|
|
42
|
+
|
|
43
|
+
interface ITextareaProps {
|
|
44
|
+
autoAdjustHeight?: boolean;
|
|
45
|
+
numberOfRows?: number;
|
|
46
|
+
ellipsifyTextCharacters?: number;
|
|
47
|
+
additionalInfo?: string;
|
|
48
|
+
maxLimit?: number;
|
|
49
|
+
saveCallback?: () => void;
|
|
50
|
+
renderExtraModalFooter?: () => React.ReactNode;
|
|
51
|
+
}
|
|
52
|
+
declare const Textarea: (props: IFieldProps<ITextareaProps>) => react_jsx_runtime.JSX.Element;
|
|
53
|
+
|
|
54
|
+
declare const RadioGroup: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
55
|
+
|
|
56
|
+
declare const CheckboxGroup: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
57
|
+
|
|
58
|
+
interface IReadOnlyFieldProps {
|
|
59
|
+
readonly value?: string;
|
|
60
|
+
readonly fieldName?: string;
|
|
61
|
+
readonly labelClassName?: string;
|
|
62
|
+
readonly valueClassName?: string;
|
|
63
|
+
readonly showControlOnSide?: boolean;
|
|
64
|
+
readonly containerClassName?: string;
|
|
65
|
+
readonly ellipsifyTextCharacters?: number;
|
|
66
|
+
}
|
|
67
|
+
declare const ReadOnlyText: React.FunctionComponent<IReadOnlyFieldProps>;
|
|
68
|
+
|
|
69
|
+
declare const ReadOnly: (props: IFieldProps<IReadOnlyFieldProps>) => react_jsx_runtime.JSX.Element;
|
|
70
|
+
|
|
71
|
+
interface IStatusMessageProps {
|
|
72
|
+
id?: string;
|
|
73
|
+
readonly error?: FieldError;
|
|
74
|
+
readonly errorCount?: number;
|
|
75
|
+
readonly savePending?: boolean;
|
|
76
|
+
readonly saving?: boolean;
|
|
77
|
+
}
|
|
78
|
+
declare const StatusMessage: React.FunctionComponent<IStatusMessageProps>;
|
|
79
|
+
|
|
80
|
+
interface IFormLoadingProps {
|
|
81
|
+
loadingShimmerCount?: number;
|
|
82
|
+
loadingFieldShimmerHeight?: number;
|
|
83
|
+
inPanel?: boolean;
|
|
84
|
+
hideTitleShimmer?: boolean;
|
|
85
|
+
}
|
|
86
|
+
declare const FormLoading: (props: IFormLoadingProps) => react_jsx_runtime.JSX.Element;
|
|
87
|
+
|
|
88
|
+
/** Creates the default React Aria Components field registry for use with InjectedFieldProvider */
|
|
89
|
+
declare function createReactAriaFieldRegistry(): Dictionary<React.JSX.Element>;
|
|
90
|
+
|
|
91
|
+
export { CheckboxGroup, DateControl, Dropdown, DynamicFragment, FormLoading, type IReadOnlyFieldProps, MultiSelect, NumberFieldComponent as Number, RadioGroup, ReadOnly, ReadOnlyText, SimpleDropdown, Slider, StatusMessage, Textarea, Textbox, Toggle, createReactAriaFieldRegistry };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { IFieldProps, Dictionary } from '@form-eng/core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { FieldError } from 'react-hook-form';
|
|
5
|
+
export { GetFieldDataTestId, formatDateTime, getFieldState } from '@form-eng/core/adapter-utils';
|
|
6
|
+
|
|
7
|
+
interface ITextboxProps {
|
|
8
|
+
ellipsifyTextCharacters?: number;
|
|
9
|
+
placeHolder?: string;
|
|
10
|
+
multiline?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const Textbox: (props: IFieldProps<ITextboxProps>) => react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
declare const NumberFieldComponent: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
15
|
+
|
|
16
|
+
declare const Toggle: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
interface IDropdownProps {
|
|
19
|
+
placeHolder?: string;
|
|
20
|
+
setDefaultKeyIfOnlyOneOption?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare const Dropdown: (props: IFieldProps<IDropdownProps>) => react_jsx_runtime.JSX.Element;
|
|
23
|
+
|
|
24
|
+
declare const MultiSelect: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
25
|
+
|
|
26
|
+
declare const DateControl: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
27
|
+
|
|
28
|
+
interface ISliderProps {
|
|
29
|
+
max?: number;
|
|
30
|
+
min?: number;
|
|
31
|
+
step?: number;
|
|
32
|
+
}
|
|
33
|
+
declare const Slider: (props: IFieldProps<ISliderProps>) => react_jsx_runtime.JSX.Element;
|
|
34
|
+
|
|
35
|
+
declare const DynamicFragment: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
36
|
+
|
|
37
|
+
interface ISimpleDropdownProps {
|
|
38
|
+
dropdownOptions?: string[];
|
|
39
|
+
placeHolder?: string;
|
|
40
|
+
}
|
|
41
|
+
declare const SimpleDropdown: (props: IFieldProps<ISimpleDropdownProps>) => react_jsx_runtime.JSX.Element;
|
|
42
|
+
|
|
43
|
+
interface ITextareaProps {
|
|
44
|
+
autoAdjustHeight?: boolean;
|
|
45
|
+
numberOfRows?: number;
|
|
46
|
+
ellipsifyTextCharacters?: number;
|
|
47
|
+
additionalInfo?: string;
|
|
48
|
+
maxLimit?: number;
|
|
49
|
+
saveCallback?: () => void;
|
|
50
|
+
renderExtraModalFooter?: () => React.ReactNode;
|
|
51
|
+
}
|
|
52
|
+
declare const Textarea: (props: IFieldProps<ITextareaProps>) => react_jsx_runtime.JSX.Element;
|
|
53
|
+
|
|
54
|
+
declare const RadioGroup: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
55
|
+
|
|
56
|
+
declare const CheckboxGroup: (props: IFieldProps<{}>) => react_jsx_runtime.JSX.Element;
|
|
57
|
+
|
|
58
|
+
interface IReadOnlyFieldProps {
|
|
59
|
+
readonly value?: string;
|
|
60
|
+
readonly fieldName?: string;
|
|
61
|
+
readonly labelClassName?: string;
|
|
62
|
+
readonly valueClassName?: string;
|
|
63
|
+
readonly showControlOnSide?: boolean;
|
|
64
|
+
readonly containerClassName?: string;
|
|
65
|
+
readonly ellipsifyTextCharacters?: number;
|
|
66
|
+
}
|
|
67
|
+
declare const ReadOnlyText: React.FunctionComponent<IReadOnlyFieldProps>;
|
|
68
|
+
|
|
69
|
+
declare const ReadOnly: (props: IFieldProps<IReadOnlyFieldProps>) => react_jsx_runtime.JSX.Element;
|
|
70
|
+
|
|
71
|
+
interface IStatusMessageProps {
|
|
72
|
+
id?: string;
|
|
73
|
+
readonly error?: FieldError;
|
|
74
|
+
readonly errorCount?: number;
|
|
75
|
+
readonly savePending?: boolean;
|
|
76
|
+
readonly saving?: boolean;
|
|
77
|
+
}
|
|
78
|
+
declare const StatusMessage: React.FunctionComponent<IStatusMessageProps>;
|
|
79
|
+
|
|
80
|
+
interface IFormLoadingProps {
|
|
81
|
+
loadingShimmerCount?: number;
|
|
82
|
+
loadingFieldShimmerHeight?: number;
|
|
83
|
+
inPanel?: boolean;
|
|
84
|
+
hideTitleShimmer?: boolean;
|
|
85
|
+
}
|
|
86
|
+
declare const FormLoading: (props: IFormLoadingProps) => react_jsx_runtime.JSX.Element;
|
|
87
|
+
|
|
88
|
+
/** Creates the default React Aria Components field registry for use with InjectedFieldProvider */
|
|
89
|
+
declare function createReactAriaFieldRegistry(): Dictionary<React.JSX.Element>;
|
|
90
|
+
|
|
91
|
+
export { CheckboxGroup, DateControl, Dropdown, DynamicFragment, FormLoading, type IReadOnlyFieldProps, MultiSelect, NumberFieldComponent as Number, RadioGroup, ReadOnly, ReadOnlyText, SimpleDropdown, Slider, StatusMessage, Textarea, Textbox, Toggle, createReactAriaFieldRegistry };
|