@dnncommunity/dnn-elements 0.13.0-beta.1

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 (244) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -0
  3. package/dist/cjs/app-globals-3a1e7e63.js +7 -0
  4. package/dist/cjs/app-globals-3a1e7e63.js.map +1 -0
  5. package/dist/cjs/css-shim-3bfdba4f.js +8 -0
  6. package/dist/cjs/css-shim-3bfdba4f.js.map +1 -0
  7. package/dist/cjs/debounce-1de79bc7.js +24 -0
  8. package/dist/cjs/debounce-1de79bc7.js.map +1 -0
  9. package/dist/cjs/dnn-button.cjs.entry.js +88 -0
  10. package/dist/cjs/dnn-button.cjs.entry.js.map +1 -0
  11. package/dist/cjs/dnn-button_14.cjs.entry.js +1580 -0
  12. package/dist/cjs/dnn-button_14.cjs.entry.js.map +1 -0
  13. package/dist/cjs/dnn-checkbox.cjs.entry.js +58 -0
  14. package/dist/cjs/dnn-checkbox.cjs.entry.js.map +1 -0
  15. package/dist/cjs/dnn-chevron.cjs.entry.js +34 -0
  16. package/dist/cjs/dnn-chevron.cjs.entry.js.map +1 -0
  17. package/dist/cjs/dnn-collapsible.cjs.entry.js +112 -0
  18. package/dist/cjs/dnn-collapsible.cjs.entry.js.map +1 -0
  19. package/dist/cjs/dnn-color-picker.cjs.entry.js +508 -0
  20. package/dist/cjs/dnn-color-picker.cjs.entry.js.map +1 -0
  21. package/dist/cjs/dnn-dropzone.cjs.entry.js +153 -0
  22. package/dist/cjs/dnn-dropzone.cjs.entry.js.map +1 -0
  23. package/dist/cjs/dnn-image-cropper.cjs.entry.js +424 -0
  24. package/dist/cjs/dnn-image-cropper.cjs.entry.js.map +1 -0
  25. package/dist/cjs/dnn-modal.cjs.entry.js +62 -0
  26. package/dist/cjs/dnn-modal.cjs.entry.js.map +1 -0
  27. package/dist/cjs/dnn-searchbox.cjs.entry.js +66 -0
  28. package/dist/cjs/dnn-searchbox.cjs.entry.js.map +1 -0
  29. package/dist/cjs/dnn-sort-icon.cjs.entry.js +43 -0
  30. package/dist/cjs/dnn-sort-icon.cjs.entry.js.map +1 -0
  31. package/dist/cjs/dnn-tab.cjs.entry.js +31 -0
  32. package/dist/cjs/dnn-tab.cjs.entry.js.map +1 -0
  33. package/dist/cjs/dnn-tabs.cjs.entry.js +50 -0
  34. package/dist/cjs/dnn-tabs.cjs.entry.js.map +1 -0
  35. package/dist/cjs/dnn-toggle.cjs.entry.js +37 -0
  36. package/dist/cjs/dnn-toggle.cjs.entry.js.map +1 -0
  37. package/dist/cjs/dnn-treeview-item.cjs.entry.js +48 -0
  38. package/dist/cjs/dnn-treeview-item.cjs.entry.js.map +1 -0
  39. package/dist/cjs/dnn.cjs.js +129 -0
  40. package/dist/cjs/dnn.cjs.js.map +1 -0
  41. package/dist/cjs/dom-8ac1ad03.js +77 -0
  42. package/dist/cjs/dom-8ac1ad03.js.map +1 -0
  43. package/dist/cjs/index-e85ec026.js +1327 -0
  44. package/dist/cjs/index-e85ec026.js.map +1 -0
  45. package/dist/cjs/index-eede7745.js +3069 -0
  46. package/dist/cjs/index-eede7745.js.map +1 -0
  47. package/dist/cjs/index.cjs.js +52 -0
  48. package/dist/cjs/index.cjs.js.map +1 -0
  49. package/dist/cjs/loader.cjs.js +39 -0
  50. package/dist/cjs/loader.cjs.js.map +1 -0
  51. package/dist/cjs/shadow-css-41d9783d.js +392 -0
  52. package/dist/cjs/shadow-css-41d9783d.js.map +1 -0
  53. package/dist/collection/collection-manifest.json +25 -0
  54. package/dist/collection/components/dnn-button/dnn-button.css +87 -0
  55. package/dist/collection/components/dnn-button/dnn-button.js +272 -0
  56. package/dist/collection/components/dnn-button/dnn-button.js.map +1 -0
  57. package/dist/collection/components/dnn-checkbox/dnn-checkbox.css +27 -0
  58. package/dist/collection/components/dnn-checkbox/dnn-checkbox.js +140 -0
  59. package/dist/collection/components/dnn-checkbox/dnn-checkbox.js.map +1 -0
  60. package/dist/collection/components/dnn-chevron/dnn-chevron.css +30 -0
  61. package/dist/collection/components/dnn-chevron/dnn-chevron.js +107 -0
  62. package/dist/collection/components/dnn-chevron/dnn-chevron.js.map +1 -0
  63. package/dist/collection/components/dnn-collapsible/dnn-collapsible.css +8 -0
  64. package/dist/collection/components/dnn-collapsible/dnn-collapsible.js +188 -0
  65. package/dist/collection/components/dnn-collapsible/dnn-collapsible.js.map +1 -0
  66. package/dist/collection/components/dnn-color-picker/dnn-color-picker.css +225 -0
  67. package/dist/collection/components/dnn-color-picker/dnn-color-picker.js +434 -0
  68. package/dist/collection/components/dnn-color-picker/dnn-color-picker.js.map +1 -0
  69. package/dist/collection/components/dnn-dropzone/dnn-dropzone.css +62 -0
  70. package/dist/collection/components/dnn-dropzone/dnn-dropzone.js +266 -0
  71. package/dist/collection/components/dnn-dropzone/dnn-dropzone.js.map +1 -0
  72. package/dist/collection/components/dnn-image-cropper/CornerType.js +9 -0
  73. package/dist/collection/components/dnn-image-cropper/CornerType.js.map +1 -0
  74. package/dist/collection/components/dnn-image-cropper/dnn-image-cropper.css +80 -0
  75. package/dist/collection/components/dnn-image-cropper/dnn-image-cropper.js +539 -0
  76. package/dist/collection/components/dnn-image-cropper/dnn-image-cropper.js.map +1 -0
  77. package/dist/collection/components/dnn-modal/dnn-modal.css +67 -0
  78. package/dist/collection/components/dnn-modal/dnn-modal.js +173 -0
  79. package/dist/collection/components/dnn-modal/dnn-modal.js.map +1 -0
  80. package/dist/collection/components/dnn-searchbox/dnn-searchbox.css +48 -0
  81. package/dist/collection/components/dnn-searchbox/dnn-searchbox.js +137 -0
  82. package/dist/collection/components/dnn-searchbox/dnn-searchbox.js.map +1 -0
  83. package/dist/collection/components/dnn-sort-icon/dnn-sort-icon.css +32 -0
  84. package/dist/collection/components/dnn-sort-icon/dnn-sort-icon.js +81 -0
  85. package/dist/collection/components/dnn-sort-icon/dnn-sort-icon.js.map +1 -0
  86. package/dist/collection/components/dnn-tab/dnn-tab.css +0 -0
  87. package/dist/collection/components/dnn-tab/dnn-tab.js +84 -0
  88. package/dist/collection/components/dnn-tab/dnn-tab.js.map +1 -0
  89. package/dist/collection/components/dnn-tabs/dnn-tabs.css +40 -0
  90. package/dist/collection/components/dnn-tabs/dnn-tabs.js +53 -0
  91. package/dist/collection/components/dnn-tabs/dnn-tabs.js.map +1 -0
  92. package/dist/collection/components/dnn-toggle/dnn-toggle.css +52 -0
  93. package/dist/collection/components/dnn-toggle/dnn-toggle.js +94 -0
  94. package/dist/collection/components/dnn-toggle/dnn-toggle.js.map +1 -0
  95. package/dist/collection/components/dnn-toggle/toggle-interface.js +2 -0
  96. package/dist/collection/components/dnn-toggle/toggle-interface.js.map +1 -0
  97. package/dist/collection/components/dnn-treeview-item/dnn-treeview-item.css +47 -0
  98. package/dist/collection/components/dnn-treeview-item/dnn-treeview-item.js +77 -0
  99. package/dist/collection/components/dnn-treeview-item/dnn-treeview-item.js.map +1 -0
  100. package/dist/collection/index.js +3 -0
  101. package/dist/collection/index.js.map +1 -0
  102. package/dist/collection/utilities/colorInfo.js +191 -0
  103. package/dist/collection/utilities/colorInfo.js.map +1 -0
  104. package/dist/collection/utilities/debounce.js +19 -0
  105. package/dist/collection/utilities/debounce.js.map +1 -0
  106. package/dist/collection/utilities/dnnServicesFramework.js +42 -0
  107. package/dist/collection/utilities/dnnServicesFramework.js.map +1 -0
  108. package/dist/dnn/app-globals-0f993ce5.js +5 -0
  109. package/dist/dnn/app-globals-0f993ce5.js.map +1 -0
  110. package/dist/dnn/css-shim-20dbffa5.js +6 -0
  111. package/dist/dnn/css-shim-20dbffa5.js.map +1 -0
  112. package/dist/dnn/debounce-06f55268.js +22 -0
  113. package/dist/dnn/debounce-06f55268.js.map +1 -0
  114. package/dist/dnn/dnn-button.entry.js +84 -0
  115. package/dist/dnn/dnn-button.entry.js.map +1 -0
  116. package/dist/dnn/dnn-checkbox.entry.js +54 -0
  117. package/dist/dnn/dnn-checkbox.entry.js.map +1 -0
  118. package/dist/dnn/dnn-chevron.entry.js +30 -0
  119. package/dist/dnn/dnn-chevron.entry.js.map +1 -0
  120. package/dist/dnn/dnn-collapsible.entry.js +108 -0
  121. package/dist/dnn/dnn-collapsible.entry.js.map +1 -0
  122. package/dist/dnn/dnn-color-picker.entry.js +504 -0
  123. package/dist/dnn/dnn-color-picker.entry.js.map +1 -0
  124. package/dist/dnn/dnn-dropzone.entry.js +149 -0
  125. package/dist/dnn/dnn-dropzone.entry.js.map +1 -0
  126. package/dist/dnn/dnn-image-cropper.entry.js +420 -0
  127. package/dist/dnn/dnn-image-cropper.entry.js.map +1 -0
  128. package/dist/dnn/dnn-modal.entry.js +58 -0
  129. package/dist/dnn/dnn-modal.entry.js.map +1 -0
  130. package/dist/dnn/dnn-searchbox.entry.js +62 -0
  131. package/dist/dnn/dnn-searchbox.entry.js.map +1 -0
  132. package/dist/dnn/dnn-sort-icon.entry.js +39 -0
  133. package/dist/dnn/dnn-sort-icon.entry.js.map +1 -0
  134. package/dist/dnn/dnn-tab.entry.js +27 -0
  135. package/dist/dnn/dnn-tab.entry.js.map +1 -0
  136. package/dist/dnn/dnn-tabs.entry.js +46 -0
  137. package/dist/dnn/dnn-tabs.entry.js.map +1 -0
  138. package/dist/dnn/dnn-toggle.entry.js +33 -0
  139. package/dist/dnn/dnn-toggle.entry.js.map +1 -0
  140. package/dist/dnn/dnn-treeview-item.entry.js +44 -0
  141. package/dist/dnn/dnn-treeview-item.entry.js.map +1 -0
  142. package/dist/dnn/dnn.esm.js +127 -0
  143. package/dist/dnn/dnn.esm.js.map +1 -0
  144. package/dist/dnn/dom-c5ed0ba5.js +75 -0
  145. package/dist/dnn/dom-c5ed0ba5.js.map +1 -0
  146. package/dist/dnn/index-6c0764e5.js +3033 -0
  147. package/dist/dnn/index-6c0764e5.js.map +1 -0
  148. package/dist/dnn/index.esm.js +47 -0
  149. package/dist/dnn/index.esm.js.map +1 -0
  150. package/dist/dnn/p-0e94f5ee.js +2 -0
  151. package/dist/dnn/p-0e94f5ee.js.map +1 -0
  152. package/dist/dnn/p-7acf3104.entry.js +11 -0
  153. package/dist/dnn/p-7acf3104.entry.js.map +1 -0
  154. package/dist/dnn/p-bd3d3361.js +2 -0
  155. package/dist/dnn/p-bd3d3361.js.map +1 -0
  156. package/dist/dnn/shadow-css-8c625855.js +390 -0
  157. package/dist/dnn/shadow-css-8c625855.js.map +1 -0
  158. package/dist/esm/app-globals-0f993ce5.js +5 -0
  159. package/dist/esm/app-globals-0f993ce5.js.map +1 -0
  160. package/dist/esm/css-shim-20dbffa5.js +6 -0
  161. package/dist/esm/css-shim-20dbffa5.js.map +1 -0
  162. package/dist/esm/debounce-06f55268.js +22 -0
  163. package/dist/esm/debounce-06f55268.js.map +1 -0
  164. package/dist/esm/dnn-button.entry.js +84 -0
  165. package/dist/esm/dnn-button.entry.js.map +1 -0
  166. package/dist/esm/dnn-button_14.entry.js +1563 -0
  167. package/dist/esm/dnn-button_14.entry.js.map +1 -0
  168. package/dist/esm/dnn-checkbox.entry.js +54 -0
  169. package/dist/esm/dnn-checkbox.entry.js.map +1 -0
  170. package/dist/esm/dnn-chevron.entry.js +30 -0
  171. package/dist/esm/dnn-chevron.entry.js.map +1 -0
  172. package/dist/esm/dnn-collapsible.entry.js +108 -0
  173. package/dist/esm/dnn-collapsible.entry.js.map +1 -0
  174. package/dist/esm/dnn-color-picker.entry.js +504 -0
  175. package/dist/esm/dnn-color-picker.entry.js.map +1 -0
  176. package/dist/esm/dnn-dropzone.entry.js +149 -0
  177. package/dist/esm/dnn-dropzone.entry.js.map +1 -0
  178. package/dist/esm/dnn-image-cropper.entry.js +420 -0
  179. package/dist/esm/dnn-image-cropper.entry.js.map +1 -0
  180. package/dist/esm/dnn-modal.entry.js +58 -0
  181. package/dist/esm/dnn-modal.entry.js.map +1 -0
  182. package/dist/esm/dnn-searchbox.entry.js +62 -0
  183. package/dist/esm/dnn-searchbox.entry.js.map +1 -0
  184. package/dist/esm/dnn-sort-icon.entry.js +39 -0
  185. package/dist/esm/dnn-sort-icon.entry.js.map +1 -0
  186. package/dist/esm/dnn-tab.entry.js +27 -0
  187. package/dist/esm/dnn-tab.entry.js.map +1 -0
  188. package/dist/esm/dnn-tabs.entry.js +46 -0
  189. package/dist/esm/dnn-tabs.entry.js.map +1 -0
  190. package/dist/esm/dnn-toggle.entry.js +33 -0
  191. package/dist/esm/dnn-toggle.entry.js.map +1 -0
  192. package/dist/esm/dnn-treeview-item.entry.js +44 -0
  193. package/dist/esm/dnn-treeview-item.entry.js.map +1 -0
  194. package/dist/esm/dnn.js +127 -0
  195. package/dist/esm/dnn.js.map +1 -0
  196. package/dist/esm/dom-c5ed0ba5.js +75 -0
  197. package/dist/esm/dom-c5ed0ba5.js.map +1 -0
  198. package/dist/esm/index-6c0764e5.js +3033 -0
  199. package/dist/esm/index-6c0764e5.js.map +1 -0
  200. package/dist/esm/index-f79d9e82.js +1299 -0
  201. package/dist/esm/index-f79d9e82.js.map +1 -0
  202. package/dist/esm/index.js +47 -0
  203. package/dist/esm/index.js.map +1 -0
  204. package/dist/esm/loader.js +35 -0
  205. package/dist/esm/loader.js.map +1 -0
  206. package/dist/esm/polyfills/core-js.js +11 -0
  207. package/dist/esm/polyfills/css-shim.js +1 -0
  208. package/dist/esm/polyfills/dom.js +79 -0
  209. package/dist/esm/polyfills/es5-html-element.js +1 -0
  210. package/dist/esm/polyfills/index.js +34 -0
  211. package/dist/esm/polyfills/system.js +6 -0
  212. package/dist/esm/shadow-css-8c625855.js +390 -0
  213. package/dist/esm/shadow-css-8c625855.js.map +1 -0
  214. package/dist/index.cjs.js +1 -0
  215. package/dist/index.js +1 -0
  216. package/dist/types/components/dnn-button/dnn-button.d.ts +55 -0
  217. package/dist/types/components/dnn-checkbox/dnn-checkbox.d.ts +16 -0
  218. package/dist/types/components/dnn-chevron/dnn-chevron.d.ts +13 -0
  219. package/dist/types/components/dnn-collapsible/dnn-collapsible.d.ts +22 -0
  220. package/dist/types/components/dnn-color-picker/dnn-color-picker.d.ts +46 -0
  221. package/dist/types/components/dnn-dropzone/dnn-dropzone.d.ts +45 -0
  222. package/dist/types/components/dnn-image-cropper/CornerType.d.ts +6 -0
  223. package/dist/types/components/dnn-image-cropper/dnn-image-cropper.d.ts +62 -0
  224. package/dist/types/components/dnn-modal/dnn-modal.d.ts +35 -0
  225. package/dist/types/components/dnn-searchbox/dnn-searchbox.d.ts +22 -0
  226. package/dist/types/components/dnn-sort-icon/dnn-sort-icon.d.ts +9 -0
  227. package/dist/types/components/dnn-tab/dnn-tab.d.ts +11 -0
  228. package/dist/types/components/dnn-tabs/dnn-tabs.d.ts +11 -0
  229. package/dist/types/components/dnn-toggle/dnn-toggle.d.ts +13 -0
  230. package/dist/types/components/dnn-toggle/toggle-interface.d.ts +3 -0
  231. package/dist/types/components/dnn-treeview-item/dnn-treeview-item.d.ts +16 -0
  232. package/dist/types/components.d.ts +611 -0
  233. package/dist/types/index.d.ts +3 -0
  234. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  235. package/dist/types/utilities/colorInfo.d.ts +52 -0
  236. package/dist/types/utilities/debounce.d.ts +5 -0
  237. package/dist/types/utilities/dnnServicesFramework.d.ts +19 -0
  238. package/loader/cdn.js +3 -0
  239. package/loader/index.cjs.js +3 -0
  240. package/loader/index.d.ts +12 -0
  241. package/loader/index.es2017.js +3 -0
  242. package/loader/index.js +4 -0
  243. package/loader/package.json +10 -0
  244. package/package.json +48 -0
@@ -0,0 +1,434 @@
1
+ /** Reusable DNN UI component to pick a color
2
+ * @copyright Copyright (c) .NET Foundation. All rights reserved.
3
+ * @license MIT
4
+ */
5
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
6
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
8
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ import { Component, h, State, Element, Prop, Event, Watch } from "@stencil/core";
12
+ import { ColorInfo } from '../../utilities/colorInfo';
13
+ import { Debounce } from "../../utilities/debounce";
14
+ /** Color Picker for Dnn */
15
+ export class DnnColorPicker {
16
+ constructor() {
17
+ /** Sets the initial color, must be a valid 8 character hexadecimal string without the # sign. */
18
+ this.color = "FFFFFF";
19
+ /** Sets the width-height ratio of the color picker saturation-lightness box.
20
+ * @example 100% renders a perfect square
21
+ */
22
+ this.colorBoxHeight = "50%";
23
+ this.rgbDisplay = "flex";
24
+ this.hslDisplay = "none";
25
+ this.hexDisplay = "none";
26
+ this.handleSaturationLightnessMouseDown = (e) => {
27
+ e.preventDefault();
28
+ this.handleDragLightnessSaturation(e);
29
+ window.addEventListener('mousemove', this.handleDragLightnessSaturation);
30
+ window.addEventListener('mouseup', this.handleSaturationLightnessMouseUp);
31
+ };
32
+ this.handleDragLightnessSaturation = (e) => {
33
+ const rect = this.saturationLightnessBox.getBoundingClientRect();
34
+ let x = e.clientX - rect.left;
35
+ if (x < 0) {
36
+ x = 0;
37
+ }
38
+ if (x > rect.width) {
39
+ x = rect.width;
40
+ }
41
+ x = x / rect.width;
42
+ let y = e.clientY - rect.top;
43
+ if (y < 0) {
44
+ y = 0;
45
+ }
46
+ if (y > rect.height) {
47
+ y = rect.height;
48
+ }
49
+ y = 1 - (y / rect.height);
50
+ const newColor = new ColorInfo();
51
+ newColor.hue = this.currentColor.hue;
52
+ newColor.saturation = x;
53
+ newColor.lightness = y;
54
+ this.currentColor = newColor;
55
+ };
56
+ this.handleSaturationLightnessMouseUp = () => {
57
+ window.removeEventListener('mousemove', this.handleDragLightnessSaturation);
58
+ window.removeEventListener('mouseup', this.handleSaturationLightnessMouseUp);
59
+ };
60
+ this.handleHueMouseDown = (e) => {
61
+ e.preventDefault();
62
+ this.handleDragHue(e);
63
+ window.addEventListener('mousemove', this.handleDragHue);
64
+ window.addEventListener('mouseup', this.handleHueMouseUp);
65
+ };
66
+ this.handleHueMouseUp = () => {
67
+ window.removeEventListener('mousemove', this.handleDragHue);
68
+ window.removeEventListener('mouseup', this.handleHueMouseUp);
69
+ };
70
+ this.handleDragHue = (e) => {
71
+ const rect = this.hueRange.getBoundingClientRect();
72
+ let x = e.clientX - rect.left;
73
+ if (x < 0) {
74
+ x = 0;
75
+ }
76
+ if (x > rect.width) {
77
+ x = rect.width;
78
+ }
79
+ x = x / rect.width * 360;
80
+ const newColor = new ColorInfo();
81
+ newColor.hue = x;
82
+ newColor.saturation = this.currentColor.saturation;
83
+ newColor.lightness = this.currentColor.lightness;
84
+ this.currentColor = newColor;
85
+ };
86
+ this.handleComponentValueChange = (e, channel) => {
87
+ let value = parseInt(e.target.value);
88
+ if (isNaN(value)) {
89
+ return;
90
+ }
91
+ const newColor = new ColorInfo();
92
+ if (value < 0) {
93
+ value = 0;
94
+ }
95
+ if (value > 255) {
96
+ value = 255;
97
+ }
98
+ let r = this.currentColor.red;
99
+ let g = this.currentColor.green;
100
+ let b = this.currentColor.blue;
101
+ switch (channel) {
102
+ case 'red':
103
+ r = value;
104
+ break;
105
+ case 'green':
106
+ g = value;
107
+ break;
108
+ case 'blue':
109
+ b = value;
110
+ break;
111
+ default:
112
+ break;
113
+ }
114
+ newColor.green = g;
115
+ newColor.red = r;
116
+ newColor.blue = b;
117
+ this.currentColor = newColor;
118
+ };
119
+ this.handleHSLChange = (e, component) => {
120
+ let value = parseInt(e.target.value);
121
+ if (isNaN(value)) {
122
+ return;
123
+ }
124
+ const newColor = new ColorInfo();
125
+ if (value != null) {
126
+ let h = this.currentColor.hue;
127
+ let s = this.currentColor.saturation;
128
+ let l = this.currentColor.lightness;
129
+ switch (component) {
130
+ case "hue":
131
+ if (value < 0) {
132
+ value = 0;
133
+ }
134
+ if (value > 359) {
135
+ value = 0;
136
+ }
137
+ h = value;
138
+ break;
139
+ case "saturation":
140
+ if (value < 0) {
141
+ value = 0;
142
+ }
143
+ if (value > 100) {
144
+ value = 100;
145
+ }
146
+ s = value / 100;
147
+ break;
148
+ case "lightness":
149
+ if (value < 0) {
150
+ value = 0;
151
+ }
152
+ if (value > 100) {
153
+ value = 100;
154
+ }
155
+ l = value / 100;
156
+ break;
157
+ default:
158
+ break;
159
+ }
160
+ newColor.hue = h;
161
+ newColor.saturation = s;
162
+ newColor.lightness = l;
163
+ this.currentColor = newColor;
164
+ }
165
+ };
166
+ this.handleSaturationLightnessKeyDown = (e) => {
167
+ let newColor = new ColorInfo();
168
+ newColor.hue = this.currentColor.hue;
169
+ newColor.saturation = this.currentColor.saturation;
170
+ newColor.lightness = this.currentColor.lightness;
171
+ let value = 0.01;
172
+ if (e.shiftKey) {
173
+ value = 0.1;
174
+ }
175
+ switch (e.key) {
176
+ case "ArrowUp":
177
+ newColor.lightness += value;
178
+ break;
179
+ case "ArrowDown":
180
+ newColor.lightness -= value;
181
+ break;
182
+ case "ArrowLeft":
183
+ newColor.saturation -= value;
184
+ break;
185
+ case "ArrowRight":
186
+ newColor.saturation += value;
187
+ default:
188
+ break;
189
+ }
190
+ this.currentColor = newColor;
191
+ };
192
+ this.handleHueKeyDown = (e) => {
193
+ let newColor = new ColorInfo();
194
+ newColor.hue = this.currentColor.hue;
195
+ newColor.saturation = this.currentColor.saturation;
196
+ newColor.lightness = this.currentColor.lightness;
197
+ let value = 1;
198
+ if (e.shiftKey) {
199
+ value = 10;
200
+ }
201
+ switch (e.key) {
202
+ case "ArrowLeft":
203
+ newColor.hue -= value;
204
+ break;
205
+ case "ArrowRight":
206
+ newColor.hue += value;
207
+ default:
208
+ break;
209
+ }
210
+ this.currentColor = newColor;
211
+ };
212
+ }
213
+ colorChangedHandler(color) {
214
+ this.colorChanged.emit(color);
215
+ }
216
+ handeCurrentColorChanged(newValue) {
217
+ this.colorChangedHandler(newValue);
218
+ }
219
+ componentWillLoad() {
220
+ this.handleHexChange(this.color);
221
+ }
222
+ componentDidLoad() {
223
+ this.el.style.setProperty("--color-box-height", this.colorBoxHeight.toString());
224
+ }
225
+ getHex() {
226
+ return this.getDoublet(this.currentColor.red) + this.getDoublet(this.currentColor.green) + this.getDoublet(this.currentColor.blue);
227
+ }
228
+ getContrast() {
229
+ return this.currentColor.contrastColor;
230
+ }
231
+ getDoublet(value) {
232
+ const valueString = value.toString(16).toUpperCase();
233
+ if (valueString.length === 1) {
234
+ return '0' + valueString;
235
+ }
236
+ return valueString;
237
+ }
238
+ handleHexChange(value) {
239
+ const newColor = new ColorInfo();
240
+ if (value.match(/^(?:[\da-f]{3}|[\da-f]{6})$/i).length > 0) {
241
+ if (value.length === 3) {
242
+ let expanded = value[0] + value[0] + value[1] + value[1] + value[2] + value[2];
243
+ value = expanded;
244
+ }
245
+ newColor.red = parseInt(value.substr(0, 2), 16);
246
+ newColor.green = parseInt(value.substr(2, 2), 16);
247
+ newColor.blue = parseInt(value.substr(4, 2), 16);
248
+ }
249
+ else {
250
+ newColor.red = this.currentColor.red;
251
+ newColor.green = this.currentColor.green;
252
+ newColor.blue = this.currentColor.blue;
253
+ }
254
+ this.currentColor = newColor;
255
+ }
256
+ switchColorMode(e) {
257
+ switch (e.target.id) {
258
+ case "rgb-switch":
259
+ this.rgbDisplay = "none";
260
+ this.hslDisplay = "none";
261
+ this.hexDisplay = "flex";
262
+ break;
263
+ case "hex-switch":
264
+ this.rgbDisplay = "none";
265
+ this.hslDisplay = "flex";
266
+ this.hexDisplay = "none";
267
+ break;
268
+ case "hsl-switch":
269
+ this.rgbDisplay = "flex";
270
+ this.hslDisplay = "none";
271
+ this.hexDisplay = "none";
272
+ break;
273
+ default:
274
+ this.rgbDisplay = "flex";
275
+ this.hslDisplay = "none";
276
+ this.hexDisplay = "none";
277
+ }
278
+ }
279
+ render() {
280
+ const hue = this.currentColor.hue;
281
+ const saturation = this.currentColor.saturation;
282
+ const lightness = this.currentColor.lightness;
283
+ const red = this.currentColor.red;
284
+ const green = this.currentColor.green;
285
+ const blue = this.currentColor.blue;
286
+ return (h("div", { class: "dnn-color-picker" },
287
+ h("div", { class: "dnn-color-sliders" },
288
+ h("div", { class: "dnn-color-s-b", ref: (element) => this.saturationLightnessBox = element, style: { backgroundColor: `hsl(${hue},100%,50%)` }, onMouseDown: this.handleSaturationLightnessMouseDown.bind(this) },
289
+ 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: {
290
+ left: Math.round(saturation * 100) + "%",
291
+ bottom: Math.round(lightness * 100) + "%"
292
+ }, onKeyDown: (e) => this.handleSaturationLightnessKeyDown(e) })),
293
+ h("div", { class: "dnn-color-bar" },
294
+ h("div", { class: "dnn-color-result", style: {
295
+ backgroundColor: '#' + this.getHex(),
296
+ boxShadow: "0 0 2px 1px " + "#" + this.getContrast()
297
+ } }),
298
+ h("div", { class: "dnn-color-hue", ref: (element) => this.hueRange = element, onMouseDown: this.handleHueMouseDown.bind(this) },
299
+ 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) })))),
300
+ h("div", { class: "dnn-color-fields" },
301
+ h("div", { class: "dnn-rgb-color-fields", style: { display: this.rgbDisplay } },
302
+ h("div", { class: "dnn-rgb-color-field" },
303
+ h("label", null, "R"),
304
+ h("input", { type: "number", min: "0", max: "255", step: "1", class: "red", value: red, "aria-label": "red value", onChange: (e) => this.handleComponentValueChange(e, 'red') })),
305
+ h("div", { class: "dnn-rgb-color-field" },
306
+ h("label", null, "G"),
307
+ h("input", { type: "number", min: "0", max: "255", class: "green", value: green, "aria-label": "green value", onChange: (e) => this.handleComponentValueChange(e, 'green') })),
308
+ h("div", { class: "dnn-rgb-color-field" },
309
+ h("label", null, "B"),
310
+ h("input", { type: "number", min: "0", max: "255", class: "blue", value: blue, "aria-label": "blue value", onChange: (e) => this.handleComponentValueChange(e, 'blue') })),
311
+ h("div", { class: "dnn-color-mode-switch" },
312
+ h("button", { id: "rgb-switch", onClick: this.switchColorMode.bind(this), "aria-label": "switch to hexadecimal value entry" },
313
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" },
314
+ h("path", { d: "M0 0h24v24H0z", fill: "none" }),
315
+ h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))),
316
+ h("div", { class: "dnn-hsl-color-fields", style: { display: this.hslDisplay } },
317
+ h("div", { class: "dnn-hsl-color-field" },
318
+ h("label", null, "H"),
319
+ h("input", { type: "number", min: "0", max: "359", step: 1, value: Math.round(hue), "aria-label": "Hue", onChange: (e) => this.handleHSLChange(e, 'hue') })),
320
+ h("div", { class: "dnn-hsl-color-field" },
321
+ h("label", null, "S"),
322
+ h("input", { type: "number", min: "0", max: "100", step: 1, value: Math.round(saturation * 100), "aria-label": "Saturation", onChange: (e) => this.handleHSLChange(e, 'saturation') })),
323
+ h("div", { class: "dnn-hsl-color-field" },
324
+ h("label", null, "L"),
325
+ h("input", { type: "number", min: "0", max: "100", step: 1, value: Math.round(lightness * 100), "aria-label": "Lightness", onChange: (e) => this.handleHSLChange(e, 'lightness') })),
326
+ h("div", { class: "dnn-color-mode-switch" },
327
+ h("button", { id: "hsl-switch", onClick: this.switchColorMode.bind(this), "aria-label": "Switch to red, green, blue entry mode" },
328
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" },
329
+ h("path", { d: "M0 0h24v24H0z", fill: "none" }),
330
+ h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))),
331
+ h("div", { class: "dnn-hex-color-fields", style: { display: this.hexDisplay } },
332
+ h("div", { class: "dnn-hex-color-field" },
333
+ h("label", null, "HEX"),
334
+ h("div", { class: "hex-input" },
335
+ h("input", { type: "text", "aria-label": "Hexadecimal value", value: this.getHex(), onChange: e => this.handleHexChange(e.target.value) }),
336
+ h("button", { class: "copy", "aria-label": "copy value" },
337
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" },
338
+ h("path", { d: "M0 0h24v24H0z", fill: "none" }),
339
+ 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" }))))),
340
+ h("div", { class: "dnn-color-mode-switch" },
341
+ h("button", { id: "hex-switch", onClick: this.switchColorMode.bind(this), "aria-label": "Switch to hue saturation lightness values" },
342
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" },
343
+ h("path", { d: "M0 0h24v24H0z", fill: "none" }),
344
+ h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))))));
345
+ }
346
+ static get is() { return "dnn-color-picker"; }
347
+ static get encapsulation() { return "shadow"; }
348
+ static get originalStyleUrls() { return {
349
+ "$": ["dnn-color-picker.scss"]
350
+ }; }
351
+ static get styleUrls() { return {
352
+ "$": ["dnn-color-picker.css"]
353
+ }; }
354
+ static get properties() { return {
355
+ "color": {
356
+ "type": "string",
357
+ "mutable": false,
358
+ "complexType": {
359
+ "original": "string",
360
+ "resolved": "string",
361
+ "references": {}
362
+ },
363
+ "required": false,
364
+ "optional": false,
365
+ "docs": {
366
+ "tags": [],
367
+ "text": "Sets the initial color, must be a valid 8 character hexadecimal string without the # sign."
368
+ },
369
+ "attribute": "color",
370
+ "reflect": false,
371
+ "defaultValue": "\"FFFFFF\""
372
+ },
373
+ "colorBoxHeight": {
374
+ "type": "string",
375
+ "mutable": false,
376
+ "complexType": {
377
+ "original": "string",
378
+ "resolved": "string",
379
+ "references": {}
380
+ },
381
+ "required": false,
382
+ "optional": false,
383
+ "docs": {
384
+ "tags": [{
385
+ "name": "example",
386
+ "text": "100% renders a perfect square"
387
+ }],
388
+ "text": "Sets the width-height ratio of the color picker saturation-lightness box."
389
+ },
390
+ "attribute": "color-box-height",
391
+ "reflect": false,
392
+ "defaultValue": "\"50%\""
393
+ }
394
+ }; }
395
+ static get states() { return {
396
+ "currentColor": {},
397
+ "rgbDisplay": {},
398
+ "hslDisplay": {},
399
+ "hexDisplay": {}
400
+ }; }
401
+ static get events() { return [{
402
+ "method": "colorChanged",
403
+ "name": "colorChanged",
404
+ "bubbles": true,
405
+ "cancelable": true,
406
+ "composed": true,
407
+ "docs": {
408
+ "tags": [{
409
+ "name": "see",
410
+ "text": ".. /../utilities/colorInfo.ts"
411
+ }],
412
+ "text": "Fires up when the color is changed and emits a ColorInfo object"
413
+ },
414
+ "complexType": {
415
+ "original": "ColorInfo",
416
+ "resolved": "ColorInfo",
417
+ "references": {
418
+ "ColorInfo": {
419
+ "location": "import",
420
+ "path": "../../utilities/colorInfo"
421
+ }
422
+ }
423
+ }
424
+ }]; }
425
+ static get elementRef() { return "el"; }
426
+ static get watchers() { return [{
427
+ "propName": "currentColor",
428
+ "methodName": "handeCurrentColorChanged"
429
+ }]; }
430
+ }
431
+ __decorate([
432
+ Debounce(100)
433
+ ], DnnColorPicker.prototype, "colorChangedHandler", null);
434
+ //# sourceMappingURL=dnn-color-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dnn-color-picker.js","sourceRoot":"","sources":["../../../src/components/dnn-color-picker/dnn-color-picker.tsx"],"names":[],"mappings":"AAAA;;;GAGG;;;;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B;YAClB,WAAK,KAAK,EAAC,WAAW;cAClB,aAAO,IAAI,EAAC,MAAM,gBAAY,mBAAmB,EAC7C,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,EACpB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAE,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAC,GAC3E;cACF,cACI,KAAK,EAAC,MAAM,gBACD,YAAY;gBAEvB,WAAK,KAAK,EAAC,4BAA4B,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,MAAM,EAAC,IAAI,EAAC,SAAS;kBAAC,YAAM,CAAC,EAAC,eAAe,EAAC,IAAI,EAAC,MAAM,GAAE;kBAAA,YAAM,CAAC,EAAC,iIAAiI,GAAE,CAAM,CACvR,CACP,CACJ;UACN,WAAK,KAAK,EAAC,uBAAuB;YAC9B,cACI,EAAE,EAAC,YAAY,EACf,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,gBAC7B,2CAA2C;cAEtD,WAAK,KAAK,EAAC,4BAA4B,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,MAAM,EAAC,IAAI,EAAC,SAAS;gBAAC,YAAM,CAAC,EAAC,eAAe,EAAC,IAAI,EAAC,MAAM,GAAE;gBAAA,YAAM,CAAC,EAAC,iEAAiE,GAAE,CAAM,CACvN,CACP,CACJ,CACJ,CACJ,CACT,CAAC;EACN,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ;AApYG;EADC,QAAQ,CAAC,GAAG,CAAC;yDAGb","sourcesContent":["/** 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}"]}
@@ -0,0 +1,62 @@
1
+ :host {
2
+ /**
3
+ * @prop --border-color: The color of the border.
4
+ * @prop --border-radius: The radius of the controls borders.
5
+ * @prop --drop-background-color: The color of the background when a file is dropping.
6
+ */
7
+ --border-color: var(--dnn-color-tertiary-contrast, lightgray);
8
+ --border-radius: var(--dnn-controls-radius, 5px);
9
+ --drop-background-color: var(--dnn-color-tertiary, lightblue);
10
+ display: flex;
11
+ flex-direction: column;
12
+ gap: 1rem;
13
+ text-align: center;
14
+ border: 2px dashed var(--border-color);
15
+ border-radius: var(--border-radius);
16
+ padding: 1rem;
17
+ transition: all 300ms ease-in-out;
18
+ }
19
+
20
+ :host(.dropping) {
21
+ background-color: var(--drop-background-color);
22
+ }
23
+
24
+ p {
25
+ margin: 0;
26
+ padding: 0;
27
+ }
28
+
29
+ button {
30
+ display: flex;
31
+ justify-content: center;
32
+ align-items: center;
33
+ border: 0px;
34
+ margin: 0;
35
+ padding: 0;
36
+ background-color: transparent;
37
+ }
38
+ button:hover {
39
+ cursor: pointer;
40
+ }
41
+ button svg {
42
+ margin-right: 0.5rem;
43
+ }
44
+
45
+ label.upload-file {
46
+ display: flex;
47
+ justify-content: center;
48
+ align-items: center;
49
+ cursor: pointer;
50
+ }
51
+ label.upload-file input {
52
+ display: none;
53
+ }
54
+
55
+ .video-preview {
56
+ display: flex;
57
+ flex-direction: column;
58
+ align-items: center;
59
+ }
60
+ .video-preview button {
61
+ margin: 1rem;
62
+ }