extended-dynamic-forms 0.2.0 → 0.3.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 +398 -1075
- package/dist/WizardForm.d.ts +4 -1
- package/dist/events/FormEventContext.d.ts +3 -0
- package/dist/events/FormEventHub.d.ts +19 -2
- package/dist/index.es.js +21051 -12923
- package/dist/index.umd.js +63 -36
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +6 -1
- package/dist/utils/fieldChangeDetector.d.ts +22 -0
- package/dist/widgets/base/index.d.ts +2 -0
- package/dist/widgets/base/types.d.ts +135 -0
- package/dist/widgets/base/utils.d.ts +63 -0
- package/dist/widgets/choice/ChoiceWidget.d.ts +30 -0
- package/dist/widgets/choice/ChoiceWidget.types.d.ts +496 -0
- package/dist/widgets/choice/examples/ChoiceWidget.example.d.ts +7 -0
- package/dist/widgets/choice/hooks/__tests__/useChoiceWidget.test.d.ts +1 -0
- package/dist/widgets/choice/hooks/__tests__/useDataSource.test.d.ts +1 -0
- package/dist/widgets/choice/hooks/examples/useChoiceWidget.example.d.ts +18 -0
- package/dist/widgets/choice/hooks/examples/useDataSourceExample.d.ts +22 -0
- package/dist/widgets/choice/hooks/index.d.ts +6 -0
- package/dist/widgets/choice/hooks/useChoiceWidget.d.ts +65 -0
- package/dist/widgets/choice/hooks/useDataSource.d.ts +69 -0
- package/dist/widgets/choice/index.d.ts +59 -0
- package/dist/widgets/choice/presenters/CheckboxPresenter.d.ts +70 -0
- package/dist/widgets/choice/presenters/DropdownPresenter.d.ts +37 -0
- package/dist/widgets/choice/presenters/PresenterStrategy.d.ts +230 -0
- package/dist/widgets/choice/presenters/RadioPresenter.d.ts +39 -0
- package/dist/widgets/choice/presenters/examples/RadioPresenterExample.d.ts +7 -0
- package/dist/widgets/choice/presenters/index.d.ts +20 -0
- package/dist/widgets/choice/providers/ApiDataSource.d.ts +241 -0
- package/dist/widgets/choice/providers/DataSourceProvider.d.ts +260 -0
- package/dist/widgets/choice/providers/StaticDataSource.d.ts +258 -0
- package/dist/widgets/choice/providers/WebSocketDataSource.d.ts +310 -0
- package/dist/widgets/choice/providers/index.d.ts +12 -0
- package/dist/widgets/choice/utils/index.d.ts +1 -0
- package/dist/widgets/choice/utils/responseMappers.d.ts +342 -0
- package/dist/widgets/date/DateTimeWidget.d.ts +26 -0
- package/dist/widgets/date/EnhancedDateWidget.d.ts +26 -0
- package/dist/widgets/date/index.d.ts +13 -0
- package/dist/widgets/file/FileUploadWidget.d.ts +40 -0
- package/dist/widgets/file/index.d.ts +2 -0
- package/dist/widgets/index.d.ts +33 -17
- package/dist/widgets/input/EmailWidget.d.ts +34 -0
- package/dist/widgets/input/NumberWidget.d.ts +39 -0
- package/dist/widgets/input/TelephoneWidget.d.ts +34 -0
- package/dist/widgets/input/URLWidget.d.ts +34 -0
- package/dist/widgets/input/index.d.ts +7 -0
- package/dist/widgets/text/PasswordWidget.d.ts +45 -0
- package/dist/widgets/text/TextWidget.d.ts +40 -0
- package/dist/widgets/text/TextareaWidget.d.ts +38 -0
- package/dist/widgets/text/index.d.ts +20 -0
- package/package.json +8 -8
- package/dist/vanilla-entry.d.ts +0 -204
- package/dist/widgets/enhanced/EnhancedWidgets.d.ts +0 -37
- package/examples/conditional-v2-example.tsx +0 -64
- package/examples/dynamic-array-items-example.tsx +0 -211
- package/examples/form-devtools-example.tsx +0 -384
- package/examples/global-ui-rules-example.tsx +0 -371
- package/examples/vanilla-js/README.md +0 -212
- package/examples/vanilla-js/basic-form.html +0 -142
- package/examples/vanilla-js/conditional-form.html +0 -159
- package/examples/vanilla-js/wizard-form.html +0 -185
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ChoiceWidgetConfig, PresentationMode } from './ChoiceWidget.types';
|
|
2
|
+
export * from './ChoiceWidget.types';
|
|
3
|
+
export { isStaticDataSource, isApiDataSource, supportsMultipleSelections, DEFAULT_CHOICE_CONFIG, DEFAULT_CACHE_CONFIG, DEFAULT_RESPONSE_MAPPER, } from './ChoiceWidget.types';
|
|
4
|
+
export { DataSourceProvider, DEFAULT_RETRY_CONFIG, createSimpleHash, validateChoiceOptions, } from './providers/DataSourceProvider';
|
|
5
|
+
export type { RetryConfig, DataSourceMetrics, DataSourceEventCallbacks, } from './providers/DataSourceProvider';
|
|
6
|
+
export { StaticDataSource, createStaticDataSource, hasGroup, createGroupedOptions, } from './providers/StaticDataSource';
|
|
7
|
+
export type { StaticDataSourceOptions } from './providers/StaticDataSource';
|
|
8
|
+
export { ApiDataSource, createApiDataSource, COMMON_RESPONSE_MAPPERS, AUTH_HELPERS, } from './providers/ApiDataSource';
|
|
9
|
+
export { WebSocketDataSource, createWebSocketDataSource, WebSocketConnectionState, WS_AUTH_HELPERS, WS_MESSAGE_HELPERS, } from './providers/WebSocketDataSource';
|
|
10
|
+
export type { WebSocketDataSourceOptions, } from './providers/WebSocketDataSource';
|
|
11
|
+
export { validateChoiceOption, getNestedValue, setNestedValue, extractArrayFromResponse, mapSimpleResponse, mapNestedResponse, createCustomMapper, mapResponse, ResponseMappingError, COMMON_MAPPERS, PAGINATED_MAPPERS, createActiveMapper, createMapperPipeline, filterEnabledOptions, sortByLabel, sortByValue, groupOptions, transformOptions, } from './utils/responseMappers';
|
|
12
|
+
export { PresenterStrategy } from './presenters/PresenterStrategy';
|
|
13
|
+
export { DropdownPresenter } from './presenters/DropdownPresenter';
|
|
14
|
+
export { RadioPresenter } from './presenters/RadioPresenter';
|
|
15
|
+
export { CheckboxPresenter } from './presenters/CheckboxPresenter';
|
|
16
|
+
export { useDataSource, useDataSourceWithRetry, useMultipleDataSources, } from './hooks';
|
|
17
|
+
export { useChoiceWidget, useChoiceWidgetWithErrorBoundary, useChoiceWidgetWithMetrics, } from './hooks/useChoiceWidget';
|
|
18
|
+
export type { UseChoiceWidgetReturn } from './hooks/useChoiceWidget';
|
|
19
|
+
export type { UseDataSourceReturn } from './hooks';
|
|
20
|
+
export { ChoiceWidget, default as DefaultChoiceWidget } from './ChoiceWidget';
|
|
21
|
+
/**
|
|
22
|
+
* Factory function to create a default ChoiceWidgetConfig
|
|
23
|
+
*/
|
|
24
|
+
export declare const createDefaultConfig: (overrides?: Partial<ChoiceWidgetConfig>) => ChoiceWidgetConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Presentation mode helper
|
|
27
|
+
* Determines the best presentation mode based on options count and schema
|
|
28
|
+
*/
|
|
29
|
+
export declare const suggestPresentationMode: (optionCount: number, isMultiSelect?: boolean, preferences?: {
|
|
30
|
+
preferRadio?: boolean;
|
|
31
|
+
preferDropdown?: boolean;
|
|
32
|
+
}) => PresentationMode;
|
|
33
|
+
/**
|
|
34
|
+
* Legacy compatibility helper
|
|
35
|
+
* Converts legacy enumOptions format to ChoiceWidgetConfig
|
|
36
|
+
*/
|
|
37
|
+
export declare const convertLegacyConfig: (enumOptions: Array<{
|
|
38
|
+
label: string;
|
|
39
|
+
value: unknown;
|
|
40
|
+
}>, uiOptions?: Record<string, unknown>) => ChoiceWidgetConfig;
|
|
41
|
+
/**
|
|
42
|
+
* Widget registration helper for RJSF
|
|
43
|
+
* Simplifies registering the Choice Widget with RJSF forms
|
|
44
|
+
*/
|
|
45
|
+
export declare const createChoiceWidgetRegistry: (customConfig?: Partial<ChoiceWidgetConfig>) => {
|
|
46
|
+
widgets: {
|
|
47
|
+
choice: import('react').FC<import('./ChoiceWidget.types').ChoiceWidgetProps>;
|
|
48
|
+
ChoiceWidget: import('react').FC<import('./ChoiceWidget.types').ChoiceWidgetProps>;
|
|
49
|
+
select: import('react').FC<import('./ChoiceWidget.types').ChoiceWidgetProps>;
|
|
50
|
+
radio: import('react').FC<import('./ChoiceWidget.types').ChoiceWidgetProps>;
|
|
51
|
+
checkboxes: import('react').FC<import('./ChoiceWidget.types').ChoiceWidgetProps>;
|
|
52
|
+
};
|
|
53
|
+
uiSchema: {
|
|
54
|
+
'ui:widget': string;
|
|
55
|
+
'ui:options': {
|
|
56
|
+
choiceConfig: ChoiceWidgetConfig;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { PresenterStrategy } from './PresenterStrategy';
|
|
3
|
+
import { ChoiceWidgetProps, ChoiceWidgetState, ChoiceWidgetConfig, PresentationMode } from '../ChoiceWidget.types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checkbox presenter configuration
|
|
7
|
+
*/
|
|
8
|
+
export interface CheckboxPresenterConfig {
|
|
9
|
+
/** Enable/disable select all functionality */
|
|
10
|
+
showSelectAll?: boolean;
|
|
11
|
+
/** Label for select all checkbox */
|
|
12
|
+
selectAllLabel?: string;
|
|
13
|
+
/** Layout mode: 'vertical' | 'horizontal' | 'grid' */
|
|
14
|
+
layout?: 'vertical' | 'horizontal' | 'grid';
|
|
15
|
+
/** Number of columns for grid layout */
|
|
16
|
+
columns?: number;
|
|
17
|
+
/** Responsive column configuration */
|
|
18
|
+
responsive?: {
|
|
19
|
+
xs?: number;
|
|
20
|
+
sm?: number;
|
|
21
|
+
md?: number;
|
|
22
|
+
lg?: number;
|
|
23
|
+
xl?: number;
|
|
24
|
+
xxl?: number;
|
|
25
|
+
};
|
|
26
|
+
/** Space between checkboxes */
|
|
27
|
+
spacing?: number;
|
|
28
|
+
/** Enable bulk operations (select all, clear, invert) */
|
|
29
|
+
enableBulkOperations?: boolean;
|
|
30
|
+
/** Custom bulk operation labels */
|
|
31
|
+
bulkOperationLabels?: {
|
|
32
|
+
selectAll?: string;
|
|
33
|
+
clearAll?: string;
|
|
34
|
+
invertSelection?: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Checkbox-based presenter strategy for multi-select choice widgets
|
|
39
|
+
*
|
|
40
|
+
* Features:
|
|
41
|
+
* - Ant Design Checkbox.Group integration
|
|
42
|
+
* - "Select All" with indeterminate states
|
|
43
|
+
* - Grid layout support with responsive columns
|
|
44
|
+
* - Individual checkbox disabled states
|
|
45
|
+
* - Bulk selection operations
|
|
46
|
+
* - Comprehensive accessibility support
|
|
47
|
+
*/
|
|
48
|
+
export declare class CheckboxPresenter extends PresenterStrategy {
|
|
49
|
+
readonly presentationMode = PresentationMode.CHECKBOX;
|
|
50
|
+
/**
|
|
51
|
+
* Render the checkbox widget using CheckboxWidget component.
|
|
52
|
+
*/
|
|
53
|
+
render(props: ChoiceWidgetProps, state: ChoiceWidgetState): React.ReactElement;
|
|
54
|
+
/**
|
|
55
|
+
* Handle selection change from Checkbox.Group component.
|
|
56
|
+
*/
|
|
57
|
+
handleSelectionChange(value: unknown, _props: ChoiceWidgetProps, _state: ChoiceWidgetState): (string | number | boolean)[];
|
|
58
|
+
/**
|
|
59
|
+
* Get default configuration for checkbox presentation.
|
|
60
|
+
*/
|
|
61
|
+
getDefaultProps(): Partial<ChoiceWidgetConfig>;
|
|
62
|
+
/**
|
|
63
|
+
* Validate checkbox-specific configuration.
|
|
64
|
+
*/
|
|
65
|
+
validateProps(config: ChoiceWidgetConfig): string[] | null;
|
|
66
|
+
/**
|
|
67
|
+
* Get the appropriate ARIA role for checkbox presentation.
|
|
68
|
+
*/
|
|
69
|
+
protected getAriaRole(): string;
|
|
70
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ChoiceWidgetProps, ChoiceWidgetState, ChoiceWidgetConfig, PresentationMode } from '../ChoiceWidget.types';
|
|
3
|
+
import { PresenterStrategy } from './PresenterStrategy';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Dropdown presenter implementation using Ant Design Select component.
|
|
7
|
+
* Provides a dropdown/select UI with support for single and multi-select modes,
|
|
8
|
+
* search functionality, virtual scrolling for large datasets, and full accessibility.
|
|
9
|
+
*
|
|
10
|
+
* @class DropdownPresenter
|
|
11
|
+
* @extends {PresenterStrategy}
|
|
12
|
+
*/
|
|
13
|
+
export declare class DropdownPresenter extends PresenterStrategy {
|
|
14
|
+
readonly presentationMode = PresentationMode.DROPDOWN;
|
|
15
|
+
/**
|
|
16
|
+
* Render the dropdown widget using Ant Design Select.
|
|
17
|
+
*/
|
|
18
|
+
render(props: ChoiceWidgetProps, state: ChoiceWidgetState): React.ReactElement;
|
|
19
|
+
/**
|
|
20
|
+
* Handle selection change from Select component.
|
|
21
|
+
* Normalizes the value(s) for consistent handling.
|
|
22
|
+
*/
|
|
23
|
+
handleSelectionChange(value: unknown, props: ChoiceWidgetProps, _state: ChoiceWidgetState): (string | number | boolean)[];
|
|
24
|
+
/**
|
|
25
|
+
* Get default configuration for dropdown presentation.
|
|
26
|
+
*/
|
|
27
|
+
getDefaultProps(): Partial<ChoiceWidgetConfig>;
|
|
28
|
+
/**
|
|
29
|
+
* Validate dropdown-specific configuration.
|
|
30
|
+
*/
|
|
31
|
+
validateProps(config: ChoiceWidgetConfig): string[] | null;
|
|
32
|
+
/**
|
|
33
|
+
* Get the ARIA role for dropdown presentation.
|
|
34
|
+
*/
|
|
35
|
+
protected getAriaRole(): string;
|
|
36
|
+
}
|
|
37
|
+
export default DropdownPresenter;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ChoiceWidgetProps, ChoiceWidgetState, ChoiceWidgetConfig, ChoiceOption, AccessibilityConfig, ErrorState, LoadingState, PresentationMode } from '../ChoiceWidget.types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base class for Choice Widget presentation strategies.
|
|
6
|
+
* Implements the Strategy Pattern to support different presentation modes
|
|
7
|
+
* (dropdown, radio, checkbox) while maintaining consistent behavior,
|
|
8
|
+
* accessibility standards, and event handling.
|
|
9
|
+
*
|
|
10
|
+
* @abstract
|
|
11
|
+
* @class PresenterStrategy
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class PresenterStrategy {
|
|
14
|
+
/**
|
|
15
|
+
* The presentation mode this strategy implements
|
|
16
|
+
*/
|
|
17
|
+
abstract readonly presentationMode: PresentationMode;
|
|
18
|
+
/**
|
|
19
|
+
* Render the widget UI according to the specific presentation strategy.
|
|
20
|
+
* Must integrate with FormEventHub and maintain accessibility standards.
|
|
21
|
+
*
|
|
22
|
+
* @param props - The widget props including RJSF props and custom configuration
|
|
23
|
+
* @param state - The current widget state including options and selection
|
|
24
|
+
* @returns React element representing the widget
|
|
25
|
+
*/
|
|
26
|
+
abstract render(props: ChoiceWidgetProps, state: ChoiceWidgetState): React.ReactElement;
|
|
27
|
+
/**
|
|
28
|
+
* Handle selection change events and transform values appropriately.
|
|
29
|
+
* Must support both single and multi-select scenarios.
|
|
30
|
+
*
|
|
31
|
+
* @param value - The new value(s) from the UI component
|
|
32
|
+
* @param props - The widget props
|
|
33
|
+
* @param state - The current widget state
|
|
34
|
+
* @returns Array of selected values (normalized)
|
|
35
|
+
*/
|
|
36
|
+
abstract handleSelectionChange(value: unknown, props: ChoiceWidgetProps, state: ChoiceWidgetState): (string | number | boolean)[];
|
|
37
|
+
/**
|
|
38
|
+
* Get default configuration specific to this presentation mode.
|
|
39
|
+
*
|
|
40
|
+
* @returns Partial configuration with mode-specific defaults
|
|
41
|
+
*/
|
|
42
|
+
abstract getDefaultProps(): Partial<ChoiceWidgetConfig>;
|
|
43
|
+
/**
|
|
44
|
+
* Validate configuration for this specific presentation mode.
|
|
45
|
+
*
|
|
46
|
+
* @param config - The widget configuration to validate
|
|
47
|
+
* @returns Array of validation error messages, or null if valid
|
|
48
|
+
*/
|
|
49
|
+
abstract validateProps(config: ChoiceWidgetConfig): string[] | null;
|
|
50
|
+
/**
|
|
51
|
+
* Generate accessibility properties for the widget.
|
|
52
|
+
* Ensures WCAG 2.1 AA compliance.
|
|
53
|
+
*
|
|
54
|
+
* @param props - The widget props
|
|
55
|
+
* @param state - The current widget state
|
|
56
|
+
* @param config - Accessibility configuration
|
|
57
|
+
* @returns Object containing ARIA attributes
|
|
58
|
+
*/
|
|
59
|
+
getAccessibilityProps(props: ChoiceWidgetProps, state: ChoiceWidgetState, config?: AccessibilityConfig): Record<string, string | boolean | number>;
|
|
60
|
+
/**
|
|
61
|
+
* Get the appropriate ARIA role for this presentation mode.
|
|
62
|
+
*
|
|
63
|
+
* @returns The ARIA role string
|
|
64
|
+
*/
|
|
65
|
+
protected abstract getAriaRole(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Handle keyboard navigation events.
|
|
68
|
+
* Supports arrow keys, home/end, and type-ahead functionality.
|
|
69
|
+
*
|
|
70
|
+
* @param event - The keyboard event
|
|
71
|
+
* @param props - The widget props
|
|
72
|
+
* @param state - The current widget state
|
|
73
|
+
* @param callbacks - Callback functions for state updates
|
|
74
|
+
*/
|
|
75
|
+
handleKeyboardNavigation(event: React.KeyboardEvent, props: ChoiceWidgetProps, state: ChoiceWidgetState, callbacks: {
|
|
76
|
+
setFocusedIndex: (index: number) => void;
|
|
77
|
+
selectOption: (option: ChoiceOption) => void;
|
|
78
|
+
toggleDropdown?: (open: boolean) => void;
|
|
79
|
+
}): void;
|
|
80
|
+
/**
|
|
81
|
+
* Handle type-ahead search functionality.
|
|
82
|
+
*
|
|
83
|
+
* @param char - The typed character
|
|
84
|
+
* @param state - The current widget state
|
|
85
|
+
* @param callbacks - Callback functions
|
|
86
|
+
*/
|
|
87
|
+
private handleTypeAhead;
|
|
88
|
+
/**
|
|
89
|
+
* Generate props for the loading state display.
|
|
90
|
+
*
|
|
91
|
+
* @param loading - The loading state
|
|
92
|
+
* @param LoadingComponent - Optional custom loading component
|
|
93
|
+
* @returns Props for the loading display
|
|
94
|
+
*/
|
|
95
|
+
getLoadingProps(loading: LoadingState, LoadingComponent?: React.ComponentType<LoadingState>): {
|
|
96
|
+
component: React.ComponentType<LoadingState>;
|
|
97
|
+
props: LoadingState;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Generate props for the error state display.
|
|
101
|
+
*
|
|
102
|
+
* @param error - The error state
|
|
103
|
+
* @param ErrorComponent - Optional custom error component
|
|
104
|
+
* @param fieldId - The field ID for accessibility
|
|
105
|
+
* @returns Props for the error display
|
|
106
|
+
*/
|
|
107
|
+
getErrorProps(error: ErrorState, ErrorComponent?: React.ComponentType<ErrorState>, fieldId?: string): {
|
|
108
|
+
component: React.ComponentType<ErrorState>;
|
|
109
|
+
props: ErrorState & {
|
|
110
|
+
id?: string;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Generate props for the empty state display.
|
|
115
|
+
*
|
|
116
|
+
* @param message - Optional message for empty state
|
|
117
|
+
* @param EmptyComponent - Optional custom empty component
|
|
118
|
+
* @returns Props for the empty display
|
|
119
|
+
*/
|
|
120
|
+
getEmptyProps(message?: string, EmptyComponent?: React.ComponentType<{
|
|
121
|
+
message?: string;
|
|
122
|
+
}>): {
|
|
123
|
+
component: React.ComponentType<{
|
|
124
|
+
message?: string;
|
|
125
|
+
}>;
|
|
126
|
+
props: {
|
|
127
|
+
message?: string;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Transform and normalize values between widget and form data.
|
|
132
|
+
* Handles both single and multi-select scenarios.
|
|
133
|
+
*
|
|
134
|
+
* @param value - The value to transform
|
|
135
|
+
* @param multiple - Whether multiple selections are allowed
|
|
136
|
+
* @returns Normalized value(s)
|
|
137
|
+
*/
|
|
138
|
+
normalizeValue(value: unknown, multiple: boolean): (string | number | boolean)[];
|
|
139
|
+
/**
|
|
140
|
+
* Transform normalized values back to widget format.
|
|
141
|
+
*
|
|
142
|
+
* @param values - The normalized values
|
|
143
|
+
* @param multiple - Whether multiple selections are allowed
|
|
144
|
+
* @returns Value in widget format
|
|
145
|
+
*/
|
|
146
|
+
denormalizeValue(values: (string | number | boolean)[], multiple: boolean): unknown;
|
|
147
|
+
/**
|
|
148
|
+
* Apply theme and custom styling to the widget.
|
|
149
|
+
* Integrates with Ant Design v5 theming system.
|
|
150
|
+
*
|
|
151
|
+
* @param config - Widget configuration
|
|
152
|
+
* @param additionalClasses - Additional CSS classes
|
|
153
|
+
* @returns Combined className string
|
|
154
|
+
*/
|
|
155
|
+
getThemeClasses(config: ChoiceWidgetConfig, additionalClasses?: string): string;
|
|
156
|
+
/**
|
|
157
|
+
* Get style object with theme integration.
|
|
158
|
+
*
|
|
159
|
+
* @param config - Widget configuration
|
|
160
|
+
* @param additionalStyles - Additional styles
|
|
161
|
+
* @returns Combined style object
|
|
162
|
+
*/
|
|
163
|
+
getThemeStyles(config: ChoiceWidgetConfig, additionalStyles?: React.CSSProperties): React.CSSProperties;
|
|
164
|
+
/**
|
|
165
|
+
* Default loading component implementation.
|
|
166
|
+
*/
|
|
167
|
+
protected DefaultLoadingComponent: React.FC<LoadingState>;
|
|
168
|
+
/**
|
|
169
|
+
* Default error component implementation.
|
|
170
|
+
*/
|
|
171
|
+
protected DefaultErrorComponent: React.FC<ErrorState & {
|
|
172
|
+
id?: string;
|
|
173
|
+
}>;
|
|
174
|
+
/**
|
|
175
|
+
* Default empty component implementation.
|
|
176
|
+
*/
|
|
177
|
+
protected DefaultEmptyComponent: React.FC<{
|
|
178
|
+
message?: string;
|
|
179
|
+
}>;
|
|
180
|
+
/**
|
|
181
|
+
* Create event handlers integrated with FormEventHub.
|
|
182
|
+
* This method helps concrete strategies integrate with the central event system.
|
|
183
|
+
*
|
|
184
|
+
* @param fieldId - The field identifier
|
|
185
|
+
* @param schema - The field schema
|
|
186
|
+
* @param formData - The current form data
|
|
187
|
+
* @param fieldPath - The field path in the form
|
|
188
|
+
* @returns Object with event handler methods
|
|
189
|
+
*/
|
|
190
|
+
protected createEventHandlers(fieldId: string, schema?: any, formData?: any, fieldPath?: string[]): {
|
|
191
|
+
fieldId: string;
|
|
192
|
+
schema: any;
|
|
193
|
+
formData: any;
|
|
194
|
+
fieldPath: string[] | undefined;
|
|
195
|
+
_hookRequired: true;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Validate option selection against configured rules.
|
|
199
|
+
*
|
|
200
|
+
* @param values - Selected values
|
|
201
|
+
* @param options - Available options
|
|
202
|
+
* @param config - Widget configuration
|
|
203
|
+
* @returns Validation error message or null if valid
|
|
204
|
+
*/
|
|
205
|
+
validateSelection(values: (string | number | boolean)[], options: ChoiceOption[], config: ChoiceWidgetConfig): string | null;
|
|
206
|
+
/**
|
|
207
|
+
* Get size mapping for Ant Design components.
|
|
208
|
+
*
|
|
209
|
+
* @param size - The size configuration
|
|
210
|
+
* @returns Ant Design size value
|
|
211
|
+
*/
|
|
212
|
+
protected getAntdSize(size?: 'small' | 'middle' | 'large'): 'small' | 'middle' | 'large';
|
|
213
|
+
/**
|
|
214
|
+
* Check if a value is selected.
|
|
215
|
+
*
|
|
216
|
+
* @param value - The value to check
|
|
217
|
+
* @param selectedValues - Currently selected values
|
|
218
|
+
* @returns Whether the value is selected
|
|
219
|
+
*/
|
|
220
|
+
protected isSelected(value: string | number | boolean, selectedValues: (string | number | boolean)[]): boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Filter options based on search configuration.
|
|
223
|
+
*
|
|
224
|
+
* @param options - All available options
|
|
225
|
+
* @param searchTerm - The search term
|
|
226
|
+
* @param searchConfig - Search configuration
|
|
227
|
+
* @returns Filtered options
|
|
228
|
+
*/
|
|
229
|
+
protected filterOptions(options: ChoiceOption[], searchTerm: string, searchConfig?: ChoiceWidgetConfig['search']): ChoiceOption[];
|
|
230
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ChoiceWidgetProps, ChoiceWidgetState, ChoiceWidgetConfig, PresentationMode } from '../ChoiceWidget.types';
|
|
3
|
+
import { PresenterStrategy } from './PresenterStrategy';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Radio presenter implementation using Ant Design Radio.Group component.
|
|
7
|
+
* Provides a radio button UI with support for single selection only,
|
|
8
|
+
* vertical and horizontal layouts, custom option rendering, and full accessibility.
|
|
9
|
+
*
|
|
10
|
+
* Radio groups are inherently single-select, making them ideal for mutually exclusive choices.
|
|
11
|
+
*
|
|
12
|
+
* @class RadioPresenter
|
|
13
|
+
* @extends {PresenterStrategy}
|
|
14
|
+
*/
|
|
15
|
+
export declare class RadioPresenter extends PresenterStrategy {
|
|
16
|
+
readonly presentationMode = PresentationMode.RADIO;
|
|
17
|
+
/**
|
|
18
|
+
* Render the radio widget using Ant Design Radio.Group.
|
|
19
|
+
*/
|
|
20
|
+
render(props: ChoiceWidgetProps, state: ChoiceWidgetState): React.ReactElement;
|
|
21
|
+
/**
|
|
22
|
+
* Handle selection change from Radio.Group component.
|
|
23
|
+
* Radio groups only support single selection.
|
|
24
|
+
*/
|
|
25
|
+
handleSelectionChange(value: unknown): (string | number | boolean)[];
|
|
26
|
+
/**
|
|
27
|
+
* Get default configuration for radio presentation.
|
|
28
|
+
*/
|
|
29
|
+
getDefaultProps(): Partial<ChoiceWidgetConfig>;
|
|
30
|
+
/**
|
|
31
|
+
* Validate radio-specific configuration.
|
|
32
|
+
*/
|
|
33
|
+
validateProps(config: ChoiceWidgetConfig): string[] | null;
|
|
34
|
+
/**
|
|
35
|
+
* Get the ARIA role for radio presentation.
|
|
36
|
+
*/
|
|
37
|
+
protected getAriaRole(): string;
|
|
38
|
+
}
|
|
39
|
+
export default RadioPresenter;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PresentationMode } from '../ChoiceWidget.types';
|
|
2
|
+
import { PresenterStrategy } from './PresenterStrategy';
|
|
3
|
+
/**
|
|
4
|
+
* Choice Widget Presenter Strategy Exports
|
|
5
|
+
*
|
|
6
|
+
* This module implements the Strategy Pattern for different presentation modes
|
|
7
|
+
* of the Choice Widget (dropdown, radio, checkbox).
|
|
8
|
+
*/
|
|
9
|
+
export { PresenterStrategy } from './PresenterStrategy';
|
|
10
|
+
export { DropdownPresenter } from './DropdownPresenter';
|
|
11
|
+
export { RadioPresenter } from './RadioPresenter';
|
|
12
|
+
export { CheckboxPresenter } from './CheckboxPresenter';
|
|
13
|
+
/**
|
|
14
|
+
* Presenter factory function to create the appropriate presenter
|
|
15
|
+
* based on the presentation mode.
|
|
16
|
+
*
|
|
17
|
+
* @param mode - The presentation mode
|
|
18
|
+
* @returns The appropriate presenter instance
|
|
19
|
+
*/
|
|
20
|
+
export declare function createPresenter(mode: PresentationMode): PresenterStrategy;
|