@masterteam/components 0.0.83 → 0.0.85
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/fesm2022/masterteam-components-dynamic-drawer.mjs +31 -19
- package/fesm2022/masterteam-components-dynamic-drawer.mjs.map +1 -1
- package/fesm2022/masterteam-components-formula.mjs +4 -3
- package/fesm2022/masterteam-components-formula.mjs.map +1 -1
- package/fesm2022/masterteam-components-upload-field.mjs +51 -7
- package/fesm2022/masterteam-components-upload-field.mjs.map +1 -1
- package/fesm2022/masterteam-components.mjs +114 -3
- package/fesm2022/masterteam-components.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-upload-field.d.ts +24 -1
- package/types/masterteam-components.d.ts +114 -3
|
@@ -424,7 +424,68 @@ interface QueryResult<T> {
|
|
|
424
424
|
error: Signal<string | null>;
|
|
425
425
|
}
|
|
426
426
|
/**
|
|
427
|
-
*
|
|
427
|
+
* @deprecated Use direct `select()` + `computed()` pattern instead for better performance.
|
|
428
|
+
*
|
|
429
|
+
* **Problem with BaseFacade:**
|
|
430
|
+
* - All computed signals depend on the full state, causing unnecessary recomputations
|
|
431
|
+
* - Bypasses NGXS selector memoization
|
|
432
|
+
* - Uses `as any` casting, losing type safety
|
|
433
|
+
*
|
|
434
|
+
* **New Pattern - Use slice-based selectors:**
|
|
435
|
+
*
|
|
436
|
+
* ```typescript
|
|
437
|
+
* // In your State class - add slice selectors:
|
|
438
|
+
* @Selector()
|
|
439
|
+
* static getLoadingActive(state: MyStateModel): string[] {
|
|
440
|
+
* return state.loadingActive;
|
|
441
|
+
* }
|
|
442
|
+
*
|
|
443
|
+
* @Selector()
|
|
444
|
+
* static getErrors(state: MyStateModel): Record<string, string | null> {
|
|
445
|
+
* return state.errors;
|
|
446
|
+
* }
|
|
447
|
+
*
|
|
448
|
+
* // In your Facade - don't extend BaseFacade:
|
|
449
|
+
* @Injectable({ providedIn: 'root' })
|
|
450
|
+
* export class MyFacade {
|
|
451
|
+
* private readonly store = inject(Store);
|
|
452
|
+
*
|
|
453
|
+
* // Data selectors - memoized by NGXS
|
|
454
|
+
* readonly items = select(MyState.getItems);
|
|
455
|
+
*
|
|
456
|
+
* // Loading/Error slices - memoized by NGXS
|
|
457
|
+
* private readonly loadingActive = select(MyState.getLoadingActive);
|
|
458
|
+
* private readonly errors = select(MyState.getErrors);
|
|
459
|
+
*
|
|
460
|
+
* // Loading signals - computed from slice (minimal reactivity)
|
|
461
|
+
* readonly isLoadingItems = computed(() =>
|
|
462
|
+
* this.loadingActive().includes(MyActionKey.GetItems)
|
|
463
|
+
* );
|
|
464
|
+
*
|
|
465
|
+
* // Error signals - computed from slice (minimal reactivity)
|
|
466
|
+
* readonly itemsError = computed(() =>
|
|
467
|
+
* this.errors()[MyActionKey.GetItems] ?? null
|
|
468
|
+
* );
|
|
469
|
+
*
|
|
470
|
+
* // Dispatchers
|
|
471
|
+
* loadItems() {
|
|
472
|
+
* return this.store.dispatch(new GetItems());
|
|
473
|
+
* }
|
|
474
|
+
* }
|
|
475
|
+
* ```
|
|
476
|
+
*
|
|
477
|
+
* **Template Usage:**
|
|
478
|
+
* ```html
|
|
479
|
+
* @if (facade.isLoadingItems()) {
|
|
480
|
+
* <loading-spinner />
|
|
481
|
+
* } @else if (facade.itemsError(); as error) {
|
|
482
|
+
* <error-alert>{{ error }}</error-alert>
|
|
483
|
+
* } @else {
|
|
484
|
+
* @for (item of facade.items(); track item.id) {
|
|
485
|
+
* <item-card [item]="item" />
|
|
486
|
+
* }
|
|
487
|
+
* }
|
|
488
|
+
* ```
|
|
428
489
|
*/
|
|
429
490
|
declare abstract class BaseFacade<TState, TLoadingName extends string> {
|
|
430
491
|
/**
|
|
@@ -482,7 +543,15 @@ interface CrudLoadConfig<T, TState, TData = T[]> {
|
|
|
482
543
|
key: string;
|
|
483
544
|
request$: Observable<Response<TData>>;
|
|
484
545
|
stateProperty?: (state: TState) => T[];
|
|
546
|
+
/**
|
|
547
|
+
* @deprecated Use `handleApiRequest` with `onSuccess` for complex state updates.
|
|
548
|
+
* CRUD methods should only be used for simple array operations with `stateProperty`.
|
|
549
|
+
*/
|
|
485
550
|
updateState?: (state: TState, data: TData) => Partial<TState>;
|
|
551
|
+
/**
|
|
552
|
+
* @deprecated Use `handleApiRequest` with `onSuccess` for data transformation.
|
|
553
|
+
* CRUD methods should only be used for simple array operations.
|
|
554
|
+
*/
|
|
486
555
|
transform?: (data: TData) => TData;
|
|
487
556
|
onError?: (error: any, state: TState) => Partial<TState> | void;
|
|
488
557
|
errorMessage?: string;
|
|
@@ -491,7 +560,15 @@ interface CrudCreateConfig<T, TState> {
|
|
|
491
560
|
key: string;
|
|
492
561
|
request$: Observable<Response<T>>;
|
|
493
562
|
stateProperty: (state: TState) => T[];
|
|
563
|
+
/**
|
|
564
|
+
* @deprecated Use `handleApiRequest` with `onSuccess` for complex state updates.
|
|
565
|
+
* CRUD methods should only be used for simple array operations with `stateProperty`.
|
|
566
|
+
*/
|
|
494
567
|
updateState?: (state: TState, items: T[]) => Partial<TState>;
|
|
568
|
+
/**
|
|
569
|
+
* @deprecated Use `handleApiRequest` with `onSuccess` for data transformation.
|
|
570
|
+
* CRUD methods should only be used for simple array operations.
|
|
571
|
+
*/
|
|
495
572
|
transform?: (data: T) => T;
|
|
496
573
|
onError?: (error: any, state: TState) => Partial<TState> | void;
|
|
497
574
|
errorMessage?: string;
|
|
@@ -502,7 +579,15 @@ interface CrudUpdateConfig<T, TState> {
|
|
|
502
579
|
uniqueKey: keyof T;
|
|
503
580
|
id: string | number;
|
|
504
581
|
stateProperty: (state: TState) => T[];
|
|
582
|
+
/**
|
|
583
|
+
* @deprecated Use `handleApiRequest` with `onSuccess` for complex state updates.
|
|
584
|
+
* CRUD methods should only be used for simple array operations with `stateProperty`.
|
|
585
|
+
*/
|
|
505
586
|
updateState?: (state: TState, items: T[]) => Partial<TState>;
|
|
587
|
+
/**
|
|
588
|
+
* @deprecated Use `handleApiRequest` with `onSuccess` for data transformation.
|
|
589
|
+
* CRUD methods should only be used for simple array operations.
|
|
590
|
+
*/
|
|
506
591
|
transform?: (data: T) => T;
|
|
507
592
|
onError?: (error: any, state: TState) => Partial<TState> | void;
|
|
508
593
|
errorMessage?: string;
|
|
@@ -513,6 +598,10 @@ interface CrudDeleteConfig<T, TState> {
|
|
|
513
598
|
uniqueKey: keyof T;
|
|
514
599
|
id: string | number;
|
|
515
600
|
stateProperty: (state: TState) => T[];
|
|
601
|
+
/**
|
|
602
|
+
* @deprecated Use `handleApiRequest` with `onSuccess` for complex state updates.
|
|
603
|
+
* CRUD methods should only be used for simple array operations with `stateProperty`.
|
|
604
|
+
*/
|
|
516
605
|
updateState?: (state: TState, items: T[]) => Partial<TState>;
|
|
517
606
|
onError?: (error: any, state: TState) => Partial<TState> | void;
|
|
518
607
|
errorMessage?: string;
|
|
@@ -529,7 +618,19 @@ declare abstract class CrudStateBase<T, TState extends LoadingStateShape<TLoad>,
|
|
|
529
618
|
*/
|
|
530
619
|
private getDefaultUpdateState;
|
|
531
620
|
/**
|
|
532
|
-
*
|
|
621
|
+
* @deprecated Use `handleApiRequest` directly with `onSuccess` callback.
|
|
622
|
+
* The `load()` method provides no significant benefit over `handleApiRequest`.
|
|
623
|
+
*
|
|
624
|
+
* @example
|
|
625
|
+
* // Instead of this.load(), use:
|
|
626
|
+
* return handleApiRequest({
|
|
627
|
+
* ctx,
|
|
628
|
+
* key: ActionKey.GetItems,
|
|
629
|
+
* request$: req$,
|
|
630
|
+
* onSuccess: (response) => ({
|
|
631
|
+
* items: response.data ?? [],
|
|
632
|
+
* }),
|
|
633
|
+
* });
|
|
533
634
|
*/
|
|
534
635
|
protected load<TData = T[]>(ctx: StateContext<TState>, config: CrudLoadConfig<T, TState, TData>): Observable<Response<TData>>;
|
|
535
636
|
/**
|
|
@@ -618,5 +719,15 @@ interface RequestContextConfig {
|
|
|
618
719
|
*/
|
|
619
720
|
declare const REQUEST_CONTEXT: HttpContextToken<RequestContextConfig>;
|
|
620
721
|
|
|
621
|
-
|
|
722
|
+
/**
|
|
723
|
+
* Color utility functions for brand display.
|
|
724
|
+
*/
|
|
725
|
+
/**
|
|
726
|
+
* Converts a hex color to a light shade (equivalent to primary-100 in Tailwind).
|
|
727
|
+
* This creates a color with ~10% opacity or a very light tint by mixing with white.
|
|
728
|
+
*/
|
|
729
|
+
declare function getLightColor(hexColor: string): string;
|
|
730
|
+
declare function getContrastColor(bgColor: string): string;
|
|
731
|
+
|
|
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 };
|
|
622
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 };
|