@masterteam/components 0.0.91 → 0.0.93

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.
@@ -0,0 +1,114 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { ControlValueAccessor, Validators, NgControl } from '@angular/forms';
3
+ import { HttpContext } from '@angular/common/http';
4
+
5
+ /**
6
+ * One source level inside connection configuration.
7
+ * Comes from `field.propertyMetadata.configuration.sourceLevels[]`
8
+ */
9
+ interface ConnectionSourceLevel {
10
+ levelId: number;
11
+ levelKey: string;
12
+ name: {
13
+ en?: string;
14
+ ar?: string;
15
+ [k: string]: string | undefined;
16
+ };
17
+ connectionId: number;
18
+ isOptional: boolean;
19
+ allowManyToMany: boolean;
20
+ supportWeights: boolean;
21
+ optionsQuery: {
22
+ path: string;
23
+ method?: string;
24
+ query?: Record<string, any>;
25
+ };
26
+ }
27
+ /**
28
+ * Full connection configuration from `field.propertyMetadata.configuration`.
29
+ * This is passed as a single input to the component.
30
+ */
31
+ interface SchemaConnectionConfig {
32
+ targetLevelId: number;
33
+ sourceLevelId?: number;
34
+ propertyKey?: string;
35
+ valueMode?: string;
36
+ sourceLevels: ConnectionSourceLevel[];
37
+ payloadTemplate?: {
38
+ levelId: number;
39
+ sources: any[];
40
+ };
41
+ sourceItemShape?: Record<string, string>;
42
+ }
43
+ /** One selected source in the connection payload */
44
+ interface ConnectionSource {
45
+ sourceLevelId: number;
46
+ sourceLevelDataId: number;
47
+ }
48
+ /** The value shape for a connection field */
49
+ interface ConnectionPayload {
50
+ levelId: number;
51
+ sources: ConnectionSource[];
52
+ }
53
+ /**
54
+ * Internal state tracked per source level dropdown.
55
+ */
56
+ interface SourceLevelState {
57
+ source: ConnectionSourceLevel;
58
+ options: any[];
59
+ loading: boolean;
60
+ }
61
+ declare class SchemaConnectionField implements ControlValueAccessor {
62
+ readonly label: _angular_core.InputSignal<string>;
63
+ readonly placeholder: _angular_core.InputSignal<string>;
64
+ readonly readonly: _angular_core.InputSignal<boolean>;
65
+ readonly required: _angular_core.InputSignal<boolean>;
66
+ readonly filter: _angular_core.InputSignal<boolean>;
67
+ /**
68
+ * Full connection configuration object from the API.
69
+ * Includes `targetLevelId`, `sourceLevels[]`, `payloadTemplate`, etc.
70
+ */
71
+ readonly configuration: _angular_core.InputSignal<SchemaConnectionConfig>;
72
+ /**
73
+ * Optional HttpContext for API requests (e.g. to set base URL behavior).
74
+ */
75
+ readonly context: _angular_core.InputSignal<HttpContext | undefined>;
76
+ /** The full ConnectionPayload value */
77
+ value: _angular_core.WritableSignal<ConnectionPayload | null>;
78
+ disabled: _angular_core.WritableSignal<boolean>;
79
+ /** Per-source-level state: options + loading */
80
+ sourceLevelStates: _angular_core.WritableSignal<SourceLevelState[]>;
81
+ /** Mutable selections per source level: sourceLevelId -> selected value */
82
+ selections: Record<number, any>;
83
+ requiredValidator: typeof Validators.required;
84
+ onTouched: () => void;
85
+ onModelChange: (value: ConnectionPayload | null) => void;
86
+ ngControl: NgControl | null;
87
+ private http;
88
+ private destroyRef;
89
+ /**
90
+ * Source levels from configuration.
91
+ */
92
+ readonly sourceLevels: _angular_core.Signal<ConnectionSourceLevel[]>;
93
+ /**
94
+ * Percentage width for each dropdown, evenly divided.
95
+ */
96
+ readonly dropdownWidth: _angular_core.Signal<string>;
97
+ constructor();
98
+ private loadOptions;
99
+ private updateSourceState;
100
+ /**
101
+ * Single handler — no params. Reads all selections, builds the combined payload.
102
+ */
103
+ syncValue(): void;
104
+ private distributeToSelections;
105
+ writeValue(value: ConnectionPayload | string | null): void;
106
+ registerOnChange(fn: (value: ConnectionPayload | null) => void): void;
107
+ registerOnTouched(fn: any): void;
108
+ setDisabledState(disabled: boolean): void;
109
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<SchemaConnectionField, never>;
110
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<SchemaConnectionField, "mt-schema-connection-field", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "filter": { "alias": "filter"; "required": false; "isSignal": true; }; "configuration": { "alias": "configuration"; "required": true; "isSignal": true; }; "context": { "alias": "context"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
111
+ }
112
+
113
+ export { SchemaConnectionField };
114
+ export type { ConnectionPayload, ConnectionSource, ConnectionSourceLevel, SchemaConnectionConfig, SourceLevelState };
@@ -590,5 +590,72 @@ declare class FormulaStatusBar {
590
590
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormulaStatusBar, "mt-formula-status-bar", never, { "validation": { "alias": "validation"; "required": false; "isSignal": true; }; "labels": { "alias": "labels"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
591
591
  }
592
592
 
593
- export { DEFAULT_OPERATORS, FormulaEditor, FormulaEditorCode, FormulaStatusBar, FormulaToolbar, FormulaToolbarItem, cloneBlock, cloneToken, cloneTokens, createFunctionBlock, createFunctionTokens, createLiteralBlock, createLiteralToken, createOperatorBlock, createOperatorToken, createPropertyBlock, createPropertyToken, findFunctionRange, generateFunctionId, generateSmartBlockId, generateTokenId, getArgumentIndexAtPosition, getFunctionTokens, isValidDropPosition, parseSignature, recalculateDepths, serializeTokens };
594
- export type { ApiErrorResponse, ArgumentSlot, AutocompleteContext, AutocompleteRequest, AutocompleteResponse, AutocompleteSuggestion, BlockType, DragBehavior, ExampleItem, FormulaToken, FormulaToolbarPropertiesContext, FunctionCategory, FunctionCategoryGroup, FunctionDefinition, FunctionInfo, OperatorDefinition, ParameterDefinition, SmartBlock, TokenType, ToolbarItemType, ToolbarTab, ValidationError, ValidationRequest, ValidationResult, ValidationSeverity, ValidationWarning };
593
+ type FormulaRuntimeDomain = 'condition' | 'validation';
594
+ type FormulaConditionMode = 'auto' | 'show' | 'hide' | 'enable' | 'disable';
595
+ interface FormulaConditionConfig {
596
+ formulaTokens: string;
597
+ formulaText?: string;
598
+ mode?: FormulaConditionMode;
599
+ }
600
+ type FormulaValidationSeverity = 'error' | 'warning';
601
+ interface FormulaValidationRuleConfig {
602
+ id: string | number;
603
+ formulaTokens: string;
604
+ formulaText?: string;
605
+ message: string;
606
+ severity: FormulaValidationSeverity;
607
+ enabled: boolean;
608
+ }
609
+ type FormulaRuntimeMessageCode = 'FORMULA_PARSE_ERROR' | 'FORMULA_EVALUATION_ERROR' | 'FORMULA_FALSE';
610
+ interface FormulaRuntimeMessage {
611
+ code: FormulaRuntimeMessageCode;
612
+ severity: FormulaValidationSeverity;
613
+ message: string;
614
+ formulaText?: string;
615
+ ruleId?: string | number;
616
+ fieldKey?: string;
617
+ }
618
+ interface FormulaEvaluationContext {
619
+ values: Record<string, any>;
620
+ }
621
+ interface FormulaConditionEvaluation {
622
+ hidden?: boolean;
623
+ disabled?: boolean;
624
+ dependencies: string[];
625
+ errors: string[];
626
+ }
627
+ interface FormulaValidationEvaluation {
628
+ valid: boolean;
629
+ dependencies: string[];
630
+ errors: string[];
631
+ }
632
+ interface FormulaRuntimeCatalog {
633
+ domain: FormulaRuntimeDomain;
634
+ functions: FunctionCategoryGroup[];
635
+ operators: OperatorDefinition[];
636
+ }
637
+
638
+ declare const CONDITION_FUNCTION_CATEGORIES: FunctionCategoryGroup[];
639
+ declare const CONDITION_OPERATORS: OperatorDefinition[];
640
+ declare const VALIDATION_FUNCTION_CATEGORIES: FunctionCategoryGroup[];
641
+ declare const VALIDATION_OPERATORS: OperatorDefinition[];
642
+ declare const CONDITION_RUNTIME_CATALOG: FormulaRuntimeCatalog;
643
+ declare const VALIDATION_RUNTIME_CATALOG: FormulaRuntimeCatalog;
644
+
645
+ type RuntimeFunction = (...args: any[]) => any;
646
+ declare class FormulaRuntimeEngine {
647
+ private readonly compiledCache;
648
+ private readonly functionRegistry;
649
+ constructor(customFunctions?: Record<string, RuntimeFunction>);
650
+ evaluateCondition(config: FormulaConditionConfig, context: FormulaEvaluationContext): FormulaConditionEvaluation;
651
+ evaluateValidation(rule: FormulaValidationRuleConfig, context: FormulaEvaluationContext): FormulaValidationEvaluation;
652
+ extractDependencies(formulaTokens: string): string[];
653
+ private resolveConditionAction;
654
+ private getCompiledFormula;
655
+ private deserializeFormulaTokens;
656
+ private toLexTokens;
657
+ private evaluateAst;
658
+ }
659
+
660
+ export { CONDITION_FUNCTION_CATEGORIES, CONDITION_OPERATORS, CONDITION_RUNTIME_CATALOG, DEFAULT_OPERATORS, FormulaEditor, FormulaEditorCode, FormulaRuntimeEngine, FormulaStatusBar, FormulaToolbar, FormulaToolbarItem, VALIDATION_FUNCTION_CATEGORIES, VALIDATION_OPERATORS, VALIDATION_RUNTIME_CATALOG, cloneBlock, cloneToken, cloneTokens, createFunctionBlock, createFunctionTokens, createLiteralBlock, createLiteralToken, createOperatorBlock, createOperatorToken, createPropertyBlock, createPropertyToken, findFunctionRange, generateFunctionId, generateSmartBlockId, generateTokenId, getArgumentIndexAtPosition, getFunctionTokens, isValidDropPosition, parseSignature, recalculateDepths, serializeTokens };
661
+ export type { ApiErrorResponse, ArgumentSlot, AutocompleteContext, AutocompleteRequest, AutocompleteResponse, AutocompleteSuggestion, BlockType, DragBehavior, ExampleItem, FormulaConditionConfig, FormulaConditionEvaluation, FormulaConditionMode, FormulaEvaluationContext, FormulaRuntimeCatalog, FormulaRuntimeDomain, FormulaRuntimeMessage, FormulaRuntimeMessageCode, FormulaToken, FormulaToolbarPropertiesContext, FormulaValidationEvaluation, FormulaValidationRuleConfig, FormulaValidationSeverity, FunctionCategory, FunctionCategoryGroup, FunctionDefinition, FunctionInfo, OperatorDefinition, ParameterDefinition, SmartBlock, TokenType, ToolbarItemType, ToolbarTab, ValidationError, ValidationRequest, ValidationResult, ValidationSeverity, ValidationWarning };
@@ -7,6 +7,7 @@ import { ButtonSeverity } from 'primeng/button';
7
7
 
8
8
  interface MTMenuItem extends Omit<MenuItem, 'icon'> {
9
9
  icon?: MTIcon;
10
+ color?: string;
10
11
  severity?: ButtonSeverity | 'danger';
11
12
  styleClass?: string;
12
13
  id?: string | number;
@@ -41,6 +42,8 @@ declare class Menu {
41
42
  show(event: Event): void;
42
43
  hide(): void;
43
44
  protected getItemIcon(item: any): MTIcon | undefined;
45
+ protected getItemColor(item: any): string | undefined;
46
+ protected getAvatarStyle(color: string): Record<string, string>;
44
47
  private transformMenuItem;
45
48
  private getSeverityClass;
46
49
  private handleItemSelect;
@@ -28,6 +28,30 @@ interface FieldRelationConfig {
28
28
  value: any;
29
29
  action: FieldRelationAction;
30
30
  }
31
+ type FormulaConditionMode = 'auto' | 'show' | 'hide' | 'enable' | 'disable';
32
+ interface FormulaConditionConfig {
33
+ formulaTokens: string;
34
+ formulaText?: string;
35
+ mode?: FormulaConditionMode;
36
+ }
37
+ type FormulaValidationSeverity = 'error' | 'warning';
38
+ interface FormulaValidationRuleConfig {
39
+ id: string | number;
40
+ formulaTokens: string;
41
+ formulaText?: string;
42
+ message: string;
43
+ severity: FormulaValidationSeverity;
44
+ enabled: boolean;
45
+ }
46
+ type FormulaRuntimeMessageCode = 'FORMULA_PARSE_ERROR' | 'FORMULA_EVALUATION_ERROR' | 'FORMULA_FALSE';
47
+ interface FormulaRuntimeMessage {
48
+ code: FormulaRuntimeMessageCode;
49
+ severity: FormulaValidationSeverity;
50
+ message: string;
51
+ formulaText?: string;
52
+ ruleId?: string | number;
53
+ fieldKey?: string;
54
+ }
31
55
  interface ResponsiveColSpan {
32
56
  xs?: number;
33
57
  sm?: number;
@@ -73,6 +97,7 @@ declare abstract class BaseFieldConfig {
73
97
  defaultValue?: any;
74
98
  customTemplate: string;
75
99
  relations: FieldRelationConfig[];
100
+ formulaCondition?: FormulaConditionConfig;
76
101
  constructor(config: {
77
102
  key?: string;
78
103
  label?: string;
@@ -87,6 +112,7 @@ declare abstract class BaseFieldConfig {
87
112
  validators?: ValidatorConfig[];
88
113
  order?: number;
89
114
  relations?: FieldRelationConfig[];
115
+ formulaCondition?: FormulaConditionConfig;
90
116
  colSpan?: number | ResponsiveColSpan;
91
117
  });
92
118
  }
@@ -383,8 +409,18 @@ declare class SpacerFieldConfig extends BaseFieldConfig {
383
409
  label?: string;
384
410
  });
385
411
  }
412
+ declare class SchemaConnectionFieldConfig extends BaseFieldConfig {
413
+ configuration: any;
414
+ context: HttpContext | undefined;
415
+ filter: boolean;
416
+ constructor(config: Omit<BaseFieldConstructorConfig, 'type'> & {
417
+ configuration: any;
418
+ context?: HttpContext | undefined;
419
+ filter?: boolean;
420
+ });
421
+ }
386
422
  type DynamicFieldConfig = {
387
- [K in keyof (TextFieldConfig & TextareaFieldConfig & SelectFieldConfig & DateFieldConfig & NumberFieldConfig & SliderFieldConfig & MultiSelectFieldConfig & PickListFieldConfig & CheckboxFieldConfig & ToggleFieldConfig & ColorPickerFieldConfig & IconFieldConfig & SpacerFieldConfig & BaseFieldConfig)]?: (TextFieldConfig & TextareaFieldConfig & SelectFieldConfig & DateFieldConfig & NumberFieldConfig & SliderFieldConfig & MultiSelectFieldConfig & PickListFieldConfig & CheckboxFieldConfig & ToggleFieldConfig & ColorPickerFieldConfig & IconFieldConfig & SpacerFieldConfig & BaseFieldConfig)[K];
423
+ [K in keyof (TextFieldConfig & TextareaFieldConfig & SelectFieldConfig & DateFieldConfig & NumberFieldConfig & SliderFieldConfig & MultiSelectFieldConfig & PickListFieldConfig & CheckboxFieldConfig & ToggleFieldConfig & ColorPickerFieldConfig & IconFieldConfig & SpacerFieldConfig & SchemaConnectionFieldConfig & BaseFieldConfig)]?: (TextFieldConfig & TextareaFieldConfig & SelectFieldConfig & DateFieldConfig & NumberFieldConfig & SliderFieldConfig & MultiSelectFieldConfig & PickListFieldConfig & CheckboxFieldConfig & ToggleFieldConfig & ColorPickerFieldConfig & IconFieldConfig & SpacerFieldConfig & SchemaConnectionFieldConfig & BaseFieldConfig)[K];
388
424
  };
389
425
  interface LayoutConfig {
390
426
  containerClass?: string;
@@ -394,6 +430,7 @@ interface LayoutConfig {
394
430
  interface DynamicFormConfig {
395
431
  sections: SectionConfig[];
396
432
  layout?: LayoutConfig;
433
+ validationRules?: FormulaValidationRuleConfig[];
397
434
  }
398
435
  interface SectionConfig {
399
436
  key?: string;
@@ -729,5 +766,5 @@ declare const REQUEST_CONTEXT: HttpContextToken<RequestContextConfig>;
729
766
  declare function getLightColor(hexColor: string): string;
730
767
  declare function getContrastColor(bgColor: string): string;
731
768
 
732
- export { BaseFacade, BaseFieldConfig, CheckboxFieldConfig, ColorPickerFieldConfig, CrudStateBase, DateFieldConfig, EditorFieldConfig, IconFieldConfig, MultiSelectFieldConfig, NumberFieldConfig, PickListFieldConfig, REQUEST_CONTEXT, RadioButtonFieldConfig, RadioCardsFieldConfig, SelectFieldConfig, SliderFieldConfig, SpacerFieldConfig, TextFieldConfig, TextareaFieldConfig, ToggleFieldConfig, UploadFileFieldConfig, UserSearchFieldConfig, ValidatorConfig, changeBackgroundColor, changePrimaryColor, changeTextColor, createCustomValidator, createEntityAdapter, endLoading, generateTailwindPalette, getContrastColor, getLightColor, handleApiRequest, isInvalid, provideMTComponents, provideMTConfirmation, provideMTMessages, setLoadingError, startLoading, wrapValidatorWithMessage };
733
- export type { ApiRequestConfig, BaseFieldConstructorConfig, CrudCreateConfig, CrudDeleteConfig, CrudLoadConfig, CrudUpdateConfig, DynamicFieldConfig, DynamicFormConfig, EntityAdapter, FieldRelationAction, FieldRelationConfig, FieldState, FieldType, LayoutConfig, LoadingStateShape, MTThemeOptions, PaletteShade, QueryResult, RequestContextConfig, Response, ResponsiveColSpan, SectionConfig, ValidatorType };
769
+ export { BaseFacade, BaseFieldConfig, CheckboxFieldConfig, ColorPickerFieldConfig, CrudStateBase, DateFieldConfig, EditorFieldConfig, IconFieldConfig, MultiSelectFieldConfig, NumberFieldConfig, PickListFieldConfig, REQUEST_CONTEXT, RadioButtonFieldConfig, RadioCardsFieldConfig, SchemaConnectionFieldConfig, SelectFieldConfig, SliderFieldConfig, SpacerFieldConfig, TextFieldConfig, TextareaFieldConfig, ToggleFieldConfig, UploadFileFieldConfig, UserSearchFieldConfig, ValidatorConfig, changeBackgroundColor, changePrimaryColor, changeTextColor, createCustomValidator, createEntityAdapter, endLoading, generateTailwindPalette, getContrastColor, getLightColor, handleApiRequest, isInvalid, provideMTComponents, provideMTConfirmation, provideMTMessages, setLoadingError, startLoading, wrapValidatorWithMessage };
770
+ export type { ApiRequestConfig, BaseFieldConstructorConfig, CrudCreateConfig, CrudDeleteConfig, CrudLoadConfig, CrudUpdateConfig, DynamicFieldConfig, DynamicFormConfig, EntityAdapter, FieldRelationAction, FieldRelationConfig, FieldState, FieldType, FormulaConditionConfig, FormulaConditionMode, FormulaRuntimeMessage, FormulaRuntimeMessageCode, FormulaValidationRuleConfig, FormulaValidationSeverity, LayoutConfig, LoadingStateShape, MTThemeOptions, PaletteShade, QueryResult, RequestContextConfig, Response, ResponsiveColSpan, SectionConfig, ValidatorType };