@sdcorejs/angular 21.0.7 → 21.0.9
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/README.md +8 -2
- package/assets/STYLE-GUIDE.md +13 -0
- package/fesm2022/sdcorejs-angular-components-anchor.mjs +2 -3
- package/fesm2022/sdcorejs-angular-components-anchor.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-autoid-inspector.mjs +195 -25
- package/fesm2022/sdcorejs-angular-components-autoid-inspector.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-badge.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-badge.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-button.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-button.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-document-builder.mjs +5 -6
- package/fesm2022/sdcorejs-angular-components-document-builder.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-editor.mjs +4 -4
- package/fesm2022/sdcorejs-angular-components-editor.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs +4 -4
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-import-excel.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-inform.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-inform.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-modal.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-modal.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-operator.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-operator.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-org-chart.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-org-chart.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-preview.mjs +3 -3
- package/fesm2022/sdcorejs-angular-components-preview.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-query-bar.mjs +8 -8
- package/fesm2022/sdcorejs-angular-components-query-bar.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-section.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-section.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs +6 -4
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-table.mjs +772 -810
- package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-tree.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-tree.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-upload-file.mjs +6 -7
- package/fesm2022/sdcorejs-angular-components-upload-file.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs +4 -5
- package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-checkbox.mjs +3 -3
- package/fesm2022/sdcorejs-angular-forms-checkbox.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs +4 -4
- package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-chip.mjs +4 -4
- package/fesm2022/sdcorejs-angular-forms-chip.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-date-range.mjs +16 -9
- package/fesm2022/sdcorejs-angular-forms-date-range.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-date.mjs +5 -6
- package/fesm2022/sdcorejs-angular-forms-date.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-datetime.mjs +5 -6
- package/fesm2022/sdcorejs-angular-forms-datetime.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-inline-text.mjs +2 -2
- package/fesm2022/sdcorejs-angular-forms-inline-text.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input-number.mjs +5 -6
- package/fesm2022/sdcorejs-angular-forms-input-number.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-input.mjs +3 -3
- package/fesm2022/sdcorejs-angular-forms-input.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-radio.mjs +3 -4
- package/fesm2022/sdcorejs-angular-forms-radio.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-select.mjs +2 -2
- package/fesm2022/sdcorejs-angular-forms-select.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-switch.mjs +3 -4
- package/fesm2022/sdcorejs-angular-forms-switch.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-textarea.mjs +5 -7
- package/fesm2022/sdcorejs-angular-forms-textarea.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-layout.mjs +2 -3
- package/fesm2022/sdcorejs-angular-modules-layout.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-api.mjs +1 -2
- package/fesm2022/sdcorejs-angular-services-api.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-services-confirm.mjs +2 -2
- package/fesm2022/sdcorejs-angular-services-confirm.mjs.map +1 -1
- package/package.json +1 -1
- package/types/sdcorejs-angular-components-autoid-inspector.d.ts +47 -137
- package/types/sdcorejs-angular-components-table.d.ts +5 -9
- package/types/sdcorejs-angular-forms-date-range.d.ts +2 -0
- package/types/sdcorejs-angular-forms-input-number.d.ts +0 -1
|
@@ -5,7 +5,6 @@ import { SdCacheService } from '@sdcorejs/angular/services/cache';
|
|
|
5
5
|
import { BrowserUtilities, Utilities } from '@sdcorejs/utils/fns';
|
|
6
6
|
import { lastValueFrom, from, throwError } from 'rxjs';
|
|
7
7
|
import { timeout, map, catchError, shareReplay, switchMap } from 'rxjs/operators';
|
|
8
|
-
import { v4 } from 'uuid';
|
|
9
8
|
|
|
10
9
|
const SD_API_CONFIG = new InjectionToken('sd-api.configuration');
|
|
11
10
|
const SD_API_CONFIGURATION = new InjectionToken('sd-api.configuration');
|
|
@@ -134,7 +133,7 @@ class SdApiService {
|
|
|
134
133
|
#generateKey = (url, method, body, option) => {
|
|
135
134
|
// FormData không hash được nội dung file, luôn generate key mới
|
|
136
135
|
if (body instanceof FormData || option?.autoCache === false) {
|
|
137
|
-
return
|
|
136
|
+
return Utilities.generateUuid();
|
|
138
137
|
}
|
|
139
138
|
return Utilities.hash({
|
|
140
139
|
url,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdcorejs-angular-services-api.mjs","sources":["../../../projects/sdcorejs-angular/services/api/src/api.model.ts","../../../projects/sdcorejs-angular/services/api/src/api.service.ts","../../../projects/sdcorejs-angular/services/api/src/interceptors/api.interceptor.ts","../../../projects/sdcorejs-angular/services/api/src/api.module.ts","../../../projects/sdcorejs-angular/services/api/sdcorejs-angular-services-api.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { HttpClient, HttpErrorResponse, HttpRequest, HttpResponse } from '@angular/common/http';\nimport { InjectionToken } from '@angular/core';\nimport { SdCacheOption } from '@sdcorejs/angular/services/cache';\n// import hash from 'object-hash';\n\nexport interface SdApiOption {\n cacheOption?: SdCacheOption;\n timeout?: number; // Default: 30000 (30s)\n autoCache?: boolean; // Default: true\n}\ntype HttpGetOption = Parameters<HttpClient['get']>[1];\nexport type SdGetOption = HttpGetOption & SdApiOption;\n\ntype HttpPostOption = Parameters<HttpClient['post']>[2];\nexport type SdPostOption = HttpPostOption & SdApiOption;\n\ntype HttpPutOption = Parameters<HttpClient['put']>[2];\nexport type SdPutOption = HttpPutOption & SdApiOption;\n\ntype HttpDeleteOption = Parameters<HttpClient['delete']>[1];\nexport type SdDeleteOption = HttpDeleteOption & SdApiOption;\n\nexport interface SdApiHandler {\n /** Danh sách host URL mà handler này sẽ xử lý */\n hosts: string[];\n /** Can thiệp request: gắn header, token, transform body... */\n intercept?: (request: HttpRequest<any>) => HttpRequest<any>;\n /** Hook chạy TRƯỚC khi gửi request (dùng để log, tracking...) */\n beforeRemote?: (request: HttpRequest<any>) => void | Promise<void>;\n /** Hook chạy SAU khi nhận response (xử lý lỗi, notify...) */\n afterRemote?: (\n response: HttpResponse<any> | HttpErrorResponse | Error\n ) => void | Promise<void>;\n /** Transform response body thành kiểu dữ liệu mong muốn */\n mapResponse?: <Tres = any, Tdata = any>(response: Tres) => Tdata;\n /** Timeout tính bằng milliseconds. Mặc định: 30000 (30 giây) */\n timeout?: number;\n}\n\nexport interface ISdApiConfiguration {\n handlers: SdApiHandler[];\n}\n\nexport const SD_API_CONFIG = new InjectionToken<ISdApiConfiguration>('sd-api.configuration');\n\nexport const SD_API_CONFIGURATION = new InjectionToken<ISdApiConfiguration>('sd-api.configuration');","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { HttpClient } from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { SdCacheService } from '@sdcorejs/angular/services/cache';\nimport { BrowserUtilities, Utilities } from '@sdcorejs/utils/fns';\nimport { lastValueFrom, Observable } from 'rxjs';\nimport { catchError, map, shareReplay, timeout } from 'rxjs/operators';\nimport { v4 } from 'uuid';\nimport { ISdApiConfiguration, SD_API_CONFIG, SdApiHandler, SdDeleteOption, SdGetOption, SdPostOption, SdPutOption } from './api.model';\n\n// Gom nhóm các Option lại cho gọn\ntype SdHttpOptions = SdGetOption & SdPostOption & SdPutOption & SdDeleteOption;\ntype HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SdApiService {\n readonly #defaultTimeout = 60000; // 60s\n readonly #dedupCacheDuration = 1000; // 1s (Deduplication cache duration)\n #httpClient = inject(HttpClient);\n #configurations = inject<ISdApiConfiguration[]>(SD_API_CONFIG, { optional: true }) || [];\n #cacheService = inject(SdCacheService);\n\n // Thay đổi cấu trúc Cache: Lưu Observable thay vì Subject phức tạp\n // Key: hash string -> Value: { stream$: Observable, expiry: number }\n #inFlightRequests: Map<string, { stream$: Observable<any>; expiry: number }> = new Map();\n\n constructor() {\n // Optional: Cơ chế dọn dẹp cache định kỳ (mỗi 1 phút dọn dẹp các key hết hạn)\n setInterval(() => this.#cleanupCache(), 60000);\n }\n\n get http() {\n return this.#httpClient;\n }\n\n // --- PUBLIC METHODS ---\n\n get = <T = any>(url: string, option?: SdGetOption): Promise<T> => {\n return this.#executeWithLayeredCache<T>(url, 'GET', undefined, option);\n };\n\n post = <T = any>(url: string, body?: any, option?: SdPostOption): Promise<T> => {\n return this.#executeWithLayeredCache<T>(url, 'POST', body, option);\n };\n\n put = <T = any>(url: string, body?: any, option?: SdPutOption): Promise<T> => {\n return this.#executeWithLayeredCache<T>(url, 'PUT', body, option);\n };\n\n delete = <T = any>(url: string, option?: SdDeleteOption): Promise<T> => {\n return this.#executeWithLayeredCache<T>(url, 'DELETE', undefined, option);\n };\n\n // Upload file logic giữ nguyên nhưng refactor nhẹ\n upload = async (url: string, option?: { extensions?: string[]; maxSizeInMb?: number }): Promise<any> => {\n const file = await BrowserUtilities.upload(option);\n if (!Array.isArray(file) && file) {\n return this.uploadFile(url, file);\n }\n };\n\n uploadFile = async (url: string, file: File): Promise<any> => {\n if (!file) return null;\n if (file.name.lastIndexOf('.') === -1) throw new Error('Invalid file extension');\n\n const formData = new FormData();\n formData.append('file', file, file.name);\n // Upload thường không cần deduplication cache, set autoCache: false\n return await this.post(url, formData, { autoCache: false });\n };\n\n // --- PRIVATE CORE LOGIC ---\n\n /**\n * Hàm trung gian xử lý Layer Cache (SdCacheService) trước khi gọi API thực tế\n */\n #executeWithLayeredCache = async <T>(url: string, method: HttpMethod, body?: any, option?: SdHttpOptions): Promise<T> => {\n // Layer 1: Persistent Cache (SdCacheService)\n if (option?.cacheOption) {\n const key = this.#generateKey(url, method, body, option);\n const { get, set, has } = this.#cacheService.create(key, option.cacheOption);\n\n if (has()) {\n return get();\n }\n\n const result = await this.#request<T>(url, method, body, option);\n set(result);\n return result;\n }\n\n // Không có cache dài hạn thì gọi trực tiếp logic deduplication\n return this.#request<T>(url, method, body, option);\n };\n\n /**\n * Core Request: Xử lý Deduplication, Timeout, Mapping Response\n */\n #request = <T>(url: string, method: HttpMethod, body: any, option?: SdHttpOptions): Promise<T> => {\n const key = this.#generateKey(url, method, body, option);\n\n // Layer 2: Deduplication Cache (In-Flight Request / Short-term cache)\n const now = Date.now();\n const cachedItem = this.#inFlightRequests.get(key);\n\n // Nếu đã có request đang chạy hoặc mới chạy xong trong vòng 1s -> Trả về stream đó luôn\n if (cachedItem && cachedItem.expiry > now) {\n return lastValueFrom(cachedItem.stream$);\n }\n\n // Setup request mới\n const handler = this.#getHandler(url);\n const apiTimeout = option?.timeout ?? handler?.timeout ?? this.#defaultTimeout;\n\n // Tạo Observable call API\n const request$ = this.#httpClient\n .request(method, url, {\n body,\n headers: option?.headers,\n params: option?.params,\n observe: 'response', // Lấy full response để check status\n responseType: option?.responseType,\n })\n .pipe(\n timeout(apiTimeout),\n map(res => {\n // Normalize Response Logic\n const bodyRes = res.body as any;\n // Logic check response cũ của bạn\n if (bodyRes && typeof bodyRes === 'object' && 'ok' in bodyRes && !bodyRes.ok) {\n throw bodyRes; // Giả sử structure trả về { ok: false, ... } là lỗi\n }\n\n if (handler?.mapResponse) {\n return handler.mapResponse(bodyRes);\n }\n\n return bodyRes;\n }),\n catchError(err => {\n // Xóa cache ngay lập tức nếu lỗi để user có thể retry\n this.#inFlightRequests.delete(key);\n throw err;\n }),\n // QUAN TRỌNG: shareReplay(1) giúp share kết quả cho các subscriber đến sau (trong 1s)\n shareReplay(1)\n );\n\n // Lưu vào Map\n this.#inFlightRequests.set(key, {\n stream$: request$,\n expiry: now + this.#dedupCacheDuration,\n });\n\n // Chuyển đổi sang Promise cho đúng return type của bạn\n return lastValueFrom(request$);\n };\n\n // --- HELPERS ---\n\n #getHandler = (url: string): SdApiHandler | undefined => {\n const handlers = this.#configurations.flatMap(b => b?.handlers || []);\n return handlers.find(e => e.hosts.some(host => url.startsWith(host)));\n };\n\n #generateKey = (url: string, method: HttpMethod, body: any, option?: SdHttpOptions): string => {\n // FormData không hash được nội dung file, luôn generate key mới\n if (body instanceof FormData || option?.autoCache === false) {\n return v4();\n }\n return Utilities.hash({\n url,\n method,\n params: option?.params,\n headers: option?.headers,\n body,\n });\n };\n\n // Dọn dẹp memory leak\n #cleanupCache() {\n const now = Date.now();\n this.#inFlightRequests.forEach((value, key) => {\n if (value.expiry < now) {\n this.#inFlightRequests.delete(key);\n }\n });\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { from, Observable, throwError } from 'rxjs';\nimport { catchError, map, switchMap } from 'rxjs/operators';\nimport { ISdApiConfiguration, SD_API_CONFIG } from '../api.model';\n\n@Injectable()\nexport class SdHttpInterceptor implements HttpInterceptor {\n #configurations = inject<ISdApiConfiguration[]>(SD_API_CONFIG, { optional: true }) || [];\n\n intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n const url = request.url;\n if (!url) {\n throw new Error(`Invalid URL`);\n }\n const handlers = this.#configurations.flatMap(configuration => configuration?.handlers || []);\n const handler = handlers?.find(e => e.hosts.some(host => url.startsWith(host)));\n const intercept = handler?.intercept;\n if (intercept) {\n request = request.clone(intercept(request));\n }\n if (request.body instanceof FormData) {\n request = request.clone({\n headers: request.headers.delete('Content-Type'),\n });\n }\n const beforeRemoteHandler = handler?.beforeRemote;\n const afterRemoteHandler = handler?.afterRemote;\n const beforeRemote = beforeRemoteHandler?.(request);\n if (beforeRemote instanceof Promise) {\n return from(beforeRemote).pipe(\n switchMap(() => next.handle(request)),\n map((event: HttpEvent<any>) => {\n if (event instanceof HttpResponse) {\n afterRemoteHandler?.(event);\n }\n return event;\n }),\n catchError((error: HttpErrorResponse) => {\n afterRemoteHandler?.(error);\n return throwError(() => error);\n })\n );\n }\n return next.handle(request).pipe(\n map((event: HttpEvent<any>) => {\n if (event instanceof HttpResponse) {\n afterRemoteHandler?.(event);\n }\n return event;\n }),\n catchError((error: HttpErrorResponse) => {\n afterRemoteHandler?.(error);\n return throwError(() => error);\n })\n );\n }\n}\n","import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';\nimport { NgModule } from '@angular/core';\nimport { SdHttpInterceptor } from './interceptors/api.interceptor';\n\n@NgModule({\n imports: [],\n exports: [],\n providers: [provideHttpClient(withInterceptorsFromDi()), { provide: HTTP_INTERCEPTORS, useClass: SdHttpInterceptor, multi: true }],\n})\nexport class SdApiModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;MA4Ca,aAAa,GAAG,IAAI,cAAc,CAAsB,sBAAsB;MAE9E,oBAAoB,GAAG,IAAI,cAAc,CAAsB,sBAAsB;;AC9ClG;MAiBa,YAAY,CAAA;AACd,IAAA,eAAe,GAAG,KAAK,CAAC;AACxB,IAAA,mBAAmB,GAAG,IAAI,CAAC;AACpC,IAAA,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;AAChC,IAAA,eAAe,GAAG,MAAM,CAAwB,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;AACxF,IAAA,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC;;;AAItC,IAAA,iBAAiB,GAA8D,IAAI,GAAG,EAAE;AAExF,IAAA,WAAA,GAAA;;QAEE,WAAW,CAAC,MAAM,IAAI,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC;IAChD;AAEA,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,WAAW;IACzB;;AAIA,IAAA,GAAG,GAAG,CAAU,GAAW,EAAE,MAAoB,KAAgB;AAC/D,QAAA,OAAO,IAAI,CAAC,wBAAwB,CAAI,GAAG,EA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EAAA,CAAA;yGAAX,WAAW,EAAA,CAAA;yGAAX,WAAW,EAAA,SAAA,EAFX,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAA,CAAA;;4FAEvH,WAAW,EAAA,UAAA,EAAA,CAAA;kBALvB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE,EAAE;AACX,oBAAA,OAAO,EAAE,EAAE;oBACX,SAAS,EAAE,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACnI,iBAAA;;;ACRD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"sdcorejs-angular-services-api.mjs","sources":["../../../projects/sdcorejs-angular/services/api/src/api.model.ts","../../../projects/sdcorejs-angular/services/api/src/api.service.ts","../../../projects/sdcorejs-angular/services/api/src/interceptors/api.interceptor.ts","../../../projects/sdcorejs-angular/services/api/src/api.module.ts","../../../projects/sdcorejs-angular/services/api/sdcorejs-angular-services-api.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { HttpClient, HttpErrorResponse, HttpRequest, HttpResponse } from '@angular/common/http';\nimport { InjectionToken } from '@angular/core';\nimport { SdCacheOption } from '@sdcorejs/angular/services/cache';\n// import hash from 'object-hash';\n\nexport interface SdApiOption {\n cacheOption?: SdCacheOption;\n timeout?: number; // Default: 30000 (30s)\n autoCache?: boolean; // Default: true\n}\ntype HttpGetOption = Parameters<HttpClient['get']>[1];\nexport type SdGetOption = HttpGetOption & SdApiOption;\n\ntype HttpPostOption = Parameters<HttpClient['post']>[2];\nexport type SdPostOption = HttpPostOption & SdApiOption;\n\ntype HttpPutOption = Parameters<HttpClient['put']>[2];\nexport type SdPutOption = HttpPutOption & SdApiOption;\n\ntype HttpDeleteOption = Parameters<HttpClient['delete']>[1];\nexport type SdDeleteOption = HttpDeleteOption & SdApiOption;\n\nexport interface SdApiHandler {\n /** Danh sách host URL mà handler này sẽ xử lý */\n hosts: string[];\n /** Can thiệp request: gắn header, token, transform body... */\n intercept?: (request: HttpRequest<any>) => HttpRequest<any>;\n /** Hook chạy TRƯỚC khi gửi request (dùng để log, tracking...) */\n beforeRemote?: (request: HttpRequest<any>) => void | Promise<void>;\n /** Hook chạy SAU khi nhận response (xử lý lỗi, notify...) */\n afterRemote?: (\n response: HttpResponse<any> | HttpErrorResponse | Error\n ) => void | Promise<void>;\n /** Transform response body thành kiểu dữ liệu mong muốn */\n mapResponse?: <Tres = any, Tdata = any>(response: Tres) => Tdata;\n /** Timeout tính bằng milliseconds. Mặc định: 30000 (30 giây) */\n timeout?: number;\n}\n\nexport interface ISdApiConfiguration {\n handlers: SdApiHandler[];\n}\n\nexport const SD_API_CONFIG = new InjectionToken<ISdApiConfiguration>('sd-api.configuration');\n\nexport const SD_API_CONFIGURATION = new InjectionToken<ISdApiConfiguration>('sd-api.configuration');","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { HttpClient } from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { SdCacheService } from '@sdcorejs/angular/services/cache';\nimport { BrowserUtilities, Utilities } from '@sdcorejs/utils/fns';\nimport { lastValueFrom, Observable } from 'rxjs';\nimport { catchError, map, shareReplay, timeout } from 'rxjs/operators';\nimport { ISdApiConfiguration, SD_API_CONFIG, SdApiHandler, SdDeleteOption, SdGetOption, SdPostOption, SdPutOption } from './api.model';\n\n// Gom nhóm các Option lại cho gọn\ntype SdHttpOptions = SdGetOption & SdPostOption & SdPutOption & SdDeleteOption;\ntype HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SdApiService {\n readonly #defaultTimeout = 60000; // 60s\n readonly #dedupCacheDuration = 1000; // 1s (Deduplication cache duration)\n #httpClient = inject(HttpClient);\n #configurations = inject<ISdApiConfiguration[]>(SD_API_CONFIG, { optional: true }) || [];\n #cacheService = inject(SdCacheService);\n\n // Thay đổi cấu trúc Cache: Lưu Observable thay vì Subject phức tạp\n // Key: hash string -> Value: { stream$: Observable, expiry: number }\n #inFlightRequests: Map<string, { stream$: Observable<any>; expiry: number }> = new Map();\n\n constructor() {\n // Optional: Cơ chế dọn dẹp cache định kỳ (mỗi 1 phút dọn dẹp các key hết hạn)\n setInterval(() => this.#cleanupCache(), 60000);\n }\n\n get http() {\n return this.#httpClient;\n }\n\n // --- PUBLIC METHODS ---\n\n get = <T = any>(url: string, option?: SdGetOption): Promise<T> => {\n return this.#executeWithLayeredCache<T>(url, 'GET', undefined, option);\n };\n\n post = <T = any>(url: string, body?: any, option?: SdPostOption): Promise<T> => {\n return this.#executeWithLayeredCache<T>(url, 'POST', body, option);\n };\n\n put = <T = any>(url: string, body?: any, option?: SdPutOption): Promise<T> => {\n return this.#executeWithLayeredCache<T>(url, 'PUT', body, option);\n };\n\n delete = <T = any>(url: string, option?: SdDeleteOption): Promise<T> => {\n return this.#executeWithLayeredCache<T>(url, 'DELETE', undefined, option);\n };\n\n // Upload file logic giữ nguyên nhưng refactor nhẹ\n upload = async (url: string, option?: { extensions?: string[]; maxSizeInMb?: number }): Promise<any> => {\n const file = await BrowserUtilities.upload(option);\n if (!Array.isArray(file) && file) {\n return this.uploadFile(url, file);\n }\n };\n\n uploadFile = async (url: string, file: File): Promise<any> => {\n if (!file) return null;\n if (file.name.lastIndexOf('.') === -1) throw new Error('Invalid file extension');\n\n const formData = new FormData();\n formData.append('file', file, file.name);\n // Upload thường không cần deduplication cache, set autoCache: false\n return await this.post(url, formData, { autoCache: false });\n };\n\n // --- PRIVATE CORE LOGIC ---\n\n /**\n * Hàm trung gian xử lý Layer Cache (SdCacheService) trước khi gọi API thực tế\n */\n #executeWithLayeredCache = async <T>(url: string, method: HttpMethod, body?: any, option?: SdHttpOptions): Promise<T> => {\n // Layer 1: Persistent Cache (SdCacheService)\n if (option?.cacheOption) {\n const key = this.#generateKey(url, method, body, option);\n const { get, set, has } = this.#cacheService.create(key, option.cacheOption);\n\n if (has()) {\n return get();\n }\n\n const result = await this.#request<T>(url, method, body, option);\n set(result);\n return result;\n }\n\n // Không có cache dài hạn thì gọi trực tiếp logic deduplication\n return this.#request<T>(url, method, body, option);\n };\n\n /**\n * Core Request: Xử lý Deduplication, Timeout, Mapping Response\n */\n #request = <T>(url: string, method: HttpMethod, body: any, option?: SdHttpOptions): Promise<T> => {\n const key = this.#generateKey(url, method, body, option);\n\n // Layer 2: Deduplication Cache (In-Flight Request / Short-term cache)\n const now = Date.now();\n const cachedItem = this.#inFlightRequests.get(key);\n\n // Nếu đã có request đang chạy hoặc mới chạy xong trong vòng 1s -> Trả về stream đó luôn\n if (cachedItem && cachedItem.expiry > now) {\n return lastValueFrom(cachedItem.stream$);\n }\n\n // Setup request mới\n const handler = this.#getHandler(url);\n const apiTimeout = option?.timeout ?? handler?.timeout ?? this.#defaultTimeout;\n\n // Tạo Observable call API\n const request$ = this.#httpClient\n .request(method, url, {\n body,\n headers: option?.headers,\n params: option?.params,\n observe: 'response', // Lấy full response để check status\n responseType: option?.responseType,\n })\n .pipe(\n timeout(apiTimeout),\n map(res => {\n // Normalize Response Logic\n const bodyRes = res.body as any;\n // Logic check response cũ của bạn\n if (bodyRes && typeof bodyRes === 'object' && 'ok' in bodyRes && !bodyRes.ok) {\n throw bodyRes; // Giả sử structure trả về { ok: false, ... } là lỗi\n }\n\n if (handler?.mapResponse) {\n return handler.mapResponse(bodyRes);\n }\n\n return bodyRes;\n }),\n catchError(err => {\n // Xóa cache ngay lập tức nếu lỗi để user có thể retry\n this.#inFlightRequests.delete(key);\n throw err;\n }),\n // QUAN TRỌNG: shareReplay(1) giúp share kết quả cho các subscriber đến sau (trong 1s)\n shareReplay(1)\n );\n\n // Lưu vào Map\n this.#inFlightRequests.set(key, {\n stream$: request$,\n expiry: now + this.#dedupCacheDuration,\n });\n\n // Chuyển đổi sang Promise cho đúng return type của bạn\n return lastValueFrom(request$);\n };\n\n // --- HELPERS ---\n\n #getHandler = (url: string): SdApiHandler | undefined => {\n const handlers = this.#configurations.flatMap(b => b?.handlers || []);\n return handlers.find(e => e.hosts.some(host => url.startsWith(host)));\n };\n\n #generateKey = (url: string, method: HttpMethod, body: any, option?: SdHttpOptions): string => {\n // FormData không hash được nội dung file, luôn generate key mới\n if (body instanceof FormData || option?.autoCache === false) {\n return Utilities.generateUuid();\n }\n return Utilities.hash({\n url,\n method,\n params: option?.params,\n headers: option?.headers,\n body,\n });\n };\n\n // Dọn dẹp memory leak\n #cleanupCache() {\n const now = Date.now();\n this.#inFlightRequests.forEach((value, key) => {\n if (value.expiry < now) {\n this.#inFlightRequests.delete(key);\n }\n });\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { from, Observable, throwError } from 'rxjs';\nimport { catchError, map, switchMap } from 'rxjs/operators';\nimport { ISdApiConfiguration, SD_API_CONFIG } from '../api.model';\n\n@Injectable()\nexport class SdHttpInterceptor implements HttpInterceptor {\n #configurations = inject<ISdApiConfiguration[]>(SD_API_CONFIG, { optional: true }) || [];\n\n intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n const url = request.url;\n if (!url) {\n throw new Error(`Invalid URL`);\n }\n const handlers = this.#configurations.flatMap(configuration => configuration?.handlers || []);\n const handler = handlers?.find(e => e.hosts.some(host => url.startsWith(host)));\n const intercept = handler?.intercept;\n if (intercept) {\n request = request.clone(intercept(request));\n }\n if (request.body instanceof FormData) {\n request = request.clone({\n headers: request.headers.delete('Content-Type'),\n });\n }\n const beforeRemoteHandler = handler?.beforeRemote;\n const afterRemoteHandler = handler?.afterRemote;\n const beforeRemote = beforeRemoteHandler?.(request);\n if (beforeRemote instanceof Promise) {\n return from(beforeRemote).pipe(\n switchMap(() => next.handle(request)),\n map((event: HttpEvent<any>) => {\n if (event instanceof HttpResponse) {\n afterRemoteHandler?.(event);\n }\n return event;\n }),\n catchError((error: HttpErrorResponse) => {\n afterRemoteHandler?.(error);\n return throwError(() => error);\n })\n );\n }\n return next.handle(request).pipe(\n map((event: HttpEvent<any>) => {\n if (event instanceof HttpResponse) {\n afterRemoteHandler?.(event);\n }\n return event;\n }),\n catchError((error: HttpErrorResponse) => {\n afterRemoteHandler?.(error);\n return throwError(() => error);\n })\n );\n }\n}\n","import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';\nimport { NgModule } from '@angular/core';\nimport { SdHttpInterceptor } from './interceptors/api.interceptor';\n\n@NgModule({\n imports: [],\n exports: [],\n providers: [provideHttpClient(withInterceptorsFromDi()), { provide: HTTP_INTERCEPTORS, useClass: SdHttpInterceptor, multi: true }],\n})\nexport class SdApiModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;MA4Ca,aAAa,GAAG,IAAI,cAAc,CAAsB,sBAAsB;MAE9E,oBAAoB,GAAG,IAAI,cAAc,CAAsB,sBAAsB;;AC9ClG;MAgBa,YAAY,CAAA;AACd,IAAA,eAAe,GAAG,KAAK,CAAC;AACxB,IAAA,mBAAmB,GAAG,IAAI,CAAC;AACpC,IAAA,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;AAChC,IAAA,eAAe,GAAG,MAAM,CAAwB,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;AACxF,IAAA,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC;;;AAItC,IAAA,iBAAiB,GAA8D,IAAI,GAAG,EAAE;AAExF,IAAA,WAAA,GAAA;;QAEE,WAAW,CAAC,MAAM,IAAI,CAAC,aAAa,EAAE,EAA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,eAAA,CAAA,UAAA,EAAA,CAAA;4GAAjB,iBAAiB,EAAA,CAAA;;4FAAjB,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAD7B;;;MCEY,WAAW,CAAA;wGAAX,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;yGAAX,WAAW,EAAA,CAAA;yGAAX,WAAW,EAAA,SAAA,EAFX,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAA,CAAA;;4FAEvH,WAAW,EAAA,UAAA,EAAA,CAAA;kBALvB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE,EAAE;AACX,oBAAA,OAAO,EAAE,EAAE;oBACX,SAAS,EAAE,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACnI,iBAAA;;;ACRD;;AAEG;;;;"}
|
|
@@ -10,7 +10,7 @@ import { SdButton } from '@sdcorejs/angular/components/button';
|
|
|
10
10
|
import { SdDate } from '@sdcorejs/angular/forms/date';
|
|
11
11
|
import { SdRadio } from '@sdcorejs/angular/forms/radio';
|
|
12
12
|
import { SdTextarea } from '@sdcorejs/angular/forms/textarea';
|
|
13
|
-
import
|
|
13
|
+
import { Utilities } from '@sdcorejs/utils/fns';
|
|
14
14
|
import { I18nService } from '@sdcorejs/angular/i18n';
|
|
15
15
|
|
|
16
16
|
class DialogConfirmComponent {
|
|
@@ -18,7 +18,7 @@ class DialogConfirmComponent {
|
|
|
18
18
|
data;
|
|
19
19
|
value;
|
|
20
20
|
required = false;
|
|
21
|
-
id = `I${
|
|
21
|
+
id = `I${Utilities.generateUuid()}`;
|
|
22
22
|
constructor(dialogRef, data) {
|
|
23
23
|
this.dialogRef = dialogRef;
|
|
24
24
|
this.data = data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdcorejs-angular-services-confirm.mjs","sources":["../../../projects/sdcorejs-angular/services/confirm/src/lib/components/dialog-confirm/dialog-confirm.component.ts","../../../projects/sdcorejs-angular/services/confirm/src/lib/components/dialog-confirm/dialog-confirm.component.html","../../../projects/sdcorejs-angular/services/confirm/src/lib/confirm.service.ts","../../../projects/sdcorejs-angular/services/confirm/src/public-api.ts","../../../projects/sdcorejs-angular/services/confirm/sdcorejs-angular-services-confirm.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, Inject } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatIconModule } from '@angular/material/icon';\nimport { SdButton } from '@sdcorejs/angular/components/button';\nimport { SdDate } from '@sdcorejs/angular/forms/date';\nimport { SdRadio } from '@sdcorejs/angular/forms/radio';\nimport { SdTextarea } from '@sdcorejs/angular/forms/textarea';\nimport { Color } from '@sdcorejs/utils/models';\nimport * as uuid from 'uuid';\n\nexport interface DialogData {\n icon?: string;\n title?: string;\n message?: string;\n yesTitle?: string;\n noTitle?: string;\n yesButtonColor?: Color;\n noButtonColor?: Color;\n input?: {\n placeholder?: string;\n minlength?: number;\n maxlength?: number;\n required?: boolean;\n defaultValue?: string;\n };\n date?: {\n required?: boolean;\n placeholder?: string;\n defaultValue?: string | Date;\n min?: string | Date;\n max?: string | Date;\n };\n radio?: {\n required?: boolean;\n defaultValue?: string | number;\n items: any[];\n valueField: string;\n displayField: string;\n display?: 'row' | 'column';\n };\n}\n\n@Component({\n selector: 'sd-dialog-confirm',\n templateUrl: 'dialog-confirm.component.html',\n styleUrls: ['./dialog-confirm.component.scss'],\n imports: [CommonModule, FormsModule, MatDialogModule, MatIconModule, SdButton, SdDate, SdRadio, SdTextarea],\n})\nexport class DialogConfirmComponent {\n value: any;\n required = false;\n id = `I${uuid.v4()}`;\n constructor(\n public dialogRef: MatDialogRef<DialogConfirmComponent>,\n @Inject(MAT_DIALOG_DATA) public data: DialogData\n ) {\n if (data?.input) {\n this.value = data?.input?.defaultValue ?? '';\n this.required = data?.input?.required || false;\n }\n if (data?.date) {\n this.value = data?.date?.defaultValue ?? '';\n this.required = data?.date?.required || false;\n }\n if (data?.radio) {\n this.value = data?.radio?.defaultValue ?? '';\n this.required = data?.radio?.required || false;\n }\n }\n\n onCancel = () => {\n this.dialogRef.close({ action: 'CANCEL', value: null });\n };\n\n onAccept = () => {\n // Always return an object with action and value for consistency\n if (this.data?.radio || this.data?.input || this.data?.date) {\n this.dialogRef.close({ action: 'ACCEPT', value: this.value });\n } else {\n this.dialogRef.close({ action: 'ACCEPT', value: null });\n }\n };\n}\n","<div mat-dialog-title class=\"\">\n @if (data.icon) {\n <mat-icon>\n {{ data.icon }}\n </mat-icon>\n }\n <span class=\"T24M\" [innerHtml]=\"data.title || 'Confirm'\"></span>\n</div>\n<div mat-dialog-content>\n <div class=\"T14R mb-4\" [innerHtml]=\"data.message\"></div>\n @if (data.input) {\n <sd-textarea [placeholder]=\"data.input.placeholder\" [(model)]=\"value\" [rows]=\"5\" [maxlength]=\"data.input.maxlength!\" />\n }\n @if (data.date) {\n <sd-date\n [placeholder]=\"data.date.placeholder\"\n [(model)]=\"value\"\n type=\"date\"\n [min]=\"data.date.min!\"\n [max]=\"data.date.max!\"\n [required]=\"data.date.required\">\n </sd-date>\n }\n @if (data.radio) {\n <sd-radio\n [items]=\"data.radio.items\"\n [valueField]=\"data.radio.valueField\"\n [displayField]=\"data.radio.displayField\"\n [display]=\"data.radio.display || 'column'\"\n [(model)]=\"value\"\n [required]=\"data.radio.required\">\n </sd-radio>\n }\n</div>\n<div mat-dialog-actions align=\"end\">\n @if (data.noTitle) {\n <sd-button [color]=\"data.noButtonColor || 'secondary'\" [title]=\"data.noTitle\" (click)=\"onCancel()\"></sd-button>\n }\n @if (data.yesTitle) {\n <sd-button\n class=\"ml-8\"\n type=\"fill\"\n [color]=\"data.yesButtonColor || 'primary'\"\n [disabled]=\"required && !value\"\n cdkFocusInitial\n [title]=\"data.yesTitle\"\n (click)=\"onAccept()\"></sd-button>\n }\n</div>\n","import { inject, Injectable } from '@angular/core';\nimport { MatDialog } from '@angular/material/dialog';\nimport { DialogConfirmComponent } from './components/dialog-confirm/dialog-confirm.component';\nimport { Color } from '@sdcorejs/utils/models';\nimport { I18nService } from '@sdcorejs/angular/i18n';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SdConfirmService {\n readonly #i18n = inject(I18nService);\n\n constructor(private dialog: MatDialog) {}\n\n confirm = (\n message: string,\n option: {\n title?: string;\n yesTitle?: string;\n noTitle?: string;\n yesButtonColor?: Color;\n noButtonColor?: Color;\n width?: string;\n disableBackdropClose?: boolean;\n } = {}\n ) => {\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\n width: option?.width || '400px',\n disableClose: option?.disableBackdropClose ?? true,\n data: {\n title: option?.title || this.#i18n.t('core.confirm.title'),\n message,\n yesTitle: option?.yesTitle || this.#i18n.t('core.confirm.yes'),\n noTitle: option?.noTitle || this.#i18n.t('core.confirm.no'),\n noButtonColor: option?.noButtonColor || 'secondary',\n yesButtonColor: option?.yesButtonColor || 'primary',\n },\n });\n return new Promise((resolve, reject) => {\n dialogRef.afterClosed().subscribe(result => {\n if (result) {\n if (result.action === 'CANCEL') {\n reject(result.action);\n } else if (result.action === 'ACCEPT') {\n resolve(result.value);\n }\n }\n });\n });\n };\n\n withInput = (\n message?: string,\n option?: {\n title?: string;\n yesTitle?: string;\n noTitle?: string;\n required?: boolean;\n maxlength?: number;\n yesButtonColor?: Color;\n noButtonColor?: Color;\n defaultValue?: string;\n disableBackdropClose?: boolean;\n }\n ): Promise<string> => {\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\n width: '400px',\n disableClose: option?.disableBackdropClose ?? true,\n data: {\n title: option?.title || this.#i18n.t('core.confirm.title'),\n message,\n yesTitle: option?.yesTitle || this.#i18n.t('core.confirm.yes-short'),\n noTitle: option?.noTitle || this.#i18n.t('core.confirm.no-short'),\n noButtonColor: option?.noButtonColor || 'secondary',\n yesButtonColor: option?.yesButtonColor || 'primary',\n input: {\n maxlength: option?.maxlength || 255,\n required: option?.required,\n defaultValue: option?.defaultValue || '',\n },\n },\n });\n return new Promise((resolve, reject) => {\n dialogRef.afterClosed().subscribe(result => {\n if (result) {\n if (result.action === 'CANCEL') {\n reject(result.action);\n } else if (result.action === 'ACCEPT') {\n resolve(result.value);\n }\n }\n });\n });\n };\n\n withRadio = (\n message?: string,\n option?: {\n title?: string;\n yesTitle?: string;\n noTitle?: string;\n required?: boolean;\n yesButtonColor?: Color;\n noButtonColor?: Color;\n defaultValue?: string | number;\n items: any[];\n valueField: string;\n displayField: string;\n display?: 'row' | 'column';\n disableBackdropClose?: boolean;\n }\n ): Promise<string> => {\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\n width: '400px',\n disableClose: option?.disableBackdropClose ?? true,\n data: {\n title: option?.title || this.#i18n.t('core.confirm.title'),\n message,\n yesTitle: option?.yesTitle || this.#i18n.t('core.confirm.yes-short'),\n noTitle: option?.noTitle || this.#i18n.t('core.confirm.no-short'),\n noButtonColor: option?.noButtonColor || 'secondary',\n yesButtonColor: option?.yesButtonColor || 'primary',\n radio: {\n items: option?.items || [],\n valueField: option?.valueField || 'value',\n displayField: option?.displayField || 'label',\n display: option?.display || 'row',\n required: option?.required,\n defaultValue: option?.defaultValue,\n },\n },\n });\n return new Promise((resolve, reject) => {\n dialogRef.afterClosed().subscribe(result => {\n if (result) {\n if (result.action === 'CANCEL') {\n reject(result.action);\n } else if (result.action === 'ACCEPT') {\n resolve(result.value);\n }\n }\n });\n });\n };\n\n withDate = (\n message?: string,\n option?: {\n title?: string;\n\n yesTitle?: string;\n noTitle?: string;\n required?: boolean;\n yesButtonColor?: Color;\n noButtonColor?: Color;\n defaultValue?: string | Date;\n placeholder?: string;\n disableBackdropClose?: boolean;\n }\n ): Promise<string> => {\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\n width: '400px',\n disableClose: option?.disableBackdropClose ?? true,\n data: {\n title: option?.title || this.#i18n.t('core.confirm.title'),\n message,\n yesTitle: option?.yesTitle || this.#i18n.t('core.confirm.yes-short'),\n noTitle: option?.noTitle || this.#i18n.t('core.confirm.no-short'),\n noButtonColor: option?.noButtonColor || 'secondary',\n yesButtonColor: option?.yesButtonColor || 'primary',\n date: {\n placeholder: option?.placeholder,\n required: option?.required,\n defaultValue: option?.defaultValue || '',\n },\n },\n });\n return new Promise((resolve, reject) => {\n dialogRef.afterClosed().subscribe(result => {\n if (result) {\n if (result.action === 'CANCEL') {\n reject(result.action);\n } else if (result.action === 'ACCEPT') {\n resolve(result.value);\n }\n }\n });\n });\n };\n}\n","/*\n * Public API Surface of superdev-angular-core\n */\n\nexport * from './lib/components/dialog-confirm/dialog-confirm.component';\nexport * from './lib/confirm.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;MAmDa,sBAAsB,CAAA;AAKxB,IAAA,SAAA;AACyB,IAAA,IAAA;AALlC,IAAA,KAAK;IACL,QAAQ,GAAG,KAAK;AAChB,IAAA,EAAE,GAAG,CAAA,CAAA,EAAI,IAAI,CAAC,EAAE,EAAE,EAAE;IACpB,WAAA,CACS,SAA+C,EACtB,IAAgB,EAAA;QADzC,IAAA,CAAA,SAAS,GAAT,SAAS;QACgB,IAAA,CAAA,IAAI,GAAJ,IAAI;AAEpC,QAAA,IAAI,IAAI,EAAE,KAAK,EAAE;YACf,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,YAAY,IAAI,EAAE;YAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ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M,IAAG;gBACzC,IAAI,MAAM,EAAE;AACV,oBAAA,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;AAC9B,wBAAA,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;oBACvB;AAAO,yBAAA,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;AACrC,wBAAA,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;oBACvB;gBACF;AACF,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC;wGAnLU,gBAAgB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,SAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAhB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,cAFf,MAAM,EAAA,CAAA;;4FAEP,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAH5B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACRD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"sdcorejs-angular-services-confirm.mjs","sources":["../../../projects/sdcorejs-angular/services/confirm/src/lib/components/dialog-confirm/dialog-confirm.component.ts","../../../projects/sdcorejs-angular/services/confirm/src/lib/components/dialog-confirm/dialog-confirm.component.html","../../../projects/sdcorejs-angular/services/confirm/src/lib/confirm.service.ts","../../../projects/sdcorejs-angular/services/confirm/src/public-api.ts","../../../projects/sdcorejs-angular/services/confirm/sdcorejs-angular-services-confirm.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, Inject } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatIconModule } from '@angular/material/icon';\nimport { SdButton } from '@sdcorejs/angular/components/button';\nimport { SdDate } from '@sdcorejs/angular/forms/date';\nimport { SdRadio } from '@sdcorejs/angular/forms/radio';\nimport { SdTextarea } from '@sdcorejs/angular/forms/textarea';\nimport { Color } from '@sdcorejs/utils/models';\nimport { Utilities } from '@sdcorejs/utils/fns';\n\nexport interface DialogData {\n icon?: string;\n title?: string;\n message?: string;\n yesTitle?: string;\n noTitle?: string;\n yesButtonColor?: Color;\n noButtonColor?: Color;\n input?: {\n placeholder?: string;\n minlength?: number;\n maxlength?: number;\n required?: boolean;\n defaultValue?: string;\n };\n date?: {\n required?: boolean;\n placeholder?: string;\n defaultValue?: string | Date;\n min?: string | Date;\n max?: string | Date;\n };\n radio?: {\n required?: boolean;\n defaultValue?: string | number;\n items: any[];\n valueField: string;\n displayField: string;\n display?: 'row' | 'column';\n };\n}\n\n@Component({\n selector: 'sd-dialog-confirm',\n templateUrl: 'dialog-confirm.component.html',\n styleUrls: ['./dialog-confirm.component.scss'],\n imports: [CommonModule, FormsModule, MatDialogModule, MatIconModule, SdButton, SdDate, SdRadio, SdTextarea],\n})\nexport class DialogConfirmComponent {\n value: any;\n required = false;\n id = `I${Utilities.generateUuid()}`;\n constructor(\n public dialogRef: MatDialogRef<DialogConfirmComponent>,\n @Inject(MAT_DIALOG_DATA) public data: DialogData\n ) {\n if (data?.input) {\n this.value = data?.input?.defaultValue ?? '';\n this.required = data?.input?.required || false;\n }\n if (data?.date) {\n this.value = data?.date?.defaultValue ?? '';\n this.required = data?.date?.required || false;\n }\n if (data?.radio) {\n this.value = data?.radio?.defaultValue ?? '';\n this.required = data?.radio?.required || false;\n }\n }\n\n onCancel = () => {\n this.dialogRef.close({ action: 'CANCEL', value: null });\n };\n\n onAccept = () => {\n // Always return an object with action and value for consistency\n if (this.data?.radio || this.data?.input || this.data?.date) {\n this.dialogRef.close({ action: 'ACCEPT', value: this.value });\n } else {\n this.dialogRef.close({ action: 'ACCEPT', value: null });\n }\n };\n}\n","<div mat-dialog-title class=\"\">\n @if (data.icon) {\n <mat-icon>\n {{ data.icon }}\n </mat-icon>\n }\n <span class=\"T24M\" [innerHtml]=\"data.title || 'Confirm'\"></span>\n</div>\n<div mat-dialog-content>\n <div class=\"T14R mb-4\" [innerHtml]=\"data.message\"></div>\n @if (data.input) {\n <sd-textarea [placeholder]=\"data.input.placeholder\" [(model)]=\"value\" [rows]=\"5\" [maxlength]=\"data.input.maxlength!\" />\n }\n @if (data.date) {\n <sd-date\n [placeholder]=\"data.date.placeholder\"\n [(model)]=\"value\"\n type=\"date\"\n [min]=\"data.date.min!\"\n [max]=\"data.date.max!\"\n [required]=\"data.date.required\">\n </sd-date>\n }\n @if (data.radio) {\n <sd-radio\n [items]=\"data.radio.items\"\n [valueField]=\"data.radio.valueField\"\n [displayField]=\"data.radio.displayField\"\n [display]=\"data.radio.display || 'column'\"\n [(model)]=\"value\"\n [required]=\"data.radio.required\">\n </sd-radio>\n }\n</div>\n<div mat-dialog-actions align=\"end\">\n @if (data.noTitle) {\n <sd-button [color]=\"data.noButtonColor || 'secondary'\" [title]=\"data.noTitle\" (click)=\"onCancel()\"></sd-button>\n }\n @if (data.yesTitle) {\n <sd-button\n class=\"ml-8\"\n type=\"fill\"\n [color]=\"data.yesButtonColor || 'primary'\"\n [disabled]=\"required && !value\"\n cdkFocusInitial\n [title]=\"data.yesTitle\"\n (click)=\"onAccept()\"></sd-button>\n }\n</div>\n","import { inject, Injectable } from '@angular/core';\nimport { MatDialog } from '@angular/material/dialog';\nimport { DialogConfirmComponent } from './components/dialog-confirm/dialog-confirm.component';\nimport { Color } from '@sdcorejs/utils/models';\nimport { I18nService } from '@sdcorejs/angular/i18n';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SdConfirmService {\n readonly #i18n = inject(I18nService);\n\n constructor(private dialog: MatDialog) {}\n\n confirm = (\n message: string,\n option: {\n title?: string;\n yesTitle?: string;\n noTitle?: string;\n yesButtonColor?: Color;\n noButtonColor?: Color;\n width?: string;\n disableBackdropClose?: boolean;\n } = {}\n ) => {\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\n width: option?.width || '400px',\n disableClose: option?.disableBackdropClose ?? true,\n data: {\n title: option?.title || this.#i18n.t('core.confirm.title'),\n message,\n yesTitle: option?.yesTitle || this.#i18n.t('core.confirm.yes'),\n noTitle: option?.noTitle || this.#i18n.t('core.confirm.no'),\n noButtonColor: option?.noButtonColor || 'secondary',\n yesButtonColor: option?.yesButtonColor || 'primary',\n },\n });\n return new Promise((resolve, reject) => {\n dialogRef.afterClosed().subscribe(result => {\n if (result) {\n if (result.action === 'CANCEL') {\n reject(result.action);\n } else if (result.action === 'ACCEPT') {\n resolve(result.value);\n }\n }\n });\n });\n };\n\n withInput = (\n message?: string,\n option?: {\n title?: string;\n yesTitle?: string;\n noTitle?: string;\n required?: boolean;\n maxlength?: number;\n yesButtonColor?: Color;\n noButtonColor?: Color;\n defaultValue?: string;\n disableBackdropClose?: boolean;\n }\n ): Promise<string> => {\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\n width: '400px',\n disableClose: option?.disableBackdropClose ?? true,\n data: {\n title: option?.title || this.#i18n.t('core.confirm.title'),\n message,\n yesTitle: option?.yesTitle || this.#i18n.t('core.confirm.yes-short'),\n noTitle: option?.noTitle || this.#i18n.t('core.confirm.no-short'),\n noButtonColor: option?.noButtonColor || 'secondary',\n yesButtonColor: option?.yesButtonColor || 'primary',\n input: {\n maxlength: option?.maxlength || 255,\n required: option?.required,\n defaultValue: option?.defaultValue || '',\n },\n },\n });\n return new Promise((resolve, reject) => {\n dialogRef.afterClosed().subscribe(result => {\n if (result) {\n if (result.action === 'CANCEL') {\n reject(result.action);\n } else if (result.action === 'ACCEPT') {\n resolve(result.value);\n }\n }\n });\n });\n };\n\n withRadio = (\n message?: string,\n option?: {\n title?: string;\n yesTitle?: string;\n noTitle?: string;\n required?: boolean;\n yesButtonColor?: Color;\n noButtonColor?: Color;\n defaultValue?: string | number;\n items: any[];\n valueField: string;\n displayField: string;\n display?: 'row' | 'column';\n disableBackdropClose?: boolean;\n }\n ): Promise<string> => {\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\n width: '400px',\n disableClose: option?.disableBackdropClose ?? true,\n data: {\n title: option?.title || this.#i18n.t('core.confirm.title'),\n message,\n yesTitle: option?.yesTitle || this.#i18n.t('core.confirm.yes-short'),\n noTitle: option?.noTitle || this.#i18n.t('core.confirm.no-short'),\n noButtonColor: option?.noButtonColor || 'secondary',\n yesButtonColor: option?.yesButtonColor || 'primary',\n radio: {\n items: option?.items || [],\n valueField: option?.valueField || 'value',\n displayField: option?.displayField || 'label',\n display: option?.display || 'row',\n required: option?.required,\n defaultValue: option?.defaultValue,\n },\n },\n });\n return new Promise((resolve, reject) => {\n dialogRef.afterClosed().subscribe(result => {\n if (result) {\n if (result.action === 'CANCEL') {\n reject(result.action);\n } else if (result.action === 'ACCEPT') {\n resolve(result.value);\n }\n }\n });\n });\n };\n\n withDate = (\n message?: string,\n option?: {\n title?: string;\n\n yesTitle?: string;\n noTitle?: string;\n required?: boolean;\n yesButtonColor?: Color;\n noButtonColor?: Color;\n defaultValue?: string | Date;\n placeholder?: string;\n disableBackdropClose?: boolean;\n }\n ): Promise<string> => {\n const dialogRef = this.dialog.open(DialogConfirmComponent, {\n width: '400px',\n disableClose: option?.disableBackdropClose ?? true,\n data: {\n title: option?.title || this.#i18n.t('core.confirm.title'),\n message,\n yesTitle: option?.yesTitle || this.#i18n.t('core.confirm.yes-short'),\n noTitle: option?.noTitle || this.#i18n.t('core.confirm.no-short'),\n noButtonColor: option?.noButtonColor || 'secondary',\n yesButtonColor: option?.yesButtonColor || 'primary',\n date: {\n placeholder: option?.placeholder,\n required: option?.required,\n defaultValue: option?.defaultValue || '',\n },\n },\n });\n return new Promise((resolve, reject) => {\n dialogRef.afterClosed().subscribe(result => {\n if (result) {\n if (result.action === 'CANCEL') {\n reject(result.action);\n } else if (result.action === 'ACCEPT') {\n resolve(result.value);\n }\n }\n });\n });\n };\n}\n","/*\n * Public API Surface of superdev-angular-core\n */\n\nexport * from './lib/components/dialog-confirm/dialog-confirm.component';\nexport * from './lib/confirm.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;MAmDa,sBAAsB,CAAA;AAKxB,IAAA,SAAA;AACyB,IAAA,IAAA;AALlC,IAAA,KAAK;IACL,QAAQ,GAAG,KAAK;AAChB,IAAA,EAAE,GAAG,CAAA,CAAA,EAAI,SAAS,CAAC,YAAY,EAAE,EAAE;IACnC,WAAA,CACS,SAA+C,EACtB,IAAgB,EAAA;QADzC,IAAA,CAAA,SAAS,GAAT,SAAS;QACgB,IAAA,CAAA,IAAI,GAAJ,IAAI;AAEpC,QAAA,IAAI,IAAI,EAAE,KAAK,EAAE;YACf,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,YAAY,IAAI,EAAE;YAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,IAAI,KAAK;QAChD;AACA,QAAA,IAAI,IAAI,EAAE,IAAI,EAAE;YACd,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,IAAI,EAAE,YAAY,IAAI,EAAE;YAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,IAAI,EAAE,QAAQ,IAAI,KAAK;QAC/C;AACA,QAAA,IAAI,IAAI,EAAE,KAAK,EAAE;YACf,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,YAAY,IAAI,EAAE;YAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,IAAI,KAAK;QAChD;IACF;IAEA,QAAQ,GAAG,MAAK;AACd,QAAA,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,QAA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AAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,cAFf,MAAM,EAAA,CAAA;;4FAEP,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAH5B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACRD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
-
import { OnDestroy } from '@angular/core';
|
|
2
|
+
import { InjectionToken, OnDestroy } from '@angular/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Runtime state attributes the component renders on the same anchor as `data-autoid`.
|
|
6
6
|
* Every field is OPTIONAL — only present when the component actually renders that attribute.
|
|
7
7
|
* All values are the raw DOM string (already "true"/"false" or stringified number/value).
|
|
8
8
|
*/
|
|
9
|
-
interface
|
|
9
|
+
interface AutoidElementState {
|
|
10
10
|
disabled?: string;
|
|
11
11
|
loading?: string;
|
|
12
12
|
empty?: string;
|
|
13
13
|
invalid?: string;
|
|
14
14
|
opened?: string;
|
|
15
15
|
count?: string;
|
|
16
|
-
/** Serialized DOM `data-value` (NOT `input.value`). Distinct from `
|
|
16
|
+
/** Serialized DOM `data-value` (NOT `input.value`). Distinct from `AutoidElement.text` field. */
|
|
17
17
|
dataValue?: string;
|
|
18
18
|
required?: string;
|
|
19
19
|
maxlength?: string;
|
|
@@ -24,7 +24,7 @@ interface SdAutoidElementState {
|
|
|
24
24
|
title?: string;
|
|
25
25
|
message?: string;
|
|
26
26
|
}
|
|
27
|
-
interface
|
|
27
|
+
interface AutoidElement {
|
|
28
28
|
stt: number;
|
|
29
29
|
name: string;
|
|
30
30
|
autoid: string;
|
|
@@ -38,7 +38,7 @@ interface SdAutoidElement {
|
|
|
38
38
|
xpath: string;
|
|
39
39
|
duplicate: boolean;
|
|
40
40
|
/** Runtime state attributes read from the DOM. Always an object — may be empty `{}`. */
|
|
41
|
-
state:
|
|
41
|
+
state: AutoidElementState;
|
|
42
42
|
/**
|
|
43
43
|
* `data-autoid` of the closest ancestor `<sd-table>` that contains this element,
|
|
44
44
|
* or `undefined` if this element is top-level (not inside any `sd-table`).
|
|
@@ -54,54 +54,75 @@ interface SdAutoidElement {
|
|
|
54
54
|
/** Human-readable warning attached to a fallback element (only set when `missingAutoid`). */
|
|
55
55
|
warning?: string;
|
|
56
56
|
}
|
|
57
|
-
interface
|
|
57
|
+
interface AutoidMissing {
|
|
58
58
|
tag: string;
|
|
59
59
|
selector: string;
|
|
60
60
|
outerHtmlPreview: string;
|
|
61
61
|
nameHint: string;
|
|
62
62
|
}
|
|
63
|
-
interface
|
|
63
|
+
interface AutoidAuditResult {
|
|
64
64
|
total: number;
|
|
65
65
|
duplicates: Record<string, number>;
|
|
66
66
|
duplicateCount: number;
|
|
67
|
-
missing:
|
|
67
|
+
missing: AutoidMissing[];
|
|
68
68
|
missingCount: number;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
interface
|
|
72
|
-
/**
|
|
71
|
+
interface SdAutoidInspectorConfiguration {
|
|
72
|
+
/** Base URL cua backend sinh E2E test, vi du `http://localhost:3012`. */
|
|
73
|
+
host?: string;
|
|
74
|
+
/** Selector phu them can audit (mac dinh component da cover sd-* form + sd-button). */
|
|
73
75
|
extraRequireSelectors?: string[];
|
|
74
|
-
/** Root scan,
|
|
76
|
+
/** Root scan, mac dinh document.body. */
|
|
75
77
|
root?: HTMLElement;
|
|
76
78
|
}
|
|
77
|
-
/**
|
|
78
|
-
declare const
|
|
79
|
+
/** Cau hinh global cho AutoId Inspector. `[config]` tren component co the override theo instance. */
|
|
80
|
+
declare const SD_AUTOID_INSPECTOR_CONFIGURATION: InjectionToken<SdAutoidInspectorConfiguration>;
|
|
81
|
+
|
|
82
|
+
type AutoidE2eTarget = 'playwright' | 'robot';
|
|
83
|
+
interface AutoidRobotExportContext {
|
|
84
|
+
requirement?: string;
|
|
85
|
+
testCases?: string;
|
|
86
|
+
testData?: string;
|
|
87
|
+
precondition?: string;
|
|
88
|
+
component?: string;
|
|
89
|
+
storyLinkages?: string;
|
|
90
|
+
qcNotes?: string;
|
|
91
|
+
}
|
|
79
92
|
|
|
80
93
|
type Segment = 'audit' | 'elements' | 'export';
|
|
94
|
+
type RobotContextField = keyof AutoidRobotExportContext;
|
|
81
95
|
declare class SdAutoidInspector implements OnDestroy {
|
|
82
96
|
#private;
|
|
83
97
|
enabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
84
|
-
config: _angular_core.InputSignal<
|
|
98
|
+
config: _angular_core.InputSignal<SdAutoidInspectorConfiguration | undefined>;
|
|
85
99
|
open: _angular_core.WritableSignal<boolean>;
|
|
86
100
|
segment: _angular_core.WritableSignal<Segment>;
|
|
87
101
|
filter: _angular_core.WritableSignal<string>;
|
|
88
|
-
elements: _angular_core.WritableSignal<
|
|
89
|
-
audit: _angular_core.WritableSignal<
|
|
102
|
+
elements: _angular_core.WritableSignal<AutoidElement[]>;
|
|
103
|
+
audit: _angular_core.WritableSignal<AutoidAuditResult | null>;
|
|
90
104
|
copyOk: _angular_core.WritableSignal<boolean>;
|
|
105
|
+
e2eExporting: _angular_core.WritableSignal<AutoidE2eTarget | null>;
|
|
106
|
+
e2eExportOk: _angular_core.WritableSignal<string | null>;
|
|
107
|
+
e2eExportError: _angular_core.WritableSignal<string | null>;
|
|
108
|
+
robotContextOpen: _angular_core.WritableSignal<boolean>;
|
|
109
|
+
robotExportContext: _angular_core.WritableSignal<AutoidRobotExportContext>;
|
|
91
110
|
highlightOn: _angular_core.WritableSignal<boolean>;
|
|
92
111
|
dismissed: _angular_core.WritableSignal<boolean>;
|
|
93
|
-
|
|
112
|
+
readonly e2eGeneratorHost: _angular_core.Signal<string | undefined>;
|
|
113
|
+
readonly hasRobotExportContext: _angular_core.Signal<boolean>;
|
|
114
|
+
filteredElements: _angular_core.Signal<AutoidElement[]>;
|
|
94
115
|
/**
|
|
95
116
|
* Elements not inside any sd-table — rendered in the main "Top-level" section.
|
|
96
117
|
*/
|
|
97
|
-
readonly topLevelElements: _angular_core.Signal<
|
|
118
|
+
readonly topLevelElements: _angular_core.Signal<AutoidElement[]>;
|
|
98
119
|
/**
|
|
99
120
|
* Map of `sd-table` autoid → its inner autoid elements. Tables themselves
|
|
100
121
|
* stay in `topLevelElements` (the table's own autoid is top-level).
|
|
101
122
|
*/
|
|
102
123
|
readonly tableGroups: _angular_core.Signal<{
|
|
103
124
|
scope: string;
|
|
104
|
-
items:
|
|
125
|
+
items: AutoidElement[];
|
|
105
126
|
}[]>;
|
|
106
127
|
readonly dataOpened: _angular_core.Signal<"true" | "false">;
|
|
107
128
|
readonly dataHighlightOn: _angular_core.Signal<"true" | "false">;
|
|
@@ -123,126 +144,15 @@ declare class SdAutoidInspector implements OnDestroy {
|
|
|
123
144
|
exportJson: () => void;
|
|
124
145
|
exportMdPom: () => void;
|
|
125
146
|
exportMdTable: () => void;
|
|
147
|
+
openRobotExportContext: () => void;
|
|
148
|
+
closeRobotExportContext: () => void;
|
|
149
|
+
updateRobotExportContext: (field: RobotContextField, value: string) => void;
|
|
150
|
+
confirmRobotExport: () => Promise<void>;
|
|
151
|
+
exportE2eTest: (target: AutoidE2eTarget, context?: AutoidRobotExportContext) => Promise<boolean>;
|
|
126
152
|
onEscape(): void;
|
|
127
153
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdAutoidInspector, never>;
|
|
128
154
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SdAutoidInspector, "sd-autoid-inspector", never, { "enabled": { "alias": "enabled"; "required": false; "isSignal": true; }; "config": { "alias": "config"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
129
155
|
}
|
|
130
156
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
/** `location.pathname + location.search` — kept for back-compat with MD exports. */
|
|
134
|
-
pageUrl: string;
|
|
135
|
-
pageTitle: string;
|
|
136
|
-
timestamp: string;
|
|
137
|
-
/** Full `location.href`. */
|
|
138
|
-
url: string;
|
|
139
|
-
/** `location.pathname` only. */
|
|
140
|
-
pathname: string;
|
|
141
|
-
/** Raw `location.search` (incl. leading `?`), or `''`. */
|
|
142
|
-
search: string;
|
|
143
|
-
/** Parsed query string → key/value map (last value wins on repeats). */
|
|
144
|
-
queryParams: Record<string, string>;
|
|
145
|
-
/**
|
|
146
|
-
* Angular route path params (`:id`, …) merged across the activated-route tree.
|
|
147
|
-
* Only present when an Angular `Router` is available at scan time; omitted otherwise.
|
|
148
|
-
*/
|
|
149
|
-
params?: Record<string, string>;
|
|
150
|
-
}
|
|
151
|
-
/** JSON export envelope: page meta + the scanned elements. */
|
|
152
|
-
interface SdAutoidExportJson {
|
|
153
|
-
meta: SdAutoidExportMeta;
|
|
154
|
-
elements: SdAutoidElement[];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
declare class SdAutoidScannerService {
|
|
158
|
-
/**
|
|
159
|
-
* Quét element có [data-autoid] trong root, gắn name/tag/value/xpath.
|
|
160
|
-
* Khi truyền `requireSelectors` (vd các sd-* form/button), những node khớp selector
|
|
161
|
-
* mà KHÔNG có data-autoid (self lẫn con) sẽ được thêm vào dưới dạng phần tử fallback
|
|
162
|
-
* (`autoid: ''`, xpath theo vị trí thẻ + cờ `missingAutoid` + warning) — để JSON xuất ra
|
|
163
|
-
* vẫn dùng được và dev biết chỗ cần bổ sung autoid.
|
|
164
|
-
*/
|
|
165
|
-
scan(root?: HTMLElement, requireSelectors?: ReadonlyArray<string>): SdAutoidElement[];
|
|
166
|
-
/**
|
|
167
|
-
* Tìm các node khớp `requireSelectors` nhưng thiếu data-autoid (self + mọi descendant),
|
|
168
|
-
* thêm vào `result` dưới dạng phần tử fallback. Trả về `stt` kế tiếp.
|
|
169
|
-
*/
|
|
170
|
-
private appendMissing;
|
|
171
|
-
/** XPath theo vị trí thẻ trong document, vd `(//sd-button)[2]`, khi không có autoid. */
|
|
172
|
-
private fallbackXpath;
|
|
173
|
-
/** Group element theo autoid để consumer lấy duplicate map. */
|
|
174
|
-
groupByAutoid(elements: SdAutoidElement[]): Record<string, SdAutoidElement[]>;
|
|
175
|
-
/**
|
|
176
|
-
* Read the optional `data-*` E2E state attributes off the same node.
|
|
177
|
-
* Only includes fields actually present on the DOM (skipped fields stay undefined).
|
|
178
|
-
*/
|
|
179
|
-
private readState;
|
|
180
|
-
/**
|
|
181
|
-
* If the node is inside an `<sd-table>` element, return that table's `data-autoid`.
|
|
182
|
-
* Walks up via closest('sd-table') — skips the node itself if it IS the table.
|
|
183
|
-
*/
|
|
184
|
-
private resolveTableScope;
|
|
185
|
-
private resolveName;
|
|
186
|
-
private resolveSdTag;
|
|
187
|
-
private resolveText;
|
|
188
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdAutoidScannerService, never>;
|
|
189
|
-
static ɵprov: _angular_core.ɵɵInjectableDeclaration<SdAutoidScannerService>;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
declare class SdAutoidAuditService {
|
|
193
|
-
/**
|
|
194
|
-
* Audit kết quả scan + DOM:
|
|
195
|
-
* - duplicates: map autoid → count khi count > 1
|
|
196
|
-
* - missing: element khớp selector yêu cầu nhưng KHÔNG có [data-autoid]
|
|
197
|
-
*/
|
|
198
|
-
audit(elements: SdAutoidElement[], options?: {
|
|
199
|
-
requireSelectors?: ReadonlyArray<string>;
|
|
200
|
-
root?: HTMLElement;
|
|
201
|
-
}): SdAutoidAuditResult;
|
|
202
|
-
private findMissing;
|
|
203
|
-
private buildSelectorPath;
|
|
204
|
-
private shortHtml;
|
|
205
|
-
private resolveNameHint;
|
|
206
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdAutoidAuditService, never>;
|
|
207
|
-
static ɵprov: _angular_core.ɵɵInjectableDeclaration<SdAutoidAuditService>;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
declare class SdAutoidHighlightService {
|
|
211
|
-
#private;
|
|
212
|
-
/** Apply outline cho mọi [data-autoid]: xanh nếu unique, đỏ nếu duplicate. Idempotent. */
|
|
213
|
-
apply(root?: HTMLElement): void;
|
|
214
|
-
/** Highlight tập element không có autoid (missing) bằng outline cam dashed. */
|
|
215
|
-
applyMissing(nodes: HTMLElement[]): void;
|
|
216
|
-
/** Restore inline style như trước khi apply. */
|
|
217
|
-
clear(root?: HTMLElement): void;
|
|
218
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdAutoidHighlightService, never>;
|
|
219
|
-
static ɵprov: _angular_core.ɵɵInjectableDeclaration<SdAutoidHighlightService>;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
declare class SdAutoidExportService {
|
|
223
|
-
/**
|
|
224
|
-
* Có `meta` → bọc `{ meta, elements }` (kèm url/queryParams) để consumer biết trang/route.
|
|
225
|
-
* Không `meta` → giữ mảng thuần (back-compat cho caller cũ chỉ cần elements).
|
|
226
|
-
*/
|
|
227
|
-
toJson(elements: SdAutoidElement[], meta?: SdAutoidExportMeta): string;
|
|
228
|
-
/** Parse a `location.search` string into a flat key/value map (last value wins). */
|
|
229
|
-
parseQueryParams(search: string): Record<string, string>;
|
|
230
|
-
toCsv(elements: SdAutoidElement[]): string;
|
|
231
|
-
/** POM TypeScript skeleton — copy ngay vào file Playwright/Cypress. */
|
|
232
|
-
toMarkdownPom(elements: SdAutoidElement[], meta: SdAutoidExportMeta): string;
|
|
233
|
-
/** Markdown reference table, group FIRST by tableScope (top-level first, then per table), then by tag. */
|
|
234
|
-
toMarkdownTable(elements: SdAutoidElement[], meta: SdAutoidExportMeta): string;
|
|
235
|
-
download(content: string, filename: string, mime: string): void;
|
|
236
|
-
copyToClipboard(content: string): Promise<void>;
|
|
237
|
-
/** Build a compact state summary string from defined state keys, e.g. "disabled=false; empty=true". */
|
|
238
|
-
private buildStateSummary;
|
|
239
|
-
private q;
|
|
240
|
-
private mdCell;
|
|
241
|
-
private toCamel;
|
|
242
|
-
private toPascal;
|
|
243
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdAutoidExportService, never>;
|
|
244
|
-
static ɵprov: _angular_core.ɵɵInjectableDeclaration<SdAutoidExportService>;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export { SD_AUTOID_DEFAULT_REQUIRE_SELECTORS, SdAutoidAuditService, SdAutoidExportService, SdAutoidHighlightService, SdAutoidInspector, SdAutoidScannerService };
|
|
248
|
-
export type { SdAutoidAuditResult, SdAutoidElement, SdAutoidElementState, SdAutoidExportFormat, SdAutoidExportJson, SdAutoidExportMeta, SdAutoidInspectorConfig, SdAutoidMissing };
|
|
157
|
+
export { SD_AUTOID_INSPECTOR_CONFIGURATION, SdAutoidInspector };
|
|
158
|
+
export type { SdAutoidInspectorConfiguration };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
-
import { TemplateRef, Signal, EventEmitter, ChangeDetectorRef, InjectionToken,
|
|
2
|
+
import { TemplateRef, Signal, EventEmitter, ChangeDetectorRef, InjectionToken, AfterViewInit, OnDestroy } from '@angular/core';
|
|
3
3
|
import { SdBadge } from '@sdcorejs/angular/components/badge';
|
|
4
4
|
import { SdSearch } from '@sdcorejs/angular/forms';
|
|
5
5
|
import { Operator, NestedKeyOf, Order, PagingReq, Color } from '@sdcorejs/utils/models';
|
|
@@ -1146,7 +1146,7 @@ declare class MatPaginatorIntlCro extends MatPaginatorIntl {
|
|
|
1146
1146
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MatPaginatorIntlCro, never>;
|
|
1147
1147
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<MatPaginatorIntlCro>;
|
|
1148
1148
|
}
|
|
1149
|
-
declare class SdTable<T = unknown> implements
|
|
1149
|
+
declare class SdTable<T = unknown> implements AfterViewInit, OnDestroy {
|
|
1150
1150
|
#private;
|
|
1151
1151
|
autoIdInput: _angular_core.InputSignal<string | null | undefined>;
|
|
1152
1152
|
autoId: _angular_core.Signal<string | undefined>;
|
|
@@ -1182,14 +1182,13 @@ declare class SdTable<T = unknown> implements OnInit, AfterViewInit, OnDestroy {
|
|
|
1182
1182
|
filterRegister: TableFilterRegister;
|
|
1183
1183
|
key: string;
|
|
1184
1184
|
columnOperator: Record<string, Operator>;
|
|
1185
|
-
columnFilter?:
|
|
1186
|
-
cacheValues: Record<string,
|
|
1185
|
+
columnFilter?: NonNullable<TableFilterValue['columnFilter']>;
|
|
1186
|
+
cacheValues: Record<string, unknown[]>;
|
|
1187
1187
|
treeRevision: _angular_core.WritableSignal<number>;
|
|
1188
1188
|
exporting: _angular_core.WritableSignal<boolean>;
|
|
1189
1189
|
exportTitle: _angular_core.WritableSignal<string>;
|
|
1190
1190
|
tableConfiguration: ISdTableConfiguration | null;
|
|
1191
1191
|
constructor();
|
|
1192
|
-
ngOnInit(): void;
|
|
1193
1192
|
ngAfterViewInit(): void;
|
|
1194
1193
|
ngOnDestroy(): void;
|
|
1195
1194
|
getFilterRequest: () => SdTableFilterRequest;
|
|
@@ -1229,10 +1228,7 @@ declare class SdTable<T = unknown> implements OnInit, AfterViewInit, OnDestroy {
|
|
|
1229
1228
|
groupContext: (header: SdTableItem<T>) => SdTableGroupDefContext<T>;
|
|
1230
1229
|
rowStyle: (row: SdTableItem<T>, index?: number) => Record<string, string> | null;
|
|
1231
1230
|
clearFilter: () => void;
|
|
1232
|
-
setFilter: (args
|
|
1233
|
-
columnFilter?: Record<string, any>;
|
|
1234
|
-
externalFilter?: Record<string, any>;
|
|
1235
|
-
}) => void;
|
|
1231
|
+
setFilter: (args?: Pick<TableFilterValue, "columnFilter" | "externalFilter">) => void;
|
|
1236
1232
|
get dataItems(): T[];
|
|
1237
1233
|
get selectedItems(): T[];
|
|
1238
1234
|
detectChanges: () => void;
|
|
@@ -21,6 +21,8 @@ declare class SdDateRange implements OnDestroy, OnInit {
|
|
|
21
21
|
private formConfig;
|
|
22
22
|
autoIdInput: _angular_core.InputSignal<string | null | undefined>;
|
|
23
23
|
autoId: _angular_core.Signal<string | undefined>;
|
|
24
|
+
fromAutoId: _angular_core.Signal<string | undefined>;
|
|
25
|
+
toAutoId: _angular_core.Signal<string | undefined>;
|
|
24
26
|
readonly dataDisabled: _angular_core.Signal<"true" | "false">;
|
|
25
27
|
readonly dataInvalid: _angular_core.Signal<"true" | "false">;
|
|
26
28
|
readonly dataEmpty: _angular_core.Signal<"true" | "false">;
|
|
@@ -25,7 +25,6 @@ declare class SdInputNumber implements OnDestroy, OnInit, AfterViewInit {
|
|
|
25
25
|
sdSuffixDef: _angular_core.Signal<SdSuffixDefDirective | undefined>;
|
|
26
26
|
private ref;
|
|
27
27
|
private coreConfiguration;
|
|
28
|
-
private formatNumberPipe;
|
|
29
28
|
private formConfig;
|
|
30
29
|
autoIdInput: _angular_core.InputSignal<string | null | undefined>;
|
|
31
30
|
autoId: _angular_core.Signal<string | undefined>;
|