@rilaykit/core 4.0.0 → 5.1.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/dist/index.d.mts +564 -370
- package/dist/index.d.ts +564 -370
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Main configuration class for Rilay form components and workflows
|
|
@@ -15,6 +15,20 @@ declare class ril<C> {
|
|
|
15
15
|
* @param type - The component type (e.g., 'text', 'email', 'heading'), used as a unique identifier.
|
|
16
16
|
* @param config - Component configuration without id and type
|
|
17
17
|
* @returns The ril instance for chaining
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Component avec validation par défaut
|
|
22
|
+
* const factory = ril.create()
|
|
23
|
+
* .addComponent('email', {
|
|
24
|
+
* name: 'Email Input',
|
|
25
|
+
* renderer: EmailInput,
|
|
26
|
+
* validation: {
|
|
27
|
+
* validators: [email('Format email invalide')],
|
|
28
|
+
* validateOnBlur: true,
|
|
29
|
+
* }
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
18
32
|
*/
|
|
19
33
|
addComponent<NewType extends string, TProps = any>(type: NewType, config: Omit<ComponentConfig<TProps>, 'id' | 'type'>): ril<C & {
|
|
20
34
|
[K in NewType]: TProps;
|
|
@@ -113,81 +127,143 @@ interface RilayLicenseConfig {
|
|
|
113
127
|
readonly environment?: 'development' | 'production';
|
|
114
128
|
readonly allowTrial?: boolean;
|
|
115
129
|
}
|
|
130
|
+
interface ValidationError {
|
|
131
|
+
readonly message: string;
|
|
132
|
+
readonly code?: string;
|
|
133
|
+
readonly path?: string;
|
|
134
|
+
}
|
|
116
135
|
interface ValidationResult {
|
|
117
136
|
readonly isValid: boolean;
|
|
118
137
|
readonly errors: ValidationError[];
|
|
119
138
|
}
|
|
120
|
-
interface ValidationError {
|
|
121
|
-
readonly code: string;
|
|
122
|
-
readonly message: string;
|
|
123
|
-
readonly path?: string[];
|
|
124
|
-
}
|
|
125
139
|
interface ValidationContext {
|
|
126
|
-
readonly fieldId
|
|
127
|
-
readonly
|
|
128
|
-
readonly
|
|
129
|
-
readonly
|
|
130
|
-
readonly
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
140
|
+
readonly fieldId?: string;
|
|
141
|
+
readonly formId?: string;
|
|
142
|
+
readonly stepId?: string;
|
|
143
|
+
readonly workflowId?: string;
|
|
144
|
+
readonly allFormData?: Record<string, any>;
|
|
145
|
+
readonly stepData?: Record<string, any>;
|
|
146
|
+
readonly workflowData?: Record<string, any>;
|
|
147
|
+
}
|
|
148
|
+
type FieldValidator<T = any> = (value: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>;
|
|
149
|
+
type FormValidator<T = Record<string, any>> = (formData: T, context: ValidationContext) => ValidationResult | Promise<ValidationResult>;
|
|
150
|
+
type ValidationSchema<T = any> = {
|
|
151
|
+
parse: (value: T) => T;
|
|
152
|
+
safeParse: (value: T) => {
|
|
153
|
+
success: boolean;
|
|
154
|
+
data?: T;
|
|
155
|
+
error?: any;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
interface ValidationAdapter<TSchema = any> {
|
|
159
|
+
readonly name: string;
|
|
160
|
+
readonly version?: string;
|
|
161
|
+
createFieldValidator<T>(schema: TSchema): FieldValidator<T>;
|
|
162
|
+
createFormValidator<T>(schema: TSchema): FormValidator<T>;
|
|
163
|
+
}
|
|
164
|
+
interface FieldValidationConfig {
|
|
165
|
+
readonly validators?: FieldValidator[];
|
|
166
|
+
readonly schema?: ValidationSchema;
|
|
136
167
|
readonly validateOnChange?: boolean;
|
|
137
168
|
readonly validateOnBlur?: boolean;
|
|
169
|
+
readonly debounceMs?: number;
|
|
170
|
+
}
|
|
171
|
+
interface FormValidationConfig {
|
|
172
|
+
readonly validators?: FormValidator[];
|
|
173
|
+
readonly schema?: ValidationSchema;
|
|
138
174
|
readonly validateOnSubmit?: boolean;
|
|
139
|
-
readonly
|
|
175
|
+
readonly validateOnStepChange?: boolean;
|
|
176
|
+
}
|
|
177
|
+
type ComponentRenderer<TProps = any> = (props: ComponentRenderProps<TProps>) => React__default.ReactElement;
|
|
178
|
+
type RendererChildrenFunction<TProps = any> = (props: TProps) => React__default.ReactNode;
|
|
179
|
+
interface ComponentRendererBaseProps<TProps = any> {
|
|
180
|
+
className?: string;
|
|
181
|
+
children?: React__default.ReactNode | RendererChildrenFunction<TProps>;
|
|
182
|
+
renderAs?: 'default' | 'children' | boolean;
|
|
183
|
+
}
|
|
184
|
+
interface ComponentRendererWrapperProps<TProps = any> extends Omit<ComponentRendererBaseProps<TProps>, 'className'> {
|
|
185
|
+
name: string;
|
|
186
|
+
props: TProps;
|
|
187
|
+
renderer?: RendererChildrenFunction<TProps>;
|
|
140
188
|
}
|
|
141
|
-
type ComponentRenderer<TProps = any> = (props: ComponentRenderProps<TProps>) => React.ReactElement;
|
|
142
189
|
interface ComponentRenderProps<TProps = any> {
|
|
143
190
|
id: string;
|
|
144
191
|
props: TProps;
|
|
145
192
|
value?: any;
|
|
146
193
|
onChange?: (value: any) => void;
|
|
147
194
|
onBlur?: () => void;
|
|
148
|
-
error?: ValidationError[];
|
|
149
|
-
touched?: boolean;
|
|
150
195
|
disabled?: boolean;
|
|
196
|
+
error?: ValidationError[];
|
|
151
197
|
isValidating?: boolean;
|
|
152
198
|
[key: string]: any;
|
|
153
199
|
}
|
|
154
|
-
type RendererChildrenFunction<TProps = any> = (props: TProps) => React.ReactNode;
|
|
155
|
-
declare function resolveRendererChildren<TProps>(children: React.ReactNode | RendererChildrenFunction<TProps> | undefined, props: TProps): React.ReactNode;
|
|
156
200
|
interface ComponentConfig<TProps = any> {
|
|
157
201
|
readonly id: string;
|
|
158
202
|
readonly type: string;
|
|
159
203
|
readonly name: string;
|
|
160
204
|
readonly description?: string;
|
|
161
205
|
readonly renderer: ComponentRenderer<TProps>;
|
|
162
|
-
readonly validation?: ValidationConfig<TProps>;
|
|
163
206
|
readonly defaultProps?: Partial<TProps>;
|
|
164
207
|
readonly useFieldRenderer?: boolean;
|
|
208
|
+
readonly validation?: FieldValidationConfig;
|
|
165
209
|
}
|
|
166
210
|
interface FormFieldConfig {
|
|
167
211
|
readonly id: string;
|
|
168
212
|
readonly componentId: string;
|
|
169
213
|
readonly props: Record<string, any>;
|
|
170
|
-
readonly validation?:
|
|
171
|
-
readonly conditional?: ConditionalConfig;
|
|
214
|
+
readonly validation?: FieldValidationConfig;
|
|
172
215
|
}
|
|
173
216
|
interface FormFieldRow {
|
|
174
217
|
readonly id: string;
|
|
175
218
|
readonly fields: FormFieldConfig[];
|
|
176
219
|
readonly maxColumns?: number;
|
|
177
|
-
readonly spacing?: 'tight' | 'normal' | 'loose';
|
|
178
|
-
readonly alignment?: 'start' | 'center' | 'end' | 'stretch';
|
|
179
220
|
}
|
|
180
|
-
interface
|
|
181
|
-
readonly
|
|
182
|
-
readonly
|
|
221
|
+
interface FormConfiguration<C extends Record<string, any> = Record<string, never>> {
|
|
222
|
+
readonly id: string;
|
|
223
|
+
readonly config: ril<C>;
|
|
224
|
+
readonly rows: FormFieldRow[];
|
|
225
|
+
readonly allFields: FormFieldConfig[];
|
|
226
|
+
readonly renderConfig?: FormRenderConfig;
|
|
227
|
+
readonly validation?: FormValidationConfig;
|
|
228
|
+
}
|
|
229
|
+
interface FormRenderConfig {
|
|
230
|
+
readonly rowRenderer?: FormRowRenderer;
|
|
231
|
+
readonly bodyRenderer?: FormBodyRenderer;
|
|
232
|
+
readonly submitButtonRenderer?: FormSubmitButtonRenderer;
|
|
233
|
+
readonly fieldRenderer?: FieldRenderer;
|
|
183
234
|
}
|
|
184
|
-
interface
|
|
185
|
-
|
|
186
|
-
readonly onAfterLeave?: (stepData: any, allData: any, context: WorkflowContext) => Promise<boolean>;
|
|
187
|
-
readonly onValidate?: (stepData: any, context: WorkflowContext) => Promise<ValidationResult>;
|
|
188
|
-
readonly onTransform?: (stepData: any, context: WorkflowContext) => Promise<any>;
|
|
189
|
-
readonly onError?: (error: Error, context: WorkflowContext) => Promise<void>;
|
|
235
|
+
interface FormComponentRendererProps {
|
|
236
|
+
children: React__default.ReactNode;
|
|
190
237
|
}
|
|
238
|
+
interface FormRowRendererProps {
|
|
239
|
+
row: FormFieldRow;
|
|
240
|
+
children: React__default.ReactNode;
|
|
241
|
+
className?: string;
|
|
242
|
+
}
|
|
243
|
+
interface FormBodyRendererProps {
|
|
244
|
+
formConfig: FormConfiguration;
|
|
245
|
+
children: React__default.ReactNode;
|
|
246
|
+
className?: string;
|
|
247
|
+
}
|
|
248
|
+
interface FormSubmitButtonRendererProps {
|
|
249
|
+
isSubmitting: boolean;
|
|
250
|
+
onSubmit: () => void;
|
|
251
|
+
className?: string;
|
|
252
|
+
children?: React__default.ReactNode;
|
|
253
|
+
}
|
|
254
|
+
interface FieldRendererProps {
|
|
255
|
+
children: React__default.ReactNode;
|
|
256
|
+
id: string;
|
|
257
|
+
disabled?: boolean;
|
|
258
|
+
error?: ValidationError[];
|
|
259
|
+
isValidating?: boolean;
|
|
260
|
+
touched?: boolean;
|
|
261
|
+
[key: string]: any;
|
|
262
|
+
}
|
|
263
|
+
type FormRowRenderer = RendererChildrenFunction<FormRowRendererProps>;
|
|
264
|
+
type FormBodyRenderer = RendererChildrenFunction<FormBodyRendererProps>;
|
|
265
|
+
type FormSubmitButtonRenderer = RendererChildrenFunction<FormSubmitButtonRendererProps>;
|
|
266
|
+
type FieldRenderer = RendererChildrenFunction<FieldRendererProps>;
|
|
191
267
|
interface WorkflowContext {
|
|
192
268
|
readonly workflowId: string;
|
|
193
269
|
readonly currentStepIndex: number;
|
|
@@ -197,80 +273,61 @@ interface WorkflowContext {
|
|
|
197
273
|
readonly isFirstStep: boolean;
|
|
198
274
|
readonly isLastStep: boolean;
|
|
199
275
|
readonly visitedSteps: Set<string>;
|
|
200
|
-
readonly user?: any;
|
|
201
276
|
}
|
|
202
|
-
interface
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
277
|
+
interface StepDataHelper {
|
|
278
|
+
/**
|
|
279
|
+
* Set data for a specific step by step ID
|
|
280
|
+
*/
|
|
281
|
+
setStepData: (stepId: string, data: Record<string, any>) => void;
|
|
282
|
+
/**
|
|
283
|
+
* Set specific field values for a step
|
|
284
|
+
*/
|
|
285
|
+
setStepFields: (stepId: string, fields: Record<string, any>) => void;
|
|
286
|
+
/**
|
|
287
|
+
* Get current data for a specific step
|
|
288
|
+
*/
|
|
289
|
+
getStepData: (stepId: string) => Record<string, any>;
|
|
290
|
+
/**
|
|
291
|
+
* Set field value for the next step
|
|
292
|
+
*/
|
|
293
|
+
setNextStepField: (fieldId: string, value: any) => void;
|
|
294
|
+
/**
|
|
295
|
+
* Set multiple fields for the next step
|
|
296
|
+
*/
|
|
297
|
+
setNextStepFields: (fields: Record<string, any>) => void;
|
|
298
|
+
/**
|
|
299
|
+
* Get all workflow data
|
|
300
|
+
*/
|
|
301
|
+
getAllData: () => Record<string, any>;
|
|
302
|
+
/**
|
|
303
|
+
* Get all step configurations for reference
|
|
304
|
+
*/
|
|
305
|
+
getSteps: () => StepConfig[];
|
|
216
306
|
}
|
|
217
307
|
interface StepConfig {
|
|
218
308
|
readonly id: string;
|
|
219
309
|
readonly title: string;
|
|
220
310
|
readonly description?: string;
|
|
221
311
|
readonly formConfig: FormConfiguration;
|
|
222
|
-
readonly validation?: StepValidationConfig;
|
|
223
|
-
readonly conditional?: StepConditionalConfig;
|
|
224
312
|
readonly allowSkip?: boolean;
|
|
225
|
-
readonly requiredToComplete?: boolean;
|
|
226
|
-
readonly hooks?: StepLifecycleHooks;
|
|
227
|
-
readonly permissions?: StepPermissions;
|
|
228
|
-
readonly isDynamic?: boolean;
|
|
229
|
-
readonly dynamicConfig?: DynamicStepConfig;
|
|
230
313
|
readonly renderer?: CustomStepRenderer;
|
|
314
|
+
readonly onAfterValidation?: (stepData: Record<string, any>, helper: StepDataHelper, context: WorkflowContext) => void | Promise<void>;
|
|
231
315
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
readonly
|
|
235
|
-
readonly blockNextIfInvalid?: boolean;
|
|
236
|
-
}
|
|
237
|
-
interface StepConditionalConfig {
|
|
238
|
-
readonly condition: (formData: Record<string, any>, context: WorkflowContext) => boolean;
|
|
239
|
-
readonly action: 'show' | 'hide' | 'skip';
|
|
240
|
-
}
|
|
241
|
-
type CustomStepRenderer = (props: StepConfig) => React.ReactElement;
|
|
242
|
-
interface WorkflowPersistenceData {
|
|
243
|
-
readonly workflowId: string;
|
|
244
|
-
readonly currentStepIndex: number;
|
|
245
|
-
readonly allData: Record<string, any>;
|
|
246
|
-
readonly metadata: {
|
|
247
|
-
readonly timestamp: number;
|
|
248
|
-
readonly version?: string;
|
|
249
|
-
readonly userId?: string;
|
|
250
|
-
readonly sessionId?: string;
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
interface PersistenceAdapter {
|
|
316
|
+
type CustomStepRenderer = (props: StepConfig) => React__default.ReactElement;
|
|
317
|
+
interface WorkflowConfig {
|
|
318
|
+
readonly id: string;
|
|
254
319
|
readonly name: string;
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
interface
|
|
262
|
-
readonly
|
|
263
|
-
readonly
|
|
264
|
-
readonly
|
|
265
|
-
readonly
|
|
266
|
-
readonly saveOnStepChange?: boolean;
|
|
267
|
-
readonly encryptionKey?: string;
|
|
268
|
-
readonly maxRetries?: number;
|
|
269
|
-
readonly retryDelayMs?: number;
|
|
270
|
-
readonly onSave?: (data: WorkflowPersistenceData) => Promise<void> | void;
|
|
271
|
-
readonly onLoad?: (data: WorkflowPersistenceData) => Promise<void> | void;
|
|
272
|
-
readonly onError?: (error: Error, operation: 'save' | 'load' | 'remove') => Promise<void> | void;
|
|
273
|
-
readonly onRetry?: (attempt: number, maxRetries: number, error: Error) => Promise<void> | void;
|
|
320
|
+
readonly description?: string;
|
|
321
|
+
readonly steps: StepConfig[];
|
|
322
|
+
readonly analytics?: WorkflowAnalytics;
|
|
323
|
+
readonly plugins?: WorkflowPlugin[];
|
|
324
|
+
readonly renderConfig?: WorkflowRenderConfig;
|
|
325
|
+
}
|
|
326
|
+
interface WorkflowRenderConfig {
|
|
327
|
+
readonly stepperRenderer?: WorkflowStepperRenderer;
|
|
328
|
+
readonly nextButtonRenderer?: WorkflowNextButtonRenderer;
|
|
329
|
+
readonly previousButtonRenderer?: WorkflowPreviousButtonRenderer;
|
|
330
|
+
readonly skipButtonRenderer?: WorkflowSkipButtonRenderer;
|
|
274
331
|
}
|
|
275
332
|
interface WorkflowAnalytics {
|
|
276
333
|
readonly onWorkflowStart?: (workflowId: string, context: WorkflowContext) => void;
|
|
@@ -279,43 +336,21 @@ interface WorkflowAnalytics {
|
|
|
279
336
|
readonly onStepStart?: (stepId: string, timestamp: number, context: WorkflowContext) => void;
|
|
280
337
|
readonly onStepComplete?: (stepId: string, duration: number, data: any, context: WorkflowContext) => void;
|
|
281
338
|
readonly onStepSkip?: (stepId: string, reason: string, context: WorkflowContext) => void;
|
|
282
|
-
readonly onValidationError?: (stepId: string, errors: ValidationError[], context: WorkflowContext) => void;
|
|
283
339
|
readonly onError?: (error: Error, context: WorkflowContext) => void;
|
|
284
340
|
}
|
|
285
|
-
interface WorkflowHooks {
|
|
286
|
-
readonly onStepChange?: (from: string, to: string, context: WorkflowContext) => void;
|
|
287
|
-
readonly onDataChange?: (data: any, context: WorkflowContext) => void;
|
|
288
|
-
readonly onValidation?: (result: ValidationResult, context: WorkflowContext) => void;
|
|
289
|
-
}
|
|
290
341
|
interface WorkflowPlugin {
|
|
291
342
|
readonly name: string;
|
|
292
343
|
readonly version?: string;
|
|
293
344
|
readonly install: (workflow: any) => void;
|
|
294
|
-
readonly hooks?: WorkflowHooks;
|
|
295
345
|
readonly dependencies?: string[];
|
|
296
346
|
}
|
|
297
|
-
interface
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
readonly completion?: CompletionConfig;
|
|
305
|
-
readonly analytics?: WorkflowAnalytics;
|
|
306
|
-
readonly plugins?: WorkflowPlugin[];
|
|
307
|
-
readonly renderConfig?: WorkflowRenderConfig;
|
|
308
|
-
}
|
|
309
|
-
interface NavigationConfig {
|
|
310
|
-
readonly allowBackNavigation?: boolean;
|
|
311
|
-
readonly allowStepSkipping?: boolean;
|
|
312
|
-
readonly showProgress?: boolean;
|
|
313
|
-
readonly customNavigation?: boolean;
|
|
314
|
-
}
|
|
315
|
-
interface CompletionConfig {
|
|
316
|
-
readonly onComplete?: (formData: Record<string, any>) => void | Promise<void>;
|
|
317
|
-
readonly confirmBeforeSubmit?: boolean;
|
|
318
|
-
readonly customCompletionStep?: any;
|
|
347
|
+
interface WorkflowComponentRendererBaseProps {
|
|
348
|
+
children?: React__default.ReactNode;
|
|
349
|
+
className?: string;
|
|
350
|
+
currentStep: StepConfig;
|
|
351
|
+
stepData: Record<string, any>;
|
|
352
|
+
allData: Record<string, any>;
|
|
353
|
+
context: WorkflowContext;
|
|
319
354
|
}
|
|
320
355
|
interface WorkflowStepperRendererProps {
|
|
321
356
|
readonly steps: StepConfig[];
|
|
@@ -324,96 +359,26 @@ interface WorkflowStepperRendererProps {
|
|
|
324
359
|
readonly onStepClick?: (stepIndex: number) => void;
|
|
325
360
|
readonly className?: string;
|
|
326
361
|
}
|
|
327
|
-
type
|
|
328
|
-
interface WorkflowRenderConfig {
|
|
329
|
-
readonly stepperRenderer?: WorkflowStepperRenderer;
|
|
330
|
-
readonly nextButtonRenderer?: WorkflowNextButtonRenderer;
|
|
331
|
-
readonly previousButtonRenderer?: WorkflowPreviousButtonRenderer;
|
|
332
|
-
readonly skipButtonRenderer?: WorkflowSkipButtonRenderer;
|
|
333
|
-
}
|
|
334
|
-
interface FormRowRendererProps {
|
|
335
|
-
row: FormFieldRow;
|
|
336
|
-
children: React.ReactNode;
|
|
337
|
-
className?: string;
|
|
338
|
-
spacing?: 'tight' | 'normal' | 'loose';
|
|
339
|
-
alignment?: 'start' | 'center' | 'end' | 'stretch';
|
|
340
|
-
}
|
|
341
|
-
interface FormBodyRendererProps {
|
|
342
|
-
formConfig: FormConfiguration;
|
|
343
|
-
children: React.ReactNode;
|
|
344
|
-
className?: string;
|
|
345
|
-
}
|
|
346
|
-
interface FormSubmitButtonRendererProps {
|
|
347
|
-
isSubmitting: boolean;
|
|
348
|
-
isValid: boolean;
|
|
349
|
-
isDirty: boolean;
|
|
350
|
-
onSubmit: () => void;
|
|
351
|
-
className?: string;
|
|
352
|
-
children?: React.ReactNode;
|
|
353
|
-
}
|
|
354
|
-
type FormRowRenderer = (props: FormRowRendererProps) => React.ReactElement;
|
|
355
|
-
type FormBodyRenderer = (props: FormBodyRendererProps) => React.ReactElement;
|
|
356
|
-
type FormSubmitButtonRenderer = (props: FormSubmitButtonRendererProps) => React.ReactElement;
|
|
357
|
-
interface FieldRendererProps {
|
|
358
|
-
children: React.ReactNode;
|
|
359
|
-
id: string;
|
|
360
|
-
error?: ValidationError[];
|
|
361
|
-
touched?: boolean;
|
|
362
|
-
disabled?: boolean;
|
|
363
|
-
isValidating?: boolean;
|
|
364
|
-
[key: string]: any;
|
|
365
|
-
}
|
|
366
|
-
type FieldRenderer = (props: FieldRendererProps) => React.ReactElement;
|
|
367
|
-
interface FormRenderConfig {
|
|
368
|
-
readonly rowRenderer?: FormRowRenderer;
|
|
369
|
-
readonly bodyRenderer?: FormBodyRenderer;
|
|
370
|
-
readonly submitButtonRenderer?: FormSubmitButtonRenderer;
|
|
371
|
-
readonly fieldRenderer?: FieldRenderer;
|
|
372
|
-
}
|
|
373
|
-
interface FormConfiguration<C extends Record<string, any> = Record<string, never>> {
|
|
374
|
-
readonly id: string;
|
|
375
|
-
readonly schema?: any;
|
|
376
|
-
readonly config: ril<C>;
|
|
377
|
-
readonly rows: FormFieldRow[];
|
|
378
|
-
readonly allFields: FormFieldConfig[];
|
|
379
|
-
readonly renderConfig?: FormRenderConfig;
|
|
380
|
-
}
|
|
381
|
-
interface WorkflowNextButtonRendererProps {
|
|
362
|
+
type WorkflowNextButtonRendererProps = WorkflowComponentRendererBaseProps & {
|
|
382
363
|
isLastStep: boolean;
|
|
383
364
|
canGoNext: boolean;
|
|
384
365
|
isSubmitting: boolean;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
children?: React.ReactNode;
|
|
389
|
-
currentStep: StepConfig;
|
|
390
|
-
stepData: Record<string, any>;
|
|
391
|
-
allData: Record<string, any>;
|
|
392
|
-
context: WorkflowContext;
|
|
393
|
-
}
|
|
394
|
-
interface WorkflowPreviousButtonRendererProps {
|
|
366
|
+
onSubmit: (event?: React__default.FormEvent) => void;
|
|
367
|
+
};
|
|
368
|
+
type WorkflowPreviousButtonRendererProps = WorkflowComponentRendererBaseProps & {
|
|
395
369
|
canGoPrevious: boolean;
|
|
396
|
-
onPrevious: (event?:
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
currentStep: StepConfig;
|
|
400
|
-
stepData: Record<string, any>;
|
|
401
|
-
allData: Record<string, any>;
|
|
402
|
-
context: WorkflowContext;
|
|
403
|
-
}
|
|
404
|
-
interface WorkflowSkipButtonRendererProps {
|
|
370
|
+
onPrevious: (event?: React__default.FormEvent) => void;
|
|
371
|
+
};
|
|
372
|
+
type WorkflowSkipButtonRendererProps = WorkflowComponentRendererBaseProps & {
|
|
405
373
|
canSkip: boolean;
|
|
406
|
-
onSkip: (event?:
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
type WorkflowNextButtonRenderer = (props: WorkflowNextButtonRendererProps) => React.ReactElement;
|
|
415
|
-
type WorkflowPreviousButtonRenderer = (props: WorkflowPreviousButtonRendererProps) => React.ReactElement;
|
|
416
|
-
type WorkflowSkipButtonRenderer = (props: WorkflowSkipButtonRendererProps) => React.ReactElement;
|
|
374
|
+
onSkip: (event?: React__default.FormEvent) => void;
|
|
375
|
+
};
|
|
376
|
+
type WorkflowStepperRenderer = RendererChildrenFunction<WorkflowStepperRendererProps>;
|
|
377
|
+
type WorkflowNextButtonRenderer = RendererChildrenFunction<WorkflowNextButtonRendererProps>;
|
|
378
|
+
type WorkflowPreviousButtonRenderer = RendererChildrenFunction<WorkflowPreviousButtonRendererProps>;
|
|
379
|
+
type WorkflowSkipButtonRenderer = RendererChildrenFunction<WorkflowSkipButtonRendererProps>;
|
|
380
|
+
|
|
381
|
+
declare function ComponentRendererWrapper<TProps = any>({ children, renderAs, renderer, name, props: baseProps, }: ComponentRendererWrapperProps<TProps>): React$1.ReactNode;
|
|
417
382
|
|
|
418
383
|
/**
|
|
419
384
|
* Utility for merging partial configurations into existing objects
|
|
@@ -436,26 +401,6 @@ declare class IdGenerator {
|
|
|
436
401
|
next(prefix: string): string;
|
|
437
402
|
reset(prefix?: string): void;
|
|
438
403
|
}
|
|
439
|
-
/**
|
|
440
|
-
* Validation error builder for consistent error handling
|
|
441
|
-
*/
|
|
442
|
-
declare class ValidationErrorBuilder {
|
|
443
|
-
private errors;
|
|
444
|
-
add(code: string, message: string, path?: string[]): this;
|
|
445
|
-
addIf(condition: boolean, code: string, message: string, path?: string[]): this;
|
|
446
|
-
build(): ValidationError[];
|
|
447
|
-
hasErrors(): boolean;
|
|
448
|
-
clear(): this;
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Common validation patterns
|
|
452
|
-
*/
|
|
453
|
-
declare const ValidationPatterns: {
|
|
454
|
-
hasValue: (value: any) => boolean;
|
|
455
|
-
isArray: (value: any) => value is any[];
|
|
456
|
-
arrayMinLength: (value: any[], min: number) => boolean;
|
|
457
|
-
arrayMaxLength: (value: any[], max: number) => boolean;
|
|
458
|
-
};
|
|
459
404
|
/**
|
|
460
405
|
* Polymorphic helper for handling single items or arrays
|
|
461
406
|
*/
|
|
@@ -469,167 +414,416 @@ declare function deepClone<T>(obj: T): T;
|
|
|
469
414
|
*/
|
|
470
415
|
declare function configureObject<T>(target: T, updates: Partial<T>, allowedKeys?: (keyof T)[]): T;
|
|
471
416
|
|
|
417
|
+
declare function resolveRendererChildren<TProps>(children: React.ReactNode | RendererChildrenFunction<TProps> | undefined, props: TProps): React.ReactNode;
|
|
418
|
+
|
|
472
419
|
/**
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
420
|
+
* @fileoverview Validation utilities
|
|
421
|
+
*
|
|
422
|
+
* This module provides utility functions for working with validation results,
|
|
423
|
+
* combining validators, and managing validation contexts.
|
|
476
424
|
*/
|
|
477
|
-
|
|
425
|
+
|
|
478
426
|
/**
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
* @
|
|
427
|
+
* Creates a validation result object
|
|
428
|
+
*
|
|
429
|
+
* @param isValid - Whether the validation passed
|
|
430
|
+
* @param errors - Array of validation errors (empty if valid)
|
|
431
|
+
* @returns A complete ValidationResult object
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* ```typescript
|
|
435
|
+
* const result = createValidationResult(false, [
|
|
436
|
+
* { message: 'Email is required', code: 'REQUIRED' }
|
|
437
|
+
* ]);
|
|
438
|
+
* ```
|
|
482
439
|
*/
|
|
483
|
-
declare
|
|
440
|
+
declare function createValidationResult(isValid: boolean, errors?: ValidationError[]): ValidationResult;
|
|
484
441
|
/**
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
442
|
+
* Combines multiple validation results into a single result
|
|
443
|
+
*
|
|
444
|
+
* The combined result is valid only if all input results are valid.
|
|
445
|
+
* All errors from all results are included in the combined result.
|
|
446
|
+
*
|
|
447
|
+
* @param results - Array of ValidationResult objects to combine
|
|
448
|
+
* @returns A single ValidationResult combining all inputs
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```typescript
|
|
452
|
+
* const combined = combineValidationResults([
|
|
453
|
+
* emailValidator(value),
|
|
454
|
+
* requiredValidator(value),
|
|
455
|
+
* minLengthValidator(value)
|
|
456
|
+
* ]);
|
|
457
|
+
* ```
|
|
489
458
|
*/
|
|
490
|
-
declare
|
|
459
|
+
declare function combineValidationResults(results: ValidationResult[]): ValidationResult;
|
|
491
460
|
/**
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
* @param
|
|
495
|
-
* @
|
|
461
|
+
* Runs multiple synchronous validators and combines their results
|
|
462
|
+
*
|
|
463
|
+
* @param validators - Array of validators to run
|
|
464
|
+
* @param value - The value to validate
|
|
465
|
+
* @param context - Validation context
|
|
466
|
+
* @returns Combined validation result
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```typescript
|
|
470
|
+
* const result = runValidators([
|
|
471
|
+
* required,
|
|
472
|
+
* email,
|
|
473
|
+
* minLength(5)
|
|
474
|
+
* ], emailValue, context);
|
|
475
|
+
* ```
|
|
496
476
|
*/
|
|
497
|
-
declare
|
|
477
|
+
declare function runValidators<T>(validators: FieldValidator<T>[], value: T, context: ValidationContext): ValidationResult;
|
|
498
478
|
/**
|
|
499
|
-
*
|
|
479
|
+
* Runs multiple asynchronous validators and combines their results
|
|
480
|
+
*
|
|
481
|
+
* @param validators - Array of validators to run (can be sync or async)
|
|
482
|
+
* @param value - The value to validate
|
|
483
|
+
* @param context - Validation context
|
|
484
|
+
* @returns Promise resolving to combined validation result
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* ```typescript
|
|
488
|
+
* const result = await runValidatorsAsync([
|
|
489
|
+
* required,
|
|
490
|
+
* email,
|
|
491
|
+
* checkEmailUnique // async validator
|
|
492
|
+
* ], emailValue, context);
|
|
493
|
+
* ```
|
|
500
494
|
*/
|
|
501
|
-
declare
|
|
502
|
-
/**
|
|
503
|
-
* Required field validator
|
|
504
|
-
*/
|
|
505
|
-
required: (message?: string) => ValidatorFunction;
|
|
506
|
-
/**
|
|
507
|
-
* Email validation
|
|
508
|
-
*/
|
|
509
|
-
email: (message?: string) => ValidatorFunction;
|
|
510
|
-
/**
|
|
511
|
-
* Minimum length validation
|
|
512
|
-
*/
|
|
513
|
-
minLength: (min: number, message?: string) => ValidatorFunction;
|
|
514
|
-
/**
|
|
515
|
-
* Maximum length validation
|
|
516
|
-
*/
|
|
517
|
-
maxLength: (max: number, message?: string) => ValidatorFunction;
|
|
518
|
-
/**
|
|
519
|
-
* Pattern/regex validation
|
|
520
|
-
*/
|
|
521
|
-
pattern: (regex: RegExp, message?: string) => ValidatorFunction;
|
|
522
|
-
/**
|
|
523
|
-
* Number range validation
|
|
524
|
-
*/
|
|
525
|
-
numberRange: (min?: number, max?: number, message?: string) => ValidatorFunction;
|
|
526
|
-
/**
|
|
527
|
-
* URL validation
|
|
528
|
-
*/
|
|
529
|
-
url: (message?: string) => ValidatorFunction;
|
|
530
|
-
/**
|
|
531
|
-
* Phone number validation (basic)
|
|
532
|
-
*/
|
|
533
|
-
phoneNumber: (message?: string) => ValidatorFunction;
|
|
534
|
-
/**
|
|
535
|
-
* Custom async validation with debouncing
|
|
536
|
-
*/
|
|
537
|
-
asyncValidation: (asyncFn: (value: any, context: ValidationContext) => Promise<boolean | string>, debounceMs?: number) => ValidatorFunction;
|
|
538
|
-
};
|
|
495
|
+
declare function runValidatorsAsync<T>(validators: FieldValidator<T>[], value: T, context: ValidationContext): Promise<ValidationResult>;
|
|
539
496
|
/**
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
* @param
|
|
543
|
-
* @returns
|
|
497
|
+
* Creates a validation context object
|
|
498
|
+
*
|
|
499
|
+
* @param options - Context configuration options
|
|
500
|
+
* @returns A complete ValidationContext object
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* ```typescript
|
|
504
|
+
* const context = createValidationContext({
|
|
505
|
+
* fieldId: 'email',
|
|
506
|
+
* formId: 'registration',
|
|
507
|
+
* allFormData: { email: 'test@example.com', name: 'John' }
|
|
508
|
+
* });
|
|
509
|
+
* ```
|
|
544
510
|
*/
|
|
545
|
-
declare
|
|
511
|
+
declare function createValidationContext(options?: Partial<ValidationContext>): ValidationContext;
|
|
512
|
+
|
|
546
513
|
/**
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
514
|
+
* @fileoverview Built-in validators
|
|
515
|
+
*
|
|
516
|
+
* This module provides a comprehensive set of built-in validators for common
|
|
517
|
+
* validation scenarios. These validators follow the FieldValidator interface
|
|
518
|
+
* and can be used standalone or combined with other validators.
|
|
552
519
|
*/
|
|
553
|
-
declare const createValidationError: (code: string, message: string, path?: string[]) => ValidationError;
|
|
554
520
|
|
|
555
521
|
/**
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* SessionStorage persistence adapter
|
|
569
|
-
* Perfect for temporary persistence within a single browser session
|
|
570
|
-
*/
|
|
571
|
-
declare class SessionStorageAdapter implements PersistenceAdapter {
|
|
572
|
-
readonly name = "sessionStorage";
|
|
573
|
-
save(key: string, data: WorkflowPersistenceData): Promise<void>;
|
|
574
|
-
load(key: string): Promise<WorkflowPersistenceData | null>;
|
|
575
|
-
remove(key: string): Promise<void>;
|
|
576
|
-
exists(key: string): Promise<boolean>;
|
|
577
|
-
list(pattern?: string): Promise<string[]>;
|
|
578
|
-
}
|
|
579
|
-
/**
|
|
580
|
-
* In-Memory persistence adapter
|
|
581
|
-
* Perfect for testing or temporary workflows
|
|
582
|
-
*/
|
|
583
|
-
declare class MemoryAdapter implements PersistenceAdapter {
|
|
584
|
-
readonly name = "memory";
|
|
585
|
-
private storage;
|
|
586
|
-
save(key: string, data: WorkflowPersistenceData): Promise<void>;
|
|
587
|
-
load(key: string): Promise<WorkflowPersistenceData | null>;
|
|
588
|
-
remove(key: string): Promise<void>;
|
|
589
|
-
exists(key: string): Promise<boolean>;
|
|
590
|
-
list(pattern?: string): Promise<string[]>;
|
|
591
|
-
clear(): void;
|
|
592
|
-
}
|
|
522
|
+
* Validates that a value is not empty, null, or undefined
|
|
523
|
+
*
|
|
524
|
+
* @param message - Custom error message (optional)
|
|
525
|
+
* @returns A FieldValidator function
|
|
526
|
+
*
|
|
527
|
+
* @example
|
|
528
|
+
* ```typescript
|
|
529
|
+
* const nameValidator = required('Name is required');
|
|
530
|
+
* ```
|
|
531
|
+
*/
|
|
532
|
+
declare function required(message?: string): FieldValidator;
|
|
593
533
|
/**
|
|
594
|
-
*
|
|
595
|
-
*
|
|
534
|
+
* Validates minimum string length
|
|
535
|
+
*
|
|
536
|
+
* @param min - Minimum length required
|
|
537
|
+
* @param message - Custom error message (optional)
|
|
538
|
+
* @returns A FieldValidator function
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```typescript
|
|
542
|
+
* const passwordValidator = minLength(8, 'Password must be at least 8 characters');
|
|
543
|
+
* ```
|
|
596
544
|
*/
|
|
597
|
-
declare
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
545
|
+
declare function minLength(min: number, message?: string): FieldValidator<string>;
|
|
546
|
+
/**
|
|
547
|
+
* Validates maximum string length
|
|
548
|
+
*
|
|
549
|
+
* @param max - Maximum length allowed
|
|
550
|
+
* @param message - Custom error message (optional)
|
|
551
|
+
* @returns A FieldValidator function
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```typescript
|
|
555
|
+
* const bioValidator = maxLength(500, 'Bio must be under 500 characters');
|
|
556
|
+
* ```
|
|
557
|
+
*/
|
|
558
|
+
declare function maxLength(max: number, message?: string): FieldValidator<string>;
|
|
559
|
+
/**
|
|
560
|
+
* Validates that a string matches a regular expression pattern
|
|
561
|
+
*
|
|
562
|
+
* @param regex - The regular expression pattern
|
|
563
|
+
* @param message - Custom error message (optional)
|
|
564
|
+
* @returns A FieldValidator function
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* ```typescript
|
|
568
|
+
* const phoneValidator = pattern(/^\d{3}-\d{3}-\d{4}$/, 'Invalid phone format');
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
571
|
+
declare function pattern(regex: RegExp, message?: string): FieldValidator<string>;
|
|
572
|
+
/**
|
|
573
|
+
* Email validation using a comprehensive regex pattern
|
|
574
|
+
*
|
|
575
|
+
* @param message - Custom error message (optional)
|
|
576
|
+
* @returns A FieldValidator function
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* ```typescript
|
|
580
|
+
* const emailValidator = email('Please enter a valid email address');
|
|
581
|
+
* ```
|
|
582
|
+
*/
|
|
583
|
+
declare function email(message?: string): FieldValidator<string>;
|
|
584
|
+
/**
|
|
585
|
+
* URL validation using a comprehensive regex pattern
|
|
586
|
+
*
|
|
587
|
+
* @param message - Custom error message (optional)
|
|
588
|
+
* @returns A FieldValidator function
|
|
589
|
+
*
|
|
590
|
+
* @example
|
|
591
|
+
* ```typescript
|
|
592
|
+
* const websiteValidator = url('Please enter a valid URL');
|
|
593
|
+
* ```
|
|
594
|
+
*/
|
|
595
|
+
declare function url(message?: string): FieldValidator<string>;
|
|
596
|
+
/**
|
|
597
|
+
* Validates that a value is a valid number
|
|
598
|
+
*
|
|
599
|
+
* @param message - Custom error message (optional)
|
|
600
|
+
* @returns A FieldValidator function
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* ```typescript
|
|
604
|
+
* const ageValidator = number('Age must be a valid number');
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
declare function number(message?: string): FieldValidator<string | number>;
|
|
608
|
+
/**
|
|
609
|
+
* Validates minimum numeric value
|
|
610
|
+
*
|
|
611
|
+
* @param minValue - Minimum value allowed
|
|
612
|
+
* @param message - Custom error message (optional)
|
|
613
|
+
* @returns A FieldValidator function
|
|
614
|
+
*
|
|
615
|
+
* @example
|
|
616
|
+
* ```typescript
|
|
617
|
+
* const ageValidator = min(18, 'Must be at least 18 years old');
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
declare function min(minValue: number, message?: string): FieldValidator<string | number>;
|
|
621
|
+
/**
|
|
622
|
+
* Validates maximum numeric value
|
|
623
|
+
*
|
|
624
|
+
* @param maxValue - Maximum value allowed
|
|
625
|
+
* @param message - Custom error message (optional)
|
|
626
|
+
* @returns A FieldValidator function
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* ```typescript
|
|
630
|
+
* const scoreValidator = max(100, 'Score cannot exceed 100');
|
|
631
|
+
* ```
|
|
632
|
+
*/
|
|
633
|
+
declare function max(maxValue: number, message?: string): FieldValidator<string | number>;
|
|
634
|
+
/**
|
|
635
|
+
* Creates a custom validator from a validation function
|
|
636
|
+
*
|
|
637
|
+
* @param validateFn - Custom validation function
|
|
638
|
+
* @param message - Error message for failed validation
|
|
639
|
+
* @param code - Optional error code
|
|
640
|
+
* @returns A FieldValidator function
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* ```typescript
|
|
644
|
+
* const evenNumberValidator = custom(
|
|
645
|
+
* (value) => Number(value) % 2 === 0,
|
|
646
|
+
* 'Number must be even',
|
|
647
|
+
* 'NOT_EVEN'
|
|
648
|
+
* );
|
|
649
|
+
* ```
|
|
650
|
+
*/
|
|
651
|
+
declare function custom<T>(validateFn: (value: T, context: ValidationContext) => boolean, message: string, code?: string): FieldValidator<T>;
|
|
652
|
+
/**
|
|
653
|
+
* Creates a validator that checks if a value matches another field's value
|
|
654
|
+
*
|
|
655
|
+
* @param targetFieldId - ID of the field to match against
|
|
656
|
+
* @param message - Custom error message (optional)
|
|
657
|
+
* @returns A FieldValidator function
|
|
658
|
+
*
|
|
659
|
+
* @example
|
|
660
|
+
* ```typescript
|
|
661
|
+
* const confirmPasswordValidator = matchField('password', 'Passwords must match');
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
664
|
+
declare function matchField(targetFieldId: string, message?: string): FieldValidator;
|
|
665
|
+
/**
|
|
666
|
+
* Creates a validator that only validates when a condition is met
|
|
667
|
+
*
|
|
668
|
+
* @param condition - Function that determines if validation should run
|
|
669
|
+
* @param validator - The validator to run conditionally
|
|
670
|
+
* @returns A FieldValidator function
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* ```typescript
|
|
674
|
+
* const conditionalValidator = when(
|
|
675
|
+
* (value, context) => context.allFormData?.userType === 'premium',
|
|
676
|
+
* required('Premium users must provide this field')
|
|
677
|
+
* );
|
|
678
|
+
* ```
|
|
679
|
+
*/
|
|
680
|
+
declare function when<T>(condition: (value: T, context: ValidationContext) => boolean, validator: FieldValidator<T>): FieldValidator<T>;
|
|
681
|
+
/**
|
|
682
|
+
* Creates an async custom validator from a validation function
|
|
683
|
+
*
|
|
684
|
+
* @param validateFn - Async custom validation function that returns a Promise<boolean>
|
|
685
|
+
* @param message - Error message for failed validation
|
|
686
|
+
* @param code - Optional error code
|
|
687
|
+
* @returns A FieldValidator function that returns a Promise
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```typescript
|
|
691
|
+
* const checkEmailUnique = customAsync(
|
|
692
|
+
* async (email) => {
|
|
693
|
+
* const response = await fetch(`/api/check-email?email=${email}`);
|
|
694
|
+
* const data = await response.json();
|
|
695
|
+
* return data.isUnique;
|
|
696
|
+
* },
|
|
697
|
+
* 'Email address is already taken',
|
|
698
|
+
* 'EMAIL_NOT_UNIQUE'
|
|
699
|
+
* );
|
|
700
|
+
* ```
|
|
701
|
+
*/
|
|
702
|
+
declare function async<T>(validateFn: (value: T, context: ValidationContext) => Promise<boolean>, message: string, code?: string): FieldValidator<T>;
|
|
608
703
|
|
|
609
704
|
/**
|
|
610
|
-
*
|
|
705
|
+
* @fileoverview Validation adapters for popular validation libraries
|
|
706
|
+
*
|
|
707
|
+
* This module provides adapters that integrate popular validation libraries
|
|
708
|
+
* like Zod with Rilay's validation system. Adapters convert external schemas
|
|
709
|
+
* into Rilay validators while maintaining type safety and error handling.
|
|
611
710
|
*/
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Generic schema interface that Zod and similar libraries implement
|
|
714
|
+
*/
|
|
715
|
+
interface ZodLikeSchema<T = any> {
|
|
716
|
+
parse(value: unknown): T;
|
|
717
|
+
safeParse(value: unknown): {
|
|
718
|
+
success: true;
|
|
719
|
+
data: T;
|
|
720
|
+
} | {
|
|
721
|
+
success: false;
|
|
722
|
+
error: {
|
|
723
|
+
errors: Array<{
|
|
724
|
+
message: string;
|
|
725
|
+
path: (string | number)[];
|
|
726
|
+
}>;
|
|
727
|
+
};
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Zod validation adapter that converts Zod schemas into Rilay validators
|
|
732
|
+
*
|
|
733
|
+
* This adapter provides seamless integration with Zod schemas, automatically
|
|
734
|
+
* converting Zod validation errors into Rilay ValidationError objects while
|
|
735
|
+
* preserving error messages and field paths.
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* ```typescript
|
|
739
|
+
* import { z } from 'zod';
|
|
740
|
+
* import { createZodAdapter } from '@rilaykit/core';
|
|
741
|
+
*
|
|
742
|
+
* const zodAdapter = createZodAdapter();
|
|
743
|
+
* const emailValidator = zodAdapter.createFieldValidator(
|
|
744
|
+
* z.string().email('Invalid email format')
|
|
745
|
+
* );
|
|
746
|
+
* ```
|
|
747
|
+
*/
|
|
748
|
+
declare class ZodValidationAdapter implements ValidationAdapter<ZodLikeSchema> {
|
|
749
|
+
readonly name = "ZodValidationAdapter";
|
|
750
|
+
readonly version = "1.0.0";
|
|
621
751
|
/**
|
|
622
|
-
*
|
|
752
|
+
* Creates a field validator from a Zod schema
|
|
753
|
+
*
|
|
754
|
+
* @param schema - The Zod schema to convert
|
|
755
|
+
* @returns A FieldValidator function compatible with Rilay
|
|
756
|
+
*
|
|
757
|
+
* @example
|
|
758
|
+
* ```typescript
|
|
759
|
+
* const emailSchema = z.string().email();
|
|
760
|
+
* const validator = adapter.createFieldValidator(emailSchema);
|
|
761
|
+
* ```
|
|
623
762
|
*/
|
|
624
|
-
|
|
763
|
+
createFieldValidator<T>(schema: ZodLikeSchema<T>): FieldValidator<T>;
|
|
625
764
|
/**
|
|
626
|
-
*
|
|
765
|
+
* Creates a form validator from a Zod object schema
|
|
766
|
+
*
|
|
767
|
+
* @param schema - The Zod object schema to convert
|
|
768
|
+
* @returns A FormValidator function compatible with Rilay
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```typescript
|
|
772
|
+
* const formSchema = z.object({
|
|
773
|
+
* email: z.string().email(),
|
|
774
|
+
* password: z.string().min(8)
|
|
775
|
+
* });
|
|
776
|
+
* const validator = adapter.createFormValidator(formSchema);
|
|
777
|
+
* ```
|
|
627
778
|
*/
|
|
628
|
-
|
|
629
|
-
}
|
|
779
|
+
createFormValidator<T>(schema: ZodLikeSchema<T>): FormValidator<T>;
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Creates a new Zod validation adapter instance
|
|
783
|
+
*
|
|
784
|
+
* @returns A configured ZodValidationAdapter instance
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* ```typescript
|
|
788
|
+
* const adapter = createZodAdapter();
|
|
789
|
+
* ```
|
|
790
|
+
*/
|
|
791
|
+
declare function createZodAdapter(): ZodValidationAdapter;
|
|
792
|
+
/**
|
|
793
|
+
* Helper function to create a field validator directly from a Zod schema
|
|
794
|
+
*
|
|
795
|
+
* This is a convenience function that creates an adapter and field validator
|
|
796
|
+
* in a single call, useful for simple use cases.
|
|
797
|
+
*
|
|
798
|
+
* @param schema - The Zod schema to convert
|
|
799
|
+
* @returns A FieldValidator function
|
|
800
|
+
*
|
|
801
|
+
* @example
|
|
802
|
+
* ```typescript
|
|
803
|
+
* import { z } from 'zod';
|
|
804
|
+
* import { zodFieldValidator } from '@rilaykit/core';
|
|
805
|
+
*
|
|
806
|
+
* const emailValidator = zodFieldValidator(z.string().email());
|
|
807
|
+
* ```
|
|
808
|
+
*/
|
|
809
|
+
declare function zodFieldValidator<T>(schema: ZodLikeSchema<T>): FieldValidator<T>;
|
|
630
810
|
/**
|
|
631
|
-
*
|
|
811
|
+
* Helper function to create a form validator directly from a Zod schema
|
|
812
|
+
*
|
|
813
|
+
* @param schema - The Zod object schema to convert
|
|
814
|
+
* @returns A FormValidator function
|
|
815
|
+
*
|
|
816
|
+
* @example
|
|
817
|
+
* ```typescript
|
|
818
|
+
* import { z } from 'zod';
|
|
819
|
+
* import { zodFormValidator } from '@rilaykit/core';
|
|
820
|
+
*
|
|
821
|
+
* const formValidator = zodFormValidator(z.object({
|
|
822
|
+
* email: z.string().email(),
|
|
823
|
+
* password: z.string().min(8)
|
|
824
|
+
* }));
|
|
825
|
+
* ```
|
|
632
826
|
*/
|
|
633
|
-
declare function
|
|
827
|
+
declare function zodFormValidator<T>(schema: ZodLikeSchema<T>): FormValidator<T>;
|
|
634
828
|
|
|
635
|
-
export { type
|
|
829
|
+
export { type ComponentConfig, type ComponentRenderProps, type ComponentRenderer, type ComponentRendererBaseProps, ComponentRendererWrapper, type ComponentRendererWrapperProps, type CustomStepRenderer, type FieldRenderer, type FieldRendererProps, type FieldValidationConfig, type FieldValidator, type FormBodyRenderer, type FormBodyRendererProps, type FormComponentRendererProps, type FormConfiguration, type FormFieldConfig, type FormFieldRow, type FormRenderConfig, type FormRowRenderer, type FormRowRendererProps, type FormSubmitButtonRenderer, type FormSubmitButtonRendererProps, type FormValidationConfig, type FormValidator, IdGenerator, type RendererChildrenFunction, type RilayLicenseConfig, type StepConfig, type StepDataHelper, type ValidationAdapter, type ValidationContext, type ValidationError, type ValidationResult, type ValidationSchema, type WorkflowAnalytics, type WorkflowComponentRendererBaseProps, type WorkflowConfig, type WorkflowContext, type WorkflowNextButtonRenderer, type WorkflowNextButtonRendererProps, type WorkflowPlugin, type WorkflowPreviousButtonRenderer, type WorkflowPreviousButtonRendererProps, type WorkflowRenderConfig, type WorkflowSkipButtonRenderer, type WorkflowSkipButtonRendererProps, type WorkflowStepperRenderer, type WorkflowStepperRendererProps, async, combineValidationResults, configureObject, createValidationContext, createValidationResult, createZodAdapter, custom, deepClone, email, ensureUnique, matchField, max, maxLength, mergeInto, min, minLength, normalizeToArray, number, pattern, required, resolveRendererChildren, ril, runValidators, runValidatorsAsync, url, validateRequired, when, zodFieldValidator, zodFormValidator };
|