import * as i0 from '@angular/core'; import { EnvironmentProviders, InjectionToken, Signal, PipeTransform } from '@angular/core'; import { MessageService, ConfirmationService } from 'primeng/api'; import { HttpContext, HttpContextToken } from '@angular/common/http'; import { AbstractControl, ValidatorFn } from '@angular/forms'; import * as _masterteam_components from '@masterteam/components'; import { StateContext } from '@ngxs/store'; import { Observable } from 'rxjs'; interface MTThemeOptions { primaryColor?: string; textColor?: string; backgroundColor?: string; } declare function changePrimaryColor(color: string): void; declare function changeBackgroundColor(color?: string): void; declare function changeTextColor(color: string): void; declare function provideMTComponents(themeOptions?: MTThemeOptions): EnvironmentProviders; declare function provideMTMessages(): typeof MessageService; declare function provideMTConfirmation(): typeof ConfirmationService; interface MTDateFormats { date: string; dateTime: string; /** Clock-time only, used by `Time` properties. */ time: string; timezone?: string; } declare const DEFAULT_MT_DATE_FORMATS: MTDateFormats; declare const MT_DATE_FORMATS: InjectionToken; /** * Converts .NET custom date/time format tokens to Angular `formatDate` (CLDR) * tokens. System-setting formats are authored in .NET convention (e.g. `hh:mm tt`), * but `formatDate` uses CLDR tokens where the AM/PM designator is `a`, not `tt`. * Every other token in the supported set (d, M, y, H, h, m, s) is identical between * the two, so only `tt`/`t` → `a` needs translating. Single-quoted literal sections * (e.g. `'at'`) are left untouched. */ declare function toAngularDateFormat(format: string): string; declare function provideMTDateFormats(formats: Partial): EnvironmentProviders; type FieldType = 'text' | 'textarea' | 'select' | 'date' | 'number' | 'slider' | 'multi-select' | 'pick-list' | 'checkbox' | 'icon-field' | 'color-picker' | 'location' | 'spacer' | 'entity-preview' | 'lookup-matrix' | 'lookup-module-check-list' | string; type ValidatorType = 'required' | 'email' | 'minLength' | 'maxLength' | 'min' | 'max' | 'pattern' | 'custom'; type FieldRelationAction = 'enable' | 'disable' | 'show' | 'hide'; interface FieldRelationConfig { key: string; value: any; action: FieldRelationAction; } type FormulaConditionMode = 'auto' | 'show' | 'hide' | 'enable' | 'disable'; interface FormulaConditionConfig { formulaTokens: string; formulaText?: string; mode?: FormulaConditionMode; } /** * Narrows a select / multi-select to the options allowed for the value of * another field in the same form — a cascading lookup (City → Area). * * `mt-dynamic-form` applies it on every value change: * - the field stays disabled until the parent holds a value, and while the * parent's value allows no option; * - a parent value with no entry in `allowedValuesByParent` offers nothing, * or everything when `allowAllWhenUnmapped` is set; * - a multi-select parent offers the union of its values' options; * - when the user changes the parent, a value it no longer allows is cleared. * A value that was loaded with the record is kept until then, so opening a * record never edits it. * * The parent is read from its control, or from `externalValues` when it has * none (hidden in this mode, a read-only preview). A parent that resolves to * neither leaves the field locked as unavailable — never unrestricted. */ interface FieldOptionsFilterConfig { /** Key of the field whose value decides which options are offered. */ parentKey: string; /** The parent's label for the placeholders, which fall back to its key. */ parentLabel?: string; /** Parent value → the option values (`optionValue`) offered while it is selected. */ allowedValuesByParent: Record; /** A parent value without an entry offers every option instead of none. */ allowAllWhenUnmapped?: boolean; } type FormulaValidationSeverity = 'error' | 'warning'; interface FormulaValidationRuleConfig { id: string | number; formulaTokens: string; formulaText?: string; message: string; severity: FormulaValidationSeverity; enabled: boolean; } type FormulaRuntimeMessageCode = 'FORMULA_PARSE_ERROR' | 'FORMULA_EVALUATION_ERROR' | 'FORMULA_FALSE'; interface FormulaRuntimeMessage { code: FormulaRuntimeMessageCode; severity: FormulaValidationSeverity; message: string; formulaText?: string; ruleId?: string | number; fieldKey?: string; /** * Every field the failing rule reads, when the rule spans more than one * (`endDate > startDate` names both). `fieldKey` stays the first of them so * existing consumers are unaffected; renderers that mark fields should read * this, because flagging only half of a cross-field rule tells the user to * look in the wrong place (finding C-02). */ fieldKeys?: string[]; } interface ResponsiveColSpan { xs?: number; sm?: number; md?: number; lg?: number; xl?: number; } declare class ValidatorConfig { type: ValidatorType; value?: any; message?: string; customValidator?: (value: any, control?: AbstractControl) => boolean | Promise; constructor(config: { type: ValidatorType; value?: any; message?: string; customValidator?: (value: any, control?: AbstractControl) => boolean | Promise; }); static required(message?: string): ValidatorConfig; static email(message?: string): ValidatorConfig; static minLength(length: number, message?: string): ValidatorConfig; static maxLength(length: number, message?: string): ValidatorConfig; static min(value: number, message?: string): ValidatorConfig; static max(value: number, message?: string): ValidatorConfig; static pattern(pattern: string, message?: string): ValidatorConfig; static custom(validator: (value: any, control?: AbstractControl) => boolean | Promise, message?: string): ValidatorConfig; } type BaseFieldConstructorConfig = ConstructorParameters[0]; declare abstract class BaseFieldConfig { key: string; label: string; type: FieldType; required: boolean; disabled: boolean; readonly: boolean; hidden: boolean; placeholder: string; hint: string; cssClass: string; validators: ValidatorConfig[]; order: number; colSpan: number | ResponsiveColSpan; defaultValue?: any; customTemplate: string; relations: FieldRelationConfig[]; formulaCondition?: FormulaConditionConfig; constructor(config: { key?: string; label?: string; type: FieldType; required?: boolean; disabled?: boolean; readonly?: boolean; hidden?: boolean; placeholder?: string; hint?: string; cssClass?: string; validators?: ValidatorConfig[]; order?: number; relations?: FieldRelationConfig[]; formulaCondition?: FormulaConditionConfig; colSpan?: number | ResponsiveColSpan; }); } declare class TextFieldConfig extends BaseFieldConfig { inputType: string; constructor(config: Omit & { inputType?: string; }); } declare class TextareaFieldConfig extends BaseFieldConfig { rows: number; autoResize: boolean; constructor(config: Omit & { rows?: number; autoResize?: boolean; }); } declare class SelectFieldConfig extends BaseFieldConfig { options: any[]; optionLabel: string; optionValue: string; group: boolean; optionGroupLabel: string; optionGroupChildren: string; multiple: boolean; filter: boolean; filterBy: string; filterPlaceholder: string; /** Unset lets mt-select-field decide: clearable unless the field is required. */ showClear?: boolean; emptyMessage: string; size: string; hasPlaceholderPrefix: boolean; optionsFilter?: FieldOptionsFilterConfig; constructor(config: Omit & { options: any[]; optionLabel?: string; optionValue?: string; group?: boolean; optionGroupLabel?: string; optionGroupChildren?: string; multiple?: boolean; filter?: boolean; filterBy?: string; filterPlaceholder?: string; showClear?: boolean; emptyMessage?: string; size?: string; hasPlaceholderPrefix?: boolean; optionsFilter?: FieldOptionsFilterConfig; }); } declare class RadioButtonFieldConfig extends BaseFieldConfig { options: any[]; optionLabel: string; optionValue: string; orientation: 'vertical' | 'horizontal'; constructor(config: Omit & { options: any[]; optionLabel?: string; optionValue?: string; orientation?: 'vertical' | 'horizontal'; }); } declare class RadioCardsFieldConfig extends BaseFieldConfig { options: any[]; optionLabel: string; optionValue: string; size: string; constructor(config: Omit & { options: any[]; optionLabel?: string; optionValue?: string; size?: string; }); } declare class UserSearchFieldConfig extends BaseFieldConfig { optionLabel: string; optionValue: string; size: string; apiUrl: string; context: HttpContext | undefined; isMultiple: boolean; hideUnlinkedHint: boolean; dataKey: string; paramName: string; minLength: number; constructor(config: Omit & { optionLabel?: string; optionValue?: string; size?: string; hint?: string; apiUrl?: string; context?: HttpContext | undefined; placeholder?: string; isMultiple?: boolean; hideUnlinkedHint?: boolean; dataKey?: string; paramName?: string; minLength?: number; }); } declare class LocationFieldConfig extends BaseFieldConfig { configuration: Record | string | null; searchUrl?: string; minLength: number; constructor(config: Omit & { configuration?: Record | string | null; searchUrl?: string; minLength?: number; }); } declare class UploadFileFieldConfig extends BaseFieldConfig { size: string; endPoint?: string; userImgClass?: string; shape?: string; multiple?: boolean; accept?: string | string[]; fileSizeLimit?: number | undefined; context: HttpContext | undefined; title: string; description: string; constructor(config: Omit & { size?: string; endPoint?: string; userImgClass?: string; shape?: string; multiple?: boolean; accept?: string | string[]; fileSizeLimit?: number | undefined; context?: HttpContext | undefined; title?: string; description?: string; }); } declare class DateFieldConfig extends BaseFieldConfig { dateFormat: string; showTime: boolean; /** Edits the clock time only — no calendar. The value stays a full `Date`. */ timeOnly: boolean; showSeconds: boolean; hourFormat: '12' | '24'; minDate?: Date; maxDate?: Date; disabledDates: Date[]; disabledDays: number[]; yearRange: string; showIcon: boolean; icon: string; showButtonBar: boolean; showClear: boolean; inline: boolean; constructor(config: Omit & { dateFormat?: string; showTime?: boolean; timeOnly?: boolean; showSeconds?: boolean; hourFormat?: '12' | '24'; minDate?: Date; maxDate?: Date; disabledDates?: Date[]; disabledDays?: number[]; yearRange?: string; showIcon?: boolean; icon?: string; showButtonBar?: boolean; showClear?: boolean; inline?: boolean; }); } declare class NumberFieldConfig extends BaseFieldConfig { min?: number; max?: number; step?: number; prefix?: string; suffix?: string; currency?: string; locale?: string; minFractionDigits?: number; maxFractionDigits?: number; useGrouping?: boolean; showButtons?: boolean; buttonLayout?: 'stacked' | 'horizontal'; incrementButtonClass?: string; decrementButtonClass?: string; incrementButtonIcon?: string; decrementButtonIcon?: string; constructor(config: Omit & { min?: number; max?: number; step?: number; prefix?: string; suffix?: string; currency?: string; locale?: string; minFractionDigits?: number; maxFractionDigits?: number; useGrouping?: boolean; showButtons?: boolean; buttonLayout?: 'stacked' | 'horizontal'; incrementButtonClass?: string; decrementButtonClass?: string; incrementButtonIcon?: string; decrementButtonIcon?: string; }); } declare class SliderFieldConfig extends BaseFieldConfig { min?: number; max?: number; step?: number; orientation?: 'horizontal' | 'vertical'; range?: boolean; animate?: boolean; unit?: string; constructor(config: Omit & { min?: number; max?: number; step?: number; orientation?: 'horizontal' | 'vertical'; range?: boolean; animate?: boolean; unit?: string; }); } declare class MultiSelectFieldConfig extends BaseFieldConfig { options: any[]; optionLabel: string; optionValue: string; filter: boolean; filterBy: string; filterPlaceholder: string; showClear: boolean; emptyMessage: string; display?: 'comma' | 'chip'; maxSelectedLabels?: number; selectedItemsLabel?: string; showToggleAll?: boolean; resetFilterOnHide?: boolean; optionsFilter?: FieldOptionsFilterConfig; constructor(config: Omit & { options: any[]; optionLabel?: string; optionValue?: string; filter?: boolean; filterBy?: string; filterPlaceholder?: string; showClear?: boolean; emptyMessage?: string; display?: 'comma' | 'chip'; maxSelectedLabels?: number; selectedItemsLabel?: string; showToggleAll?: boolean; resetFilterOnHide?: boolean; optionsFilter?: FieldOptionsFilterConfig; }); } declare class PickListFieldConfig extends BaseFieldConfig { options: any[]; /** Selected values the user cannot move back out of the target list. */ lockedValues: any[]; optionLabel: string; optionValue: string; sourceHeader: string; targetHeader: string; showSourceControls: boolean; showTargetControls: boolean; showSourceFilter: boolean; showTargetFilter: boolean; filterBy: string; dataKey?: string; dragdrop: boolean; responsive: boolean; breakpoint: string; constructor(config: Omit & { options: any[]; optionLabel?: string; optionValue?: string; sourceHeader?: string; targetHeader?: string; showSourceControls?: boolean; showTargetControls?: boolean; showSourceFilter?: boolean; showTargetFilter?: boolean; filterBy?: string; dataKey?: string; dragdrop?: boolean; responsive?: boolean; lockedValues?: any[]; }); } declare class CheckboxFieldConfig extends BaseFieldConfig { binary?: boolean; trueValue?: any; falseValue?: any; checkboxIcon?: string; constructor(config: Omit & { binary?: boolean; trueValue?: any; falseValue?: any; checkboxIcon?: string; }); } declare class ToggleFieldConfig extends BaseFieldConfig { toggleShape?: 'toggle' | 'card'; icon?: string; descriptionCard?: string; constructor(config: Omit & { toggleShape?: 'toggle' | 'card'; icon?: string; descriptionCard?: string; }); } declare class EditorFieldConfig extends BaseFieldConfig { constructor(config: Omit); } declare class ColorPickerFieldConfig extends BaseFieldConfig { format?: 'hex' | 'rgb' | 'hsb'; inline?: boolean; appendTo?: any; variant?: 'outlined' | 'filled'; constructor(config: Omit & { format?: 'hex' | 'rgb' | 'hsb'; inline?: boolean; appendTo?: any; variant?: 'outlined' | 'filled'; }); } declare class IconFieldConfig extends BaseFieldConfig { constructor(config: Omit & {}); } declare class SpacerFieldConfig extends BaseFieldConfig { constructor(config: Omit & { key?: string; label?: string; }); } interface LookupOptionItemConfig { id?: number | string; key?: string; label: string; value: any; color?: string | null; description?: string; } interface LookupMatrixCellConfig { row: number; column: number; xLookupItemId: number | string; yLookupItemId?: number | string; zLookupItemId?: number | string | null; label: string; color?: string | null; } declare class LookupMatrixFieldConfig extends BaseFieldConfig { xFieldKey: string; yFieldKey?: string; xAxisLabel: string; yAxisLabel?: string; xOptions: LookupOptionItemConfig[]; yOptions?: LookupOptionItemConfig[]; cells: LookupMatrixCellConfig[]; emptyMessage: string; constructor(config: Omit & { xFieldKey: string; yFieldKey?: string; xAxisLabel?: string; yAxisLabel?: string; xOptions?: LookupOptionItemConfig[]; yOptions?: LookupOptionItemConfig[]; cells?: LookupMatrixCellConfig[]; emptyMessage?: string; }); } interface SchemaConnectionFieldRuntimeContext { /** * The active plan/template instance id. When present, it is sent as a * `templateId` structural filter on every source level's `fetch/query` * options request, scoping the dropdown to records owned by this plan. * When absent, options load unscoped (back-compat with hosts that don't * pass `templateId` to `mt-client-form`). */ templateId?: number | string | null; } declare class SchemaConnectionFieldConfig extends BaseFieldConfig { configuration: any; context: HttpContext | undefined; filter: boolean; runtimeContext: SchemaConnectionFieldRuntimeContext | null; constructor(config: Omit & { configuration: any; context?: HttpContext | undefined; filter?: boolean; runtimeContext?: SchemaConnectionFieldRuntimeContext | null; }); } interface SchedulePredecessorFieldRuntimeContext { levelId?: number | string | null; levelDataId?: number | string | null; moduleDataId?: number | string | null; } declare class SchedulePredecessorFieldConfig extends BaseFieldConfig { configuration: any; runtimeContext: SchedulePredecessorFieldRuntimeContext | null; constructor(config: Omit & { configuration?: any; runtimeContext?: SchedulePredecessorFieldRuntimeContext | null; }); } interface EntityListFieldRuntimeContext { /** * Route id for the read endpoint. * - Level-scoped EntityList properties → level-data id * - Module-scoped EntityList properties → source module-data id */ sourceId?: number | string | null; /** Current level id (used to build the fetch/query contextKey). */ levelId?: number | string | null; levelDataId?: number | string | null; /** * Module schema id of the form that owns the property — the `Module:{id}` * segment of the options `contextKey` a Selected list's picker sends. Absent * on a level's own form, whose context is `Level:{levelId}`. */ moduleId?: number | string | null; /** * The record that owns the list. A read-only Related list with an owner * shows its saved list's preserved and current values * (`entity-lists/comparison`) instead of querying the source module. */ ownerKind?: 'ModuleData' | 'LevelData' | null; ownerId?: number | null; } declare class EntityListFieldConfig extends BaseFieldConfig { /** EntityList property id (used in the read endpoint route). */ propertyId: number | null; /** * EntityList property key — the `forms/options/{propertyKey}` route a * Selected list's picker loads its candidates from. */ propertyKey: string; /** Property configuration (sourceType, moduleId, access, snapshotMode, fields). */ configuration: any; /** Runtime ids needed to call the read endpoint. */ runtimeContext: EntityListFieldRuntimeContext | null; /** * Full lookup catalog, carried through to the add/edit dialog's nested form. * Without it a `Lookup` field of the target module renders "no options". */ lookups: unknown[]; context: HttpContext | undefined; /** * The bound value is an unapplied process submission — an Approval step's * frozen create/update/delete operations — rather than a persisted record * value. Its `rows[]` and `deletedIds` are pending intent to overlay on the * loaded records, not markers of writes the backend already applied. */ pendingSubmission: boolean; constructor(config: Omit & { propertyId?: number | null; propertyKey?: string; configuration?: any; runtimeContext?: EntityListFieldRuntimeContext | null; lookups?: unknown[]; context?: HttpContext | undefined; pendingSubmission?: boolean; }); } interface ScheduleItemSelectorFieldRuntimeContext { /** Current level id — used to build the options `contextKey` (`Level:{levelId}`). */ levelId?: number | string | null; /** * Module schema id of the form that owns the selector property — the * `Module:{moduleId}` segment of the options `contextKey`. For Deliverable * Acceptance this is the Deliverable Acceptance module schema id, NOT the * target schedule module id. */ moduleId?: number | string | null; /** Current workspace instance id (`levelDataId` query param). */ levelDataId?: number | string | null; /** * Record being edited (`ownerRecordId` query param). Lets the backend keep * the current record's existing selections valid in edit mode. */ ownerRecordId?: number | string | null; } declare class ScheduleItemSelectorFieldConfig extends BaseFieldConfig { /** Property key — used in the options endpoint route `forms/options/{propertyKey}`. */ propertyKey: string; /** `Single` renders a single-select picker, `Multi` a multi-select picker. */ selectionMode: 'Single' | 'Multi'; /** Raw property configuration (selectionMode, scheduleModuleKey, etc.). */ configuration: any; /** Runtime ids needed to call the options endpoint. */ runtimeContext: ScheduleItemSelectorFieldRuntimeContext | null; context: HttpContext | undefined; constructor(config: Omit & { propertyKey?: string; selectionMode?: 'Single' | 'Multi'; configuration?: any; runtimeContext?: ScheduleItemSelectorFieldRuntimeContext | null; context?: HttpContext | undefined; }); } /** One configured module property the checklist captures for each entry. */ interface LookupCheckListPropertyConfig { /** Property key persisted in `props[].key`. */ key: string; /** Human-readable label shown next to the input. */ label: string; } interface LookupModuleCheckListFieldRuntimeContext { /** Current level id — passed to `process-form-load` for each section form. */ levelId?: number | string | null; /** Current workspace instance id — passed to `process-form-load`. */ levelDataId?: number | string | null; } declare class LookupModuleCheckListFieldConfig extends BaseFieldConfig { /** Lookup items rendered as collapsible checklist sections. */ lookupOptions: LookupOptionItemConfig[]; /** Full lookup catalog passed through to the rich nested form renderer. */ lookups: unknown[]; /** Module property keys/labels captured per checklist entry. */ propertyFields: LookupCheckListPropertyConfig[]; /** Scope module id whose form is loaded for each section. */ scopeId: number | string | null; /** Property keys to render in each section form (`allowedFieldKeys`). */ propertyKeys: string[]; /** Runtime ids needed to load each section form. */ runtimeContext: LookupModuleCheckListFieldRuntimeContext | null; /** Raw property configuration (lookup id, scope/module id, properties). */ configuration: any; constructor(config: Omit & { lookupOptions?: LookupOptionItemConfig[]; lookups?: unknown[]; propertyFields?: LookupCheckListPropertyConfig[]; scopeId?: number | string | null; propertyKeys?: string[]; runtimeContext?: LookupModuleCheckListFieldRuntimeContext | null; configuration?: any; }); } type DynamicFieldConfig = { [K in keyof (TextFieldConfig & TextareaFieldConfig & SelectFieldConfig & DateFieldConfig & NumberFieldConfig & SliderFieldConfig & MultiSelectFieldConfig & PickListFieldConfig & CheckboxFieldConfig & ToggleFieldConfig & LocationFieldConfig & ColorPickerFieldConfig & IconFieldConfig & SpacerFieldConfig & LookupMatrixFieldConfig & SchemaConnectionFieldConfig & SchedulePredecessorFieldConfig & EntityListFieldConfig & ScheduleItemSelectorFieldConfig & LookupModuleCheckListFieldConfig & BaseFieldConfig)]?: (TextFieldConfig & TextareaFieldConfig & SelectFieldConfig & DateFieldConfig & NumberFieldConfig & SliderFieldConfig & MultiSelectFieldConfig & PickListFieldConfig & CheckboxFieldConfig & ToggleFieldConfig & LocationFieldConfig & ColorPickerFieldConfig & IconFieldConfig & SpacerFieldConfig & LookupMatrixFieldConfig & SchemaConnectionFieldConfig & SchedulePredecessorFieldConfig & EntityListFieldConfig & ScheduleItemSelectorFieldConfig & LookupModuleCheckListFieldConfig & BaseFieldConfig)[K]; }; interface LayoutConfig { containerClass?: string; sectionClass?: string; fieldClass?: string; } interface DynamicFormConfig { sections: SectionConfig[]; layout?: LayoutConfig; validationRules?: FormulaValidationRuleConfig[]; } interface SectionConfig { key?: string; label?: string; type: 'none' | 'header'; cssClass?: string; bodyClass?: string; headerClass?: string; columns?: number; order?: number; fields: DynamicFieldConfig[]; } interface FieldState { hidden: boolean; disabled: boolean; } /** * What a field's {@link FieldOptionsFilterConfig} resolved to right now: * the options to offer and, while the field is locked, the placeholder that * says why. `mt-dynamic-form` keeps the reference stable until it changes. */ interface FieldOptionsFilterState { options: any[]; placeholder?: string; } declare function createCustomValidator(customValidator: (value: any, control?: AbstractControl) => boolean | Promise, message?: string): ValidatorFn; declare function wrapValidatorWithMessage(validator: ValidatorFn, errorKey: string, message: string): ValidatorFn; /** * Query result with separate signals for each property */ interface QueryResult { data: Signal; isPending: Signal; isSuccess: Signal; isError: Signal; error: Signal; } /** * @deprecated Use direct `select()` + `computed()` pattern instead for better performance. * * **Problem with BaseFacade:** * - All computed signals depend on the full state, causing unnecessary recomputations * - Bypasses NGXS selector memoization * - Uses `as any` casting, losing type safety * * **New Pattern - Use slice-based selectors:** * * ```typescript * // In your State class - add slice selectors: * @Selector() * static getLoadingActive(state: MyStateModel): string[] { * return state.loadingActive; * } * * @Selector() * static getErrors(state: MyStateModel): Record { * return state.errors; * } * * // In your Facade - don't extend BaseFacade: * @Injectable({ providedIn: 'root' }) * export class MyFacade { * private readonly store = inject(Store); * * // Data selectors - memoized by NGXS * readonly items = select(MyState.getItems); * * // Loading/Error slices - memoized by NGXS * private readonly loadingActive = select(MyState.getLoadingActive); * private readonly errors = select(MyState.getErrors); * * // Loading signals - computed from slice (minimal reactivity) * readonly isLoadingItems = computed(() => * this.loadingActive().includes(MyActionKey.GetItems) * ); * * // Error signals - computed from slice (minimal reactivity) * readonly itemsError = computed(() => * this.errors()[MyActionKey.GetItems] ?? null * ); * * // Dispatchers * loadItems() { * return this.store.dispatch(new GetItems()); * } * } * ``` * * **Template Usage:** * ```html * @if (facade.isLoadingItems()) { * * } @else if (facade.itemsError(); as error) { * {{ error }} * } @else { * @for (item of facade.items(); track item.id) { * * } * } * ``` */ declare abstract class BaseFacade { /** * Override in child facade to provide the state selector */ protected abstract state(): Signal; /** * Creates a query object with separate signals for data, loading, and error states * Each property is its own signal for granular reactivity * * @example * readonly modulesQuery = this.query( * 'getModulesLoading', * (state) => state.allModules * ); * * // In template - each is a separate signal: * @if (modulesQuery.isPending()) { Loading... } * @if (modulesQuery.error(); as error) { Error: {{ error }} } * @if (modulesQuery.data(); as modules) { *
{{ m.title }}
* } */ protected query(loadingKey: TLoadingName, dataSelector: (state: TState) => T): QueryResult; /** * Creates a loading signal for a specific operation */ protected loading(loadingKey: TLoadingName): Signal; /** * Creates an error signal for a specific operation */ protected errorSignal(loadingKey: TLoadingName): Signal; } interface LoadingStateShape { loadingActive: L[]; errors: Partial>; } type LoadingName$1> = T['loadingActive'][number]; declare function startLoading>(ctx: StateContext, loadingName: LoadingName$1): void; declare function endLoading>(ctx: StateContext, loadingName: LoadingName$1): void; declare function setLoadingError>(ctx: StateContext, loadingName: LoadingName$1, message: string): void; interface Response { endpoint: string; status: number; code: number; locale: string; message?: string | null; errors?: unknown | null; data: T; cacheSession?: string; } interface CrudLoadConfig { key: TLoad; request$: Observable>; stateProperty?: (state: TState) => T[]; /** * @deprecated Use `handleApiRequest` with `onSuccess` for complex state updates. * CRUD methods should only be used for simple array operations with `stateProperty`. */ updateState?: (state: TState, data: TData) => Partial; /** * @deprecated Use `handleApiRequest` with `onSuccess` for data transformation. * CRUD methods should only be used for simple array operations. */ transform?: (data: TData) => TData; onError?: (error: any, state: TState) => Partial | void; errorMessage?: string; } interface CrudCreateConfig { key: TLoad; request$: Observable>; stateProperty: (state: TState) => T[]; /** * @deprecated Use `handleApiRequest` with `onSuccess` for complex state updates. * CRUD methods should only be used for simple array operations with `stateProperty`. */ updateState?: (state: TState, items: T[]) => Partial; /** * @deprecated Use `handleApiRequest` with `onSuccess` for data transformation. * CRUD methods should only be used for simple array operations. */ transform?: (data: T) => T; onError?: (error: any, state: TState) => Partial | void; errorMessage?: string; } interface CrudUpdateConfig { key: TLoad; request$: Observable>; uniqueKey: keyof T; id: string | number; stateProperty: (state: TState) => T[]; /** * @deprecated Use `handleApiRequest` with `onSuccess` for complex state updates. * CRUD methods should only be used for simple array operations with `stateProperty`. */ updateState?: (state: TState, items: T[]) => Partial; /** * @deprecated Use `handleApiRequest` with `onSuccess` for data transformation. * CRUD methods should only be used for simple array operations. */ transform?: (data: T) => T; onError?: (error: any, state: TState) => Partial | void; errorMessage?: string; } interface CrudDeleteConfig { key: TLoad; request$: Observable>; uniqueKey: keyof T; id: string | number; stateProperty: (state: TState) => T[]; /** * @deprecated Use `handleApiRequest` with `onSuccess` for complex state updates. * CRUD methods should only be used for simple array operations with `stateProperty`. */ updateState?: (state: TState, items: T[]) => Partial; onError?: (error: any, state: TState) => Partial | void; errorMessage?: string; } /** * T = entity type (Module, User, ...) * TState = full state model (must include LoadingStateShape) * TLoad = union type of loading keys for this feature */ declare abstract class CrudStateBase, TLoad extends string> { protected adapter: _masterteam_components.EntityAdapter; /** * Helper to create default updateState function */ private getDefaultUpdateState; /** * @deprecated Use `handleApiRequest` directly with `onSuccess` callback. * The `load()` method provides no significant benefit over `handleApiRequest`. * * @example * // Instead of this.load(), use: * return handleApiRequest({ * ctx, * key: ActionKey.GetItems, * request$: req$, * onSuccess: (response) => ({ * items: response.data ?? [], * }), * }); */ protected load(ctx: StateContext, config: CrudLoadConfig): Observable>; /** * Create one entity with config object */ protected create(ctx: StateContext, config: CrudCreateConfig): Observable>; /** * Update one entity with config object */ protected update(ctx: StateContext, config: CrudUpdateConfig): Observable>; /** * Delete one entity with config object */ protected delete(ctx: StateContext, config: CrudDeleteConfig): Observable>; } type TailwindColorPalette = { [key: string]: string; }; /** * Generates a Tailwind-like color palette (50-950) from a primary color (assumed to be 500). * * @param primaryColor500 - The hex string of the primary color (e.g., "#0284c7"). * @returns An object representing the color palette, where keys are color numbers (e.g., "50", "100") * and values are hex color strings. */ type PaletteShade = '0' | '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | '950'; /** * Generates a Tailwind-like color palette (50-950) from any given base color. * * @param baseColorHex - The hex string of the base color (e.g., "#0284c7"). * @param baseColorShade - The shade of the base color (e.g., "500", "700"). * @returns An object representing the full color palette. */ declare function generateTailwindPalette(baseColorHex: string, baseColorShade?: PaletteShade): TailwindColorPalette; declare function isInvalid(control: AbstractControl | null): boolean; type LoadingName> = TState['loadingActive'][number]; interface ApiRequestConfig, TResponse> { ctx: StateContext; key: LoadingName; request$: Observable; onSuccess: (response: TResponse, state: TState) => Partial | void; onError?: (error: any, state: TState) => Partial | void; errorMessage?: string; } declare function handleApiRequest, TResponse>(config: ApiRequestConfig): Observable; interface EntityAdapter { addOne(state: T[], entity: T): T[]; upsertOne(state: T[], entity: T, uniqueKey?: keyof T): T[]; updateOne(state: T[], id: string | number, changes: Partial, uniqueKey?: keyof T): T[]; removeOne(state: T[], id: string | number, uniqueKey?: keyof T): T[]; setAll(state: T[], entities: T[]): T[]; } declare function createEntityAdapter(): EntityAdapter; /** * HTTP context configuration for request handling */ interface RequestContextConfig { /** Use base URL instead of gateway URL */ useBaseUrl?: boolean; } /** * Shared HTTP context token for request configuration. * Used by interceptors to determine base URL routing. * * @example * ```typescript * import { REQUEST_CONTEXT } from '@masterteam/components'; * * // In a service * private context = new HttpContext().set(REQUEST_CONTEXT, { useBaseUrl: true }); * * getMetadata(): Observable { * return this.http.get('metadata', { context: this.context }); * } * * // In interceptor * const config = req.context.get(REQUEST_CONTEXT); * if (config?.useBaseUrl) { * // Use base URL * } * ``` */ declare const REQUEST_CONTEXT: HttpContextToken; /** * Color utility functions for brand display. */ /** * Converts a hex color to a light shade (equivalent to primary-100 in Tailwind). * This creates a color with ~10% opacity or a very light tint by mixing with white. */ declare function getLightColor(hexColor: string): string; declare function getContrastColor(bgColor: string): string; /** * WCAG 2.x relative luminance. * * Note this is NOT the 0.299/0.587/0.114 perceived-brightness formula used by * `getContrastColor` above — that one is fine for "is this light or dark?" but * it is not the definition a conformance ratio is measured against, so it * cannot be used to decide whether text passes AA. */ declare function relativeLuminance(hex: string): number | null; /** WCAG contrast ratio between two hex colours, 1–21. Null if either is bad. */ declare function contrastRatio(foreground: string, background: string): number | null; /** WCAG 1.4.3 Contrast Minimum, normal-size text. */ declare const WCAG_AA_NORMAL_TEXT = 4.5; /** Dark ink used when white text would not be legible on a status colour. */ declare const READABLE_DARK_INK = "#1f2937"; /** * Picks the more legible of white and a dark ink for text sitting on `bgColor`. * * Status and lookup colours come from a tenant's own catalog, so they can be * any hex at all — and the count badges on the Explore cards were painting * white on every one of them, which measured 2.59:1 at the low end (finding * H-03 / M-04). Rather than restrict what colours a tenant may choose, pick the * foreground that actually reads on the colour they chose. * * Measured with the WCAG relative-luminance ratio, not the perceived-brightness * shortcut in `getContrastColor`, because that shortcut is not the definition * conformance is judged against. Unparseable input falls back to white, which * is the behaviour every caller had before. */ declare function readableTextOn(bgColor: string | null | undefined, dark?: string, light?: string): string; /** * A unique DOM id for a form field, shared by its control and its `