@acorex/components 20.1.29 → 20.1.32

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 (241) hide show
  1. package/code-editor/README.md +3 -0
  2. package/code-editor/index.d.ts +103 -0
  3. package/comment/index.d.ts +4 -5
  4. package/conversation/index.d.ts +106 -78
  5. package/data-pager/index.d.ts +12 -12
  6. package/data-table/index.d.ts +1 -1
  7. package/datetime-box/index.d.ts +10 -10
  8. package/drawer-2/index.d.ts +7 -8
  9. package/dropdown/index.d.ts +3 -3
  10. package/fesm2022/acorex-components-accordion.mjs +10 -10
  11. package/fesm2022/acorex-components-accordion.mjs.map +1 -1
  12. package/fesm2022/acorex-components-action-sheet.mjs +10 -10
  13. package/fesm2022/acorex-components-action-sheet.mjs.map +1 -1
  14. package/fesm2022/acorex-components-alert.mjs +7 -7
  15. package/fesm2022/acorex-components-alert.mjs.map +1 -1
  16. package/fesm2022/acorex-components-audio-wave.mjs +7 -7
  17. package/fesm2022/acorex-components-audio-wave.mjs.map +1 -1
  18. package/fesm2022/acorex-components-autocomplete.mjs +7 -7
  19. package/fesm2022/acorex-components-autocomplete.mjs.map +1 -1
  20. package/fesm2022/acorex-components-avatar.mjs +10 -10
  21. package/fesm2022/acorex-components-avatar.mjs.map +1 -1
  22. package/fesm2022/acorex-components-badge.mjs +7 -7
  23. package/fesm2022/acorex-components-badge.mjs.map +1 -1
  24. package/fesm2022/acorex-components-bottom-navigation.mjs +10 -10
  25. package/fesm2022/acorex-components-bottom-navigation.mjs.map +1 -1
  26. package/fesm2022/acorex-components-breadcrumbs.mjs +10 -10
  27. package/fesm2022/acorex-components-breadcrumbs.mjs.map +1 -1
  28. package/fesm2022/acorex-components-button-group.mjs +10 -10
  29. package/fesm2022/acorex-components-button-group.mjs.map +1 -1
  30. package/fesm2022/acorex-components-button.mjs +13 -13
  31. package/fesm2022/acorex-components-button.mjs.map +1 -1
  32. package/fesm2022/acorex-components-calendar.mjs +13 -13
  33. package/fesm2022/acorex-components-calendar.mjs.map +1 -1
  34. package/fesm2022/acorex-components-check-box.mjs +7 -7
  35. package/fesm2022/acorex-components-check-box.mjs.map +1 -1
  36. package/fesm2022/acorex-components-chips.mjs +7 -7
  37. package/fesm2022/acorex-components-chips.mjs.map +1 -1
  38. package/fesm2022/acorex-components-circular-progress.mjs +7 -7
  39. package/fesm2022/acorex-components-circular-progress.mjs.map +1 -1
  40. package/fesm2022/acorex-components-code-editor.mjs +591 -0
  41. package/fesm2022/acorex-components-code-editor.mjs.map +1 -0
  42. package/fesm2022/acorex-components-collapse.mjs +10 -10
  43. package/fesm2022/acorex-components-collapse.mjs.map +1 -1
  44. package/fesm2022/acorex-components-color-box.mjs +7 -7
  45. package/fesm2022/acorex-components-color-box.mjs.map +1 -1
  46. package/fesm2022/acorex-components-color-palette.mjs +30 -30
  47. package/fesm2022/acorex-components-color-palette.mjs.map +1 -1
  48. package/fesm2022/acorex-components-comment.mjs +36 -36
  49. package/fesm2022/acorex-components-comment.mjs.map +1 -1
  50. package/fesm2022/acorex-components-conversation.mjs +119 -87
  51. package/fesm2022/acorex-components-conversation.mjs.map +1 -1
  52. package/fesm2022/acorex-components-cron-job.mjs +46 -46
  53. package/fesm2022/acorex-components-cron-job.mjs.map +1 -1
  54. package/fesm2022/acorex-components-data-pager.mjs +31 -31
  55. package/fesm2022/acorex-components-data-pager.mjs.map +1 -1
  56. package/fesm2022/acorex-components-data-table.mjs +37 -37
  57. package/fesm2022/acorex-components-data-table.mjs.map +1 -1
  58. package/fesm2022/acorex-components-datetime-box.mjs +11 -11
  59. package/fesm2022/acorex-components-datetime-box.mjs.map +1 -1
  60. package/fesm2022/acorex-components-datetime-input.mjs +7 -7
  61. package/fesm2022/acorex-components-datetime-input.mjs.map +1 -1
  62. package/fesm2022/acorex-components-datetime-picker.mjs +7 -7
  63. package/fesm2022/acorex-components-datetime-picker.mjs.map +1 -1
  64. package/fesm2022/acorex-components-decorators.mjs +25 -25
  65. package/fesm2022/acorex-components-decorators.mjs.map +1 -1
  66. package/fesm2022/acorex-components-dialog.mjs +10 -10
  67. package/fesm2022/acorex-components-dialog.mjs.map +1 -1
  68. package/fesm2022/acorex-components-drawer-2.mjs +13 -14
  69. package/fesm2022/acorex-components-drawer-2.mjs.map +1 -1
  70. package/fesm2022/acorex-components-drawer.mjs +13 -13
  71. package/fesm2022/acorex-components-drawer.mjs.map +1 -1
  72. package/fesm2022/acorex-components-dropdown-button.mjs +7 -7
  73. package/fesm2022/acorex-components-dropdown-button.mjs.map +1 -1
  74. package/fesm2022/acorex-components-dropdown.mjs +13 -13
  75. package/fesm2022/acorex-components-dropdown.mjs.map +1 -1
  76. package/fesm2022/acorex-components-file-explorer.mjs +25 -25
  77. package/fesm2022/acorex-components-file-explorer.mjs.map +1 -1
  78. package/fesm2022/acorex-components-flow-chart.mjs +16 -16
  79. package/fesm2022/acorex-components-flow-chart.mjs.map +1 -1
  80. package/fesm2022/acorex-components-form.mjs +16 -16
  81. package/fesm2022/acorex-components-form.mjs.map +1 -1
  82. package/fesm2022/acorex-components-grid-layout-builder.mjs +10 -10
  83. package/fesm2022/acorex-components-grid-layout-builder.mjs.map +1 -1
  84. package/fesm2022/acorex-components-image-editor.mjs +40 -34
  85. package/fesm2022/acorex-components-image-editor.mjs.map +1 -1
  86. package/fesm2022/acorex-components-image.mjs +7 -7
  87. package/fesm2022/acorex-components-image.mjs.map +1 -1
  88. package/fesm2022/acorex-components-json-viewer.mjs +7 -7
  89. package/fesm2022/acorex-components-json-viewer.mjs.map +1 -1
  90. package/fesm2022/acorex-components-kanban.mjs +3 -3
  91. package/fesm2022/acorex-components-kanban.mjs.map +1 -1
  92. package/fesm2022/acorex-components-kbd.mjs +6 -6
  93. package/fesm2022/acorex-components-kbd.mjs.map +1 -1
  94. package/fesm2022/acorex-components-label.mjs +7 -7
  95. package/fesm2022/acorex-components-label.mjs.map +1 -1
  96. package/fesm2022/acorex-components-list.mjs +7 -7
  97. package/fesm2022/acorex-components-list.mjs.map +1 -1
  98. package/fesm2022/acorex-components-loading-dialog.mjs +10 -10
  99. package/fesm2022/acorex-components-loading-dialog.mjs.map +1 -1
  100. package/fesm2022/acorex-components-loading.mjs +16 -16
  101. package/fesm2022/acorex-components-loading.mjs.map +1 -1
  102. package/fesm2022/acorex-components-map.mjs +13 -13
  103. package/fesm2022/acorex-components-map.mjs.map +1 -1
  104. package/fesm2022/acorex-components-media-viewer.mjs +34 -34
  105. package/fesm2022/acorex-components-media-viewer.mjs.map +1 -1
  106. package/fesm2022/acorex-components-menu.mjs +19 -19
  107. package/fesm2022/acorex-components-menu.mjs.map +1 -1
  108. package/fesm2022/{acorex-components-modal-acorex-components-modal-CmzrV-vD.mjs → acorex-components-modal-acorex-components-modal-BdrQgtUV.mjs} +21 -21
  109. package/fesm2022/{acorex-components-modal-acorex-components-modal-CmzrV-vD.mjs.map → acorex-components-modal-acorex-components-modal-BdrQgtUV.mjs.map} +1 -1
  110. package/fesm2022/{acorex-components-modal-modal-content.component-CaZfLUuL.mjs → acorex-components-modal-modal-content.component-DTrjX50k.mjs} +24 -8
  111. package/fesm2022/acorex-components-modal-modal-content.component-DTrjX50k.mjs.map +1 -0
  112. package/fesm2022/acorex-components-modal.mjs +1 -1
  113. package/fesm2022/acorex-components-navbar.mjs +7 -7
  114. package/fesm2022/acorex-components-navbar.mjs.map +1 -1
  115. package/fesm2022/acorex-components-notification.mjs +10 -10
  116. package/fesm2022/acorex-components-notification.mjs.map +1 -1
  117. package/fesm2022/acorex-components-number-box-2.mjs +8 -5
  118. package/fesm2022/acorex-components-number-box-2.mjs.map +1 -1
  119. package/fesm2022/acorex-components-number-box.mjs +7 -7
  120. package/fesm2022/acorex-components-number-box.mjs.map +1 -1
  121. package/fesm2022/acorex-components-otp.mjs +7 -7
  122. package/fesm2022/acorex-components-otp.mjs.map +1 -1
  123. package/fesm2022/acorex-components-page.mjs +10 -10
  124. package/fesm2022/acorex-components-page.mjs.map +1 -1
  125. package/fesm2022/acorex-components-paint.mjs +27 -27
  126. package/fesm2022/acorex-components-paint.mjs.map +1 -1
  127. package/fesm2022/acorex-components-password-box.mjs +13 -16
  128. package/fesm2022/acorex-components-password-box.mjs.map +1 -1
  129. package/fesm2022/acorex-components-pdf-reader.mjs +7 -7
  130. package/fesm2022/acorex-components-pdf-reader.mjs.map +1 -1
  131. package/fesm2022/acorex-components-phone-box.mjs +7 -7
  132. package/fesm2022/acorex-components-phone-box.mjs.map +1 -1
  133. package/fesm2022/acorex-components-picker.mjs +13 -13
  134. package/fesm2022/acorex-components-picker.mjs.map +1 -1
  135. package/fesm2022/acorex-components-popover.mjs +7 -7
  136. package/fesm2022/acorex-components-popover.mjs.map +1 -1
  137. package/fesm2022/acorex-components-popup.mjs +10 -10
  138. package/fesm2022/acorex-components-popup.mjs.map +1 -1
  139. package/fesm2022/acorex-components-progress-bar.mjs +7 -7
  140. package/fesm2022/acorex-components-progress-bar.mjs.map +1 -1
  141. package/fesm2022/acorex-components-qrcode.mjs +7 -7
  142. package/fesm2022/acorex-components-qrcode.mjs.map +1 -1
  143. package/fesm2022/acorex-components-query-builder.mjs +7 -7
  144. package/fesm2022/acorex-components-query-builder.mjs.map +1 -1
  145. package/fesm2022/acorex-components-radio.mjs +7 -7
  146. package/fesm2022/acorex-components-radio.mjs.map +1 -1
  147. package/fesm2022/acorex-components-rail-navigation.mjs +13 -13
  148. package/fesm2022/acorex-components-rail-navigation.mjs.map +1 -1
  149. package/fesm2022/acorex-components-range-slider.mjs +11 -7
  150. package/fesm2022/acorex-components-range-slider.mjs.map +1 -1
  151. package/fesm2022/acorex-components-rate-picker.mjs +7 -7
  152. package/fesm2022/acorex-components-rate-picker.mjs.map +1 -1
  153. package/fesm2022/acorex-components-rest-api-generator.mjs +22 -22
  154. package/fesm2022/acorex-components-rest-api-generator.mjs.map +1 -1
  155. package/fesm2022/acorex-components-result.mjs +7 -7
  156. package/fesm2022/acorex-components-result.mjs.map +1 -1
  157. package/fesm2022/acorex-components-routing-progress.mjs +7 -7
  158. package/fesm2022/acorex-components-routing-progress.mjs.map +1 -1
  159. package/fesm2022/acorex-components-rrule.mjs +6 -6
  160. package/fesm2022/acorex-components-rrule.mjs.map +1 -1
  161. package/fesm2022/acorex-components-scheduler.mjs +31 -31
  162. package/fesm2022/acorex-components-scheduler.mjs.map +1 -1
  163. package/fesm2022/acorex-components-scss.mjs +4 -4
  164. package/fesm2022/acorex-components-scss.mjs.map +1 -1
  165. package/fesm2022/acorex-components-search-box.mjs +7 -7
  166. package/fesm2022/acorex-components-search-box.mjs.map +1 -1
  167. package/fesm2022/acorex-components-select-box.mjs +7 -7
  168. package/fesm2022/acorex-components-select-box.mjs.map +1 -1
  169. package/fesm2022/acorex-components-selection-list-2.mjs +8 -8
  170. package/fesm2022/acorex-components-selection-list-2.mjs.map +1 -1
  171. package/fesm2022/acorex-components-selection-list.mjs +7 -7
  172. package/fesm2022/acorex-components-selection-list.mjs.map +1 -1
  173. package/fesm2022/acorex-components-side-menu.mjs +13 -13
  174. package/fesm2022/acorex-components-side-menu.mjs.map +1 -1
  175. package/fesm2022/acorex-components-skeleton.mjs +7 -7
  176. package/fesm2022/acorex-components-skeleton.mjs.map +1 -1
  177. package/fesm2022/acorex-components-slider.mjs +7 -7
  178. package/fesm2022/acorex-components-slider.mjs.map +1 -1
  179. package/fesm2022/acorex-components-sliding-item.mjs +15 -15
  180. package/fesm2022/acorex-components-sliding-item.mjs.map +1 -1
  181. package/fesm2022/acorex-components-step-wizard.mjs +13 -13
  182. package/fesm2022/acorex-components-step-wizard.mjs.map +1 -1
  183. package/fesm2022/acorex-components-switch.mjs +10 -10
  184. package/fesm2022/acorex-components-switch.mjs.map +1 -1
  185. package/fesm2022/acorex-components-tabs.mjs +13 -13
  186. package/fesm2022/acorex-components-tabs.mjs.map +1 -1
  187. package/fesm2022/acorex-components-tag-box.mjs +23 -7
  188. package/fesm2022/acorex-components-tag-box.mjs.map +1 -1
  189. package/fesm2022/acorex-components-tag.mjs +7 -7
  190. package/fesm2022/acorex-components-tag.mjs.map +1 -1
  191. package/fesm2022/acorex-components-text-area.mjs +8 -9
  192. package/fesm2022/acorex-components-text-area.mjs.map +1 -1
  193. package/fesm2022/acorex-components-text-box.mjs +10 -10
  194. package/fesm2022/acorex-components-text-box.mjs.map +1 -1
  195. package/fesm2022/acorex-components-time-duration.mjs +7 -7
  196. package/fesm2022/acorex-components-time-duration.mjs.map +1 -1
  197. package/fesm2022/acorex-components-time-line.mjs +13 -10
  198. package/fesm2022/acorex-components-time-line.mjs.map +1 -1
  199. package/fesm2022/acorex-components-toast.mjs +57 -12
  200. package/fesm2022/acorex-components-toast.mjs.map +1 -1
  201. package/fesm2022/acorex-components-toolbar.mjs +7 -7
  202. package/fesm2022/acorex-components-toolbar.mjs.map +1 -1
  203. package/fesm2022/acorex-components-tooltip.mjs +10 -10
  204. package/fesm2022/acorex-components-tooltip.mjs.map +1 -1
  205. package/fesm2022/acorex-components-tree-view.mjs +10 -10
  206. package/fesm2022/acorex-components-tree-view.mjs.map +1 -1
  207. package/fesm2022/acorex-components-uploader.mjs +252 -56
  208. package/fesm2022/acorex-components-uploader.mjs.map +1 -1
  209. package/fesm2022/acorex-components-video-player.mjs +7 -7
  210. package/fesm2022/acorex-components-video-player.mjs.map +1 -1
  211. package/fesm2022/acorex-components-wysiwyg.mjs +31 -31
  212. package/fesm2022/acorex-components-wysiwyg.mjs.map +1 -1
  213. package/form/index.d.ts +13 -13
  214. package/image/index.d.ts +4 -4
  215. package/image-editor/index.d.ts +10 -4
  216. package/menu/index.d.ts +6 -6
  217. package/modal/index.d.ts +1 -0
  218. package/number-box-2/index.d.ts +1 -1
  219. package/package.json +40 -16
  220. package/paint/index.d.ts +5 -5
  221. package/password-box/index.d.ts +2 -5
  222. package/phone-box/index.d.ts +7 -8
  223. package/popover/index.d.ts +1 -1
  224. package/popup/index.d.ts +2 -2
  225. package/qrcode/index.d.ts +7 -7
  226. package/query-builder/index.d.ts +1 -1
  227. package/range-slider/index.d.ts +13 -13
  228. package/rate-picker/index.d.ts +4 -4
  229. package/rest-api-generator/index.d.ts +1 -1
  230. package/result/index.d.ts +2 -2
  231. package/search-box/index.d.ts +2 -2
  232. package/select-box/index.d.ts +2 -2
  233. package/selection-list-2/index.d.ts +3 -3
  234. package/side-menu/index.d.ts +9 -9
  235. package/sliding-item/index.d.ts +4 -5
  236. package/tag-box/index.d.ts +16 -0
  237. package/text-area/index.d.ts +1 -2
  238. package/time-line/index.d.ts +3 -0
  239. package/toast/index.d.ts +45 -1
  240. package/uploader/index.d.ts +215 -5
  241. package/fesm2022/acorex-components-modal-modal-content.component-CaZfLUuL.mjs.map +0 -1
@@ -0,0 +1,591 @@
1
+ import { MXValueComponent, AXValuableComponent, AXComponent } from '@acorex/cdk/common';
2
+ import { AXPlatform } from '@acorex/core/platform';
3
+ import { isPlatformBrowser, CommonModule } from '@angular/common';
4
+ import * as i0 from '@angular/core';
5
+ import { input, output, viewChild, inject, PLATFORM_ID, DestroyRef, signal, computed, afterNextRender, effect, forwardRef, Component, NgModule } from '@angular/core';
6
+ import { NG_VALUE_ACCESSOR } from '@angular/forms';
7
+
8
+ class AXCodeEditorComponent extends MXValueComponent {
9
+ constructor() {
10
+ super();
11
+ // Inputs (signals)
12
+ // value = input<string>('');
13
+ /** Active language mode. Default: 'javascript'. */
14
+ this.language = input('javascript', ...(ngDevMode ? [{ debugName: "language" }] : []));
15
+ /** When true, the editor becomes readonly (non-editable). */
16
+ this.readOnly = input(false, ...(ngDevMode ? [{ debugName: "readOnly" }] : []));
17
+ /** Placeholder text shown when the document is empty. */
18
+ this.placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : []));
19
+ /** Toggle rendering of line numbers in the gutter. */
20
+ this.lineNumbers = input(true, ...(ngDevMode ? [{ debugName: "lineNumbers" }] : []));
21
+ /** Soft-wrap long lines when true. */
22
+ this.lineWrapping = input(false, ...(ngDevMode ? [{ debugName: "lineWrapping" }] : []));
23
+ /** Tab size (spaces per indent level). */
24
+ this.tabSize = input(2, ...(ngDevMode ? [{ debugName: "tabSize" }] : []));
25
+ /** When true, the Tab key indents instead of moving focus. */
26
+ this.indentWithTab = input(true, ...(ngDevMode ? [{ debugName: "indentWithTab" }] : []));
27
+ /** Fixed height for the editor (e.g., '320px'). */
28
+ this.height = input(null, ...(ngDevMode ? [{ debugName: "height" }] : []));
29
+ /** Minimum height for the editor. */
30
+ this.minHeight = input(null, ...(ngDevMode ? [{ debugName: "minHeight" }] : []));
31
+ /** Maximum height for the editor. */
32
+ this.maxHeight = input(null, ...(ngDevMode ? [{ debugName: "maxHeight" }] : []));
33
+ // Theme follows platform theme mode; no input
34
+ /** Additional CodeMirror extensions to apply. Reconfigures at runtime. */
35
+ this.extensions = input([], ...(ngDevMode ? [{ debugName: "extensions" }] : []));
36
+ /** ARIA label for accessibility. */
37
+ this.ariaLabel = input(null, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : []));
38
+ /** Focus the editor after first render. */
39
+ this.focusOnReady = input(false, ...(ngDevMode ? [{ debugName: "focusOnReady" }] : []));
40
+ /** If true, format the document via Prettier before emitting save. */
41
+ this.formatOnSave = input(false, ...(ngDevMode ? [{ debugName: "formatOnSave" }] : []));
42
+ /**
43
+ * Custom autocompletion options: either a static array of Completion items
44
+ * or a CodeMirror CompletionSource function.
45
+ */
46
+ this.customCompletions = input(null, ...(ngDevMode ? [{ debugName: "customCompletions" }] : []));
47
+ // Outputs (signals)
48
+ // valueChange = output<string>();
49
+ /** Emits when the editor is fully initialized and ready. */
50
+ this.ready = output();
51
+ /** Emits when the user triggers save (Ctrl/Cmd+S). Payload is the current text. */
52
+ this.save = output();
53
+ // View container
54
+ this.host = viewChild('host', ...(ngDevMode ? [{ debugName: "host" }] : []));
55
+ // Runtime state
56
+ this.platformId = inject(PLATFORM_ID);
57
+ this.destroyRef = inject(DestroyRef);
58
+ this.platformService = inject(AXPlatform);
59
+ this.editorViewSig = signal(null, ...(ngDevMode ? [{ debugName: "editorViewSig" }] : []));
60
+ // Compartments to reconfigure editor without recreating it
61
+ this.languageCompartment = null;
62
+ this.readOnlyCompartment = null;
63
+ this.themeCompartment = null;
64
+ this.placeholderCompartment = null;
65
+ this.wrappingCompartment = null;
66
+ this.keymapExtrasCompartment = null;
67
+ this.tabSizeCompartment = null;
68
+ this.lineNumbersCompartment = null;
69
+ // Cached CodeMirror modules after initialization
70
+ this.cm = { view: null, state: null, language: null, autocomplete: null, commands: null, search: null, lint: null };
71
+ this.isBrowser = computed(() => isPlatformBrowser(this.platformId), ...(ngDevMode ? [{ debugName: "isBrowser" }] : []));
72
+ afterNextRender(() => {
73
+ if (!this.isBrowser())
74
+ return;
75
+ this.initializeEditor();
76
+ });
77
+ // Keep model in sync when external value changes
78
+ effect(() => {
79
+ const view = this.editorViewSig();
80
+ if (!view)
81
+ return;
82
+ const newDoc = this.value ?? '';
83
+ const current = view.state.doc.toString();
84
+ if (newDoc !== current) {
85
+ view.dispatch({
86
+ changes: { from: 0, to: view.state.doc.length, insert: newDoc },
87
+ });
88
+ }
89
+ });
90
+ // React to dynamic configuration changes
91
+ effect(() => {
92
+ const view = this.editorViewSig();
93
+ if (!view || !this.languageCompartment)
94
+ return;
95
+ const lang = this.language();
96
+ this.resolveLanguageExtension(lang).then((ext) => {
97
+ if (!view || !this.languageCompartment)
98
+ return;
99
+ view.dispatch({ effects: this.languageCompartment.reconfigure(ext) });
100
+ });
101
+ });
102
+ effect(() => {
103
+ const view = this.editorViewSig();
104
+ if (!view || !this.readOnlyCompartment)
105
+ return;
106
+ const editable = !this.readOnly();
107
+ import('@codemirror/view').then(({ EditorView }) => {
108
+ if (!view || !this.readOnlyCompartment)
109
+ return;
110
+ view.dispatch({ effects: this.readOnlyCompartment.reconfigure(EditorView.editable.of(editable)) });
111
+ });
112
+ });
113
+ effect(() => {
114
+ const view = this.editorViewSig();
115
+ // Establish reactive dependency on platform theme
116
+ // Create a reactive dependency to platform theme
117
+ void this.platformService.themeMode();
118
+ if (!view || !this.themeCompartment)
119
+ return;
120
+ this.resolveThemeExtension().then((themeExt) => {
121
+ if (!view || !this.themeCompartment)
122
+ return;
123
+ view.dispatch({ effects: this.themeCompartment.reconfigure(themeExt) });
124
+ });
125
+ });
126
+ effect(() => {
127
+ this.placeholder();
128
+ const view = this.editorViewSig();
129
+ if (!view || !this.placeholderCompartment)
130
+ return;
131
+ import('@codemirror/view').then(({ placeholder }) => {
132
+ if (!view || !this.placeholderCompartment)
133
+ return;
134
+ view.dispatch({ effects: this.placeholderCompartment.reconfigure(placeholder(this.placeholder() ?? '')) });
135
+ });
136
+ });
137
+ effect(() => {
138
+ const view = this.editorViewSig();
139
+ if (!view || !this.wrappingCompartment)
140
+ return;
141
+ const EditorView = this.cm.view?.EditorView;
142
+ if (!EditorView)
143
+ return;
144
+ const nextExt = this.lineWrapping() ? EditorView.lineWrapping : [];
145
+ this.reconfigure(this.wrappingCompartment, nextExt);
146
+ });
147
+ effect(() => {
148
+ const view = this.editorViewSig();
149
+ if (!view || !this.tabSizeCompartment)
150
+ return;
151
+ const EditorState = this.cm.state?.EditorState;
152
+ if (!EditorState)
153
+ return;
154
+ this.reconfigure(this.tabSizeCompartment, EditorState.tabSize.of(this.tabSize() ?? 2));
155
+ });
156
+ effect(() => {
157
+ const view = this.editorViewSig();
158
+ if (!view || !this.keymapExtrasCompartment)
159
+ return;
160
+ const keymap = this.cm.view?.keymap;
161
+ const commands = this.cm.commands;
162
+ if (!keymap || !commands)
163
+ return;
164
+ this.reconfigure(this.keymapExtrasCompartment, keymap.of(this.indentWithTab() ? [commands.indentWithTab] : []));
165
+ });
166
+ effect(() => {
167
+ const view = this.editorViewSig();
168
+ if (!view || !this.lineNumbersCompartment)
169
+ return;
170
+ const lineNumbers = this.cm.view?.lineNumbers;
171
+ if (!lineNumbers)
172
+ return;
173
+ this.reconfigure(this.lineNumbersCompartment, this.lineNumbers() ? lineNumbers() : []);
174
+ });
175
+ }
176
+ async initializeEditor() {
177
+ const hostEl = this.host()?.nativeElement;
178
+ if (!hostEl)
179
+ return;
180
+ await this.loadCodeMirrorModules();
181
+ this.createCompartments();
182
+ const keymaps = this.buildKeymaps();
183
+ const viewMod = this.cm.view;
184
+ const stateMod = this.cm.state;
185
+ const languageMod = this.cm.language;
186
+ const autoMod = this.cm.autocomplete;
187
+ const commandsMod = this.cm.commands;
188
+ const searchMod = this.cm.search;
189
+ const lintMod = this.cm.lint;
190
+ if (!viewMod || !stateMod || !languageMod || !autoMod || !commandsMod || !searchMod || !lintMod)
191
+ return;
192
+ const languageExt = await this.resolveLanguageExtension(this.language());
193
+ const themeExt = await this.resolveThemeExtension();
194
+ const placeholderExt = viewMod.placeholder(this.placeholder() ?? '');
195
+ const editableExt = viewMod.EditorView.editable.of(!this.readOnly());
196
+ const wrappingExt = this.lineWrapping() ? viewMod.EditorView.lineWrapping : [];
197
+ const tabSizeExt = stateMod.EditorState.tabSize.of(this.tabSize() ?? 2);
198
+ const lineNumbersExt = this.lineNumbers() ? viewMod.lineNumbers() : [];
199
+ const autoCompleteExt = autoMod.autocompletion({
200
+ override: this.buildCustomCompletionSources(),
201
+ });
202
+ const baseExtensions = [
203
+ this.lineNumbersCompartment.of(lineNumbersExt),
204
+ viewMod.highlightActiveLine(),
205
+ viewMod.highlightActiveLineGutter(),
206
+ viewMod.drawSelection(),
207
+ viewMod.dropCursor(),
208
+ viewMod.rectangularSelection(),
209
+ viewMod.crosshairCursor(),
210
+ viewMod.highlightSpecialChars(),
211
+ languageMod.syntaxHighlighting(languageMod.defaultHighlightStyle, { fallback: true }),
212
+ languageMod.bracketMatching(),
213
+ languageMod.foldGutter(),
214
+ commandsMod.history(),
215
+ searchMod.highlightSelectionMatches(),
216
+ viewMod.keymap.of(keymaps),
217
+ autoCompleteExt,
218
+ this.languageCompartment.of(languageExt),
219
+ this.readOnlyCompartment.of(editableExt),
220
+ this.themeCompartment.of(themeExt),
221
+ this.placeholderCompartment.of(placeholderExt),
222
+ this.wrappingCompartment.of(wrappingExt),
223
+ this.tabSizeCompartment.of(tabSizeExt),
224
+ this.keymapExtrasCompartment.of(viewMod.keymap.of(this.indentWithTab() ? [commandsMod.indentWithTab] : [])),
225
+ ...this.extensions(),
226
+ ];
227
+ const updateListener = viewMod.EditorView.updateListener.of((vu) => {
228
+ if (vu.docChanged) {
229
+ const text = vu.state.doc.toString();
230
+ // this.writeValue(text);
231
+ this.value = text;
232
+ }
233
+ });
234
+ const state = stateMod.EditorState.create({
235
+ doc: this.value ?? '',
236
+ extensions: [...baseExtensions, updateListener],
237
+ });
238
+ const view = new viewMod.EditorView({ state, parent: hostEl });
239
+ // Update listener for external changes (selection, viewport, etc.) if needed later
240
+ view.dispatch({ effects: [] });
241
+ this.editorViewSig.set(view);
242
+ this.destroyRef.onDestroy(() => {
243
+ view.destroy();
244
+ this.editorViewSig.set(null);
245
+ });
246
+ if (this.focusOnReady()) {
247
+ view.focus();
248
+ }
249
+ this.ready.emit();
250
+ }
251
+ reconfigure(comp, ext) {
252
+ const view = this.editorViewSig();
253
+ if (!view || !comp)
254
+ return;
255
+ view.dispatch({ effects: comp.reconfigure(ext) });
256
+ }
257
+ /**
258
+ * Handles Ctrl/Cmd+S on the host. If formatOnSave is enabled, attempts
259
+ * to format the document first, then emits the saved text.
260
+ */
261
+ async onSaveShortcut(event) {
262
+ event.preventDefault();
263
+ const view = this.editorViewSig();
264
+ const current = view?.state.doc.toString() ?? this.value ?? '';
265
+ const payload = current;
266
+ if (this.formatOnSave()) {
267
+ await this.format(true);
268
+ }
269
+ this.save.emit(payload);
270
+ }
271
+ async loadCodeMirrorModules() {
272
+ const [viewMod, stateMod, langMod, autoMod, cmdMod, searchMod, lintMod] = await Promise.all([
273
+ import('@codemirror/view'),
274
+ import('@codemirror/state'),
275
+ import('@codemirror/language'),
276
+ import('@codemirror/autocomplete'),
277
+ import('@codemirror/commands'),
278
+ import('@codemirror/search'),
279
+ import('@codemirror/lint'),
280
+ ]);
281
+ this.cm.view = viewMod;
282
+ this.cm.state = stateMod;
283
+ this.cm.language = langMod;
284
+ this.cm.autocomplete = autoMod;
285
+ this.cm.commands = cmdMod;
286
+ this.cm.search = searchMod;
287
+ this.cm.lint = lintMod;
288
+ }
289
+ createCompartments() {
290
+ const stateMod = this.cm.state;
291
+ if (!stateMod)
292
+ return;
293
+ this.languageCompartment = new stateMod.Compartment();
294
+ this.readOnlyCompartment = new stateMod.Compartment();
295
+ this.themeCompartment = new stateMod.Compartment();
296
+ this.placeholderCompartment = new stateMod.Compartment();
297
+ this.wrappingCompartment = new stateMod.Compartment();
298
+ this.tabSizeCompartment = new stateMod.Compartment();
299
+ this.keymapExtrasCompartment = new stateMod.Compartment();
300
+ this.lineNumbersCompartment = new stateMod.Compartment();
301
+ }
302
+ buildKeymaps() {
303
+ const cmdMod = this.cm.commands;
304
+ const searchMod = this.cm.search;
305
+ const autoMod = this.cm.autocomplete;
306
+ const lintMod = this.cm.lint;
307
+ if (!cmdMod || !searchMod || !autoMod || !lintMod)
308
+ return [];
309
+ return [
310
+ ...cmdMod.defaultKeymap,
311
+ ...cmdMod.historyKeymap,
312
+ ...searchMod.searchKeymap,
313
+ ...autoMod.completionKeymap,
314
+ ...lintMod.lintKeymap,
315
+ ];
316
+ }
317
+ // Attempts to format code using Prettier (browser-only). Returns formatted text or null on failure/unsupported.
318
+ async tryFormatWithPrettier(text, lang) {
319
+ if (!this.isBrowser())
320
+ return null;
321
+ try {
322
+ const prettier = await import('prettier/standalone');
323
+ let parser = null;
324
+ const plugins = [];
325
+ switch (lang) {
326
+ case 'javascript':
327
+ case 'js': {
328
+ const [babel, estree] = await Promise.all([
329
+ import('prettier/plugins/babel'),
330
+ import('prettier/plugins/estree'),
331
+ ]);
332
+ plugins.push(babel, estree);
333
+ parser = 'babel';
334
+ break;
335
+ }
336
+ case 'typescript':
337
+ case 'ts': {
338
+ const [typescript, estree] = await Promise.all([
339
+ import('prettier/plugins/typescript'),
340
+ import('prettier/plugins/estree'),
341
+ ]);
342
+ plugins.push(typescript, estree);
343
+ parser = 'typescript';
344
+ break;
345
+ }
346
+ case 'json': {
347
+ const [babel, estree] = await Promise.all([
348
+ import('prettier/plugins/babel'),
349
+ import('prettier/plugins/estree'),
350
+ ]);
351
+ plugins.push(babel, estree);
352
+ parser = 'json';
353
+ break;
354
+ }
355
+ case 'html': {
356
+ const html = await import('prettier/plugins/html');
357
+ plugins.push(html);
358
+ parser = 'html';
359
+ break;
360
+ }
361
+ case 'css': {
362
+ const postcss = await import('prettier/plugins/postcss');
363
+ plugins.push(postcss);
364
+ parser = 'css';
365
+ break;
366
+ }
367
+ case 'markdown': {
368
+ const markdown = await import('prettier/plugins/markdown');
369
+ plugins.push(markdown);
370
+ parser = 'markdown';
371
+ break;
372
+ }
373
+ default:
374
+ return null;
375
+ }
376
+ if (!parser)
377
+ return null;
378
+ const formatted = await prettier.format(text, {
379
+ parser,
380
+ plugins,
381
+ });
382
+ return formatted;
383
+ }
384
+ catch {
385
+ return null;
386
+ }
387
+ }
388
+ async resolveLanguageExtension(lang) {
389
+ switch (lang) {
390
+ case 'javascript':
391
+ case 'js': {
392
+ const m = await import('@codemirror/lang-javascript');
393
+ return m.javascript();
394
+ }
395
+ case 'typescript':
396
+ case 'ts': {
397
+ const m = await import('@codemirror/lang-javascript');
398
+ return m.javascript({ typescript: true });
399
+ }
400
+ case 'json': {
401
+ const m = await import('@codemirror/lang-json');
402
+ return m.json();
403
+ }
404
+ case 'html': {
405
+ const m = await import('@codemirror/lang-html');
406
+ return m.html();
407
+ }
408
+ case 'css': {
409
+ const m = await import('@codemirror/lang-css');
410
+ return m.css();
411
+ }
412
+ case 'scss':
413
+ case 'sass': {
414
+ const m = await import('@codemirror/lang-sass');
415
+ return m.sass();
416
+ }
417
+ case 'sql': {
418
+ const m = await import('@codemirror/lang-sql');
419
+ return m.sql();
420
+ }
421
+ case 'xml': {
422
+ const m = await import('@codemirror/lang-xml');
423
+ return m.xml();
424
+ }
425
+ case 'markdown': {
426
+ const m = await import('@codemirror/lang-markdown');
427
+ return m.markdown();
428
+ }
429
+ default:
430
+ return [];
431
+ }
432
+ }
433
+ async resolveThemeExtension() {
434
+ const { EditorView } = await import('@codemirror/view');
435
+ const darkMode = this.platformService.themeMode() === 'dark';
436
+ // const surfaceVar = 'rgb(var(--ax-sys-color-surface)) !important';
437
+ if (darkMode) {
438
+ try {
439
+ const { oneDark } = await import('@codemirror/theme-one-dark');
440
+ return [
441
+ oneDark,
442
+ EditorView.theme({
443
+ '&': { backgroundColor: 'transparent !important' },
444
+ '.cm-gutters': {},
445
+ }, { dark: true }),
446
+ ];
447
+ }
448
+ catch {
449
+ return EditorView.theme({
450
+ '&': { backgroundColor: 'transparent !important' },
451
+ '.cm-gutters': {},
452
+ }, { dark: true });
453
+ }
454
+ }
455
+ return EditorView.theme({
456
+ '&': { backgroundColor: 'transparent !important' },
457
+ '.cm-gutters': {},
458
+ }, { dark: false });
459
+ }
460
+ buildCustomCompletionSources() {
461
+ const provided = this.customCompletions();
462
+ if (!provided)
463
+ return undefined;
464
+ if (typeof provided === 'function') {
465
+ return [provided];
466
+ }
467
+ // Treat array as a static completion list
468
+ const staticSource = (context) => {
469
+ const from = context.pos;
470
+ return { from, options: provided };
471
+ };
472
+ return [staticSource];
473
+ }
474
+ // Public API
475
+ /** Programmatically focus the editor. */
476
+ focus() {
477
+ const view = this.editorViewSig();
478
+ if (view)
479
+ view.focus();
480
+ }
481
+ /** Select all text in the current document. */
482
+ selectAll() {
483
+ const view = this.editorViewSig();
484
+ if (!view)
485
+ return;
486
+ const length = view.state.doc.length;
487
+ view.dispatch({ selection: { anchor: 0, head: length } });
488
+ }
489
+ // Formats the current document with Prettier (if available for the active language).
490
+ // Returns the formatted text or null if unchanged/unsupported.
491
+ async format(affect = true) {
492
+ const view = this.editorViewSig();
493
+ if (!view)
494
+ return null;
495
+ const source = view.state.doc.toString();
496
+ if (!source)
497
+ return null;
498
+ const formatted = await this.tryFormatWithPrettier(source, this.language());
499
+ if (!formatted || formatted === source)
500
+ return null;
501
+ if (affect) {
502
+ view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert: formatted } });
503
+ }
504
+ return formatted;
505
+ }
506
+ /** Returns the total number of characters in the current document. */
507
+ getTotalCharacters() {
508
+ const view = this.editorViewSig();
509
+ if (view)
510
+ return view.state.doc.length ?? 0;
511
+ const text = this.value ?? '';
512
+ return text.length;
513
+ }
514
+ /** Returns the total number of lines in the current document. */
515
+ getTotalLines() {
516
+ const view = this.editorViewSig();
517
+ if (view) {
518
+ const doc = view.state.doc;
519
+ return typeof doc?.lines === 'number' ? doc.lines : doc.toString().split(/\r?\n/).length;
520
+ }
521
+ const text = this.value ?? '';
522
+ return text ? text.split(/\r?\n/).length : 1;
523
+ }
524
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AXCodeEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
525
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.2.4", type: AXCodeEditorComponent, isStandalone: true, selector: "ax-code-editor", inputs: { language: { classPropertyName: "language", publicName: "language", isSignal: true, isRequired: false, transformFunction: null }, readOnly: { classPropertyName: "readOnly", publicName: "readOnly", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, lineNumbers: { classPropertyName: "lineNumbers", publicName: "lineNumbers", isSignal: true, isRequired: false, transformFunction: null }, lineWrapping: { classPropertyName: "lineWrapping", publicName: "lineWrapping", isSignal: true, isRequired: false, transformFunction: null }, tabSize: { classPropertyName: "tabSize", publicName: "tabSize", isSignal: true, isRequired: false, transformFunction: null }, indentWithTab: { classPropertyName: "indentWithTab", publicName: "indentWithTab", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, extensions: { classPropertyName: "extensions", publicName: "extensions", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, focusOnReady: { classPropertyName: "focusOnReady", publicName: "focusOnReady", isSignal: true, isRequired: false, transformFunction: null }, formatOnSave: { classPropertyName: "formatOnSave", publicName: "formatOnSave", isSignal: true, isRequired: false, transformFunction: null }, customCompletions: { classPropertyName: "customCompletions", publicName: "customCompletions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ready: "ready", save: "save" }, host: { listeners: { "keydown.control.s": "onSaveShortcut($event)" }, classAttribute: "ax-code-editor block" }, providers: [
526
+ { provide: AXValuableComponent, useExisting: AXCodeEditorComponent },
527
+ {
528
+ provide: NG_VALUE_ACCESSOR,
529
+ useExisting: forwardRef(() => AXCodeEditorComponent),
530
+ multi: true,
531
+ },
532
+ { provide: AXComponent, useExisting: AXCodeEditorComponent },
533
+ ], viewQueries: [{ propertyName: "host", first: true, predicate: ["host"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: `
534
+ <div
535
+ #host
536
+ class="cm-editor"
537
+ [attr.aria-label]="ariaLabel() ?? null"
538
+ [attr.aria-readonly]="readOnly() ? 'true' : 'false'"
539
+ [attr.data-placeholder]="placeholder() ?? null"
540
+ [style.height]="height() ?? null"
541
+ [style.minHeight]="minHeight() ?? null"
542
+ [style.maxHeight]="maxHeight() ?? null"
543
+ ></div>
544
+ `, isInline: true, styles: [":host{display:block;width:100%;transition:none}.cm-editor{width:100%;max-width:100%;box-sizing:border-box}.cm-editor.cm-focused{outline:none}\n"] }); }
545
+ }
546
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AXCodeEditorComponent, decorators: [{
547
+ type: Component,
548
+ args: [{ selector: 'ax-code-editor', host: {
549
+ '(keydown.control.s)': 'onSaveShortcut($event)',
550
+ class: 'ax-code-editor block',
551
+ }, providers: [
552
+ { provide: AXValuableComponent, useExisting: AXCodeEditorComponent },
553
+ {
554
+ provide: NG_VALUE_ACCESSOR,
555
+ useExisting: forwardRef(() => AXCodeEditorComponent),
556
+ multi: true,
557
+ },
558
+ { provide: AXComponent, useExisting: AXCodeEditorComponent },
559
+ ], template: `
560
+ <div
561
+ #host
562
+ class="cm-editor"
563
+ [attr.aria-label]="ariaLabel() ?? null"
564
+ [attr.aria-readonly]="readOnly() ? 'true' : 'false'"
565
+ [attr.data-placeholder]="placeholder() ?? null"
566
+ [style.height]="height() ?? null"
567
+ [style.minHeight]="minHeight() ?? null"
568
+ [style.maxHeight]="maxHeight() ?? null"
569
+ ></div>
570
+ `, styles: [":host{display:block;width:100%;transition:none}.cm-editor{width:100%;max-width:100%;box-sizing:border-box}.cm-editor.cm-focused{outline:none}\n"] }]
571
+ }], ctorParameters: () => [] });
572
+
573
+ class AXCodeEditorModule {
574
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AXCodeEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
575
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.2.4", ngImport: i0, type: AXCodeEditorModule, imports: [CommonModule, AXCodeEditorComponent], exports: [AXCodeEditorComponent] }); }
576
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AXCodeEditorModule, imports: [CommonModule] }); }
577
+ }
578
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: AXCodeEditorModule, decorators: [{
579
+ type: NgModule,
580
+ args: [{
581
+ imports: [CommonModule, AXCodeEditorComponent],
582
+ exports: [AXCodeEditorComponent],
583
+ }]
584
+ }] });
585
+
586
+ /**
587
+ * Generated bundle index. Do not edit.
588
+ */
589
+
590
+ export { AXCodeEditorComponent, AXCodeEditorModule };
591
+ //# sourceMappingURL=acorex-components-code-editor.mjs.map