create-basicjs 0.1.3 → 0.1.5

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 (559) hide show
  1. package/README.md +2 -2
  2. package/bin/create-basicjs.js +31 -4
  3. package/bin/verify-package.js +1 -1
  4. package/package.json +2 -2
  5. package/payload/starter/AGENTS.md +11 -6
  6. package/payload/starter/README.md +1 -1
  7. package/payload/starter/_basic/VERSION +1 -1
  8. package/payload/starter/_basic/assets/cards/almond-blossom.png +0 -0
  9. package/payload/starter/_basic/assets/cards/blackberry.png +0 -0
  10. package/payload/starter/_basic/assets/cards/borage.png +0 -0
  11. package/payload/starter/_basic/assets/cards/chamomile.png +0 -0
  12. package/payload/starter/_basic/assets/cards/dill.png +0 -0
  13. package/payload/starter/_basic/assets/cards/eucalyptus.png +0 -0
  14. package/payload/starter/_basic/assets/cards/fennel.png +0 -0
  15. package/payload/starter/_basic/assets/cards/fig.png +0 -0
  16. package/payload/starter/_basic/assets/cards/juniper.png +0 -0
  17. package/payload/starter/_basic/assets/cards/lavender.png +0 -0
  18. package/payload/starter/_basic/assets/cards/lemon.png +0 -0
  19. package/payload/starter/_basic/assets/cards/olives.png +0 -0
  20. package/payload/starter/_basic/assets/cards/oregano.png +0 -0
  21. package/payload/starter/_basic/assets/cards/pepper.png +0 -0
  22. package/payload/starter/_basic/assets/cards/physalis.png +0 -0
  23. package/payload/starter/_basic/assets/cards/pomegranate.png +0 -0
  24. package/payload/starter/_basic/assets/cards/poppy.png +0 -0
  25. package/payload/starter/_basic/assets/cards/rosehip.png +0 -0
  26. package/payload/starter/_basic/assets/cards/saffron.png +0 -0
  27. package/payload/starter/_basic/assets/categories/cappuccino.png +0 -0
  28. package/payload/starter/_basic/assets/categories/chocolate-milk.png +0 -0
  29. package/payload/starter/_basic/assets/categories/coffee.png +0 -0
  30. package/payload/starter/_basic/assets/categories/frappe.png +0 -0
  31. package/payload/starter/_basic/assets/categories/iced-caffee.png +0 -0
  32. package/payload/starter/_basic/assets/categories/milkshake.png +0 -0
  33. package/payload/starter/_basic/assets/categories/orange-juice.png +0 -0
  34. package/payload/starter/_basic/assets/categories/tea.png +0 -0
  35. package/payload/starter/_basic/assets/fruids/brokoli.png +0 -0
  36. package/payload/starter/_basic/assets/fruids/cilek.png +0 -0
  37. package/payload/starter/_basic/assets/fruids/domates.png +0 -0
  38. package/payload/starter/_basic/assets/fruids/elma.png +0 -0
  39. package/payload/starter/_basic/assets/fruids/havuc.png +0 -0
  40. package/payload/starter/_basic/assets/fruids/karpuz.png +0 -0
  41. package/payload/starter/_basic/assets/fruids/limon.png +0 -0
  42. package/payload/starter/_basic/assets/fruids/muz.png +0 -0
  43. package/payload/starter/_basic/assets/fruids/nar.png +0 -0
  44. package/payload/starter/_basic/assets/fruids/patlican.png +0 -0
  45. package/payload/starter/_basic/assets/fruids/yabanmersini.png +0 -0
  46. package/payload/starter/_basic/assets/fruids/yesilbiber.png +0 -0
  47. package/payload/starter/_basic/basic/LICENSE +1 -1
  48. package/payload/starter/_basic/basic/basic.css +3 -6
  49. package/payload/starter/_basic/basic/basic.js +154 -60
  50. package/payload/starter/_basic/basic/basic.min.js +19 -6
  51. package/payload/starter/_basic/basic/scroll-bar.js +4 -2
  52. package/payload/starter/_basic/basic/scroll-bar.min.js +1 -0
  53. package/payload/starter/_basic/comp/accordion.js +659 -0
  54. package/payload/starter/_basic/comp/action-button.js +22 -23
  55. package/payload/starter/_basic/comp/action-tab-bar.js +8 -8
  56. package/payload/starter/_basic/comp/app-bar.js +12 -11
  57. package/payload/starter/_basic/comp/{badge-v2.js → badge.js} +51 -5
  58. package/payload/starter/_basic/comp/bottom-bar.js +31 -23
  59. package/payload/starter/_basic/comp/breadcrumbs.js +4 -2
  60. package/payload/starter/_basic/comp/canvas.js +652 -0
  61. package/payload/starter/_basic/comp/chat-view.js +827 -0
  62. package/payload/starter/_basic/comp/check-box.js +137 -21
  63. package/payload/starter/_basic/comp/code-editor.js +953 -0
  64. package/payload/starter/_basic/comp/{select-color.js → color-picker.js} +62 -29
  65. package/payload/starter/_basic/comp/context-menu.js +342 -30
  66. package/payload/starter/_basic/comp/{currency-input-b.js → currency-field.js} +48 -29
  67. package/payload/starter/_basic/comp/data-table.js +114 -42
  68. package/payload/starter/_basic/comp/{select-date.js → date-picker.js} +104 -52
  69. package/payload/starter/_basic/comp/dialog.js +214 -76
  70. package/payload/starter/_basic/comp/email-field.js +65 -0
  71. package/payload/starter/_basic/comp/{select-file.js → file-picker.js} +245 -57
  72. package/payload/starter/_basic/comp/filters.js +374 -60
  73. package/payload/starter/_basic/comp/form.js +38 -26
  74. package/payload/starter/_basic/comp/full-screen-select.js +36 -33
  75. package/payload/starter/_basic/comp/gauge.js +12 -8
  76. package/payload/starter/_basic/comp/graph-box.js +3911 -0
  77. package/payload/starter/_basic/comp/grid-group.js +185 -0
  78. package/payload/starter/_basic/comp/hold-to-confirm-button.js +16 -7
  79. package/payload/starter/_basic/comp/image-view.js +598 -0
  80. package/payload/starter/_basic/comp/item-list.js +507 -163
  81. package/payload/starter/_basic/comp/json-editor.js +3221 -0
  82. package/payload/starter/_basic/comp/json-view.js +597 -0
  83. package/payload/starter/_basic/comp/label-editor.js +22 -19
  84. package/payload/starter/_basic/comp/left-menu.js +97 -25
  85. package/payload/starter/_basic/comp/line-progress-bar.js +196 -45
  86. package/payload/starter/_basic/comp/loading-screen.js +49 -18
  87. package/payload/starter/_basic/comp/log-view.js +530 -0
  88. package/payload/starter/_basic/comp/{login-page-v2.js → login-page.js} +205 -106
  89. package/payload/starter/_basic/comp/markdown-view.js +1044 -0
  90. package/payload/starter/_basic/comp/menu-bar.js +624 -0
  91. package/payload/starter/_basic/comp/mini-graph-box.js +20 -11
  92. package/payload/starter/_basic/comp/minimal-accent.js +208 -0
  93. package/payload/starter/_basic/comp/notice.js +15 -13
  94. package/payload/starter/_basic/comp/{number-input-b.js → number-field.js} +26 -19
  95. package/payload/starter/_basic/comp/numeric-keyboard.js +15 -13
  96. package/payload/starter/_basic/comp/page-control.js +21 -4
  97. package/payload/starter/_basic/comp/page-header.js +7 -6
  98. package/payload/starter/_basic/comp/password-field.js +192 -0
  99. package/payload/starter/_basic/comp/period-bar.js +8 -7
  100. package/payload/starter/_basic/comp/{phone-input-b.js → phone-field.js} +80 -45
  101. package/payload/starter/_basic/comp/progress-bar.js +401 -85
  102. package/payload/starter/_basic/comp/property-panel.js +1022 -123
  103. package/payload/starter/_basic/comp/radio-button.js +79 -19
  104. package/payload/starter/_basic/comp/range-slider.js +569 -0
  105. package/payload/starter/_basic/comp/rich-text-editor.js +33 -30
  106. package/payload/starter/_basic/comp/scroll-area.js +308 -0
  107. package/payload/starter/_basic/comp/scrolling-text.js +10 -9
  108. package/payload/starter/_basic/comp/search-input.js +725 -0
  109. package/payload/starter/_basic/comp/search-results.js +60 -24
  110. package/payload/starter/_basic/comp/select-box.js +229 -107
  111. package/payload/starter/_basic/comp/settings-row.js +20 -19
  112. package/payload/starter/_basic/comp/side-panel.js +53 -10
  113. package/payload/starter/_basic/comp/slider-field.js +264 -88
  114. package/payload/starter/_basic/comp/slider.js +541 -86
  115. package/payload/starter/_basic/comp/smart-button.js +433 -352
  116. package/payload/starter/_basic/comp/smart-table.js +740 -185
  117. package/payload/starter/_basic/comp/sortable-list.js +47 -38
  118. package/payload/starter/_basic/comp/spark-line-box.js +25 -16
  119. package/payload/starter/_basic/comp/splitter.js +411 -0
  120. package/payload/starter/_basic/comp/status-bar.js +408 -0
  121. package/payload/starter/_basic/comp/step-bar.js +345 -0
  122. package/payload/starter/_basic/comp/stepper.js +77 -49
  123. package/payload/starter/_basic/comp/tabs.js +67 -18
  124. package/payload/starter/_basic/comp/tag-input.js +50 -10
  125. package/payload/starter/_basic/comp/tap-effect.js +6 -4
  126. package/payload/starter/_basic/comp/text-area-field.js +233 -0
  127. package/payload/starter/_basic/comp/text-field.js +1006 -0
  128. package/payload/starter/_basic/comp/time-line.js +102 -28
  129. package/payload/starter/_basic/comp/{select-time.js → time-picker.js} +104 -51
  130. package/payload/starter/_basic/comp/tiny-select.js +79 -39
  131. package/payload/starter/_basic/comp/tiny-table.js +12 -8
  132. package/payload/starter/_basic/comp/toast.js +87 -34
  133. package/payload/starter/_basic/comp/toggle.js +147 -27
  134. package/payload/starter/_basic/comp/tool-bar.js +760 -0
  135. package/payload/starter/_basic/comp/tooltip.js +80 -17
  136. package/payload/starter/_basic/comp/tree-view.js +124 -41
  137. package/payload/starter/_basic/comp/ui-effects.js +17 -11
  138. package/payload/starter/_basic/comp/ui-standards.js +5 -4
  139. package/payload/starter/_basic/comp/url-field.js +190 -0
  140. package/payload/starter/_basic/comp/web-view.js +70 -16
  141. package/payload/starter/_basic/docs/basic-js-animated-rules.md +15 -9
  142. package/payload/starter/_basic/docs/basic-js-code-rules.md +42 -5
  143. package/payload/starter/_basic/docs/basic-js-components.md +12 -17
  144. package/payload/starter/_basic/docs/basic-js-core.md +5 -4
  145. package/payload/starter/_basic/docs/component-index.md +245 -104
  146. package/payload/starter/_basic/docs/component-template.js +28 -24
  147. package/payload/starter/_basic/docs/handbook/00-introduction.md +6 -2
  148. package/payload/starter/_basic/docs/handbook/00-what-is-new.md +21 -0
  149. package/payload/starter/_basic/docs/handbook/01-label.md +4 -4
  150. package/payload/starter/_basic/docs/handbook/02-box.md +7 -7
  151. package/payload/starter/_basic/docs/handbook/03-image.md +4 -4
  152. package/payload/starter/_basic/docs/handbook/04-common-properties.md +6 -5
  153. package/payload/starter/_basic/docs/handbook/05-autolayout.md +8 -7
  154. package/payload/starter/_basic/docs/handbook/06-button.md +3 -3
  155. package/payload/starter/_basic/docs/handbook/07-input.md +3 -3
  156. package/payload/starter/_basic/docs/handbook/08-page.md +3 -3
  157. package/payload/starter/_basic/docs/handbook/09-useful-examples.md +39 -58
  158. package/payload/starter/_basic/docs/handbook/10-motion.md +6 -6
  159. package/payload/starter/_basic/docs/handbook/11-other-functions.md +1 -0
  160. package/payload/starter/_basic/docs/handbook/13-sound.md +3 -3
  161. package/payload/starter/_basic/docs/handbook/14-using-components.md +180 -0
  162. package/payload/starter/_basic/docs/handbook/15-making-a-component.md +338 -0
  163. package/payload/starter/_basic/docs/what-is-new.md +106 -0
  164. package/payload/starter/_basic/examples/accordion.htm +174 -0
  165. package/payload/starter/_basic/examples/action-button.htm +74 -32
  166. package/payload/starter/_basic/examples/action-tab-bar.htm +5 -6
  167. package/payload/starter/_basic/examples/app-bar.htm +63 -41
  168. package/payload/starter/_basic/examples/badge.htm +96 -0
  169. package/payload/starter/_basic/examples/bottom-bar-2.htm +61 -48
  170. package/payload/starter/_basic/examples/bottom-bar.htm +74 -16
  171. package/payload/starter/_basic/examples/breadcrumbs.htm +160 -150
  172. package/payload/starter/_basic/examples/canvas.htm +190 -0
  173. package/payload/starter/_basic/examples/chat-view.htm +143 -0
  174. package/payload/starter/_basic/examples/check-box-2.htm +71 -82
  175. package/payload/starter/_basic/examples/check-box-3.htm +72 -83
  176. package/payload/starter/_basic/examples/check-box.htm +207 -0
  177. package/payload/starter/_basic/examples/code-editor-2.htm +259 -0
  178. package/payload/starter/_basic/examples/code-editor.htm +225 -0
  179. package/payload/starter/_basic/examples/color-picker.htm +206 -0
  180. package/payload/starter/_basic/examples/context-menu.htm +180 -139
  181. package/payload/starter/_basic/examples/currency-field.htm +105 -0
  182. package/payload/starter/_basic/examples/data-table-2.htm +2 -1
  183. package/payload/starter/_basic/examples/data-table-3.htm +1 -1
  184. package/payload/starter/_basic/examples/data-table-4.htm +15 -12
  185. package/payload/starter/_basic/examples/data-table-5.htm +11 -3
  186. package/payload/starter/_basic/examples/data-table.htm +90 -40
  187. package/payload/starter/_basic/examples/date-picker.htm +239 -0
  188. package/payload/starter/_basic/examples/dialog-centered.htm +394 -40
  189. package/payload/starter/_basic/examples/dialog.htm +267 -46
  190. package/payload/starter/_basic/examples/email-field.htm +102 -0
  191. package/payload/starter/_basic/examples/file-picker.htm +296 -0
  192. package/payload/starter/_basic/examples/filters.htm +33 -22
  193. package/payload/starter/_basic/examples/{form-1.htm → form.htm} +18 -19
  194. package/payload/starter/_basic/examples/full-screen-select.htm +81 -58
  195. package/payload/starter/_basic/examples/gauge.htm +95 -81
  196. package/payload/starter/_basic/examples/graph-box.htm +365 -0
  197. package/payload/starter/_basic/examples/grid-group.htm +179 -0
  198. package/payload/starter/_basic/examples/hold-to-confirm-button.htm +102 -113
  199. package/payload/starter/_basic/examples/image-view.htm +195 -0
  200. package/payload/starter/_basic/examples/item-list-2.htm +138 -94
  201. package/payload/starter/_basic/examples/item-list.htm +191 -86
  202. package/payload/starter/_basic/examples/json-editor.htm +206 -0
  203. package/payload/starter/_basic/examples/json-view.htm +153 -0
  204. package/payload/starter/_basic/examples/label-editor.htm +85 -89
  205. package/payload/starter/_basic/examples/left-menu-2.htm +93 -0
  206. package/payload/starter/_basic/examples/left-menu.htm +42 -37
  207. package/payload/starter/_basic/examples/line-progress-bar.htm +155 -114
  208. package/payload/starter/_basic/examples/loading-screen.htm +149 -125
  209. package/payload/starter/_basic/examples/log-view.htm +175 -0
  210. package/payload/starter/_basic/examples/{login-page-dark-v2.htm → login-page-dark.htm} +265 -267
  211. package/payload/starter/_basic/examples/{login-page-v2.htm → login-page.htm} +266 -267
  212. package/payload/starter/_basic/examples/markdown-view.htm +220 -0
  213. package/payload/starter/_basic/examples/menu-bar-2.htm +225 -0
  214. package/payload/starter/_basic/examples/menu-bar.htm +145 -0
  215. package/payload/starter/_basic/examples/mini-graph-box.htm +98 -109
  216. package/payload/starter/_basic/examples/minimal-accent.htm +196 -0
  217. package/payload/starter/_basic/examples/minimal-theme.htm +432 -0
  218. package/payload/starter/_basic/examples/notice.htm +13 -4
  219. package/payload/starter/_basic/examples/number-field.htm +103 -0
  220. package/payload/starter/_basic/examples/numeric-keyboard.htm +44 -42
  221. package/payload/starter/_basic/examples/page-control.htm +181 -130
  222. package/payload/starter/_basic/examples/page-header.htm +57 -30
  223. package/payload/starter/_basic/examples/password-field.htm +117 -0
  224. package/payload/starter/_basic/examples/period-bar.htm +43 -29
  225. package/payload/starter/_basic/examples/phone-field-select-country.htm +292 -0
  226. package/payload/starter/_basic/examples/phone-field.htm +104 -0
  227. package/payload/starter/_basic/examples/progress-bar-ozden.htm +229 -92
  228. package/payload/starter/_basic/examples/progress-bar.htm +222 -174
  229. package/payload/starter/_basic/examples/property-panel.htm +152 -52
  230. package/payload/starter/_basic/examples/radio-button-2.htm +101 -109
  231. package/payload/starter/_basic/examples/radio-button-3.htm +81 -71
  232. package/payload/starter/_basic/examples/radio-button.htm +289 -0
  233. package/payload/starter/_basic/examples/range-slider.htm +171 -0
  234. package/payload/starter/_basic/examples/rich-text-editor.htm +115 -110
  235. package/payload/starter/_basic/examples/scroll-area.htm +293 -0
  236. package/payload/starter/_basic/examples/scrolling-text.htm +27 -6
  237. package/payload/starter/_basic/examples/search-input-2-light.htm +112 -0
  238. package/payload/starter/_basic/examples/search-input-3-dark.htm +105 -0
  239. package/payload/starter/_basic/examples/{search-input-v2-place.htm → search-input-place.htm} +25 -26
  240. package/payload/starter/_basic/examples/search-input.htm +159 -0
  241. package/payload/starter/_basic/examples/search-results.htm +85 -88
  242. package/payload/starter/_basic/examples/select-box-ozden-dark-text.htm +70 -0
  243. package/payload/starter/_basic/examples/select-box-ozden-item.htm +6 -5
  244. package/payload/starter/_basic/examples/select-box-ozden-text.htm +5 -3
  245. package/payload/starter/_basic/examples/select-box.htm +190 -159
  246. package/payload/starter/_basic/examples/settings-row.htm +92 -43
  247. package/payload/starter/_basic/examples/side-panel-2.htm +63 -25
  248. package/payload/starter/_basic/examples/side-panel.htm +84 -70
  249. package/payload/starter/_basic/examples/slider-2-classic.htm +152 -0
  250. package/payload/starter/_basic/examples/slider-field-ozden.htm +286 -0
  251. package/payload/starter/_basic/examples/slider-field.htm +174 -134
  252. package/payload/starter/_basic/examples/slider.htm +257 -180
  253. package/payload/starter/_basic/examples/smart-button-3-ozden.htm +170 -257
  254. package/payload/starter/_basic/examples/smart-button-4-dark.htm +86 -47
  255. package/payload/starter/_basic/examples/smart-button-5-features.htm +130 -125
  256. package/payload/starter/_basic/examples/smart-button-alternatif.htm +266 -0
  257. package/payload/starter/_basic/examples/smart-button.htm +207 -174
  258. package/payload/starter/_basic/examples/smart-table-2.htm +43 -56
  259. package/payload/starter/_basic/examples/smart-table-3.htm +148 -113
  260. package/payload/starter/_basic/examples/smart-table-4.htm +37 -50
  261. package/payload/starter/_basic/examples/{smart-table-1.htm → smart-table-5.htm} +37 -48
  262. package/payload/starter/_basic/examples/smart-table.htm +183 -0
  263. package/payload/starter/_basic/examples/sortable-list.htm +191 -142
  264. package/payload/starter/_basic/examples/spark-line-box.htm +149 -161
  265. package/payload/starter/_basic/examples/splitter.htm +164 -0
  266. package/payload/starter/_basic/examples/status-bar.htm +166 -0
  267. package/payload/starter/_basic/examples/step-bar.htm +129 -0
  268. package/payload/starter/_basic/examples/stepper-2.htm +71 -59
  269. package/payload/starter/_basic/examples/stepper.htm +146 -135
  270. package/payload/starter/_basic/examples/tabs-2.htm +58 -67
  271. package/payload/starter/_basic/examples/tabs.htm +197 -180
  272. package/payload/starter/_basic/examples/tag-input.htm +150 -153
  273. package/payload/starter/_basic/examples/tap-effect.htm +23 -19
  274. package/payload/starter/_basic/examples/text-area-field.htm +104 -0
  275. package/payload/starter/_basic/examples/text-field-2.htm +113 -0
  276. package/payload/starter/_basic/examples/text-field-3-style.htm +105 -0
  277. package/payload/starter/_basic/examples/text-field-4-custom-unit.htm +96 -0
  278. package/payload/starter/_basic/examples/{input-b-ex5-warning-icon.htm → text-field-5-warning-icon.htm} +19 -19
  279. package/payload/starter/_basic/examples/text-field-6-modern-dark.htm +114 -0
  280. package/payload/starter/_basic/examples/text-field-7-modern.htm +106 -0
  281. package/payload/starter/_basic/examples/text-field-8-light-dark.htm +159 -0
  282. package/payload/starter/_basic/examples/text-field.htm +163 -0
  283. package/payload/starter/_basic/examples/time-line.htm +180 -116
  284. package/payload/starter/_basic/examples/time-picker.htm +240 -0
  285. package/payload/starter/_basic/examples/tiny-select.htm +118 -86
  286. package/payload/starter/_basic/examples/tiny-table.htm +40 -34
  287. package/payload/starter/_basic/examples/toast.htm +145 -147
  288. package/payload/starter/_basic/examples/toggle-2.htm +99 -68
  289. package/payload/starter/_basic/examples/toggle-3.htm +104 -101
  290. package/payload/starter/_basic/examples/toggle.htm +161 -93
  291. package/payload/starter/_basic/examples/tool-bar.htm +172 -0
  292. package/payload/starter/_basic/examples/tooltip-2.htm +110 -60
  293. package/payload/starter/_basic/examples/tooltip-3.htm +124 -65
  294. package/payload/starter/_basic/examples/tooltip-4.htm +218 -0
  295. package/payload/starter/_basic/examples/tooltip.htm +206 -124
  296. package/payload/starter/_basic/examples/tree-view.htm +210 -182
  297. package/payload/starter/_basic/examples/ui-effects.htm +207 -185
  298. package/payload/starter/_basic/examples/ui-standards.htm +200 -139
  299. package/payload/starter/_basic/examples/url-field.htm +120 -0
  300. package/payload/starter/_basic/examples/web-view.htm +109 -110
  301. package/payload/starter/_basic/min/accordion.min.js +2 -0
  302. package/payload/starter/_basic/min/action-button.min.js +1 -1
  303. package/payload/starter/_basic/min/app-bar.min.js +1 -1
  304. package/payload/starter/_basic/min/badge.min.js +2 -0
  305. package/payload/starter/_basic/min/bottom-bar.min.js +1 -1
  306. package/payload/starter/_basic/min/canvas.min.js +2 -0
  307. package/payload/starter/_basic/min/chat-view.min.js +2 -0
  308. package/payload/starter/_basic/min/check-box.min.js +1 -1
  309. package/payload/starter/_basic/min/code-editor.min.js +2 -0
  310. package/payload/starter/_basic/min/color-picker.min.js +2 -0
  311. package/payload/starter/_basic/min/context-menu.min.js +1 -1
  312. package/payload/starter/_basic/min/currency-field.min.js +2 -0
  313. package/payload/starter/_basic/min/data-table.min.js +1 -1
  314. package/payload/starter/_basic/min/date-picker.min.js +2 -0
  315. package/payload/starter/_basic/min/dialog.min.js +1 -1
  316. package/payload/starter/_basic/min/email-field.min.js +2 -0
  317. package/payload/starter/_basic/min/file-picker.min.js +2 -0
  318. package/payload/starter/_basic/min/filters.min.js +1 -1
  319. package/payload/starter/_basic/min/form.min.js +1 -1
  320. package/payload/starter/_basic/min/full-screen-select.min.js +1 -1
  321. package/payload/starter/_basic/min/gauge.min.js +1 -1
  322. package/payload/starter/_basic/min/graph-box.min.js +2 -0
  323. package/payload/starter/_basic/min/grid-group.min.js +2 -0
  324. package/payload/starter/_basic/min/hold-to-confirm-button.min.js +1 -1
  325. package/payload/starter/_basic/min/image-view.min.js +2 -0
  326. package/payload/starter/_basic/min/item-list.min.js +1 -1
  327. package/payload/starter/_basic/min/json-editor.min.js +2 -0
  328. package/payload/starter/_basic/min/json-view.min.js +2 -0
  329. package/payload/starter/_basic/min/label-editor.min.js +1 -1
  330. package/payload/starter/_basic/min/left-menu.min.js +1 -1
  331. package/payload/starter/_basic/min/line-progress-bar.min.js +1 -1
  332. package/payload/starter/_basic/min/loading-screen.min.js +1 -1
  333. package/payload/starter/_basic/min/log-view.min.js +2 -0
  334. package/payload/starter/_basic/min/login-page.min.js +2 -0
  335. package/payload/starter/_basic/min/markdown-view.min.js +2 -0
  336. package/payload/starter/_basic/min/menu-bar.min.js +2 -0
  337. package/payload/starter/_basic/min/mini-graph-box.min.js +1 -1
  338. package/payload/starter/_basic/min/minimal-accent.min.js +2 -0
  339. package/payload/starter/_basic/min/notice.min.js +1 -1
  340. package/payload/starter/_basic/min/number-field.min.js +2 -0
  341. package/payload/starter/_basic/min/numeric-keyboard.min.js +1 -1
  342. package/payload/starter/_basic/min/page-control.min.js +1 -1
  343. package/payload/starter/_basic/min/password-field.min.js +2 -0
  344. package/payload/starter/_basic/min/phone-field.min.js +2 -0
  345. package/payload/starter/_basic/min/progress-bar.min.js +1 -1
  346. package/payload/starter/_basic/min/property-panel.min.js +1 -1
  347. package/payload/starter/_basic/min/radio-button.min.js +1 -1
  348. package/payload/starter/_basic/min/range-slider.min.js +2 -0
  349. package/payload/starter/_basic/min/rich-text-editor.min.js +1 -1
  350. package/payload/starter/_basic/min/scroll-area.min.js +2 -0
  351. package/payload/starter/_basic/min/scrolling-text.min.js +1 -1
  352. package/payload/starter/_basic/min/search-input.min.js +2 -0
  353. package/payload/starter/_basic/min/search-results.min.js +1 -1
  354. package/payload/starter/_basic/min/select-box.min.js +1 -1
  355. package/payload/starter/_basic/min/settings-row.min.js +1 -1
  356. package/payload/starter/_basic/min/side-panel.min.js +1 -1
  357. package/payload/starter/_basic/min/slider-field.min.js +1 -1
  358. package/payload/starter/_basic/min/slider.min.js +1 -1
  359. package/payload/starter/_basic/min/smart-button.min.js +1 -1
  360. package/payload/starter/_basic/min/smart-table.min.js +1 -1
  361. package/payload/starter/_basic/min/sortable-list.min.js +1 -1
  362. package/payload/starter/_basic/min/spark-line-box.min.js +1 -1
  363. package/payload/starter/_basic/min/splitter.min.js +2 -0
  364. package/payload/starter/_basic/min/status-bar.min.js +2 -0
  365. package/payload/starter/_basic/min/step-bar.min.js +2 -0
  366. package/payload/starter/_basic/min/stepper.min.js +1 -1
  367. package/payload/starter/_basic/min/tabs.min.js +1 -1
  368. package/payload/starter/_basic/min/tag-input.min.js +1 -1
  369. package/payload/starter/_basic/min/text-area-field.min.js +2 -0
  370. package/payload/starter/_basic/min/text-field.min.js +2 -0
  371. package/payload/starter/_basic/min/time-line.min.js +1 -1
  372. package/payload/starter/_basic/min/time-picker.min.js +2 -0
  373. package/payload/starter/_basic/min/tiny-select.min.js +1 -1
  374. package/payload/starter/_basic/min/toast.min.js +1 -1
  375. package/payload/starter/_basic/min/toggle.min.js +1 -1
  376. package/payload/starter/_basic/min/tool-bar.min.js +2 -0
  377. package/payload/starter/_basic/min/tooltip.min.js +1 -1
  378. package/payload/starter/_basic/min/tree-view.min.js +1 -1
  379. package/payload/starter/_basic/min/ui-effects.min.js +1 -1
  380. package/payload/starter/_basic/min/url-field.min.js +2 -0
  381. package/payload/starter/_basic/min/web-view.min.js +1 -1
  382. package/payload/templates/booking/app/app.js +11 -8
  383. package/payload/templates/booking/app/settings.js +4 -4
  384. package/payload/templates/booking/index.htm +3 -3
  385. package/payload/templates/booking/pages/account.js +6 -6
  386. package/payload/templates/booking/pages/book.js +1 -1
  387. package/payload/templates/booking/pages/services.js +5 -4
  388. package/payload/templates/classic/app/app.js +15 -11
  389. package/payload/templates/classic/app/settings.js +22 -20
  390. package/payload/templates/classic/assets/_attribute.txt +2 -0
  391. package/payload/templates/classic/assets/cards/dill.png +0 -0
  392. package/payload/templates/classic/assets/cards/fennel.png +0 -0
  393. package/payload/templates/classic/assets/cards/juniper.png +0 -0
  394. package/payload/templates/classic/assets/cards/olives.png +0 -0
  395. package/payload/templates/classic/assets/cards/oregano.png +0 -0
  396. package/payload/templates/classic/assets/cards/pepper.png +0 -0
  397. package/payload/templates/classic/assets/cards/rosehip.png +0 -0
  398. package/payload/templates/classic/assets/categories/cappuccino.png +0 -0
  399. package/payload/templates/classic/assets/categories/chocolate-milk.png +0 -0
  400. package/payload/templates/classic/assets/categories/coffee.png +0 -0
  401. package/payload/templates/classic/assets/categories/frappe.png +0 -0
  402. package/payload/templates/classic/assets/categories/iced-caffee.png +0 -0
  403. package/payload/templates/classic/assets/categories/milkshake.png +0 -0
  404. package/payload/templates/classic/assets/categories/orange-juice.png +0 -0
  405. package/payload/templates/classic/assets/categories/tea.png +0 -0
  406. package/payload/templates/classic/index.htm +2 -2
  407. package/payload/templates/classic/pages/example.js +10 -10
  408. package/payload/templates/classic/pages/examples.js +44 -43
  409. package/payload/templates/classic/pages/home.js +16 -15
  410. package/payload/templates/classic/pages/info-pages.js +5 -5
  411. package/payload/templates/classic/pages/search.js +8 -7
  412. package/payload/templates/classic/pages/settings.js +13 -13
  413. package/payload/templates/classic/pages/tasks.js +1 -0
  414. package/payload/templates/classic/pages/template-pages.js +12 -11
  415. package/payload/templates/coffee-shop/app/app.js +12 -8
  416. package/payload/templates/coffee-shop/app/settings.js +4 -4
  417. package/payload/templates/coffee-shop/index.htm +3 -3
  418. package/payload/templates/coffee-shop/pages/drink.js +1 -1
  419. package/payload/templates/coffee-shop/pages/menu.js +5 -4
  420. package/payload/templates/forms/TEMPLATE.md +1 -1
  421. package/payload/templates/forms/appointment-form.htm +55 -53
  422. package/payload/templates/forms/contact-form-to-mail.htm +38 -37
  423. package/payload/templates/forms/contact-form-to-supabase.htm +47 -46
  424. package/payload/templates/forms/dark-contact-form.htm +43 -40
  425. package/payload/templates/forms/event-registration-form.htm +80 -77
  426. package/payload/templates/forms/feedback-form.htm +54 -54
  427. package/payload/templates/forms/order-form.htm +88 -84
  428. package/payload/templates/forms/recruitment-form.htm +60 -60
  429. package/payload/templates/forms/service/readme.md +9 -8
  430. package/payload/templates/forms/service/send-form-mail.php +38 -21
  431. package/payload/templates/forms/support-ticket-form.htm +67 -65
  432. package/payload/templates/panel/common/module-page.js +2 -2
  433. package/payload/templates/panel/common/theme.js +37 -10
  434. package/payload/templates/panel/common/top-bar.js +45 -40
  435. package/payload/templates/panel/index.htm +63 -60
  436. package/payload/templates/panel/module10/greenhouse.htm +98 -113
  437. package/payload/templates/panel/module11/arduino-projects.htm +47 -58
  438. package/payload/templates/panel/module6/energy-hub.htm +71 -103
  439. package/payload/templates/panel/module7/3d-printers.htm +58 -81
  440. package/payload/templates/panel/module8/cold-rooms.htm +58 -79
  441. package/payload/templates/panel/module9/elevator-fleet.htm +72 -93
  442. package/payload/templates/panel/pages/activity.js +134 -152
  443. package/payload/templates/panel/pages/contents.js +291 -308
  444. package/payload/templates/panel/pages/customers.js +250 -267
  445. package/payload/templates/panel/pages/edit-user.js +31 -30
  446. package/payload/templates/panel/pages/home.js +39 -70
  447. package/payload/templates/panel/pages/media.js +166 -183
  448. package/payload/templates/panel/pages/notifications.js +7 -7
  449. package/payload/templates/panel/pages/orders.js +200 -217
  450. package/payload/templates/panel/pages/products.js +259 -278
  451. package/payload/templates/panel/pages/reports.js +74 -123
  452. package/payload/templates/panel/pages/roles.js +57 -60
  453. package/payload/templates/panel/pages/settings.js +127 -143
  454. package/payload/templates/panel/pages/user-actions.js +106 -110
  455. package/payload/templates/panel/pages/user-list.js +221 -238
  456. package/payload/templates/panel/pages/users.js +14 -29
  457. package/payload/templates/shop/TEMPLATE.md +1 -1
  458. package/payload/templates/shop/app/app.js +11 -8
  459. package/payload/templates/shop/app/settings.js +4 -4
  460. package/payload/templates/shop/index.htm +3 -3
  461. package/payload/templates/shop/pages/account.js +7 -7
  462. package/payload/templates/shop/pages/cart.js +1 -1
  463. package/payload/templates/shop/pages/checkout.js +2 -2
  464. package/payload/templates/shop/pages/product.js +2 -2
  465. package/payload/templates/shop/pages/shop.js +6 -5
  466. package/payload/templates/starter/TEMPLATE.md +1 -1
  467. package/payload/templates/starter/app/app.js +12 -8
  468. package/payload/templates/starter/app/settings.js +14 -11
  469. package/payload/templates/starter/index.htm +3 -3
  470. package/payload/templates/starter/pages/about.js +1 -1
  471. package/payload/templates/starter/pages/home.js +2 -2
  472. package/payload/templates/starter/pages/product.js +1 -1
  473. package/payload/templates/starter/pages/products.js +5 -5
  474. package/payload/templates/starter/pages/settings.js +1 -1
  475. package/payload/templates/starter/pages/tasks.js +8 -8
  476. package/payload/templates/starter/pages/website.js +1 -1
  477. package/payload/starter/_basic/comp/chart-box/chart-4.5.1.umd.min.js +0 -13
  478. package/payload/starter/_basic/comp/chart-box/chart-js-LICENSE.md +0 -9
  479. package/payload/starter/_basic/comp/chart-box.js +0 -868
  480. package/payload/starter/_basic/comp/email-input-b.js +0 -57
  481. package/payload/starter/_basic/comp/input-b.js +0 -759
  482. package/payload/starter/_basic/comp/password-input-b.js +0 -164
  483. package/payload/starter/_basic/comp/search-input-v2.js +0 -427
  484. package/payload/starter/_basic/comp/textarea-b.js +0 -184
  485. package/payload/starter/_basic/comp/url-input-b.js +0 -145
  486. package/payload/starter/_basic/examples/badgeV2.htm +0 -68
  487. package/payload/starter/_basic/examples/chart-box.htm +0 -287
  488. package/payload/starter/_basic/examples/check-box-1.htm +0 -220
  489. package/payload/starter/_basic/examples/currency-input-b.htm +0 -71
  490. package/payload/starter/_basic/examples/email-input-b.htm +0 -67
  491. package/payload/starter/_basic/examples/input-b-ex1.htm +0 -132
  492. package/payload/starter/_basic/examples/input-b-ex2.htm +0 -136
  493. package/payload/starter/_basic/examples/input-b-ex3-style.htm +0 -113
  494. package/payload/starter/_basic/examples/input-b-ex4-custom-unit.htm +0 -112
  495. package/payload/starter/_basic/examples/input-b-ex6-dark.htm +0 -108
  496. package/payload/starter/_basic/examples/input-b-ex7-ozden.htm +0 -153
  497. package/payload/starter/_basic/examples/number-input-b.htm +0 -68
  498. package/payload/starter/_basic/examples/password-input-b.htm +0 -70
  499. package/payload/starter/_basic/examples/phone-input-b-select-country.htm +0 -298
  500. package/payload/starter/_basic/examples/phone-input-b.htm +0 -72
  501. package/payload/starter/_basic/examples/radio-button-1.htm +0 -264
  502. package/payload/starter/_basic/examples/search-input-v2-ozden.htm +0 -128
  503. package/payload/starter/_basic/examples/search-input-v2.htm +0 -65
  504. package/payload/starter/_basic/examples/select-color.htm +0 -215
  505. package/payload/starter/_basic/examples/select-date.htm +0 -244
  506. package/payload/starter/_basic/examples/select-file.htm +0 -268
  507. package/payload/starter/_basic/examples/select-time.htm +0 -249
  508. package/payload/starter/_basic/examples/smart-button-2.htm +0 -220
  509. package/payload/starter/_basic/examples/textarea-b.htm +0 -76
  510. package/payload/starter/_basic/examples/unfinished-login-page-dark-supabase.htm +0 -221
  511. package/payload/starter/_basic/examples/unfinished-login-page-supabase.htm +0 -221
  512. package/payload/starter/_basic/examples/url-input-b.htm +0 -85
  513. package/payload/starter/_basic/min/badge-v2.min.js +0 -2
  514. package/payload/starter/_basic/min/chart-box.min.js +0 -2
  515. package/payload/starter/_basic/min/currency-input-b.min.js +0 -2
  516. package/payload/starter/_basic/min/email-input-b.min.js +0 -2
  517. package/payload/starter/_basic/min/input-b.min.js +0 -2
  518. package/payload/starter/_basic/min/login-page-v2.min.js +0 -2
  519. package/payload/starter/_basic/min/number-input-b.min.js +0 -2
  520. package/payload/starter/_basic/min/password-input-b.min.js +0 -2
  521. package/payload/starter/_basic/min/phone-input-b.min.js +0 -2
  522. package/payload/starter/_basic/min/search-input-v2.min.js +0 -2
  523. package/payload/starter/_basic/min/select-color.min.js +0 -2
  524. package/payload/starter/_basic/min/select-date.min.js +0 -2
  525. package/payload/starter/_basic/min/select-file.min.js +0 -2
  526. package/payload/starter/_basic/min/select-time.min.js +0 -2
  527. package/payload/starter/_basic/min/textarea-b.min.js +0 -2
  528. package/payload/starter/_basic/min/url-input-b.min.js +0 -2
  529. package/payload/templates/panel/common/bridge.min.js +0 -0
  530. package/payload/templates/panel/common/full-view.min.js +0 -1
  531. package/payload/templates/panel/common/main-view.min.js +0 -1
  532. package/payload/templates/panel/common/module-page.min.js +0 -1
  533. package/payload/templates/panel/common/right-view.min.js +0 -1
  534. package/payload/templates/panel/common/start-page.min.js +0 -1
  535. package/payload/templates/panel/common/top-bar-v25-07-29-1.js +0 -330
  536. package/payload/templates/panel/common/top-bar-v25-07-29-2.js +0 -265
  537. package/payload/templates/panel/common/top-bar.min.js +0 -1
  538. package/payload/templates/panel/common/ui-standards.min.js +0 -1
  539. package/payload/templates/panel/managers/database.min.js +0 -1
  540. package/payload/templates/panel/managers/login.min.js +0 -1
  541. package/payload/templates/panel/pages/_page-template.min.js +0 -1
  542. package/payload/templates/panel/pages/contents.min.js +0 -1
  543. package/payload/templates/panel/pages/edit-user.min.js +0 -1
  544. package/payload/templates/panel/pages/edit-users-table.min.js +0 -1
  545. package/payload/templates/panel/pages/home.min.js +0 -1
  546. package/payload/templates/panel/pages/notifications.min.js +0 -1
  547. package/payload/templates/panel/pages/reports.min.js +0 -1
  548. package/payload/templates/panel/pages/settings.min.js +0 -1
  549. package/payload/templates/panel/pages/user-actions.min.js +0 -2
  550. package/payload/templates/panel/pages/users.min.js +0 -1
  551. /package/payload/starter/_basic/comp/{password-input-b → password-field}/hide-btn.png +0 -0
  552. /package/payload/starter/_basic/comp/{password-input-b → password-field}/hide-btn2.png +0 -0
  553. /package/payload/starter/_basic/comp/{password-input-b → password-field}/show-btn.png +0 -0
  554. /package/payload/starter/_basic/comp/{password-input-b → password-field}/show-btn2.png +0 -0
  555. /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/clear-round.svg +0 -0
  556. /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/clear.svg +0 -0
  557. /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/filter.png +0 -0
  558. /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/filter.svg +0 -0
  559. /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/search.svg +0 -0
@@ -0,0 +1,953 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ CodeEditor - v26.11
6
+
7
+ UI COMPONENT
8
+ - A text editor for code: line numbers, colors by language, the line of the cursor. A long line does not wrap: the
9
+ view scrolls sideways.
10
+ - Languages: "python", "javascript", "json", "html", "css", "sql", "bash", "text". CodeEditor.languages takes your own.
11
+ - The typing is the <textarea> of the browser: selection, copy, paste, undo and the input of every language work as
12
+ they do everywhere. The colors are drawn behind it, only for the lines that are seen, so a file of 100000 lines stays
13
+ fast.
14
+ - Keys: Tab and Shift + Tab indent (also many lines), Enter keeps the indent of its line (one more after ":" in Python,
15
+ after "{", "[" or "(" in the others), Backspace in the indent goes back one level, Ctrl (or Cmd) + / comments the
16
+ lines out. Undo takes all of them back. Escape, then Tab leaves the editor (for a keyboard user).
17
+ - changeDelay (ms): onChange waits for the typing to rest (for a big text sent to another place).
18
+ - Style packages: "light" (default), "dark". Select with styleName (CodeEditor.styles), or later with setTheme().
19
+
20
+ USAGE:
21
+ const editor = CodeEditor({
22
+ width: 600, height: 400,
23
+ language: "python",
24
+ value: "def hello():\n print('Hello')\n",
25
+ onChange: function (self) { println(self.value.length); },
26
+ onCursorChange: function (self) { println(self.cursorLine + ":" + self.cursorColumn); },
27
+ });
28
+ editor.setValue("x = 1\n"); // onChange is called; setValue(text, 1): silent. Undo starts again.
29
+ editor.getValue(); // the text now (self.value too)
30
+ editor.insertText("print(x)"); // at the cursor; undo takes it back
31
+ editor.getSelectedText();
32
+ editor.setLanguage("javascript");
33
+ editor.setReadOnly(1);
34
+ editor.setShowLineNumbers(0);
35
+ editor.setTabSize(2);
36
+ editor.goToLine(120);
37
+ editor.focusEditor();
38
+ editor.setTheme("dark");
39
+ CodeEditor({ styleName: "dark", placeholder: "Write here", changeDelay: 150 });
40
+
41
+ A NEW LANGUAGE:
42
+ CodeEditor.languages.toml = { lineComment: "#", strings: ['"""', '"', "'"], multiLineStrings: ['"""'], keywords: ["true", "false"], propertyWords: 1 };
43
+ Its keys: lineComment, blockComment: [start, end], strings (the longest first), multiLineStrings, keywords, builtins,
44
+ ignoreCase: 1, callWords: 1 (a word before "(" is a function), propertyWords: 1 (a word before ":" is a property),
45
+ propertyStrings: 1 (a string before ":" is a property), decorators: "@", variables: "$", indentAfter: ":" (the letters
46
+ at the end of a line that open one more level). tokenize: function (text, state): your own, instead of all of them:
47
+ returns { parts: [[kind, text], ...], state }. kind: "keyword", "string", "number", "comment", "builtin", "function",
48
+ "property", "tag", "attribute", "variable", "" (plain). state goes to the next line.
49
+
50
+ Started Date: November 2026
51
+ Webpage: https://bug7a.github.io/js-components/
52
+
53
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
54
+ Licensed under the Apache License, Version 2.0
55
+ SPDX-License-Identifier: Apache-2.0
56
+
57
+ */
58
+
59
+ "use strict";
60
+
61
+ // Default values:
62
+ const CodeEditorDefaults = {
63
+ key: "0", // Your name for this object: read it in a callback (self.key)
64
+ left: 0,
65
+ top: 0,
66
+ width: "100%",
67
+ height: 320,
68
+ value: "", // The text
69
+ language: "text", // A name of CodeEditor.languages
70
+ tabSize: 4, // The spaces of one level
71
+ readOnly: 0,
72
+ showLineNumbers: 1,
73
+ placeholder: "",
74
+ changeDelay: 0, // ms: onChange waits for the typing to rest
75
+ ariaLabel: "Code",
76
+ onChange: function (self) { }, // self.value changed. (Not at create time, not with silent: 1)
77
+ onCursorChange: function (self) { }, // self.cursorLine, self.cursorColumn (from 1)
78
+ styleName: "light", // "light", "dark" or a name added to CodeEditor.styles
79
+ style: { // Light style package (default)
80
+ box: { color: "white", border: 1, borderColor: Black(0.14), round: 8 },
81
+ text: {
82
+ fontSize: 13,
83
+ lineHeight: 20,
84
+ fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',
85
+ color: "#2B2B2A",
86
+ caretColor: "#111111",
87
+ paddingX: 10,
88
+ paddingY: 8,
89
+ },
90
+ gutter: { color: "#F6F6F4", lineColor: Black(0.08), textColor: Black(0.38), activeTextColor: Black(0.8), space: 1 }, // space: letters at each side
91
+ activeLine: { color: "rgba(91, 186, 193, 0.1)" },
92
+ selection: { color: "rgba(91, 186, 193, 0.35)" },
93
+ placeholder: { color: Black(0.4) },
94
+ scrollBar: { color: Black(0.22), hoverColor: Black(0.4), size: 10 },
95
+ // The colors of the code
96
+ kinds: {
97
+ keyword: "#8A2F8E",
98
+ string: "#1F7A3D",
99
+ number: "#A85A00",
100
+ comment: "#7A7F87",
101
+ builtin: "#00717A",
102
+ function: "#2467B8",
103
+ property: "#2467B8",
104
+ tag: "#A32A4B",
105
+ attribute: "#A85A00",
106
+ variable: "#00717A",
107
+ },
108
+ },
109
+ };
110
+
111
+ const CodeEditor = function (params = {}) {
112
+
113
+ // Merge style package: params.style > CodeEditor.styles[styleName] > CodeEditorDefaults.style (light)
114
+ const pageStyle = params.style; // WHY: setTheme() puts it over another package.
115
+ basic.applyStylePackage(params, CodeEditor.styles, CodeEditorDefaults);
116
+
117
+ // Merge params:
118
+ mergeIntoIfMissing(params, CodeEditorDefaults);
119
+
120
+ // BOX: Component container
121
+ const box = startObject(params);
122
+
123
+ // *** PRIVATE VARIABLES:
124
+ let _s = box.style;
125
+ const BUFFER_LINES = 25; // Lines drawn over and under the ones that are seen: a small scroll draws nothing
126
+ const MAX_COLORED_LETTERS = 2000; // A longer line is colored up to here (a minified file)
127
+ const MIN_GUTTER_DIGITS = 2;
128
+ const CARET_MARGIN_LINES = 2; // goToLine() keeps this many lines around the line
129
+ let lines = [""];
130
+ let lineStates = [null]; // lineStates[i]: the state of the tokenizer at the start of line i
131
+ let validStateCount = 1; // The states up to here are right
132
+ let drawnFirstLine = -1; // The lines of the code layer now
133
+ let drawnLastLine = -1;
134
+ let cancelChange = null; // The waiting onChange (changeDelay)
135
+ let canLeaveWithTab = 0; // 1: Escape was pressed: the next Tab leaves the editor
136
+
137
+ // *** PUBLIC VARIABLES:
138
+ box.cursorLine = 1; // Read only (from 1)
139
+ box.cursorColumn = 1;
140
+ // NOTE: Default values are also public variables. (box.value, box.language, box.readOnly...)
141
+
142
+ // *** PRIVATE FUNCTIONS:
143
+
144
+ // The style of a package, with the style of the page over it. (setTheme)
145
+ const styleOfPackage = function (styleName) {
146
+ const fresh = { styleName: styleName, style: pageStyle };
147
+ basic.applyStylePackage(fresh, CodeEditor.styles, CodeEditorDefaults);
148
+ mergeIntoIfMissing(fresh, CodeEditorDefaults);
149
+ return fresh.style;
150
+ };
151
+
152
+ const languageDefinition = function () {
153
+ return CodeEditor.languages[box.language] || CodeEditor.languages.text;
154
+ };
155
+
156
+ const textarea = function () {
157
+ return box.textareaElem;
158
+ };
159
+
160
+ // WHY up to the line: a change only moves the states after it, and only the lines that are seen ask for them.
161
+ const makeStatesUpTo = function (lineIndex) {
162
+ const definition = languageDefinition();
163
+ for (let i = validStateCount; i <= lineIndex && i < lines.length; i++) {
164
+ const previousText = lines[i - 1].slice(0, MAX_COLORED_LETTERS);
165
+ lineStates[i] = CodeEditor.tokenizeLine(previousText, lineStates[i - 1], definition).state;
166
+ validStateCount = i + 1;
167
+ }
168
+ };
169
+
170
+ const lineHtml = function (lineIndex) {
171
+ const text = lines[lineIndex];
172
+ const colored = text.slice(0, MAX_COLORED_LETTERS);
173
+ const result = CodeEditor.tokenizeLine(colored, lineStates[lineIndex], languageDefinition());
174
+ const html = result.parts.map(CodeEditor.partHtml).join("");
175
+ return html + basic.escapeHtml(text.slice(MAX_COLORED_LETTERS));
176
+ };
177
+
178
+ const lineHeight = function () {
179
+ return _s.text.lineHeight;
180
+ };
181
+
182
+ // CONTENT: the lines that are seen and the ones around them. force: also when they are the same lines.
183
+ const drawVisibleLines = function (force) {
184
+ const elem = textarea();
185
+ const firstSeen = Math.floor(elem.scrollTop / lineHeight());
186
+ const seenCount = Math.ceil(elem.clientHeight / lineHeight()) + 1;
187
+ const lastSeen = Math.min(lines.length - 1, firstSeen + seenCount);
188
+ const isInDrawnLines = (firstSeen >= drawnFirstLine && lastSeen <= drawnLastLine);
189
+
190
+ if (force || !isInDrawnLines) {
191
+ drawnFirstLine = Math.max(0, firstSeen - BUFFER_LINES);
192
+ drawnLastLine = Math.min(lines.length - 1, lastSeen + BUFFER_LINES);
193
+ makeStatesUpTo(drawnLastLine);
194
+ drawCode();
195
+ drawGutter();
196
+ }
197
+ placeLayers();
198
+ };
199
+
200
+ const drawCode = function () {
201
+ const parts = [];
202
+ for (let i = drawnFirstLine; i <= drawnLastLine; i++) parts.push(lineHtml(i));
203
+ box.codeLayer.text = parts.join("\n");
204
+ };
205
+
206
+ const drawGutter = function () {
207
+ const numbers = [];
208
+ for (let i = drawnFirstLine; i <= drawnLastLine; i++) {
209
+ const isActive = (i + 1 === box.cursorLine);
210
+ numbers.push((isActive) ? '<span class="code-editor-active-number">' + (i + 1) + "</span>" : String(i + 1));
211
+ }
212
+ box.gutterLayer.text = numbers.join("\n");
213
+ };
214
+
215
+ // LAYOUT: the layers follow the scroll of the textarea
216
+ const placeLayers = function () {
217
+ const elem = textarea();
218
+ const top = _s.text.paddingY + drawnFirstLine * lineHeight() - elem.scrollTop;
219
+ const left = _s.text.paddingX - elem.scrollLeft;
220
+ box.codeLayer.css.transform = "translate(" + left + "px, " + top + "px)";
221
+ box.gutterLayer.css.transform = "translateY(" + top + "px)";
222
+ box.activeLine.top = _s.text.paddingY + (box.cursorLine - 1) * lineHeight() - elem.scrollTop;
223
+ };
224
+
225
+ // LAYOUT: the gutter is as wide as the number of the last line
226
+ const refreshGutterWidth = function () {
227
+ const digits = Math.max(MIN_GUTTER_DIGITS, String(lines.length).length);
228
+ const letters = digits + 2 * _s.gutter.space;
229
+ const width = (box.showLineNumbers == 1) ? "calc(" + letters + "ch + 1px)" : "0px";
230
+ box.gutter.visible = (box.showLineNumbers == 1) ? 1 : 0;
231
+ box.gutter.css.width = width;
232
+ box.gutterLayer.css.right = _s.gutter.space + "ch";
233
+ box.codeArea.css.left = width;
234
+ box.codeArea.css.width = "calc(100% - " + width + ")";
235
+ };
236
+
237
+ // The state of a changed text: the states before the first changed line stay.
238
+ const readValue = function () {
239
+ // WHY once: a big textarea makes its value again at every read (about 100 ms for 100000 lines in WebKit).
240
+ const value = textarea().value;
241
+ const newLines = value.split("\n");
242
+ let firstChanged = 0;
243
+ const shorter = Math.min(lines.length, newLines.length);
244
+ while (firstChanged < shorter && lines[firstChanged] === newLines[firstChanged]) firstChanged++;
245
+ lines = newLines;
246
+ lineStates.length = Math.min(lineStates.length, lines.length);
247
+ validStateCount = Math.min(validStateCount, firstChanged + 1, lines.length);
248
+ box.value = value;
249
+ };
250
+
251
+ // The line and the column of the cursor, and what shows them
252
+ const readCursor = function () {
253
+ const cursor = textarea().selectionStart;
254
+ let line = 1;
255
+ let lineStart = 0;
256
+ let lineBreak = box.value.indexOf("\n");
257
+ while (lineBreak >= 0 && lineBreak < cursor) {
258
+ line++;
259
+ lineStart = lineBreak + 1;
260
+ lineBreak = box.value.indexOf("\n", lineStart);
261
+ }
262
+ const column = cursor - lineStart + 1;
263
+ const isSame = (line === box.cursorLine && column === box.cursorColumn);
264
+ const isOtherLine = (line !== box.cursorLine);
265
+ box.cursorLine = line;
266
+ box.cursorColumn = column;
267
+ if (isOtherLine) drawGutter();
268
+ placeLayers();
269
+ if (!isSame) box.onCursorChange(box);
270
+ };
271
+
272
+ const tellChange = function () {
273
+ if (cancelChange) cancelChange();
274
+ cancelChange = null;
275
+ if (box.changeDelay <= 0) {
276
+ box.onChange(box);
277
+ return;
278
+ }
279
+ cancelChange = box.after(box.changeDelay, function () {
280
+ cancelChange = null;
281
+ box.onChange(box);
282
+ });
283
+ };
284
+
285
+ const onInput = function () {
286
+ readValue();
287
+ refreshGutterWidth();
288
+ drawVisibleLines(1);
289
+ readCursor();
290
+ tellChange();
291
+ };
292
+
293
+ // WHY execCommand: the only way that stays in the undo of the textarea (setRangeText and value do not).
294
+ const insertAtSelection = function (text) {
295
+ const elem = textarea();
296
+ elem.focus();
297
+ const isDone = (text === "") ? document.execCommand("delete") : document.execCommand("insertText", false, text);
298
+ if (!isDone) {
299
+ elem.setRangeText(text, elem.selectionStart, elem.selectionEnd, "end");
300
+ onInput();
301
+ }
302
+ };
303
+
304
+ // The start and the end of the whole lines of the selection, as places in the text
305
+ const selectedLineRange = function () {
306
+ const elem = textarea();
307
+ const value = elem.value;
308
+ const start = value.lastIndexOf("\n", elem.selectionStart - 1) + 1;
309
+ // WHY: A selection that ends at the start of a line does not take that line.
310
+ const lastPlace = (elem.selectionEnd > elem.selectionStart && value[elem.selectionEnd - 1] === "\n") ? elem.selectionEnd - 1 : elem.selectionEnd;
311
+ let end = value.indexOf("\n", lastPlace);
312
+ if (end < 0) end = value.length;
313
+ return { start: start, end: end };
314
+ };
315
+
316
+ // Changes the whole lines of the selection with one step of undo, and selects them.
317
+ const changeSelectedLines = function (changeLine) {
318
+ const elem = textarea();
319
+ const range = selectedLineRange();
320
+ const oldLines = elem.value.slice(range.start, range.end).split("\n");
321
+ const newText = oldLines.map(changeLine).join("\n");
322
+ elem.setSelectionRange(range.start, range.end);
323
+ insertAtSelection(newText);
324
+ elem.setSelectionRange(range.start, range.start + newText.length);
325
+ };
326
+
327
+ const indentOne = function () {
328
+ return " ".repeat(box.tabSize);
329
+ };
330
+
331
+ const isManyLines = function () {
332
+ const elem = textarea();
333
+ return elem.value.slice(elem.selectionStart, elem.selectionEnd).includes("\n");
334
+ };
335
+
336
+ const onTabKey = function () {
337
+ if (isManyLines()) {
338
+ changeSelectedLines(function (line) { return (line.length > 0) ? indentOne() + line : line; });
339
+ return;
340
+ }
341
+ const elem = textarea();
342
+ const lineStart = elem.value.lastIndexOf("\n", elem.selectionStart - 1) + 1;
343
+ const column = elem.selectionStart - lineStart;
344
+ insertAtSelection(" ".repeat(box.tabSize - (column % box.tabSize)));
345
+ };
346
+
347
+ const onShiftTabKey = function () {
348
+ changeSelectedLines(function (line) {
349
+ const spaces = line.match(/^ */)[0].length;
350
+ return line.slice(Math.min(spaces, box.tabSize));
351
+ });
352
+ };
353
+
354
+ const onEnterKey = function () {
355
+ const elem = textarea();
356
+ const lineStart = elem.value.lastIndexOf("\n", elem.selectionStart - 1) + 1;
357
+ const beforeCursor = elem.value.slice(lineStart, elem.selectionStart);
358
+ const indent = beforeCursor.match(/^[ \t]*/)[0];
359
+ const opensLevel = (languageDefinition().indentAfter || "").includes(beforeCursor.trimEnd().slice(-1) || " ");
360
+ insertAtSelection("\n" + indent + ((opensLevel) ? indentOne() : ""));
361
+ };
362
+
363
+ // In the indent, Backspace goes back to the level before. Returns 1 when it did.
364
+ const onBackspaceKey = function () {
365
+ const elem = textarea();
366
+ if (elem.selectionStart !== elem.selectionEnd) return 0;
367
+ const lineStart = elem.value.lastIndexOf("\n", elem.selectionStart - 1) + 1;
368
+ const beforeCursor = elem.value.slice(lineStart, elem.selectionStart);
369
+ if (beforeCursor.length === 0 || beforeCursor.trim().length > 0) return 0;
370
+ const count = ((beforeCursor.length - 1) % box.tabSize) + 1;
371
+ elem.setSelectionRange(elem.selectionStart - count, elem.selectionStart);
372
+ insertAtSelection("");
373
+ return 1;
374
+ };
375
+
376
+ const toggleLineComment = function () {
377
+ const mark = languageDefinition().lineComment;
378
+ if (!mark) return;
379
+ const elem = textarea();
380
+ const range = selectedLineRange();
381
+ const oldLines = elem.value.slice(range.start, range.end).split("\n");
382
+ const isCommented = oldLines.every(function (line) { return line.trim() === "" || line.trimStart().startsWith(mark); });
383
+ changeSelectedLines(function (line) {
384
+ if (line.trim() === "") return line;
385
+ if (!isCommented) return line.replace(/^(\s*)/, "$1" + mark + " ");
386
+ return line.replace(new RegExp("^(\\s*)" + CodeEditor.escapeRegExp(mark) + " ?"), "$1");
387
+ });
388
+ };
389
+
390
+ const onKeyDown = function (event) {
391
+ const isTab = (event.key === "Tab");
392
+ const isCommentKey = (event.key === "/" && (event.ctrlKey || event.metaKey));
393
+ if (event.key === "Escape") canLeaveWithTab = 1;
394
+ else if (!isTab) canLeaveWithTab = 0;
395
+
396
+ if (isTab && canLeaveWithTab) {
397
+ canLeaveWithTab = 0;
398
+ return; // WHY: The Tab of the browser: a keyboard user can leave the editor.
399
+ }
400
+ if (box.readOnly == 1) return;
401
+
402
+ if (isTab) {
403
+ event.preventDefault();
404
+ if (event.shiftKey) onShiftTabKey();
405
+ else onTabKey();
406
+ } else if (event.key === "Enter" && !event.isComposing) {
407
+ event.preventDefault();
408
+ onEnterKey();
409
+ } else if (event.key === "Backspace" && !event.isComposing) {
410
+ if (onBackspaceKey()) event.preventDefault();
411
+ } else if (isCommentKey) {
412
+ event.preventDefault();
413
+ toggleLineComment();
414
+ }
415
+ };
416
+
417
+ // LOOK: everything that comes from the style (the first drawing and setTheme)
418
+ const applyLook = function () {
419
+ const text = _s.text;
420
+ const fontCss = { fontFamily: text.fontFamily, fontSize: text.fontSize + "px", lineHeight: text.lineHeight + "px" };
421
+ box.props(_s.box);
422
+ box.gutter.color = _s.gutter.color;
423
+ // WHY the font of the code on these two: their widths are written in ch, the width of a letter of their own font.
424
+ box.gutter.css = { ...fontCss, borderRight: "1px solid " + _s.gutter.lineColor };
425
+ box.codeArea.css = fontCss;
426
+ box.gutterLayer.css = { ...fontCss, color: _s.gutter.textColor };
427
+ box.codeLayer.css = { ...fontCss, color: text.color, tabSize: box.tabSize };
428
+ box.activeLine.color = _s.activeLine.color;
429
+ box.activeLine.height = text.lineHeight;
430
+ Object.assign(textarea().style, fontCss, {
431
+ padding: text.paddingY + "px " + text.paddingX + "px",
432
+ caretColor: text.caretColor,
433
+ tabSize: box.tabSize,
434
+ });
435
+ const variables = { "--code-editor-selection": _s.selection.color, "--code-editor-placeholder": _s.placeholder.color,
436
+ "--code-editor-active-number": _s.gutter.activeTextColor, "--code-editor-bar": _s.scrollBar.color,
437
+ "--code-editor-bar-hover": _s.scrollBar.hoverColor, "--code-editor-bar-size": _s.scrollBar.size + "px" };
438
+ Object.keys(_s.kinds).forEach(function (kind) { variables["--code-editor-" + kind] = _s.kinds[kind]; });
439
+ Object.keys(variables).forEach(function (name) { box.elem.style.setProperty(name, variables[name]); });
440
+ refreshGutterWidth();
441
+ drawVisibleLines(1);
442
+ };
443
+
444
+ // Everything of a new text
445
+ const showValue = function () {
446
+ lines = [""];
447
+ lineStates = [null];
448
+ validStateCount = 1;
449
+ readValue();
450
+ textarea().scrollTop = 0;
451
+ textarea().scrollLeft = 0;
452
+ box.cursorLine = 1;
453
+ box.cursorColumn = 1;
454
+ refreshGutterWidth();
455
+ drawVisibleLines(1);
456
+ };
457
+
458
+ // *** PUBLIC FUNCTIONS:
459
+
460
+ // silent: 1 -> onChange is not called. NOTE: The undo of the browser starts again with a new text.
461
+ box.setValue = function (value, silent = 0) {
462
+ const text = (value === null || value === undefined) ? "" : String(value);
463
+ if (text === textarea().value) return; // the same text: nothing to draw, no onChange
464
+ textarea().value = text;
465
+ showValue();
466
+ if (!silent) tellChange();
467
+ };
468
+ // USAGE: get: editor.value (or editor.getValue()), set: editor.setValue("x = 1\n")
469
+
470
+ box.getValue = function () {
471
+ return textarea().value;
472
+ };
473
+
474
+ // At the cursor, over the selected text. Undo takes it back.
475
+ box.insertText = function (text) {
476
+ insertAtSelection(String(text));
477
+ };
478
+ // USAGE: editor.insertText("print(x)")
479
+
480
+ box.getSelectedText = function () {
481
+ const elem = textarea();
482
+ return elem.value.slice(elem.selectionStart, elem.selectionEnd);
483
+ };
484
+
485
+ box.setLanguage = function (language) {
486
+ box.language = language;
487
+ validStateCount = 1;
488
+ drawVisibleLines(1);
489
+ };
490
+ // USAGE: editor.setLanguage("python")
491
+
492
+ box.setReadOnly = function (value) {
493
+ box.readOnly = basic.isOn(value) ? 1 : 0;
494
+ textarea().readOnly = (box.readOnly == 1);
495
+ };
496
+ // USAGE: editor.setReadOnly(1)
497
+
498
+ box.setShowLineNumbers = function (value) {
499
+ box.showLineNumbers = basic.isOn(value) ? 1 : 0;
500
+ refreshGutterWidth();
501
+ };
502
+ // USAGE: editor.setShowLineNumbers(0)
503
+
504
+ box.setTabSize = function (size) {
505
+ box.tabSize = size;
506
+ textarea().style.tabSize = size;
507
+ box.codeLayer.css.tabSize = size;
508
+ };
509
+ // USAGE: editor.setTabSize(2)
510
+
511
+ // Puts the cursor at the start of a line (from 1) and shows it.
512
+ box.goToLine = function (lineNumber) {
513
+ const elem = textarea();
514
+ const line = basic.clamp(Math.round(lineNumber), 1, lines.length);
515
+ let place = 0;
516
+ for (let i = 0; i < line - 1; i++) place += lines[i].length + 1;
517
+ elem.focus({ preventScroll: true });
518
+ elem.setSelectionRange(place, place);
519
+ const top = (line - 1) * lineHeight();
520
+ const margin = CARET_MARGIN_LINES * lineHeight();
521
+ const isSeen = (top - margin >= elem.scrollTop && top + lineHeight() + margin <= elem.scrollTop + elem.clientHeight);
522
+ if (!isSeen) elem.scrollTop = Math.max(0, top - elem.clientHeight / 2);
523
+ drawVisibleLines(0);
524
+ readCursor();
525
+ };
526
+ // USAGE: editor.goToLine(120)
527
+
528
+ box.focusEditor = function () {
529
+ textarea().focus({ preventScroll: true });
530
+ };
531
+ // USAGE: editor.focusEditor()
532
+
533
+ // Another style package while it is on the page. A style given by the page stays over it.
534
+ box.setTheme = function (styleName) {
535
+ box.styleName = styleName;
536
+ _s = styleOfPackage(styleName);
537
+ box.style = _s;
538
+ applyLook();
539
+ };
540
+ // USAGE: editor.setTheme("dark")
541
+
542
+ // *** OBJECT VIEW:
543
+
544
+ basic.addCss("code-editor",
545
+ ".code-editor-textarea { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 0; border: 0; outline: none;" +
546
+ " resize: none; box-sizing: border-box; background: transparent; color: transparent; -webkit-text-fill-color: transparent;" +
547
+ " white-space: pre; overflow: auto; pointer-events: auto; user-select: text; -webkit-user-select: text; font-variant-ligatures: none; }" +
548
+ ".code-editor-textarea::selection { background: var(--code-editor-selection); }" +
549
+ ".code-editor-textarea::placeholder { color: var(--code-editor-placeholder); -webkit-text-fill-color: var(--code-editor-placeholder); }" +
550
+ ".code-editor-textarea::-webkit-scrollbar { width: var(--code-editor-bar-size); height: var(--code-editor-bar-size); }" +
551
+ ".code-editor-textarea::-webkit-scrollbar-thumb { background: var(--code-editor-bar); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }" +
552
+ ".code-editor-textarea::-webkit-scrollbar-thumb:hover { background: var(--code-editor-bar-hover); border: 2px solid transparent; background-clip: padding-box; }" +
553
+ ".code-editor-textarea::-webkit-scrollbar-corner { background: transparent; }" +
554
+ ".code-editor-layer { white-space: pre; font-variant-ligatures: none; overflow: visible; width: max-content; }" +
555
+ ".code-editor-active-number { color: var(--code-editor-active-number); }" +
556
+ CodeEditor.KIND_NAMES.map(function (kind) { return ".code-editor-" + kind + " { color: var(--code-editor-" + kind + "); }"; }).join("")
557
+ );
558
+
559
+ // BOX: The line numbers
560
+ box.gutter = startBox({ left: 0, top: 0, height: "100%", css: { boxSizing: "border-box" } });
561
+
562
+ // LABEL: The numbers that are seen
563
+ box.gutterLayer = Label({ top: 0, textAlign: "right" });
564
+ box.gutterLayer.elem.classList.add("code-editor-layer");
565
+ box.gutterLayer.css.left = "auto";
566
+ box.gutterLayer.aria = { hidden: "true" };
567
+
568
+ endBox();
569
+
570
+ // BOX: The code
571
+ box.codeArea = startBox({ top: 0, height: "100%", color: "transparent" });
572
+
573
+ // BOX: The line of the cursor
574
+ box.activeLine = Box({ left: 0, width: "100%" });
575
+
576
+ // LABEL: The colored code that is seen (behind the textarea)
577
+ box.codeLayer = Label({ left: 0, top: 0 });
578
+ box.codeLayer.elem.classList.add("code-editor-layer");
579
+ box.codeLayer.aria = { hidden: "true" };
580
+
581
+ endBox();
582
+
583
+ // TEXTAREA: The typing. A raw element: basic.js has no object of more lines. Its text is transparent, over the colors.
584
+ box.textareaElem = document.createElement("textarea");
585
+ box.textareaElem.classList.add("code-editor-textarea");
586
+ box.textareaElem.wrap = "off";
587
+ box.textareaElem.spellcheck = false;
588
+ box.textareaElem.setAttribute("autocomplete", "off");
589
+ box.textareaElem.setAttribute("autocorrect", "off");
590
+ box.textareaElem.setAttribute("autocapitalize", "off");
591
+ box.textareaElem.setAttribute("aria-label", box.ariaLabel);
592
+ box.textareaElem.placeholder = box.placeholder;
593
+ box.textareaElem.readOnly = (box.readOnly == 1);
594
+ box.textareaElem.value = (box.value === null || box.value === undefined) ? "" : String(box.value);
595
+ box.codeArea.elem.appendChild(box.textareaElem);
596
+
597
+ // *** OBJECT INIT CODE:
598
+
599
+ box.listenTo(textarea(), "input", onInput);
600
+ box.listenTo(textarea(), "scroll", function () { drawVisibleLines(0); });
601
+ box.listenTo(textarea(), "keydown", function (self, event) { onKeyDown(event); });
602
+ box.listenTo(textarea(), "keyup", readCursor);
603
+ box.listenTo(textarea(), "mouseup", readCursor);
604
+ box.listenTo(textarea(), "focus", readCursor);
605
+ box.listenTo(document, "selectionchange", function () {
606
+ if (document.activeElement === textarea()) readCursor();
607
+ });
608
+ // WHY: The first drawing has no height when the box is not on the page yet; a new height shows more lines.
609
+ box.onResize(function () { drawVisibleLines(0); });
610
+
611
+ readValue();
612
+ applyLook();
613
+
614
+ return endObject(box);
615
+
616
+ };
617
+
618
+ // *** STATIC VARIABLES AND FUNCTIONS:
619
+
620
+ CodeEditor.KIND_NAMES = ["keyword", "string", "number", "comment", "builtin", "function", "property", "tag", "attribute", "variable"];
621
+
622
+ CodeEditor.escapeRegExp = function (text) {
623
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
624
+ };
625
+
626
+ // [kind, text] as HTML
627
+ CodeEditor.partHtml = function (part) {
628
+ const text = basic.escapeHtml(part[1]);
629
+ return (part[0]) ? '<span class="code-editor-' + part[0] + '">' + text + "</span>" : text;
630
+ };
631
+
632
+ CodeEditor.NUMBER = /^(0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(\.\d*)?([eE][+-]?\d+)?|\.\d+([eE][+-]?\d+)?)/;
633
+ // WHY the letters of every language: "şif" is one word, not "ş" and the keyword "if".
634
+ CodeEditor.WORD = /^[\p{L}_][\p{L}\p{N}_]*/u;
635
+ CodeEditor.WORD_LETTER = /[\p{L}\p{N}_]/u;
636
+
637
+ // The text from a place to the end of a string, with the letters after a backslash skipped. -1: it does not end here.
638
+ CodeEditor.findStringEnd = function (text, from, mark) {
639
+ let index = from;
640
+ while (index < text.length) {
641
+ if (text[index] === "\\") {
642
+ index += 2;
643
+ } else if (text.startsWith(mark, index)) {
644
+ return index + mark.length;
645
+ } else {
646
+ index++;
647
+ }
648
+ }
649
+ return -1;
650
+ };
651
+
652
+ // The kind of a word by its place
653
+ CodeEditor.kindOfWord = function (word, restOfLine, definition) {
654
+ const lookedUp = (definition.ignoreCase) ? word.toLowerCase() : word;
655
+ if (definition.keywordSet.has(lookedUp)) return "keyword";
656
+ if (definition.builtinSet.has(lookedUp)) return "builtin";
657
+ if (definition.callWords && /^\s*\(/.test(restOfLine)) return "function";
658
+ if (definition.propertyWords && /^\s*:/.test(restOfLine)) return "property";
659
+ return "";
660
+ };
661
+
662
+ // WHY sets, made once: the words are looked up for every word of every line that is drawn.
663
+ CodeEditor.prepareDefinition = function (definition) {
664
+ if (definition.keywordSet) return;
665
+ definition.keywordSet = new Set(definition.keywords || []);
666
+ definition.builtinSet = new Set(definition.builtins || []);
667
+ };
668
+
669
+ // One line: { parts: [[kind, text], ...], state }. state: the end mark of what is still open at the end of the line.
670
+ CodeEditor.tokenizeLine = function (text, state, definition) {
671
+ if (definition.tokenize) return definition.tokenize(text, state);
672
+ CodeEditor.prepareDefinition(definition);
673
+
674
+ const parts = [];
675
+ const add = function (kind, value) {
676
+ if (value.length === 0) return;
677
+ const last = parts[parts.length - 1];
678
+ if (last && last[0] === kind) last[1] += value;
679
+ else parts.push([kind, value]);
680
+ };
681
+ let index = 0;
682
+ let openState = state;
683
+
684
+ // WHAT IS STILL OPEN from the lines before (a comment, a string of many lines)
685
+ if (openState) {
686
+ const isString = (definition.multiLineStrings || []).includes(openState);
687
+ const end = (isString) ? CodeEditor.findStringEnd(text, 0, openState) : text.indexOf(openState);
688
+ const kind = (isString) ? "string" : "comment";
689
+ if (end < 0) {
690
+ add(kind, text);
691
+ return { parts: parts, state: openState };
692
+ }
693
+ const stop = (isString) ? end : end + openState.length;
694
+ add(kind, text.slice(0, stop));
695
+ index = stop;
696
+ openState = null;
697
+ }
698
+
699
+ const lineComment = definition.lineComment;
700
+ const blockComment = definition.blockComment;
701
+ const strings = definition.strings || [];
702
+ const multiLine = definition.multiLineStrings || [];
703
+
704
+ while (index < text.length) {
705
+ const rest = text.slice(index);
706
+ const letter = text[index];
707
+
708
+ if (lineComment && rest.startsWith(lineComment)) {
709
+ add("comment", rest);
710
+ break;
711
+ }
712
+
713
+ if (blockComment && rest.startsWith(blockComment[0])) {
714
+ const end = text.indexOf(blockComment[1], index + blockComment[0].length);
715
+ if (end < 0) {
716
+ add("comment", rest);
717
+ openState = blockComment[1];
718
+ break;
719
+ }
720
+ add("comment", text.slice(index, end + blockComment[1].length));
721
+ index = end + blockComment[1].length;
722
+ continue;
723
+ }
724
+
725
+ const stringMark = strings.find(function (mark) { return rest.startsWith(mark); });
726
+ if (stringMark) {
727
+ const end = CodeEditor.findStringEnd(text, index + stringMark.length, stringMark);
728
+ if (end < 0) {
729
+ add("string", rest);
730
+ if (multiLine.includes(stringMark)) openState = stringMark;
731
+ break;
732
+ }
733
+ const isProperty = (definition.propertyStrings && /^\s*:/.test(text.slice(end)));
734
+ add((isProperty) ? "property" : "string", text.slice(index, end));
735
+ index = end;
736
+ continue;
737
+ }
738
+
739
+ const isAfterWord = (index > 0 && CodeEditor.WORD_LETTER.test(text[index - 1]));
740
+ const numberMatch = (isAfterWord) ? null : CodeEditor.NUMBER.exec(rest);
741
+ if (numberMatch) {
742
+ add("number", numberMatch[0]);
743
+ index += numberMatch[0].length;
744
+ continue;
745
+ }
746
+
747
+ if (definition.decorators && letter === definition.decorators) {
748
+ const decorator = CodeEditor.WORD.exec(rest.slice(1));
749
+ if (decorator) {
750
+ add("function", letter + decorator[0]);
751
+ index += 1 + decorator[0].length;
752
+ continue;
753
+ }
754
+ }
755
+
756
+ if (definition.variables && letter === definition.variables) {
757
+ const variable = CodeEditor.WORD.exec(rest.slice(1));
758
+ if (variable) {
759
+ add("variable", letter + variable[0]);
760
+ index += 1 + variable[0].length;
761
+ continue;
762
+ }
763
+ }
764
+
765
+ const wordMatch = CodeEditor.WORD.exec(rest);
766
+ if (wordMatch) {
767
+ const word = wordMatch[0];
768
+ add(CodeEditor.kindOfWord(word, rest.slice(word.length), definition), word);
769
+ index += word.length;
770
+ continue;
771
+ }
772
+
773
+ add("", letter);
774
+ index++;
775
+ }
776
+
777
+ return { parts: parts, state: openState };
778
+ };
779
+
780
+ // HTML has tags instead of words. state: "-->" (a comment), "tag" (the attributes of a tag go on)
781
+ CodeEditor.tokenizeHtml = function (text, state) {
782
+ const parts = [];
783
+ let index = 0;
784
+ let openState = state;
785
+
786
+ const readTagInside = function () {
787
+ while (index < text.length) {
788
+ const rest = text.slice(index);
789
+ const closing = /^\/?>/.exec(rest);
790
+ if (closing) {
791
+ parts.push(["tag", closing[0]]);
792
+ index += closing[0].length;
793
+ openState = null;
794
+ return;
795
+ }
796
+ const attribute = /^[A-Za-z_:@][\w:.-]*/.exec(rest);
797
+ const quoted = /^("[^"]*"?|'[^']*'?)/.exec(rest);
798
+ if (attribute) {
799
+ parts.push(["attribute", attribute[0]]);
800
+ index += attribute[0].length;
801
+ } else if (quoted) {
802
+ parts.push(["string", quoted[0]]);
803
+ index += quoted[0].length;
804
+ } else {
805
+ parts.push(["", text[index]]);
806
+ index++;
807
+ }
808
+ }
809
+ openState = "tag";
810
+ };
811
+
812
+ if (openState === "-->") {
813
+ const end = text.indexOf("-->");
814
+ if (end < 0) return { parts: [["comment", text]], state: "-->" };
815
+ parts.push(["comment", text.slice(0, end + 3)]);
816
+ index = end + 3;
817
+ openState = null;
818
+ } else if (openState === "tag") {
819
+ readTagInside();
820
+ }
821
+
822
+ while (index < text.length) {
823
+ const rest = text.slice(index);
824
+ if (rest.startsWith("<!--")) {
825
+ const end = text.indexOf("-->", index + 4);
826
+ if (end < 0) {
827
+ parts.push(["comment", rest]);
828
+ return { parts: parts, state: "-->" };
829
+ }
830
+ parts.push(["comment", text.slice(index, end + 3)]);
831
+ index = end + 3;
832
+ continue;
833
+ }
834
+ const opening = /^<\/?[A-Za-z!][\w:-]*/.exec(rest);
835
+ if (opening) {
836
+ parts.push(["tag", opening[0]]);
837
+ index += opening[0].length;
838
+ readTagInside();
839
+ continue;
840
+ }
841
+ const nextTag = rest.indexOf("<", 1);
842
+ const stop = (nextTag < 0) ? text.length : index + nextTag;
843
+ parts.push(["", text.slice(index, stop)]);
844
+ index = stop;
845
+ }
846
+
847
+ return { parts: parts, state: openState };
848
+ };
849
+
850
+ // *** LANGUAGES:
851
+ CodeEditor.languages = {
852
+
853
+ text: {
854
+ tokenize: function (line) { return { parts: [["", line]], state: null }; },
855
+ },
856
+
857
+ python: {
858
+ lineComment: "#",
859
+ strings: ['"""', "'''", '"', "'"],
860
+ multiLineStrings: ['"""', "'''"],
861
+ keywords: ["False", "None", "True", "and", "as", "assert", "async", "await", "break", "class", "continue", "def", "del", "elif", "else", "except", "finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "nonlocal", "not", "or", "pass", "raise", "return", "try", "while", "with", "yield"],
862
+ builtins: ["abs", "all", "any", "bool", "bytes", "dict", "dir", "enumerate", "filter", "float", "format", "getattr", "hasattr", "input", "int", "isinstance", "iter", "len", "list", "map", "max", "min", "next", "object", "open", "print", "range", "repr", "reversed", "round", "set", "setattr", "sorted", "str", "sum", "super", "tuple", "type", "zip", "self", "cls"],
863
+ callWords: 1,
864
+ decorators: "@",
865
+ indentAfter: ":",
866
+ },
867
+
868
+ javascript: {
869
+ lineComment: "//",
870
+ blockComment: ["/*", "*/"],
871
+ strings: ['"', "'", "`"],
872
+ multiLineStrings: ["`"],
873
+ keywords: ["async", "await", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "else", "export", "extends", "false", "finally", "for", "function", "if", "import", "in", "instanceof", "let", "new", "null", "of", "return", "static", "super", "switch", "this", "throw", "true", "try", "typeof", "undefined", "var", "void", "while", "yield"],
874
+ builtins: ["Array", "Boolean", "Date", "Error", "JSON", "Map", "Math", "Number", "Object", "Promise", "RegExp", "Set", "String", "console", "document", "window"],
875
+ callWords: 1,
876
+ indentAfter: "{[(",
877
+ },
878
+
879
+ json: {
880
+ strings: ['"'],
881
+ keywords: ["true", "false", "null"],
882
+ propertyStrings: 1,
883
+ indentAfter: "{[",
884
+ },
885
+
886
+ css: {
887
+ blockComment: ["/*", "*/"],
888
+ strings: ['"', "'"],
889
+ propertyWords: 1,
890
+ variables: "#", // #fff, #title
891
+ indentAfter: "{",
892
+ },
893
+
894
+ sql: {
895
+ lineComment: "--",
896
+ blockComment: ["/*", "*/"],
897
+ strings: ["'", '"'],
898
+ ignoreCase: 1,
899
+ keywords: ["add", "all", "alter", "and", "as", "asc", "between", "by", "case", "create", "delete", "desc", "distinct", "drop", "else", "end", "exists", "from", "group", "having", "in", "index", "inner", "insert", "into", "is", "join", "key", "left", "like", "limit", "not", "null", "offset", "on", "or", "order", "outer", "primary", "right", "select", "set", "table", "then", "union", "unique", "update", "values", "view", "when", "where"],
900
+ builtins: ["avg", "count", "max", "min", "sum", "coalesce", "lower", "upper", "integer", "text", "real", "varchar", "boolean", "date"],
901
+ callWords: 1,
902
+ indentAfter: "(",
903
+ },
904
+
905
+ bash: {
906
+ lineComment: "#",
907
+ strings: ['"', "'"],
908
+ keywords: ["case", "do", "done", "elif", "else", "esac", "exit", "export", "fi", "for", "function", "if", "in", "local", "return", "set", "then", "until", "while"],
909
+ builtins: ["cat", "cd", "chmod", "cp", "echo", "find", "grep", "ls", "mkdir", "mv", "pwd", "read", "rm", "sed", "sudo", "touch"],
910
+ variables: "$",
911
+ indentAfter: "{(",
912
+ },
913
+
914
+ html: {
915
+ tokenize: CodeEditor.tokenizeHtml,
916
+ },
917
+
918
+ };
919
+
920
+ // *** STYLE PACKAGES:
921
+ // USAGE: CodeEditor({ styleName: "dark" })
922
+ // USAGE: CodeEditor({ styleName: "dark", style: { kinds: { keyword: "tomato" } } }) // Change only some keys.
923
+ // NOTE: A new package needs only the keys that differ from the default (light) style.
924
+ // USAGE: CodeEditor.styles.myStyle = { box: { color: "#FFFDF5" } };
925
+ CodeEditor.styles = {
926
+
927
+ // White, a soft gray for the numbers.
928
+ light: CodeEditorDefaults.style,
929
+
930
+ // For a dark window.
931
+ dark: {
932
+ box: { color: "#1C1C1B", borderColor: White(0.1) },
933
+ text: { color: "#E6E6E3", caretColor: "#FFFFFF" },
934
+ gutter: { color: "#232322", lineColor: White(0.08), textColor: White(0.38), activeTextColor: White(0.85) },
935
+ activeLine: { color: White(0.05) },
936
+ selection: { color: "rgba(111, 198, 205, 0.35)" },
937
+ placeholder: { color: White(0.42) },
938
+ scrollBar: { color: White(0.22), hoverColor: White(0.4) },
939
+ kinds: {
940
+ keyword: "#D7A2E8",
941
+ string: "#8FD694",
942
+ number: "#F0B56A",
943
+ comment: "#8D939B",
944
+ builtin: "#6FC6CD",
945
+ function: "#8CC4EE",
946
+ property: "#8CC4EE",
947
+ tag: "#F08FA8",
948
+ attribute: "#F0B56A",
949
+ variable: "#6FC6CD",
950
+ },
951
+ },
952
+
953
+ };