@schukai/monster 3.65.0 → 3.65.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (383) hide show
  1. package/CHANGELOG.md +82 -327
  2. package/README.md +44 -40
  3. package/package.json +1 -48
  4. package/source/components/constants.mjs +10 -3
  5. package/source/components/datatable/change-button.mjs +12 -5
  6. package/source/components/datatable/columnbar.mjs +10 -1
  7. package/source/components/datatable/constants.mjs +11 -4
  8. package/source/components/datatable/dataset.mjs +10 -1
  9. package/source/components/datatable/datasource/dom.mjs +14 -1
  10. package/source/components/datatable/datasource/rest.mjs +10 -1
  11. package/source/components/datatable/datasource.mjs +10 -1
  12. package/source/components/datatable/datatable/header.mjs +220 -218
  13. package/source/components/datatable/datatable.mjs +757 -752
  14. package/source/components/datatable/embedded-pagination.mjs +10 -1
  15. package/source/components/datatable/filter/abstract-base.mjs +10 -1
  16. package/source/components/datatable/filter/date-range.mjs +10 -1
  17. package/source/components/datatable/filter/input.mjs +10 -1
  18. package/source/components/datatable/filter/range.mjs +10 -1
  19. package/source/components/datatable/filter/select.mjs +11 -4
  20. package/source/components/datatable/filter/settings.mjs +14 -0
  21. package/source/components/datatable/filter/util.mjs +14 -0
  22. package/source/components/datatable/filter-button.mjs +10 -1
  23. package/source/components/datatable/filter.mjs +11 -3
  24. package/source/components/datatable/pagination.mjs +14 -5
  25. package/source/components/datatable/save-button.mjs +279 -270
  26. package/source/components/datatable/status.mjs +10 -1
  27. package/source/components/datatable/stylesheet/change-button.mjs +16 -7
  28. package/source/components/datatable/stylesheet/column-bar.mjs +16 -7
  29. package/source/components/datatable/stylesheet/dataset.mjs +16 -7
  30. package/source/components/datatable/stylesheet/datasource.mjs +16 -7
  31. package/source/components/datatable/stylesheet/datatable.mjs +16 -7
  32. package/source/components/datatable/stylesheet/embedded-pagination.mjs +16 -7
  33. package/source/components/datatable/stylesheet/filter-button.mjs +16 -7
  34. package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +16 -7
  35. package/source/components/datatable/stylesheet/filter-date-range.mjs +16 -7
  36. package/source/components/datatable/stylesheet/filter-range.mjs +16 -7
  37. package/source/components/datatable/stylesheet/filter.mjs +16 -7
  38. package/source/components/datatable/stylesheet/pagination.mjs +16 -7
  39. package/source/components/datatable/stylesheet/save-button.mjs +16 -7
  40. package/source/components/datatable/stylesheet/select-filter.mjs +16 -7
  41. package/source/components/datatable/stylesheet/status.mjs +16 -7
  42. package/source/components/datatable/util.mjs +16 -8
  43. package/source/components/form/action-button.mjs +11 -3
  44. package/source/components/form/api-button.mjs +11 -3
  45. package/source/components/form/button-bar.mjs +11 -3
  46. package/source/components/form/button.mjs +254 -249
  47. package/source/components/form/confirm-button.mjs +11 -3
  48. package/source/components/form/constants.mjs +10 -3
  49. package/source/components/form/context-error.mjs +69 -52
  50. package/source/components/form/context-help.mjs +11 -3
  51. package/source/components/form/field-set.mjs +10 -15
  52. package/source/components/form/form.mjs +12 -4
  53. package/source/components/form/message-state-button.mjs +11 -3
  54. package/source/components/form/popper-button.mjs +11 -3
  55. package/source/components/form/popper.mjs +6 -6
  56. package/source/components/form/reload.mjs +12 -4
  57. package/source/components/form/select.mjs +44 -33
  58. package/source/components/form/shadow-reload.mjs +11 -3
  59. package/source/components/form/state-button.mjs +11 -3
  60. package/source/components/form/stylesheet/action-button.mjs +16 -7
  61. package/source/components/form/stylesheet/api-button.mjs +16 -7
  62. package/source/components/form/stylesheet/button-bar.mjs +16 -7
  63. package/source/components/form/stylesheet/button.mjs +16 -7
  64. package/source/components/form/stylesheet/confirm-button.mjs +16 -7
  65. package/source/components/form/stylesheet/context-error.mjs +16 -7
  66. package/source/components/form/stylesheet/context-help.mjs +16 -7
  67. package/source/components/form/stylesheet/field-set.mjs +16 -7
  68. package/source/components/form/stylesheet/form.mjs +16 -7
  69. package/source/components/form/stylesheet/message-state-button.mjs +16 -7
  70. package/source/components/form/stylesheet/popper-button.mjs +16 -7
  71. package/source/components/form/stylesheet/select.mjs +16 -7
  72. package/source/components/form/stylesheet/state-button.mjs +16 -7
  73. package/source/components/form/stylesheet/toggle-switch.mjs +16 -7
  74. package/source/components/form/stylesheet/tree-select.mjs +16 -7
  75. package/source/components/form/tabs.mjs +12 -8
  76. package/source/components/form/template.mjs +11 -3
  77. package/source/components/form/toggle-switch.mjs +12 -8
  78. package/source/components/form/tree-select.mjs +10 -3
  79. package/source/components/form/types/state.mjs +10 -3
  80. package/source/components/form/util/fetch.mjs +10 -3
  81. package/source/components/form/util/floating-ui.mjs +10 -3
  82. package/source/components/form/util/popper.mjs +10 -3
  83. package/source/components/host/call-button.mjs +10 -1
  84. package/source/components/host/collapse.mjs +4 -6
  85. package/source/components/host/config-manager.mjs +2 -0
  86. package/source/components/host/constants.mjs +2 -0
  87. package/source/components/host/details.mjs +5 -8
  88. package/source/components/host/host.mjs +10 -1
  89. package/source/components/host/overlay.mjs +10 -1
  90. package/source/components/host/stylesheet/call-button.mjs +16 -7
  91. package/source/components/host/stylesheet/config-manager.mjs +16 -7
  92. package/source/components/host/stylesheet/host.mjs +16 -7
  93. package/source/components/host/stylesheet/overlay.mjs +16 -7
  94. package/source/components/host/stylesheet/toggle-button.mjs +16 -7
  95. package/source/components/host/stylesheet/viewer.mjs +16 -7
  96. package/source/components/host/toggle-button.mjs +10 -1
  97. package/source/components/host/util.mjs +14 -0
  98. package/source/components/host/viewer.mjs +10 -1
  99. package/source/components/layout/collapse.mjs +4 -3
  100. package/source/components/layout/details.mjs +2 -0
  101. package/source/components/layout/panel.mjs +179 -169
  102. package/source/components/layout/popper.mjs +324 -320
  103. package/source/components/layout/split-panel.mjs +329 -303
  104. package/source/components/layout/stylesheet/collapse.mjs +16 -7
  105. package/source/components/layout/stylesheet/details.mjs +16 -7
  106. package/source/components/layout/stylesheet/panel.mjs +16 -7
  107. package/source/components/layout/stylesheet/popper.mjs +16 -7
  108. package/source/components/layout/stylesheet/split-panel.mjs +16 -7
  109. package/source/components/layout/stylesheet/tabs.mjs +16 -7
  110. package/source/components/layout/stylesheet/width-toggle.mjs +16 -7
  111. package/source/components/layout/tabs.mjs +39 -24
  112. package/source/components/layout/width-toggle.mjs +148 -138
  113. package/source/components/navigation/style/table-of-content.pcss +20 -5
  114. package/source/components/navigation/stylesheet/table-of-content.mjs +17 -8
  115. package/source/components/navigation/table-of-content.mjs +394 -266
  116. package/source/components/notify/constants.mjs +10 -3
  117. package/source/components/notify/message.mjs +16 -9
  118. package/source/components/notify/notify.mjs +11 -4
  119. package/source/components/notify/stylesheet/message.mjs +16 -7
  120. package/source/components/notify/stylesheet/notify.mjs +16 -7
  121. package/source/components/state/log/entry.mjs +10 -1
  122. package/source/components/state/log.mjs +10 -1
  123. package/source/components/state/state.mjs +10 -1
  124. package/source/components/state/stylesheet/log.mjs +16 -7
  125. package/source/components/state/stylesheet/state.mjs +16 -7
  126. package/source/components/style/mixin/form.pcss +0 -1
  127. package/source/components/stylesheet/badge.mjs +16 -7
  128. package/source/components/stylesheet/border.mjs +16 -7
  129. package/source/components/stylesheet/button.mjs +16 -7
  130. package/source/components/stylesheet/card.mjs +16 -7
  131. package/source/components/stylesheet/color.mjs +16 -7
  132. package/source/components/stylesheet/common.mjs +16 -7
  133. package/source/components/stylesheet/control.mjs +16 -7
  134. package/source/components/stylesheet/data-grid.mjs +16 -7
  135. package/source/components/stylesheet/display.mjs +16 -7
  136. package/source/components/stylesheet/floating-ui.mjs +16 -7
  137. package/source/components/stylesheet/form.mjs +16 -7
  138. package/source/components/stylesheet/host.mjs +16 -7
  139. package/source/components/stylesheet/icons.mjs +16 -7
  140. package/source/components/stylesheet/link.mjs +16 -7
  141. package/source/components/stylesheet/mixin/badge.mjs +16 -7
  142. package/source/components/stylesheet/mixin/button.mjs +16 -7
  143. package/source/components/stylesheet/mixin/form.mjs +16 -7
  144. package/source/components/stylesheet/mixin/hover.mjs +16 -7
  145. package/source/components/stylesheet/mixin/icon.mjs +16 -7
  146. package/source/components/stylesheet/mixin/media.mjs +16 -7
  147. package/source/components/stylesheet/mixin/property.mjs +16 -7
  148. package/source/components/stylesheet/mixin/skeleton.mjs +16 -7
  149. package/source/components/stylesheet/mixin/spinner.mjs +16 -7
  150. package/source/components/stylesheet/mixin/typography.mjs +16 -7
  151. package/source/components/stylesheet/normalize.mjs +16 -7
  152. package/source/components/stylesheet/popper.mjs +16 -7
  153. package/source/components/stylesheet/property.mjs +16 -7
  154. package/source/components/stylesheet/ripple.mjs +16 -7
  155. package/source/components/stylesheet/skeleton.mjs +16 -7
  156. package/source/components/stylesheet/space.mjs +16 -7
  157. package/source/components/stylesheet/spinner.mjs +16 -7
  158. package/source/components/stylesheet/table.mjs +16 -7
  159. package/source/components/stylesheet/theme.mjs +16 -7
  160. package/source/components/stylesheet/tree-menu.mjs +10 -3
  161. package/source/components/stylesheet/typography.mjs +16 -7
  162. package/source/components/tree-menu/stylesheet/tree-menu.mjs +16 -7
  163. package/source/components/tree-menu/tree-menu.mjs +19 -8
  164. package/source/constants.mjs +10 -6
  165. package/source/constraints/abstract.mjs +10 -3
  166. package/source/constraints/abstractoperator.mjs +10 -3
  167. package/source/constraints/andoperator.mjs +10 -3
  168. package/source/constraints/invalid.mjs +10 -3
  169. package/source/constraints/isarray.mjs +10 -3
  170. package/source/constraints/isobject.mjs +10 -3
  171. package/source/constraints/oroperator.mjs +10 -3
  172. package/source/constraints/valid.mjs +10 -3
  173. package/source/data/buildmap.mjs +10 -3
  174. package/source/data/buildtree.mjs +10 -3
  175. package/source/data/datasource/dom.mjs +10 -3
  176. package/source/data/datasource/server/restapi/data-fetch-error.mjs +10 -3
  177. package/source/data/datasource/server/restapi/writeerror.mjs +10 -3
  178. package/source/data/datasource/server/restapi.mjs +10 -3
  179. package/source/data/datasource/server/webconnect.mjs +10 -3
  180. package/source/data/datasource/server.mjs +10 -3
  181. package/source/data/datasource/storage/localstorage.mjs +10 -3
  182. package/source/data/datasource/storage/sessionstorage.mjs +10 -3
  183. package/source/data/datasource/storage.mjs +10 -3
  184. package/source/data/datasource.mjs +10 -3
  185. package/source/data/diff.mjs +10 -3
  186. package/source/data/extend.mjs +10 -3
  187. package/source/data/pathfinder.mjs +10 -3
  188. package/source/data/pipe.mjs +10 -3
  189. package/source/data/transformer.mjs +34 -10
  190. package/source/dom/assembler.mjs +10 -3
  191. package/source/dom/attributes.mjs +10 -3
  192. package/source/dom/constants.mjs +10 -3
  193. package/source/dom/customcontrol.mjs +11 -4
  194. package/source/dom/customelement.mjs +31 -17
  195. package/source/dom/dimension.mjs +10 -3
  196. package/source/dom/events.mjs +10 -3
  197. package/source/dom/focusmanager.mjs +10 -3
  198. package/source/dom/locale.mjs +10 -3
  199. package/source/dom/ready.mjs +2 -1
  200. package/source/dom/resource/data.mjs +10 -3
  201. package/source/dom/resource/link/stylesheet.mjs +10 -3
  202. package/source/dom/resource/link.mjs +10 -3
  203. package/source/dom/resource/script.mjs +10 -3
  204. package/source/dom/resource.mjs +10 -3
  205. package/source/dom/resourcemanager.mjs +10 -3
  206. package/source/dom/slotted.mjs +14 -0
  207. package/source/dom/template.mjs +124 -136
  208. package/source/dom/theme.mjs +10 -3
  209. package/source/dom/updater.mjs +10 -3
  210. package/source/dom/util/extract-keys.mjs +10 -3
  211. package/source/dom/util/init-options-from-attributes.mjs +68 -61
  212. package/source/dom/util/set-option-from-attribute.mjs +10 -3
  213. package/source/dom/util.mjs +11 -4
  214. package/source/dom/worker/factory.mjs +10 -3
  215. package/source/i18n/formatter.mjs +10 -3
  216. package/source/i18n/locale.mjs +10 -3
  217. package/source/i18n/provider.mjs +10 -3
  218. package/source/i18n/providers/embed.mjs +10 -3
  219. package/source/i18n/providers/fetch.mjs +10 -3
  220. package/source/i18n/translations.mjs +10 -3
  221. package/source/logging/handler/console.mjs +10 -3
  222. package/source/logging/handler.mjs +10 -3
  223. package/source/logging/logentry.mjs +10 -3
  224. package/source/logging/logger.mjs +10 -3
  225. package/source/math/random.mjs +10 -3
  226. package/source/monster.mjs +3 -9
  227. package/source/net/webconnect/message.mjs +10 -3
  228. package/source/net/webconnect.mjs +20 -5
  229. package/source/text/bracketed-key-value-hash.mjs +10 -3
  230. package/source/text/formatter.mjs +10 -3
  231. package/source/text/generate-range-comparison-expression.mjs +10 -3
  232. package/source/text/util.mjs +14 -0
  233. package/source/types/base.mjs +10 -3
  234. package/source/types/basewithoptions.mjs +10 -3
  235. package/source/types/binary.mjs +10 -3
  236. package/source/types/dataurl.mjs +10 -3
  237. package/source/types/global.mjs +14 -7
  238. package/source/types/id.mjs +10 -3
  239. package/source/types/internal.mjs +11 -3
  240. package/source/types/is.mjs +10 -3
  241. package/source/types/mediatype.mjs +10 -3
  242. package/source/types/node.mjs +10 -3
  243. package/source/types/nodelist.mjs +10 -3
  244. package/source/types/noderecursiveiterator.mjs +10 -3
  245. package/source/types/observablequeue.mjs +10 -3
  246. package/source/types/observer.mjs +10 -3
  247. package/source/types/observerlist.mjs +10 -3
  248. package/source/types/proxyobserver.mjs +10 -3
  249. package/source/types/queue.mjs +10 -3
  250. package/source/types/randomid.mjs +10 -3
  251. package/source/types/regex.mjs +10 -3
  252. package/source/types/stack.mjs +10 -3
  253. package/source/types/tokenlist.mjs +10 -3
  254. package/source/types/typeof.mjs +10 -3
  255. package/source/types/uniquequeue.mjs +10 -3
  256. package/source/types/uuid.mjs +10 -3
  257. package/source/types/validate.mjs +10 -3
  258. package/source/types/version.mjs +10 -3
  259. package/source/util/clone.mjs +10 -3
  260. package/source/util/comparator.mjs +10 -3
  261. package/source/util/deadmansswitch.mjs +10 -3
  262. package/source/util/freeze.mjs +10 -3
  263. package/source/util/processing.mjs +10 -3
  264. package/source/util/runtime.mjs +10 -7
  265. package/source/util/sleep.mjs +10 -10
  266. package/source/util/trimspaces.mjs +10 -3
  267. package/test/cases/data/datasource/server/websocket.mjs +7 -9
  268. package/test/cases/data/transformer.mjs +47 -15
  269. package/test/cases/dom/customcontrol.mjs +0 -1
  270. package/test/cases/dom/customelement.mjs +1 -3
  271. package/test/cases/dom/template.mjs +3 -1
  272. package/test/util/jsdom.mjs +8 -7
  273. package/test/util/websocket.mjs +5 -1
  274. package/test/web/import.js +2 -1
  275. package/test/web/puppeteer.mjs +111 -0
  276. package/test/web/test.html +2 -2
  277. package/test/web/tests.js +2036 -1189
  278. package/example/components/form/button.mjs +0 -10
  279. package/example/components/form/field-set.mjs +0 -4
  280. package/example/components/form/select.mjs +0 -25
  281. package/example/components/form/toggle-switch.mjs +0 -7
  282. package/example/components/form/tree-select.mjs +0 -27
  283. package/example/components/host/host.mjs +0 -0
  284. package/example/components/notify/message.mjs +0 -4
  285. package/example/components/notify/notify.mjs +0 -4
  286. package/example/components/state/log.mjs +0 -0
  287. package/example/components/state/state.mjs +0 -0
  288. package/example/constraints/andoperator.mjs +0 -17
  289. package/example/constraints/invalid.mjs +0 -6
  290. package/example/constraints/isarray.mjs +0 -11
  291. package/example/constraints/isobject.mjs +0 -12
  292. package/example/constraints/oroperator.mjs +0 -15
  293. package/example/constraints/valid.mjs +0 -6
  294. package/example/data/buildmap.mjs +0 -67
  295. package/example/data/datasource/server/restapi.mjs +0 -20
  296. package/example/data/datasource/server/webconnect.mjs +0 -9
  297. package/example/data/datasource.mjs +0 -7
  298. package/example/data/diff.mjs +0 -39
  299. package/example/data/pathfinder-1.mjs +0 -23
  300. package/example/data/pathfinder-2.mjs +0 -19
  301. package/example/data/pipe.mjs +0 -14
  302. package/example/data/transformer.mjs +0 -9
  303. package/example/dom/customelement.mjs +0 -14
  304. package/example/dom/theme.mjs +0 -5
  305. package/example/dom/updater.mjs +0 -23
  306. package/example/i18n/formatter.mjs +0 -10
  307. package/example/i18n/providers/embed.mjs +0 -5
  308. package/example/i18n/providers/fetch.mjs +0 -5
  309. package/example/i18n/translations.mjs +0 -20
  310. package/example/net/webconnect.mjs +0 -16
  311. package/example/types/basewithoptions.mjs +0 -10
  312. package/example/types/is-1.mjs +0 -5
  313. package/example/types/is-10.mjs +0 -6
  314. package/example/types/is-2.mjs +0 -4
  315. package/example/types/is-3.mjs +0 -4
  316. package/example/types/is-4.mjs +0 -5
  317. package/example/types/is-5.mjs +0 -4
  318. package/example/types/is-6.mjs +0 -4
  319. package/example/types/is-7.mjs +0 -4
  320. package/example/types/is-8.mjs +0 -4
  321. package/example/types/is-9.mjs +0 -6
  322. package/example/types/noderecursiveiterator.mjs +0 -32
  323. package/example/types/observer.mjs +0 -9
  324. package/example/types/proxyobserver.mjs +0 -25
  325. package/example/types/queue.mjs +0 -20
  326. package/example/types/tokenlist-1.mjs +0 -4
  327. package/example/types/tokenlist-2.mjs +0 -7
  328. package/example/types/tokenlist-3.mjs +0 -5
  329. package/example/types/tokenlist-4.mjs +0 -5
  330. package/example/types/tokenlist-5.mjs +0 -5
  331. package/example/types/typeof.mjs +0 -9
  332. package/example/types/version-1.mjs +0 -6
  333. package/example/types/version-2.mjs +0 -3
  334. package/example/util/comparator.mjs +0 -10
  335. package/example/util/deadmansswitch.mjs +0 -9
  336. package/example/util/processing.mjs +0 -17
  337. package/source/components/datatable/datasource/namespace.mjs +0 -13
  338. package/source/components/datatable/datatable/namespace.mjs +0 -13
  339. package/source/components/datatable/events.mjs +0 -24
  340. package/source/components/datatable/filter/namespace.mjs +0 -13
  341. package/source/components/datatable/namespace.mjs +0 -11
  342. package/source/components/datatable/stylesheet/namespace.mjs +0 -13
  343. package/source/components/events.mjs +0 -17
  344. package/source/components/form/events.mjs +0 -108
  345. package/source/components/form/namespace.mjs +0 -13
  346. package/source/components/form/stylesheet/namespace.mjs +0 -13
  347. package/source/components/form/types/namespace.mjs +0 -13
  348. package/source/components/form/util/namespace.mjs +0 -13
  349. package/source/components/host/events.mjs +0 -131
  350. package/source/components/host/namespace.mjs +0 -13
  351. package/source/components/host/stylesheet/namespace.mjs +0 -13
  352. package/source/components/layout/events.mjs +0 -30
  353. package/source/components/layout/namespace.mjs +0 -13
  354. package/source/components/namespace.mjs +0 -14
  355. package/source/components/notify/events.mjs +0 -15
  356. package/source/components/notify/namespace.mjs +0 -15
  357. package/source/components/notify/stylesheet/namespace.mjs +0 -15
  358. package/source/components/state/log/namespace.mjs +0 -13
  359. package/source/components/state/namespace.mjs +0 -13
  360. package/source/components/stylesheet/namespace.mjs +0 -13
  361. package/source/components/tree-menu/namespace.mjs +0 -13
  362. package/source/components/tree-menu/stylesheet/namespace.mjs +0 -13
  363. package/source/constraints/namespace.mjs +0 -13
  364. package/source/data/datasource/namespace.mjs +0 -13
  365. package/source/data/datasource/server/namespace.mjs +0 -13
  366. package/source/data/datasource/server/restapi/namespace.mjs +0 -13
  367. package/source/data/datasource/storage/namespace.mjs +0 -13
  368. package/source/data/namespace.mjs +0 -13
  369. package/source/dom/namespace.mjs +0 -13
  370. package/source/dom/resource/link/namespace.mjs +0 -13
  371. package/source/dom/resource/namespace.mjs +0 -13
  372. package/source/dom/util/namespace.mjs +0 -13
  373. package/source/dom/worker/namespace.mjs +0 -13
  374. package/source/i18n/namespace.mjs +0 -13
  375. package/source/i18n/providers/namespace.mjs +0 -13
  376. package/source/logging/handler/namespace.mjs +0 -11
  377. package/source/logging/namespace.mjs +0 -13
  378. package/source/math/namespace.mjs +0 -13
  379. package/source/net/namespace.mjs +0 -13
  380. package/source/net/webconnect/namespace.mjs +0 -13
  381. package/source/text/namespace.mjs +0 -13
  382. package/source/types/namespace.mjs +0 -13
  383. package/source/util/namespace.mjs +0 -13
@@ -1,66 +1,82 @@
1
1
  /**
2
- * Copyright 2023 schukai GmbH
2
+ * Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. All rights reserved.
3
+ * Node module: @schukai/monster
4
+ *
5
+ * This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3).
6
+ * The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html
7
+ *
8
+ * For those who do not wish to adhere to the AGPLv3, a commercial license is available.
9
+ * Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
10
+ * For more information about purchasing a commercial license, please contact schukai GmbH.
11
+ *
3
12
  * SPDX-License-Identifier: AGPL-3.0
4
13
  */
5
14
 
6
- import {Datasource} from "./datasource.mjs";
15
+ import { Datasource } from "./datasource.mjs";
7
16
  import {
8
- assembleMethodSymbol,
9
- CustomElement,
10
- registerCustomElement,
11
- getSlottedElements,
17
+ assembleMethodSymbol,
18
+ CustomElement,
19
+ registerCustomElement,
20
+ getSlottedElements,
12
21
  } from "../../dom/customelement.mjs";
13
- import {findTargetElementFromEvent, fireCustomEvent} from "../../dom/events.mjs";
14
- import {clone} from "../../util/clone.mjs";
15
22
  import {
16
- isString,
17
- isFunction,
18
- isInstance,
19
- isObject,
20
- isArray,
23
+ findTargetElementFromEvent,
24
+ fireCustomEvent,
25
+ } from "../../dom/events.mjs";
26
+ import { clone } from "../../util/clone.mjs";
27
+ import {
28
+ isString,
29
+ isFunction,
30
+ isInstance,
31
+ isObject,
32
+ isArray,
21
33
  } from "../../types/is.mjs";
22
- import {validateArray, validateInteger, validateObject} from "../../types/validate.mjs";
23
- import {Observer} from "../../types/observer.mjs";
24
34
  import {
25
- ATTRIBUTE_DATATABLE_HEAD,
26
- ATTRIBUTE_DATATABLE_GRID_TEMPLATE,
27
- ATTRIBUTE_DATASOURCE_SELECTOR,
28
- ATTRIBUTE_DATATABLE_ALIGN,
29
- ATTRIBUTE_DATATABLE_SORTABLE,
30
- ATTRIBUTE_DATATABLE_MODE,
31
- ATTRIBUTE_DATATABLE_INDEX,
32
- ATTRIBUTE_DATATABLE_MODE_HIDDEN,
33
- ATTRIBUTE_DATATABLE_MODE_VISIBLE,
34
- ATTRIBUTE_DATATABLE_RESPONSIVE_BREAKPOINT,
35
- ATTRIBUTE_DATATABLE_MODE_FIXED,
35
+ validateArray,
36
+ validateInteger,
37
+ validateObject,
38
+ } from "../../types/validate.mjs";
39
+ import { Observer } from "../../types/observer.mjs";
40
+ import {
41
+ ATTRIBUTE_DATATABLE_HEAD,
42
+ ATTRIBUTE_DATATABLE_GRID_TEMPLATE,
43
+ ATTRIBUTE_DATASOURCE_SELECTOR,
44
+ ATTRIBUTE_DATATABLE_ALIGN,
45
+ ATTRIBUTE_DATATABLE_SORTABLE,
46
+ ATTRIBUTE_DATATABLE_MODE,
47
+ ATTRIBUTE_DATATABLE_INDEX,
48
+ ATTRIBUTE_DATATABLE_MODE_HIDDEN,
49
+ ATTRIBUTE_DATATABLE_MODE_VISIBLE,
50
+ ATTRIBUTE_DATATABLE_RESPONSIVE_BREAKPOINT,
51
+ ATTRIBUTE_DATATABLE_MODE_FIXED,
36
52
  } from "./constants.mjs";
37
- import {instanceSymbol} from "../../constants.mjs";
53
+ import { instanceSymbol } from "../../constants.mjs";
38
54
  import {
39
- Header,
40
- createOrderStatement,
41
- DIRECTION_ASC,
42
- DIRECTION_DESC,
43
- DIRECTION_NONE,
55
+ Header,
56
+ createOrderStatement,
57
+ DIRECTION_ASC,
58
+ DIRECTION_DESC,
59
+ DIRECTION_NONE,
44
60
  } from "./datatable/header.mjs";
45
- import {DatatableStyleSheet} from "./stylesheet/datatable.mjs";
61
+ import { DatatableStyleSheet } from "./stylesheet/datatable.mjs";
46
62
  import {
47
- handleDataSourceChanges,
48
- datasourceLinkedElementSymbol,
63
+ handleDataSourceChanges,
64
+ datasourceLinkedElementSymbol,
49
65
  } from "./util.mjs";
50
66
  import "./columnbar.mjs";
51
67
  import "./filter-button.mjs";
52
- import {getDocument, getWindow} from "../../dom/util.mjs";
53
- import {addAttributeToken} from "../../dom/attributes.mjs";
54
- import {ATTRIBUTE_ERRORMESSAGE} from "../../dom/constants.mjs";
55
- import {getDocumentTranslations} from "../../i18n/translations.mjs";
68
+ import {findElementWithSelectorUpwards, getDocument, getWindow} from "../../dom/util.mjs";
69
+ import { addAttributeToken } from "../../dom/attributes.mjs";
70
+ import { ATTRIBUTE_ERRORMESSAGE } from "../../dom/constants.mjs";
71
+ import { getDocumentTranslations } from "../../i18n/translations.mjs";
56
72
  import "../state/state.mjs";
57
73
  import "../host/collapse.mjs";
58
- import {generateUniqueConfigKey} from "../host/util.mjs";
74
+ import { generateUniqueConfigKey } from "../host/util.mjs";
59
75
 
60
76
  import "./datasource/dom.mjs";
61
77
  import "./datasource/rest.mjs";
62
78
 
63
- export {DataTable};
79
+ export { DataTable };
64
80
 
65
81
  /**
66
82
  * @private
@@ -124,358 +140,354 @@ const columnBarElementSymbol = Symbol("columnBarElement");
124
140
  * @fire Monster.Components.Datatable.event:monster-datatable-row-added
125
141
  */
126
142
  class DataTable extends CustomElement {
127
- /**
128
- * This method is called by the `instanceof` operator.
129
- * @returns {symbol}
130
- */
131
- static get [instanceSymbol]() {
132
- return Symbol.for("@schukai/monster/components/datatable@@instance");
133
- }
134
-
135
- /**
136
- * To set the options via the html tag the attribute `data-monster-options` must be used.
137
- * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
138
- *
139
- * The individual configuration values can be found in the table.
140
- *
141
- * @property {Object} templates Template definitions
142
- * @property {string} templates.main Main template
143
- * @property {Object} datasource Datasource configuration
144
- * @property {string} datasource.selector Selector for the datasource
145
- * @property {Object} mapping Mapping configuration
146
- * @property {string} mapping.data Data mapping
147
- * @property {Array} data Data
148
- * @property {Array} headers Headers
149
- * @property {Object} responsive Responsive configuration
150
- * @property {number} responsive.breakpoint Breakpoint for responsive mode
151
- * @property {Object} labels Labels
152
- * @property {string} labels.theListContainsNoEntries Label for empty state
153
- * @property {Object} classes Classes
154
- * @property {string} classes.container Container class
155
- * @property {Object} features Features
156
- * @property {boolean} features.settings Settings feature
157
- * @property {boolean} features.footer Footer feature
158
- * @property {boolean} features.autoInit Auto init feature (init datasource automatically)
159
- * @property {Object} templateMapping Template mapping
160
- * @property {string} templateMapping.row-key Row key
161
- * @property {string} templateMapping.filter-id Filter id
162
- **/
163
- get defaults() {
164
- return Object.assign(
165
- {},
166
- super.defaults,
167
- {
168
- templates: {
169
- main: getTemplate(),
170
- emptyState: getEmptyTemplate(),
171
- },
172
-
173
- datasource: {
174
- selector: null,
175
- },
176
-
177
- mapping: {
178
- data: "dataset",
179
- },
180
-
181
- data: [],
182
- headers: [],
183
-
184
- responsive: {
185
- breakpoint: 800,
186
- },
187
-
188
- labels: {
189
- theListContainsNoEntries: "The list contains no entries",
190
- },
191
-
192
- classes : {
193
- control: "monster-theme-control-container-1",
194
- container: "monster-theme-control-container-1",
195
- row: "monster-theme-control-row-1",
196
- },
197
-
198
- features: {
199
- settings: true,
200
- footer: true,
201
- autoInit: true,
202
- },
203
-
204
- templateMapping: {
205
- "row-key": null,
206
- "filter-id": null,
207
- },
208
- },
209
- initOptionsFromArguments.call(this),
210
- );
211
- }
212
-
213
- /**
214
- *
215
- * @param {string} selector
216
- * @returns {NodeListOf<*>}
217
- */
218
- getGridElements(selector) {
219
- return this[gridElementSymbol].querySelectorAll(selector);
220
- }
221
-
222
- /**
223
- *
224
- * @return {string}
225
- */
226
- static getTag() {
227
- return "monster-datatable";
228
- }
229
-
230
- /**
231
- *
232
- * @return {Monster.Components.Form.Form}
233
- */
234
- [assembleMethodSymbol]() {
235
- const rawKey = this.getOption("templateMapping.row-key");
236
-
237
- if (rawKey === null) {
238
- if (this.id !== null && this.id !== "") {
239
- const rawKey = this.getOption("templateMapping.row-key");
240
- if (rawKey === null) {
241
- this.setOption("templateMapping.row-key", this.id + "-row");
242
- }
243
- } else {
244
- this.setOption("templateMapping.row-key", "row");
245
- }
246
- }
247
-
248
- if (this.id !== null && this.id !== "") {
249
- this.setOption("templateMapping.filter-id", "" + this.id + "-filter");
250
- } else {
251
- this.setOption("templateMapping.filter-id", "filter");
252
- }
253
-
254
- super[assembleMethodSymbol]();
255
-
256
- initControlReferences.call(this);
257
- initEventHandler.call(this);
258
-
259
- const selector = this.getOption("datasource.selector");
260
-
261
- if (isString(selector)) {
262
- const elements = document.querySelectorAll(selector);
263
- if (elements.length !== 1) {
264
- throw new Error("the selector must match exactly one element");
265
- }
266
-
267
- const element = elements[0];
268
-
269
- if (!isInstance(element, Datasource)) {
270
- throw new TypeError("the element must be a datasource");
271
- }
272
-
273
- this[datasourceLinkedElementSymbol] = element;
274
-
275
- setTimeout(() => {
276
- handleDataSourceChanges.call(this);
277
- element.datasource.attachObserver(
278
- new Observer(handleDataSourceChanges.bind(this)),
279
- );
280
- }, 0);
281
- }
282
-
283
- getHostConfig
284
- .call(this, getColumnVisibilityConfigKey)
285
- .then((config) => {
286
- const headerOrderMap = new Map();
287
-
288
- getHostConfig
289
- .call(this, getStoredOrderConfigKey)
290
- .then((orderConfig) => {
291
- if (isArray(orderConfig) || orderConfig.length > 0) {
292
- for (let i = 0; i < orderConfig.length; i++) {
293
- const item = orderConfig[i];
294
- const parts = item.split(" ");
295
- const field = parts[0];
296
- const direction = parts[1] || DIRECTION_ASC;
297
- headerOrderMap.set(field, direction);
298
- }
299
- }
300
- })
301
- .then(() => {
302
- try {
303
- initGridAndStructs.call(this, config, headerOrderMap);
304
- } catch (error) {
305
- addAttributeToken(
306
- this,
307
- ATTRIBUTE_ERRORMESSAGE,
308
- error?.message || error.toString(),
309
- );
310
- }
311
-
312
- updateColumnBar.call(this);
313
- })
314
- .catch((error) => {
315
- addAttributeToken(
316
- this,
317
- ATTRIBUTE_ERRORMESSAGE,
318
- error?.message || error.toString(),
319
- );
320
- });
321
- })
322
- .catch((error) => {
323
- addAttributeToken(
324
- this,
325
- ATTRIBUTE_ERRORMESSAGE,
326
- error?.message || error.toString(),
327
- );
328
- });
329
- }
330
-
331
- /**
332
- *
333
- * @return {CSSStyleSheet[]}
334
- */
335
- static getCSSStyleSheet() {
336
- return [DatatableStyleSheet];
337
- }
338
-
339
- /**
340
- * Copy a row from the datatable
341
- * @param {number} fromIndex
342
- * @param {number} toIndex
343
- * @returns {Monster.Components.Datatable.DataTable}
344
- * @fire Monster.Components.Datatable.event:monster-datatable-row-copied
345
- */
346
- copyRow(fromIndex, toIndex) {
347
-
348
- const datasource = this[datasourceLinkedElementSymbol];
349
- if (!datasource) {
350
- return this;
351
- }
352
- let d = datasource.data;
353
- let c = clone(d);
354
-
355
- let rows = c
356
- const mapping = this.getOption("mapping.data");
357
-
358
- if (mapping) {
359
- rows=c?.[mapping];
360
- }
361
-
362
- if (rows === undefined || rows === null) {
363
- rows = [];
364
- }
365
-
366
- if (toIndex===undefined) {
367
- toIndex = rows.length;
368
- }
369
-
370
- fromIndex = parseInt(fromIndex);
371
- toIndex = parseInt(toIndex);
372
-
373
- if (toIndex < 0 || toIndex > rows.length) {
374
- throw new RangeError("index out of bounds");
375
- }
376
-
377
- validateArray(rows);
378
- validateInteger(fromIndex);
379
- validateInteger(toIndex);
380
-
381
- if (fromIndex < 0 || fromIndex >= rows.length) {
382
- throw new RangeError("index out of bounds");
383
- }
384
-
385
- rows.splice(toIndex, 0, clone(rows[fromIndex]));
386
- datasource.data=c;
387
-
388
- fireCustomEvent(this, "monster-datatable-row-copied", {
389
- index: toIndex,
390
- });
391
-
392
- return this;
393
- }
394
-
395
- /**
396
- * Remove a row from the datatable
397
- * @param index
398
- * @returns {Monster.Components.Datatable.DataTable}
399
- * @fire Monster.Components.Datatable.event:monster-datatable-row-removed
400
- */
401
- removeRow(index) {
402
- const datasource = this[datasourceLinkedElementSymbol];
403
- if (!datasource) {
404
- return this;
405
- }
406
- let d = datasource.data;
407
- let c = clone(d);
408
-
409
- let rows = c
410
- const mapping = this.getOption("mapping.data");
411
-
412
- if (mapping) {
413
- rows=c?.[mapping];
414
- }
415
-
416
- if (rows === undefined || rows === null) {
417
- rows = [];
418
- }
419
-
420
- index = parseInt(index);
421
-
422
- validateArray(rows);
423
- validateInteger(index);
424
- if (index < 0 || index >= rows.length) {
425
- throw new RangeError("index out of bounds");
426
- }
427
- if (mapping) {
428
- rows=c?.[mapping];
429
- }
430
-
431
- rows.splice(index, 1)
432
- datasource.data=c;
433
-
434
- fireCustomEvent(this, "monster-datatable-row-removed", {
435
- index: index,
436
- });
437
-
438
- return this;
439
- }
440
-
441
- /**
442
- * Add a row to the datatable
443
- * @param {Object} data
444
- * @returns {Monster.Components.Datatable.DataTable}
445
- * @fire Monster.Components.Datatable.event:monster-datatable-row-added
446
- **/
447
- addRow(data) {
448
- const datasource = this[datasourceLinkedElementSymbol];
449
- if (!datasource) {
450
- return this;
451
- }
452
- let d = datasource.data;
453
- let c = clone(d);
454
-
455
- let rows = c
456
-
457
- const mapping = this.getOption("mapping.data");
458
- if (mapping) {
459
- rows=c?.[mapping];
460
- }
461
-
462
- if (rows === undefined || rows === null) {
463
- rows = [];
464
- }
465
-
466
- validateArray(rows);
467
- validateObject(data);
468
-
469
- rows.push(data)
470
- datasource.data=c;
471
-
472
- fireCustomEvent(this, "monster-datatable-row-added", {
473
- index: rows.length - 1,
474
- });
475
-
476
- return this;
477
- }
478
-
143
+ /**
144
+ * This method is called by the `instanceof` operator.
145
+ * @returns {symbol}
146
+ */
147
+ static get [instanceSymbol]() {
148
+ return Symbol.for("@schukai/monster/components/datatable@@instance");
149
+ }
150
+
151
+ /**
152
+ * To set the options via the html tag the attribute `data-monster-options` must be used.
153
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
154
+ *
155
+ * The individual configuration values can be found in the table.
156
+ *
157
+ * @property {Object} templates Template definitions
158
+ * @property {string} templates.main Main template
159
+ * @property {Object} datasource Datasource configuration
160
+ * @property {string} datasource.selector Selector for the datasource
161
+ * @property {Object} mapping Mapping configuration
162
+ * @property {string} mapping.data Data mapping
163
+ * @property {Array} data Data
164
+ * @property {Array} headers Headers
165
+ * @property {Object} responsive Responsive configuration
166
+ * @property {number} responsive.breakpoint Breakpoint for responsive mode
167
+ * @property {Object} labels Labels
168
+ * @property {string} labels.theListContainsNoEntries Label for empty state
169
+ * @property {Object} classes Classes
170
+ * @property {string} classes.container Container class
171
+ * @property {Object} features Features
172
+ * @property {boolean} features.settings Settings feature
173
+ * @property {boolean} features.footer Footer feature
174
+ * @property {boolean} features.autoInit Auto init feature (init datasource automatically)
175
+ * @property {Object} templateMapping Template mapping
176
+ * @property {string} templateMapping.row-key Row key
177
+ * @property {string} templateMapping.filter-id Filter id
178
+ **/
179
+ get defaults() {
180
+ return Object.assign(
181
+ {},
182
+ super.defaults,
183
+ {
184
+ templates: {
185
+ main: getTemplate(),
186
+ emptyState: getEmptyTemplate(),
187
+ },
188
+
189
+ datasource: {
190
+ selector: null,
191
+ },
192
+
193
+ mapping: {
194
+ data: "dataset",
195
+ },
196
+
197
+ data: [],
198
+ headers: [],
199
+
200
+ responsive: {
201
+ breakpoint: 800,
202
+ },
203
+
204
+ labels: {
205
+ theListContainsNoEntries: "The list contains no entries",
206
+ },
207
+
208
+ classes: {
209
+ control: "monster-theme-control-container-1",
210
+ container: "monster-theme-control-container-1",
211
+ row: "monster-theme-control-row-1",
212
+ },
213
+
214
+ features: {
215
+ settings: true,
216
+ footer: true,
217
+ autoInit: true,
218
+ },
219
+
220
+ templateMapping: {
221
+ "row-key": null,
222
+ "filter-id": null,
223
+ },
224
+ },
225
+ initOptionsFromArguments.call(this),
226
+ );
227
+ }
228
+
229
+ /**
230
+ *
231
+ * @param {string} selector
232
+ * @returns {NodeListOf<*>}
233
+ */
234
+ getGridElements(selector) {
235
+ return this[gridElementSymbol].querySelectorAll(selector);
236
+ }
237
+
238
+ /**
239
+ *
240
+ * @return {string}
241
+ */
242
+ static getTag() {
243
+ return "monster-datatable";
244
+ }
245
+
246
+ /**
247
+ *
248
+ * @return {Monster.Components.Form.Form}
249
+ */
250
+ [assembleMethodSymbol]() {
251
+ const rawKey = this.getOption("templateMapping.row-key");
252
+
253
+ if (rawKey === null) {
254
+ if (this.id !== null && this.id !== "") {
255
+ const rawKey = this.getOption("templateMapping.row-key");
256
+ if (rawKey === null) {
257
+ this.setOption("templateMapping.row-key", this.id + "-row");
258
+ }
259
+ } else {
260
+ this.setOption("templateMapping.row-key", "row");
261
+ }
262
+ }
263
+
264
+ if (this.id !== null && this.id !== "") {
265
+ this.setOption("templateMapping.filter-id", "" + this.id + "-filter");
266
+ } else {
267
+ this.setOption("templateMapping.filter-id", "filter");
268
+ }
269
+
270
+ super[assembleMethodSymbol]();
271
+
272
+ initControlReferences.call(this);
273
+ initEventHandler.call(this);
274
+
275
+ const selector = this.getOption("datasource.selector");
276
+
277
+ if (isString(selector)) {
278
+ const element = findElementWithSelectorUpwards( this,selector);
279
+ if (element===null) {
280
+ throw new Error("the selector must match exactly one element");
281
+ }
282
+
283
+ if (!isInstance(element, Datasource)) {
284
+ throw new TypeError("the element must be a datasource");
285
+ }
286
+
287
+ this[datasourceLinkedElementSymbol] = element;
288
+
289
+ setTimeout(() => {
290
+ handleDataSourceChanges.call(this);
291
+ element.datasource.attachObserver(
292
+ new Observer(handleDataSourceChanges.bind(this)),
293
+ );
294
+ }, 0);
295
+ }
296
+
297
+ getHostConfig
298
+ .call(this, getColumnVisibilityConfigKey)
299
+ .then((config) => {
300
+ const headerOrderMap = new Map();
301
+
302
+ getHostConfig
303
+ .call(this, getStoredOrderConfigKey)
304
+ .then((orderConfig) => {
305
+ if (isArray(orderConfig) || orderConfig.length > 0) {
306
+ for (let i = 0; i < orderConfig.length; i++) {
307
+ const item = orderConfig[i];
308
+ const parts = item.split(" ");
309
+ const field = parts[0];
310
+ const direction = parts[1] || DIRECTION_ASC;
311
+ headerOrderMap.set(field, direction);
312
+ }
313
+ }
314
+ })
315
+ .then(() => {
316
+ try {
317
+ initGridAndStructs.call(this, config, headerOrderMap);
318
+ } catch (error) {
319
+ addAttributeToken(
320
+ this,
321
+ ATTRIBUTE_ERRORMESSAGE,
322
+ error?.message || error.toString(),
323
+ );
324
+ }
325
+
326
+ updateColumnBar.call(this);
327
+ })
328
+ .catch((error) => {
329
+ addAttributeToken(
330
+ this,
331
+ ATTRIBUTE_ERRORMESSAGE,
332
+ error?.message || error.toString(),
333
+ );
334
+ });
335
+ })
336
+ .catch((error) => {
337
+ addAttributeToken(
338
+ this,
339
+ ATTRIBUTE_ERRORMESSAGE,
340
+ error?.message || error.toString(),
341
+ );
342
+ });
343
+ }
344
+
345
+ /**
346
+ *
347
+ * @return {CSSStyleSheet[]}
348
+ */
349
+ static getCSSStyleSheet() {
350
+ return [DatatableStyleSheet];
351
+ }
352
+
353
+ /**
354
+ * Copy a row from the datatable
355
+ * @param {number} fromIndex
356
+ * @param {number} toIndex
357
+ * @returns {Monster.Components.Datatable.DataTable}
358
+ * @fire Monster.Components.Datatable.event:monster-datatable-row-copied
359
+ */
360
+ copyRow(fromIndex, toIndex) {
361
+ const datasource = this[datasourceLinkedElementSymbol];
362
+ if (!datasource) {
363
+ return this;
364
+ }
365
+ let d = datasource.data;
366
+ let c = clone(d);
367
+
368
+ let rows = c;
369
+ const mapping = this.getOption("mapping.data");
370
+
371
+ if (mapping) {
372
+ rows = c?.[mapping];
373
+ }
374
+
375
+ if (rows === undefined || rows === null) {
376
+ rows = [];
377
+ }
378
+
379
+ if (toIndex === undefined) {
380
+ toIndex = rows.length;
381
+ }
382
+
383
+ fromIndex = parseInt(fromIndex);
384
+ toIndex = parseInt(toIndex);
385
+
386
+ if (toIndex < 0 || toIndex > rows.length) {
387
+ throw new RangeError("index out of bounds");
388
+ }
389
+
390
+ validateArray(rows);
391
+ validateInteger(fromIndex);
392
+ validateInteger(toIndex);
393
+
394
+ if (fromIndex < 0 || fromIndex >= rows.length) {
395
+ throw new RangeError("index out of bounds");
396
+ }
397
+
398
+ rows.splice(toIndex, 0, clone(rows[fromIndex]));
399
+ datasource.data = c;
400
+
401
+ fireCustomEvent(this, "monster-datatable-row-copied", {
402
+ index: toIndex,
403
+ });
404
+
405
+ return this;
406
+ }
407
+
408
+ /**
409
+ * Remove a row from the datatable
410
+ * @param index
411
+ * @returns {Monster.Components.Datatable.DataTable}
412
+ * @fire Monster.Components.Datatable.event:monster-datatable-row-removed
413
+ */
414
+ removeRow(index) {
415
+ const datasource = this[datasourceLinkedElementSymbol];
416
+ if (!datasource) {
417
+ return this;
418
+ }
419
+ let d = datasource.data;
420
+ let c = clone(d);
421
+
422
+ let rows = c;
423
+ const mapping = this.getOption("mapping.data");
424
+
425
+ if (mapping) {
426
+ rows = c?.[mapping];
427
+ }
428
+
429
+ if (rows === undefined || rows === null) {
430
+ rows = [];
431
+ }
432
+
433
+ index = parseInt(index);
434
+
435
+ validateArray(rows);
436
+ validateInteger(index);
437
+ if (index < 0 || index >= rows.length) {
438
+ throw new RangeError("index out of bounds");
439
+ }
440
+ if (mapping) {
441
+ rows = c?.[mapping];
442
+ }
443
+
444
+ rows.splice(index, 1);
445
+ datasource.data = c;
446
+
447
+ fireCustomEvent(this, "monster-datatable-row-removed", {
448
+ index: index,
449
+ });
450
+
451
+ return this;
452
+ }
453
+
454
+ /**
455
+ * Add a row to the datatable
456
+ * @param {Object} data
457
+ * @returns {Monster.Components.Datatable.DataTable}
458
+ * @fire Monster.Components.Datatable.event:monster-datatable-row-added
459
+ **/
460
+ addRow(data) {
461
+ const datasource = this[datasourceLinkedElementSymbol];
462
+ if (!datasource) {
463
+ return this;
464
+ }
465
+ let d = datasource.data;
466
+ let c = clone(d);
467
+
468
+ let rows = c;
469
+
470
+ const mapping = this.getOption("mapping.data");
471
+ if (mapping) {
472
+ rows = c?.[mapping];
473
+ }
474
+
475
+ if (rows === undefined || rows === null) {
476
+ rows = [];
477
+ }
478
+
479
+ validateArray(rows);
480
+ validateObject(data);
481
+
482
+ rows.push(data);
483
+ datasource.data = c;
484
+
485
+ fireCustomEvent(this, "monster-datatable-row-added", {
486
+ index: rows.length - 1,
487
+ });
488
+
489
+ return this;
490
+ }
479
491
  }
480
492
 
481
493
  /**
@@ -483,7 +495,7 @@ class DataTable extends CustomElement {
483
495
  * @returns {string}
484
496
  */
485
497
  function getColumnVisibilityConfigKey() {
486
- return generateUniqueConfigKey("datatable", this?.id, "columns-visibility");
498
+ return generateUniqueConfigKey("datatable", this?.id, "columns-visibility");
487
499
  }
488
500
 
489
501
  /**
@@ -491,7 +503,7 @@ function getColumnVisibilityConfigKey() {
491
503
  * @returns {string}
492
504
  */
493
505
  function getFilterConfigKey() {
494
- return generateUniqueConfigKey("datatable", this?.id, "filter");
506
+ return generateUniqueConfigKey("datatable", this?.id, "filter");
495
507
  }
496
508
 
497
509
  /**
@@ -499,293 +511,293 @@ function getFilterConfigKey() {
499
511
  * @returns {Promise}
500
512
  */
501
513
  function getHostConfig(callback) {
502
- const document = getDocument();
503
- const host = document.querySelector("monster-host");
504
-
505
- if (!(host && this.id)) {
506
- return Promise.resolve({});
507
- }
508
-
509
- if (!host || !isFunction(host?.getConfig)) {
510
- throw new TypeError("the host must be a monster-host");
511
- }
512
-
513
- const configKey = callback.call(this);
514
- return host.hasConfig(configKey).then((hasConfig) => {
515
- if (hasConfig) {
516
- return host.getConfig(configKey);
517
- } else {
518
- return {};
519
- }
520
- });
514
+ const document = getDocument();
515
+ const host = document.querySelector("monster-host");
516
+
517
+ if (!(host && this.id)) {
518
+ return Promise.resolve({});
519
+ }
520
+
521
+ if (!host || !isFunction(host?.getConfig)) {
522
+ throw new TypeError("the host must be a monster-host");
523
+ }
524
+
525
+ const configKey = callback.call(this);
526
+ return host.hasConfig(configKey).then((hasConfig) => {
527
+ if (hasConfig) {
528
+ return host.getConfig(configKey);
529
+ } else {
530
+ return {};
531
+ }
532
+ });
521
533
  }
522
534
 
523
535
  /**
524
536
  * @private
525
537
  */
526
538
  function updateColumnBar() {
527
- if (!this[columnBarElementSymbol]) {
528
- return;
529
- }
530
-
531
- const columns = [];
532
- for (const header of this.getOption("headers")) {
533
- const mode = header.getInternal("mode");
534
-
535
- if (mode === ATTRIBUTE_DATATABLE_MODE_FIXED) {
536
- continue;
537
- }
538
-
539
- columns.push({
540
- visible: mode !== ATTRIBUTE_DATATABLE_MODE_HIDDEN,
541
- name: header.label,
542
- index: header.index,
543
- });
544
- }
545
-
546
- this[columnBarElementSymbol].setOption("columns", columns);
539
+ if (!this[columnBarElementSymbol]) {
540
+ return;
541
+ }
542
+
543
+ const columns = [];
544
+ for (const header of this.getOption("headers")) {
545
+ const mode = header.getInternal("mode");
546
+
547
+ if (mode === ATTRIBUTE_DATATABLE_MODE_FIXED) {
548
+ continue;
549
+ }
550
+
551
+ columns.push({
552
+ visible: mode !== ATTRIBUTE_DATATABLE_MODE_HIDDEN,
553
+ name: header.label,
554
+ index: header.index,
555
+ });
556
+ }
557
+
558
+ this[columnBarElementSymbol].setOption("columns", columns);
547
559
  }
548
560
 
549
561
  /**
550
562
  * @private
551
563
  */
552
564
  function updateHeaderFromColumnBar() {
553
- if (!this[columnBarElementSymbol]) {
554
- return;
555
- }
565
+ if (!this[columnBarElementSymbol]) {
566
+ return;
567
+ }
556
568
 
557
- const options = this[columnBarElementSymbol].getOption("columns");
558
- if (!isArray(options)) return;
569
+ const options = this[columnBarElementSymbol].getOption("columns");
570
+ if (!isArray(options)) return;
559
571
 
560
- const invisibleMap = {};
572
+ const invisibleMap = {};
561
573
 
562
- for (let i = 0; i < options.length; i++) {
563
- const option = options[i];
564
- invisibleMap[option.index] = option.visible;
565
- }
574
+ for (let i = 0; i < options.length; i++) {
575
+ const option = options[i];
576
+ invisibleMap[option.index] = option.visible;
577
+ }
566
578
 
567
- for (const header of this.getOption("headers")) {
568
- const mode = header.getInternal("mode");
579
+ for (const header of this.getOption("headers")) {
580
+ const mode = header.getInternal("mode");
569
581
 
570
- if (mode === ATTRIBUTE_DATATABLE_MODE_FIXED) {
571
- continue;
572
- }
582
+ if (mode === ATTRIBUTE_DATATABLE_MODE_FIXED) {
583
+ continue;
584
+ }
573
585
 
574
- if (invisibleMap[header.index] === false) {
575
- header.setInternal("mode", ATTRIBUTE_DATATABLE_MODE_HIDDEN);
576
- } else {
577
- header.setInternal("mode", ATTRIBUTE_DATATABLE_MODE_VISIBLE);
578
- }
579
- }
586
+ if (invisibleMap[header.index] === false) {
587
+ header.setInternal("mode", ATTRIBUTE_DATATABLE_MODE_HIDDEN);
588
+ } else {
589
+ header.setInternal("mode", ATTRIBUTE_DATATABLE_MODE_VISIBLE);
590
+ }
591
+ }
580
592
  }
581
593
 
582
594
  /**
583
595
  * @private
584
596
  */
585
597
  function updateConfigColumnBar() {
586
- if (!this[columnBarElementSymbol]) {
587
- return;
588
- }
589
-
590
- const options = this[columnBarElementSymbol].getOption("columns");
591
- if (!isArray(options)) return;
592
-
593
- const map = {};
594
- for (let i = 0; i < options.length; i++) {
595
- const option = options[i];
596
- map[option.name] = option.visible;
597
- }
598
-
599
- const document = getDocument();
600
- const host = document.querySelector("monster-host");
601
- if (!(host && this.id)) {
602
- return;
603
- }
604
- const configKey = getColumnVisibilityConfigKey.call(this);
605
-
606
- try {
607
- host.setConfig(configKey, map);
608
- } catch (error) {
609
- addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, String(error));
610
- }
598
+ if (!this[columnBarElementSymbol]) {
599
+ return;
600
+ }
601
+
602
+ const options = this[columnBarElementSymbol].getOption("columns");
603
+ if (!isArray(options)) return;
604
+
605
+ const map = {};
606
+ for (let i = 0; i < options.length; i++) {
607
+ const option = options[i];
608
+ map[option.name] = option.visible;
609
+ }
610
+
611
+ const document = getDocument();
612
+ const host = document.querySelector("monster-host");
613
+ if (!(host && this.id)) {
614
+ return;
615
+ }
616
+ const configKey = getColumnVisibilityConfigKey.call(this);
617
+
618
+ try {
619
+ host.setConfig(configKey, map);
620
+ } catch (error) {
621
+ addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, String(error));
622
+ }
611
623
  }
612
624
 
613
625
  /**
614
626
  * @private
615
627
  */
616
628
  function initEventHandler() {
617
- const self = this;
618
-
619
- getWindow().addEventListener("resize", (event) => {
620
- updateGrid.call(self);
621
- });
622
-
623
- self[columnBarElementSymbol].attachObserver(
624
- new Observer((e) => {
625
- updateHeaderFromColumnBar.call(self);
626
- updateGrid.call(self);
627
- updateConfigColumnBar.call(self);
628
- }),
629
- );
630
-
631
- self[gridHeadersElementSymbol].addEventListener("click", function (event) {
632
- let element = null;
633
- const datasource = self[datasourceLinkedElementSymbol];
634
- if (!datasource) {
635
- return;
636
- }
637
-
638
- element = findTargetElementFromEvent(event, ATTRIBUTE_DATATABLE_SORTABLE);
639
- if (element) {
640
- const index = element.parentNode.getAttribute(ATTRIBUTE_DATATABLE_INDEX);
641
- const headers = self.getOption("headers");
642
-
643
- event.preventDefault();
644
-
645
- headers[index].changeDirection();
646
-
647
- setTimeout(function () {
648
- /** hotfix, normally this should be done via the updater, no idea why this is not possible. */
649
- element.setAttribute(
650
- ATTRIBUTE_DATATABLE_SORTABLE,
651
- `${headers[index].field} ${headers[index].direction}`,
652
- );
653
-
654
- storeOrderStatement.call(self, true);
655
- }, 0);
656
- }
657
- });
629
+ const self = this;
630
+
631
+ getWindow().addEventListener("resize", (event) => {
632
+ updateGrid.call(self);
633
+ });
634
+
635
+ self[columnBarElementSymbol].attachObserver(
636
+ new Observer((e) => {
637
+ updateHeaderFromColumnBar.call(self);
638
+ updateGrid.call(self);
639
+ updateConfigColumnBar.call(self);
640
+ }),
641
+ );
642
+
643
+ self[gridHeadersElementSymbol].addEventListener("click", function (event) {
644
+ let element = null;
645
+ const datasource = self[datasourceLinkedElementSymbol];
646
+ if (!datasource) {
647
+ return;
648
+ }
649
+
650
+ element = findTargetElementFromEvent(event, ATTRIBUTE_DATATABLE_SORTABLE);
651
+ if (element) {
652
+ const index = element.parentNode.getAttribute(ATTRIBUTE_DATATABLE_INDEX);
653
+ const headers = self.getOption("headers");
654
+
655
+ event.preventDefault();
656
+
657
+ headers[index].changeDirection();
658
+
659
+ setTimeout(function () {
660
+ /** hotfix, normally this should be done via the updater, no idea why this is not possible. */
661
+ element.setAttribute(
662
+ ATTRIBUTE_DATATABLE_SORTABLE,
663
+ `${headers[index].field} ${headers[index].direction}`,
664
+ );
665
+
666
+ storeOrderStatement.call(self, true);
667
+ }, 0);
668
+ }
669
+ });
658
670
  }
659
671
 
660
672
  /**
661
673
  * @private
662
674
  */
663
675
  function initGridAndStructs(hostConfig, headerOrderMap) {
664
- const rowID = this.getOption("templateMapping.row-key");
665
-
666
- if (!this[gridElementSymbol]) {
667
- throw new Error("no grid element is defined");
668
- }
669
-
670
- let template;
671
- getSlottedElements.call(this).forEach((e) => {
672
- if (e instanceof HTMLTemplateElement && e.id === rowID) {
673
- template = e;
674
- }
675
- });
676
-
677
- if (!template) {
678
- throw new Error("no template is defined");
679
- }
680
-
681
- const rowCount = template.content.children.length;
682
-
683
- const headers = [];
684
-
685
- for (let i = 0; i < rowCount; i++) {
686
- let hClass = "";
687
- const row = template.content.children[i];
688
-
689
- let mode = "";
690
- if (row.hasAttribute(ATTRIBUTE_DATATABLE_MODE)) {
691
- mode = row.getAttribute(ATTRIBUTE_DATATABLE_MODE);
692
- }
693
-
694
- let grid = row.getAttribute(ATTRIBUTE_DATATABLE_GRID_TEMPLATE);
695
- if (!grid || grid === "" || grid === "auto") {
696
- grid = "minmax(0, 1fr)";
697
- }
698
-
699
- let label = "";
700
- let labelKey = "";
701
-
702
- if (row.hasAttribute(ATTRIBUTE_DATATABLE_HEAD)) {
703
- label = row.getAttribute(ATTRIBUTE_DATATABLE_HEAD);
704
- labelKey = label;
705
-
706
- try {
707
- if (label.startsWith("i18n:")) {
708
- label = label.substring(5, label.length);
709
- label = getDocumentTranslations().getText(label, label);
710
- }
711
- } catch (e) {
712
- label = "i18n error " + label;
713
- }
714
- }
715
-
716
- if (!label) {
717
- label = i + 1 + "";
718
- mode = ATTRIBUTE_DATATABLE_MODE_FIXED;
719
- labelKey = label;
720
- }
721
-
722
- if (isObject(hostConfig) && hostConfig.hasOwnProperty(label)) {
723
- if (hostConfig[label] === false) {
724
- mode = ATTRIBUTE_DATATABLE_MODE_HIDDEN;
725
- } else {
726
- mode = ATTRIBUTE_DATATABLE_MODE_VISIBLE;
727
- }
728
- }
729
-
730
- let align = "";
731
- if (row.hasAttribute(ATTRIBUTE_DATATABLE_ALIGN)) {
732
- align = row.getAttribute(ATTRIBUTE_DATATABLE_ALIGN);
733
- }
734
-
735
- switch (align) {
736
- case "center":
737
- hClass = "flex-center";
738
- break;
739
- case "end":
740
- hClass = "flex-end";
741
- break;
742
- case "start":
743
- hClass = "flex-start";
744
- break;
745
- default:
746
- hClass = "flex-start";
747
- }
748
-
749
- let field = "";
750
- let direction = DIRECTION_NONE;
751
- if (row.hasAttribute(ATTRIBUTE_DATATABLE_SORTABLE)) {
752
- field = row.getAttribute(ATTRIBUTE_DATATABLE_SORTABLE).trim();
753
- const parts = field.split(" ").map((item) => item.trim());
754
- field = parts[0];
755
-
756
- if (headerOrderMap.has(field)) {
757
- direction = headerOrderMap.get(field);
758
- } else if (
759
- parts.length === 2 &&
760
- [DIRECTION_ASC, DIRECTION_DESC].indexOf(parts[1]) !== -1
761
- ) {
762
- direction = parts[1];
763
- }
764
- }
765
-
766
- if (mode === ATTRIBUTE_DATATABLE_MODE_HIDDEN) {
767
- hClass += " hidden";
768
- }
769
-
770
- const header = new Header();
771
- header.setInternals({
772
- field: field,
773
- label: label,
774
- classes: hClass,
775
- index: i,
776
- mode: mode,
777
- grid: grid,
778
- labelKey: labelKey,
779
- direction: direction,
780
- });
781
-
782
- headers.push(header);
783
- }
784
-
785
- this.setOption("headers", headers);
786
- setTimeout(() => {
787
- storeOrderStatement.call(this, this.getOption("features.autoInit"));
788
- }, 0);
676
+ const rowID = this.getOption("templateMapping.row-key");
677
+
678
+ if (!this[gridElementSymbol]) {
679
+ throw new Error("no grid element is defined");
680
+ }
681
+
682
+ let template;
683
+ getSlottedElements.call(this).forEach((e) => {
684
+ if (e instanceof HTMLTemplateElement && e.id === rowID) {
685
+ template = e;
686
+ }
687
+ });
688
+
689
+ if (!template) {
690
+ throw new Error("no template is defined");
691
+ }
692
+
693
+ const rowCount = template.content.children.length;
694
+
695
+ const headers = [];
696
+
697
+ for (let i = 0; i < rowCount; i++) {
698
+ let hClass = "";
699
+ const row = template.content.children[i];
700
+
701
+ let mode = "";
702
+ if (row.hasAttribute(ATTRIBUTE_DATATABLE_MODE)) {
703
+ mode = row.getAttribute(ATTRIBUTE_DATATABLE_MODE);
704
+ }
705
+
706
+ let grid = row.getAttribute(ATTRIBUTE_DATATABLE_GRID_TEMPLATE);
707
+ if (!grid || grid === "" || grid === "auto") {
708
+ grid = "minmax(0, 1fr)";
709
+ }
710
+
711
+ let label = "";
712
+ let labelKey = "";
713
+
714
+ if (row.hasAttribute(ATTRIBUTE_DATATABLE_HEAD)) {
715
+ label = row.getAttribute(ATTRIBUTE_DATATABLE_HEAD);
716
+ labelKey = label;
717
+
718
+ try {
719
+ if (label.startsWith("i18n:")) {
720
+ label = label.substring(5, label.length);
721
+ label = getDocumentTranslations().getText(label, label);
722
+ }
723
+ } catch (e) {
724
+ label = "i18n error " + label;
725
+ }
726
+ }
727
+
728
+ if (!label) {
729
+ label = i + 1 + "";
730
+ mode = ATTRIBUTE_DATATABLE_MODE_FIXED;
731
+ labelKey = label;
732
+ }
733
+
734
+ if (isObject(hostConfig) && hostConfig.hasOwnProperty(label)) {
735
+ if (hostConfig[label] === false) {
736
+ mode = ATTRIBUTE_DATATABLE_MODE_HIDDEN;
737
+ } else {
738
+ mode = ATTRIBUTE_DATATABLE_MODE_VISIBLE;
739
+ }
740
+ }
741
+
742
+ let align = "";
743
+ if (row.hasAttribute(ATTRIBUTE_DATATABLE_ALIGN)) {
744
+ align = row.getAttribute(ATTRIBUTE_DATATABLE_ALIGN);
745
+ }
746
+
747
+ switch (align) {
748
+ case "center":
749
+ hClass = "flex-center";
750
+ break;
751
+ case "end":
752
+ hClass = "flex-end";
753
+ break;
754
+ case "start":
755
+ hClass = "flex-start";
756
+ break;
757
+ default:
758
+ hClass = "flex-start";
759
+ }
760
+
761
+ let field = "";
762
+ let direction = DIRECTION_NONE;
763
+ if (row.hasAttribute(ATTRIBUTE_DATATABLE_SORTABLE)) {
764
+ field = row.getAttribute(ATTRIBUTE_DATATABLE_SORTABLE).trim();
765
+ const parts = field.split(" ").map((item) => item.trim());
766
+ field = parts[0];
767
+
768
+ if (headerOrderMap.has(field)) {
769
+ direction = headerOrderMap.get(field);
770
+ } else if (
771
+ parts.length === 2 &&
772
+ [DIRECTION_ASC, DIRECTION_DESC].indexOf(parts[1]) !== -1
773
+ ) {
774
+ direction = parts[1];
775
+ }
776
+ }
777
+
778
+ if (mode === ATTRIBUTE_DATATABLE_MODE_HIDDEN) {
779
+ hClass += " hidden";
780
+ }
781
+
782
+ const header = new Header();
783
+ header.setInternals({
784
+ field: field,
785
+ label: label,
786
+ classes: hClass,
787
+ index: i,
788
+ mode: mode,
789
+ grid: grid,
790
+ labelKey: labelKey,
791
+ direction: direction,
792
+ });
793
+
794
+ headers.push(header);
795
+ }
796
+
797
+ this.setOption("headers", headers);
798
+ setTimeout(() => {
799
+ storeOrderStatement.call(this, this.getOption("features.autoInit"));
800
+ }, 0);
789
801
  }
790
802
 
791
803
  /**
@@ -793,78 +805,76 @@ function initGridAndStructs(hostConfig, headerOrderMap) {
793
805
  * @returns {string}
794
806
  */
795
807
  export function getStoredOrderConfigKey() {
796
- return generateUniqueConfigKey("datatable", this?.id, "stored-order");
808
+ return generateUniqueConfigKey("datatable", this?.id, "stored-order");
797
809
  }
798
810
 
799
811
  /**
800
812
  * @private
801
813
  */
802
814
  function storeOrderStatement(doFetch) {
803
- const headers = this.getOption("headers");
804
- const statement = createOrderStatement(headers);
805
- setDataSource.call(this, {orderBy: statement}, doFetch);
815
+ const headers = this.getOption("headers");
816
+ const statement = createOrderStatement(headers);
817
+ setDataSource.call(this, { orderBy: statement }, doFetch);
806
818
 
807
- const document = getDocument();
808
- const host = document.querySelector("monster-host");
809
- if (!(host && this.id)) {
810
- return;
811
- }
819
+ const document = getDocument();
820
+ const host = document.querySelector("monster-host");
821
+ if (!(host && this.id)) {
822
+ return;
823
+ }
812
824
 
813
- const configKey = getStoredOrderConfigKey.call(this);
825
+ const configKey = getStoredOrderConfigKey.call(this);
814
826
 
815
- // statement explode with , and remove all empty
816
- const list = statement.split(",").filter((item) => item.trim() !== "");
817
- if (list.length === 0) {
818
- return;
819
- }
827
+ // statement explode with , and remove all empty
828
+ const list = statement.split(",").filter((item) => item.trim() !== "");
829
+ if (list.length === 0) {
830
+ return;
831
+ }
820
832
 
821
- host.setConfig(configKey, list);
833
+ host.setConfig(configKey, list);
822
834
  }
823
835
 
824
836
  /**
825
837
  * @private
826
838
  */
827
839
  function updateGrid() {
828
- if (!this[gridElementSymbol]) {
829
- throw new Error("no grid element is defined");
830
- }
831
-
832
- let gridTemplateColumns = "";
833
-
834
- const headers = this.getOption("headers");
835
-
836
- let styles = "";
837
-
838
- for (let i = 0; i < headers.length; i++) {
839
- const header = headers[i];
840
-
841
- if (header.mode === ATTRIBUTE_DATATABLE_MODE_HIDDEN) {
842
- styles += `[data-monster-role=datatable]>[data-monster-head="${header.labelKey}"] { display: none; }\n`;
843
- styles += `[data-monster-role=datatable-headers]>[data-monster-index="${header.index}"] { display: none; }\n`;
844
- } else {
845
- gridTemplateColumns += `${header.grid} `;
846
- }
847
- }
848
-
849
- const sheet = new CSSStyleSheet();
850
- if (styles !== "") sheet.replaceSync(styles);
851
- this.shadowRoot.adoptedStyleSheets = [...DataTable.getCSSStyleSheet(), sheet];
852
-
853
- const bodyWidth = getDocument().body.getBoundingClientRect().width;
854
-
855
- const breakpoint = this.getOption("responsive.breakpoint");
856
-
857
- if (bodyWidth > breakpoint) {
858
- this[
859
- gridElementSymbol
860
- ].style.gridTemplateColumns = `${gridTemplateColumns}`;
861
- this[
862
- gridHeadersElementSymbol
863
- ].style.gridTemplateColumns = `${gridTemplateColumns}`;
864
- } else {
865
- this[gridElementSymbol].style.gridTemplateColumns = "auto";
866
- this[gridHeadersElementSymbol].style.gridTemplateColumns = "auto";
867
- }
840
+ if (!this[gridElementSymbol]) {
841
+ throw new Error("no grid element is defined");
842
+ }
843
+
844
+ let gridTemplateColumns = "";
845
+
846
+ const headers = this.getOption("headers");
847
+
848
+ let styles = "";
849
+
850
+ for (let i = 0; i < headers.length; i++) {
851
+ const header = headers[i];
852
+
853
+ if (header.mode === ATTRIBUTE_DATATABLE_MODE_HIDDEN) {
854
+ styles += `[data-monster-role=datatable]>[data-monster-head="${header.labelKey}"] { display: none; }\n`;
855
+ styles += `[data-monster-role=datatable-headers]>[data-monster-index="${header.index}"] { display: none; }\n`;
856
+ } else {
857
+ gridTemplateColumns += `${header.grid} `;
858
+ }
859
+ }
860
+
861
+ const sheet = new CSSStyleSheet();
862
+ if (styles !== "") sheet.replaceSync(styles);
863
+ this.shadowRoot.adoptedStyleSheets = [...DataTable.getCSSStyleSheet(), sheet];
864
+
865
+ const bodyWidth = getDocument().body.getBoundingClientRect().width;
866
+
867
+ const breakpoint = this.getOption("responsive.breakpoint");
868
+
869
+ if (bodyWidth > breakpoint) {
870
+ this[gridElementSymbol].style.gridTemplateColumns =
871
+ `${gridTemplateColumns}`;
872
+ this[gridHeadersElementSymbol].style.gridTemplateColumns =
873
+ `${gridTemplateColumns}`;
874
+ } else {
875
+ this[gridElementSymbol].style.gridTemplateColumns = "auto";
876
+ this[gridHeadersElementSymbol].style.gridTemplateColumns = "auto";
877
+ }
868
878
  }
869
879
 
870
880
  /**
@@ -872,20 +882,20 @@ function updateGrid() {
872
882
  * @param {Monster.Components.Datatable.Header[]} headers
873
883
  * @param {bool} doFetch
874
884
  */
875
- function setDataSource({orderBy}, doFetch) {
876
- const datasource = this[datasourceLinkedElementSymbol];
885
+ function setDataSource({ orderBy }, doFetch) {
886
+ const datasource = this[datasourceLinkedElementSymbol];
877
887
 
878
- if (!datasource) {
879
- return;
880
- }
888
+ if (!datasource) {
889
+ return;
890
+ }
881
891
 
882
- if (isFunction(datasource?.setParameters)) {
883
- datasource.setParameters({orderBy});
884
- }
892
+ if (isFunction(datasource?.setParameters)) {
893
+ datasource.setParameters({ orderBy });
894
+ }
885
895
 
886
- if (doFetch !== false && isFunction(datasource?.fetch)) {
887
- datasource.fetch();
888
- }
896
+ if (doFetch !== false && isFunction(datasource?.fetch)) {
897
+ datasource.fetch();
898
+ }
889
899
  }
890
900
 
891
901
  /**
@@ -893,20 +903,20 @@ function setDataSource({orderBy}, doFetch) {
893
903
  * @return {Monster.Components.Datatable.Form}
894
904
  */
895
905
  function initControlReferences() {
896
- if (!this.shadowRoot) {
897
- throw new Error("no shadow-root is defined");
898
- }
899
-
900
- this[gridElementSymbol] = this.shadowRoot.querySelector(
901
- "[data-monster-role=datatable]",
902
- );
903
- this[gridHeadersElementSymbol] = this.shadowRoot.querySelector(
904
- "[data-monster-role=datatable-headers]",
905
- );
906
- this[columnBarElementSymbol] =
907
- this.shadowRoot.querySelector("monster-column-bar");
908
-
909
- return this;
906
+ if (!this.shadowRoot) {
907
+ throw new Error("no shadow-root is defined");
908
+ }
909
+
910
+ this[gridElementSymbol] = this.shadowRoot.querySelector(
911
+ "[data-monster-role=datatable]",
912
+ );
913
+ this[gridHeadersElementSymbol] = this.shadowRoot.querySelector(
914
+ "[data-monster-role=datatable-headers]",
915
+ );
916
+ this[columnBarElementSymbol] =
917
+ this.shadowRoot.querySelector("monster-column-bar");
918
+
919
+ return this;
910
920
  }
911
921
 
912
922
  /**
@@ -916,22 +926,22 @@ function initControlReferences() {
916
926
  * @throws {Error} the datasource could not be initialized
917
927
  */
918
928
  function initOptionsFromArguments() {
919
- const options = {};
920
- const selector = this.getAttribute(ATTRIBUTE_DATASOURCE_SELECTOR);
921
-
922
- if (selector) {
923
- options.datasource = {selector: selector};
924
- }
925
-
926
- const breakpoint = this.getAttribute(
927
- ATTRIBUTE_DATATABLE_RESPONSIVE_BREAKPOINT,
928
- );
929
- if (breakpoint) {
930
- options.responsive = {};
931
- options.responsive.breakpoint = parseInt(breakpoint);
932
- }
933
-
934
- return options;
929
+ const options = {};
930
+ const selector = this.getAttribute(ATTRIBUTE_DATASOURCE_SELECTOR);
931
+
932
+ if (selector) {
933
+ options.datasource = { selector: selector };
934
+ }
935
+
936
+ const breakpoint = this.getAttribute(
937
+ ATTRIBUTE_DATATABLE_RESPONSIVE_BREAKPOINT,
938
+ );
939
+ if (breakpoint) {
940
+ options.responsive = {};
941
+ options.responsive.breakpoint = parseInt(breakpoint);
942
+ }
943
+
944
+ return options;
935
945
  }
936
946
 
937
947
  /**
@@ -939,14 +949,9 @@ function initOptionsFromArguments() {
939
949
  * @return {string}
940
950
  */
941
951
  function getEmptyTemplate() {
942
- return `<monster-state data-monster-role="empty-without-action">
952
+ return `<monster-state data-monster-role="empty-without-action">
943
953
  <div part="visual">
944
- <style>
945
- path {
946
- fill: var(--monster-bg-color-primary-4);
947
- }
948
- </style>
949
- <svg width="4rem" height="4rem" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
954
+ <svg width="4rem" height="4rem" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
950
955
  <path d="m21.5 22h-19c-1.378 0-2.5-1.121-2.5-2.5v-7c0-.07.015-.141.044-.205l3.969-8.82c.404-.896 1.299-1.475 2.28-1.475h11.414c.981 0 1.876.579 2.28 1.475l3.969 8.82c.029.064.044.135.044.205v7c0 1.379-1.122 2.5-2.5 2.5zm-20.5-9.393v6.893c0 .827.673 1.5 1.5 1.5h19c.827 0 1.5-.673 1.5-1.5v-6.893l-3.925-8.723c-.242-.536-.779-.884-1.368-.884h-11.414c-.589 0-1.126.348-1.368.885z"/>
951
956
  <path d="m16.807 17h-9.614c-.622 0-1.186-.391-1.404-.973l-1.014-2.703c-.072-.194-.26-.324-.468-.324h-3.557c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h3.557c.622 0 1.186.391 1.405.973l1.013 2.703c.073.194.261.324.468.324h9.613c.208 0 .396-.13.468-.324l1.013-2.703c.22-.582.784-.973 1.406-.973h3.807c.276 0 .5.224.5.5s-.224.5-.5.5h-3.807c-.208 0-.396.13-.468.324l-1.013 2.703c-.219.582-.784.973-1.405.973z"/>
952
957
  </svg>
@@ -962,8 +967,8 @@ function getEmptyTemplate() {
962
967
  * @return {string}
963
968
  */
964
969
  function getTemplate() {
965
- // language=HTML
966
- return `
970
+ // language=HTML
971
+ return `
967
972
  <div data-monster-role="control" part="control" data-monster-attributes="class path:classes.control">
968
973
  <template id="headers-row">
969
974
  <div data-monster-attributes="class path:headers-row.classes,