@dnncommunity/dnn-elements 0.15.0-beta.7 → 0.15.0

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 (221) hide show
  1. package/dist/cjs/dnn-button_17.cjs.entry.js +1 -1
  2. package/dist/cjs/dnn-button_17.cjs.entry.js.map +1 -1
  3. package/dist/cjs/dnn.cjs.js +4 -116
  4. package/dist/cjs/dnn.cjs.js.map +1 -1
  5. package/dist/cjs/loader.cjs.js +2 -18
  6. package/dist/cjs/loader.cjs.js.map +1 -1
  7. package/dist/collection/components/dnn-tabs/dnn-tabs.css +0 -1
  8. package/dist/collection/components/dnn-tabs/dnn-tabs.stories.js +5 -0
  9. package/dist/collection/components/dnn-tabs/dnn-tabs.stories.js.map +1 -1
  10. package/dist/dnn/dnn.esm.js +1 -130
  11. package/dist/dnn/dnn.esm.js.map +1 -1
  12. package/dist/dnn/dnn.js +1 -1
  13. package/dist/dnn/index.esm.js +1 -46
  14. package/dist/dnn/index.esm.js.map +1 -1
  15. package/dist/dnn/{p-c222c8b7.entry.js → p-058a3145.entry.js} +2 -2
  16. package/dist/dnn/{p-c222c8b7.entry.js.map → p-058a3145.entry.js.map} +1 -1
  17. package/dist/dnn/{p-31dc68a7.system.entry.js → p-1893c229.system.entry.js} +2 -2
  18. package/dist/dnn/{p-31dc68a7.system.entry.js.map → p-1893c229.system.entry.js.map} +1 -1
  19. package/dist/dnn/p-5bcf3629.system.js +1 -1
  20. package/dist/esm/dnn-button_17.entry.js +1 -1
  21. package/dist/esm/dnn-button_17.entry.js.map +1 -1
  22. package/dist/esm/dnn.js +4 -116
  23. package/dist/esm/dnn.js.map +1 -1
  24. package/dist/esm/loader.js +2 -18
  25. package/dist/esm/loader.js.map +1 -1
  26. package/dist/esm-es5/dnn-button_17.entry.js +1 -1
  27. package/dist/esm-es5/dnn-button_17.entry.js.map +1 -1
  28. package/dist/index.js +1 -1
  29. package/package.json +6 -3
  30. package/dist/cjs/app-globals-3a1e7e63.js +0 -7
  31. package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
  32. package/dist/cjs/css-shim-aaf4fec9.js +0 -8
  33. package/dist/cjs/css-shim-aaf4fec9.js.map +0 -1
  34. package/dist/cjs/dnn-button.cjs.entry.js +0 -92
  35. package/dist/cjs/dnn-button.cjs.entry.js.map +0 -1
  36. package/dist/cjs/dnn-checkbox.cjs.entry.js +0 -58
  37. package/dist/cjs/dnn-checkbox.cjs.entry.js.map +0 -1
  38. package/dist/cjs/dnn-chevron.cjs.entry.js +0 -34
  39. package/dist/cjs/dnn-chevron.cjs.entry.js.map +0 -1
  40. package/dist/cjs/dnn-collapsible.cjs.entry.js +0 -69
  41. package/dist/cjs/dnn-collapsible.cjs.entry.js.map +0 -1
  42. package/dist/cjs/dnn-color-picker.cjs.entry.js +0 -508
  43. package/dist/cjs/dnn-color-picker.cjs.entry.js.map +0 -1
  44. package/dist/cjs/dnn-dropzone.cjs.entry.js +0 -153
  45. package/dist/cjs/dnn-dropzone.cjs.entry.js.map +0 -1
  46. package/dist/cjs/dnn-image-cropper.cjs.entry.js +0 -408
  47. package/dist/cjs/dnn-image-cropper.cjs.entry.js.map +0 -1
  48. package/dist/cjs/dnn-modal.cjs.entry.js +0 -65
  49. package/dist/cjs/dnn-modal.cjs.entry.js.map +0 -1
  50. package/dist/cjs/dnn-permissions-grid.cjs.entry.js +0 -320
  51. package/dist/cjs/dnn-permissions-grid.cjs.entry.js.map +0 -1
  52. package/dist/cjs/dnn-searchbox.cjs.entry.js +0 -66
  53. package/dist/cjs/dnn-searchbox.cjs.entry.js.map +0 -1
  54. package/dist/cjs/dnn-sort-icon.cjs.entry.js +0 -43
  55. package/dist/cjs/dnn-sort-icon.cjs.entry.js.map +0 -1
  56. package/dist/cjs/dnn-tab.cjs.entry.js +0 -31
  57. package/dist/cjs/dnn-tab.cjs.entry.js.map +0 -1
  58. package/dist/cjs/dnn-tabs.cjs.entry.js +0 -52
  59. package/dist/cjs/dnn-tabs.cjs.entry.js.map +0 -1
  60. package/dist/cjs/dnn-toggle.cjs.entry.js +0 -37
  61. package/dist/cjs/dnn-toggle.cjs.entry.js.map +0 -1
  62. package/dist/cjs/dnn-treeview-item.cjs.entry.js +0 -68
  63. package/dist/cjs/dnn-treeview-item.cjs.entry.js.map +0 -1
  64. package/dist/cjs/dnn-vertical-overflow-menu.cjs.entry.js +0 -124
  65. package/dist/cjs/dnn-vertical-overflow-menu.cjs.entry.js.map +0 -1
  66. package/dist/cjs/dnn-vertical-splitview.cjs.entry.js +0 -133
  67. package/dist/cjs/dnn-vertical-splitview.cjs.entry.js.map +0 -1
  68. package/dist/cjs/dom-14886762.js +0 -77
  69. package/dist/cjs/dom-14886762.js.map +0 -1
  70. package/dist/cjs/index-d53702a3.js +0 -3095
  71. package/dist/cjs/index-d53702a3.js.map +0 -1
  72. package/dist/cjs/mouseUtilities-ecd5ecf7.js +0 -25
  73. package/dist/cjs/mouseUtilities-ecd5ecf7.js.map +0 -1
  74. package/dist/cjs/shadow-css-c44ea13a.js +0 -392
  75. package/dist/cjs/shadow-css-c44ea13a.js.map +0 -1
  76. package/dist/dnn/app-globals-0f993ce5.js +0 -5
  77. package/dist/dnn/app-globals-0f993ce5.js.map +0 -1
  78. package/dist/dnn/app-globals-497eb362.system.js +0 -2
  79. package/dist/dnn/app-globals-497eb362.system.js.map +0 -1
  80. package/dist/dnn/css-shim-091f949f.js +0 -6
  81. package/dist/dnn/css-shim-091f949f.js.map +0 -1
  82. package/dist/dnn/css-shim-c5bffe6b.system.js +0 -2
  83. package/dist/dnn/css-shim-c5bffe6b.system.js.map +0 -1
  84. package/dist/dnn/debounce-6be67abd.js +0 -22
  85. package/dist/dnn/debounce-6be67abd.js.map +0 -1
  86. package/dist/dnn/debounce-db438a09.system.js +0 -2
  87. package/dist/dnn/debounce-db438a09.system.js.map +0 -1
  88. package/dist/dnn/dnn-button.entry.js +0 -88
  89. package/dist/dnn/dnn-button.entry.js.map +0 -1
  90. package/dist/dnn/dnn-button.system.entry.js +0 -2
  91. package/dist/dnn/dnn-button.system.entry.js.map +0 -1
  92. package/dist/dnn/dnn-checkbox.entry.js +0 -54
  93. package/dist/dnn/dnn-checkbox.entry.js.map +0 -1
  94. package/dist/dnn/dnn-checkbox.system.entry.js +0 -2
  95. package/dist/dnn/dnn-checkbox.system.entry.js.map +0 -1
  96. package/dist/dnn/dnn-chevron.entry.js +0 -30
  97. package/dist/dnn/dnn-chevron.entry.js.map +0 -1
  98. package/dist/dnn/dnn-chevron.system.entry.js +0 -2
  99. package/dist/dnn/dnn-chevron.system.entry.js.map +0 -1
  100. package/dist/dnn/dnn-collapsible.entry.js +0 -65
  101. package/dist/dnn/dnn-collapsible.entry.js.map +0 -1
  102. package/dist/dnn/dnn-collapsible.system.entry.js +0 -2
  103. package/dist/dnn/dnn-collapsible.system.entry.js.map +0 -1
  104. package/dist/dnn/dnn-color-picker.entry.js +0 -504
  105. package/dist/dnn/dnn-color-picker.entry.js.map +0 -1
  106. package/dist/dnn/dnn-color-picker.system.entry.js +0 -12
  107. package/dist/dnn/dnn-color-picker.system.entry.js.map +0 -1
  108. package/dist/dnn/dnn-dropzone.entry.js +0 -149
  109. package/dist/dnn/dnn-dropzone.entry.js.map +0 -1
  110. package/dist/dnn/dnn-dropzone.system.entry.js +0 -2
  111. package/dist/dnn/dnn-dropzone.system.entry.js.map +0 -1
  112. package/dist/dnn/dnn-image-cropper.entry.js +0 -404
  113. package/dist/dnn/dnn-image-cropper.entry.js.map +0 -1
  114. package/dist/dnn/dnn-image-cropper.system.entry.js +0 -2
  115. package/dist/dnn/dnn-image-cropper.system.entry.js.map +0 -1
  116. package/dist/dnn/dnn-modal.entry.js +0 -61
  117. package/dist/dnn/dnn-modal.entry.js.map +0 -1
  118. package/dist/dnn/dnn-modal.system.entry.js +0 -2
  119. package/dist/dnn/dnn-modal.system.entry.js.map +0 -1
  120. package/dist/dnn/dnn-permissions-grid.entry.js +0 -316
  121. package/dist/dnn/dnn-permissions-grid.entry.js.map +0 -1
  122. package/dist/dnn/dnn-permissions-grid.system.entry.js +0 -2
  123. package/dist/dnn/dnn-permissions-grid.system.entry.js.map +0 -1
  124. package/dist/dnn/dnn-searchbox.entry.js +0 -62
  125. package/dist/dnn/dnn-searchbox.entry.js.map +0 -1
  126. package/dist/dnn/dnn-searchbox.system.entry.js +0 -2
  127. package/dist/dnn/dnn-searchbox.system.entry.js.map +0 -1
  128. package/dist/dnn/dnn-sort-icon.entry.js +0 -39
  129. package/dist/dnn/dnn-sort-icon.entry.js.map +0 -1
  130. package/dist/dnn/dnn-sort-icon.system.entry.js +0 -2
  131. package/dist/dnn/dnn-sort-icon.system.entry.js.map +0 -1
  132. package/dist/dnn/dnn-tab.entry.js +0 -27
  133. package/dist/dnn/dnn-tab.entry.js.map +0 -1
  134. package/dist/dnn/dnn-tab.system.entry.js +0 -2
  135. package/dist/dnn/dnn-tab.system.entry.js.map +0 -1
  136. package/dist/dnn/dnn-tabs.entry.js +0 -48
  137. package/dist/dnn/dnn-tabs.entry.js.map +0 -1
  138. package/dist/dnn/dnn-tabs.system.entry.js +0 -2
  139. package/dist/dnn/dnn-tabs.system.entry.js.map +0 -1
  140. package/dist/dnn/dnn-toggle.entry.js +0 -33
  141. package/dist/dnn/dnn-toggle.entry.js.map +0 -1
  142. package/dist/dnn/dnn-toggle.system.entry.js +0 -2
  143. package/dist/dnn/dnn-toggle.system.entry.js.map +0 -1
  144. package/dist/dnn/dnn-treeview-item.entry.js +0 -64
  145. package/dist/dnn/dnn-treeview-item.entry.js.map +0 -1
  146. package/dist/dnn/dnn-treeview-item.system.entry.js +0 -2
  147. package/dist/dnn/dnn-treeview-item.system.entry.js.map +0 -1
  148. package/dist/dnn/dnn-vertical-overflow-menu.entry.js +0 -120
  149. package/dist/dnn/dnn-vertical-overflow-menu.entry.js.map +0 -1
  150. package/dist/dnn/dnn-vertical-overflow-menu.system.entry.js +0 -2
  151. package/dist/dnn/dnn-vertical-overflow-menu.system.entry.js.map +0 -1
  152. package/dist/dnn/dnn-vertical-splitview.entry.js +0 -129
  153. package/dist/dnn/dnn-vertical-splitview.entry.js.map +0 -1
  154. package/dist/dnn/dnn-vertical-splitview.system.entry.js +0 -2
  155. package/dist/dnn/dnn-vertical-splitview.system.entry.js.map +0 -1
  156. package/dist/dnn/dnn.system.js +0 -2
  157. package/dist/dnn/dnn.system.js.map +0 -1
  158. package/dist/dnn/dom-99eb7b76.system.js +0 -22
  159. package/dist/dnn/dom-99eb7b76.system.js.map +0 -1
  160. package/dist/dnn/dom-a385e381.js +0 -75
  161. package/dist/dnn/dom-a385e381.js.map +0 -1
  162. package/dist/dnn/index-20e42ad7.js +0 -3059
  163. package/dist/dnn/index-20e42ad7.js.map +0 -1
  164. package/dist/dnn/index-c3cc3b5b.system.js +0 -2
  165. package/dist/dnn/index-c3cc3b5b.system.js.map +0 -1
  166. package/dist/dnn/index.system.js +0 -2
  167. package/dist/dnn/index.system.js.map +0 -1
  168. package/dist/dnn/mouseUtilities-233ad7e3.system.js +0 -2
  169. package/dist/dnn/mouseUtilities-233ad7e3.system.js.map +0 -1
  170. package/dist/dnn/mouseUtilities-b261ca4f.js +0 -23
  171. package/dist/dnn/mouseUtilities-b261ca4f.js.map +0 -1
  172. package/dist/dnn/shadow-css-27708fdd.system.js +0 -14
  173. package/dist/dnn/shadow-css-27708fdd.system.js.map +0 -1
  174. package/dist/dnn/shadow-css-ef431969.js +0 -390
  175. package/dist/dnn/shadow-css-ef431969.js.map +0 -1
  176. package/dist/esm/app-globals-0f993ce5.js +0 -5
  177. package/dist/esm/app-globals-0f993ce5.js.map +0 -1
  178. package/dist/esm/css-shim-091f949f.js +0 -6
  179. package/dist/esm/css-shim-091f949f.js.map +0 -1
  180. package/dist/esm/dnn-button.entry.js +0 -88
  181. package/dist/esm/dnn-button.entry.js.map +0 -1
  182. package/dist/esm/dnn-checkbox.entry.js +0 -54
  183. package/dist/esm/dnn-checkbox.entry.js.map +0 -1
  184. package/dist/esm/dnn-chevron.entry.js +0 -30
  185. package/dist/esm/dnn-chevron.entry.js.map +0 -1
  186. package/dist/esm/dnn-collapsible.entry.js +0 -65
  187. package/dist/esm/dnn-collapsible.entry.js.map +0 -1
  188. package/dist/esm/dnn-color-picker.entry.js +0 -504
  189. package/dist/esm/dnn-color-picker.entry.js.map +0 -1
  190. package/dist/esm/dnn-dropzone.entry.js +0 -149
  191. package/dist/esm/dnn-dropzone.entry.js.map +0 -1
  192. package/dist/esm/dnn-image-cropper.entry.js +0 -404
  193. package/dist/esm/dnn-image-cropper.entry.js.map +0 -1
  194. package/dist/esm/dnn-modal.entry.js +0 -61
  195. package/dist/esm/dnn-modal.entry.js.map +0 -1
  196. package/dist/esm/dnn-permissions-grid.entry.js +0 -316
  197. package/dist/esm/dnn-permissions-grid.entry.js.map +0 -1
  198. package/dist/esm/dnn-searchbox.entry.js +0 -62
  199. package/dist/esm/dnn-searchbox.entry.js.map +0 -1
  200. package/dist/esm/dnn-sort-icon.entry.js +0 -39
  201. package/dist/esm/dnn-sort-icon.entry.js.map +0 -1
  202. package/dist/esm/dnn-tab.entry.js +0 -27
  203. package/dist/esm/dnn-tab.entry.js.map +0 -1
  204. package/dist/esm/dnn-tabs.entry.js +0 -48
  205. package/dist/esm/dnn-tabs.entry.js.map +0 -1
  206. package/dist/esm/dnn-toggle.entry.js +0 -33
  207. package/dist/esm/dnn-toggle.entry.js.map +0 -1
  208. package/dist/esm/dnn-treeview-item.entry.js +0 -64
  209. package/dist/esm/dnn-treeview-item.entry.js.map +0 -1
  210. package/dist/esm/dnn-vertical-overflow-menu.entry.js +0 -120
  211. package/dist/esm/dnn-vertical-overflow-menu.entry.js.map +0 -1
  212. package/dist/esm/dnn-vertical-splitview.entry.js +0 -129
  213. package/dist/esm/dnn-vertical-splitview.entry.js.map +0 -1
  214. package/dist/esm/dom-a385e381.js +0 -75
  215. package/dist/esm/dom-a385e381.js.map +0 -1
  216. package/dist/esm/index-20e42ad7.js +0 -3059
  217. package/dist/esm/index-20e42ad7.js.map +0 -1
  218. package/dist/esm/mouseUtilities-b261ca4f.js +0 -23
  219. package/dist/esm/mouseUtilities-b261ca4f.js.map +0 -1
  220. package/dist/esm/shadow-css-ef431969.js +0 -390
  221. package/dist/esm/shadow-css-ef431969.js.map +0 -1
@@ -1,12 +0,0 @@
1
- System.register(["./index-c3cc3b5b.system.js","./debounce-db438a09.system.js"],(function(e){"use strict";var n,t,o,r,i;return{setters:[function(e){n=e.r;t=e.e;o=e.h;r=e.g},function(e){i=e.D}],execute:function(){
2
- /** Color utility class with hsl and rgb converters
3
- * based on math at https://en.wikipedia.org/wiki/HSL_and_HSV
4
- * @copyright Copyright (c) .NET Foundation. All rights reserved.
5
- * @license MIT
6
- */
7
- var l=function(){function e(){this._hue=0;this._saturation=0;this._lightness=0}Object.defineProperty(e.prototype,"hue",{get:function(){return this._hue},set:function(e){if(e<0){e=0}if(e>359){e=359}this._hue=e},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"saturation",{get:function(){return this._saturation},set:function(e){if(e<0){e=0}if(e>1){e=1}this._saturation=e},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"lightness",{get:function(){return this._lightness},set:function(e){if(e<0){e=0}if(e>1){e=1}this._lightness=e},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"red",{get:function(){return this.getRGB().red},set:function(e){this.setHSL(e,this.green,this.blue)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"green",{get:function(){return this.getRGB().green},set:function(e){this.setHSL(this.red,e,this.blue)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"blue",{get:function(){return this.getRGB().blue},set:function(e){this.setHSL(this.red,this.green,e)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"hex",{get:function(){var e=this.getHex(this.red);var n=this.getHex(this.green);var t=this.getHex(this.blue);return e+n+t},set:function(e){this.red=parseInt(e.substr(0,2));this.green=parseInt(e.substr(2,2));this.blue=parseInt(e.substr(4,2))},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"contrastColor",{get:function(){var e=(this.red*299+this.green*587+this.blue*114)/1e3;if(e>127){return"000000"}return"FFFFFF"},enumerable:false,configurable:true});e.prototype.getRGB=function(){var e=(1-Math.abs(2*this._lightness-1))*this.saturation;var n=this._hue/60;var t=e*(1-Math.abs(n%2-1));var o=0,r=0,i=0;if(0<=n&&n<=1){o=e;r=t}else if(1<=n&&n<=2){r=e;o=t}else if(2<=n&&n<=3){r=e;i=t}else if(3<=n&&n<=4){i=e;r=t}else if(4<=n&&n<=5){i=e;o=t}else if(5<=n&&n<=6){o=e;i=t}var l=this._lightness-e/2;return{red:Math.round((o+l)*255),green:Math.round((r+l)*255),blue:Math.round((i+l)*255)}};e.prototype.setHSL=function(e,n,t){var o=e/255,r=n/255,i=t/255;var l=Math.min(o,r,i);var s=Math.max(o,r,i);var a=s-l;var d=0,c=0,u=0;if(a===0){d=0}else if(s===o){d=60*((r-i)/a)}else if(s===r){d=60*(2+(i-o)/a)}else if(s===i){d=60*(4+(o-r)/a)}if(d<0){d=d+360}if(d>359){d=359}u=(s+l)/2;if(s===0||l===1){c=0}else{c=(s-u)/Math.min(u,1-u)}this._hue=d;this._saturation=c;this._lightness=u};e.prototype.getHex=function(e){var n=e.toString(16);if(n.length<2){n="0"+n}return n};return e}();var s='.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}';
8
- /** Reusable DNN UI component to pick a color
9
- * @copyright Copyright (c) .NET Foundation. All rights reserved.
10
- * @license MIT
11
- */var a=undefined&&undefined.__decorate||function(e,n,t,o){var r=arguments.length,i=r<3?n:o===null?o=Object.getOwnPropertyDescriptor(n,t):o,l;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")i=Reflect.decorate(e,n,t,o);else for(var s=e.length-1;s>=0;s--)if(l=e[s])i=(r<3?l(i):r>3?l(n,t,i):l(n,t))||i;return r>3&&i&&Object.defineProperty(n,t,i),i};var d=e("dnn_color_picker",function(){function e(e){var o=this;n(this,e);this.colorChanged=t(this,"colorChanged",7);this.color="FFFFFF";this.colorBoxHeight="50%";this.rgbDisplay="flex";this.hslDisplay="none";this.hexDisplay="none";this.handleSaturationLightnessMouseDown=function(e){e.preventDefault();o.handleDragLightnessSaturation(e);window.addEventListener("mousemove",o.handleDragLightnessSaturation);window.addEventListener("mouseup",o.handleSaturationLightnessMouseUp)};this.handleDragLightnessSaturation=function(e){var n=o.saturationLightnessBox.getBoundingClientRect();var t=e.clientX-n.left;if(t<0){t=0}if(t>n.width){t=n.width}t=t/n.width;var r=e.clientY-n.top;if(r<0){r=0}if(r>n.height){r=n.height}r=1-r/n.height;var i=new l;i.hue=o.currentColor.hue;i.saturation=t;i.lightness=r;o.currentColor=i};this.handleSaturationLightnessMouseUp=function(){window.removeEventListener("mousemove",o.handleDragLightnessSaturation);window.removeEventListener("mouseup",o.handleSaturationLightnessMouseUp)};this.handleHueMouseDown=function(e){e.preventDefault();o.handleDragHue(e);window.addEventListener("mousemove",o.handleDragHue);window.addEventListener("mouseup",o.handleHueMouseUp)};this.handleHueMouseUp=function(){window.removeEventListener("mousemove",o.handleDragHue);window.removeEventListener("mouseup",o.handleHueMouseUp)};this.handleDragHue=function(e){var n=o.hueRange.getBoundingClientRect();var t=e.clientX-n.left;if(t<0){t=0}if(t>n.width){t=n.width}t=t/n.width*360;var r=new l;r.hue=t;r.saturation=o.currentColor.saturation;r.lightness=o.currentColor.lightness;o.currentColor=r};this.handleComponentValueChange=function(e,n){var t=parseInt(e.target.value);if(isNaN(t)){return}var r=new l;if(t<0){t=0}if(t>255){t=255}var i=o.currentColor.red;var s=o.currentColor.green;var a=o.currentColor.blue;switch(n){case"red":i=t;break;case"green":s=t;break;case"blue":a=t;break;default:break}r.green=s;r.red=i;r.blue=a;o.currentColor=r};this.handleHSLChange=function(e,n){var t=parseInt(e.target.value);if(isNaN(t)){return}var r=new l;if(t!=null){var i=o.currentColor.hue;var s=o.currentColor.saturation;var a=o.currentColor.lightness;switch(n){case"hue":if(t<0){t=0}if(t>359){t=0}i=t;break;case"saturation":if(t<0){t=0}if(t>100){t=100}s=t/100;break;case"lightness":if(t<0){t=0}if(t>100){t=100}a=t/100;break;default:break}r.hue=i;r.saturation=s;r.lightness=a;o.currentColor=r}};this.handleSaturationLightnessKeyDown=function(e){var n=new l;n.hue=o.currentColor.hue;n.saturation=o.currentColor.saturation;n.lightness=o.currentColor.lightness;var t=.01;if(e.shiftKey){t=.1}switch(e.key){case"ArrowUp":n.lightness+=t;break;case"ArrowDown":n.lightness-=t;break;case"ArrowLeft":n.saturation-=t;break;case"ArrowRight":n.saturation+=t;default:break}o.currentColor=n};this.handleHueKeyDown=function(e){var n=new l;n.hue=o.currentColor.hue;n.saturation=o.currentColor.saturation;n.lightness=o.currentColor.lightness;var t=1;if(e.shiftKey){t=10}switch(e.key){case"ArrowLeft":n.hue-=t;break;case"ArrowRight":n.hue+=t;default:break}o.currentColor=n}}e.prototype.colorChangedHandler=function(e){this.colorChanged.emit(e)};e.prototype.handeCurrentColorChanged=function(e){this.colorChangedHandler(e)};e.prototype.componentWillLoad=function(){this.handleHexChange(this.color)};e.prototype.componentDidLoad=function(){this.el.style.setProperty("--color-box-height",this.colorBoxHeight.toString())};e.prototype.getHex=function(){return this.getDoublet(this.currentColor.red)+this.getDoublet(this.currentColor.green)+this.getDoublet(this.currentColor.blue)};e.prototype.getContrast=function(){return this.currentColor.contrastColor};e.prototype.getDoublet=function(e){var n=e.toString(16).toUpperCase();if(n.length===1){return"0"+n}return n};e.prototype.handleHexChange=function(e){var n=new l;if(e.match(/^(?:[\da-f]{3}|[\da-f]{6})$/i).length>0){if(e.length===3){var t=e[0]+e[0]+e[1]+e[1]+e[2]+e[2];e=t}n.red=parseInt(e.substr(0,2),16);n.green=parseInt(e.substr(2,2),16);n.blue=parseInt(e.substr(4,2),16)}else{n.red=this.currentColor.red;n.green=this.currentColor.green;n.blue=this.currentColor.blue}this.currentColor=n};e.prototype.switchColorMode=function(e){switch(e.target.id){case"rgb-switch":this.rgbDisplay="none";this.hslDisplay="none";this.hexDisplay="flex";break;case"hex-switch":this.rgbDisplay="none";this.hslDisplay="flex";this.hexDisplay="none";break;case"hsl-switch":this.rgbDisplay="flex";this.hslDisplay="none";this.hexDisplay="none";break;default:this.rgbDisplay="flex";this.hslDisplay="none";this.hexDisplay="none"}};e.prototype.render=function(){var e=this;var n=this.currentColor.hue;var t=this.currentColor.saturation;var r=this.currentColor.lightness;var i=this.currentColor.red;var l=this.currentColor.green;var s=this.currentColor.blue;return o("div",{class:"dnn-color-picker"},o("div",{class:"dnn-color-sliders"},o("div",{class:"dnn-color-s-b",ref:function(n){return e.saturationLightnessBox=n},style:{backgroundColor:"hsl(".concat(n,",100%,50%)")},onMouseDown:this.handleSaturationLightnessMouseDown.bind(this)},o("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: ".concat(Math.round(this.currentColor.saturation*100),"%, Lightness: ").concat(Math.round(this.currentColor.lightness*100),"%"),style:{left:Math.round(t*100)+"%",bottom:Math.round(r*100)+"%"},onKeyDown:function(n){return e.handleSaturationLightnessKeyDown(n)}})),o("div",{class:"dnn-color-bar"},o("div",{class:"dnn-color-result",style:{backgroundColor:"#"+this.getHex(),boxShadow:"0 0 2px 1px "+"#"+this.getContrast()}}),o("div",{class:"dnn-color-hue",ref:function(n){return e.hueRange=n},onMouseDown:this.handleHueMouseDown.bind(this)},o("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(n),style:{left:(n/359*100).toString()+"%"},onKeyDown:function(n){return e.handleHueKeyDown(n)}})))),o("div",{class:"dnn-color-fields"},o("div",{class:"dnn-rgb-color-fields",style:{display:this.rgbDisplay}},o("div",{class:"dnn-rgb-color-field"},o("label",null,"R"),o("input",{type:"number",min:"0",max:"255",step:"1",class:"red",value:i,"aria-label":"red value",onChange:function(n){return e.handleComponentValueChange(n,"red")}})),o("div",{class:"dnn-rgb-color-field"},o("label",null,"G"),o("input",{type:"number",min:"0",max:"255",class:"green",value:l,"aria-label":"green value",onChange:function(n){return e.handleComponentValueChange(n,"green")}})),o("div",{class:"dnn-rgb-color-field"},o("label",null,"B"),o("input",{type:"number",min:"0",max:"255",class:"blue",value:s,"aria-label":"blue value",onChange:function(n){return e.handleComponentValueChange(n,"blue")}})),o("div",{class:"dnn-color-mode-switch"},o("button",{id:"rgb-switch",onClick:this.switchColorMode.bind(this),"aria-label":"switch to hexadecimal value entry"},o("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},o("path",{d:"M0 0h24v24H0z",fill:"none"}),o("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"}))))),o("div",{class:"dnn-hsl-color-fields",style:{display:this.hslDisplay}},o("div",{class:"dnn-hsl-color-field"},o("label",null,"H"),o("input",{type:"number",min:"0",max:"359",step:1,value:Math.round(n),"aria-label":"Hue",onChange:function(n){return e.handleHSLChange(n,"hue")}})),o("div",{class:"dnn-hsl-color-field"},o("label",null,"S"),o("input",{type:"number",min:"0",max:"100",step:1,value:Math.round(t*100),"aria-label":"Saturation",onChange:function(n){return e.handleHSLChange(n,"saturation")}})),o("div",{class:"dnn-hsl-color-field"},o("label",null,"L"),o("input",{type:"number",min:"0",max:"100",step:1,value:Math.round(r*100),"aria-label":"Lightness",onChange:function(n){return e.handleHSLChange(n,"lightness")}})),o("div",{class:"dnn-color-mode-switch"},o("button",{id:"hsl-switch",onClick:this.switchColorMode.bind(this),"aria-label":"Switch to red, green, blue entry mode"},o("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},o("path",{d:"M0 0h24v24H0z",fill:"none"}),o("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"}))))),o("div",{class:"dnn-hex-color-fields",style:{display:this.hexDisplay}},o("div",{class:"dnn-hex-color-field"},o("label",null,"HEX"),o("div",{class:"hex-input"},o("input",{type:"text","aria-label":"Hexadecimal value",value:this.getHex(),onChange:function(n){return e.handleHexChange(n.target.value)}}),o("button",{class:"copy","aria-label":"copy value"},o("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},o("path",{d:"M0 0h24v24H0z",fill:"none"}),o("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"}))))),o("div",{class:"dnn-color-mode-switch"},o("button",{id:"hex-switch",onClick:this.switchColorMode.bind(this),"aria-label":"Switch to hue saturation lightness values"},o("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},o("path",{d:"M0 0h24v24H0z",fill:"none"}),o("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"})))))))};Object.defineProperty(e.prototype,"el",{get:function(){return r(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{currentColor:["handeCurrentColorChanged"]}},enumerable:false,configurable:true});return e}());a([i(100)],d.prototype,"colorChangedHandler",null);d.style=s}}}));
12
- //# sourceMappingURL=dnn-color-picker.system.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["src/utilities/colorInfo.ts","src/components/dnn-color-picker/dnn-color-picker.scss?tag=dnn-color-picker&encapsulation=shadow","src/components/dnn-color-picker/dnn-color-picker.tsx"],"names":["ColorInfo","this","_hue","_saturation","_lightness","Object","defineProperty","prototype","value","getRGB","red","setHSL","green","blue","r","getHex","g","b","parseInt","substr","brightness","chroma","Math","abs","saturation","quadrant","offset","bias","round","min","max","diff","h","s","l","hex","toString","length","dnnColorPickerCss","DnnColorPicker","exports","class_1","hostRef","_this","color","colorBoxHeight","rgbDisplay","hslDisplay","hexDisplay","handleSaturationLightnessMouseDown","e","preventDefault","handleDragLightnessSaturation","window","addEventListener","handleSaturationLightnessMouseUp","rect","saturationLightnessBox","getBoundingClientRect","x","clientX","left","width","y","clientY","top","height","newColor","hue","currentColor","lightness","removeEventListener","handleHueMouseDown","handleDragHue","handleHueMouseUp","hueRange","handleComponentValueChange","channel","target","isNaN","handleHSLChange","component","h_1","handleSaturationLightnessKeyDown","shiftKey","key","handleHueKeyDown","colorChangedHandler","colorChanged","emit","handeCurrentColorChanged","newValue","componentWillLoad","handleHexChange","componentDidLoad","el","style","setProperty","getDoublet","getContrast","contrastColor","valueString","toUpperCase","match","expanded","switchColorMode","id","render","class","ref","element","backgroundColor","concat","onMouseDown","bind","aria-label","role","aria-valuemin","aria-valuemax","aria-valuetext","bottom","onKeyDown","boxShadow","aria-valuenow","display","type","step","onChange","onClick","xmlns","viewBox","fill","d","__decorate","Debounce"],"mappings":";;;;;;iBAMA,SAAAA,IAEYC,KAAAC,KAAe,EAWfD,KAAAE,YAAsB,EAWtBF,KAAAG,WAAqB,EAlB7BC,OAAAC,eAAIN,EAAAO,UAAA,MAAG,KAAP,WAAY,OAAON,KAAKC,UACxB,SAAQM,GACJ,GAAIA,EAAQ,EAAG,CAAEA,EAAQ,EACzB,GAAIA,EAAQ,IAAK,CAAEA,EAAQ,IAC3BP,KAAKC,KAAOM,wCAOhBH,OAAAC,eAAIN,EAAAO,UAAA,aAAU,KAAd,WAAmB,OAAON,KAAKE,iBAC/B,SAAeK,GACX,GAAIA,EAAQ,EAAG,CAAEA,EAAQ,EACzB,GAAIA,EAAQ,EAAG,CAAEA,EAAQ,EACzBP,KAAKE,YAAcK,wCAOvBH,OAAAC,eAAIN,EAAAO,UAAA,YAAS,KAAb,WAAkB,OAAON,KAAKG,gBAC9B,SAAcI,GACV,GAAIA,EAAQ,EAAG,CAAEA,EAAQ,EACzB,GAAIA,EAAQ,EAAG,CAAEA,EAAQ,EACzBP,KAAKG,WAAaI,wCAMtBH,OAAAC,eAAIN,EAAAO,UAAA,MAAG,KAAP,WACI,OAAON,KAAKQ,SAASC,SAEzB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AAKiG,MAAM,6BAA6B/D,OAAO,OAAOgE,QAAQ,YAAYpE,MAAM,OAAOqE,KAAK,WAAUnG,EAAA,OAAA,CAAMoG,EAAE,gBAAgBD,KAAK,SAAQnG,EAAA,OAAA,CAAMoG,EAAE,wIAI/JpG,EAAA,MAAA,CAAK4E,MAAM,yBACP5E,EAAA,SAAA,CACI0E,GAAG,aACHsB,QAAS/H,KAAKwG,gBAAgBS,KAAKjH,MAAKkH,aAC7B,6CAEXnF,EAAA,MAAA,CAAKiG,MAAM,6BAA6B/D,OAAO,OAAOgE,QAAQ,YAAYpE,MAAM,OAAOqE,KAAK,WAAUnG,EAAA,OAAA,CAAMoG,EAAE,gBAAgBD,KAAK,SAAQnG,EAAA,OAAA,CAAMoG,EAAE,2UAnZxJ,IAuBvBC,EAAA,CADCC,EAAS","sourcesContent":["/** Color utility class with hsl and rgb converters\r\n * based on math at https://en.wikipedia.org/wiki/HSL_and_HSV\r\n * @copyright Copyright (c) .NET Foundation. All rights reserved.\r\n * @license MIT \r\n */\r\n\r\nexport class ColorInfo{\r\n\r\n private _hue: number = 0;\r\n /** gets the color hue\r\n * @returns a number between 0 and 359, could contain decimals\r\n */\r\n get hue() { return this._hue; }\r\n set hue(value: number){\r\n if (value < 0) { value = 0; }\r\n if (value > 359) { value = 359; }\r\n this._hue = value;\r\n }\r\n\r\n private _saturation: number = 0;\r\n /** gets the color saturation\r\n * @returns a number between 0 and 1, could contain decimals\r\n */\r\n get saturation() { return this._saturation; }\r\n set saturation(value: number) {\r\n if (value < 0) { value = 0; }\r\n if (value > 1) { value = 1; }\r\n this._saturation = value;\r\n }\r\n\r\n private _lightness: number = 0;\r\n /** gets the color lightness\r\n * @returns a number between 0 and 1, could contain decimals\r\n */\r\n get lightness() { return this._lightness; }\r\n set lightness(value: number) {\r\n if (value < 0) { value = 0; }\r\n if (value > 1) { value = 1; }\r\n this._lightness = value;\r\n }\r\n\r\n /** gets or sets the red component \r\n * @returns an integer between 0 and 255\r\n */\r\n get red() {\r\n return this.getRGB().red;\r\n }\r\n set red(value) {\r\n this.setHSL(value, this.green, this.blue);\r\n }\r\n\r\n /** gets or sets the green component\r\n * @returns an integer between 0 and 255\r\n */\r\n get green() {\r\n return this.getRGB().green;\r\n }\r\n set green(value: number) {\r\n this.setHSL(this.red, value, this.blue);\r\n }\r\n\r\n /** gets or sets the blue component\r\n * @returns an integer between 0 and 255\r\n */\r\n get blue() {\r\n return this.getRGB().blue;\r\n }\r\n set blue(value: number) {\r\n this.setHSL(this.red, this.green, value);\r\n }\r\n\r\n /** gets or sets the hex color value, expresses as 6 hexadecimal characters.\r\n * @returns hex representation of the color\r\n */\r\n get hex() {\r\n var r = this.getHex(this.red);\r\n var g = this.getHex(this.green);\r\n var b = this.getHex(this.blue);\r\n return r + g + b;\r\n }\r\n set hex(value: string){\r\n this.red = parseInt(value.substr(0,2));\r\n this.green = parseInt(value.substr(2,2));\r\n this.blue = parseInt(value.substr(4,2));\r\n }\r\n\r\n /** gets white or black color that is a good oposite to the current color\r\n * @returns - \"000000\" or \"FFFFFF\"\r\n */\r\n get contrastColor() {\r\n const brightness = (this.red*299 + this.green*587 + this.blue*114) / 1000\r\n if (brightness > 127){\r\n return \"000000\";\r\n }\r\n return \"FFFFFF\";\r\n }\r\n\r\n private getRGB() {\r\n const chroma = (1 - Math.abs((2 * this._lightness) - 1)) * this.saturation;\r\n // find the quandrant of the hue\r\n const quadrant = this._hue / 60;\r\n // calculate the offset from the quandrant center\r\n const offset = chroma * (1 - Math.abs(quadrant % 2 - 1));\r\n\r\n // Apply the chroma to the primary component and the offset to the 2nd most important component\r\n let r = 0, g = 0, b = 0;\r\n if (0 <= quadrant && quadrant <= 1) {\r\n r = chroma; g = offset; // red to yellow\r\n } else if (1 <= quadrant && quadrant <= 2) {\r\n g = chroma; r = offset; // yellow to green\r\n } else if (2 <= quadrant && quadrant <= 3) {\r\n g = chroma; b = offset; // green to cyan\r\n } else if (3 <= quadrant && quadrant <= 4) {\r\n b = chroma; g = offset; // cyan to blue\r\n } else if (4 <= quadrant && quadrant <= 5) {\r\n b = chroma; r = offset; // blue to magenta\r\n } else if (5 <= quadrant && quadrant <= 6) {\r\n r = chroma; b = offset; // magenta to red\r\n }\r\n // calculate the bias to add to all channels to match the lightness\r\n const bias = this._lightness - (chroma / 2);\r\n\r\n return {\r\n red: Math.round((r + bias) * 255),\r\n green: Math.round((g + bias) * 255),\r\n blue: Math.round((b + bias) * 255)\r\n }\r\n }\r\n\r\n private setHSL(red: number, green: number, blue: number) {\r\n // GENERAL DATA\r\n // all math is based on values from 0 to 1\r\n const r = red/255, g = green/255, b = blue/255;\r\n // we need to max, min and the difference between them to derive hsl\r\n const min = Math.min(r, g, b);\r\n const max = Math.max(r, g, b);\r\n const diff = max - min;\r\n let h = 0, s = 0, l = 0;\r\n\r\n // HUE\r\n if (diff === 0) { // neutral\r\n h = 0;\r\n } else if (max === r) { // red (magenta to yellow range)\r\n h = 60 * ((g - b) / diff);\r\n } else if (max === g) { // green (yellow to cyan range)\r\n h = 60 * (2 + ((b - r) / diff));\r\n } else if (max === b) { // blue (cyan to magenta range)\r\n h = 60 * (4 + ((r - g) / diff));\r\n }\r\n if (h < 0) { h = h + 360} // ensures positive hues only\r\n if (h > 359) { h = 359} // ensures we never return 360 for simplicity since it is the same as 0\r\n\r\n // LIGHTNESS\r\n l = (max + min) / 2;\r\n\r\n // SATURATION\r\n if (max === 0 || min === 1) { // pure black or white have no saturation\r\n s = 0;\r\n } else {\r\n s = (max - l) / (Math.min(l, 1 - l));\r\n }\r\n\r\n this._hue = h;\r\n this._saturation = s;\r\n this._lightness = l;\r\n }\r\n\r\n private getHex(value: number){\r\n var hex = value.toString(16);\r\n if (hex.length < 2){\r\n hex = \"0\" + hex;\r\n }\r\n return hex;\r\n }\r\n} ",".dnn-color-picker{\r\n padding: 15px;\r\n max-width: 400px;\r\n .dnn-color-sliders{\r\n display:flex;\r\n flex-direction: column;\r\n min-width: 200px;\r\n .dnn-color-s-b{\r\n border: 1px solid #ccc;\r\n padding-bottom: var(--color-box-height, 50%);\r\n position: relative;\r\n background-color: red;\r\n &:before{\r\n content: '';\r\n position: absolute;\r\n top:0;\r\n left:0;\r\n width: 100%;\r\n height:100%;\r\n z-index:1;\r\n background: linear-gradient(to right, white, red);\r\n mix-blend-mode: saturation;\r\n }\r\n &:after{\r\n content: '';\r\n position: absolute;\r\n top:0;\r\n left:0;\r\n width: 100%;\r\n height:100%;\r\n z-index:2;\r\n background: linear-gradient(to bottom, white, black);\r\n mix-blend-mode: luminosity;\r\n }\r\n button{\r\n position: absolute;\r\n bottom: calc(50% - 4px);\r\n left: calc(50% - 4px);\r\n width: 8px;\r\n height: 8px;\r\n z-index: 3;\r\n display: block;\r\n background: none;\r\n border: none;\r\n margin-left: -4px;\r\n margin-bottom: -4px;\r\n padding: 7px;\r\n background-color: #fff;\r\n border-radius: 50%;\r\n &:before{\r\n content:'';\r\n position: absolute;\r\n top: -1px;\r\n left: -1px;\r\n border-radius: 50%;\r\n }\r\n &:after{\r\n content:'';\r\n position: absolute;\r\n top: 0px;\r\n left: 0px;\r\n border-radius: 50%;\r\n width: 10px;\r\n height: 10px;\r\n border: 2px solid #ccc;\r\n }\r\n } \r\n }\r\n .dnn-color-bar {\r\n display: flex;\r\n align-items: center;\r\n margin-top: 15px;\r\n .dnn-color-result {\r\n flex-direction: column;\r\n width: 50px;\r\n height: 50px;\r\n border-radius: 50%;\r\n background: red;\r\n }\r\n .dnn-color-hue{\r\n flex: auto;\r\n margin-left: 10px;\r\n height: 16px;\r\n border: 1px solid #ccc;\r\n position: relative;\r\n background: linear-gradient(\r\n to right, \r\n #f00 0, \r\n #ff0 17%,\r\n #0f0 33%,\r\n #0ff 50%,\r\n #00f 67%,\r\n #f0f 84%,\r\n #f00 100%\r\n );\r\n button{\r\n width: 10px;\r\n height: 20px;\r\n position: absolute;\r\n top: -2px;\r\n left: calc(50% - 4px);\r\n border: 0;\r\n padding: 0;\r\n background-color: transparent;\r\n padding-left: -8px;\r\n &:before{\r\n content:'';\r\n position: absolute;\r\n top: -2px;\r\n left: 0px;\r\n border-radius: 3px;\r\n width: 100%;\r\n height: 100%;\r\n border: 1px solid #ccc;\r\n background-color: #fff;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n .dnn-color-fields{\r\n display:flex;\r\n flex-direction: column;\r\n justify-content: space-between;\r\n .dnn-color-mode-switch {\r\n display: flex;\r\n align-items: flex-end;\r\n padding: .5em;\r\n button {\r\n background-color: transparent;\r\n border: none;\r\n svg {\r\n width: 3em;\r\n height: 3em;\r\n pointer-events: none;\r\n outline: none;\r\n }\r\n }\r\n }\r\n .dnn-rgb-color-fields {\r\n display: flex;\r\n justify-content: space-evenly;\r\n .dnn-rgb-color-field {\r\n display: flex;\r\n flex-direction: column;\r\n flex: auto;\r\n text-align: center;\r\n padding: .5em;\r\n label {\r\n padding-bottom: .25em;\r\n }\r\n input{\r\n border-radius: var(--dnn-button-radius, 3px);\r\n border: 1px solid #ccc;\r\n padding: 0.5em;\r\n padding-left: 1.3em;\r\n text-align: center;\r\n &.red{\r\n border-color: red;\r\n }\r\n &.green{\r\n border-color: green; \r\n }\r\n &.blue{\r\n border-color: blue;\r\n } \r\n }\r\n }\r\n }\r\n .dnn-hsl-color-fields {\r\n display: flex;\r\n justify-content: space-evenly;\r\n .dnn-hsl-color-field {\r\n display: flex;\r\n flex-direction: column;\r\n flex: auto;\r\n text-align: center;\r\n padding: .5em;\r\n label {\r\n padding-bottom: .25em;\r\n }\r\n input{\r\n border-radius: var(--dnn-button-radius, 3px);\r\n border: 1px solid #ccc;\r\n padding: 0.5em;\r\n padding-left: 1.3em;\r\n text-align: center;\r\n }\r\n }\r\n }\r\n .dnn-hex-color-fields {\r\n display: flex;\r\n justify-content: space-evenly;\r\n .dnn-hex-color-field {\r\n display: flex;\r\n flex-direction: column;\r\n flex: auto;\r\n text-align: center;\r\n padding: .5em;\r\n label {\r\n padding-bottom: .25em;\r\n }\r\n .hex-input{\r\n position: relative;\r\n border-radius: var(--dnn-button-radius, 3px);\r\n border: 1px solid #ccc;\r\n padding: 0.323em;\r\n text-align: center;\r\n input{\r\n border:0;\r\n padding:0;\r\n margin:0;\r\n width:100%;\r\n height:100%;\r\n text-align:center;\r\n }\r\n button{\r\n position: absolute;\r\n height: 100%;\r\n top: 0;\r\n right: 1em;\r\n background-color: transparent;\r\n border:0;\r\n padding:0;\r\n margin:0;\r\n svg{\r\n min-width: 1em;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n} ","/** Reusable DNN UI component to pick a color\r\n * @copyright Copyright (c) .NET Foundation. All rights reserved.\r\n * @license MIT \r\n */\r\n\r\nimport { Component, h, State, Element, Prop, EventEmitter, Event, Watch } from \"@stencil/core\";\r\nimport { ColorInfo } from '../../utilities/colorInfo';\r\nimport { Debounce } from \"../../utilities/debounce\";\r\n\r\n/** Color Picker for Dnn */\r\n@Component({\r\n tag: 'dnn-color-picker',\r\n styleUrl: 'dnn-color-picker.scss',\r\n shadow: true\r\n})\r\nexport class DnnColorPicker {\r\n\r\n @Element() el: HTMLDnnColorPickerElement;\r\n\r\n /** Sets the initial color, must be a valid 8 character hexadecimal string without the # sign. */\r\n @Prop() color: string = \"FFFFFF\";\r\n\r\n /** Sets the width-height ratio of the color picker saturation-lightness box.\r\n * @example 100% renders a perfect square\r\n */\r\n @Prop() colorBoxHeight: string = \"50%\";\r\n \r\n @State() currentColor: ColorInfo;\r\n @State() rgbDisplay: string = \"flex\";\r\n @State() hslDisplay: string = \"none\";\r\n @State() hexDisplay: string = \"none\";\r\n\r\n /** Fires up when the color is changed and emits a ColorInfo object\r\n * @see ../../utilities/colorInfo.ts\r\n */\r\n @Event() colorChanged: EventEmitter<ColorInfo>;\r\n\r\n @Debounce(100)\r\n private colorChangedHandler(color: ColorInfo) {\r\n this.colorChanged.emit(color);\r\n }\r\n\r\n @Watch(\"currentColor\")\r\n handeCurrentColorChanged(newValue: ColorInfo){\r\n this.colorChangedHandler(newValue);\r\n }\r\n \r\n private saturationLightnessBox?: HTMLDivElement;\r\n private hueRange?: HTMLDivElement;\r\n\r\n\r\n componentWillLoad() {\r\n this.handleHexChange(this.color);\r\n }\r\n\r\n componentDidLoad() {\r\n (this.el as unknown as HTMLElement).style.setProperty(\"--color-box-height\", this.colorBoxHeight.toString());\r\n }\r\n \r\n private getHex() {\r\n return this.getDoublet(this.currentColor.red) + this.getDoublet(this.currentColor.green) + this.getDoublet(this.currentColor.blue);\r\n }\r\n\r\n private getContrast() {\r\n return this.currentColor.contrastColor;\r\n }\r\n\r\n private getDoublet(value: number){\r\n const valueString = value.toString(16).toUpperCase();\r\n if (valueString.length === 1){\r\n return '0' + valueString;\r\n }\r\n return valueString;\r\n }\r\n\r\n private handleSaturationLightnessMouseDown = (e) => {\r\n e.preventDefault();\r\n this.handleDragLightnessSaturation(e);\r\n window.addEventListener('mousemove', this.handleDragLightnessSaturation);\r\n window.addEventListener('mouseup', this.handleSaturationLightnessMouseUp);\r\n }\r\n\r\n private handleDragLightnessSaturation = (e) => {\r\n const rect = this.saturationLightnessBox.getBoundingClientRect(); \r\n\r\n let x = e.clientX - rect.left; \r\n if (x < 0) { x = 0}\r\n if (x > rect.width) { x = rect.width}\r\n x = x/rect.width;\r\n\r\n let y = e.clientY - rect.top;\r\n if (y < 0) { y = 0}\r\n if (y > rect.height) { y = rect.height}\r\n y = 1 - (y/rect.height);\r\n\r\n const newColor = new ColorInfo();\r\n newColor.hue = this.currentColor.hue;\r\n newColor.saturation = x;\r\n newColor.lightness = y;\r\n this.currentColor = newColor;\r\n }\r\n\r\n private handleSaturationLightnessMouseUp = () => {\r\n window.removeEventListener('mousemove', this.handleDragLightnessSaturation);\r\n window.removeEventListener('mouseup', this.handleSaturationLightnessMouseUp);\r\n }\r\n\r\n private handleHueMouseDown = (e) => {\r\n e.preventDefault();\r\n this.handleDragHue(e);\r\n window.addEventListener('mousemove', this.handleDragHue);\r\n window.addEventListener('mouseup', this.handleHueMouseUp); \r\n }\r\n\r\n private handleHueMouseUp = () => {\r\n window.removeEventListener('mousemove', this.handleDragHue);\r\n window.removeEventListener('mouseup', this.handleHueMouseUp); \r\n }\r\n\r\n private handleDragHue = (e) => {\r\n const rect = this.hueRange.getBoundingClientRect(); \r\n\r\n let x = e.clientX - rect.left;\r\n if (x < 0) { x = 0}\r\n if (x > rect.width) { x = rect.width}\r\n x = x/rect.width*360; \r\n\r\n const newColor = new ColorInfo();\r\n newColor.hue = x;\r\n newColor.saturation = this.currentColor.saturation;\r\n newColor.lightness = this.currentColor.lightness;\r\n this.currentColor = newColor;\r\n }\r\n\r\n private handleComponentValueChange = (e, channel) => {\r\n let value = parseInt(e.target.value);\r\n if (isNaN(value)) { return }\r\n const newColor = new ColorInfo();\r\n if (value < 0) { value = 0; }\r\n if (value > 255) { value = 255; }\r\n let r = this.currentColor.red;\r\n let g = this.currentColor.green;\r\n let b = this.currentColor.blue;\r\n switch (channel) {\r\n case 'red':\r\n r = value;\r\n break;\r\n case 'green':\r\n g = value;\r\n break;\r\n case 'blue':\r\n b = value;\r\n break;\r\n default:\r\n break;\r\n }\r\n newColor.green = g;\r\n newColor.red = r;\r\n newColor.blue = b;\r\n this.currentColor = newColor;\r\n }\r\n\r\n private handleHSLChange = (e, component) => { \r\n let value = parseInt(e.target.value);\r\n if (isNaN(value)) {return}\r\n const newColor = new ColorInfo();\r\n if (value != null) { \r\n let h = this.currentColor.hue;\r\n let s = this.currentColor.saturation;\r\n let l = this.currentColor.lightness;\r\n switch (component) {\r\n case \"hue\":\r\n if (value < 0) { value = 0}\r\n if (value > 359) { value = 0}\r\n h = value;\r\n break;\r\n case \"saturation\":\r\n if (value < 0) { value = 0}\r\n if (value > 100) { value = 100}\r\n s = value / 100;\r\n break;\r\n case \"lightness\":\r\n if (value < 0) { value = 0}\r\n if (value > 100) { value = 100}\r\n l = value / 100;\r\n break; \r\n default:\r\n break; \r\n }\r\n newColor.hue = h;\r\n newColor.saturation = s;\r\n newColor.lightness = l;\r\n this.currentColor = newColor;\r\n }\r\n }\r\n\r\n private handleHexChange(value: string){\r\n const newColor = new ColorInfo();\r\n if (value.match(/^(?:[\\da-f]{3}|[\\da-f]{6})$/i).length > 0) {\r\n if (value.length === 3){\r\n let expanded = value[0] + value[0] + value[1] + value[1] + value[2] + value [2];\r\n value = expanded;\r\n }\r\n newColor.red = parseInt(value.substr(0,2), 16);\r\n newColor.green = parseInt(value.substr(2,2), 16);\r\n newColor.blue = parseInt(value.substr(4,2), 16);\r\n }\r\n else{\r\n newColor.red = this.currentColor.red;\r\n newColor.green = this.currentColor.green;\r\n newColor.blue = this.currentColor.blue;\r\n }\r\n this.currentColor = newColor;\r\n }\r\n\r\n private switchColorMode(e) {\r\n switch(e.target.id) {\r\n case \"rgb-switch\":\r\n this.rgbDisplay = \"none\";\r\n this.hslDisplay = \"none\";\r\n this.hexDisplay = \"flex\";\r\n break;\r\n case \"hex-switch\":\r\n this.rgbDisplay = \"none\";\r\n this.hslDisplay = \"flex\";\r\n this.hexDisplay = \"none\";\r\n break;\r\n case \"hsl-switch\":\r\n this.rgbDisplay = \"flex\";\r\n this.hslDisplay = \"none\";\r\n this.hexDisplay = \"none\";\r\n break;\r\n default:\r\n this.rgbDisplay = \"flex\";\r\n this.hslDisplay = \"none\";\r\n this.hexDisplay = \"none\";\r\n }\r\n }\r\n\r\n private handleSaturationLightnessKeyDown = (e) => { \r\n let newColor = new ColorInfo();\r\n newColor.hue = this.currentColor.hue;\r\n newColor.saturation = this.currentColor.saturation;\r\n newColor.lightness = this.currentColor.lightness;\r\n\r\n let value = 0.01;\r\n if (e.shiftKey) { value = 0.1 ;}\r\n\r\n switch (e.key) {\r\n case \"ArrowUp\":\r\n newColor.lightness += value;\r\n break;\r\n case \"ArrowDown\":\r\n newColor.lightness -= value;\r\n break;\r\n case \"ArrowLeft\":\r\n newColor.saturation -= value;\r\n break;\r\n case \"ArrowRight\":\r\n newColor.saturation += value;\r\n default:\r\n break; \r\n }\r\n this.currentColor = newColor;\r\n }\r\n\r\n private handleHueKeyDown = (e) => {\r\n let newColor = new ColorInfo();\r\n newColor.hue = this.currentColor.hue;\r\n newColor.saturation = this.currentColor.saturation;\r\n newColor.lightness = this.currentColor.lightness;\r\n\r\n let value = 1;\r\n if (e.shiftKey) { value = 10}\r\n\r\n switch (e.key) {\r\n case \"ArrowLeft\":\r\n newColor.hue -= value;\r\n break;\r\n case \"ArrowRight\":\r\n newColor.hue += value;\r\n default:\r\n break;\r\n }\r\n this.currentColor = newColor;\r\n }\r\n\r\n render() {\r\n const hue = this.currentColor.hue;\r\n const saturation = this.currentColor.saturation;\r\n const lightness = this.currentColor.lightness;\r\n const red = this.currentColor.red;\r\n const green = this.currentColor.green;\r\n const blue = this.currentColor.blue;\r\n\r\n return (\r\n <div class=\"dnn-color-picker\">\r\n <div class=\"dnn-color-sliders\">\r\n <div class=\"dnn-color-s-b\" ref={(element) => this.saturationLightnessBox = element as HTMLDivElement}\r\n style={{backgroundColor: `hsl(${hue},100%,50%)`}}\r\n onMouseDown={this.handleSaturationLightnessMouseDown.bind(this)}\r\n >\r\n <button class=\"dnn-s-b-picker\"\r\n aria-label=\"Press up or down to adjust lightness, left or right to adjust saturation, hold shift to move by 10%\"\r\n role=\"slider\"\r\n aria-valuemin=\"0\"\r\n aria-valuemax=\"100\"\r\n aria-valuetext={`Saturation: ${Math.round(this.currentColor.saturation*100)}%, Lightness: ${Math.round(this.currentColor.lightness*100)}%`}\r\n style={{\r\n left: Math.round(saturation * 100) + \"%\",\r\n bottom: Math.round(lightness * 100) + \"%\"\r\n }}\r\n onKeyDown={(e) => this.handleSaturationLightnessKeyDown(e)}\r\n />\r\n </div>\r\n <div class=\"dnn-color-bar\">\r\n <div class=\"dnn-color-result\" style={{\r\n backgroundColor: '#' + this.getHex(),\r\n boxShadow: \"0 0 2px 1px \" + \"#\" + this.getContrast()\r\n }} \r\n />\r\n <div class=\"dnn-color-hue\"\r\n ref={(element) => this.hueRange = element as HTMLDivElement}\r\n onMouseDown={this.handleHueMouseDown.bind(this)}\r\n >\r\n <button class=\"dnn-hue-picker\"\r\n aria-label=\"Press left or right to adjust hue, hold shift to move by 10 degrees\"\r\n role=\"slider\"\r\n aria-valuemin=\"0\"\r\n aria-valuemax=\"359\"\r\n aria-valuenow={Math.round(hue)}\r\n style={{left: (hue/359*100).toString() + \"%\"}}\r\n onKeyDown={(e) => this.handleHueKeyDown(e)}\r\n />\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"dnn-color-fields\">\r\n <div class=\"dnn-rgb-color-fields\" style={{display: this.rgbDisplay}}>\r\n <div class=\"dnn-rgb-color-field\">\r\n <label>R</label>\r\n <input type=\"number\" min=\"0\" max=\"255\" step=\"1\" class=\"red\" value={red} aria-label=\"red value\"\r\n onChange={(e) => this.handleComponentValueChange(e, 'red')}\r\n />\r\n </div>\r\n <div class=\"dnn-rgb-color-field\">\r\n <label>G</label>\r\n <input type=\"number\" min=\"0\" max=\"255\" class=\"green\" value={green} aria-label=\"green value\"\r\n onChange={(e) => this.handleComponentValueChange(e, 'green')}\r\n />\r\n </div>\r\n <div class=\"dnn-rgb-color-field\">\r\n <label>B</label>\r\n <input type=\"number\" min=\"0\" max=\"255\" class=\"blue\" value={blue} aria-label=\"blue value\"\r\n onChange={(e) => this.handleComponentValueChange(e, 'blue')}\r\n />\r\n </div>\r\n <div class=\"dnn-color-mode-switch\">\r\n <button\r\n id=\"rgb-switch\"\r\n onClick={this.switchColorMode.bind(this)}\r\n aria-label=\"switch to hexadecimal value entry\"\r\n >\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#000000\"><path d=\"M0 0h24v24H0z\" fill=\"none\"/><path d=\"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z\"/></svg>\r\n </button>\r\n </div>\r\n </div>\r\n <div class=\"dnn-hsl-color-fields\" style={{display: this.hslDisplay}}>\r\n <div class=\"dnn-hsl-color-field\">\r\n <label>H</label>\r\n <input type=\"number\" min=\"0\" max=\"359\" step={1} value={Math.round(hue)} aria-label=\"Hue\"\r\n onChange={(e) => this.handleHSLChange(e, 'hue')}\r\n />\r\n </div>\r\n <div class=\"dnn-hsl-color-field\">\r\n <label>S</label>\r\n <input type=\"number\" min=\"0\" max=\"100\" step={1} value={Math.round(saturation*100)} aria-label=\"Saturation\"\r\n onChange={(e) => this.handleHSLChange(e, 'saturation')}\r\n />\r\n </div>\r\n <div class=\"dnn-hsl-color-field\">\r\n <label>L</label>\r\n <input type=\"number\" min=\"0\" max=\"100\" step={1} value={Math.round(lightness*100)} aria-label=\"Lightness\"\r\n onChange={(e) => this.handleHSLChange(e, 'lightness')}\r\n />\r\n </div>\r\n <div class=\"dnn-color-mode-switch\">\r\n <button\r\n id=\"hsl-switch\"\r\n onClick={this.switchColorMode.bind(this)}\r\n aria-label=\"Switch to red, green, blue entry mode\"\r\n >\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#000000\"><path d=\"M0 0h24v24H0z\" fill=\"none\"/><path d=\"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z\"/></svg>\r\n </button>\r\n </div>\r\n </div>\r\n <div class=\"dnn-hex-color-fields\" style={{display: this.hexDisplay}}>\r\n <div class=\"dnn-hex-color-field\">\r\n <label>HEX</label>\r\n <div class=\"hex-input\">\r\n <input type=\"text\" aria-label=\"Hexadecimal value\"\r\n value={this.getHex()}\r\n onChange={e => this.handleHexChange((e.target as HTMLInputElement).value)}\r\n />\r\n <button\r\n class=\"copy\"\r\n aria-label=\"copy value\"\r\n >\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#000000\"><path d=\"M0 0h24v24H0z\" fill=\"none\"/><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\"/></svg>\r\n </button>\r\n </div>\r\n </div>\r\n <div class=\"dnn-color-mode-switch\">\r\n <button\r\n id=\"hex-switch\"\r\n onClick={this.switchColorMode.bind(this)}\r\n aria-label=\"Switch to hue saturation lightness values\"\r\n >\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#000000\"><path d=\"M0 0h24v24H0z\" fill=\"none\"/><path d=\"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z\"/></svg>\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n }\r\n}"]}
@@ -1,149 +0,0 @@
1
- import { r as registerInstance, e as createEvent, h, f as Host } from './index-20e42ad7.js';
2
-
3
- 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}";
4
-
5
- const DnnDropzone = class {
6
- constructor(hostRef) {
7
- registerInstance(this, hostRef);
8
- this.filesSelected = createEvent(this, "filesSelected", 7);
9
- /** Localization strings */
10
- this.resx = {
11
- dragAndDropFile: "Drag and drop a file",
12
- capture: "Capture",
13
- or: "or",
14
- takePicture: "Take a picture",
15
- uploadFile: "Upload a file",
16
- };
17
- /**
18
- * If true, will allow the user to take a snapshot
19
- * using the device camera. (only works over https).
20
- */
21
- this.allowCameraMode = false;
22
- /**
23
- * Specifies the jpeg quality for when the device
24
- * camera is used to generate a picture.
25
- * Needs to be a number between 0 and 1 and defaults to 0.8
26
- */
27
- this.captureQuality = 0.8;
28
- this.canTakeSnapshots = false;
29
- this.takingPicture = false;
30
- this.handleDragOver = (event) => {
31
- event.stopPropagation();
32
- event.preventDefault();
33
- event.dataTransfer.dropEffect = "copy";
34
- this.dropzone.classList.add("dropping");
35
- };
36
- this.handleDrop = (dropEvent) => {
37
- dropEvent.stopPropagation();
38
- dropEvent.preventDefault();
39
- const files = dropEvent.dataTransfer.files;
40
- if (this.hasInvalidExtensions(files)) {
41
- return;
42
- }
43
- var fileList = this.getFilesFromFileList(files);
44
- this.filesSelected.emit(fileList);
45
- };
46
- }
47
- componentDidLoad() {
48
- if (this.allowCameraMode) {
49
- this.checkIfBrowserCanTakeSnapshots()
50
- .then(result => this.canTakeSnapshots = result);
51
- }
52
- if (this.allowedExtensions != undefined && this.allowedExtensions.length > 0) {
53
- var extensionsWithDots = this.allowedExtensions.map(e => `.${e}`);
54
- var extensionsList = extensionsWithDots.join(",");
55
- this.fileInput.accept = extensionsList;
56
- }
57
- }
58
- checkIfBrowserCanTakeSnapshots() {
59
- return new Promise((resolve) => {
60
- const mediaDevices = navigator.mediaDevices;
61
- if (mediaDevices == undefined || mediaDevices.enumerateDevices == undefined) {
62
- resolve(false);
63
- }
64
- mediaDevices.enumerateDevices()
65
- .then(devices => {
66
- var result = devices.some(device => device.kind == "videoinput");
67
- resolve(result);
68
- });
69
- });
70
- }
71
- getFilesFromFileList(files) {
72
- var fileList = [];
73
- for (let index = 0; index < files.length; index++) {
74
- const file = files[index];
75
- fileList.push(file);
76
- }
77
- return fileList;
78
- }
79
- handleUploadButton(element) {
80
- let files = this.getFilesFromFileList(element.files);
81
- this.filesSelected.emit(files);
82
- }
83
- hasInvalidExtensions(files) {
84
- var hasInvalid = false;
85
- for (let fileIndex = 0; fileIndex < files.length; fileIndex++) {
86
- const file = files[fileIndex];
87
- var regex = /(?:\.([^.]+))?$/;
88
- const fileExtension = regex.exec(file.name)[1];
89
- if (fileExtension == undefined) {
90
- hasInvalid = true;
91
- }
92
- if (this.allowedExtensions != undefined && !this.allowedExtensions.includes(fileExtension)) {
93
- hasInvalid = true;
94
- }
95
- return hasInvalid;
96
- }
97
- }
98
- takeSnapshot() {
99
- this.takingPicture = true;
100
- navigator.mediaDevices.getUserMedia({ video: true, audio: false })
101
- .then(stream => {
102
- stream;
103
- this.videoPreview.srcObject = stream;
104
- this.videoPreview.play()
105
- .then(() => {
106
- this.videoSettings = stream.getVideoTracks()[0].getSettings();
107
- });
108
- })
109
- .catch(error => alert(error));
110
- }
111
- applySnapshot() {
112
- var canvas = document.createElement("canvas");
113
- const context = canvas.getContext("2d");
114
- canvas.width = this.videoSettings.width;
115
- canvas.height = this.videoSettings.height;
116
- context.drawImage(this.videoPreview, 0, 0);
117
- canvas.toBlob(blob => {
118
- var file = new File([blob], "image.jpeg", { type: "image/jpeg" });
119
- this.takingPicture = false;
120
- var fileList = [file];
121
- this.filesSelected.emit(fileList);
122
- }, "image/jpeg", this.captureQuality);
123
- }
124
- render() {
125
- var _a, _b, _c, _d, _e, _f;
126
- return (h(Host, { ref: e => this.dropzone = e, class: "dropzone", onDragOver: this.handleDragOver, onDrop: this.handleDrop, onDragLeave: () => this.dropzone.classList.remove("dropping") }, !this.takingPicture &&
127
- [
128
- h("p", null, (_a = this.resx) === null || _a === void 0 ? void 0 : _a.dragAndDropFile),
129
- h("p", null, "- ", (_b = this.resx) === null || _b === void 0 ? void 0 :
130
- _b.or, " -"),
131
- h("label", { class: "upload-file" }, h("input", { type: "file", ref: el => this.fileInput = el, onChange: e => this.handleUploadButton(e.target) }), h("span", null, h("svg", { xmlns: "http://www.w3.org/2000/svg", "enable-background": "new 0 0 24 24", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("g", null, h("rect", { fill: "none", height: "24", width: "24" })), h("g", null, h("path", { d: "M5,20h14v-2H5V20z M5,10h4v6h6v-6h4l-7-7L5,10z" })))), "\u00A0", (_c = this.resx) === null || _c === void 0 ? void 0 :
132
- _c.uploadFile),
133
- this.canTakeSnapshots &&
134
- [
135
- h("p", null, "- ", (_d = this.resx) === null || _d === void 0 ? void 0 :
136
- _d.or, " -"),
137
- h("button", { onClick: () => this.takeSnapshot() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("circle", { cx: "12", cy: "12", r: "3.2" }), h("path", { d: "M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z" })), (_e = this.resx) === null || _e === void 0 ? void 0 :
138
- _e.takePicture)
139
- ]
140
- ], this.takingPicture &&
141
- h("div", { class: "video-preview" }, h("video", { ref: e => this.videoPreview = e }), h("button", { onClick: () => this.applySnapshot() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("circle", { cx: "12", cy: "12", r: "3.2" }), h("path", { d: "M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z" })), "\u00A0", (_f = this.resx) === null || _f === void 0 ? void 0 :
142
- _f.capture))));
143
- }
144
- };
145
- DnnDropzone.style = dnnDropzoneCss;
146
-
147
- export { DnnDropzone as dnn_dropzone };
148
-
149
- //# sourceMappingURL=dnn-dropzone.entry.js.map
@@ -1 +0,0 @@
1
- {"file":"dnn-dropzone.entry.esm.js","mappings":";;AAAA,MAAM,cAAc,GAAG,4mCAA4mC;;MCOtnC,WAAW;EALxB;;;;IAOU,SAAI,GAMR;MACF,eAAe,EAAE,sBAAsB;MACvC,OAAO,EAAE,SAAS;MAClB,EAAE,EAAE,IAAI;MACR,WAAW,EAAE,gBAAgB;MAC7B,UAAU,EAAE,eAAe;KAC5B,CAAA;;;;;IAYO,oBAAe,GAAY,KAAK,CAAC;;;;;;IAOjC,mBAAc,GAAW,GAAG,CAAC;IAK5B,qBAAgB,GAAY,KAAK,CAAC;IAElC,kBAAa,GAAY,KAAK,CAAC;IAkDhC,mBAAc,GAAG,CAAC,KAAgB;MAExC,KAAK,CAAC,eAAe,EAAE,CAAC;MACxB,KAAK,CAAC,cAAc,EAAE,CAAC;MACvB,KAAK,CAAC,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC;MACvC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;KACzC,CAAC;IAoBM,eAAU,GAAG,CAAC,SAAoB;MACxC,SAAS,CAAC,eAAe,EAAE,CAAC;MAC5B,SAAS,CAAC,cAAc,EAAE,CAAC;MAC3B,MAAM,KAAK,GAAG,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC;MAE3C,IAAI,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAC;QACnC,OAAO;OACR;MACD,IAAI,QAAQ,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;MAChD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC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,CAAC,YAAY,GAAG,CAAC,GAAI,EAC1C,cACE,OAAO,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,IAEnC,WAAK,KAAK,EAAC,4BAA4B,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,MAAM,EAAC,IAAI,EAAC,SAAS,IAAC,YAAM,CAAC,EAAC,eAAe,EAAC,IAAI,EAAC,MAAM,GAAE,EAAA,cAAQ,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,KAAK,GAAE,EAAA,YAAM,CAAC,EAAC,2JAA2J,GAAE,CAAM,YACtV,MAAA,IAAI,CAAC,IAAI;WAAE,OAAO,CACZ,CACL,CAEH,EACP;GACH;;;;;;","names":[],"sources":["./src/components/dnn-dropzone/dnn-dropzone.scss?tag=dnn-dropzone&encapsulation=shadow","./src/components/dnn-dropzone/dnn-dropzone.tsx"],"sourcesContent":["\n:host {\n /** \n * @prop --border-color: The color of the border.\n * @prop --border-radius: The radius of the controls borders.\n * @prop --drop-background-color: The color of the background when a file is dropping.\n */\n --border-color: var(--dnn-color-tertiary-contrast, lightgray);\n --border-radius: var(--dnn-controls-radius, 5px);\n --drop-background-color: var(--dnn-color-tertiary, lightblue);\n\n display: flex;\n flex-direction: column;\n gap: 1rem;\n text-align: center;\n border: 2px dashed var(--border-color);\n border-radius: var(--border-radius);\n padding: 1rem;\n transition: all 300ms ease-in-out;\n}\n\n:host(.dropping){\n background-color: var(--drop-background-color);\n}\np{\n margin: 0;\n padding: 0;\n}\nbutton{\n display: flex;\n justify-content: center;\n align-items: center;\n border: 0px;\n margin: 0;\n padding: 0;\n background-color: transparent;\n &:hover{\n cursor: pointer;\n }\n svg{\n margin-right: 0.5rem;\n }\n}\nlabel.upload-file{\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n input{\n display: none;\n }\n}\n.video-preview{\n display: flex;\n flex-direction: column;\n align-items: center;\n button{\n margin: 1rem;\n }\n}\n","import { Component, Host, h, Prop, State, Event, EventEmitter } from '@stencil/core';\n\n@Component({\n tag: 'dnn-dropzone',\n styleUrl: 'dnn-dropzone.scss',\n shadow: true,\n})\nexport class DnnDropzone {\n /** Localization strings */\n @Prop() resx:{\n dragAndDropFile: string;\n capture: string;\n or: string;\n takePicture: string;\n uploadFile: string;\n } = {\n dragAndDropFile: \"Drag and drop a file\",\n capture: \"Capture\",\n or: \"or\",\n takePicture: \"Take a picture\",\n uploadFile: \"Upload a file\",\n }\n\n /** A list of allowed file extensions.\n * If not specified, any file is allowed.\n * Ex: [\"jpg\", \"jped\", \"gif\", \"png\"]\n */\n @Prop() allowedExtensions: string[];\n\n /**\n * If true, will allow the user to take a snapshot\n * using the device camera. (only works over https).\n */\n @Prop() allowCameraMode: boolean = false;\n\n /**\n * Specifies the jpeg quality for when the device\n * camera is used to generate a picture.\n * Needs to be a number between 0 and 1 and defaults to 0.8\n */\n @Prop() captureQuality: number = 0.8;\n\n /** Fires when file were selected. */\n @Event() filesSelected: EventEmitter<File[]>;\n \n @State() canTakeSnapshots: boolean = false;\n\n @State() takingPicture: boolean = false;\n \n private dropzone: HTMLElement;\n private fileInput: HTMLInputElement;\n private videoPreview: HTMLVideoElement;\n private videoSettings!: MediaTrackSettings;\n\n\n componentDidLoad() {\n if (this.allowCameraMode){\n this.checkIfBrowserCanTakeSnapshots()\n .then(result => this.canTakeSnapshots = result);\n }\n if (this.allowedExtensions != undefined && this.allowedExtensions.length > 0){\n var extensionsWithDots = this.allowedExtensions.map(e => `.${e}`);\n var extensionsList = extensionsWithDots.join(\",\");\n this.fileInput.accept = extensionsList;\n }\n }\n\n private checkIfBrowserCanTakeSnapshots(): Promise<boolean> {\n return new Promise((resolve) => {\n const mediaDevices = navigator.mediaDevices;\n if (mediaDevices == undefined || mediaDevices.enumerateDevices == undefined) {\n resolve(false);\n }\n mediaDevices.enumerateDevices()\n .then(devices => {\n var result = devices.some(device => device.kind == \"videoinput\");\n resolve(result);\n });\n });\n }\n\n private getFilesFromFileList(files: FileList) : File[] {\n var fileList: File[] = [];\n for (let index = 0; index < files.length; index++) {\n const file = files[index];\n fileList.push(file);\n }\n\n return fileList;\n }\n\n private handleUploadButton(element: HTMLInputElement): void {\n let files = this.getFilesFromFileList(element.files);\n\n this.filesSelected.emit(files);\n }\n\n private handleDragOver = (event: DragEvent) => \n {\n event.stopPropagation();\n event.preventDefault();\n event.dataTransfer.dropEffect = \"copy\";\n this.dropzone.classList.add(\"dropping\");\n };\n\n private hasInvalidExtensions(files: FileList): boolean{\n var hasInvalid = false;\n for (let fileIndex = 0; fileIndex < files.length; fileIndex++) {\n const file = files[fileIndex];\n var regex = /(?:\\.([^.]+))?$/;\n const fileExtension = regex.exec(file.name)[1];\n if (fileExtension == undefined){\n hasInvalid = true;\n }\n\n if (this.allowedExtensions != undefined && !this.allowedExtensions.includes(fileExtension)){\n hasInvalid = true;\n }\n\n return hasInvalid;\n }\n }\n\n private handleDrop = (dropEvent: DragEvent) => {\n dropEvent.stopPropagation();\n dropEvent.preventDefault();\n const files = dropEvent.dataTransfer.files;\n\n if (this.hasInvalidExtensions(files)){\n return;\n }\n var fileList = this.getFilesFromFileList(files);\n this.filesSelected.emit(fileList);\n };\n\n private takeSnapshot(): void {\n this.takingPicture = true;\n navigator.mediaDevices.getUserMedia({video: true, audio: false})\n .then(stream => {\n stream\n this.videoPreview.srcObject = stream;\n this.videoPreview.play()\n .then(() => {\n this.videoSettings = stream.getVideoTracks()[0].getSettings();\n });\n })\n .catch(error => alert(error));\n }\n\n private applySnapshot(): void {\n var canvas = document.createElement(\"canvas\");\n const context = canvas.getContext(\"2d\");\n canvas.width = this.videoSettings.width;\n canvas.height = this.videoSettings.height;\n context.drawImage(this.videoPreview, 0, 0);\n canvas.toBlob(blob => {\n var file = new File([blob], \"image.jpeg\", {type:\"image/jpeg\"});\n this.takingPicture = false;\n \n var fileList = [file];\n this.filesSelected.emit(fileList)\n }, \"image/jpeg\", this.captureQuality);\n }\n \n render() {\n return (\n <Host\n ref={e => this.dropzone = e}\n class=\"dropzone\"\n onDragOver={this.handleDragOver}\n onDrop={this.handleDrop}\n onDragLeave={() => this.dropzone.classList.remove(\"dropping\")}\n >\n {!this.takingPicture &&\n [\n <p>{this.resx?.dragAndDropFile}</p>\n ,\n <p>- {this.resx?.or} -</p>\n ,\n <label class=\"upload-file\">\n <input\n type=\"file\"\n ref={el => this.fileInput = el}\n onChange={e => this.handleUploadButton(e.target as HTMLInputElement)}\n >\n </input>\n <span>\n <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\"><g><rect fill=\"none\" height=\"24\" width=\"24\"/></g><g><path d=\"M5,20h14v-2H5V20z M5,10h4v6h6v-6h4l-7-7L5,10z\"/></g></svg>\n </span>\n &nbsp;\n {this.resx?.uploadFile}\n </label>\n ,\n this.canTakeSnapshots &&\n [\n <p>- {this.resx?.or} -</p>\n ,\n <button\n onClick={() => this.takeSnapshot()}\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#000000\"><path d=\"M0 0h24v24H0z\" fill=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"3.2\"/><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\"/></svg>\n {this.resx?.takePicture}\n </button>\n ]\n ]\n }\n {this.takingPicture &&\n <div class=\"video-preview\">\n <video ref={e => this.videoPreview = e} />\n <button\n onClick={() => this.applySnapshot()}\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#000000\"><path d=\"M0 0h24v24H0z\" fill=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"3.2\"/><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\"/></svg>&nbsp;\n {this.resx?.capture}\n </button>\n </div>\n }\n </Host>\n );\n }\n\n}\n"],"version":3}
@@ -1,2 +0,0 @@
1
- System.register(["./index-c3cc3b5b.system.js"],(function(e){"use strict";var t,i,n,r;return{setters:[function(e){t=e.r;i=e.e;n=e.h;r=e.f}],execute:function(){var o=":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}";var a=e("dnn_dropzone",function(){function e(e){var n=this;t(this,e);this.filesSelected=i(this,"filesSelected",7);this.resx={dragAndDropFile:"Drag and drop a file",capture:"Capture",or:"or",takePicture:"Take a picture",uploadFile:"Upload a file"};this.allowCameraMode=false;this.captureQuality=.8;this.canTakeSnapshots=false;this.takingPicture=false;this.handleDragOver=function(e){e.stopPropagation();e.preventDefault();e.dataTransfer.dropEffect="copy";n.dropzone.classList.add("dropping")};this.handleDrop=function(e){e.stopPropagation();e.preventDefault();var t=e.dataTransfer.files;if(n.hasInvalidExtensions(t)){return}var i=n.getFilesFromFileList(t);n.filesSelected.emit(i)}}e.prototype.componentDidLoad=function(){var e=this;if(this.allowCameraMode){this.checkIfBrowserCanTakeSnapshots().then((function(t){return e.canTakeSnapshots=t}))}if(this.allowedExtensions!=undefined&&this.allowedExtensions.length>0){var t=this.allowedExtensions.map((function(e){return".".concat(e)}));var i=t.join(",");this.fileInput.accept=i}};e.prototype.checkIfBrowserCanTakeSnapshots=function(){return new Promise((function(e){var t=navigator.mediaDevices;if(t==undefined||t.enumerateDevices==undefined){e(false)}t.enumerateDevices().then((function(t){var i=t.some((function(e){return e.kind=="videoinput"}));e(i)}))}))};e.prototype.getFilesFromFileList=function(e){var t=[];for(var i=0;i<e.length;i++){var n=e[i];t.push(n)}return t};e.prototype.handleUploadButton=function(e){var t=this.getFilesFromFileList(e.files);this.filesSelected.emit(t)};e.prototype.hasInvalidExtensions=function(e){var t=false;for(var i=0;i<e.length;i++){var n=e[i];var r=/(?:\.([^.]+))?$/;var o=r.exec(n.name)[1];if(o==undefined){t=true}if(this.allowedExtensions!=undefined&&!this.allowedExtensions.includes(o)){t=true}return t}};e.prototype.takeSnapshot=function(){var e=this;this.takingPicture=true;navigator.mediaDevices.getUserMedia({video:true,audio:false}).then((function(t){t;e.videoPreview.srcObject=t;e.videoPreview.play().then((function(){e.videoSettings=t.getVideoTracks()[0].getSettings()}))})).catch((function(e){return alert(e)}))};e.prototype.applySnapshot=function(){var e=this;var t=document.createElement("canvas");var i=t.getContext("2d");t.width=this.videoSettings.width;t.height=this.videoSettings.height;i.drawImage(this.videoPreview,0,0);t.toBlob((function(t){var i=new File([t],"image.jpeg",{type:"image/jpeg"});e.takingPicture=false;var n=[i];e.filesSelected.emit(n)}),"image/jpeg",this.captureQuality)};e.prototype.render=function(){var e=this;var t,i,o,a,s,l;return n(r,{ref:function(t){return e.dropzone=t},class:"dropzone",onDragOver:this.handleDragOver,onDrop:this.handleDrop,onDragLeave:function(){return e.dropzone.classList.remove("dropping")}},!this.takingPicture&&[n("p",null,(t=this.resx)===null||t===void 0?void 0:t.dragAndDropFile),n("p",null,"- ",(i=this.resx)===null||i===void 0?void 0:i.or," -"),n("label",{class:"upload-file"},n("input",{type:"file",ref:function(t){return e.fileInput=t},onChange:function(t){return e.handleUploadButton(t.target)}}),n("span",null,n("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"},n("g",null,n("rect",{fill:"none",height:"24",width:"24"})),n("g",null,n("path",{d:"M5,20h14v-2H5V20z M5,10h4v6h6v-6h4l-7-7L5,10z"}))))," ",(o=this.resx)===null||o===void 0?void 0:o.uploadFile),this.canTakeSnapshots&&[n("p",null,"- ",(a=this.resx)===null||a===void 0?void 0:a.or," -"),n("button",{onClick:function(){return e.takeSnapshot()}},n("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},n("path",{d:"M0 0h24v24H0z",fill:"none"}),n("circle",{cx:"12",cy:"12",r:"3.2"}),n("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"})),(s=this.resx)===null||s===void 0?void 0:s.takePicture)]],this.takingPicture&&n("div",{class:"video-preview"},n("video",{ref:function(t){return e.videoPreview=t}}),n("button",{onClick:function(){return e.applySnapshot()}},n("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},n("path",{d:"M0 0h24v24H0z",fill:"none"}),n("circle",{cx:"12",cy:"12",r:"3.2"}),n("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"}))," ",(l=this.resx)===null||l===void 0?void 0:l.capture)))};return e}());a.style=o}}}));
2
- //# sourceMappingURL=dnn-dropzone.system.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["src/components/dnn-dropzone/dnn-dropzone.scss?tag=dnn-dropzone&encapsulation=shadow","src/components/dnn-dropzone/dnn-dropzone.tsx"],"names":["dnnDropzoneCss","DnnDropzone","exports","class_1","hostRef","_this","this","resx","dragAndDropFile","capture","or","takePicture","uploadFile","allowCameraMode","captureQuality","canTakeSnapshots","takingPicture","handleDragOver","event","stopPropagation","preventDefault","dataTransfer","dropEffect","dropzone","classList","add","handleDrop","dropEvent","files","hasInvalidExtensions","fileList","getFilesFromFileList","filesSelected","emit","prototype","componentDidLoad","checkIfBrowserCanTakeSnapshots","then","result","allowedExtensions","undefined","length","extensionsWithDots","map","e","concat","extensionsList","join","fileInput","accept","Promise","resolve","mediaDevices","navigator","enumerateDevices","devices","some","device","kind","index","file","push","handleUploadButton","element","hasInvalid","fileIndex","regex","fileExtension","exec","name","includes","takeSnapshot","getUserMedia","video","audio","stream","videoPreview","srcObject","play","videoSettings","getVideoTracks","getSettings","catch","error","alert","applySnapshot","canvas","document","createElement","context","getContext","width","height","drawImage","toBlob","blob","File","type","render","h","Host","ref","class","onDragOver","onDrop","onDragLeave","remove","_a","_b","el","onChange","target","xmlns","enable-background","viewBox","fill","d","_c","_d","onClick","cx","cy","r","_e","_f"],"mappings":"8JAAA,IAAMA,EAAiB,inCCOVC,EAAWC,EAAA,eAAA,WALxB,SAAAC,EAAAC,GAAA,IAAAC,EAAAC,4DAOUA,KAAAC,KAMJ,CACFC,gBAAiB,uBACjBC,QAAS,UACTC,GAAI,KACJC,YAAa,iBAC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AAM,6BAA6BpB,OAAO,OAAOsB,QAAQ,YAAYvB,MAAM,OAAOwB,KAAK,WAAUhB,EAAA,OAAA,CAAMiB,EAAE,gBAAgBD,KAAK,SAAQhB,EAAA,SAAA,CAAQqB,GAAG,KAAKC,GAAG,KAAKC,EAAE,QAAOvB,EAAA,OAAA,CAAMiB,EAAE,gKACnLO,EAAArH,KAAKC,QAAI,MAAAoH,SAAA,OAAA,IAAEhH,eAKrBL,KAAKU,eACJmF,EAAA,MAAA,CAAKG,MAAM,iBACTH,EAAA,QAAA,CAAOE,IAAK,SAAAzD,GAAK,OAAAvC,EAAKuE,aAAehC,KACrCuD,EAAA,SAAA,CACEoB,QAAS,WAAM,OAAAlH,EAAKgF,kBAEpBc,EAAA,MAAA,CAAKa,MAAM,6BAA6BpB,OAAO,OAAOsB,QAAQ,YAAYvB,MAAM,OAAOwB,KAAK,WAAUhB,EAAA,OAAA,CAAMiB,EAAE,gBAAgBD,KAAK,SAAQhB,EAAA,SAAA,CAAQqB,GAAG,KAAKC,GAAG,KAAKC,EAAE,QAAOvB,EAAA,OAAA,CAAMiB,EAAE,+JAAmK,KACtVQ,EAAAtH,KAAKC,QAAI,MAAAqH,SAAA,OAAA,IAAEnH,qBA9MF","sourcesContent":["\n:host {\n /** \n * @prop --border-color: The color of the border.\n * @prop --border-radius: The radius of the controls borders.\n * @prop --drop-background-color: The color of the background when a file is dropping.\n */\n --border-color: var(--dnn-color-tertiary-contrast, lightgray);\n --border-radius: var(--dnn-controls-radius, 5px);\n --drop-background-color: var(--dnn-color-tertiary, lightblue);\n\n display: flex;\n flex-direction: column;\n gap: 1rem;\n text-align: center;\n border: 2px dashed var(--border-color);\n border-radius: var(--border-radius);\n padding: 1rem;\n transition: all 300ms ease-in-out;\n}\n\n:host(.dropping){\n background-color: var(--drop-background-color);\n}\np{\n margin: 0;\n padding: 0;\n}\nbutton{\n display: flex;\n justify-content: center;\n align-items: center;\n border: 0px;\n margin: 0;\n padding: 0;\n background-color: transparent;\n &:hover{\n cursor: pointer;\n }\n svg{\n margin-right: 0.5rem;\n }\n}\nlabel.upload-file{\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n input{\n display: none;\n }\n}\n.video-preview{\n display: flex;\n flex-direction: column;\n align-items: center;\n button{\n margin: 1rem;\n }\n}\n","import { Component, Host, h, Prop, State, Event, EventEmitter } from '@stencil/core';\n\n@Component({\n tag: 'dnn-dropzone',\n styleUrl: 'dnn-dropzone.scss',\n shadow: true,\n})\nexport class DnnDropzone {\n /** Localization strings */\n @Prop() resx:{\n dragAndDropFile: string;\n capture: string;\n or: string;\n takePicture: string;\n uploadFile: string;\n } = {\n dragAndDropFile: \"Drag and drop a file\",\n capture: \"Capture\",\n or: \"or\",\n takePicture: \"Take a picture\",\n uploadFile: \"Upload a file\",\n }\n\n /** A list of allowed file extensions.\n * If not specified, any file is allowed.\n * Ex: [\"jpg\", \"jped\", \"gif\", \"png\"]\n */\n @Prop() allowedExtensions: string[];\n\n /**\n * If true, will allow the user to take a snapshot\n * using the device camera. (only works over https).\n */\n @Prop() allowCameraMode: boolean = false;\n\n /**\n * Specifies the jpeg quality for when the device\n * camera is used to generate a picture.\n * Needs to be a number between 0 and 1 and defaults to 0.8\n */\n @Prop() captureQuality: number = 0.8;\n\n /** Fires when file were selected. */\n @Event() filesSelected: EventEmitter<File[]>;\n \n @State() canTakeSnapshots: boolean = false;\n\n @State() takingPicture: boolean = false;\n \n private dropzone: HTMLElement;\n private fileInput: HTMLInputElement;\n private videoPreview: HTMLVideoElement;\n private videoSettings!: MediaTrackSettings;\n\n\n componentDidLoad() {\n if (this.allowCameraMode){\n this.checkIfBrowserCanTakeSnapshots()\n .then(result => this.canTakeSnapshots = result);\n }\n if (this.allowedExtensions != undefined && this.allowedExtensions.length > 0){\n var extensionsWithDots = this.allowedExtensions.map(e => `.${e}`);\n var extensionsList = extensionsWithDots.join(\",\");\n this.fileInput.accept = extensionsList;\n }\n }\n\n private checkIfBrowserCanTakeSnapshots(): Promise<boolean> {\n return new Promise((resolve) => {\n const mediaDevices = navigator.mediaDevices;\n if (mediaDevices == undefined || mediaDevices.enumerateDevices == undefined) {\n resolve(false);\n }\n mediaDevices.enumerateDevices()\n .then(devices => {\n var result = devices.some(device => device.kind == \"videoinput\");\n resolve(result);\n });\n });\n }\n\n private getFilesFromFileList(files: FileList) : File[] {\n var fileList: File[] = [];\n for (let index = 0; index < files.length; index++) {\n const file = files[index];\n fileList.push(file);\n }\n\n return fileList;\n }\n\n private handleUploadButton(element: HTMLInputElement): void {\n let files = this.getFilesFromFileList(element.files);\n\n this.filesSelected.emit(files);\n }\n\n private handleDragOver = (event: DragEvent) => \n {\n event.stopPropagation();\n event.preventDefault();\n event.dataTransfer.dropEffect = \"copy\";\n this.dropzone.classList.add(\"dropping\");\n };\n\n private hasInvalidExtensions(files: FileList): boolean{\n var hasInvalid = false;\n for (let fileIndex = 0; fileIndex < files.length; fileIndex++) {\n const file = files[fileIndex];\n var regex = /(?:\\.([^.]+))?$/;\n const fileExtension = regex.exec(file.name)[1];\n if (fileExtension == undefined){\n hasInvalid = true;\n }\n\n if (this.allowedExtensions != undefined && !this.allowedExtensions.includes(fileExtension)){\n hasInvalid = true;\n }\n\n return hasInvalid;\n }\n }\n\n private handleDrop = (dropEvent: DragEvent) => {\n dropEvent.stopPropagation();\n dropEvent.preventDefault();\n const files = dropEvent.dataTransfer.files;\n\n if (this.hasInvalidExtensions(files)){\n return;\n }\n var fileList = this.getFilesFromFileList(files);\n this.filesSelected.emit(fileList);\n };\n\n private takeSnapshot(): void {\n this.takingPicture = true;\n navigator.mediaDevices.getUserMedia({video: true, audio: false})\n .then(stream => {\n stream\n this.videoPreview.srcObject = stream;\n this.videoPreview.play()\n .then(() => {\n this.videoSettings = stream.getVideoTracks()[0].getSettings();\n });\n })\n .catch(error => alert(error));\n }\n\n private applySnapshot(): void {\n var canvas = document.createElement(\"canvas\");\n const context = canvas.getContext(\"2d\");\n canvas.width = this.videoSettings.width;\n canvas.height = this.videoSettings.height;\n context.drawImage(this.videoPreview, 0, 0);\n canvas.toBlob(blob => {\n var file = new File([blob], \"image.jpeg\", {type:\"image/jpeg\"});\n this.takingPicture = false;\n \n var fileList = [file];\n this.filesSelected.emit(fileList)\n }, \"image/jpeg\", this.captureQuality);\n }\n \n render() {\n return (\n <Host\n ref={e => this.dropzone = e}\n class=\"dropzone\"\n onDragOver={this.handleDragOver}\n onDrop={this.handleDrop}\n onDragLeave={() => this.dropzone.classList.remove(\"dropping\")}\n >\n {!this.takingPicture &&\n [\n <p>{this.resx?.dragAndDropFile}</p>\n ,\n <p>- {this.resx?.or} -</p>\n ,\n <label class=\"upload-file\">\n <input\n type=\"file\"\n ref={el => this.fileInput = el}\n onChange={e => this.handleUploadButton(e.target as HTMLInputElement)}\n >\n </input>\n <span>\n <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\"><g><rect fill=\"none\" height=\"24\" width=\"24\"/></g><g><path d=\"M5,20h14v-2H5V20z M5,10h4v6h6v-6h4l-7-7L5,10z\"/></g></svg>\n </span>\n &nbsp;\n {this.resx?.uploadFile}\n </label>\n ,\n this.canTakeSnapshots &&\n [\n <p>- {this.resx?.or} -</p>\n ,\n <button\n onClick={() => this.takeSnapshot()}\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#000000\"><path d=\"M0 0h24v24H0z\" fill=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"3.2\"/><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\"/></svg>\n {this.resx?.takePicture}\n </button>\n ]\n ]\n }\n {this.takingPicture &&\n <div class=\"video-preview\">\n <video ref={e => this.videoPreview = e} />\n <button\n onClick={() => this.applySnapshot()}\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 0 24 24\" width=\"24px\" fill=\"#000000\"><path d=\"M0 0h24v24H0z\" fill=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"3.2\"/><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\"/></svg>&nbsp;\n {this.resx?.capture}\n </button>\n </div>\n }\n </Host>\n );\n }\n\n}\n"]}