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