@dnncommunity/dnn-elements 0.14.1 → 0.15.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (422) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +24 -24
  3. package/dist/.storybook/utilities.js +16 -0
  4. package/dist/.storybook/utilities.js.map +1 -0
  5. package/dist/cjs/{css-shim-3bfdba4f.js → css-shim-aaf4fec9.js} +3 -3
  6. package/dist/cjs/css-shim-aaf4fec9.js.map +1 -0
  7. package/dist/cjs/{debounce-1de79bc7.js → debounce-901e1f0c.js} +18 -18
  8. package/dist/cjs/{debounce-1de79bc7.js.map → debounce-901e1f0c.js.map} +1 -1
  9. package/dist/cjs/dnn-button.cjs.entry.js +80 -76
  10. package/dist/cjs/dnn-button.cjs.entry.js.map +1 -1
  11. package/dist/cjs/{dnn-button_16.cjs.entry.js → dnn-button_17.cjs.entry.js} +2024 -1710
  12. package/dist/cjs/dnn-button_17.cjs.entry.js.map +1 -0
  13. package/dist/cjs/dnn-checkbox.cjs.entry.js +47 -47
  14. package/dist/cjs/dnn-checkbox.cjs.entry.js.map +1 -1
  15. package/dist/cjs/dnn-chevron.cjs.entry.js +22 -22
  16. package/dist/cjs/dnn-chevron.cjs.entry.js.map +1 -1
  17. package/dist/cjs/dnn-collapsible.cjs.entry.js +57 -54
  18. package/dist/cjs/dnn-collapsible.cjs.entry.js.map +1 -1
  19. package/dist/cjs/dnn-color-picker.cjs.entry.js +494 -494
  20. package/dist/cjs/dnn-color-picker.cjs.entry.js.map +1 -1
  21. package/dist/cjs/dnn-dropzone.cjs.entry.js +141 -141
  22. package/dist/cjs/dnn-dropzone.cjs.entry.js.map +1 -1
  23. package/dist/cjs/dnn-image-cropper.cjs.entry.js +394 -394
  24. package/dist/cjs/dnn-image-cropper.cjs.entry.js.map +1 -1
  25. package/dist/cjs/dnn-modal.cjs.entry.js +53 -50
  26. package/dist/cjs/dnn-modal.cjs.entry.js.map +1 -1
  27. package/dist/cjs/dnn-permissions-grid.cjs.entry.js +320 -0
  28. package/dist/cjs/dnn-permissions-grid.cjs.entry.js.map +1 -0
  29. package/dist/cjs/dnn-searchbox.cjs.entry.js +54 -54
  30. package/dist/cjs/dnn-searchbox.cjs.entry.js.map +1 -1
  31. package/dist/cjs/dnn-sort-icon.cjs.entry.js +32 -32
  32. package/dist/cjs/dnn-sort-icon.cjs.entry.js.map +1 -1
  33. package/dist/cjs/dnn-tab.cjs.entry.js +19 -19
  34. package/dist/cjs/dnn-tab.cjs.entry.js.map +1 -1
  35. package/dist/cjs/dnn-tabs.cjs.entry.js +40 -40
  36. package/dist/cjs/dnn-tabs.cjs.entry.js.map +1 -1
  37. package/dist/cjs/dnn-toggle.cjs.entry.js +26 -26
  38. package/dist/cjs/dnn-toggle.cjs.entry.js.map +1 -1
  39. package/dist/cjs/dnn-treeview-item.cjs.entry.js +56 -56
  40. package/dist/cjs/dnn-treeview-item.cjs.entry.js.map +1 -1
  41. package/dist/cjs/dnn-vertical-overflow-menu.cjs.entry.js +113 -111
  42. package/dist/cjs/dnn-vertical-overflow-menu.cjs.entry.js.map +1 -1
  43. package/dist/cjs/dnn-vertical-splitview.cjs.entry.js +121 -121
  44. package/dist/cjs/dnn-vertical-splitview.cjs.entry.js.map +1 -1
  45. package/dist/cjs/dnn.cjs.js +8 -4
  46. package/dist/cjs/dnn.cjs.js.map +1 -1
  47. package/dist/cjs/{dom-8ac1ad03.js → dom-14886762.js} +2 -2
  48. package/dist/cjs/{dom-8ac1ad03.js.map → dom-14886762.js.map} +1 -1
  49. package/dist/cjs/{index-7505bd72.js → index-514ef6dd.js} +32 -2
  50. package/dist/cjs/index-514ef6dd.js.map +1 -0
  51. package/dist/cjs/{index-aff4d89a.js → index-d53702a3.js} +30 -4
  52. package/dist/cjs/index-d53702a3.js.map +1 -0
  53. package/dist/cjs/index.cjs.js +41 -41
  54. package/dist/cjs/loader.cjs.js +4 -4
  55. package/dist/cjs/loader.cjs.js.map +1 -1
  56. package/dist/cjs/{mouseUtilities-75be531a.js → mouseUtilities-ecd5ecf7.js} +19 -19
  57. package/dist/cjs/{mouseUtilities-75be531a.js.map → mouseUtilities-ecd5ecf7.js.map} +1 -1
  58. package/dist/cjs/{shadow-css-41d9783d.js → shadow-css-c44ea13a.js} +2 -2
  59. package/dist/cjs/{shadow-css-41d9783d.js.map → shadow-css-c44ea13a.js.map} +1 -1
  60. package/dist/collection/collection-manifest.json +3 -2
  61. package/dist/collection/components/dnn-button/dnn-button.js +275 -271
  62. package/dist/collection/components/dnn-button/dnn-button.js.map +1 -1
  63. package/dist/collection/components/dnn-button/dnn-button.stories.js +72 -0
  64. package/dist/collection/components/dnn-button/dnn-button.stories.js.map +1 -0
  65. package/dist/collection/components/dnn-checkbox/dnn-checkbox.css +6 -0
  66. package/dist/collection/components/dnn-checkbox/dnn-checkbox.js +151 -139
  67. package/dist/collection/components/dnn-checkbox/dnn-checkbox.js.map +1 -1
  68. package/dist/collection/components/dnn-checkbox/dnn-checkbox.stories.js +39 -0
  69. package/dist/collection/components/dnn-checkbox/dnn-checkbox.stories.js.map +1 -0
  70. package/dist/collection/components/dnn-chevron/dnn-chevron.js +106 -106
  71. package/dist/collection/components/dnn-chevron/dnn-chevron.js.map +1 -1
  72. package/dist/collection/components/dnn-chevron/dnn-chevron.stories.js +38 -0
  73. package/dist/collection/components/dnn-chevron/dnn-chevron.stories.js.map +1 -0
  74. package/dist/collection/components/dnn-collapsible/dnn-collapsible.js +145 -142
  75. package/dist/collection/components/dnn-collapsible/dnn-collapsible.js.map +1 -1
  76. package/dist/collection/components/dnn-collapsible/dnn-collapsible.stories.js +39 -0
  77. package/dist/collection/components/dnn-collapsible/dnn-collapsible.stories.js.map +1 -0
  78. package/dist/collection/components/dnn-color-picker/dnn-color-picker.js +433 -433
  79. package/dist/collection/components/dnn-color-picker/dnn-color-picker.js.map +1 -1
  80. package/dist/collection/components/dnn-color-picker/dnn-color-picker.stories.js +33 -0
  81. package/dist/collection/components/dnn-color-picker/dnn-color-picker.stories.js.map +1 -0
  82. package/dist/collection/components/dnn-dropzone/dnn-dropzone.js +265 -265
  83. package/dist/collection/components/dnn-dropzone/dnn-dropzone.js.map +1 -1
  84. package/dist/collection/components/dnn-dropzone/dnn-dropzone.stories.js +48 -0
  85. package/dist/collection/components/dnn-dropzone/dnn-dropzone.stories.js.map +1 -0
  86. package/dist/collection/components/dnn-image-cropper/CornerType.js +8 -8
  87. package/dist/collection/components/dnn-image-cropper/CornerType.js.map +1 -1
  88. package/dist/collection/components/dnn-image-cropper/dnn-image-cropper.js +522 -522
  89. package/dist/collection/components/dnn-image-cropper/dnn-image-cropper.js.map +1 -1
  90. package/dist/collection/components/dnn-image-cropper/dnn-image-cropper.stories.js +60 -0
  91. package/dist/collection/components/dnn-image-cropper/dnn-image-cropper.stories.js.map +1 -0
  92. package/dist/collection/components/dnn-modal/dnn-modal.js +190 -172
  93. package/dist/collection/components/dnn-modal/dnn-modal.js.map +1 -1
  94. package/dist/collection/components/dnn-modal/dnn-modal.stories.js +47 -0
  95. package/dist/collection/components/dnn-modal/dnn-modal.stories.js.map +1 -0
  96. package/dist/collection/components/dnn-permissions-grid/dnn-permissions-grid.css +83 -0
  97. package/dist/collection/components/dnn-permissions-grid/dnn-permissions-grid.js +531 -0
  98. package/dist/collection/components/dnn-permissions-grid/dnn-permissions-grid.js.map +1 -0
  99. package/dist/collection/components/dnn-permissions-grid/dnn-permissions-grid.stories.js +273 -0
  100. package/dist/collection/components/dnn-permissions-grid/dnn-permissions-grid.stories.js.map +1 -0
  101. package/dist/collection/components/dnn-permissions-grid/localization-interface.js +3 -0
  102. package/dist/collection/components/dnn-permissions-grid/localization-interface.js.map +1 -0
  103. package/dist/collection/components/dnn-permissions-grid/permissions-interface.js +3 -0
  104. package/dist/collection/components/dnn-permissions-grid/permissions-interface.js.map +1 -0
  105. package/dist/collection/components/dnn-permissions-grid/role-group-interface.js +2 -0
  106. package/dist/collection/components/dnn-permissions-grid/role-group-interface.js.map +1 -0
  107. package/dist/collection/components/dnn-permissions-grid/role-interface.js +2 -0
  108. package/dist/collection/components/dnn-permissions-grid/role-interface.js.map +1 -0
  109. package/dist/collection/components/dnn-permissions-grid/searched-user-interface.js +2 -0
  110. package/dist/collection/components/dnn-permissions-grid/searched-user-interface.js.map +1 -0
  111. package/dist/collection/components/dnn-searchbox/dnn-searchbox.js +136 -136
  112. package/dist/collection/components/dnn-searchbox/dnn-searchbox.js.map +1 -1
  113. package/dist/collection/components/dnn-searchbox/dnn-searchbox.stories.js +26 -0
  114. package/dist/collection/components/dnn-searchbox/dnn-searchbox.stories.js.map +1 -0
  115. package/dist/collection/components/dnn-sort-icon/dnn-sort-icon.css +6 -3
  116. package/dist/collection/components/dnn-sort-icon/dnn-sort-icon.js +80 -80
  117. package/dist/collection/components/dnn-sort-icon/dnn-sort-icon.js.map +1 -1
  118. package/dist/collection/components/dnn-sort-icon/dnn-sort-icon.stories.js +58 -0
  119. package/dist/collection/components/dnn-sort-icon/dnn-sort-icon.stories.js.map +1 -0
  120. package/dist/collection/components/dnn-tab/dnn-tab.js +83 -83
  121. package/dist/collection/components/dnn-tab/dnn-tab.js.map +1 -1
  122. package/dist/collection/components/dnn-tab/dnn-tab.stories.js +25 -0
  123. package/dist/collection/components/dnn-tab/dnn-tab.stories.js.map +1 -0
  124. package/dist/collection/components/dnn-tabs/dnn-tabs.js +54 -54
  125. package/dist/collection/components/dnn-tabs/dnn-tabs.js.map +1 -1
  126. package/dist/collection/components/dnn-tabs/dnn-tabs.stories.js +48 -0
  127. package/dist/collection/components/dnn-tabs/dnn-tabs.stories.js.map +1 -0
  128. package/dist/collection/components/dnn-toggle/dnn-toggle.css +1 -1
  129. package/dist/collection/components/dnn-toggle/dnn-toggle.js +93 -93
  130. package/dist/collection/components/dnn-toggle/dnn-toggle.js.map +1 -1
  131. package/dist/collection/components/dnn-toggle/dnn-toggle.stories.js +53 -0
  132. package/dist/collection/components/dnn-toggle/dnn-toggle.stories.js.map +1 -0
  133. package/dist/collection/components/dnn-toggle/toggle-interface.js +1 -1
  134. package/dist/collection/components/dnn-toggle/toggle-interface.js.map +1 -1
  135. package/dist/collection/components/dnn-treeview-item/dnn-treeview-item.js +130 -126
  136. package/dist/collection/components/dnn-treeview-item/dnn-treeview-item.js.map +1 -1
  137. package/dist/collection/components/dnn-treeview-item/dnn-treeview-item.stories.js +36 -0
  138. package/dist/collection/components/dnn-treeview-item/dnn-treeview-item.stories.js.map +1 -0
  139. package/dist/collection/components/dnn-vertical-overflow-menu/dnn-vertical-overflow-menu.css +6 -7
  140. package/dist/collection/components/dnn-vertical-overflow-menu/dnn-vertical-overflow-menu.js +133 -131
  141. package/dist/collection/components/dnn-vertical-overflow-menu/dnn-vertical-overflow-menu.js.map +1 -1
  142. package/dist/collection/components/dnn-vertical-overflow-menu/dnn-vertical-overflow-menu.stories.js +60 -0
  143. package/dist/collection/components/dnn-vertical-overflow-menu/dnn-vertical-overflow-menu.stories.js.map +1 -0
  144. package/dist/collection/components/dnn-vertical-splitview/dnn-vertical-splitview.css +4 -2
  145. package/dist/collection/components/dnn-vertical-splitview/dnn-vertical-splitview.js +233 -233
  146. package/dist/collection/components/dnn-vertical-splitview/dnn-vertical-splitview.js.map +1 -1
  147. package/dist/collection/components/dnn-vertical-splitview/dnn-vertical-splitview.stories.js +75 -0
  148. package/dist/collection/components/dnn-vertical-splitview/dnn-vertical-splitview.stories.js.map +1 -0
  149. package/dist/collection/index.js +2 -2
  150. package/dist/collection/index.js.map +1 -1
  151. package/dist/collection/utilities/colorInfo.js +190 -190
  152. package/dist/collection/utilities/colorInfo.js.map +1 -1
  153. package/dist/collection/utilities/debounce.js +18 -18
  154. package/dist/collection/utilities/debounce.js.map +1 -1
  155. package/dist/collection/utilities/dnnServicesFramework.js +41 -41
  156. package/dist/collection/utilities/dnnServicesFramework.js.map +1 -1
  157. package/dist/collection/utilities/mouseUtilities.js +19 -19
  158. package/dist/collection/utilities/mouseUtilities.js.map +1 -1
  159. package/dist/{esm/css-shim-20dbffa5.js → dnn/css-shim-091f949f.js} +3 -3
  160. package/dist/dnn/css-shim-091f949f.js.map +1 -0
  161. package/dist/dnn/{css-shim-856c55de.system.js → css-shim-c5bffe6b.system.js} +2 -2
  162. package/dist/dnn/css-shim-c5bffe6b.system.js.map +1 -0
  163. package/dist/{esm/debounce-06f55268.js → dnn/debounce-6be67abd.js} +18 -18
  164. package/dist/dnn/{debounce-06f55268.js.map → debounce-6be67abd.js.map} +1 -1
  165. package/dist/dnn/{debounce-eef81bf7.system.js → debounce-db438a09.system.js} +1 -1
  166. package/dist/dnn/{debounce-eef81bf7.system.js.map → debounce-db438a09.system.js.map} +0 -0
  167. package/dist/dnn/dnn-button.entry.js +80 -76
  168. package/dist/dnn/dnn-button.entry.js.map +1 -1
  169. package/dist/dnn/dnn-button.system.entry.js +1 -1
  170. package/dist/dnn/dnn-button.system.entry.js.map +1 -1
  171. package/dist/dnn/dnn-checkbox.entry.js +47 -47
  172. package/dist/dnn/dnn-checkbox.entry.js.map +1 -1
  173. package/dist/dnn/dnn-checkbox.system.entry.js +1 -1
  174. package/dist/dnn/dnn-checkbox.system.entry.js.map +1 -1
  175. package/dist/dnn/dnn-chevron.entry.js +22 -22
  176. package/dist/dnn/dnn-chevron.entry.js.map +1 -1
  177. package/dist/dnn/dnn-chevron.system.entry.js +1 -1
  178. package/dist/dnn/dnn-chevron.system.entry.js.map +1 -1
  179. package/dist/dnn/dnn-collapsible.entry.js +57 -54
  180. package/dist/dnn/dnn-collapsible.entry.js.map +1 -1
  181. package/dist/dnn/dnn-collapsible.system.entry.js +1 -1
  182. package/dist/dnn/dnn-collapsible.system.entry.js.map +1 -1
  183. package/dist/dnn/dnn-color-picker.entry.js +494 -494
  184. package/dist/dnn/dnn-color-picker.entry.js.map +1 -1
  185. package/dist/dnn/dnn-color-picker.system.entry.js +2 -2
  186. package/dist/dnn/dnn-color-picker.system.entry.js.map +1 -1
  187. package/dist/dnn/dnn-dropzone.entry.js +141 -141
  188. package/dist/dnn/dnn-dropzone.entry.js.map +1 -1
  189. package/dist/dnn/dnn-dropzone.system.entry.js +1 -1
  190. package/dist/dnn/dnn-dropzone.system.entry.js.map +1 -1
  191. package/dist/dnn/dnn-image-cropper.entry.js +394 -394
  192. package/dist/dnn/dnn-image-cropper.entry.js.map +1 -1
  193. package/dist/dnn/dnn-image-cropper.system.entry.js +1 -1
  194. package/dist/dnn/dnn-image-cropper.system.entry.js.map +1 -1
  195. package/dist/dnn/dnn-modal.entry.js +53 -50
  196. package/dist/dnn/dnn-modal.entry.js.map +1 -1
  197. package/dist/dnn/dnn-modal.system.entry.js +1 -1
  198. package/dist/dnn/dnn-modal.system.entry.js.map +1 -1
  199. package/dist/dnn/dnn-permissions-grid.entry.js +316 -0
  200. package/dist/dnn/dnn-permissions-grid.entry.js.map +1 -0
  201. package/dist/dnn/dnn-permissions-grid.system.entry.js +2 -0
  202. package/dist/dnn/dnn-permissions-grid.system.entry.js.map +1 -0
  203. package/dist/dnn/dnn-searchbox.entry.js +54 -54
  204. package/dist/dnn/dnn-searchbox.entry.js.map +1 -1
  205. package/dist/dnn/dnn-searchbox.system.entry.js +1 -1
  206. package/dist/dnn/dnn-searchbox.system.entry.js.map +1 -1
  207. package/dist/dnn/dnn-sort-icon.entry.js +32 -32
  208. package/dist/dnn/dnn-sort-icon.entry.js.map +1 -1
  209. package/dist/dnn/dnn-sort-icon.system.entry.js +1 -1
  210. package/dist/dnn/dnn-sort-icon.system.entry.js.map +1 -1
  211. package/dist/dnn/dnn-tab.entry.js +19 -19
  212. package/dist/dnn/dnn-tab.entry.js.map +1 -1
  213. package/dist/dnn/dnn-tab.system.entry.js +1 -1
  214. package/dist/dnn/dnn-tabs.entry.js +40 -40
  215. package/dist/dnn/dnn-tabs.entry.js.map +1 -1
  216. package/dist/dnn/dnn-tabs.system.entry.js +1 -1
  217. package/dist/dnn/dnn-tabs.system.entry.js.map +1 -1
  218. package/dist/dnn/dnn-toggle.entry.js +26 -26
  219. package/dist/dnn/dnn-toggle.entry.js.map +1 -1
  220. package/dist/dnn/dnn-toggle.system.entry.js +1 -1
  221. package/dist/dnn/dnn-toggle.system.entry.js.map +1 -1
  222. package/dist/dnn/dnn-treeview-item.entry.js +56 -56
  223. package/dist/dnn/dnn-treeview-item.entry.js.map +1 -1
  224. package/dist/dnn/dnn-treeview-item.system.entry.js +1 -1
  225. package/dist/dnn/dnn-treeview-item.system.entry.js.map +1 -1
  226. package/dist/dnn/dnn-vertical-overflow-menu.entry.js +113 -111
  227. package/dist/dnn/dnn-vertical-overflow-menu.entry.js.map +1 -1
  228. package/dist/dnn/dnn-vertical-overflow-menu.system.entry.js +1 -1
  229. package/dist/dnn/dnn-vertical-overflow-menu.system.entry.js.map +1 -1
  230. package/dist/dnn/dnn-vertical-splitview.entry.js +121 -121
  231. package/dist/dnn/dnn-vertical-splitview.entry.js.map +1 -1
  232. package/dist/dnn/dnn-vertical-splitview.system.entry.js +1 -1
  233. package/dist/dnn/dnn-vertical-splitview.system.entry.js.map +1 -1
  234. package/dist/dnn/dnn.esm.js +8 -4
  235. package/dist/dnn/dnn.esm.js.map +1 -1
  236. package/dist/dnn/dnn.system.js +1 -1
  237. package/dist/dnn/dnn.system.js.map +1 -1
  238. package/dist/dnn/{dom-938307ec.system.js → dom-99eb7b76.system.js} +1 -1
  239. package/dist/dnn/{dom-938307ec.system.js.map → dom-99eb7b76.system.js.map} +1 -1
  240. package/dist/dnn/{dom-c5ed0ba5.js → dom-a385e381.js} +2 -2
  241. package/dist/{esm/dom-c5ed0ba5.js.map → dnn/dom-a385e381.js.map} +1 -1
  242. package/dist/dnn/{index-b5a28c1d.js → index-20e42ad7.js} +30 -4
  243. package/dist/dnn/index-20e42ad7.js.map +1 -0
  244. package/dist/dnn/index-c3cc3b5b.system.js +2 -0
  245. package/dist/dnn/index-c3cc3b5b.system.js.map +1 -0
  246. package/dist/dnn/index.esm.js +41 -41
  247. package/dist/dnn/index.system.js +1 -1
  248. package/dist/dnn/{mouseUtilities-e7e4e78f.system.js → mouseUtilities-233ad7e3.system.js} +1 -1
  249. package/dist/dnn/{mouseUtilities-e7e4e78f.system.js.map → mouseUtilities-233ad7e3.system.js.map} +0 -0
  250. package/dist/{esm/mouseUtilities-817973b4.js → dnn/mouseUtilities-b261ca4f.js} +19 -19
  251. package/dist/dnn/{mouseUtilities-817973b4.js.map → mouseUtilities-b261ca4f.js.map} +1 -1
  252. package/dist/dnn/{p-646cfb1b.system.js → p-1e26a4e1.system.js} +1 -1
  253. package/dist/dnn/{p-646cfb1b.system.js.map → p-1e26a4e1.system.js.map} +0 -0
  254. package/dist/dnn/p-31dc68a7.system.entry.js +11 -0
  255. package/dist/dnn/p-31dc68a7.system.entry.js.map +1 -0
  256. package/dist/dnn/p-5bcf3629.system.js +2 -0
  257. package/dist/dnn/p-5bcf3629.system.js.map +1 -0
  258. package/dist/dnn/{p-fb637662.system.js → p-78561bb1.system.js} +2 -2
  259. package/dist/dnn/{p-fb637662.system.js.map → p-78561bb1.system.js.map} +0 -0
  260. package/dist/dnn/p-7ffdbed1.js +2 -0
  261. package/dist/dnn/p-7ffdbed1.js.map +1 -0
  262. package/dist/dnn/{p-0e94f5ee.js → p-9b8731a9.js} +1 -1
  263. package/dist/dnn/{p-0e94f5ee.js.map → p-9b8731a9.js.map} +0 -0
  264. package/dist/dnn/p-b8064287.system.js +2 -0
  265. package/dist/dnn/p-b8064287.system.js.map +1 -0
  266. package/dist/dnn/p-c222c8b7.entry.js +11 -0
  267. package/dist/dnn/p-c222c8b7.entry.js.map +1 -0
  268. package/dist/dnn/shadow-css-27708fdd.system.js +14 -0
  269. package/dist/dnn/shadow-css-27708fdd.system.js.map +1 -0
  270. package/dist/dnn/{shadow-css-8c625855.js → shadow-css-ef431969.js} +2 -2
  271. package/dist/{esm/shadow-css-8c625855.js.map → dnn/shadow-css-ef431969.js.map} +1 -1
  272. package/dist/{dnn/css-shim-20dbffa5.js → esm/css-shim-091f949f.js} +3 -3
  273. package/dist/esm/css-shim-091f949f.js.map +1 -0
  274. package/dist/{dnn/debounce-06f55268.js → esm/debounce-6be67abd.js} +18 -18
  275. package/dist/esm/{debounce-06f55268.js.map → debounce-6be67abd.js.map} +1 -1
  276. package/dist/esm/dnn-button.entry.js +80 -76
  277. package/dist/esm/dnn-button.entry.js.map +1 -1
  278. package/dist/esm/{dnn-button_16.entry.js → dnn-button_17.entry.js} +2024 -1711
  279. package/dist/esm/dnn-button_17.entry.js.map +1 -0
  280. package/dist/esm/dnn-checkbox.entry.js +47 -47
  281. package/dist/esm/dnn-checkbox.entry.js.map +1 -1
  282. package/dist/esm/dnn-chevron.entry.js +22 -22
  283. package/dist/esm/dnn-chevron.entry.js.map +1 -1
  284. package/dist/esm/dnn-collapsible.entry.js +57 -54
  285. package/dist/esm/dnn-collapsible.entry.js.map +1 -1
  286. package/dist/esm/dnn-color-picker.entry.js +494 -494
  287. package/dist/esm/dnn-color-picker.entry.js.map +1 -1
  288. package/dist/esm/dnn-dropzone.entry.js +141 -141
  289. package/dist/esm/dnn-dropzone.entry.js.map +1 -1
  290. package/dist/esm/dnn-image-cropper.entry.js +394 -394
  291. package/dist/esm/dnn-image-cropper.entry.js.map +1 -1
  292. package/dist/esm/dnn-modal.entry.js +53 -50
  293. package/dist/esm/dnn-modal.entry.js.map +1 -1
  294. package/dist/esm/dnn-permissions-grid.entry.js +316 -0
  295. package/dist/esm/dnn-permissions-grid.entry.js.map +1 -0
  296. package/dist/esm/dnn-searchbox.entry.js +54 -54
  297. package/dist/esm/dnn-searchbox.entry.js.map +1 -1
  298. package/dist/esm/dnn-sort-icon.entry.js +32 -32
  299. package/dist/esm/dnn-sort-icon.entry.js.map +1 -1
  300. package/dist/esm/dnn-tab.entry.js +19 -19
  301. package/dist/esm/dnn-tab.entry.js.map +1 -1
  302. package/dist/esm/dnn-tabs.entry.js +40 -40
  303. package/dist/esm/dnn-tabs.entry.js.map +1 -1
  304. package/dist/esm/dnn-toggle.entry.js +26 -26
  305. package/dist/esm/dnn-toggle.entry.js.map +1 -1
  306. package/dist/esm/dnn-treeview-item.entry.js +56 -56
  307. package/dist/esm/dnn-treeview-item.entry.js.map +1 -1
  308. package/dist/esm/dnn-vertical-overflow-menu.entry.js +113 -111
  309. package/dist/esm/dnn-vertical-overflow-menu.entry.js.map +1 -1
  310. package/dist/esm/dnn-vertical-splitview.entry.js +121 -121
  311. package/dist/esm/dnn-vertical-splitview.entry.js.map +1 -1
  312. package/dist/esm/dnn.js +8 -4
  313. package/dist/esm/dnn.js.map +1 -1
  314. package/dist/esm/{dom-c5ed0ba5.js → dom-a385e381.js} +2 -2
  315. package/dist/{dnn/dom-c5ed0ba5.js.map → esm/dom-a385e381.js.map} +1 -1
  316. package/dist/esm/{index-b5a28c1d.js → index-20e42ad7.js} +30 -4
  317. package/dist/esm/index-20e42ad7.js.map +1 -0
  318. package/dist/esm/{index-cdbad319.js → index-59e0950f.js} +32 -2
  319. package/dist/esm/index-59e0950f.js.map +1 -0
  320. package/dist/esm/index.js +41 -41
  321. package/dist/esm/loader.js +4 -4
  322. package/dist/esm/loader.js.map +1 -1
  323. package/dist/{dnn/mouseUtilities-817973b4.js → esm/mouseUtilities-b261ca4f.js} +19 -19
  324. package/dist/esm/{mouseUtilities-817973b4.js.map → mouseUtilities-b261ca4f.js.map} +1 -1
  325. package/dist/esm/polyfills/core-js.js +0 -0
  326. package/dist/esm/polyfills/css-shim.js +1 -1
  327. package/dist/esm/polyfills/dom.js +0 -0
  328. package/dist/esm/polyfills/es5-html-element.js +0 -0
  329. package/dist/esm/polyfills/index.js +0 -0
  330. package/dist/esm/polyfills/system.js +0 -0
  331. package/dist/esm/{shadow-css-8c625855.js → shadow-css-ef431969.js} +2 -2
  332. package/dist/{dnn/shadow-css-8c625855.js.map → esm/shadow-css-ef431969.js.map} +1 -1
  333. package/dist/esm-es5/{debounce-06f55268.js → debounce-6be67abd.js} +1 -1
  334. package/dist/esm-es5/{debounce-06f55268.js.map → debounce-6be67abd.js.map} +0 -0
  335. package/dist/esm-es5/dnn-button_17.entry.js +11 -0
  336. package/dist/esm-es5/dnn-button_17.entry.js.map +1 -0
  337. package/dist/esm-es5/dnn.js +1 -1
  338. package/dist/esm-es5/dnn.js.map +1 -1
  339. package/dist/esm-es5/index-59e0950f.js +2 -0
  340. package/dist/esm-es5/index-59e0950f.js.map +1 -0
  341. package/dist/esm-es5/index.js +1 -1
  342. package/dist/esm-es5/loader.js +1 -1
  343. package/dist/esm-es5/loader.js.map +1 -1
  344. package/dist/types/components/dnn-button/dnn-button.d.ts +56 -55
  345. package/dist/types/components/dnn-button/dnn-button.stories.d.ts +4 -0
  346. package/dist/types/components/dnn-checkbox/dnn-checkbox.d.ts +20 -16
  347. package/dist/types/components/dnn-checkbox/dnn-checkbox.stories.d.ts +4 -0
  348. package/dist/types/components/dnn-chevron/dnn-chevron.d.ts +13 -13
  349. package/dist/types/components/dnn-chevron/dnn-chevron.stories.d.ts +4 -0
  350. package/dist/types/components/dnn-collapsible/dnn-collapsible.d.ts +19 -18
  351. package/dist/types/components/dnn-collapsible/dnn-collapsible.stories.d.ts +4 -0
  352. package/dist/types/components/dnn-color-picker/dnn-color-picker.d.ts +46 -46
  353. package/dist/types/components/dnn-color-picker/dnn-color-picker.stories.d.ts +4 -0
  354. package/dist/types/components/dnn-dropzone/dnn-dropzone.d.ts +45 -45
  355. package/dist/types/components/dnn-dropzone/dnn-dropzone.stories.d.ts +4 -0
  356. package/dist/types/components/dnn-image-cropper/CornerType.d.ts +6 -6
  357. package/dist/types/components/dnn-image-cropper/dnn-image-cropper.d.ts +61 -61
  358. package/dist/types/components/dnn-image-cropper/dnn-image-cropper.stories.d.ts +4 -0
  359. package/dist/types/components/dnn-modal/dnn-modal.d.ts +38 -35
  360. package/dist/types/components/dnn-modal/dnn-modal.stories.d.ts +4 -0
  361. package/dist/types/components/dnn-permissions-grid/dnn-permissions-grid.d.ts +47 -0
  362. package/dist/types/components/dnn-permissions-grid/dnn-permissions-grid.stories.d.ts +4 -0
  363. package/dist/types/components/dnn-permissions-grid/localization-interface.d.ts +11 -0
  364. package/dist/types/components/dnn-permissions-grid/permissions-interface.d.ts +26 -0
  365. package/dist/types/components/dnn-permissions-grid/role-group-interface.d.ts +6 -0
  366. package/dist/types/components/dnn-permissions-grid/role-interface.d.ts +6 -0
  367. package/dist/types/components/dnn-permissions-grid/searched-user-interface.d.ts +4 -0
  368. package/dist/types/components/dnn-searchbox/dnn-searchbox.d.ts +22 -22
  369. package/dist/types/components/dnn-searchbox/dnn-searchbox.stories.d.ts +4 -0
  370. package/dist/types/components/dnn-sort-icon/dnn-sort-icon.d.ts +9 -9
  371. package/dist/types/components/dnn-sort-icon/dnn-sort-icon.stories.d.ts +4 -0
  372. package/dist/types/components/dnn-tab/dnn-tab.d.ts +11 -11
  373. package/dist/types/components/dnn-tab/dnn-tab.stories.d.ts +4 -0
  374. package/dist/types/components/dnn-tabs/dnn-tabs.d.ts +11 -11
  375. package/dist/types/components/dnn-tabs/dnn-tabs.stories.d.ts +4 -0
  376. package/dist/types/components/dnn-toggle/dnn-toggle.d.ts +13 -13
  377. package/dist/types/components/dnn-toggle/dnn-toggle.stories.d.ts +4 -0
  378. package/dist/types/components/dnn-toggle/toggle-interface.d.ts +3 -3
  379. package/dist/types/components/dnn-treeview-item/dnn-treeview-item.d.ts +28 -24
  380. package/dist/types/components/dnn-treeview-item/dnn-treeview-item.stories.d.ts +4 -0
  381. package/dist/types/components/dnn-vertical-overflow-menu/dnn-vertical-overflow-menu.d.ts +16 -16
  382. package/dist/types/components/dnn-vertical-overflow-menu/dnn-vertical-overflow-menu.stories.d.ts +4 -0
  383. package/dist/types/components/dnn-vertical-splitview/dnn-vertical-splitview.d.ts +28 -28
  384. package/dist/types/components/dnn-vertical-splitview/dnn-vertical-splitview.stories.d.ts +4 -0
  385. package/dist/types/components.d.ts +108 -34
  386. package/dist/types/global.d.ts +1 -0
  387. package/dist/types/home/runner/work/dnn-elements/dnn-elements/.stencil/.storybook/utilities.d.ts +1 -0
  388. package/dist/types/index.d.ts +3 -3
  389. package/dist/types/utilities/colorInfo.d.ts +52 -52
  390. package/dist/types/utilities/debounce.d.ts +5 -5
  391. package/dist/types/utilities/dnnServicesFramework.d.ts +19 -19
  392. package/dist/types/utilities/mouseUtilities.d.ts +4 -4
  393. package/package.json +63 -48
  394. package/dist/cjs/css-shim-3bfdba4f.js.map +0 -1
  395. package/dist/cjs/dnn-button_16.cjs.entry.js.map +0 -1
  396. package/dist/cjs/index-7505bd72.js.map +0 -1
  397. package/dist/cjs/index-aff4d89a.js.map +0 -1
  398. package/dist/dnn/css-shim-20dbffa5.js.map +0 -1
  399. package/dist/dnn/css-shim-856c55de.system.js.map +0 -1
  400. package/dist/dnn/index-a3a55419.system.js +0 -2
  401. package/dist/dnn/index-a3a55419.system.js.map +0 -1
  402. package/dist/dnn/index-b5a28c1d.js.map +0 -1
  403. package/dist/dnn/p-058ba146.system.js +0 -2
  404. package/dist/dnn/p-058ba146.system.js.map +0 -1
  405. package/dist/dnn/p-45ce2139.js +0 -2
  406. package/dist/dnn/p-45ce2139.js.map +0 -1
  407. package/dist/dnn/p-755d047d.system.entry.js +0 -11
  408. package/dist/dnn/p-755d047d.system.entry.js.map +0 -1
  409. package/dist/dnn/p-8ec1f3a8.entry.js +0 -11
  410. package/dist/dnn/p-8ec1f3a8.entry.js.map +0 -1
  411. package/dist/dnn/p-f91193e2.system.js +0 -2
  412. package/dist/dnn/p-f91193e2.system.js.map +0 -1
  413. package/dist/dnn/shadow-css-d573707f.system.js +0 -14
  414. package/dist/dnn/shadow-css-d573707f.system.js.map +0 -1
  415. package/dist/esm/css-shim-20dbffa5.js.map +0 -1
  416. package/dist/esm/dnn-button_16.entry.js.map +0 -1
  417. package/dist/esm/index-b5a28c1d.js.map +0 -1
  418. package/dist/esm/index-cdbad319.js.map +0 -1
  419. package/dist/esm-es5/dnn-button_16.entry.js +0 -11
  420. package/dist/esm-es5/dnn-button_16.entry.js.map +0 -1
  421. package/dist/esm-es5/index-cdbad319.js +0 -2
  422. package/dist/esm-es5/index-cdbad319.js.map +0 -1
@@ -1,1779 +1,2092 @@
1
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-cdbad319.js';
2
- import { D as Debounce } from './debounce-06f55268.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-59e0950f.js';
2
+ import { D as Debounce } from './debounce-6be67abd.js';
3
3
 
4
4
  const dnnButtonCss = ":host{--background-color:transparent;--color:#333;--border-size:1px;--border-color:var(--backround-color);--border-radius:var(--dnn-controls-radius, 5px);--padding:var(--dnn-controls-padding, 5px);display:inline-block;width:auto}:host(.disabled){pointer-events:none}:host(.primary){--background-color:var(--dnn-color-primary, blue);--color:var(--dnn-color-primary-contrast, white);--focus-color:var(--background-color)}:host(.primary.reversed){--background-color:var(--dnn-color-primary-contrast, white);--color:var(--dnn-color-primary, blue);--border-color:var(--dnn-color-primary, blue);--focus-color:var(--color)}:host(.secondary){--background-color:var(--dnn-color-secondary, green);--color:var(--dnn-color-secondary-contrast, white);--focus-color:var(--background-color)}:host(.secondary.reversed){--background-color:var(--dnn-color-secondary-contrast, white);--color:var(--dnn-color-secondary, blue);--border-color:var(--dnn-color-secondary, blue);--focus-color:var(--color)}:host(.tertiary){--background-color:var(--dnn-color-tertiary, yellow);--color:var(--dnn-color-tertiary-contrast, black);--focus-color:var(--background-color)}:host(.tertiary.reversed){--background-color:var(--dnn-color-tertiary-contrast, white);--color:var(--dnn-color-tertiary, blue);--border-color:var(--dnn-color-tertiary, blue);--focus-color:var(--color)}:host(.hydrated) button{border:var(--border-size) solid var(--border-color);border-radius:var(--border-radius);padding:var(--padding) calc(var(--padding) * 2);background-color:transparent;background-color:var(--background-color);color:var(--color);outline:none}:host(.hydrated) button:focus,:host(.hydrated) button:hover{-webkit-box-shadow:0 0 2px 2px var(--focus-color);box-shadow:0 0 2px 2px var(--focus-color)}:host(:disabled,[disabled]) button{pointer-events:none;opacity:0.5}:host(.small) button{padding:calc(var(--padding) / 2) var(--padding);font-size:0.7em}:host(.large) button{padding:calc(var(--padding) * 1.5) calc(var(--padding) * 3);font-size:1.2em}button{height:100%;width:100%;cursor:pointer}";
5
5
 
6
- let DnnButton = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- this.confirmed = createEvent(this, "confirmed", 3);
10
- this.canceled = createEvent(this, "canceled", 3);
11
- /**
12
- * Optional button style,
13
- * can be either primary, secondary or tertiary and defaults to primary if not specified
14
- */
15
- this.type = 'primary';
16
- /**
17
- * Optionally reverses the button style.
18
- */
19
- this.reversed = false;
20
- /**
21
- * Optionally sets the button size, small normal or large, defaults to normal
22
- */
23
- this.size = 'normal';
24
- /**
25
- * Optionally add a confirmation dialog before firing the action.
26
- */
27
- this.confirm = false;
28
- /**
29
- * The text of the yes button for confirmation.
30
- */
31
- this.confirmYesText = "Yes";
32
- /**
33
- * The text of the no button for confirmation.
34
- */
35
- this.confirmNoText = "No";
36
- /**
37
- * The text of the confirmation message;
38
- */
39
- this.confirmMessage = "Are you sure ?";
40
- /**
41
- * Disables the button
42
- */
43
- this.disabled = false;
44
- this.modalVisible = false;
45
- }
46
- componentDidLoad() {
47
- this.el.classList.add(this.type);
48
- if (this.reversed) {
49
- this.el.classList.add('reversed');
50
- }
51
- if (this.size !== 'normal') {
52
- this.el.classList.add(this.size);
53
- }
54
- this.modal = this.el.shadowRoot.querySelector('dnn-modal');
55
- }
56
- handleConfirm() {
57
- this.modal.hide();
58
- this.modalVisible = false;
59
- this.confirmed.emit();
60
- }
61
- handleCancel() {
62
- this.modal.hide();
63
- this.modalVisible = false;
64
- this.canceled.emit();
65
- }
66
- handleClick() {
67
- if (this.confirm && !this.modalVisible) {
68
- this.modal.show();
69
- this.modalVisible = true;
70
- }
71
- }
72
- render() {
73
- return (h(Host, { disabled: this.disabled, style: { 'pointer-events': this.disabled ? 'none' : 'all' } }, h("button", { class: "button", onClick: () => this.handleClick(), disabled: this.disabled }, h("slot", null)), this.confirm &&
74
- h("dnn-modal", { showCloseButton: false, backdropDismiss: false }, h("p", null, this.confirmMessage), h("div", { style: {
75
- display: 'flex',
76
- justifyContent: 'flex-end'
77
- } }, h("dnn-button", { type: 'primary', style: { margin: '5px' }, onClick: () => this.handleConfirm() }, this.confirmYesText), h("dnn-button", { type: 'secondary', style: { margin: '5px' }, onClick: () => this.handleCancel() }, this.confirmNoText)))));
78
- }
79
- get el() { return getElement(this); }
80
- };
6
+ const DnnButton = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.confirmed = createEvent(this, "confirmed", 7);
10
+ this.canceled = createEvent(this, "canceled", 7);
11
+ /**
12
+ * Optional button style,
13
+ * can be either primary, secondary or tertiary and defaults to primary if not specified
14
+ */
15
+ this.type = 'primary';
16
+ /**
17
+ * Optionally reverses the button style.
18
+ */
19
+ this.reversed = false;
20
+ /**
21
+ * Optionally sets the button size, small normal or large, defaults to normal
22
+ */
23
+ this.size = 'normal';
24
+ /**
25
+ * Optionally add a confirmation dialog before firing the action.
26
+ */
27
+ this.confirm = false;
28
+ /**
29
+ * The text of the yes button for confirmation.
30
+ */
31
+ this.confirmYesText = "Yes";
32
+ /**
33
+ * The text of the no button for confirmation.
34
+ */
35
+ this.confirmNoText = "No";
36
+ /**
37
+ * The text of the confirmation message;
38
+ */
39
+ this.confirmMessage = "Are you sure ?";
40
+ /**
41
+ * Disables the button
42
+ */
43
+ this.disabled = false;
44
+ this.modalVisible = false;
45
+ }
46
+ componentDidLoad() {
47
+ this.modal = this.el.shadowRoot.querySelector('dnn-modal');
48
+ }
49
+ handleConfirm() {
50
+ this.modal.hide();
51
+ this.modalVisible = false;
52
+ this.confirmed.emit();
53
+ }
54
+ handleCancel() {
55
+ this.modal.hide();
56
+ this.modalVisible = false;
57
+ this.canceled.emit();
58
+ }
59
+ handleClick() {
60
+ if (this.confirm && !this.modalVisible) {
61
+ this.modal.show();
62
+ this.modalVisible = true;
63
+ }
64
+ }
65
+ getElementClasses() {
66
+ const classes = [];
67
+ classes.push(this.type);
68
+ if (this.reversed) {
69
+ classes.push('reversed');
70
+ }
71
+ if (this.size !== 'normal') {
72
+ classes.push(this.size);
73
+ }
74
+ return classes.join(' ');
75
+ }
76
+ render() {
77
+ return (h(Host, { class: this.getElementClasses(), disabled: this.disabled, style: { 'pointer-events': this.disabled ? 'none' : 'all' } }, h("button", { class: "button", onClick: () => this.handleClick(), disabled: this.disabled }, h("slot", null)), this.confirm &&
78
+ h("dnn-modal", { showCloseButton: false, backdropDismiss: false }, h("p", null, this.confirmMessage), h("div", { style: {
79
+ display: 'flex',
80
+ justifyContent: 'flex-end'
81
+ } }, h("dnn-button", { type: 'primary', style: { margin: '5px' }, onClick: () => this.handleConfirm() }, this.confirmYesText), h("dnn-button", { type: 'secondary', style: { margin: '5px' }, onClick: () => this.handleCancel() }, this.confirmNoText)))));
82
+ }
83
+ get el() { return getElement(this); }
84
+ };
81
85
  DnnButton.style = dnnButtonCss;
82
86
 
83
- const dnnCheckboxCss = ":host{--focus-color:var(--dnn-color-primary, #3792ED);display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;gap:0.25rem;margin:3px}button{background-color:transparent;border:0;padding:0;margin:0;outline:none;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}button svg.undefined{opacity:0.45}button:focus{-webkit-box-shadow:0 0 2px 2px var(--focus-color);box-shadow:0 0 2px 2px var(--focus-color)}";
87
+ const dnnCheckboxCss = ":host{--focus-color:var(--dnn-color-primary, #3792ED);display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;gap:0.25rem;margin:3px}button{background-color:transparent;border:0;padding:0;margin:0;outline:none;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}button .unchecked,button .checked,button .intermediate{display:none}button.checked .checked,button.unchecked .unchecked,button.intermediate .intermediate{display:block}button svg.undefined{opacity:0.45}button:focus{-webkit-box-shadow:0 0 2px 2px var(--focus-color);box-shadow:0 0 2px 2px var(--focus-color)}";
84
88
 
85
- let DnnCheckbox = class {
86
- constructor(hostRef) {
87
- registerInstance(this, hostRef);
88
- this.checkedchange = createEvent(this, "checkedchange", 7);
89
- /** Defines if the checkbox is checked (true) or unchecked (false) or in an intermediate state (undefined) */
90
- this.checked = false;
91
- /** Defines if clicking the checkbox will go through the intermediate state between checked and unchecked (tri-state) */
92
- this.useIntermediate = false;
93
- }
94
- changeState() {
95
- if (!this.useIntermediate) {
96
- this.checked = !this.checked;
97
- this.emitEvents();
98
- return;
99
- }
100
- if (this.checked === true) {
101
- this.checked = false;
102
- this.button.classList.remove("undefined");
103
- this.emitEvents();
104
- return;
105
- }
106
- if (this.checked === undefined) {
107
- this.checked = true;
108
- this.button.classList.remove("undefined");
109
- this.emitEvents();
110
- return;
111
- }
112
- if (this.checked === false) {
113
- this.checked = undefined;
114
- this.button.classList.add("undefined");
115
- this.emitEvents();
116
- return;
117
- }
118
- }
119
- emitEvents() {
120
- this.checkedchange.emit(this.checked);
121
- }
122
- render() {
123
- return (h(Host, null, h("button", { class: "icon", onClick: () => this.changeState(), ref: el => this.button = el }, this.checked === false &&
124
- h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z" })), this.checked === true &&
125
- h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" })), this.checked === undefined &&
126
- h("svg", { class: "undefined", xmlns: "http://www.w3.org/2000/svg", "enable-background": "new 0 0 24 24", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("g", null, h("rect", { fill: "none", height: "24", width: "24" })), h("g", null, h("g", null, h("g", null, h("path", { d: "M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M17,13H7v-2h10V13z" })))))), h("label", { htmlFor: this.el.id, onClick: () => this.changeState() }, h("slot", null))));
127
- }
128
- get el() { return getElement(this); }
129
- };
89
+ const DnnCheckbox = class {
90
+ constructor(hostRef) {
91
+ registerInstance(this, hostRef);
92
+ this.checkedchange = createEvent(this, "checkedchange", 7);
93
+ /** Defines if the checkbox is checked (true) or unchecked (false) or in an intermediate state (undefined) */
94
+ this.checked = "unchecked";
95
+ /** Defines if clicking the checkbox will go through the intermediate state between checked and unchecked (tri-state) */
96
+ this.useIntermediate = false;
97
+ }
98
+ changeState() {
99
+ if (!this.useIntermediate) {
100
+ switch (this.checked) {
101
+ case "checked":
102
+ this.checked = "unchecked";
103
+ break;
104
+ case "unchecked":
105
+ case "intermediate":
106
+ this.checked = "checked";
107
+ break;
108
+ }
109
+ this.checkedchange.emit(this.checked);
110
+ return;
111
+ }
112
+ switch (this.checked) {
113
+ case "checked":
114
+ this.checked = "intermediate";
115
+ break;
116
+ case "intermediate":
117
+ this.checked = "unchecked";
118
+ break;
119
+ case "unchecked":
120
+ this.checked = "checked";
121
+ break;
122
+ }
123
+ this.checkedchange.emit(this.checked);
124
+ }
125
+ render() {
126
+ return (h(Host, null, h("button", { class: `icon ${this.checked}`, onClick: () => this.changeState() }, h("div", { class: "unchecked" }, h("slot", { name: "uncheckedicon" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z" })))), h("div", { class: "checked" }, h("slot", { name: "checkedicon" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" })))), h("div", { class: "intermediate" }, h("slot", { name: "intermediateicon" }, h("svg", { class: "undefined", xmlns: "http://www.w3.org/2000/svg", "enable-background": "new 0 0 24 24", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("g", null, h("rect", { fill: "none", height: "24", width: "24" })), h("g", null, h("g", null, h("g", null, h("path", { d: "M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M17,13H7v-2h10V13z" })))))))), h("label", { htmlFor: this.el.id, onClick: () => this.changeState() }, h("slot", null))));
127
+ }
128
+ get el() { return getElement(this); }
129
+ };
130
130
  DnnCheckbox.style = dnnCheckboxCss;
131
131
 
132
132
  const dnnChevronCss = ":host{display:inline-block}button{border:none;padding:0px;margin:0px;min-width:15px;min-height:15px;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;background-color:transparent;outline:none}svg{height:2em;width:2em;-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out}button:focus svg,button:hover svg{color:var(--dnn-color-primary)}:host([expanded]) svg{-webkit-transform:rotate(90deg);transform:rotate(90deg)}";
133
133
 
134
- let DnnChevron = class {
135
- constructor(hostRef) {
136
- registerInstance(this, hostRef);
137
- this.changed = createEvent(this, "changed", 7);
138
- /** Expand text for screen readers */
139
- this.expandText = "expand";
140
- /** Collapse text for screen readers */
141
- this.collapseText = "collapse";
142
- /** Is the chevron expanded */
143
- this.expanded = false;
144
- }
145
- handleExpandedChanged(newValue) {
146
- this.changed.emit(newValue);
147
- }
148
- render() {
149
- return (h(Host, null, h("button", { "aria-label": this.expanded ? this.collapseText : this.expandText, onClick: () => this.expanded = !this.expanded }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" })))));
150
- }
151
- static get watchers() { return {
152
- "expanded": ["handleExpandedChanged"]
153
- }; }
154
- };
134
+ const DnnChevron = class {
135
+ constructor(hostRef) {
136
+ registerInstance(this, hostRef);
137
+ this.changed = createEvent(this, "changed", 7);
138
+ /** Expand text for screen readers */
139
+ this.expandText = "expand";
140
+ /** Collapse text for screen readers */
141
+ this.collapseText = "collapse";
142
+ /** Is the chevron expanded */
143
+ this.expanded = false;
144
+ }
145
+ handleExpandedChanged(newValue) {
146
+ this.changed.emit(newValue);
147
+ }
148
+ render() {
149
+ return (h(Host, null, h("button", { "aria-label": this.expanded ? this.collapseText : this.expandText, onClick: () => this.expanded = !this.expanded }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" })))));
150
+ }
151
+ static get watchers() { return {
152
+ "expanded": ["handleExpandedChanged"]
153
+ }; }
154
+ };
155
155
  DnnChevron.style = dnnChevronCss;
156
156
 
157
157
  const dnnCollapsibleCss = ":host{display:block}#container{max-height:0;overflow:hidden;-webkit-transition:max-height 300ms ease-in-out;transition:max-height 300ms ease-in-out}";
158
158
 
159
- let DnnCollapsible = class {
160
- constructor(hostRef) {
161
- registerInstance(this, hostRef);
162
- this.dnnCollapsibleHeightChanged = createEvent(this, "dnnCollapsibleHeightChanged", 7);
163
- /** Defines if the panel is expanded or not. */
164
- this.expanded = false;
165
- /** Defines the transition time in ms, defaults to 100ms */
166
- this.transitionDuration = 150;
167
- }
168
- handleHeightChanged() {
169
- requestAnimationFrame(() => {
170
- this.updateSize();
171
- });
172
- }
173
- /**
174
- * Updates the component height, use to update after a slot content changes.
175
- */
176
- async updateSize() {
177
- if (this.expanded) {
178
- requestAnimationFrame(() => {
179
- this.container.style.maxHeight = `${this.container.scrollHeight}px`;
180
- });
181
- setTimeout(() => {
182
- this.container.style.maxHeight = "none";
183
- }, this.transitionDuration);
184
- }
185
- }
186
- handledExpandedChanged(expanded) {
187
- if (expanded) {
188
- this.updateSize();
189
- }
190
- else {
191
- requestAnimationFrame(() => {
192
- this.container.style.maxHeight = `${this.container.scrollHeight}px`;
193
- requestAnimationFrame(() => {
194
- this.container.style.maxHeight = "0px";
195
- });
196
- });
197
- }
198
- setTimeout(() => {
199
- requestAnimationFrame(() => {
200
- this.dnnCollapsibleHeightChanged.emit();
201
- });
202
- }, this.transitionDuration);
203
- }
204
- render() {
205
- return (h(Host, null, h("div", { id: "container", class: this.expanded && "expanded", ref: el => this.container = el }, h("slot", null))));
206
- }
207
- get el() { return getElement(this); }
208
- static get watchers() { return {
209
- "expanded": ["handledExpandedChanged"]
210
- }; }
211
- };
159
+ const DnnCollapsible = class {
160
+ constructor(hostRef) {
161
+ registerInstance(this, hostRef);
162
+ this.dnnCollapsibleHeightChanged = createEvent(this, "dnnCollapsibleHeightChanged", 7);
163
+ /** Defines if the panel is expanded or not. */
164
+ this.expanded = false;
165
+ /** Defines the transition time in ms, defaults to 150ms */
166
+ this.transitionDuration = 150;
167
+ }
168
+ handleHeightChanged() {
169
+ requestAnimationFrame(() => {
170
+ this.updateSize();
171
+ });
172
+ }
173
+ /**
174
+ * Updates the component height, use to update after a slot content changes.
175
+ */
176
+ async updateSize() {
177
+ if (this.expanded) {
178
+ requestAnimationFrame(() => {
179
+ this.container.style.maxHeight = `${this.container.scrollHeight}px`;
180
+ });
181
+ setTimeout(() => {
182
+ this.container.style.maxHeight = "none";
183
+ }, this.transitionDuration);
184
+ }
185
+ }
186
+ handledExpandedChanged(expanded) {
187
+ if (expanded) {
188
+ this.updateSize();
189
+ }
190
+ else {
191
+ requestAnimationFrame(() => {
192
+ this.container.style.maxHeight = `${this.container.scrollHeight}px`;
193
+ requestAnimationFrame(() => {
194
+ this.container.style.maxHeight = "0px";
195
+ });
196
+ });
197
+ }
198
+ setTimeout(() => {
199
+ requestAnimationFrame(() => {
200
+ this.dnnCollapsibleHeightChanged.emit();
201
+ });
202
+ }, this.transitionDuration);
203
+ }
204
+ componentDidLoad() {
205
+ this.container.style.transition = `max-height ${this.transitionDuration}ms ease-in-out`;
206
+ }
207
+ render() {
208
+ return (h(Host, null, h("div", { id: "container", class: this.expanded && "expanded", ref: el => this.container = el, style: { transition: `max-height ${this.transitionDuration}ms ease-in-out` } }, h("slot", null))));
209
+ }
210
+ get el() { return getElement(this); }
211
+ static get watchers() { return {
212
+ "expanded": ["handledExpandedChanged"]
213
+ }; }
214
+ };
212
215
  DnnCollapsible.style = dnnCollapsibleCss;
213
216
 
214
- /** Color utility class with hsl and rgb converters
215
- * based on math at https://en.wikipedia.org/wiki/HSL_and_HSV
216
- * @copyright Copyright (c) .NET Foundation. All rights reserved.
217
- * @license MIT
218
- */
219
- class ColorInfo {
220
- constructor() {
221
- this._hue = 0;
222
- this._saturation = 0;
223
- this._lightness = 0;
224
- }
225
- /** gets the color hue
226
- * @returns a number between 0 and 359, could contain decimals
227
- */
228
- get hue() { return this._hue; }
229
- set hue(value) {
230
- if (value < 0) {
231
- value = 0;
232
- }
233
- if (value > 359) {
234
- value = 359;
235
- }
236
- this._hue = value;
237
- }
238
- /** gets the color saturation
239
- * @returns a number between 0 and 1, could contain decimals
240
- */
241
- get saturation() { return this._saturation; }
242
- set saturation(value) {
243
- if (value < 0) {
244
- value = 0;
245
- }
246
- if (value > 1) {
247
- value = 1;
248
- }
249
- this._saturation = value;
250
- }
251
- /** gets the color lightness
252
- * @returns a number between 0 and 1, could contain decimals
253
- */
254
- get lightness() { return this._lightness; }
255
- set lightness(value) {
256
- if (value < 0) {
257
- value = 0;
258
- }
259
- if (value > 1) {
260
- value = 1;
261
- }
262
- this._lightness = value;
263
- }
264
- /** gets or sets the red component
265
- * @returns an integer between 0 and 255
266
- */
267
- get red() {
268
- return this.getRGB().red;
269
- }
270
- set red(value) {
271
- this.setHSL(value, this.green, this.blue);
272
- }
273
- /** gets or sets the green component
274
- * @returns an integer between 0 and 255
275
- */
276
- get green() {
277
- return this.getRGB().green;
278
- }
279
- set green(value) {
280
- this.setHSL(this.red, value, this.blue);
281
- }
282
- /** gets or sets the blue component
283
- * @returns an integer between 0 and 255
284
- */
285
- get blue() {
286
- return this.getRGB().blue;
287
- }
288
- set blue(value) {
289
- this.setHSL(this.red, this.green, value);
290
- }
291
- /** gets or sets the hex color value, expresses as 6 hexadecimal characters.
292
- * @returns hex representation of the color
293
- */
294
- get hex() {
295
- var r = this.getHex(this.red);
296
- var g = this.getHex(this.green);
297
- var b = this.getHex(this.blue);
298
- return r + g + b;
299
- }
300
- set hex(value) {
301
- this.red = parseInt(value.substr(0, 2));
302
- this.green = parseInt(value.substr(2, 2));
303
- this.blue = parseInt(value.substr(4, 2));
304
- }
305
- /** gets white or black color that is a good oposite to the current color
306
- * @returns - "000000" or "FFFFFF"
307
- */
308
- get contrastColor() {
309
- const brightness = (this.red * 299 + this.green * 587 + this.blue * 114) / 1000;
310
- if (brightness > 127) {
311
- return "000000";
312
- }
313
- return "FFFFFF";
314
- }
315
- getRGB() {
316
- const chroma = (1 - Math.abs((2 * this._lightness) - 1)) * this.saturation;
317
- // find the quandrant of the hue
318
- const quadrant = this._hue / 60;
319
- // calculate the offset from the quandrant center
320
- const offset = chroma * (1 - Math.abs(quadrant % 2 - 1));
321
- // Apply the chroma to the primary component and the offset to the 2nd most important component
322
- let r = 0, g = 0, b = 0;
323
- if (0 <= quadrant && quadrant <= 1) {
324
- r = chroma;
325
- g = offset; // red to yellow
326
- }
327
- else if (1 <= quadrant && quadrant <= 2) {
328
- g = chroma;
329
- r = offset; // yellow to green
330
- }
331
- else if (2 <= quadrant && quadrant <= 3) {
332
- g = chroma;
333
- b = offset; // green to cyan
334
- }
335
- else if (3 <= quadrant && quadrant <= 4) {
336
- b = chroma;
337
- g = offset; // cyan to blue
338
- }
339
- else if (4 <= quadrant && quadrant <= 5) {
340
- b = chroma;
341
- r = offset; // blue to magenta
342
- }
343
- else if (5 <= quadrant && quadrant <= 6) {
344
- r = chroma;
345
- b = offset; // magenta to red
346
- }
347
- // calculate the bias to add to all channels to match the lightness
348
- const bias = this._lightness - (chroma / 2);
349
- return {
350
- red: Math.round((r + bias) * 255),
351
- green: Math.round((g + bias) * 255),
352
- blue: Math.round((b + bias) * 255)
353
- };
354
- }
355
- setHSL(red, green, blue) {
356
- // GENERAL DATA
357
- // all math is based on values from 0 to 1
358
- const r = red / 255, g = green / 255, b = blue / 255;
359
- // we need to max, min and the difference between them to derive hsl
360
- const min = Math.min(r, g, b);
361
- const max = Math.max(r, g, b);
362
- const diff = max - min;
363
- let h = 0, s = 0, l = 0;
364
- // HUE
365
- if (diff === 0) { // neutral
366
- h = 0;
367
- }
368
- else if (max === r) { // red (magenta to yellow range)
369
- h = 60 * ((g - b) / diff);
370
- }
371
- else if (max === g) { // green (yellow to cyan range)
372
- h = 60 * (2 + ((b - r) / diff));
373
- }
374
- else if (max === b) { // blue (cyan to magenta range)
375
- h = 60 * (4 + ((r - g) / diff));
376
- }
377
- if (h < 0) {
378
- h = h + 360;
379
- } // ensures positive hues only
380
- if (h > 359) {
381
- h = 359;
382
- } // ensures we never return 360 for simplicity since it is the same as 0
383
- // LIGHTNESS
384
- l = (max + min) / 2;
385
- // SATURATION
386
- if (max === 0 || min === 1) { // pure black or white have no saturation
387
- s = 0;
388
- }
389
- else {
390
- s = (max - l) / (Math.min(l, 1 - l));
391
- }
392
- this._hue = h;
393
- this._saturation = s;
394
- this._lightness = l;
395
- }
396
- getHex(value) {
397
- var hex = value.toString(16);
398
- if (hex.length < 2) {
399
- hex = "0" + hex;
400
- }
401
- return hex;
402
- }
217
+ /** Color utility class with hsl and rgb converters
218
+ * based on math at https://en.wikipedia.org/wiki/HSL_and_HSV
219
+ * @copyright Copyright (c) .NET Foundation. All rights reserved.
220
+ * @license MIT
221
+ */
222
+ class ColorInfo {
223
+ constructor() {
224
+ this._hue = 0;
225
+ this._saturation = 0;
226
+ this._lightness = 0;
227
+ }
228
+ /** gets the color hue
229
+ * @returns a number between 0 and 359, could contain decimals
230
+ */
231
+ get hue() { return this._hue; }
232
+ set hue(value) {
233
+ if (value < 0) {
234
+ value = 0;
235
+ }
236
+ if (value > 359) {
237
+ value = 359;
238
+ }
239
+ this._hue = value;
240
+ }
241
+ /** gets the color saturation
242
+ * @returns a number between 0 and 1, could contain decimals
243
+ */
244
+ get saturation() { return this._saturation; }
245
+ set saturation(value) {
246
+ if (value < 0) {
247
+ value = 0;
248
+ }
249
+ if (value > 1) {
250
+ value = 1;
251
+ }
252
+ this._saturation = value;
253
+ }
254
+ /** gets the color lightness
255
+ * @returns a number between 0 and 1, could contain decimals
256
+ */
257
+ get lightness() { return this._lightness; }
258
+ set lightness(value) {
259
+ if (value < 0) {
260
+ value = 0;
261
+ }
262
+ if (value > 1) {
263
+ value = 1;
264
+ }
265
+ this._lightness = value;
266
+ }
267
+ /** gets or sets the red component
268
+ * @returns an integer between 0 and 255
269
+ */
270
+ get red() {
271
+ return this.getRGB().red;
272
+ }
273
+ set red(value) {
274
+ this.setHSL(value, this.green, this.blue);
275
+ }
276
+ /** gets or sets the green component
277
+ * @returns an integer between 0 and 255
278
+ */
279
+ get green() {
280
+ return this.getRGB().green;
281
+ }
282
+ set green(value) {
283
+ this.setHSL(this.red, value, this.blue);
284
+ }
285
+ /** gets or sets the blue component
286
+ * @returns an integer between 0 and 255
287
+ */
288
+ get blue() {
289
+ return this.getRGB().blue;
290
+ }
291
+ set blue(value) {
292
+ this.setHSL(this.red, this.green, value);
293
+ }
294
+ /** gets or sets the hex color value, expresses as 6 hexadecimal characters.
295
+ * @returns hex representation of the color
296
+ */
297
+ get hex() {
298
+ var r = this.getHex(this.red);
299
+ var g = this.getHex(this.green);
300
+ var b = this.getHex(this.blue);
301
+ return r + g + b;
302
+ }
303
+ set hex(value) {
304
+ this.red = parseInt(value.substr(0, 2));
305
+ this.green = parseInt(value.substr(2, 2));
306
+ this.blue = parseInt(value.substr(4, 2));
307
+ }
308
+ /** gets white or black color that is a good oposite to the current color
309
+ * @returns - "000000" or "FFFFFF"
310
+ */
311
+ get contrastColor() {
312
+ const brightness = (this.red * 299 + this.green * 587 + this.blue * 114) / 1000;
313
+ if (brightness > 127) {
314
+ return "000000";
315
+ }
316
+ return "FFFFFF";
317
+ }
318
+ getRGB() {
319
+ const chroma = (1 - Math.abs((2 * this._lightness) - 1)) * this.saturation;
320
+ // find the quandrant of the hue
321
+ const quadrant = this._hue / 60;
322
+ // calculate the offset from the quandrant center
323
+ const offset = chroma * (1 - Math.abs(quadrant % 2 - 1));
324
+ // Apply the chroma to the primary component and the offset to the 2nd most important component
325
+ let r = 0, g = 0, b = 0;
326
+ if (0 <= quadrant && quadrant <= 1) {
327
+ r = chroma;
328
+ g = offset; // red to yellow
329
+ }
330
+ else if (1 <= quadrant && quadrant <= 2) {
331
+ g = chroma;
332
+ r = offset; // yellow to green
333
+ }
334
+ else if (2 <= quadrant && quadrant <= 3) {
335
+ g = chroma;
336
+ b = offset; // green to cyan
337
+ }
338
+ else if (3 <= quadrant && quadrant <= 4) {
339
+ b = chroma;
340
+ g = offset; // cyan to blue
341
+ }
342
+ else if (4 <= quadrant && quadrant <= 5) {
343
+ b = chroma;
344
+ r = offset; // blue to magenta
345
+ }
346
+ else if (5 <= quadrant && quadrant <= 6) {
347
+ r = chroma;
348
+ b = offset; // magenta to red
349
+ }
350
+ // calculate the bias to add to all channels to match the lightness
351
+ const bias = this._lightness - (chroma / 2);
352
+ return {
353
+ red: Math.round((r + bias) * 255),
354
+ green: Math.round((g + bias) * 255),
355
+ blue: Math.round((b + bias) * 255)
356
+ };
357
+ }
358
+ setHSL(red, green, blue) {
359
+ // GENERAL DATA
360
+ // all math is based on values from 0 to 1
361
+ const r = red / 255, g = green / 255, b = blue / 255;
362
+ // we need to max, min and the difference between them to derive hsl
363
+ const min = Math.min(r, g, b);
364
+ const max = Math.max(r, g, b);
365
+ const diff = max - min;
366
+ let h = 0, s = 0, l = 0;
367
+ // HUE
368
+ if (diff === 0) { // neutral
369
+ h = 0;
370
+ }
371
+ else if (max === r) { // red (magenta to yellow range)
372
+ h = 60 * ((g - b) / diff);
373
+ }
374
+ else if (max === g) { // green (yellow to cyan range)
375
+ h = 60 * (2 + ((b - r) / diff));
376
+ }
377
+ else if (max === b) { // blue (cyan to magenta range)
378
+ h = 60 * (4 + ((r - g) / diff));
379
+ }
380
+ if (h < 0) {
381
+ h = h + 360;
382
+ } // ensures positive hues only
383
+ if (h > 359) {
384
+ h = 359;
385
+ } // ensures we never return 360 for simplicity since it is the same as 0
386
+ // LIGHTNESS
387
+ l = (max + min) / 2;
388
+ // SATURATION
389
+ if (max === 0 || min === 1) { // pure black or white have no saturation
390
+ s = 0;
391
+ }
392
+ else {
393
+ s = (max - l) / (Math.min(l, 1 - l));
394
+ }
395
+ this._hue = h;
396
+ this._saturation = s;
397
+ this._lightness = l;
398
+ }
399
+ getHex(value) {
400
+ var hex = value.toString(16);
401
+ if (hex.length < 2) {
402
+ hex = "0" + hex;
403
+ }
404
+ return hex;
405
+ }
403
406
  }
404
407
 
405
408
  const dnnColorPickerCss = ".dnn-color-picker{padding:15px;max-width:400px}.dnn-color-picker .dnn-color-sliders{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;min-width:200px}.dnn-color-picker .dnn-color-sliders .dnn-color-s-b{border:1px solid #ccc;padding-bottom:var(--color-box-height, 50%);position:relative;background-color:red}.dnn-color-picker .dnn-color-sliders .dnn-color-s-b:before{content:\"\";position:absolute;top:0;left:0;width:100%;height:100%;z-index:1;background:-webkit-gradient(linear, left top, right top, from(white), to(red));background:linear-gradient(to right, white, red);mix-blend-mode:saturation}.dnn-color-picker .dnn-color-sliders .dnn-color-s-b:after{content:\"\";position:absolute;top:0;left:0;width:100%;height:100%;z-index:2;background:-webkit-gradient(linear, left top, left bottom, from(white), to(black));background:linear-gradient(to bottom, white, black);mix-blend-mode:luminosity}.dnn-color-picker .dnn-color-sliders .dnn-color-s-b button{position:absolute;bottom:calc(50% - 4px);left:calc(50% - 4px);width:8px;height:8px;z-index:3;display:block;background:none;border:none;margin-left:-4px;margin-bottom:-4px;padding:7px;background-color:#fff;border-radius:50%}.dnn-color-picker .dnn-color-sliders .dnn-color-s-b button:before{content:\"\";position:absolute;top:-1px;left:-1px;border-radius:50%}.dnn-color-picker .dnn-color-sliders .dnn-color-s-b button:after{content:\"\";position:absolute;top:0px;left:0px;border-radius:50%;width:10px;height:10px;border:2px solid #ccc}.dnn-color-picker .dnn-color-sliders .dnn-color-bar{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;margin-top:15px}.dnn-color-picker .dnn-color-sliders .dnn-color-bar .dnn-color-result{-ms-flex-direction:column;flex-direction:column;width:50px;height:50px;border-radius:50%;background:red}.dnn-color-picker .dnn-color-sliders .dnn-color-bar .dnn-color-hue{-ms-flex:auto;flex:auto;margin-left:10px;height:16px;border:1px solid #ccc;position:relative;background:-webkit-gradient(linear, left top, right top, color-stop(0, #f00), color-stop(17%, #ff0), color-stop(33%, #0f0), color-stop(50%, #0ff), color-stop(67%, #00f), color-stop(84%, #f0f), to(#f00));background:linear-gradient(to right, #f00 0, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 84%, #f00 100%)}.dnn-color-picker .dnn-color-sliders .dnn-color-bar .dnn-color-hue button{width:10px;height:20px;position:absolute;top:-2px;left:calc(50% - 4px);border:0;padding:0;background-color:transparent;padding-left:-8px}.dnn-color-picker .dnn-color-sliders .dnn-color-bar .dnn-color-hue button:before{content:\"\";position:absolute;top:-2px;left:0px;border-radius:3px;width:100%;height:100%;border:1px solid #ccc;background-color:#fff}.dnn-color-picker .dnn-color-fields{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:justify;justify-content:space-between}.dnn-color-picker .dnn-color-fields .dnn-color-mode-switch{display:-ms-flexbox;display:flex;-ms-flex-align:end;align-items:flex-end;padding:0.5em}.dnn-color-picker .dnn-color-fields .dnn-color-mode-switch button{background-color:transparent;border:none}.dnn-color-picker .dnn-color-fields .dnn-color-mode-switch button svg{width:3em;height:3em;pointer-events:none;outline:none}.dnn-color-picker .dnn-color-fields .dnn-rgb-color-fields{display:-ms-flexbox;display:flex;-ms-flex-pack:space-evenly;justify-content:space-evenly}.dnn-color-picker .dnn-color-fields .dnn-rgb-color-fields .dnn-rgb-color-field{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex:auto;flex:auto;text-align:center;padding:0.5em}.dnn-color-picker .dnn-color-fields .dnn-rgb-color-fields .dnn-rgb-color-field label{padding-bottom:0.25em}.dnn-color-picker .dnn-color-fields .dnn-rgb-color-fields .dnn-rgb-color-field input{border-radius:var(--dnn-button-radius, 3px);border:1px solid #ccc;padding:0.5em;padding-left:1.3em;text-align:center}.dnn-color-picker .dnn-color-fields .dnn-rgb-color-fields .dnn-rgb-color-field input.red{border-color:red}.dnn-color-picker .dnn-color-fields .dnn-rgb-color-fields .dnn-rgb-color-field input.green{border-color:green}.dnn-color-picker .dnn-color-fields .dnn-rgb-color-fields .dnn-rgb-color-field input.blue{border-color:blue}.dnn-color-picker .dnn-color-fields .dnn-hsl-color-fields{display:-ms-flexbox;display:flex;-ms-flex-pack:space-evenly;justify-content:space-evenly}.dnn-color-picker .dnn-color-fields .dnn-hsl-color-fields .dnn-hsl-color-field{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex:auto;flex:auto;text-align:center;padding:0.5em}.dnn-color-picker .dnn-color-fields .dnn-hsl-color-fields .dnn-hsl-color-field label{padding-bottom:0.25em}.dnn-color-picker .dnn-color-fields .dnn-hsl-color-fields .dnn-hsl-color-field input{border-radius:var(--dnn-button-radius, 3px);border:1px solid #ccc;padding:0.5em;padding-left:1.3em;text-align:center}.dnn-color-picker .dnn-color-fields .dnn-hex-color-fields{display:-ms-flexbox;display:flex;-ms-flex-pack:space-evenly;justify-content:space-evenly}.dnn-color-picker .dnn-color-fields .dnn-hex-color-fields .dnn-hex-color-field{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex:auto;flex:auto;text-align:center;padding:0.5em}.dnn-color-picker .dnn-color-fields .dnn-hex-color-fields .dnn-hex-color-field label{padding-bottom:0.25em}.dnn-color-picker .dnn-color-fields .dnn-hex-color-fields .dnn-hex-color-field .hex-input{position:relative;border-radius:var(--dnn-button-radius, 3px);border:1px solid #ccc;padding:0.323em;text-align:center}.dnn-color-picker .dnn-color-fields .dnn-hex-color-fields .dnn-hex-color-field .hex-input input{border:0;padding:0;margin:0;width:100%;height:100%;text-align:center}.dnn-color-picker .dnn-color-fields .dnn-hex-color-fields .dnn-hex-color-field .hex-input button{position:absolute;height:100%;top:0;right:1em;background-color:transparent;border:0;padding:0;margin:0}.dnn-color-picker .dnn-color-fields .dnn-hex-color-fields .dnn-hex-color-field .hex-input button svg{min-width:1em}";
406
409
 
407
- /** Reusable DNN UI component to pick a color
408
- * @copyright Copyright (c) .NET Foundation. All rights reserved.
409
- * @license MIT
410
- */
411
- var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
412
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
413
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
414
- r = Reflect.decorate(decorators, target, key, desc);
415
- else
416
- for (var i = decorators.length - 1; i >= 0; i--)
417
- if (d = decorators[i])
418
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
419
- return c > 3 && r && Object.defineProperty(target, key, r), r;
420
- };
421
- let DnnColorPicker = class {
422
- constructor(hostRef) {
423
- registerInstance(this, hostRef);
424
- this.colorChanged = createEvent(this, "colorChanged", 7);
425
- /** Sets the initial color, must be a valid 8 character hexadecimal string without the # sign. */
426
- this.color = "FFFFFF";
427
- /** Sets the width-height ratio of the color picker saturation-lightness box.
428
- * @example 100% renders a perfect square
429
- */
430
- this.colorBoxHeight = "50%";
431
- this.rgbDisplay = "flex";
432
- this.hslDisplay = "none";
433
- this.hexDisplay = "none";
434
- this.handleSaturationLightnessMouseDown = (e) => {
435
- e.preventDefault();
436
- this.handleDragLightnessSaturation(e);
437
- window.addEventListener('mousemove', this.handleDragLightnessSaturation);
438
- window.addEventListener('mouseup', this.handleSaturationLightnessMouseUp);
439
- };
440
- this.handleDragLightnessSaturation = (e) => {
441
- const rect = this.saturationLightnessBox.getBoundingClientRect();
442
- let x = e.clientX - rect.left;
443
- if (x < 0) {
444
- x = 0;
445
- }
446
- if (x > rect.width) {
447
- x = rect.width;
448
- }
449
- x = x / rect.width;
450
- let y = e.clientY - rect.top;
451
- if (y < 0) {
452
- y = 0;
453
- }
454
- if (y > rect.height) {
455
- y = rect.height;
456
- }
457
- y = 1 - (y / rect.height);
458
- const newColor = new ColorInfo();
459
- newColor.hue = this.currentColor.hue;
460
- newColor.saturation = x;
461
- newColor.lightness = y;
462
- this.currentColor = newColor;
463
- };
464
- this.handleSaturationLightnessMouseUp = () => {
465
- window.removeEventListener('mousemove', this.handleDragLightnessSaturation);
466
- window.removeEventListener('mouseup', this.handleSaturationLightnessMouseUp);
467
- };
468
- this.handleHueMouseDown = (e) => {
469
- e.preventDefault();
470
- this.handleDragHue(e);
471
- window.addEventListener('mousemove', this.handleDragHue);
472
- window.addEventListener('mouseup', this.handleHueMouseUp);
473
- };
474
- this.handleHueMouseUp = () => {
475
- window.removeEventListener('mousemove', this.handleDragHue);
476
- window.removeEventListener('mouseup', this.handleHueMouseUp);
477
- };
478
- this.handleDragHue = (e) => {
479
- const rect = this.hueRange.getBoundingClientRect();
480
- let x = e.clientX - rect.left;
481
- if (x < 0) {
482
- x = 0;
483
- }
484
- if (x > rect.width) {
485
- x = rect.width;
486
- }
487
- x = x / rect.width * 360;
488
- const newColor = new ColorInfo();
489
- newColor.hue = x;
490
- newColor.saturation = this.currentColor.saturation;
491
- newColor.lightness = this.currentColor.lightness;
492
- this.currentColor = newColor;
493
- };
494
- this.handleComponentValueChange = (e, channel) => {
495
- let value = parseInt(e.target.value);
496
- if (isNaN(value)) {
497
- return;
498
- }
499
- const newColor = new ColorInfo();
500
- if (value < 0) {
501
- value = 0;
502
- }
503
- if (value > 255) {
504
- value = 255;
505
- }
506
- let r = this.currentColor.red;
507
- let g = this.currentColor.green;
508
- let b = this.currentColor.blue;
509
- switch (channel) {
510
- case 'red':
511
- r = value;
512
- break;
513
- case 'green':
514
- g = value;
515
- break;
516
- case 'blue':
517
- b = value;
518
- break;
519
- }
520
- newColor.green = g;
521
- newColor.red = r;
522
- newColor.blue = b;
523
- this.currentColor = newColor;
524
- };
525
- this.handleHSLChange = (e, component) => {
526
- let value = parseInt(e.target.value);
527
- if (isNaN(value)) {
528
- return;
529
- }
530
- const newColor = new ColorInfo();
531
- if (value != null) {
532
- let h = this.currentColor.hue;
533
- let s = this.currentColor.saturation;
534
- let l = this.currentColor.lightness;
535
- switch (component) {
536
- case "hue":
537
- if (value < 0) {
538
- value = 0;
539
- }
540
- if (value > 359) {
541
- value = 0;
542
- }
543
- h = value;
544
- break;
545
- case "saturation":
546
- if (value < 0) {
547
- value = 0;
548
- }
549
- if (value > 100) {
550
- value = 100;
551
- }
552
- s = value / 100;
553
- break;
554
- case "lightness":
555
- if (value < 0) {
556
- value = 0;
557
- }
558
- if (value > 100) {
559
- value = 100;
560
- }
561
- l = value / 100;
562
- break;
563
- }
564
- newColor.hue = h;
565
- newColor.saturation = s;
566
- newColor.lightness = l;
567
- this.currentColor = newColor;
568
- }
569
- };
570
- this.handleSaturationLightnessKeyDown = (e) => {
571
- let newColor = new ColorInfo();
572
- newColor.hue = this.currentColor.hue;
573
- newColor.saturation = this.currentColor.saturation;
574
- newColor.lightness = this.currentColor.lightness;
575
- let value = 0.01;
576
- if (e.shiftKey) {
577
- value = 0.1;
578
- }
579
- switch (e.key) {
580
- case "ArrowUp":
581
- newColor.lightness += value;
582
- break;
583
- case "ArrowDown":
584
- newColor.lightness -= value;
585
- break;
586
- case "ArrowLeft":
587
- newColor.saturation -= value;
588
- break;
589
- case "ArrowRight":
590
- newColor.saturation += value;
591
- }
592
- this.currentColor = newColor;
593
- };
594
- this.handleHueKeyDown = (e) => {
595
- let newColor = new ColorInfo();
596
- newColor.hue = this.currentColor.hue;
597
- newColor.saturation = this.currentColor.saturation;
598
- newColor.lightness = this.currentColor.lightness;
599
- let value = 1;
600
- if (e.shiftKey) {
601
- value = 10;
602
- }
603
- switch (e.key) {
604
- case "ArrowLeft":
605
- newColor.hue -= value;
606
- break;
607
- case "ArrowRight":
608
- newColor.hue += value;
609
- }
610
- this.currentColor = newColor;
611
- };
612
- }
613
- colorChangedHandler(color) {
614
- this.colorChanged.emit(color);
615
- }
616
- handeCurrentColorChanged(newValue) {
617
- this.colorChangedHandler(newValue);
618
- }
619
- componentWillLoad() {
620
- this.handleHexChange(this.color);
621
- }
622
- componentDidLoad() {
623
- this.el.style.setProperty("--color-box-height", this.colorBoxHeight.toString());
624
- }
625
- getHex() {
626
- return this.getDoublet(this.currentColor.red) + this.getDoublet(this.currentColor.green) + this.getDoublet(this.currentColor.blue);
627
- }
628
- getContrast() {
629
- return this.currentColor.contrastColor;
630
- }
631
- getDoublet(value) {
632
- const valueString = value.toString(16).toUpperCase();
633
- if (valueString.length === 1) {
634
- return '0' + valueString;
635
- }
636
- return valueString;
637
- }
638
- handleHexChange(value) {
639
- const newColor = new ColorInfo();
640
- if (value.match(/^(?:[\da-f]{3}|[\da-f]{6})$/i).length > 0) {
641
- if (value.length === 3) {
642
- let expanded = value[0] + value[0] + value[1] + value[1] + value[2] + value[2];
643
- value = expanded;
644
- }
645
- newColor.red = parseInt(value.substr(0, 2), 16);
646
- newColor.green = parseInt(value.substr(2, 2), 16);
647
- newColor.blue = parseInt(value.substr(4, 2), 16);
648
- }
649
- else {
650
- newColor.red = this.currentColor.red;
651
- newColor.green = this.currentColor.green;
652
- newColor.blue = this.currentColor.blue;
653
- }
654
- this.currentColor = newColor;
655
- }
656
- switchColorMode(e) {
657
- switch (e.target.id) {
658
- case "rgb-switch":
659
- this.rgbDisplay = "none";
660
- this.hslDisplay = "none";
661
- this.hexDisplay = "flex";
662
- break;
663
- case "hex-switch":
664
- this.rgbDisplay = "none";
665
- this.hslDisplay = "flex";
666
- this.hexDisplay = "none";
667
- break;
668
- case "hsl-switch":
669
- this.rgbDisplay = "flex";
670
- this.hslDisplay = "none";
671
- this.hexDisplay = "none";
672
- break;
673
- default:
674
- this.rgbDisplay = "flex";
675
- this.hslDisplay = "none";
676
- this.hexDisplay = "none";
677
- }
678
- }
679
- render() {
680
- const hue = this.currentColor.hue;
681
- const saturation = this.currentColor.saturation;
682
- const lightness = this.currentColor.lightness;
683
- const red = this.currentColor.red;
684
- const green = this.currentColor.green;
685
- const blue = this.currentColor.blue;
686
- return (h("div", { class: "dnn-color-picker" }, h("div", { class: "dnn-color-sliders" }, h("div", { class: "dnn-color-s-b", ref: (element) => this.saturationLightnessBox = element, style: { backgroundColor: `hsl(${hue},100%,50%)` }, onMouseDown: this.handleSaturationLightnessMouseDown.bind(this) }, h("button", { class: "dnn-s-b-picker", "aria-label": "Press up or down to adjust lightness, left or right to adjust saturation, hold shift to move by 10%", role: "slider", "aria-valuemin": "0", "aria-valuemax": "100", "aria-valuetext": `Saturation: ${Math.round(this.currentColor.saturation * 100)}%, Lightness: ${Math.round(this.currentColor.lightness * 100)}%`, style: {
687
- left: Math.round(saturation * 100) + "%",
688
- bottom: Math.round(lightness * 100) + "%"
689
- }, onKeyDown: (e) => this.handleSaturationLightnessKeyDown(e) })), h("div", { class: "dnn-color-bar" }, h("div", { class: "dnn-color-result", style: {
690
- backgroundColor: '#' + this.getHex(),
691
- boxShadow: "0 0 2px 1px " + "#" + this.getContrast()
692
- } }), h("div", { class: "dnn-color-hue", ref: (element) => this.hueRange = element, onMouseDown: this.handleHueMouseDown.bind(this) }, h("button", { class: "dnn-hue-picker", "aria-label": "Press left or right to adjust hue, hold shift to move by 10 degrees", role: "slider", "aria-valuemin": "0", "aria-valuemax": "359", "aria-valuenow": Math.round(hue), style: { left: (hue / 359 * 100).toString() + "%" }, onKeyDown: (e) => this.handleHueKeyDown(e) })))), h("div", { class: "dnn-color-fields" }, h("div", { class: "dnn-rgb-color-fields", style: { display: this.rgbDisplay } }, h("div", { class: "dnn-rgb-color-field" }, h("label", null, "R"), h("input", { type: "number", min: "0", max: "255", step: "1", class: "red", value: red, "aria-label": "red value", onChange: (e) => this.handleComponentValueChange(e, 'red') })), h("div", { class: "dnn-rgb-color-field" }, h("label", null, "G"), h("input", { type: "number", min: "0", max: "255", class: "green", value: green, "aria-label": "green value", onChange: (e) => this.handleComponentValueChange(e, 'green') })), h("div", { class: "dnn-rgb-color-field" }, h("label", null, "B"), h("input", { type: "number", min: "0", max: "255", class: "blue", value: blue, "aria-label": "blue value", onChange: (e) => this.handleComponentValueChange(e, 'blue') })), h("div", { class: "dnn-color-mode-switch" }, h("button", { id: "rgb-switch", onClick: this.switchColorMode.bind(this), "aria-label": "switch to hexadecimal value entry" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))), h("div", { class: "dnn-hsl-color-fields", style: { display: this.hslDisplay } }, h("div", { class: "dnn-hsl-color-field" }, h("label", null, "H"), h("input", { type: "number", min: "0", max: "359", step: 1, value: Math.round(hue), "aria-label": "Hue", onChange: (e) => this.handleHSLChange(e, 'hue') })), h("div", { class: "dnn-hsl-color-field" }, h("label", null, "S"), h("input", { type: "number", min: "0", max: "100", step: 1, value: Math.round(saturation * 100), "aria-label": "Saturation", onChange: (e) => this.handleHSLChange(e, 'saturation') })), h("div", { class: "dnn-hsl-color-field" }, h("label", null, "L"), h("input", { type: "number", min: "0", max: "100", step: 1, value: Math.round(lightness * 100), "aria-label": "Lightness", onChange: (e) => this.handleHSLChange(e, 'lightness') })), h("div", { class: "dnn-color-mode-switch" }, h("button", { id: "hsl-switch", onClick: this.switchColorMode.bind(this), "aria-label": "Switch to red, green, blue entry mode" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))), h("div", { class: "dnn-hex-color-fields", style: { display: this.hexDisplay } }, h("div", { class: "dnn-hex-color-field" }, h("label", null, "HEX"), h("div", { class: "hex-input" }, h("input", { type: "text", "aria-label": "Hexadecimal value", value: this.getHex(), onChange: e => this.handleHexChange(e.target.value) }), h("button", { class: "copy", "aria-label": "copy value" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" }))))), h("div", { class: "dnn-color-mode-switch" }, h("button", { id: "hex-switch", onClick: this.switchColorMode.bind(this), "aria-label": "Switch to hue saturation lightness values" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))))));
693
- }
694
- get el() { return getElement(this); }
695
- static get watchers() { return {
696
- "currentColor": ["handeCurrentColorChanged"]
697
- }; }
698
- };
699
- __decorate$1([
700
- Debounce(100)
701
- ], DnnColorPicker.prototype, "colorChangedHandler", null);
410
+ /** Reusable DNN UI component to pick a color
411
+ * @copyright Copyright (c) .NET Foundation. All rights reserved.
412
+ * @license MIT
413
+ */
414
+ var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
415
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
416
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
417
+ r = Reflect.decorate(decorators, target, key, desc);
418
+ else
419
+ for (var i = decorators.length - 1; i >= 0; i--)
420
+ if (d = decorators[i])
421
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
422
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
423
+ };
424
+ const DnnColorPicker = class {
425
+ constructor(hostRef) {
426
+ registerInstance(this, hostRef);
427
+ this.colorChanged = createEvent(this, "colorChanged", 7);
428
+ /** Sets the initial color, must be a valid 8 character hexadecimal string without the # sign. */
429
+ this.color = "FFFFFF";
430
+ /** Sets the width-height ratio of the color picker saturation-lightness box.
431
+ * @example 100% renders a perfect square
432
+ */
433
+ this.colorBoxHeight = "50%";
434
+ this.rgbDisplay = "flex";
435
+ this.hslDisplay = "none";
436
+ this.hexDisplay = "none";
437
+ this.handleSaturationLightnessMouseDown = (e) => {
438
+ e.preventDefault();
439
+ this.handleDragLightnessSaturation(e);
440
+ window.addEventListener('mousemove', this.handleDragLightnessSaturation);
441
+ window.addEventListener('mouseup', this.handleSaturationLightnessMouseUp);
442
+ };
443
+ this.handleDragLightnessSaturation = (e) => {
444
+ const rect = this.saturationLightnessBox.getBoundingClientRect();
445
+ let x = e.clientX - rect.left;
446
+ if (x < 0) {
447
+ x = 0;
448
+ }
449
+ if (x > rect.width) {
450
+ x = rect.width;
451
+ }
452
+ x = x / rect.width;
453
+ let y = e.clientY - rect.top;
454
+ if (y < 0) {
455
+ y = 0;
456
+ }
457
+ if (y > rect.height) {
458
+ y = rect.height;
459
+ }
460
+ y = 1 - (y / rect.height);
461
+ const newColor = new ColorInfo();
462
+ newColor.hue = this.currentColor.hue;
463
+ newColor.saturation = x;
464
+ newColor.lightness = y;
465
+ this.currentColor = newColor;
466
+ };
467
+ this.handleSaturationLightnessMouseUp = () => {
468
+ window.removeEventListener('mousemove', this.handleDragLightnessSaturation);
469
+ window.removeEventListener('mouseup', this.handleSaturationLightnessMouseUp);
470
+ };
471
+ this.handleHueMouseDown = (e) => {
472
+ e.preventDefault();
473
+ this.handleDragHue(e);
474
+ window.addEventListener('mousemove', this.handleDragHue);
475
+ window.addEventListener('mouseup', this.handleHueMouseUp);
476
+ };
477
+ this.handleHueMouseUp = () => {
478
+ window.removeEventListener('mousemove', this.handleDragHue);
479
+ window.removeEventListener('mouseup', this.handleHueMouseUp);
480
+ };
481
+ this.handleDragHue = (e) => {
482
+ const rect = this.hueRange.getBoundingClientRect();
483
+ let x = e.clientX - rect.left;
484
+ if (x < 0) {
485
+ x = 0;
486
+ }
487
+ if (x > rect.width) {
488
+ x = rect.width;
489
+ }
490
+ x = x / rect.width * 360;
491
+ const newColor = new ColorInfo();
492
+ newColor.hue = x;
493
+ newColor.saturation = this.currentColor.saturation;
494
+ newColor.lightness = this.currentColor.lightness;
495
+ this.currentColor = newColor;
496
+ };
497
+ this.handleComponentValueChange = (e, channel) => {
498
+ let value = parseInt(e.target.value);
499
+ if (isNaN(value)) {
500
+ return;
501
+ }
502
+ const newColor = new ColorInfo();
503
+ if (value < 0) {
504
+ value = 0;
505
+ }
506
+ if (value > 255) {
507
+ value = 255;
508
+ }
509
+ let r = this.currentColor.red;
510
+ let g = this.currentColor.green;
511
+ let b = this.currentColor.blue;
512
+ switch (channel) {
513
+ case 'red':
514
+ r = value;
515
+ break;
516
+ case 'green':
517
+ g = value;
518
+ break;
519
+ case 'blue':
520
+ b = value;
521
+ break;
522
+ }
523
+ newColor.green = g;
524
+ newColor.red = r;
525
+ newColor.blue = b;
526
+ this.currentColor = newColor;
527
+ };
528
+ this.handleHSLChange = (e, component) => {
529
+ let value = parseInt(e.target.value);
530
+ if (isNaN(value)) {
531
+ return;
532
+ }
533
+ const newColor = new ColorInfo();
534
+ if (value != null) {
535
+ let h = this.currentColor.hue;
536
+ let s = this.currentColor.saturation;
537
+ let l = this.currentColor.lightness;
538
+ switch (component) {
539
+ case "hue":
540
+ if (value < 0) {
541
+ value = 0;
542
+ }
543
+ if (value > 359) {
544
+ value = 0;
545
+ }
546
+ h = value;
547
+ break;
548
+ case "saturation":
549
+ if (value < 0) {
550
+ value = 0;
551
+ }
552
+ if (value > 100) {
553
+ value = 100;
554
+ }
555
+ s = value / 100;
556
+ break;
557
+ case "lightness":
558
+ if (value < 0) {
559
+ value = 0;
560
+ }
561
+ if (value > 100) {
562
+ value = 100;
563
+ }
564
+ l = value / 100;
565
+ break;
566
+ }
567
+ newColor.hue = h;
568
+ newColor.saturation = s;
569
+ newColor.lightness = l;
570
+ this.currentColor = newColor;
571
+ }
572
+ };
573
+ this.handleSaturationLightnessKeyDown = (e) => {
574
+ let newColor = new ColorInfo();
575
+ newColor.hue = this.currentColor.hue;
576
+ newColor.saturation = this.currentColor.saturation;
577
+ newColor.lightness = this.currentColor.lightness;
578
+ let value = 0.01;
579
+ if (e.shiftKey) {
580
+ value = 0.1;
581
+ }
582
+ switch (e.key) {
583
+ case "ArrowUp":
584
+ newColor.lightness += value;
585
+ break;
586
+ case "ArrowDown":
587
+ newColor.lightness -= value;
588
+ break;
589
+ case "ArrowLeft":
590
+ newColor.saturation -= value;
591
+ break;
592
+ case "ArrowRight":
593
+ newColor.saturation += value;
594
+ }
595
+ this.currentColor = newColor;
596
+ };
597
+ this.handleHueKeyDown = (e) => {
598
+ let newColor = new ColorInfo();
599
+ newColor.hue = this.currentColor.hue;
600
+ newColor.saturation = this.currentColor.saturation;
601
+ newColor.lightness = this.currentColor.lightness;
602
+ let value = 1;
603
+ if (e.shiftKey) {
604
+ value = 10;
605
+ }
606
+ switch (e.key) {
607
+ case "ArrowLeft":
608
+ newColor.hue -= value;
609
+ break;
610
+ case "ArrowRight":
611
+ newColor.hue += value;
612
+ }
613
+ this.currentColor = newColor;
614
+ };
615
+ }
616
+ colorChangedHandler(color) {
617
+ this.colorChanged.emit(color);
618
+ }
619
+ handeCurrentColorChanged(newValue) {
620
+ this.colorChangedHandler(newValue);
621
+ }
622
+ componentWillLoad() {
623
+ this.handleHexChange(this.color);
624
+ }
625
+ componentDidLoad() {
626
+ this.el.style.setProperty("--color-box-height", this.colorBoxHeight.toString());
627
+ }
628
+ getHex() {
629
+ return this.getDoublet(this.currentColor.red) + this.getDoublet(this.currentColor.green) + this.getDoublet(this.currentColor.blue);
630
+ }
631
+ getContrast() {
632
+ return this.currentColor.contrastColor;
633
+ }
634
+ getDoublet(value) {
635
+ const valueString = value.toString(16).toUpperCase();
636
+ if (valueString.length === 1) {
637
+ return '0' + valueString;
638
+ }
639
+ return valueString;
640
+ }
641
+ handleHexChange(value) {
642
+ const newColor = new ColorInfo();
643
+ if (value.match(/^(?:[\da-f]{3}|[\da-f]{6})$/i).length > 0) {
644
+ if (value.length === 3) {
645
+ let expanded = value[0] + value[0] + value[1] + value[1] + value[2] + value[2];
646
+ value = expanded;
647
+ }
648
+ newColor.red = parseInt(value.substr(0, 2), 16);
649
+ newColor.green = parseInt(value.substr(2, 2), 16);
650
+ newColor.blue = parseInt(value.substr(4, 2), 16);
651
+ }
652
+ else {
653
+ newColor.red = this.currentColor.red;
654
+ newColor.green = this.currentColor.green;
655
+ newColor.blue = this.currentColor.blue;
656
+ }
657
+ this.currentColor = newColor;
658
+ }
659
+ switchColorMode(e) {
660
+ switch (e.target.id) {
661
+ case "rgb-switch":
662
+ this.rgbDisplay = "none";
663
+ this.hslDisplay = "none";
664
+ this.hexDisplay = "flex";
665
+ break;
666
+ case "hex-switch":
667
+ this.rgbDisplay = "none";
668
+ this.hslDisplay = "flex";
669
+ this.hexDisplay = "none";
670
+ break;
671
+ case "hsl-switch":
672
+ this.rgbDisplay = "flex";
673
+ this.hslDisplay = "none";
674
+ this.hexDisplay = "none";
675
+ break;
676
+ default:
677
+ this.rgbDisplay = "flex";
678
+ this.hslDisplay = "none";
679
+ this.hexDisplay = "none";
680
+ }
681
+ }
682
+ render() {
683
+ const hue = this.currentColor.hue;
684
+ const saturation = this.currentColor.saturation;
685
+ const lightness = this.currentColor.lightness;
686
+ const red = this.currentColor.red;
687
+ const green = this.currentColor.green;
688
+ const blue = this.currentColor.blue;
689
+ return (h("div", { class: "dnn-color-picker" }, h("div", { class: "dnn-color-sliders" }, h("div", { class: "dnn-color-s-b", ref: (element) => this.saturationLightnessBox = element, style: { backgroundColor: `hsl(${hue},100%,50%)` }, onMouseDown: this.handleSaturationLightnessMouseDown.bind(this) }, h("button", { class: "dnn-s-b-picker", "aria-label": "Press up or down to adjust lightness, left or right to adjust saturation, hold shift to move by 10%", role: "slider", "aria-valuemin": "0", "aria-valuemax": "100", "aria-valuetext": `Saturation: ${Math.round(this.currentColor.saturation * 100)}%, Lightness: ${Math.round(this.currentColor.lightness * 100)}%`, style: {
690
+ left: Math.round(saturation * 100) + "%",
691
+ bottom: Math.round(lightness * 100) + "%"
692
+ }, onKeyDown: (e) => this.handleSaturationLightnessKeyDown(e) })), h("div", { class: "dnn-color-bar" }, h("div", { class: "dnn-color-result", style: {
693
+ backgroundColor: '#' + this.getHex(),
694
+ boxShadow: "0 0 2px 1px " + "#" + this.getContrast()
695
+ } }), h("div", { class: "dnn-color-hue", ref: (element) => this.hueRange = element, onMouseDown: this.handleHueMouseDown.bind(this) }, h("button", { class: "dnn-hue-picker", "aria-label": "Press left or right to adjust hue, hold shift to move by 10 degrees", role: "slider", "aria-valuemin": "0", "aria-valuemax": "359", "aria-valuenow": Math.round(hue), style: { left: (hue / 359 * 100).toString() + "%" }, onKeyDown: (e) => this.handleHueKeyDown(e) })))), h("div", { class: "dnn-color-fields" }, h("div", { class: "dnn-rgb-color-fields", style: { display: this.rgbDisplay } }, h("div", { class: "dnn-rgb-color-field" }, h("label", null, "R"), h("input", { type: "number", min: "0", max: "255", step: "1", class: "red", value: red, "aria-label": "red value", onChange: (e) => this.handleComponentValueChange(e, 'red') })), h("div", { class: "dnn-rgb-color-field" }, h("label", null, "G"), h("input", { type: "number", min: "0", max: "255", class: "green", value: green, "aria-label": "green value", onChange: (e) => this.handleComponentValueChange(e, 'green') })), h("div", { class: "dnn-rgb-color-field" }, h("label", null, "B"), h("input", { type: "number", min: "0", max: "255", class: "blue", value: blue, "aria-label": "blue value", onChange: (e) => this.handleComponentValueChange(e, 'blue') })), h("div", { class: "dnn-color-mode-switch" }, h("button", { id: "rgb-switch", onClick: this.switchColorMode.bind(this), "aria-label": "switch to hexadecimal value entry" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))), h("div", { class: "dnn-hsl-color-fields", style: { display: this.hslDisplay } }, h("div", { class: "dnn-hsl-color-field" }, h("label", null, "H"), h("input", { type: "number", min: "0", max: "359", step: 1, value: Math.round(hue), "aria-label": "Hue", onChange: (e) => this.handleHSLChange(e, 'hue') })), h("div", { class: "dnn-hsl-color-field" }, h("label", null, "S"), h("input", { type: "number", min: "0", max: "100", step: 1, value: Math.round(saturation * 100), "aria-label": "Saturation", onChange: (e) => this.handleHSLChange(e, 'saturation') })), h("div", { class: "dnn-hsl-color-field" }, h("label", null, "L"), h("input", { type: "number", min: "0", max: "100", step: 1, value: Math.round(lightness * 100), "aria-label": "Lightness", onChange: (e) => this.handleHSLChange(e, 'lightness') })), h("div", { class: "dnn-color-mode-switch" }, h("button", { id: "hsl-switch", onClick: this.switchColorMode.bind(this), "aria-label": "Switch to red, green, blue entry mode" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))), h("div", { class: "dnn-hex-color-fields", style: { display: this.hexDisplay } }, h("div", { class: "dnn-hex-color-field" }, h("label", null, "HEX"), h("div", { class: "hex-input" }, h("input", { type: "text", "aria-label": "Hexadecimal value", value: this.getHex(), onChange: e => this.handleHexChange(e.target.value) }), h("button", { class: "copy", "aria-label": "copy value" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" }))))), h("div", { class: "dnn-color-mode-switch" }, h("button", { id: "hex-switch", onClick: this.switchColorMode.bind(this), "aria-label": "Switch to hue saturation lightness values" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))))));
696
+ }
697
+ get el() { return getElement(this); }
698
+ static get watchers() { return {
699
+ "currentColor": ["handeCurrentColorChanged"]
700
+ }; }
701
+ };
702
+ __decorate$1([
703
+ Debounce(100)
704
+ ], DnnColorPicker.prototype, "colorChangedHandler", null);
702
705
  DnnColorPicker.style = dnnColorPickerCss;
703
706
 
704
707
  const dnnDropzoneCss = ":host{--border-color:var(--dnn-color-tertiary-contrast, lightgray);--border-radius:var(--dnn-controls-radius, 5px);--drop-background-color:var(--dnn-color-tertiary, lightblue);display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:1rem;text-align:center;border:2px dashed var(--border-color);border-radius:var(--border-radius);padding:1rem;-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out}:host(.dropping){background-color:var(--drop-background-color)}p{margin:0;padding:0}button{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;border:0px;margin:0;padding:0;background-color:transparent}button:hover{cursor:pointer}button svg{margin-right:0.5rem}label.upload-file{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;cursor:pointer}label.upload-file input{display:none}.video-preview{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center}.video-preview button{margin:1rem}";
705
708
 
706
- let DnnDropzone = class {
707
- constructor(hostRef) {
708
- registerInstance(this, hostRef);
709
- this.filesSelected = createEvent(this, "filesSelected", 7);
710
- /** Localization strings */
711
- this.resx = {
712
- dragAndDropFile: "Drag and drop a file",
713
- capture: "Capture",
714
- or: "or",
715
- takePicture: "Take a picture",
716
- uploadFile: "Upload a file",
717
- };
718
- /**
719
- * If true, will allow the user to take a snapshot
720
- * using the device camera. (only works over https).
721
- */
722
- this.allowCameraMode = false;
723
- /**
724
- * Specifies the jpeg quality for when the device
725
- * camera is used to generate a picture.
726
- * Needs to be a number between 0 and 1 and defaults to 0.8
727
- */
728
- this.captureQuality = 0.8;
729
- this.canTakeSnapshots = false;
730
- this.takingPicture = false;
731
- this.handleDragOver = (event) => {
732
- event.stopPropagation();
733
- event.preventDefault();
734
- event.dataTransfer.dropEffect = "copy";
735
- this.dropzone.classList.add("dropping");
736
- };
737
- this.handleDrop = (dropEvent) => {
738
- dropEvent.stopPropagation();
739
- dropEvent.preventDefault();
740
- const files = dropEvent.dataTransfer.files;
741
- if (this.hasInvalidExtensions(files)) {
742
- return;
743
- }
744
- var fileList = this.getFilesFromFileList(files);
745
- this.filesSelected.emit(fileList);
746
- };
747
- }
748
- componentDidLoad() {
749
- if (this.allowCameraMode) {
750
- this.checkIfBrowserCanTakeSnapshots()
751
- .then(result => this.canTakeSnapshots = result);
752
- }
753
- if (this.allowedExtensions != undefined && this.allowedExtensions.length > 0) {
754
- var extensionsWithDots = this.allowedExtensions.map(e => `.${e}`);
755
- var extensionsList = extensionsWithDots.join(",");
756
- this.fileInput.accept = extensionsList;
757
- }
758
- }
759
- checkIfBrowserCanTakeSnapshots() {
760
- return new Promise((resolve) => {
761
- const mediaDevices = navigator.mediaDevices;
762
- if (mediaDevices == undefined || mediaDevices.enumerateDevices == undefined) {
763
- resolve(false);
764
- }
765
- mediaDevices.enumerateDevices()
766
- .then(devices => {
767
- var result = devices.some(device => device.kind == "videoinput");
768
- resolve(result);
769
- });
770
- });
771
- }
772
- getFilesFromFileList(files) {
773
- var fileList = [];
774
- for (let index = 0; index < files.length; index++) {
775
- const file = files[index];
776
- fileList.push(file);
777
- }
778
- return fileList;
779
- }
780
- handleUploadButton(element) {
781
- let files = this.getFilesFromFileList(element.files);
782
- this.filesSelected.emit(files);
783
- }
784
- hasInvalidExtensions(files) {
785
- var hasInvalid = false;
786
- for (let fileIndex = 0; fileIndex < files.length; fileIndex++) {
787
- const file = files[fileIndex];
788
- var regex = /(?:\.([^.]+))?$/;
789
- const fileExtension = regex.exec(file.name)[1];
790
- if (fileExtension == undefined) {
791
- hasInvalid = true;
792
- }
793
- if (this.allowedExtensions != undefined && !this.allowedExtensions.includes(fileExtension)) {
794
- hasInvalid = true;
795
- }
796
- return hasInvalid;
797
- }
798
- }
799
- takeSnapshot() {
800
- this.takingPicture = true;
801
- navigator.mediaDevices.getUserMedia({ video: true, audio: false })
802
- .then(stream => {
803
- this.videoPreview.srcObject = stream;
804
- this.videoPreview.play()
805
- .then(() => {
806
- this.videoSettings = stream.getVideoTracks()[0].getSettings();
807
- });
808
- })
809
- .catch(error => alert(error));
810
- }
811
- applySnapshot() {
812
- var canvas = document.createElement("canvas");
813
- const context = canvas.getContext("2d");
814
- canvas.width = this.videoSettings.width;
815
- canvas.height = this.videoSettings.height;
816
- context.drawImage(this.videoPreview, 0, 0);
817
- canvas.toBlob(blob => {
818
- var file = new File([blob], "image.jpeg", { type: "image/jpeg" });
819
- this.takingPicture = false;
820
- var fileList = [file];
821
- this.filesSelected.emit(fileList);
822
- }, "image/jpeg", this.captureQuality);
823
- }
824
- render() {
825
- var _a, _b, _c, _d, _e, _f;
826
- return (h(Host, { ref: e => this.dropzone = e, class: "dropzone", onDragOver: this.handleDragOver, onDrop: this.handleDrop, onDragLeave: () => this.dropzone.classList.remove("dropping") }, !this.takingPicture &&
827
- [
828
- h("p", null, (_a = this.resx) === null || _a === void 0 ? void 0 : _a.dragAndDropFile),
829
- h("p", null, "- ", (_b = this.resx) === null || _b === void 0 ? void 0 :
830
- _b.or, " -"),
831
- h("label", { class: "upload-file" }, h("input", { type: "file", ref: el => this.fileInput = el, onChange: e => this.handleUploadButton(e.target) }), h("span", null, h("svg", { xmlns: "http://www.w3.org/2000/svg", "enable-background": "new 0 0 24 24", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("g", null, h("rect", { fill: "none", height: "24", width: "24" })), h("g", null, h("path", { d: "M5,20h14v-2H5V20z M5,10h4v6h6v-6h4l-7-7L5,10z" })))), "\u00A0", (_c = this.resx) === null || _c === void 0 ? void 0 :
832
- _c.uploadFile),
833
- this.canTakeSnapshots &&
834
- [
835
- h("p", null, "- ", (_d = this.resx) === null || _d === void 0 ? void 0 :
836
- _d.or, " -"),
837
- h("button", { onClick: () => this.takeSnapshot() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("circle", { cx: "12", cy: "12", r: "3.2" }), h("path", { d: "M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z" })), (_e = this.resx) === null || _e === void 0 ? void 0 :
838
- _e.takePicture)
839
- ]
840
- ], this.takingPicture &&
841
- h("div", { class: "video-preview" }, h("video", { ref: e => this.videoPreview = e }), h("button", { onClick: () => this.applySnapshot() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("circle", { cx: "12", cy: "12", r: "3.2" }), h("path", { d: "M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z" })), "\u00A0", (_f = this.resx) === null || _f === void 0 ? void 0 :
842
- _f.capture))));
843
- }
844
- };
709
+ const DnnDropzone = class {
710
+ constructor(hostRef) {
711
+ registerInstance(this, hostRef);
712
+ this.filesSelected = createEvent(this, "filesSelected", 7);
713
+ /** Localization strings */
714
+ this.resx = {
715
+ dragAndDropFile: "Drag and drop a file",
716
+ capture: "Capture",
717
+ or: "or",
718
+ takePicture: "Take a picture",
719
+ uploadFile: "Upload a file",
720
+ };
721
+ /**
722
+ * If true, will allow the user to take a snapshot
723
+ * using the device camera. (only works over https).
724
+ */
725
+ this.allowCameraMode = false;
726
+ /**
727
+ * Specifies the jpeg quality for when the device
728
+ * camera is used to generate a picture.
729
+ * Needs to be a number between 0 and 1 and defaults to 0.8
730
+ */
731
+ this.captureQuality = 0.8;
732
+ this.canTakeSnapshots = false;
733
+ this.takingPicture = false;
734
+ this.handleDragOver = (event) => {
735
+ event.stopPropagation();
736
+ event.preventDefault();
737
+ event.dataTransfer.dropEffect = "copy";
738
+ this.dropzone.classList.add("dropping");
739
+ };
740
+ this.handleDrop = (dropEvent) => {
741
+ dropEvent.stopPropagation();
742
+ dropEvent.preventDefault();
743
+ const files = dropEvent.dataTransfer.files;
744
+ if (this.hasInvalidExtensions(files)) {
745
+ return;
746
+ }
747
+ var fileList = this.getFilesFromFileList(files);
748
+ this.filesSelected.emit(fileList);
749
+ };
750
+ }
751
+ componentDidLoad() {
752
+ if (this.allowCameraMode) {
753
+ this.checkIfBrowserCanTakeSnapshots()
754
+ .then(result => this.canTakeSnapshots = result);
755
+ }
756
+ if (this.allowedExtensions != undefined && this.allowedExtensions.length > 0) {
757
+ var extensionsWithDots = this.allowedExtensions.map(e => `.${e}`);
758
+ var extensionsList = extensionsWithDots.join(",");
759
+ this.fileInput.accept = extensionsList;
760
+ }
761
+ }
762
+ checkIfBrowserCanTakeSnapshots() {
763
+ return new Promise((resolve) => {
764
+ const mediaDevices = navigator.mediaDevices;
765
+ if (mediaDevices == undefined || mediaDevices.enumerateDevices == undefined) {
766
+ resolve(false);
767
+ }
768
+ mediaDevices.enumerateDevices()
769
+ .then(devices => {
770
+ var result = devices.some(device => device.kind == "videoinput");
771
+ resolve(result);
772
+ });
773
+ });
774
+ }
775
+ getFilesFromFileList(files) {
776
+ var fileList = [];
777
+ for (let index = 0; index < files.length; index++) {
778
+ const file = files[index];
779
+ fileList.push(file);
780
+ }
781
+ return fileList;
782
+ }
783
+ handleUploadButton(element) {
784
+ let files = this.getFilesFromFileList(element.files);
785
+ this.filesSelected.emit(files);
786
+ }
787
+ hasInvalidExtensions(files) {
788
+ var hasInvalid = false;
789
+ for (let fileIndex = 0; fileIndex < files.length; fileIndex++) {
790
+ const file = files[fileIndex];
791
+ var regex = /(?:\.([^.]+))?$/;
792
+ const fileExtension = regex.exec(file.name)[1];
793
+ if (fileExtension == undefined) {
794
+ hasInvalid = true;
795
+ }
796
+ if (this.allowedExtensions != undefined && !this.allowedExtensions.includes(fileExtension)) {
797
+ hasInvalid = true;
798
+ }
799
+ return hasInvalid;
800
+ }
801
+ }
802
+ takeSnapshot() {
803
+ this.takingPicture = true;
804
+ navigator.mediaDevices.getUserMedia({ video: true, audio: false })
805
+ .then(stream => {
806
+ this.videoPreview.srcObject = stream;
807
+ this.videoPreview.play()
808
+ .then(() => {
809
+ this.videoSettings = stream.getVideoTracks()[0].getSettings();
810
+ });
811
+ })
812
+ .catch(error => alert(error));
813
+ }
814
+ applySnapshot() {
815
+ var canvas = document.createElement("canvas");
816
+ const context = canvas.getContext("2d");
817
+ canvas.width = this.videoSettings.width;
818
+ canvas.height = this.videoSettings.height;
819
+ context.drawImage(this.videoPreview, 0, 0);
820
+ canvas.toBlob(blob => {
821
+ var file = new File([blob], "image.jpeg", { type: "image/jpeg" });
822
+ this.takingPicture = false;
823
+ var fileList = [file];
824
+ this.filesSelected.emit(fileList);
825
+ }, "image/jpeg", this.captureQuality);
826
+ }
827
+ render() {
828
+ var _a, _b, _c, _d, _e, _f;
829
+ return (h(Host, { ref: e => this.dropzone = e, class: "dropzone", onDragOver: this.handleDragOver, onDrop: this.handleDrop, onDragLeave: () => this.dropzone.classList.remove("dropping") }, !this.takingPicture &&
830
+ [
831
+ h("p", null, (_a = this.resx) === null || _a === void 0 ? void 0 : _a.dragAndDropFile),
832
+ h("p", null, "- ", (_b = this.resx) === null || _b === void 0 ? void 0 :
833
+ _b.or, " -"),
834
+ h("label", { class: "upload-file" }, h("input", { type: "file", ref: el => this.fileInput = el, onChange: e => this.handleUploadButton(e.target) }), h("span", null, h("svg", { xmlns: "http://www.w3.org/2000/svg", "enable-background": "new 0 0 24 24", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("g", null, h("rect", { fill: "none", height: "24", width: "24" })), h("g", null, h("path", { d: "M5,20h14v-2H5V20z M5,10h4v6h6v-6h4l-7-7L5,10z" })))), "\u00A0", (_c = this.resx) === null || _c === void 0 ? void 0 :
835
+ _c.uploadFile),
836
+ this.canTakeSnapshots &&
837
+ [
838
+ h("p", null, "- ", (_d = this.resx) === null || _d === void 0 ? void 0 :
839
+ _d.or, " -"),
840
+ h("button", { onClick: () => this.takeSnapshot() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("circle", { cx: "12", cy: "12", r: "3.2" }), h("path", { d: "M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z" })), (_e = this.resx) === null || _e === void 0 ? void 0 :
841
+ _e.takePicture)
842
+ ]
843
+ ], this.takingPicture &&
844
+ h("div", { class: "video-preview" }, h("video", { ref: e => this.videoPreview = e }), h("button", { onClick: () => this.applySnapshot() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("circle", { cx: "12", cy: "12", r: "3.2" }), h("path", { d: "M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z" })), "\u00A0", (_f = this.resx) === null || _f === void 0 ? void 0 :
845
+ _f.capture))));
846
+ }
847
+ };
845
848
  DnnDropzone.style = dnnDropzoneCss;
846
849
 
847
- var CornerType;
848
- (function (CornerType) {
849
- CornerType[CornerType["nw"] = 0] = "nw";
850
- CornerType[CornerType["ne"] = 1] = "ne";
851
- CornerType[CornerType["se"] = 2] = "se";
852
- CornerType[CornerType["sw"] = 3] = "sw";
850
+ var CornerType;
851
+ (function (CornerType) {
852
+ CornerType[CornerType["nw"] = 0] = "nw";
853
+ CornerType[CornerType["ne"] = 1] = "ne";
854
+ CornerType[CornerType["se"] = 2] = "se";
855
+ CornerType[CornerType["sw"] = 3] = "sw";
853
856
  })(CornerType || (CornerType = {}));
854
857
 
855
- function getMovementFromEvent(event, previousTouch) {
856
- let movementX = 0;
857
- let movementY = 0;
858
- if (event instanceof MouseEvent) {
859
- movementX = event.movementX;
860
- movementY = event.movementY;
861
- }
862
- if (typeof TouchEvent !== "undefined") {
863
- if (event instanceof TouchEvent) {
864
- let touch = event.touches[0];
865
- if (previousTouch != undefined) {
866
- movementX = touch.pageX - this.previousTouch.pageX;
867
- movementY = touch.pageY - this.previousTouch.pageY;
868
- }
869
- previousTouch = touch;
870
- }
871
- }
872
- return { movementX, movementY };
858
+ function getMovementFromEvent(event, previousTouch) {
859
+ let movementX = 0;
860
+ let movementY = 0;
861
+ if (event instanceof MouseEvent) {
862
+ movementX = event.movementX;
863
+ movementY = event.movementY;
864
+ }
865
+ if (typeof TouchEvent !== "undefined") {
866
+ if (event instanceof TouchEvent) {
867
+ let touch = event.touches[0];
868
+ if (previousTouch != undefined) {
869
+ movementX = touch.pageX - this.previousTouch.pageX;
870
+ movementY = touch.pageY - this.previousTouch.pageY;
871
+ }
872
+ previousTouch = touch;
873
+ }
874
+ }
875
+ return { movementX, movementY };
873
876
  }
874
877
 
875
878
  const dnnImageCropperCss = ":host{display:block}canvas{display:none}.view{visibility:hidden;opacity:0;height:0;overflow:hidden;-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out}.view.visible{visibility:visible;opacity:1;height:initial;overflow:visible}.view .cropper{position:relative;width:100%}.view .cropper img{width:100%;display:block;margin:0 auto}.view .cropper .backdrop{-webkit-backdrop-filter:saturate(0.5);backdrop-filter:saturate(0.5);-webkit-backdrop-filter:brightness(0.5);backdrop-filter:brightness(0.5);position:absolute;left:0;top:0;width:100%;height:100%}.view .cropper .crop{position:absolute;top:0;left:0;width:100%;height:100%;outline:2px dashed white;-webkit-box-shadow:black 0 0 0px 2px;box-shadow:black 0 0 0px 2px;-webkit-backdrop-filter:saturate(2);backdrop-filter:saturate(2);-webkit-backdrop-filter:brightness(2);backdrop-filter:brightness(2);cursor:move}.view .cropper .crop>div{width:20px;height:20px;background-color:white;border:2px solid rgba(0, 0, 0, 0.5);position:absolute}.view .cropper .crop>div.nw,.view .cropper .crop>div.ne{top:-17px}.view .cropper .crop>div.ne,.view .cropper .crop>div.se{right:-17px}.view .cropper .crop>div.se,.view .cropper .crop>div.sw{bottom:-17px}.view .cropper .crop>div.sw,.view .cropper .crop>div.nw{left:-17px}.view .cropper .crop>div.nw,.view .cropper .crop>div.se{cursor:nwse-resize}.view .cropper .crop>div.ne,.view .cropper .crop>div.sw{cursor:nesw-resize}dnn-modal{--max-width:512px}";
876
879
 
877
- let DnnImageCropper = class {
878
- constructor(hostRef) {
879
- registerInstance(this, hostRef);
880
- this.imageCropChanged = createEvent(this, "imageCropChanged", 7);
881
- /** Sets the desired final image width. */
882
- this.width = 600;
883
- /** Sets the desired final image height. */
884
- this.height = 600;
885
- /** Can be used to customize controls text.
886
- * Some values support tokens, see default values for examples.
887
- */
888
- this.resx = {
889
- capture: "Capture",
890
- dragAndDropFile: "Drag and drop an image",
891
- or: "or",
892
- takePicture: "Take a picture",
893
- uploadFile: "Upload an image",
894
- imageTooSmall: "The image you are attempting to upload does not meet the minimum size requirement of {width} pixels by {height} pixels. Please upload a larger image.",
895
- modalCloseText: "Close",
896
- };
897
- /** Sets the output quality of the corpped image (number between 0 and 1). */
898
- this.quality = 0.8;
899
- /** When set to true, prevents cropping an image smaller than the required size, which would blow pixel and make the final picture look blurry. */
900
- this.preventUndersized = false;
901
- this.handleCropMouseDown = (event) => {
902
- event.stopPropagation();
903
- event.preventDefault();
904
- const element = event.target;
905
- const className = element.classList[0];
906
- document.addEventListener("mouseup", this.handleImageCropFinished, false);
907
- document.addEventListener("touchend", this.handleImageCropFinished, false);
908
- switch (className) {
909
- case "crop":
910
- document.addEventListener("mousemove", this.handleCropDrag, false);
911
- document.addEventListener("touchmove", this.handleCropDrag, false);
912
- document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleCropDrag));
913
- document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleCropDrag));
914
- break;
915
- case "nw":
916
- document.addEventListener("mousemove", this.handleNwMouseMove, false);
917
- document.addEventListener("touchmove", this.handleNwMouseMove, false);
918
- document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleNwMouseMove));
919
- document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleNwMouseMove));
920
- break;
921
- case "ne":
922
- document.addEventListener("mousemove", this.handleNeMouseMove, false);
923
- document.addEventListener("touchmove", this.handleNeMouseMove, false);
924
- document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleNeMouseMove));
925
- document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleNeMouseMove));
926
- break;
927
- case "se":
928
- document.addEventListener("mousemove", this.handleSeMouseMove, false);
929
- document.addEventListener("touchmove", this.handleSeMouseMove, false);
930
- document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleSeMouseMove));
931
- document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleSeMouseMove));
932
- break;
933
- case "sw":
934
- document.addEventListener("mousemove", this.handleSwMouseMove, false);
935
- document.addEventListener("touchmove", this.handleSwMouseMove, false);
936
- document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleSwMouseMove));
937
- document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleSwMouseMove));
938
- break;
939
- }
940
- };
941
- this.handleImageCropFinished = (_ev) => {
942
- this.emitImage();
943
- document.removeEventListener("mouseup", this.handleImageCropFinished);
944
- this.previousTouch = undefined;
945
- };
946
- this.handleNwMouseMove = (event) => {
947
- this.handleCornerDrag(event, CornerType.nw);
948
- };
949
- this.handleNeMouseMove = (event) => {
950
- this.handleCornerDrag(event, CornerType.ne);
951
- };
952
- this.handleSeMouseMove = (event) => {
953
- this.handleCornerDrag(event, CornerType.se);
954
- };
955
- this.handleSwMouseMove = (event) => {
956
- this.handleCornerDrag(event, CornerType.sw);
957
- };
958
- this.handleCornerDrag = (event, corner) => {
959
- if (!this.isMouseStillInTarget(event)) {
960
- return;
961
- }
962
- let { left, top } = this.getCornerLeftTop(corner);
963
- let newWidth = 0;
964
- let newHeight = 0;
965
- let orientation = "horizontal";
966
- const wantedRatio = this.width / this.height;
967
- const cropRect = this.crop.getBoundingClientRect();
968
- const imageRect = this.image.getBoundingClientRect();
969
- let { movementX, movementY } = getMovementFromEvent(event, this.previousTouch);
970
- if (Math.abs(movementX) < Math.abs(movementY)) {
971
- orientation = "vertical";
972
- }
973
- if (orientation == "horizontal") {
974
- switch (corner) {
975
- case CornerType.nw:
976
- case CornerType.sw:
977
- newWidth = cropRect.width - movementX;
978
- newHeight = newWidth / wantedRatio;
979
- break;
980
- case CornerType.ne:
981
- case CornerType.se:
982
- newWidth = cropRect.width + movementX;
983
- newHeight = newWidth / wantedRatio;
984
- break;
985
- }
986
- }
987
- else {
988
- switch (corner) {
989
- case CornerType.nw:
990
- case CornerType.ne:
991
- newHeight = cropRect.height - movementY;
992
- newWidth = newHeight * wantedRatio;
993
- break;
994
- case CornerType.se:
995
- case CornerType.sw:
996
- newHeight = cropRect.height + movementY;
997
- newWidth = newHeight * wantedRatio;
998
- break;
999
- }
1000
- }
1001
- switch (corner) {
1002
- case CornerType.ne:
1003
- case CornerType.nw:
1004
- const topOffset = cropRect.height - newHeight;
1005
- top = this.crop.offsetTop + topOffset;
1006
- }
1007
- switch (corner) {
1008
- case CornerType.nw:
1009
- case CornerType.sw:
1010
- const leftOffset = cropRect.width - newWidth;
1011
- left = this.crop.offsetLeft + leftOffset;
1012
- if (left < 0)
1013
- left = 0;
1014
- if (left > imageRect.width)
1015
- left = imageRect.width;
1016
- if (top < 0)
1017
- top = 0;
1018
- if (top > imageRect.height)
1019
- top = imageRect.height;
1020
- if (left + newWidth > imageRect.width)
1021
- newWidth = imageRect.width - left;
1022
- if (top + newHeight > imageRect.height)
1023
- newHeight = imageRect.height - top;
1024
- break;
1025
- case CornerType.ne:
1026
- case CornerType.se:
1027
- if (top < 0)
1028
- top = 0;
1029
- if (top > imageRect.height)
1030
- top = imageRect.height;
1031
- if (left + newWidth > imageRect.width)
1032
- newWidth = imageRect.width - left;
1033
- if (top + newHeight > imageRect.height)
1034
- newHeight = imageRect.height - top;
1035
- break;
1036
- }
1037
- if (newWidth / newHeight != wantedRatio) {
1038
- return;
1039
- }
1040
- if (this.preventUndersized) {
1041
- const zoomRatio = this.image.width / this.image.naturalWidth;
1042
- if (newWidth / zoomRatio < this.width || newHeight / zoomRatio < this.height) {
1043
- return;
1044
- }
1045
- }
1046
- switch (corner) {
1047
- case CornerType.ne:
1048
- this.crop.style.top = `${top}px`;
1049
- this.crop.style.width = `${newWidth}px`;
1050
- this.crop.style.height = `${newHeight}px`;
1051
- break;
1052
- case CornerType.nw:
1053
- this.crop.style.left = `${left}px`;
1054
- this.crop.style.top = `${top}px`;
1055
- this.crop.style.width = `${newWidth}px`;
1056
- this.crop.style.height = `${newHeight}px`;
1057
- break;
1058
- case CornerType.se:
1059
- this.crop.style.width = `${newWidth}px`;
1060
- this.crop.style.height = `${newHeight}px`;
1061
- break;
1062
- case CornerType.sw:
1063
- this.crop.style.left = `${left}px`;
1064
- this.crop.style.width = `${newWidth}px`;
1065
- this.crop.style.height = `${newHeight}px`;
1066
- break;
1067
- }
1068
- };
1069
- this.handleCropDrag = (ev) => {
1070
- if (!this.isMouseStillInTarget(ev)) {
1071
- return;
1072
- }
1073
- let { movementX, movementY } = getMovementFromEvent(ev, this.previousTouch);
1074
- let newLeft = this.crop.offsetLeft + movementX;
1075
- let newTop = this.crop.offsetTop + movementY;
1076
- var imageRect = this.image.getBoundingClientRect();
1077
- var cropRect = this.crop.getBoundingClientRect();
1078
- if (newLeft < 0) {
1079
- newLeft = 0;
1080
- }
1081
- if (newTop < 0) {
1082
- newTop = 0;
1083
- }
1084
- if (newLeft + cropRect.width > imageRect.width) {
1085
- newLeft = this.crop.offsetLeft;
1086
- }
1087
- if (newTop + cropRect.height > imageRect.height) {
1088
- newTop = this.crop.offsetTop;
1089
- }
1090
- this.crop.style.left = newLeft + "px";
1091
- this.crop.style.top = newTop + "px";
1092
- };
1093
- }
1094
- componentDidLoad() {
1095
- requestAnimationFrame(() => {
1096
- this.setView("noPictureView");
1097
- });
1098
- }
1099
- setView(newView) {
1100
- const views = this.host.shadowRoot.querySelectorAll(".view");
1101
- views.forEach(v => v.classList.remove("visible"));
1102
- switch (newView) {
1103
- case "noPictureView":
1104
- this.noPictureView.classList.add("visible");
1105
- break;
1106
- case "hasPictureView":
1107
- this.hasPictureView.classList.add("visible");
1108
- break;
1109
- }
1110
- this.view = newView;
1111
- }
1112
- initCrop() {
1113
- var wantedRatio = this.width / this.height;
1114
- var imageRect = this.image.getBoundingClientRect();
1115
- var imageRatio = imageRect.width / imageRect.height;
1116
- if (wantedRatio > imageRatio) {
1117
- var wantedHeight = imageRect.width / wantedRatio;
1118
- var diff = imageRect.height - wantedHeight;
1119
- this.crop.style.top = Math.round(diff / 2).toString() + "px";
1120
- this.crop.style.height = Math.round(wantedHeight).toString() + "px";
1121
- }
1122
- else {
1123
- var wantedWidth = imageRect.height * wantedRatio;
1124
- var diff = imageRect.width - wantedWidth;
1125
- this.crop.style.left = Math.round(diff / 2).toString() + "px";
1126
- this.crop.style.width = Math.round(wantedWidth).toString() + "px";
1127
- }
1128
- }
1129
- setImage() {
1130
- this.image.addEventListener('load', () => {
1131
- this.initCrop();
1132
- this.emitImage();
1133
- });
1134
- this.image.src = this.canvas.toDataURL();
1135
- }
1136
- handleNewFile(file) {
1137
- if (file.type.split('/')[0] != "image") {
1138
- return;
1139
- }
1140
- var reader = new FileReader();
1141
- reader.onload = readerLoadEvent => {
1142
- var img = new Image();
1143
- img.onload = () => {
1144
- this.canvas.width = img.width;
1145
- this.canvas.height = img.height;
1146
- if (this.preventUndersized && (img.width < this.width || img.height < this.height)) {
1147
- this.imageTooSmallModal.show();
1148
- return;
1149
- }
1150
- var ctx = this.canvas.getContext("2d");
1151
- ctx.drawImage(img, 0, 0);
1152
- this.setView("hasPictureView");
1153
- this.setImage();
1154
- };
1155
- img.src = readerLoadEvent.target.result.toString();
1156
- };
1157
- reader.readAsDataURL(file);
1158
- }
1159
- emitImage() {
1160
- var x = this.crop.offsetLeft / this.image.width * this.image.naturalWidth;
1161
- var y = this.crop.offsetTop / this.image.height * this.image.naturalHeight;
1162
- var cropRect = this.crop.getBoundingClientRect();
1163
- var width = cropRect.width / this.image.width * this.image.naturalWidth;
1164
- var height = cropRect.height / this.image.height * this.image.naturalHeight;
1165
- if (x < 0)
1166
- x = 0;
1167
- if (x > this.image.naturalWidth)
1168
- x = this.image.naturalWidth;
1169
- if (y < 0)
1170
- y = 0;
1171
- if (y > this.image.naturalWidth)
1172
- y = this.image.naturalWidth;
1173
- if (width > this.image.naturalWidth)
1174
- width = this.image.naturalWidth;
1175
- if (height > this.image.naturalHeight)
1176
- height = this.image.naturalHeight;
1177
- var dataUrl = this.generateCroppedImage(x, y, width, height, this.width, this.height);
1178
- this.imageCropChanged.emit(dataUrl);
1179
- }
1180
- generateCroppedImage(x, y, width, height, desiredWidth, desiredHeight) {
1181
- this.canvas.width = desiredWidth;
1182
- this.canvas.height = desiredHeight;
1183
- const context = this.canvas.getContext("2d");
1184
- context.clearRect(0, 0, desiredWidth, desiredHeight);
1185
- context.drawImage(this.image, x, y, width, height, 0, 0, desiredWidth, desiredHeight);
1186
- return this.canvas.toDataURL("image/jpeg", this.quality);
1187
- }
1188
- getCornerLeftTop(corner) {
1189
- let left = 0;
1190
- let top = 0;
1191
- switch (corner) {
1192
- case CornerType.se:
1193
- left = this.crop.offsetLeft;
1194
- top = this.crop.offsetTop;
1195
- break;
1196
- case CornerType.sw:
1197
- top = this.crop.offsetTop;
1198
- break;
1199
- }
1200
- return { top, left };
1201
- }
1202
- isMouseStillInTarget(event) {
1203
- var inside = false;
1204
- let mouseX;
1205
- let mouseY;
1206
- const imageRect = this.image.getBoundingClientRect();
1207
- if (event instanceof MouseEvent) {
1208
- mouseX = event.clientX;
1209
- mouseY = event.clientY;
1210
- }
1211
- if (typeof TouchEvent !== "undefined") {
1212
- if (event instanceof TouchEvent) {
1213
- var touch = event.touches[0];
1214
- mouseX = touch.clientX;
1215
- mouseY = touch.clientY;
1216
- }
1217
- }
1218
- if (mouseX >= imageRect.x &&
1219
- mouseY >= imageRect.y &&
1220
- mouseX <= imageRect.left + imageRect.width &&
1221
- mouseY <= imageRect.top + imageRect.height) {
1222
- inside = true;
1223
- }
1224
- var corners = this.crop.querySelectorAll("div");
1225
- corners.forEach(corner => {
1226
- var cornerRect = corner.getBoundingClientRect();
1227
- if (mouseX >= cornerRect.x &&
1228
- mouseY >= cornerRect.y &&
1229
- mouseX <= cornerRect.left + cornerRect.width &&
1230
- mouseY <= cornerRect.top + cornerRect.height) {
1231
- inside = true;
1232
- }
1233
- });
1234
- return inside;
1235
- }
1236
- render() {
1237
- return (h(Host, { ref: el => this.host = el }, h("canvas", { ref: el => this.canvas = el }), h("div", { class: "view", ref: el => this.hasPictureView = el }, h("div", { class: "cropper" }, h("img", { ref: el => this.image = el }), h("div", { class: "backdrop" }), h("div", { class: "crop", ref: e => this.crop = e, onMouseDown: this.handleCropMouseDown, onTouchStart: this.handleCropMouseDown }, h("div", { class: "nw" }), h("div", { class: "ne" }), h("div", { class: "se" }), h("div", { class: "sw" })))), h("div", { class: "view", ref: el => this.noPictureView = el }, h("dnn-dropzone", { allowCameraMode: true, onFilesSelected: e => this.handleNewFile(e.detail[0]), resx: {
1238
- capture: this.resx.capture,
1239
- dragAndDropFile: this.resx.dragAndDropFile,
1240
- or: this.resx.or,
1241
- takePicture: this.resx.takePicture,
1242
- uploadFile: this.resx.uploadFile,
1243
- } })), h("dnn-modal", { ref: el => this.imageTooSmallModal = el, "close-text": this.resx.modalCloseText }, h("p", null, this.resx.imageTooSmall.replace("{width}", this.width.toString()).replace("{height}", this.height.toString())))));
1244
- }
1245
- };
880
+ const DnnImageCropper = class {
881
+ constructor(hostRef) {
882
+ registerInstance(this, hostRef);
883
+ this.imageCropChanged = createEvent(this, "imageCropChanged", 7);
884
+ /** Sets the desired final image width. */
885
+ this.width = 600;
886
+ /** Sets the desired final image height. */
887
+ this.height = 600;
888
+ /** Can be used to customize controls text.
889
+ * Some values support tokens, see default values for examples.
890
+ */
891
+ this.resx = {
892
+ capture: "Capture",
893
+ dragAndDropFile: "Drag and drop an image",
894
+ or: "or",
895
+ takePicture: "Take a picture",
896
+ uploadFile: "Upload an image",
897
+ imageTooSmall: "The image you are attempting to upload does not meet the minimum size requirement of {width} pixels by {height} pixels. Please upload a larger image.",
898
+ modalCloseText: "Close",
899
+ };
900
+ /** Sets the output quality of the corpped image (number between 0 and 1). */
901
+ this.quality = 0.8;
902
+ /** When set to true, prevents cropping an image smaller than the required size, which would blow pixel and make the final picture look blurry. */
903
+ this.preventUndersized = false;
904
+ this.handleCropMouseDown = (event) => {
905
+ event.stopPropagation();
906
+ event.preventDefault();
907
+ const element = event.target;
908
+ const className = element.classList[0];
909
+ document.addEventListener("mouseup", this.handleImageCropFinished, false);
910
+ document.addEventListener("touchend", this.handleImageCropFinished, false);
911
+ switch (className) {
912
+ case "crop":
913
+ document.addEventListener("mousemove", this.handleCropDrag, false);
914
+ document.addEventListener("touchmove", this.handleCropDrag, false);
915
+ document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleCropDrag));
916
+ document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleCropDrag));
917
+ break;
918
+ case "nw":
919
+ document.addEventListener("mousemove", this.handleNwMouseMove, false);
920
+ document.addEventListener("touchmove", this.handleNwMouseMove, false);
921
+ document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleNwMouseMove));
922
+ document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleNwMouseMove));
923
+ break;
924
+ case "ne":
925
+ document.addEventListener("mousemove", this.handleNeMouseMove, false);
926
+ document.addEventListener("touchmove", this.handleNeMouseMove, false);
927
+ document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleNeMouseMove));
928
+ document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleNeMouseMove));
929
+ break;
930
+ case "se":
931
+ document.addEventListener("mousemove", this.handleSeMouseMove, false);
932
+ document.addEventListener("touchmove", this.handleSeMouseMove, false);
933
+ document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleSeMouseMove));
934
+ document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleSeMouseMove));
935
+ break;
936
+ case "sw":
937
+ document.addEventListener("mousemove", this.handleSwMouseMove, false);
938
+ document.addEventListener("touchmove", this.handleSwMouseMove, false);
939
+ document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleSwMouseMove));
940
+ document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleSwMouseMove));
941
+ break;
942
+ }
943
+ };
944
+ this.handleImageCropFinished = (_ev) => {
945
+ this.emitImage();
946
+ document.removeEventListener("mouseup", this.handleImageCropFinished);
947
+ this.previousTouch = undefined;
948
+ };
949
+ this.handleNwMouseMove = (event) => {
950
+ this.handleCornerDrag(event, CornerType.nw);
951
+ };
952
+ this.handleNeMouseMove = (event) => {
953
+ this.handleCornerDrag(event, CornerType.ne);
954
+ };
955
+ this.handleSeMouseMove = (event) => {
956
+ this.handleCornerDrag(event, CornerType.se);
957
+ };
958
+ this.handleSwMouseMove = (event) => {
959
+ this.handleCornerDrag(event, CornerType.sw);
960
+ };
961
+ this.handleCornerDrag = (event, corner) => {
962
+ if (!this.isMouseStillInTarget(event)) {
963
+ return;
964
+ }
965
+ let { left, top } = this.getCornerLeftTop(corner);
966
+ let newWidth = 0;
967
+ let newHeight = 0;
968
+ let orientation = "horizontal";
969
+ const wantedRatio = this.width / this.height;
970
+ const cropRect = this.crop.getBoundingClientRect();
971
+ const imageRect = this.image.getBoundingClientRect();
972
+ let { movementX, movementY } = getMovementFromEvent(event, this.previousTouch);
973
+ if (Math.abs(movementX) < Math.abs(movementY)) {
974
+ orientation = "vertical";
975
+ }
976
+ if (orientation == "horizontal") {
977
+ switch (corner) {
978
+ case CornerType.nw:
979
+ case CornerType.sw:
980
+ newWidth = cropRect.width - movementX;
981
+ newHeight = newWidth / wantedRatio;
982
+ break;
983
+ case CornerType.ne:
984
+ case CornerType.se:
985
+ newWidth = cropRect.width + movementX;
986
+ newHeight = newWidth / wantedRatio;
987
+ break;
988
+ }
989
+ }
990
+ else {
991
+ switch (corner) {
992
+ case CornerType.nw:
993
+ case CornerType.ne:
994
+ newHeight = cropRect.height - movementY;
995
+ newWidth = newHeight * wantedRatio;
996
+ break;
997
+ case CornerType.se:
998
+ case CornerType.sw:
999
+ newHeight = cropRect.height + movementY;
1000
+ newWidth = newHeight * wantedRatio;
1001
+ break;
1002
+ }
1003
+ }
1004
+ switch (corner) {
1005
+ case CornerType.ne:
1006
+ case CornerType.nw:
1007
+ const topOffset = cropRect.height - newHeight;
1008
+ top = this.crop.offsetTop + topOffset;
1009
+ }
1010
+ switch (corner) {
1011
+ case CornerType.nw:
1012
+ case CornerType.sw:
1013
+ const leftOffset = cropRect.width - newWidth;
1014
+ left = this.crop.offsetLeft + leftOffset;
1015
+ if (left < 0)
1016
+ left = 0;
1017
+ if (left > imageRect.width)
1018
+ left = imageRect.width;
1019
+ if (top < 0)
1020
+ top = 0;
1021
+ if (top > imageRect.height)
1022
+ top = imageRect.height;
1023
+ if (left + newWidth > imageRect.width)
1024
+ newWidth = imageRect.width - left;
1025
+ if (top + newHeight > imageRect.height)
1026
+ newHeight = imageRect.height - top;
1027
+ break;
1028
+ case CornerType.ne:
1029
+ case CornerType.se:
1030
+ if (top < 0)
1031
+ top = 0;
1032
+ if (top > imageRect.height)
1033
+ top = imageRect.height;
1034
+ if (left + newWidth > imageRect.width)
1035
+ newWidth = imageRect.width - left;
1036
+ if (top + newHeight > imageRect.height)
1037
+ newHeight = imageRect.height - top;
1038
+ break;
1039
+ }
1040
+ if (newWidth / newHeight != wantedRatio) {
1041
+ return;
1042
+ }
1043
+ if (this.preventUndersized) {
1044
+ const zoomRatio = this.image.width / this.image.naturalWidth;
1045
+ if (newWidth / zoomRatio < this.width || newHeight / zoomRatio < this.height) {
1046
+ return;
1047
+ }
1048
+ }
1049
+ switch (corner) {
1050
+ case CornerType.ne:
1051
+ this.crop.style.top = `${top}px`;
1052
+ this.crop.style.width = `${newWidth}px`;
1053
+ this.crop.style.height = `${newHeight}px`;
1054
+ break;
1055
+ case CornerType.nw:
1056
+ this.crop.style.left = `${left}px`;
1057
+ this.crop.style.top = `${top}px`;
1058
+ this.crop.style.width = `${newWidth}px`;
1059
+ this.crop.style.height = `${newHeight}px`;
1060
+ break;
1061
+ case CornerType.se:
1062
+ this.crop.style.width = `${newWidth}px`;
1063
+ this.crop.style.height = `${newHeight}px`;
1064
+ break;
1065
+ case CornerType.sw:
1066
+ this.crop.style.left = `${left}px`;
1067
+ this.crop.style.width = `${newWidth}px`;
1068
+ this.crop.style.height = `${newHeight}px`;
1069
+ break;
1070
+ }
1071
+ };
1072
+ this.handleCropDrag = (ev) => {
1073
+ if (!this.isMouseStillInTarget(ev)) {
1074
+ return;
1075
+ }
1076
+ let { movementX, movementY } = getMovementFromEvent(ev, this.previousTouch);
1077
+ let newLeft = this.crop.offsetLeft + movementX;
1078
+ let newTop = this.crop.offsetTop + movementY;
1079
+ var imageRect = this.image.getBoundingClientRect();
1080
+ var cropRect = this.crop.getBoundingClientRect();
1081
+ if (newLeft < 0) {
1082
+ newLeft = 0;
1083
+ }
1084
+ if (newTop < 0) {
1085
+ newTop = 0;
1086
+ }
1087
+ if (newLeft + cropRect.width > imageRect.width) {
1088
+ newLeft = this.crop.offsetLeft;
1089
+ }
1090
+ if (newTop + cropRect.height > imageRect.height) {
1091
+ newTop = this.crop.offsetTop;
1092
+ }
1093
+ this.crop.style.left = newLeft + "px";
1094
+ this.crop.style.top = newTop + "px";
1095
+ };
1096
+ }
1097
+ componentDidLoad() {
1098
+ requestAnimationFrame(() => {
1099
+ this.setView("noPictureView");
1100
+ });
1101
+ }
1102
+ setView(newView) {
1103
+ const views = this.host.shadowRoot.querySelectorAll(".view");
1104
+ views.forEach(v => v.classList.remove("visible"));
1105
+ switch (newView) {
1106
+ case "noPictureView":
1107
+ this.noPictureView.classList.add("visible");
1108
+ break;
1109
+ case "hasPictureView":
1110
+ this.hasPictureView.classList.add("visible");
1111
+ break;
1112
+ }
1113
+ this.view = newView;
1114
+ }
1115
+ initCrop() {
1116
+ var wantedRatio = this.width / this.height;
1117
+ var imageRect = this.image.getBoundingClientRect();
1118
+ var imageRatio = imageRect.width / imageRect.height;
1119
+ if (wantedRatio > imageRatio) {
1120
+ var wantedHeight = imageRect.width / wantedRatio;
1121
+ var diff = imageRect.height - wantedHeight;
1122
+ this.crop.style.top = Math.round(diff / 2).toString() + "px";
1123
+ this.crop.style.height = Math.round(wantedHeight).toString() + "px";
1124
+ }
1125
+ else {
1126
+ var wantedWidth = imageRect.height * wantedRatio;
1127
+ var diff = imageRect.width - wantedWidth;
1128
+ this.crop.style.left = Math.round(diff / 2).toString() + "px";
1129
+ this.crop.style.width = Math.round(wantedWidth).toString() + "px";
1130
+ }
1131
+ }
1132
+ setImage() {
1133
+ this.image.addEventListener('load', () => {
1134
+ this.initCrop();
1135
+ this.emitImage();
1136
+ });
1137
+ this.image.src = this.canvas.toDataURL();
1138
+ }
1139
+ handleNewFile(file) {
1140
+ if (file.type.split('/')[0] != "image") {
1141
+ return;
1142
+ }
1143
+ var reader = new FileReader();
1144
+ reader.onload = readerLoadEvent => {
1145
+ var img = new Image();
1146
+ img.onload = () => {
1147
+ this.canvas.width = img.width;
1148
+ this.canvas.height = img.height;
1149
+ if (this.preventUndersized && (img.width < this.width || img.height < this.height)) {
1150
+ this.imageTooSmallModal.show();
1151
+ return;
1152
+ }
1153
+ var ctx = this.canvas.getContext("2d");
1154
+ ctx.drawImage(img, 0, 0);
1155
+ this.setView("hasPictureView");
1156
+ this.setImage();
1157
+ };
1158
+ img.src = readerLoadEvent.target.result.toString();
1159
+ };
1160
+ reader.readAsDataURL(file);
1161
+ }
1162
+ emitImage() {
1163
+ var x = this.crop.offsetLeft / this.image.width * this.image.naturalWidth;
1164
+ var y = this.crop.offsetTop / this.image.height * this.image.naturalHeight;
1165
+ var cropRect = this.crop.getBoundingClientRect();
1166
+ var width = cropRect.width / this.image.width * this.image.naturalWidth;
1167
+ var height = cropRect.height / this.image.height * this.image.naturalHeight;
1168
+ if (x < 0)
1169
+ x = 0;
1170
+ if (x > this.image.naturalWidth)
1171
+ x = this.image.naturalWidth;
1172
+ if (y < 0)
1173
+ y = 0;
1174
+ if (y > this.image.naturalWidth)
1175
+ y = this.image.naturalWidth;
1176
+ if (width > this.image.naturalWidth)
1177
+ width = this.image.naturalWidth;
1178
+ if (height > this.image.naturalHeight)
1179
+ height = this.image.naturalHeight;
1180
+ var dataUrl = this.generateCroppedImage(x, y, width, height, this.width, this.height);
1181
+ this.imageCropChanged.emit(dataUrl);
1182
+ }
1183
+ generateCroppedImage(x, y, width, height, desiredWidth, desiredHeight) {
1184
+ this.canvas.width = desiredWidth;
1185
+ this.canvas.height = desiredHeight;
1186
+ const context = this.canvas.getContext("2d");
1187
+ context.clearRect(0, 0, desiredWidth, desiredHeight);
1188
+ context.drawImage(this.image, x, y, width, height, 0, 0, desiredWidth, desiredHeight);
1189
+ return this.canvas.toDataURL("image/jpeg", this.quality);
1190
+ }
1191
+ getCornerLeftTop(corner) {
1192
+ let left = 0;
1193
+ let top = 0;
1194
+ switch (corner) {
1195
+ case CornerType.se:
1196
+ left = this.crop.offsetLeft;
1197
+ top = this.crop.offsetTop;
1198
+ break;
1199
+ case CornerType.sw:
1200
+ top = this.crop.offsetTop;
1201
+ break;
1202
+ }
1203
+ return { top, left };
1204
+ }
1205
+ isMouseStillInTarget(event) {
1206
+ var inside = false;
1207
+ let mouseX;
1208
+ let mouseY;
1209
+ const imageRect = this.image.getBoundingClientRect();
1210
+ if (event instanceof MouseEvent) {
1211
+ mouseX = event.clientX;
1212
+ mouseY = event.clientY;
1213
+ }
1214
+ if (typeof TouchEvent !== "undefined") {
1215
+ if (event instanceof TouchEvent) {
1216
+ var touch = event.touches[0];
1217
+ mouseX = touch.clientX;
1218
+ mouseY = touch.clientY;
1219
+ }
1220
+ }
1221
+ if (mouseX >= imageRect.x &&
1222
+ mouseY >= imageRect.y &&
1223
+ mouseX <= imageRect.left + imageRect.width &&
1224
+ mouseY <= imageRect.top + imageRect.height) {
1225
+ inside = true;
1226
+ }
1227
+ var corners = this.crop.querySelectorAll("div");
1228
+ corners.forEach(corner => {
1229
+ var cornerRect = corner.getBoundingClientRect();
1230
+ if (mouseX >= cornerRect.x &&
1231
+ mouseY >= cornerRect.y &&
1232
+ mouseX <= cornerRect.left + cornerRect.width &&
1233
+ mouseY <= cornerRect.top + cornerRect.height) {
1234
+ inside = true;
1235
+ }
1236
+ });
1237
+ return inside;
1238
+ }
1239
+ render() {
1240
+ return (h(Host, { ref: el => this.host = el }, h("canvas", { ref: el => this.canvas = el }), h("div", { class: "view", ref: el => this.hasPictureView = el }, h("div", { class: "cropper" }, h("img", { ref: el => this.image = el }), h("div", { class: "backdrop" }), h("div", { class: "crop", ref: e => this.crop = e, onMouseDown: this.handleCropMouseDown, onTouchStart: this.handleCropMouseDown }, h("div", { class: "nw" }), h("div", { class: "ne" }), h("div", { class: "se" }), h("div", { class: "sw" })))), h("div", { class: "view", ref: el => this.noPictureView = el }, h("dnn-dropzone", { allowCameraMode: true, onFilesSelected: e => this.handleNewFile(e.detail[0]), resx: {
1241
+ capture: this.resx.capture,
1242
+ dragAndDropFile: this.resx.dragAndDropFile,
1243
+ or: this.resx.or,
1244
+ takePicture: this.resx.takePicture,
1245
+ uploadFile: this.resx.uploadFile,
1246
+ } })), h("dnn-modal", { ref: el => this.imageTooSmallModal = el, "close-text": this.resx.modalCloseText }, h("p", null, this.resx.imageTooSmall.replace("{width}", this.width.toString()).replace("{height}", this.height.toString())))));
1247
+ }
1248
+ };
1246
1249
  DnnImageCropper.style = dnnImageCropperCss;
1247
1250
 
1248
1251
  const dnnModalCss = ":host{display:block}:host .overlay{background-color:rgba(0, 0, 0, 0.5);position:fixed;top:0;left:0;width:100%;height:100%;z-index:1;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out;visibility:hidden;opacity:0}:host .overlay .modal{max-width:var(--max-width, 1200px);background-color:white;padding:30px;-webkit-transform:scale(2);transform:scale(2);-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out;z-index:2;position:relative;margin:10%;max-height:80%;border-radius:var(--dnn-controls-radius, 5px);-webkit-box-shadow:10px 10px 20px 0 rgba(0, 0, 0, 0.5);box-shadow:10px 10px 20px 0 rgba(0, 0, 0, 0.5);display:block}:host .overlay .modal .close{position:absolute;background-color:white;border:2px solid white;border-radius:50%;padding:0;margin:0;top:-12px;right:-12px;outline:none;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}:host .overlay .modal .close:focus,:host .overlay .modal .close:hover{-webkit-box-shadow:0 0 2px 2px var(--dnn-color-primary, blue);box-shadow:0 0 2px 2px var(--dnn-color-primary, blue)}:host .overlay .modal .close svg{width:24px;height:24px;color:grey}:host .overlay.visible{visibility:visible;opacity:1}:host .overlay.visible .modal{-webkit-transform:scale(1);transform:scale(1);-webkit-box-shadow:4px 4px 10px 0px rgba(0, 0, 0, 0.5);box-shadow:4px 4px 10px 0px rgba(0, 0, 0, 0.5);display:block}";
1249
1252
 
1250
- let DnnModal = class {
1251
- constructor(hostRef) {
1252
- registerInstance(this, hostRef);
1253
- this.dismissed = createEvent(this, "dismissed", 7);
1254
- /**
1255
- * Pass false to remove the backdrop click auto-dismiss feature.
1256
- */
1257
- this.backdropDismiss = true;
1258
- /**
1259
- * Optionally pass the aria-label text for the close button.
1260
- * Defaults to "Close modal" if not provided.
1261
- */
1262
- this.closeText = "Close modal";
1263
- /**
1264
- * Optionally you can pass false to not show the close button.
1265
- * If you decide to do so, you should either not also prevent dismissal by clicking the backdrop
1266
- * or provide your own dismissal logic in the modal content.
1267
- */
1268
- this.showCloseButton = true;
1269
- this.visible = false;
1270
- }
1271
- /**
1272
- * Shows the modal
1273
- */
1274
- async show() {
1275
- this.visible = true;
1276
- }
1277
- /**
1278
- * Hides the modal
1279
- */
1280
- async hide() {
1281
- this.visible = false;
1282
- }
1283
- handleDismiss() {
1284
- this.visible = false;
1285
- this.dismissed.emit();
1286
- }
1287
- handleBackdropClick(e) {
1288
- const element = e.target;
1289
- if (element.id === "backdrop" && this.backdropDismiss) {
1290
- this.handleDismiss();
1291
- }
1292
- }
1293
- render() {
1294
- return (h(Host, null, h("div", { id: "backdrop", class: this.visible ? 'overlay visible' : 'overlay', onClick: e => this.handleBackdropClick(e) }, h("div", { class: "modal" }, this.showCloseButton &&
1295
- h("button", { class: "close", "aria-label": this.closeText, onClick: () => this.handleDismiss() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z" }))), h("slot", null)))));
1296
- }
1297
- get el() { return getElement(this); }
1298
- };
1253
+ const DnnModal = class {
1254
+ constructor(hostRef) {
1255
+ registerInstance(this, hostRef);
1256
+ this.dismissed = createEvent(this, "dismissed", 7);
1257
+ /**
1258
+ * Pass false to remove the backdrop click auto-dismiss feature.
1259
+ */
1260
+ this.backdropDismiss = true;
1261
+ /**
1262
+ * Optionally pass the aria-label text for the close button.
1263
+ * Defaults to "Close modal" if not provided.
1264
+ */
1265
+ this.closeText = "Close modal";
1266
+ /**
1267
+ * Optionally you can pass false to not show the close button.
1268
+ * If you decide to do so, you should either not also prevent dismissal by clicking the backdrop
1269
+ * or provide your own dismissal logic in the modal content.
1270
+ */
1271
+ this.showCloseButton = true;
1272
+ /**
1273
+ * Reflects the visible state of the modal.
1274
+ */
1275
+ this.visible = false;
1276
+ }
1277
+ /**
1278
+ * Shows the modal
1279
+ */
1280
+ async show() {
1281
+ this.visible = true;
1282
+ }
1283
+ /**
1284
+ * Hides the modal
1285
+ */
1286
+ async hide() {
1287
+ this.visible = false;
1288
+ }
1289
+ handleDismiss() {
1290
+ this.visible = false;
1291
+ this.dismissed.emit();
1292
+ }
1293
+ handleBackdropClick(e) {
1294
+ const element = e.target;
1295
+ if (element.id === "backdrop" && this.backdropDismiss) {
1296
+ this.handleDismiss();
1297
+ }
1298
+ }
1299
+ render() {
1300
+ return (h(Host, null, h("div", { id: "backdrop", class: this.visible ? 'overlay visible' : 'overlay', onClick: e => this.handleBackdropClick(e) }, h("div", { class: "modal" }, this.showCloseButton &&
1301
+ h("button", { class: "close", "aria-label": this.closeText, onClick: () => this.handleDismiss() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z" }))), h("slot", null)))));
1302
+ }
1303
+ get el() { return getElement(this); }
1304
+ };
1299
1305
  DnnModal.style = dnnModalCss;
1300
1306
 
1307
+ const dnnPermissionsGridCss = ":host{display:block}.add-role-row{display:-ms-flexbox;display:flex;gap:1em;-ms-flex-align:center;align-items:center;-ms-flex-wrap:wrap;flex-wrap:wrap}.add-role-row label{margin-right:0.5em}.search-user{display:-ms-flexbox;display:flex;gap:1em;margin-top:1em}.search-user .search-control{position:relative}.search-user .search-control dnn-collapsible{position:absolute;left:0;top:calc(100% - 2px);width:100%;-webkit-box-shadow:0px 4px 4px;box-shadow:0px 4px 4px}.search-user .search-control dnn-collapsible .dropdown{background-color:white;border:1px solid lightgray;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}.search-user .search-control dnn-collapsible .dropdown button{background-color:transparent;border:none;border-bottom:1px solid lightgray;padding:0.25em;margin:0;text-align:left}table{border:1px solid lightgray;border-collapse:collapse;margin-top:1em}table thead{text-align:center}table thead tr{border-bottom:1px solid lightgray}table thead th{background-color:lightgray;padding:0.25em 0.5em}table thead th:first-child{border-right:1px solid lightgray}table tbody tr{border-bottom:1px dotted lightgray}table tbody tr th{text-align:left;border-right:1px solid lightgray;padding:0 0.5em}table tbody tr td{text-align:center}table tbody tr td dnn-checkbox span{display:none}table tbody tr td button{background-color:transparent;border:0;padding:0;margin:0;margin-right:1em}";
1308
+
1309
+ const DnnPermissionsGrid = class {
1310
+ constructor(hostRef) {
1311
+ registerInstance(this, hostRef);
1312
+ this.userSearchQueryChanged = createEvent(this, "userSearchQueryChanged", 7);
1313
+ this.permissionsChanged = createEvent(this, "permissionsChanged", 7);
1314
+ /** Optionally allows localizing the component strings. */
1315
+ this.resx = {
1316
+ Add: "Add",
1317
+ AllRoles: "All Roles",
1318
+ FilterByGroup: "Filter By Group",
1319
+ GlobalRoles: "Global Roles",
1320
+ Role: "Role",
1321
+ RolePermissions: "Role Permissions",
1322
+ SelectRole: "Select Role",
1323
+ User: "User",
1324
+ UserPermissions: "User Permissions",
1325
+ };
1326
+ /** The list of users to show under the search users field when a search is performed. */
1327
+ this.foundUsers = [];
1328
+ this.selectedRoleGroupId = -1;
1329
+ }
1330
+ handleFoundUsersChanged(newValue) {
1331
+ if ((newValue === null || newValue === void 0 ? void 0 : newValue.length) > 0) {
1332
+ setTimeout(() => {
1333
+ this.userCollapsible.expanded = true;
1334
+ }, 100);
1335
+ }
1336
+ }
1337
+ componentWillLoad() {
1338
+ document.addEventListener("click", this.dismissUserResults.bind(this));
1339
+ }
1340
+ disconnectedCallback() {
1341
+ document.removeEventListener("click", this.disconnectedCallback.bind(this));
1342
+ }
1343
+ dismissUserResults(e) {
1344
+ const dropdownRect = this.roleDropDown.getBoundingClientRect();
1345
+ if (e.pageX > dropdownRect.right ||
1346
+ e.pageX < dropdownRect.left ||
1347
+ e.pageY > dropdownRect.bottom ||
1348
+ e.pageY < dropdownRect.top) {
1349
+ this.userCollapsible.expanded = false;
1350
+ }
1351
+ }
1352
+ handleRoleGroupChanged(dropdown) {
1353
+ const index = dropdown.selectedIndex;
1354
+ const value = Number.parseInt(dropdown.options[index].value);
1355
+ this.selectedRoleGroupId = value;
1356
+ }
1357
+ addRole() {
1358
+ const roleId = Number.parseInt(this.roleDropDown.options[this.roleDropDown.selectedIndex].value);
1359
+ const role = this.roles.filter(r => r.RoleId == roleId)[0];
1360
+ this.permissions = Object.assign(Object.assign({}, this.permissions), { rolePermissions: [
1361
+ ...this.permissions.rolePermissions,
1362
+ {
1363
+ default: false,
1364
+ locked: false,
1365
+ permissions: [],
1366
+ roleId: role.RoleId,
1367
+ roleName: role.RoleName,
1368
+ }
1369
+ ] });
1370
+ this.permissionsChanged.emit(this.permissions);
1371
+ }
1372
+ addUser() {
1373
+ if (this.pickedUser != undefined) {
1374
+ this.permissions = Object.assign(Object.assign({}, this.permissions), { userPermissions: [
1375
+ ...this.permissions.userPermissions,
1376
+ {
1377
+ displayName: this.pickedUser.displayName,
1378
+ permissions: [],
1379
+ userId: this.pickedUser.userId,
1380
+ },
1381
+ ] });
1382
+ this.pickedUser = undefined;
1383
+ this.userQuery = "";
1384
+ this.permissionsChanged.emit(this.permissions);
1385
+ }
1386
+ }
1387
+ getRoles() {
1388
+ const filteredRoles = this.roles.filter(role => !this.permissions.rolePermissions.some(rp => rp.roleId == role.RoleId));
1389
+ if (this.selectedRoleGroupId == -2) {
1390
+ // All Roles
1391
+ return filteredRoles;
1392
+ }
1393
+ if (this.selectedRoleGroupId == -1) {
1394
+ // Global Roles
1395
+ return filteredRoles.filter(role => role.IsSystemRole);
1396
+ }
1397
+ return filteredRoles.filter(role => role.RoleGroupId == this.selectedRoleGroupId);
1398
+ }
1399
+ renderRoleCheckBox(rolePermission, permissionDefinition) {
1400
+ const item = rolePermission.permissions.filter(permission => permission.permissionId == permissionDefinition.permissionId)[0];
1401
+ if (rolePermission.locked) {
1402
+ return (h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("g", { fill: "none" }, h("path", { d: "M0 0h24v24H0V0z" }), h("path", { d: "M0 0h24v24H0V0z", opacity: ".87" })), h("path", { d: "M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9V6zm9 14H6V10h12v10zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" })));
1403
+ }
1404
+ const checked = item == undefined ? "intermediate" : item.allowAccess ? "checked" : "unchecked";
1405
+ return (h("dnn-checkbox", { "use-intermediate": true, checked: checked, onCheckedchange: e => this.handleRoleChanged(e.detail, rolePermission, permissionDefinition) }, h("div", { slot: "intermediateicon" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0V0z", fill: "none" }), h("path", { d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z" }))), h("div", { slot: "uncheckedicon" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0V0z", fill: "none" }), h("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z" }))), h("span", null, permissionDefinition.permissionName)));
1406
+ }
1407
+ renderUserCheckBox(userPermission, permissionDefinition) {
1408
+ const item = userPermission.permissions.filter(permission => permission.permissionId == permissionDefinition.permissionId)[0];
1409
+ const checked = item == undefined ? "intermediate" : item.allowAccess ? "checked" : "unchecked";
1410
+ return (h("dnn-checkbox", { "use-intermediate": true, checked: checked, onCheckedchange: e => this.handleUserChanged(e.detail, userPermission, permissionDefinition) }, h("div", { slot: "intermediateicon" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0V0z", fill: "none" }), h("path", { d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z" }))), h("div", { slot: "uncheckedicon" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0V0z", fill: "none" }), h("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z" }))), h("span", null, permissionDefinition.permissionName)));
1411
+ }
1412
+ handleRoleChanged(checked, rolePermission, permissionDefinition) {
1413
+ switch (checked) {
1414
+ case "unchecked":
1415
+ this.permissions = Object.assign(Object.assign({}, this.permissions), { rolePermissions: [
1416
+ ...this.permissions.rolePermissions.map(r => {
1417
+ if (r.roleId != rolePermission.roleId) {
1418
+ return r;
1419
+ }
1420
+ const newRolePermission = Object.assign({}, r);
1421
+ newRolePermission.permissions = [
1422
+ ...newRolePermission.permissions.filter(p => p.permissionId != permissionDefinition.permissionId),
1423
+ {
1424
+ allowAccess: false,
1425
+ fullControl: false,
1426
+ permissionCode: permissionDefinition.permissionCode,
1427
+ permissionId: permissionDefinition.permissionId,
1428
+ permissionKey: permissionDefinition.permissionKey,
1429
+ permissionName: permissionDefinition.permissionName,
1430
+ view: false,
1431
+ },
1432
+ ];
1433
+ return newRolePermission;
1434
+ }),
1435
+ ] });
1436
+ break;
1437
+ case "checked":
1438
+ this.permissions = Object.assign(Object.assign({}, this.permissions), { rolePermissions: [
1439
+ ...this.permissions.rolePermissions.map(r => {
1440
+ if (r.roleId != rolePermission.roleId) {
1441
+ return r;
1442
+ }
1443
+ const newRolePermission = Object.assign({}, r);
1444
+ newRolePermission.permissions = [
1445
+ ...newRolePermission.permissions.filter(p => p.permissionId != permissionDefinition.permissionId),
1446
+ {
1447
+ allowAccess: true,
1448
+ fullControl: false,
1449
+ permissionCode: permissionDefinition.permissionCode,
1450
+ permissionId: permissionDefinition.permissionId,
1451
+ permissionKey: permissionDefinition.permissionKey,
1452
+ permissionName: permissionDefinition.permissionName,
1453
+ view: false,
1454
+ },
1455
+ ];
1456
+ return newRolePermission;
1457
+ }),
1458
+ ] });
1459
+ break;
1460
+ case "intermediate":
1461
+ this.permissions = Object.assign(Object.assign({}, this.permissions), { rolePermissions: [
1462
+ ...this.permissions.rolePermissions.map(r => {
1463
+ if (r.roleId != rolePermission.roleId) {
1464
+ return r;
1465
+ }
1466
+ const newRolePermission = Object.assign({}, r);
1467
+ newRolePermission.permissions = [
1468
+ ...newRolePermission.permissions.filter(p => p.permissionId != permissionDefinition.permissionId),
1469
+ ];
1470
+ return newRolePermission;
1471
+ }),
1472
+ ] });
1473
+ break;
1474
+ }
1475
+ this.permissionsChanged.emit(this.permissions);
1476
+ }
1477
+ handleUserChanged(checked, userPermission, permissionDefinition) {
1478
+ switch (checked) {
1479
+ case "unchecked":
1480
+ this.permissions = Object.assign(Object.assign({}, this.permissions), { userPermissions: [
1481
+ ...this.permissions.userPermissions.map(u => {
1482
+ if (u.userId != userPermission.userId) {
1483
+ return u;
1484
+ }
1485
+ const newUserPermission = Object.assign({}, u);
1486
+ newUserPermission.permissions = [
1487
+ ...newUserPermission.permissions.filter(p => p.permissionId != permissionDefinition.permissionId),
1488
+ {
1489
+ allowAccess: false,
1490
+ fullControl: false,
1491
+ permissionCode: permissionDefinition.permissionCode,
1492
+ permissionId: permissionDefinition.permissionId,
1493
+ permissionKey: permissionDefinition.permissionKey,
1494
+ permissionName: permissionDefinition.permissionName,
1495
+ view: false,
1496
+ },
1497
+ ];
1498
+ return newUserPermission;
1499
+ }),
1500
+ ] });
1501
+ break;
1502
+ case "checked":
1503
+ this.permissions = Object.assign(Object.assign({}, this.permissions), { userPermissions: [
1504
+ ...this.permissions.userPermissions.map(u => {
1505
+ if (u.userId != userPermission.userId) {
1506
+ return u;
1507
+ }
1508
+ const newUserPermission = Object.assign({}, u);
1509
+ newUserPermission.permissions = [
1510
+ ...newUserPermission.permissions.filter(p => p.permissionId != permissionDefinition.permissionId),
1511
+ {
1512
+ allowAccess: true,
1513
+ fullControl: false,
1514
+ permissionCode: permissionDefinition.permissionCode,
1515
+ permissionId: permissionDefinition.permissionId,
1516
+ permissionKey: permissionDefinition.permissionKey,
1517
+ permissionName: permissionDefinition.permissionName,
1518
+ view: false,
1519
+ },
1520
+ ];
1521
+ return newUserPermission;
1522
+ }),
1523
+ ] });
1524
+ break;
1525
+ case "intermediate":
1526
+ this.permissions = Object.assign(Object.assign({}, this.permissions), { userPermissions: [
1527
+ ...this.permissions.userPermissions.map(u => {
1528
+ if (u.userId != userPermission.userId) {
1529
+ return u;
1530
+ }
1531
+ const newUserPermission = Object.assign({}, u);
1532
+ newUserPermission.permissions = [
1533
+ ...newUserPermission.permissions.filter(p => p.permissionId != permissionDefinition.permissionId),
1534
+ ];
1535
+ return newUserPermission;
1536
+ }),
1537
+ ] });
1538
+ break;
1539
+ }
1540
+ this.permissionsChanged.emit(this.permissions);
1541
+ }
1542
+ removeRole(rolePermission) {
1543
+ this.permissions = Object.assign(Object.assign({}, this.permissions), { rolePermissions: [
1544
+ ...this.permissions.rolePermissions.filter(rp => rp.roleId != rolePermission.roleId),
1545
+ ] });
1546
+ this.permissionsChanged.emit();
1547
+ }
1548
+ removeUser(userPermission) {
1549
+ this.permissions = Object.assign(Object.assign({}, this.permissions), { userPermissions: [
1550
+ ...this.permissions.userPermissions.filter(up => up.userId != userPermission.userId),
1551
+ ] });
1552
+ this.permissionsChanged.emit(this.permissions);
1553
+ }
1554
+ handleQueryChanged(query) {
1555
+ this.userQuery = query;
1556
+ if (query == undefined || query.length == 0) {
1557
+ this.userCollapsible.expanded = false;
1558
+ this.pickedUser = undefined;
1559
+ this.foundUsers = [];
1560
+ return;
1561
+ }
1562
+ this.userSearchQueryChanged.emit(query);
1563
+ }
1564
+ handleSearchUserFieldKeyDown(e) {
1565
+ if (e.key != "ArrowDown") {
1566
+ return;
1567
+ }
1568
+ e.preventDefault();
1569
+ const firstButton = this.userCollapsible.querySelector("button");
1570
+ if (firstButton != undefined) {
1571
+ firstButton.focus();
1572
+ }
1573
+ }
1574
+ handleSearchedUserKeyDown(e) {
1575
+ const button = e.target;
1576
+ switch (e.key) {
1577
+ case "ArrowDown":
1578
+ e.preventDefault();
1579
+ const nextButton = button.nextElementSibling;
1580
+ nextButton === null || nextButton === void 0 ? void 0 : nextButton.focus();
1581
+ break;
1582
+ case "ArrowUp":
1583
+ e.preventDefault();
1584
+ const previousButton = button.previousElementSibling;
1585
+ previousButton === null || previousButton === void 0 ? void 0 : previousButton.focus();
1586
+ break;
1587
+ }
1588
+ }
1589
+ handleUserPicked(searchedUser) {
1590
+ this.userQuery = searchedUser.displayName;
1591
+ this.pickedUser = searchedUser;
1592
+ }
1593
+ getFilteredUsers() {
1594
+ return this.foundUsers.filter(fu => !this.permissions.userPermissions.some(up => up.userId == fu.userId));
1595
+ }
1596
+ render() {
1597
+ const filteredRoles = this.getRoles();
1598
+ return (h(Host, null, h("div", { class: "add-role-row" }, h("div", { class: "dropdown" }, h("label", null, this.resx.FilterByGroup, " :"), h("select", { onChange: e => this.handleRoleGroupChanged(e.target) }, h("option", { value: -2, selected: this.selectedRoleGroupId == -2 }, this.resx.AllRoles), h("option", { value: -1, selected: this.selectedRoleGroupId == -1 }, this.resx.GlobalRoles), this.roleGroups.map(roleGroup => h("option", { value: roleGroup.id, selected: this.selectedRoleGroupId == roleGroup.id }, roleGroup.name)))), filteredRoles && filteredRoles.length > 0 && [
1599
+ h("div", { class: "dropdown" }, h("label", null, this.resx.SelectRole, " :"), h("select", { ref: el => this.roleDropDown = el }, this.getRoles().map(role => h("option", { value: role.RoleId }, role.RoleName)))),
1600
+ h("dnn-button", { type: "primary", onClick: () => this.addRole() }, this.resx.Add)
1601
+ ]), h("table", { class: "roles-table" }, h("caption", null, this.resx.RolePermissions), h("thead", null, h("tr", null, h("th", null, this.resx.Role), this.permissions.permissionDefinitions.map(permissionDefinition => h("th", null, permissionDefinition.permissionName)), h("th", null, "\u00A0"))), h("tbody", null, this.permissions.rolePermissions.map(rolePermission => h("tr", null, h("th", null, rolePermission.roleName), this.permissions.permissionDefinitions.map(permissionDefinition => h("td", null, this.renderRoleCheckBox(rolePermission, permissionDefinition))), h("td", null, !rolePermission.default &&
1602
+ h("button", { onClick: () => this.removeRole(rolePermission) }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0V0z", fill: "none" }), h("path", { d: "M14.59 8L12 10.59 9.41 8 8 9.41 10.59 12 8 14.59 9.41 16 12 13.41 14.59 16 16 14.59 13.41 12 16 9.41 14.59 8zM12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z" })))))))), h("div", { class: "search-user" }, h("div", { class: "search-control" }, h("dnn-searchbox", { placeholder: this.resx.User, debounced: true, onQueryChanged: e => this.handleQueryChanged(e.detail), onKeyDown: e => this.handleSearchUserFieldKeyDown(e), query: this.userQuery }), h("dnn-collapsible", { ref: el => this.userCollapsible = el }, h("div", { class: "dropdown" }, this.getFilteredUsers().map(searchedUser => h("button", { onKeyDown: e => this.handleSearchedUserKeyDown(e), onClick: () => this.handleUserPicked(searchedUser) }, searchedUser.displayName))))), this.pickedUser &&
1603
+ h("dnn-button", { onClick: () => this.addUser() }, this.resx.Add)), this.permissions.userPermissions && this.permissions.userPermissions.length > 0 &&
1604
+ h("table", { class: "users-table" }, h("caption", null, this.resx.UserPermissions), h("thead", null, h("tr", null, h("th", null, this.resx.User), this.permissions.permissionDefinitions.map(permissionDefinition => h("th", null, permissionDefinition.permissionName)), h("th", null, "\u00A0"))), h("tbody", null, this.permissions.userPermissions.map(userPermission => h("tr", null, h("th", null, userPermission.displayName), this.permissions.permissionDefinitions.map(permissionDefinition => h("td", null, this.renderUserCheckBox(userPermission, permissionDefinition))), h("td", null, h("button", { onClick: () => this.removeUser(userPermission) }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0V0z", fill: "none" }), h("path", { d: "M14.59 8L12 10.59 9.41 8 8 9.41 10.59 12 8 14.59 9.41 16 12 13.41 14.59 16 16 14.59 13.41 12 16 9.41 14.59 8zM12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z" }))))))))));
1605
+ }
1606
+ static get watchers() { return {
1607
+ "foundUsers": ["handleFoundUsersChanged"]
1608
+ }; }
1609
+ };
1610
+ DnnPermissionsGrid.style = dnnPermissionsGridCss;
1611
+
1301
1612
  const dnnSearchboxCss = ":host{position:relative;display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;--background-color:transparent;--color:#333;--border-size:1px;--border-color:grey;--border-active-color:black;--border-radius:var(--dnn-controls-radius, 5px);--padding:var(--dnn-controls-padding, 5px);--focus-color:var(--dnn-color-primary, blue)}:host input{width:100%;border:var(--border-size) solid var(--border-color);outline:none;border-radius:var(--border-radius);padding:var(--padding);padding-right:32px;-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out}:host input:focus,:host input:hover{outline:none;-webkit-box-shadow:0 0 2px 2px var(--focus-color);box-shadow:0 0 2px 2px var(--focus-color)}:host svg{position:absolute;top:0;right:0;height:100%;-webkit-transform:scale(0.7);transform:scale(0.7);fill:var(--color);outline:var(--color);color:var(--color);-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out}:host button{background:transparent;border:0;margin:0;padding:0}:host button:focus svg,:host button:hover svg{fill:var(--focus-color);outline:var(--focus-color);color:var(--focus-color)}";
1302
1613
 
1303
- var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1304
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1305
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1306
- r = Reflect.decorate(decorators, target, key, desc);
1307
- else
1308
- for (var i = decorators.length - 1; i >= 0; i--)
1309
- if (d = decorators[i])
1310
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1311
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1312
- };
1313
- let DnnSearchbox = class {
1314
- constructor(hostRef) {
1315
- registerInstance(this, hostRef);
1316
- this.queryChanged = createEvent(this, "queryChanged", 7);
1317
- /**
1318
- * Sets the field placeholder text.
1319
- */
1320
- this.placeholder = "";
1321
- /**
1322
- * Debounces the queryChanged by 500ms.
1323
- */
1324
- this.debounced = true;
1325
- /** Sets the query */
1326
- this.query = "";
1327
- }
1328
- fireQueryChanged() {
1329
- if (this.debounced) {
1330
- this.debouncedHandleQueryChanged();
1331
- }
1332
- else {
1333
- this.handleQueryChanged();
1334
- }
1335
- }
1336
- handleQueryChanged() {
1337
- this.queryChanged.emit(this.query);
1338
- }
1339
- debouncedHandleQueryChanged() {
1340
- this.handleQueryChanged();
1341
- }
1342
- render() {
1343
- return (h(Host, null, h("input", { type: "text", value: this.query, placeholder: this.placeholder, onInput: e => this.query = e.target.value }), this.query !== "" ?
1344
- h("button", { class: "svg clear", onClick: () => this.query = "" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z" })))
1345
- :
1346
- h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" }))));
1347
- }
1348
- static get watchers() { return {
1349
- "query": ["fireQueryChanged"]
1350
- }; }
1351
- };
1352
- __decorate([
1353
- Debounce(500)
1354
- ], DnnSearchbox.prototype, "debouncedHandleQueryChanged", null);
1614
+ var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1615
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1616
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1617
+ r = Reflect.decorate(decorators, target, key, desc);
1618
+ else
1619
+ for (var i = decorators.length - 1; i >= 0; i--)
1620
+ if (d = decorators[i])
1621
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1622
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1623
+ };
1624
+ const DnnSearchbox = class {
1625
+ constructor(hostRef) {
1626
+ registerInstance(this, hostRef);
1627
+ this.queryChanged = createEvent(this, "queryChanged", 7);
1628
+ /**
1629
+ * Sets the field placeholder text.
1630
+ */
1631
+ this.placeholder = "";
1632
+ /**
1633
+ * Debounces the queryChanged by 500ms.
1634
+ */
1635
+ this.debounced = true;
1636
+ /** Sets the query */
1637
+ this.query = "";
1638
+ }
1639
+ fireQueryChanged() {
1640
+ if (this.debounced) {
1641
+ this.debouncedHandleQueryChanged();
1642
+ }
1643
+ else {
1644
+ this.handleQueryChanged();
1645
+ }
1646
+ }
1647
+ handleQueryChanged() {
1648
+ this.queryChanged.emit(this.query);
1649
+ }
1650
+ debouncedHandleQueryChanged() {
1651
+ this.handleQueryChanged();
1652
+ }
1653
+ render() {
1654
+ return (h(Host, null, h("input", { type: "text", value: this.query, placeholder: this.placeholder, onInput: e => this.query = e.target.value }), this.query !== "" ?
1655
+ h("button", { class: "svg clear", onClick: () => this.query = "" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z" })))
1656
+ :
1657
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" }))));
1658
+ }
1659
+ static get watchers() { return {
1660
+ "query": ["fireQueryChanged"]
1661
+ }; }
1662
+ };
1663
+ __decorate([
1664
+ Debounce(500)
1665
+ ], DnnSearchbox.prototype, "debouncedHandleQueryChanged", null);
1355
1666
  DnnSearchbox.style = dnnSearchboxCss;
1356
1667
 
1357
- const dnnSortIconCss = ":host{display:inline-block}button{outline:none;border:none;margin:0;padding:0;background-color:transparent;outline:none;display:inline-block;line-height:1em;position:relative;top:0.25em}button svg{height:1.5em;width:auto;fill:var(--color, #888)}button.active svg{fill:var(--color-sorted, var(--dnn-color-primary, #028bff))}button:hover svg,button:focus svg{fill:var(--color-hover, var(--dnn-color-primary-light, #36a1ff))}";
1668
+ const dnnSortIconCss = ":host{--color:#888;--color-sorted:var(--dnn-color-primary, rgb(2,139,255));--color-hover:var(--dnn-color-primary-light, #36a1ff);display:inline-block}button{outline:none;border:none;margin:0;padding:0;background-color:transparent;outline:none;display:inline-block;line-height:1em;position:relative;top:0.25em}button svg{height:1.5em;width:auto;fill:var(--color)}button.active svg{fill:var(--color-sorted)}button:hover svg,button:focus svg{fill:var(--color-hover)}";
1358
1669
 
1359
- let DnnSortIcon = class {
1360
- constructor(hostRef) {
1361
- registerInstance(this, hostRef);
1362
- this.sortChanged = createEvent(this, "sortChanged", 7);
1363
- /** Defines the current sort direction */
1364
- this.sortDirection = "none";
1365
- }
1366
- changeSort() {
1367
- switch (this.sortDirection) {
1368
- case "asc":
1369
- this.sortDirection = "desc";
1370
- break;
1371
- case "desc":
1372
- this.sortDirection = "asc";
1373
- break;
1374
- case "none":
1375
- this.sortDirection = "asc";
1376
- break;
1377
- }
1378
- this.sortChanged.emit(this.sortDirection);
1379
- }
1380
- render() {
1381
- return (h(Host, null, h("button", { class: { "active": this.sortDirection != "none" }, onClick: () => this.changeSort() }, this.sortDirection == "none" &&
1382
- h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 16" }, h("path", { d: "M 0 7 H 12 L 6 0 Z M 0 9 H 12 L 6 16 Z" })), this.sortDirection == "asc" &&
1383
- h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 16" }, h("path", { d: "M 0 7 H 12 L 6 0 Z" })), this.sortDirection == "desc" &&
1384
- h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 16" }, h("path", { d: "M 0 9 H 12 L 6 16 Z" })))));
1385
- }
1386
- };
1670
+ const DnnSortIcon = class {
1671
+ constructor(hostRef) {
1672
+ registerInstance(this, hostRef);
1673
+ this.sortChanged = createEvent(this, "sortChanged", 7);
1674
+ /** Defines the current sort direction */
1675
+ this.sortDirection = "none";
1676
+ }
1677
+ changeSort() {
1678
+ switch (this.sortDirection) {
1679
+ case "asc":
1680
+ this.sortDirection = "desc";
1681
+ break;
1682
+ case "desc":
1683
+ this.sortDirection = "asc";
1684
+ break;
1685
+ case "none":
1686
+ this.sortDirection = "asc";
1687
+ break;
1688
+ }
1689
+ this.sortChanged.emit(this.sortDirection);
1690
+ }
1691
+ render() {
1692
+ return (h(Host, null, h("button", { class: { "active": this.sortDirection != "none" }, onClick: () => this.changeSort() }, this.sortDirection == "none" &&
1693
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 16" }, h("path", { d: "M 0 7 H 12 L 6 0 Z M 0 9 H 12 L 6 16 Z" })), this.sortDirection == "asc" &&
1694
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 16" }, h("path", { d: "M 0 7 H 12 L 6 0 Z" })), this.sortDirection == "desc" &&
1695
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 16" }, h("path", { d: "M 0 9 H 12 L 6 16 Z" })))));
1696
+ }
1697
+ };
1387
1698
  DnnSortIcon.style = dnnSortIconCss;
1388
1699
 
1389
1700
  const dnnTabCss = "";
1390
1701
 
1391
- let DnnTab = class {
1392
- constructor(hostRef) {
1393
- registerInstance(this, hostRef);
1394
- this.visible = false;
1395
- }
1396
- /** Shows the tab. */
1397
- async show() {
1398
- this.visible = true;
1399
- }
1400
- /** Hides the modal */
1401
- async hide() {
1402
- this.visible = false;
1403
- }
1404
- render() {
1405
- return (h(Host, null, this.visible &&
1406
- h("slot", null)));
1407
- }
1408
- };
1702
+ const DnnTab = class {
1703
+ constructor(hostRef) {
1704
+ registerInstance(this, hostRef);
1705
+ this.visible = false;
1706
+ }
1707
+ /** Shows the tab. */
1708
+ async show() {
1709
+ this.visible = true;
1710
+ }
1711
+ /** Hides the modal */
1712
+ async hide() {
1713
+ this.visible = false;
1714
+ }
1715
+ render() {
1716
+ return (h(Host, null, this.visible &&
1717
+ h("slot", null)));
1718
+ }
1719
+ };
1409
1720
  DnnTab.style = dnnTabCss;
1410
1721
 
1411
1722
  const dnnTabsCss = ":host{display:block;--color-background:var(--dnn-color-secondary-dark, lightgray);--color-text:var(--dnn-color-secondary-contrast, #333);--color-visible:var(--dnn-color-primary, #3792ED);--color-visible-text:var(--dnn-color-primary-contrast, #FFF);--color-focus:var(--dnn-color-primary, #3792ed)}.tabTitles{display:-ms-flexbox;display:flex;background-color:var(--color-background);color:var(--color-text)}.tabTitles button{padding:0.5rem 1rem;border:0;margin:0;background-color:transparent}.tabTitles button.visible{background-color:var(--color-visible);color:var(--color-bisible-text)}.tabTitles button:focus,.tabTitles button:hover{outline:none;-webkit-box-shadow:0 0 2px 2px var(--color-focus);box-shadow:0 0 2px 2px var(--color-focus)}.currentTab{border:1px solid var(--color-background);padding:1rem}";
1412
1723
 
1413
- let DnnTabs = class {
1414
- constructor(hostRef) {
1415
- registerInstance(this, hostRef);
1416
- this.tabTitles = [];
1417
- this.selectedTabTitle = "";
1418
- }
1419
- componentDidLoad() {
1420
- requestAnimationFrame(() => {
1421
- this.updateTitles();
1422
- this.showFirstTab();
1423
- });
1424
- }
1425
- getTabs() {
1426
- return this.component.shadowRoot.querySelector("slot").assignedElements();
1427
- }
1428
- updateTitles() {
1429
- const tabs = this.getTabs();
1430
- tabs.forEach(tab => this.tabTitles = [...this.tabTitles, tab.tabTitle]);
1431
- }
1432
- showFirstTab() {
1433
- const tab = this.getTabs()[0];
1434
- tab.show();
1435
- this.selectedTabTitle = tab.tabTitle;
1436
- }
1437
- showTab(tabTitle) {
1438
- const tabs = this.getTabs();
1439
- tabs.forEach(tab => {
1440
- if (tab.tabTitle == tabTitle) {
1441
- tab.show();
1442
- return;
1443
- }
1444
- tab.hide();
1445
- });
1446
- this.selectedTabTitle = tabTitle;
1447
- }
1448
- render() {
1449
- return (h(Host, { ref: el => this.component = el }, h("div", { class: "tabTitles" }, this.tabTitles.map(tabTitle => h("button", { class: this.selectedTabTitle == tabTitle ? "visible" : "", onClick: () => this.showTab(tabTitle) }, tabTitle))), h("div", { class: "currentTab" }, h("slot", null))));
1450
- }
1451
- };
1724
+ const DnnTabs = class {
1725
+ constructor(hostRef) {
1726
+ registerInstance(this, hostRef);
1727
+ this.tabTitles = [];
1728
+ this.selectedTabTitle = "";
1729
+ }
1730
+ componentDidLoad() {
1731
+ requestAnimationFrame(() => {
1732
+ this.updateTitles();
1733
+ this.showFirstTab();
1734
+ });
1735
+ }
1736
+ getTabs() {
1737
+ return this.component.shadowRoot.querySelector("slot").assignedElements();
1738
+ }
1739
+ updateTitles() {
1740
+ const tabs = this.getTabs();
1741
+ tabs.forEach(tab => this.tabTitles = [...this.tabTitles, tab.tabTitle]);
1742
+ }
1743
+ showFirstTab() {
1744
+ const tab = this.getTabs()[0];
1745
+ tab.show();
1746
+ this.selectedTabTitle = tab.tabTitle;
1747
+ }
1748
+ showTab(tabTitle) {
1749
+ const tabs = this.getTabs();
1750
+ tabs.forEach(tab => {
1751
+ if (tab.tabTitle == tabTitle) {
1752
+ tab.show();
1753
+ return;
1754
+ }
1755
+ tab.hide();
1756
+ });
1757
+ this.selectedTabTitle = tabTitle;
1758
+ }
1759
+ render() {
1760
+ return (h(Host, { ref: el => this.component = el }, h("div", { class: "tabTitles" }, this.tabTitles.map(tabTitle => h("button", { class: this.selectedTabTitle == tabTitle ? "visible" : "", onClick: () => this.showTab(tabTitle) }, tabTitle))), h("div", { class: "currentTab" }, h("slot", null))));
1761
+ }
1762
+ };
1452
1763
  DnnTabs.style = dnnTabsCss;
1453
1764
 
1454
- const dnnToggleCss = ":host{display:inline-block;outline:none;cursor:pointer}button{height:1.5em;width:2.5em;outline:none;background-color:var(--background, #888);border:0;border-radius:var(--border-radius, var(--dnn-controls-radius, 0.75em));padding:0.1em;position:relative;margin:0;-webkit-transition:background-color 300ms ease-in-out;transition:background-color 300ms ease-in-out;position:relative;cursor:pointer}button:hover,button:focus{-webkit-box-shadow:0 0 2px 2px var(--dnn-color-primary);box-shadow:0 0 2px 2px var(--dnn-color-primary)}button.checked{background-color:var(--background-checked, var(--dnn-color-primary, blue))}button.checked .handle{left:calc(1em + 4px)}button:disabled{opacity:0.5;cursor:not-allowed;-webkit-box-shadow:none;box-shadow:none}button .handle{-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out;background-color:white;width:1em;height:1em;border-radius:var(--dnn-controls-radius, 50%);position:absolute;top:calc(50% - 0.5em);left:2px}";
1765
+ const dnnToggleCss = ":host{display:inline-block;outline:none;cursor:pointer}button{height:1.5em;width:2.5em;outline:none;background-color:var(--background, #888);border:0;border-radius:var(--border-radius, var(--dnn-controls-radius, 0.75em));padding:0.1em;position:relative;margin:0;-webkit-transition:background-color 300ms ease-in-out;transition:background-color 300ms ease-in-out;position:relative;cursor:pointer}button:hover,button:focus{-webkit-box-shadow:0 0 2px 2px var(--dnn-color-primary);box-shadow:0 0 2px 2px var(--dnn-color-primary)}button.checked{background-color:var(--background-checked, var(--dnn-color-primary, blue))}button.checked .handle{left:calc(1em + 4px)}button:disabled{opacity:0.5;cursor:not-allowed;-webkit-box-shadow:none;box-shadow:none}button .handle{-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out;background-color:white;width:1em;height:1em;border-radius:var(--handle-border-radius, var(--dnn-controls-radius, 50%));position:absolute;top:calc(50% - 0.5em);left:2px}";
1455
1766
 
1456
- let DnnToggle = class {
1457
- constructor(hostRef) {
1458
- registerInstance(this, hostRef);
1459
- this.checkChanged = createEvent(this, "checkChanged", 7);
1460
- /** If 'true' the toggle is checked (on). */
1461
- this.checked = false;
1462
- /** If 'true' the toggle is not be interacted with. */
1463
- this.disabled = false;
1464
- }
1465
- checkedChanged(isChecked) {
1466
- this.checkChanged.emit({ checked: isChecked });
1467
- }
1468
- render() {
1469
- return (h(Host, null, h("button", { disabled: this.disabled, class: { 'checked': this.checked }, onClick: () => {
1470
- if (!this.disabled) {
1471
- this.checked = !this.checked;
1472
- }
1473
- } }, h("div", { class: "handle" }))));
1474
- }
1475
- get element() { return getElement(this); }
1476
- static get watchers() { return {
1477
- "checked": ["checkedChanged"]
1478
- }; }
1479
- };
1767
+ const DnnToggle = class {
1768
+ constructor(hostRef) {
1769
+ registerInstance(this, hostRef);
1770
+ this.checkChanged = createEvent(this, "checkChanged", 7);
1771
+ /** If 'true' the toggle is checked (on). */
1772
+ this.checked = false;
1773
+ /** If 'true' the toggle is not be interacted with. */
1774
+ this.disabled = false;
1775
+ }
1776
+ checkedChanged(isChecked) {
1777
+ this.checkChanged.emit({ checked: isChecked });
1778
+ }
1779
+ render() {
1780
+ return (h(Host, null, h("button", { disabled: this.disabled, class: { 'checked': this.checked }, onClick: () => {
1781
+ if (!this.disabled) {
1782
+ this.checked = !this.checked;
1783
+ }
1784
+ } }, h("div", { class: "handle" }))));
1785
+ }
1786
+ get element() { return getElement(this); }
1787
+ static get watchers() { return {
1788
+ "checked": ["checkedChanged"]
1789
+ }; }
1790
+ };
1480
1791
  DnnToggle.style = dnnToggleCss;
1481
1792
 
1482
1793
  const dnnTreeviewItemCss = ":host{display:-ms-flexbox;display:flex;overflow:visible}.expander{width:24px;height:24px}.expander button{-webkit-transition:all 150ms ease-in-out;transition:all 150ms ease-in-out;background-color:transparent;border:none;padding:0;margin:0;height:1em;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;cursor:pointer;position:relative;top:2px}.expander button svg :first-child{-webkit-transition:all 150ms ease-in-out;transition:all 150ms ease-in-out;fill:white;stroke:black}.expander.expanded button{-webkit-transform:rotate(45deg);transform:rotate(45deg)}.expander.expanded button svg :first-child{fill:black;stroke:black}div.item .item-slot{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:0.25em;min-height:24px}div.item div.children{overflow:hidden;height:0;-webkit-transition:all 150ms ease-in-out;transition:all 150ms ease-in-out}";
1483
1794
 
1484
- let DnnTreeviewItem = class {
1485
- constructor(hostRef) {
1486
- registerInstance(this, hostRef);
1487
- this.userExpanded = createEvent(this, "userExpanded", 3);
1488
- this.userCollapsed = createEvent(this, "userCollapsed", 3);
1489
- /** Defines if the current node is expanded. */
1490
- this.expanded = false;
1491
- /** Manages state for whether or not item has children. */
1492
- this.hasChildren = false;
1493
- }
1494
- /** Watch expanded Prop */
1495
- watchExpanded(expanded) {
1496
- if (expanded) {
1497
- this.expander.classList.add("expanded");
1498
- this.collapsible.expanded = true;
1499
- return;
1500
- }
1501
- this.expander.classList.remove("expanded");
1502
- this.collapsible.expanded = false;
1503
- }
1504
- componentDidLoad() {
1505
- requestAnimationFrame(() => {
1506
- const child = this.childElement.children[0];
1507
- const count = child.assignedElements().length;
1508
- if (count > 0) {
1509
- this.hasChildren = true;
1510
- }
1511
- if (this.expanded) {
1512
- this.expander.classList.add("expanded");
1513
- this.collapsible.expanded = false;
1514
- setTimeout(() => {
1515
- this.collapsible.expanded = true;
1516
- }, 300);
1517
- }
1518
- });
1519
- }
1520
- toggleCollapse() {
1521
- this.expanded = !this.expanded;
1522
- if (this.expanded) {
1523
- this.expander.classList.add("expanded");
1524
- this.userExpanded.emit();
1525
- return;
1526
- }
1527
- this.expander.classList.remove("expanded");
1528
- this.userCollapsed.emit();
1529
- }
1530
- render() {
1531
- return (h(Host, null, h("div", { class: "expander", ref: el => this.expander = el }, this.hasChildren &&
1532
- h("button", { onClick: () => this.toggleCollapse() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M10 17l5-5-5-5v10z" }), h("path", { d: "M0 24V0h24v24H0z", fill: "none" })))), h("div", { class: "item" }, h("div", { class: "item-slot" }, h("slot", null)), h("dnn-collapsible", { ref: el => this.collapsible = el, expanded: this.expanded }, h("div", { ref: el => this.childElement = el }, h("slot", { name: "children" }))))));
1533
- }
1534
- get el() { return getElement(this); }
1535
- static get watchers() { return {
1536
- "expanded": ["watchExpanded"]
1537
- }; }
1538
- };
1795
+ const DnnTreeviewItem = class {
1796
+ constructor(hostRef) {
1797
+ registerInstance(this, hostRef);
1798
+ this.userExpanded = createEvent(this, "userExpanded", 3);
1799
+ this.userCollapsed = createEvent(this, "userCollapsed", 3);
1800
+ /** Defines if the current node is expanded. */
1801
+ this.expanded = false;
1802
+ /** Manages state for whether or not item has children. */
1803
+ this.hasChildren = false;
1804
+ }
1805
+ /** Watch expanded Prop */
1806
+ watchExpanded(expanded) {
1807
+ if (expanded) {
1808
+ this.expander.classList.add("expanded");
1809
+ this.collapsible.expanded = true;
1810
+ return;
1811
+ }
1812
+ this.expander.classList.remove("expanded");
1813
+ this.collapsible.expanded = false;
1814
+ }
1815
+ componentDidLoad() {
1816
+ requestAnimationFrame(() => {
1817
+ const child = this.childElement.children[0];
1818
+ const count = child.assignedElements().length;
1819
+ if (count > 0) {
1820
+ this.hasChildren = true;
1821
+ }
1822
+ if (this.expanded) {
1823
+ this.expander.classList.add("expanded");
1824
+ this.collapsible.expanded = false;
1825
+ setTimeout(() => {
1826
+ this.collapsible.expanded = true;
1827
+ }, 300);
1828
+ }
1829
+ });
1830
+ }
1831
+ toggleCollapse() {
1832
+ this.expanded = !this.expanded;
1833
+ if (this.expanded) {
1834
+ this.expander.classList.add("expanded");
1835
+ this.userExpanded.emit();
1836
+ return;
1837
+ }
1838
+ this.expander.classList.remove("expanded");
1839
+ this.userCollapsed.emit();
1840
+ }
1841
+ render() {
1842
+ return (h(Host, null, h("div", { class: "expander", ref: el => this.expander = el }, this.hasChildren &&
1843
+ h("button", { onClick: () => this.toggleCollapse() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M10 17l5-5-5-5v10z" }), h("path", { d: "M0 24V0h24v24H0z", fill: "none" })))), h("div", { class: "item" }, h("div", { class: "item-slot" }, h("slot", null)), h("dnn-collapsible", { ref: el => this.collapsible = el, expanded: this.expanded }, h("div", { ref: el => this.childElement = el }, h("slot", { name: "children" }))))));
1844
+ }
1845
+ get el() { return getElement(this); }
1846
+ static get watchers() { return {
1847
+ "expanded": ["watchExpanded"]
1848
+ }; }
1849
+ };
1539
1850
  DnnTreeviewItem.style = dnnTreeviewItemCss;
1540
1851
 
1541
- const dnnVerticalOverflowMenuCss = ":host{display:block;--background-color:var(--dnn-color-primary-contrast, white);--foreground-color:var(--dnn-color-primary, blue);--text-color:#222}.menu-container{display:-ms-flexbox;display:flex;-ms-flex-pack:start;justify-content:flex-start;-ms-flex-align:center;align-items:center;background-color:var(--background-color);color:var(--text-color)}.menu-container .menu{margin:0.5em;display:-ms-flexbox;display:flex;gap:1em;-ms-flex-pack:start;justify-content:flex-start;-ms-flex-align:center;align-items:center;white-space:nowrap;width:100%}.menu-container .overflow{margin-left:auto;position:relative}.menu-container .overflow button{cursor:pointer;padding:0;margin:0;background-color:transparent;border:none}.menu-container .overflow button svg{fill:var(--foreground-color)}.menu-container .overflow .dropdown{position:absolute;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;white-space:nowrap;right:0;-webkit-transition:100ms ease-in-out;transition:100ms ease-in-out;height:0;overflow:hidden}.menu-container .overflow .dropdown.visible{padding:1em;gap:0.5em;background-color:var(--background-color);-webkit-box-shadow:2px 2px 4px rgba(0, 0, 0, 0.7);box-shadow:2px 2px 4px rgba(0, 0, 0, 0.7)}";
1852
+ const dnnVerticalOverflowMenuCss = ":host{--background-color:var(--dnn-color-primary-contrast, white);--foreground-color:var(--dnn-color-primary, #3792ED);display:block}.menu-container{display:-ms-flexbox;display:flex;-ms-flex-pack:start;justify-content:flex-start;-ms-flex-align:center;align-items:center;background-color:var(--background-color)}.menu-container .menu{margin:0.5em;display:-ms-flexbox;display:flex;gap:1em;-ms-flex-pack:start;justify-content:flex-start;-ms-flex-align:center;align-items:center;white-space:nowrap;width:100%}.menu-container .overflow{margin-left:auto;position:relative}.menu-container .overflow button{cursor:pointer;padding:0;margin:0;background-color:transparent;border:none}.menu-container .overflow button svg{fill:var(--foreground-color)}.menu-container .overflow .dropdown{position:absolute;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;white-space:nowrap;right:0;-webkit-transition:100ms ease-in-out;transition:100ms ease-in-out;height:0;overflow:hidden}.menu-container .overflow .dropdown.visible{padding:1em;gap:0.5em;background-color:var(--background-color);-webkit-box-shadow:2px 2px 4px rgba(0, 0, 0, 0.7);box-shadow:2px 2px 4px rgba(0, 0, 0, 0.7)}";
1542
1853
 
1543
- let DnnVerticalOverflowMenu = class {
1544
- constructor(hostRef) {
1545
- registerInstance(this, hostRef);
1546
- this.showDropdownButton = false;
1547
- this.showDropdownMenu = false;
1548
- this.previousMenuWidth = 0;
1549
- }
1550
- componentDidRender() {
1551
- requestAnimationFrame(() => {
1552
- this.moveItemsToDropDownIfNecessery();
1553
- this.resizeObserver = new ResizeObserver(entries => {
1554
- for (let entry of entries) {
1555
- if (entry.contentRect.width < this.previousMenuWidth) {
1556
- this.moveItemsToDropDownIfNecessery();
1557
- }
1558
- if (this.previousMenuWidth > 0 && entry.contentRect.width > this.previousMenuWidth) {
1559
- this.moveItemsToMenuIfPossible();
1560
- }
1561
- this.previousMenuWidth = entry.contentRect.width;
1562
- }
1563
- });
1564
- this.resizeObserver.observe(this.element);
1565
- });
1566
- }
1567
- moveItemsToDropDownIfNecessery() {
1568
- const menuItems = Array.from(this.menu.querySelector("slot").assignedElements());
1569
- const availableWidth = this.menu.getBoundingClientRect().width;
1570
- let neededWidth = parseFloat(getComputedStyle(this.element).fontSize) * 2;
1571
- menuItems.forEach(item => neededWidth += this.getFullWidth(item));
1572
- neededWidth += (menuItems.length - 1) * parseFloat(getComputedStyle(this.element).fontSize);
1573
- if (neededWidth > availableWidth) {
1574
- this.showDropdownButton = true;
1575
- var lastItem = menuItems[menuItems.length - 1];
1576
- if (this.dropdown == undefined) {
1577
- return;
1578
- }
1579
- lastItem.slot = "dropdown";
1580
- this.moveItemsToDropDownIfNecessery();
1581
- }
1582
- }
1583
- moveItemsToMenuIfPossible() {
1584
- if (this.dropdown == undefined || !this.dropdown.hasChildNodes()) {
1585
- return;
1586
- }
1587
- const menuItems = Array.from(this.menu.querySelector("slot").assignedElements());
1588
- const availableWidth = this.menu.getBoundingClientRect().width;
1589
- let neededWidth = parseFloat(getComputedStyle(this.element).fontSize) * 2;
1590
- neededWidth += (menuItems.length - 1) * parseFloat(getComputedStyle(this.element).fontSize);
1591
- menuItems.forEach(item => neededWidth += this.getFullWidth(item));
1592
- const firstItem = this.dropdown.querySelector("slot").assignedElements()[0];
1593
- if (firstItem != undefined) {
1594
- neededWidth += this.getFullWidth(firstItem);
1595
- }
1596
- if (neededWidth < availableWidth) {
1597
- if (firstItem != undefined) {
1598
- firstItem.slot = "";
1599
- }
1600
- if (firstItem == undefined) {
1601
- this.dropdown.classList.remove("visible");
1602
- this.showDropdownMenu = false;
1603
- this.showDropdownButton = false;
1604
- }
1605
- }
1606
- }
1607
- getFullWidth(item) {
1608
- var width = item.getBoundingClientRect().width;
1609
- var styles = getComputedStyle(item);
1610
- width += parseFloat(styles.marginLeft);
1611
- width += parseFloat(styles.marginRight);
1612
- width += parseFloat(styles.paddingLeft);
1613
- width += parseFloat(styles.paddingRight);
1614
- return width;
1615
- }
1616
- toggleOverflowMenu() {
1617
- this.showDropdownMenu = !this.showDropdownMenu;
1618
- if (this.showDropdownMenu) {
1619
- this.dropdown.classList.add("visible");
1620
- let contentHeight = 0;
1621
- const items = Array.from(this.dropdown.querySelector("slot").assignedElements());
1622
- items.forEach(item => contentHeight += item.getBoundingClientRect().height);
1623
- var emHeight = parseFloat(getComputedStyle(this.dropdown).fontSize) * 0.5;
1624
- var additionalHeight = emHeight * (this.dropdown.children.length - 1);
1625
- contentHeight += additionalHeight;
1626
- this.dropdown.style.height = `${contentHeight}px`;
1627
- const dismissMenu = (e) => {
1628
- const buttonRect = this.button.getBoundingClientRect();
1629
- if (e.clientX < buttonRect.left ||
1630
- e.clientX > buttonRect.right ||
1631
- e.clientY < buttonRect.top ||
1632
- e.clientY > buttonRect.bottom) {
1633
- this.toggleOverflowMenu();
1634
- }
1635
- document.removeEventListener("click", dismissMenu);
1636
- };
1637
- setTimeout(() => {
1638
- document.addEventListener("click", dismissMenu, false);
1639
- }, 100);
1640
- }
1641
- else {
1642
- this.dropdown.classList.remove("visible");
1643
- this.dropdown.style.height = "0px";
1644
- }
1645
- }
1646
- render() {
1647
- return (h(Host, null, h("div", { class: "menu-container" }, h("div", { class: "menu", ref: el => this.menu = el }, h("slot", null)), this.showDropdownButton &&
1648
- h("div", { class: "overflow" }, h("button", { ref: el => this.button = el, class: "icon", onClick: () => this.toggleOverflowMenu() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }))), h("div", { class: "dropdown", ref: el => this.dropdown = el }, h("slot", { name: "dropdown" }))))));
1649
- }
1650
- get element() { return getElement(this); }
1651
- };
1854
+ const DnnVerticalOverflowMenu = class {
1855
+ constructor(hostRef) {
1856
+ registerInstance(this, hostRef);
1857
+ this.showDropdownButton = false;
1858
+ this.showDropdownMenu = false;
1859
+ this.previousMenuWidth = 0;
1860
+ }
1861
+ componentDidRender() {
1862
+ requestAnimationFrame(() => {
1863
+ this.moveItemsToDropDownIfNecessery();
1864
+ this.resizeObserver = new ResizeObserver(entries => {
1865
+ for (let entry of entries) {
1866
+ if (entry.contentRect.width < this.previousMenuWidth) {
1867
+ this.moveItemsToDropDownIfNecessery();
1868
+ }
1869
+ if (this.previousMenuWidth > 0 && entry.contentRect.width > this.previousMenuWidth) {
1870
+ this.moveItemsToMenuIfPossible();
1871
+ }
1872
+ this.previousMenuWidth = entry.contentRect.width;
1873
+ }
1874
+ });
1875
+ this.resizeObserver.observe(this.element);
1876
+ });
1877
+ }
1878
+ moveItemsToDropDownIfNecessery() {
1879
+ const menuItems = Array.from(this.menu.querySelector("slot").assignedElements());
1880
+ const availableWidth = this.menu.getBoundingClientRect().width;
1881
+ let neededWidth = parseFloat(getComputedStyle(this.element).fontSize) * 2;
1882
+ menuItems.forEach(item => neededWidth += this.getFullWidth(item));
1883
+ neededWidth += (menuItems.length - 1) * parseFloat(getComputedStyle(this.element).fontSize);
1884
+ if (neededWidth > availableWidth) {
1885
+ this.showDropdownButton = true;
1886
+ var lastItem = menuItems[menuItems.length - 1];
1887
+ if (this.dropdown == undefined) {
1888
+ return;
1889
+ }
1890
+ lastItem.slot = "dropdown";
1891
+ this.moveItemsToDropDownIfNecessery();
1892
+ }
1893
+ }
1894
+ moveItemsToMenuIfPossible() {
1895
+ if (this.dropdown == undefined || !this.dropdown.hasChildNodes()) {
1896
+ return;
1897
+ }
1898
+ const menuItems = Array.from(this.menu.querySelector("slot").assignedElements());
1899
+ const availableWidth = this.menu.getBoundingClientRect().width;
1900
+ let neededWidth = parseFloat(getComputedStyle(this.element).fontSize) * 2;
1901
+ neededWidth += (menuItems.length - 1) * parseFloat(getComputedStyle(this.element).fontSize);
1902
+ menuItems.forEach(item => neededWidth += this.getFullWidth(item));
1903
+ const firstItem = this.dropdown.querySelector("slot").assignedElements()[0];
1904
+ if (firstItem != undefined) {
1905
+ neededWidth += this.getFullWidth(firstItem);
1906
+ }
1907
+ if (neededWidth < availableWidth) {
1908
+ if (firstItem != undefined) {
1909
+ firstItem.slot = "";
1910
+ }
1911
+ if (firstItem == undefined) {
1912
+ this.dropdown.classList.remove("visible");
1913
+ this.showDropdownMenu = false;
1914
+ this.showDropdownButton = false;
1915
+ }
1916
+ }
1917
+ }
1918
+ getFullWidth(item) {
1919
+ var width = item.getBoundingClientRect().width;
1920
+ var styles = getComputedStyle(item);
1921
+ width += parseFloat(styles.marginLeft);
1922
+ width += parseFloat(styles.marginRight);
1923
+ width += parseFloat(styles.paddingLeft);
1924
+ width += parseFloat(styles.paddingRight);
1925
+ return width;
1926
+ }
1927
+ toggleOverflowMenu() {
1928
+ this.showDropdownMenu = !this.showDropdownMenu;
1929
+ if (this.showDropdownMenu) {
1930
+ this.dropdown.classList.add("visible");
1931
+ let contentHeight = 0;
1932
+ const items = Array.from(this.dropdown.querySelector("slot").assignedElements());
1933
+ items.forEach(item => contentHeight += item.getBoundingClientRect().height);
1934
+ const emHeight = parseFloat(getComputedStyle(this.dropdown).fontSize);
1935
+ const gapsHeight = emHeight * (this.dropdown.children.length - 1) / 2;
1936
+ contentHeight += gapsHeight;
1937
+ const marginHeight = emHeight * 2;
1938
+ contentHeight += marginHeight;
1939
+ this.dropdown.style.height = `${contentHeight}px`;
1940
+ const dismissMenu = (e) => {
1941
+ const buttonRect = this.button.getBoundingClientRect();
1942
+ if (e.clientX < buttonRect.left ||
1943
+ e.clientX > buttonRect.right ||
1944
+ e.clientY < buttonRect.top ||
1945
+ e.clientY > buttonRect.bottom) {
1946
+ this.toggleOverflowMenu();
1947
+ }
1948
+ document.removeEventListener("click", dismissMenu);
1949
+ };
1950
+ setTimeout(() => {
1951
+ document.addEventListener("click", dismissMenu, false);
1952
+ }, 100);
1953
+ }
1954
+ else {
1955
+ this.dropdown.classList.remove("visible");
1956
+ this.dropdown.style.height = "0px";
1957
+ }
1958
+ }
1959
+ render() {
1960
+ return (h(Host, null, h("div", { class: "menu-container" }, h("div", { class: "menu", ref: el => this.menu = el }, h("slot", null)), this.showDropdownButton &&
1961
+ h("div", { class: "overflow" }, h("button", { ref: el => this.button = el, class: "icon", onClick: () => this.toggleOverflowMenu() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }))), h("div", { class: "dropdown", ref: el => this.dropdown = el }, h("slot", { name: "dropdown" }))))));
1962
+ }
1963
+ get element() { return getElement(this); }
1964
+ };
1652
1965
  DnnVerticalOverflowMenu.style = dnnVerticalOverflowMenuCss;
1653
1966
 
1654
1967
  const dnnVerticalSplitviewCss = ":host{display:-ms-flexbox;display:flex;-ms-flex-align:stretch;align-items:stretch;margin:0 auto;position:relative;--left-pane-background-color:transparent;--right-pane-background-color:transparent}button{border:none;margin:0;padding:0;cursor:ew-resize;position:absolute;height:100%;background-color:transparent}button.transition{-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out}.pane{overflow-y:auto}.pane.transition{-webkit-transition:all 300ms ease-in-out;transition:all 300ms ease-in-out}.pane.left{background-color:var(--left-pane-background-color)}.pane.right{background-color:var(--right-pane-background-color);-ms-flex-positive:1;flex-grow:1}";
1655
1968
 
1656
- let DnnVerticalSplitview = class {
1657
- constructor(hostRef) {
1658
- registerInstance(this, hostRef);
1659
- this.widthChanged = createEvent(this, "widthChanged", 7);
1660
- /** The width of the splitter area. */
1661
- this.splitterWidth = 16;
1662
- /** The percentage position of the splitter in the container. */
1663
- this.splitWidthPercentage = 30;
1664
- this.leftWidth = 0;
1665
- this.rightWidth = 0;
1666
- }
1667
- /** Sets the width percentage of the divider */
1668
- async setSplitWidthPercentage(newWidth) {
1669
- const panes = this.element.shadowRoot.querySelectorAll(".pane");
1670
- requestAnimationFrame(() => {
1671
- panes.forEach(pane => pane.classList.add("transition"));
1672
- this.splitter.classList.add("transition");
1673
- requestAnimationFrame(() => {
1674
- const fullWidth = this.element.getBoundingClientRect().width;
1675
- let newLeft = fullWidth * newWidth / 100;
1676
- if (newLeft < 0) {
1677
- newLeft = 0;
1678
- }
1679
- if (newLeft > fullWidth) {
1680
- newLeft = fullWidth;
1681
- }
1682
- this.leftWidth = newLeft;
1683
- this.rightWidth = fullWidth - newLeft;
1684
- setTimeout(() => {
1685
- panes.forEach(pane => pane.classList.remove("transition"));
1686
- this.splitter.classList.remove("transition");
1687
- }, 300);
1688
- });
1689
- });
1690
- }
1691
- /** Gets the current divider position percentage. */
1692
- async getSplitWidthPercentage() {
1693
- const fullWidth = this.element.getBoundingClientRect().width;
1694
- return this.leftWidth / fullWidth;
1695
- }
1696
- componentDidLoad() {
1697
- requestAnimationFrame(() => {
1698
- this.resizeObserver = new ResizeObserver(() => {
1699
- const fullWidth = this.element.getBoundingClientRect().width;
1700
- this.leftWidth = fullWidth * this.splitWidthPercentage / 100;
1701
- this.rightWidth = fullWidth - this.leftWidth;
1702
- this.widthChanged.emit(this.splitWidthPercentage);
1703
- });
1704
- this.resizeObserver.observe(this.element);
1705
- });
1706
- }
1707
- handleMouseDown(event) {
1708
- event.preventDefault();
1709
- const handleDrag = (ev) => {
1710
- requestAnimationFrame(() => {
1711
- let fullWidth = this.element.getBoundingClientRect().width;
1712
- let { movementX } = getMovementFromEvent(ev, this.previousTouch);
1713
- let newLeft = this.leftWidth + movementX;
1714
- if (newLeft < 0) {
1715
- newLeft = 0;
1716
- }
1717
- if (newLeft > fullWidth) {
1718
- newLeft = fullWidth;
1719
- }
1720
- this.leftWidth = newLeft;
1721
- this.rightWidth = fullWidth - newLeft;
1722
- this.splitWidthPercentage = this.leftWidth / fullWidth * 100;
1723
- });
1724
- };
1725
- const handleDragFinished = () => {
1726
- document.removeEventListener("mousemove", handleDrag);
1727
- document.removeEventListener("touchmove", handleDrag);
1728
- const fullWidth = this.element.getBoundingClientRect().width;
1729
- const newPercentage = this.leftWidth / fullWidth * 100;
1730
- this.widthChanged.emit(newPercentage);
1731
- };
1732
- document.addEventListener("mouseup", handleDragFinished);
1733
- document.addEventListener("touchend", handleDragFinished);
1734
- document.addEventListener("mousemove", handleDrag);
1735
- document.addEventListener("touchmove", handleDrag);
1736
- }
1737
- handleKeyDown(e) {
1738
- let movementX = 0;
1739
- switch (e.key) {
1740
- case "ArrowLeft":
1741
- movementX = -10;
1742
- break;
1743
- case "ArrowRight":
1744
- movementX = 10;
1745
- break;
1746
- default:
1747
- return;
1748
- }
1749
- if (e.shiftKey) {
1750
- movementX = movementX * 10;
1751
- }
1752
- const fullWidth = this.element.getBoundingClientRect().width;
1753
- let newLeft = this.leftWidth + movementX;
1754
- if (newLeft < 0) {
1755
- newLeft = 0;
1756
- }
1757
- if (newLeft > fullWidth) {
1758
- newLeft = fullWidth;
1759
- }
1760
- this.leftWidth = newLeft;
1761
- this.rightWidth = fullWidth - this.leftWidth;
1762
- }
1763
- render() {
1764
- return (h(Host, null, h("div", { class: "left pane", style: {
1765
- width: `${this.leftWidth}px`,
1766
- } }, h("slot", { name: "left" })), h("button", { onMouseDown: e => this.handleMouseDown(e), onTouchStart: e => this.handleMouseDown(e), onKeyDown: e => this.handleKeyDown(e), ref: el => this.splitter = el, style: {
1767
- minWidth: `${this.splitterWidth.toString()}px`,
1768
- left: `${this.leftWidth - 2}px`,
1769
- } }, h("slot", null)), h("div", { class: "right pane", style: {
1770
- width: `${this.rightWidth}px`,
1771
- } }, h("slot", { name: "right" }))));
1772
- }
1773
- get element() { return getElement(this); }
1774
- };
1969
+ const DnnVerticalSplitview = class {
1970
+ constructor(hostRef) {
1971
+ registerInstance(this, hostRef);
1972
+ this.widthChanged = createEvent(this, "widthChanged", 7);
1973
+ /** The width of the splitter area. */
1974
+ this.splitterWidth = 16;
1975
+ /** The percentage position of the splitter in the container. */
1976
+ this.splitWidthPercentage = 30;
1977
+ this.leftWidth = 0;
1978
+ this.rightWidth = 0;
1979
+ }
1980
+ /** Sets the width percentage of the divider */
1981
+ async setSplitWidthPercentage(newWidth) {
1982
+ const panes = this.element.shadowRoot.querySelectorAll(".pane");
1983
+ requestAnimationFrame(() => {
1984
+ panes.forEach(pane => pane.classList.add("transition"));
1985
+ this.splitter.classList.add("transition");
1986
+ requestAnimationFrame(() => {
1987
+ const fullWidth = this.element.getBoundingClientRect().width;
1988
+ let newLeft = fullWidth * newWidth / 100;
1989
+ if (newLeft < 0) {
1990
+ newLeft = 0;
1991
+ }
1992
+ if (newLeft > fullWidth) {
1993
+ newLeft = fullWidth;
1994
+ }
1995
+ this.leftWidth = newLeft;
1996
+ this.rightWidth = fullWidth - newLeft;
1997
+ setTimeout(() => {
1998
+ panes.forEach(pane => pane.classList.remove("transition"));
1999
+ this.splitter.classList.remove("transition");
2000
+ }, 300);
2001
+ });
2002
+ });
2003
+ }
2004
+ /** Gets the current divider position percentage. */
2005
+ async getSplitWidthPercentage() {
2006
+ const fullWidth = this.element.getBoundingClientRect().width;
2007
+ return this.leftWidth / fullWidth;
2008
+ }
2009
+ componentDidLoad() {
2010
+ requestAnimationFrame(() => {
2011
+ this.resizeObserver = new ResizeObserver(() => {
2012
+ const fullWidth = this.element.getBoundingClientRect().width;
2013
+ this.leftWidth = fullWidth * this.splitWidthPercentage / 100;
2014
+ this.rightWidth = fullWidth - this.leftWidth;
2015
+ this.widthChanged.emit(this.splitWidthPercentage);
2016
+ });
2017
+ this.resizeObserver.observe(this.element);
2018
+ });
2019
+ }
2020
+ handleMouseDown(event) {
2021
+ event.preventDefault();
2022
+ const handleDrag = (ev) => {
2023
+ requestAnimationFrame(() => {
2024
+ let fullWidth = this.element.getBoundingClientRect().width;
2025
+ let { movementX } = getMovementFromEvent(ev, this.previousTouch);
2026
+ let newLeft = this.leftWidth + movementX;
2027
+ if (newLeft < 0) {
2028
+ newLeft = 0;
2029
+ }
2030
+ if (newLeft > fullWidth) {
2031
+ newLeft = fullWidth;
2032
+ }
2033
+ this.leftWidth = newLeft;
2034
+ this.rightWidth = fullWidth - newLeft;
2035
+ this.splitWidthPercentage = this.leftWidth / fullWidth * 100;
2036
+ });
2037
+ };
2038
+ const handleDragFinished = () => {
2039
+ document.removeEventListener("mousemove", handleDrag);
2040
+ document.removeEventListener("touchmove", handleDrag);
2041
+ const fullWidth = this.element.getBoundingClientRect().width;
2042
+ const newPercentage = this.leftWidth / fullWidth * 100;
2043
+ this.widthChanged.emit(newPercentage);
2044
+ };
2045
+ document.addEventListener("mouseup", handleDragFinished);
2046
+ document.addEventListener("touchend", handleDragFinished);
2047
+ document.addEventListener("mousemove", handleDrag);
2048
+ document.addEventListener("touchmove", handleDrag);
2049
+ }
2050
+ handleKeyDown(e) {
2051
+ let movementX = 0;
2052
+ switch (e.key) {
2053
+ case "ArrowLeft":
2054
+ movementX = -10;
2055
+ break;
2056
+ case "ArrowRight":
2057
+ movementX = 10;
2058
+ break;
2059
+ default:
2060
+ return;
2061
+ }
2062
+ if (e.shiftKey) {
2063
+ movementX = movementX * 10;
2064
+ }
2065
+ const fullWidth = this.element.getBoundingClientRect().width;
2066
+ let newLeft = this.leftWidth + movementX;
2067
+ if (newLeft < 0) {
2068
+ newLeft = 0;
2069
+ }
2070
+ if (newLeft > fullWidth) {
2071
+ newLeft = fullWidth;
2072
+ }
2073
+ this.leftWidth = newLeft;
2074
+ this.rightWidth = fullWidth - this.leftWidth;
2075
+ }
2076
+ render() {
2077
+ return (h(Host, null, h("div", { class: "left pane", style: {
2078
+ width: `${this.leftWidth}px`,
2079
+ } }, h("slot", { name: "left" })), h("button", { onMouseDown: e => this.handleMouseDown(e), onTouchStart: e => this.handleMouseDown(e), onKeyDown: e => this.handleKeyDown(e), ref: el => this.splitter = el, style: {
2080
+ minWidth: `${this.splitterWidth.toString()}px`,
2081
+ left: `${this.leftWidth - 2}px`,
2082
+ } }, h("slot", null)), h("div", { class: "right pane", style: {
2083
+ width: `${this.rightWidth}px`,
2084
+ } }, h("slot", { name: "right" }))));
2085
+ }
2086
+ get element() { return getElement(this); }
2087
+ };
1775
2088
  DnnVerticalSplitview.style = dnnVerticalSplitviewCss;
1776
2089
 
1777
- export { DnnButton as dnn_button, DnnCheckbox as dnn_checkbox, DnnChevron as dnn_chevron, DnnCollapsible as dnn_collapsible, DnnColorPicker as dnn_color_picker, DnnDropzone as dnn_dropzone, DnnImageCropper as dnn_image_cropper, DnnModal as dnn_modal, DnnSearchbox as dnn_searchbox, DnnSortIcon as dnn_sort_icon, DnnTab as dnn_tab, DnnTabs as dnn_tabs, DnnToggle as dnn_toggle, DnnTreeviewItem as dnn_treeview_item, DnnVerticalOverflowMenu as dnn_vertical_overflow_menu, DnnVerticalSplitview as dnn_vertical_splitview };
2090
+ export { DnnButton as dnn_button, DnnCheckbox as dnn_checkbox, DnnChevron as dnn_chevron, DnnCollapsible as dnn_collapsible, DnnColorPicker as dnn_color_picker, DnnDropzone as dnn_dropzone, DnnImageCropper as dnn_image_cropper, DnnModal as dnn_modal, DnnPermissionsGrid as dnn_permissions_grid, DnnSearchbox as dnn_searchbox, DnnSortIcon as dnn_sort_icon, DnnTab as dnn_tab, DnnTabs as dnn_tabs, DnnToggle as dnn_toggle, DnnTreeviewItem as dnn_treeview_item, DnnVerticalOverflowMenu as dnn_vertical_overflow_menu, DnnVerticalSplitview as dnn_vertical_splitview };
1778
2091
 
1779
- //# sourceMappingURL=dnn-button_16.entry.js.map
2092
+ //# sourceMappingURL=dnn-button_17.entry.js.map