@sdcorejs/angular 19.0.0 → 19.0.3

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.
Files changed (103) hide show
  1. package/README.md +36 -19
  2. package/assets/scss/core/_inline-edit.scss +105 -0
  3. package/assets/scss/core/form.scss +15 -0
  4. package/components/autoid-inspector/src/models/autoid-element.model.d.ts +11 -0
  5. package/components/autoid-inspector/src/models/autoid-export-format.model.d.ts +19 -0
  6. package/components/autoid-inspector/src/services/autoid-export.service.d.ts +7 -1
  7. package/components/autoid-inspector/src/services/autoid-scanner.service.d.ts +15 -2
  8. package/components/form-generic/src/components/form-builder/form-builder.component.d.ts +12 -13
  9. package/components/index.d.ts +1 -0
  10. package/components/modal-resizable/index.d.ts +1 -0
  11. package/components/modal-resizable/src/modal-resizable.component.d.ts +29 -0
  12. package/components/query-bar/src/components/inline-chip/inline-chip.component.d.ts +11 -22
  13. package/components/query-bar/src/components/inline-value-chip/inline-value-chip.component.d.ts +3 -7
  14. package/components/table/src/components/config/config.component.d.ts +3 -1
  15. package/components/table/src/components/selector-action/selector-action.component.d.ts +3 -1
  16. package/components/table/src/models/table-option-tree.model.d.ts +96 -8
  17. package/components/table/src/services/tree/tree.util.d.ts +43 -2
  18. package/components/view/src/view.component.d.ts +33 -0
  19. package/fesm2022/sdcorejs-angular-components-autoid-inspector.mjs +97 -10
  20. package/fesm2022/sdcorejs-angular-components-autoid-inspector.mjs.map +1 -1
  21. package/fesm2022/sdcorejs-angular-components-avatar.mjs +2 -2
  22. package/fesm2022/sdcorejs-angular-components-avatar.mjs.map +1 -1
  23. package/fesm2022/sdcorejs-angular-components-button.mjs +2 -2
  24. package/fesm2022/sdcorejs-angular-components-button.mjs.map +1 -1
  25. package/fesm2022/sdcorejs-angular-components-form-generic.mjs +102 -189
  26. package/fesm2022/sdcorejs-angular-components-form-generic.mjs.map +1 -1
  27. package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs +158 -0
  28. package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs.map +1 -0
  29. package/fesm2022/sdcorejs-angular-components-operator.mjs +3 -1
  30. package/fesm2022/sdcorejs-angular-components-operator.mjs.map +1 -1
  31. package/fesm2022/sdcorejs-angular-components-preview.mjs +4 -4
  32. package/fesm2022/sdcorejs-angular-components-preview.mjs.map +1 -1
  33. package/fesm2022/sdcorejs-angular-components-query-bar.mjs +41 -87
  34. package/fesm2022/sdcorejs-angular-components-query-bar.mjs.map +1 -1
  35. package/fesm2022/sdcorejs-angular-components-side-drawer.mjs +2 -2
  36. package/fesm2022/sdcorejs-angular-components-side-drawer.mjs.map +1 -1
  37. package/fesm2022/sdcorejs-angular-components-table.mjs +234 -107
  38. package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
  39. package/fesm2022/sdcorejs-angular-components-upload-file.mjs +2 -2
  40. package/fesm2022/sdcorejs-angular-components-upload-file.mjs.map +1 -1
  41. package/fesm2022/sdcorejs-angular-components-view.mjs +43 -11
  42. package/fesm2022/sdcorejs-angular-components-view.mjs.map +1 -1
  43. package/fesm2022/sdcorejs-angular-components.mjs +1 -0
  44. package/fesm2022/sdcorejs-angular-components.mjs.map +1 -1
  45. package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs +25 -5
  46. package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs.map +1 -1
  47. package/fesm2022/sdcorejs-angular-forms-checkbox.mjs +9 -4
  48. package/fesm2022/sdcorejs-angular-forms-checkbox.mjs.map +1 -1
  49. package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs +10 -5
  50. package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs.map +1 -1
  51. package/fesm2022/sdcorejs-angular-forms-chip.mjs +10 -5
  52. package/fesm2022/sdcorejs-angular-forms-chip.mjs.map +1 -1
  53. package/fesm2022/sdcorejs-angular-forms-date-range.mjs +18 -9
  54. package/fesm2022/sdcorejs-angular-forms-date-range.mjs.map +1 -1
  55. package/fesm2022/sdcorejs-angular-forms-date.mjs +20 -8
  56. package/fesm2022/sdcorejs-angular-forms-date.mjs.map +1 -1
  57. package/fesm2022/sdcorejs-angular-forms-datetime.mjs +20 -8
  58. package/fesm2022/sdcorejs-angular-forms-datetime.mjs.map +1 -1
  59. package/fesm2022/sdcorejs-angular-forms-inline-text.mjs +167 -0
  60. package/fesm2022/sdcorejs-angular-forms-inline-text.mjs.map +1 -0
  61. package/fesm2022/sdcorejs-angular-forms-input-color.mjs +5 -3
  62. package/fesm2022/sdcorejs-angular-forms-input-color.mjs.map +1 -1
  63. package/fesm2022/sdcorejs-angular-forms-input-number.mjs +34 -7
  64. package/fesm2022/sdcorejs-angular-forms-input-number.mjs.map +1 -1
  65. package/fesm2022/sdcorejs-angular-forms-input.mjs +35 -9
  66. package/fesm2022/sdcorejs-angular-forms-input.mjs.map +1 -1
  67. package/fesm2022/sdcorejs-angular-forms-models.mjs +32 -2
  68. package/fesm2022/sdcorejs-angular-forms-models.mjs.map +1 -1
  69. package/fesm2022/sdcorejs-angular-forms-radio.mjs +9 -4
  70. package/fesm2022/sdcorejs-angular-forms-radio.mjs.map +1 -1
  71. package/fesm2022/sdcorejs-angular-forms-select.mjs +33 -9
  72. package/fesm2022/sdcorejs-angular-forms-select.mjs.map +1 -1
  73. package/fesm2022/sdcorejs-angular-forms-switch.mjs +9 -4
  74. package/fesm2022/sdcorejs-angular-forms-switch.mjs.map +1 -1
  75. package/fesm2022/sdcorejs-angular-forms-textarea.mjs +15 -5
  76. package/fesm2022/sdcorejs-angular-forms-textarea.mjs.map +1 -1
  77. package/fesm2022/sdcorejs-angular-i18n.mjs +20 -0
  78. package/fesm2022/sdcorejs-angular-i18n.mjs.map +1 -1
  79. package/fesm2022/sdcorejs-angular-services-confirm.mjs +1 -1
  80. package/fesm2022/sdcorejs-angular-services-confirm.mjs.map +1 -1
  81. package/fesm2022/sdcorejs-angular-services-notify.mjs +15 -2
  82. package/fesm2022/sdcorejs-angular-services-notify.mjs.map +1 -1
  83. package/forms/autocomplete/src/autocomplete.component.d.ts +16 -3
  84. package/forms/checkbox/src/checkbox.component.d.ts +5 -1
  85. package/forms/chip/src/chip.component.d.ts +5 -2
  86. package/forms/chip-calendar/src/chip-calendar.component.d.ts +5 -2
  87. package/forms/date/src/date.component.d.ts +14 -5
  88. package/forms/date-range/src/date-range.component.d.ts +12 -5
  89. package/forms/datetime/src/datetime.component.d.ts +14 -5
  90. package/forms/inline-text/index.d.ts +1 -0
  91. package/forms/inline-text/src/inline-text.component.d.ts +76 -0
  92. package/forms/input/src/input.component.d.ts +14 -2
  93. package/forms/input-color/src/input-color.component.d.ts +3 -1
  94. package/forms/input-number/src/input-number.component.d.ts +14 -2
  95. package/forms/models/index.d.ts +1 -0
  96. package/forms/models/src/sd-viewed.d.ts +38 -0
  97. package/forms/radio/src/radio.component.d.ts +5 -2
  98. package/forms/select/src/select.component.d.ts +23 -5
  99. package/forms/switch/src/switch.component.d.ts +5 -2
  100. package/forms/textarea/src/textarea.component.d.ts +9 -2
  101. package/i18n/src/en.d.ts +4 -0
  102. package/package.json +10 -1
  103. package/services/notify/src/components/toast/toast.component.d.ts +4 -0
@@ -1,12 +1,100 @@
1
- export interface SdTableOptionTree<T = any> {
2
- /** Key trên object row chứa mảng children. Mặc định: 'children' */
3
- childrenKey?: string;
4
- /** Giới hạn độ sâu cây. undefined = không giới hạn. */
1
+ import { NestedKeyOf } from '@sdcorejs/utils/models';
2
+ /**
3
+ * Cấu hình tree-rows cho `<sd-table>` — render dòng con inline dưới dòng cha
4
+ * kèm expand/collapse.
5
+ *
6
+ * Đây là discriminated union theo `loadType`:
7
+ * - `'static'` ({@link TableOptionTreeStatic}) — children đã nằm sẵn trong data
8
+ * (embedded array tại `childrenKey`). Không gọi API khi bung.
9
+ * - `'lazy'` ({@link TableOptionTreeLazy}) — children nạp theo yêu cầu qua
10
+ * `onExpandChildren` khi người dùng bung dòng lần đầu.
11
+ *
12
+ * `loadType` là discriminant: TypeScript dựa vào nó để narrow union (vd chỉ
13
+ * `static` mới có `childrenKey`/`defaultExpanded`, chỉ `lazy` mới có
14
+ * `onExpandChildren`). Dùng type-guard `isLazyTree()` trong `tree.util.ts` để
15
+ * narrow an toàn thay vì truy cập field trực tiếp trên union.
16
+ *
17
+ * @example Static (children embedded)
18
+ * ```ts
19
+ * tree: { loadType: 'static', childrenKey: 'children', defaultExpanded: 1 }
20
+ * ```
21
+ * @example Lazy (nạp theo yêu cầu)
22
+ * ```ts
23
+ * tree: { loadType: 'lazy', onExpandChildren: row => api.getChildren(row.id) }
24
+ * ```
25
+ */
26
+ export type SdTableOptionTree<T = any> = TableOptionTreeStatic<T> | TableOptionTreeLazy<T>;
27
+ /**
28
+ * Tree với dữ liệu children **embedded** sẵn trong mỗi row.
29
+ *
30
+ * Table đọc mảng con tại `childrenKey` ngay trên object data; không có lời gọi
31
+ * bất đồng bộ nào khi bung dòng. Đây cũng là chế độ hỗ trợ **search ở cấp con**
32
+ * cho table `type: 'local'` (xem `tree.util.ts#subtreeMatches` /
33
+ * `filterMatchingChildren`): khi lọc, một nhánh được giữ lại nếu chính nó hoặc
34
+ * bất kỳ hậu duệ nào khớp từ khoá, và nhánh khớp sẽ tự bung.
35
+ */
36
+ export interface TableOptionTreeStatic<T = any> {
37
+ /** Chế độ nạp children: dữ liệu đã embedded sẵn trong row. */
38
+ loadType: 'static';
39
+ /**
40
+ * Key trên object row chứa mảng children.
41
+ * Mặc định: `'children'`.
42
+ */
43
+ childrenKey?: NestedKeyOf<T> | 'children';
44
+ /**
45
+ * Giới hạn độ sâu cây (level gốc = 0).
46
+ * `undefined` = không giới hạn.
47
+ */
5
48
  maxDepth?: number;
6
- /** false | true | number (mở tới cấp N) */
49
+ /**
50
+ * Trạng thái bung mặc định khi load:
51
+ * - `false` — thu gọn hết (mặc định)
52
+ * - `true` — bung toàn bộ
53
+ * - `number N` — bung tới cấp `N` (row có `level < N` được bung)
54
+ */
7
55
  defaultExpanded?: boolean | number;
8
- /** Lazy load khi row chưa có children embedded */
9
- onExpandChildren?: (rowData: T) => Promise<T[]> | T[];
10
- /** Pixel indent mỗi cấp. Mặc định: 20 */
56
+ /**
57
+ * Số pixel thụt lề (indent) cho mỗi cấp sâu.
58
+ * Mặc định: `20`.
59
+ */
60
+ indentSize?: number;
61
+ }
62
+ /**
63
+ * Tree với children **nạp lười (lazy)** theo yêu cầu.
64
+ *
65
+ * Khi người dùng bung một dòng lần đầu mà dòng đó chưa có children embedded,
66
+ * table gọi `onExpandChildren(row)` để nạp; kết quả được cache lại trên row
67
+ * (ghi vào key `'children'`) nên các lần bung sau không gọi lại.
68
+ *
69
+ * Lazy tree **không hỗ trợ** `childrenKey` tuỳ biến (luôn dùng `'children'` làm
70
+ * nơi lưu kết quả) và **không hỗ trợ** `defaultExpanded` (không thể bung mặc
71
+ * định nhánh chưa nạp).
72
+ */
73
+ export interface TableOptionTreeLazy<T = any> {
74
+ /** Chế độ nạp children: nạp lười theo yêu cầu khi bung. */
75
+ loadType: 'lazy';
76
+ /**
77
+ * Giới hạn độ sâu cây (level gốc = 0).
78
+ * `undefined` = không giới hạn.
79
+ */
80
+ maxDepth?: number;
81
+ /**
82
+ * Hàm nạp children khi bung dòng chưa có children embedded.
83
+ * Trả về `Promise<T[]>`; kết quả được ghi vào key `'children'` của row data
84
+ * và cache cho các lần bung sau.
85
+ */
86
+ onExpandChildren: (rowData: T) => Promise<T[]>;
87
+ /**
88
+ * Xác định một row có con hay không — để quyết định có hiển thị icon expand.
89
+ * - Không truyền: MỌI lazy node đều hiện icon expand (không biết trước được).
90
+ * - Truyền: chỉ hiện icon khi trả `true`; trả `false` ⇒ row là lá (ẩn icon,
91
+ * không gọi `onExpandChildren`).
92
+ * Lưu ý: nếu row đã có children embedded sẵn thì luôn coi là có con (bỏ qua hàm này).
93
+ */
94
+ hasChildren?: (rowData: T) => boolean;
95
+ /**
96
+ * Số pixel thụt lề (indent) cho mỗi cấp sâu.
97
+ * Mặc định: `20`.
98
+ */
11
99
  indentSize?: number;
12
100
  }
@@ -1,10 +1,51 @@
1
- import { SdTableOptionTree } from '../../models/table-option-tree.model';
1
+ import { SdTableOptionTree, TableOptionTreeLazy } from '../../models/table-option-tree.model';
2
2
  import { SdTableItem } from '../../models/table-item.model';
3
+ /**
4
+ * Type-guard: tree có nạp children lười (lazy) hay không.
5
+ * Dùng để narrow discriminated union `SdTableOptionTree` một cách an toàn —
6
+ * thay vì truy cập `option.onExpandChildren` trực tiếp trên union (chỉ tồn tại
7
+ * ở nhánh lazy).
8
+ */
9
+ export declare const isLazyTree: <T = any>(option?: SdTableOptionTree<T>) => option is TableOptionTreeLazy<T>;
10
+ /**
11
+ * Key chứa mảng children trên object row.
12
+ * - `static`: lấy `childrenKey` đã cấu hình, mặc định `'children'`.
13
+ * - `lazy`: không có `childrenKey` riêng → luôn dùng `'children'` làm nơi lưu
14
+ * kết quả nạp lười.
15
+ */
3
16
  export declare const getChildrenKey: (option?: SdTableOptionTree) => string;
4
17
  export declare const getChildrenFromData: <T>(data: T, option?: SdTableOptionTree) => T[];
18
+ /**
19
+ * Trạng thái bung mặc định cho một cấp.
20
+ * Chỉ `static` mới có `defaultExpanded`; lazy luôn trả `false` (không thể bung
21
+ * mặc định nhánh chưa nạp).
22
+ */
5
23
  export declare const resolveDefaultExpanded: (level: number, option?: SdTableOptionTree) => boolean;
6
- export declare const resolveHasChildren: <T>(row: SdTableItem<T>, option?: SdTableOptionTree) => boolean;
24
+ /**
25
+ * Row có khả năng có children hay không (để hiện nút bung).
26
+ * - Có children embedded → true.
27
+ * - Lazy tree: dùng `hasChildren(row.data)` nếu được cấu hình; không thì luôn
28
+ * true (chưa biết cho tới khi nạp).
29
+ */
30
+ export declare const resolveHasChildren: <T>(row: SdTableItem<T>, option?: SdTableOptionTree<T>) => boolean;
31
+ /** Row cần nạp lười (lazy) khi bung: là lazy tree và chưa có children embedded. */
7
32
  export declare const hasLazyChildren: <T>(row: SdTableItem<T>, option?: SdTableOptionTree) => boolean;
33
+ /**
34
+ * True nếu `data` HOẶC bất kỳ hậu duệ nào (theo `childrenKey`) thoả `predicate`.
35
+ *
36
+ * Dùng cho search ở cấp con (static tree, table `type: 'local'`): một nhánh
37
+ * gốc được giữ lại trong kết quả lọc nếu subtree của nó có ít nhất một node
38
+ * khớp từ khoá. `visited` chống đệ quy vô hạn khi data có circular reference.
39
+ */
40
+ export declare const subtreeMatches: <T>(data: T, predicate: (data: T) => boolean, option?: SdTableOptionTree, visited?: Set<unknown>) => boolean;
41
+ /**
42
+ * Lọc mảng children: chỉ giữ child có subtree khớp `predicate`.
43
+ *
44
+ * Trả về MẢNG MỚI nhưng GIỮ NGUYÊN object reference của từng child (không clone)
45
+ * — nhờ vậy `meta.id` (hash từ data) ổn định, selection / trạng thái bung không
46
+ * bị mất khi từ khoá search đổi. Đây là bước "prune" của tính năng search-con.
47
+ */
48
+ export declare const filterMatchingChildren: <T>(children: T[], predicate: (data: T) => boolean, option?: SdTableOptionTree) => T[];
8
49
  export declare const flattenTree: <T>(roots: SdTableItem<T>[], option?: SdTableOptionTree, visited?: Set<string>) => SdTableItem<T>[];
9
50
  /** Thu thập mọi SdTableItem đã format trong cây (kể cả node đang collapse). */
10
51
  export declare const collectFormattedTreeRows: <T>(roots: SdTableItem<T>[]) => SdTableItem<T>[];
@@ -1,16 +1,49 @@
1
1
  import { TemplateRef } from '@angular/core';
2
2
  import * as i0 from "@angular/core";
3
+ /**
4
+ * `<sd-view>` — pure read-only display of a value (text, hyperlink, or a custom template).
5
+ *
6
+ * Presentational proxy with no state of its own: the parent form control (`<sd-select>`,
7
+ * `<sd-input>`, …) computes the display string + resolved selection and passes them in;
8
+ * `<sd-view>` only decides WHICH template renders. It is the single rendering path for every
9
+ * "viewed" state across the form controls (DETAIL `viewed=true` and the `viewed='inline'`
10
+ * text face), so a custom `valueTemplate` (e.g. `sdViewDef` / `#sdValue`) looks identical in
11
+ * both. OnPush — re-renders only when an input signal changes.
12
+ */
3
13
  export declare class SdView {
14
+ /** Optional label rendered above the value (omitted when a parent supplies its own label). */
4
15
  label: import("@angular/core").InputSignal<string | null | undefined>;
16
+ /** Raw selected value — NOT rendered directly; only exposed in the `valueTemplate` context as `value`. */
5
17
  value: import("@angular/core").InputSignal<any>;
18
+ /**
19
+ * Display string — what shows when no custom value template is bound.
20
+ * why: `input.required()` forces the parent to bind `[display]` (compile error otherwise),
21
+ * so the component never has to guess a fallback string from `value`.
22
+ */
6
23
  display: import("@angular/core").InputSignal<string | null | undefined>;
24
+ /** When set, the value renders as a link (`<a [sdHref]>`) instead of plain text. */
7
25
  hyperlink: import("@angular/core").InputSignal<string | null | undefined>;
26
+ /** Label template handed down by a parent control (wins over `label` + `#sdLabel`). */
8
27
  labelTemplate: import("@angular/core").InputSignal<TemplateRef<any> | undefined>;
28
+ /** Value template handed down by a parent control (wins over `display` + `#sdValue`). */
9
29
  valueTemplate: import("@angular/core").InputSignal<TemplateRef<any> | undefined>;
30
+ /**
31
+ * Resolved selected-item objects passed by the parent (e.g. `<sd-select>`).
32
+ * why: the parent owns option/lazy resolution — `<sd-view>` is a proxy and must NOT rebuild
33
+ * the list. Exposed in the value-template context so a "head +N" template can read `displayField`.
34
+ */
10
35
  selectedItems: import("@angular/core").InputSignal<any[] | undefined>;
36
+ /** `#sdLabel` template projected directly into `<sd-view>` (fallback when no `[labelTemplate]`). */
11
37
  contentLabelTemplate: import("@angular/core").Signal<TemplateRef<any> | undefined>;
38
+ /** `#sdValue` template projected directly into `<sd-view>` (fallback when no `[valueTemplate]`). */
12
39
  contentValueTemplate: import("@angular/core").Signal<TemplateRef<any> | undefined>;
40
+ /**
41
+ * Effective label template: input from parent wins, else the projected `#sdLabel`.
42
+ * why: `computed` caches the choice so the template's `@if (activeLabelTemplate())` doesn't
43
+ * re-evaluate two content-child reads on every change-detection pass.
44
+ */
13
45
  activeLabelTemplate: import("@angular/core").Signal<TemplateRef<any> | undefined>;
46
+ /** Effective value template: input from parent wins, else the projected `#sdValue`. Cached for the same reason. */
14
47
  activeValueTemplate: import("@angular/core").Signal<TemplateRef<any> | undefined>;
15
48
  static ɵfac: i0.ɵɵFactoryDeclaration<SdView, never>;
16
49
  static ɵcmp: i0.ɵɵComponentDeclaration<SdView, "sd-view", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "display": { "alias": "display"; "required": true; "isSignal": true; }; "hyperlink": { "alias": "hyperlink"; "required": false; "isSignal": true; }; "labelTemplate": { "alias": "labelTemplate"; "required": false; "isSignal": true; }; "valueTemplate": { "alias": "valueTemplate"; "required": false; "isSignal": true; }; "selectedItems": { "alias": "selectedItems"; "required": false; "isSignal": true; }; }, {}, ["contentLabelTemplate", "contentValueTemplate"], never, true, never>;