@schukai/monster 3.64.1 → 3.65.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (395) hide show
  1. package/CHANGELOG.md +92 -318
  2. package/README.md +44 -40
  3. package/package.json +1 -47
  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 +12 -3
  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/style/dataset.pcss +1 -0
  28. package/source/components/datatable/style/datatable.pcss +1 -0
  29. package/source/components/datatable/stylesheet/change-button.mjs +16 -7
  30. package/source/components/datatable/stylesheet/column-bar.mjs +16 -7
  31. package/source/components/datatable/stylesheet/dataset.mjs +17 -8
  32. package/source/components/datatable/stylesheet/datasource.mjs +16 -7
  33. package/source/components/datatable/stylesheet/datatable.mjs +17 -8
  34. package/source/components/datatable/stylesheet/embedded-pagination.mjs +16 -7
  35. package/source/components/datatable/stylesheet/filter-button.mjs +16 -7
  36. package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +16 -7
  37. package/source/components/datatable/stylesheet/filter-date-range.mjs +16 -7
  38. package/source/components/datatable/stylesheet/filter-range.mjs +16 -7
  39. package/source/components/datatable/stylesheet/filter.mjs +16 -7
  40. package/source/components/datatable/stylesheet/pagination.mjs +16 -7
  41. package/source/components/datatable/stylesheet/save-button.mjs +16 -7
  42. package/source/components/datatable/stylesheet/select-filter.mjs +16 -7
  43. package/source/components/datatable/stylesheet/status.mjs +16 -7
  44. package/source/components/datatable/util.mjs +16 -8
  45. package/source/components/form/action-button.mjs +11 -3
  46. package/source/components/form/api-button.mjs +11 -3
  47. package/source/components/form/button-bar.mjs +11 -3
  48. package/source/components/form/button.mjs +37 -50
  49. package/source/components/form/confirm-button.mjs +11 -3
  50. package/source/components/form/constants.mjs +10 -3
  51. package/source/components/form/context-error.mjs +69 -52
  52. package/source/components/form/context-help.mjs +11 -3
  53. package/source/components/form/field-set.mjs +295 -0
  54. package/source/components/form/form.mjs +12 -4
  55. package/source/components/form/message-state-button.mjs +11 -3
  56. package/source/components/form/popper-button.mjs +11 -3
  57. package/source/components/form/popper.mjs +13 -480
  58. package/source/components/form/reload.mjs +12 -4
  59. package/source/components/form/select.mjs +44 -33
  60. package/source/components/form/shadow-reload.mjs +11 -3
  61. package/source/components/form/state-button.mjs +11 -3
  62. package/source/components/form/style/field-set.pcss +13 -0
  63. package/source/components/form/stylesheet/action-button.mjs +16 -7
  64. package/source/components/form/stylesheet/api-button.mjs +16 -7
  65. package/source/components/form/stylesheet/button-bar.mjs +17 -8
  66. package/source/components/form/stylesheet/button.mjs +16 -7
  67. package/source/components/form/stylesheet/confirm-button.mjs +17 -8
  68. package/source/components/form/stylesheet/context-error.mjs +16 -7
  69. package/source/components/form/stylesheet/context-help.mjs +16 -7
  70. package/source/components/form/stylesheet/field-set.mjs +40 -0
  71. package/source/components/form/stylesheet/form.mjs +17 -8
  72. package/source/components/form/stylesheet/message-state-button.mjs +16 -7
  73. package/source/components/form/stylesheet/popper-button.mjs +16 -7
  74. package/source/components/form/stylesheet/select.mjs +16 -7
  75. package/source/components/form/stylesheet/state-button.mjs +16 -7
  76. package/source/components/form/stylesheet/toggle-switch.mjs +16 -7
  77. package/source/components/form/stylesheet/tree-select.mjs +16 -7
  78. package/source/components/form/tabs.mjs +12 -8
  79. package/source/components/form/template.mjs +11 -3
  80. package/source/components/form/toggle-switch.mjs +12 -8
  81. package/source/components/form/tree-select.mjs +10 -3
  82. package/source/components/form/types/state.mjs +10 -3
  83. package/source/components/form/util/fetch.mjs +10 -3
  84. package/source/components/form/util/floating-ui.mjs +10 -3
  85. package/source/components/form/util/popper.mjs +10 -3
  86. package/source/components/host/call-button.mjs +10 -1
  87. package/source/components/host/collapse.mjs +15 -519
  88. package/source/components/host/config-manager.mjs +10 -1
  89. package/source/components/host/constants.mjs +11 -4
  90. package/source/components/host/details.mjs +14 -256
  91. package/source/components/host/host.mjs +10 -1
  92. package/source/components/host/overlay.mjs +10 -1
  93. package/source/components/host/stylesheet/call-button.mjs +16 -7
  94. package/source/components/host/stylesheet/config-manager.mjs +16 -7
  95. package/source/components/host/stylesheet/host.mjs +17 -8
  96. package/source/components/host/stylesheet/overlay.mjs +17 -8
  97. package/source/components/host/stylesheet/toggle-button.mjs +16 -7
  98. package/source/components/host/stylesheet/viewer.mjs +16 -7
  99. package/source/components/host/toggle-button.mjs +10 -1
  100. package/source/components/host/util.mjs +14 -0
  101. package/source/components/host/viewer.mjs +10 -1
  102. package/source/components/layout/collapse.mjs +543 -0
  103. package/source/components/layout/details.mjs +273 -0
  104. package/source/components/layout/panel.mjs +179 -169
  105. package/source/components/layout/popper.mjs +480 -0
  106. package/source/components/layout/split-panel.mjs +329 -303
  107. package/source/components/{host → layout}/stylesheet/collapse.mjs +16 -7
  108. package/source/components/{host → layout}/stylesheet/details.mjs +16 -7
  109. package/source/components/layout/stylesheet/panel.mjs +16 -7
  110. package/source/components/{form → layout}/stylesheet/popper.mjs +16 -7
  111. package/source/components/layout/stylesheet/split-panel.mjs +16 -7
  112. package/source/components/layout/stylesheet/tabs.mjs +16 -7
  113. package/source/components/layout/stylesheet/width-toggle.mjs +16 -7
  114. package/source/components/layout/tabs.mjs +38 -23
  115. package/source/components/layout/width-toggle.mjs +150 -140
  116. package/source/components/navigation/style/table-of-content.pcss +99 -0
  117. package/source/components/navigation/stylesheet/table-of-content.mjs +40 -0
  118. package/source/components/navigation/table-of-content.mjs +546 -0
  119. package/source/components/notify/constants.mjs +10 -3
  120. package/source/components/notify/message.mjs +16 -9
  121. package/source/components/notify/notify.mjs +11 -4
  122. package/source/components/notify/stylesheet/message.mjs +16 -7
  123. package/source/components/notify/stylesheet/notify.mjs +16 -7
  124. package/source/components/state/log/entry.mjs +10 -1
  125. package/source/components/state/log.mjs +10 -1
  126. package/source/components/state/state.mjs +10 -1
  127. package/source/components/state/stylesheet/log.mjs +16 -7
  128. package/source/components/state/stylesheet/state.mjs +17 -8
  129. package/source/components/style/link.pcss +0 -1
  130. package/source/components/style/mixin/form.pcss +0 -1
  131. package/source/components/style/mixin/typography.pcss +7 -7
  132. package/source/components/style/typography.pcss +1 -1
  133. package/source/components/stylesheet/badge.mjs +16 -7
  134. package/source/components/stylesheet/border.mjs +16 -7
  135. package/source/components/stylesheet/button.mjs +16 -7
  136. package/source/components/stylesheet/card.mjs +16 -7
  137. package/source/components/stylesheet/color.mjs +16 -7
  138. package/source/components/stylesheet/common.mjs +16 -7
  139. package/source/components/stylesheet/control.mjs +16 -7
  140. package/source/components/stylesheet/data-grid.mjs +16 -7
  141. package/source/components/stylesheet/display.mjs +16 -7
  142. package/source/components/stylesheet/floating-ui.mjs +16 -7
  143. package/source/components/stylesheet/form.mjs +16 -7
  144. package/source/components/stylesheet/host.mjs +16 -7
  145. package/source/components/stylesheet/icons.mjs +16 -7
  146. package/source/components/stylesheet/link.mjs +16 -7
  147. package/source/components/stylesheet/mixin/badge.mjs +16 -7
  148. package/source/components/stylesheet/mixin/button.mjs +16 -7
  149. package/source/components/stylesheet/mixin/form.mjs +16 -7
  150. package/source/components/stylesheet/mixin/hover.mjs +16 -7
  151. package/source/components/stylesheet/mixin/icon.mjs +16 -7
  152. package/source/components/stylesheet/mixin/media.mjs +16 -7
  153. package/source/components/stylesheet/mixin/property.mjs +16 -7
  154. package/source/components/stylesheet/mixin/skeleton.mjs +16 -7
  155. package/source/components/stylesheet/mixin/spinner.mjs +16 -7
  156. package/source/components/stylesheet/mixin/typography.mjs +16 -7
  157. package/source/components/stylesheet/normalize.mjs +16 -7
  158. package/source/components/stylesheet/popper.mjs +16 -7
  159. package/source/components/stylesheet/property.mjs +16 -7
  160. package/source/components/stylesheet/ripple.mjs +16 -7
  161. package/source/components/stylesheet/skeleton.mjs +16 -7
  162. package/source/components/stylesheet/space.mjs +16 -7
  163. package/source/components/stylesheet/spinner.mjs +16 -7
  164. package/source/components/stylesheet/table.mjs +16 -7
  165. package/source/components/stylesheet/theme.mjs +16 -7
  166. package/source/components/stylesheet/tree-menu.mjs +10 -3
  167. package/source/components/stylesheet/typography.mjs +17 -8
  168. package/source/components/tree-menu/stylesheet/tree-menu.mjs +16 -7
  169. package/source/components/tree-menu/tree-menu.mjs +19 -8
  170. package/source/constants.mjs +10 -6
  171. package/source/constraints/abstract.mjs +10 -3
  172. package/source/constraints/abstractoperator.mjs +10 -3
  173. package/source/constraints/andoperator.mjs +10 -3
  174. package/source/constraints/invalid.mjs +10 -3
  175. package/source/constraints/isarray.mjs +10 -3
  176. package/source/constraints/isobject.mjs +10 -3
  177. package/source/constraints/oroperator.mjs +10 -3
  178. package/source/constraints/valid.mjs +10 -3
  179. package/source/data/buildmap.mjs +10 -3
  180. package/source/data/buildtree.mjs +10 -3
  181. package/source/data/datasource/dom.mjs +10 -3
  182. package/source/data/datasource/server/restapi/data-fetch-error.mjs +10 -3
  183. package/source/data/datasource/server/restapi/writeerror.mjs +10 -3
  184. package/source/data/datasource/server/restapi.mjs +10 -3
  185. package/source/data/datasource/server/webconnect.mjs +10 -3
  186. package/source/data/datasource/server.mjs +10 -3
  187. package/source/data/datasource/storage/localstorage.mjs +10 -3
  188. package/source/data/datasource/storage/sessionstorage.mjs +10 -3
  189. package/source/data/datasource/storage.mjs +10 -3
  190. package/source/data/datasource.mjs +10 -3
  191. package/source/data/diff.mjs +10 -3
  192. package/source/data/extend.mjs +10 -3
  193. package/source/data/pathfinder.mjs +10 -3
  194. package/source/data/pipe.mjs +10 -3
  195. package/source/data/transformer.mjs +34 -10
  196. package/source/dom/assembler.mjs +10 -3
  197. package/source/dom/attributes.mjs +10 -3
  198. package/source/dom/constants.mjs +10 -3
  199. package/source/dom/customcontrol.mjs +11 -4
  200. package/source/dom/customelement.mjs +31 -17
  201. package/source/dom/dimension.mjs +10 -3
  202. package/source/dom/events.mjs +10 -3
  203. package/source/dom/focusmanager.mjs +10 -3
  204. package/source/dom/locale.mjs +10 -3
  205. package/source/dom/ready.mjs +11 -4
  206. package/source/dom/resource/data.mjs +10 -3
  207. package/source/dom/resource/link/stylesheet.mjs +10 -3
  208. package/source/dom/resource/link.mjs +10 -3
  209. package/source/dom/resource/script.mjs +10 -3
  210. package/source/dom/resource.mjs +10 -3
  211. package/source/dom/resourcemanager.mjs +10 -3
  212. package/source/dom/slotted.mjs +14 -0
  213. package/source/dom/template.mjs +124 -136
  214. package/source/dom/theme.mjs +10 -3
  215. package/source/dom/updater.mjs +10 -3
  216. package/source/dom/util/extract-keys.mjs +10 -3
  217. package/source/dom/util/init-options-from-attributes.mjs +68 -61
  218. package/source/dom/util/set-option-from-attribute.mjs +10 -3
  219. package/source/dom/util.mjs +11 -4
  220. package/source/dom/worker/factory.mjs +10 -3
  221. package/source/i18n/formatter.mjs +10 -3
  222. package/source/i18n/locale.mjs +10 -3
  223. package/source/i18n/provider.mjs +10 -3
  224. package/source/i18n/providers/embed.mjs +10 -3
  225. package/source/i18n/providers/fetch.mjs +10 -3
  226. package/source/i18n/translations.mjs +10 -3
  227. package/source/logging/handler/console.mjs +10 -3
  228. package/source/logging/handler.mjs +10 -3
  229. package/source/logging/logentry.mjs +10 -3
  230. package/source/logging/logger.mjs +10 -3
  231. package/source/math/random.mjs +10 -3
  232. package/source/monster.mjs +8 -93
  233. package/source/net/webconnect/message.mjs +10 -3
  234. package/source/net/webconnect.mjs +20 -5
  235. package/source/text/bracketed-key-value-hash.mjs +10 -3
  236. package/source/text/formatter.mjs +10 -3
  237. package/source/text/generate-range-comparison-expression.mjs +10 -3
  238. package/source/text/util.mjs +14 -0
  239. package/source/types/base.mjs +10 -3
  240. package/source/types/basewithoptions.mjs +10 -3
  241. package/source/types/binary.mjs +10 -3
  242. package/source/types/dataurl.mjs +10 -3
  243. package/source/types/global.mjs +14 -7
  244. package/source/types/id.mjs +10 -3
  245. package/source/types/internal.mjs +11 -3
  246. package/source/types/is.mjs +10 -3
  247. package/source/types/mediatype.mjs +10 -3
  248. package/source/types/node.mjs +10 -3
  249. package/source/types/nodelist.mjs +10 -3
  250. package/source/types/noderecursiveiterator.mjs +10 -3
  251. package/source/types/observablequeue.mjs +10 -3
  252. package/source/types/observer.mjs +10 -3
  253. package/source/types/observerlist.mjs +10 -3
  254. package/source/types/proxyobserver.mjs +14 -5
  255. package/source/types/queue.mjs +10 -3
  256. package/source/types/randomid.mjs +10 -3
  257. package/source/types/regex.mjs +10 -3
  258. package/source/types/stack.mjs +10 -3
  259. package/source/types/tokenlist.mjs +10 -3
  260. package/source/types/typeof.mjs +10 -3
  261. package/source/types/uniquequeue.mjs +10 -3
  262. package/source/types/uuid.mjs +10 -3
  263. package/source/types/validate.mjs +10 -3
  264. package/source/types/version.mjs +11 -4
  265. package/source/util/clone.mjs +10 -3
  266. package/source/util/comparator.mjs +10 -3
  267. package/source/util/deadmansswitch.mjs +10 -3
  268. package/source/util/freeze.mjs +10 -3
  269. package/source/util/processing.mjs +10 -3
  270. package/source/util/runtime.mjs +10 -7
  271. package/source/util/sleep.mjs +10 -10
  272. package/source/util/trimspaces.mjs +10 -3
  273. package/test/cases/data/datasource/server/websocket.mjs +7 -9
  274. package/test/cases/data/transformer.mjs +47 -15
  275. package/test/cases/dom/customcontrol.mjs +0 -1
  276. package/test/cases/dom/customelement.mjs +1 -3
  277. package/test/cases/dom/template.mjs +3 -1
  278. package/test/cases/monster.mjs +1 -1
  279. package/test/util/jsdom.mjs +8 -7
  280. package/test/util/websocket.mjs +5 -1
  281. package/test/web/import.js +2 -1
  282. package/test/web/puppeteer.mjs +111 -0
  283. package/test/web/test.html +2 -2
  284. package/test/web/tests.js +2039 -1192
  285. package/example/components/form/button.mjs +0 -10
  286. package/example/components/form/select.mjs +0 -25
  287. package/example/components/form/toggle-switch.mjs +0 -7
  288. package/example/components/form/tree-select.mjs +0 -27
  289. package/example/components/host/host.mjs +0 -0
  290. package/example/components/notify/message.mjs +0 -4
  291. package/example/components/notify/notify.mjs +0 -4
  292. package/example/components/state/log.mjs +0 -0
  293. package/example/components/state/state.mjs +0 -0
  294. package/example/constraints/andoperator.mjs +0 -17
  295. package/example/constraints/invalid.mjs +0 -6
  296. package/example/constraints/isarray.mjs +0 -11
  297. package/example/constraints/isobject.mjs +0 -12
  298. package/example/constraints/oroperator.mjs +0 -15
  299. package/example/constraints/valid.mjs +0 -6
  300. package/example/data/buildmap.mjs +0 -67
  301. package/example/data/datasource/server/restapi.mjs +0 -20
  302. package/example/data/datasource/server/webconnect.mjs +0 -9
  303. package/example/data/datasource.mjs +0 -7
  304. package/example/data/diff.mjs +0 -39
  305. package/example/data/pathfinder-1.mjs +0 -23
  306. package/example/data/pathfinder-2.mjs +0 -19
  307. package/example/data/pipe.mjs +0 -14
  308. package/example/data/transformer.mjs +0 -9
  309. package/example/dom/customelement.mjs +0 -14
  310. package/example/dom/theme.mjs +0 -5
  311. package/example/dom/updater.mjs +0 -23
  312. package/example/i18n/formatter.mjs +0 -10
  313. package/example/i18n/providers/embed.mjs +0 -5
  314. package/example/i18n/providers/fetch.mjs +0 -5
  315. package/example/i18n/translations.mjs +0 -20
  316. package/example/net/webconnect.mjs +0 -16
  317. package/example/types/basewithoptions.mjs +0 -10
  318. package/example/types/is-1.mjs +0 -5
  319. package/example/types/is-10.mjs +0 -6
  320. package/example/types/is-2.mjs +0 -4
  321. package/example/types/is-3.mjs +0 -4
  322. package/example/types/is-4.mjs +0 -5
  323. package/example/types/is-5.mjs +0 -4
  324. package/example/types/is-6.mjs +0 -4
  325. package/example/types/is-7.mjs +0 -4
  326. package/example/types/is-8.mjs +0 -4
  327. package/example/types/is-9.mjs +0 -6
  328. package/example/types/noderecursiveiterator.mjs +0 -32
  329. package/example/types/observer.mjs +0 -9
  330. package/example/types/proxyobserver.mjs +0 -25
  331. package/example/types/queue.mjs +0 -20
  332. package/example/types/tokenlist-1.mjs +0 -4
  333. package/example/types/tokenlist-2.mjs +0 -7
  334. package/example/types/tokenlist-3.mjs +0 -5
  335. package/example/types/tokenlist-4.mjs +0 -5
  336. package/example/types/tokenlist-5.mjs +0 -5
  337. package/example/types/typeof.mjs +0 -9
  338. package/example/types/version-1.mjs +0 -6
  339. package/example/types/version-2.mjs +0 -3
  340. package/example/util/comparator.mjs +0 -10
  341. package/example/util/deadmansswitch.mjs +0 -9
  342. package/example/util/processing.mjs +0 -17
  343. package/source/components/datatable/datasource/namespace.mjs +0 -13
  344. package/source/components/datatable/datatable/namespace.mjs +0 -13
  345. package/source/components/datatable/events.mjs +0 -24
  346. package/source/components/datatable/filter/namespace.mjs +0 -13
  347. package/source/components/datatable/namespace.mjs +0 -11
  348. package/source/components/datatable/stylesheet/namespace.mjs +0 -13
  349. package/source/components/events.mjs +0 -17
  350. package/source/components/form/events.mjs +0 -108
  351. package/source/components/form/form-field.mjs +0 -341
  352. package/source/components/form/namespace.mjs +0 -13
  353. package/source/components/form/style/form-field.pcss +0 -4
  354. package/source/components/form/stylesheet/form-field.mjs +0 -31
  355. package/source/components/form/stylesheet/namespace.mjs +0 -13
  356. package/source/components/form/types/namespace.mjs +0 -13
  357. package/source/components/form/util/namespace.mjs +0 -13
  358. package/source/components/host/events.mjs +0 -131
  359. package/source/components/host/namespace.mjs +0 -13
  360. package/source/components/host/stylesheet/namespace.mjs +0 -13
  361. package/source/components/layout/events.mjs +0 -30
  362. package/source/components/layout/namespace.mjs +0 -13
  363. package/source/components/namespace.mjs +0 -14
  364. package/source/components/notify/events.mjs +0 -15
  365. package/source/components/notify/namespace.mjs +0 -15
  366. package/source/components/notify/stylesheet/namespace.mjs +0 -15
  367. package/source/components/state/log/namespace.mjs +0 -13
  368. package/source/components/state/namespace.mjs +0 -13
  369. package/source/components/stylesheet/namespace.mjs +0 -13
  370. package/source/components/tree-menu/namespace.mjs +0 -13
  371. package/source/components/tree-menu/stylesheet/namespace.mjs +0 -13
  372. package/source/constraints/namespace.mjs +0 -13
  373. package/source/data/datasource/namespace.mjs +0 -13
  374. package/source/data/datasource/server/namespace.mjs +0 -13
  375. package/source/data/datasource/server/restapi/namespace.mjs +0 -13
  376. package/source/data/datasource/storage/namespace.mjs +0 -13
  377. package/source/data/namespace.mjs +0 -13
  378. package/source/dom/namespace.mjs +0 -13
  379. package/source/dom/resource/link/namespace.mjs +0 -13
  380. package/source/dom/resource/namespace.mjs +0 -13
  381. package/source/dom/util/namespace.mjs +0 -13
  382. package/source/dom/worker/namespace.mjs +0 -13
  383. package/source/i18n/namespace.mjs +0 -13
  384. package/source/i18n/providers/namespace.mjs +0 -13
  385. package/source/logging/handler/namespace.mjs +0 -11
  386. package/source/logging/namespace.mjs +0 -13
  387. package/source/math/namespace.mjs +0 -13
  388. package/source/net/namespace.mjs +0 -13
  389. package/source/net/webconnect/namespace.mjs +0 -13
  390. package/source/text/namespace.mjs +0 -13
  391. package/source/types/namespace.mjs +0 -13
  392. package/source/util/namespace.mjs +0 -13
  393. /package/source/components/{host → layout}/style/collapse.pcss +0 -0
  394. /package/source/components/{host → layout}/style/details.pcss +0 -0
  395. /package/source/components/{form → layout}/style/popper.pcss +0 -0
@@ -0,0 +1,480 @@
1
+ /**
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
+ *
12
+ * SPDX-License-Identifier: AGPL-3.0
13
+ */
14
+
15
+ import { instanceSymbol } from "../../constants.mjs";
16
+ import {
17
+ addAttributeToken,
18
+ removeAttributeToken,
19
+ } from "../../dom/attributes.mjs";
20
+ import { ATTRIBUTE_ROLE } from "../../dom/constants.mjs";
21
+ import {
22
+ assembleMethodSymbol,
23
+ CustomElement,
24
+ registerCustomElement,
25
+ } from "../../dom/customelement.mjs";
26
+ import { fireCustomEvent } from "../../dom/events.mjs";
27
+ import { getDocument } from "../../dom/util.mjs";
28
+ import { DeadMansSwitch } from "../../util/deadmansswitch.mjs";
29
+ import { STYLE_DISPLAY_MODE_BLOCK } from "../form/constants.mjs";
30
+ import { positionPopper } from "../form/util/floating-ui.mjs";
31
+ import { CustomControl } from "../../dom/customcontrol.mjs";
32
+ import { PopperStyleSheet } from "./stylesheet/popper.mjs";
33
+ import { isArray } from "../../types/is.mjs";
34
+
35
+ export { Popper };
36
+
37
+ /**
38
+ * @private
39
+ * @type {symbol}
40
+ */
41
+ const timerCallbackSymbol = Symbol("timerCallback");
42
+
43
+ /**
44
+ * local symbol
45
+ * @private
46
+ * @type {symbol}
47
+ */
48
+ const resizeObserverSymbol = Symbol("resizeObserver");
49
+
50
+ /**
51
+ * local symbol
52
+ * @private
53
+ * @type {symbol}
54
+ */
55
+ const closeEventHandler = Symbol("closeEventHandler");
56
+
57
+ /**
58
+ * @private
59
+ * @type {symbol}
60
+ */
61
+ const controlElementSymbol = Symbol("controlElement");
62
+
63
+ /**
64
+ * @private
65
+ * @type {symbol}
66
+ */
67
+ const buttonElementSymbol = Symbol("buttonElement");
68
+
69
+ /**
70
+ * local symbol
71
+ * @private
72
+ * @type {symbol}
73
+ */
74
+ const popperElementSymbol = Symbol("popperElement");
75
+
76
+ /**
77
+ * local symbol
78
+ * @private
79
+ * @type {symbol}
80
+ */
81
+ const arrowElementSymbol = Symbol("arrowElement");
82
+
83
+ /**
84
+ * A Popper is a floating UI element that can be shown or hidden.
85
+ *
86
+ * @fragments /fragments/components/layout/popper/
87
+ *
88
+ * @example /examples/components/layout/popper-simple
89
+ * @example /examples/components/layout/popper-click
90
+ *
91
+ * @since 1.65.0
92
+ * @copyright schukai GmbH
93
+ * @summary A beautiful popper that can make your life easier and also looks good.
94
+ * @fires monster-popper-hide fired when the popper is hide.
95
+ * @fires monster-popper-hidden fired when the popper is hidden.
96
+ * @fires monster-popper-open fired when the popper is open.
97
+ * @fires monster-popper-opened fired when the popper is opened.
98
+ */
99
+ class Popper extends CustomElement {
100
+ /**
101
+ * This method is called by the `instanceof` operator.
102
+ * @returns {symbol}
103
+ */
104
+ static get [instanceSymbol]() {
105
+ return Symbol.for("@schukai/monster/components/layout/popper@@instance");
106
+ }
107
+
108
+ /**
109
+ * To set the options via the html tag the attribute `data-monster-options` must be used.
110
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
111
+ *
112
+ * The individual configuration values can be found in the table.
113
+ *
114
+ * @property {Object} templates The templates for the control.
115
+ * @property {string} templates.main The main template.
116
+ * @property {string} mode The mode of the popper. Possible values are `click`, `enter`, `manual`, `focus`, "auto" or a combination of them.
117
+ * @property {string} content The content of the popper.
118
+ * @property {object} popper The popper options.
119
+ * @property {string} popper.placement The placement of the popper. Possible values are `top`, `bottom`, `left` and `right`.
120
+ * @property {function[]} popper.middleware The middleware functions of the popper.
121
+ * @property {Object} features The features of the popper.
122
+ * @property {boolean} features.preventOpenEventSent Prevents the open event from being sent.
123
+ */
124
+ get defaults() {
125
+ return Object.assign({}, super.defaults, {
126
+ templates: {
127
+ main: getTemplate(),
128
+ },
129
+ mode: "auto focus",
130
+ content: "<slot></slot>",
131
+ popper: {
132
+ placement: "top",
133
+ middleware: ["autoPlacement", "offset:10", "arrow"],
134
+ },
135
+ features: {
136
+ preventOpenEventSent: false,
137
+ },
138
+ });
139
+ }
140
+
141
+ /**
142
+ * This method is called by the `connectedCallback` method on the first call.
143
+ *
144
+ * @return {Void}
145
+ */
146
+ [assembleMethodSymbol]() {
147
+ super[assembleMethodSymbol]();
148
+ initControlReferences.call(this);
149
+ initEventHandler.call(this);
150
+ }
151
+
152
+ /**
153
+ * This method returns the tag name of the element.
154
+ *
155
+ * @return {string}
156
+ */
157
+ static getTag() {
158
+ return "monster-popper";
159
+ }
160
+
161
+ /**
162
+ * This method returns the css styles of the element.
163
+ *
164
+ * @return {CSSStyleSheet[]}
165
+ */
166
+ static getCSSStyleSheet() {
167
+ return [PopperStyleSheet];
168
+ }
169
+
170
+ /**
171
+ * This method is called when the element is connected to the dom.
172
+ *
173
+ * @return {void}
174
+ */
175
+ connectedCallback() {
176
+ super.connectedCallback();
177
+
178
+ const document = getDocument();
179
+
180
+ for (const [, type] of Object.entries(["click", "touch"])) {
181
+ // close on outside ui-events
182
+ document.addEventListener(type, this[closeEventHandler]);
183
+ }
184
+
185
+ updatePopper.call(this);
186
+ attachResizeObserver.call(this);
187
+ }
188
+
189
+ /**
190
+ * This method is called when the element is disconnected from the dom.
191
+ *
192
+ * @return {void}
193
+ */
194
+ disconnectedCallback() {
195
+ super.disconnectedCallback();
196
+
197
+ // close on outside ui-events
198
+ for (const [, type] of Object.entries(["click", "touch"])) {
199
+ document.removeEventListener(type, this[closeEventHandler]);
200
+ }
201
+
202
+ disconnectResizeObserver.call(this);
203
+ }
204
+
205
+ /**
206
+ * With this method you can show the popper.
207
+ *
208
+ * @return {Popper}
209
+ */
210
+ showDialog() {
211
+ show.call(this);
212
+ return this;
213
+ }
214
+
215
+ /**
216
+ * With this method you can hide the popper.
217
+ *
218
+ * @return {Popper}
219
+ */
220
+ hideDialog() {
221
+ hide.call(this);
222
+ return this;
223
+ }
224
+
225
+ /**
226
+ * With this method you can toggle the popper.
227
+ *
228
+ * @return {Popper}
229
+ */
230
+ toggleDialog() {
231
+ if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
232
+ this.hideDialog();
233
+ } else {
234
+ this.showDialog();
235
+ }
236
+ return this;
237
+ }
238
+ }
239
+
240
+ /**
241
+ * @private
242
+ * @return {Popper}
243
+ */
244
+ function initEventHandler() {
245
+ this[closeEventHandler] = (event) => {
246
+ const path = event.composedPath();
247
+
248
+ for (const [, element] of Object.entries(path)) {
249
+ if (element === this) {
250
+ return;
251
+ }
252
+ }
253
+ hide.call(this);
254
+ };
255
+
256
+ let modes = null;
257
+ const modeOption = this.getOption("mode");
258
+
259
+ if (typeof modeOption === "string") {
260
+ modes = modeOption.split(" ");
261
+ }
262
+
263
+ if (
264
+ modes === null ||
265
+ modes === undefined ||
266
+ isArray(modes) === false ||
267
+ modes.length === 0
268
+ ) {
269
+ modes = ["manual"];
270
+ }
271
+
272
+ for (const [, mode] of Object.entries(modes)) {
273
+ initEventHandlerByMode.call(this, mode);
274
+ }
275
+
276
+ return this;
277
+ }
278
+
279
+ /**
280
+ * @private
281
+ * @param mode
282
+ * @return {Popper}
283
+ * @throws Error
284
+ */
285
+ function initEventHandlerByMode(mode) {
286
+ switch (mode) {
287
+ case "manual":
288
+ break;
289
+
290
+ case "focus":
291
+ this[buttonElementSymbol].addEventListener("focus", (event) => {
292
+ if (this.getOption("features.preventOpenEventSent") === true) {
293
+ event.preventDefault();
294
+ }
295
+ this.showDialog();
296
+ });
297
+ this[buttonElementSymbol].addEventListener("blur", (event) => {
298
+ if (this.getOption("features.preventOpenEventSent") === true) {
299
+ event.preventDefault();
300
+ }
301
+ this.hideDialog();
302
+ });
303
+ break;
304
+
305
+ case "click":
306
+ this[buttonElementSymbol].addEventListener("click", (event) => {
307
+ if (this.getOption("features.preventOpenEventSent") === true) {
308
+ event.preventDefault();
309
+ }
310
+ this.toggleDialog();
311
+ });
312
+ break;
313
+ case "enter":
314
+ this[buttonElementSymbol].addEventListener("mouseenter", (event) => {
315
+ if (this.getOption("features.preventOpenEventSent") === true) {
316
+ event.preventDefault();
317
+ }
318
+ this.showDialog();
319
+ });
320
+ break;
321
+
322
+ case "auto": // is hover
323
+ this[buttonElementSymbol].addEventListener("mouseenter", (event) => {
324
+ if (this.getOption("features.preventOpenEventSent") === true) {
325
+ event.preventDefault();
326
+ }
327
+ this.showDialog();
328
+ });
329
+ this[buttonElementSymbol].addEventListener("mouseleave", (event) => {
330
+ if (this.getOption("features.preventOpenEventSent") === true) {
331
+ event.preventDefault();
332
+ }
333
+ this.hideDialog();
334
+ });
335
+ break;
336
+ default:
337
+ throw new Error(`Unknown mode ${mode}`);
338
+ }
339
+ }
340
+
341
+ /**
342
+ * @private
343
+ */
344
+ function attachResizeObserver() {
345
+ // against flickering
346
+ this[resizeObserverSymbol] = new ResizeObserver((entries) => {
347
+ if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
348
+ try {
349
+ this[timerCallbackSymbol].touch();
350
+ return;
351
+ } catch (e) {
352
+ delete this[timerCallbackSymbol];
353
+ }
354
+ }
355
+
356
+ this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
357
+ updatePopper.call(this);
358
+ });
359
+ });
360
+
361
+ this[resizeObserverSymbol].observe(this.parentElement);
362
+ }
363
+
364
+ function disconnectResizeObserver() {
365
+ if (this[resizeObserverSymbol] instanceof ResizeObserver) {
366
+ this[resizeObserverSymbol].disconnect();
367
+ }
368
+ }
369
+
370
+ /**
371
+ * @private
372
+ */
373
+ function hide() {
374
+ const self = this;
375
+
376
+ fireCustomEvent(self, "monster-popper-hide", {
377
+ self,
378
+ });
379
+
380
+ self[popperElementSymbol].style.display = "none";
381
+ removeAttributeToken(self[controlElementSymbol], "class", "open");
382
+
383
+ setTimeout(() => {
384
+ fireCustomEvent(self, "monster-popper-hidden", {
385
+ self,
386
+ });
387
+ }, 0);
388
+ }
389
+
390
+ /**
391
+ * @private
392
+ */
393
+ function show() {
394
+ const self = this;
395
+
396
+ if (self.getOption("disabled", false) === true) {
397
+ return;
398
+ }
399
+
400
+ if (self[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
401
+ return;
402
+ }
403
+
404
+ fireCustomEvent(self, "monster-popper-open", {
405
+ self,
406
+ });
407
+
408
+ self[popperElementSymbol].style.visibility = "hidden";
409
+ self[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
410
+
411
+ addAttributeToken(self[controlElementSymbol], "class", "open");
412
+ updatePopper.call(self);
413
+
414
+ setTimeout(() => {
415
+ fireCustomEvent(self, "monster-popper-opened", {
416
+ self,
417
+ });
418
+ }, 0);
419
+ }
420
+
421
+ /**
422
+ * @private
423
+ */
424
+ function updatePopper() {
425
+ if (this[popperElementSymbol].style.display !== STYLE_DISPLAY_MODE_BLOCK) {
426
+ return;
427
+ }
428
+
429
+ if (this.getOption("disabled", false) === true) {
430
+ return;
431
+ }
432
+
433
+ positionPopper.call(
434
+ this,
435
+ this[controlElementSymbol],
436
+ this[popperElementSymbol],
437
+ this.getOption("popper", {}),
438
+ );
439
+ }
440
+
441
+ /**
442
+ * @private
443
+ * @return {Popper}
444
+ */
445
+ function initControlReferences() {
446
+ this[controlElementSymbol] = this.shadowRoot.querySelector(
447
+ `[${ATTRIBUTE_ROLE}=control]`,
448
+ );
449
+ this[buttonElementSymbol] = this.shadowRoot.querySelector(
450
+ `[${ATTRIBUTE_ROLE}=button]`,
451
+ );
452
+ this[popperElementSymbol] = this.shadowRoot.querySelector(
453
+ `[${ATTRIBUTE_ROLE}=popper]`,
454
+ );
455
+ this[arrowElementSymbol] = this.shadowRoot.querySelector(
456
+ `[${ATTRIBUTE_ROLE}=arrow]`,
457
+ );
458
+ return this;
459
+ }
460
+
461
+ /**
462
+ * @private
463
+ * @return {string}
464
+ */
465
+ function getTemplate() {
466
+ // language=HTML
467
+ return `
468
+ <div data-monster-role="control" part="control">
469
+ <slot name="button" data-monster-role="button"></slot>
470
+
471
+ <div data-monster-role="popper" part="popper" tabindex="-1" class="monster-color-primary-1">
472
+ <div data-monster-role="arrow"></div>
473
+ <div part="content" class="flex" data-monster-replace="path:content">
474
+ </div>
475
+ </div>
476
+ </div>
477
+ `;
478
+ }
479
+
480
+ registerCustomElement(Popper);