@masterteam/components 0.0.263 → 0.0.265

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 (755) hide show
  1. package/.angular/cache/21.2.7/@masterteam/components/.tsbuildinfo +1 -0
  2. package/.angular/cache/21.2.7/@masterteam/components/angular-compiler.db +0 -0
  3. package/.angular/cache/21.2.7/@masterteam/components/angular-compiler.db-lock +0 -0
  4. package/.angular/cache/21.2.7/ng-packagr/045efd332b9db1d21b3a595a37ae03ebb11b457a5dc6e2d1cbc561b694e17f1a +1 -0
  5. package/.angular/cache/21.2.7/ng-packagr/0727b170af3d53236c0cafe16ea670d089e48d4c5c525b1dbcc1c684bb6e99c7 +1 -0
  6. package/.angular/cache/21.2.7/ng-packagr/0873bc9048494ebc33fe0a7b856324c7c4ca681b0dcaa87338e3290186906d49 +1 -0
  7. package/.angular/cache/21.2.7/ng-packagr/1010cd8fc996d0c2df519ed60085f4b1f38ccfc873900055bc75fc20a3c26bab +1 -0
  8. package/.angular/cache/21.2.7/ng-packagr/12379a8ab7254ad3df2635823a358cfce32e6d0f390be68596cc97e02307e6c4 +1 -0
  9. package/.angular/cache/21.2.7/ng-packagr/1239e7a937657b62f858d17d47738ed30facbdaa91032511e29ed148b748400b +1 -0
  10. package/.angular/cache/21.2.7/ng-packagr/133b9ecf47ba424244902da90d77cd3f135b85f95c01b16de7b2247f57518f01 +1 -0
  11. package/.angular/cache/21.2.7/ng-packagr/175d45dc6da51834e7fe937c09d23dbf28d2a823f838ef5271fd3e148776d6ec +1 -0
  12. package/.angular/cache/21.2.7/ng-packagr/19d99ad4d927324b03cdbef34331ba2c58bd580f1f0ca591cb5f8dbf436c913c +1 -0
  13. package/.angular/cache/21.2.7/ng-packagr/1a86918763f95c1c2b9fa781bda1ceedf15aead87f0e11ea1324318af43a897a +1 -0
  14. package/.angular/cache/21.2.7/ng-packagr/1f08100dbc280be7da64c809315376eb7d0cfd074916a6042f609f03f4276a8e +1 -0
  15. package/.angular/cache/21.2.7/ng-packagr/2224877a7e762b86541428e4c40d61f54f505867c305769ae42e67e4aa81bd93 +1 -0
  16. package/.angular/cache/21.2.7/ng-packagr/24957fb7ec060692ebcf1471e1bdce39f40aed938959e580048ade58015762d2 +1 -0
  17. package/.angular/cache/21.2.7/ng-packagr/295fcdc1c4462e7feae96a24255369508a559faaecc4676267749a7ce23e4b6d +1 -0
  18. package/.angular/cache/21.2.7/ng-packagr/2b37e2f2d6564d10bad1fd0ecc16453962fd855cd1e36ad7aa24baf3e4f2e8b3 +1 -0
  19. package/.angular/cache/21.2.7/ng-packagr/2c20f0929771e857b570ba2beffe91f598f299ce26d4825fe4315bfe5a3dd40a +1 -0
  20. package/.angular/cache/21.2.7/ng-packagr/37dea2e5798cad4a21d66292eeed5be26d04500d9a1534332ad42ce664a058c2 +1 -0
  21. package/.angular/cache/21.2.7/ng-packagr/3b6239b640fcb5ea7067a2655a2901d32f55372812b586aa008e77c59e8f2090 +1 -0
  22. package/.angular/cache/21.2.7/ng-packagr/3beb1b4dfe75d1e6749cf91f05d51ba4eece939f5c15f6f33ed587bfd198f0a3 +1 -0
  23. package/.angular/cache/21.2.7/ng-packagr/3f161e6c2ead4519d0663dd79199dafceb2cc22da7ce92a72b809b93bfce0bb0 +1 -0
  24. package/.angular/cache/21.2.7/ng-packagr/43551862d17cd02626e18b30243390081a6247784485660048b060a3d4ab7fa7 +1 -0
  25. package/.angular/cache/21.2.7/ng-packagr/47aedf032519b41d96866fcf8fbd4f1dfd29f9e9a534b39dee0e44d402227d2d +1 -0
  26. package/.angular/cache/21.2.7/ng-packagr/4a1768888c60921955bfdfba8b31c8d853bd7b2a7d3a7b83934de049e1e6e6a2 +1 -0
  27. package/.angular/cache/21.2.7/ng-packagr/4a783e339117597607bff17eeca0ad24d84b8cbc1e28927e7e453ccfa6223180 +1 -0
  28. package/.angular/cache/21.2.7/ng-packagr/4d9331b2050326f586cd8f6593a9e04e1c7944b2f9e98023649023c099597a5d +1 -0
  29. package/.angular/cache/21.2.7/ng-packagr/4e379f506919d47af7008658c75242aa05f0056c1caec4061d7fa5746f776049 +1 -0
  30. package/.angular/cache/21.2.7/ng-packagr/55009bb7d44552dd816ce32fa2b0f7985f3f08fefd6409c2b4f6b9ffe35dad83 +1 -0
  31. package/.angular/cache/21.2.7/ng-packagr/58ae3f1f9664f7b16844d2e4a279dd4ca9371de014cf5687320c2d5cb259a74f +1 -0
  32. package/.angular/cache/21.2.7/ng-packagr/5c08e906bd3fe1aa6c1d62f2bbb2b3f276e1c17fe45ef081e76bd1b865ac3dfa +1 -0
  33. package/.angular/cache/21.2.7/ng-packagr/5ce333a40ad635188347fa9bc601d5fd14be6baacbae7d096259d725ac9757af +1 -0
  34. package/.angular/cache/21.2.7/ng-packagr/5f32cceaee6a6ea19cc6cbff5ea089b752f13a0fdcd32597d4c99d5e1e031bb5 +1 -0
  35. package/.angular/cache/21.2.7/ng-packagr/691ad4ccdc0a8ede36e1f4e5e97638c20c2d3142916ffac3a1b172178c139205 +1 -0
  36. package/.angular/cache/21.2.7/ng-packagr/6b57160e0d2da3f31693831e84a3f4209c1f33a04abd636e34af03956e7329d8 +1 -0
  37. package/.angular/cache/21.2.7/ng-packagr/70bc711a1d7b631845885c26adc2d6b1bff47d11332b2625cedfa11e9d5ac79a +1 -0
  38. package/.angular/cache/21.2.7/ng-packagr/7427c266237012afaef486c2af94ee08a491e8d7b6fc7e5ee887980830bbd333 +1 -0
  39. package/.angular/cache/21.2.7/ng-packagr/7e8fa7c61cf9a932ba3a0e65eb73c7412e81666b7a8f923dac7b75acfbb94b1d +1 -0
  40. package/.angular/cache/21.2.7/ng-packagr/81aab7fdab43cbdfa869db759d6113ae01ec6f5e0e9061d7fc089c260886e4d1 +1 -0
  41. package/.angular/cache/21.2.7/ng-packagr/83a81758045ff710a34ea3cf6f54435a1f5dea9839d8c0adda0bbce7c3fb6e8b +1 -0
  42. package/.angular/cache/21.2.7/ng-packagr/883eae810a4c09f06617bdc2e4bc30a69f09726401b2a051840969f635d076f1 +1 -0
  43. package/.angular/cache/21.2.7/ng-packagr/8a6b9be66de40c57054dca5fde376c3cec1bec1ae191a16f1ae6a83306d9ebfe +1 -0
  44. package/.angular/cache/21.2.7/ng-packagr/8d42c8144f6929de46984094bf390a0c4168404ab13a5194839f6ba5e42bc3ce +1 -0
  45. package/.angular/cache/21.2.7/ng-packagr/91093656c61a5404f0d576f872247eeb480dd938e6999d481a97893c72b5f3d0 +1 -0
  46. package/.angular/cache/21.2.7/ng-packagr/91e881172037c63d819e30d30e390e0d7dc0dee9808b3902275ccc8b1887d864 +1 -0
  47. package/.angular/cache/21.2.7/ng-packagr/9ef28cf3a676e7bd0d37762c4868b4810efca2f241ed0dae75ebca41988e2c00 +1 -0
  48. package/.angular/cache/21.2.7/ng-packagr/a07cbea405c1831b3f686a8e57c4b500d89cbab2b95e110487890269945feeaa +1 -0
  49. package/.angular/cache/21.2.7/ng-packagr/a463deba940880d9461612c9cd00d90062bf97aa31b1c4556b8b47a967cb6882 +1 -0
  50. package/.angular/cache/21.2.7/ng-packagr/ab03ed1e4a371113b41b663d526d2b06565ceb062e6f033f726f1e455fc5d1d6 +1 -0
  51. package/.angular/cache/21.2.7/ng-packagr/ad0e84be4f2211aff6187b4bec9adbe15f0e8b36851e9c6c63b38303c2daad37 +1 -0
  52. package/.angular/cache/21.2.7/ng-packagr/aece79242dae70eb748605e37483e75e122e4ce414fa8be875499e8af26ee5d6 +1 -0
  53. package/.angular/cache/21.2.7/ng-packagr/aff32db91ce03de30d2bbc84f266fe3fb2c6629d5eeb39a364204d9499484368 +1 -0
  54. package/.angular/cache/21.2.7/ng-packagr/b0671e73a162927d28ef1742ec008e514264bc2ce29f2255bedaea553492fe5d +1 -0
  55. package/.angular/cache/21.2.7/ng-packagr/bb50d71f3cdeebbb85fd983be8103f9c216060464f8e7e534271197391e6dcf7 +1 -0
  56. package/.angular/cache/21.2.7/ng-packagr/c64241290ab30d8761b2f5493a039427f5cda1a48b5be88ce62ee5c714c0f690 +1 -0
  57. package/.angular/cache/21.2.7/ng-packagr/c794d2e79b26ab378c0dbf8afa7b8ac1337ba9afb288941d44a086cb1bd4bad2 +1 -0
  58. package/.angular/cache/21.2.7/ng-packagr/d942edf8fd8e8e884138ffcdb1a07ad14a0b5e211f8ccea1dc9ea0b48f50cfc9 +1 -0
  59. package/.angular/cache/21.2.7/ng-packagr/dbe0b9b9f18ba7b96d9c84f4fd16cde158c9701c202d00113e6f88ba93407bce +1 -0
  60. package/.angular/cache/21.2.7/ng-packagr/f564395a410a2723aac48e582f5fe416bfeaa48677cea47b10c5152d4f2b6672 +1 -0
  61. package/.angular/cache/21.2.7/ng-packagr/fc9b0d27f081ca7b2a4cbefa75136d7bd7a8c341dbaa0587855071a6003906b8 +1 -0
  62. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-avatar-text.tsbuildinfo +1 -0
  63. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-avatar.tsbuildinfo +1 -0
  64. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-breadcrumb.tsbuildinfo +1 -0
  65. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-business-fields.tsbuildinfo +1 -0
  66. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-button-group.tsbuildinfo +1 -0
  67. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-button.tsbuildinfo +1 -0
  68. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-card.tsbuildinfo +1 -0
  69. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-checkbox-field.tsbuildinfo +1 -0
  70. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-chip.tsbuildinfo +1 -0
  71. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-client-page-menu.tsbuildinfo +1 -0
  72. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-client-page.tsbuildinfo +1 -0
  73. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-color-picker-field.tsbuildinfo +1 -0
  74. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-confirmation.tsbuildinfo +1 -0
  75. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-date-field.tsbuildinfo +1 -0
  76. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-dialog.tsbuildinfo +1 -0
  77. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-drawer.tsbuildinfo +1 -0
  78. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-dynamic-drawer.tsbuildinfo +1 -0
  79. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-editor-field.tsbuildinfo +1 -0
  80. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-empty-state.tsbuildinfo +1 -0
  81. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-entities.tsbuildinfo +1 -0
  82. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-field-validation.tsbuildinfo +1 -0
  83. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-formula.tsbuildinfo +1 -0
  84. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-icon-field.tsbuildinfo +1 -0
  85. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-list.tsbuildinfo +1 -0
  86. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-location-field.tsbuildinfo +1 -0
  87. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-menu.tsbuildinfo +1 -0
  88. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-modal.tsbuildinfo +1 -0
  89. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-module-summary-card.tsbuildinfo +1 -0
  90. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-multi-select-field.tsbuildinfo +1 -0
  91. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-number-field.tsbuildinfo +1 -0
  92. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-page-header.tsbuildinfo +1 -0
  93. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-page.tsbuildinfo +1 -0
  94. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-paginator.tsbuildinfo +1 -0
  95. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-pick-list-field.tsbuildinfo +1 -0
  96. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-progress.tsbuildinfo +1 -0
  97. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-property-filter-builder.tsbuildinfo +1 -0
  98. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-radio-button-field.tsbuildinfo +1 -0
  99. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-radio-cards-field.tsbuildinfo +1 -0
  100. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-radio-cards.tsbuildinfo +1 -0
  101. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-runtime-action.tsbuildinfo +1 -0
  102. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-select-field.tsbuildinfo +1 -0
  103. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-sidebar.tsbuildinfo +1 -0
  104. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-slider-field.tsbuildinfo +1 -0
  105. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-statistic-card.tsbuildinfo +1 -0
  106. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-table.tsbuildinfo +1 -0
  107. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-tabs.tsbuildinfo +1 -0
  108. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-text-field.tsbuildinfo +1 -0
  109. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-textarea-field.tsbuildinfo +1 -0
  110. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-toast.tsbuildinfo +1 -0
  111. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-toggle-field.tsbuildinfo +1 -0
  112. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-tooltip.tsbuildinfo +1 -0
  113. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-topbar.tsbuildinfo +1 -0
  114. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-tree.tsbuildinfo +1 -0
  115. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-treeselect-field.tsbuildinfo +1 -0
  116. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-upload-field.tsbuildinfo +1 -0
  117. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-uploader.tsbuildinfo +1 -0
  118. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components-user-search-field.tsbuildinfo +1 -0
  119. package/.angular/cache/21.2.7/ng-packagr/tsbuildinfo/masterteam-components.tsbuildinfo +1 -0
  120. package/angular.json +32 -0
  121. package/api/api.ts +1 -0
  122. package/api/public-api.ts +5 -0
  123. package/assets/common.css +309 -2
  124. package/assets/i18n/ar.json +10 -2
  125. package/assets/i18n/en.json +10 -2
  126. package/avatar/avatar.html +32 -0
  127. package/avatar/avatar.scss +0 -0
  128. package/avatar/avatar.ts +54 -0
  129. package/avatar/ng-package.json +6 -0
  130. package/avatar/public-api.ts +1 -0
  131. package/avatar-text/avatar-text.html +26 -0
  132. package/avatar-text/avatar-text.scss +0 -0
  133. package/avatar-text/avatar-text.ts +52 -0
  134. package/avatar-text/ng-package.json +6 -0
  135. package/avatar-text/public-api.ts +1 -0
  136. package/breadcrumb/breadcrumb.html +53 -0
  137. package/breadcrumb/breadcrumb.scss +0 -0
  138. package/breadcrumb/breadcrumb.ts +26 -0
  139. package/breadcrumb/ng-package.json +6 -0
  140. package/breadcrumb/public-api.ts +1 -0
  141. package/business-fields/entity-list-field/entity-list-add-token.ts +25 -0
  142. package/business-fields/entity-list-field/entity-list-field.html +70 -0
  143. package/business-fields/entity-list-field/entity-list-field.scss +3 -0
  144. package/business-fields/entity-list-field/entity-list-field.ts +1067 -0
  145. package/business-fields/lookup-matrix-field/lookup-matrix-field.html +38 -0
  146. package/business-fields/lookup-matrix-field/lookup-matrix-field.spec.ts +183 -0
  147. package/business-fields/lookup-matrix-field/lookup-matrix-field.ts +239 -0
  148. package/business-fields/lookup-module-check-list-field/lookup-module-check-list-field.html +95 -0
  149. package/business-fields/lookup-module-check-list-field/lookup-module-check-list-field.ts +336 -0
  150. package/business-fields/lookup-module-check-list-field/lookup-module-check-list-form-token.ts +42 -0
  151. package/business-fields/ng-package.json +6 -0
  152. package/business-fields/public-api.ts +8 -0
  153. package/business-fields/schedule-item-selector-field/schedule-item-selector-field.html +32 -0
  154. package/business-fields/schedule-item-selector-field/schedule-item-selector-field.ts +272 -0
  155. package/business-fields/schedule-predecessor-field/schedule-predecessor-field.html +89 -0
  156. package/business-fields/schedule-predecessor-field/schedule-predecessor-field.ts +441 -0
  157. package/business-fields/schema-connection-field/schema-connection-field.html +58 -0
  158. package/business-fields/schema-connection-field/schema-connection-field.scss +0 -0
  159. package/business-fields/schema-connection-field/schema-connection-field.ts +456 -0
  160. package/button/button.html +44 -0
  161. package/button/button.scss +0 -0
  162. package/button/button.ts +120 -0
  163. package/button/ng-package.json +6 -0
  164. package/button/public-api.ts +1 -0
  165. package/button-group/button-group.html +3 -0
  166. package/button-group/button-group.scss +20 -0
  167. package/button-group/button-group.ts +12 -0
  168. package/button-group/ng-package.json +6 -0
  169. package/button-group/public-api.ts +1 -0
  170. package/card/card.html +26 -0
  171. package/card/card.scss +0 -0
  172. package/card/card.ts +29 -0
  173. package/card/ng-package.json +6 -0
  174. package/card/public-api.ts +1 -0
  175. package/checkbox-field/checkbox-field.html +31 -0
  176. package/checkbox-field/checkbox-field.scss +0 -0
  177. package/checkbox-field/checkbox-field.spec.ts +21 -0
  178. package/checkbox-field/checkbox-field.ts +123 -0
  179. package/checkbox-field/ng-package.json +6 -0
  180. package/checkbox-field/public-api.ts +1 -0
  181. package/chip/chip.html +16 -0
  182. package/chip/chip.scss +19 -0
  183. package/chip/chip.ts +45 -0
  184. package/chip/ng-package.json +6 -0
  185. package/chip/public-api.ts +1 -0
  186. package/client-page/client-page.html +232 -0
  187. package/client-page/client-page.ts +588 -0
  188. package/client-page/index.ts +2 -0
  189. package/client-page/ng-package.json +6 -0
  190. package/client-page/public-api.ts +1 -0
  191. package/client-page-menu/client-page-menu.html +142 -0
  192. package/client-page-menu/client-page-menu.ts +199 -0
  193. package/client-page-menu/index.ts +2 -0
  194. package/client-page-menu/ng-package.json +6 -0
  195. package/client-page-menu/public-api.ts +1 -0
  196. package/color-picker-field/color-picker-field.html +45 -0
  197. package/color-picker-field/color-picker-field.scss +52 -0
  198. package/color-picker-field/color-picker-field.ts +131 -0
  199. package/color-picker-field/ng-package.json +6 -0
  200. package/color-picker-field/public-api.ts +1 -0
  201. package/confirmation/confirmation-dialog.html +83 -0
  202. package/confirmation/confirmation-dialog.scss +0 -0
  203. package/confirmation/confirmation-dialog.ts +15 -0
  204. package/confirmation/confirmation.spec.ts +43 -0
  205. package/confirmation/confirmation.ts +103 -0
  206. package/confirmation/ng-package.json +6 -0
  207. package/confirmation/public-api.ts +2 -0
  208. package/date-field/date-field.html +65 -0
  209. package/date-field/date-field.scss +0 -0
  210. package/date-field/date-field.spec.ts +118 -0
  211. package/date-field/date-field.ts +196 -0
  212. package/date-field/ng-package.json +6 -0
  213. package/date-field/public-api.ts +1 -0
  214. package/dialog/dialog.ts +29 -0
  215. package/dialog/ng-package.json +6 -0
  216. package/dialog/public-api.ts +1 -0
  217. package/drawer/drawer.html +67 -0
  218. package/drawer/drawer.scss +1 -0
  219. package/drawer/drawer.ts +348 -0
  220. package/drawer/ng-package.json +5 -0
  221. package/drawer/public-api.ts +1 -0
  222. package/dynamic-drawer/dynamic-drawer-host.ts +476 -0
  223. package/dynamic-drawer/dynamic-drawer.spec.ts +204 -0
  224. package/dynamic-drawer/dynamic-drawer.ts +235 -0
  225. package/dynamic-drawer/ng-package.json +6 -0
  226. package/dynamic-drawer/public-api.ts +2 -0
  227. package/editor-field/editor-field.html +38 -0
  228. package/editor-field/editor-field.scss +219 -0
  229. package/editor-field/editor-field.ts +126 -0
  230. package/editor-field/ng-package.json +6 -0
  231. package/editor-field/public-api.ts +1 -0
  232. package/empty-state/empty-state.html +236 -0
  233. package/empty-state/empty-state.ts +85 -0
  234. package/empty-state/ng-package.json +6 -0
  235. package/empty-state/public-api.ts +1 -0
  236. package/entities/comparison/comparison-entity-list/comparison-entity-list.html +87 -0
  237. package/entities/comparison/comparison-entity-list/comparison-entity-list.ts +93 -0
  238. package/entities/comparison/comparison-value/comparison-value.html +31 -0
  239. package/entities/comparison/comparison-value/comparison-value.ts +53 -0
  240. package/entities/currency-display.utils.spec.ts +94 -0
  241. package/entities/currency-display.utils.ts +92 -0
  242. package/entities/entities-manage/entities-manage.html +74 -0
  243. package/entities/entities-manage/entities-manage.scss +72 -0
  244. package/entities/entities-manage/entities-manage.ts +121 -0
  245. package/entities/entities-manage/entities-resize-base.ts +153 -0
  246. package/entities/entities-preview/entities-preview.css +77 -0
  247. package/entities/entities-preview/entities-preview.html +56 -0
  248. package/entities/entities-preview/entities-preview.ts +281 -0
  249. package/entities/entity-attachment/entity-attachment.html +49 -0
  250. package/entities/entity-attachment/entity-attachment.ts +462 -0
  251. package/entities/entity-checkbox/entity-checkbox.html +28 -0
  252. package/entities/entity-checkbox/entity-checkbox.ts +65 -0
  253. package/entities/entity-comparison.model.ts +39 -0
  254. package/entities/entity-connection/entity-connection.html +12 -0
  255. package/entities/entity-connection/entity-connection.ts +75 -0
  256. package/entities/entity-currency/entity-currency.html +12 -0
  257. package/entities/entity-currency/entity-currency.ts +59 -0
  258. package/entities/entity-date/entity-date.html +16 -0
  259. package/entities/entity-date/entity-date.ts +50 -0
  260. package/entities/entity-display.utils.ts +94 -0
  261. package/entities/entity-field/entity-field.ts +94 -0
  262. package/entities/entity-leaf-details/entity-leaf-details.html +35 -0
  263. package/entities/entity-leaf-details/entity-leaf-details.ts +56 -0
  264. package/entities/entity-location/entity-location.html +34 -0
  265. package/entities/entity-location/entity-location.ts +98 -0
  266. package/entities/entity-long-text/entity-long-text.html +9 -0
  267. package/entities/entity-long-text/entity-long-text.ts +45 -0
  268. package/entities/entity-lookup/entity-lookup.html +25 -0
  269. package/entities/entity-lookup/entity-lookup.ts +68 -0
  270. package/entities/entity-lookup-module-check-list/entity-lookup-module-check-list.html +39 -0
  271. package/entities/entity-lookup-module-check-list/entity-lookup-module-check-list.spec.ts +148 -0
  272. package/entities/entity-lookup-module-check-list/entity-lookup-module-check-list.ts +152 -0
  273. package/entities/entity-percentage/entity-percentage.html +22 -0
  274. package/entities/entity-percentage/entity-percentage.ts +163 -0
  275. package/entities/entity-phase-gate/entity-phase-gate.html +20 -0
  276. package/entities/entity-phase-gate/entity-phase-gate.ts +129 -0
  277. package/entities/entity-preview/entity-preview-body.html +8 -0
  278. package/entities/entity-preview/entity-preview-body.ts +19 -0
  279. package/entities/entity-preview/entity-preview.html +14 -0
  280. package/entities/entity-preview/entity-preview.ts +33 -0
  281. package/entities/entity-preview/entity-value-preview.html +62 -0
  282. package/entities/entity-preview/entity-value-preview.spec.ts +191 -0
  283. package/entities/entity-preview/entity-value-preview.ts +69 -0
  284. package/entities/entity-schedule-item/entity-schedule-item.html +19 -0
  285. package/entities/entity-schedule-item/entity-schedule-item.ts +41 -0
  286. package/entities/entity-sections.util.ts +103 -0
  287. package/entities/entity-status/entity-status.html +20 -0
  288. package/entities/entity-status/entity-status.ts +60 -0
  289. package/entities/entity-text/entity-text.html +20 -0
  290. package/entities/entity-text/entity-text.ts +35 -0
  291. package/entities/entity-user/entity-user.html +181 -0
  292. package/entities/entity-user/entity-user.ts +179 -0
  293. package/entities/entity.model.ts +407 -0
  294. package/entities/leaf-details-display.utils.ts +269 -0
  295. package/entities/ng-package.json +6 -0
  296. package/entities/percentage-color.utils.spec.ts +94 -0
  297. package/entities/percentage-color.utils.ts +80 -0
  298. package/entities/public-api.ts +30 -0
  299. package/field-validation/character-limit.validator.ts +22 -0
  300. package/field-validation/error-message.pipe.spec.ts +184 -0
  301. package/field-validation/error-message.pipe.ts +80 -0
  302. package/field-validation/field-validation.ts +168 -0
  303. package/field-validation/ng-package.json +6 -0
  304. package/field-validation/public-api.ts +2 -0
  305. package/formula/formula-editor/formula-editor.html +89 -0
  306. package/formula/formula-editor/formula-editor.scss +25 -0
  307. package/formula/formula-editor/formula-editor.ts +467 -0
  308. package/formula/formula-editor/index.ts +1 -0
  309. package/formula/formula-editor-code/formula-autocomplete-normalization.util.spec.ts +58 -0
  310. package/formula/formula-editor-code/formula-autocomplete-normalization.util.ts +64 -0
  311. package/formula/formula-editor-code/formula-completion-range.util.spec.ts +62 -0
  312. package/formula/formula-editor-code/formula-completion-range.util.ts +71 -0
  313. package/formula/formula-editor-code/formula-completion-suggestion.util.spec.ts +23 -0
  314. package/formula/formula-editor-code/formula-completion-suggestion.util.ts +18 -0
  315. package/formula/formula-editor-code/formula-editor-code.html +15 -0
  316. package/formula/formula-editor-code/formula-editor-code.scss +90 -0
  317. package/formula/formula-editor-code/formula-editor-code.ts +1095 -0
  318. package/formula/formula-editor-code/index.ts +1 -0
  319. package/formula/formula-status-bar/formula-status-bar.html +119 -0
  320. package/formula/formula-status-bar/formula-status-bar.ts +66 -0
  321. package/formula/formula-status-bar/index.ts +1 -0
  322. package/formula/formula-toolbar/formula-toolbar.html +361 -0
  323. package/formula/formula-toolbar/formula-toolbar.ts +532 -0
  324. package/formula/formula-toolbar/index.ts +2 -0
  325. package/formula/formula-toolbar/operators.ts +122 -0
  326. package/formula/models/formula-block.model.ts +61 -0
  327. package/formula/models/formula-token.model.spec.ts +57 -0
  328. package/formula/models/formula-token.model.ts +852 -0
  329. package/formula/models/index.ts +5 -0
  330. package/formula/models/smart-block.model.ts +132 -0
  331. package/formula/models/validation-result.model.ts +80 -0
  332. package/formula/ng-package.json +6 -0
  333. package/formula/public-api.ts +8 -0
  334. package/formula/runtime/formula-runtime-catalogs.ts +554 -0
  335. package/formula/runtime/formula-runtime-engine.spec.ts +328 -0
  336. package/formula/runtime/formula-runtime-engine.ts +794 -0
  337. package/formula/runtime/formula-runtime.model.ts +53 -0
  338. package/formula/runtime/index.ts +3 -0
  339. package/formula/toolbar-item/index.ts +1 -0
  340. package/formula/toolbar-item/toolbar-item.html +143 -0
  341. package/formula/toolbar-item/toolbar-item.scss +14 -0
  342. package/formula/toolbar-item/toolbar-item.ts +223 -0
  343. package/icon-field/icon-field.html +58 -0
  344. package/icon-field/icon-field.scss +24 -0
  345. package/icon-field/icon-field.spec.ts +77 -0
  346. package/icon-field/icon-field.ts +205 -0
  347. package/icon-field/ng-package.json +6 -0
  348. package/icon-field/public-api.ts +1 -0
  349. package/list/list.html +22 -0
  350. package/list/list.ts +36 -0
  351. package/list/ng-package.json +6 -0
  352. package/list/public-api.ts +1 -0
  353. package/location-field/location-field.html +86 -0
  354. package/location-field/location-field.spec.ts +295 -0
  355. package/location-field/location-field.ts +662 -0
  356. package/location-field/location-manual-dialog.html +43 -0
  357. package/location-field/location-manual-dialog.ts +104 -0
  358. package/location-field/location-value.ts +67 -0
  359. package/location-field/ng-package.json +6 -0
  360. package/location-field/public-api.ts +3 -0
  361. package/menu/menu.html +71 -0
  362. package/menu/menu.scss +3 -0
  363. package/menu/menu.ts +186 -0
  364. package/menu/ng-package.json +6 -0
  365. package/menu/public-api.ts +1 -0
  366. package/modal/modal.ts +127 -0
  367. package/modal/ng-package.json +6 -0
  368. package/modal/public-api.ts +1 -0
  369. package/module-summary-card/module-summary-card.html +43 -0
  370. package/module-summary-card/module-summary-card.scss +0 -0
  371. package/module-summary-card/module-summary-card.ts +40 -0
  372. package/module-summary-card/ng-package.json +6 -0
  373. package/module-summary-card/public-api.ts +1 -0
  374. package/multi-select-field/multi-select-field.html +140 -0
  375. package/multi-select-field/multi-select-field.scss +0 -0
  376. package/multi-select-field/multi-select-field.spec.ts +21 -0
  377. package/multi-select-field/multi-select-field.ts +397 -0
  378. package/multi-select-field/ng-package.json +6 -0
  379. package/multi-select-field/public-api.ts +1 -0
  380. package/ng-package.json +9 -0
  381. package/number-field/ng-package.json +6 -0
  382. package/number-field/number-field.html +39 -0
  383. package/number-field/number-field.scss +8 -0
  384. package/number-field/number-field.spec.ts +21 -0
  385. package/number-field/number-field.ts +124 -0
  386. package/number-field/public-api.ts +1 -0
  387. package/package.json +54 -274
  388. package/page/index.ts +1 -0
  389. package/page/ng-package.json +6 -0
  390. package/page/page.html +37 -0
  391. package/page/page.ts +43 -0
  392. package/page/public-api.ts +1 -0
  393. package/page-header/index.ts +2 -0
  394. package/page-header/ng-package.json +6 -0
  395. package/page-header/page-header.html +60 -0
  396. package/page-header/page-header.ts +54 -0
  397. package/page-header/public-api.ts +1 -0
  398. package/paginator/ng-package.json +6 -0
  399. package/paginator/paginator.html +50 -0
  400. package/paginator/paginator.scss +0 -0
  401. package/paginator/paginator.ts +53 -0
  402. package/paginator/public-api.ts +1 -0
  403. package/pick-list-field/ng-package.json +6 -0
  404. package/pick-list-field/pick-list-field.html +39 -0
  405. package/pick-list-field/pick-list-field.scss +26 -0
  406. package/pick-list-field/pick-list-field.ts +259 -0
  407. package/pick-list-field/public-api.ts +1 -0
  408. package/progress/ng-package.json +6 -0
  409. package/progress/progress.html +36 -0
  410. package/progress/progress.ts +61 -0
  411. package/progress/public-api.ts +1 -0
  412. package/property-filter-builder/ng-package.json +6 -0
  413. package/property-filter-builder/property-filter-builder.html +192 -0
  414. package/property-filter-builder/property-filter-builder.ts +548 -0
  415. package/property-filter-builder/public-api.ts +1 -0
  416. package/radio-button-field/ng-package.json +6 -0
  417. package/radio-button-field/public-api.ts +1 -0
  418. package/radio-button-field/radio-button-field.html +44 -0
  419. package/radio-button-field/radio-button-field.scss +0 -0
  420. package/radio-button-field/radio-button-field.ts +114 -0
  421. package/radio-cards/ng-package.json +6 -0
  422. package/radio-cards/public-api.ts +1 -0
  423. package/radio-cards/radio-cards.css +3 -0
  424. package/radio-cards/radio-cards.html +54 -0
  425. package/radio-cards/radio-cards.spec.ts +22 -0
  426. package/radio-cards/radio-cards.ts +92 -0
  427. package/radio-cards-field/ng-package.json +6 -0
  428. package/radio-cards-field/public-api.ts +1 -0
  429. package/radio-cards-field/radio-cards-field.css +0 -0
  430. package/radio-cards-field/radio-cards-field.html +38 -0
  431. package/radio-cards-field/radio-cards-field.spec.ts +22 -0
  432. package/radio-cards-field/radio-cards-field.ts +182 -0
  433. package/runtime-action/ng-package.json +6 -0
  434. package/runtime-action/payload-builder.ts +246 -0
  435. package/runtime-action/public-api.ts +4 -0
  436. package/runtime-action/runtime-action-context.store.ts +26 -0
  437. package/runtime-action/runtime-action.runner.ts +302 -0
  438. package/runtime-action/runtime-action.types.ts +82 -0
  439. package/select-field/current-user.util.ts +54 -0
  440. package/select-field/ng-package.json +6 -0
  441. package/select-field/public-api.ts +1 -0
  442. package/select-field/select-field.html +142 -0
  443. package/select-field/select-field.scss +0 -0
  444. package/select-field/select-field.spec.ts +21 -0
  445. package/select-field/select-field.ts +471 -0
  446. package/sidebar/ng-package.json +6 -0
  447. package/sidebar/public-api.ts +1 -0
  448. package/sidebar/sidebar.html +368 -0
  449. package/sidebar/sidebar.ts +303 -0
  450. package/slider-field/ng-package.json +7 -0
  451. package/slider-field/public-api.ts +1 -0
  452. package/slider-field/slider-field.html +33 -0
  453. package/slider-field/slider-field.scss +11 -0
  454. package/slider-field/slider-field.spec.ts +44 -0
  455. package/slider-field/slider-field.ts +166 -0
  456. package/src/lib/base/base.facade.ts +159 -0
  457. package/src/lib/base/crud-base.state.ts +248 -0
  458. package/src/lib/config/date-format.config.ts +55 -0
  459. package/src/lib/config/ds-identity.preset.ts +538 -0
  460. package/src/lib/config/ds-identity.tokens.ts +209 -0
  461. package/src/lib/config/dynamic-form.model.ts +1162 -0
  462. package/src/lib/config/povide-messages.ts +5 -0
  463. package/src/lib/config/provide-confirmation.ts +5 -0
  464. package/src/lib/config/providemt.ts +506 -0
  465. package/src/lib/config/public-api.ts +0 -0
  466. package/src/lib/pipes/mt-date-format.pipe.spec.ts +60 -0
  467. package/src/lib/pipes/mt-date-format.pipe.ts +81 -0
  468. package/src/lib/utils/api-request.helper.ts +59 -0
  469. package/src/lib/utils/clock-time.util.ts +58 -0
  470. package/src/lib/utils/color.utils.ts +187 -0
  471. package/src/lib/utils/entity-adapter.ts +50 -0
  472. package/src/lib/utils/field-id.ts +42 -0
  473. package/src/lib/utils/http-context.ts +35 -0
  474. package/src/lib/utils/inputs.ts +6 -0
  475. package/src/lib/utils/state-helpers.ts +49 -0
  476. package/src/lib/utils/theme.ts +281 -0
  477. package/src/public-api.ts +30 -0
  478. package/statistic-card/ng-package.json +6 -0
  479. package/statistic-card/public-api.ts +1 -0
  480. package/statistic-card/statistic-card.html +31 -0
  481. package/statistic-card/statistic-card.scss +0 -0
  482. package/statistic-card/statistic-card.ts +59 -0
  483. package/table/ng-package.json +7 -0
  484. package/table/public-api.ts +10 -0
  485. package/table/table-actions-menu/public-api.ts +1 -0
  486. package/table/table-actions-menu/table-actions-menu.html +75 -0
  487. package/table/table-actions-menu/table-actions-menu.ts +171 -0
  488. package/table/table-caption/public-api.ts +1 -0
  489. package/table/table-caption/table-caption.html +118 -0
  490. package/table/table-caption/table-caption.ts +221 -0
  491. package/table/table-column-filter/public-api.ts +1 -0
  492. package/table/table-column-filter/table-column-filter.html +44 -0
  493. package/table/table-column-filter/table-column-filter.ts +106 -0
  494. package/table/table-export/html-to-text.util.ts +67 -0
  495. package/table/table-export/public-api.ts +1 -0
  496. package/table/table-export/table-export.service.spec.ts +186 -0
  497. package/table/table-export/table-export.service.ts +325 -0
  498. package/table/table-filter/public-api.ts +1 -0
  499. package/table/table-filter/table-filter.css +9 -0
  500. package/table/table-filter/table-filter.html +63 -0
  501. package/table/table-filter/table-filter.ts +126 -0
  502. package/table/table-filter-field/public-api.ts +1 -0
  503. package/table/table-filter-field/table-filter-field.html +182 -0
  504. package/table/table-filter-field/table-filter-field.ts +208 -0
  505. package/table/table-grouping/public-api.ts +1 -0
  506. package/table/table-grouping/table-grouping.spec.ts +218 -0
  507. package/table/table-grouping/table-grouping.ts +237 -0
  508. package/table/table-types.ts +242 -0
  509. package/table/table-value.utils.spec.ts +63 -0
  510. package/table/table-value.utils.ts +1014 -0
  511. package/table/table.css +145 -0
  512. package/table/table.html +572 -0
  513. package/table/table.ts +2042 -0
  514. package/tabs/ng-package.json +6 -0
  515. package/tabs/public-api.ts +1 -0
  516. package/tabs/tabs.html +417 -0
  517. package/tabs/tabs.scss +3 -0
  518. package/tabs/tabs.spec.ts +79 -0
  519. package/tabs/tabs.ts +397 -0
  520. package/text-field/ng-package.json +6 -0
  521. package/text-field/public-api.ts +1 -0
  522. package/text-field/text-field.html +75 -0
  523. package/text-field/text-field.scss +56 -0
  524. package/text-field/text-field.ts +251 -0
  525. package/textarea-field/ng-package.json +6 -0
  526. package/textarea-field/public-api.ts +1 -0
  527. package/textarea-field/textarea-field.html +37 -0
  528. package/textarea-field/textarea-field.scss +0 -0
  529. package/textarea-field/textarea-field.spec.ts +21 -0
  530. package/textarea-field/textarea-field.ts +169 -0
  531. package/toast/ng-package.json +6 -0
  532. package/toast/public-api.ts +2 -0
  533. package/toast/toast.html +18 -0
  534. package/toast/toast.service.ts +67 -0
  535. package/toast/toast.ts +21 -0
  536. package/toggle-field/ng-package.json +6 -0
  537. package/toggle-field/public-api.ts +1 -0
  538. package/toggle-field/toggle-field.html +78 -0
  539. package/toggle-field/toggle-field.scss +24 -0
  540. package/toggle-field/toggle-field.ts +150 -0
  541. package/tooltip/ng-package.json +6 -0
  542. package/tooltip/public-api.ts +2 -0
  543. package/tooltip/tooltip.ts +30 -0
  544. package/tooltip/truncate-tooltip.ts +124 -0
  545. package/topbar/ng-package.json +6 -0
  546. package/topbar/public-api.ts +1 -0
  547. package/topbar/topbar.html +52 -0
  548. package/topbar/topbar.ts +27 -0
  549. package/tree/ng-package.json +6 -0
  550. package/tree/public-api.ts +2 -0
  551. package/tree/tree-types.ts +55 -0
  552. package/tree/tree.html +126 -0
  553. package/tree/tree.scss +1 -0
  554. package/tree/tree.ts +303 -0
  555. package/treeselect-field/ng-package.json +6 -0
  556. package/treeselect-field/public-api.ts +1 -0
  557. package/treeselect-field/treeselect-field.html +71 -0
  558. package/treeselect-field/treeselect-field.ts +348 -0
  559. package/tsconfig.check.json +20 -0
  560. package/tsconfig.json +16 -0
  561. package/tsconfig.spec.json +24 -0
  562. package/upload-field/ng-package.json +6 -0
  563. package/upload-field/public-api.ts +2 -0
  564. package/upload-field/secure-image.pipe.ts +258 -0
  565. package/upload-field/upload-field.html +274 -0
  566. package/upload-field/upload-field.scss +0 -0
  567. package/upload-field/upload-field.spec.ts +169 -0
  568. package/upload-field/upload-field.ts +764 -0
  569. package/upload-field/upload-file-preview/upload-file-preview.html +41 -0
  570. package/upload-field/upload-file-preview/upload-file-preview.scss +0 -0
  571. package/upload-field/upload-file-preview/upload-file-preview.ts +57 -0
  572. package/upload-field/upload-user-preview/upload-user-preview.css +0 -0
  573. package/upload-field/upload-user-preview/upload-user-preview.html +73 -0
  574. package/upload-field/upload-user-preview/upload-user-preview.ts +54 -0
  575. package/uploader/ng-package.json +6 -0
  576. package/uploader/public-api.ts +1 -0
  577. package/uploader/uploader.service.spec.ts +271 -0
  578. package/uploader/uploader.service.ts +733 -0
  579. package/user-search-field/ng-package.json +6 -0
  580. package/user-search-field/public-api.ts +1 -0
  581. package/user-search-field/user-search-field.html +88 -0
  582. package/user-search-field/user-search-field.scss +4 -0
  583. package/user-search-field/user-search-field.spec.ts +176 -0
  584. package/user-search-field/user-search-field.ts +483 -0
  585. package/fesm2022/masterteam-components-avatar-text.mjs +0 -46
  586. package/fesm2022/masterteam-components-avatar-text.mjs.map +0 -1
  587. package/fesm2022/masterteam-components-avatar.mjs +0 -50
  588. package/fesm2022/masterteam-components-avatar.mjs.map +0 -1
  589. package/fesm2022/masterteam-components-breadcrumb.mjs +0 -27
  590. package/fesm2022/masterteam-components-breadcrumb.mjs.map +0 -1
  591. package/fesm2022/masterteam-components-business-fields.mjs +0 -1902
  592. package/fesm2022/masterteam-components-business-fields.mjs.map +0 -1
  593. package/fesm2022/masterteam-components-button-group.mjs +0 -20
  594. package/fesm2022/masterteam-components-button-group.mjs.map +0 -1
  595. package/fesm2022/masterteam-components-button.mjs +0 -52
  596. package/fesm2022/masterteam-components-button.mjs.map +0 -1
  597. package/fesm2022/masterteam-components-card.mjs +0 -28
  598. package/fesm2022/masterteam-components-card.mjs.map +0 -1
  599. package/fesm2022/masterteam-components-checkbox-field.mjs +0 -88
  600. package/fesm2022/masterteam-components-checkbox-field.mjs.map +0 -1
  601. package/fesm2022/masterteam-components-chip.mjs +0 -39
  602. package/fesm2022/masterteam-components-chip.mjs.map +0 -1
  603. package/fesm2022/masterteam-components-client-page-menu.mjs +0 -152
  604. package/fesm2022/masterteam-components-client-page-menu.mjs.map +0 -1
  605. package/fesm2022/masterteam-components-client-page.mjs +0 -371
  606. package/fesm2022/masterteam-components-client-page.mjs.map +0 -1
  607. package/fesm2022/masterteam-components-color-picker-field.mjs +0 -102
  608. package/fesm2022/masterteam-components-color-picker-field.mjs.map +0 -1
  609. package/fesm2022/masterteam-components-confirmation.mjs +0 -98
  610. package/fesm2022/masterteam-components-confirmation.mjs.map +0 -1
  611. package/fesm2022/masterteam-components-date-field.mjs +0 -154
  612. package/fesm2022/masterteam-components-date-field.mjs.map +0 -1
  613. package/fesm2022/masterteam-components-dialog.mjs +0 -33
  614. package/fesm2022/masterteam-components-dialog.mjs.map +0 -1
  615. package/fesm2022/masterteam-components-drawer.mjs +0 -268
  616. package/fesm2022/masterteam-components-drawer.mjs.map +0 -1
  617. package/fesm2022/masterteam-components-dynamic-drawer.mjs +0 -608
  618. package/fesm2022/masterteam-components-dynamic-drawer.mjs.map +0 -1
  619. package/fesm2022/masterteam-components-editor-field.mjs +0 -99
  620. package/fesm2022/masterteam-components-editor-field.mjs.map +0 -1
  621. package/fesm2022/masterteam-components-entities.mjs +0 -2033
  622. package/fesm2022/masterteam-components-entities.mjs.map +0 -1
  623. package/fesm2022/masterteam-components-field-validation.mjs +0 -158
  624. package/fesm2022/masterteam-components-field-validation.mjs.map +0 -1
  625. package/fesm2022/masterteam-components-formula.mjs +0 -3848
  626. package/fesm2022/masterteam-components-formula.mjs.map +0 -1
  627. package/fesm2022/masterteam-components-icon-field.mjs +0 -161
  628. package/fesm2022/masterteam-components-icon-field.mjs.map +0 -1
  629. package/fesm2022/masterteam-components-list.mjs +0 -31
  630. package/fesm2022/masterteam-components-list.mjs.map +0 -1
  631. package/fesm2022/masterteam-components-location-field.mjs +0 -603
  632. package/fesm2022/masterteam-components-location-field.mjs.map +0 -1
  633. package/fesm2022/masterteam-components-menu.mjs +0 -135
  634. package/fesm2022/masterteam-components-menu.mjs.map +0 -1
  635. package/fesm2022/masterteam-components-modal.mjs +0 -108
  636. package/fesm2022/masterteam-components-modal.mjs.map +0 -1
  637. package/fesm2022/masterteam-components-module-summary-card.mjs +0 -34
  638. package/fesm2022/masterteam-components-module-summary-card.mjs.map +0 -1
  639. package/fesm2022/masterteam-components-multi-select-field.mjs +0 -317
  640. package/fesm2022/masterteam-components-multi-select-field.mjs.map +0 -1
  641. package/fesm2022/masterteam-components-number-field.mjs +0 -98
  642. package/fesm2022/masterteam-components-number-field.mjs.map +0 -1
  643. package/fesm2022/masterteam-components-page-header.mjs +0 -42
  644. package/fesm2022/masterteam-components-page-header.mjs.map +0 -1
  645. package/fesm2022/masterteam-components-page.mjs +0 -35
  646. package/fesm2022/masterteam-components-page.mjs.map +0 -1
  647. package/fesm2022/masterteam-components-paginator.mjs +0 -43
  648. package/fesm2022/masterteam-components-paginator.mjs.map +0 -1
  649. package/fesm2022/masterteam-components-pick-list-field.mjs +0 -206
  650. package/fesm2022/masterteam-components-pick-list-field.mjs.map +0 -1
  651. package/fesm2022/masterteam-components-progress.mjs +0 -63
  652. package/fesm2022/masterteam-components-progress.mjs.map +0 -1
  653. package/fesm2022/masterteam-components-property-filter-builder.mjs +0 -386
  654. package/fesm2022/masterteam-components-property-filter-builder.mjs.map +0 -1
  655. package/fesm2022/masterteam-components-radio-button-field.mjs +0 -85
  656. package/fesm2022/masterteam-components-radio-button-field.mjs.map +0 -1
  657. package/fesm2022/masterteam-components-radio-cards-field.mjs +0 -126
  658. package/fesm2022/masterteam-components-radio-cards-field.mjs.map +0 -1
  659. package/fesm2022/masterteam-components-radio-cards.mjs +0 -74
  660. package/fesm2022/masterteam-components-radio-cards.mjs.map +0 -1
  661. package/fesm2022/masterteam-components-runtime-action.mjs +0 -406
  662. package/fesm2022/masterteam-components-runtime-action.mjs.map +0 -1
  663. package/fesm2022/masterteam-components-select-field.mjs +0 -411
  664. package/fesm2022/masterteam-components-select-field.mjs.map +0 -1
  665. package/fesm2022/masterteam-components-sidebar.mjs +0 -155
  666. package/fesm2022/masterteam-components-sidebar.mjs.map +0 -1
  667. package/fesm2022/masterteam-components-slider-field.mjs +0 -128
  668. package/fesm2022/masterteam-components-slider-field.mjs.map +0 -1
  669. package/fesm2022/masterteam-components-statistic-card.mjs +0 -42
  670. package/fesm2022/masterteam-components-statistic-card.mjs.map +0 -1
  671. package/fesm2022/masterteam-components-table.mjs +0 -3197
  672. package/fesm2022/masterteam-components-table.mjs.map +0 -1
  673. package/fesm2022/masterteam-components-tabs.mjs +0 -289
  674. package/fesm2022/masterteam-components-tabs.mjs.map +0 -1
  675. package/fesm2022/masterteam-components-text-field.mjs +0 -198
  676. package/fesm2022/masterteam-components-text-field.mjs.map +0 -1
  677. package/fesm2022/masterteam-components-textarea-field.mjs +0 -122
  678. package/fesm2022/masterteam-components-textarea-field.mjs.map +0 -1
  679. package/fesm2022/masterteam-components-toast.mjs +0 -80
  680. package/fesm2022/masterteam-components-toast.mjs.map +0 -1
  681. package/fesm2022/masterteam-components-toggle-field.mjs +0 -116
  682. package/fesm2022/masterteam-components-toggle-field.mjs.map +0 -1
  683. package/fesm2022/masterteam-components-tooltip.mjs +0 -147
  684. package/fesm2022/masterteam-components-tooltip.mjs.map +0 -1
  685. package/fesm2022/masterteam-components-topbar.mjs +0 -32
  686. package/fesm2022/masterteam-components-topbar.mjs.map +0 -1
  687. package/fesm2022/masterteam-components-tree.mjs +0 -260
  688. package/fesm2022/masterteam-components-tree.mjs.map +0 -1
  689. package/fesm2022/masterteam-components-treeselect-field.mjs +0 -265
  690. package/fesm2022/masterteam-components-treeselect-field.mjs.map +0 -1
  691. package/fesm2022/masterteam-components-upload-field.mjs +0 -841
  692. package/fesm2022/masterteam-components-upload-field.mjs.map +0 -1
  693. package/fesm2022/masterteam-components-uploader.mjs +0 -425
  694. package/fesm2022/masterteam-components-uploader.mjs.map +0 -1
  695. package/fesm2022/masterteam-components-user-search-field.mjs +0 -370
  696. package/fesm2022/masterteam-components-user-search-field.mjs.map +0 -1
  697. package/fesm2022/masterteam-components.mjs +0 -2334
  698. package/fesm2022/masterteam-components.mjs.map +0 -1
  699. package/types/masterteam-components-avatar-text.d.ts +0 -23
  700. package/types/masterteam-components-avatar.d.ts +0 -23
  701. package/types/masterteam-components-breadcrumb.d.ts +0 -18
  702. package/types/masterteam-components-business-fields.d.ts +0 -671
  703. package/types/masterteam-components-button-group.d.ts +0 -8
  704. package/types/masterteam-components-button.d.ts +0 -36
  705. package/types/masterteam-components-card.d.ts +0 -14
  706. package/types/masterteam-components-checkbox-field.d.ts +0 -34
  707. package/types/masterteam-components-chip.d.ts +0 -21
  708. package/types/masterteam-components-client-page-menu.d.ts +0 -55
  709. package/types/masterteam-components-client-page.d.ts +0 -109
  710. package/types/masterteam-components-color-picker-field.d.ts +0 -35
  711. package/types/masterteam-components-confirmation.d.ts +0 -41
  712. package/types/masterteam-components-date-field.d.ts +0 -53
  713. package/types/masterteam-components-dialog.d.ts +0 -12
  714. package/types/masterteam-components-drawer.d.ts +0 -62
  715. package/types/masterteam-components-dynamic-drawer.d.ts +0 -159
  716. package/types/masterteam-components-editor-field.d.ts +0 -35
  717. package/types/masterteam-components-entities.d.ts +0 -1030
  718. package/types/masterteam-components-field-validation.d.ts +0 -23
  719. package/types/masterteam-components-formula.d.ts +0 -759
  720. package/types/masterteam-components-icon-field.d.ts +0 -40
  721. package/types/masterteam-components-list.d.ts +0 -18
  722. package/types/masterteam-components-location-field.d.ts +0 -169
  723. package/types/masterteam-components-menu.d.ts +0 -55
  724. package/types/masterteam-components-modal.d.ts +0 -30
  725. package/types/masterteam-components-module-summary-card.d.ts +0 -18
  726. package/types/masterteam-components-multi-select-field.d.ts +0 -100
  727. package/types/masterteam-components-number-field.d.ts +0 -43
  728. package/types/masterteam-components-page-header.d.ts +0 -30
  729. package/types/masterteam-components-page.d.ts +0 -26
  730. package/types/masterteam-components-paginator.d.ts +0 -20
  731. package/types/masterteam-components-pick-list-field.d.ts +0 -61
  732. package/types/masterteam-components-progress.d.ts +0 -30
  733. package/types/masterteam-components-property-filter-builder.d.ts +0 -90
  734. package/types/masterteam-components-radio-button-field.d.ts +0 -41
  735. package/types/masterteam-components-radio-cards-field.d.ts +0 -35
  736. package/types/masterteam-components-radio-cards.d.ts +0 -33
  737. package/types/masterteam-components-runtime-action.d.ts +0 -105
  738. package/types/masterteam-components-select-field.d.ts +0 -132
  739. package/types/masterteam-components-sidebar.d.ts +0 -71
  740. package/types/masterteam-components-slider-field.d.ts +0 -41
  741. package/types/masterteam-components-statistic-card.d.ts +0 -28
  742. package/types/masterteam-components-table.d.ts +0 -827
  743. package/types/masterteam-components-tabs.d.ts +0 -80
  744. package/types/masterteam-components-text-field.d.ts +0 -56
  745. package/types/masterteam-components-textarea-field.d.ts +0 -41
  746. package/types/masterteam-components-toast.d.ts +0 -27
  747. package/types/masterteam-components-toggle-field.d.ts +0 -44
  748. package/types/masterteam-components-tooltip.d.ts +0 -26
  749. package/types/masterteam-components-topbar.d.ts +0 -20
  750. package/types/masterteam-components-tree.d.ts +0 -106
  751. package/types/masterteam-components-treeselect-field.d.ts +0 -79
  752. package/types/masterteam-components-upload-field.d.ts +0 -108
  753. package/types/masterteam-components-uploader.d.ts +0 -53
  754. package/types/masterteam-components-user-search-field.d.ts +0 -106
  755. package/types/masterteam-components.d.ts +0 -1181
@@ -1,3848 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { input, output, signal, computed, effect, forwardRef, Component, viewChild, inject, NgZone, ViewEncapsulation, ChangeDetectionStrategy, contentChild, TemplateRef } from '@angular/core';
3
- import * as i1$2 from '@angular/common';
4
- import { CommonModule, DOCUMENT } from '@angular/common';
5
- import * as i2$1 from '@angular/forms';
6
- import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
7
- import * as i1 from '@angular/cdk/drag-drop';
8
- import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
9
- import * as i1$1 from '@jsverse/transloco';
10
- import { TranslocoPipe, TranslocoModule, TranslocoService } from '@jsverse/transloco';
11
- import { Subject, isObservable, from, firstValueFrom, of } from 'rxjs';
12
- import { debounceTime, filter, takeUntil, catchError } from 'rxjs/operators';
13
- import * as i2 from 'primeng/tooltip';
14
- import { TooltipModule } from 'primeng/tooltip';
15
-
16
- /**
17
- * Flat Formula Token Model
18
- *
19
- * The formula is represented as a FLAT array of tokens.
20
- * This approach provides:
21
- * - Better performance (no deep component nesting)
22
- * - Solid drag-drop behavior (functions move as complete units)
23
- * - Simple serialization (just join token values)
24
- *
25
- * STRUCTURE RULES:
26
- * - fn-open: "IF(" - function name + opening paren as ONE token
27
- * - fn-close: ")" - closing paren, belongs to a function
28
- * - fn-separator: "," - argument separator, belongs to a function
29
- * - Dragging any structural token moves the ENTIRE function
30
- * - Content tokens (property, operator, literal) can move individually
31
- */
32
- // ============ UTILITY FUNCTIONS ============
33
- /** Generate unique token ID */
34
- function generateTokenId() {
35
- return `tok_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`;
36
- }
37
- /** Generate unique function ID */
38
- function generateFunctionId() {
39
- return `fn_${Date.now()}_${Math.random().toString(36).substring(2, 7)}`;
40
- }
41
- /** Parse function signature like "SUM(values)" or "IF(cond, a, b)" */
42
- function parseSignature(signature) {
43
- const match = signature.match(/^(\w+)\((.*)\)$/);
44
- if (!match)
45
- return { name: signature, args: [] };
46
- const name = match[1];
47
- const argsStr = match[2].trim();
48
- if (!argsStr)
49
- return { name, args: [] };
50
- const args = [];
51
- let current = '';
52
- let depth = 0;
53
- for (const char of argsStr) {
54
- if (char === '(')
55
- depth++;
56
- else if (char === ')')
57
- depth--;
58
- else if (char === ',' && depth === 0) {
59
- args.push(current.trim());
60
- current = '';
61
- continue;
62
- }
63
- current += char;
64
- }
65
- if (current.trim())
66
- args.push(current.trim());
67
- return { name, args };
68
- }
69
- /**
70
- * Create a function's tokens from signature
71
- * e.g., "IF(condition, trueVal, falseVal)" creates:
72
- * - fn-open: "IF("
73
- * - fn-separator: "," (x2)
74
- * - fn-close: ")"
75
- */
76
- function createFunctionTokens(signature, depth = 0) {
77
- const parsed = parseSignature(signature);
78
- const functionId = generateFunctionId();
79
- const tokens = [];
80
- // Opening token: "NAME("
81
- tokens.push({
82
- id: generateTokenId(),
83
- type: 'fn-open',
84
- value: `${parsed.name}(`,
85
- functionId,
86
- functionName: parsed.name,
87
- depth,
88
- dragBehavior: 'function',
89
- });
90
- // Separators for arguments (one less than arg count)
91
- for (let i = 0; i < parsed.args.length - 1; i++) {
92
- tokens.push({
93
- id: generateTokenId(),
94
- type: 'fn-separator',
95
- value: ',',
96
- functionId,
97
- depth,
98
- argIndex: i, // Separator AFTER this argument
99
- dragBehavior: 'function',
100
- });
101
- }
102
- // Closing token: ")"
103
- tokens.push({
104
- id: generateTokenId(),
105
- type: 'fn-close',
106
- value: ')',
107
- functionId,
108
- depth,
109
- dragBehavior: 'function',
110
- });
111
- return tokens;
112
- }
113
- /**
114
- * Create a property token
115
- */
116
- function createPropertyToken(propertyKey, propertyType = 'current', depth = 0, functionId, argIndex, display) {
117
- const usesFullPath = propertyKey.startsWith('@');
118
- const prefix = propertyType === 'current'
119
- ? '@'
120
- : propertyType === 'children'
121
- ? '*.'
122
- : '$.';
123
- return {
124
- id: generateTokenId(),
125
- type: 'property',
126
- value: usesFullPath ? propertyKey : `${prefix}${propertyKey}`,
127
- display,
128
- propertyType,
129
- depth,
130
- functionId,
131
- argIndex,
132
- dragBehavior: 'single',
133
- };
134
- }
135
- /**
136
- * Create an operator token
137
- */
138
- function createOperatorToken(symbol, depth = 0, functionId, argIndex) {
139
- return {
140
- id: generateTokenId(),
141
- type: 'operator',
142
- value: symbol,
143
- depth,
144
- functionId,
145
- argIndex,
146
- dragBehavior: 'single',
147
- };
148
- }
149
- /**
150
- * Create a literal token
151
- */
152
- function createLiteralToken(value, depth = 0, functionId, argIndex, display) {
153
- let displayValue = String(value);
154
- let literalType = 'string';
155
- if (typeof value === 'number') {
156
- literalType = 'number';
157
- }
158
- else if (typeof value === 'boolean') {
159
- literalType = 'boolean';
160
- }
161
- else if (typeof value === 'string' && !value.startsWith('"')) {
162
- displayValue = `"${value}"`;
163
- }
164
- return {
165
- id: generateTokenId(),
166
- type: 'literal',
167
- value: displayValue,
168
- // Friendly label rendered on the chip while `value` stays the executable
169
- // (serialized) form — e.g. a lookup value shows "Completed" but serializes
170
- // as "completed". Cosmetic only; serialization never reads `display`.
171
- display: display?.trim() ? display : undefined,
172
- literalType,
173
- depth,
174
- functionId,
175
- argIndex,
176
- dragBehavior: 'single',
177
- };
178
- }
179
- /**
180
- * Create a raw text token for identifiers or syntax fragments that are not
181
- * properties, literals, or operators.
182
- */
183
- function createTextToken(value, depth = 0, functionId, argIndex) {
184
- return {
185
- id: generateTokenId(),
186
- type: 'text',
187
- value,
188
- depth,
189
- functionId,
190
- argIndex,
191
- dragBehavior: 'single',
192
- };
193
- }
194
- // ============ TOKEN ARRAY OPERATIONS ============
195
- /**
196
- * Find the complete range of a function in the token array
197
- * This includes ALL tokens between fn-open and fn-close (including nested content)
198
- * Returns [startIndex, endIndex] inclusive
199
- */
200
- function findFunctionRange(tokens, functionId) {
201
- // Find the fn-open token with this functionId
202
- const openIndex = tokens.findIndex((t) => t.functionId === functionId && t.type === 'fn-open');
203
- if (openIndex === -1)
204
- return null;
205
- // Now find the matching fn-close by counting depth
206
- // Start from fn-open and find matching close paren
207
- let depth = 1;
208
- for (let i = openIndex + 1; i < tokens.length; i++) {
209
- const token = tokens[i];
210
- if (token.type === 'fn-open') {
211
- depth++;
212
- }
213
- else if (token.type === 'fn-close') {
214
- depth--;
215
- if (depth === 0) {
216
- // Found the matching close
217
- return [openIndex, i];
218
- }
219
- }
220
- }
221
- // Fallback: find fn-close with same functionId
222
- const closeIndex = tokens.findIndex((t) => t.functionId === functionId && t.type === 'fn-close');
223
- if (closeIndex === -1)
224
- return null;
225
- return [openIndex, closeIndex];
226
- }
227
- /**
228
- * Get all tokens belonging to a function (including nested content)
229
- */
230
- function getFunctionTokens(tokens, functionId) {
231
- const range = findFunctionRange(tokens, functionId);
232
- if (!range)
233
- return [];
234
- return tokens.slice(range[0], range[1] + 1);
235
- }
236
- /**
237
- * Validate if a drop position is allowed
238
- */
239
- function isValidDropPosition(tokens, dropIndex, draggedTokens) {
240
- // Can always drop at start or end
241
- if (dropIndex === 0 || dropIndex === tokens.length)
242
- return true;
243
- const _prevToken = tokens[dropIndex - 1];
244
- const _nextToken = tokens[dropIndex];
245
- // If dragging a function, check if it would create invalid nesting
246
- const isDraggingFunction = draggedTokens.some((t) => t.type === 'fn-open' || t.type === 'fn-close');
247
- if (isDraggingFunction) {
248
- // Don't allow dropping a function that would break structure
249
- // For now, allow all - we can refine later
250
- }
251
- return true;
252
- }
253
- /**
254
- * Serialize tokens to the canonical, executable formula string.
255
- * Uses each token's `value` (e.g. `@Current::startdate`) — never `display` —
256
- * so the produced expression is stable and engine/back-end compatible.
257
- */
258
- function serializeTokens(tokens) {
259
- const parts = [];
260
- let lastType = null;
261
- let lastValue = '';
262
- for (const token of tokens) {
263
- if (shouldInsertSpace(lastType, lastValue, token)) {
264
- parts.push(' ');
265
- }
266
- parts.push(token.value);
267
- lastType = token.type;
268
- lastValue = token.value;
269
- }
270
- return parts.join('');
271
- }
272
- /**
273
- * Serialize tokens to a human-readable preview string using each token's
274
- * `display` label (the friendly property name) when present, falling back to
275
- * its `value`. Spacing is computed from the canonical `value`/`type` so that a
276
- * friendly name containing spaces (e.g. "Start Date") does not corrupt
277
- * function/paren/separator spacing. This output is for display/preview ONLY
278
- * (e.g. `formulaText`) — never feed it to the validator or persist it as the
279
- * executable expression.
280
- */
281
- function serializeTokensForDisplay(tokens) {
282
- const parts = [];
283
- let lastType = null;
284
- let lastValue = '';
285
- for (const token of tokens) {
286
- if (shouldInsertSpace(lastType, lastValue, token)) {
287
- parts.push(' ');
288
- }
289
- parts.push(token.display ?? token.value);
290
- lastType = token.type;
291
- lastValue = token.value;
292
- }
293
- return parts.join('');
294
- }
295
- function shouldInsertSpace(previousType, previousValue, current) {
296
- if (!previousType)
297
- return false;
298
- if (previousType === 'fn-open')
299
- return false;
300
- if (current.type === 'fn-close')
301
- return false;
302
- if (current.type === 'fn-separator')
303
- return false;
304
- if (previousType === 'fn-separator')
305
- return true;
306
- if (current.value === ':')
307
- return false;
308
- if (previousValue === ':')
309
- return true;
310
- return true;
311
- }
312
- /**
313
- * Clone a token with new ID
314
- */
315
- function cloneToken(token) {
316
- return {
317
- ...token,
318
- id: generateTokenId(),
319
- };
320
- }
321
- /**
322
- * Clone multiple tokens with new IDs and new function IDs
323
- */
324
- function cloneTokens(tokens) {
325
- // Map old function IDs to new ones
326
- const functionIdMap = new Map();
327
- return tokens.map((token) => {
328
- const newToken = cloneToken(token);
329
- // Remap function IDs
330
- if (token.functionId) {
331
- if (!functionIdMap.has(token.functionId)) {
332
- functionIdMap.set(token.functionId, generateFunctionId());
333
- }
334
- newToken.functionId = functionIdMap.get(token.functionId);
335
- }
336
- return newToken;
337
- });
338
- }
339
- /**
340
- * Update depth for all tokens (after move)
341
- */
342
- function recalculateDepths(tokens) {
343
- let currentDepth = 0;
344
- const result = [];
345
- for (const token of tokens) {
346
- if (token.type === 'fn-open') {
347
- result.push({ ...token, depth: currentDepth });
348
- currentDepth++;
349
- }
350
- else if (token.type === 'fn-close') {
351
- currentDepth--;
352
- result.push({ ...token, depth: currentDepth });
353
- }
354
- else {
355
- result.push({ ...token, depth: currentDepth });
356
- }
357
- }
358
- return result;
359
- }
360
- /**
361
- * Convert a backend template or insertText into builder tokens while
362
- * preserving the authored syntax as closely as the flat token model allows.
363
- */
364
- function tokenizeFormulaTemplate(template) {
365
- const source = template.trim();
366
- if (!source)
367
- return [];
368
- let index = 0;
369
- const parseExpression = (context) => {
370
- const tokens = [];
371
- while (index < source.length) {
372
- skipWhitespace();
373
- if (index >= source.length)
374
- break;
375
- const char = source[index];
376
- if (char === ',' || char === ')') {
377
- break;
378
- }
379
- if (char === '@') {
380
- const propertyPath = readPropertyPath();
381
- tokens.push(createPropertyToken(propertyPath, 'current', context.depth, context.functionId, context.argIndex, resolvePropertyDisplay(propertyPath)));
382
- continue;
383
- }
384
- if (char === '"' || char === "'") {
385
- tokens.push(createLiteralToken(readQuotedString(), context.depth, context.functionId, context.argIndex));
386
- continue;
387
- }
388
- if (isDigit(char)) {
389
- tokens.push(createLiteralToken(Number(readNumber()), context.depth, context.functionId, context.argIndex));
390
- continue;
391
- }
392
- if (char === '-' &&
393
- isDigit(source[index + 1] ?? '') &&
394
- shouldReadNegativeNumber(tokens)) {
395
- tokens.push(createLiteralToken(Number(readNumber()), context.depth, context.functionId, context.argIndex));
396
- continue;
397
- }
398
- if (isIdentifierStart(char)) {
399
- const identifier = readIdentifier();
400
- skipWhitespace();
401
- if (source[index] === '(') {
402
- tokens.push(...parseFunction(identifier, context.depth));
403
- continue;
404
- }
405
- if (identifier === 'true' || identifier === 'false') {
406
- tokens.push(createLiteralToken(identifier === 'true', context.depth, context.functionId, context.argIndex));
407
- continue;
408
- }
409
- if (identifier === 'null') {
410
- tokens.push(createTextToken(identifier, context.depth, context.functionId, context.argIndex));
411
- continue;
412
- }
413
- tokens.push(createTextToken(identifier, context.depth, context.functionId, context.argIndex));
414
- continue;
415
- }
416
- const operator = readOperator();
417
- if (operator) {
418
- tokens.push(createOperatorToken(operator, context.depth, context.functionId, context.argIndex));
419
- continue;
420
- }
421
- tokens.push(createTextToken(char, context.depth, context.functionId, context.argIndex));
422
- index += 1;
423
- }
424
- return tokens;
425
- };
426
- const parseFunction = (name, depth) => {
427
- const functionId = generateFunctionId();
428
- const tokens = [
429
- {
430
- id: generateTokenId(),
431
- type: 'fn-open',
432
- value: `${name}(`,
433
- functionId,
434
- functionName: name,
435
- depth,
436
- dragBehavior: 'function',
437
- },
438
- ];
439
- index += 1; // consume '('
440
- let argIndex = 0;
441
- while (index < source.length) {
442
- skipWhitespace();
443
- if (source[index] === ')') {
444
- index += 1;
445
- break;
446
- }
447
- tokens.push(...parseExpression({
448
- depth: depth + 1,
449
- functionId,
450
- argIndex,
451
- }));
452
- skipWhitespace();
453
- if (source[index] === ',') {
454
- tokens.push({
455
- id: generateTokenId(),
456
- type: 'fn-separator',
457
- value: ',',
458
- functionId,
459
- depth,
460
- argIndex,
461
- dragBehavior: 'function',
462
- });
463
- argIndex += 1;
464
- index += 1;
465
- continue;
466
- }
467
- if (source[index] === ')') {
468
- index += 1;
469
- break;
470
- }
471
- }
472
- tokens.push({
473
- id: generateTokenId(),
474
- type: 'fn-close',
475
- value: ')',
476
- functionId,
477
- depth,
478
- dragBehavior: 'function',
479
- });
480
- return tokens;
481
- };
482
- const skipWhitespace = () => {
483
- while (index < source.length && /\s/.test(source[index])) {
484
- index += 1;
485
- }
486
- };
487
- const readQuotedString = () => {
488
- const quote = source[index];
489
- let value = quote;
490
- index += 1;
491
- while (index < source.length) {
492
- const char = source[index];
493
- value += char;
494
- index += 1;
495
- if (char === '\\' && index < source.length) {
496
- value += source[index];
497
- index += 1;
498
- continue;
499
- }
500
- if (char === quote) {
501
- break;
502
- }
503
- }
504
- return value;
505
- };
506
- const readNumber = () => {
507
- const start = index;
508
- if (source[index] === '-') {
509
- index += 1;
510
- }
511
- while (index < source.length && /[0-9.]/.test(source[index])) {
512
- index += 1;
513
- }
514
- return source.slice(start, index);
515
- };
516
- const readIdentifier = () => {
517
- const start = index;
518
- index += 1;
519
- while (index < source.length && /[\w.]/.test(source[index])) {
520
- index += 1;
521
- }
522
- return source.slice(start, index);
523
- };
524
- const readPropertyPath = () => {
525
- const start = index;
526
- index += 1;
527
- while (index < source.length) {
528
- const char = source[index];
529
- const next = source[index + 1] ?? '';
530
- if (/\s/.test(char) || char === ',' || char === ')' || char === '(') {
531
- break;
532
- }
533
- if (char === ':' && next === ':') {
534
- index += 2;
535
- continue;
536
- }
537
- if (/[+\-*/%<>=!&|?:]/.test(char)) {
538
- break;
539
- }
540
- index += 1;
541
- }
542
- return source.slice(start, index);
543
- };
544
- const readOperator = () => {
545
- const operators = [
546
- '==',
547
- '!=',
548
- '>=',
549
- '<=',
550
- '&&',
551
- '||',
552
- ':',
553
- '+',
554
- '-',
555
- '*',
556
- '/',
557
- '%',
558
- '>',
559
- '<',
560
- '!',
561
- '?',
562
- ];
563
- for (const operator of operators) {
564
- if (source.startsWith(operator, index)) {
565
- index += operator.length;
566
- return operator;
567
- }
568
- }
569
- return null;
570
- };
571
- return recalculateDepths(parseExpression({ depth: 0 }));
572
- }
573
- function isDigit(value) {
574
- return /[0-9]/.test(value);
575
- }
576
- function isIdentifierStart(value) {
577
- return /[A-Za-z_]/.test(value);
578
- }
579
- function resolvePropertyDisplay(propertyPath) {
580
- const scopedSeparatorIndex = propertyPath.lastIndexOf('::');
581
- if (scopedSeparatorIndex < 0) {
582
- return undefined;
583
- }
584
- const propertyKey = propertyPath.slice(scopedSeparatorIndex + 2).trim();
585
- return propertyKey || undefined;
586
- }
587
- function shouldReadNegativeNumber(tokens) {
588
- const previous = tokens[tokens.length - 1];
589
- if (!previous)
590
- return true;
591
- return previous.type === 'operator' || previous.type === 'fn-open';
592
- }
593
- /**
594
- * Find which argument index a position belongs to within a function
595
- */
596
- function getArgumentIndexAtPosition(tokens, functionId, position) {
597
- const range = findFunctionRange(tokens, functionId);
598
- if (!range)
599
- return 0;
600
- let argIndex = 0;
601
- for (let i = range[0] + 1; i < position && i <= range[1]; i++) {
602
- if (tokens[i].type === 'fn-separator' &&
603
- tokens[i].functionId === functionId) {
604
- argIndex++;
605
- }
606
- }
607
- return argIndex;
608
- }
609
-
610
- /**
611
- * Smart Formula Block - Types and Factory Functions
612
- * Defines the block structure and creation helpers
613
- */
614
- /** Generate unique block ID */
615
- function generateSmartBlockId() {
616
- return `sb_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
617
- }
618
- /** Create a function block from signature */
619
- function createFunctionBlock(signature, name, insertText, cursorOffset) {
620
- const parsed = parseSignature(signature);
621
- return {
622
- id: generateSmartBlockId(),
623
- type: 'function',
624
- value: parsed.name,
625
- functionName: name || parsed.name,
626
- signature,
627
- insertText,
628
- cursorOffset,
629
- arguments: parsed.args.map((arg) => ({
630
- id: generateSmartBlockId(),
631
- name: arg,
632
- blocks: [],
633
- placeholder: arg,
634
- })),
635
- };
636
- }
637
- /** Create a property block */
638
- function createPropertyBlock(propertyKey, propertyType = 'current', display) {
639
- const usesFullPath = propertyKey.startsWith('@');
640
- const prefix = propertyType === 'current'
641
- ? '@'
642
- : propertyType === 'children'
643
- ? '*.'
644
- : '$.';
645
- return {
646
- id: generateSmartBlockId(),
647
- type: 'property',
648
- value: usesFullPath ? propertyKey : `${prefix}${propertyKey}`,
649
- display,
650
- propertyType,
651
- propertyKey,
652
- };
653
- }
654
- /** Create an operator block */
655
- function createOperatorBlock(symbol) {
656
- return {
657
- id: generateSmartBlockId(),
658
- type: 'operator',
659
- value: symbol,
660
- operatorSymbol: symbol,
661
- };
662
- }
663
- /** Create a literal block */
664
- function createLiteralBlock(value, display) {
665
- return {
666
- id: generateSmartBlockId(),
667
- type: 'literal',
668
- value: String(value),
669
- display,
670
- literalValue: value,
671
- };
672
- }
673
- /** Deep clone a block with new IDs */
674
- function cloneBlock(block) {
675
- const newBlock = { ...block, id: generateSmartBlockId() };
676
- if (block.arguments) {
677
- newBlock.arguments = block.arguments.map((arg) => ({
678
- ...arg,
679
- id: generateSmartBlockId(),
680
- blocks: arg.blocks.map((b) => cloneBlock(b)),
681
- }));
682
- }
683
- return newBlock;
684
- }
685
-
686
- /**
687
- * Validation Result Models
688
- * API response types for formula validation
689
- */
690
-
691
- /**
692
- * Formula Block Model - Types for formula functions and operators
693
- */
694
-
695
- // Models index
696
-
697
- class FormulaEditor {
698
- // ============ INPUTS ============
699
- placeholder = input('Click toolbar items to build formula...', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
700
- initialTokens = input([], ...(ngDevMode ? [{ debugName: "initialTokens" }] : /* istanbul ignore next */ []));
701
- disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
702
- borderless = input(false, ...(ngDevMode ? [{ debugName: "borderless" }] : /* istanbul ignore next */ []));
703
- // ============ OUTPUTS ============
704
- formulaChange = output();
705
- tokensChange = output();
706
- onBlur = output();
707
- onFocus = output();
708
- // ============ STATE ============
709
- tokens = signal([], ...(ngDevMode ? [{ debugName: "tokens" }] : /* istanbul ignore next */ []));
710
- /** Index range being dragged [start, end] inclusive */
711
- draggedRange = null;
712
- /** Is currently dragging */
713
- isDragging = signal(false, ...(ngDevMode ? [{ debugName: "isDragging" }] : /* istanbul ignore next */ []));
714
- /** Hovered function ID for highlighting */
715
- hoveredFunctionId = signal(null, ...(ngDevMode ? [{ debugName: "hoveredFunctionId" }] : /* istanbul ignore next */ []));
716
- /** Is focused */
717
- isFocused = signal(false, ...(ngDevMode ? [{ debugName: "isFocused" }] : /* istanbul ignore next */ []));
718
- // ============ CVA ============
719
- onChange = () => { };
720
- onTouched = () => { };
721
- // ============ COMPUTED ============
722
- containerClasses = computed(() => {
723
- const base = 'flex min-h-20 font-mono text-sm bg-white dark:bg-surface-800';
724
- if (this.borderless()) {
725
- return base;
726
- }
727
- return `${base} border border-surface-200 dark:border-surface-700 rounded-md focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/10`;
728
- }, ...(ngDevMode ? [{ debugName: "containerClasses" }] : /* istanbul ignore next */ []));
729
- lineNumberClasses = computed(() => {
730
- const base = 'flex flex-col px-1.5 py-2 bg-surface-50 dark:bg-surface-900 border-r border-surface-200 dark:border-surface-700 select-none min-w-6 text-right';
731
- if (this.borderless()) {
732
- return base;
733
- }
734
- return `${base} rounded-l-md`;
735
- }, ...(ngDevMode ? [{ debugName: "lineNumberClasses" }] : /* istanbul ignore next */ []));
736
- /** Line numbers based on token count */
737
- lines = computed(() => {
738
- const count = Math.max(1, Math.ceil(this.tokens().length / 8));
739
- return Array(count).fill(0);
740
- }, ...(ngDevMode ? [{ debugName: "lines" }] : /* istanbul ignore next */ []));
741
- /** Serialized formula string */
742
- formulaString = computed(() => serializeTokens(this.tokens()), ...(ngDevMode ? [{ debugName: "formulaString" }] : /* istanbul ignore next */ []));
743
- constructor() {
744
- // Initialize from input
745
- effect(() => {
746
- const initial = this.initialTokens();
747
- if (initial.length > 0) {
748
- this.tokens.set(initial);
749
- }
750
- });
751
- }
752
- // ============ CONTROL VALUE ACCESSOR ============
753
- writeValue(value) {
754
- if (value === null || value === undefined) {
755
- this.tokens.set([]);
756
- return;
757
- }
758
- // Value should be tokens array
759
- if (Array.isArray(value)) {
760
- this.tokens.set(value);
761
- }
762
- }
763
- registerOnChange(fn) {
764
- this.onChange = fn;
765
- }
766
- registerOnTouched(fn) {
767
- this.onTouched = fn;
768
- }
769
- // ============ PUBLIC API ============
770
- /**
771
- * Add a block from toolbar (converts SmartBlock to tokens)
772
- */
773
- addBlock(block) {
774
- if (this.disabled())
775
- return;
776
- const newTokens = this.smartBlockToTokens(block);
777
- this.tokens.update((tokens) => [...tokens, ...cloneTokens(newTokens)]);
778
- this.emit();
779
- }
780
- /**
781
- * Add tokens directly
782
- */
783
- addTokens(newTokens) {
784
- if (this.disabled())
785
- return;
786
- this.tokens.update((tokens) => [...tokens, ...cloneTokens(newTokens)]);
787
- this.emit();
788
- }
789
- /**
790
- * Clear all tokens
791
- */
792
- clear() {
793
- if (this.disabled())
794
- return;
795
- this.tokens.set([]);
796
- this.emit();
797
- }
798
- /**
799
- * Get current formula string
800
- */
801
- serialize() {
802
- return this.formulaString();
803
- }
804
- /**
805
- * Get current tokens
806
- */
807
- getTokens() {
808
- return this.tokens();
809
- }
810
- // ============ FOCUS HANDLERS ============
811
- handleFocus() {
812
- this.isFocused.set(true);
813
- this.onFocus.emit();
814
- }
815
- handleBlur() {
816
- this.isFocused.set(false);
817
- this.onTouched();
818
- this.onBlur.emit();
819
- }
820
- // ============ DRAG HANDLERS ============
821
- /**
822
- * Handle drag start - determine what tokens to drag
823
- */
824
- onDragStart(event, token, index) {
825
- if (this.disabled())
826
- return;
827
- this.isDragging.set(true);
828
- if (token.dragBehavior === 'function' && token.functionId) {
829
- // Drag entire function (all tokens from fn-open to fn-close)
830
- const range = findFunctionRange(this.tokens(), token.functionId);
831
- if (range) {
832
- this.draggedRange = range;
833
- }
834
- else {
835
- // Fallback to single token if range not found
836
- this.draggedRange = [index, index];
837
- }
838
- }
839
- else {
840
- // Drag single token
841
- this.draggedRange = [index, index];
842
- }
843
- }
844
- /**
845
- * Handle drop - reorder tokens in the formula
846
- */
847
- onDrop(event) {
848
- if (this.disabled())
849
- return;
850
- this.isDragging.set(false);
851
- const { previousIndex, currentIndex } = event;
852
- // No movement
853
- if (previousIndex === currentIndex) {
854
- this.resetDragState();
855
- return;
856
- }
857
- // No drag data (shouldn't happen but be safe)
858
- if (!this.draggedRange) {
859
- this.resetDragState();
860
- return;
861
- }
862
- const [start, end] = this.draggedRange;
863
- const count = end - start + 1;
864
- const isSingleToken = start === end;
865
- // Block dropping inside own range (only for multi-token drag)
866
- if (!isSingleToken && currentIndex > start && currentIndex <= end) {
867
- this.resetDragState();
868
- return;
869
- }
870
- const tokens = [...this.tokens()];
871
- if (isSingleToken) {
872
- // Simple single-token move using CDK utility
873
- moveItemInArray(tokens, previousIndex, currentIndex);
874
- }
875
- else {
876
- // Multi-token move (function with all content)
877
- // 1. Extract the tokens we're moving
878
- const moving = tokens.splice(start, count);
879
- // 2. Calculate insert position
880
- let insertAt;
881
- if (currentIndex <= start) {
882
- // Moving left/backward - insert at drop position
883
- insertAt = currentIndex;
884
- }
885
- else {
886
- // Moving right/forward
887
- // After removal, adjust for removed count and insert AFTER drop target
888
- insertAt = currentIndex - count + 1;
889
- }
890
- // 3. Clamp and insert
891
- insertAt = Math.max(0, Math.min(insertAt, tokens.length));
892
- tokens.splice(insertAt, 0, ...moving);
893
- }
894
- // Update state with recalculated depths
895
- this.tokens.set(recalculateDepths(tokens));
896
- this.resetDragState();
897
- this.emit();
898
- }
899
- /**
900
- * Reset drag state
901
- */
902
- resetDragState() {
903
- this.draggedRange = null;
904
- }
905
- /**
906
- * Handle drag end
907
- * NOTE: CDK fires cdkDragEnded BEFORE cdkDropListDropped
908
- * So we don't reset draggedRange here - onDrop handles it
909
- */
910
- onDragEnd() {
911
- this.isDragging.set(false);
912
- }
913
- // ============ DELETE ============
914
- /**
915
- * Remove a token or function
916
- */
917
- removeToken(token, index) {
918
- if (this.disabled())
919
- return;
920
- if (token.dragBehavior === 'function' && token.functionId) {
921
- // Remove entire function
922
- const range = findFunctionRange(this.tokens(), token.functionId);
923
- if (range) {
924
- this.tokens.update((tokens) => {
925
- const newTokens = [...tokens];
926
- newTokens.splice(range[0], range[1] - range[0] + 1);
927
- return recalculateDepths(newTokens);
928
- });
929
- }
930
- }
931
- else {
932
- // Remove single token
933
- this.tokens.update((tokens) => tokens.filter((_, i) => i !== index));
934
- }
935
- this.emit();
936
- }
937
- // ============ HOVER EFFECTS ============
938
- onTokenHover(token) {
939
- if (token.functionId && token.dragBehavior === 'function') {
940
- this.hoveredFunctionId.set(token.functionId);
941
- }
942
- }
943
- onTokenLeave() {
944
- this.hoveredFunctionId.set(null);
945
- }
946
- /**
947
- * Check if token should be highlighted
948
- * Only structural tokens (fn-open, fn-close, fn-separator) get highlighted
949
- * Content tokens (property, operator, literal) inside function are NOT highlighted
950
- */
951
- isHighlighted(token) {
952
- const hoveredId = this.hoveredFunctionId();
953
- if (!hoveredId)
954
- return false;
955
- // Only highlight structural tokens of the function, not content inside
956
- const isStructural = token.type === 'fn-open' ||
957
- token.type === 'fn-close' ||
958
- token.type === 'fn-separator';
959
- return isStructural && token.functionId === hoveredId;
960
- }
961
- // ============ STYLING ============
962
- /** Base token classes */
963
- baseTokenClasses = 'inline-flex items-center px-2 py-1 rounded text-sm font-medium cursor-grab select-none whitespace-nowrap active:cursor-grabbing';
964
- /**
965
- * Get Tailwind classes for a token
966
- */
967
- getTokenClasses(token) {
968
- const base = this.baseTokenClasses;
969
- // Type-based styling using Tailwind
970
- switch (token.type) {
971
- case 'fn-open':
972
- // Function opening: "IF(" - rounded left only
973
- return `${base} bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-300 font-semibold hover:bg-slate-300 dark:hover:bg-slate-600 rounded-r-none pr-0.5`;
974
- case 'fn-close':
975
- // Function closing: ")" - rounded right only
976
- return `${base} bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-300 font-semibold hover:bg-slate-300 dark:hover:bg-slate-600 rounded-l-none pl-0.5`;
977
- case 'fn-separator':
978
- // Function separator: ","
979
- return `${base} bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-300 font-semibold hover:bg-slate-300 dark:hover:bg-slate-600 rounded-sm px-1`;
980
- case 'property':
981
- // Property tokens - amber colors
982
- return `${base} bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300 font-semibold hover:bg-amber-200 dark:hover:bg-amber-900/50`;
983
- case 'operator':
984
- // Operator tokens - sky colors
985
- return `${base} bg-sky-100 dark:bg-sky-900/30 text-sky-700 dark:text-sky-300 font-bold hover:bg-sky-200 dark:hover:bg-sky-900/50 px-2`;
986
- case 'literal':
987
- // Literal tokens - emerald colors
988
- return `${base} bg-emerald-100 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-300 hover:bg-emerald-200 dark:hover:bg-emerald-900/50`;
989
- case 'text':
990
- return `${base} bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700`;
991
- default:
992
- return base;
993
- }
994
- }
995
- // ============ CONVERSION ============
996
- /**
997
- * Convert SmartBlock to FormulaTokens
998
- */
999
- smartBlockToTokens(block) {
1000
- switch (block.type) {
1001
- case 'function':
1002
- return tokenizeFormulaTemplate(block.insertText || block.signature || `${block.functionName}()`);
1003
- case 'property':
1004
- return [
1005
- createPropertyToken(block.propertyKey || block.value, block.propertyType, 0, undefined, undefined, block.display),
1006
- ];
1007
- case 'operator':
1008
- return [createOperatorToken(block.operatorSymbol || block.value)];
1009
- case 'literal':
1010
- return [
1011
- createLiteralToken(block.literalValue ?? block.value, 0, undefined, undefined, block.display),
1012
- ];
1013
- default:
1014
- return [createLiteralToken(block.value)];
1015
- }
1016
- }
1017
- // ============ EMIT ============
1018
- emit() {
1019
- const formula = this.formulaString();
1020
- const tokens = this.tokens();
1021
- this.tokensChange.emit(tokens);
1022
- this.formulaChange.emit(formula);
1023
- this.onChange(tokens);
1024
- }
1025
- // ============ CDK HELPERS ============
1026
- /**
1027
- * Track function for ngFor
1028
- */
1029
- trackByToken(_index, token) {
1030
- return token.id;
1031
- }
1032
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormulaEditor, deps: [], target: i0.ɵɵFactoryTarget.Component });
1033
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: FormulaEditor, isStandalone: true, selector: "mt-formula-editor", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, initialTokens: { classPropertyName: "initialTokens", publicName: "initialTokens", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, borderless: { classPropertyName: "borderless", publicName: "borderless", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { formulaChange: "formulaChange", tokensChange: "tokensChange", onBlur: "onBlur", onFocus: "onFocus" }, providers: [
1034
- {
1035
- provide: NG_VALUE_ACCESSOR,
1036
- useExisting: forwardRef(() => FormulaEditor),
1037
- multi: true,
1038
- },
1039
- ], ngImport: i0, template: "<div\r\n [class]=\"containerClasses()\"\r\n [class.opacity-60]=\"disabled()\"\r\n [class.pointer-events-none]=\"disabled()\"\r\n (focus)=\"handleFocus()\"\r\n (blur)=\"handleBlur()\"\r\n tabindex=\"0\"\r\n>\r\n <!-- Line Numbers -->\r\n <div [class]=\"lineNumberClasses()\">\r\n @for (line of lines(); track $index) {\r\n <div class=\"text-surface-400 dark:text-surface-500 text-sm leading-6\">\r\n {{ $index + 1 }}\r\n </div>\r\n }\r\n </div>\r\n\r\n <!-- Editor Content - Single Drop Zone -->\r\n <div\r\n class=\"flex-1 p-2 flex flex-wrap gap-0.5 items-start content-start min-h-14 cursor-text\"\r\n cdkDropList\r\n cdkDropListOrientation=\"mixed\"\r\n [cdkDropListData]=\"tokens()\"\r\n [cdkDropListDisabled]=\"disabled()\"\r\n (cdkDropListDropped)=\"onDrop($event)\"\r\n >\r\n @if (tokens().length === 0) {\r\n <div class=\"text-surface-400 dark:text-surface-500 text-sm italic\">\r\n {{ placeholder() }}\r\n </div>\r\n } @else {\r\n @for (token of tokens(); track token.id; let i = $index) {\r\n <div\r\n class=\"relative inline-flex items-center group\"\r\n cdkDrag\r\n [cdkDragData]=\"token\"\r\n [cdkDragDisabled]=\"disabled()\"\r\n (cdkDragStarted)=\"onDragStart($event, token, i)\"\r\n (cdkDragEnded)=\"onDragEnd()\"\r\n >\r\n <!-- Drag Placeholder (thin cursor line) -->\r\n <div\r\n *cdkDragPlaceholder\r\n class=\"w-2 min-w-2 h-5 bg-primary rounded-sm opacity-80\"\r\n ></div>\r\n\r\n <!-- Token -->\r\n <span\r\n [class]=\"getTokenClasses(token)\"\r\n [class.border-b-2]=\"!isDragging() && isHighlighted(token)\"\r\n [class.border-primary]=\"!isDragging() && isHighlighted(token)\"\r\n (mouseenter)=\"onTokenHover(token)\"\r\n (mouseleave)=\"onTokenLeave()\"\r\n >\r\n {{ token.display ?? token.value }}\r\n </span>\r\n\r\n <!-- Delete Button (shows on hover, hidden during drag) -->\r\n @if (!isDragging() && !disabled()) {\r\n <button\r\n type=\"button\"\r\n class=\"absolute -top-1.5 -right-1.5 w-3.5 h-3.5 flex items-center justify-center bg-red-500 hover:bg-red-600 text-white rounded-full cursor-pointer scale-75 hover:scale-100 opacity-0 group-hover:opacity-100 pointer-events-none group-hover:pointer-events-auto z-10\"\r\n (click)=\"removeToken(token, i); $event.stopPropagation()\"\r\n [title]=\"\r\n token.dragBehavior === 'function'\r\n ? ('components.formulaEditor.removeFunction' | transloco)\r\n : ('components.formulaEditor.remove' | transloco)\r\n \"\r\n >\r\n <svg\r\n class=\"h-2.5 w-2.5\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"3\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M6 18L18 6M6 6l12 12\"\r\n />\r\n </svg>\r\n </button>\r\n }\r\n </div>\r\n }\r\n }\r\n </div>\r\n</div>\r\n", styles: [".cdk-drag-preview{width:20px!important;height:20px!important;min-width:20px!important;min-height:20px!important;max-width:20px!important;max-height:20px!important;border-radius:4px;opacity:.9;overflow:hidden!important;cursor:grabbing}.cdk-drag-animating{transition:none!important}.cdk-drag-dragging{opacity:1}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: DragDropModule }, { kind: "directive", type: i1.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer", "cdkDropListHasAnchor"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i1.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i1.CdkDragPlaceholder, selector: "ng-template[cdkDragPlaceholder]", inputs: ["data"] }, { kind: "ngmodule", type: FormsModule }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }] });
1040
- }
1041
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormulaEditor, decorators: [{
1042
- type: Component,
1043
- args: [{ selector: 'mt-formula-editor', standalone: true, imports: [CommonModule, DragDropModule, FormsModule, TranslocoPipe], providers: [
1044
- {
1045
- provide: NG_VALUE_ACCESSOR,
1046
- useExisting: forwardRef(() => FormulaEditor),
1047
- multi: true,
1048
- },
1049
- ], template: "<div\r\n [class]=\"containerClasses()\"\r\n [class.opacity-60]=\"disabled()\"\r\n [class.pointer-events-none]=\"disabled()\"\r\n (focus)=\"handleFocus()\"\r\n (blur)=\"handleBlur()\"\r\n tabindex=\"0\"\r\n>\r\n <!-- Line Numbers -->\r\n <div [class]=\"lineNumberClasses()\">\r\n @for (line of lines(); track $index) {\r\n <div class=\"text-surface-400 dark:text-surface-500 text-sm leading-6\">\r\n {{ $index + 1 }}\r\n </div>\r\n }\r\n </div>\r\n\r\n <!-- Editor Content - Single Drop Zone -->\r\n <div\r\n class=\"flex-1 p-2 flex flex-wrap gap-0.5 items-start content-start min-h-14 cursor-text\"\r\n cdkDropList\r\n cdkDropListOrientation=\"mixed\"\r\n [cdkDropListData]=\"tokens()\"\r\n [cdkDropListDisabled]=\"disabled()\"\r\n (cdkDropListDropped)=\"onDrop($event)\"\r\n >\r\n @if (tokens().length === 0) {\r\n <div class=\"text-surface-400 dark:text-surface-500 text-sm italic\">\r\n {{ placeholder() }}\r\n </div>\r\n } @else {\r\n @for (token of tokens(); track token.id; let i = $index) {\r\n <div\r\n class=\"relative inline-flex items-center group\"\r\n cdkDrag\r\n [cdkDragData]=\"token\"\r\n [cdkDragDisabled]=\"disabled()\"\r\n (cdkDragStarted)=\"onDragStart($event, token, i)\"\r\n (cdkDragEnded)=\"onDragEnd()\"\r\n >\r\n <!-- Drag Placeholder (thin cursor line) -->\r\n <div\r\n *cdkDragPlaceholder\r\n class=\"w-2 min-w-2 h-5 bg-primary rounded-sm opacity-80\"\r\n ></div>\r\n\r\n <!-- Token -->\r\n <span\r\n [class]=\"getTokenClasses(token)\"\r\n [class.border-b-2]=\"!isDragging() && isHighlighted(token)\"\r\n [class.border-primary]=\"!isDragging() && isHighlighted(token)\"\r\n (mouseenter)=\"onTokenHover(token)\"\r\n (mouseleave)=\"onTokenLeave()\"\r\n >\r\n {{ token.display ?? token.value }}\r\n </span>\r\n\r\n <!-- Delete Button (shows on hover, hidden during drag) -->\r\n @if (!isDragging() && !disabled()) {\r\n <button\r\n type=\"button\"\r\n class=\"absolute -top-1.5 -right-1.5 w-3.5 h-3.5 flex items-center justify-center bg-red-500 hover:bg-red-600 text-white rounded-full cursor-pointer scale-75 hover:scale-100 opacity-0 group-hover:opacity-100 pointer-events-none group-hover:pointer-events-auto z-10\"\r\n (click)=\"removeToken(token, i); $event.stopPropagation()\"\r\n [title]=\"\r\n token.dragBehavior === 'function'\r\n ? ('components.formulaEditor.removeFunction' | transloco)\r\n : ('components.formulaEditor.remove' | transloco)\r\n \"\r\n >\r\n <svg\r\n class=\"h-2.5 w-2.5\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"3\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M6 18L18 6M6 6l12 12\"\r\n />\r\n </svg>\r\n </button>\r\n }\r\n </div>\r\n }\r\n }\r\n </div>\r\n</div>\r\n", styles: [".cdk-drag-preview{width:20px!important;height:20px!important;min-width:20px!important;min-height:20px!important;max-width:20px!important;max-height:20px!important;border-radius:4px;opacity:.9;overflow:hidden!important;cursor:grabbing}.cdk-drag-animating{transition:none!important}.cdk-drag-dragging{opacity:1}\n"] }]
1050
- }], ctorParameters: () => [], propDecorators: { placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], initialTokens: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialTokens", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], borderless: [{ type: i0.Input, args: [{ isSignal: true, alias: "borderless", required: false }] }], formulaChange: [{ type: i0.Output, args: ["formulaChange"] }], tokensChange: [{ type: i0.Output, args: ["tokensChange"] }], onBlur: [{ type: i0.Output, args: ["onBlur"] }], onFocus: [{ type: i0.Output, args: ["onFocus"] }] } });
1051
-
1052
- function buildCompletionFilterText(suggestion) {
1053
- const candidates = [
1054
- suggestion.displayText,
1055
- suggestion.insertText,
1056
- suggestion.text,
1057
- ]
1058
- .map((value) => value?.trim() ?? '')
1059
- .filter((value) => value.length > 0);
1060
- return Array.from(new Set(candidates)).join(' ');
1061
- }
1062
-
1063
- function normalizeAutocompleteSuggestion(suggestion, context) {
1064
- const insertText = resolveScopedInsertText(suggestion, context);
1065
- if (insertText === (suggestion.insertText ?? suggestion.text)) {
1066
- return suggestion;
1067
- }
1068
- return {
1069
- ...suggestion,
1070
- insertText,
1071
- };
1072
- }
1073
- function resolveScopedInsertText(suggestion, context) {
1074
- const insertText = suggestion.insertText ?? suggestion.text;
1075
- if (suggestion.type !== 'Property' ||
1076
- !insertText ||
1077
- insertText.startsWith('@')) {
1078
- return insertText;
1079
- }
1080
- const tablePath = resolveTablePath(context);
1081
- if (!tablePath) {
1082
- return insertText;
1083
- }
1084
- return `@${tablePath}::${insertText}`;
1085
- }
1086
- function resolveTablePath(context) {
1087
- const tablePath = context?.tablePath?.trim();
1088
- if (tablePath) {
1089
- return tablePath;
1090
- }
1091
- const scopeToken = context?.scopeToken?.trim();
1092
- if (scopeToken) {
1093
- const scopeParameter = context?.scopeParameter?.trim();
1094
- return scopeParameter ? `${scopeToken}.${scopeParameter}` : scopeToken;
1095
- }
1096
- const scope = context?.scope?.trim();
1097
- if (!scope) {
1098
- return '';
1099
- }
1100
- return scope.replace(/^@/, '').replace(/::$/, '');
1101
- }
1102
-
1103
- const FORMULA_REFERENCE_CHARACTER = /[@\w.:]/;
1104
- function resolveCompletionRangeBounds(lineContent, column, wordStartColumn, wordEndColumn, suggestion) {
1105
- const referenceBounds = getReferenceCompletionBounds(lineContent, column, suggestion);
1106
- return (referenceBounds ?? {
1107
- startColumn: wordStartColumn,
1108
- endColumn: wordEndColumn,
1109
- });
1110
- }
1111
- function getReferenceCompletionBounds(lineContent, column, suggestion) {
1112
- const insertText = suggestion.insertText ?? suggestion.text;
1113
- if (suggestion.type !== 'Property' &&
1114
- suggestion.type !== 'Context' &&
1115
- !insertText.startsWith('@')) {
1116
- return null;
1117
- }
1118
- const cursorIndex = Math.max(0, Math.min(column - 1, lineContent.length));
1119
- let startIndex = cursorIndex;
1120
- while (startIndex > 0 &&
1121
- FORMULA_REFERENCE_CHARACTER.test(lineContent[startIndex - 1] ?? '')) {
1122
- startIndex--;
1123
- }
1124
- let endIndex = cursorIndex;
1125
- while (endIndex < lineContent.length &&
1126
- FORMULA_REFERENCE_CHARACTER.test(lineContent[endIndex] ?? '')) {
1127
- endIndex++;
1128
- }
1129
- return {
1130
- startColumn: startIndex + 1,
1131
- endColumn: endIndex + 1,
1132
- };
1133
- }
1134
-
1135
- /** Path (relative to the document base) where the host copies monaco `min/vs`. */
1136
- const MONACO_ASSET_DIR = 'assets/monaco/vs';
1137
- /**
1138
- * Shared, lazily-resolved Monaco loader promise (module scope so every editor
1139
- * instance reuses a single load).
1140
- */
1141
- let monacoLoadPromise = null;
1142
- /**
1143
- * Shared, body-level container for Monaco's overflow widgets (the suggest and
1144
- * hover popups). Monaco renders those with `position: fixed`, which is meant to
1145
- * resolve against the viewport — but a `transform` / `will-change: transform`
1146
- * on ANY ancestor turns that ancestor into the containing block, so a popup
1147
- * inside a transformed host lands at the wrong offset. This is exactly what
1148
- * breaks the suggest dropdown inside a PrimeNG dialog/drawer (`.p-dialog` /
1149
- * `.p-drawer` carry `transform: scale(1)`) and the foblex-flow canvas (`scale`).
1150
- *
1151
- * Pointing the editor's `overflowWidgetsDomNode` at a node appended straight to
1152
- * <body> — which has no transformed ancestor — makes `position: fixed` resolve
1153
- * against the viewport again, fixing every host at once instead of patching one
1154
- * container type. Created once and reused by every editor instance (Monaco
1155
- * appends and cleans up its own per-editor sub-nodes inside it), mirroring how
1156
- * VS Code shares a single overflow container.
1157
- */
1158
- let monacoOverflowWidgetsNode = null;
1159
- function resolveOverflowWidgetsNode(doc) {
1160
- if (monacoOverflowWidgetsNode?.isConnected) {
1161
- return monacoOverflowWidgetsNode;
1162
- }
1163
- const node = doc.createElement('div');
1164
- // `monaco-editor` lets Monaco's global, theme-driven suggest/hover CSS match;
1165
- // `mt-formula-editor-overflow` carries our cosmetic tweaks + escape z-index.
1166
- node.className = 'monaco-editor mt-formula-editor-overflow';
1167
- doc.body.appendChild(node);
1168
- monacoOverflowWidgetsNode = node;
1169
- return node;
1170
- }
1171
- /** Absolute URL to the copied Monaco `vs` folder, with no trailing slash. */
1172
- function resolveMonacoAssetBase(doc) {
1173
- return new URL(`${MONACO_ASSET_DIR}/`, doc.baseURI)
1174
- .toString()
1175
- .replace(/\/$/, '');
1176
- }
1177
- /**
1178
- * Point Monaco's web workers at the copied assets via a tiny same-origin proxy
1179
- * worker. Loading workers from `/assets/monaco/vs` (instead of node_modules)
1180
- * avoids the Vite `@fs` serving-allow-list 403 and the "define
1181
- * MonacoEnvironment.getWorkerUrl" warning. Set once; respects a host-provided
1182
- * MonacoEnvironment if one already exists.
1183
- */
1184
- function configureMonacoWorker(base) {
1185
- const globalScope = self;
1186
- if (globalScope.MonacoEnvironment) {
1187
- return;
1188
- }
1189
- globalScope.MonacoEnvironment = {
1190
- getWorkerUrl: () => {
1191
- const proxy = `self.MonacoEnvironment={baseUrl:'${base}/'};` +
1192
- `importScripts('${base}/base/worker/workerMain.js');`;
1193
- return `data:text/javascript;charset=utf-8,${encodeURIComponent(proxy)}`;
1194
- },
1195
- };
1196
- }
1197
- /**
1198
- * Load Monaco via its own AMD loader from `/assets/monaco/vs`. This is fully
1199
- * self-contained: `editor.main` injects its CSS and the codicon font from the
1200
- * same folder, and workers resolve from there too — so no editor CSS/font is
1201
- * pulled into the app bundle and there is no node_modules/`@fs` access at all.
1202
- */
1203
- function loadMonacoFromAssets(doc, base) {
1204
- return new Promise((resolve, reject) => {
1205
- const globalScope = window;
1206
- if (globalScope.monaco) {
1207
- resolve({ monaco: globalScope.monaco, fromAssets: true });
1208
- return;
1209
- }
1210
- const startRequire = () => {
1211
- const amdRequire = globalScope.require;
1212
- if (!amdRequire?.config) {
1213
- reject(new Error('Monaco AMD loader is unavailable'));
1214
- return;
1215
- }
1216
- configureMonacoWorker(base);
1217
- amdRequire.config({ paths: { vs: base } });
1218
- amdRequire(['vs/editor/editor.main'], () => globalScope.monaco
1219
- ? resolve({ monaco: globalScope.monaco, fromAssets: true })
1220
- : reject(new Error('Monaco did not initialize')), (error) => reject(error));
1221
- };
1222
- if (globalScope.require?.config) {
1223
- startRequire();
1224
- return;
1225
- }
1226
- const existing = doc.querySelector('script[data-mt-monaco-loader]');
1227
- if (existing) {
1228
- existing.addEventListener('load', startRequire, { once: true });
1229
- existing.addEventListener('error', () => reject(new Error('Monaco loader failed to load')), { once: true });
1230
- return;
1231
- }
1232
- const script = doc.createElement('script');
1233
- script.src = `${base}/loader.js`;
1234
- script.async = true;
1235
- script.dataset['mtMonacoLoader'] = 'true';
1236
- script.addEventListener('load', startRequire, { once: true });
1237
- script.addEventListener('error', () => reject(new Error('Monaco loader failed to load')), { once: true });
1238
- doc.head.appendChild(script);
1239
- });
1240
- }
1241
- /**
1242
- * Resolve Monaco once, preferring the self-contained assets loader and falling
1243
- * back to the bundled ESM build if `/assets/monaco/vs` is unavailable (so hosts
1244
- * that do not copy `min/vs` keep working, just without the asset-served CSS).
1245
- */
1246
- function loadMonaco(doc) {
1247
- if (monacoLoadPromise) {
1248
- return monacoLoadPromise;
1249
- }
1250
- const base = resolveMonacoAssetBase(doc);
1251
- monacoLoadPromise = loadMonacoFromAssets(doc, base).catch(async (error) => {
1252
- console.warn(`[mt-formula-editor-code] Could not load Monaco from ${base}; falling back ` +
1253
- `to the bundled monaco-editor. Copy "node_modules/monaco-editor/min/vs/" ` +
1254
- `to "/assets/monaco/vs/" in the host app's angular.json for the ` +
1255
- `self-contained loader (CSS, codicon font, and workers from assets).`, error);
1256
- const monaco = (await import('monaco-editor'));
1257
- return { monaco, fromAssets: false };
1258
- });
1259
- return monacoLoadPromise;
1260
- }
1261
- class FormulaEditorCode {
1262
- placeholder = input('Enter formula...', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
1263
- initialFormula = input('', ...(ngDevMode ? [{ debugName: "initialFormula" }] : /* istanbul ignore next */ []));
1264
- disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
1265
- language = input('formula', ...(ngDevMode ? [{ debugName: "language" }] : /* istanbul ignore next */ []));
1266
- theme = input('formula-light', ...(ngDevMode ? [{ debugName: "theme" }] : /* istanbul ignore next */ []));
1267
- borderless = input(false, ...(ngDevMode ? [{ debugName: "borderless" }] : /* istanbul ignore next */ []));
1268
- autocompleteProvider = input(null, ...(ngDevMode ? [{ debugName: "autocompleteProvider" }] : /* istanbul ignore next */ []));
1269
- autocompleteDebounceMs = input(150, ...(ngDevMode ? [{ debugName: "autocompleteDebounceMs" }] : /* istanbul ignore next */ []));
1270
- formulaChange = output();
1271
- onBlur = output();
1272
- onFocus = output();
1273
- editorHost = viewChild('editorHost', ...(ngDevMode ? [{ debugName: "editorHost" }] : /* istanbul ignore next */ []));
1274
- zone = inject(NgZone);
1275
- document = inject(DOCUMENT);
1276
- monaco = null;
1277
- editor = null;
1278
- model = null;
1279
- disposables = [];
1280
- resizeObserver = null;
1281
- completionProvider = null;
1282
- // Autocomplete state - using RxJS for proper debounce and cancellation
1283
- autocompleteSubject = new Subject();
1284
- autocompleteSubscription = null;
1285
- cancelAutocomplete$ = new Subject();
1286
- currentAutocompleteRequestId = 0;
1287
- static formulaAssetsReady = false;
1288
- static monacoStylesReady = false;
1289
- value = signal('', ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
1290
- isFocused = signal(false, ...(ngDevMode ? [{ debugName: "isFocused" }] : /* istanbul ignore next */ []));
1291
- showPlaceholder = computed(() => this.value().length === 0 && !this.isFocused(), ...(ngDevMode ? [{ debugName: "showPlaceholder" }] : /* istanbul ignore next */ []));
1292
- containerClasses = computed(() => {
1293
- const base = 'relative flex min-h-20 flex-col bg-white dark:bg-surface-800 font-mono text-sm';
1294
- if (this.borderless()) {
1295
- return base;
1296
- }
1297
- return `${base} rounded-md border border-surface-200 dark:border-surface-700 focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/10`;
1298
- }, ...(ngDevMode ? [{ debugName: "containerClasses" }] : /* istanbul ignore next */ []));
1299
- hasWrittenValue = false;
1300
- isApplyingExternalValue = false;
1301
- onChange = () => { };
1302
- onTouched = () => { };
1303
- constructor() {
1304
- effect(() => {
1305
- const initial = this.initialFormula();
1306
- if (!this.hasWrittenValue && this.value().length === 0 && initial) {
1307
- this.value.set(initial);
1308
- }
1309
- });
1310
- effect(() => {
1311
- const readOnly = this.disabled();
1312
- if (this.editor) {
1313
- this.editor.updateOptions({ readOnly });
1314
- }
1315
- });
1316
- effect(() => {
1317
- const theme = this.theme();
1318
- if (this.monaco) {
1319
- this.monaco.editor.setTheme(theme);
1320
- }
1321
- });
1322
- effect(() => {
1323
- const language = this.language();
1324
- if (this.monaco && this.model) {
1325
- this.ensureFormulaAssets(this.monaco);
1326
- this.monaco.editor.setModelLanguage(this.model, language);
1327
- // Completion provider is registered in the autocompleteProvider effect
1328
- }
1329
- });
1330
- effect(() => {
1331
- // Track both language and provider changes - reading signals to subscribe
1332
- const _provider = this.autocompleteProvider();
1333
- const language = this.language();
1334
- if (this.monaco && language) {
1335
- this.registerCompletionProvider();
1336
- }
1337
- });
1338
- }
1339
- ngAfterViewInit() {
1340
- this.zone.runOutsideAngular(() => {
1341
- void this.initEditor();
1342
- });
1343
- }
1344
- ngOnDestroy() {
1345
- this.resizeObserver?.disconnect();
1346
- // Cancel any pending autocomplete
1347
- this.cancelAutocomplete$.next();
1348
- this.cancelAutocomplete$.complete();
1349
- this.autocompleteSubject.complete();
1350
- this.autocompleteSubscription?.unsubscribe();
1351
- if (this.completionProvider) {
1352
- this.completionProvider.dispose();
1353
- this.completionProvider = null;
1354
- }
1355
- this.disposables.forEach((disposable) => disposable.dispose());
1356
- this.editor?.dispose();
1357
- this.model?.dispose();
1358
- }
1359
- writeValue(value) {
1360
- this.hasWrittenValue = true;
1361
- const next = value ?? '';
1362
- this.value.set(next);
1363
- this.syncEditorValue(next);
1364
- }
1365
- registerOnChange(fn) {
1366
- this.onChange = fn;
1367
- }
1368
- registerOnTouched(fn) {
1369
- this.onTouched = fn;
1370
- }
1371
- addBlock(block) {
1372
- if (this.disabled())
1373
- return;
1374
- const { text, cursorOffset } = this.smartBlockToText(block);
1375
- this.insertText(text, cursorOffset);
1376
- }
1377
- insertText(text, cursorOffset = 0) {
1378
- if (this.disabled())
1379
- return;
1380
- if (!this.editor || !this.model || !this.monaco) {
1381
- const next = `${this.value()}${text}`;
1382
- this.emitValue(next);
1383
- return;
1384
- }
1385
- const selection = this.editor.getSelection() ?? new this.monaco.Selection(1, 1, 1, 1);
1386
- this.editor.executeEdits('formula-editor-code', [
1387
- { range: selection, text, forceMoveMarkers: true },
1388
- ]);
1389
- const startOffset = this.model.getOffsetAt(selection.getStartPosition());
1390
- const nextOffset = Math.max(0, Math.min(startOffset + text.length + cursorOffset, this.model.getValueLength()));
1391
- const nextPos = this.model.getPositionAt(nextOffset);
1392
- this.editor.setSelection(new this.monaco.Selection(nextPos.lineNumber, nextPos.column, nextPos.lineNumber, nextPos.column));
1393
- this.editor.focus();
1394
- }
1395
- clear() {
1396
- if (this.disabled())
1397
- return;
1398
- if (this.model) {
1399
- this.isApplyingExternalValue = true;
1400
- this.model.setValue('');
1401
- this.isApplyingExternalValue = false;
1402
- }
1403
- this.emitValue('');
1404
- }
1405
- getValue() {
1406
- return this.value();
1407
- }
1408
- async initEditor() {
1409
- const host = this.editorHost()?.nativeElement;
1410
- if (!host)
1411
- return;
1412
- let loaded;
1413
- try {
1414
- loaded = await loadMonaco(this.document);
1415
- }
1416
- catch (error) {
1417
- console.warn('Failed to load Monaco editor:', error);
1418
- return;
1419
- }
1420
- const monaco = loaded.monaco;
1421
- // The assets (AMD) path injects its own CSS + codicon font from
1422
- // /assets/monaco/vs. Only the bundled ESM fallback needs the manual link.
1423
- if (!loaded.fromAssets) {
1424
- this.ensureMonacoStylesLoaded();
1425
- }
1426
- this.monaco = monaco;
1427
- this.ensureFormulaAssets(monaco);
1428
- const model = monaco.editor.createModel(this.value(), this.language());
1429
- this.model = model;
1430
- const editor = monaco.editor.create(host, {
1431
- model,
1432
- theme: this.theme(),
1433
- readOnly: this.disabled(),
1434
- minimap: { enabled: false },
1435
- scrollBeyondLastLine: false,
1436
- wordWrap: 'on',
1437
- fontSize: 14,
1438
- lineHeight: 21,
1439
- lineNumbers: 'on',
1440
- lineNumbersMinChars: 3,
1441
- lineDecorationsWidth: 10,
1442
- glyphMargin: false,
1443
- automaticLayout: true,
1444
- fixedOverflowWidgets: true,
1445
- // Render suggest/hover popups in a body-level node so their
1446
- // `position: fixed` resolves against the viewport, not a transformed
1447
- // ancestor (PrimeNG dialog/drawer, foblex-flow canvas). See
1448
- // resolveOverflowWidgetsNode above.
1449
- overflowWidgetsDomNode: resolveOverflowWidgetsNode(this.document),
1450
- suggestOnTriggerCharacters: true,
1451
- quickSuggestions: { other: true, comments: false, strings: true },
1452
- renderLineHighlight: 'line',
1453
- matchBrackets: 'always',
1454
- bracketPairColorization: { enabled: true },
1455
- padding: { top: 4, bottom: 4 },
1456
- fontFamily: "Consolas, 'Courier New', monospace",
1457
- fontLigatures: false,
1458
- cursorBlinking: 'blink',
1459
- cursorStyle: 'line',
1460
- cursorWidth: 2,
1461
- renderWhitespace: 'selection',
1462
- folding: false,
1463
- occurrencesHighlight: 'singleFile',
1464
- selectionHighlight: true,
1465
- roundedSelection: true,
1466
- smoothScrolling: true,
1467
- mouseWheelZoom: false,
1468
- contextmenu: true,
1469
- scrollbar: {
1470
- vertical: 'auto',
1471
- horizontal: 'auto',
1472
- verticalScrollbarSize: 14,
1473
- horizontalScrollbarSize: 10,
1474
- useShadows: false,
1475
- },
1476
- });
1477
- this.editor = editor;
1478
- this.attachEditorListeners(editor, model);
1479
- this.setupResizeObserver(host, editor);
1480
- this.registerCompletionProvider();
1481
- }
1482
- ensureMonacoStylesLoaded() {
1483
- if (FormulaEditorCode.monacoStylesReady) {
1484
- return;
1485
- }
1486
- const doc = this.document;
1487
- if (!doc?.head) {
1488
- return;
1489
- }
1490
- const existing = doc.head.querySelector('link[data-mt-monaco-style="editor-main"]');
1491
- if (existing) {
1492
- FormulaEditorCode.monacoStylesReady = true;
1493
- return;
1494
- }
1495
- // Monaco assets are copied by the app to /assets/monaco/vs/.
1496
- const stylesheetHref = new URL('assets/monaco/vs/editor/editor.main.css', doc.baseURI).toString();
1497
- const link = doc.createElement('link');
1498
- link.rel = 'stylesheet';
1499
- link.href = stylesheetHref;
1500
- link.dataset['mtMonacoStyle'] = 'editor-main';
1501
- link.onerror = () => {
1502
- console.warn(`[mt-formula-editor-code] Failed to load Monaco stylesheet at ${stylesheetHref}. ` +
1503
- `The editor will render without styles. Ensure the host app installs "monaco-editor" ` +
1504
- `and copies "node_modules/monaco-editor/min/vs/" to "/assets/monaco/vs/" in angular.json.`);
1505
- };
1506
- doc.head.appendChild(link);
1507
- FormulaEditorCode.monacoStylesReady = true;
1508
- }
1509
- ensureFormulaAssets(monaco) {
1510
- if (FormulaEditorCode.formulaAssetsReady)
1511
- return;
1512
- monaco.languages.register({ id: 'formula' });
1513
- monaco.languages.setMonarchTokensProvider('formula', {
1514
- keywords: ['true', 'false', 'null'],
1515
- operators: [
1516
- '==',
1517
- '!=',
1518
- '>=',
1519
- '<=',
1520
- '>',
1521
- '<',
1522
- '+',
1523
- '-',
1524
- '*',
1525
- '/',
1526
- '%',
1527
- '^',
1528
- '&&',
1529
- '||',
1530
- '!',
1531
- ],
1532
- symbols: /[=><!~?:&|+\-*/^%]+/,
1533
- tokenizer: {
1534
- root: [
1535
- [/@[a-zA-Z_][\w.]*::[\w_]+/, 'type.identifier'],
1536
- [/@[a-zA-Z_][\w.]*/, 'type.identifier'],
1537
- [/\b[A-Z_][A-Z0-9_]*\b/, 'function'],
1538
- [
1539
- /[a-zA-Z_][\w_]*/,
1540
- {
1541
- cases: {
1542
- '@keywords': 'keyword',
1543
- '@default': 'identifier',
1544
- },
1545
- },
1546
- ],
1547
- [/[0-9]+(\.[0-9]+)?/, 'number'],
1548
- [/"/, { token: 'string.quote', bracket: '@open', next: '@string' }],
1549
- [/'[^'\\]*(?:\\.[^'\\]*)*'/, 'string'],
1550
- [/@symbols/, { cases: { '@operators': 'operator', '@default': '' } }],
1551
- [/[()[\]{}]/, '@brackets'],
1552
- [/[;,.]/, 'delimiter'],
1553
- { include: '@whitespace' },
1554
- ],
1555
- whitespace: [
1556
- [/\s+/, 'white'],
1557
- [/\/\/.*$/, 'comment'],
1558
- [/\/\*/, 'comment', '@comment'],
1559
- ],
1560
- comment: [
1561
- [/[^/*]+/, 'comment'],
1562
- [/\*\//, 'comment', '@pop'],
1563
- [/[/*]/, 'comment'],
1564
- ],
1565
- string: [
1566
- [/[^\\"]+/, 'string'],
1567
- [/\\./, 'string.escape'],
1568
- [/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }],
1569
- ],
1570
- },
1571
- });
1572
- monaco.languages.setLanguageConfiguration('formula', {
1573
- brackets: [
1574
- ['{', '}'],
1575
- ['[', ']'],
1576
- ['(', ')'],
1577
- ],
1578
- autoClosingPairs: [
1579
- { open: '{', close: '}' },
1580
- { open: '[', close: ']' },
1581
- { open: '(', close: ')' },
1582
- { open: '"', close: '"' },
1583
- { open: "'", close: "'" },
1584
- ],
1585
- surroundingPairs: [
1586
- { open: '{', close: '}' },
1587
- { open: '[', close: ']' },
1588
- { open: '(', close: ')' },
1589
- { open: '"', close: '"' },
1590
- { open: "'", close: "'" },
1591
- ],
1592
- });
1593
- monaco.editor.defineTheme('formula-light', {
1594
- base: 'vs',
1595
- inherit: true,
1596
- rules: [
1597
- // VS Code Light+ token colors
1598
- { token: 'function', foreground: '795E26', fontStyle: 'bold' },
1599
- { token: 'type.identifier', foreground: '267F99' },
1600
- { token: 'keyword', foreground: '0000FF', fontStyle: 'bold' },
1601
- { token: 'number', foreground: '098658' },
1602
- { token: 'string', foreground: 'A31515' },
1603
- { token: 'string.escape', foreground: 'EE0000' },
1604
- { token: 'operator', foreground: '000000' },
1605
- { token: 'delimiter', foreground: '000000' },
1606
- { token: 'comment', foreground: '008000', fontStyle: 'italic' },
1607
- { token: 'identifier', foreground: '001080' },
1608
- { token: 'variable', foreground: '001080' },
1609
- ],
1610
- colors: {
1611
- // Editor core
1612
- 'editor.background': '#FFFFFF',
1613
- 'editor.foreground': '#000000',
1614
- 'editorCursor.foreground': '#000000',
1615
- // Line numbers
1616
- 'editorLineNumber.foreground': '#237893',
1617
- 'editorLineNumber.activeForeground': '#0B216F',
1618
- // Line highlight
1619
- 'editorLineHighlight.background': '#00000000',
1620
- 'editorLineHighlight.border': '#EEF0F1',
1621
- // Selection
1622
- 'editor.selectionBackground': '#ADD6FF',
1623
- 'editor.inactiveSelectionBackground': '#E5EBF1',
1624
- 'editor.selectionHighlightBackground': '#ADD6FF80',
1625
- // Word highlight (when cursor is on a word/function)
1626
- 'editor.wordHighlightBackground': '#57575740',
1627
- 'editor.wordHighlightStrongBackground': '#0E639C40',
1628
- 'editor.wordHighlightBorder': '#595959',
1629
- 'editor.wordHighlightStrongBorder': '#0E639C',
1630
- // Find match
1631
- 'editor.findMatchBackground': '#A8AC94',
1632
- 'editor.findMatchHighlightBackground': '#EA5C0055',
1633
- // Bracket matching
1634
- 'editorBracketMatch.background': '#0064001A',
1635
- 'editorBracketMatch.border': '#B9B9B9',
1636
- // Indent guides
1637
- 'editorIndentGuide.background': '#D3D3D3',
1638
- 'editorIndentGuide.activeBackground': '#939393',
1639
- // Gutter
1640
- 'editorGutter.background': '#FFFFFF',
1641
- // Suggest widget
1642
- 'editorSuggestWidget.background': '#F3F3F3',
1643
- 'editorSuggestWidget.border': '#C8C8C8',
1644
- 'editorSuggestWidget.foreground': '#000000',
1645
- 'editorSuggestWidget.selectedBackground': '#0060C0',
1646
- 'editorSuggestWidget.selectedForeground': '#FFFFFF',
1647
- 'editorSuggestWidget.highlightForeground': '#0066BF',
1648
- 'editorSuggestWidget.focusHighlightForeground': '#FFFFFF',
1649
- // Hover widget
1650
- 'editorHoverWidget.background': '#F3F3F3',
1651
- 'editorHoverWidget.border': '#C8C8C8',
1652
- 'editorHoverWidget.foreground': '#000000',
1653
- // Generic widget
1654
- 'editorWidget.background': '#F3F3F3',
1655
- 'editorWidget.border': '#C8C8C8',
1656
- // Scrollbar
1657
- 'scrollbarSlider.background': '#64646433',
1658
- 'scrollbarSlider.hoverBackground': '#646464B3',
1659
- 'scrollbarSlider.activeBackground': '#646464B3',
1660
- },
1661
- });
1662
- monaco.editor.defineTheme('formula-dark', {
1663
- base: 'vs-dark',
1664
- inherit: true,
1665
- rules: [
1666
- // VS Code Dark+ token colors
1667
- { token: 'function', foreground: 'DCDCAA', fontStyle: 'bold' },
1668
- { token: 'type.identifier', foreground: '4EC9B0' },
1669
- { token: 'keyword', foreground: '569CD6', fontStyle: 'bold' },
1670
- { token: 'number', foreground: 'B5CEA8' },
1671
- { token: 'string', foreground: 'CE9178' },
1672
- { token: 'string.escape', foreground: 'D7BA7D' },
1673
- { token: 'operator', foreground: 'D4D4D4' },
1674
- { token: 'delimiter', foreground: 'D4D4D4' },
1675
- { token: 'comment', foreground: '6A9955', fontStyle: 'italic' },
1676
- { token: 'identifier', foreground: '9CDCFE' },
1677
- { token: 'variable', foreground: '9CDCFE' },
1678
- ],
1679
- colors: {
1680
- // Editor core
1681
- 'editor.background': '#1E1E1E',
1682
- 'editor.foreground': '#D4D4D4',
1683
- 'editorCursor.foreground': '#AEAFAD',
1684
- // Line numbers
1685
- 'editorLineNumber.foreground': '#858585',
1686
- 'editorLineNumber.activeForeground': '#C6C6C6',
1687
- // Line highlight
1688
- 'editorLineHighlight.background': '#2A2D2E',
1689
- 'editorLineHighlight.border': '#282828',
1690
- // Selection
1691
- 'editor.selectionBackground': '#264F78',
1692
- 'editor.inactiveSelectionBackground': '#3A3D41',
1693
- 'editor.selectionHighlightBackground': '#ADD6FF26',
1694
- // Word highlight (when cursor is on a word/function)
1695
- 'editor.wordHighlightBackground': '#575757B3',
1696
- 'editor.wordHighlightStrongBackground': '#004972B3',
1697
- 'editor.wordHighlightBorder': '#858585',
1698
- 'editor.wordHighlightStrongBorder': '#007ACC',
1699
- // Find match
1700
- 'editor.findMatchBackground': '#515C6A',
1701
- 'editor.findMatchHighlightBackground': '#EA5C0055',
1702
- // Bracket matching
1703
- 'editorBracketMatch.background': '#0064001A',
1704
- 'editorBracketMatch.border': '#888888',
1705
- // Indent guides
1706
- 'editorIndentGuide.background': '#404040',
1707
- 'editorIndentGuide.activeBackground': '#707070',
1708
- // Gutter
1709
- 'editorGutter.background': '#1E1E1E',
1710
- // Suggest widget
1711
- 'editorSuggestWidget.background': '#252526',
1712
- 'editorSuggestWidget.border': '#454545',
1713
- 'editorSuggestWidget.foreground': '#D4D4D4',
1714
- 'editorSuggestWidget.selectedBackground': '#04395E',
1715
- 'editorSuggestWidget.selectedForeground': '#FFFFFF',
1716
- 'editorSuggestWidget.highlightForeground': '#18A3FF',
1717
- 'editorSuggestWidget.focusHighlightForeground': '#18A3FF',
1718
- // Hover widget
1719
- 'editorHoverWidget.background': '#252526',
1720
- 'editorHoverWidget.border': '#454545',
1721
- 'editorHoverWidget.foreground': '#D4D4D4',
1722
- // Generic widget
1723
- 'editorWidget.background': '#252526',
1724
- 'editorWidget.border': '#454545',
1725
- // Scrollbar
1726
- 'scrollbarSlider.background': '#79797966',
1727
- 'scrollbarSlider.hoverBackground': '#646464B3',
1728
- 'scrollbarSlider.activeBackground': '#BFBFBF66',
1729
- },
1730
- });
1731
- FormulaEditorCode.formulaAssetsReady = true;
1732
- }
1733
- attachEditorListeners(editor, model) {
1734
- this.disposables.push(model.onDidChangeContent(() => {
1735
- if (this.isApplyingExternalValue)
1736
- return;
1737
- const next = model.getValue();
1738
- this.emitValue(next);
1739
- this.scheduleAutocomplete();
1740
- }), editor.onDidFocusEditorText(() => {
1741
- this.zone.run(() => {
1742
- this.isFocused.set(true);
1743
- this.onFocus.emit();
1744
- });
1745
- }), editor.onDidBlurEditorText(() => {
1746
- this.zone.run(() => {
1747
- this.isFocused.set(false);
1748
- this.onTouched();
1749
- this.onBlur.emit();
1750
- });
1751
- }));
1752
- }
1753
- setupResizeObserver(host, editor) {
1754
- if (typeof ResizeObserver === 'undefined')
1755
- return;
1756
- this.resizeObserver = new ResizeObserver(() => {
1757
- editor.layout();
1758
- });
1759
- this.resizeObserver.observe(host);
1760
- }
1761
- scheduleAutocomplete() {
1762
- if (!this.editor || !this.autocompleteProvider())
1763
- return;
1764
- // Emit to subject - debouncing is handled in setupAutocompleteStream
1765
- this.autocompleteSubject.next();
1766
- }
1767
- setupAutocompleteStream() {
1768
- // Clean up previous subscription
1769
- this.autocompleteSubscription?.unsubscribe();
1770
- const debounceMs = Math.max(0, this.autocompleteDebounceMs());
1771
- this.autocompleteSubscription = this.autocompleteSubject
1772
- .pipe(debounceTime(debounceMs), filter(() => !!this.editor && !!this.autocompleteProvider()))
1773
- .subscribe(() => {
1774
- // Trigger Monaco's suggest widget - this will call provideCompletionItems
1775
- this.editor?.trigger('formula-editor-code', 'editor.action.triggerSuggest', {});
1776
- });
1777
- }
1778
- registerCompletionProvider() {
1779
- if (!this.monaco)
1780
- return;
1781
- // Clean up previous provider
1782
- if (this.completionProvider) {
1783
- this.completionProvider.dispose();
1784
- this.completionProvider = null;
1785
- }
1786
- const provider = this.autocompleteProvider();
1787
- if (!provider)
1788
- return;
1789
- const language = this.language();
1790
- // Setup the autocomplete stream for debouncing
1791
- this.setupAutocompleteStream();
1792
- this.completionProvider =
1793
- this.monaco.languages.registerCompletionItemProvider(language, {
1794
- triggerCharacters: ['@', '.', ':', '(', ',', ' '],
1795
- provideCompletionItems: async (model, position) => {
1796
- // Cancel any previous in-flight request
1797
- this.cancelAutocomplete$.next();
1798
- // Generate unique request ID
1799
- const requestId = ++this.currentAutocompleteRequestId;
1800
- const cursorPosition = model.getOffsetAt(position);
1801
- const formula = model.getValue();
1802
- try {
1803
- const response = await this.resolveAutocompleteResponse(provider, { formula, cursorPosition }, requestId);
1804
- // Check if this request is still the current one
1805
- if (!response || requestId !== this.currentAutocompleteRequestId) {
1806
- return { suggestions: [] };
1807
- }
1808
- return {
1809
- suggestions: (response.suggestions ?? []).map((suggestion, index) => {
1810
- const normalizedSuggestion = normalizeAutocompleteSuggestion(suggestion, response.context);
1811
- const label = normalizedSuggestion.displayText?.trim() ||
1812
- normalizedSuggestion.text;
1813
- const description = normalizedSuggestion.description?.trim() || '';
1814
- const detail = description || normalizedSuggestion.category || '';
1815
- const insertText = normalizedSuggestion.insertText ??
1816
- normalizedSuggestion.text;
1817
- const { text, rule } = this.applyCursorOffset(insertText, normalizedSuggestion.cursorOffset ?? 0);
1818
- return {
1819
- label,
1820
- kind: this.mapSuggestionKind(normalizedSuggestion.type),
1821
- insertText: text,
1822
- insertTextRules: rule,
1823
- detail,
1824
- documentation: description
1825
- ? { value: description }
1826
- : undefined,
1827
- range: this.getCompletionRanges(model, position, normalizedSuggestion),
1828
- sortText: String(index).padStart(4, '0'),
1829
- filterText: buildCompletionFilterText(normalizedSuggestion),
1830
- };
1831
- }),
1832
- };
1833
- }
1834
- catch (error) {
1835
- // Request was cancelled or failed - return empty
1836
- console.debug('Autocomplete request cancelled or failed:', error);
1837
- return { suggestions: [] };
1838
- }
1839
- },
1840
- });
1841
- }
1842
- async resolveAutocompleteResponse(provider, request, _requestId) {
1843
- const result = provider(request);
1844
- if (!result)
1845
- return null;
1846
- // Convert to Observable for unified handling with cancellation
1847
- let source$;
1848
- if (isObservable(result)) {
1849
- source$ = result;
1850
- }
1851
- else if (result instanceof Promise) {
1852
- source$ = from(result);
1853
- }
1854
- else {
1855
- // Synchronous result
1856
- return result;
1857
- }
1858
- // Use takeUntil for cancellation
1859
- return await firstValueFrom(source$.pipe(takeUntil(this.cancelAutocomplete$), catchError(() => of(null)))).catch(() => null);
1860
- }
1861
- applyCursorOffset(insertText, cursorOffset) {
1862
- if (!cursorOffset) {
1863
- return { text: insertText };
1864
- }
1865
- const cursorIndex = Math.max(0, Math.min(insertText.length + cursorOffset, insertText.length));
1866
- const snippet = insertText.slice(0, cursorIndex) + '$0' + insertText.slice(cursorIndex);
1867
- return {
1868
- text: snippet,
1869
- rule: this.monaco?.languages.CompletionItemInsertTextRule.InsertAsSnippet,
1870
- };
1871
- }
1872
- getCompletionRanges(model, position, suggestion) {
1873
- const word = model.getWordUntilPosition(position);
1874
- const { startColumn, endColumn } = resolveCompletionRangeBounds(model.getLineContent(position.lineNumber), position.column, word.startColumn, Math.max(word.endColumn, position.column), suggestion);
1875
- return {
1876
- insert: new this.monaco.Range(position.lineNumber, startColumn, position.lineNumber, position.column),
1877
- replace: new this.monaco.Range(position.lineNumber, startColumn, position.lineNumber, endColumn),
1878
- };
1879
- }
1880
- mapSuggestionKind(type) {
1881
- if (!this.monaco) {
1882
- return 17;
1883
- }
1884
- switch (type) {
1885
- case 'Function':
1886
- return this.monaco.languages.CompletionItemKind.Function;
1887
- case 'Operator':
1888
- return this.monaco.languages.CompletionItemKind.Operator;
1889
- case 'Property':
1890
- return this.monaco.languages.CompletionItemKind.Field;
1891
- case 'Context':
1892
- return this.monaco.languages.CompletionItemKind.Module;
1893
- case 'Keyword':
1894
- return this.monaco.languages.CompletionItemKind.Keyword;
1895
- default:
1896
- return this.monaco.languages.CompletionItemKind.Text;
1897
- }
1898
- }
1899
- syncEditorValue(value) {
1900
- if (!this.model)
1901
- return;
1902
- if (this.model.getValue() === value)
1903
- return;
1904
- this.isApplyingExternalValue = true;
1905
- this.model.setValue(value);
1906
- this.isApplyingExternalValue = false;
1907
- }
1908
- smartBlockToText(block) {
1909
- switch (block.type) {
1910
- case 'function': {
1911
- const text = block.insertText ??
1912
- block.signature ??
1913
- `${block.functionName ?? block.value}()`;
1914
- const cursorOffset = block.cursorOffset ?? (text.endsWith(')') ? -1 : 0);
1915
- return { text, cursorOffset };
1916
- }
1917
- case 'property':
1918
- return { text: block.value ?? '', cursorOffset: 0 };
1919
- case 'operator':
1920
- return {
1921
- text: block.operatorSymbol ?? block.value ?? '',
1922
- cursorOffset: 0,
1923
- };
1924
- case 'literal':
1925
- return {
1926
- text: this.formatLiteral(block.literalValue ?? block.value ?? ''),
1927
- cursorOffset: 0,
1928
- };
1929
- default:
1930
- return { text: block.value ?? '', cursorOffset: 0 };
1931
- }
1932
- }
1933
- formatLiteral(value) {
1934
- if (typeof value === 'string') {
1935
- if (value.startsWith('"') && value.endsWith('"')) {
1936
- return value;
1937
- }
1938
- return `"${value}"`;
1939
- }
1940
- return String(value);
1941
- }
1942
- emitValue(value) {
1943
- this.zone.run(() => {
1944
- this.value.set(value);
1945
- this.formulaChange.emit(value);
1946
- this.onChange(value);
1947
- });
1948
- }
1949
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormulaEditorCode, deps: [], target: i0.ɵɵFactoryTarget.Component });
1950
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: FormulaEditorCode, isStandalone: true, selector: "mt-formula-editor-code", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, initialFormula: { classPropertyName: "initialFormula", publicName: "initialFormula", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, language: { classPropertyName: "language", publicName: "language", isSignal: true, isRequired: false, transformFunction: null }, theme: { classPropertyName: "theme", publicName: "theme", isSignal: true, isRequired: false, transformFunction: null }, borderless: { classPropertyName: "borderless", publicName: "borderless", isSignal: true, isRequired: false, transformFunction: null }, autocompleteProvider: { classPropertyName: "autocompleteProvider", publicName: "autocompleteProvider", isSignal: true, isRequired: false, transformFunction: null }, autocompleteDebounceMs: { classPropertyName: "autocompleteDebounceMs", publicName: "autocompleteDebounceMs", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { formulaChange: "formulaChange", onBlur: "onBlur", onFocus: "onFocus" }, host: { classAttribute: "block mt-formula-editor-code" }, providers: [
1951
- {
1952
- provide: NG_VALUE_ACCESSOR,
1953
- useExisting: forwardRef(() => FormulaEditorCode),
1954
- multi: true,
1955
- },
1956
- ], viewQueries: [{ propertyName: "editorHost", first: true, predicate: ["editorHost"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\r\n [class]=\"containerClasses()\"\r\n [class.opacity-60]=\"disabled()\"\r\n [class.pointer-events-none]=\"disabled()\"\r\n>\r\n <div #editorHost class=\"min-h-20 flex-1\"></div>\r\n\r\n @if (showPlaceholder()) {\r\n <div\r\n class=\"mt-formula-editor-code__placeholder text-sm italic text-surface-400 dark:text-surface-500\"\r\n >\r\n {{ placeholder() }}\r\n </div>\r\n }\r\n</div>\r\n", styles: [".mt-formula-editor-code{position:relative;--mt-formula-editor-code-gutter: 3.25rem;--mt-formula-editor-code-placeholder-top: .25rem}.mt-formula-editor-code__placeholder{position:absolute;top:var(--mt-formula-editor-code-placeholder-top);left:var(--mt-formula-editor-code-gutter);pointer-events:none;z-index:2;white-space:nowrap}.mt-formula-editor-code .monaco-editor .overflow-guard{overflow:visible}.mt-formula-editor-overflow{position:fixed;inset:0 auto auto 0;width:0;height:0;z-index:100000;transform:none}.mt-formula-editor-code .monaco-editor .cursor{transition:opacity .1s ease-in-out}.mt-formula-editor-code .monaco-editor .selected-text{border-radius:0}.mt-formula-editor-code .monaco-editor .bracket-match{border-radius:2px}.mt-formula-editor-code .monaco-editor .view-overlays .current-line{border:none}.mt-formula-editor-code .monaco-editor .monaco-scrollable-element>.scrollbar>.slider{border-radius:0}.mt-formula-editor-code .monaco-editor .suggest-widget,.mt-formula-editor-overflow .suggest-widget{z-index:2000;border-radius:3px;box-shadow:0 2px 8px #00000029,0 0 0 1px #0000000a}.mt-formula-editor-code .monaco-editor .suggest-widget .monaco-list-row,.mt-formula-editor-overflow .suggest-widget .monaco-list-row{padding:0 4px}.mt-formula-editor-code .monaco-editor .suggest-widget .monaco-list-row.focused,.mt-formula-editor-overflow .suggest-widget .monaco-list-row.focused{border-radius:3px}.mt-formula-editor-code .monaco-editor .monaco-hover,.mt-formula-editor-overflow .monaco-hover{z-index:2000;border-radius:3px;box-shadow:0 2px 8px #00000029}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1957
- }
1958
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormulaEditorCode, decorators: [{
1959
- type: Component,
1960
- args: [{ selector: 'mt-formula-editor-code', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
1961
- class: 'block mt-formula-editor-code',
1962
- }, providers: [
1963
- {
1964
- provide: NG_VALUE_ACCESSOR,
1965
- useExisting: forwardRef(() => FormulaEditorCode),
1966
- multi: true,
1967
- },
1968
- ], template: "<div\r\n [class]=\"containerClasses()\"\r\n [class.opacity-60]=\"disabled()\"\r\n [class.pointer-events-none]=\"disabled()\"\r\n>\r\n <div #editorHost class=\"min-h-20 flex-1\"></div>\r\n\r\n @if (showPlaceholder()) {\r\n <div\r\n class=\"mt-formula-editor-code__placeholder text-sm italic text-surface-400 dark:text-surface-500\"\r\n >\r\n {{ placeholder() }}\r\n </div>\r\n }\r\n</div>\r\n", styles: [".mt-formula-editor-code{position:relative;--mt-formula-editor-code-gutter: 3.25rem;--mt-formula-editor-code-placeholder-top: .25rem}.mt-formula-editor-code__placeholder{position:absolute;top:var(--mt-formula-editor-code-placeholder-top);left:var(--mt-formula-editor-code-gutter);pointer-events:none;z-index:2;white-space:nowrap}.mt-formula-editor-code .monaco-editor .overflow-guard{overflow:visible}.mt-formula-editor-overflow{position:fixed;inset:0 auto auto 0;width:0;height:0;z-index:100000;transform:none}.mt-formula-editor-code .monaco-editor .cursor{transition:opacity .1s ease-in-out}.mt-formula-editor-code .monaco-editor .selected-text{border-radius:0}.mt-formula-editor-code .monaco-editor .bracket-match{border-radius:2px}.mt-formula-editor-code .monaco-editor .view-overlays .current-line{border:none}.mt-formula-editor-code .monaco-editor .monaco-scrollable-element>.scrollbar>.slider{border-radius:0}.mt-formula-editor-code .monaco-editor .suggest-widget,.mt-formula-editor-overflow .suggest-widget{z-index:2000;border-radius:3px;box-shadow:0 2px 8px #00000029,0 0 0 1px #0000000a}.mt-formula-editor-code .monaco-editor .suggest-widget .monaco-list-row,.mt-formula-editor-overflow .suggest-widget .monaco-list-row{padding:0 4px}.mt-formula-editor-code .monaco-editor .suggest-widget .monaco-list-row.focused,.mt-formula-editor-overflow .suggest-widget .monaco-list-row.focused{border-radius:3px}.mt-formula-editor-code .monaco-editor .monaco-hover,.mt-formula-editor-overflow .monaco-hover{z-index:2000;border-radius:3px;box-shadow:0 2px 8px #00000029}\n"] }]
1969
- }], ctorParameters: () => [], propDecorators: { placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], initialFormula: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialFormula", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], language: [{ type: i0.Input, args: [{ isSignal: true, alias: "language", required: false }] }], theme: [{ type: i0.Input, args: [{ isSignal: true, alias: "theme", required: false }] }], borderless: [{ type: i0.Input, args: [{ isSignal: true, alias: "borderless", required: false }] }], autocompleteProvider: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocompleteProvider", required: false }] }], autocompleteDebounceMs: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocompleteDebounceMs", required: false }] }], formulaChange: [{ type: i0.Output, args: ["formulaChange"] }], onBlur: [{ type: i0.Output, args: ["onBlur"] }], onFocus: [{ type: i0.Output, args: ["onFocus"] }], editorHost: [{ type: i0.ViewChild, args: ['editorHost', { isSignal: true }] }] } });
1970
-
1971
- /**
1972
- * Toolbar Item Component
1973
- * Clickable item in the toolbar (function, property, operator)
1974
- * Items are clicked to insert - no drag from toolbar
1975
- *
1976
- * This is a pure input/output component with no service dependencies.
1977
- */
1978
- class FormulaToolbarItem {
1979
- /** Item type */
1980
- type = input.required(...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
1981
- /** Item value (function name, property key, operator symbol) */
1982
- value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
1983
- /** Display value (optional, defaults to value) */
1984
- display = input(...(ngDevMode ? [undefined, { debugName: "display" }] : /* istanbul ignore next */ []));
1985
- /** Description for tooltip */
1986
- description = input('', ...(ngDevMode ? [{ debugName: "description" }] : /* istanbul ignore next */ []));
1987
- /** Function signature (for functions only, e.g., "SUM(values)") */
1988
- signature = input(...(ngDevMode ? [undefined, { debugName: "signature" }] : /* istanbul ignore next */ []));
1989
- /** Function examples (for functions only) - can be strings or objects with code/description */
1990
- examples = input([], ...(ngDevMode ? [{ debugName: "examples" }] : /* istanbul ignore next */ []));
1991
- /** Backend template to insert (preferred over signature) */
1992
- template = input(...(ngDevMode ? [undefined, { debugName: "template" }] : /* istanbul ignore next */ []));
1993
- /** Cursor offset relative to inserted template */
1994
- templateCursorOffset = input(...(ngDevMode ? [undefined, { debugName: "templateCursorOffset" }] : /* istanbul ignore next */ []));
1995
- /** Function hints from backend documentation */
1996
- hints = input([], ...(ngDevMode ? [{ debugName: "hints" }] : /* istanbul ignore next */ []));
1997
- /** Function return type */
1998
- returnType = input(...(ngDevMode ? [undefined, { debugName: "returnType" }] : /* istanbul ignore next */ []));
1999
- /** Function parameters */
2000
- parameters = input([], ...(ngDevMode ? [{ debugName: "parameters" }] : /* istanbul ignore next */ []));
2001
- /** Normalized description */
2002
- normalizedDescription = computed(() => this.description().trim(), ...(ngDevMode ? [{ debugName: "normalizedDescription" }] : /* istanbul ignore next */ []));
2003
- /** Normalized signature */
2004
- normalizedSignature = computed(() => this.signature()?.trim() ?? '', ...(ngDevMode ? [{ debugName: "normalizedSignature" }] : /* istanbul ignore next */ []));
2005
- /** Normalized template */
2006
- normalizedTemplate = computed(() => this.template()?.trim() ?? '', ...(ngDevMode ? [{ debugName: "normalizedTemplate" }] : /* istanbul ignore next */ []));
2007
- /** Normalized return type */
2008
- normalizedReturnType = computed(() => this.returnType()?.trim() ?? '', ...(ngDevMode ? [{ debugName: "normalizedReturnType" }] : /* istanbul ignore next */ []));
2009
- /** Normalized examples as ExampleItem[] */
2010
- normalizedExamples = computed(() => {
2011
- return this.examples()
2012
- .map((example) => {
2013
- const normalized = typeof example === 'string' ? { code: example } : example;
2014
- return {
2015
- code: normalized.code.trim(),
2016
- description: normalized.description?.trim() || undefined,
2017
- };
2018
- })
2019
- .filter((example) => example.code.length > 0);
2020
- }, ...(ngDevMode ? [{ debugName: "normalizedExamples" }] : /* istanbul ignore next */ []));
2021
- /** Normalized hints */
2022
- normalizedHints = computed(() => this.hints()
2023
- .map((hint) => hint.trim())
2024
- .filter((hint) => hint.length > 0), ...(ngDevMode ? [{ debugName: "normalizedHints" }] : /* istanbul ignore next */ []));
2025
- /** Normalized parameters */
2026
- normalizedParameters = computed(() => this.parameters()
2027
- .map((parameter) => ({
2028
- ...parameter,
2029
- name: parameter.name.trim(),
2030
- type: parameter.type.trim(),
2031
- description: parameter.description.trim(),
2032
- }))
2033
- .filter((parameter) => parameter.name.length > 0 ||
2034
- parameter.type.length > 0 ||
2035
- parameter.description.length > 0), ...(ngDevMode ? [{ debugName: "normalizedParameters" }] : /* istanbul ignore next */ []));
2036
- /** Property type for properties */
2037
- propertyType = input('current', ...(ngDevMode ? [{ debugName: "propertyType" }] : /* istanbul ignore next */ []));
2038
- /** Insert event - emits SmartBlock */
2039
- onInsert = output();
2040
- /** Computed display value */
2041
- displayValue = computed(() => this.display() ?? this.value(), ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
2042
- /** Whether function metadata should use the rich tooltip template */
2043
- hasRichTooltip = computed(() => this.type() === 'function' &&
2044
- Boolean(this.normalizedSignature() ||
2045
- this.shouldShowTemplate() ||
2046
- this.normalizedDescription() ||
2047
- this.normalizedReturnType() ||
2048
- this.normalizedParameters().length > 0 ||
2049
- this.normalizedExamples().length > 0 ||
2050
- this.normalizedHints().length > 0), ...(ngDevMode ? [{ debugName: "hasRichTooltip" }] : /* istanbul ignore next */ []));
2051
- /** Keep lightweight tooltip behavior only for small descriptions */
2052
- simpleTooltip = computed(() => this.hasRichTooltip() ? '' : this.normalizedDescription(), ...(ngDevMode ? [{ debugName: "simpleTooltip" }] : /* istanbul ignore next */ []));
2053
- /** Show insert template when it adds useful information beyond the signature */
2054
- shouldShowTemplate = computed(() => {
2055
- const template = this.normalizedTemplate();
2056
- return template.length > 0 && template !== this.normalizedSignature();
2057
- }, ...(ngDevMode ? [{ debugName: "shouldShowTemplate" }] : /* istanbul ignore next */ []));
2058
- /** PrimeNG tooltip class to widen rich tooltip content */
2059
- tooltipStyleClass = computed(() => this.hasRichTooltip()
2060
- ? 'mt-formula-toolbar-item-tooltip mt-formula-toolbar-item-tooltip-rich'
2061
- : 'mt-formula-toolbar-item-tooltip', ...(ngDevMode ? [{ debugName: "tooltipStyleClass" }] : /* istanbul ignore next */ []));
2062
- /** Build SmartBlock from item data */
2063
- smartBlock = computed(() => {
2064
- switch (this.type()) {
2065
- case 'function':
2066
- return createFunctionBlock(this.normalizedSignature() || `${this.value()}()`, this.value(), this.normalizedTemplate() ||
2067
- this.normalizedSignature() ||
2068
- `${this.value()}()`, this.templateCursorOffset());
2069
- case 'property':
2070
- return createPropertyBlock(this.value(), this.propertyType(), this.display());
2071
- case 'operator':
2072
- return createOperatorBlock(this.value());
2073
- default:
2074
- return createOperatorBlock(this.value());
2075
- }
2076
- }, ...(ngDevMode ? [{ debugName: "smartBlock" }] : /* istanbul ignore next */ []));
2077
- /** Item CSS class based on type */
2078
- itemClass = computed(() => {
2079
- switch (this.type()) {
2080
- case 'function':
2081
- return 'bg-slate-200 text-slate-700 hover:bg-slate-300 dark:bg-slate-700 dark:text-slate-300 dark:hover:bg-slate-600';
2082
- case 'property':
2083
- return 'bg-amber-100 text-amber-700 hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-300 dark:hover:bg-amber-900/50';
2084
- case 'operator':
2085
- return 'bg-sky-100 text-sky-700 hover:bg-sky-200 dark:bg-sky-900/30 dark:text-sky-300 dark:hover:bg-sky-900/50';
2086
- default:
2087
- return 'bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300';
2088
- }
2089
- }, ...(ngDevMode ? [{ debugName: "itemClass" }] : /* istanbul ignore next */ []));
2090
- /** Handle click - emit the SmartBlock */
2091
- handleClick() {
2092
- this.onInsert.emit(this.smartBlock());
2093
- }
2094
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormulaToolbarItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
2095
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: FormulaToolbarItem, isStandalone: true, selector: "mt-formula-toolbar-item", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, display: { classPropertyName: "display", publicName: "display", isSignal: true, isRequired: false, transformFunction: null }, description: { classPropertyName: "description", publicName: "description", isSignal: true, isRequired: false, transformFunction: null }, signature: { classPropertyName: "signature", publicName: "signature", isSignal: true, isRequired: false, transformFunction: null }, examples: { classPropertyName: "examples", publicName: "examples", isSignal: true, isRequired: false, transformFunction: null }, template: { classPropertyName: "template", publicName: "template", isSignal: true, isRequired: false, transformFunction: null }, templateCursorOffset: { classPropertyName: "templateCursorOffset", publicName: "templateCursorOffset", isSignal: true, isRequired: false, transformFunction: null }, hints: { classPropertyName: "hints", publicName: "hints", isSignal: true, isRequired: false, transformFunction: null }, returnType: { classPropertyName: "returnType", publicName: "returnType", isSignal: true, isRequired: false, transformFunction: null }, parameters: { classPropertyName: "parameters", publicName: "parameters", isSignal: true, isRequired: false, transformFunction: null }, propertyType: { classPropertyName: "propertyType", publicName: "propertyType", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onInsert: "onInsert" }, host: { classAttribute: "inline-block max-w-full" }, ngImport: i0, template: "<button\r\n type=\"button\"\r\n class=\"inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded px-2 py-1 text-sm font-medium transition-colors hover:shadow-sm active:scale-95\"\r\n [class]=\"itemClass()\"\r\n [pTooltip]=\"hasRichTooltip() ? richTooltip : simpleTooltip()\"\r\n [tooltipDisabled]=\"!hasRichTooltip() && !simpleTooltip()\"\r\n [tooltipStyleClass]=\"tooltipStyleClass()\"\r\n [tooltipPosition]=\"'bottom'\"\r\n [showDelay]=\"300\"\r\n [hideDelay]=\"100\"\r\n [autoHide]=\"!hasRichTooltip()\"\r\n (click)=\"handleClick()\"\r\n>\r\n @if (type() === \"function\") {\r\n <span class=\"text-sm opacity-60\">f</span>\r\n }\r\n <span class=\"truncate\">{{ displayValue() }}</span>\r\n</button>\r\n\r\n<ng-template #richTooltip>\r\n <div\r\n *transloco=\"let t; prefix: 'components.formula.toolbarItem'\"\r\n class=\"space-y-3\"\r\n >\r\n @if (normalizedSignature()) {\r\n <div class=\"rounded bg-slate-700 px-3 py-2\">\r\n <code\r\n class=\"block whitespace-pre-wrap break-words font-mono text-sm text-emerald-400\"\r\n >{{ normalizedSignature() }}</code\r\n >\r\n </div>\r\n }\r\n\r\n @if (shouldShowTemplate()) {\r\n <div class=\"space-y-1\">\r\n <span\r\n class=\"text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"insert\") }}</span\r\n >\r\n <div class=\"rounded bg-slate-800 px-3 py-2\">\r\n <code\r\n class=\"block whitespace-pre-wrap break-words font-mono text-xs text-amber-300\"\r\n >{{ normalizedTemplate() }}</code\r\n >\r\n </div>\r\n </div>\r\n }\r\n\r\n @if (normalizedDescription()) {\r\n <p class=\"text-sm leading-relaxed text-slate-200\">\r\n {{ normalizedDescription() }}\r\n </p>\r\n }\r\n\r\n @if (normalizedReturnType()) {\r\n <div class=\"flex items-center gap-2 text-xs text-slate-300\">\r\n <span class=\"font-semibold uppercase tracking-wider text-slate-400\">{{\r\n t(\"returns\")\r\n }}</span>\r\n <code class=\"rounded bg-slate-800 px-2 py-0.5 text-sky-300\">{{\r\n normalizedReturnType()\r\n }}</code>\r\n </div>\r\n }\r\n\r\n @if (normalizedParameters().length > 0) {\r\n <div class=\"space-y-2 border-t border-slate-600 pt-3\">\r\n <span\r\n class=\"text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"parameters\") }}</span\r\n >\r\n <div class=\"space-y-2\">\r\n @for (\r\n parameter of normalizedParameters();\r\n track parameter.name + parameter.type\r\n ) {\r\n <div class=\"rounded bg-slate-800/70 px-3 py-2\">\r\n <div class=\"flex flex-wrap items-center gap-2 text-xs\">\r\n @if (parameter.name) {\r\n <code class=\"font-mono text-emerald-300\">{{\r\n parameter.name\r\n }}</code>\r\n }\r\n @if (parameter.type) {\r\n <code class=\"text-sky-300\">{{ parameter.type }}</code>\r\n }\r\n </div>\r\n @if (parameter.description) {\r\n <p class=\"mt-1 text-xs leading-relaxed text-slate-400\">\r\n {{ parameter.description }}\r\n </p>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n }\r\n\r\n @if (normalizedExamples().length > 0) {\r\n <div class=\"space-y-2 border-t border-slate-600 pt-3\">\r\n <span\r\n class=\"text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"examples\") }}</span\r\n >\r\n <div class=\"space-y-2\">\r\n @for (example of normalizedExamples(); track example.code + $index) {\r\n <div class=\"space-y-1\">\r\n <div class=\"rounded bg-slate-800 px-3 py-2\">\r\n <code\r\n class=\"block whitespace-pre-wrap break-words font-mono text-xs text-amber-300\"\r\n >{{ example.code }}</code\r\n >\r\n </div>\r\n @if (example.description) {\r\n <p class=\"px-1 text-xs leading-relaxed text-slate-400\">\r\n {{ example.description }}\r\n </p>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n }\r\n\r\n @if (normalizedHints().length > 0) {\r\n <div class=\"space-y-2 border-t border-slate-600 pt-3\">\r\n <span\r\n class=\"text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"hints\") }}</span\r\n >\r\n <div class=\"space-y-1.5\">\r\n @for (hint of normalizedHints(); track hint) {\r\n <p\r\n class=\"rounded bg-slate-800/70 px-3 py-2 text-xs leading-relaxed text-slate-300\"\r\n >\r\n {{ hint }}\r\n </p>\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n</ng-template>\r\n", styles: [".mt-formula-toolbar-item-tooltip.p-tooltip,.mt-formula-toolbar-item-tooltip .p-tooltip-text{max-width:min(32rem,92vw)}.mt-formula-toolbar-item-tooltip-rich .p-tooltip-text{width:min(32rem,92vw);max-height:min(70vh,36rem);overflow-y:auto;padding:.75rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: TranslocoModule }, { kind: "directive", type: i1$1.TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i2.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "showOnEllipsis", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo", "ptTooltip", "pTooltipPT", "pTooltipUnstyled"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2096
- }
2097
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormulaToolbarItem, decorators: [{
2098
- type: Component,
2099
- args: [{ selector: 'mt-formula-toolbar-item', standalone: true, imports: [CommonModule, TranslocoModule, TooltipModule], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
2100
- class: 'inline-block max-w-full',
2101
- }, template: "<button\r\n type=\"button\"\r\n class=\"inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded px-2 py-1 text-sm font-medium transition-colors hover:shadow-sm active:scale-95\"\r\n [class]=\"itemClass()\"\r\n [pTooltip]=\"hasRichTooltip() ? richTooltip : simpleTooltip()\"\r\n [tooltipDisabled]=\"!hasRichTooltip() && !simpleTooltip()\"\r\n [tooltipStyleClass]=\"tooltipStyleClass()\"\r\n [tooltipPosition]=\"'bottom'\"\r\n [showDelay]=\"300\"\r\n [hideDelay]=\"100\"\r\n [autoHide]=\"!hasRichTooltip()\"\r\n (click)=\"handleClick()\"\r\n>\r\n @if (type() === \"function\") {\r\n <span class=\"text-sm opacity-60\">f</span>\r\n }\r\n <span class=\"truncate\">{{ displayValue() }}</span>\r\n</button>\r\n\r\n<ng-template #richTooltip>\r\n <div\r\n *transloco=\"let t; prefix: 'components.formula.toolbarItem'\"\r\n class=\"space-y-3\"\r\n >\r\n @if (normalizedSignature()) {\r\n <div class=\"rounded bg-slate-700 px-3 py-2\">\r\n <code\r\n class=\"block whitespace-pre-wrap break-words font-mono text-sm text-emerald-400\"\r\n >{{ normalizedSignature() }}</code\r\n >\r\n </div>\r\n }\r\n\r\n @if (shouldShowTemplate()) {\r\n <div class=\"space-y-1\">\r\n <span\r\n class=\"text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"insert\") }}</span\r\n >\r\n <div class=\"rounded bg-slate-800 px-3 py-2\">\r\n <code\r\n class=\"block whitespace-pre-wrap break-words font-mono text-xs text-amber-300\"\r\n >{{ normalizedTemplate() }}</code\r\n >\r\n </div>\r\n </div>\r\n }\r\n\r\n @if (normalizedDescription()) {\r\n <p class=\"text-sm leading-relaxed text-slate-200\">\r\n {{ normalizedDescription() }}\r\n </p>\r\n }\r\n\r\n @if (normalizedReturnType()) {\r\n <div class=\"flex items-center gap-2 text-xs text-slate-300\">\r\n <span class=\"font-semibold uppercase tracking-wider text-slate-400\">{{\r\n t(\"returns\")\r\n }}</span>\r\n <code class=\"rounded bg-slate-800 px-2 py-0.5 text-sky-300\">{{\r\n normalizedReturnType()\r\n }}</code>\r\n </div>\r\n }\r\n\r\n @if (normalizedParameters().length > 0) {\r\n <div class=\"space-y-2 border-t border-slate-600 pt-3\">\r\n <span\r\n class=\"text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"parameters\") }}</span\r\n >\r\n <div class=\"space-y-2\">\r\n @for (\r\n parameter of normalizedParameters();\r\n track parameter.name + parameter.type\r\n ) {\r\n <div class=\"rounded bg-slate-800/70 px-3 py-2\">\r\n <div class=\"flex flex-wrap items-center gap-2 text-xs\">\r\n @if (parameter.name) {\r\n <code class=\"font-mono text-emerald-300\">{{\r\n parameter.name\r\n }}</code>\r\n }\r\n @if (parameter.type) {\r\n <code class=\"text-sky-300\">{{ parameter.type }}</code>\r\n }\r\n </div>\r\n @if (parameter.description) {\r\n <p class=\"mt-1 text-xs leading-relaxed text-slate-400\">\r\n {{ parameter.description }}\r\n </p>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n }\r\n\r\n @if (normalizedExamples().length > 0) {\r\n <div class=\"space-y-2 border-t border-slate-600 pt-3\">\r\n <span\r\n class=\"text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"examples\") }}</span\r\n >\r\n <div class=\"space-y-2\">\r\n @for (example of normalizedExamples(); track example.code + $index) {\r\n <div class=\"space-y-1\">\r\n <div class=\"rounded bg-slate-800 px-3 py-2\">\r\n <code\r\n class=\"block whitespace-pre-wrap break-words font-mono text-xs text-amber-300\"\r\n >{{ example.code }}</code\r\n >\r\n </div>\r\n @if (example.description) {\r\n <p class=\"px-1 text-xs leading-relaxed text-slate-400\">\r\n {{ example.description }}\r\n </p>\r\n }\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n }\r\n\r\n @if (normalizedHints().length > 0) {\r\n <div class=\"space-y-2 border-t border-slate-600 pt-3\">\r\n <span\r\n class=\"text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"hints\") }}</span\r\n >\r\n <div class=\"space-y-1.5\">\r\n @for (hint of normalizedHints(); track hint) {\r\n <p\r\n class=\"rounded bg-slate-800/70 px-3 py-2 text-xs leading-relaxed text-slate-300\"\r\n >\r\n {{ hint }}\r\n </p>\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n</ng-template>\r\n", styles: [".mt-formula-toolbar-item-tooltip.p-tooltip,.mt-formula-toolbar-item-tooltip .p-tooltip-text{max-width:min(32rem,92vw)}.mt-formula-toolbar-item-tooltip-rich .p-tooltip-text{width:min(32rem,92vw);max-height:min(70vh,36rem);overflow-y:auto;padding:.75rem}\n"] }]
2102
- }], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], display: [{ type: i0.Input, args: [{ isSignal: true, alias: "display", required: false }] }], description: [{ type: i0.Input, args: [{ isSignal: true, alias: "description", required: false }] }], signature: [{ type: i0.Input, args: [{ isSignal: true, alias: "signature", required: false }] }], examples: [{ type: i0.Input, args: [{ isSignal: true, alias: "examples", required: false }] }], template: [{ type: i0.Input, args: [{ isSignal: true, alias: "template", required: false }] }], templateCursorOffset: [{ type: i0.Input, args: [{ isSignal: true, alias: "templateCursorOffset", required: false }] }], hints: [{ type: i0.Input, args: [{ isSignal: true, alias: "hints", required: false }] }], returnType: [{ type: i0.Input, args: [{ isSignal: true, alias: "returnType", required: false }] }], parameters: [{ type: i0.Input, args: [{ isSignal: true, alias: "parameters", required: false }] }], propertyType: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertyType", required: false }] }], onInsert: [{ type: i0.Output, args: ["onInsert"] }] } });
2103
-
2104
- const OPERATOR_SYMBOL_TO_TRANSLATION_KEY = {
2105
- '+': 'add',
2106
- '-': 'subtract',
2107
- '*': 'multiply',
2108
- '/': 'divide',
2109
- '%': 'modulo',
2110
- '==': 'equal',
2111
- '!=': 'notEqual',
2112
- '>': 'greater',
2113
- '<': 'less',
2114
- '>=': 'greaterOrEqual',
2115
- '<=': 'lessOrEqual',
2116
- '&&': 'and',
2117
- '||': 'or',
2118
- '!': 'not',
2119
- };
2120
- const DEFAULT_OPERATORS = [
2121
- // Arithmetic
2122
- {
2123
- symbol: '+',
2124
- name: 'Add',
2125
- type: 'arithmetic',
2126
- description: 'Addition',
2127
- precedence: 4,
2128
- },
2129
- {
2130
- symbol: '-',
2131
- name: 'Subtract',
2132
- type: 'arithmetic',
2133
- description: 'Subtraction',
2134
- precedence: 4,
2135
- },
2136
- {
2137
- symbol: '*',
2138
- name: 'Multiply',
2139
- type: 'arithmetic',
2140
- description: 'Multiplication',
2141
- precedence: 5,
2142
- },
2143
- {
2144
- symbol: '/',
2145
- name: 'Divide',
2146
- type: 'arithmetic',
2147
- description: 'Division',
2148
- precedence: 5,
2149
- },
2150
- {
2151
- symbol: '%',
2152
- name: 'Modulo',
2153
- type: 'arithmetic',
2154
- description: 'Modulo',
2155
- precedence: 5,
2156
- },
2157
- // Comparison
2158
- {
2159
- symbol: '==',
2160
- name: 'Equal',
2161
- type: 'comparison',
2162
- description: 'Equal to',
2163
- precedence: 3,
2164
- },
2165
- {
2166
- symbol: '!=',
2167
- name: 'Not Equal',
2168
- type: 'comparison',
2169
- description: 'Not equal to',
2170
- precedence: 3,
2171
- },
2172
- {
2173
- symbol: '>',
2174
- name: 'Greater',
2175
- type: 'comparison',
2176
- description: 'Greater than',
2177
- precedence: 3,
2178
- },
2179
- {
2180
- symbol: '<',
2181
- name: 'Less',
2182
- type: 'comparison',
2183
- description: 'Less than',
2184
- precedence: 3,
2185
- },
2186
- {
2187
- symbol: '>=',
2188
- name: 'Greater or Equal',
2189
- type: 'comparison',
2190
- description: 'Greater than or equal',
2191
- precedence: 3,
2192
- },
2193
- {
2194
- symbol: '<=',
2195
- name: 'Less or Equal',
2196
- type: 'comparison',
2197
- description: 'Less than or equal',
2198
- precedence: 3,
2199
- },
2200
- // Logical
2201
- {
2202
- symbol: '&&',
2203
- name: 'And',
2204
- type: 'logical',
2205
- description: 'Logical AND',
2206
- precedence: 2,
2207
- },
2208
- {
2209
- symbol: '||',
2210
- name: 'Or',
2211
- type: 'logical',
2212
- description: 'Logical OR',
2213
- precedence: 1,
2214
- },
2215
- {
2216
- symbol: '!',
2217
- name: 'Not',
2218
- type: 'logical',
2219
- description: 'Logical NOT',
2220
- precedence: 6,
2221
- },
2222
- ];
2223
-
2224
- /**
2225
- * Formula Toolbar Component
2226
- * Vertical tabs toolbar with functions, properties, and operators
2227
- *
2228
- * This is a PURE input/output component with NO service dependencies.
2229
- * All data (functions, operators, properties) must be passed via inputs.
2230
- */
2231
- class FormulaToolbar {
2232
- transloco = inject(TranslocoService);
2233
- // ============ INPUTS ============
2234
- /** Known properties to show in properties tab */
2235
- knownProperties = input([], ...(ngDevMode ? [{ debugName: "knownProperties" }] : /* istanbul ignore next */ []));
2236
- /** Custom properties template */
2237
- propertiesTemplate = input(null, ...(ngDevMode ? [{ debugName: "propertiesTemplate" }] : /* istanbul ignore next */ []));
2238
- /** Projected properties template */
2239
- projectedPropertiesTemplate = contentChild('properties', { ...(ngDevMode ? { debugName: "projectedPropertiesTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
2240
- /** Function categories (from API or static data) */
2241
- functionCategories = input([], ...(ngDevMode ? [{ debugName: "functionCategories" }] : /* istanbul ignore next */ []));
2242
- /** Operators list (overridable) */
2243
- operators = input(DEFAULT_OPERATORS, ...(ngDevMode ? [{ debugName: "operators" }] : /* istanbul ignore next */ []));
2244
- /** Initial active tab */
2245
- initialTab = input('functions', ...(ngDevMode ? [{ debugName: "initialTab" }] : /* istanbul ignore next */ []));
2246
- /** Tabs visible in the toolbar */
2247
- visibleTabs = input([
2248
- 'functions',
2249
- 'properties',
2250
- 'operators',
2251
- ], ...(ngDevMode ? [{ debugName: "visibleTabs" }] : /* istanbul ignore next */ []));
2252
- /** Placeholder for search input */
2253
- searchPlaceholder = input('', ...(ngDevMode ? [{ debugName: "searchPlaceholder" }] : /* istanbul ignore next */ []));
2254
- /** Labels */
2255
- labels = input({}, ...(ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []));
2256
- // ============ OUTPUTS ============
2257
- /** Insert event - emits SmartBlock for the editor */
2258
- onBlockInsert = output();
2259
- /** Tab change event */
2260
- onTabChange = output();
2261
- // ============ STATE ============
2262
- /** Active tab */
2263
- activeTab = signal('functions', ...(ngDevMode ? [{ debugName: "activeTab" }] : /* istanbul ignore next */ []));
2264
- /** Tab options */
2265
- tabOptions = computed(() => [
2266
- {
2267
- label: this.transloco.translate('components.formula.toolbar.functions'),
2268
- value: 'functions',
2269
- },
2270
- {
2271
- label: this.transloco.translate('components.formula.toolbar.properties'),
2272
- value: 'properties',
2273
- },
2274
- {
2275
- label: this.transloco.translate('components.formula.toolbar.operators'),
2276
- value: 'operators',
2277
- },
2278
- ], ...(ngDevMode ? [{ debugName: "tabOptions" }] : /* istanbul ignore next */ []));
2279
- /** Tabs actually rendered */
2280
- resolvedTabOptions = computed(() => {
2281
- const visibleTabs = this.visibleTabs();
2282
- const allTabs = this.tabOptions();
2283
- const tabs = allTabs.filter((tab) => visibleTabs.includes(tab.value));
2284
- return tabs.length > 0 ? tabs : [allTabs[0]];
2285
- }, ...(ngDevMode ? [{ debugName: "resolvedTabOptions" }] : /* istanbul ignore next */ []));
2286
- /** Context for custom properties template */
2287
- propertiesTemplateContext = {
2288
- insertBlock: (block) => this.insertBlock(block),
2289
- };
2290
- /** Resolve properties template (projected first, input fallback) */
2291
- resolvedPropertiesTemplate = computed(() => this.projectedPropertiesTemplate() ?? this.propertiesTemplate(), ...(ngDevMode ? [{ debugName: "resolvedPropertiesTemplate" }] : /* istanbul ignore next */ []));
2292
- /** Search query */
2293
- searchQuery = signal('', ...(ngDevMode ? [{ debugName: "searchQuery" }] : /* istanbul ignore next */ []));
2294
- /** Custom value input */
2295
- customValue = signal('', ...(ngDevMode ? [{ debugName: "customValue" }] : /* istanbul ignore next */ []));
2296
- /** Detected type of custom value */
2297
- customValueType = computed(() => {
2298
- const val = this.customValue().trim();
2299
- if (!val)
2300
- return 'text';
2301
- // Check if it's a number
2302
- if (/^-?\d+(\.\d+)?$/.test(val)) {
2303
- return 'number';
2304
- }
2305
- // Check if it's a quoted string
2306
- if ((val.startsWith('"') && val.endsWith('"')) ||
2307
- (val.startsWith("'") && val.endsWith("'"))) {
2308
- return 'string';
2309
- }
2310
- return 'text';
2311
- }, ...(ngDevMode ? [{ debugName: "customValueType" }] : /* istanbul ignore next */ []));
2312
- /** Preview of custom value */
2313
- customValuePreview = computed(() => {
2314
- const val = this.customValue().trim();
2315
- if (!val)
2316
- return '';
2317
- const type = this.customValueType();
2318
- if (type === 'string') {
2319
- // Show the quoted string as-is
2320
- return val;
2321
- }
2322
- if (type === 'number') {
2323
- return val;
2324
- }
2325
- // For unquoted text, show as string preview
2326
- return `"${val}"`;
2327
- }, ...(ngDevMode ? [{ debugName: "customValuePreview" }] : /* istanbul ignore next */ []));
2328
- /** CSS class for custom value type */
2329
- customValueTypeClass = computed(() => {
2330
- switch (this.customValueType()) {
2331
- case 'number':
2332
- return 'bg-rose-100 text-rose-700 hover:bg-rose-200 dark:bg-rose-900/30 dark:text-rose-300 dark:hover:bg-rose-900/50';
2333
- case 'string':
2334
- return 'bg-emerald-100 text-emerald-700 hover:bg-emerald-200 dark:bg-emerald-900/30 dark:text-emerald-300 dark:hover:bg-emerald-900/50';
2335
- default:
2336
- return 'bg-slate-100 text-slate-700 hover:bg-slate-200 dark:bg-slate-700 dark:text-slate-300 dark:hover:bg-slate-600';
2337
- }
2338
- }, ...(ngDevMode ? [{ debugName: "customValueTypeClass" }] : /* istanbul ignore next */ []));
2339
- constructor() {
2340
- // Initialize active tab from input
2341
- effect(() => {
2342
- const initial = this.initialTab();
2343
- const availableTabs = this.resolvedTabOptions();
2344
- const nextTab = availableTabs.some((tab) => tab.value === initial)
2345
- ? initial
2346
- : availableTabs[0]?.value;
2347
- if (nextTab) {
2348
- this.activeTab.set(nextTab);
2349
- }
2350
- });
2351
- }
2352
- // ============ COMPUTED ============
2353
- /** Filtered categories based on search */
2354
- filteredCategories = computed(() => {
2355
- const query = this.searchQuery().trim().toLowerCase();
2356
- return this.functionCategories()
2357
- .map((cat) => ({
2358
- ...cat,
2359
- functions: cat.functions.filter((fn) => {
2360
- if (!query) {
2361
- return true;
2362
- }
2363
- const functionName = fn.name.toLowerCase();
2364
- const description = fn.description.toLowerCase();
2365
- const categoryName = String(cat.displayName ?? cat.name).toLowerCase();
2366
- return (functionName.includes(query) ||
2367
- description.includes(query) ||
2368
- categoryName.includes(query));
2369
- }),
2370
- }))
2371
- .filter((cat) => cat.functions.length > 0);
2372
- }, ...(ngDevMode ? [{ debugName: "filteredCategories" }] : /* istanbul ignore next */ []));
2373
- /** Property items normalized from legacy string keys or keyed descriptors */
2374
- propertyItems = computed(() => {
2375
- return this.knownProperties().map((property) => {
2376
- if (typeof property === 'string') {
2377
- return {
2378
- key: property,
2379
- name: property,
2380
- };
2381
- }
2382
- return {
2383
- key: property.key,
2384
- name: property.name?.trim() || property.key,
2385
- description: property.description?.trim() || undefined,
2386
- };
2387
- });
2388
- }, ...(ngDevMode ? [{ debugName: "propertyItems" }] : /* istanbul ignore next */ []));
2389
- /** Filtered properties based on search */
2390
- filteredProperties = computed(() => {
2391
- const query = this.searchQuery().toLowerCase();
2392
- const props = this.propertyItems();
2393
- if (!query)
2394
- return props;
2395
- return props.filter((p) => {
2396
- const key = p.key.toLowerCase();
2397
- const name = (p.name ?? '').toLowerCase();
2398
- const description = (p.description ?? '').toLowerCase();
2399
- return (key.includes(query) ||
2400
- name.includes(query) ||
2401
- description.includes(query));
2402
- });
2403
- }, ...(ngDevMode ? [{ debugName: "filteredProperties" }] : /* istanbul ignore next */ []));
2404
- /** Operators translated through the active locale */
2405
- translatedOperators = computed(() => this.operators().map((op) => {
2406
- const key = OPERATOR_SYMBOL_TO_TRANSLATION_KEY[op.symbol];
2407
- if (!key)
2408
- return op;
2409
- return {
2410
- ...op,
2411
- name: this.transloco.translate(`components.formulaOperators.${key}.name`),
2412
- description: this.transloco.translate(`components.formulaOperators.${key}.description`),
2413
- };
2414
- }), ...(ngDevMode ? [{ debugName: "translatedOperators" }] : /* istanbul ignore next */ []));
2415
- /** Filtered operators based on search */
2416
- filteredOperators = computed(() => {
2417
- const query = this.searchQuery().toLowerCase();
2418
- const ops = this.translatedOperators();
2419
- if (!query)
2420
- return ops;
2421
- return ops.filter((op) => op.symbol.toLowerCase().includes(query) ||
2422
- op.name.toLowerCase().includes(query) ||
2423
- op.description.toLowerCase().includes(query));
2424
- }, ...(ngDevMode ? [{ debugName: "filteredOperators" }] : /* istanbul ignore next */ []));
2425
- /** Count of filtered items per tab */
2426
- filteredFunctionsCount = computed(() => this.filteredCategories().reduce((sum, cat) => sum + cat.functions.length, 0), ...(ngDevMode ? [{ debugName: "filteredFunctionsCount" }] : /* istanbul ignore next */ []));
2427
- filteredPropertiesCount = computed(() => this.filteredProperties().length, ...(ngDevMode ? [{ debugName: "filteredPropertiesCount" }] : /* istanbul ignore next */ []));
2428
- filteredOperatorsCount = computed(() => this.filteredOperators().length, ...(ngDevMode ? [{ debugName: "filteredOperatorsCount" }] : /* istanbul ignore next */ []));
2429
- /** Smart search effect - switches to tab with results */
2430
- smartSearchEffect = effect(() => {
2431
- const query = this.searchQuery();
2432
- if (!query || query.length < 2)
2433
- return;
2434
- const currentTab = this.activeTab();
2435
- const availableTabs = this.resolvedTabOptions().map((tab) => tab.value);
2436
- const functionsCount = this.filteredFunctionsCount();
2437
- const propertiesCount = this.filteredPropertiesCount();
2438
- const operatorsCount = this.filteredOperatorsCount();
2439
- // Check if current tab has results
2440
- const currentHasResults = (currentTab === 'functions' && functionsCount > 0) ||
2441
- (currentTab === 'properties' && propertiesCount > 0) ||
2442
- (currentTab === 'operators' && operatorsCount > 0);
2443
- // If current tab has no results, switch to first tab with results
2444
- if (!currentHasResults) {
2445
- if (availableTabs.includes('functions') && functionsCount > 0) {
2446
- this.activeTab.set('functions');
2447
- }
2448
- else if (availableTabs.includes('properties') && propertiesCount > 0) {
2449
- this.activeTab.set('properties');
2450
- }
2451
- else if (availableTabs.includes('operators') && operatorsCount > 0) {
2452
- this.activeTab.set('operators');
2453
- }
2454
- }
2455
- }, ...(ngDevMode ? [{ debugName: "smartSearchEffect" }] : /* istanbul ignore next */ []));
2456
- /** Group operators by type */
2457
- operatorGroups = computed(() => {
2458
- const ops = this.filteredOperators();
2459
- const groups = new Map();
2460
- ops.forEach((op) => {
2461
- const type = op.type || 'other';
2462
- if (!groups.has(type)) {
2463
- groups.set(type, []);
2464
- }
2465
- groups.get(type).push(op);
2466
- });
2467
- return Array.from(groups.entries()).map(([type, operators]) => ({
2468
- type,
2469
- operators,
2470
- }));
2471
- }, ...(ngDevMode ? [{ debugName: "operatorGroups" }] : /* istanbul ignore next */ []));
2472
- /** Translate an operator group header, falling back to a capitalized label */
2473
- operatorTypeLabel(type) {
2474
- const key = `components.formula.toolbar.operatorTypes.${type}`;
2475
- const translated = this.transloco.translate(key);
2476
- return translated && translated !== key
2477
- ? translated
2478
- : type.charAt(0).toUpperCase() + type.slice(1);
2479
- }
2480
- /**
2481
- * Resolve a function category header.
2482
- * The backend already returns a localized `displayName`, so we render it
2483
- * verbatim instead of re-translating on the client (which only covered a
2484
- * subset of categories and left newer ones like "Task Baseline" untranslated).
2485
- */
2486
- categoryLabel(category) {
2487
- return category.displayName || String(category.name ?? '');
2488
- }
2489
- /** Total item count for current tab */
2490
- itemCount = computed(() => {
2491
- switch (this.activeTab()) {
2492
- case 'functions':
2493
- return this.filteredCategories().reduce((sum, cat) => sum + cat.functions.length, 0);
2494
- case 'properties':
2495
- return this.filteredProperties().length;
2496
- case 'operators':
2497
- return this.filteredOperators().length;
2498
- default:
2499
- return 0;
2500
- }
2501
- }, ...(ngDevMode ? [{ debugName: "itemCount" }] : /* istanbul ignore next */ []));
2502
- // ============ COMPUTED LABELS ============
2503
- labelFunctions = computed(() => this.labels()?.functions ?? 'Functions', ...(ngDevMode ? [{ debugName: "labelFunctions" }] : /* istanbul ignore next */ []));
2504
- labelProperties = computed(() => this.labels()?.properties ?? 'Properties', ...(ngDevMode ? [{ debugName: "labelProperties" }] : /* istanbul ignore next */ []));
2505
- labelOperators = computed(() => this.labels()?.operators ?? 'Operators', ...(ngDevMode ? [{ debugName: "labelOperators" }] : /* istanbul ignore next */ []));
2506
- labelNoFunctions = computed(() => this.labels()?.noFunctionsFound ?? 'No functions found', ...(ngDevMode ? [{ debugName: "labelNoFunctions" }] : /* istanbul ignore next */ []));
2507
- labelNoProperties = computed(() => this.labels()?.noPropertiesAvailable ?? 'No properties available', ...(ngDevMode ? [{ debugName: "labelNoProperties" }] : /* istanbul ignore next */ []));
2508
- labelNoOperators = computed(() => this.labels()?.noOperatorsFound ?? 'No operators found', ...(ngDevMode ? [{ debugName: "labelNoOperators" }] : /* istanbul ignore next */ []));
2509
- // ============ METHODS ============
2510
- /** Get count for a specific tab (filtered when searching) */
2511
- getTabCount(tab) {
2512
- const query = this.searchQuery();
2513
- if (query) {
2514
- // When searching, show filtered count
2515
- switch (tab) {
2516
- case 'functions':
2517
- return this.filteredFunctionsCount();
2518
- case 'properties':
2519
- return this.filteredPropertiesCount();
2520
- case 'operators':
2521
- return this.filteredOperatorsCount();
2522
- default:
2523
- return 0;
2524
- }
2525
- }
2526
- else {
2527
- // When not searching, show total count
2528
- switch (tab) {
2529
- case 'functions':
2530
- return this.functionCategories().reduce((sum, cat) => sum + cat.functions.length, 0);
2531
- case 'properties':
2532
- return this.propertyItems().length;
2533
- case 'operators':
2534
- return this.operators().length;
2535
- default:
2536
- return 0;
2537
- }
2538
- }
2539
- }
2540
- /** Check if a tab has results when searching */
2541
- tabHasResults(tab) {
2542
- return this.getTabCount(tab) > 0;
2543
- }
2544
- /** Set active tab */
2545
- setActiveTab(tab) {
2546
- this.activeTab.set(tab);
2547
- this.onTabChange.emit(tab);
2548
- }
2549
- /** Emit block insert event */
2550
- insertBlock(block) {
2551
- this.onBlockInsert.emit(block);
2552
- }
2553
- /** Clear search */
2554
- clearSearch() {
2555
- this.searchQuery.set('');
2556
- }
2557
- /** Insert custom value */
2558
- insertCustomValue() {
2559
- const val = this.customValue().trim();
2560
- if (!val)
2561
- return;
2562
- const type = this.customValueType();
2563
- let literalValue;
2564
- if (type === 'number') {
2565
- literalValue = parseFloat(val);
2566
- }
2567
- else if (type === 'string') {
2568
- // Remove quotes for storage, keep the content
2569
- literalValue = val.slice(1, -1);
2570
- }
2571
- else {
2572
- // Treat as string, add quotes
2573
- literalValue = val;
2574
- }
2575
- const block = createLiteralBlock(literalValue);
2576
- // For strings, ensure the value includes quotes for display
2577
- if (type === 'string' || type === 'text') {
2578
- block.value = type === 'string' ? val : `"${val}"`;
2579
- }
2580
- this.onBlockInsert.emit(block);
2581
- this.clearCustomValue();
2582
- }
2583
- /** Clear custom value input */
2584
- clearCustomValue() {
2585
- this.customValue.set('');
2586
- }
2587
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormulaToolbar, deps: [], target: i0.ɵɵFactoryTarget.Component });
2588
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: FormulaToolbar, isStandalone: true, selector: "mt-formula-toolbar", inputs: { knownProperties: { classPropertyName: "knownProperties", publicName: "knownProperties", isSignal: true, isRequired: false, transformFunction: null }, propertiesTemplate: { classPropertyName: "propertiesTemplate", publicName: "propertiesTemplate", isSignal: true, isRequired: false, transformFunction: null }, functionCategories: { classPropertyName: "functionCategories", publicName: "functionCategories", isSignal: true, isRequired: false, transformFunction: null }, operators: { classPropertyName: "operators", publicName: "operators", isSignal: true, isRequired: false, transformFunction: null }, initialTab: { classPropertyName: "initialTab", publicName: "initialTab", isSignal: true, isRequired: false, transformFunction: null }, visibleTabs: { classPropertyName: "visibleTabs", publicName: "visibleTabs", isSignal: true, isRequired: false, transformFunction: null }, searchPlaceholder: { classPropertyName: "searchPlaceholder", publicName: "searchPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, labels: { classPropertyName: "labels", publicName: "labels", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onBlockInsert: "onBlockInsert", onTabChange: "onTabChange" }, queries: [{ propertyName: "projectedPropertiesTemplate", first: true, predicate: ["properties"], descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: "<div\r\n *transloco=\"let t; prefix: 'components.formula.toolbar'\"\r\n class=\"flex flex-col border-b border-slate-200 dark:border-slate-700\"\r\n [class.h-52]=\"activeTab() !== 'properties' || !resolvedPropertiesTemplate()\"\r\n>\r\n <!-- Top Bar: Search + Quick Insert -->\r\n <div\r\n class=\"flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-slate-700\"\r\n >\r\n <!-- Search Field -->\r\n <div class=\"relative flex-1\">\r\n <svg\r\n class=\"absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z\"\r\n />\r\n </svg>\r\n <input\r\n type=\"text\"\r\n class=\"w-full rounded-lg border border-slate-300 bg-white py-1.5 ps-9 pe-8 text-sm text-slate-700 placeholder:text-slate-400 focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 transition-all duration-200 dark:border-slate-600 dark:bg-slate-900 dark:text-slate-200 dark:placeholder:text-slate-500\"\r\n [placeholder]=\"searchPlaceholder() || t('search')\"\r\n [(ngModel)]=\"searchQuery\"\r\n />\r\n @if (searchQuery()) {\r\n <button\r\n type=\"button\"\r\n class=\"absolute end-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-slate-400 hover:bg-slate-200 hover:text-slate-600 transition-all duration-200 dark:hover:bg-slate-700\"\r\n (click)=\"clearSearch()\"\r\n >\r\n <svg\r\n class=\"h-4 w-4\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M6 18L18 6M6 6l12 12\"\r\n />\r\n </svg>\r\n </button>\r\n }\r\n </div>\r\n\r\n <!-- Separator -->\r\n <div class=\"h-6 w-px bg-slate-200 dark:bg-slate-600\"></div>\r\n\r\n <!-- Quick Insert Input -->\r\n <div class=\"relative flex items-center gap-2\">\r\n <span\r\n class=\"text-sm font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide\"\r\n >{{ t(\"insertLabel\") }}:</span\r\n >\r\n <div class=\"relative\">\r\n <input\r\n #customValueInput\r\n type=\"text\"\r\n class=\"w-32 rounded-md border border-dashed border-slate-300 bg-slate-50 px-3 py-1.5 text-sm font-mono text-slate-700 placeholder:text-slate-400 focus:border-primary focus:bg-white focus:outline-none focus:ring-2 focus:ring-primary/20 transition-all duration-200 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200 dark:placeholder:text-slate-500 dark:focus:bg-slate-900\"\r\n [placeholder]=\"t('customValuePlaceholder')\"\r\n [(ngModel)]=\"customValue\"\r\n (keydown.enter)=\"insertCustomValue()\"\r\n (keydown.escape)=\"clearCustomValue()\"\r\n />\r\n </div>\r\n\r\n <!-- Insert Button with Type Preview -->\r\n @if (customValue()) {\r\n <button\r\n type=\"button\"\r\n class=\"inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-all duration-200 hover:shadow-sm active:scale-95\"\r\n [class]=\"customValueTypeClass()\"\r\n (click)=\"insertCustomValue()\"\r\n [title]=\"t('insertType', { type: customValueType() })\"\r\n >\r\n @switch (customValueType()) {\r\n @case (\"number\") {\r\n <svg\r\n class=\"h-3 w-3\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M7 20l4-16m2 16l4-16M6 9h14M4 15h14\"\r\n />\r\n </svg>\r\n }\r\n @case (\"string\") {\r\n <svg\r\n class=\"h-3 w-3\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z\"\r\n />\r\n </svg>\r\n }\r\n @default {\r\n <svg\r\n class=\"h-3 w-3\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M12 4.5v15m7.5-7.5h-15\"\r\n />\r\n </svg>\r\n }\r\n }\r\n <span class=\"max-w-16 truncate\">{{ customValuePreview() }}</span>\r\n </button>\r\n }\r\n </div>\r\n </div>\r\n\r\n <!-- Main Content Row -->\r\n <div class=\"flex flex-1 overflow-hidden\">\r\n <!-- Vertical Tabs -->\r\n <div\r\n class=\"flex w-44 flex-col border-e border-slate-200 dark:border-slate-700\"\r\n >\r\n @for (tab of resolvedTabOptions(); track tab.value) {\r\n <button\r\n type=\"button\"\r\n class=\"flex cursor-pointer items-center gap-2 px-3 py-2.5 text-start text-sm font-medium transition-all duration-200\"\r\n [class]=\"\r\n activeTab() === tab.value\r\n ? 'bg-white border-e-2 border-primary text-primary dark:bg-slate-900'\r\n : searchQuery() && !tabHasResults(tab.value)\r\n ? 'text-slate-300 dark:text-slate-600'\r\n : 'text-slate-600 hover:bg-slate-100 hover:text-slate-800 dark:text-slate-300 dark:hover:bg-slate-700'\r\n \"\r\n (click)=\"setActiveTab(tab.value)\"\r\n >\r\n <!-- Tab Icons -->\r\n @switch (tab.value) {\r\n @case (\"functions\") {\r\n <svg\r\n class=\"h-5 w-5 shrink-0\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5\"\r\n />\r\n </svg>\r\n }\r\n @case (\"properties\") {\r\n <svg\r\n class=\"h-5 w-5 shrink-0\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M9.568 3H5.25A2.25 2.25 0 003 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.095 18.095 0 005.223-5.223c.542-.827.369-1.908-.33-2.607L11.16 3.66A2.25 2.25 0 009.568 3z\"\r\n />\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M6 6h.008v.008H6V6z\"\r\n />\r\n </svg>\r\n }\r\n @case (\"operators\") {\r\n <svg\r\n class=\"h-5 w-5 shrink-0\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M15.75 15.75V18m-7.5-6.75h.008v.008H8.25v-.008zm0 2.25h.008v.008H8.25V13.5zm0 2.25h.008v.008H8.25v-.008zm0 2.25h.008v.008H8.25V18zm2.498-6.75h.007v.008h-.007v-.008zm0 2.25h.007v.008h-.007V13.5zm0 2.25h.007v.008h-.007v-.008zm0 2.25h.007v.008h-.007V18zm2.504-6.75h.008v.008h-.008v-.008zm0 2.25h.008v.008h-.008V13.5zm0 2.25h.008v.008h-.008v-.008zm0 2.25h.008v.008h-.008V18zm2.498-6.75h.008v.008h-.008v-.008zm0 2.25h.008v.008h-.008V13.5zM8.25 6h7.5v2.25h-7.5V6zM12 2.25c-1.892 0-3.758.11-5.593.322C5.307 2.7 4.5 3.65 4.5 4.757V19.5a2.25 2.25 0 002.25 2.25h10.5a2.25 2.25 0 002.25-2.25V4.757c0-1.108-.806-2.057-1.907-2.185A48.507 48.507 0 0012 2.25z\"\r\n />\r\n </svg>\r\n }\r\n }\r\n <!-- Label (always visible) -->\r\n <span class=\"truncate whitespace-nowrap text-sm\">{{\r\n t(tab.value)\r\n }}</span>\r\n <!-- Count Badge -->\r\n @if (tab.value !== \"properties\" || !resolvedPropertiesTemplate()) {\r\n <span\r\n class=\"ms-auto rounded-full px-1.5 py-0.5 text-xs font-semibold\"\r\n [class]=\"\r\n activeTab() === tab.value\r\n ? 'bg-primary/10 text-primary'\r\n : 'bg-slate-200 text-slate-600 dark:bg-slate-600 dark:text-slate-300'\r\n \"\r\n >\r\n {{ getTabCount(tab.value) }}\r\n </span>\r\n }\r\n </button>\r\n }\r\n </div>\r\n\r\n <!-- Content Area -->\r\n <div class=\"flex flex-1 flex-col overflow-hidden\">\r\n <!-- Items Grid -->\r\n <div\r\n class=\"flex-1 p-2.5\"\r\n [class.overflow-y-auto]=\"\r\n activeTab() !== 'properties' || !resolvedPropertiesTemplate()\r\n \"\r\n >\r\n @switch (activeTab()) {\r\n @case (\"functions\") {\r\n @if (filteredCategories().length === 0) {\r\n <div\r\n class=\"flex h-full items-center justify-center text-sm text-slate-400 dark:text-slate-500\"\r\n >\r\n {{ labels()?.noFunctionsFound ?? t(\"noFunctionsFound\") }}\r\n </div>\r\n } @else {\r\n <div class=\"space-y-3\">\r\n @for (category of filteredCategories(); track category.name) {\r\n <div>\r\n <div class=\"mb-2 flex items-center gap-2\">\r\n <span\r\n class=\"text-sm font-semibold uppercase tracking-wider text-slate-500 dark:text-slate-400\"\r\n >\r\n {{ categoryLabel(category) }}\r\n </span>\r\n <span\r\n class=\"h-px flex-1 bg-slate-200/60 dark:bg-slate-700/60\"\r\n ></span>\r\n <span\r\n class=\"text-sm text-slate-400 dark:text-slate-500\"\r\n >{{ category.functions.length }}</span\r\n >\r\n </div>\r\n <div class=\"flex flex-wrap gap-1.5\">\r\n @for (fn of category.functions; track fn.name) {\r\n <mt-formula-toolbar-item\r\n type=\"function\"\r\n [value]=\"fn.name\"\r\n [description]=\"fn.description\"\r\n [signature]=\"fn.signature\"\r\n [template]=\"fn.template\"\r\n [templateCursorOffset]=\"fn.templateCursorOffset\"\r\n [returnType]=\"fn.returnType\"\r\n [parameters]=\"fn.parameters ?? []\"\r\n [examples]=\"fn.examples ?? []\"\r\n [hints]=\"fn.hints ?? []\"\r\n (onInsert)=\"insertBlock($event)\"\r\n />\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n }\r\n }\r\n @case (\"properties\") {\r\n @if (resolvedPropertiesTemplate(); as template) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"template\"\r\n [ngTemplateOutletContext]=\"propertiesTemplateContext\"\r\n />\r\n } @else {\r\n @if (filteredProperties().length === 0) {\r\n <div\r\n class=\"flex h-full items-center justify-center text-sm text-slate-400 dark:text-slate-500\"\r\n >\r\n {{\r\n labels()?.noPropertiesAvailable ??\r\n t(\"noPropertiesAvailable\")\r\n }}\r\n </div>\r\n } @else {\r\n <div class=\"flex flex-wrap gap-1.5\">\r\n @for (prop of filteredProperties(); track prop.key) {\r\n <mt-formula-toolbar-item\r\n type=\"property\"\r\n [value]=\"prop.key\"\r\n [display]=\"prop.name\"\r\n [description]=\"\r\n prop.description || t('property') + ': ' + prop.key\r\n \"\r\n propertyType=\"current\"\r\n (onInsert)=\"insertBlock($event)\"\r\n />\r\n }\r\n </div>\r\n }\r\n }\r\n }\r\n @case (\"operators\") {\r\n @if (filteredOperators().length === 0) {\r\n <div\r\n class=\"flex h-full items-center justify-center text-sm text-slate-400 dark:text-slate-500\"\r\n >\r\n {{ labels()?.noOperatorsFound ?? t(\"noOperatorsFound\") }}\r\n </div>\r\n } @else {\r\n <div class=\"space-y-3\">\r\n @for (group of operatorGroups(); track group.type) {\r\n <div>\r\n <div class=\"mb-2 flex items-center gap-2\">\r\n <span\r\n class=\"text-sm font-semibold uppercase tracking-wider text-slate-500 dark:text-slate-400\"\r\n >\r\n {{ operatorTypeLabel(group.type) }}\r\n </span>\r\n <span\r\n class=\"h-px flex-1 bg-slate-200/60 dark:bg-slate-700/60\"\r\n ></span>\r\n </div>\r\n <div class=\"flex flex-wrap gap-1.5\">\r\n @for (op of group.operators; track op.symbol) {\r\n <mt-formula-toolbar-item\r\n type=\"operator\"\r\n [value]=\"op.symbol\"\r\n [description]=\"op.description\"\r\n (onInsert)=\"insertBlock($event)\"\r\n />\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n }\r\n }\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "directive", type: i1$1.TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: FormulaToolbarItem, selector: "mt-formula-toolbar-item", inputs: ["type", "value", "display", "description", "signature", "examples", "template", "templateCursorOffset", "hints", "returnType", "parameters", "propertyType"], outputs: ["onInsert"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2589
- }
2590
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormulaToolbar, decorators: [{
2591
- type: Component,
2592
- args: [{ selector: 'mt-formula-toolbar', standalone: true, imports: [CommonModule, FormsModule, TranslocoModule, FormulaToolbarItem], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\r\n *transloco=\"let t; prefix: 'components.formula.toolbar'\"\r\n class=\"flex flex-col border-b border-slate-200 dark:border-slate-700\"\r\n [class.h-52]=\"activeTab() !== 'properties' || !resolvedPropertiesTemplate()\"\r\n>\r\n <!-- Top Bar: Search + Quick Insert -->\r\n <div\r\n class=\"flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-slate-700\"\r\n >\r\n <!-- Search Field -->\r\n <div class=\"relative flex-1\">\r\n <svg\r\n class=\"absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z\"\r\n />\r\n </svg>\r\n <input\r\n type=\"text\"\r\n class=\"w-full rounded-lg border border-slate-300 bg-white py-1.5 ps-9 pe-8 text-sm text-slate-700 placeholder:text-slate-400 focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 transition-all duration-200 dark:border-slate-600 dark:bg-slate-900 dark:text-slate-200 dark:placeholder:text-slate-500\"\r\n [placeholder]=\"searchPlaceholder() || t('search')\"\r\n [(ngModel)]=\"searchQuery\"\r\n />\r\n @if (searchQuery()) {\r\n <button\r\n type=\"button\"\r\n class=\"absolute end-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-slate-400 hover:bg-slate-200 hover:text-slate-600 transition-all duration-200 dark:hover:bg-slate-700\"\r\n (click)=\"clearSearch()\"\r\n >\r\n <svg\r\n class=\"h-4 w-4\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M6 18L18 6M6 6l12 12\"\r\n />\r\n </svg>\r\n </button>\r\n }\r\n </div>\r\n\r\n <!-- Separator -->\r\n <div class=\"h-6 w-px bg-slate-200 dark:bg-slate-600\"></div>\r\n\r\n <!-- Quick Insert Input -->\r\n <div class=\"relative flex items-center gap-2\">\r\n <span\r\n class=\"text-sm font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide\"\r\n >{{ t(\"insertLabel\") }}:</span\r\n >\r\n <div class=\"relative\">\r\n <input\r\n #customValueInput\r\n type=\"text\"\r\n class=\"w-32 rounded-md border border-dashed border-slate-300 bg-slate-50 px-3 py-1.5 text-sm font-mono text-slate-700 placeholder:text-slate-400 focus:border-primary focus:bg-white focus:outline-none focus:ring-2 focus:ring-primary/20 transition-all duration-200 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200 dark:placeholder:text-slate-500 dark:focus:bg-slate-900\"\r\n [placeholder]=\"t('customValuePlaceholder')\"\r\n [(ngModel)]=\"customValue\"\r\n (keydown.enter)=\"insertCustomValue()\"\r\n (keydown.escape)=\"clearCustomValue()\"\r\n />\r\n </div>\r\n\r\n <!-- Insert Button with Type Preview -->\r\n @if (customValue()) {\r\n <button\r\n type=\"button\"\r\n class=\"inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-all duration-200 hover:shadow-sm active:scale-95\"\r\n [class]=\"customValueTypeClass()\"\r\n (click)=\"insertCustomValue()\"\r\n [title]=\"t('insertType', { type: customValueType() })\"\r\n >\r\n @switch (customValueType()) {\r\n @case (\"number\") {\r\n <svg\r\n class=\"h-3 w-3\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M7 20l4-16m2 16l4-16M6 9h14M4 15h14\"\r\n />\r\n </svg>\r\n }\r\n @case (\"string\") {\r\n <svg\r\n class=\"h-3 w-3\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 01.865-.501 48.172 48.172 0 003.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z\"\r\n />\r\n </svg>\r\n }\r\n @default {\r\n <svg\r\n class=\"h-3 w-3\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M12 4.5v15m7.5-7.5h-15\"\r\n />\r\n </svg>\r\n }\r\n }\r\n <span class=\"max-w-16 truncate\">{{ customValuePreview() }}</span>\r\n </button>\r\n }\r\n </div>\r\n </div>\r\n\r\n <!-- Main Content Row -->\r\n <div class=\"flex flex-1 overflow-hidden\">\r\n <!-- Vertical Tabs -->\r\n <div\r\n class=\"flex w-44 flex-col border-e border-slate-200 dark:border-slate-700\"\r\n >\r\n @for (tab of resolvedTabOptions(); track tab.value) {\r\n <button\r\n type=\"button\"\r\n class=\"flex cursor-pointer items-center gap-2 px-3 py-2.5 text-start text-sm font-medium transition-all duration-200\"\r\n [class]=\"\r\n activeTab() === tab.value\r\n ? 'bg-white border-e-2 border-primary text-primary dark:bg-slate-900'\r\n : searchQuery() && !tabHasResults(tab.value)\r\n ? 'text-slate-300 dark:text-slate-600'\r\n : 'text-slate-600 hover:bg-slate-100 hover:text-slate-800 dark:text-slate-300 dark:hover:bg-slate-700'\r\n \"\r\n (click)=\"setActiveTab(tab.value)\"\r\n >\r\n <!-- Tab Icons -->\r\n @switch (tab.value) {\r\n @case (\"functions\") {\r\n <svg\r\n class=\"h-5 w-5 shrink-0\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5\"\r\n />\r\n </svg>\r\n }\r\n @case (\"properties\") {\r\n <svg\r\n class=\"h-5 w-5 shrink-0\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M9.568 3H5.25A2.25 2.25 0 003 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.095 18.095 0 005.223-5.223c.542-.827.369-1.908-.33-2.607L11.16 3.66A2.25 2.25 0 009.568 3z\"\r\n />\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M6 6h.008v.008H6V6z\"\r\n />\r\n </svg>\r\n }\r\n @case (\"operators\") {\r\n <svg\r\n class=\"h-5 w-5 shrink-0\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M15.75 15.75V18m-7.5-6.75h.008v.008H8.25v-.008zm0 2.25h.008v.008H8.25V13.5zm0 2.25h.008v.008H8.25v-.008zm0 2.25h.008v.008H8.25V18zm2.498-6.75h.007v.008h-.007v-.008zm0 2.25h.007v.008h-.007V13.5zm0 2.25h.007v.008h-.007v-.008zm0 2.25h.007v.008h-.007V18zm2.504-6.75h.008v.008h-.008v-.008zm0 2.25h.008v.008h-.008V13.5zm0 2.25h.008v.008h-.008v-.008zm0 2.25h.008v.008h-.008V18zm2.498-6.75h.008v.008h-.008v-.008zm0 2.25h.008v.008h-.008V13.5zM8.25 6h7.5v2.25h-7.5V6zM12 2.25c-1.892 0-3.758.11-5.593.322C5.307 2.7 4.5 3.65 4.5 4.757V19.5a2.25 2.25 0 002.25 2.25h10.5a2.25 2.25 0 002.25-2.25V4.757c0-1.108-.806-2.057-1.907-2.185A48.507 48.507 0 0012 2.25z\"\r\n />\r\n </svg>\r\n }\r\n }\r\n <!-- Label (always visible) -->\r\n <span class=\"truncate whitespace-nowrap text-sm\">{{\r\n t(tab.value)\r\n }}</span>\r\n <!-- Count Badge -->\r\n @if (tab.value !== \"properties\" || !resolvedPropertiesTemplate()) {\r\n <span\r\n class=\"ms-auto rounded-full px-1.5 py-0.5 text-xs font-semibold\"\r\n [class]=\"\r\n activeTab() === tab.value\r\n ? 'bg-primary/10 text-primary'\r\n : 'bg-slate-200 text-slate-600 dark:bg-slate-600 dark:text-slate-300'\r\n \"\r\n >\r\n {{ getTabCount(tab.value) }}\r\n </span>\r\n }\r\n </button>\r\n }\r\n </div>\r\n\r\n <!-- Content Area -->\r\n <div class=\"flex flex-1 flex-col overflow-hidden\">\r\n <!-- Items Grid -->\r\n <div\r\n class=\"flex-1 p-2.5\"\r\n [class.overflow-y-auto]=\"\r\n activeTab() !== 'properties' || !resolvedPropertiesTemplate()\r\n \"\r\n >\r\n @switch (activeTab()) {\r\n @case (\"functions\") {\r\n @if (filteredCategories().length === 0) {\r\n <div\r\n class=\"flex h-full items-center justify-center text-sm text-slate-400 dark:text-slate-500\"\r\n >\r\n {{ labels()?.noFunctionsFound ?? t(\"noFunctionsFound\") }}\r\n </div>\r\n } @else {\r\n <div class=\"space-y-3\">\r\n @for (category of filteredCategories(); track category.name) {\r\n <div>\r\n <div class=\"mb-2 flex items-center gap-2\">\r\n <span\r\n class=\"text-sm font-semibold uppercase tracking-wider text-slate-500 dark:text-slate-400\"\r\n >\r\n {{ categoryLabel(category) }}\r\n </span>\r\n <span\r\n class=\"h-px flex-1 bg-slate-200/60 dark:bg-slate-700/60\"\r\n ></span>\r\n <span\r\n class=\"text-sm text-slate-400 dark:text-slate-500\"\r\n >{{ category.functions.length }}</span\r\n >\r\n </div>\r\n <div class=\"flex flex-wrap gap-1.5\">\r\n @for (fn of category.functions; track fn.name) {\r\n <mt-formula-toolbar-item\r\n type=\"function\"\r\n [value]=\"fn.name\"\r\n [description]=\"fn.description\"\r\n [signature]=\"fn.signature\"\r\n [template]=\"fn.template\"\r\n [templateCursorOffset]=\"fn.templateCursorOffset\"\r\n [returnType]=\"fn.returnType\"\r\n [parameters]=\"fn.parameters ?? []\"\r\n [examples]=\"fn.examples ?? []\"\r\n [hints]=\"fn.hints ?? []\"\r\n (onInsert)=\"insertBlock($event)\"\r\n />\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n }\r\n }\r\n @case (\"properties\") {\r\n @if (resolvedPropertiesTemplate(); as template) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"template\"\r\n [ngTemplateOutletContext]=\"propertiesTemplateContext\"\r\n />\r\n } @else {\r\n @if (filteredProperties().length === 0) {\r\n <div\r\n class=\"flex h-full items-center justify-center text-sm text-slate-400 dark:text-slate-500\"\r\n >\r\n {{\r\n labels()?.noPropertiesAvailable ??\r\n t(\"noPropertiesAvailable\")\r\n }}\r\n </div>\r\n } @else {\r\n <div class=\"flex flex-wrap gap-1.5\">\r\n @for (prop of filteredProperties(); track prop.key) {\r\n <mt-formula-toolbar-item\r\n type=\"property\"\r\n [value]=\"prop.key\"\r\n [display]=\"prop.name\"\r\n [description]=\"\r\n prop.description || t('property') + ': ' + prop.key\r\n \"\r\n propertyType=\"current\"\r\n (onInsert)=\"insertBlock($event)\"\r\n />\r\n }\r\n </div>\r\n }\r\n }\r\n }\r\n @case (\"operators\") {\r\n @if (filteredOperators().length === 0) {\r\n <div\r\n class=\"flex h-full items-center justify-center text-sm text-slate-400 dark:text-slate-500\"\r\n >\r\n {{ labels()?.noOperatorsFound ?? t(\"noOperatorsFound\") }}\r\n </div>\r\n } @else {\r\n <div class=\"space-y-3\">\r\n @for (group of operatorGroups(); track group.type) {\r\n <div>\r\n <div class=\"mb-2 flex items-center gap-2\">\r\n <span\r\n class=\"text-sm font-semibold uppercase tracking-wider text-slate-500 dark:text-slate-400\"\r\n >\r\n {{ operatorTypeLabel(group.type) }}\r\n </span>\r\n <span\r\n class=\"h-px flex-1 bg-slate-200/60 dark:bg-slate-700/60\"\r\n ></span>\r\n </div>\r\n <div class=\"flex flex-wrap gap-1.5\">\r\n @for (op of group.operators; track op.symbol) {\r\n <mt-formula-toolbar-item\r\n type=\"operator\"\r\n [value]=\"op.symbol\"\r\n [description]=\"op.description\"\r\n (onInsert)=\"insertBlock($event)\"\r\n />\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n }\r\n }\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n" }]
2593
- }], ctorParameters: () => [], propDecorators: { knownProperties: [{ type: i0.Input, args: [{ isSignal: true, alias: "knownProperties", required: false }] }], propertiesTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertiesTemplate", required: false }] }], projectedPropertiesTemplate: [{ type: i0.ContentChild, args: ['properties', { ...{
2594
- read: TemplateRef,
2595
- }, isSignal: true }] }], functionCategories: [{ type: i0.Input, args: [{ isSignal: true, alias: "functionCategories", required: false }] }], operators: [{ type: i0.Input, args: [{ isSignal: true, alias: "operators", required: false }] }], initialTab: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialTab", required: false }] }], visibleTabs: [{ type: i0.Input, args: [{ isSignal: true, alias: "visibleTabs", required: false }] }], searchPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchPlaceholder", required: false }] }], labels: [{ type: i0.Input, args: [{ isSignal: true, alias: "labels", required: false }] }], onBlockInsert: [{ type: i0.Output, args: ["onBlockInsert"] }], onTabChange: [{ type: i0.Output, args: ["onTabChange"] }] } });
2596
-
2597
- /**
2598
- * Formula Status Bar Component
2599
- * Displays validation status, complexity, and dependencies
2600
- *
2601
- * This is a PURE input/output component with NO service dependencies.
2602
- */
2603
- class FormulaStatusBar {
2604
- // ============ INPUTS ============
2605
- /** Validation result */
2606
- validation = input(null, ...(ngDevMode ? [{ debugName: "validation" }] : /* istanbul ignore next */ []));
2607
- /** Labels for i18n support */
2608
- labels = input({}, ...(ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []));
2609
- // ============ COMPUTED ============
2610
- /** Is formula valid */
2611
- isValid = computed(() => this.validation()?.isValid ?? true, ...(ngDevMode ? [{ debugName: "isValid" }] : /* istanbul ignore next */ []));
2612
- /** Complexity score */
2613
- complexity = computed(() => this.validation()?.complexity ?? 0, ...(ngDevMode ? [{ debugName: "complexity" }] : /* istanbul ignore next */ []));
2614
- /** Dependencies list */
2615
- dependencies = computed(() => this.validation()?.dependencies ?? [], ...(ngDevMode ? [{ debugName: "dependencies" }] : /* istanbul ignore next */ []));
2616
- /** Dependencies as text */
2617
- dependenciesText = computed(() => {
2618
- const deps = this.dependencies();
2619
- if (deps.length <= 3) {
2620
- return deps.join(', ');
2621
- }
2622
- return `${deps.slice(0, 3).join(', ')} +${deps.length - 3}`;
2623
- }, ...(ngDevMode ? [{ debugName: "dependenciesText" }] : /* istanbul ignore next */ []));
2624
- /** First error */
2625
- firstError = computed(() => this.validation()?.errors?.[0] ?? null, ...(ngDevMode ? [{ debugName: "firstError" }] : /* istanbul ignore next */ []));
2626
- /** Complexity CSS class */
2627
- complexityClass = computed(() => {
2628
- const c = this.complexity();
2629
- if (c <= 10)
2630
- return 'text-emerald-600 dark:text-emerald-400';
2631
- if (c <= 25)
2632
- return 'text-amber-600 dark:text-amber-400';
2633
- return 'text-rose-600 dark:text-rose-400';
2634
- }, ...(ngDevMode ? [{ debugName: "complexityClass" }] : /* istanbul ignore next */ []));
2635
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormulaStatusBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
2636
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: FormulaStatusBar, isStandalone: true, selector: "mt-formula-status-bar", inputs: { validation: { classPropertyName: "validation", publicName: "validation", isSignal: true, isRequired: false, transformFunction: null }, labels: { classPropertyName: "labels", publicName: "labels", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div\r\n *transloco=\"let t; prefix: 'components.formula.statusBar'\"\r\n class=\"flex items-center gap-4 border-t border-slate-200 px-4 py-2 text-sm dark:border-slate-700\"\r\n>\r\n <!-- Validation Status -->\r\n <div class=\"flex items-center gap-1.5\">\r\n @if (isValid()) {\r\n <span\r\n class=\"flex h-5 w-5 items-center justify-center rounded-full bg-emerald-100 text-emerald-600 dark:bg-emerald-900 dark:text-emerald-400\"\r\n >\r\n <svg\r\n class=\"h-3.5 w-3.5\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2.5\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M5 13l4 4L19 7\"\r\n />\r\n </svg>\r\n </span>\r\n <span class=\"font-medium text-emerald-600 dark:text-emerald-400\">\r\n {{ labels()?.valid ?? t(\"valid\") }}\r\n </span>\r\n } @else {\r\n <span\r\n class=\"flex h-5 w-5 items-center justify-center rounded-full bg-rose-100 text-rose-600 dark:bg-rose-900 dark:text-rose-400\"\r\n >\r\n <svg\r\n class=\"h-3.5 w-3.5\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2.5\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M6 18L18 6M6 6l12 12\"\r\n />\r\n </svg>\r\n </span>\r\n <span class=\"font-medium text-rose-600 dark:text-rose-400\">\r\n {{ labels()?.invalid ?? t(\"invalid\") }}\r\n </span>\r\n }\r\n </div>\r\n\r\n <!-- Separator -->\r\n <div class=\"h-4 w-px bg-slate-300 dark:bg-slate-600\"></div>\r\n\r\n <!-- Complexity -->\r\n <div class=\"flex items-center gap-1.5 text-slate-500 dark:text-slate-400\">\r\n <svg class=\"h-4 w-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n stroke-width=\"2\"\r\n d=\"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z\"\r\n />\r\n </svg>\r\n <span>{{ labels()?.complexity ?? t(\"complexity\") }}:</span>\r\n <span class=\"font-medium\" [class]=\"complexityClass()\">\r\n {{ complexity() }}\r\n </span>\r\n </div>\r\n\r\n <!-- Dependencies -->\r\n @if (dependencies().length > 0) {\r\n <div class=\"h-4 w-px bg-slate-300 dark:bg-slate-600\"></div>\r\n <div class=\"flex items-center gap-1.5 text-slate-500 dark:text-slate-400\">\r\n <svg\r\n class=\"h-4 w-4\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n stroke-width=\"2\"\r\n d=\"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1\"\r\n />\r\n </svg>\r\n <span>{{ labels()?.dependencies ?? t(\"dependencies\") }}:</span>\r\n <span class=\"font-medium text-slate-700 dark:text-slate-300\">\r\n {{ dependenciesText() }}\r\n </span>\r\n </div>\r\n }\r\n\r\n <!-- Error message (if any) -->\r\n @if (firstError(); as error) {\r\n <div\r\n class=\"ms-auto flex items-center gap-1.5 text-rose-600 dark:text-rose-400\"\r\n >\r\n <svg\r\n class=\"h-4 w-4\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n stroke-width=\"2\"\r\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\r\n />\r\n </svg>\r\n <span class=\"text-xs\">{{ error.message }}</span>\r\n <span class=\"text-xs opacity-60\"\r\n >({{ error.line }}:{{ error.column }})</span\r\n >\r\n </div>\r\n }\r\n</div>\r\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: TranslocoModule }, { kind: "directive", type: i1$1.TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }] });
2637
- }
2638
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormulaStatusBar, decorators: [{
2639
- type: Component,
2640
- args: [{ selector: 'mt-formula-status-bar', standalone: true, imports: [CommonModule, TranslocoModule], template: "<div\r\n *transloco=\"let t; prefix: 'components.formula.statusBar'\"\r\n class=\"flex items-center gap-4 border-t border-slate-200 px-4 py-2 text-sm dark:border-slate-700\"\r\n>\r\n <!-- Validation Status -->\r\n <div class=\"flex items-center gap-1.5\">\r\n @if (isValid()) {\r\n <span\r\n class=\"flex h-5 w-5 items-center justify-center rounded-full bg-emerald-100 text-emerald-600 dark:bg-emerald-900 dark:text-emerald-400\"\r\n >\r\n <svg\r\n class=\"h-3.5 w-3.5\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2.5\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M5 13l4 4L19 7\"\r\n />\r\n </svg>\r\n </span>\r\n <span class=\"font-medium text-emerald-600 dark:text-emerald-400\">\r\n {{ labels()?.valid ?? t(\"valid\") }}\r\n </span>\r\n } @else {\r\n <span\r\n class=\"flex h-5 w-5 items-center justify-center rounded-full bg-rose-100 text-rose-600 dark:bg-rose-900 dark:text-rose-400\"\r\n >\r\n <svg\r\n class=\"h-3.5 w-3.5\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n stroke-width=\"2.5\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n d=\"M6 18L18 6M6 6l12 12\"\r\n />\r\n </svg>\r\n </span>\r\n <span class=\"font-medium text-rose-600 dark:text-rose-400\">\r\n {{ labels()?.invalid ?? t(\"invalid\") }}\r\n </span>\r\n }\r\n </div>\r\n\r\n <!-- Separator -->\r\n <div class=\"h-4 w-px bg-slate-300 dark:bg-slate-600\"></div>\r\n\r\n <!-- Complexity -->\r\n <div class=\"flex items-center gap-1.5 text-slate-500 dark:text-slate-400\">\r\n <svg class=\"h-4 w-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n stroke-width=\"2\"\r\n d=\"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z\"\r\n />\r\n </svg>\r\n <span>{{ labels()?.complexity ?? t(\"complexity\") }}:</span>\r\n <span class=\"font-medium\" [class]=\"complexityClass()\">\r\n {{ complexity() }}\r\n </span>\r\n </div>\r\n\r\n <!-- Dependencies -->\r\n @if (dependencies().length > 0) {\r\n <div class=\"h-4 w-px bg-slate-300 dark:bg-slate-600\"></div>\r\n <div class=\"flex items-center gap-1.5 text-slate-500 dark:text-slate-400\">\r\n <svg\r\n class=\"h-4 w-4\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n stroke-width=\"2\"\r\n d=\"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1\"\r\n />\r\n </svg>\r\n <span>{{ labels()?.dependencies ?? t(\"dependencies\") }}:</span>\r\n <span class=\"font-medium text-slate-700 dark:text-slate-300\">\r\n {{ dependenciesText() }}\r\n </span>\r\n </div>\r\n }\r\n\r\n <!-- Error message (if any) -->\r\n @if (firstError(); as error) {\r\n <div\r\n class=\"ms-auto flex items-center gap-1.5 text-rose-600 dark:text-rose-400\"\r\n >\r\n <svg\r\n class=\"h-4 w-4\"\r\n fill=\"none\"\r\n viewBox=\"0 0 24 24\"\r\n stroke=\"currentColor\"\r\n >\r\n <path\r\n stroke-linecap=\"round\"\r\n stroke-linejoin=\"round\"\r\n stroke-width=\"2\"\r\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\r\n />\r\n </svg>\r\n <span class=\"text-xs\">{{ error.message }}</span>\r\n <span class=\"text-xs opacity-60\"\r\n >({{ error.line }}:{{ error.column }})</span\r\n >\r\n </div>\r\n }\r\n</div>\r\n" }]
2641
- }], propDecorators: { validation: [{ type: i0.Input, args: [{ isSignal: true, alias: "validation", required: false }] }], labels: [{ type: i0.Input, args: [{ isSignal: true, alias: "labels", required: false }] }] } });
2642
-
2643
- const CONDITION_FUNCTION_CATEGORIES = [
2644
- {
2645
- name: 'Logic',
2646
- displayName: 'Field Visibility',
2647
- functions: [
2648
- {
2649
- name: 'SHOW_IF',
2650
- category: 'Logic',
2651
- description: 'Show this field when condition is true',
2652
- signature: 'SHOW_IF(condition)',
2653
- parameters: [
2654
- {
2655
- name: 'condition',
2656
- type: 'boolean',
2657
- description: 'When true, field is visible',
2658
- required: true,
2659
- },
2660
- ],
2661
- returnType: 'boolean',
2662
- examples: ['SHOW_IF(@Status == "Active")'],
2663
- },
2664
- {
2665
- name: 'HIDE_IF',
2666
- category: 'Logic',
2667
- description: 'Hide this field when condition is true',
2668
- signature: 'HIDE_IF(condition)',
2669
- parameters: [
2670
- {
2671
- name: 'condition',
2672
- type: 'boolean',
2673
- description: 'When true, field is hidden',
2674
- required: true,
2675
- },
2676
- ],
2677
- returnType: 'boolean',
2678
- examples: ['HIDE_IF(@Status == "Closed")'],
2679
- },
2680
- {
2681
- name: 'DISABLE_IF',
2682
- category: 'Logic',
2683
- description: 'Disable this field when condition is true',
2684
- signature: 'DISABLE_IF(condition)',
2685
- parameters: [
2686
- {
2687
- name: 'condition',
2688
- type: 'boolean',
2689
- description: 'When true, field is disabled',
2690
- required: true,
2691
- },
2692
- ],
2693
- returnType: 'boolean',
2694
- examples: ['DISABLE_IF(@Status == "Approved")'],
2695
- },
2696
- {
2697
- name: 'ENABLE_IF',
2698
- category: 'Logic',
2699
- description: 'Enable this field when condition is true',
2700
- signature: 'ENABLE_IF(condition)',
2701
- parameters: [
2702
- {
2703
- name: 'condition',
2704
- type: 'boolean',
2705
- description: 'When true, field is enabled',
2706
- required: true,
2707
- },
2708
- ],
2709
- returnType: 'boolean',
2710
- examples: ['ENABLE_IF(@Status == "Draft")'],
2711
- },
2712
- ],
2713
- },
2714
- {
2715
- name: 'Aggregation',
2716
- displayName: 'Logic Helpers',
2717
- functions: [
2718
- {
2719
- name: 'AND',
2720
- category: 'Aggregation',
2721
- description: 'Returns true if all conditions are true',
2722
- signature: 'AND(condition1, condition2)',
2723
- parameters: [
2724
- {
2725
- name: 'condition1',
2726
- type: 'boolean',
2727
- description: 'First condition',
2728
- required: true,
2729
- },
2730
- {
2731
- name: 'condition2',
2732
- type: 'boolean',
2733
- description: 'Second condition',
2734
- required: true,
2735
- },
2736
- ],
2737
- returnType: 'boolean',
2738
- examples: ['AND(@Status == "Active", @Priority > 0)'],
2739
- },
2740
- {
2741
- name: 'OR',
2742
- category: 'Aggregation',
2743
- description: 'Returns true if any condition is true',
2744
- signature: 'OR(condition1, condition2)',
2745
- parameters: [
2746
- {
2747
- name: 'condition1',
2748
- type: 'boolean',
2749
- description: 'First condition',
2750
- required: true,
2751
- },
2752
- {
2753
- name: 'condition2',
2754
- type: 'boolean',
2755
- description: 'Second condition',
2756
- required: true,
2757
- },
2758
- ],
2759
- returnType: 'boolean',
2760
- examples: ['OR(@Status == "Active", @Status == "Pending")'],
2761
- },
2762
- {
2763
- name: 'NOT',
2764
- category: 'Aggregation',
2765
- description: 'Returns the opposite of the condition',
2766
- signature: 'NOT(condition)',
2767
- parameters: [
2768
- {
2769
- name: 'condition',
2770
- type: 'boolean',
2771
- description: 'Condition to negate',
2772
- required: true,
2773
- },
2774
- ],
2775
- returnType: 'boolean',
2776
- examples: ['NOT(@IsCompleted)'],
2777
- },
2778
- {
2779
- name: 'ISNULL',
2780
- category: 'Aggregation',
2781
- description: 'Returns true if value is null or empty',
2782
- signature: 'ISNULL(value)',
2783
- parameters: [
2784
- {
2785
- name: 'value',
2786
- type: 'any',
2787
- description: 'Value to check',
2788
- required: true,
2789
- },
2790
- ],
2791
- returnType: 'boolean',
2792
- examples: ['ISNULL(@Description)'],
2793
- },
2794
- {
2795
- name: 'CONTAINS',
2796
- category: 'Aggregation',
2797
- description: 'Returns true if text contains the search string',
2798
- signature: 'CONTAINS(text, search)',
2799
- parameters: [
2800
- {
2801
- name: 'text',
2802
- type: 'string',
2803
- description: 'Text to search in',
2804
- required: true,
2805
- },
2806
- {
2807
- name: 'search',
2808
- type: 'string',
2809
- description: 'String to search for',
2810
- required: true,
2811
- },
2812
- ],
2813
- returnType: 'boolean',
2814
- examples: ['CONTAINS(@Name, "Project")'],
2815
- },
2816
- ],
2817
- },
2818
- ];
2819
- const CONDITION_OPERATORS = [
2820
- {
2821
- symbol: '==',
2822
- name: 'Equal',
2823
- type: 'comparison',
2824
- description: 'Equal to',
2825
- precedence: 3,
2826
- },
2827
- {
2828
- symbol: '!=',
2829
- name: 'Not Equal',
2830
- type: 'comparison',
2831
- description: 'Not equal to',
2832
- precedence: 3,
2833
- },
2834
- {
2835
- symbol: '>',
2836
- name: 'Greater Than',
2837
- type: 'comparison',
2838
- description: 'Greater than',
2839
- precedence: 4,
2840
- },
2841
- {
2842
- symbol: '<',
2843
- name: 'Less Than',
2844
- type: 'comparison',
2845
- description: 'Less than',
2846
- precedence: 4,
2847
- },
2848
- {
2849
- symbol: '>=',
2850
- name: 'Greater or Equal',
2851
- type: 'comparison',
2852
- description: 'Greater than or equal',
2853
- precedence: 4,
2854
- },
2855
- {
2856
- symbol: '<=',
2857
- name: 'Less or Equal',
2858
- type: 'comparison',
2859
- description: 'Less than or equal',
2860
- precedence: 4,
2861
- },
2862
- {
2863
- symbol: '&&',
2864
- name: 'And',
2865
- type: 'logical',
2866
- description: 'Logical AND',
2867
- precedence: 2,
2868
- },
2869
- {
2870
- symbol: '||',
2871
- name: 'Or',
2872
- type: 'logical',
2873
- description: 'Logical OR',
2874
- precedence: 1,
2875
- },
2876
- ];
2877
- const VALIDATION_FUNCTION_CATEGORIES = [
2878
- {
2879
- name: 'Validation',
2880
- displayName: 'Validation',
2881
- functions: [
2882
- {
2883
- name: 'REQUIRED',
2884
- category: 'Validation',
2885
- description: 'Returns true when value is not empty',
2886
- signature: 'REQUIRED(value)',
2887
- parameters: [
2888
- {
2889
- name: 'value',
2890
- type: 'any',
2891
- description: 'Value to check',
2892
- required: true,
2893
- },
2894
- ],
2895
- returnType: 'boolean',
2896
- examples: ['REQUIRED(@Email)'],
2897
- },
2898
- {
2899
- name: 'ISNULL',
2900
- category: 'Validation',
2901
- description: 'Returns true if value is null or empty',
2902
- signature: 'ISNULL(value)',
2903
- parameters: [
2904
- {
2905
- name: 'value',
2906
- type: 'any',
2907
- description: 'Value to check',
2908
- required: true,
2909
- },
2910
- ],
2911
- returnType: 'boolean',
2912
- examples: ['ISNULL(@Phone)'],
2913
- },
2914
- {
2915
- name: 'MIN_LENGTH',
2916
- category: 'Validation',
2917
- description: 'Returns true if value length is at least min',
2918
- signature: 'MIN_LENGTH(value, min)',
2919
- parameters: [
2920
- {
2921
- name: 'value',
2922
- type: 'string',
2923
- description: 'Value to check',
2924
- required: true,
2925
- },
2926
- {
2927
- name: 'min',
2928
- type: 'number',
2929
- description: 'Minimum length',
2930
- required: true,
2931
- },
2932
- ],
2933
- returnType: 'boolean',
2934
- examples: ['MIN_LENGTH(@Password, 8)'],
2935
- },
2936
- {
2937
- name: 'MAX_LENGTH',
2938
- category: 'Validation',
2939
- description: 'Returns true if value length is at most max',
2940
- signature: 'MAX_LENGTH(value, max)',
2941
- parameters: [
2942
- {
2943
- name: 'value',
2944
- type: 'string',
2945
- description: 'Value to check',
2946
- required: true,
2947
- },
2948
- {
2949
- name: 'max',
2950
- type: 'number',
2951
- description: 'Maximum length',
2952
- required: true,
2953
- },
2954
- ],
2955
- returnType: 'boolean',
2956
- examples: ['MAX_LENGTH(@Title, 120)'],
2957
- },
2958
- {
2959
- name: 'REGEX',
2960
- category: 'Validation',
2961
- description: 'Returns true if value matches regex pattern',
2962
- signature: 'REGEX(value, pattern)',
2963
- parameters: [
2964
- {
2965
- name: 'value',
2966
- type: 'string',
2967
- description: 'Value to check',
2968
- required: true,
2969
- },
2970
- {
2971
- name: 'pattern',
2972
- type: 'string',
2973
- description: 'Regex pattern',
2974
- required: true,
2975
- },
2976
- ],
2977
- returnType: 'boolean',
2978
- examples: ['REGEX(@Email, "^[^@]+@[^@]+\\.[^@]+$")'],
2979
- },
2980
- {
2981
- name: 'BEFORE',
2982
- category: 'Validation',
2983
- description: 'Returns true if date is before reference date',
2984
- signature: 'BEFORE(date, reference)',
2985
- parameters: [
2986
- {
2987
- name: 'date',
2988
- type: 'date',
2989
- description: 'Date to check',
2990
- required: true,
2991
- },
2992
- {
2993
- name: 'reference',
2994
- type: 'date',
2995
- description: 'Reference date',
2996
- required: true,
2997
- },
2998
- ],
2999
- returnType: 'boolean',
3000
- examples: ['BEFORE(@EndDate, @StartDate)'],
3001
- },
3002
- {
3003
- name: 'AFTER',
3004
- category: 'Validation',
3005
- description: 'Returns true if date is after reference date',
3006
- signature: 'AFTER(date, reference)',
3007
- parameters: [
3008
- {
3009
- name: 'date',
3010
- type: 'date',
3011
- description: 'Date to check',
3012
- required: true,
3013
- },
3014
- {
3015
- name: 'reference',
3016
- type: 'date',
3017
- description: 'Reference date',
3018
- required: true,
3019
- },
3020
- ],
3021
- returnType: 'boolean',
3022
- examples: ['AFTER(@StartDate, @EndDate)'],
3023
- },
3024
- ],
3025
- },
3026
- {
3027
- name: 'Logic',
3028
- displayName: 'Logic Helpers',
3029
- functions: [
3030
- {
3031
- name: 'AND',
3032
- category: 'Logic',
3033
- description: 'Returns true if all conditions are true',
3034
- signature: 'AND(condition1, condition2)',
3035
- parameters: [
3036
- {
3037
- name: 'condition1',
3038
- type: 'boolean',
3039
- description: 'First condition',
3040
- required: true,
3041
- },
3042
- {
3043
- name: 'condition2',
3044
- type: 'boolean',
3045
- description: 'Second condition',
3046
- required: true,
3047
- },
3048
- ],
3049
- returnType: 'boolean',
3050
- examples: ['AND(REQUIRED(@Email), REGEX(@Email, "^.+@.+$"))'],
3051
- },
3052
- {
3053
- name: 'OR',
3054
- category: 'Logic',
3055
- description: 'Returns true if any condition is true',
3056
- signature: 'OR(condition1, condition2)',
3057
- parameters: [
3058
- {
3059
- name: 'condition1',
3060
- type: 'boolean',
3061
- description: 'First condition',
3062
- required: true,
3063
- },
3064
- {
3065
- name: 'condition2',
3066
- type: 'boolean',
3067
- description: 'Second condition',
3068
- required: true,
3069
- },
3070
- ],
3071
- returnType: 'boolean',
3072
- examples: ['OR(ISNULL(@Phone), REGEX(@Phone, "^\\+?[0-9]+$"))'],
3073
- },
3074
- {
3075
- name: 'NOT',
3076
- category: 'Logic',
3077
- description: 'Returns the opposite of a condition',
3078
- signature: 'NOT(condition)',
3079
- parameters: [
3080
- {
3081
- name: 'condition',
3082
- type: 'boolean',
3083
- description: 'Condition to negate',
3084
- required: true,
3085
- },
3086
- ],
3087
- returnType: 'boolean',
3088
- examples: ['NOT(ISNULL(@Password))'],
3089
- },
3090
- ],
3091
- },
3092
- ];
3093
- const VALIDATION_OPERATORS = [
3094
- {
3095
- symbol: '+',
3096
- name: 'Add',
3097
- type: 'arithmetic',
3098
- description: 'Addition',
3099
- precedence: 4,
3100
- },
3101
- {
3102
- symbol: '-',
3103
- name: 'Subtract',
3104
- type: 'arithmetic',
3105
- description: 'Subtraction',
3106
- precedence: 4,
3107
- },
3108
- {
3109
- symbol: '*',
3110
- name: 'Multiply',
3111
- type: 'arithmetic',
3112
- description: 'Multiplication',
3113
- precedence: 5,
3114
- },
3115
- {
3116
- symbol: '/',
3117
- name: 'Divide',
3118
- type: 'arithmetic',
3119
- description: 'Division',
3120
- precedence: 5,
3121
- },
3122
- {
3123
- symbol: '==',
3124
- name: 'Equal',
3125
- type: 'comparison',
3126
- description: 'Equal to',
3127
- precedence: 3,
3128
- },
3129
- {
3130
- symbol: '!=',
3131
- name: 'Not Equal',
3132
- type: 'comparison',
3133
- description: 'Not equal to',
3134
- precedence: 3,
3135
- },
3136
- {
3137
- symbol: '>',
3138
- name: 'Greater Than',
3139
- type: 'comparison',
3140
- description: 'Greater than',
3141
- precedence: 3,
3142
- },
3143
- {
3144
- symbol: '<',
3145
- name: 'Less Than',
3146
- type: 'comparison',
3147
- description: 'Less than',
3148
- precedence: 3,
3149
- },
3150
- {
3151
- symbol: '>=',
3152
- name: 'Greater or Equal',
3153
- type: 'comparison',
3154
- description: 'Greater than or equal',
3155
- precedence: 3,
3156
- },
3157
- {
3158
- symbol: '<=',
3159
- name: 'Less or Equal',
3160
- type: 'comparison',
3161
- description: 'Less than or equal',
3162
- precedence: 3,
3163
- },
3164
- {
3165
- symbol: '&&',
3166
- name: 'And',
3167
- type: 'logical',
3168
- description: 'Logical AND',
3169
- precedence: 2,
3170
- },
3171
- {
3172
- symbol: '||',
3173
- name: 'Or',
3174
- type: 'logical',
3175
- description: 'Logical OR',
3176
- precedence: 1,
3177
- },
3178
- ];
3179
- const CONDITION_RUNTIME_CATALOG = {
3180
- domain: 'condition',
3181
- functions: CONDITION_FUNCTION_CATEGORIES,
3182
- operators: CONDITION_OPERATORS,
3183
- };
3184
- const VALIDATION_RUNTIME_CATALOG = {
3185
- domain: 'validation',
3186
- functions: VALIDATION_FUNCTION_CATEGORIES,
3187
- operators: VALIDATION_OPERATORS,
3188
- };
3189
-
3190
- const CONDITION_WRAPPER_NAMES = new Set([
3191
- 'show',
3192
- 'hide',
3193
- 'enable',
3194
- 'disable',
3195
- ]);
3196
- const PROPERTY_PREFIXES = ['@', '*.', '$.'];
3197
- // Matches plain integers / decimals (optionally signed). Such values are
3198
- // numbers, never dates — see `toDate`.
3199
- const NUMERIC_STRING_PATTERN = /^[+-]?(\d+\.?\d*|\.\d+)$/;
3200
- class FormulaParser {
3201
- tokens;
3202
- current = 0;
3203
- dependencies = new Set();
3204
- constructor(tokens) {
3205
- this.tokens = tokens;
3206
- }
3207
- parse() {
3208
- const ast = this.expression();
3209
- this.consume('eof', 'Unexpected tokens after formula end');
3210
- const topLevelWrapper = ast.type === 'call' ? normalizeWrapperAction(ast.name) : null;
3211
- return {
3212
- ast,
3213
- dependencies: Array.from(this.dependencies),
3214
- topLevelWrapper,
3215
- };
3216
- }
3217
- expression() {
3218
- return this.logicalOr();
3219
- }
3220
- logicalOr() {
3221
- let expr = this.logicalAnd();
3222
- while (this.matchOperator('||')) {
3223
- const operator = this.previousOperator();
3224
- const right = this.logicalAnd();
3225
- expr = { type: 'binary', operator, left: expr, right };
3226
- }
3227
- return expr;
3228
- }
3229
- logicalAnd() {
3230
- let expr = this.equality();
3231
- while (this.matchOperator('&&')) {
3232
- const operator = this.previousOperator();
3233
- const right = this.equality();
3234
- expr = { type: 'binary', operator, left: expr, right };
3235
- }
3236
- return expr;
3237
- }
3238
- equality() {
3239
- let expr = this.comparison();
3240
- while (this.matchOperator('==', '!=')) {
3241
- const operator = this.previousOperator();
3242
- const right = this.comparison();
3243
- expr = { type: 'binary', operator, left: expr, right };
3244
- }
3245
- return expr;
3246
- }
3247
- comparison() {
3248
- let expr = this.addition();
3249
- while (this.matchOperator('>', '>=', '<', '<=')) {
3250
- const operator = this.previousOperator();
3251
- const right = this.addition();
3252
- expr = { type: 'binary', operator, left: expr, right };
3253
- }
3254
- return expr;
3255
- }
3256
- addition() {
3257
- let expr = this.multiplication();
3258
- while (this.matchOperator('+', '-')) {
3259
- const operator = this.previousOperator();
3260
- const right = this.multiplication();
3261
- expr = { type: 'binary', operator, left: expr, right };
3262
- }
3263
- return expr;
3264
- }
3265
- multiplication() {
3266
- let expr = this.unary();
3267
- while (this.matchOperator('*', '/')) {
3268
- const operator = this.previousOperator();
3269
- const right = this.unary();
3270
- expr = { type: 'binary', operator, left: expr, right };
3271
- }
3272
- return expr;
3273
- }
3274
- unary() {
3275
- if (this.matchOperator('!', '-')) {
3276
- const operator = this.previousOperator();
3277
- const right = this.unary();
3278
- return { type: 'unary', operator, right };
3279
- }
3280
- return this.primary();
3281
- }
3282
- primary() {
3283
- if (this.match('literal')) {
3284
- return { type: 'literal', value: this.previous().value };
3285
- }
3286
- if (this.match('property')) {
3287
- const token = this.previousProperty();
3288
- this.dependencies.add(token.value);
3289
- return { type: 'property', key: token.value, raw: token.raw };
3290
- }
3291
- if (this.match('identifier')) {
3292
- const name = this.previous().value;
3293
- if (!this.match('lparen')) {
3294
- throw new Error(`Expected "(" after function "${name}"`);
3295
- }
3296
- const args = [];
3297
- if (!this.check('rparen')) {
3298
- do {
3299
- args.push(this.expression());
3300
- } while (this.match('comma'));
3301
- }
3302
- this.consume('rparen', `Expected ")" after function "${name}"`);
3303
- return { type: 'call', name, args };
3304
- }
3305
- if (this.match('lparen')) {
3306
- const expr = this.expression();
3307
- this.consume('rparen', 'Expected ")" after expression');
3308
- return expr;
3309
- }
3310
- throw new Error('Unexpected token while parsing formula');
3311
- }
3312
- previous() {
3313
- return this.tokens[this.current - 1];
3314
- }
3315
- previousProperty() {
3316
- return this.tokens[this.current - 1];
3317
- }
3318
- previousOperator() {
3319
- return this.tokens[this.current - 1].value;
3320
- }
3321
- consume(type, message) {
3322
- if (this.check(type)) {
3323
- this.advance();
3324
- return;
3325
- }
3326
- throw new Error(message);
3327
- }
3328
- match(type) {
3329
- if (!this.check(type))
3330
- return false;
3331
- this.advance();
3332
- return true;
3333
- }
3334
- matchOperator(...operators) {
3335
- if (!this.check('operator'))
3336
- return false;
3337
- const token = this.peek();
3338
- if (!operators.includes(token.value))
3339
- return false;
3340
- this.advance();
3341
- return true;
3342
- }
3343
- check(type) {
3344
- if (this.isAtEnd())
3345
- return type === 'eof';
3346
- return this.peek().type === type;
3347
- }
3348
- advance() {
3349
- if (!this.isAtEnd())
3350
- this.current++;
3351
- return this.tokens[this.current - 1];
3352
- }
3353
- isAtEnd() {
3354
- return this.peek().type === 'eof';
3355
- }
3356
- peek() {
3357
- return this.tokens[this.current];
3358
- }
3359
- }
3360
- class FormulaRuntimeEngine {
3361
- compiledCache = new Map();
3362
- functionRegistry;
3363
- constructor(customFunctions) {
3364
- this.functionRegistry = {
3365
- ...buildDefaultFunctionRegistry(),
3366
- ...(customFunctions ?? {}),
3367
- };
3368
- }
3369
- evaluateCondition(config, context) {
3370
- let compiled;
3371
- try {
3372
- compiled = this.getCompiledFormula(config.formulaTokens);
3373
- }
3374
- catch (error) {
3375
- return {
3376
- dependencies: [],
3377
- errors: [createRuntimeError('FORMULA_PARSE_ERROR', error)],
3378
- };
3379
- }
3380
- let rawValue;
3381
- try {
3382
- rawValue = this.evaluateAst(compiled.ast, context.values);
3383
- }
3384
- catch (error) {
3385
- return {
3386
- dependencies: compiled.dependencies,
3387
- errors: [createRuntimeError('FORMULA_EVALUATION_ERROR', error)],
3388
- };
3389
- }
3390
- const action = this.resolveConditionAction(config.mode, compiled);
3391
- const conditionValue = toBoolean(rawValue);
3392
- switch (action) {
3393
- case 'show':
3394
- return {
3395
- hidden: !conditionValue,
3396
- dependencies: compiled.dependencies,
3397
- errors: [],
3398
- };
3399
- case 'hide':
3400
- return {
3401
- hidden: conditionValue,
3402
- dependencies: compiled.dependencies,
3403
- errors: [],
3404
- };
3405
- case 'enable':
3406
- return {
3407
- disabled: !conditionValue,
3408
- dependencies: compiled.dependencies,
3409
- errors: [],
3410
- };
3411
- case 'disable':
3412
- return {
3413
- disabled: conditionValue,
3414
- dependencies: compiled.dependencies,
3415
- errors: [],
3416
- };
3417
- default:
3418
- return {
3419
- dependencies: compiled.dependencies,
3420
- errors: [],
3421
- };
3422
- }
3423
- }
3424
- evaluateValidation(rule, context) {
3425
- let compiled;
3426
- try {
3427
- compiled = this.getCompiledFormula(rule.formulaTokens);
3428
- }
3429
- catch (error) {
3430
- return {
3431
- valid: false,
3432
- dependencies: [],
3433
- errors: [createRuntimeError('FORMULA_PARSE_ERROR', error)],
3434
- };
3435
- }
3436
- try {
3437
- const value = this.evaluateAst(compiled.ast, context.values);
3438
- return {
3439
- valid: toBoolean(value),
3440
- dependencies: compiled.dependencies,
3441
- errors: [],
3442
- };
3443
- }
3444
- catch (error) {
3445
- return {
3446
- valid: false,
3447
- dependencies: compiled.dependencies,
3448
- errors: [createRuntimeError('FORMULA_EVALUATION_ERROR', error)],
3449
- };
3450
- }
3451
- }
3452
- evaluateValidationRules(rules, context, options) {
3453
- const errors = [];
3454
- const warnings = [];
3455
- const isDependencyActive = options?.isDependencyActive ?? (() => true);
3456
- rules.forEach((rule) => {
3457
- if (!rule.enabled)
3458
- return;
3459
- const result = this.evaluateValidation(rule, context);
3460
- const hasInactiveDependency = result.dependencies.some((dependency) => !isDependencyActive(dependency));
3461
- if (hasInactiveDependency)
3462
- return;
3463
- if (result.errors.length > 0) {
3464
- const firstError = result.errors[0];
3465
- const message = {
3466
- code: firstError.code,
3467
- severity: rule.severity,
3468
- message: firstError.message,
3469
- formulaText: rule.formulaText,
3470
- ruleId: rule.id,
3471
- };
3472
- if (rule.severity === 'error')
3473
- errors.push(message);
3474
- else
3475
- warnings.push(message);
3476
- return;
3477
- }
3478
- if (!result.valid) {
3479
- const message = {
3480
- code: 'FORMULA_FALSE',
3481
- severity: rule.severity,
3482
- message: rule.message || 'Validation rule failed',
3483
- formulaText: rule.formulaText,
3484
- ruleId: rule.id,
3485
- };
3486
- if (rule.severity === 'error')
3487
- errors.push(message);
3488
- else
3489
- warnings.push(message);
3490
- }
3491
- });
3492
- return { errors, warnings };
3493
- }
3494
- extractDependencies(formulaTokens) {
3495
- try {
3496
- return this.getCompiledFormula(formulaTokens).dependencies;
3497
- }
3498
- catch {
3499
- return [];
3500
- }
3501
- }
3502
- resolveConditionAction(mode, compiled) {
3503
- if (mode && mode !== 'auto')
3504
- return mode;
3505
- return compiled.topLevelWrapper ?? 'show';
3506
- }
3507
- getCompiledFormula(formulaTokens) {
3508
- const key = formulaTokens?.trim();
3509
- if (!key) {
3510
- throw new Error('Formula tokens are empty');
3511
- }
3512
- const cached = this.compiledCache.get(key);
3513
- if (cached)
3514
- return cached;
3515
- const tokens = this.deserializeFormulaTokens(key);
3516
- const lexTokens = this.toLexTokens(tokens);
3517
- const compiled = new FormulaParser(lexTokens).parse();
3518
- this.compiledCache.set(key, compiled);
3519
- return compiled;
3520
- }
3521
- deserializeFormulaTokens(formulaTokens) {
3522
- const trimmed = formulaTokens.trim();
3523
- // `formulaTokens` may be persisted in two equivalent encodings:
3524
- // - the canonical executable EXPRESSION string (e.g.
3525
- // "OR(ISNULL(@Current::x), ...)") — what the back-end stores; or
3526
- // - a JSON token array (legacy / inline-form snapshots).
3527
- // Accept both: a value that parses to an array of token objects is used
3528
- // directly; anything else is tokenized from the expression string.
3529
- if (trimmed.startsWith('[')) {
3530
- try {
3531
- const parsed = JSON.parse(trimmed);
3532
- if (Array.isArray(parsed) &&
3533
- (parsed.length === 0 ||
3534
- (typeof parsed[0] === 'object' &&
3535
- parsed[0] !== null &&
3536
- 'type' in parsed[0]))) {
3537
- return parsed;
3538
- }
3539
- }
3540
- catch {
3541
- // Not valid JSON — fall through and treat it as an expression string.
3542
- }
3543
- }
3544
- return tokenizeFormulaTemplate(trimmed);
3545
- }
3546
- toLexTokens(tokens) {
3547
- if (!tokens.length) {
3548
- throw new Error('Formula token array is empty');
3549
- }
3550
- const lex = [];
3551
- for (const token of tokens) {
3552
- switch (token.type) {
3553
- case 'fn-open': {
3554
- const functionName = (token.functionName ?? token.value.replace(/\($/, '')).trim();
3555
- if (!functionName) {
3556
- throw new Error('Formula contains function token without a name');
3557
- }
3558
- lex.push({ type: 'identifier', value: functionName });
3559
- lex.push({ type: 'lparen' });
3560
- break;
3561
- }
3562
- case 'fn-close':
3563
- lex.push({ type: 'rparen' });
3564
- break;
3565
- case 'fn-separator':
3566
- lex.push({ type: 'comma' });
3567
- break;
3568
- case 'operator':
3569
- lex.push({ type: 'operator', value: token.value });
3570
- break;
3571
- case 'property':
3572
- lex.push({
3573
- type: 'property',
3574
- value: normalizePropertyToken(token.value),
3575
- raw: token.value,
3576
- });
3577
- break;
3578
- case 'literal':
3579
- lex.push({ type: 'literal', value: parseLiteralTokenValue(token) });
3580
- break;
3581
- default:
3582
- throw new Error(`Unsupported formula token type: ${token.type}`);
3583
- }
3584
- }
3585
- lex.push({ type: 'eof' });
3586
- return lex;
3587
- }
3588
- evaluateAst(ast, values) {
3589
- switch (ast.type) {
3590
- case 'literal':
3591
- return ast.value;
3592
- case 'property':
3593
- return resolvePropertyValue(values, ast.key, ast.raw);
3594
- case 'unary': {
3595
- const right = this.evaluateAst(ast.right, values);
3596
- if (ast.operator === '!')
3597
- return !toBoolean(right);
3598
- if (ast.operator === '-')
3599
- return -toNumber(right);
3600
- throw new Error(`Unsupported unary operator: ${ast.operator}`);
3601
- }
3602
- case 'binary': {
3603
- const left = this.evaluateAst(ast.left, values);
3604
- const right = this.evaluateAst(ast.right, values);
3605
- return evaluateBinary(ast.operator, left, right);
3606
- }
3607
- case 'call': {
3608
- const fn = this.functionRegistry[ast.name.toUpperCase()];
3609
- if (!fn) {
3610
- throw new Error(`Unsupported function: ${ast.name}`);
3611
- }
3612
- const args = ast.args.map((arg) => this.evaluateAst(arg, values));
3613
- return fn(...args);
3614
- }
3615
- default:
3616
- throw new Error('Unsupported formula AST node');
3617
- }
3618
- }
3619
- }
3620
- function evaluateBinary(operator, left, right) {
3621
- switch (operator) {
3622
- case '||':
3623
- return toBoolean(left) || toBoolean(right);
3624
- case '&&':
3625
- return toBoolean(left) && toBoolean(right);
3626
- case '==':
3627
- return looseEqual(left, right);
3628
- case '!=':
3629
- return !looseEqual(left, right);
3630
- case '>':
3631
- return compareValues(left, right) > 0;
3632
- case '>=':
3633
- return compareValues(left, right) >= 0;
3634
- case '<':
3635
- return compareValues(left, right) < 0;
3636
- case '<=':
3637
- return compareValues(left, right) <= 0;
3638
- case '+':
3639
- return typeof left === 'string' || typeof right === 'string'
3640
- ? `${left ?? ''}${right ?? ''}`
3641
- : toNumber(left) + toNumber(right);
3642
- case '-':
3643
- return toNumber(left) - toNumber(right);
3644
- case '*':
3645
- return toNumber(left) * toNumber(right);
3646
- case '/':
3647
- return toNumber(left) / toNumber(right);
3648
- default:
3649
- throw new Error(`Unsupported operator: ${operator}`);
3650
- }
3651
- }
3652
- function looseEqual(left, right) {
3653
- if (Array.isArray(left) && Array.isArray(right)) {
3654
- return right.every((item) => left.includes(item));
3655
- }
3656
- if (Array.isArray(left))
3657
- return left.includes(right);
3658
- if (Array.isArray(right))
3659
- return right.includes(left);
3660
- const leftDate = toDate(left);
3661
- const rightDate = toDate(right);
3662
- if (leftDate && rightDate) {
3663
- return leftDate.getTime() === rightDate.getTime();
3664
- }
3665
- const leftNumber = maybeNumber(left);
3666
- const rightNumber = maybeNumber(right);
3667
- if (leftNumber !== null && rightNumber !== null) {
3668
- return leftNumber === rightNumber;
3669
- }
3670
- return left === right;
3671
- }
3672
- function compareValues(left, right) {
3673
- const leftDate = toDate(left);
3674
- const rightDate = toDate(right);
3675
- if (leftDate && rightDate) {
3676
- return leftDate.getTime() - rightDate.getTime();
3677
- }
3678
- const leftNumber = toNumber(left);
3679
- const rightNumber = toNumber(right);
3680
- return leftNumber - rightNumber;
3681
- }
3682
- function buildDefaultFunctionRegistry() {
3683
- const isNull = (value) => value === null ||
3684
- value === undefined ||
3685
- value === '' ||
3686
- (Array.isArray(value) && value.length === 0);
3687
- return {
3688
- SHOW_IF: (condition) => toBoolean(condition),
3689
- HIDE_IF: (condition) => toBoolean(condition),
3690
- ENABLE_IF: (condition) => toBoolean(condition),
3691
- DISABLE_IF: (condition) => toBoolean(condition),
3692
- AND: (...args) => args.every((arg) => toBoolean(arg)),
3693
- OR: (...args) => args.some((arg) => toBoolean(arg)),
3694
- NOT: (condition) => !toBoolean(condition),
3695
- ISNULL: (value) => isNull(value),
3696
- CONTAINS: (text, search) => String(text ?? '')
3697
- .toLowerCase()
3698
- .includes(String(search ?? '').toLowerCase()),
3699
- REQUIRED: (value) => !isNull(value),
3700
- MIN_LENGTH: (value, min) => String(value ?? '').length >= toNumber(min),
3701
- MAX_LENGTH: (value, max) => String(value ?? '').length <= toNumber(max),
3702
- REGEX: (value, pattern) => {
3703
- try {
3704
- return new RegExp(String(pattern ?? '')).test(String(value ?? ''));
3705
- }
3706
- catch {
3707
- return false;
3708
- }
3709
- },
3710
- BEFORE: (date, reference) => {
3711
- const left = toDate(date);
3712
- const right = toDate(reference);
3713
- if (!left || !right)
3714
- return false;
3715
- return left.getTime() < right.getTime();
3716
- },
3717
- AFTER: (date, reference) => {
3718
- const left = toDate(date);
3719
- const right = toDate(reference);
3720
- if (!left || !right)
3721
- return false;
3722
- return left.getTime() > right.getTime();
3723
- },
3724
- };
3725
- }
3726
- function normalizeWrapperAction(name) {
3727
- const normalized = name.trim().toLowerCase();
3728
- return CONDITION_WRAPPER_NAMES.has(normalized)
3729
- ? normalized
3730
- : null;
3731
- }
3732
- function normalizePropertyToken(raw) {
3733
- const value = String(raw ?? '').trim();
3734
- const prefix = PROPERTY_PREFIXES.find((p) => value.startsWith(p));
3735
- return prefix ? value.slice(prefix.length) : value;
3736
- }
3737
- function parseLiteralTokenValue(token) {
3738
- if (token.literalType === 'number') {
3739
- return toNumber(token.value);
3740
- }
3741
- if (token.literalType === 'boolean') {
3742
- return toBoolean(token.value);
3743
- }
3744
- const value = String(token.value ?? '').trim();
3745
- if ((value.startsWith('"') && value.endsWith('"')) ||
3746
- (value.startsWith("'") && value.endsWith("'"))) {
3747
- return value.slice(1, -1);
3748
- }
3749
- if (value.toLowerCase() === 'true')
3750
- return true;
3751
- if (value.toLowerCase() === 'false')
3752
- return false;
3753
- const asNumber = maybeNumber(value);
3754
- if (asNumber !== null)
3755
- return asNumber;
3756
- return value;
3757
- }
3758
- function resolvePropertyValue(values, key, raw) {
3759
- if (Object.prototype.hasOwnProperty.call(values, key)) {
3760
- return values[key];
3761
- }
3762
- if (Object.prototype.hasOwnProperty.call(values, raw)) {
3763
- return values[raw];
3764
- }
3765
- if (!key.includes('.')) {
3766
- return undefined;
3767
- }
3768
- const parts = key.split('.');
3769
- let current = values;
3770
- for (const part of parts) {
3771
- if (current === null || current === undefined) {
3772
- return undefined;
3773
- }
3774
- current = current[part];
3775
- }
3776
- return current;
3777
- }
3778
- function toBoolean(value) {
3779
- if (typeof value === 'boolean')
3780
- return value;
3781
- if (typeof value === 'number')
3782
- return !Number.isNaN(value) && value !== 0;
3783
- if (typeof value === 'string') {
3784
- const normalized = value.trim().toLowerCase();
3785
- if (normalized === '' ||
3786
- normalized === 'false' ||
3787
- normalized === '0' ||
3788
- normalized === 'null' ||
3789
- normalized === 'undefined') {
3790
- return false;
3791
- }
3792
- return true;
3793
- }
3794
- if (Array.isArray(value))
3795
- return value.length > 0;
3796
- return Boolean(value);
3797
- }
3798
- function toNumber(value) {
3799
- const num = Number(value);
3800
- return Number.isFinite(num) ? num : 0;
3801
- }
3802
- function maybeNumber(value) {
3803
- if (value === '' || value === null || value === undefined)
3804
- return null;
3805
- const num = Number(value);
3806
- return Number.isFinite(num) ? num : null;
3807
- }
3808
- function toDate(value) {
3809
- if (value instanceof Date) {
3810
- return Number.isNaN(value.getTime()) ? null : value;
3811
- }
3812
- // Plain numbers and numeric strings are NOT dates. `new Date('100')` parses
3813
- // as the year 0100, which would otherwise hijack equality/ordering of a
3814
- // numeric value (e.g. a percentage `== 100`) into a bogus date comparison.
3815
- // Leave those to the numeric path.
3816
- if (typeof value === 'number') {
3817
- return null;
3818
- }
3819
- if (typeof value === 'string') {
3820
- const trimmed = value.trim();
3821
- if (trimmed === '' || NUMERIC_STRING_PATTERN.test(trimmed)) {
3822
- return null;
3823
- }
3824
- const date = new Date(trimmed);
3825
- return Number.isNaN(date.getTime()) ? null : date;
3826
- }
3827
- return null;
3828
- }
3829
- function toErrorMessage(error) {
3830
- if (error instanceof Error && error.message)
3831
- return error.message;
3832
- return 'Formula evaluation failed';
3833
- }
3834
- function createRuntimeError(code, error) {
3835
- return {
3836
- code,
3837
- message: toErrorMessage(error),
3838
- };
3839
- }
3840
-
3841
- // Formula components public API
3842
-
3843
- /**
3844
- * Generated bundle index. Do not edit.
3845
- */
3846
-
3847
- export { CONDITION_FUNCTION_CATEGORIES, CONDITION_OPERATORS, CONDITION_RUNTIME_CATALOG, DEFAULT_OPERATORS, FormulaEditor, FormulaEditorCode, FormulaRuntimeEngine, FormulaStatusBar, FormulaToolbar, FormulaToolbarItem, OPERATOR_SYMBOL_TO_TRANSLATION_KEY, VALIDATION_FUNCTION_CATEGORIES, VALIDATION_OPERATORS, VALIDATION_RUNTIME_CATALOG, cloneBlock, cloneToken, cloneTokens, createFunctionBlock, createFunctionTokens, createLiteralBlock, createLiteralToken, createOperatorBlock, createOperatorToken, createPropertyBlock, createPropertyToken, createTextToken, findFunctionRange, generateFunctionId, generateSmartBlockId, generateTokenId, getArgumentIndexAtPosition, getFunctionTokens, isValidDropPosition, parseSignature, recalculateDepths, serializeTokens, serializeTokensForDisplay, shouldInsertSpace, tokenizeFormulaTemplate };
3848
- //# sourceMappingURL=masterteam-components-formula.mjs.map