extended-dynamic-forms 0.1.21 → 0.1.23

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.
Files changed (60) hide show
  1. package/README.md +134 -70
  2. package/dist/ExtendedForm.d.ts +4 -0
  3. package/dist/WizardForm.d.ts +25 -0
  4. package/dist/components/arrays/ArrayFieldItemTemplate.d.ts +3 -0
  5. package/dist/components/arrays/ArrayFieldTemplate.d.ts +3 -0
  6. package/dist/components/arrays/index.d.ts +2 -0
  7. package/dist/components/fields/AddressField.d.ts +3 -0
  8. package/dist/components/fields/CurrencyField.d.ts +4 -0
  9. package/dist/components/fields/PhoneField.d.ts +4 -0
  10. package/dist/components/index.d.ts +24 -0
  11. package/dist/components/templates/FieldTemplate.d.ts +4 -0
  12. package/dist/components/templates/SubmitButton.d.ts +4 -0
  13. package/dist/components/templates/index.d.ts +2 -0
  14. package/dist/conditionals/index.d.ts +1 -0
  15. package/dist/conditionals/v2/createConditionalEngineHook.d.ts +3 -0
  16. package/dist/conditionals/v2/effects/customHandlers.d.ts +35 -0
  17. package/dist/conditionals/v2/engines/schemaEngineConfig.d.ts +4 -0
  18. package/dist/conditionals/v2/engines/uiEngineConfig.d.ts +4 -0
  19. package/dist/conditionals/v2/engines/validationEngineConfig.d.ts +13 -0
  20. package/dist/conditionals/v2/hooks/useConditionalSchema.d.ts +4 -0
  21. package/dist/conditionals/v2/hooks/useConditionalUi.d.ts +4 -0
  22. package/dist/conditionals/v2/hooks/useConditionalValidation.d.ts +4 -0
  23. package/dist/conditionals/v2/index.d.ts +9 -0
  24. package/dist/conditionals/v2/types.d.ts +47 -0
  25. package/dist/conditionals/v2/utils/dynamicArrayItems.d.ts +59 -0
  26. package/dist/conditionals/v2/utils/jsonPatch.d.ts +9 -0
  27. package/dist/events/FormEventContext.d.ts +19 -0
  28. package/dist/events/FormEventHub.d.ts +27 -0
  29. package/dist/events/FormEventManager.d.ts +10 -0
  30. package/dist/events/index.d.ts +4 -0
  31. package/dist/hooks/index.d.ts +1 -0
  32. package/dist/index.d.ts +15 -0
  33. package/dist/index.es.js +19075 -0
  34. package/dist/index.umd.js +162 -0
  35. package/dist/layouts/index.d.ts +2 -0
  36. package/dist/layouts/wizard/ProgressIndicator.d.ts +10 -0
  37. package/dist/layouts/wizard/StepNavigation.d.ts +11 -0
  38. package/dist/layouts/wizard/WizardLayout.d.ts +31 -0
  39. package/dist/layouts/wizard/WizardNavigation.d.ts +16 -0
  40. package/dist/layouts/wizard/WizardObjectFieldTemplate.d.ts +4 -0
  41. package/dist/layouts/wizard/WizardSectionTemplate.d.ts +11 -0
  42. package/dist/layouts/wizard/index.d.ts +7 -0
  43. package/dist/types/index.d.ts +47 -0
  44. package/dist/utils/formDataUtils.d.ts +22 -0
  45. package/dist/utils/index.d.ts +4 -0
  46. package/dist/utils/schemaUtils.d.ts +24 -0
  47. package/dist/utils/validationUtils.d.ts +26 -0
  48. package/dist/vanilla-entry.d.ts +204 -0
  49. package/dist/widgets/date/DateWidget.d.ts +4 -0
  50. package/dist/widgets/enhanced/EnhancedWidgets.d.ts +37 -0
  51. package/dist/widgets/file/FileWidget.d.ts +4 -0
  52. package/dist/widgets/index.d.ts +33 -0
  53. package/dist/widgets/input/ColorWidget.d.ts +4 -0
  54. package/dist/widgets/input/RangeWidget.d.ts +4 -0
  55. package/dist/widgets/input/RatingWidget.d.ts +4 -0
  56. package/examples/conditional-v2-example.tsx +2 -2
  57. package/examples/form-devtools-example.tsx +7 -9
  58. package/examples/global-ui-rules-example.tsx +34 -19
  59. package/package.json +8 -3
  60. package/dist/extended-dynamic-forms.standalone.js +0 -882
@@ -0,0 +1,47 @@
1
+ import { ErrorSchema } from '@rjsf/utils';
2
+ import { RulesLogic } from 'json-logic-js';
3
+
4
+ export type JsonLogicRule = RulesLogic;
5
+ export type ConditionPredicate = (formData: any) => boolean;
6
+ export type Condition = ConditionPredicate | JsonLogicRule;
7
+ export interface Rule<T> {
8
+ name: string;
9
+ condition: Condition;
10
+ effect: T;
11
+ order?: number;
12
+ }
13
+ export interface EngineConfig<T, C = any> {
14
+ applyEffects: (effects: T[], baseConfig: C, formData: any) => C;
15
+ defaultConfig: () => C;
16
+ }
17
+ export type ConditionalEngineHook<T, C = any> = (rules: Rule<T>[], baseConfig: C, formData: any) => C;
18
+ export interface UiEffect {
19
+ op: 'add' | 'remove' | 'replace';
20
+ path: string;
21
+ value?: any;
22
+ }
23
+ export interface JsonPatchSchemaEffect {
24
+ op: 'add' | 'remove' | 'replace';
25
+ path: string;
26
+ value?: any;
27
+ }
28
+ export interface CustomSchemaEffect {
29
+ op: 'require' | 'optional';
30
+ path: string;
31
+ field: string;
32
+ }
33
+ export type SchemaEffect = JsonPatchSchemaEffect | CustomSchemaEffect;
34
+ export interface ValidationEffect {
35
+ /**
36
+ * Name of the validation rule for debugging purposes
37
+ */
38
+ name: string;
39
+ /**
40
+ * Determines if this validation should be applied based on current form data
41
+ */
42
+ isActive: Condition;
43
+ /**
44
+ * Applies validation logic and adds errors to the ErrorSchema
45
+ */
46
+ validate: (errors: ErrorSchema, formData: any) => void;
47
+ }
@@ -0,0 +1,59 @@
1
+ import { UiSchema } from '@rjsf/utils';
2
+
3
+ /**
4
+ * Function type for dynamic uiSchema.items in RJSF fork
5
+ * This enables O(n) performance for array conditionals
6
+ */
7
+ export type ArrayItemsFunction = (itemData: any, index: number, formContext?: any) => UiSchema;
8
+ /**
9
+ * Function type for conditional logic applied to array items
10
+ */
11
+ export type ArrayItemConditionalFn = (itemData: any, index: number, formContext?: any) => Partial<UiSchema>;
12
+ /**
13
+ * Creates a dynamic uiSchema.items function for array fields
14
+ *
15
+ * @param baseItemUiSchema - Base UI schema applied to all array items
16
+ * @param conditionalLogic - Function that returns conditional UI schema modifications
17
+ * @returns Function compatible with RJSF fork's dynamic uiSchema.items
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const directorsUiSchema = {
22
+ * items: createDynamicArrayItemsUiSchema(
23
+ * { 'ui:order': ['name', 'hasShareholding', 'shareholdingPercentage'] },
24
+ * (itemData) => {
25
+ * if (!itemData?.hasShareholding) {
26
+ * return { shareholdingPercentage: { 'ui:widget': 'hidden' } };
27
+ * }
28
+ * return {};
29
+ * }
30
+ * )
31
+ * };
32
+ * ```
33
+ */
34
+ export declare function createDynamicArrayItemsUiSchema(baseItemUiSchema: UiSchema, conditionalLogic: ArrayItemConditionalFn): ArrayItemsFunction;
35
+ /**
36
+ * Safely merges UI schemas with proper handling of nested properties
37
+ *
38
+ * @param base - Base UI schema
39
+ * @param overrides - Conditional UI schema overrides
40
+ * @returns Merged UI schema
41
+ */
42
+ export declare function mergeItemUiSchema(base: UiSchema, overrides: Partial<UiSchema>): UiSchema;
43
+ /**
44
+ * Helper to create common conditional patterns
45
+ */
46
+ export declare const arrayItemPatterns: {
47
+ /**
48
+ * Show/hide a field based on a condition
49
+ */
50
+ hideField: (fieldName: string, condition: (itemData: any) => boolean) => ArrayItemConditionalFn;
51
+ /**
52
+ * Make a field required based on a condition
53
+ */
54
+ requireField: (fieldName: string, condition: (itemData: any) => boolean) => ArrayItemConditionalFn;
55
+ /**
56
+ * Apply styles to first/last items
57
+ */
58
+ applyIndexStyles: (totalItems: number) => ArrayItemConditionalFn;
59
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Simple JSON Patch-like utility for applying operations to objects
3
+ * Supports add, remove, and replace operations with JSONPath-like syntax
4
+ */
5
+ export declare function applyPatch(target: any, operations: Array<{
6
+ op: string;
7
+ path: string;
8
+ value?: any;
9
+ }>): any;
@@ -0,0 +1,19 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ import { FormEventHub } from './FormEventHub';
3
+
4
+ export interface FormEventContextType {
5
+ eventHub: FormEventHub;
6
+ formData?: any;
7
+ }
8
+ export interface FormEventProviderProps {
9
+ eventHub: FormEventHub;
10
+ formData?: any;
11
+ children: ReactNode;
12
+ }
13
+ export declare const FormEventProvider: React.FC<FormEventProviderProps>;
14
+ export declare const useFormEventHub: () => FormEventContextType;
15
+ export declare const useFieldEventHandlers: (fieldId: string, schema?: any, fieldPath?: string[]) => {
16
+ onFocus: (value: any) => Promise<void>;
17
+ onBlur: (value: any) => Promise<void>;
18
+ onChange: (value: any) => Promise<void>;
19
+ };
@@ -0,0 +1,27 @@
1
+ import { FormEventHandlers, FieldEventHandlers, WebhookConfig } from '../types';
2
+
3
+ export declare class FormEventHub {
4
+ private formHandlers;
5
+ private fieldHandlers;
6
+ private webhooks;
7
+ private debounceTimers;
8
+ private webhookQueue;
9
+ private isProcessingQueue;
10
+ constructor(formHandlers: FormEventHandlers, fieldHandlers?: FieldEventHandlers, webhooks?: WebhookConfig[]);
11
+ handleBeforeSubmit(data: any): Promise<any>;
12
+ handleAfterSubmit(data: any): Promise<void>;
13
+ handleBeforeValidation(data: any): Promise<any>;
14
+ handleAfterValidation(data: any, errors: any): Promise<void>;
15
+ handleFieldEvent(eventType: 'focus' | 'blur' | 'change', fieldId: string, fieldValue: any, schema?: any, formData?: any, fieldPath?: string[]): Promise<void>;
16
+ private processWebhooks;
17
+ private debounceWebhook;
18
+ private queueWebhook;
19
+ private processWebhookQueue;
20
+ private callWebhook;
21
+ createFieldEventHandlers(fieldId: string, schema?: any, formData?: any, fieldPath?: string[]): {
22
+ onFocus: (value: any) => Promise<void>;
23
+ onBlur: (value: any) => Promise<void>;
24
+ onChange: (value: any) => Promise<void>;
25
+ };
26
+ cleanup(): void;
27
+ }
@@ -0,0 +1,10 @@
1
+ import { FormEventHandlers } from '../types';
2
+
3
+ export declare class FormEventManager {
4
+ private handlers;
5
+ constructor(handlers: FormEventHandlers);
6
+ handleBeforeSubmit(data: any): Promise<any>;
7
+ handleAfterSubmit(data: any): Promise<void>;
8
+ handleBeforeValidation(data: any): Promise<any>;
9
+ handleAfterValidation(data: any, errors: any): Promise<void>;
10
+ }
@@ -0,0 +1,4 @@
1
+ export { FormEventManager } from './FormEventManager';
2
+ export { FormEventHub } from './FormEventHub';
3
+ export { FormEventProvider, useFormEventHub, useFieldEventHandlers, } from './FormEventContext';
4
+ export type { FormEventHandlers, FieldEventHandlers, FormFieldEvent, WebhookConfig, } from '../types';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+
2
+ export * from './components';
3
+ export * from './widgets';
4
+ export * from './layouts';
5
+ export * from './events';
6
+ export * from './conditionals';
7
+ export * from './types';
8
+ export * from './utils';
9
+ export * from './hooks';
10
+ export type { FormProps, IChangeEvent } from '@rjsf/core';
11
+ export type { RJSFSchema, UiSchema, WidgetProps, FieldProps, ArrayFieldTemplateProps, ObjectFieldTemplateProps, FieldTemplateProps, ErrorSchema, RJSFValidationError, } from '@rjsf/utils';
12
+ export { default as validator } from '@rjsf/validator-ajv8';
13
+ export { ExtendedForm } from './ExtendedForm';
14
+ export { WizardForm } from './WizardForm';
15
+ export type { WizardFormProps, WizardStep } from './WizardForm';