@isettingkit/business-rules 2.2.14 → 2.2.16

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.
@@ -1,5 +1,5 @@
1
1
  import { IButton } from '@inubekit/inubekit';
2
- import { ICondition } from '@isettingkit/input';
2
+ import { ICondition as ICondition_2 } from '@isettingkit/input';
3
3
  import { IDecision } from '@isettingkit/input';
4
4
  import { IOption } from '@inubekit/inubekit';
5
5
  import { IRuleDecision } from '@isettingkit/input';
@@ -80,7 +80,7 @@ export declare const formatDecisionForBackend: (props: {
80
80
  businessRuleId?: string;
81
81
  conditionDataType?: ValueDataType[keyof ValueDataType];
82
82
  conditionName?: string;
83
- conditionGroups?: ICondition[];
83
+ conditionGroups?: ICondition_2[];
84
84
  decision?: IDecision;
85
85
  decisions?: IDecision[];
86
86
  decisionDataType?: ValueDataType[keyof ValueDataType];
@@ -107,6 +107,20 @@ export declare const groupsRecordToArrayNew: (record: Record<string, any[]>) =>
107
107
  conditionsThatEstablishesTheDecision: any[];
108
108
  }[];
109
109
 
110
+ declare interface IAttributesGridItem<TData> {
111
+ id: string;
112
+ label: string;
113
+ render?: (value: unknown, ctx: IRenderCtx<TData>) => React.ReactNode;
114
+ value: IPath<TData>;
115
+ withTag?: boolean;
116
+ }
117
+
118
+ declare interface IAttributesGridNode<TData> extends INodeBase<TData> {
119
+ items: IAttributesGridItem<TData>[];
120
+ layout?: ILayout;
121
+ type: "attributesGrid";
122
+ }
123
+
110
124
  export declare interface IBackAndNextButton extends Omit<IButton, "onClick" | "path" | "children"> {
111
125
  handleBack: () => void;
112
126
  handleNext: () => void;
@@ -219,6 +233,10 @@ export declare interface ICheckpickerField {
219
233
 
220
234
  export declare type IClientLabel = string;
221
235
 
236
+ export declare interface ICondition<TData> {
237
+ (data: TData): boolean;
238
+ }
239
+
222
240
  export declare interface IDragAndDropBoxes {
223
241
  group?: string;
224
242
  left: IDragAndDropColumn;
@@ -259,6 +277,7 @@ export declare interface IDropdownMenu {
259
277
  headerPath?: string;
260
278
  links: TLinkItem[];
261
279
  onClick: () => void;
280
+ onBeforeNavigate?: (to: string, link: TLinkItem) => Promise<boolean> | boolean;
262
281
  title: string;
263
282
  activeId?: string;
264
283
  }
@@ -267,6 +286,7 @@ export declare interface IDropdownMenuContainer {
267
286
  collapseOnNavigate?: boolean;
268
287
  defaultOpenId?: string | null;
269
288
  groups: IDropdownMenuGroup[];
289
+ onBeforeNavigate?: (to: string, link: TLinkItem) => Promise<boolean> | boolean;
270
290
  }
271
291
 
272
292
  export declare interface IDropdownMenuGroup {
@@ -276,6 +296,15 @@ export declare interface IDropdownMenuGroup {
276
296
  path?: string;
277
297
  }
278
298
 
299
+ declare interface IEntriesGridNode<TData, TEntry> extends INodeBase<TData> {
300
+ entries: IPath<TData>;
301
+ keyOf: (entry: TEntry) => string;
302
+ labelOf: (entry: TEntry) => string;
303
+ layout?: ILayout;
304
+ type: "entriesGrid";
305
+ valueOf: (entry: TEntry) => string;
306
+ }
307
+
279
308
  export declare interface IFilter {
280
309
  appliedFilters?: IFilterTag[];
281
310
  onClear: () => void;
@@ -300,6 +329,25 @@ export declare interface IFormFilter {
300
329
  noFiltersLabel?: string;
301
330
  }
302
331
 
332
+ declare interface IGroupNode<TData> extends INodeBase<TData> {
333
+ children: Array<TSchemaNode<TData, any>>;
334
+ type: "group";
335
+ }
336
+
337
+ declare interface IJsonNode<TData> extends INodeBase<TData> {
338
+ type: "json";
339
+ value: IPath<TData>;
340
+ }
341
+
342
+ declare interface ILayout {
343
+ columns?: {
344
+ desktop: string;
345
+ mobile: string;
346
+ };
347
+ gapToken?: string;
348
+ variant?: "lightCard" | "none";
349
+ }
350
+
303
351
  declare type IListSide = "left" | "right";
304
352
 
305
353
  declare interface IModalRules {
@@ -310,6 +358,27 @@ declare interface IModalRules {
310
358
  description?: string;
311
359
  }
312
360
 
361
+ declare interface INodeBase<TData> {
362
+ id: string;
363
+ when?: ICondition<TData>;
364
+ }
365
+
366
+ export declare type IPath<TData> = string | IPathFn<TData>;
367
+
368
+ declare interface IPathFn<TData> {
369
+ (data: TData): unknown;
370
+ }
371
+
372
+ export declare interface IRenderCtx<TData> {
373
+ data: TData;
374
+ isMobile: boolean;
375
+ isTablet: boolean;
376
+ }
377
+
378
+ declare interface IRenderer<TData> {
379
+ (node: TSchemaNode<TData, any>, ctx: IRenderCtx<TData>): React.ReactNode;
380
+ }
381
+
313
382
  declare interface IRevertSortedData {
314
383
  decisionTemplate?: IRuleDecision;
315
384
  dataDecision?: IRuleDecision;
@@ -381,11 +450,32 @@ declare interface IRulesFormTextValues_3 {
381
450
  validUntil?: string;
382
451
  }
383
452
 
453
+ export declare interface IStepSchema<TData> {
454
+ id: string;
455
+ name: string;
456
+ nodes: Array<TSchemaNode<TData, any>>;
457
+ onBack?: (ctx: {
458
+ stepId: string;
459
+ }) => void;
460
+ }
461
+
384
462
  declare interface ITranslateOptions {
385
463
  url: string;
386
464
  apiKey: string;
387
465
  }
388
466
 
467
+ declare interface IVerificationEngine<TData> {
468
+ data: TData;
469
+ isMobile: boolean;
470
+ isTablet: boolean;
471
+ onBackStep?: (stepId: string) => void;
472
+ schema?: IVerificationSchema<TData>;
473
+ }
474
+
475
+ export declare interface IVerificationSchema<TData> {
476
+ steps: IStepSchema<TData>[];
477
+ }
478
+
389
479
  export declare const mapByGroupNew: (raw: any, mapFn: (condition: any) => any) => Record<string, any[]>;
390
480
 
391
481
  export declare const ModalRules: (props: IModalRules) => ReactPortal;
@@ -398,11 +488,11 @@ export declare const parseRangeFromString: (value: string | number | string[] |
398
488
  } | undefined;
399
489
 
400
490
  export declare const revertSortedDataSampleSwitchPlaces: (props: IRevertSortedData) => {
401
- conditionsThatEstablishesTheDecision: ICondition[];
491
+ conditionsThatEstablishesTheDecision: ICondition_2[];
402
492
  businessRuleId?: string;
403
493
  conditionDataType?: ValueDataType[keyof ValueDataType];
404
494
  conditionName?: string;
405
- conditionGroups?: ICondition[];
495
+ conditionGroups?: ICondition_2[];
406
496
  decision?: IDecision;
407
497
  decisions?: IDecision[];
408
498
  decisionDataType?: ValueDataType[keyof ValueDataType];
@@ -432,8 +522,8 @@ export declare const sortDisplayDataSampleSwitchPlaces: (props: IRevertSortedDat
432
522
  businessRuleId?: string;
433
523
  conditionDataType?: ValueDataType[keyof ValueDataType];
434
524
  conditionName?: string;
435
- conditionGroups?: ICondition[];
436
- conditionsThatEstablishesTheDecision?: ICondition[];
525
+ conditionGroups?: ICondition_2[];
526
+ conditionsThatEstablishesTheDecision?: ICondition_2[];
437
527
  decision?: IDecision;
438
528
  decisions?: IDecision[];
439
529
  decisionDataType?: ValueDataType[keyof ValueDataType];
@@ -465,4 +555,10 @@ export declare const translateObject: (data: Record<string, any>, targetLang: st
465
555
 
466
556
  export declare const translateText: (text: string, targetLang: string, { url, apiKey }: ITranslateOptions) => Promise<string>;
467
557
 
558
+ export declare type TRegistry<TData> = Record<TSchemaNode<TData, any>["type"], IRenderer<TData>>;
559
+
560
+ export declare type TSchemaNode<TData, TEntry> = IAttributesGridNode<TData> | IEntriesGridNode<TData, TEntry> | IGroupNode<TData> | IJsonNode<TData>;
561
+
562
+ export declare function Verification<TData>(props: IVerificationEngine<TData>): JSX.Element;
563
+
468
564
  export { }