@schukai/monster 3.51.5 → 3.52.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (360) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +15 -12
  3. package/example/components/form/button.mjs +10 -0
  4. package/example/components/form/select.mjs +25 -0
  5. package/example/components/form/tree-select.mjs +27 -0
  6. package/example/components/host/host.mjs +0 -0
  7. package/example/components/notify/message.mjs +4 -0
  8. package/example/components/notify/notify.mjs +4 -0
  9. package/example/components/state/log.mjs +0 -0
  10. package/example/components/state/state.mjs +0 -0
  11. package/package.json +6 -2
  12. package/source/components/constants.mjs +132 -0
  13. package/source/components/datatable/columnbar.mjs +310 -0
  14. package/source/components/datatable/constants.mjs +121 -0
  15. package/source/components/datatable/dataset.mjs +219 -0
  16. package/source/components/datatable/datasource/dom.mjs +186 -0
  17. package/source/components/datatable/datasource/namespace.mjs +13 -0
  18. package/source/components/datatable/datasource/rest.mjs +400 -0
  19. package/source/components/datatable/datasource.mjs +102 -0
  20. package/source/components/datatable/datatable/header.mjs +268 -0
  21. package/source/components/datatable/datatable/namespace.mjs +13 -0
  22. package/source/components/datatable/datatable.mjs +789 -0
  23. package/source/components/datatable/embedded-pagination.mjs +113 -0
  24. package/source/components/datatable/filter/abstract-base.mjs +31 -0
  25. package/source/components/datatable/filter/date-range.mjs +1041 -0
  26. package/source/components/datatable/filter/input.mjs +175 -0
  27. package/source/components/datatable/filter/namespace.mjs +13 -0
  28. package/source/components/datatable/filter/range.mjs +671 -0
  29. package/source/components/datatable/filter/select.mjs +65 -0
  30. package/source/components/datatable/filter/settings.mjs +116 -0
  31. package/source/components/datatable/filter-button.mjs +98 -0
  32. package/source/components/datatable/filter.mjs +929 -0
  33. package/source/components/datatable/namespace.mjs +11 -0
  34. package/source/components/datatable/pagination.mjs +456 -0
  35. package/source/components/datatable/style/column-bar.pcss +123 -0
  36. package/source/components/datatable/style/dataset.pcss +13 -0
  37. package/source/components/datatable/style/datasource.pcss +16 -0
  38. package/source/components/datatable/style/datatable.pcss +239 -0
  39. package/source/components/datatable/style/embedded-pagination.pcss +101 -0
  40. package/source/components/datatable/style/filter-button.pcss +22 -0
  41. package/source/components/datatable/style/filter-controls-defaults.pcss +46 -0
  42. package/source/components/datatable/style/filter-date-range.pcss +9 -0
  43. package/source/components/datatable/style/filter-range.pcss +5 -0
  44. package/source/components/datatable/style/filter.pcss +156 -0
  45. package/source/components/datatable/style/pagination.pcss +59 -0
  46. package/source/components/datatable/style/select-filter.pcss +27 -0
  47. package/source/components/datatable/stylesheet/column-bar.mjs +33 -0
  48. package/source/components/datatable/stylesheet/dataset.mjs +33 -0
  49. package/source/components/datatable/stylesheet/datasource.mjs +33 -0
  50. package/source/components/datatable/stylesheet/datatable.mjs +33 -0
  51. package/source/components/datatable/stylesheet/embedded-pagination.mjs +33 -0
  52. package/source/components/datatable/stylesheet/filter-button.mjs +33 -0
  53. package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +33 -0
  54. package/source/components/datatable/stylesheet/filter-date-range.mjs +33 -0
  55. package/source/components/datatable/stylesheet/filter-range.mjs +33 -0
  56. package/source/components/datatable/stylesheet/filter.mjs +33 -0
  57. package/source/components/datatable/stylesheet/namespace.mjs +13 -0
  58. package/source/components/datatable/stylesheet/pagination.mjs +33 -0
  59. package/source/components/datatable/stylesheet/select-filter.mjs +33 -0
  60. package/source/components/datatable/util.mjs +60 -0
  61. package/source/components/form/action-button.mjs +262 -0
  62. package/source/components/form/api-button.mjs +515 -0
  63. package/source/components/form/button-bar.mjs +739 -0
  64. package/source/components/form/button.mjs +350 -0
  65. package/source/components/form/confirm-button.mjs +330 -0
  66. package/source/components/form/constants.mjs +111 -0
  67. package/source/components/form/context-help.mjs +123 -0
  68. package/source/components/form/events.mjs +84 -0
  69. package/source/components/form/form.mjs +601 -0
  70. package/source/components/form/message-state-button.mjs +396 -0
  71. package/source/components/form/namespace.mjs +13 -0
  72. package/source/components/form/popper-button.mjs +435 -0
  73. package/source/components/form/popper.mjs +487 -0
  74. package/source/components/form/reload.mjs +360 -0
  75. package/source/components/form/select.mjs +2314 -0
  76. package/source/components/form/shadow-reload.mjs +137 -0
  77. package/source/components/form/state-button.mjs +182 -0
  78. package/source/components/form/style/action-button.pcss +41 -0
  79. package/source/components/form/style/api-button.pcss +0 -0
  80. package/source/components/form/style/button-bar.pcss +51 -0
  81. package/source/components/form/style/button.pcss +8 -0
  82. package/source/components/form/style/confirm-button.pcss +17 -0
  83. package/source/components/form/style/context-help.pcss +16 -0
  84. package/source/components/form/style/form.pcss +10 -0
  85. package/source/components/form/style/message-state-button.pcss +10 -0
  86. package/source/components/form/style/popper-button.pcss +16 -0
  87. package/source/components/form/style/popper.pcss +8 -0
  88. package/source/components/form/style/select.pcss +265 -0
  89. package/source/components/form/style/state-button.pcss +116 -0
  90. package/source/components/form/style/tabs.pcss +170 -0
  91. package/source/components/form/style/tree-select.pcss +81 -0
  92. package/source/components/form/stylesheet/action-button.mjs +33 -0
  93. package/source/components/form/stylesheet/api-button.mjs +33 -0
  94. package/source/components/form/stylesheet/button-bar.mjs +33 -0
  95. package/source/components/form/stylesheet/button.mjs +33 -0
  96. package/source/components/form/stylesheet/confirm-button.mjs +33 -0
  97. package/source/components/form/stylesheet/context-help.mjs +33 -0
  98. package/source/components/form/stylesheet/form.mjs +33 -0
  99. package/source/components/form/stylesheet/message-state-button.mjs +33 -0
  100. package/source/components/form/stylesheet/namespace.mjs +13 -0
  101. package/source/components/form/stylesheet/popper-button.mjs +33 -0
  102. package/source/components/form/stylesheet/popper.mjs +33 -0
  103. package/source/components/form/stylesheet/select.mjs +33 -0
  104. package/source/components/form/stylesheet/state-button.mjs +33 -0
  105. package/source/components/form/stylesheet/tabs.mjs +33 -0
  106. package/source/components/form/stylesheet/tree-select.mjs +33 -0
  107. package/source/components/form/tabs.mjs +1011 -0
  108. package/source/components/form/template.mjs +373 -0
  109. package/source/components/form/tree-select.mjs +527 -0
  110. package/source/components/form/types/namespace.mjs +13 -0
  111. package/source/components/form/types/state.mjs +93 -0
  112. package/source/components/form/util/fetch.mjs +133 -0
  113. package/source/components/form/util/floating-ui.mjs +245 -0
  114. package/source/components/form/util/namespace.mjs +13 -0
  115. package/source/components/form/util/popper.mjs +49 -0
  116. package/source/components/host/call-button.mjs +236 -0
  117. package/source/components/host/collapse.mjs +526 -0
  118. package/source/components/host/config-manager.mjs +304 -0
  119. package/source/components/host/constants.mjs +18 -0
  120. package/source/components/host/details.mjs +268 -0
  121. package/source/components/host/events.mjs +131 -0
  122. package/source/components/host/host.mjs +420 -0
  123. package/source/components/host/namespace.mjs +13 -0
  124. package/source/components/host/overlay.mjs +339 -0
  125. package/source/components/host/style/call-button.pcss +36 -0
  126. package/source/components/host/style/collapse.pcss +67 -0
  127. package/source/components/host/style/config-manager.pcss +5 -0
  128. package/source/components/host/style/details.pcss +68 -0
  129. package/source/components/host/style/host.pcss +43 -0
  130. package/source/components/host/style/overlay.pcss +73 -0
  131. package/source/components/host/style/toggle-button.pcss +36 -0
  132. package/source/components/host/style/viewer.pcss +13 -0
  133. package/source/components/host/stylesheet/call-button.mjs +33 -0
  134. package/source/components/host/stylesheet/collapse.mjs +33 -0
  135. package/source/components/host/stylesheet/config-manager.mjs +33 -0
  136. package/source/components/host/stylesheet/details.mjs +33 -0
  137. package/source/components/host/stylesheet/host.mjs +33 -0
  138. package/source/components/host/stylesheet/namespace.mjs +13 -0
  139. package/source/components/host/stylesheet/overlay.mjs +33 -0
  140. package/source/components/host/stylesheet/toggle-button.mjs +33 -0
  141. package/source/components/host/stylesheet/viewer.mjs +33 -0
  142. package/source/components/host/toggle-button.mjs +88 -0
  143. package/source/components/host/util.mjs +23 -0
  144. package/source/components/host/viewer.mjs +309 -0
  145. package/source/components/namespace.mjs +14 -0
  146. package/source/components/notify/constants.mjs +15 -0
  147. package/source/components/notify/events.mjs +15 -0
  148. package/source/components/notify/message.mjs +374 -0
  149. package/source/components/notify/namespace.mjs +15 -0
  150. package/source/components/notify/notify.mjs +236 -0
  151. package/source/components/notify/style/message.pcss +57 -0
  152. package/source/components/notify/style/notify.pcss +118 -0
  153. package/source/components/notify/stylesheet/message.mjs +33 -0
  154. package/source/components/notify/stylesheet/namespace.mjs +15 -0
  155. package/source/components/notify/stylesheet/notify.mjs +33 -0
  156. package/source/components/state/log/entry.mjs +126 -0
  157. package/source/components/state/log/namespace.mjs +13 -0
  158. package/source/components/state/log.mjs +275 -0
  159. package/source/components/state/namespace.mjs +13 -0
  160. package/source/components/state/state.mjs +131 -0
  161. package/source/components/state/style/log.pcss +111 -0
  162. package/source/components/state/style/state.pcss +113 -0
  163. package/source/components/state/stylesheet/log.mjs +33 -0
  164. package/source/components/state/stylesheet/state.mjs +33 -0
  165. package/source/components/style/badge.pcss +92 -0
  166. package/source/components/style/border.pcss +77 -0
  167. package/source/components/style/button.pcss +105 -0
  168. package/source/components/style/card.pcss +108 -0
  169. package/source/components/style/color.pcss +257 -0
  170. package/source/components/style/common.pcss +103 -0
  171. package/source/components/style/control.pcss +11 -0
  172. package/source/components/style/data-grid.pcss +43 -0
  173. package/source/components/style/display.pcss +42 -0
  174. package/source/components/style/floating-ui.pcss +33 -0
  175. package/source/components/style/form.pcss +5 -0
  176. package/source/components/style/host.pcss +15 -0
  177. package/source/components/style/link.pcss +63 -0
  178. package/source/components/style/mixin/badge.pcss +18 -0
  179. package/source/components/style/mixin/button.pcss +54 -0
  180. package/source/components/style/mixin/form.pcss +247 -0
  181. package/source/components/style/mixin/hover.pcss +8 -0
  182. package/source/components/style/mixin/media.pcss +107 -0
  183. package/source/components/style/mixin/property.pcss +288 -0
  184. package/source/components/style/mixin/skeleton.pcss +26 -0
  185. package/source/components/style/mixin/spinner.pcss +24 -0
  186. package/source/components/style/mixin/typography.pcss +52 -0
  187. package/source/components/style/normalize.pcss +14 -0
  188. package/source/components/style/popper.pcss +78 -0
  189. package/source/components/style/property.pcss +17 -0
  190. package/source/components/style/ripple.pcss +14 -0
  191. package/source/components/style/skeleton.pcss +28 -0
  192. package/source/components/style/space.pcss +47 -0
  193. package/source/components/style/spinner.pcss +6 -0
  194. package/source/components/style/table.pcss +46 -0
  195. package/source/components/style/theme.pcss +119 -0
  196. package/source/components/style/typography.pcss +131 -0
  197. package/source/components/stylesheet/badge.mjs +33 -0
  198. package/source/components/stylesheet/border.mjs +33 -0
  199. package/source/components/stylesheet/button.mjs +33 -0
  200. package/source/components/stylesheet/card.mjs +33 -0
  201. package/source/components/stylesheet/color.mjs +33 -0
  202. package/source/components/stylesheet/common.mjs +33 -0
  203. package/source/components/stylesheet/control.mjs +33 -0
  204. package/source/components/stylesheet/data-grid.mjs +33 -0
  205. package/source/components/stylesheet/display.mjs +33 -0
  206. package/source/components/stylesheet/floating-ui.mjs +33 -0
  207. package/source/components/stylesheet/form.mjs +33 -0
  208. package/source/components/stylesheet/host.mjs +33 -0
  209. package/source/components/stylesheet/link.mjs +33 -0
  210. package/source/components/stylesheet/namespace.mjs +13 -0
  211. package/source/components/stylesheet/normalize.mjs +33 -0
  212. package/source/components/stylesheet/popper.mjs +33 -0
  213. package/source/components/stylesheet/property.mjs +33 -0
  214. package/source/components/stylesheet/ripple.mjs +33 -0
  215. package/source/components/stylesheet/skeleton.mjs +33 -0
  216. package/source/components/stylesheet/space.mjs +33 -0
  217. package/source/components/stylesheet/spinner.mjs +33 -0
  218. package/source/components/stylesheet/table.mjs +33 -0
  219. package/source/components/stylesheet/theme.mjs +33 -0
  220. package/source/components/stylesheet/tree-menu.mjs +33 -0
  221. package/source/components/stylesheet/typography.mjs +33 -0
  222. package/source/components/tree-menu/namespace.mjs +13 -0
  223. package/source/components/tree-menu/style/tree-menu.pcss +107 -0
  224. package/source/components/tree-menu/stylesheet/namespace.mjs +13 -0
  225. package/source/components/tree-menu/stylesheet/tree-menu.mjs +33 -0
  226. package/source/components/tree-menu/tree-menu.mjs +660 -0
  227. package/source/constraints/abstract.mjs +17 -24
  228. package/source/constraints/abstractoperator.mjs +27 -22
  229. package/source/constraints/andoperator.mjs +20 -17
  230. package/source/constraints/invalid.mjs +17 -17
  231. package/source/constraints/isarray.mjs +20 -20
  232. package/source/constraints/isobject.mjs +20 -20
  233. package/source/constraints/oroperator.mjs +45 -45
  234. package/source/constraints/valid.mjs +17 -17
  235. package/source/data/buildmap.mjs +108 -103
  236. package/source/data/buildtree.mjs +59 -57
  237. package/source/data/datasource/dom.mjs +80 -84
  238. package/source/data/datasource/namespace.mjs +1 -1
  239. package/source/data/datasource/server/restapi/data-fetch-error.mjs +27 -25
  240. package/source/data/datasource/server/restapi/writeerror.mjs +34 -32
  241. package/source/data/datasource/server/restapi.mjs +176 -177
  242. package/source/data/datasource/server/webconnect.mjs +150 -156
  243. package/source/data/datasource/server.mjs +58 -59
  244. package/source/data/datasource/storage/localstorage.mjs +25 -24
  245. package/source/data/datasource/storage/sessionstorage.mjs +28 -25
  246. package/source/data/datasource/storage.mjs +74 -73
  247. package/source/data/datasource.mjs +176 -167
  248. package/source/data/diff.mjs +98 -97
  249. package/source/data/extend.mjs +42 -42
  250. package/source/data/pathfinder.mjs +301 -288
  251. package/source/data/pipe.mjs +36 -36
  252. package/source/data/transformer.mjs +742 -726
  253. package/source/dom/assembler.mjs +44 -44
  254. package/source/dom/attributes.mjs +142 -122
  255. package/source/dom/constants.mjs +62 -58
  256. package/source/dom/customcontrol.mjs +299 -299
  257. package/source/dom/customelement.mjs +843 -806
  258. package/source/dom/dimension.mjs +56 -46
  259. package/source/dom/events.mjs +74 -69
  260. package/source/dom/focusmanager.mjs +175 -175
  261. package/source/dom/locale.mjs +28 -28
  262. package/source/dom/ready.mjs +13 -13
  263. package/source/dom/resource/data.mjs +117 -111
  264. package/source/dom/resource/link/stylesheet.mjs +16 -16
  265. package/source/dom/resource/link.mjs +94 -96
  266. package/source/dom/resource/script.mjs +72 -74
  267. package/source/dom/resource.mjs +174 -172
  268. package/source/dom/resourcemanager.mjs +152 -156
  269. package/source/dom/slotted.mjs +78 -80
  270. package/source/dom/template.mjs +126 -112
  271. package/source/dom/theme.mjs +35 -35
  272. package/source/dom/updater.mjs +673 -651
  273. package/source/dom/util/extract-keys.mjs +34 -22
  274. package/source/dom/util/init-options-from-attributes.mjs +46 -38
  275. package/source/dom/util/namespace.mjs +13 -0
  276. package/source/dom/util/set-option-from-attribute.mjs +35 -29
  277. package/source/dom/util.mjs +112 -81
  278. package/source/dom/worker/factory.mjs +83 -83
  279. package/source/i18n/formatter.mjs +75 -73
  280. package/source/i18n/locale.mjs +146 -144
  281. package/source/i18n/provider.mjs +70 -64
  282. package/source/i18n/providers/embed.mjs +136 -127
  283. package/source/i18n/providers/fetch.mjs +84 -76
  284. package/source/i18n/translations.mjs +205 -195
  285. package/source/logging/handler/console.mjs +36 -36
  286. package/source/logging/handler.mjs +140 -140
  287. package/source/logging/logentry.mjs +25 -25
  288. package/source/logging/logger.mjs +177 -175
  289. package/source/math/random.mjs +63 -59
  290. package/source/monster.mjs +223 -103
  291. package/source/net/webconnect/message.mjs +31 -31
  292. package/source/net/webconnect.mjs +278 -271
  293. package/source/text/bracketed-key-value-hash.mjs +182 -179
  294. package/source/text/formatter.mjs +235 -210
  295. package/source/text/generate-range-comparison-expression.mjs +56 -34
  296. package/source/text/namespace.mjs +1 -1
  297. package/source/types/base.mjs +69 -61
  298. package/source/types/basewithoptions.mjs +46 -46
  299. package/source/types/binary.mjs +20 -20
  300. package/source/types/dataurl.mjs +96 -90
  301. package/source/types/global.mjs +45 -39
  302. package/source/types/id.mjs +25 -25
  303. package/source/types/internal.mjs +115 -114
  304. package/source/types/is.mjs +56 -40
  305. package/source/types/mediatype.mjs +119 -119
  306. package/source/types/namespace.mjs +1 -1
  307. package/source/types/node.mjs +160 -150
  308. package/source/types/nodelist.mjs +94 -96
  309. package/source/types/noderecursiveiterator.mjs +50 -50
  310. package/source/types/observablequeue.mjs +73 -73
  311. package/source/types/observer.mjs +104 -104
  312. package/source/types/observerlist.mjs +66 -66
  313. package/source/types/proxyobserver.mjs +210 -210
  314. package/source/types/queue.mjs +63 -63
  315. package/source/types/randomid.mjs +13 -13
  316. package/source/types/regex.mjs +3 -1
  317. package/source/types/stack.mjs +64 -64
  318. package/source/types/tokenlist.mjs +206 -205
  319. package/source/types/typeof.mjs +12 -10
  320. package/source/types/uniquequeue.mjs +48 -48
  321. package/source/types/uuid.mjs +32 -32
  322. package/source/types/validate.mjs +67 -67
  323. package/source/types/version.mjs +115 -105
  324. package/source/util/clone.mjs +103 -91
  325. package/source/util/comparator.mjs +97 -97
  326. package/source/util/deadmansswitch.mjs +40 -44
  327. package/source/util/freeze.mjs +10 -9
  328. package/source/util/namespace.mjs +1 -1
  329. package/source/util/processing.mjs +104 -105
  330. package/source/util/runtime.mjs +56 -44
  331. package/source/util/trimspaces.mjs +24 -24
  332. package/test/cases/components/form/button.mjs +122 -0
  333. package/test/cases/components/form/confirm-button.mjs +127 -0
  334. package/test/cases/components/form/form.mjs +317 -0
  335. package/test/cases/components/form/reload.mjs +188 -0
  336. package/test/cases/components/form/select.mjs +229 -0
  337. package/test/cases/components/form/state-button.mjs +130 -0
  338. package/test/cases/components/form/tabs.mjs +98 -0
  339. package/test/cases/components/form/template.mjs +189 -0
  340. package/test/cases/components/form/tree-select.mjs +216 -0
  341. package/test/cases/components/host/details.mjs +68 -0
  342. package/test/cases/components/host/host.mjs +70 -0
  343. package/test/cases/components/host/overlay.mjs +60 -0
  344. package/test/cases/components/host/util.mjs +79 -0
  345. package/test/cases/components/notify/message.mjs +39 -0
  346. package/test/cases/components/notify/notify.mjs +89 -0
  347. package/test/cases/dom/customcontrol.mjs +5 -4
  348. package/test/cases/math/random.mjs +0 -1
  349. package/test/cases/monster.mjs +1 -1
  350. package/test/cases/net/webconnect/message.mjs +0 -1
  351. package/test/cases/types/node.mjs +1 -1
  352. package/test/util/chai-dom.mjs +2 -2
  353. package/test/util/intersection-mock.mjs +69 -0
  354. package/test/util/jsdom.mjs +41 -25
  355. package/test/util/localstorage.mjs +1 -0
  356. package/test/util/resize-observer.mjs +29 -0
  357. package/test/util/websocket.mjs +4 -1
  358. package/test/web/import.js +16 -1
  359. package/test/web/test.html +28 -5
  360. package/test/web/tests.js +30398 -17879
@@ -0,0 +1,1011 @@
1
+ /**
2
+ * Copyright schukai GmbH and contributors 2023. All Rights Reserved.
3
+ * Node module: @schukai/monster
4
+ * This file is licensed under the AGPLv3 License.
5
+ * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
+ */
7
+ import { instanceSymbol } from "../../constants.mjs";
8
+ import { createPopper } from "@popperjs/core";
9
+ import { extend } from "../../data/extend.mjs";
10
+ import { Pathfinder } from "../../data/pathfinder.mjs";
11
+ import { addToObjectLink, hasObjectLink } from "../../dom/attributes.mjs";
12
+ import { ATTRIBUTE_PREFIX, ATTRIBUTE_ROLE } from "../../dom/constants.mjs";
13
+ import {
14
+ assembleMethodSymbol,
15
+ CustomElement,
16
+ getSlottedElements,
17
+ registerCustomElement,
18
+ } from "../../dom/customelement.mjs";
19
+ import { findTargetElementFromEvent } from "../../dom/events.mjs";
20
+ import { getDocument } from "../../dom/util.mjs";
21
+ import { random } from "../../math/random.mjs";
22
+ import { getGlobal } from "../../types/global.mjs";
23
+ import { ID } from "../../types/id.mjs";
24
+ import { isArray, isString } from "../../types/is.mjs";
25
+ import { TokenList } from "../../types/tokenlist.mjs";
26
+ import { clone } from "../../util/clone.mjs";
27
+ import { DeadMansSwitch } from "../../util/deadmansswitch.mjs";
28
+ import { Processing } from "../../util/processing.mjs";
29
+ import {
30
+ ATTRIBUTE_BUTTON_LABEL,
31
+ ATTRIBUTE_FORM_RELOAD,
32
+ ATTRIBUTE_FORM_URL,
33
+ STYLE_DISPLAY_MODE_BLOCK,
34
+ } from "./constants.mjs";
35
+
36
+ import { TabsStyleSheet } from "./stylesheet/tabs.mjs";
37
+ import { loadAndAssignContent } from "./util/fetch.mjs";
38
+ import {
39
+ popperInstanceSymbol,
40
+ setEventListenersModifiers,
41
+ } from "./util/popper.mjs";
42
+
43
+ export { Tabs };
44
+
45
+ /**
46
+ * @private
47
+ * @type {symbol}
48
+ */
49
+ const popperElementSymbol = Symbol("popperElement");
50
+
51
+ /**
52
+ * @private
53
+ * @type {symbol}
54
+ */
55
+ const popperNavElementSymbol = Symbol("popperNavElement");
56
+
57
+ /**
58
+ * @private
59
+ * @type {symbol}
60
+ */
61
+ const controlElementSymbol = Symbol("controlElement");
62
+
63
+ /**
64
+ * @private
65
+ * @type {symbol}
66
+ */
67
+ const navElementSymbol = Symbol("navElement");
68
+ /**
69
+ * @private
70
+ * @type {symbol}
71
+ */
72
+ const switchElementSymbol = Symbol("switchElement");
73
+
74
+ /**
75
+ * @private
76
+ * @type {symbol}
77
+ */
78
+ const changeTabEventHandler = Symbol("changeTabEventHandler");
79
+ /**
80
+ * @private
81
+ * @type {symbol}
82
+ */
83
+ const removeTabEventHandler = Symbol("removeTabEventHandler");
84
+
85
+ /**
86
+ * @private
87
+ * @type {symbol}
88
+ */
89
+ const popperSwitchEventHandler = Symbol("popperSwitchEventHandler");
90
+
91
+ /**
92
+ * local symbol
93
+ * @private
94
+ * @type {symbol}
95
+ */
96
+ const closeEventHandler = Symbol("closeEventHandler");
97
+
98
+ /**
99
+ * @private
100
+ * @type {symbol}
101
+ */
102
+ const mutationObserverSymbol = Symbol("mutationObserver");
103
+
104
+ /**
105
+ * @private
106
+ * @type {symbol}
107
+ */
108
+ const dimensionsSymbol = Symbol("dimensions");
109
+
110
+ /**
111
+ * @private
112
+ * @type {symbol}
113
+ */
114
+ const timerCallbackSymbol = Symbol("timerCallback");
115
+
116
+ /**
117
+ * local symbol
118
+ * @private
119
+ * @type {symbol}
120
+ */
121
+ const resizeObserverSymbol = Symbol("resizeObserver");
122
+
123
+ /**
124
+ * This CustomControl creates a tab element with a variety of options.
125
+ *
126
+ * <img src="./images/tabs.png">
127
+ *
128
+ * Dependencies: the system uses functions of the [monsterjs](https://monsterjs.org/) library.
129
+ *
130
+ * You can create this control either by specifying the HTML tag `<monster-tabs />` directly in the HTML or using
131
+ * Javascript via the `document.createElement('monster-tabs');` method.
132
+ *
133
+ * ```html
134
+ * <monster-tabs></monster-tabs>
135
+ * ```
136
+ *
137
+ * Or you can create this CustomControl directly in Javascript:
138
+ *
139
+ * ```js
140
+ * import {Tabs} from '@schukai/component-form/source/tab.js';
141
+ * document.createElement('monster-tabs');
142
+ * ```
143
+ *
144
+ * @startuml tabs.png
145
+ * skinparam monochrome true
146
+ * skinparam shadowing false
147
+ * HTMLElement <|-- CustomElement
148
+ * CustomElement <|-- CustomControl
149
+ * CustomControl <|-- Tabs
150
+ * @enduml
151
+ *
152
+ * @since 1.10.0
153
+ * @copyright schukai GmbH
154
+ * @memberOf Monster.Components.Form
155
+ * @summary A configurable tab control
156
+ * @fires Monster.Components.Form.event:monster-fetched
157
+ */
158
+ class Tabs extends CustomElement {
159
+ /**
160
+ * This method is called by the `instanceof` operator.
161
+ * @returns {symbol}
162
+ * @since 2.1.0
163
+ */
164
+ static get [instanceSymbol]() {
165
+ return Symbol.for("@schukai/component-form/tabs");
166
+ }
167
+
168
+ /**
169
+ * To set the options via the html tag the attribute `data-monster-options` must be used.
170
+ * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
171
+ *
172
+ * The individual configuration values can be found in the table.
173
+ *
174
+ * @property {Object} templates Template definitions
175
+ * @property {string} templates.main Main template
176
+ * @property {Object} labels
177
+ * @property {string} labels.new-tab-label="New Tab"
178
+ * @property {Object} fetch Fetch [see Using Fetch mozilla.org](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)
179
+ * @property {String} fetch.redirect=error
180
+ * @property {String} fetch.method=GET
181
+ * @property {String} fetch.mode=same-origin
182
+ * @property {String} fetch.credentials=same-origin
183
+ * @property {Object} fetch.headers={"accept":"text/html"}}
184
+ * @property {Object} popper [PopperJS Options](https://popper.js.org/docs/v2/)
185
+ * @property {string} popper.placement=bottom PopperJS placement
186
+ * @property {Object[]} modifiers={name:offset} PopperJS placement
187
+ */
188
+ get defaults() {
189
+ return Object.assign({}, super.defaults, {
190
+ templates: {
191
+ main: getTemplate(),
192
+ },
193
+ labels: {
194
+ "new-tab-label": "New Tab",
195
+ },
196
+ buttons: {
197
+ standard: [],
198
+ popper: [],
199
+ },
200
+ fetch: {
201
+ redirect: "error",
202
+ method: "GET",
203
+ mode: "same-origin",
204
+ credentials: "same-origin",
205
+ headers: {
206
+ accept: "text/html",
207
+ },
208
+ },
209
+ popper: {
210
+ placement: "bottom",
211
+ modifiers: [
212
+ {
213
+ name: "offset",
214
+ options: {
215
+ offset: [0, 2],
216
+ },
217
+ },
218
+
219
+ {
220
+ name: "eventListeners",
221
+ enabled: false,
222
+ },
223
+ ],
224
+ },
225
+ });
226
+ }
227
+
228
+ /**
229
+ * This method is called internal and should not be called directly.
230
+ */
231
+ [assembleMethodSymbol]() {;
232
+ super[assembleMethodSymbol]();
233
+
234
+ initControlReferences.call(this);
235
+
236
+ this[dimensionsSymbol] = new Pathfinder({ data: {} });
237
+ // change and remove Tabs
238
+ initEventhandler.call(this);
239
+
240
+ // setup structure
241
+ initTabButtons.call(this).then(() => {
242
+ initPopperSwitch.call(this);
243
+ initPopper.call(this);
244
+ attachResizeObserver.call(this);
245
+ attachTabChangeObserver.call(this);
246
+ });
247
+ }
248
+
249
+ /**
250
+ * This method is called internal and should not be called directly.
251
+ *
252
+ * @return {CSSStyleSheet[]}
253
+ */
254
+ static getCSSStyleSheet() {
255
+ return [TabsStyleSheet];
256
+ }
257
+
258
+ /**
259
+ * This method is called internal and should not be called directly.
260
+ *
261
+ * @return {string}
262
+ */
263
+ static getTag() {
264
+ return "monster-tabs";
265
+ }
266
+
267
+ /**
268
+ * This method is called by the dom and should not be called directly.
269
+ *
270
+ * @return {void}
271
+ */
272
+ connectedCallback() {
273
+ super.connectedCallback();
274
+
275
+ const document = getDocument();;
276
+
277
+ for (const [, type] of Object.entries(["click", "touch"])) {
278
+ // close on outside ui-events
279
+ document.addEventListener(type, this[closeEventHandler]);
280
+ }
281
+ }
282
+
283
+ /**
284
+ * This method is called by the dom and should not be called directly.
285
+ *
286
+ * @return {void}
287
+ */
288
+ disconnectedCallback() {
289
+ super.disconnectedCallback();
290
+
291
+ const document = getDocument();
292
+
293
+ // close on outside ui-events
294
+ for (const [, type] of Object.entries(["click", "touch"])) {
295
+ document.removeEventListener(type, this[closeEventHandler]);
296
+ }
297
+ }
298
+ }
299
+
300
+ /**
301
+ * @private
302
+ */
303
+ function initPopperSwitch() {;
304
+
305
+ const nodes = getSlottedElements.call(this, `[${ATTRIBUTE_ROLE}="switch"]`); // null ↦ only unnamed slots
306
+ let switchButton;
307
+ if (nodes.size === 0) {
308
+ switchButton = document.createElement("button");
309
+ switchButton.setAttribute(ATTRIBUTE_ROLE, "switch");
310
+ switchButton.setAttribute("part", "switch");
311
+ switchButton.classList.add("hidden");
312
+ switchButton.innerHTML =
313
+ '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M9.5 13a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z"/></svg>';
314
+ this[navElementSymbol].prepend(switchButton);
315
+ } else {
316
+ switchButton = nodes.next();
317
+ }
318
+
319
+ /**
320
+ * @param {Event} event
321
+ */
322
+ this[popperSwitchEventHandler] = (event) => {
323
+ const element = findTargetElementFromEvent(event, ATTRIBUTE_ROLE, "switch");
324
+
325
+ if (element instanceof HTMLButtonElement) {
326
+ togglePopper.call(this);
327
+ }
328
+ };
329
+
330
+ for (const type of ["click", "touch"]) {
331
+ switchButton.addEventListener(type, this[popperSwitchEventHandler]);
332
+ }
333
+
334
+ this[switchElementSymbol] = switchButton;
335
+ }
336
+
337
+ /**
338
+ * @private
339
+ */
340
+ function hidePopper() {;
341
+
342
+ if (!this[popperInstanceSymbol]) {
343
+ return;
344
+ }
345
+
346
+ this[popperElementSymbol].style.display = "none";
347
+ // performance https://popper.js.org/docs/v2/tutorial/#performance
348
+ setEventListenersModifiers.call(this, false);
349
+ }
350
+
351
+ /**
352
+ * @private
353
+ */
354
+ function showPopper() {;
355
+
356
+ if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
357
+ return;
358
+ }
359
+
360
+ this[popperElementSymbol].style.visibility = "hidden";
361
+ this[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
362
+ // performance https://popper.js.org/docs/v2/tutorial/#performance
363
+ setEventListenersModifiers.call(this, true);
364
+
365
+ this[popperInstanceSymbol].update();
366
+
367
+ new Processing(() => {
368
+ this[popperElementSymbol].style.removeProperty("visibility");
369
+ }).run();
370
+ }
371
+
372
+ /**
373
+ * @private
374
+ */
375
+ function togglePopper() {;
376
+
377
+ if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
378
+ hidePopper.call(this);
379
+ } else {
380
+ showPopper.call(this);
381
+ }
382
+ }
383
+
384
+ /**
385
+ * @private
386
+ */
387
+ function attachResizeObserver() {;
388
+
389
+ // against flickering
390
+ this[resizeObserverSymbol] = new ResizeObserver((entries) => {
391
+ if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
392
+ try {
393
+ this[timerCallbackSymbol].touch();
394
+ return;
395
+ } catch (e) {
396
+ delete this[timerCallbackSymbol];
397
+ }
398
+ }
399
+
400
+ this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
401
+ this[dimensionsSymbol].setVia("data.calculated", false);
402
+ checkAndRearrangeButtons.call(this);
403
+ });
404
+ });
405
+
406
+ this[resizeObserverSymbol].observe(this[navElementSymbol]);
407
+ }
408
+
409
+ /**
410
+ * @private
411
+ */
412
+ function attachTabChangeObserver() {;
413
+
414
+ // against flickering
415
+ new MutationObserver((mutations) => {
416
+ let runUpdate = false;
417
+
418
+ for (const mutation of mutations) {
419
+ if (mutation.type === "childList") {
420
+ if (
421
+ mutation.addedNodes.length > 0 ||
422
+ mutation.removedNodes.length > 0
423
+ ) {
424
+ runUpdate = true;
425
+ break;
426
+ }
427
+ }
428
+ }
429
+
430
+ if (runUpdate === true) {
431
+ this[dimensionsSymbol].setVia("data.calculated", false);
432
+ initTabButtons.call(this);
433
+ }
434
+ }).observe(this, {
435
+ childList: true,
436
+ });
437
+ }
438
+
439
+ /**
440
+ * @private
441
+ * @return {Select}
442
+ * @external "external:createPopper"
443
+ * @see {@link Plugins}
444
+ */
445
+ function initPopper() {
446
+ const self = this;
447
+
448
+ const options = extend({}, self.getOption("popper"));
449
+
450
+ self[popperInstanceSymbol] = createPopper(
451
+ self[switchElementSymbol],
452
+ self[popperElementSymbol],
453
+ options,
454
+ );
455
+
456
+ const observer1 = new MutationObserver(function (mutations) {
457
+ let runUpdate = false;
458
+
459
+ for (const mutation of mutations) {
460
+ if (mutation.type === "childList") {
461
+ if (
462
+ mutation.addedNodes.length > 0 ||
463
+ mutation.removedNodes.length > 0
464
+ ) {
465
+ runUpdate = true;
466
+ break;
467
+ }
468
+ }
469
+ }
470
+
471
+ if (runUpdate === true) {
472
+ self[popperInstanceSymbol].update();
473
+ }
474
+ });
475
+
476
+ observer1.observe(self[popperNavElementSymbol], {
477
+ childList: true,
478
+ subtree: true,
479
+ });
480
+
481
+ return self;
482
+ }
483
+
484
+ /**
485
+ * @private
486
+ * @param {HTMLElement} element
487
+ */
488
+ function show(element) {;
489
+
490
+ if (!this.shadowRoot) {
491
+ throw new Error("no shadow-root is defined");
492
+ }
493
+
494
+ const reference = element.getAttribute(`${ATTRIBUTE_PREFIX}tab-reference`);
495
+
496
+ const nodes = getSlottedElements.call(this);
497
+ for (const node of nodes) {
498
+ const id = node.getAttribute("id");
499
+ if (id === reference) {
500
+ node.classList.add("active");
501
+
502
+ if (node.hasAttribute(ATTRIBUTE_FORM_URL)) {
503
+ const url = node.getAttribute(ATTRIBUTE_FORM_URL);
504
+
505
+ if (
506
+ !node.hasAttribute(ATTRIBUTE_FORM_RELOAD) ||
507
+ node.getAttribute(ATTRIBUTE_FORM_RELOAD).toLowerCase() === "onshow"
508
+ ) {
509
+ node.removeAttribute(ATTRIBUTE_FORM_URL);
510
+ }
511
+
512
+ const options = this.getOption("fetch", {});
513
+ loadAndAssignContent(node, url, options);
514
+ }
515
+ } else {
516
+ node.classList.remove("active");
517
+ }
518
+ }
519
+
520
+ const standardButtons = this.getOption("buttons.standard");
521
+ for (const [index] in standardButtons) {
522
+ const button = standardButtons[index];
523
+ const state = button["reference"] === reference ? "active" : "inactive";
524
+ this.setOption(`buttons.standard.${index}.state`, state);
525
+ }
526
+
527
+ const popperButton = this.getOption("buttons.popper");
528
+ for (const [index] in popperButton) {
529
+ const button = popperButton[index];
530
+ const state = button["reference"] === reference ? "active" : "inactive";
531
+ this.setOption(`buttons.popper.${index}.state`, state);
532
+ }
533
+
534
+ hidePopper.call(this);
535
+ }
536
+
537
+ /**
538
+ * @private
539
+ */
540
+ function initEventhandler() {;
541
+
542
+ if (!this.shadowRoot) {
543
+ throw new Error("no shadow-root is defined");
544
+ }
545
+
546
+ /**
547
+ * @param {Event} event
548
+ */
549
+ this[changeTabEventHandler] = (event) => {
550
+ const element = findTargetElementFromEvent(event, ATTRIBUTE_ROLE, "button");
551
+
552
+ if (element instanceof HTMLButtonElement && element.disabled !== true) {
553
+ show.call(this, element);
554
+ }
555
+ };
556
+
557
+ /**
558
+ * @param {Event} event
559
+ */
560
+ this[removeTabEventHandler] = (event) => {
561
+ const element = findTargetElementFromEvent(
562
+ event,
563
+ ATTRIBUTE_ROLE,
564
+ "remove-tab",
565
+ );
566
+
567
+ if (element instanceof HTMLElement) {
568
+ const button = findTargetElementFromEvent(
569
+ event,
570
+ ATTRIBUTE_ROLE,
571
+ "button",
572
+ );
573
+
574
+ if (button instanceof HTMLButtonElement && button.disabled !== true) {
575
+ const reference = button.getAttribute(
576
+ `${ATTRIBUTE_PREFIX}tab-reference`,
577
+ );
578
+ if (reference) {
579
+ const container = this.querySelector(`[id=${reference}]`);
580
+ if (container instanceof HTMLElement) {
581
+ container.remove();
582
+ initTabButtons.call(this);
583
+ }
584
+ }
585
+ }
586
+ }
587
+ };
588
+
589
+ this[navElementSymbol].addEventListener("touch", this[changeTabEventHandler]);
590
+ this[navElementSymbol].addEventListener("click", this[changeTabEventHandler]);
591
+
592
+ this[navElementSymbol].addEventListener("touch", this[removeTabEventHandler]);
593
+ this[navElementSymbol].addEventListener("click", this[removeTabEventHandler]);
594
+
595
+ /**
596
+ * @param {Event} event
597
+ */
598
+ this[closeEventHandler] = (event) => {
599
+ const path = event.composedPath();
600
+
601
+ for (const [, element] of Object.entries(path)) {
602
+ if (element === this) {
603
+ return;
604
+ }
605
+ }
606
+
607
+ hidePopper.call(this);
608
+ };
609
+
610
+ return this;
611
+ }
612
+
613
+ /**
614
+ * @private
615
+ * @param observedNode
616
+ */
617
+ function attachTabMutationObserver(observedNode) {
618
+ const self = this;
619
+
620
+ if (hasObjectLink(observedNode, mutationObserverSymbol)) {
621
+ return;
622
+ }
623
+
624
+ /**
625
+ * this construct monitors a node whether it is disabled or modified
626
+ * @type {MutationObserver}
627
+ */
628
+ const observer = new MutationObserver(function (mutations) {
629
+ if (isArray(mutations)) {
630
+ const mutation = mutations.pop();
631
+ if (mutation instanceof MutationRecord) {
632
+ initTabButtons.call(self);
633
+ }
634
+ }
635
+ });
636
+
637
+ observer.observe(observedNode, {
638
+ childList: false,
639
+ attributes: true,
640
+ subtree: false,
641
+ attributeFilter: [
642
+ "disabled",
643
+ ATTRIBUTE_BUTTON_LABEL,
644
+ `${ATTRIBUTE_PREFIX}button-icon`,
645
+ ],
646
+ });
647
+
648
+ addToObjectLink(observedNode, mutationObserverSymbol, observer);
649
+ }
650
+
651
+ /**
652
+ * @private
653
+ * @return {Select}
654
+ * @throws {Error} no shadow-root is defined
655
+ */
656
+ function initControlReferences() {;
657
+
658
+ if (!this.shadowRoot) {
659
+ throw new Error("no shadow-root is defined");
660
+ }
661
+
662
+ this[controlElementSymbol] = this.shadowRoot.querySelector(
663
+ `[${ATTRIBUTE_ROLE}=control]`,
664
+ );
665
+ this[navElementSymbol] = this.shadowRoot.querySelector(
666
+ `nav[${ATTRIBUTE_ROLE}=nav]`,
667
+ );
668
+ this[popperElementSymbol] = this.shadowRoot.querySelector(
669
+ `[${ATTRIBUTE_ROLE}=popper]`,
670
+ );
671
+ this[popperNavElementSymbol] = this.shadowRoot.querySelector(
672
+ `[${ATTRIBUTE_ROLE}=popper-nav]`,
673
+ );
674
+ }
675
+
676
+ /**
677
+ * @private
678
+ * @return {Promise<unknown>}
679
+ * @throws {Error} no shadow-root is defined
680
+ *
681
+ */
682
+ function initTabButtons() {;
683
+
684
+ if (!this.shadowRoot) {
685
+ throw new Error("no shadow-root is defined");
686
+ }
687
+
688
+ let activeReference;
689
+
690
+ const dimensionsCalculated = this[dimensionsSymbol].getVia(
691
+ "data.calculated",
692
+ false,
693
+ );
694
+
695
+ const buttons = [];
696
+ const nodes = getSlottedElements.call(this, undefined, null); // null ↦ only unnamed slots
697
+
698
+ for (const node of nodes) {
699
+ if (!(node instanceof HTMLElement)) continue;
700
+ let label = getButtonLabel.call(this, node);
701
+
702
+ let reference;
703
+ if (node.hasAttribute("id")) {
704
+ reference = node.getAttribute("id");
705
+ }
706
+
707
+ let disabled;
708
+ if (node.hasAttribute("disabled") || node.disabled === true) {
709
+ disabled = true;
710
+ }
711
+
712
+ if (!reference) {
713
+ reference = new ID("tab").toString();
714
+ node.setAttribute("id", reference);
715
+ }
716
+
717
+ if (node.hasAttribute(`${ATTRIBUTE_PREFIX}button-icon`)) {
718
+ label = `<span part="label">${label}</span><img part="icon" src="${node.getAttribute(
719
+ `${ATTRIBUTE_PREFIX}button-icon`,
720
+ )}">`;
721
+ }
722
+
723
+ let remove = false;
724
+ if (node.hasAttribute(`${ATTRIBUTE_PREFIX}removable`)) {
725
+ remove = true;
726
+ }
727
+
728
+ if (node.matches(".active") === true && disabled !== true) {
729
+ node.classList.remove("active");
730
+ activeReference = reference;
731
+ }
732
+
733
+ const state = "";
734
+ const classes = dimensionsCalculated ? "" : "invisible";
735
+
736
+ buttons.push({
737
+ reference,
738
+ label,
739
+ state,
740
+ class: classes,
741
+ disabled,
742
+ remove,
743
+ });
744
+
745
+ attachTabMutationObserver.call(this, node);
746
+ }
747
+
748
+ this.setOption("buttons.standard", clone(buttons));
749
+ this.setOption("buttons.popper", []);
750
+ this.setOption("marker", random());
751
+
752
+ return adjustButtonVisibility.call(this).then(() => {
753
+ if (activeReference) {
754
+ return new Processing(() => {
755
+ const button = this.shadowRoot.querySelector(
756
+ `[${ATTRIBUTE_PREFIX}tab-reference="${activeReference}"]`,
757
+ );
758
+ if (button instanceof HTMLButtonElement && button.disabled !== true) {
759
+ show.call(this, button);
760
+ }
761
+ }).run();
762
+ }
763
+
764
+ return;
765
+ });
766
+ }
767
+
768
+ function checkAndRearrangeButtons() {;
769
+
770
+ if (this[dimensionsSymbol].getVia("data.calculated", false) !== true) {
771
+ calculateNavigationButtonsDimensions.call(this);
772
+ }
773
+
774
+ rearrangeButtons.call(this);
775
+ }
776
+
777
+ /**
778
+ * @private
779
+ * @return {Promise<unknown>}
780
+ */
781
+ function adjustButtonVisibility() {
782
+ const self = this;
783
+
784
+ return new Promise((resolve) => {
785
+ const observer = new MutationObserver(function (mutations) {
786
+ const defCount = self.getOption("buttons.standard").length;
787
+ const domCount = self[navElementSymbol].querySelectorAll(
788
+ 'button[data-monster-role="button"]',
789
+ ).length;
790
+
791
+ // in drawing
792
+ if (defCount !== domCount) return;
793
+
794
+ observer.disconnect();
795
+
796
+ checkAndRearrangeButtons.call(self);
797
+
798
+ resolve();
799
+ });
800
+
801
+ observer.observe(self[navElementSymbol], {
802
+ attributes: true,
803
+ });
804
+ });
805
+ }
806
+
807
+ /**
808
+ * @private
809
+ * @param node
810
+ * @return {number}
811
+ */
812
+ function getDimValue(value) {
813
+ if ([undefined, null].indexOf(value) !== -1) {
814
+ return 0;
815
+ }
816
+
817
+ const valueAsInt = parseInt(value, 10);
818
+
819
+ if (isNaN(valueAsInt)) {
820
+ return 0;
821
+ }
822
+
823
+ return valueAsInt;
824
+ }
825
+
826
+ /**
827
+ * @private
828
+ * @param {HTMLElement} node
829
+ * @return {number}
830
+ */
831
+ function calcBoxWidth(node) {
832
+ const dim = getGlobal("window").getComputedStyle(node);
833
+ const bounding = node.getBoundingClientRect();
834
+
835
+ return (
836
+ getDimValue(dim["border-left-width"]) +
837
+ getDimValue(dim["padding-left"]) +
838
+ getDimValue(dim["margin-left"]) +
839
+ getDimValue(bounding["width"]) +
840
+ getDimValue(dim["border-right-width"]) +
841
+ getDimValue(dim["margin-right"]) +
842
+ getDimValue(dim["padding-left"])
843
+ );
844
+ }
845
+
846
+ /**
847
+ * @private
848
+ * @return {Object}
849
+ */
850
+ function rearrangeButtons() {;
851
+
852
+ const standardButtons = [];
853
+ const popperButtons = [];
854
+
855
+ let sum = 0;
856
+ const space = this[dimensionsSymbol].getVia("data.space");
857
+
858
+ const buttons = this.getOption("buttons.standard");
859
+ for (const [, button] of buttons.entries()) {
860
+ const ref = button?.reference;
861
+
862
+ sum += this[dimensionsSymbol].getVia(`data.button.${ref}`);
863
+
864
+ if (sum > space) {
865
+ popperButtons.push(clone(button));
866
+ } else {
867
+ standardButtons.push(clone(button));
868
+ }
869
+ }
870
+
871
+ this.setOption("buttons.standard", standardButtons);
872
+ this.setOption("buttons.popper", popperButtons);
873
+
874
+ if (this[switchElementSymbol]) {
875
+ if (popperButtons.length > 0) {
876
+ this[switchElementSymbol].classList.remove("hidden");
877
+ } else {
878
+ this[switchElementSymbol].classList.add("hidden");
879
+ }
880
+ }
881
+ }
882
+
883
+ /**
884
+ * @private
885
+ * @return {Object}
886
+ */
887
+ function calculateNavigationButtonsDimensions() {;
888
+
889
+ const width = this[navElementSymbol].getBoundingClientRect().width;
890
+
891
+ let startEndWidth = 0;
892
+
893
+ getSlottedElements.call(this, undefined, "start").forEach((node) => {
894
+ startEndWidth += calcBoxWidth.call(this, node);
895
+ });
896
+
897
+ getSlottedElements.call(this, undefined, "end").forEach((node) => {
898
+ startEndWidth += calcBoxWidth.call(this, node);
899
+ });
900
+
901
+ this[dimensionsSymbol].setVia("data.space", width - startEndWidth - 2);
902
+ this[dimensionsSymbol].setVia("data.visible", !(width === 0));
903
+
904
+ const buttons = this
905
+ .getOption("buttons.standard")
906
+ .concat(this.getOption("buttons.popper"));
907
+
908
+ for (const [i, button] of buttons.entries()) {
909
+ const ref = button?.reference;
910
+ const element = this[navElementSymbol].querySelector(
911
+ `:scope > [${ATTRIBUTE_PREFIX}tab-reference="${ref}"]`,
912
+ );
913
+ if (!(element instanceof HTMLButtonElement)) continue;
914
+
915
+ this[dimensionsSymbol].setVia(
916
+ `data.button.${ref}`,
917
+ calcBoxWidth.call(this, element),
918
+ );
919
+ button["class"] = new TokenList(button["class"])
920
+ .remove("invisible")
921
+ .toString();
922
+ }
923
+
924
+ const slots = this[controlElementSymbol].querySelectorAll(
925
+ `nav[${ATTRIBUTE_PREFIX}role=nav] > slot.invisible, slot[${ATTRIBUTE_PREFIX}role=slot].invisible`,
926
+ );
927
+ for (const [, slot] of slots.entries()) {
928
+ slot.classList.remove("invisible");
929
+ }
930
+
931
+ this[dimensionsSymbol].setVia("data.calculated", true);
932
+ this.setOption("buttons.standard", clone(buttons));
933
+ }
934
+
935
+ /**
936
+ * @private
937
+ * @param {HTMLElement} node
938
+ * @return {string}
939
+ */
940
+ function getButtonLabel(node) {;
941
+
942
+ let label;
943
+ let setLabel = false;
944
+ if (node.hasAttribute(ATTRIBUTE_BUTTON_LABEL)) {
945
+ label = node.getAttribute(ATTRIBUTE_BUTTON_LABEL);
946
+ } else {
947
+ label = node.innerText;
948
+ setLabel = true;
949
+ }
950
+
951
+ if (!isString(label)) {
952
+ label = "";
953
+ }
954
+
955
+ label = label.trim();
956
+
957
+ if (label === "") {
958
+ label = this.getOption("labels.new-tab-label", "New Tab");
959
+ }
960
+
961
+ if (label.length > 100) {
962
+ label = `${label.substring(0, 99)}…`;
963
+ }
964
+
965
+ if (setLabel === true) {
966
+ node.setAttribute(ATTRIBUTE_BUTTON_LABEL, label);
967
+ }
968
+
969
+ return label;
970
+ }
971
+
972
+ /**
973
+ * @private
974
+ * @return {string}
975
+ */
976
+ function getTemplate() {
977
+ // language=HTML
978
+ return `
979
+ <template id="buttons">
980
+ <button part="button"
981
+ data-monster-role="button"
982
+ data-monster-attributes="
983
+ data-monster-state path:buttons.state,
984
+ disabled path:buttons.disabled | if:true,
985
+ data-monster-tab-reference path:buttons.reference"><span
986
+ data-monster-replace="path:buttons.label"></span><span part="remove-tab"
987
+ data-monster-attributes="class path:buttons.remove | ?:remove-tab:hidden "
988
+ data-monster-role="remove-tab"
989
+ tabindex="-1"></span></button>
990
+ </template>
991
+ <div data-monster-role="control" part="control">
992
+ <nav data-monster-role="nav" part="nav"
993
+ data-monster-attributes="data-monster-marker path:marker"
994
+ data-monster-insert="buttons path:buttons.standard">
995
+ <slot name="start" class="invisible"></slot>
996
+ <div data-monster-role="popper" part="popper" tabindex="-1" class="monster-color-primary-1">
997
+ <div data-popper-arrow></div>
998
+
999
+
1000
+ <div part="popper-nav" data-monster-role="popper-nav"
1001
+ data-monster-insert="buttons path:buttons.popper"
1002
+ tabindex="-1"></div>
1003
+ </div>
1004
+ <slot name="popper" class="invisible"></slot>
1005
+ <slot name="end" class="invisible"></slot>
1006
+ </nav>
1007
+ <slot data-monster-role="slot" class="invisible"></slot>
1008
+ </div>`;
1009
+ }
1010
+
1011
+ registerCustomElement(Tabs);