@sdcorejs/angular 20.2.14 → 20.3.0

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 (205) hide show
  1. package/README.md +7 -5
  2. package/assets/STYLE-GUIDE.md +6 -3
  3. package/assets/THEME.md +166 -0
  4. package/assets/fonts/fonts.scss +1 -1
  5. package/assets/scss/ckeditor5.scss +2 -2
  6. package/assets/scss/core/_inline-edit.scss +3 -3
  7. package/assets/scss/core/_read-state-panel.scss +2 -2
  8. package/assets/scss/core/color.scss +4 -2
  9. package/assets/scss/core/form.scss +35 -12
  10. package/assets/scss/core/scrollbar.scss +3 -3
  11. package/assets/scss/core/utilities/_base.scss +5 -5
  12. package/assets/scss/core/utilities/_typography.scss +22 -22
  13. package/assets/scss/sd-core.scss +12 -0
  14. package/assets/scss/themes/_component-tokens.scss +261 -0
  15. package/assets/scss/themes/_presets.scss +3 -0
  16. package/assets/scss/themes/_ramps.scss +56 -0
  17. package/assets/scss/themes/_scales.scss +90 -0
  18. package/assets/scss/themes/_semantic.scss +22 -0
  19. package/assets/scss/themes/default.scss +113 -10
  20. package/assets/scss/themes/material-theme.scss +3 -0
  21. package/components/breadcrumb/index.d.ts +2 -1
  22. package/components/button/index.d.ts +5 -0
  23. package/components/data-state/index.d.ts +6 -2
  24. package/components/file-explorer/index.d.ts +503 -0
  25. package/components/form-generic/index.d.ts +897 -835
  26. package/components/highlight/index.d.ts +27 -0
  27. package/components/image-editor/index.d.ts +478 -0
  28. package/components/index.d.ts +3 -0
  29. package/components/inform/index.d.ts +5 -2
  30. package/components/mini-editor/index.d.ts +1 -1
  31. package/components/preview/index.d.ts +51 -2
  32. package/components/query-builder/index.d.ts +1 -1
  33. package/components/section/index.d.ts +5 -1
  34. package/components/side-drawer/index.d.ts +13 -2
  35. package/components/table/index.d.ts +6 -0
  36. package/directives/index.d.ts +8 -0
  37. package/fesm2022/sdcorejs-angular-components-anchor.mjs +2 -2
  38. package/fesm2022/sdcorejs-angular-components-anchor.mjs.map +1 -1
  39. package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs +6 -6
  40. package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs.map +1 -1
  41. package/fesm2022/sdcorejs-angular-components-audit-diff.mjs +2 -2
  42. package/fesm2022/sdcorejs-angular-components-audit-diff.mjs.map +1 -1
  43. package/fesm2022/sdcorejs-angular-components-autoid-inspector.mjs +2 -2
  44. package/fesm2022/sdcorejs-angular-components-autoid-inspector.mjs.map +1 -1
  45. package/fesm2022/sdcorejs-angular-components-avatar.mjs +34 -27
  46. package/fesm2022/sdcorejs-angular-components-avatar.mjs.map +1 -1
  47. package/fesm2022/sdcorejs-angular-components-badge.mjs +2 -2
  48. package/fesm2022/sdcorejs-angular-components-badge.mjs.map +1 -1
  49. package/fesm2022/sdcorejs-angular-components-breadcrumb.mjs +35 -5
  50. package/fesm2022/sdcorejs-angular-components-breadcrumb.mjs.map +1 -1
  51. package/fesm2022/sdcorejs-angular-components-button.mjs +23 -11
  52. package/fesm2022/sdcorejs-angular-components-button.mjs.map +1 -1
  53. package/fesm2022/sdcorejs-angular-components-card.mjs +2 -2
  54. package/fesm2022/sdcorejs-angular-components-card.mjs.map +1 -1
  55. package/fesm2022/sdcorejs-angular-components-ckeditor-styles.mjs +2 -2
  56. package/fesm2022/sdcorejs-angular-components-ckeditor-styles.mjs.map +1 -1
  57. package/fesm2022/sdcorejs-angular-components-code-editor.mjs +2 -2
  58. package/fesm2022/sdcorejs-angular-components-code-editor.mjs.map +1 -1
  59. package/fesm2022/sdcorejs-angular-components-data-state.mjs +8 -4
  60. package/fesm2022/sdcorejs-angular-components-data-state.mjs.map +1 -1
  61. package/fesm2022/sdcorejs-angular-components-editor.mjs +12 -4
  62. package/fesm2022/sdcorejs-angular-components-editor.mjs.map +1 -1
  63. package/fesm2022/sdcorejs-angular-components-file-explorer.mjs +2637 -0
  64. package/fesm2022/sdcorejs-angular-components-file-explorer.mjs.map +1 -0
  65. package/fesm2022/sdcorejs-angular-components-form-generic.mjs +5846 -6504
  66. package/fesm2022/sdcorejs-angular-components-form-generic.mjs.map +1 -1
  67. package/fesm2022/sdcorejs-angular-components-highlight.mjs +63 -0
  68. package/fesm2022/sdcorejs-angular-components-highlight.mjs.map +1 -0
  69. package/fesm2022/sdcorejs-angular-components-history.mjs +2 -2
  70. package/fesm2022/sdcorejs-angular-components-history.mjs.map +1 -1
  71. package/fesm2022/sdcorejs-angular-components-image-editor.mjs +2088 -0
  72. package/fesm2022/sdcorejs-angular-components-image-editor.mjs.map +1 -0
  73. package/fesm2022/sdcorejs-angular-components-import-excel.mjs +2 -2
  74. package/fesm2022/sdcorejs-angular-components-import-excel.mjs.map +1 -1
  75. package/fesm2022/sdcorejs-angular-components-inform.mjs +9 -5
  76. package/fesm2022/sdcorejs-angular-components-inform.mjs.map +1 -1
  77. package/fesm2022/sdcorejs-angular-components-job-progress.mjs +2 -2
  78. package/fesm2022/sdcorejs-angular-components-job-progress.mjs.map +1 -1
  79. package/fesm2022/sdcorejs-angular-components-mini-editor.mjs +40 -22
  80. package/fesm2022/sdcorejs-angular-components-mini-editor.mjs.map +1 -1
  81. package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs +2 -2
  82. package/fesm2022/sdcorejs-angular-components-modal-resizable.mjs.map +1 -1
  83. package/fesm2022/sdcorejs-angular-components-modal.mjs +2 -2
  84. package/fesm2022/sdcorejs-angular-components-modal.mjs.map +1 -1
  85. package/fesm2022/sdcorejs-angular-components-operator.mjs +2 -2
  86. package/fesm2022/sdcorejs-angular-components-operator.mjs.map +1 -1
  87. package/fesm2022/sdcorejs-angular-components-org-chart.mjs +2 -2
  88. package/fesm2022/sdcorejs-angular-components-org-chart.mjs.map +1 -1
  89. package/fesm2022/sdcorejs-angular-components-preview.mjs +129 -7
  90. package/fesm2022/sdcorejs-angular-components-preview.mjs.map +1 -1
  91. package/fesm2022/sdcorejs-angular-components-query-bar.mjs +33 -24
  92. package/fesm2022/sdcorejs-angular-components-query-bar.mjs.map +1 -1
  93. package/fesm2022/sdcorejs-angular-components-query-builder.mjs +2 -2
  94. package/fesm2022/sdcorejs-angular-components-query-builder.mjs.map +1 -1
  95. package/fesm2022/sdcorejs-angular-components-quick-action.mjs +2 -2
  96. package/fesm2022/sdcorejs-angular-components-quick-action.mjs.map +1 -1
  97. package/fesm2022/sdcorejs-angular-components-section.mjs +11 -7
  98. package/fesm2022/sdcorejs-angular-components-section.mjs.map +1 -1
  99. package/fesm2022/sdcorejs-angular-components-side-drawer.mjs +118 -9
  100. package/fesm2022/sdcorejs-angular-components-side-drawer.mjs.map +1 -1
  101. package/fesm2022/sdcorejs-angular-components-splitter.mjs +2 -2
  102. package/fesm2022/sdcorejs-angular-components-splitter.mjs.map +1 -1
  103. package/fesm2022/sdcorejs-angular-components-stepper.mjs +2 -2
  104. package/fesm2022/sdcorejs-angular-components-stepper.mjs.map +1 -1
  105. package/fesm2022/sdcorejs-angular-components-tab-router.mjs +4 -4
  106. package/fesm2022/sdcorejs-angular-components-tab-router.mjs.map +1 -1
  107. package/fesm2022/sdcorejs-angular-components-tab.mjs +2 -2
  108. package/fesm2022/sdcorejs-angular-components-tab.mjs.map +1 -1
  109. package/fesm2022/sdcorejs-angular-components-table.mjs +308 -113
  110. package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
  111. package/fesm2022/sdcorejs-angular-components-tree.mjs +2 -2
  112. package/fesm2022/sdcorejs-angular-components-tree.mjs.map +1 -1
  113. package/fesm2022/sdcorejs-angular-components-upload-file.mjs +14 -5
  114. package/fesm2022/sdcorejs-angular-components-upload-file.mjs.map +1 -1
  115. package/fesm2022/sdcorejs-angular-components.mjs +3 -0
  116. package/fesm2022/sdcorejs-angular-components.mjs.map +1 -1
  117. package/fesm2022/sdcorejs-angular-directives.mjs +99 -13
  118. package/fesm2022/sdcorejs-angular-directives.mjs.map +1 -1
  119. package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs +149 -6
  120. package/fesm2022/sdcorejs-angular-forms-autocomplete.mjs.map +1 -1
  121. package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs +19 -4
  122. package/fesm2022/sdcorejs-angular-forms-chip-calendar.mjs.map +1 -1
  123. package/fesm2022/sdcorejs-angular-forms-chip.mjs +19 -4
  124. package/fesm2022/sdcorejs-angular-forms-chip.mjs.map +1 -1
  125. package/fesm2022/sdcorejs-angular-forms-date-range.mjs +2 -2
  126. package/fesm2022/sdcorejs-angular-forms-date-range.mjs.map +1 -1
  127. package/fesm2022/sdcorejs-angular-forms-date.mjs +17 -7
  128. package/fesm2022/sdcorejs-angular-forms-date.mjs.map +1 -1
  129. package/fesm2022/sdcorejs-angular-forms-datetime.mjs +17 -7
  130. package/fesm2022/sdcorejs-angular-forms-datetime.mjs.map +1 -1
  131. package/fesm2022/sdcorejs-angular-forms-entity-picker.mjs +2 -2
  132. package/fesm2022/sdcorejs-angular-forms-entity-picker.mjs.map +1 -1
  133. package/fesm2022/sdcorejs-angular-forms-inline-text.mjs +3 -3
  134. package/fesm2022/sdcorejs-angular-forms-inline-text.mjs.map +1 -1
  135. package/fesm2022/sdcorejs-angular-forms-input-color.mjs +2 -2
  136. package/fesm2022/sdcorejs-angular-forms-input-color.mjs.map +1 -1
  137. package/fesm2022/sdcorejs-angular-forms-input-number.mjs +18 -4
  138. package/fesm2022/sdcorejs-angular-forms-input-number.mjs.map +1 -1
  139. package/fesm2022/sdcorejs-angular-forms-input.mjs +29 -5
  140. package/fesm2022/sdcorejs-angular-forms-input.mjs.map +1 -1
  141. package/fesm2022/sdcorejs-angular-forms-label.mjs +27 -2
  142. package/fesm2022/sdcorejs-angular-forms-label.mjs.map +1 -1
  143. package/fesm2022/sdcorejs-angular-forms-radio.mjs +1 -1
  144. package/fesm2022/sdcorejs-angular-forms-radio.mjs.map +1 -1
  145. package/fesm2022/sdcorejs-angular-forms-select.mjs +498 -7
  146. package/fesm2022/sdcorejs-angular-forms-select.mjs.map +1 -1
  147. package/fesm2022/sdcorejs-angular-forms-switch.mjs +1 -1
  148. package/fesm2022/sdcorejs-angular-forms-switch.mjs.map +1 -1
  149. package/fesm2022/sdcorejs-angular-forms-textarea.mjs +22 -4
  150. package/fesm2022/sdcorejs-angular-forms-textarea.mjs.map +1 -1
  151. package/fesm2022/sdcorejs-angular-forms-time-range.mjs +2 -2
  152. package/fesm2022/sdcorejs-angular-forms-time-range.mjs.map +1 -1
  153. package/fesm2022/sdcorejs-angular-forms-time.mjs +2 -2
  154. package/fesm2022/sdcorejs-angular-forms-time.mjs.map +1 -1
  155. package/fesm2022/sdcorejs-angular-forms-tree-select.mjs +1 -1
  156. package/fesm2022/sdcorejs-angular-forms-tree-select.mjs.map +1 -1
  157. package/fesm2022/sdcorejs-angular-i18n.mjs +1859 -271
  158. package/fesm2022/sdcorejs-angular-i18n.mjs.map +1 -1
  159. package/fesm2022/sdcorejs-angular-modules-auth.mjs +35 -3
  160. package/fesm2022/sdcorejs-angular-modules-auth.mjs.map +1 -1
  161. package/fesm2022/sdcorejs-angular-modules-icon.mjs +25 -0
  162. package/fesm2022/sdcorejs-angular-modules-icon.mjs.map +1 -1
  163. package/fesm2022/sdcorejs-angular-modules-layout.mjs +39 -48
  164. package/fesm2022/sdcorejs-angular-modules-layout.mjs.map +1 -1
  165. package/fesm2022/sdcorejs-angular-modules-permission.mjs.map +1 -1
  166. package/fesm2022/sdcorejs-angular-services-api.mjs +196 -8
  167. package/fesm2022/sdcorejs-angular-services-api.mjs.map +1 -1
  168. package/fesm2022/sdcorejs-angular-services-confirm.mjs +10 -3
  169. package/fesm2022/sdcorejs-angular-services-confirm.mjs.map +1 -1
  170. package/fesm2022/sdcorejs-angular-services-excel.mjs +5 -0
  171. package/fesm2022/sdcorejs-angular-services-excel.mjs.map +1 -1
  172. package/fesm2022/sdcorejs-angular-services-loading.mjs +1 -1
  173. package/fesm2022/sdcorejs-angular-services-loading.mjs.map +1 -1
  174. package/fesm2022/sdcorejs-angular-services-notify.mjs +107 -7
  175. package/fesm2022/sdcorejs-angular-services-notify.mjs.map +1 -1
  176. package/fesm2022/sdcorejs-angular-utilities-extensions.mjs +458 -1
  177. package/fesm2022/sdcorejs-angular-utilities-extensions.mjs.map +1 -1
  178. package/fesm2022/sdcorejs-angular-utilities-theme.mjs +169 -0
  179. package/fesm2022/sdcorejs-angular-utilities-theme.mjs.map +1 -0
  180. package/fesm2022/sdcorejs-angular-utilities.mjs +1 -0
  181. package/fesm2022/sdcorejs-angular-utilities.mjs.map +1 -1
  182. package/forms/autocomplete/index.d.ts +19 -1
  183. package/forms/chip/index.d.ts +13 -2
  184. package/forms/chip-calendar/index.d.ts +13 -2
  185. package/forms/date/index.d.ts +7 -2
  186. package/forms/datetime/index.d.ts +7 -2
  187. package/forms/inline-text/index.d.ts +1 -1
  188. package/forms/input/index.d.ts +21 -5
  189. package/forms/input-number/index.d.ts +12 -2
  190. package/forms/label/index.d.ts +16 -1
  191. package/forms/models/index.d.ts +16 -1
  192. package/forms/select/index.d.ts +66 -4
  193. package/forms/textarea/index.d.ts +9 -2
  194. package/i18n/index.d.ts +370 -54
  195. package/modules/auth/index.d.ts +3 -3
  196. package/modules/icon/index.d.ts +11 -1
  197. package/modules/layout/index.d.ts +2 -2
  198. package/modules/permission/index.d.ts +3 -2
  199. package/package.json +18 -2
  200. package/services/api/index.d.ts +49 -2
  201. package/services/confirm/index.d.ts +15 -0
  202. package/services/notify/index.d.ts +8 -0
  203. package/utilities/extensions/index.d.ts +68 -1
  204. package/utilities/index.d.ts +1 -0
  205. package/utilities/theme/index.d.ts +25 -0
@@ -1,921 +1,983 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { InjectionToken, OnDestroy, OnInit, AfterViewInit, QueryList } from '@angular/core';
3
- import { SdSearch, SdCustomValidator } from '@sdcorejs/angular/forms/models';
4
- import { SdTableColumn, SdTableOption, SdTable } from '@sdcorejs/angular/components/table';
5
- import { SdUploadFile } from '@sdcorejs/angular/components/upload-file';
6
- import { Operator, ValidationPatternType, Color } from '@sdcorejs/utils/models';
7
- import { SdUnwrapSignal } from '@sdcorejs/angular/utilities/models';
8
- import { CdkDropList, CdkDragMove, CdkDragDrop, CdkDragEnter, CdkDragSortEvent, CdkDrag } from '@angular/cdk/drag-drop';
9
- import { FormGroup } from '@angular/forms';
2
+ import { EnvironmentProviders, ElementRef } from '@angular/core';
3
+ import { Filter, Color } from '@sdcorejs/utils/models';
10
4
  import { SdModal } from '@sdcorejs/angular/components/modal';
11
- import { Subject } from 'rxjs';
12
- import { SdSideDrawer } from '@sdcorejs/angular/components/side-drawer';
13
- import { SdSearch as SdSearch$1 } from '@sdcorejs/angular/forms';
14
5
  import * as _sdcorejs_angular_components_form_generic from '@sdcorejs/angular/components/form-generic';
6
+ import { Subject } from 'rxjs';
7
+ import { FormGroup } from '@angular/forms';
8
+ import { SdLabelPlacement } from '@sdcorejs/angular/forms/models';
15
9
 
16
- type SdFormRenderEntity = Record<string, any> & {
17
- sdRaw?: Record<string, any>;
18
- };
19
-
20
- interface SdFormGenericSelectionItem<T = unknown> {
21
- value: string;
22
- display: string;
23
- disabled?: boolean;
24
- template?: string;
25
- data?: T;
26
- }
27
- interface SdFormGenericSelectionStaticItem {
28
- value: string;
29
- label: string;
10
+ /** Mức bố cục của form, chọn theo bề rộng FORM (không phải màn hình). */
11
+ type SdFormGenericBreakpoint = 'mobile' | 'tablet' | 'desktop';
12
+ /** Ngưỡng (px, bề rộng form) bắt đầu mức tablet và desktop. */
13
+ interface SdFormGenericBreakpoints {
14
+ tablet: number;
15
+ desktop: number;
30
16
  }
31
- type SdFormGenericDefinitionSelection<T = unknown, TArgs = unknown> = SelectionValues<T> | SelectionLazyValues<T> | SelectionValuesKey<TArgs> | SelectionLazyValuesKey<TArgs>;
32
- interface SelectionVariables<T = unknown> {
33
- items?: {
34
- value: Extract<keyof T, string>;
35
- display: string;
36
- }[];
37
- detail?: (values: string | number | string[] | number[], args: SdFormGenericArgs) => Promise<T | undefined>;
17
+ /**
18
+ * Ngưỡng mặc định: < 600px là mobile, 600–1023px là tablet, từ 1024px là desktop.
19
+ * Portal ghi đè từng phần qua `provideSdFormGeneric({ breakpoints })`.
20
+ */
21
+ declare const SD_FORM_GENERIC_BREAKPOINTS: Readonly<{
22
+ readonly tablet: 600;
23
+ readonly desktop: 1024;
24
+ }>;
25
+
26
+ /**
27
+ * Bố cục của một phần tử trên lưới 12 cột, theo 3 mức bề rộng FORM (không phải màn hình).
28
+ *
29
+ * - `span.desktop` mặc định 12; `span.tablet` mặc định theo desktop; `span.mobile` mặc định 12.
30
+ * - `newRow: true` luôn mở hàng mới dù hàng trước còn chỗ (thay cho phần tử `break` cũ).
31
+ */
32
+ interface SdFormGenericLayout {
33
+ span?: {
34
+ desktop?: number;
35
+ tablet?: number;
36
+ mobile?: number;
37
+ };
38
+ newRow?: boolean;
38
39
  }
39
- interface SelectionQueries {
40
- items?: {
40
+ /**
41
+ * Điều kiện động, lưu bằng `Filter` của `@sdcorejs/utils` và đánh giá trên `{ ...value, ...variables }`.
42
+ * Hiện khi (`visible` vắng hoặc đúng) và (`hidden` vắng hoặc sai); `disabled`/`required` là OR với cờ tĩnh.
43
+ */
44
+ interface SdFormGenericRules {
45
+ visible?: Filter;
46
+ hidden?: Filter;
47
+ disabled?: Filter;
48
+ required?: Filter;
49
+ }
50
+ /** Quốc gia ép định dạng số điện thoại cho `subtype: 'phone'`. Hiện hỗ trợ `'VN'`. */
51
+ type SdFormGenericPhoneCountry = 'VN';
52
+ /** Ràng buộc của field. `min`/`max`: số với `number`; `'today'` hoặc ngày ISO với `datetime`. */
53
+ interface SdFormGenericFieldValidation {
54
+ required?: boolean;
55
+ min?: number | 'today' | (string & {});
56
+ max?: number | 'today' | (string & {});
57
+ minLength?: number;
58
+ maxLength?: number;
59
+ pattern?: {
41
60
  value: string;
42
- display: string;
43
- }[];
61
+ message?: string;
62
+ };
63
+ /** Số phần tử tối đa của chip-string / chip-calendar. */
64
+ maxItems?: number;
65
+ phoneCountry?: SdFormGenericPhoneCountry;
44
66
  }
45
- interface SelecttionBase {
67
+ /** Một lựa chọn tĩnh của select/radio. */
68
+ interface SdFormGenericOption {
46
69
  value: string;
47
- display: string;
48
- viewed?: (values: (string | number)[], args: SdFormGenericArgs) => Promise<string>;
49
- queries?: SelectionQueries;
50
- variables?: SelectionVariables;
51
- }
52
- interface SelectionValuesKey<TArgs> extends SelecttionBase {
53
- valuesKey: string;
54
- args?: TArgs;
55
- }
56
- interface SelectionLazyValuesKey<TArgs> extends SelecttionBase {
57
- lazyValuesKey: string;
58
- args?: TArgs;
70
+ label: string;
71
+ disabled?: boolean;
59
72
  }
60
- interface SelectionValues<T = unknown> extends SelecttionBase {
61
- values: (args: SdFormGenericArgs) => Promise<SdFormGenericSelectionItem<T>[]>;
73
+ /** Tham chiếu có cấu trúc tới giá trị: field khác, biến, hoặc hằng số. */
74
+ type SdFormGenericValueRef = {
75
+ field: string;
76
+ } | {
77
+ variable: string;
78
+ } | {
79
+ value: string | number | boolean;
80
+ };
81
+ /** Tham số gửi cho catalog / html query / upload, giá trị là tham chiếu có cấu trúc. */
82
+ interface SdFormGenericParam {
83
+ name: string;
84
+ value: SdFormGenericValueRef;
62
85
  }
63
- interface SelectionLazyValues<T = unknown> extends SelecttionBase {
64
- lazyValues: (searchArgs: Parameters<SdSearch>[0], args: SdFormGenericArgs) => Promise<SdFormGenericSelectionItem<T>[]>;
86
+ /** Khi người dùng chọn một mục catalog: ghi `item.data[from]` vào field `field`. */
87
+ interface SdFormGenericFill {
88
+ field: string;
89
+ from: string;
65
90
  }
66
-
67
- interface SdFormGenericExpression {
68
- key: string;
69
- type: 'combinator';
70
- combinator: '&&' | '||';
71
- conditions: (SdFormGenericExpression | SdFormGenericExpressionCondition)[];
72
- }
73
- interface SdFormGenericExpressionCondition {
91
+ /** Nguồn lựa chọn: danh sách tĩnh, hoặc catalog đăng ký ở `provideSdFormGeneric`. */
92
+ type SdFormGenericOptions = {
93
+ source: 'static';
94
+ items: SdFormGenericOption[];
95
+ } | {
96
+ source: 'catalog';
97
+ catalog: string;
98
+ params?: SdFormGenericParam[];
99
+ fill?: SdFormGenericFill[];
100
+ };
101
+ /**
102
+ * Kiểu nhập (preset) của `textfield`. Không có / `'text'` = văn bản tự do.
103
+ * `'password'` che ký tự, không áp `defaultValue`, không hiện giá trị ở chế độ xem.
104
+ */
105
+ type SdFormGenericTextfieldSubtype = 'text' | 'email' | 'phone' | 'url' | 'password';
106
+ /**
107
+ * Kiểu số (preset) của `number`. Dữ liệu luôn là `number`; ký hiệu và dấu phân cách chỉ là trình bày.
108
+ * `'percent'` theo quy ước của `sd-input-number`: nhập `10` nghĩa là 10%.
109
+ */
110
+ type SdFormGenericNumberSubtype = 'integer' | 'decimal' | 'currency' | 'percent';
111
+ interface SdFormGenericFieldBase<TType extends string, TValue> {
112
+ id: string;
113
+ type: TType;
74
114
  key: string;
75
- type: 'condition';
76
- field?: string;
77
- operator: Operator;
78
- value: any;
79
- dayInfo: DayInfo;
80
- }
81
- type SdFormGenericOperator = 'EQUAL' | 'NOT_EQUAL' | 'GREATER_THAN' | 'LESS_THAN' | 'GREATER_OR_EQUAL' | 'LESS_OR_EQUAL' | 'NULL' | 'NOT_NULL';
82
- declare const SdFormGenericOperators: {
83
- value: SdFormGenericOperator;
84
- symbol?: string;
85
- display: string;
86
- }[];
87
- type Attribute = AttributeBase | AttributeBoolean | AttributeDate | AttributeValues;
88
- interface AttributeBase {
89
- value: string;
90
- display: string;
91
- type: 'string' | 'number';
92
- }
93
- interface AttributeBoolean {
94
- value: string;
95
- display: string;
96
- type: 'boolean';
97
- displayOnTrue: string;
98
- displayOnFalse: string;
99
- }
100
- interface AttributeDate {
101
- value: string;
102
- display: string;
103
- type: 'datetime';
104
- }
105
- interface DayInfo {
106
- type?: 'RELATED' | 'NOW' | 'DATETIME' | 'ATTRIBUTE';
107
- related?: 'LASTDAY' | 'NEXTDAY' | 'LASTWEEK' | 'NEXTWEEK' | 'LASTMONTH' | 'NEXTMONTH';
108
- relatedValue?: number;
109
- }
110
- declare const SD_DAY_INFO_TYPES: {
111
- value: string;
112
- display: string;
113
- }[];
114
- declare const SD_DAY_INFO_PREVIOUSES: {
115
- value: string;
116
- display: string;
117
- format: (n: number) => string;
118
- }[];
119
- declare const sdGetDatetimeValue: (value: string) => string | undefined;
120
- interface AttributeValues {
121
- value: string;
122
- display: string;
123
- type: 'values';
124
- values: {
125
- value: string;
126
- display: string;
127
- }[];
115
+ label: string;
116
+ placeholder?: string;
117
+ helperText?: string;
118
+ defaultValue?: TValue;
119
+ layout?: SdFormGenericLayout;
120
+ rules?: SdFormGenericRules;
121
+ validation?: SdFormGenericFieldValidation;
122
+ disabled?: boolean;
123
+ /** Hiển thị dạng chỉ xem (khác disabled). */
124
+ viewed?: boolean;
125
+ hidden?: boolean;
126
+ /** Link khi ở chế độ chỉ xem; `${key}` trong chuỗi là văn bản tự do, không được đổi khi đổi mã. */
127
+ hyperlink?: string;
128
+ }
129
+ interface SdFormGenericTextfield extends SdFormGenericFieldBase<'textfield', string> {
130
+ subtype?: SdFormGenericTextfieldSubtype;
131
+ }
132
+ type SdFormGenericTextarea = SdFormGenericFieldBase<'textarea', string>;
133
+ interface SdFormGenericNumber extends SdFormGenericFieldBase<'number', number> {
134
+ subtype?: SdFormGenericNumberSubtype;
135
+ /** Số chữ số thập phân tối đa; không có thì theo preset. */
136
+ precision?: number;
137
+ /** Mã tiền tệ cho `subtype: 'currency'` (mặc định `VND`). */
138
+ currency?: string;
139
+ }
140
+ interface SdFormGenericSelect extends SdFormGenericFieldBase<'select', string | string[]> {
141
+ options: SdFormGenericOptions;
142
+ multiple?: boolean;
143
+ }
144
+ interface SdFormGenericRadio extends SdFormGenericFieldBase<'radio', string> {
145
+ options: SdFormGenericOptions;
146
+ direction?: 'row' | 'column';
147
+ }
148
+ type SdFormGenericCheckbox = SdFormGenericFieldBase<'checkbox', boolean>;
149
+ interface SdFormGenericDatetime extends SdFormGenericFieldBase<'datetime', string> {
150
+ subtype?: 'date' | 'datetime';
151
+ }
152
+ type SdFormGenericChipString = SdFormGenericFieldBase<'chip-string', string[]>;
153
+ type SdFormGenericChipCalendar = SdFormGenericFieldBase<'chip-calendar', string[]>;
154
+ interface SdFormGenericUpload extends SdFormGenericFieldBase<'upload', unknown> {
155
+ accept?: 'file' | 'image';
156
+ source?: 'ALL' | 'PHOTO_LIBRARY' | 'CAPTURE';
157
+ extensions?: string[];
158
+ maxFiles?: number;
159
+ maxSizeMb?: number;
160
+ params?: SdFormGenericParam[];
161
+ }
162
+ /** Nội dung HTML: tĩnh (`content` + `variables`) hoặc theo html definition của portal (`definition` + `query`). */
163
+ interface SdFormGenericHtml extends Omit<SdFormGenericFieldBase<'html', never>, 'key' | 'defaultValue' | 'validation'> {
164
+ key?: string;
165
+ definition?: string;
166
+ content?: string;
167
+ variables?: Record<string, string>;
168
+ query?: SdFormGenericParam[];
128
169
  }
129
- declare const SD_ATTRIBUTE_OPERATORS: Record<Attribute['type'], {
130
- value: SdFormGenericOperator;
131
- symbol?: string;
132
- display: string;
133
- }[]>;
134
- declare const sdGetAttributes: (components: (SdFormGenericComponent | SdFormGenericGroup)[]) => Attribute[];
135
- declare const sdTemplateToCondition: (template: string | undefined | null, entity: Record<string, any>) => string | undefined;
136
- declare const sdEvaluateExpression: (condition: SdFormGenericExpression | SdFormGenericExpressionCondition, entity: Record<string, any>) => boolean | undefined;
137
- declare const sdExpressionToJavascriptExpression: (condition: SdFormGenericExpression | SdFormGenericExpressionCondition) => string | undefined;
170
+ type SdFormGenericField = SdFormGenericTextfield | SdFormGenericTextarea | SdFormGenericNumber | SdFormGenericSelect | SdFormGenericRadio | SdFormGenericCheckbox | SdFormGenericDatetime | SdFormGenericChipString | SdFormGenericChipCalendar | SdFormGenericUpload | SdFormGenericHtml;
171
+ type SdFormGenericFieldType = SdFormGenericField['type'];
138
172
 
139
- type SdFormGenericValidation = ValidationExpression | ValidationFunction;
140
- interface ValidationBase {
141
- alert: 'warning' | 'error';
173
+ /** Mục trả về từ catalog; `data` là dữ liệu thêm để `fill` đọc (`item.data[from]`). */
174
+ interface SdFormGenericCatalogItem<TData extends Record<string, unknown> = Record<string, unknown>> extends SdFormGenericOption {
175
+ data?: TData;
176
+ }
177
+ /** Ngữ cảnh truyền cho callback của portal. Chỉ đọc. */
178
+ interface SdFormGenericCatalogContext {
179
+ field: SdFormGenericField;
180
+ value: Readonly<Record<string, unknown>>;
181
+ variables: Readonly<Record<string, unknown>>;
182
+ }
183
+ /** Nguồn dữ liệu lựa chọn do portal đăng ký. Component không tự gọi HTTP. */
184
+ interface SdFormGenericCatalog {
185
+ id: string;
186
+ label: string;
187
+ /** Tham số catalog nhận; builder dùng để dựng editor `options.params`. */
188
+ params?: {
189
+ name: string;
190
+ label: string;
191
+ required?: boolean;
192
+ }[];
193
+ /** Thuộc tính trong `item.data` mà `options.fill` có thể đọc. */
194
+ fields?: {
195
+ name: string;
196
+ label: string;
197
+ }[];
198
+ load: (params: Record<string, unknown>, context: SdFormGenericCatalogContext) => Promise<SdFormGenericCatalogItem[]>;
199
+ /** Có thì select tìm theo từ khoá thay vì tải toàn bộ. */
200
+ search?: (term: string, params: Record<string, unknown>, context: SdFormGenericCatalogContext) => Promise<SdFormGenericCatalogItem[]>;
201
+ /** Có thì dùng để lấy nhãn của giá trị đã chọn ở chế độ chỉ xem / viewEntities thay vì `load`. */
202
+ labels?: (values: string[], params: Record<string, unknown>) => Promise<SdFormGenericOption[]>;
142
203
  }
143
- declare const ValidationAlerts: {
144
- value: string;
145
- display: string;
146
- }[];
147
- interface ValidationExpression extends ValidationBase {
148
- type: 'expression';
149
- expression: SdFormGenericExpression;
150
- message: string;
204
+ /** Mẫu field chọn nhanh trong builder. */
205
+ interface SdFormGenericTemplate {
206
+ id: string;
207
+ label: string;
208
+ field: Exclude<SdFormGenericField, SdFormGenericHtml>;
151
209
  }
152
- interface ValidationFunction extends ValidationBase {
153
- type: 'function';
154
- code: string;
210
+ interface SdFormGenericHtmlDefinitionBase {
211
+ id: string;
212
+ label: string;
213
+ /** Biến thay vào `${key}` của nội dung (nhập ở builder). */
214
+ variables?: {
215
+ key: string;
216
+ label: string;
217
+ value?: string;
218
+ }[];
155
219
  }
156
- interface ValidateArgs {
157
- entity: Record<string, any>;
220
+ interface SdFormGenericHtmlStaticDefinition extends SdFormGenericHtmlDefinitionBase {
221
+ type: 'static';
222
+ content: string;
158
223
  }
159
- interface SdFormGenericValidationFunction {
160
- value: string;
161
- display: string;
162
- validate: (args: ValidateArgs) => Promise<string | undefined | null>;
224
+ interface SdFormGenericHtmlQueryDefinition extends SdFormGenericHtmlDefinitionBase {
225
+ type: 'query';
226
+ /** Tham số mà `content` nhận; field html gán giá trị qua `query`. */
227
+ params: {
228
+ name: string;
229
+ label: string;
230
+ }[];
231
+ content: (params: Record<string, unknown>) => Promise<string>;
163
232
  }
164
- interface SdFormGenericValidationConfiguration {
165
- functions?: SdFormGenericValidationFunction[];
233
+ type SdFormGenericHtmlDefinition = SdFormGenericHtmlStaticDefinition | SdFormGenericHtmlQueryDefinition;
234
+ /** Validator hàm dùng cho validation cấp form `{ type: 'function', validator: id }`. */
235
+ interface SdFormGenericValidator {
236
+ id: string;
237
+ label: string;
238
+ /** Trả message (có thể là HTML) khi lỗi; `null`/`undefined`/`''` khi hợp lệ. */
239
+ validate: (value: Readonly<Record<string, unknown>>) => Promise<string | null | undefined> | string | null | undefined;
240
+ }
241
+ type SdFormGenericMaybeAsyncList<T> = T[] | (() => T[] | Promise<T[]>);
242
+ /** Cấu hình của portal cho `provideSdFormGeneric`. */
243
+ interface SdFormGenericConfig {
244
+ catalogs?: SdFormGenericCatalog[];
245
+ templates?: SdFormGenericTemplate[];
246
+ htmlDefinitions?: SdFormGenericMaybeAsyncList<SdFormGenericHtmlDefinition>;
247
+ validators?: SdFormGenericValidator[];
248
+ /** Ghi đè từng phần `SD_FORM_GENERIC_BREAKPOINTS` (px, bề rộng form). */
249
+ breakpoints?: {
250
+ tablet?: number;
251
+ desktop?: number;
252
+ };
166
253
  }
167
254
 
168
- interface SdFormGeneric {
169
- components: (SdFormGenericComponent | SdFormGenericGroup)[];
170
- variables?: SdFormGenericVariable[];
171
- validations?: SdFormGenericValidation[];
172
- }
255
+ /**
256
+ * Cấu hình portal cho form generic: catalog lựa chọn, mẫu field, html definition, validator hàm và
257
+ * ngưỡng breakpoint. Dữ liệu của portal chỉ vào form qua các callback này — component không gọi HTTP.
258
+ *
259
+ * Gọi ở `bootstrapApplication` hoặc ở `providers` của một route: builder, renderer và
260
+ * `SdFormRenderService` bên dưới route đó đều đọc đúng cấu hình của route.
261
+ *
262
+ * @example
263
+ * bootstrapApplication(App, {
264
+ * providers: [provideSdFormGeneric({ catalogs: [districts], breakpoints: { tablet: 700 } })],
265
+ * });
266
+ */
267
+ declare function provideSdFormGeneric(config?: SdFormGenericConfig): EnvironmentProviders;
173
268
 
174
- interface SdFormRenderConfiguration {
175
- onLoaded?: () => void;
176
- components: SdFormGeneric['components'];
177
- validations?: SdFormGeneric['validations'];
269
+ /**
270
+ * Schema form generic — phiên bản đầu tiên, JSON do consumer lưu trữ.
271
+ *
272
+ * Ngữ pháp cố định: Form → pages → (group | element); group chỉ chứa element, không lồng group.
273
+ * Form một trang vẫn lưu `pages: [ … ]` với một phần tử.
274
+ */
275
+ interface SdFormGenericSchema {
276
+ pages: SdFormGenericPage[];
277
+ /** Chừa cho tabs/steps (đợt 3). Vắng = một trang. */
278
+ navigation?: SdFormGenericNavigation;
279
+ /** Biến do consumer cấp qua `[variables]`; dùng chung không gian key với field. */
178
280
  variables?: SdFormGenericVariable[];
179
- beforeSubmit?: (entity: Record<string, any>) => Promise<Record<string, any>>;
180
- }
181
- interface SdFormGenericLayout {
182
- row?: string;
183
- columns: '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
184
- mobileColumns?: '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
281
+ /** Validation cấp form, chạy trong `validate()`. */
282
+ validations?: SdFormGenericValidation[];
185
283
  }
186
- declare const sdGenerateId: () => string;
187
- declare const sdGenerateKey: () => string;
188
- declare const sdFormatComponent: (component: SdFormGenericComponent | SdFormGenericGroup) => void;
189
- interface SdFormGenericVariable {
190
- id: string;
191
- key: string;
192
- label: string;
284
+ type SdFormGenericNavigation = {
285
+ type: 'tabs';
286
+ } | {
287
+ type: 'steps';
288
+ linear?: boolean;
289
+ };
290
+ /** Điều kiện ẩn/hiện của trang hoặc group. */
291
+ interface SdFormGenericVisibilityRules {
292
+ visible?: Filter;
293
+ hidden?: Filter;
193
294
  }
194
- type SdFormGenericComponent = SdFormGenericTextfield | SdFormGenericChipString | SdFormGenericChipCalendar | SdFormGenericTextarea | SdFormGenericNumber | SdFormGenericCheckbox | SdFormGenericDatetime | SdFormGenericValues | SdFormGenericUpload | SdFormGenericTable | SdFormGenericHtml | SdFormGenericBreak;
195
- type SdFormGenericValues = SdFormGenericRadio | SdFormGenericSelect | SdFormGenericChecklist;
196
- interface SdFormGenericComponentBase {
197
- template?: string;
295
+ interface SdFormGenericPage {
198
296
  id: string;
199
- key: string;
200
- label: string;
201
- helperText?: string;
202
- layout?: SdFormGenericLayout;
203
- validate?: {
204
- required?: boolean;
205
- };
206
- disabled?: boolean;
207
- properties?: {
208
- viewed?: boolean;
209
- hyperlink?: string;
210
- hidden?: boolean;
211
- hiddenWhenExpression?: SdFormGenericExpression;
212
- visibleWhenExpression?: SdFormGenericExpression;
213
- disabledWhenExpression?: SdFormGenericExpression;
214
- requiredWhenExpression?: SdFormGenericExpression;
215
- onChange?: {
216
- setValues?: Record<string, any>;
217
- };
218
- } & Record<string, any>;
219
- }
220
- interface SdFormGenericTextfield extends SdFormGenericComponentBase {
221
- type: 'textfield';
222
- defaultValue?: string;
223
- validate?: {
224
- maxlength?: number;
225
- minlength?: number;
226
- pattern?: ValidationPatternType | string;
227
- patternErrorMessage?: string;
228
- } & SdFormGenericComponentBase['validate'];
229
- }
230
- interface SdFormGenericChipString extends SdFormGenericComponentBase {
231
- type: 'chip-string';
232
- defaultValue?: string[];
233
- validate?: {
234
- maxlength?: number;
235
- minlength?: number;
236
- pattern?: ValidationPatternType | string;
237
- patternErrorMessage?: string;
238
- maxOfItems?: number;
239
- } & SdFormGenericComponentBase['validate'];
240
- }
241
- interface SdFormGenericChipCalendar extends SdFormGenericComponentBase {
242
- type: 'chip-calendar';
243
- defaultValue?: string[];
244
- validate?: {
245
- maxlength?: number;
246
- minlength?: number;
247
- pattern?: ValidationPatternType | string;
248
- patternErrorMessage?: string;
249
- maxOfItems?: number;
250
- } & SdFormGenericComponentBase['validate'];
251
- }
252
- interface SdFormGenericTextarea extends SdFormGenericComponentBase {
253
- type: 'textarea';
254
- defaultValue?: string;
255
- validate?: {
256
- maxlength?: number;
257
- minlength?: number;
258
- } & SdFormGenericComponentBase['validate'];
259
- }
260
- interface SdFormGenericNumber extends SdFormGenericComponentBase {
261
- type: 'number';
262
- defaultValue?: number;
263
- validate?: {
264
- min?: number;
265
- max?: number;
266
- } & SdFormGenericComponentBase['validate'];
267
- }
268
- interface SdFormGenericCheckbox extends SdFormGenericComponentBase {
269
- type: 'checkbox';
270
- defaultValue?: boolean;
271
- }
272
- interface SdFormGenericDatetime extends SdFormGenericComponentBase {
273
- type: 'datetime';
274
- subtype: 'date' | 'datetime';
275
- defaultValue?: string;
276
- validate?: {
277
- min?: 'TODAY' | string;
278
- max?: 'TODAY' | string;
279
- } & SdFormGenericComponentBase['validate'];
280
- }
281
- interface SdFormGenericRadio extends SdFormGenericComponentBase {
282
- type: 'radio';
283
- values?: SdFormGenericSelectionStaticItem[];
284
- valuesKey?: string;
285
- defaultValue?: string;
286
- properties?: {
287
- direction?: 'row' | 'column';
288
- } & SdFormGenericComponentBase['properties'];
289
- }
290
- interface SdFormGenericSelect extends SdFormGenericComponentBase {
291
- type: 'select';
292
- values?: SdFormGenericSelectionStaticItem[];
293
- valuesKey?: string;
294
- defaultValue?: string | string[];
295
- properties?: {
296
- query?: Record<string, any>;
297
- multiple?: boolean;
298
- setVariables?: Record<string, string>;
299
- } & SdFormGenericComponentBase['properties'];
300
- }
301
- interface SdFormGenericChecklist extends SdFormGenericComponentBase {
302
- type: 'checklist';
303
- values?: SdFormGenericSelectionStaticItem[];
304
- valuesKey?: string;
305
- defaultValue?: string[];
306
- properties?: {
307
- query?: Record<string, any>;
308
- } & SdFormGenericComponentBase['properties'];
297
+ label?: string;
298
+ icon?: string;
299
+ rules?: SdFormGenericVisibilityRules;
300
+ elements: SdFormGenericPageElement[];
309
301
  }
302
+ type SdFormGenericPageElement = SdFormGenericGroup | SdFormGenericElement;
303
+ /** Group luôn chiếm trọn một hàng và chỉ chứa element (không lồng group). */
310
304
  interface SdFormGenericGroup {
311
305
  id: string;
312
306
  type: 'group';
313
307
  label: string;
314
- layout: SdFormGenericLayout;
315
- components: SdFormGenericComponent[];
316
- properties: {
317
- icon: string;
318
- color: Color;
319
- collapsible?: boolean;
320
- hidden?: boolean;
321
- hiddenWhenExpression?: SdFormGenericExpression;
322
- visibleWhenExpression?: SdFormGenericExpression;
323
- };
308
+ icon?: string;
309
+ color?: Color;
310
+ collapsible?: boolean;
311
+ hidden?: boolean;
312
+ rules?: SdFormGenericVisibilityRules;
313
+ elements: SdFormGenericElement[];
324
314
  }
325
- interface SdFormGenericUpload extends SdFormGenericComponentBase {
326
- type: 'upload';
327
- properties?: {
328
- type?: SdUnwrapSignal<SdUploadFile['type']>;
329
- maxSize?: SdUnwrapSignal<SdUploadFile['maxSize']>;
330
- max?: SdUnwrapSignal<SdUploadFile['max']>;
331
- extensions?: SdUnwrapSignal<SdUploadFile['extensions']>;
332
- args?: Record<string, any>;
333
- source?: 'ALL' | 'PHOTO_LIBRARY' | 'CAPTURE';
334
- } & SdFormGenericComponentBase['properties'];
335
- }
336
- interface FormRenderComponentTableColumnValues {
337
- valuesKey: string;
338
- query?: Record<string, any>;
339
- }
340
- type SdFormGenericTableColumn<T = any> = TableColumnString<T> | TableColumnNumber<T> | TableColumnBool<T> | TableColumnDate<T> | TableColumnDatetime<T> | TableColumnRadio<T> | TableColumnValues<T> | TableColumnImage<T> | TableColumnFile<T>;
341
- declare const SD_TABLE_COLUMN_TYPES: {
342
- value: string;
343
- display: string;
344
- }[];
345
- interface TableColumnBase<T = any> {
346
- key: Extract<keyof T, string>;
315
+ /**
316
+ * Phần tử đặt trên lưới. Các đợt sau THÊM thành viên vào union (static, button, table) mà không đổi
317
+ * shape thành viên cũ; renderer bỏ qua type chưa biết, builder giữ nguyên khi phát lại.
318
+ */
319
+ type SdFormGenericElement = SdFormGenericField;
320
+ interface SdFormGenericVariable {
321
+ key: string;
347
322
  label: string;
348
- width?: SdTableColumn['width'];
349
- validate?: {
350
- required?: boolean;
351
- };
352
323
  }
353
- interface TableColumnString<T = any> extends TableColumnBase<T> {
354
- type: 'string';
355
- validate?: {
356
- minlength?: number;
357
- maxlength?: number;
358
- pattern?: string;
359
- patternErrorMessage?: string;
360
- } & TableColumnBase['validate'];
361
- }
362
- interface TableColumnNumber<T = any> extends TableColumnBase<T> {
363
- type: 'number';
364
- validate?: {
365
- min?: number;
366
- max?: number;
367
- } & TableColumnBase['validate'];
368
- }
369
- interface TableColumnDate<T = any> extends TableColumnBase<T> {
370
- type: 'date';
371
- validate?: {
372
- min?: 'TODAY' | string;
373
- max?: 'TODAY' | string;
374
- } & TableColumnBase['validate'];
375
- }
376
- interface TableColumnDatetime<T = any> extends TableColumnBase<T> {
377
- type: 'datetime';
378
- validate?: {
379
- min?: 'TODAY' | string;
380
- max?: 'TODAY' | string;
381
- } & TableColumnBase['validate'];
382
- }
383
- interface TableColumnBool<T = any> extends TableColumnBase<T> {
384
- type: 'boolean';
385
- displayOnTrue?: string;
386
- displayOnFalse?: string;
387
- }
388
- interface TableColumnRadio<T = any> extends TableColumnBase<T> {
389
- type: 'radio';
390
- values?: SdFormGenericSelectionStaticItem[];
391
- }
392
- interface TableColumnValues<T = any> extends TableColumnBase<T> {
393
- type: 'values';
394
- valuesKey: string;
395
- query?: Record<string, any>;
396
- values?: SdFormGenericSelectionStaticItem[];
397
- }
398
- interface TableColumnImage<T = any> extends TableColumnBase<T> {
399
- type: 'image';
400
- args?: Record<string, any>;
401
- validate?: {
402
- max?: number;
403
- maxSize?: number;
404
- } & TableColumnBase['validate'];
405
- }
406
- interface TableColumnFile<T = any> extends TableColumnBase<T> {
407
- type: 'file';
408
- args?: Record<string, any>;
409
- validate?: {
410
- max?: number;
411
- maxSize?: number;
412
- } & TableColumnBase['validate'];
413
- }
414
- interface SdFormGenericTable extends SdFormGenericComponentBase {
415
- type: 'table';
416
- columnsKey?: string;
417
- columns?: SdFormGenericTableColumn[];
418
- properties?: {
419
- type?: SdTableOption['type'];
420
- titleButtonCreate?: string;
421
- } & SdFormGenericComponentBase['properties'];
324
+ type SdFormGenericAlert = 'error' | 'warning';
325
+ interface SdFormGenericFilterValidation {
326
+ type: 'filter';
327
+ /** Filter đúng thì hiện `message`. */
328
+ filter: Filter;
329
+ message: string;
330
+ alert: SdFormGenericAlert;
422
331
  }
332
+ interface SdFormGenericFunctionValidation {
333
+ type: 'function';
334
+ /** Id của validator đăng ký trong `provideSdFormGeneric({ validators })`. */
335
+ validator: string;
336
+ alert: SdFormGenericAlert;
337
+ }
338
+ type SdFormGenericValidation = SdFormGenericFilterValidation | SdFormGenericFunctionValidation;
339
+
340
+ interface SdFormGenericElementState {
341
+ visible: boolean;
342
+ disabled: boolean;
343
+ required: boolean;
344
+ }
345
+
346
+ interface SdFormGenericValidationMessages {
347
+ error: string[];
348
+ warning: string[];
349
+ }
350
+ /** Kết quả `validate()`: luôn có hai danh sách; chỉ lỗi `error` làm `valid = false`. */
351
+ interface SdFormGenericValidationResult {
352
+ valid: boolean;
353
+ messages: SdFormGenericValidationMessages;
354
+ }
355
+
356
+ /** Một phần tử trên canvas: field, group, hoặc phần tử type chưa hỗ trợ (giữ nguyên khi phát lại). */
357
+ type BuilderItem = SdFormGenericPageElement;
358
+ /** Vùng chứa phần tử: `null` = trang, ngược lại là `id` của group. */
359
+ type ContainerId = string | null;
423
360
  /**
424
- * Break component — invisible runtime element ép xuống dòng mới. Dùng khi layout có
425
- * vùng cố định và việc ẩn/hiện trường khác không nên xáo trộn vị trí các trường còn lại.
426
- * Ở canvas (design) render thanh ngang mảnh; ở runtime render empty 12-col cell.
361
+ * Nguồn schema chuẩn DUY NHẤT của builder. Được thay thế bất biến bởi các command — không component
362
+ * nào sửa object bên trong. Selection, viewport, kéo-thả… là editor state, không nằm ở đây.
427
363
  *
428
- * Extend SdFormGenericComponentBase để tương thích với union narrowing trong các pipe/render
429
- * (key, validate, disabled, properties full) — runtime sẽ ignore mọi field ngoài id/type/layout.
364
+ * `elements` là phần tử của trang đang thiết kế (đợt 1: trang đầu). `base` giữ phần còn lại của
365
+ * schema (thông tin trang, các trang khác, navigation, khoá lạ) để phát lại nguyên vẹn.
430
366
  */
431
- interface SdFormGenericBreak extends SdFormGenericComponentBase {
432
- type: 'break';
433
- }
434
- interface SdFormGenericHtml {
435
- template?: string;
436
- id: string;
437
- key?: string;
438
- type: 'html';
439
- content: string;
440
- validate?: {
441
- required?: boolean;
442
- };
443
- layout?: SdFormGenericLayout;
444
- properties?: {
445
- viewed?: boolean;
446
- hyperlink?: string;
447
- hidden?: boolean;
448
- hiddenWhenExpression?: SdFormGenericExpression;
449
- visibleWhenExpression?: SdFormGenericExpression;
450
- variables?: {
451
- key: string;
452
- label: string;
453
- value?: string;
454
- }[];
455
- queries?: {
456
- key: string;
457
- label: string;
458
- }[];
459
- query?: Record<string, any>;
367
+ interface BuilderDocument {
368
+ readonly elements: readonly BuilderItem[];
369
+ readonly variables: readonly SdFormGenericVariable[];
370
+ readonly validations: readonly SdFormGenericValidation[];
371
+ readonly base: {
372
+ readonly page: Omit<SdFormGenericPage, 'elements'>;
373
+ readonly otherPages: readonly SdFormGenericPage[];
374
+ readonly rest: Readonly<Record<string, unknown>>;
460
375
  };
461
376
  }
462
- type FormBuilderComponentGroup = 'basic' | 'choice' | 'advanced' | 'layout';
463
- interface FormBuilderComponent {
464
- type: string;
465
- /** Material Icons Outlined icon name. Rendered via the builder icon alias. */
466
- symbol: string;
467
- /** Category group for the left palette grouping. */
468
- group: FormBuilderComponentGroup;
469
- name: string;
377
+ /** Vị trí của một phần tử trong tài liệu. */
378
+ interface ItemLocation {
379
+ readonly item: BuilderItem;
380
+ readonly parentId: ContainerId;
381
+ readonly index: number;
470
382
  }
471
- declare const SD_FORM_BUILDER_COMPONENTS: FormBuilderComponent[];
472
- /** Lookup: component type → Material icon + label, used by attribute panel header. */
473
- declare const SD_COMPONENT_ICONS: Record<string, {
474
- symbol: string;
475
- label: string;
476
- }>;
477
- declare const sdGetComponentAttributes: (components: (SdFormGenericComponent | SdFormGenericGroup)[]) => {
478
- value: string;
479
- display: string;
480
- }[];
481
- declare const sdGetVariableAttributes: (variables: SdFormGenericVariable[]) => {
482
- value: string;
483
- display: string;
484
- }[];
485
383
 
486
- interface SdFormGenericArgs {
487
- entity: Record<string, any>;
488
- component?: SdFormGenericComponent;
489
- column?: SdFormGenericTableColumn;
490
- query?: Record<string, any>;
384
+ /**
385
+ * Thuật toán bố cục của builder — THUẦN, không phụ thuộc DOM/Angular.
386
+ *
387
+ * Hàng lấy từ `sdPackRows` — cùng hàm renderer dùng — nên hàng trên canvas = hàng khi render ở cùng
388
+ * mức. Khi người dùng muốn "hàng mới" mà luật tự nhiên sẽ dồn phần tử lên hàng trước, `planDrop` bật
389
+ * `layout.newRow` của phần tử đó: hàng tạo trong editor vì thế round-trip qua schema.
390
+ *
391
+ * Indicator khi kéo và lệnh commit dùng CHUNG `planDrop` → thứ nhìn thấy là thứ được lưu.
392
+ */
393
+ /** Mức bố cục đang thiết kế (Desktop | Tablet | Mobile). */
394
+ type LayoutMode = SdFormGenericBreakpoint;
395
+ /** Độ rộng tạm thời khi đang kéo resize (chưa commit). */
396
+ interface SpanOverride {
397
+ readonly id: string;
398
+ readonly span: number;
399
+ readonly mode: LayoutMode;
400
+ }
401
+ /** Một hàng logic của canvas. */
402
+ interface LayoutRow {
403
+ /** Khoá ổn định: id phần tử đầu tiên của hàng. */
404
+ readonly key: string;
405
+ readonly kind: 'fields' | 'group';
406
+ readonly items: readonly BuilderItem[];
407
+ /** Tổng số cột đã dùng. */
408
+ readonly used: number;
491
409
  }
492
-
493
- interface SdFormGenericTemplate {
494
- value: string;
495
- display: string;
496
- component: Exclude<SdFormGenericComponent, SdFormGenericHtml>;
410
+ /**
411
+ * Ý định thả, gắn vào id ỔN ĐỊNH của tài liệu hiện tại (không phải toạ độ):
412
+ * - `row`: thành một hàng mới đứng trước hàng `beforeRowKey` (`null` = cuối vùng chứa).
413
+ * - `inline`: vào hàng `rowKey`, đứng trước `beforeItemId` (`null` = cuối hàng).
414
+ */
415
+ type DropIntent = {
416
+ readonly kind: 'row';
417
+ readonly parentId: ContainerId;
418
+ readonly beforeRowKey: string | null;
419
+ } | {
420
+ readonly kind: 'inline';
421
+ readonly parentId: ContainerId;
422
+ readonly rowKey: string;
423
+ readonly beforeItemId: string | null;
424
+ };
425
+ /** Thứ đang được thả: phần tử mới (từ palette) hoặc phần tử có sẵn (theo id). */
426
+ type DragSubject = {
427
+ readonly kind: 'new';
428
+ readonly item: BuilderItem;
429
+ } | {
430
+ readonly kind: 'move';
431
+ readonly id: string;
432
+ };
433
+ type DropRejectReason = 'not-found' | 'nested-group' | 'row-full' | 'invalid';
434
+ interface DropPlan {
435
+ readonly doc: BuilderDocument;
436
+ /** id của phần tử được thả (mới hoặc di chuyển). */
437
+ readonly itemId: string;
438
+ /** `false` khi thả đúng chỗ cũ — không tạo bước history. */
439
+ readonly changed: boolean;
440
+ /** Số `newRow` được bật để giữ đúng hàng mà người dùng chỉ định. */
441
+ readonly insertedRowStarts: number;
442
+ }
443
+ type DropResult = {
444
+ readonly ok: true;
445
+ readonly plan: DropPlan;
446
+ } | {
447
+ readonly ok: false;
448
+ readonly reason: DropRejectReason;
449
+ };
450
+ interface GeoRect {
451
+ readonly left: number;
452
+ readonly top: number;
453
+ readonly right: number;
454
+ readonly bottom: number;
497
455
  }
498
-
499
- interface SdFormGenericDefinitionTable<T = any> {
500
- value: string;
501
- display: string;
502
- columns: () => SdFormGenericTableColumn<T>[];
456
+ interface GeoItem extends GeoRect {
457
+ readonly id: string;
503
458
  }
504
-
505
- type SdFormGenericDefinitionHtml = SdFormGenericDefinitionHtmlStatic | SdFormGenericDefinitionHtmlQuery;
506
- interface SdFormGenericDefinitionHtmlStatic {
507
- type: 'static';
508
- value: string;
509
- display: string;
510
- content: string;
511
- variables?: {
512
- key: string;
513
- label: string;
514
- value?: string;
515
- }[];
459
+ interface GeoRow extends GeoRect {
460
+ readonly key: string;
461
+ readonly items: readonly GeoItem[];
516
462
  }
517
- interface SdFormGenericDefinitionHtmlQuery {
518
- type: 'query';
519
- value: string;
520
- display: string;
521
- queries: {
522
- key: string;
523
- label: string;
524
- }[];
525
- content: (query?: Record<string, any>) => Promise<string>;
526
- variables?: {
527
- key: string;
528
- label: string;
529
- value?: string;
530
- }[];
463
+ interface GeoContainer extends GeoRect {
464
+ readonly parentId: ContainerId;
465
+ readonly rows: readonly GeoRow[];
466
+ }
467
+ interface CanvasGeometry {
468
+ /** Vùng gốc (cả trang canvas). */
469
+ readonly root: GeoContainer;
470
+ /** Thân các group (vùng nhận thả bên trong group). */
471
+ readonly groups: readonly GeoContainer[];
531
472
  }
532
473
 
533
- interface IWorkflowConfigurationForm<TSelectionArgs = unknown> {
534
- templates: SdFormGenericTemplate[];
535
- selections: SdFormGenericDefinitionSelection<any, TSelectionArgs>[] | (() => SdFormGenericDefinitionSelection<any, TSelectionArgs>[]) | (() => Promise<SdFormGenericDefinitionSelection[]>);
536
- getValues?: (key: string, selectionArgs?: TSelectionArgs) => Promise<SdFormGenericSelectionItem[]>;
537
- getLazyValues?: (key: string, selectionArgs?: TSelectionArgs) => (searchArgs: Parameters<SdSearch>[0], args: SdFormGenericArgs) => Promise<SdFormGenericSelectionItem[]>;
538
- tables: SdFormGenericDefinitionTable[];
539
- htmls: SdFormGenericDefinitionHtml[] | (() => SdFormGenericDefinitionHtml[]) | (() => Promise<SdFormGenericDefinitionHtml[]>);
540
- validation?: SdFormGenericValidationConfiguration;
474
+ type SdFormGenericReferenceWhere = 'rule' | 'group-rule' | 'page-rule' | 'options-param' | 'options-fill' | 'upload-param' | 'html-query' | 'validation' | 'hyperlink' | 'html-content';
475
+ interface SdFormGenericKeyReference {
476
+ /** Id của phần tử chứa tham chiếu; `null` với validation cấp form. */
477
+ elementId: string | null;
478
+ where: SdFormGenericReferenceWhere;
479
+ kind: 'structured' | 'text';
541
480
  }
542
481
 
543
- interface ISdFormGenericConfiguration {
544
- form?: IWorkflowConfigurationForm;
482
+ /** Một dòng của dialog Biến: biến gốc (nếu đã có) và key/nhãn mới. */
483
+ interface VariableEdit {
484
+ readonly source?: SdFormGenericVariable;
485
+ readonly key: string;
486
+ readonly label: string;
545
487
  }
546
- declare const SD_FORM_GENERIC_CONFIGURATION: InjectionToken<ISdFormGenericConfiguration>;
547
488
 
548
- declare class UploadComponent implements OnDestroy, OnInit {
549
- #private;
550
- private readonly ref;
551
- readonly setVariables: _angular_core.InputSignal<Subject<{
552
- key: string;
553
- value: any;
554
- }>>;
555
- sdUploadFile?: SdUploadFile;
556
- readonly form: _angular_core.InputSignal<FormGroup<{}>>;
557
- value: any;
558
- entity: Record<string, any>;
559
- set _entity(val: Record<string, any>);
560
- component?: SdFormGenericUpload;
561
- set _component(val: SdFormGenericUpload);
562
- disabled: boolean;
563
- set _disabled(val: boolean | '' | undefined | null);
564
- required: boolean;
565
- set _required(val: boolean | '' | undefined | null);
566
- viewed: boolean;
567
- set _viewed(val: boolean | '' | undefined | null);
568
- validator?: SdCustomValidator;
569
- set _validator(validator: SdCustomValidator | undefined | null);
570
- /** Inserted by Angular inject() migration for backwards compatibility */
571
- constructor(...args: unknown[]);
572
- ngOnDestroy(): void;
573
- ngOnInit(): void;
574
- upload: () => Promise<void | undefined>;
575
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<UploadComponent, never>;
576
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<UploadComponent, "lib-upload", never, { "setVariables": { "alias": "setVariables"; "required": true; "isSignal": true; }; "form": { "alias": "form"; "required": false; "isSignal": true; }; "_entity": { "alias": "entity"; "required": true; }; "_component": { "alias": "component"; "required": true; }; "_disabled": { "alias": "disabled"; "required": false; }; "_required": { "alias": "required"; "required": false; }; "_viewed": { "alias": "viewed"; "required": false; }; "_validator": { "alias": "validator"; "required": false; }; }, {}, never, never, true, never>;
489
+ /** Nhóm của palette. */
490
+ type PaletteCategory = 'basic' | 'number' | 'choice' | 'datetime' | 'advanced' | 'layout';
491
+ /** Dịch key i18n (truyền từ component để palette không phụ thuộc DI). */
492
+ type PaletteTranslate = (key: string, params?: Record<string, string | number>) => string;
493
+ interface PaletteCreateContext {
494
+ /** Key đang dùng trong form — key mới không được trùng. */
495
+ readonly takenKeys: ReadonlySet<string>;
496
+ readonly t: PaletteTranslate;
497
+ }
498
+ /**
499
+ * Một mục palette. `id` riêng theo PRESET — nhiều preset cùng map vào `textfield`/`number`, nên
500
+ * palette không bao giờ định danh mục chỉ bằng `type`.
501
+ */
502
+ interface PaletteItem {
503
+ readonly id: string;
504
+ readonly category: PaletteCategory;
505
+ /** Tên icon Material Icons Outlined. */
506
+ readonly icon: string;
507
+ /** Key i18n của tên hiển thị. */
508
+ readonly labelKey: string;
509
+ /** Từ khoá tìm kiếm phụ (không dịch — type/preset kỹ thuật). */
510
+ readonly keywords: readonly string[];
511
+ /** `type` schema tạo ra — để hiển thị, KHÔNG phải định danh. */
512
+ readonly type: BuilderItem['type'];
513
+ readonly create: (context: PaletteCreateContext) => BuilderItem;
577
514
  }
578
515
 
579
- declare class TableComponent implements AfterViewInit, OnDestroy, OnInit {
516
+ type BuilderMode = 'design' | 'preview' | 'schema';
517
+ type BuilderViewport = LayoutMode;
518
+ type InspectorTab = 'general' | 'data' | 'rules' | 'layout';
519
+ type LeftTab = 'components' | 'structure';
520
+ /** Trạng thái kéo-thả tạm thời — KHÔNG phải schema, không vào history. */
521
+ interface BuilderDragState {
522
+ readonly subject: DragSubject;
523
+ readonly label: string;
524
+ readonly icon: string;
525
+ /** Ý định đã được `planDrop` xác nhận hợp lệ; `null` = thả lúc này sẽ huỷ. */
526
+ readonly intent: DropIntent | null;
527
+ readonly hint?: 'row-full' | 'nested-group' | 'outside';
528
+ }
529
+ interface CommitOptions {
530
+ /** Gộp các lần sửa liên tiếp (vd gõ nhãn) thành một bước undo. */
531
+ readonly coalesceKey?: string;
532
+ /** Câu thông báo cho screen reader (aria-live). */
533
+ readonly announce?: string;
534
+ }
535
+ /**
536
+ * State của MỘT `<sd-form-builder>` (provide ở component → mỗi builder một instance độc lập).
537
+ *
538
+ * Tách bạch: `doc` là schema chuẩn duy nhất; selection/mode/viewport/kéo-thả/resize là editor state.
539
+ * Mọi thay đổi schema đi qua `commit` (một bước history) — không nơi nào mutate `doc`.
540
+ */
541
+ declare class FormBuilderStore {
580
542
  #private;
581
- private ref;
582
- private readonly formGenericService;
583
- uploadFiles?: QueryList<SdUploadFile>;
584
- table?: SdTable;
585
- sideDrawer?: SdSideDrawer;
586
- readonly setVariables: _angular_core.InputSignal<Subject<{
587
- key: string;
588
- value: any;
589
- }>>;
590
- readonly form: _angular_core.InputSignal<FormGroup<{}>>;
591
- component?: SdFormGenericTable;
592
- col: string;
593
- set _component(val: SdFormGenericTable);
594
- required: boolean;
595
- set _required(val: boolean | '');
596
- viewed: boolean;
597
- set _viewed(val: boolean | '' | undefined | null);
598
- model: any[];
599
- set _model(val: any[] | undefined | null);
600
- readonly modelChange: _angular_core.OutputEmitterRef<any[]>;
601
- tableOption?: SdTableOption;
602
- row: any;
603
- columnValues: Record<string, SdFormGenericSelectionItem[] | SdSearch$1<SdFormGenericSelectionItem>>;
604
- formRenderColumn: Record<string, SdFormGenericTableColumn>;
605
- fileKeys: string[];
606
- imageKeys: string[];
607
- /** Inserted by Angular inject() migration for backwards compatibility */
608
- constructor(...args: unknown[]);
609
- ngOnInit(): void;
610
- ngAfterViewInit(): void;
611
- ngOnDestroy(): void;
543
+ readonly doc: _angular_core.WritableSignal<BuilderDocument>;
544
+ readonly selectedId: _angular_core.WritableSignal<string | null>;
545
+ readonly mode: _angular_core.WritableSignal<BuilderMode>;
546
+ readonly viewport: _angular_core.WritableSignal<_sdcorejs_angular_components_form_generic.SdFormGenericBreakpoint>;
547
+ readonly leftTab: _angular_core.WritableSignal<LeftTab>;
548
+ readonly inspectorTab: _angular_core.WritableSignal<InspectorTab>;
549
+ /** Group đang thu gọn TRÊN CANVAS (chỉ trình bày lúc thiết kế, không lưu vào schema). */
550
+ readonly collapsed: _angular_core.WritableSignal<ReadonlySet<string>>;
551
+ readonly drag: _angular_core.WritableSignal<BuilderDragState | null>;
552
+ readonly resize: _angular_core.WritableSignal<SpanOverride | null>;
553
+ /** Thông báo cho vùng aria-live. */
554
+ readonly announcement: _angular_core.WritableSignal<string>;
555
+ /** Yêu cầu đưa focus (mỗi yêu cầu là object mới) — shell nhận, rồi canvas focus sau khi render. */
556
+ readonly focusRequest: _angular_core.WritableSignal<{
557
+ readonly id: string | null;
558
+ } | null>;
559
+ /** Phát MỖI thay đổi schema do người dùng (commit/undo/redo) — KHÔNG phát khi nạp tài liệu. */
560
+ readonly changes: Subject<BuilderDocument>;
561
+ readonly canUndo: _angular_core.Signal<boolean>;
562
+ readonly canRedo: _angular_core.Signal<boolean>;
563
+ readonly index: _angular_core.Signal<Map<string, ItemLocation>>;
564
+ readonly selected: _angular_core.Signal<ItemLocation | null>;
565
+ readonly layoutMode: _angular_core.Signal<_sdcorejs_angular_components_form_generic.SdFormGenericBreakpoint>;
566
+ readonly groups: _angular_core.Signal<_sdcorejs_angular_components_form_generic.SdFormGenericGroup[]>;
567
+ /** Hàng của vùng gốc theo viewport + độ rộng resize tạm thời. */
568
+ readonly rootRows: _angular_core.Signal<LayoutRow[]>;
569
+ /** Hàng của từng group. */
570
+ readonly groupRows: _angular_core.Signal<Map<string, LayoutRow[]>>;
571
+ /** Hàng của một vùng chứa (theo state hiện tại). */
572
+ rowsOf: (parentId: ContainerId) => readonly LayoutRow[];
573
+ t: (key: string, params?: Record<string, string | number>) => string;
574
+ /** Nạp tài liệu mới (form khác từ ngoài): reset history, selection và state tạm. Không phát `changes`. */
575
+ load(doc: BuilderDocument): void;
576
+ /** Áp tài liệu mới do người dùng thao tác — một bước undo (hoặc gộp theo `coalesceKey`). */
577
+ commit(next: BuilderDocument, options?: CommitOptions): boolean;
578
+ undo(): boolean;
579
+ redo(): boolean;
580
+ /** Kết thúc phiên gộp history (rời ô nhập). */
581
+ sealHistory(): void;
582
+ /** Xin canvas đưa focus tới phần tử `id` sau lần render kế tiếp (`null` = vùng canvas). */
583
+ requestFocus(id: string | null): void;
584
+ announce(message: string): void;
585
+ select(id: string | null): void;
586
+ setMode(mode: BuilderMode): void;
587
+ toggleCollapsed(groupId: string, collapsed?: boolean): void;
588
+ /** Mở group chứa phần tử (khi chọn từ tab Cấu trúc). */
589
+ revealItem(id: string): void;
590
+ /** Thêm preset từ palette theo selection hiện tại (cùng semantics với kéo-thả). */
591
+ addFromPalette(entry: PaletteItem): string | null;
592
+ /** Tạo phần tử mới từ preset (chưa đưa vào tài liệu). */
593
+ createFromPalette(entry: PaletteItem): BuilderItem;
594
+ /** Thả theo ý định đã hiển thị. Kế hoạch được lập lại từ tài liệu HIỆN TẠI trước khi commit. */
595
+ drop(intent: DropIntent, subject: DragSubject, label?: string): DropResult;
596
+ remove(id: string): boolean;
597
+ /** Nhân bản (không với phần tử type chưa hỗ trợ, hoặc group chứa nó — xem `canDuplicate`). */
598
+ duplicate(id: string): string | null;
599
+ moveBy(id: string, delta: -1 | 1): boolean;
600
+ moveTo(id: string, parentId: ContainerId): boolean;
601
+ ungroup(groupId: string): boolean;
602
+ /** Bật/tắt "Bắt đầu hàng mới" (`layout.newRow`) của phần tử. */
603
+ setNewRow(id: string, newRow: boolean): boolean;
604
+ /** Span của mức `mode` (mặc định mức đang xem); `null` xoá về kế thừa. */
605
+ setSpan(id: string, span: number | null, mode?: LayoutMode): boolean;
606
+ /** Cập nhật thuộc tính một phần tử. `updater` trả object MỚI (giữ `id`). */
607
+ update(id: string, updater: (item: BuilderItem) => BuilderItem, coalesceKey?: string): boolean;
612
608
  /**
613
- * Tiêu đề của side-drawer phải nói đúng tác vụ đang làm — trước đây nó cứng là "Chi tiết" cho cả
614
- * thêm mới lẫn sửa, còn dòng "Tạo mới/cập nhật" thì rơi vào thân drawer vì gắn nhầm slot.
609
+ * Đổi key (đã kiểm tra hợp lệ) + cập nhật tham chiếu có cấu trúc. Trả số tham chiếu đã cập nhật,
610
+ * hoặc `-1` khi không đổi được (key đích đã có — không commit gì).
615
611
  */
616
- get detailTitle(): string;
617
- onDetail: (row?: any) => void;
618
- onCancel: () => void;
619
- onAccept: (addable?: boolean) => void;
620
- onFileUploadChange(item: any, key: string, newValue: any): void;
621
- getArgs(key: string): Record<string, any> | undefined;
622
- upload: () => Promise<void>;
623
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<TableComponent, never>;
624
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<TableComponent, "lib-table", never, { "setVariables": { "alias": "setVariables"; "required": true; "isSignal": true; }; "form": { "alias": "form"; "required": false; "isSignal": true; }; "_component": { "alias": "component"; "required": true; }; "_required": { "alias": "required"; "required": false; }; "_viewed": { "alias": "viewed"; "required": false; }; "_model": { "alias": "model"; "required": false; }; }, { "modelChange": "modelChange"; }, never, never, true, never>;
625
- }
626
-
627
- declare class LibItemComponent {
628
- itemUpload?: UploadComponent;
629
- itemTable?: TableComponent;
630
- readonly setVariables: _angular_core.InputSignal<Subject<{
631
- key: string;
632
- value: any;
633
- }>>;
634
- readonly form: _angular_core.InputSignal<FormGroup<{}>>;
635
- value: any;
636
- entity: Record<string, any>;
637
- set _entity(val: Record<string, any>);
638
- col: string;
639
- component?: SdFormGenericComponent;
640
- set _component(val: SdFormGenericComponent);
641
- disabled: boolean;
642
- set _disabled(val: boolean | '' | undefined);
643
- required: boolean;
644
- set _required(val: boolean | '' | undefined);
645
- viewed: boolean;
646
- set _viewed(val: boolean | '' | undefined);
647
- validator?: SdCustomValidator;
648
- set _validator(validator: SdCustomValidator);
649
- upload: () => Promise<void>;
650
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<LibItemComponent, never>;
651
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<LibItemComponent, "lib-item", never, { "setVariables": { "alias": "setVariables"; "required": true; "isSignal": true; }; "form": { "alias": "form"; "required": false; "isSignal": true; }; "_entity": { "alias": "entity"; "required": true; }; "_component": { "alias": "component"; "required": true; }; "_disabled": { "alias": "disabled"; "required": false; }; "_required": { "alias": "required"; "required": false; }; "_viewed": { "alias": "viewed"; "required": false; }; "_validator": { "alias": "validator"; "required": false; }; }, {}, never, never, true, never>;
612
+ renameKey(id: string, nextKey: string): number;
613
+ /**
614
+ * Áp mẫu của portal: `updater` đặt cấu hình của mẫu, `nextKey` (nếu có) đổi key kèm tham chiếu có
615
+ * cấu trúc — cả hai là MỘT bước undo. Trả `false` khi không đổi được (key đích đã có).
616
+ */
617
+ applyTemplate(id: string, updater: (item: BuilderItem) => BuilderItem, nextKey: string | null): boolean;
618
+ /** Lưu dialog Biến: đổi key biến kéo theo tham chiếu (một bước undo); không đổi gì thì không commit. */
619
+ saveVariables(edits: readonly VariableEdit[]): boolean;
620
+ /** Thay danh sách biến; cùng nội dung thì không tạo bước undo. */
621
+ setVariables(variables: SdFormGenericVariable[]): boolean;
622
+ /** Thay validation cấp form; cùng nội dung thì không tạo bước undo. */
623
+ setValidations(validations: SdFormGenericValidation[]): boolean;
624
+ /** Tham chiếu tới field (hoặc các field con của group) từ NƠI KHÁC — ảnh hưởng khi xoá. */
625
+ dependentsOf(id: string): SdFormGenericKeyReference[];
626
+ labelOf(item: BuilderItem): string;
627
+ /** Vùng chứa của phần tử (hoặc `undefined` nếu không có). */
628
+ parentOf(id: string): ContainerId | undefined;
629
+ childrenOf(parentId: ContainerId): readonly BuilderItem[];
630
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormBuilderStore, never>;
631
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<FormBuilderStore>;
652
632
  }
653
633
 
654
- declare class SdFormRender implements OnDestroy, AfterViewInit {
634
+ /**
635
+ * Canvas thiết kế: hàng (cùng thuật toán với renderer), group sửa trực tiếp, chọn/kéo/resize.
636
+ * Mọi thay đổi schema đi qua `FormBuilderStore`; trong lúc kéo/resize chỉ đổi state tạm.
637
+ */
638
+ declare class CanvasComponent {
655
639
  #private;
656
- formRenderItems: QueryList<LibItemComponent>;
657
- form: FormGroup;
658
- configuration: SdFormRenderConfiguration;
659
- set _configuration(val: SdFormRenderConfiguration);
660
- set _default(defaultEntity: Record<string, any>);
661
- entity: Record<string, any>;
662
- set _entity(val: Record<string, any>);
663
- properties: string[];
664
- set _properties(val: string[]);
665
- viewed: boolean;
666
- set _viewed(val: boolean | '');
667
- loadCompleted: boolean;
668
- hashedValues?: string;
669
- formValue: Record<string, any>;
670
- setVariables: Subject<{
671
- key: string;
672
- value: any;
673
- }>;
674
- private readonly ref;
675
- private readonly formGenericConfiguration;
676
- ngAfterViewInit(): void;
677
- ngOnDestroy(): void;
678
- upload: () => Promise<void>;
679
- getValidationMessages: (alert: SdFormGenericValidation["alert"]) => Promise<string[] | undefined>;
680
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdFormRender, never>;
681
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<SdFormRender, "sd-form-render", never, { "form": { "alias": "form"; "required": false; }; "_configuration": { "alias": "configuration"; "required": true; }; "_default": { "alias": "defaultEntity"; "required": false; }; "_entity": { "alias": "entity"; "required": false; }; "_properties": { "alias": "properties"; "required": false; }; "_viewed": { "alias": "viewed"; "required": false; }; }, {}, never, never, true, never>;
640
+ readonly store: FormBuilderStore;
641
+ /** Người dùng muốn thêm thành phần (bấm vùng "thêm" cuối canvas) — shell đưa focus sang palette. */
642
+ readonly requestAdd: _angular_core.OutputEmitterRef<void>;
643
+ /** Người dùng yêu cầu xoá (shell hỏi xác nhận khi có phụ thuộc). */
644
+ readonly requestRemove: _angular_core.OutputEmitterRef<string>;
645
+ readonly scroller: _angular_core.Signal<ElementRef<HTMLElement>>;
646
+ readonly page: _angular_core.Signal<ElementRef<HTMLElement>>;
647
+ readonly GRID_COLUMNS = 12;
648
+ readonly itemIcon: (item: BuilderItem) => string;
649
+ readonly itemTypeLabelKey: (item: BuilderItem) => string;
650
+ readonly isGroup: (item: BuilderItem | null | undefined) => item is SdFormGenericGroup;
651
+ readonly isUnknown: (item: BuilderItem | null | undefined) => boolean;
652
+ readonly canDuplicate: (item: BuilderItem | null | undefined) => boolean;
653
+ /**
654
+ * Đang kéo? — boolean chỉ đổi lúc bắt đầu/kết thúc kéo.
655
+ * why: canvas KHÔNG đọc `store.drag()` trực tiếp trong template (intent đổi liên tục khi kéo và
656
+ * sẽ refresh cả canvas); phản hồi theo intent nằm ở `fb-drop-indicator` / `fb-drop-status`.
657
+ */
658
+ readonly isDragging: _angular_core.Signal<boolean>;
659
+ /** id phần tử đang được kéo (mờ đi tại chỗ cũ). Chỉ đổi lúc bắt đầu/kết thúc kéo. */
660
+ readonly movingId: _angular_core.Signal<string | null>;
661
+ constructor();
662
+ spanOf: (item: BuilderItem) => number;
663
+ widthOf: (item: BuilderItem) => string;
664
+ isSelected: (item: BuilderItem) => boolean;
665
+ isHidden: (item: BuilderItem) => boolean;
666
+ /** Phần tử tự mở hàng mới (`layout.newRow`). */
667
+ hasNewRow: (item: BuilderItem) => boolean;
668
+ /**
669
+ * Nhãn span của field đang chọn ở mức đang xem: `6/12`, kèm "Theo Desktop" (tablet) hoặc "Mặc định"
670
+ * (mobile) khi mức đó chưa tự khai báo span.
671
+ */
672
+ spanLabel: (item: BuilderItem) => string;
673
+ labelOf: (item: BuilderItem) => string;
674
+ /** Tên truy cập của nút chọn field: nhãn, loại, trạng thái. */
675
+ ariaLabelOf: (item: BuilderItem) => string;
676
+ groupRows: (group: SdFormGenericGroup) => LayoutRow[];
677
+ groupCount: (group: SdFormGenericGroup) => number;
678
+ isCollapsed: (group: SdFormGenericGroup) => boolean;
679
+ canMoveUp: (item: BuilderItem) => boolean;
680
+ canMoveDown: (item: BuilderItem) => boolean;
681
+ parentOf: (item: BuilderItem) => ContainerId;
682
+ /** Group khác (đích cho "Chuyển vào nhóm"). */
683
+ otherGroups: (item: BuilderItem) => SdFormGenericGroup[];
684
+ resizeBadge: (item: BuilderItem) => string | null;
685
+ select(item: BuilderItem, event?: Event): void;
686
+ onBackgroundClick(event: MouseEvent): void;
687
+ onCardKeydown(event: KeyboardEvent, item: BuilderItem): void;
688
+ /** Kéo từ thân card (chuột/bút). Trên cảm ứng chỉ tay nắm mới kéo — để vuốt vẫn cuộn được canvas. */
689
+ onCardPointerDown(event: PointerEvent, item: BuilderItem): void;
690
+ onGripPointerDown(event: PointerEvent, item: BuilderItem): void;
691
+ onResizePointerDown(event: PointerEvent, item: BuilderItem, cell: HTMLElement): void;
692
+ duplicate(item: BuilderItem): void;
693
+ remove(item: BuilderItem): void;
694
+ moveBy(item: BuilderItem, delta: -1 | 1): void;
695
+ moveTo(item: BuilderItem, parentId: ContainerId): void;
696
+ toggleNewRow(item: BuilderItem): void;
697
+ toggleCollapsed(group: SdFormGenericGroup, event: Event): void;
698
+ /**
699
+ * Cuộn tới phần tử (khi chọn từ tab Cấu trúc hoặc vừa thêm).
700
+ * why: sau lần render KẾ TIẾP — phần tử vừa thêm/nhân bản chưa có trong DOM khi lệnh vừa commit, còn
701
+ * microtask/setTimeout(0) chạy trước change detection (nhất là khi app bật eventCoalescing).
702
+ */
703
+ scrollToItem(id: string, focus?: boolean): void;
704
+ /**
705
+ * Focus thẻ của phần tử sau lần render kế tiếp; không có (hoặc `null`) thì focus vùng canvas.
706
+ * Shell gọi khi xử lý `store.focusRequest` (sau xoá / tách nhóm).
707
+ */
708
+ focusItem(id: string | null): void;
709
+ /** Đo hàng/phần tử theo toạ độ nội dung của vùng cuộn (dùng cho hit-test và indicator). */
710
+ measure(): CanvasGeometry;
711
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CanvasComponent, never>;
712
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CanvasComponent, "fb-canvas", never, {}, { "requestAdd": "requestAdd"; "requestRemove": "requestRemove"; }, never, never, true, never>;
682
713
  }
683
714
 
684
- declare class ConfigureValidationComponent implements AfterViewInit, OnDestroy {
685
- modal?: SdModal;
686
- form: FormGroup<{}>;
687
- attributes: Attribute[];
688
- validations: SdFormGenericValidation[];
689
- functions: SdFormGenericValidationFunction[];
690
- alerts: {
715
+ /** Bản nháp trong dialog: validation Filter được phép chưa có điều kiện (bị bỏ khi lưu). */
716
+ type DraftValidation = {
717
+ type: 'filter';
718
+ filter?: Filter;
719
+ message: string;
720
+ alert: SdFormGenericAlert;
721
+ } | {
722
+ type: 'function';
723
+ validator: string;
724
+ alert: SdFormGenericAlert;
725
+ };
726
+ /** Validation cấp form: điều kiện `Filter` kèm câu thông báo, hoặc validator hàm của portal. */
727
+ declare class ConfigureValidationComponent {
728
+ #private;
729
+ readonly modal: _angular_core.Signal<SdModal | undefined>;
730
+ readonly accept: _angular_core.OutputEmitterRef<SdFormGenericValidation[]>;
731
+ readonly form: FormGroup<{}>;
732
+ readonly validations: _angular_core.WritableSignal<DraftValidation[]>;
733
+ readonly elements: _angular_core.WritableSignal<readonly SdFormGenericPageElement[]>;
734
+ readonly variables: _angular_core.WritableSignal<readonly SdFormGenericVariable[]>;
735
+ readonly validators: _angular_core.Signal<{
691
736
  value: string;
692
737
  display: string;
693
- }[];
694
- readonly accept: _angular_core.OutputEmitterRef<SdFormGenericValidation[]>;
695
- private readonly ref;
696
- private readonly formGenericConfiguration;
697
- constructor();
698
- ngAfterViewInit(): void;
699
- ngOnDestroy(): void;
700
- open: (formGeneric: SdFormGeneric) => void;
701
- addValidation: (type: SdFormGenericValidation["type"]) => void;
702
- removaValidation: (index: number) => void;
703
- updateValidations: () => void;
738
+ }[]>;
739
+ readonly alerts: _angular_core.Signal<{
740
+ value: string;
741
+ display: string;
742
+ }[]>;
743
+ open(elements: readonly SdFormGenericPageElement[], variables: readonly SdFormGenericVariable[], validations: readonly SdFormGenericValidation[]): void;
744
+ add(type: DraftValidation['type']): void;
745
+ remove(index: number): void;
746
+ patch(index: number, patch: Partial<DraftValidation>): void;
747
+ save(): void;
704
748
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<ConfigureValidationComponent, never>;
705
749
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<ConfigureValidationComponent, "configure-validation", never, {}, { "accept": "accept"; }, never, never, true, never>;
706
750
  }
707
751
 
708
- type FormBuilderLayoutItem = SdFormGenericComponent | SdFormGenericGroup;
709
- interface FormBuilderLayoutRow {
710
- id: string;
711
- items: FormBuilderLayoutItem[];
712
- columns: number;
752
+ interface PaletteSection {
753
+ readonly category: PaletteCategory;
754
+ readonly items: readonly PaletteItem[];
713
755
  }
714
-
715
- interface DragDropRowItem extends FormBuilderLayoutRow {
716
- rowIndex?: number;
717
- }
718
- interface ResizeState {
719
- itemId: string;
720
- rowId: string;
721
- columns: string;
722
- }
723
- type RowInsertionEdge = 'before' | 'after';
724
- type PaletteDropTarget = {
725
- kind: 'empty';
726
- } | {
727
- kind: 'inline';
728
- rowId: string;
729
- index: number;
730
- columns: string;
731
- } | {
732
- kind: 'edge';
733
- rowId: string;
734
- edge: RowInsertionEdge;
735
- };
736
- declare class SdFormBuilder implements OnInit, OnDestroy {
756
+ /**
757
+ * Panel trái: tab "Thành phần" (palette có tìm kiếm, bấm/Enter/Space hoặc kéo để thêm) và tab
758
+ * "Cấu trúc" (cây phản chiếu schema). Cùng một vị trí chèn cho click, bàn phím và kéo-thả.
759
+ */
760
+ declare class PaletteComponent {
737
761
  #private;
738
- readonly popupViewJSON: _angular_core.Signal<SdModal | undefined>;
739
- readonly popupConfigureVariables: _angular_core.Signal<SdModal | undefined>;
740
- readonly configureValidation: _angular_core.Signal<ConfigureValidationComponent | undefined>;
741
- readonly formRender: _angular_core.Signal<SdFormRender | undefined>;
742
- private readonly canvasDropZone;
743
- readonly rowDropLists: _angular_core.Signal<readonly CdkDropList<any>[]>;
744
- readonly connectedRowDropLists: _angular_core.Signal<CdkDropList<any>[]>;
745
- form: FormGroup<{}>;
746
- /** Input chính: schema form. Mỗi lần ref thay đổi → effect sẽ clone về local arrays. */
747
- readonly formGeneric: _angular_core.InputSignal<SdFormGeneric | undefined>;
748
- readonly formBuilderComponents: FormBuilderComponent[];
749
- readonly componentIcons: Record<string, {
750
- symbol: string;
762
+ readonly store: FormBuilderStore;
763
+ /** Tiền tố id riêng cho từng builder — hai builder trên một trang không trùng id tab. */
764
+ readonly uid: string;
765
+ /** Phần tử vừa được thêm/chọn từ cây — shell cuộn canvas tới đó. */
766
+ readonly itemAdded: _angular_core.OutputEmitterRef<string>;
767
+ readonly itemFocused: _angular_core.OutputEmitterRef<string>;
768
+ readonly search: _angular_core.WritableSignal<string>;
769
+ readonly collapsedCategories: _angular_core.WritableSignal<ReadonlySet<PaletteCategory>>;
770
+ readonly searchInput: _angular_core.Signal<ElementRef<HTMLInputElement> | undefined>;
771
+ readonly sections: _angular_core.Signal<PaletteSection[]>;
772
+ /** Đích thêm khi bấm (hiển thị rõ cho người dùng). */
773
+ readonly target: _angular_core.Signal<{
774
+ kind: "root";
751
775
  label: string;
752
- }>;
753
- readonly paletteSearch: _angular_core.WritableSignal<string>;
754
- readonly paletteGroups: _angular_core.Signal<{
755
- key: FormBuilderComponentGroup;
776
+ } | {
777
+ kind: "group";
756
778
  label: string;
757
- items: FormBuilderComponent[];
758
- }[]>;
759
- components: Required<SdFormGeneric>['components'];
760
- variables: Required<SdFormGeneric>['variables'];
761
- validations: Required<SdFormGeneric>['validations'];
762
- /** Cloned variables — dùng cho modal "Configure variables" (huỷ thì discard, ok thì gán ngược). */
763
- clonedVariables: SdFormGenericVariable[];
764
- readonly selectedComponent: _angular_core.WritableSignal<SdFormGenericComponent | SdFormGenericGroup | undefined>;
765
- readonly isPreview: _angular_core.WritableSignal<boolean>;
766
- readonly editingGroupId: _angular_core.WritableSignal<string | undefined>;
767
- /** Group đang được Detail (tìm ở TOP-LEVEL theo id), undefined = đang ở canvas chính. */
768
- readonly editingGroup: _angular_core.Signal<SdFormGenericGroup | undefined>;
769
- /** Signal toàn cục: TRUE khi BẤT KỲ cdkDrag nào đang active (palette, canvas, group, resize).
770
- * Trigger class `.fb-shell--dragging` để ẩn hover/actions/resize toàn diện, không phụ thuộc :has(). */
771
- readonly isAnyDragging: _angular_core.WritableSignal<boolean>;
772
- readonly dragSource: _angular_core.WritableSignal<"row" | "palette" | "canvas" | "resize" | undefined>;
773
- readonly draggedPaletteItem: _angular_core.WritableSignal<FormBuilderComponent | undefined>;
774
- readonly paletteDropTarget: _angular_core.WritableSignal<PaletteDropTarget | undefined>;
775
- /** @deprecated Internal drag-preview compatibility mirror; use no application code. */
776
- readonly rowInsertionEdge: _angular_core.WritableSignal<RowInsertionEdge>;
777
- /** @deprecated Internal drag-preview compatibility mirror; use no application code. */
778
- readonly inlineDropTargetRow: _angular_core.WritableSignal<DragDropRowItem | undefined>;
779
- readonly resizeState: _angular_core.WritableSignal<ResizeState | undefined>;
780
- readonly isResizing: _angular_core.Signal<boolean>;
781
- expand: boolean;
782
- dragDropRows: DragDropRowItem[];
783
- isDragging: boolean;
784
- targetItem?: DragDropRowItem;
785
- private lastDragPointer?;
786
- /** Handler chung cho mọi cdkDragStarted — set signal global true. */
787
- onAnyDragStarted: () => void;
788
- onPaletteDragStarted: (item?: FormBuilderComponent) => void;
789
- onRowDragStarted: () => void;
790
- onAnyDragMoved: (event: CdkDragMove<any>) => void;
791
- /** Handler chung cho mọi cdkDragEnded — set signal global false (dùng setTimeout 0
792
- * để chờ CDK xử lý xong drop event trước khi UI re-enable). */
793
- onAnyDragEnded: () => void;
794
- startResizeControl: (item: SdFormGenericComponent | SdFormGenericGroup, row: DragDropRowItem) => void;
795
- endResizeControl: (event: any) => void;
779
+ } | {
780
+ kind: "after";
781
+ label: string;
782
+ }>;
783
+ /** Esc trong ô tìm: xoá từ khoá nếu có và dừng ở đó — Esc tiếp theo mới đóng panel nổi. */
784
+ clearSearch(event: Event): void;
785
+ focusSearch(): void;
786
+ isCollapsed: (category: PaletteCategory) => boolean;
787
+ toggleCategory(category: PaletteCategory): void;
788
+ add(entry: PaletteItem): void;
789
+ /** Kéo từ palette: chuột/bút từ cả mục; cảm ứng chỉ từ tay nắm (vuốt trên danh sách vẫn cuộn). */
790
+ onPointerDown(event: PointerEvent, entry: PaletteItem, fromGrip?: boolean): void;
791
+ /** Đổi tab bằng bàn phím và đưa focus sang tab mới (tab cũ đã thành `tabindex=-1`). */
792
+ switchTab(tab: 'components' | 'structure', target: HTMLElement, event: Event): void;
793
+ clearSelection(): void;
794
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<PaletteComponent, never>;
795
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<PaletteComponent, "fb-palette", never, {}, { "itemAdded": "itemAdded"; "itemFocused": "itemFocused"; }, never, never, true, never>;
796
+ }
797
+
798
+ interface VariableDraft {
799
+ /** Id cục bộ của dòng trong dialog (không lưu vào schema). */
800
+ id: string;
801
+ key: string;
802
+ label: string;
803
+ /** Biến gốc (nếu có) — giữ các thuộc tính khác của consumer khi lưu. */
804
+ source?: SdFormGenericVariable;
805
+ }
806
+ /**
807
+ * `<sd-form-builder>` — trình thiết kế form NHÚNG trong Core UI (không phải ứng dụng riêng: không
808
+ * header ứng dụng, không lưu/nháp/xuất bản — persistence thuộc consumer).
809
+ *
810
+ * Bố cục: toolbar nội bộ `[Thiết kế | Xem trước | Schema] [Desktop | Tablet | Mobile] [Hoàn tác |
811
+ * Làm lại | Công cụ]`, dưới là Thành phần/Cấu trúc · Canvas · Thuộc tính. Chiều cao do host quyết định.
812
+ * Viewport chọn mức bố cục đang thiết kế: resize và tab Bố cục ghi span của mức đó.
813
+ *
814
+ * State: schema chuẩn duy nhất trong `FormBuilderStore` (một instance/builder); mọi chỉnh sửa là
815
+ * command có undo. Input của consumer không bao giờ bị mutate.
816
+ */
817
+ declare class SdFormBuilder {
818
+ #private;
819
+ readonly store: FormBuilderStore;
820
+ /**
821
+ * Schema của builder — `[(schema)]`. Mỗi tham chiếu MỚI có nội dung khác schema hiện tại = nạp form
822
+ * khác: reset lịch sử undo và selection. Nhận lại đúng schema vừa phát, hoặc tham chiếu mới nhưng
823
+ * CÙNG nội dung (vd consumer lưu rồi truyền lại), bị bỏ qua — không reset, không vòng lặp.
824
+ *
825
+ * Builder phát snapshot (bản clone độc lập) sau MỖI thay đổi do người dùng — kể cả hoàn tác/làm lại;
826
+ * không phát khi nạp schema, khi đổi selection/mode/viewport. Input không bao giờ bị mutate; sửa
827
+ * object tại chỗ sẽ KHÔNG nạp lại — hãy truyền object mới.
828
+ */
829
+ readonly schema: _angular_core.ModelSignal<SdFormGenericSchema | undefined>;
830
+ readonly canvas: _angular_core.Signal<CanvasComponent | undefined>;
831
+ readonly palette: _angular_core.Signal<PaletteComponent | undefined>;
832
+ readonly validationDialog: _angular_core.Signal<ConfigureValidationComponent | undefined>;
833
+ readonly variablesModal: _angular_core.Signal<SdModal | undefined>;
834
+ readonly shortcutsModal: _angular_core.Signal<SdModal | undefined>;
835
+ /** Container hẹp → palette/inspector thành panel nổi. */
836
+ readonly compact: _angular_core.WritableSignal<boolean>;
837
+ readonly leftOpen: _angular_core.WritableSignal<boolean>;
838
+ readonly rightOpen: _angular_core.WritableSignal<boolean>;
839
+ /** Id của hai panel — nút mở trỏ tới qua `aria-controls`. */
840
+ protected readonly leftPanelId: string;
841
+ protected readonly rightPanelId: string;
842
+ protected readonly leftToggle: _angular_core.Signal<ElementRef<HTMLButtonElement> | undefined>;
843
+ protected readonly rightToggle: _angular_core.Signal<ElementRef<HTMLButtonElement> | undefined>;
844
+ readonly modes: readonly BuilderMode[];
845
+ readonly viewports: readonly BuilderViewport[];
846
+ readonly modeIcons: Record<BuilderMode, string>;
847
+ readonly viewportIcons: Record<BuilderViewport, string>;
848
+ readonly isDesign: _angular_core.Signal<boolean>;
849
+ readonly schemaText: _angular_core.Signal<string>;
850
+ readonly variableDrafts: _angular_core.WritableSignal<VariableDraft[]>;
851
+ readonly variableErrors: _angular_core.Signal<string[]>;
852
+ readonly variablesInvalid: _angular_core.Signal<boolean>;
796
853
  constructor();
797
- ngOnInit(): void;
798
- ngOnDestroy(): void;
799
- addComponent: (item: FormBuilderComponent, index?: number, layoutColumns?: string) => void;
800
- /** Symbol Material để render trên canvas item / attribute header. */
801
- symbolFor: (item: SdFormGenericComponent | SdFormGenericGroup) => string;
802
- /** Human-readable type label (e.g. "Text field", "Date"). */
803
- typeLabelFor: (item: SdFormGenericComponent | SdFormGenericGroup) => string;
804
- placeholderSymbolFor: (item: FormBuilderComponent | SdFormGenericComponent | SdFormGenericGroup | DragDropRowItem | undefined) => string;
805
- placeholderTitleFor: (item: FormBuilderComponent | SdFormGenericComponent | SdFormGenericGroup | DragDropRowItem | undefined) => string;
806
- placeholderMetaFor: (item: FormBuilderComponent | SdFormGenericComponent | SdFormGenericGroup | DragDropRowItem | undefined) => string;
807
- placeholderColumnsFor: (item: FormBuilderComponent | SdFormGenericComponent | SdFormGenericGroup | DragDropRowItem | undefined) => number;
808
- /** True nếu component có expression điều kiện — drives the "conditional" status chip. */
809
- hasConditional: (item: SdFormGenericComponent | SdFormGenericGroup) => boolean;
810
- /** Map Color preset → 2 CSS var names cho header-bg và header-fg của group card. */
811
- groupColorVars: (color: string | undefined | null) => {
812
- bg: string;
813
- fg: string;
814
- };
815
- /** Segmented Design/Preview toggle (replaces play_circle/stop_circle). */
816
- setMode: (preview: boolean) => void;
817
- /** Mở canvas thiết kế riêng cho 1 group (chỉ children của nó). Snapshot để Cancel revert. */
818
- onEnterGroupEditKeydown: (group: SdFormGenericGroup, event: KeyboardEvent) => void;
819
- enterGroupEdit: (group: SdFormGenericGroup) => void;
820
- /** OK: giữ thay đổi children, quay về canvas chính. */
821
- confirmGroupEdit: () => void;
822
- /** Cancel: revert children về snapshot lúc vào Detail, rồi quay về canvas chính. */
823
- cancelGroupEdit: () => void;
824
- /** Quick-add break sau row chỉ định (theo scope hiện tại — top-level hoặc group).
825
- * Tính component index cuối cùng của row đó trong scope, splice break vào sau.
854
+ /** Snapshot schema hiện tại (bản clone độc lập, sửa thoải mái không ảnh hưởng builder). */
855
+ getSchema: () => SdFormGenericSchema;
856
+ setMode(mode: BuilderMode): void;
857
+ setViewport(viewport: BuilderViewport): void;
858
+ /** Phím của radiogroup (APG): ←/↑ lùi, →/↓ tiến (vòng), Home/End về đầu/cuối. */
859
+ onSegmentKeydown(event: KeyboardEvent, values: readonly string[], current: string, apply: (value: string) => void): void;
860
+ applyMode: (value: string) => void;
861
+ applyViewport: (value: string) => void;
862
+ undo(): void;
863
+ redo(): void;
864
+ /** Phím tắt trong phạm vi builder (không bắt toàn trang). Ô nhập giữ undo gõ chữ của trình duyệt. */
865
+ onKeydown(event: KeyboardEvent): void;
866
+ focusPalette(): void;
867
+ /** Mở/đóng panel nổi (builder hẹp). Mở thì focus vào panel; Esc đóng và trả focus về nút. */
868
+ protected togglePanel(side: 'left' | 'right'): void;
869
+ onItemAdded(id: string): void;
870
+ onItemFocused(id: string): void;
871
+ /** Xoá — hỏi xác nhận khi có nơi khác phụ thuộc vào field, hoặc group còn field con. */
872
+ remove(id: string): Promise<void>;
873
+ openVariables(): void;
874
+ addVariable(): void;
875
+ updateVariable(index: number, field: 'key' | 'label', value: string): void;
876
+ removeVariable(index: number): void;
877
+ /**
878
+ * Lưu dialog Biến. Đổi key biến kéo theo mọi tham chiếu có cấu trúc (như đổi mã field); bỏ một biến
879
+ * còn được dùng thì hỏi trước, vì các điều kiện/tham số đó sẽ không còn đúng.
826
880
  */
827
- insertBreakAfter: (row: DragDropRowItem) => void;
828
- /** Xoá component theo scope hiện tại (top-level hoặc children của group đang Detail). */
829
- removeComponent: (id: string) => void;
830
- selectComponent: (item?: SdFormGenericComponent | SdFormGenericGroup) => void;
831
- onPaletteItemKeydown: (item: FormBuilderComponent, event: KeyboardEvent) => void;
832
- onClickedOutside: (e: any) => void;
833
- clickFormContentEmpty: () => void;
834
- drop: (event: CdkDragDrop<any[]>) => void;
835
- dragStartComponentItem: (event: any) => void;
836
- dragEndComponentItem: (event: any) => void;
837
- onMouseover: (event: MouseEvent, rowItem: DragDropRowItem) => void;
838
- isRowFull: (row: DragDropRowItem) => boolean;
839
- isRowInlineDropLocked: (row: DragDropRowItem) => boolean;
840
- shouldShowRowInsertionPlaceholder: (row: DragDropRowItem, edge?: RowInsertionEdge) => boolean;
841
- shouldShowInlinePalettePlaceholder: (row: DragDropRowItem, index: number) => boolean;
842
- isPaletteEmptyDropTarget: () => boolean;
843
- palettePlaceholderColumnsFor: (row?: DragDropRowItem) => number;
844
- onRowItemsDropEntered: (row: DragDropRowItem, event?: CdkDragEnter<any[]>) => void;
845
- onRowItemsDropSorted: (row: DragDropRowItem, event: CdkDragSortEvent<any[]>) => void;
846
- onRowItemsDropExited: (row: DragDropRowItem) => void;
847
- canEnterCanvasDropList: (drag: CdkDrag<FormBuilderComponent | SdFormGenericComponent | SdFormGenericGroup | DragDropRowItem>) => boolean;
848
- canEnterRowDropList: (drag: CdkDrag<FormBuilderComponent | SdFormGenericComponent | SdFormGenericGroup>, drop: CdkDropList<(SdFormGenericComponent | SdFormGenericGroup)[]>) => boolean;
849
- onFocus: (event: FocusEvent) => void;
850
- xuLyKeoCheo: (dragItem?: SdFormGenericComponent | SdFormGenericGroup) => void;
851
- noReturnPredicate: () => boolean;
852
- changeSizeControl: (event: CdkDragMove<SdFormGenericComponent | SdFormGenericGroup>, item: SdFormGenericComponent | SdFormGenericGroup, items: (SdFormGenericComponent | SdFormGenericGroup)[], currentIndex: number) => Promise<void>;
853
- dragEndChangeSizeControl: (event: any) => void;
854
- onChangeViewed: (component: SdFormGenericComponent) => void;
855
- onChangeHidden: (component: SdFormGenericComponent | SdFormGenericGroup) => void;
856
- onDuplicate: (component: SdFormGenericComponent | SdFormGenericGroup) => void;
857
- jsonString?: string;
858
- viewJSON: () => void;
859
- updateJSON: () => void;
860
- configureVariables: () => void;
861
- addVariables: () => void;
862
- removeVariables: (id: string) => void;
863
- updateVariables: () => void;
864
- getComponents: () => (SdFormGenericComponent | SdFormGenericGroup)[];
865
- getVariables: () => SdFormGenericVariable[];
866
- getForm: () => SdFormGeneric;
867
- openConfigureValidation: () => void;
868
- onUpdateValidations: (validations: SdFormGenericValidation[]) => void;
869
- onValidate: () => Promise<void>;
881
+ saveVariables(): Promise<void>;
882
+ openValidations(): void;
883
+ onValidationsAccepted(validations: SdFormGenericValidation[]): void;
884
+ openShortcuts(): void;
870
885
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdFormBuilder, never>;
871
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<SdFormBuilder, "sd-form-builder", never, { "formGeneric": { "alias": "formGeneric"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
886
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<SdFormBuilder, "sd-form-builder", never, { "schema": { "alias": "schema"; "required": false; "isSignal": true; }; }, { "schema": "schemaChange"; }, never, never, true, never>;
872
887
  }
873
888
 
874
- declare class SdFeelExpression implements OnInit {
889
+ interface SdFormGenericLayoutCell<T> {
890
+ element: T;
891
+ span: number;
892
+ }
893
+ type SdFormGenericLayoutRow<T> = SdFormGenericLayoutCell<T>[];
894
+
895
+ interface FieldNode {
896
+ kind: 'field';
897
+ id: string;
898
+ type: string;
899
+ layout?: SdFormGenericLayout;
900
+ field: SdFormGenericField;
901
+ state: SdFormGenericElementState;
902
+ }
903
+ interface GroupNode {
904
+ kind: 'group';
905
+ id: string;
906
+ type: 'group';
907
+ layout?: undefined;
908
+ group: SdFormGenericGroup;
909
+ rows: SdFormGenericLayoutRow<FieldNode>[];
910
+ }
911
+ type RenderNode = FieldNode | GroupNode;
912
+ /** Ô của lưới CSS 12 cột: hàng (1-based) và cột (`start / span n`) lấy từ `sdPackRows`. */
913
+ interface FieldCell {
914
+ kind: 'field';
915
+ id: string;
916
+ row: number;
917
+ column: string;
918
+ field: SdFormGenericField;
919
+ state: SdFormGenericElementState;
920
+ }
921
+ interface GroupCell {
922
+ kind: 'group';
923
+ id: string;
924
+ row: number;
925
+ column: string;
926
+ group: SdFormGenericGroup;
927
+ children: FieldCell[];
928
+ }
929
+ type RenderCell = FieldCell | GroupCell;
930
+ declare class SdFormRender {
875
931
  #private;
876
- private ref;
877
- private expressionFeelPipe;
878
- private formGenericService;
879
- modal?: SdModal;
880
- form: FormGroup<{}>;
881
- attributeOperators: Record<"string" | "number" | "boolean" | "datetime" | "values", {
882
- value: _sdcorejs_angular_components_form_generic.SdFormGenericOperator;
883
- symbol?: string;
884
- display: string;
885
- }[]>;
886
- attributes: Attribute[];
887
- attribute: Record<string, Attribute>;
888
- readonly components: _angular_core.InputSignal<(SdFormGenericComponent | SdFormGenericGroup)[]>;
889
- expression?: SdFormGenericExpression;
890
- set _expression(expression: SdFormGenericExpression | undefined);
891
- readonly expressionChange: _angular_core.OutputEmitterRef<SdFormGenericExpression>;
892
- model?: string;
893
- set _model(model: string | undefined);
894
- readonly modelChange: _angular_core.OutputEmitterRef<string | undefined>;
895
- readonly sdChange: _angular_core.OutputEmitterRef<{
896
- model?: string;
897
- expression?: SdFormGenericExpression;
898
- }>;
899
- /** Inserted by Angular inject() migration for backwards compatibility */
900
- constructor(...args: unknown[]);
901
- ngOnInit(): void;
902
- edit: () => Promise<void>;
903
- addCondition: (conditions: SdFormGenericExpression["conditions"]) => void;
904
- addCombinator: (conditions: SdFormGenericExpression["conditions"]) => void;
905
- remove: (conditions: SdFormGenericExpression["conditions"], idx: number) => void;
906
- onAccept: () => void;
907
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdFeelExpression, never>;
908
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<SdFeelExpression, "sd-feel-expression", never, { "components": { "alias": "components"; "required": true; "isSignal": true; }; "_expression": { "alias": "expression"; "required": true; }; "_model": { "alias": "model"; "required": true; }; }, { "expressionChange": "expressionChange"; "modelChange": "modelChange"; "sdChange": "sdChange"; }, never, never, true, never>;
932
+ /** Schema form (không bị sửa). */
933
+ readonly schema: _angular_core.InputSignal<SdFormGenericSchema>;
934
+ /** Giá trị form; mỗi thay đổi phát object MỚI, object cũ của consumer không bị sửa. */
935
+ readonly value: _angular_core.ModelSignal<Record<string, unknown>>;
936
+ /** FormGroup của consumer; không truyền thì renderer dùng FormGroup riêng. */
937
+ readonly form: _angular_core.InputSignal<FormGroup<any> | null>;
938
+ /** Biến do consumer cấp; dùng trong điều kiện, value ref và hyperlink. */
939
+ readonly variables: _angular_core.InputSignal<Record<string, unknown> | null>;
940
+ readonly viewed: _angular_core.InputSignalWithTransform<boolean, unknown>;
941
+ /** Ép mức bố cục (vd Xem trước của builder); `null` = đo theo bề rộng form. */
942
+ readonly breakpoint: _angular_core.InputSignal<SdFormGenericBreakpoint | null>;
943
+ /** Vị trí nhãn của mọi control (mặc định nhãn rời phía trên). */
944
+ readonly labelPlacement: _angular_core.InputSignal<SdLabelPlacement>;
945
+ /** Chỉ render field có key trong danh sách; `null` = mọi field. */
946
+ readonly keys: _angular_core.InputSignal<readonly string[] | null>;
947
+ private readonly grid;
948
+ private readonly items;
949
+ readonly formGroup: _angular_core.Signal<FormGroup<any> | FormGroup<{}>>;
950
+ readonly normalized: _angular_core.Signal<SdFormGenericSchema>;
951
+ readonly scope: _angular_core.Signal<Readonly<Record<string, unknown>>>;
952
+ /** Mức bố cục hiện hành. */
953
+ readonly level: _angular_core.Signal<SdFormGenericBreakpoint>;
954
+ /** Hàng của trang đang hiện (đợt 1: một trang). */
955
+ readonly rows: _angular_core.Signal<SdFormGenericLayoutRow<RenderNode>[]>;
956
+ /** Ô của lưới theo thứ tự tài liệu (DOM phẳng, vị trí từ `rows`). */
957
+ readonly cells: _angular_core.Signal<RenderCell[]>;
958
+ constructor();
959
+ /**
960
+ * Đánh dấu mọi control đã chạm, chờ validator bất đồng bộ, rồi chạy validation cấp form.
961
+ * Luôn trả `{ valid, messages: { error, warning } }`; chỉ lỗi làm `valid = false`.
962
+ */
963
+ validate(): Promise<SdFormGenericValidationResult>;
964
+ /** Tải lên các tệp đang chờ của mọi field upload; kết quả được ghi vào value. Gọi trước khi lưu. */
965
+ upload(): Promise<void>;
966
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdFormRender, never>;
967
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<SdFormRender, "sd-form-render", never, { "schema": { "alias": "schema"; "required": true; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "form": { "alias": "form"; "required": false; "isSignal": true; }; "variables": { "alias": "variables"; "required": false; "isSignal": true; }; "viewed": { "alias": "viewed"; "required": false; "isSignal": true; }; "breakpoint": { "alias": "breakpoint"; "required": false; "isSignal": true; }; "labelPlacement": { "alias": "labelPlacement"; "required": false; "isSignal": true; }; "keys": { "alias": "keys"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; }, never, never, true, never>;
909
968
  }
910
969
 
911
970
  declare class SdFormRenderService {
912
- private readonly componentViewedPipe;
913
- /** Inserted by Angular inject() migration for backwards compatibility */
914
- constructor(...args: unknown[]);
915
- viewEntities: (form: SdFormGeneric, entities: Record<string, any>[]) => Promise<Record<string, any>[]>;
971
+ #private;
972
+ /**
973
+ * Giá trị hiển thị (chuỗi) theo từng field của mỗi entity — cùng định dạng với chế độ chỉ xem.
974
+ * Bỏ qua upload và html. Nhãn của options catalog lấy qua catalog của portal, một lần cho mỗi
975
+ * catalog + params + giá trị.
976
+ */
977
+ viewEntities(schema: SdFormGenericSchema, entities: readonly Record<string, unknown>[]): Promise<Record<string, string>[]>;
916
978
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdFormRenderService, never>;
917
979
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<SdFormRenderService>;
918
980
  }
919
981
 
920
- export { SD_ATTRIBUTE_OPERATORS, SD_COMPONENT_ICONS, SD_DAY_INFO_PREVIOUSES, SD_DAY_INFO_TYPES, SD_FORM_BUILDER_COMPONENTS, SD_FORM_GENERIC_CONFIGURATION, SD_TABLE_COLUMN_TYPES, SdFeelExpression, SdFormBuilder, SdFormGenericOperators, SdFormRender, SdFormRenderService, ValidationAlerts, sdEvaluateExpression, sdExpressionToJavascriptExpression, sdFormatComponent, sdGenerateId, sdGenerateKey, sdGetAttributes, sdGetComponentAttributes, sdGetDatetimeValue, sdGetVariableAttributes, sdTemplateToCondition };
921
- export type { Attribute, DayInfo, FormBuilderComponent, FormBuilderComponentGroup, FormRenderComponentTableColumnValues, ISdFormGenericConfiguration, IWorkflowConfigurationForm, SdFormGeneric, SdFormGenericArgs, SdFormGenericBreak, SdFormGenericCheckbox, SdFormGenericChecklist, SdFormGenericChipCalendar, SdFormGenericChipString, SdFormGenericComponent, SdFormGenericComponentBase, SdFormGenericDatetime, SdFormGenericDefinitionHtml, SdFormGenericDefinitionSelection, SdFormGenericDefinitionTable, SdFormGenericExpression, SdFormGenericExpressionCondition, SdFormGenericGroup, SdFormGenericHtml, SdFormGenericLayout, SdFormGenericNumber, SdFormGenericOperator, SdFormGenericRadio, SdFormGenericSelect, SdFormGenericSelectionItem, SdFormGenericSelectionStaticItem, SdFormGenericTable, SdFormGenericTableColumn, SdFormGenericTemplate, SdFormGenericTextarea, SdFormGenericTextfield, SdFormGenericUpload, SdFormGenericValidation, SdFormGenericValidationConfiguration, SdFormGenericValidationFunction, SdFormGenericValues, SdFormGenericVariable, SdFormRenderConfiguration, SdFormRenderEntity };
982
+ export { SD_FORM_GENERIC_BREAKPOINTS, SdFormBuilder, SdFormRender, SdFormRenderService, provideSdFormGeneric };
983
+ export type { SdFormGenericAlert, SdFormGenericBreakpoint, SdFormGenericBreakpoints, SdFormGenericCatalog, SdFormGenericCatalogContext, SdFormGenericCatalogItem, SdFormGenericCheckbox, SdFormGenericChipCalendar, SdFormGenericChipString, SdFormGenericConfig, SdFormGenericDatetime, SdFormGenericElement, SdFormGenericField, SdFormGenericFieldType, SdFormGenericFieldValidation, SdFormGenericFill, SdFormGenericFilterValidation, SdFormGenericFunctionValidation, SdFormGenericGroup, SdFormGenericHtml, SdFormGenericHtmlDefinition, SdFormGenericHtmlQueryDefinition, SdFormGenericHtmlStaticDefinition, SdFormGenericLayout, SdFormGenericNavigation, SdFormGenericNumber, SdFormGenericNumberSubtype, SdFormGenericOption, SdFormGenericOptions, SdFormGenericPage, SdFormGenericPageElement, SdFormGenericParam, SdFormGenericPhoneCountry, SdFormGenericRadio, SdFormGenericRules, SdFormGenericSchema, SdFormGenericSelect, SdFormGenericTemplate, SdFormGenericTextarea, SdFormGenericTextfield, SdFormGenericTextfieldSubtype, SdFormGenericUpload, SdFormGenericValidation, SdFormGenericValidationMessages, SdFormGenericValidationResult, SdFormGenericValidator, SdFormGenericValueRef, SdFormGenericVariable, SdFormGenericVisibilityRules };