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
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
html,body{width:100%;height:100%}input::-ms-clear,input::-ms-reveal{display:none}*,*:before,*:after{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:rgba(0,0,0,0)}@-ms-viewport{width:device-width}body{margin:0}[tabindex="-1"]:focus{outline:none}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5em;font-weight:500}p{margin-top:0;margin-bottom:1em}abbr[title],abbr[data-original-title]{-webkit-text-decoration:underline dotted;text-decoration:underline;text-decoration:underline dotted;border-bottom:0;cursor:help}address{margin-bottom:1em;font-style:normal;line-height:inherit}input[type=text],input[type=password],input[type=number],textarea{-webkit-appearance:none}ol,ul,dl{margin-top:0;margin-bottom:1em}ol ol,ul ul,ol ul,ul ol{margin-bottom:0}dt{font-weight:500}dd{margin-bottom:.5em;margin-left:0}blockquote{margin:0 0 1em}dfn{font-style:italic}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}pre,code,kbd,samp{font-size:1em;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace}pre{margin-top:0;margin-bottom:1em;overflow:auto}figure{margin:0 0 1em}img{vertical-align:middle;border-style:none}a,area,button,[role=button],input:not([type=range]),label,select,summary,textarea{touch-action:manipulation}table{border-collapse:collapse}caption{padding-top:.75em;padding-bottom:.3em;text-align:left;caption-side:bottom}input,button,select,optgroup,textarea{margin:0;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}button,html [type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{padding:0;border-style:none}input[type=radio],input[type=checkbox]{box-sizing:border-box;padding:0}input[type=date],input[type=time],input[type=datetime-local],input[type=month]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;margin:0;padding:0;border:0}legend{display:block;width:100%;max-width:100%;margin-bottom:.5em;padding:0;color:inherit;font-size:1.5em;line-height:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item}template{display:none}[hidden]{display:none!important}mark{padding:.2em;background-color:#feffe6}.rjsf-form{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.vertical-form-item .ant-form-item-label{padding-bottom:0!important;margin-bottom:0}.vertical-form-item .ant-form-item-label>label{margin-bottom:0}.ant-form-item-has-error .ant-form-item-label>label{color:#ff4d4f}.ant-form-item-required:before{display:inline-block;margin-right:4px;color:#ff4d4f;font-size:14px;font-family:SimSun,sans-serif;line-height:1;content:"*"}
|
|
1
|
+
html,body{width:100%;height:100%}input::-ms-clear,input::-ms-reveal{display:none}*,*:before,*:after{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:rgba(0,0,0,0)}@-ms-viewport{width:device-width}body{margin:0}[tabindex="-1"]:focus{outline:none}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5em;font-weight:500}p{margin-top:0;margin-bottom:1em}abbr[title],abbr[data-original-title]{-webkit-text-decoration:underline dotted;text-decoration:underline;text-decoration:underline dotted;border-bottom:0;cursor:help}address{margin-bottom:1em;font-style:normal;line-height:inherit}input[type=text],input[type=password],input[type=number],textarea{-webkit-appearance:none}ol,ul,dl{margin-top:0;margin-bottom:1em}ol ol,ul ul,ol ul,ul ol{margin-bottom:0}dt{font-weight:500}dd{margin-bottom:.5em;margin-left:0}blockquote{margin:0 0 1em}dfn{font-style:italic}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}pre,code,kbd,samp{font-size:1em;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace}pre{margin-top:0;margin-bottom:1em;overflow:auto}figure{margin:0 0 1em}img{vertical-align:middle;border-style:none}a,area,button,[role=button],input:not([type=range]),label,select,summary,textarea{touch-action:manipulation}table{border-collapse:collapse}caption{padding-top:.75em;padding-bottom:.3em;text-align:left;caption-side:bottom}input,button,select,optgroup,textarea{margin:0;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}button,html [type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{padding:0;border-style:none}input[type=radio],input[type=checkbox]{box-sizing:border-box;padding:0}input[type=date],input[type=time],input[type=datetime-local],input[type=month]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;margin:0;padding:0;border:0}legend{display:block;width:100%;max-width:100%;margin-bottom:.5em;padding:0;color:inherit;font-size:1.5em;line-height:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item}template{display:none}[hidden]{display:none!important}mark{padding:.2em;background-color:#feffe6}.rjsf-form{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.vertical-form-item .ant-form-item-label{padding-bottom:0!important;margin-bottom:0}.vertical-form-item .ant-form-item-label>label{margin-bottom:0}.ant-form-item-has-error .ant-form-item-label>label{color:#ff4d4f}.ant-form-item-required:before{display:inline-block;margin-right:4px;color:#ff4d4f;font-size:14px;font-family:SimSun,sans-serif;line-height:1;content:"*"}.edf-choice-widget{position:relative;width:100%}.edf-choice-widget--small{font-size:12px}.edf-choice-widget--middle{font-size:14px}.edf-choice-widget--large{font-size:16px}.edf-choice-widget--disabled{opacity:.6;cursor:not-allowed}.edf-choice-widget--readonly{pointer-events:none}.edf-choice-widget__loading{display:flex;align-items:center;gap:8px;padding:8px;color:#666}.edf-choice-widget__loading-spinner{display:inline-block;width:16px;height:16px;border:2px solid #f3f3f3;border-top:2px solid #1890ff;border-radius:50%;animation:edf-spin 1s linear infinite}.edf-choice-widget__loading-message{font-size:14px}.edf-choice-widget__loading-progress{width:100%;height:4px;background-color:#f0f0f0;border-radius:2px;overflow:hidden;margin-top:4px}.edf-choice-widget__loading-progress-bar{height:100%;background-color:#1890ff;transition:width .3s ease}.edf-choice-widget__error{display:flex;align-items:center;gap:8px;padding:8px;color:#ff4d4f;background-color:#fff2f0;border:1px solid #ffccc7;border-radius:4px;margin-top:4px}.edf-choice-widget__error-icon{font-size:16px;flex-shrink:0}.edf-choice-widget__error-message{font-size:14px;flex:1}.edf-choice-widget__error-hint{font-size:12px;color:#8c8c8c;font-style:italic}.edf-choice-widget__empty{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px;color:#8c8c8c;text-align:center}.edf-choice-widget__empty-icon{font-size:32px;margin-bottom:8px;opacity:.5}.edf-choice-widget__empty-message{font-size:14px}@keyframes edf-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.edf-choice-widget--dropdown .edf-choice-widget__wrapper{position:relative}.edf-choice-widget--dropdown .edf-choice-widget__loading-overlay{position:absolute;top:0;left:0;right:0;bottom:0;background-color:#ffffffe6;display:flex;align-items:center;justify-content:center;z-index:10;border-radius:4px}.edf-choice-widget--dropdown .edf-choice-widget__option-icon{margin-right:4px;display:inline-flex;align-items:center}.edf-choice-widget--dropdown .edf-choice-widget__option-label{flex:1}.edf-choice-widget--dropdown .edf-choice-widget__option-description{display:block;font-size:12px;color:#8c8c8c;margin-top:2px;white-space:normal}.edf-choice-widget--dropdown.has-error .ant-select-selector{border-color:#ff4d4f!important}.edf-choice-widget--dropdown.has-error .ant-select-focused .ant-select-selector{border-color:#ff7875!important;box-shadow:0 0 0 2px #ff4d4f33}.edf-choice-widget--radio .edf-choice-widget__wrapper{position:relative}.edf-choice-widget--radio .edf-choice-widget__radio-content{display:flex;flex-direction:column;gap:2px}.edf-choice-widget--radio .edf-choice-widget__radio-main{display:flex;align-items:center;gap:4px}.edf-choice-widget--radio .edf-choice-widget__option-icon{display:inline-flex;align-items:center;font-size:16px}.edf-choice-widget--radio .edf-choice-widget__option-label{font-weight:500}.edf-choice-widget--radio .edf-choice-widget__option-description{margin-left:24px;font-size:12px;color:#8c8c8c;line-height:1.5}.edf-choice-widget--radio .edf-choice-widget__radio-group-label{font-weight:600;color:#595959;margin-bottom:8px;margin-top:16px;padding-bottom:4px;border-bottom:1px solid #f0f0f0}.edf-choice-widget--radio .edf-choice-widget__radio-group-label:first-child{margin-top:0}.edf-choice-widget--radio .edf-choice-widget__radio-divider{height:1px;background-color:#f0f0f0;margin:12px 0}.edf-choice-widget--radio.has-error .ant-radio-group{border:1px solid #ff4d4f;border-radius:4px;padding:8px}.edf-choice-widget--radio .ant-radio-wrapper{margin-bottom:8px;display:flex;align-items:flex-start}.edf-choice-widget--radio .ant-radio-wrapper:last-child{margin-bottom:0}.edf-choice-widget--radio .ant-radio-wrapper-disabled{cursor:not-allowed;opacity:.6}.edf-choice-widget--radio .ant-space-horizontal .ant-radio-wrapper{margin-bottom:0;margin-right:16px}.edf-choice-widget--radio .ant-space-horizontal .ant-radio-wrapper:last-child{margin-right:0}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FormProps } from '@rjsf/core';
|
|
2
2
|
import { RJSFSchema, UiSchema } from '@rjsf/utils';
|
|
3
3
|
|
|
4
|
+
export type WebhookEventType = 'focus' | 'blur' | 'change' | 'submit' | 'stepChange' | 'validationError';
|
|
4
5
|
export interface FormEventHandlers {
|
|
5
6
|
beforeSubmit?: (data: any) => Promise<any> | any;
|
|
6
7
|
afterSubmit?: (data: any) => Promise<void> | void;
|
|
@@ -20,7 +21,7 @@ export interface WebhookConfig {
|
|
|
20
21
|
url: string;
|
|
21
22
|
method?: 'POST' | 'PUT' | 'PATCH';
|
|
22
23
|
headers?: Record<string, string>;
|
|
23
|
-
events?:
|
|
24
|
+
events?: WebhookEventType[];
|
|
24
25
|
debounceMs?: number;
|
|
25
26
|
retries?: number;
|
|
26
27
|
timeout?: number;
|
|
@@ -34,6 +35,10 @@ export interface ExtendedFormProps extends Omit<FormProps, 'validator'>, FormEve
|
|
|
34
35
|
schema: RJSFSchema;
|
|
35
36
|
uiSchema?: UiSchema;
|
|
36
37
|
webhooks?: WebhookConfig[];
|
|
38
|
+
eventHub?: any;
|
|
39
|
+
onWebhookStart?: (webhook: WebhookConfig, event: any) => void;
|
|
40
|
+
onWebhookComplete?: (webhook: WebhookConfig, event: any, response: any) => void;
|
|
41
|
+
onWebhookError?: (webhook: WebhookConfig, event: any, error: Error) => void;
|
|
37
42
|
}
|
|
38
43
|
export interface CustomWidgetProps {
|
|
39
44
|
label?: string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility for detecting field-level changes in form data
|
|
3
|
+
*/
|
|
4
|
+
export interface FieldChange {
|
|
5
|
+
fieldId: string;
|
|
6
|
+
fieldPath: string[];
|
|
7
|
+
oldValue: any;
|
|
8
|
+
newValue: any;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Deep comparison to find changed fields between two form data objects
|
|
12
|
+
*/
|
|
13
|
+
export declare function detectFieldChanges(oldData: any, newData: any, parentPath?: string[]): FieldChange[];
|
|
14
|
+
/**
|
|
15
|
+
* Convert field path to RJSF field ID format
|
|
16
|
+
* RJSF uses a specific format like "root_fieldName_0_subField"
|
|
17
|
+
*/
|
|
18
|
+
export declare function pathToFieldId(path: string[], idPrefix?: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Extract schema for a specific field path
|
|
21
|
+
*/
|
|
22
|
+
export declare function getFieldSchema(schema: any, path: string[]): any | undefined;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { WidgetProps } from '@rjsf/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base interface for all enhanced widgets
|
|
5
|
+
*/
|
|
6
|
+
export interface EnhancedWidgetProps extends WidgetProps {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Ant Design Input component options that can be configured through uiSchema
|
|
10
|
+
*/
|
|
11
|
+
export interface AntInputOptions {
|
|
12
|
+
size?: 'large' | 'middle' | 'small';
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
prefix?: React.ReactNode;
|
|
15
|
+
suffix?: React.ReactNode;
|
|
16
|
+
allowClear?: boolean;
|
|
17
|
+
bordered?: boolean;
|
|
18
|
+
variant?: 'outlined' | 'borderless' | 'filled';
|
|
19
|
+
defaultValue?: string;
|
|
20
|
+
maxLength?: number;
|
|
21
|
+
showCount?: boolean | {
|
|
22
|
+
formatter: (info: {
|
|
23
|
+
value: string;
|
|
24
|
+
count: number;
|
|
25
|
+
maxLength?: number;
|
|
26
|
+
}) => React.ReactNode;
|
|
27
|
+
};
|
|
28
|
+
status?: 'error' | 'warning';
|
|
29
|
+
style?: React.CSSProperties;
|
|
30
|
+
className?: string;
|
|
31
|
+
addonBefore?: React.ReactNode;
|
|
32
|
+
addonAfter?: React.ReactNode;
|
|
33
|
+
emptyValue?: any;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Ant Design TextArea component options
|
|
37
|
+
*/
|
|
38
|
+
export interface AntTextAreaOptions extends AntInputOptions {
|
|
39
|
+
rows?: number;
|
|
40
|
+
autoSize?: boolean | {
|
|
41
|
+
minRows?: number;
|
|
42
|
+
maxRows?: number;
|
|
43
|
+
};
|
|
44
|
+
showCount?: boolean | {
|
|
45
|
+
formatter: (info: {
|
|
46
|
+
value: string;
|
|
47
|
+
count: number;
|
|
48
|
+
maxLength?: number;
|
|
49
|
+
}) => React.ReactNode;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Ant Design DatePicker component options
|
|
54
|
+
*/
|
|
55
|
+
export interface AntDatePickerOptions {
|
|
56
|
+
format?: string | string[];
|
|
57
|
+
picker?: 'date' | 'week' | 'month' | 'quarter' | 'year';
|
|
58
|
+
placeholder?: string | [string, string];
|
|
59
|
+
placement?: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';
|
|
60
|
+
showTime?: boolean | object;
|
|
61
|
+
showNow?: boolean;
|
|
62
|
+
showToday?: boolean;
|
|
63
|
+
disabledDate?: (currentDate: any) => boolean;
|
|
64
|
+
size?: 'large' | 'middle' | 'small';
|
|
65
|
+
bordered?: boolean;
|
|
66
|
+
variant?: 'outlined' | 'borderless' | 'filled';
|
|
67
|
+
suffixIcon?: React.ReactNode;
|
|
68
|
+
style?: React.CSSProperties;
|
|
69
|
+
className?: string;
|
|
70
|
+
status?: 'error' | 'warning';
|
|
71
|
+
emptyValue?: any;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Ant Design InputNumber component options
|
|
75
|
+
*/
|
|
76
|
+
export interface AntInputNumberOptions {
|
|
77
|
+
size?: 'large' | 'middle' | 'small';
|
|
78
|
+
placeholder?: string;
|
|
79
|
+
prefix?: React.ReactNode;
|
|
80
|
+
min?: number;
|
|
81
|
+
max?: number;
|
|
82
|
+
step?: number;
|
|
83
|
+
precision?: number;
|
|
84
|
+
decimalSeparator?: string;
|
|
85
|
+
formatter?: (value: number | string | undefined, info: {
|
|
86
|
+
userTyping: boolean;
|
|
87
|
+
input: string;
|
|
88
|
+
}) => string;
|
|
89
|
+
parser?: (value: string | undefined) => number;
|
|
90
|
+
keyboard?: boolean;
|
|
91
|
+
controls?: boolean | {
|
|
92
|
+
upIcon?: React.ReactNode;
|
|
93
|
+
downIcon?: React.ReactNode;
|
|
94
|
+
};
|
|
95
|
+
bordered?: boolean;
|
|
96
|
+
variant?: 'outlined' | 'borderless' | 'filled';
|
|
97
|
+
style?: React.CSSProperties;
|
|
98
|
+
className?: string;
|
|
99
|
+
status?: 'error' | 'warning';
|
|
100
|
+
addonBefore?: React.ReactNode;
|
|
101
|
+
addonAfter?: React.ReactNode;
|
|
102
|
+
emptyValue?: any;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Type mapping for widget options
|
|
106
|
+
*/
|
|
107
|
+
export type WidgetOptionsMap = {
|
|
108
|
+
text: AntInputOptions;
|
|
109
|
+
textarea: AntTextAreaOptions;
|
|
110
|
+
password: AntInputOptions;
|
|
111
|
+
email: AntInputOptions;
|
|
112
|
+
tel: AntInputOptions;
|
|
113
|
+
url: AntInputOptions;
|
|
114
|
+
number: AntInputNumberOptions;
|
|
115
|
+
date: AntDatePickerOptions;
|
|
116
|
+
'datetime-local': AntDatePickerOptions;
|
|
117
|
+
file: any;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Common props passed to widgets from RJSF that we use frequently
|
|
121
|
+
*/
|
|
122
|
+
export interface CommonWidgetProps {
|
|
123
|
+
id: string;
|
|
124
|
+
value: any;
|
|
125
|
+
disabled?: boolean;
|
|
126
|
+
readonly?: boolean;
|
|
127
|
+
required?: boolean;
|
|
128
|
+
placeholder?: string;
|
|
129
|
+
onChange: (value: any) => void;
|
|
130
|
+
onBlur?: (id: string, value: any) => void;
|
|
131
|
+
onFocus?: (id: string, value: any) => void;
|
|
132
|
+
options?: any;
|
|
133
|
+
rawErrors?: string[];
|
|
134
|
+
schema: any;
|
|
135
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { InputProps, TextAreaProps } from 'antd/es/input';
|
|
2
|
+
import { DatePickerProps } from 'antd/es/date-picker';
|
|
3
|
+
import { InputNumberProps } from 'antd/es/input-number';
|
|
4
|
+
import { AntInputOptions, AntTextAreaOptions, AntDatePickerOptions, AntInputNumberOptions } from './types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Extract Ant Design Input props from uiSchema options
|
|
8
|
+
*/
|
|
9
|
+
export declare const getAntInputProps: (options?: AntInputOptions) => Partial<InputProps>;
|
|
10
|
+
/**
|
|
11
|
+
* Extract Ant Design TextArea props from uiSchema options
|
|
12
|
+
*/
|
|
13
|
+
export declare const getAntTextAreaProps: (options?: AntTextAreaOptions) => Partial<TextAreaProps>;
|
|
14
|
+
/**
|
|
15
|
+
* Extract Ant Design DatePicker props from uiSchema options
|
|
16
|
+
*/
|
|
17
|
+
export declare const getAntDatePickerProps: (options?: AntDatePickerOptions) => Partial<DatePickerProps>;
|
|
18
|
+
/**
|
|
19
|
+
* Extract Ant Design InputNumber props from uiSchema options
|
|
20
|
+
*/
|
|
21
|
+
export declare const getAntInputNumberProps: (options?: AntInputNumberOptions) => Partial<InputNumberProps>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if the widget has validation errors
|
|
24
|
+
*/
|
|
25
|
+
export declare const hasError: (rawErrors?: string[]) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Get the appropriate empty value based on options
|
|
28
|
+
*/
|
|
29
|
+
export declare const getEmptyValue: (options: any, defaultValue?: any) => any;
|
|
30
|
+
/**
|
|
31
|
+
* Get value or empty value for controlled components
|
|
32
|
+
*/
|
|
33
|
+
export declare const getValue: (value: any, options: any, defaultValue?: any) => any;
|
|
34
|
+
/**
|
|
35
|
+
* Handle change event and return the appropriate value
|
|
36
|
+
*/
|
|
37
|
+
export declare const handleChangeValue: (value: any, options: any, defaultEmptyValue?: any) => any;
|
|
38
|
+
/**
|
|
39
|
+
* Common props for Ant Design form components
|
|
40
|
+
*/
|
|
41
|
+
export declare const getCommonAntProps: (id: string, hasError: boolean, disabled?: boolean, readonly?: boolean) => {
|
|
42
|
+
id: string;
|
|
43
|
+
status: "error" | undefined;
|
|
44
|
+
disabled: boolean | undefined;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Extract numeric constraints from JSON schema
|
|
48
|
+
*/
|
|
49
|
+
export declare const getNumericConstraints: (schema?: any) => {
|
|
50
|
+
min: any;
|
|
51
|
+
max: any;
|
|
52
|
+
step: any;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Merge options from different sources (schema, uiSchema)
|
|
56
|
+
* Priority: uiSchema options > schema constraints > defaults
|
|
57
|
+
*/
|
|
58
|
+
export declare const mergeOptions: (schemaOptions?: any, uiSchemaOptions?: any, defaults?: any) => any;
|
|
59
|
+
/**
|
|
60
|
+
* Convert various value types to boolean
|
|
61
|
+
* Handles string "true"/"false" conversions properly
|
|
62
|
+
*/
|
|
63
|
+
export declare const toBooleanValue: (value: any, defaultValue?: boolean) => boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ChoiceWidgetProps } from './ChoiceWidget.types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Main Choice Widget component with error boundary
|
|
6
|
+
*
|
|
7
|
+
* Provides comprehensive error handling and graceful fallback mechanisms:
|
|
8
|
+
* - Error boundary catches and handles all rendering errors
|
|
9
|
+
* - Fallback to basic HTML select on critical failures
|
|
10
|
+
* - Retry mechanism with configurable limits
|
|
11
|
+
* - Error reporting to FormEventHub
|
|
12
|
+
* - Development-friendly error details
|
|
13
|
+
* - Accessibility-compliant error announcements
|
|
14
|
+
*
|
|
15
|
+
* Key features:
|
|
16
|
+
* - Full RJSF WidgetProps compliance
|
|
17
|
+
* - Automatic presenter strategy selection
|
|
18
|
+
* - Comprehensive error boundary implementation
|
|
19
|
+
* - Event system integration via FormEventHub
|
|
20
|
+
* - Performance optimization (<200ms render target)
|
|
21
|
+
* - WCAG 2.1 AA accessibility compliance
|
|
22
|
+
* - Loading and error state management
|
|
23
|
+
* - Backward compatibility preservation
|
|
24
|
+
*
|
|
25
|
+
* @param props - RJSF-compatible widget props with Choice Widget extensions
|
|
26
|
+
* @returns Fully-featured choice widget with error boundaries
|
|
27
|
+
*/
|
|
28
|
+
export declare const ChoiceWidget: React.FC<ChoiceWidgetProps>;
|
|
29
|
+
export type { ChoiceWidgetProps, ChoiceWidgetConfig, ChoiceWidgetState, ChoiceOption, PresentationMode, ErrorState, LoadingState, } from './ChoiceWidget.types';
|
|
30
|
+
export default ChoiceWidget;
|