@ckeditor/ckeditor5-ui 41.3.0-alpha.4 → 41.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (324) hide show
  1. package/ckeditor5-metadata.json +1 -1
  2. package/lang/contexts.json +12 -2
  3. package/lang/translations/af.po +210 -0
  4. package/lang/translations/ar.po +44 -4
  5. package/lang/translations/ast.po +44 -4
  6. package/lang/translations/az.po +44 -4
  7. package/lang/translations/bg.po +44 -4
  8. package/lang/translations/bn.po +44 -4
  9. package/lang/translations/bs.po +210 -0
  10. package/lang/translations/ca.po +44 -4
  11. package/lang/translations/cs.po +44 -4
  12. package/lang/translations/da.po +44 -4
  13. package/lang/translations/de-ch.po +44 -4
  14. package/lang/translations/de.po +44 -4
  15. package/lang/translations/el.po +44 -4
  16. package/lang/translations/en-au.po +44 -4
  17. package/lang/translations/en-gb.po +44 -4
  18. package/lang/translations/en.po +44 -4
  19. package/lang/translations/eo.po +44 -4
  20. package/lang/translations/es-co.po +210 -0
  21. package/lang/translations/es.po +44 -4
  22. package/lang/translations/et.po +44 -4
  23. package/lang/translations/eu.po +44 -4
  24. package/lang/translations/fa.po +44 -4
  25. package/lang/translations/fi.po +44 -4
  26. package/lang/translations/fr.po +44 -4
  27. package/lang/translations/gl.po +44 -4
  28. package/lang/translations/he.po +44 -4
  29. package/lang/translations/hi.po +44 -4
  30. package/lang/translations/hr.po +44 -4
  31. package/lang/translations/hu.po +44 -4
  32. package/lang/translations/id.po +44 -4
  33. package/lang/translations/it.po +44 -4
  34. package/lang/translations/ja.po +44 -4
  35. package/lang/translations/jv.po +210 -0
  36. package/lang/translations/km.po +44 -4
  37. package/lang/translations/kn.po +44 -4
  38. package/lang/translations/ko.po +44 -4
  39. package/lang/translations/ku.po +44 -4
  40. package/lang/translations/lt.po +44 -4
  41. package/lang/translations/lv.po +44 -4
  42. package/lang/translations/ms.po +44 -4
  43. package/lang/translations/nb.po +44 -4
  44. package/lang/translations/ne.po +44 -4
  45. package/lang/translations/nl.po +44 -4
  46. package/lang/translations/no.po +44 -4
  47. package/lang/translations/pl.po +44 -4
  48. package/lang/translations/pt-br.po +44 -4
  49. package/lang/translations/pt.po +44 -4
  50. package/lang/translations/ro.po +44 -4
  51. package/lang/translations/ru.po +44 -4
  52. package/lang/translations/sk.po +44 -4
  53. package/lang/translations/sl.po +44 -4
  54. package/lang/translations/sq.po +44 -4
  55. package/lang/translations/sr-latn.po +44 -4
  56. package/lang/translations/sr.po +44 -4
  57. package/lang/translations/sv.po +44 -4
  58. package/lang/translations/th.po +44 -4
  59. package/lang/translations/tk.po +44 -4
  60. package/lang/translations/tr.po +44 -4
  61. package/lang/translations/tt.po +44 -4
  62. package/lang/translations/ug.po +44 -4
  63. package/lang/translations/uk.po +44 -4
  64. package/lang/translations/ur.po +44 -4
  65. package/lang/translations/uz.po +44 -4
  66. package/lang/translations/vi.po +44 -4
  67. package/lang/translations/zh-cn.po +44 -4
  68. package/lang/translations/zh.po +44 -4
  69. package/package.json +3 -4
  70. package/src/button/button.d.ts +6 -0
  71. package/src/button/buttonview.d.ts +4 -0
  72. package/src/button/buttonview.js +1 -0
  73. package/src/button/filedialogbuttonview.d.ts +80 -0
  74. package/src/button/filedialogbuttonview.js +103 -0
  75. package/src/dropdown/utils.js +1 -5
  76. package/src/editorui/accessibilityhelp/accessibilityhelp.d.ts +4 -0
  77. package/src/editorui/accessibilityhelp/accessibilityhelp.js +25 -9
  78. package/src/index.d.ts +12 -3
  79. package/src/index.js +10 -2
  80. package/src/menubar/menubarmenubuttonview.d.ts +35 -0
  81. package/src/menubar/menubarmenubuttonview.js +64 -0
  82. package/src/menubar/menubarmenulistitembuttonview.d.ts +21 -0
  83. package/src/menubar/menubarmenulistitembuttonview.js +30 -0
  84. package/src/menubar/menubarmenulistitemfiledialogbuttonview.d.ts +23 -0
  85. package/src/menubar/menubarmenulistitemfiledialogbuttonview.js +32 -0
  86. package/src/menubar/menubarmenulistitemview.d.ts +25 -0
  87. package/src/menubar/menubarmenulistitemview.js +34 -0
  88. package/src/menubar/menubarmenulistview.d.ts +24 -0
  89. package/src/menubar/menubarmenulistview.js +23 -0
  90. package/src/menubar/menubarmenupanelview.d.ts +53 -0
  91. package/src/menubar/menubarmenupanelview.js +60 -0
  92. package/src/menubar/menubarmenuview.d.ts +109 -0
  93. package/src/menubar/menubarmenuview.js +159 -0
  94. package/src/menubar/menubarview.d.ts +164 -0
  95. package/src/menubar/menubarview.js +254 -0
  96. package/src/menubar/utils.d.ts +432 -0
  97. package/src/menubar/utils.js +1320 -0
  98. package/src/toolbar/toolbarview.js +5 -3
  99. package/src/tooltipmanager.d.ts +11 -0
  100. package/src/tooltipmanager.js +37 -6
  101. package/theme/components/menubar/menubar.css +10 -0
  102. package/theme/components/menubar/menubarmenu.css +9 -0
  103. package/theme/components/menubar/menubarmenubutton.css +11 -0
  104. package/theme/components/menubar/menubarmenulistitem.css +10 -0
  105. package/theme/components/menubar/menubarmenulistitembutton.css +10 -0
  106. package/theme/components/menubar/menubarmenupanel.css +62 -0
  107. package/theme/components/tooltip/tooltip.css +0 -3
  108. package/theme/globals/_reset.css +13 -0
  109. package/theme/globals/globals.css +1 -0
  110. package/dist/content-index.css +0 -4
  111. package/dist/editor-index.css +0 -445
  112. package/dist/index.css +0 -844
  113. package/dist/index.css.map +0 -1
  114. package/dist/translations/ar.d.ts +0 -8
  115. package/dist/translations/ar.js +0 -5
  116. package/dist/translations/ast.d.ts +0 -8
  117. package/dist/translations/ast.js +0 -5
  118. package/dist/translations/az.d.ts +0 -8
  119. package/dist/translations/az.js +0 -5
  120. package/dist/translations/bg.d.ts +0 -8
  121. package/dist/translations/bg.js +0 -5
  122. package/dist/translations/bn.d.ts +0 -8
  123. package/dist/translations/bn.js +0 -5
  124. package/dist/translations/ca.d.ts +0 -8
  125. package/dist/translations/ca.js +0 -5
  126. package/dist/translations/cs.d.ts +0 -8
  127. package/dist/translations/cs.js +0 -5
  128. package/dist/translations/da.d.ts +0 -8
  129. package/dist/translations/da.js +0 -5
  130. package/dist/translations/de-ch.d.ts +0 -8
  131. package/dist/translations/de-ch.js +0 -5
  132. package/dist/translations/de.d.ts +0 -8
  133. package/dist/translations/de.js +0 -5
  134. package/dist/translations/el.d.ts +0 -8
  135. package/dist/translations/el.js +0 -5
  136. package/dist/translations/en-au.d.ts +0 -8
  137. package/dist/translations/en-au.js +0 -5
  138. package/dist/translations/en-gb.d.ts +0 -8
  139. package/dist/translations/en-gb.js +0 -5
  140. package/dist/translations/en.d.ts +0 -8
  141. package/dist/translations/en.js +0 -5
  142. package/dist/translations/eo.d.ts +0 -8
  143. package/dist/translations/eo.js +0 -5
  144. package/dist/translations/es.d.ts +0 -8
  145. package/dist/translations/es.js +0 -5
  146. package/dist/translations/et.d.ts +0 -8
  147. package/dist/translations/et.js +0 -5
  148. package/dist/translations/eu.d.ts +0 -8
  149. package/dist/translations/eu.js +0 -5
  150. package/dist/translations/fa.d.ts +0 -8
  151. package/dist/translations/fa.js +0 -5
  152. package/dist/translations/fi.d.ts +0 -8
  153. package/dist/translations/fi.js +0 -5
  154. package/dist/translations/fr.d.ts +0 -8
  155. package/dist/translations/fr.js +0 -5
  156. package/dist/translations/gl.d.ts +0 -8
  157. package/dist/translations/gl.js +0 -5
  158. package/dist/translations/he.d.ts +0 -8
  159. package/dist/translations/he.js +0 -5
  160. package/dist/translations/hi.d.ts +0 -8
  161. package/dist/translations/hi.js +0 -5
  162. package/dist/translations/hr.d.ts +0 -8
  163. package/dist/translations/hr.js +0 -5
  164. package/dist/translations/hu.d.ts +0 -8
  165. package/dist/translations/hu.js +0 -5
  166. package/dist/translations/id.d.ts +0 -8
  167. package/dist/translations/id.js +0 -5
  168. package/dist/translations/it.d.ts +0 -8
  169. package/dist/translations/it.js +0 -5
  170. package/dist/translations/ja.d.ts +0 -8
  171. package/dist/translations/ja.js +0 -5
  172. package/dist/translations/km.d.ts +0 -8
  173. package/dist/translations/km.js +0 -5
  174. package/dist/translations/kn.d.ts +0 -8
  175. package/dist/translations/kn.js +0 -5
  176. package/dist/translations/ko.d.ts +0 -8
  177. package/dist/translations/ko.js +0 -5
  178. package/dist/translations/ku.d.ts +0 -8
  179. package/dist/translations/ku.js +0 -5
  180. package/dist/translations/lt.d.ts +0 -8
  181. package/dist/translations/lt.js +0 -5
  182. package/dist/translations/lv.d.ts +0 -8
  183. package/dist/translations/lv.js +0 -5
  184. package/dist/translations/ms.d.ts +0 -8
  185. package/dist/translations/ms.js +0 -5
  186. package/dist/translations/nb.d.ts +0 -8
  187. package/dist/translations/nb.js +0 -5
  188. package/dist/translations/ne.d.ts +0 -8
  189. package/dist/translations/ne.js +0 -5
  190. package/dist/translations/nl.d.ts +0 -8
  191. package/dist/translations/nl.js +0 -5
  192. package/dist/translations/no.d.ts +0 -8
  193. package/dist/translations/no.js +0 -5
  194. package/dist/translations/pl.d.ts +0 -8
  195. package/dist/translations/pl.js +0 -5
  196. package/dist/translations/pt-br.d.ts +0 -8
  197. package/dist/translations/pt-br.js +0 -5
  198. package/dist/translations/pt.d.ts +0 -8
  199. package/dist/translations/pt.js +0 -5
  200. package/dist/translations/ro.d.ts +0 -8
  201. package/dist/translations/ro.js +0 -5
  202. package/dist/translations/ru.d.ts +0 -8
  203. package/dist/translations/ru.js +0 -5
  204. package/dist/translations/sk.d.ts +0 -8
  205. package/dist/translations/sk.js +0 -5
  206. package/dist/translations/sl.d.ts +0 -8
  207. package/dist/translations/sl.js +0 -5
  208. package/dist/translations/sq.d.ts +0 -8
  209. package/dist/translations/sq.js +0 -5
  210. package/dist/translations/sr-latn.d.ts +0 -8
  211. package/dist/translations/sr-latn.js +0 -5
  212. package/dist/translations/sr.d.ts +0 -8
  213. package/dist/translations/sr.js +0 -5
  214. package/dist/translations/sv.d.ts +0 -8
  215. package/dist/translations/sv.js +0 -5
  216. package/dist/translations/th.d.ts +0 -8
  217. package/dist/translations/th.js +0 -5
  218. package/dist/translations/tk.d.ts +0 -8
  219. package/dist/translations/tk.js +0 -5
  220. package/dist/translations/tr.d.ts +0 -8
  221. package/dist/translations/tr.js +0 -5
  222. package/dist/translations/tt.d.ts +0 -8
  223. package/dist/translations/tt.js +0 -5
  224. package/dist/translations/ug.d.ts +0 -8
  225. package/dist/translations/ug.js +0 -5
  226. package/dist/translations/uk.d.ts +0 -8
  227. package/dist/translations/uk.js +0 -5
  228. package/dist/translations/ur.d.ts +0 -8
  229. package/dist/translations/ur.js +0 -5
  230. package/dist/translations/uz.d.ts +0 -8
  231. package/dist/translations/uz.js +0 -5
  232. package/dist/translations/vi.d.ts +0 -8
  233. package/dist/translations/vi.js +0 -5
  234. package/dist/translations/zh-cn.d.ts +0 -8
  235. package/dist/translations/zh-cn.js +0 -5
  236. package/dist/translations/zh.d.ts +0 -8
  237. package/dist/translations/zh.js +0 -5
  238. package/dist/types/arialiveannouncer.d.ts +0 -102
  239. package/dist/types/augmentation.d.ts +0 -92
  240. package/dist/types/autocomplete/autocompleteview.d.ts +0 -85
  241. package/dist/types/bindings/addkeyboardhandlingforgrid.d.ts +0 -31
  242. package/dist/types/bindings/clickoutsidehandler.d.ts +0 -32
  243. package/dist/types/bindings/csstransitiondisablermixin.d.ts +0 -44
  244. package/dist/types/bindings/draggableviewmixin.d.ts +0 -50
  245. package/dist/types/bindings/injectcsstransitiondisabler.d.ts +0 -63
  246. package/dist/types/bindings/preventdefault.d.ts +0 -37
  247. package/dist/types/bindings/submithandler.d.ts +0 -61
  248. package/dist/types/button/button.d.ts +0 -179
  249. package/dist/types/button/buttonlabel.d.ts +0 -38
  250. package/dist/types/button/buttonlabelview.d.ts +0 -35
  251. package/dist/types/button/buttonview.d.ts +0 -185
  252. package/dist/types/button/switchbuttonview.d.ts +0 -49
  253. package/dist/types/collapsible/collapsibleview.d.ts +0 -74
  254. package/dist/types/colorgrid/colorgridview.d.ts +0 -136
  255. package/dist/types/colorgrid/colortileview.d.ts +0 -32
  256. package/dist/types/colorgrid/utils.d.ts +0 -51
  257. package/dist/types/colorpicker/colorpickerview.d.ts +0 -146
  258. package/dist/types/colorpicker/utils.d.ts +0 -52
  259. package/dist/types/colorselector/colorgridsfragmentview.d.ts +0 -199
  260. package/dist/types/colorselector/colorpickerfragmentview.d.ts +0 -133
  261. package/dist/types/colorselector/colorselectorview.d.ts +0 -246
  262. package/dist/types/colorselector/documentcolorcollection.d.ts +0 -74
  263. package/dist/types/componentfactory.d.ts +0 -85
  264. package/dist/types/dialog/dialog.d.ts +0 -277
  265. package/dist/types/dialog/dialogactionsview.d.ts +0 -73
  266. package/dist/types/dialog/dialogcontentview.d.ts +0 -31
  267. package/dist/types/dialog/dialogview.d.ts +0 -260
  268. package/dist/types/dropdown/button/dropdownbutton.d.ts +0 -29
  269. package/dist/types/dropdown/button/dropdownbuttonview.d.ts +0 -52
  270. package/dist/types/dropdown/button/splitbuttonview.d.ts +0 -166
  271. package/dist/types/dropdown/dropdownpanelfocusable.d.ts +0 -25
  272. package/dist/types/dropdown/dropdownpanelview.d.ts +0 -66
  273. package/dist/types/dropdown/dropdownview.d.ts +0 -319
  274. package/dist/types/dropdown/utils.d.ts +0 -239
  275. package/dist/types/editableui/editableuiview.d.ts +0 -76
  276. package/dist/types/editableui/inline/inlineeditableuiview.d.ts +0 -44
  277. package/dist/types/editorui/accessibilityhelp/accessibilityhelp.d.ts +0 -51
  278. package/dist/types/editorui/accessibilityhelp/accessibilityhelpcontentview.d.ts +0 -39
  279. package/dist/types/editorui/bodycollection.d.ts +0 -59
  280. package/dist/types/editorui/boxed/boxededitoruiview.d.ts +0 -44
  281. package/dist/types/editorui/editorui.d.ts +0 -292
  282. package/dist/types/editorui/editoruiview.d.ts +0 -43
  283. package/dist/types/editorui/poweredby.d.ts +0 -75
  284. package/dist/types/focuscycler.d.ts +0 -249
  285. package/dist/types/formheader/formheaderview.d.ts +0 -63
  286. package/dist/types/highlightedtext/highlightedtextview.d.ts +0 -42
  287. package/dist/types/icon/iconview.d.ts +0 -92
  288. package/dist/types/iframe/iframeview.d.ts +0 -54
  289. package/dist/types/index.d.ts +0 -78
  290. package/dist/types/input/inputbase.d.ts +0 -123
  291. package/dist/types/input/inputview.d.ts +0 -40
  292. package/dist/types/inputnumber/inputnumberview.d.ts +0 -53
  293. package/dist/types/inputtext/inputtextview.d.ts +0 -22
  294. package/dist/types/label/labelview.d.ts +0 -40
  295. package/dist/types/labeledfield/labeledfieldview.d.ts +0 -191
  296. package/dist/types/labeledfield/utils.d.ts +0 -127
  297. package/dist/types/labeledinput/labeledinputview.d.ts +0 -129
  298. package/dist/types/list/listitemgroupview.d.ts +0 -63
  299. package/dist/types/list/listitemview.d.ts +0 -40
  300. package/dist/types/list/listseparatorview.d.ts +0 -22
  301. package/dist/types/list/listview.d.ts +0 -128
  302. package/dist/types/model.d.ts +0 -26
  303. package/dist/types/notification/notification.d.ts +0 -215
  304. package/dist/types/panel/balloon/balloonpanelview.d.ts +0 -689
  305. package/dist/types/panel/balloon/contextualballoon.d.ts +0 -303
  306. package/dist/types/panel/sticky/stickypanelview.d.ts +0 -160
  307. package/dist/types/search/filteredview.d.ts +0 -35
  308. package/dist/types/search/searchinfoview.d.ts +0 -49
  309. package/dist/types/search/searchresultsview.d.ts +0 -58
  310. package/dist/types/search/text/searchtextqueryview.d.ts +0 -80
  311. package/dist/types/search/text/searchtextview.d.ts +0 -223
  312. package/dist/types/spinner/spinnerview.d.ts +0 -29
  313. package/dist/types/template.d.ts +0 -946
  314. package/dist/types/textarea/textareaview.d.ts +0 -108
  315. package/dist/types/toolbar/balloon/balloontoolbar.d.ts +0 -121
  316. package/dist/types/toolbar/block/blockbuttonview.d.ts +0 -39
  317. package/dist/types/toolbar/block/blocktoolbar.d.ts +0 -157
  318. package/dist/types/toolbar/normalizetoolbarconfig.d.ts +0 -44
  319. package/dist/types/toolbar/toolbarlinebreakview.d.ts +0 -22
  320. package/dist/types/toolbar/toolbarseparatorview.d.ts +0 -22
  321. package/dist/types/toolbar/toolbarview.d.ts +0 -271
  322. package/dist/types/tooltipmanager.d.ts +0 -188
  323. package/dist/types/view.d.ts +0 -426
  324. package/dist/types/viewcollection.d.ts +0 -143
@@ -1,946 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
8
- */
9
- /**
10
- * @module ui/template
11
- */
12
- import View from './view.js';
13
- import ViewCollection from './viewcollection.js';
14
- import { type ArrayOrItem, type Emitter, type Observable } from '@ckeditor/ckeditor5-utils';
15
- declare const Template_base: {
16
- new (): Emitter;
17
- prototype: Emitter;
18
- };
19
- /**
20
- * A basic Template class. It renders a DOM HTML element or text from a
21
- * {@link module:ui/template~TemplateDefinition definition} and supports element attributes, children,
22
- * bindings to {@link module:utils/observablemixin~Observable observables} and DOM event propagation.
23
- *
24
- * A simple template can look like this:
25
- *
26
- * ```ts
27
- * const bind = Template.bind( observable, emitter );
28
- *
29
- * new Template( {
30
- * tag: 'p',
31
- * attributes: {
32
- * class: 'foo',
33
- * style: {
34
- * backgroundColor: 'yellow'
35
- * }
36
- * },
37
- * on: {
38
- * click: bind.to( 'clicked' )
39
- * },
40
- * children: [
41
- * 'A paragraph.'
42
- * ]
43
- * } ).render();
44
- * ```
45
- *
46
- * and it will render the following HTML element:
47
- *
48
- * ```html
49
- * <p class="foo" style="background-color: yellow;">A paragraph.</p>
50
- * ```
51
- *
52
- * Additionally, the `observable` will always fire `clicked` upon clicking `<p>` in the DOM.
53
- *
54
- * See {@link module:ui/template~TemplateDefinition} to know more about templates and complex
55
- * template definitions.
56
- */
57
- export default class Template extends Template_base {
58
- ns?: string;
59
- /**
60
- * The tag (`tagName`) of this template, e.g. `div`. It also indicates that the template
61
- * renders to an HTML element.
62
- */
63
- tag?: string;
64
- /**
65
- * The text of the template. It also indicates that the template renders to a DOM text node.
66
- */
67
- text?: Array<TemplateSimpleValue | TemplateBinding>;
68
- /**
69
- * The attributes of the template, e.g. `{ id: [ 'ck-id' ] }`, corresponding with
70
- * the attributes of an HTML element.
71
- *
72
- * **Note**: This property only makes sense when {@link #tag} is defined.
73
- */
74
- attributes?: Record<string, AttributeValues>;
75
- /**
76
- * The children of the template. They can be either:
77
- * * independent instances of {@link ~Template} (sub–templates),
78
- * * native DOM Nodes.
79
- *
80
- * **Note**: This property only makes sense when {@link #tag} is defined.
81
- */
82
- children?: Array<ViewCollection | View | Node | Template>;
83
- /**
84
- * The DOM event listeners of the template.
85
- */
86
- eventListeners?: Record<string, Array<TemplateToBinding>>;
87
- /**
88
- * Indicates whether this particular Template instance has been
89
- * {@link #render rendered}.
90
- */
91
- private _isRendered;
92
- /**
93
- * The data used by the {@link #revert} method to restore a node to its original state.
94
- *
95
- * See: {@link #apply}.
96
- */
97
- private _revertData;
98
- /**
99
- * Creates an instance of the {@link ~Template} class.
100
- *
101
- * @param def The definition of the template.
102
- */
103
- constructor(def: TemplateDefinition);
104
- /**
105
- * Renders a DOM Node (an HTML element or text) out of the template.
106
- *
107
- * ```ts
108
- * const domNode = new Template( { ... } ).render();
109
- * ```
110
- *
111
- * See: {@link #apply}.
112
- */
113
- render(): HTMLElement | Text;
114
- /**
115
- * Applies the template to an existing DOM Node, either HTML element or text.
116
- *
117
- * **Note:** No new DOM nodes will be created. Applying extends:
118
- *
119
- * {@link module:ui/template~TemplateDefinition attributes},
120
- * {@link module:ui/template~TemplateDefinition event listeners}, and
121
- * `textContent` of {@link module:ui/template~TemplateDefinition children} only.
122
- *
123
- * **Note:** Existing `class` and `style` attributes are extended when a template
124
- * is applied to an HTML element, while other attributes and `textContent` are overridden.
125
- *
126
- * **Note:** The process of applying a template can be easily reverted using the
127
- * {@link module:ui/template~Template#revert} method.
128
- *
129
- * ```ts
130
- * const element = document.createElement( 'div' );
131
- * const observable = new Model( { divClass: 'my-div' } );
132
- * const emitter = Object.create( EmitterMixin );
133
- * const bind = Template.bind( observable, emitter );
134
- *
135
- * new Template( {
136
- * attributes: {
137
- * id: 'first-div',
138
- * class: bind.to( 'divClass' )
139
- * },
140
- * on: {
141
- * click: bind( 'elementClicked' ) // Will be fired by the observable.
142
- * },
143
- * children: [
144
- * 'Div text.'
145
- * ]
146
- * } ).apply( element );
147
- *
148
- * console.log( element.outerHTML ); // -> '<div id="first-div" class="my-div"></div>'
149
- * ```
150
- *
151
- * @see module:ui/template~Template#render
152
- * @see module:ui/template~Template#revert
153
- * @param node Root node for the template to apply.
154
- */
155
- apply(node: HTMLElement | Text): HTMLElement | Text;
156
- /**
157
- * Reverts a template {@link module:ui/template~Template#apply applied} to a DOM node.
158
- *
159
- * @param node The root node for the template to revert. In most of the cases, it is the
160
- * same node used by {@link module:ui/template~Template#apply}.
161
- */
162
- revert(node: HTMLElement | Text): void;
163
- /**
164
- * Returns an iterator which traverses the template in search of {@link module:ui/view~View}
165
- * instances and returns them one by one.
166
- *
167
- * ```ts
168
- * const viewFoo = new View();
169
- * const viewBar = new View();
170
- * const viewBaz = new View();
171
- * const template = new Template( {
172
- * tag: 'div',
173
- * children: [
174
- * viewFoo,
175
- * {
176
- * tag: 'div',
177
- * children: [
178
- * viewBar
179
- * ]
180
- * },
181
- * viewBaz
182
- * ]
183
- * } );
184
- *
185
- * // Logs: viewFoo, viewBar, viewBaz
186
- * for ( const view of template.getViews() ) {
187
- * console.log( view );
188
- * }
189
- * ```
190
- */
191
- getViews(): IterableIterator<View>;
192
- /**
193
- * An entry point to the interface which binds DOM nodes to
194
- * {@link module:utils/observablemixin~Observable observables}.
195
- * There are two types of bindings:
196
- *
197
- * * HTML element attributes or text `textContent` synchronized with attributes of an
198
- * {@link module:utils/observablemixin~Observable}. Learn more about {@link module:ui/template~BindChain#to}
199
- * and {@link module:ui/template~BindChain#if}.
200
- *
201
- * ```ts
202
- * const bind = Template.bind( observable, emitter );
203
- *
204
- * new Template( {
205
- * attributes: {
206
- * // Binds the element "class" attribute to observable#classAttribute.
207
- * class: bind.to( 'classAttribute' )
208
- * }
209
- * } ).render();
210
- * ```
211
- *
212
- * * DOM events fired on HTML element propagated through
213
- * {@link module:utils/observablemixin~Observable}. Learn more about {@link module:ui/template~BindChain#to}.
214
- *
215
- * ```ts
216
- * const bind = Template.bind( observable, emitter );
217
- *
218
- * new Template( {
219
- * on: {
220
- * // Will be fired by the observable.
221
- * click: bind( 'elementClicked' )
222
- * }
223
- * } ).render();
224
- * ```
225
- *
226
- * Also see {@link module:ui/view~View#bindTemplate}.
227
- *
228
- * @param observable An observable which provides boundable attributes.
229
- * @param emitter An emitter that listens to observable attribute
230
- * changes or DOM Events (depending on the kind of the binding). Usually, a {@link module:ui/view~View} instance.
231
- */
232
- static bind<TObservable extends Observable>(observable: TObservable, emitter: Emitter): BindChain<TObservable>;
233
- /**
234
- * Extends an existing {@link module:ui/template~Template} instance with some additional content
235
- * from another {@link module:ui/template~TemplateDefinition}.
236
- *
237
- * ```ts
238
- * const bind = Template.bind( observable, emitter );
239
- *
240
- * const template = new Template( {
241
- * tag: 'p',
242
- * attributes: {
243
- * class: 'a',
244
- * data-x: bind.to( 'foo' )
245
- * },
246
- * children: [
247
- * {
248
- * tag: 'span',
249
- * attributes: {
250
- * class: 'b'
251
- * },
252
- * children: [
253
- * 'Span'
254
- * ]
255
- * }
256
- * ]
257
- * } );
258
- *
259
- * // Instance-level extension.
260
- * Template.extend( template, {
261
- * attributes: {
262
- * class: 'b',
263
- * data-x: bind.to( 'bar' )
264
- * },
265
- * children: [
266
- * {
267
- * attributes: {
268
- * class: 'c'
269
- * }
270
- * }
271
- * ]
272
- * } );
273
- *
274
- * // Child extension.
275
- * Template.extend( template.children[ 0 ], {
276
- * attributes: {
277
- * class: 'd'
278
- * }
279
- * } );
280
- * ```
281
- *
282
- * the `outerHTML` of `template.render()` is:
283
- *
284
- * ```html
285
- * <p class="a b" data-x="{ observable.foo } { observable.bar }">
286
- * <span class="b c d">Span</span>
287
- * </p>
288
- * ```
289
- *
290
- * @param template An existing template instance to be extended.
291
- * @param def Additional definition to be applied to a template.
292
- */
293
- static extend(template: Template, def: Partial<TemplateDefinition>): void;
294
- /**
295
- * Renders a DOM Node (either an HTML element or text) out of the template.
296
- *
297
- * @param data Rendering data.
298
- */
299
- private _renderNode;
300
- /**
301
- * Renders an HTML element out of the template.
302
- *
303
- * @param data Rendering data.
304
- */
305
- private _renderElement;
306
- /**
307
- * Renders a text node out of {@link module:ui/template~Template#text}.
308
- *
309
- * @param data Rendering data.
310
- */
311
- private _renderText;
312
- /**
313
- * Renders HTML element attributes out of {@link module:ui/template~Template#attributes}.
314
- *
315
- * @param data Rendering data.
316
- */
317
- private _renderAttributes;
318
- /**
319
- * Renders the `style` attribute of an HTML element based on
320
- * {@link module:ui/template~Template#attributes}.
321
- *
322
- * A style attribute is an object with static values:
323
- *
324
- * ```ts
325
- * attributes: {
326
- * style: {
327
- * color: 'red'
328
- * }
329
- * }
330
- * ```
331
- *
332
- * or values bound to {@link module:ui/model~Model} properties:
333
- *
334
- * ```ts
335
- * attributes: {
336
- * style: {
337
- * color: bind.to( ... )
338
- * }
339
- * }
340
- * ```
341
- *
342
- * Note: The `style` attribute is rendered without setting the namespace. It does not seem to be
343
- * needed.
344
- *
345
- * @param styles Styles located in `attributes.style` of {@link module:ui/template~TemplateDefinition}.
346
- * @param data Rendering data.
347
- */
348
- private _renderStyleAttribute;
349
- /**
350
- * Recursively renders HTML element's children from {@link module:ui/template~Template#children}.
351
- *
352
- * @param data Rendering data.
353
- */
354
- private _renderElementChildren;
355
- /**
356
- * Activates `on` event listeners from the {@link module:ui/template~TemplateDefinition}
357
- * on an HTML element.
358
- *
359
- * @param data Rendering data.
360
- */
361
- private _setUpListeners;
362
- /**
363
- * For a given {@link module:ui/template~TemplateValueSchema} containing {@link module:ui/template~TemplateBinding}
364
- * activates the binding and sets its initial value.
365
- *
366
- * Note: {@link module:ui/template~TemplateValueSchema} can be for HTML element attributes or
367
- * text node `textContent`.
368
- *
369
- * @param options Binding options.
370
- * @param options.updater A function which updates the DOM (like attribute or text).
371
- * @param options.data Rendering data.
372
- */
373
- private _bindToObservable;
374
- /**
375
- * Reverts {@link module:ui/template~RenderData#revertData template data} from a node to
376
- * return it to the original state.
377
- *
378
- * @param node A node to be reverted.
379
- * @param revertData An object that stores information about what changes have been made by
380
- * {@link #apply} to the node. See {@link module:ui/template~RenderData#revertData} for more information.
381
- */
382
- private _revertTemplateFromNode;
383
- }
384
- type AttributeValues = Array<TemplateSimpleValue | TemplateBinding> | [
385
- NamespacedValue<Array<TemplateSimpleValue | TemplateBinding>>
386
- ];
387
- /**
388
- * Describes a binding created by the {@link module:ui/template~Template.bind} interface.
389
- *
390
- * @internal
391
- */
392
- export declare abstract class TemplateBinding {
393
- /**
394
- * The name of the {@link module:ui/template~TemplateBinding#observable observed attribute}.
395
- */
396
- readonly attribute: string;
397
- /**
398
- * An observable instance of the binding. It either:
399
- *
400
- * * provides the attribute with the value,
401
- * * or passes the event when a corresponding DOM event is fired.
402
- */
403
- readonly observable: Observable;
404
- /**
405
- * An {@link module:utils/emittermixin~Emitter} used by the binding to:
406
- *
407
- * * listen to the attribute change in the {@link module:ui/template~TemplateBinding#observable},
408
- * * or listen to the event in the DOM.
409
- */
410
- readonly emitter: Emitter;
411
- /**
412
- * A custom function to process the value of the {@link module:ui/template~TemplateBinding#attribute}.
413
- */
414
- readonly callback?: (value: any, node: Node) => TemplateSimpleValue;
415
- /**
416
- * Creates an instance of the {@link module:ui/template~TemplateBinding} class.
417
- *
418
- * @param def The definition of the binding.
419
- */
420
- constructor(def: {
421
- attribute: string;
422
- observable: Observable;
423
- emitter: Emitter;
424
- callback?: (value: any, node: Node) => TemplateSimpleValue;
425
- });
426
- /**
427
- * Returns the value of the binding. It is the value of the {@link module:ui/template~TemplateBinding#attribute} in
428
- * {@link module:ui/template~TemplateBinding#observable}. The value may be processed by the
429
- * {@link module:ui/template~TemplateBinding#callback}, if such has been passed to the binding.
430
- *
431
- * @param node A native DOM node, passed to the custom {@link module:ui/template~TemplateBinding#callback}.
432
- * @returns The value of {@link module:ui/template~TemplateBinding#attribute} in
433
- * {@link module:ui/template~TemplateBinding#observable}.
434
- */
435
- getValue(node: Node): TemplateSimpleValue;
436
- /**
437
- * Activates the listener which waits for changes of the {@link module:ui/template~TemplateBinding#attribute} in
438
- * {@link module:ui/template~TemplateBinding#observable}, then updates the DOM with the aggregated
439
- * value of {@link module:ui/template~TemplateValueSchema}.
440
- *
441
- * @param schema A full schema to generate an attribute or text in the DOM.
442
- * @param updater A DOM updater function used to update the native DOM attribute or text.
443
- * @param data Rendering data.
444
- * @returns A function to sever the listener binding.
445
- */
446
- activateAttributeListener(schema: Array<TemplateSimpleValue | TemplateBinding>, updater: Updater, data: RenderData): () => void;
447
- }
448
- /**
449
- * Describes either:
450
- *
451
- * * a binding to an {@link module:utils/observablemixin~Observable},
452
- * * or a native DOM event binding.
453
- *
454
- * It is created by the {@link module:ui/template~BindChain#to} method.
455
- *
456
- * @internal
457
- */
458
- export declare class TemplateToBinding extends TemplateBinding {
459
- readonly eventNameOrFunction: string | ((domEvent: Event) => void);
460
- constructor(def: ConstructorParameters<typeof TemplateBinding>[0] & {
461
- eventNameOrFunction: string | ((domEvent: Event) => void);
462
- });
463
- /**
464
- * Activates the listener for the native DOM event, which when fired, is propagated by
465
- * the {@link module:ui/template~TemplateBinding#emitter}.
466
- *
467
- * @param domEvtName The name of the native DOM event.
468
- * @param domSelector The selector in the DOM to filter delegated events.
469
- * @param data Rendering data.
470
- * @returns A function to sever the listener binding.
471
- */
472
- activateDomEventListener(domEvtName: string, domSelector: string, data: {
473
- node: any;
474
- }): () => void;
475
- }
476
- /**
477
- * Describes a binding to {@link module:utils/observablemixin~Observable} created by the {@link module:ui/template~BindChain#if}
478
- * method.
479
- *
480
- * @internal
481
- */
482
- export declare class TemplateIfBinding extends TemplateBinding {
483
- /**
484
- * The value of the DOM attribute or text to be set if the {@link module:ui/template~TemplateBinding#attribute} in
485
- * {@link module:ui/template~TemplateBinding#observable} is `true`.
486
- */
487
- readonly valueIfTrue?: string;
488
- constructor(def: ConstructorParameters<typeof TemplateBinding>[0] & {
489
- valueIfTrue?: string;
490
- });
491
- /**
492
- * @inheritDoc
493
- */
494
- getValue(node: Node): TemplateSimpleValue;
495
- }
496
- interface Updater {
497
- set(value: any): void;
498
- remove(): void;
499
- }
500
- /**
501
- * A definition of the {@link module:ui/template~Template}. It describes what kind of
502
- * node a template will render (HTML element or text), attributes of an element, DOM event
503
- * listeners and children.
504
- *
505
- * Also see:
506
- * * {@link module:ui/template~TemplateValueSchema} to learn about HTML element attributes,
507
- * * {@link module:ui/template~TemplateListenerSchema} to learn about DOM event listeners.
508
- *
509
- * A sample definition on an HTML element can look like this:
510
- *
511
- * ```ts
512
- * new Template( {
513
- * tag: 'p',
514
- * children: [
515
- * {
516
- * tag: 'span',
517
- * attributes: { ... },
518
- * children: [ ... ],
519
- * },
520
- * {
521
- * text: 'static–text'
522
- * },
523
- * 'also-static–text',
524
- * ],
525
- * attributes: {
526
- * class: {@link module:ui/template~TemplateValueSchema},
527
- * id: {@link module:ui/template~TemplateValueSchema},
528
- * style: {@link module:ui/template~TemplateValueSchema}
529
- *
530
- * // ...
531
- * },
532
- * on: {
533
- * 'click': {@link module:ui/template~TemplateListenerSchema}
534
- *
535
- * // Document.querySelector format is also accepted.
536
- * 'keyup@a.some-class': {@link module:ui/template~TemplateListenerSchema}
537
- *
538
- * // ...
539
- * }
540
- * } );
541
- * ```
542
- *
543
- * A {@link module:ui/view~View}, another {@link module:ui/template~Template} or a native DOM node
544
- * can also become a child of a template. When a view is passed, its {@link module:ui/view~View#element} is used:
545
- *
546
- * ```ts
547
- * const view = new SomeView();
548
- * const childTemplate = new Template( { ... } );
549
- * const childNode = document.createElement( 'b' );
550
- *
551
- * new Template( {
552
- * tag: 'p',
553
- *
554
- * children: [
555
- * // view#element will be added as a child of this <p>.
556
- * view,
557
- *
558
- * // The output of childTemplate.render() will be added here.
559
- * childTemplate,
560
- *
561
- * // Native DOM nodes are included directly in the rendered output.
562
- * childNode
563
- * ]
564
- * } );
565
- * ```
566
- *
567
- * An entire {@link module:ui/viewcollection~ViewCollection} can be used as a child in the definition:
568
- *
569
- * ```ts
570
- * const collection = new ViewCollection();
571
- * collection.add( someView );
572
- *
573
- * new Template( {
574
- * tag: 'p',
575
- *
576
- * children: collection
577
- * } );
578
- * ```
579
- */
580
- export type TemplateDefinition = string | Template | TemplateElementDefinition | TemplateTextDefinition;
581
- export type TemplateElementDefinition = {
582
- /**
583
- * See the template {@link module:ui/template~Template#tag} property.
584
- */
585
- tag: string;
586
- /**
587
- * See the template {@link module:ui/template~Template#attributes} property.
588
- */
589
- attributes?: Record<string, TemplateValueSchema>;
590
- /**
591
- * See the template {@link module:ui/template~Template#children} property.
592
- */
593
- children?: Iterable<View | Node | Template | TemplateDefinition>;
594
- /**
595
- * See the template {@link module:ui/template~Template#eventListeners} property.
596
- */
597
- on?: Record<string, TemplateListenerSchema>;
598
- };
599
- export type TemplateTextDefinition = {
600
- /**
601
- * See the template {@link module:ui/template~Template#text} property.
602
- */
603
- text: ArrayOrItem<TemplateSimpleValueSchema>;
604
- };
605
- export type FalsyValue = false | null | undefined | '';
606
- export type NamespacedValue<T> = {
607
- ns: string;
608
- value: T;
609
- };
610
- export type TemplateSimpleValue = string | boolean | number | null | undefined;
611
- export type TemplateSimpleValueSchema = TemplateSimpleValue | AttributeBinding;
612
- /**
613
- * Describes a value of an HTML element attribute or `textContent`. It allows combining multiple
614
- * data sources like static values and {@link module:utils/observablemixin~Observable} attributes.
615
- *
616
- * Also see:
617
- * * {@link module:ui/template~TemplateDefinition} to learn where to use it,
618
- * * {@link module:ui/template~Template.bind} to learn how to configure
619
- * {@link module:utils/observablemixin~Observable} attribute bindings,
620
- * * {@link module:ui/template~Template#render} to learn how to render a template,
621
- * * {@link module:ui/template~BindChain#to `to()`} and {@link module:ui/template~BindChain#if `if()`}
622
- * methods to learn more about bindings.
623
- *
624
- * Attribute values can be described in many different ways:
625
- *
626
- * ```ts
627
- * // Bind helper will create bindings to attributes of the observable.
628
- * const bind = Template.bind( observable, emitter );
629
- *
630
- * new Template( {
631
- * tag: 'p',
632
- * attributes: {
633
- * // A plain string schema.
634
- * 'class': 'static-text',
635
- *
636
- * // An object schema, binds to the "foo" attribute of the
637
- * // observable and follows its value.
638
- * 'class': bind.to( 'foo' ),
639
- *
640
- * // An array schema, combines the above.
641
- * 'class': [
642
- * 'static-text',
643
- * bind.to( 'bar', () => { ... } ),
644
- *
645
- * // Bindings can also be conditional.
646
- * bind.if( 'baz', 'class-when-baz-is-true' )
647
- * ],
648
- *
649
- * // An array schema, with a custom namespace, e.g. useful for creating SVGs.
650
- * 'class': {
651
- * ns: 'http://ns.url',
652
- * value: [
653
- * bind.if( 'baz', 'value-when-true' ),
654
- * 'static-text'
655
- * ]
656
- * },
657
- *
658
- * // An object schema, specific for styles.
659
- * style: {
660
- * color: 'red',
661
- * backgroundColor: bind.to( 'qux', () => { ... } )
662
- * }
663
- * }
664
- * } );
665
- * ```
666
- *
667
- * Text nodes can also have complex values:
668
- *
669
- * ```ts
670
- * const bind = Template.bind( observable, emitter );
671
- *
672
- * // Will render a "foo" text node.
673
- * new Template( {
674
- * text: 'foo'
675
- * } );
676
- *
677
- * // Will render a "static text: {observable.foo}" text node.
678
- * // The text of the node will be updated as the "foo" attribute changes.
679
- * new Template( {
680
- * text: [
681
- * 'static text: ',
682
- * bind.to( 'foo', () => { ... } )
683
- * ]
684
- * } );
685
- * ```
686
- */
687
- export type TemplateValueSchema = ArrayOrItem<TemplateSimpleValueSchema | NamespacedValue<TemplateSimpleValueSchema>> | Record<string, TemplateSimpleValueSchema>;
688
- /**
689
- * Describes an event listener attached to an HTML element. Such listener can propagate DOM events
690
- * through an {@link module:utils/observablemixin~Observable} instance, execute custom callbacks
691
- * or both, if necessary.
692
- *
693
- * Also see:
694
- * * {@link module:ui/template~TemplateDefinition} to learn more about template definitions,
695
- * * {@link module:ui/template~BindChain#to `to()`} method to learn more about bindings.
696
- *
697
- * Check out different ways of attaching event listeners below:
698
- *
699
- * ```ts
700
- * // Bind helper will propagate events through the observable.
701
- * const bind = Template.bind( observable, emitter );
702
- *
703
- * new Template( {
704
- * tag: 'p',
705
- * on: {
706
- * // An object schema. The observable will fire the "clicked" event upon DOM "click".
707
- * click: bind.to( 'clicked' )
708
- *
709
- * // An object schema. It will work for "click" event on "a.foo" children only.
710
- * 'click@a.foo': bind.to( 'clicked' )
711
- *
712
- * // An array schema, makes the observable propagate multiple events.
713
- * click: [
714
- * bind.to( 'clicked' ),
715
- * bind.to( 'executed' )
716
- * ],
717
- *
718
- * // An array schema with a custom callback.
719
- * 'click@a.foo': {
720
- * bind.to( 'clicked' ),
721
- * bind.to( evt => {
722
- * console.log( `${ evt.target } has been clicked!` );
723
- * } }
724
- * }
725
- * }
726
- * } );
727
- * ```
728
- */
729
- export type TemplateListenerSchema = ArrayOrItem<ListenerBinding>;
730
- declare const AttributeBindingSymbol: unique symbol;
731
- declare const ListenerBindingSymbol: unique symbol;
732
- export interface AttributeBinding {
733
- _opaqueAttributeBinding: typeof AttributeBindingSymbol;
734
- }
735
- export interface ListenerBinding {
736
- _opaqueListenerBinding: typeof ListenerBindingSymbol;
737
- }
738
- /**
739
- * The return value of {@link ~Template.bind `Template.bind()`}. It provides `to()` and `if()`
740
- * methods to create the {@link module:utils/observablemixin~Observable observable} attribute and event bindings.
741
- */
742
- export interface BindChain<TObservable> {
743
- /**
744
- * Binds an {@link module:utils/observablemixin~Observable observable} to either:
745
- *
746
- * * an HTML element attribute or a text node `textContent`, so it remains in sync with the observable
747
- * attribute as it changes,
748
- * * or an HTML element DOM event, so the DOM events are propagated through an observable.
749
- *
750
- * Some common use cases of `to()` bindings are presented below:
751
- *
752
- * ```ts
753
- * const bind = Template.bind( observable, emitter );
754
- *
755
- * new Template( {
756
- * tag: 'p',
757
- * attributes: {
758
- * // class="..." attribute gets bound to `observable#a`
759
- * class: bind.to( 'a' )
760
- * },
761
- * children: [
762
- * // <p>...</p> gets bound to observable#b; always `toUpperCase()`.
763
- * {
764
- * text: bind.to( 'b', ( value, node ) => value.toUpperCase() )
765
- * }
766
- * ],
767
- * on: {
768
- * click: [
769
- * // An observable will fire "clicked" upon "click" in the DOM.
770
- * bind.to( 'clicked' ),
771
- *
772
- * // A custom callback will be executed upon "click" in the DOM.
773
- * bind.to( () => {
774
- * ...
775
- * } )
776
- * ]
777
- * }
778
- * } ).render();
779
- * ```
780
- *
781
- * Learn more about using `to()` in the {@link module:ui/template~TemplateValueSchema} and
782
- * {@link module:ui/template~TemplateListenerSchema}.
783
- *
784
- * @label ATTRIBUTE
785
- * @param attribute An attribute name of {@link module:utils/observablemixin~Observable}.
786
- */
787
- to<TAttribute extends keyof TObservable & string>(attribute: TAttribute): AttributeBinding & ListenerBinding;
788
- /**
789
- * Binds an {@link module:utils/observablemixin~Observable observable} to either:
790
- *
791
- * * an HTML element attribute or a text node `textContent`, so it remains in sync with the observable
792
- * attribute as it changes,
793
- * * or an HTML element DOM event, so the DOM events are propagated through an observable.
794
- *
795
- * Some common use cases of `to()` bindings are presented below:
796
- *
797
- * ```ts
798
- * const bind = Template.bind( observable, emitter );
799
- *
800
- * new Template( {
801
- * tag: 'p',
802
- * attributes: {
803
- * // class="..." attribute gets bound to `observable#a`
804
- * class: bind.to( 'a' )
805
- * },
806
- * children: [
807
- * // <p>...</p> gets bound to observable#b; always `toUpperCase()`.
808
- * {
809
- * text: bind.to( 'b', ( value, node ) => value.toUpperCase() )
810
- * }
811
- * ],
812
- * on: {
813
- * click: [
814
- * // An observable will fire "clicked" upon "click" in the DOM.
815
- * bind.to( 'clicked' ),
816
- *
817
- * // A custom callback will be executed upon "click" in the DOM.
818
- * bind.to( () => {
819
- * ...
820
- * } )
821
- * ]
822
- * }
823
- * } ).render();
824
- * ```
825
- *
826
- * Learn more about using `to()` in the {@link module:ui/template~TemplateValueSchema} and
827
- * {@link module:ui/template~TemplateListenerSchema}.
828
- *
829
- * @label ATTRIBUTE_CALLBACK
830
- * @param attribute An attribute name of {@link module:utils/observablemixin~Observable}.
831
- * @param callback Allows for processing of the value. Accepts `Node` and `value` as arguments.
832
- */
833
- to<TAttribute extends keyof TObservable & string>(attribute: TAttribute, callback: (value: TObservable[TAttribute], node: Node) => (TemplateSimpleValue)): AttributeBinding;
834
- /**
835
- * Binds an {@link module:utils/observablemixin~Observable observable} to either:
836
- *
837
- * * an HTML element attribute or a text node `textContent`, so it remains in sync with the observable
838
- * attribute as it changes,
839
- * * or an HTML element DOM event, so the DOM events are propagated through an observable.
840
- *
841
- * Some common use cases of `to()` bindings are presented below:
842
- *
843
- * ```ts
844
- * const bind = Template.bind( observable, emitter );
845
- *
846
- * new Template( {
847
- * tag: 'p',
848
- * attributes: {
849
- * // class="..." attribute gets bound to `observable#a`
850
- * class: bind.to( 'a' )
851
- * },
852
- * children: [
853
- * // <p>...</p> gets bound to observable#b; always `toUpperCase()`.
854
- * {
855
- * text: bind.to( 'b', ( value, node ) => value.toUpperCase() )
856
- * }
857
- * ],
858
- * on: {
859
- * click: [
860
- * // An observable will fire "clicked" upon "click" in the DOM.
861
- * bind.to( 'clicked' ),
862
- *
863
- * // A custom callback will be executed upon "click" in the DOM.
864
- * bind.to( () => {
865
- * ...
866
- * } )
867
- * ]
868
- * }
869
- * } ).render();
870
- * ```
871
- *
872
- * Learn more about using `to()` in the {@link module:ui/template~TemplateValueSchema} and
873
- * {@link module:ui/template~TemplateListenerSchema}.
874
- *
875
- * @label EVENT
876
- * @param eventNameOrCallback A DOM event name or an event callback.
877
- */
878
- to(eventNameOrCallback: string | ((domEvent: Event) => void)): ListenerBinding;
879
- /**
880
- * Binds an {@link module:utils/observablemixin~Observable observable} to an HTML element attribute or a text
881
- * node `textContent` so it remains in sync with the observable attribute as it changes.
882
- *
883
- * Unlike {@link module:ui/template~BindChain#to}, it controls the presence of the attribute or `textContent`
884
- * depending on the "falseness" of an {@link module:utils/observablemixin~Observable} attribute.
885
- *
886
- * ```ts
887
- * const bind = Template.bind( observable, emitter );
888
- *
889
- * new Template( {
890
- * tag: 'input',
891
- * attributes: {
892
- * // <input checked> when `observable#a` is not undefined/null/false/''
893
- * // <input> when `observable#a` is undefined/null/false
894
- * checked: bind.if( 'a' )
895
- * },
896
- * children: [
897
- * {
898
- * // <input>"b-is-not-set"</input> when `observable#b` is undefined/null/false/''
899
- * // <input></input> when `observable#b` is not "falsy"
900
- * text: bind.if( 'b', 'b-is-not-set', ( value, node ) => !value )
901
- * }
902
- * ]
903
- * } ).render();
904
- * ```
905
- *
906
- * Learn more about using `if()` in the {@link module:ui/template~TemplateValueSchema}.
907
- *
908
- * @param attribute An attribute name of {@link module:utils/observablemixin~Observable} used in the binding.
909
- * @param valueIfTrue Value set when the {@link module:utils/observablemixin~Observable} attribute is not
910
- * undefined/null/false/'' (empty string).
911
- * @param callback Allows for processing of the value. Accepts `Node` and `value` as arguments.
912
- */
913
- if<TAttribute extends keyof TObservable & string>(attribute: TAttribute, valueIfTrue?: unknown, callback?: (value: TObservable[TAttribute], node: Node) => (boolean | FalsyValue)): AttributeBinding;
914
- }
915
- /**
916
- * The {@link module:ui/template~Template#_renderNode} configuration.
917
- */
918
- export interface RenderData {
919
- /**
920
- * A node which is being rendered.
921
- */
922
- node: HTMLElement | Text;
923
- /**
924
- * Tells {@link module:ui/template~Template#_renderNode} to render
925
- * children into `DocumentFragment` first and then append the fragment
926
- * to the parent element. It is a speed optimization.
927
- */
928
- intoFragment: boolean;
929
- /**
930
- * Indicates whether the {@link #node} has been provided by {@link module:ui/template~Template#apply}.
931
- */
932
- isApplying: boolean;
933
- /**
934
- * An object storing the data that helps {@link module:ui/template~Template#revert}
935
- * bringing back an element to its initial state, i.e. before
936
- * {@link module:ui/template~Template#apply} was called.
937
- */
938
- revertData?: RevertData;
939
- }
940
- interface RevertData {
941
- text?: string | null;
942
- children: Array<RevertData>;
943
- bindings: Array<Array<() => void>>;
944
- attributes: Record<string, string | null>;
945
- }
946
- export {};