@cccteam/ccc-lib 0.0.21 → 0.0.22

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,6 +1,39 @@
1
1
  import { FormGroup, FormArray } from '@angular/forms';
2
- import { isEqual } from 'lodash-es';
3
2
 
3
+ /**
4
+ * Deep equality comparison for two values.
5
+ * Handles primitives, arrays, objects, dates, and null/undefined.
6
+ */
7
+ function isEqual(a, b) {
8
+ // Same reference or both primitives with same value
9
+ if (a === b)
10
+ return true;
11
+ // Handle null/undefined
12
+ if (a == null || b == null)
13
+ return a === b;
14
+ // Handle different types
15
+ if (typeof a !== typeof b)
16
+ return false;
17
+ // Handle Date objects
18
+ if (a instanceof Date && b instanceof Date) {
19
+ return a.getTime() === b.getTime();
20
+ }
21
+ // Handle arrays
22
+ if (Array.isArray(a) && Array.isArray(b)) {
23
+ if (a.length !== b.length)
24
+ return false;
25
+ return a.every((item, index) => isEqual(item, b[index]));
26
+ }
27
+ // Handle objects
28
+ if (typeof a === 'object' && typeof b === 'object') {
29
+ const keysA = Object.keys(a);
30
+ const keysB = Object.keys(b);
31
+ if (keysA.length !== keysB.length)
32
+ return false;
33
+ return keysA.every((key) => isEqual(a[key], b[key]));
34
+ }
35
+ return false;
36
+ }
4
37
  /**
5
38
  * Compares two objects and returns a sparse object containing only the differing key-value pairs
6
39
  * @param data - object to compare
@@ -1 +1 @@
1
- {"version":3,"file":"cccteam-ccc-lib-forms.mjs","sources":["../../../projects/ccc-lib/forms/index.ts","../../../projects/ccc-lib/forms/cccteam-ccc-lib-forms.ts"],"sourcesContent":["import { AbstractControl, FormArray, FormGroup } from '@angular/forms';\nimport { isEqual } from 'lodash-es';\n\n/**\n * Compares two objects and returns a sparse object containing only the differing key-value pairs\n * @param data - object to compare\n * @param compareData - object to compare against\n * @returns Partial<T>\n * @example sparseData<UserCreate>(this.user, initUser)\n */\nexport function sparseData<T extends Record<string, unknown>>(data: T, compareData: T): Partial<T> {\n const sparseData: Partial<T> = {};\n\n for (const key in data) {\n if (Object.prototype.hasOwnProperty.call(data, key)) {\n if (!isEqual(data[key], compareData[key])) {\n sparseData[key] = data[key];\n }\n }\n }\n\n return sparseData;\n}\n\n/**\n * Iterates through a form group's controls and returns a sparse object with only the changed values.\n * @param form - The form group to iterate through\n * @param compareData - The object to compare the form's values to\n * @returns - A sparse object with only the changed values\n * @example sparseFormData<UserCreate>(this.userForm, initUser)\n */\nexport function sparseFormData<T>(form: FormGroup, compareData: T): T {\n const sparseFormData: T = {} as T;\n for (const key in form.controls) {\n if (Object.prototype.hasOwnProperty.call(form.controls, key)) {\n const control = form.controls[key];\n const controlValue = control.value;\n const compareValue = compareData[key as keyof T];\n if (controlValue !== compareValue) {\n sparseFormData[key as keyof T] = controlValue as T[keyof T];\n }\n }\n }\n return sparseFormData;\n}\n\n/**\n * Recursively cleans a FormGroup or FormArray, removing controls with empty string values.\n * Similar to sparseFormData, but doesn't compare to an initial state\n * @param control - The FormGroup or FormArray to clean.\n * @returns A cleaned object with non-empty values.\n */\nexport function cleanStringForm<T>(control: AbstractControl): T | undefined {\n if (control instanceof FormGroup) {\n const cleanedGroup: Record<string, unknown> = {};\n for (const key of Object.keys(control.controls)) {\n const childControl = control.get(key);\n if (childControl) {\n const cleanedValue = cleanStringForm(childControl);\n if (cleanedValue !== undefined && cleanedValue !== null && cleanedValue !== '') {\n cleanedGroup[key] = cleanedValue;\n }\n }\n }\n return cleanedGroup as T;\n } else if (control instanceof FormArray) {\n const cleanedArray = control.controls\n .map((childControl) => cleanStringForm(childControl))\n .filter((item) => item !== undefined && item !== null && item !== '');\n return cleanedArray as unknown as T;\n } else {\n return control.value !== '' ? control.value : undefined;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAGA;;;;;;AAMG;AACG,SAAU,UAAU,CAAoC,IAAO,EAAE,WAAc,EAAA;IACnF,MAAM,UAAU,GAAe,EAAE;AAEjC,IA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A,MAAM,YAAY,GAAG,eAAe,CAAC,YAAY,CAAC;AAClD,gBAAA,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,EAAE,EAAE;AAC9E,oBAAA,YAAY,CAAC,GAAG,CAAC,GAAG,YAAY;gBAClC;YACF;QACF;AACA,QAAA,OAAO,YAAiB;IAC1B;AAAO,SAAA,IAAI,OAAO,YAAY,SAAS,EAAE;AACvC,QAAA,MAAM,YAAY,GAAG,OAAO,CAAC;aAC1B,GAAG,CAAC,CAAC,YAAY,KAAK,eAAe,CAAC,YAAY,CAAC;AACnD,aAAA,MAAM,CAAC,CAAC,IAAI,KAAK,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;AACvE,QAAA,OAAO,YAA4B;IACrC;SAAO;AACL,QAAA,OAAO,OAAO,CAAC,KAAK,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS;IACzD;AACF;;ACzEA;;AAEG;;;;"}
1
+ {"version":3,"file":"cccteam-ccc-lib-forms.mjs","sources":["../../../projects/ccc-lib/forms/index.ts","../../../projects/ccc-lib/forms/cccteam-ccc-lib-forms.ts"],"sourcesContent":["import { AbstractControl, FormArray, FormGroup } from '@angular/forms';\n\n/**\n * Deep equality comparison for two values.\n * Handles primitives, arrays, objects, dates, and null/undefined.\n */\nfunction isEqual(a: unknown, b: unknown): boolean {\n // Same reference or both primitives with same value\n if (a === b) return true;\n\n // Handle null/undefined\n if (a == null || b == null) return a === b;\n\n // Handle different types\n if (typeof a !== typeof b) return false;\n\n // Handle Date objects\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Handle arrays\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n return a.every((item, index) => isEqual(item, b[index]));\n }\n\n // Handle objects\n if (typeof a === 'object' && typeof b === 'object') {\n const keysA = Object.keys(a as object);\n const keysB = Object.keys(b as object);\n if (keysA.length !== keysB.length) return false;\n return keysA.every((key) => isEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key]));\n }\n\n return false;\n}\n\n/**\n * Compares two objects and returns a sparse object containing only the differing key-value pairs\n * @param data - object to compare\n * @param compareData - object to compare against\n * @returns Partial<T>\n * @example sparseData<UserCreate>(this.user, initUser)\n */\nexport function sparseData<T extends Record<string, unknown>>(data: T, compareData: T): Partial<T> {\n const sparseData: Partial<T> = {};\n\n for (const key in data) {\n if (Object.prototype.hasOwnProperty.call(data, key)) {\n if (!isEqual(data[key], compareData[key])) {\n sparseData[key] = data[key];\n }\n }\n }\n\n return sparseData;\n}\n\n/**\n * Iterates through a form group's controls and returns a sparse object with only the changed values.\n * @param form - The form group to iterate through\n * @param compareData - The object to compare the form's values to\n * @returns - A sparse object with only the changed values\n * @example sparseFormData<UserCreate>(this.userForm, initUser)\n */\nexport function sparseFormData<T>(form: FormGroup, compareData: T): T {\n const sparseFormData: T = {} as T;\n for (const key in form.controls) {\n if (Object.prototype.hasOwnProperty.call(form.controls, key)) {\n const control = form.controls[key];\n const controlValue = control.value;\n const compareValue = compareData[key as keyof T];\n if (controlValue !== compareValue) {\n sparseFormData[key as keyof T] = controlValue as T[keyof T];\n }\n }\n }\n return sparseFormData;\n}\n\n/**\n * Recursively cleans a FormGroup or FormArray, removing controls with empty string values.\n * Similar to sparseFormData, but doesn't compare to an initial state\n * @param control - The FormGroup or FormArray to clean.\n * @returns A cleaned object with non-empty values.\n */\nexport function cleanStringForm<T>(control: AbstractControl): T | undefined {\n if (control instanceof FormGroup) {\n const cleanedGroup: Record<string, unknown> = {};\n for (const key of Object.keys(control.controls)) {\n const childControl = control.get(key);\n if (childControl) {\n const cleanedValue = cleanStringForm(childControl);\n if (cleanedValue !== undefined && cleanedValue !== null && cleanedValue !== '') {\n cleanedGroup[key] = cleanedValue;\n }\n }\n }\n return cleanedGroup as T;\n } else if (control instanceof FormArray) {\n const cleanedArray = control.controls\n .map((childControl) => cleanStringForm(childControl))\n .filter((item) => item !== undefined && item !== null && item !== '');\n return cleanedArray as unknown as T;\n } else {\n return control.value !== '' ? control.value : undefined;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACH,SAAS,OAAO,CAAC,CAAU,EAAE,CAAU,EAAA;;IAErC,IAAI,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;;AAGxB,IAAA,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI;QAAE,OAAO,CAAC,KAAK,CAAC;;AAG1C,IAAA,IAAI,OAAO,CAAC,KAAK,OAAO,CAAC;AAAE,QAAA,OAAO,KAAK;;IAGvC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,IAAI,EAAE;QAC1C,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE;IACpC;;AAGA,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;AACxC,QAAA,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;AAAE,YAAA,OAAO,KAAK;QACvC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1D;;IAGA,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;QAClD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAW,CAAC;QACtC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAW,CAAC;AACtC,QAAA,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;AAAE,YAAA,OAAO,KAAK;QAC/C,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC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AY,SAAS,EAAE;QAChC,MAAM,YAAY,GAA4B,EAAE;AAChD,QAAA,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC/C,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;YACrC,IAAI,YAAY,EAAE;AAChB,gBAAA,MAAM,YAAY,GAAG,eAAe,CAAC,YAAY,CAAC;AAClD,gBAAA,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,EAAE,EAAE;AAC9E,oBAAA,YAAY,CAAC,GAAG,CAAC,GAAG,YAAY;gBAClC;YACF;QACF;AACA,QAAA,OAAO,YAAiB;IAC1B;AAAO,SAAA,IAAI,OAAO,YAAY,SAAS,EAAE;AACvC,QAAA,MAAM,YAAY,GAAG,OAAO,CAAC;aAC1B,GAAG,CAAC,CAAC,YAAY,KAAK,eAAe,CAAC,YAAY,CAAC;AACnD,aAAA,MAAM,CAAC,CAAC,IAAI,KAAK,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;AACvE,QAAA,OAAO,YAA4B;IACrC;SAAO;AACL,QAAA,OAAO,OAAO,CAAC,KAAK,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS;IACzD;AACF;;AC5GA;;AAEG;;;;"}
@@ -1,7 +1,8 @@
1
1
  import { inject } from '@angular/core';
2
2
  import { MatDialog } from '@angular/material/dialog';
3
3
  import { AuthService } from '@cccteam/ccc-lib/auth-service';
4
- import { FormStateService, LeavePageConfirmationModalComponent } from '@cccteam/ccc-lib/ccc-resource';
4
+ import { LeavePageConfirmationModalComponent } from '@cccteam/ccc-lib/ccc-resource-modals';
5
+ import { FormStateService } from '@cccteam/ccc-lib/ccc-resource-services';
5
6
  import { tap, firstValueFrom } from 'rxjs';
6
7
 
7
8
  const canDeactivateGuard = async (_, __, ___, nextState) => {
@@ -1 +1 @@
1
- {"version":3,"file":"cccteam-ccc-lib-guards.mjs","sources":["../../../projects/ccc-lib/guards/can-deactivate.guard.ts","../../../projects/ccc-lib/guards/cccteam-ccc-lib-guards.ts"],"sourcesContent":["import { inject } from '@angular/core';\nimport { MatDialog } from '@angular/material/dialog';\nimport { CanDeactivateFn, UrlTree } from '@angular/router';\nimport { AuthService } from '@cccteam/ccc-lib/auth-service';\nimport { FormStateService, LeavePageConfirmationModalComponent } from '@cccteam/ccc-lib/ccc-resource';\nimport { firstValueFrom, Observable, tap } from 'rxjs';\n\nexport type CanDeactivateType = Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;\n\nexport interface CanComponentDeactivate {\n canDeactivate: () => CanDeactivateType;\n}\n\nexport const canDeactivateGuard: CanDeactivateFn<CanComponentDeactivate> = async (_, __, ___, nextState) => {\n const auth = inject(AuthService);\n const dialog = inject(MatDialog);\n const formStateService = inject(FormStateService);\n\n if (nextState?.url.includes(auth.loginRoute())) {\n return true;\n }\n\n if (!formStateService.isDirty()) {\n return true;\n }\n\n const existingDialog = dialog.openDialogs.find(\n (d) => d.componentInstance instanceof LeavePageConfirmationModalComponent,\n );\n\n const dialogRef = existingDialog ?? dialog.open(LeavePageConfirmationModalComponent, { delayFocusTrap: false });\n\n const result = dialogRef.afterClosed().pipe(\n tap((value) => {\n if (value === true) {\n formStateService.resetDirtyForms();\n }\n }),\n );\n\n return firstValueFrom(result);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAaO,MAAM,kBAAkB,GAA4C,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,KAAI;AACzG,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;AAChC,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC;AAChC,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAEjD,IAAA,IAAI,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE;AAC9C,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAE;AAC/B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAC5C,CAAC,CAAC,KAAK,CAAC,CAAC,iBAAiB,YAAY,mCAAmC,CAC1E;AAED,IAAA,MAAM,SAAS,GAAG,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,mCAAmC,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;AAE/G,IAAA,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,IAAI,CACzC,GAAG,CAAC,CAAC,KAAK,KAAI;AACZ,QAAA,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,gBAAgB,CAAC,eAAe,EAAE;QACpC;IACF,CAAC,CAAC,CACH;AAED,IAAA,OAAO,cAAc,CAAC,MAAM,CAAC;AAC/B;;ACzCA;;AAEG;;;;"}
1
+ {"version":3,"file":"cccteam-ccc-lib-guards.mjs","sources":["../../../projects/ccc-lib/guards/can-deactivate.guard.ts","../../../projects/ccc-lib/guards/cccteam-ccc-lib-guards.ts"],"sourcesContent":["import { inject } from '@angular/core';\nimport { MatDialog } from '@angular/material/dialog';\nimport { CanDeactivateFn, UrlTree } from '@angular/router';\nimport { AuthService } from '@cccteam/ccc-lib/auth-service';\nimport { LeavePageConfirmationModalComponent } from '@cccteam/ccc-lib/ccc-resource-modals';\nimport { FormStateService } from '@cccteam/ccc-lib/ccc-resource-services';\nimport { firstValueFrom, Observable, tap } from 'rxjs';\n\nexport type CanDeactivateType = Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;\n\nexport interface CanComponentDeactivate {\n canDeactivate: () => CanDeactivateType;\n}\n\nexport const canDeactivateGuard: CanDeactivateFn<CanComponentDeactivate> = async (_, __, ___, nextState) => {\n const auth = inject(AuthService);\n const dialog = inject(MatDialog);\n const formStateService = inject(FormStateService);\n\n if (nextState?.url.includes(auth.loginRoute())) {\n return true;\n }\n\n if (!formStateService.isDirty()) {\n return true;\n }\n\n const existingDialog = dialog.openDialogs.find(\n (d) => d.componentInstance instanceof LeavePageConfirmationModalComponent,\n );\n\n const dialogRef = existingDialog ?? dialog.open(LeavePageConfirmationModalComponent, { delayFocusTrap: false });\n\n const result = dialogRef.afterClosed().pipe(\n tap((value) => {\n if (value === true) {\n formStateService.resetDirtyForms();\n }\n }),\n );\n\n return firstValueFrom(result);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAcO,MAAM,kBAAkB,GAA4C,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,KAAI;AACzG,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC;AAChC,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC;AAChC,IAAA,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAEjD,IAAA,IAAI,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE;AAC9C,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAE;AAC/B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAC5C,CAAC,CAAC,KAAK,CAAC,CAAC,iBAAiB,YAAY,mCAAmC,CAC1E;AAED,IAAA,MAAM,SAAS,GAAG,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,mCAAmC,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;AAE/G,IAAA,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,IAAI,CACzC,GAAG,CAAC,CAAC,KAAK,KAAI;AACZ,QAAA,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,gBAAgB,CAAC,eAAe,EAAE;QACpC;IACF,CAAC,CAAC,CACH;AAED,IAAA,OAAO,cAAc,CAAC,MAAM,CAAC;AAC/B;;AC1CA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cccteam/ccc-lib",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git://github.com/cccteam/ccc-lib.git"
@@ -57,6 +57,14 @@
57
57
  "types": "./types/cccteam-ccc-lib-ccc-resource.d.ts",
58
58
  "default": "./fesm2022/cccteam-ccc-lib-ccc-resource.mjs"
59
59
  },
60
+ "./ccc-resource-modals": {
61
+ "types": "./types/cccteam-ccc-lib-ccc-resource-modals.d.ts",
62
+ "default": "./fesm2022/cccteam-ccc-lib-ccc-resource-modals.mjs"
63
+ },
64
+ "./ccc-resource-services": {
65
+ "types": "./types/cccteam-ccc-lib-ccc-resource-services.d.ts",
66
+ "default": "./fesm2022/cccteam-ccc-lib-ccc-resource-services.mjs"
67
+ },
60
68
  "./forms": {
61
69
  "types": "./types/cccteam-ccc-lib-forms.d.ts",
62
70
  "default": "./fesm2022/cccteam-ccc-lib-forms.mjs"
@@ -0,0 +1,8 @@
1
+ import * as i0 from '@angular/core';
2
+
3
+ declare class LeavePageConfirmationModalComponent {
4
+ static ɵfac: i0.ɵɵFactoryDeclaration<LeavePageConfirmationModalComponent, never>;
5
+ static ɵcmp: i0.ɵɵComponentDeclaration<LeavePageConfirmationModalComponent, "ccc-leave-page-confirmation-modal", never, {}, {}, never, never, true, never>;
6
+ }
7
+
8
+ export { LeavePageConfirmationModalComponent };
@@ -0,0 +1,13 @@
1
+ import * as _angular_core from '@angular/core';
2
+
3
+ declare class FormStateService {
4
+ dirtyForms: _angular_core.WritableSignal<number>;
5
+ incrementDirtyForms(): void;
6
+ decrementDirtyForms(): void;
7
+ resetDirtyForms(): void;
8
+ isDirty: _angular_core.Signal<boolean>;
9
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormStateService, never>;
10
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<FormStateService>;
11
+ }
12
+
13
+ export { FormStateService };
@@ -4,6 +4,7 @@ import * as _cccteam_ccc_lib_types from '@cccteam/ccc-lib/types';
4
4
  import { ResourceMeta, RecordData, Resource, DataType, ViewConfig, ConfigElement, RPCRecordData, MethodMeta, FieldSort, ColumnConfig, RPCConfig, FieldElement, Method, RPCBaseFormData, RootConfig, ParentResourceConfig, ChildResourceConfig, FormatType, PaddingElement, ArrayConfig, ListViewConfig, Meta, FieldMeta, RPCFieldMeta, ValidDisplayTypes, ComponentConfig } from '@cccteam/ccc-lib/types';
5
5
  import { MatDialog } from '@angular/material/dialog';
6
6
  import { Router, ActivatedRoute } from '@angular/router';
7
+ import { FormStateService } from '@cccteam/ccc-lib/ccc-resource-services';
7
8
  import { NotificationService } from '@cccteam/ccc-lib/ui-notification-service';
8
9
  import { HttpClient } from '@angular/common/http';
9
10
  import { Observable } from 'rxjs';
@@ -29,16 +30,6 @@ declare class ActionAccessControlWrapperComponent {
29
30
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<ActionAccessControlWrapperComponent, "action-access-control-wrapper", never, { "actionContext": { "alias": "actionContext"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
30
31
  }
31
32
 
32
- declare class FormStateService {
33
- dirtyForms: _angular_core.WritableSignal<number>;
34
- incrementDirtyForms(): void;
35
- decrementDirtyForms(): void;
36
- resetDirtyForms(): void;
37
- isDirty: _angular_core.Signal<boolean>;
38
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormStateService, never>;
39
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<FormStateService>;
40
- }
41
-
42
33
  interface Link {
43
34
  id: string;
44
35
  resource: Resource;
@@ -282,6 +273,15 @@ declare function hyphenSpaceConcatWithoutResource(args: string[]): string;
282
273
  * @example noSpaceConcatWithoutResource(['foo', 'bar', 'baz']) => 'foobarbaz'
283
274
  */
284
275
  declare function noSpaceConcatWithoutResource(args: string[]): string;
276
+ /**
277
+ * Converts a string to camelCase.
278
+ * @param str The string to convert.
279
+ * @returns The camelCase version of the string.
280
+ * @example camelCase('hello-world') => 'helloWorld'
281
+ * @example camelCase('HelloWorld') => 'helloWorld'
282
+ * @example camelCase('hello_world') => 'helloWorld'
283
+ */
284
+ declare function camelCase(str: string): string;
285
285
 
286
286
  declare class DeleteResourceConfirmationModalComponent {
287
287
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<DeleteResourceConfirmationModalComponent, never>;
@@ -324,11 +324,6 @@ declare const resourceValidators: Readonly<{
324
324
  MAX_LENGTH: (maxLength: number) => _cccteam_ccc_lib_types.ResourceValidatorFn;
325
325
  }>;
326
326
 
327
- declare class LeavePageConfirmationModalComponent {
328
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<LeavePageConfirmationModalComponent, never>;
329
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<LeavePageConfirmationModalComponent, "ccc-leave-page-confirmation-modal", never, {}, {}, never, never, true, never>;
330
- }
331
-
332
327
  declare class PaddingElementComponent implements OnInit {
333
328
  paddingElement: _angular_core.InputSignal<PaddingElement>;
334
329
  class: string;
@@ -631,5 +626,5 @@ declare class ResourceViewComponent implements OnInit {
631
626
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<ResourceViewComponent, "ccc-resource-view", never, { "uuid": { "alias": "uuid"; "required": true; "isSignal": true; }; "config": { "alias": "config"; "required": true; "isSignal": true; }; "relatedData": { "alias": "relatedData"; "required": false; "isSignal": true; }; "compoundResourceView": { "alias": "compoundResourceView"; "required": false; "isSignal": true; }; "navAfterDelete": { "alias": "navAfterDelete"; "required": false; "isSignal": true; }; "showCreateForm": { "alias": "showCreateForm"; "required": false; "isSignal": true; }; }, { "deleted": "deleted"; "showCreateForm": "showCreateFormChange"; }, never, never, true, never>;
632
627
  }
633
628
 
634
- export { ActionAccessControlWrapperComponent, BaseInputComponent, BaseRPCModalComponent, CompoundResourceComponent, DeleteResourceConfirmationModalComponent, EmptyReadonlyFieldComponent, FormStateService, LeavePageConfirmationModalComponent, PaddingElementComponent, ResourceArrayViewComponent, ResourceCreateComponent, ResourceFieldComponent, ResourceLayoutComponent, ResourceListComponent, ResourceListCreateComponent, ResourceResolverComponent, ResourceStore, ResourceViewComponent, RpcButtonComponent, ValueFormatters, applyFormatting, civildateCoercion, concatFunctions, createFormGroup, extractFieldNames, flattenElements, formatDateString, hyphenConcat, hyphenConcatWithoutResource, hyphenSpaceConcat, hyphenSpaceConcatWithoutResource, isUUID, maxConfigElementRecursionDepth, maxLayoutNestingDepth, metadataTypeCoercion, noSpaceConcatWithoutResource, resourceValidators, simpleSlashDateFormatter, spaceConcat, spaceConcatWithoutResource, spaceHyphenConcat, spaceHyphenConcatWithoutResource };
629
+ export { ActionAccessControlWrapperComponent, BaseInputComponent, BaseRPCModalComponent, CompoundResourceComponent, DeleteResourceConfirmationModalComponent, EmptyReadonlyFieldComponent, PaddingElementComponent, ResourceArrayViewComponent, ResourceCreateComponent, ResourceFieldComponent, ResourceLayoutComponent, ResourceListComponent, ResourceListCreateComponent, ResourceResolverComponent, ResourceStore, ResourceViewComponent, RpcButtonComponent, ValueFormatters, applyFormatting, camelCase, civildateCoercion, concatFunctions, createFormGroup, extractFieldNames, flattenElements, formatDateString, hyphenConcat, hyphenConcatWithoutResource, hyphenSpaceConcat, hyphenSpaceConcatWithoutResource, isUUID, maxConfigElementRecursionDepth, maxLayoutNestingDepth, metadataTypeCoercion, noSpaceConcatWithoutResource, resourceValidators, simpleSlashDateFormatter, spaceConcat, spaceConcatWithoutResource, spaceHyphenConcat, spaceHyphenConcatWithoutResource };
635
630
  export type { ActionButtonContext, CreateOperation, DeleteOperation, FormatterFn, Link, Operation, PatchOperation, PristineData, UpdateOperation };