@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,1563 @@
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-f79d9e82.js';
2
+ import { D as Debounce } from './debounce-06f55268.js';
3
+
4
+ const dnnButtonCss = ":host{--background-color:transparent;--color:#333;--border-size:1px;--border-color:var(--backround-color);--border-radius:var(--dnn-controls-radius, 5px);--padding:var(--dnn-controls-padding, 5px);display:inline-block;width:auto}:host(.disabled){pointer-events:none}:host(.primary){--background-color:var(--dnn-color-primary, blue);--color:var(--dnn-color-primary-contrast, white);--focus-color:var(--background-color)}:host(.primary.reversed){--background-color:var(--dnn-color-primary-contrast, white);--color:var(--dnn-color-primary, blue);--border-color:var(--dnn-color-primary, blue);--focus-color:var(--color)}:host(.secondary){--background-color:var(--dnn-color-secondary, green);--color:var(--dnn-color-secondary-contrast, white);--focus-color:var(--background-color)}:host(.secondary.reversed){--background-color:var(--dnn-color-secondary-contrast, white);--color:var(--dnn-color-secondary, blue);--border-color:var(--dnn-color-secondary, blue);--focus-color:var(--color)}:host(.tertiary){--background-color:var(--dnn-color-tertiary, yellow);--color:var(--dnn-color-tertiary-contrast, black);--focus-color:var(--background-color)}:host(.tertiary.reversed){--background-color:var(--dnn-color-tertiary-contrast, white);--color:var(--dnn-color-tertiary, blue);--border-color:var(--dnn-color-tertiary, blue);--focus-color:var(--color)}:host(.hydrated) button{border:var(--border-size) solid var(--border-color);border-radius:var(--border-radius);padding:var(--padding) calc(var(--padding) * 2);background-color:transparent;background-color:var(--background-color);color:var(--color);outline:none}:host(.hydrated) button:focus,:host(.hydrated) button:hover{box-shadow:0 0 2px 2px var(--focus-color)}:host(:disabled,[disabled]) button{pointer-events:none;opacity:0.5}:host(.small) button{padding:calc(var(--padding) / 2) var(--padding);font-size:0.7em}:host(.large) button{padding:calc(var(--padding) * 1.5) calc(var(--padding) * 3);font-size:1.2em}button{height:100%;width:100%;cursor:pointer}";
5
+
6
+ let DnnButton = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.confirmed = createEvent(this, "confirmed", 3);
10
+ this.canceled = createEvent(this, "canceled", 3);
11
+ /**
12
+ * Optional button style,
13
+ * can be either primary, secondary or tertiary and defaults to primary if not specified
14
+ */
15
+ this.type = 'primary';
16
+ /**
17
+ * Optionally reverses the button style.
18
+ */
19
+ this.reversed = false;
20
+ /**
21
+ * Optionally sets the button size, small normal or large, defaults to normal
22
+ */
23
+ this.size = 'normal';
24
+ /**
25
+ * Optionally add a confirmation dialog before firing the action.
26
+ */
27
+ this.confirm = false;
28
+ /**
29
+ * The text of the yes button for confirmation.
30
+ */
31
+ this.confirmYesText = "Yes";
32
+ /**
33
+ * The text of the no button for confirmation.
34
+ */
35
+ this.confirmNoText = "No";
36
+ /**
37
+ * The text of the confirmation message;
38
+ */
39
+ this.confirmMessage = "Are you sure ?";
40
+ /**
41
+ * Disables the button
42
+ */
43
+ this.disabled = false;
44
+ this.modalVisible = false;
45
+ }
46
+ componentDidLoad() {
47
+ this.el.classList.add(this.type);
48
+ if (this.reversed) {
49
+ this.el.classList.add('reversed');
50
+ }
51
+ if (this.size !== 'normal') {
52
+ this.el.classList.add(this.size);
53
+ }
54
+ this.modal = this.el.shadowRoot.querySelector('dnn-modal');
55
+ }
56
+ handleConfirm() {
57
+ this.modal.hide();
58
+ this.modalVisible = false;
59
+ this.confirmed.emit();
60
+ }
61
+ handleCancel() {
62
+ this.modal.hide();
63
+ this.modalVisible = false;
64
+ this.canceled.emit();
65
+ }
66
+ handleClick() {
67
+ if (this.confirm && !this.modalVisible) {
68
+ this.modal.show();
69
+ this.modalVisible = true;
70
+ }
71
+ }
72
+ render() {
73
+ return (h(Host, { disabled: this.disabled, style: { 'pointer-events': this.disabled ? 'none' : 'all' } }, h("button", { class: "button", onClick: () => this.handleClick(), disabled: this.disabled }, h("slot", null)), this.confirm &&
74
+ h("dnn-modal", { showCloseButton: false, backdropDismiss: false }, h("p", null, this.confirmMessage), h("div", { style: {
75
+ display: 'flex',
76
+ justifyContent: 'flex-end'
77
+ } }, h("dnn-button", { type: 'primary', style: { margin: '5px' }, onClick: () => this.handleConfirm() }, this.confirmYesText), h("dnn-button", { type: 'secondary', style: { margin: '5px' }, onClick: () => this.handleCancel() }, this.confirmNoText)))));
78
+ }
79
+ get el() { return getElement(this); }
80
+ };
81
+ DnnButton.style = dnnButtonCss;
82
+
83
+ const dnnCheckboxCss = ":host{--focus-color:var(--dnn-color-primary, #3792ED);display:inline-flex;align-items:center;gap:0.25rem;margin:3px}button{background-color:transparent;border:0;padding:0;margin:0;outline:none;display:flex;justify-content:center;align-items:center}button svg.undefined{opacity:0.45}button:focus{box-shadow:0 0 2px 2px var(--focus-color)}";
84
+
85
+ let DnnCheckbox = class {
86
+ constructor(hostRef) {
87
+ registerInstance(this, hostRef);
88
+ this.checkedchange = createEvent(this, "checkedchange", 7);
89
+ /** Defines if the checkbox is checked (true) or unchecked (false) or in an intermediate state (undefined) */
90
+ this.checked = false;
91
+ /** Defines if clicking the checkbox will go through the intermediate state between checked and unchecked (tri-state) */
92
+ this.useIntermediate = false;
93
+ }
94
+ changeState() {
95
+ if (!this.useIntermediate) {
96
+ this.checked = !this.checked;
97
+ this.emitEvents();
98
+ return;
99
+ }
100
+ if (this.checked === true) {
101
+ this.checked = false;
102
+ this.button.classList.remove("undefined");
103
+ this.emitEvents();
104
+ return;
105
+ }
106
+ if (this.checked === undefined) {
107
+ this.checked = true;
108
+ this.button.classList.remove("undefined");
109
+ this.emitEvents();
110
+ return;
111
+ }
112
+ if (this.checked === false) {
113
+ this.checked = undefined;
114
+ this.button.classList.add("undefined");
115
+ this.emitEvents();
116
+ return;
117
+ }
118
+ }
119
+ emitEvents() {
120
+ this.checkedchange.emit(this.checked);
121
+ }
122
+ render() {
123
+ return (h(Host, null, h("button", { class: "icon", onClick: () => this.changeState(), ref: el => this.button = el }, this.checked === false &&
124
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z" })), this.checked === true &&
125
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" })), this.checked === undefined &&
126
+ h("svg", { class: "undefined", xmlns: "http://www.w3.org/2000/svg", "enable-background": "new 0 0 24 24", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("g", null, h("rect", { fill: "none", height: "24", width: "24" })), h("g", null, h("g", null, h("g", null, h("path", { d: "M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M17,13H7v-2h10V13z" })))))), h("label", { htmlFor: this.el.id, onClick: () => this.changeState() }, h("slot", null))));
127
+ }
128
+ get el() { return getElement(this); }
129
+ };
130
+ DnnCheckbox.style = dnnCheckboxCss;
131
+
132
+ const dnnChevronCss = ":host{display:inline-block}button{border:none;padding:0px;margin:0px;min-width:15px;min-height:15px;display:flex;justify-content:center;align-items:center;background-color:transparent;outline:none}svg{height:2em;width:2em;transition:all 300ms ease-in-out}button:focus svg,button:hover svg{color:var(--dnn-color-primary)}:host([expanded]) svg{transform:rotate(90deg)}";
133
+
134
+ let DnnChevron = class {
135
+ constructor(hostRef) {
136
+ registerInstance(this, hostRef);
137
+ this.changed = createEvent(this, "changed", 7);
138
+ /** Expand text for screen readers */
139
+ this.expandText = "expand";
140
+ /** Collapse text for screen readers */
141
+ this.collapseText = "collapse";
142
+ /** Is the chevron expanded */
143
+ this.expanded = false;
144
+ }
145
+ handleExpandedChanged(newValue) {
146
+ this.changed.emit(newValue);
147
+ }
148
+ render() {
149
+ return (h(Host, null, h("button", { "aria-label": this.expanded ? this.collapseText : this.expandText, onClick: () => this.expanded = !this.expanded }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" })))));
150
+ }
151
+ static get watchers() { return {
152
+ "expanded": ["handleExpandedChanged"]
153
+ }; }
154
+ };
155
+ DnnChevron.style = dnnChevronCss;
156
+
157
+ const dnnCollapsibleCss = ":host{display:block}:host #container{height:0;overflow:hidden;transition:height 300ms ease-in-out}";
158
+
159
+ var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
160
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
161
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
162
+ r = Reflect.decorate(decorators, target, key, desc);
163
+ else
164
+ for (var i = decorators.length - 1; i >= 0; i--)
165
+ if (d = decorators[i])
166
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
167
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
168
+ };
169
+ let DnnCollapsible = class {
170
+ constructor(hostRef) {
171
+ registerInstance(this, hostRef);
172
+ this.dnnCollapsibleHeightChanged = createEvent(this, "dnnCollapsibleHeightChanged", 7);
173
+ /** Defines if the panel is expanded or not. */
174
+ this.expanded = false;
175
+ /** Defines the transition time in ms, defaults to 100ms */
176
+ this.transitionDuration = 150;
177
+ this.animating = false;
178
+ }
179
+ handleExpandedChanged(newValue) {
180
+ this.animating = true;
181
+ requestAnimationFrame(() => {
182
+ const container = this.el.shadowRoot.querySelector("#container");
183
+ if (newValue) {
184
+ container.style.height = container.scrollHeight + "px";
185
+ }
186
+ else {
187
+ container.style.height = "0px";
188
+ }
189
+ });
190
+ requestAnimationFrame(() => {
191
+ this.animating = false;
192
+ this.dnnCollapsibleHeightChanged.emit();
193
+ });
194
+ }
195
+ /** Updates the component height, use to update after a slot content changes. */
196
+ async updateSize() {
197
+ this.updateComponentSize();
198
+ }
199
+ updateComponentSize() {
200
+ if (this.expanded) {
201
+ this.animating = true;
202
+ requestAnimationFrame(() => {
203
+ const container = this.el.shadowRoot.querySelector("#container");
204
+ let newHeight = 0;
205
+ container.querySelector('slot').assignedElements().forEach(node => {
206
+ newHeight += node.scrollHeight;
207
+ });
208
+ container.style.height = newHeight + "px";
209
+ });
210
+ }
211
+ }
212
+ handleOtherCollapsibleHeightChanged() {
213
+ setTimeout(() => {
214
+ this.updateComponentSize();
215
+ }, this.transitionDuration);
216
+ }
217
+ handleMutation(mutationList) {
218
+ mutationList.forEach(mutation => {
219
+ requestAnimationFrame(() => {
220
+ mutation.target.closest('dnn-collapsible').updateSize();
221
+ });
222
+ });
223
+ }
224
+ componentWillLoad() {
225
+ this.mutationObserver = new MutationObserver((mutationList) => {
226
+ this.handleMutation(mutationList);
227
+ });
228
+ }
229
+ componentDidLoad() {
230
+ const container = this.el.shadowRoot.querySelector('#container');
231
+ container.style.transitionDuration = this.transitionDuration + 'ms';
232
+ // Monitor for content changes and update own height
233
+ const childNodes = [this.el];
234
+ childNodes.forEach(element => {
235
+ this.mutationObserver.observe(element, { attributes: true, characterData: true, childList: true, subtree: true });
236
+ });
237
+ const slot = this.el.shadowRoot.querySelector('slot');
238
+ slot.addEventListener("slotchange", () => {
239
+ this.updateSize();
240
+ });
241
+ }
242
+ disconnectedCallback() {
243
+ this.mutationObserver.disconnect();
244
+ }
245
+ /*eslint-enable @stencil/own-methods-must-be-private */
246
+ render() {
247
+ return (h(Host, null, h("div", { id: "container" }, h("slot", null))));
248
+ }
249
+ get el() { return getElement(this); }
250
+ static get watchers() { return {
251
+ "expanded": ["handleExpandedChanged"]
252
+ }; }
253
+ };
254
+ __decorate$2([
255
+ Debounce()
256
+ ], DnnCollapsible.prototype, "updateSize", null);
257
+ DnnCollapsible.style = dnnCollapsibleCss;
258
+
259
+ /** Color utility class with hsl and rgb converters
260
+ * based on math at https://en.wikipedia.org/wiki/HSL_and_HSV
261
+ * @copyright Copyright (c) .NET Foundation. All rights reserved.
262
+ * @license MIT
263
+ */
264
+ class ColorInfo {
265
+ constructor() {
266
+ this._hue = 0;
267
+ this._saturation = 0;
268
+ this._lightness = 0;
269
+ }
270
+ /** gets the color hue
271
+ * @returns a number between 0 and 359, could contain decimals
272
+ */
273
+ get hue() { return this._hue; }
274
+ set hue(value) {
275
+ if (value < 0) {
276
+ value = 0;
277
+ }
278
+ if (value > 359) {
279
+ value = 359;
280
+ }
281
+ this._hue = value;
282
+ }
283
+ /** gets the color saturation
284
+ * @returns a number between 0 and 1, could contain decimals
285
+ */
286
+ get saturation() { return this._saturation; }
287
+ set saturation(value) {
288
+ if (value < 0) {
289
+ value = 0;
290
+ }
291
+ if (value > 1) {
292
+ value = 1;
293
+ }
294
+ this._saturation = value;
295
+ }
296
+ /** gets the color lightness
297
+ * @returns a number between 0 and 1, could contain decimals
298
+ */
299
+ get lightness() { return this._lightness; }
300
+ set lightness(value) {
301
+ if (value < 0) {
302
+ value = 0;
303
+ }
304
+ if (value > 1) {
305
+ value = 1;
306
+ }
307
+ this._lightness = value;
308
+ }
309
+ /** gets or sets the red component
310
+ * @returns an integer between 0 and 255
311
+ */
312
+ get red() {
313
+ return this.getRGB().red;
314
+ }
315
+ set red(value) {
316
+ this.setHSL(value, this.green, this.blue);
317
+ }
318
+ /** gets or sets the green component
319
+ * @returns an integer between 0 and 255
320
+ */
321
+ get green() {
322
+ return this.getRGB().green;
323
+ }
324
+ set green(value) {
325
+ this.setHSL(this.red, value, this.blue);
326
+ }
327
+ /** gets or sets the blue component
328
+ * @returns an integer between 0 and 255
329
+ */
330
+ get blue() {
331
+ return this.getRGB().blue;
332
+ }
333
+ set blue(value) {
334
+ this.setHSL(this.red, this.green, value);
335
+ }
336
+ /** gets or sets the hex color value, expresses as 6 hexadecimal characters.
337
+ * @returns hex representation of the color
338
+ */
339
+ get hex() {
340
+ var r = this.getHex(this.red);
341
+ var g = this.getHex(this.green);
342
+ var b = this.getHex(this.blue);
343
+ return r + g + b;
344
+ }
345
+ set hex(value) {
346
+ this.red = parseInt(value.substr(0, 2));
347
+ this.green = parseInt(value.substr(2, 2));
348
+ this.blue = parseInt(value.substr(4, 2));
349
+ }
350
+ /** gets white or black color that is a good oposite to the current color
351
+ * @returns - "000000" or "FFFFFF"
352
+ */
353
+ get contrastColor() {
354
+ const brightness = (this.red * 299 + this.green * 587 + this.blue * 114) / 1000;
355
+ if (brightness > 127) {
356
+ return "000000";
357
+ }
358
+ return "FFFFFF";
359
+ }
360
+ getRGB() {
361
+ const chroma = (1 - Math.abs((2 * this._lightness) - 1)) * this.saturation;
362
+ // find the quandrant of the hue
363
+ const quadrant = this._hue / 60;
364
+ // calculate the offset from the quandrant center
365
+ const offset = chroma * (1 - Math.abs(quadrant % 2 - 1));
366
+ // Apply the chroma to the primary component and the offset to the 2nd most important component
367
+ let r = 0, g = 0, b = 0;
368
+ if (0 <= quadrant && quadrant <= 1) {
369
+ r = chroma;
370
+ g = offset; // red to yellow
371
+ }
372
+ else if (1 <= quadrant && quadrant <= 2) {
373
+ g = chroma;
374
+ r = offset; // yellow to green
375
+ }
376
+ else if (2 <= quadrant && quadrant <= 3) {
377
+ g = chroma;
378
+ b = offset; // green to cyan
379
+ }
380
+ else if (3 <= quadrant && quadrant <= 4) {
381
+ b = chroma;
382
+ g = offset; // cyan to blue
383
+ }
384
+ else if (4 <= quadrant && quadrant <= 5) {
385
+ b = chroma;
386
+ r = offset; // blue to magenta
387
+ }
388
+ else if (5 <= quadrant && quadrant <= 6) {
389
+ r = chroma;
390
+ b = offset; // magenta to red
391
+ }
392
+ // calculate the bias to add to all channels to match the lightness
393
+ const bias = this._lightness - (chroma / 2);
394
+ return {
395
+ red: Math.round((r + bias) * 255),
396
+ green: Math.round((g + bias) * 255),
397
+ blue: Math.round((b + bias) * 255)
398
+ };
399
+ }
400
+ setHSL(red, green, blue) {
401
+ // GENERAL DATA
402
+ // all math is based on values from 0 to 1
403
+ const r = red / 255, g = green / 255, b = blue / 255;
404
+ // we need to max, min and the difference between them to derive hsl
405
+ const min = Math.min(r, g, b);
406
+ const max = Math.max(r, g, b);
407
+ const diff = max - min;
408
+ let h = 0, s = 0, l = 0;
409
+ // HUE
410
+ if (diff === 0) { // neutral
411
+ h = 0;
412
+ }
413
+ else if (max === r) { // red (magenta to yellow range)
414
+ h = 60 * ((g - b) / diff);
415
+ }
416
+ else if (max === g) { // green (yellow to cyan range)
417
+ h = 60 * (2 + ((b - r) / diff));
418
+ }
419
+ else if (max === b) { // blue (cyan to magenta range)
420
+ h = 60 * (4 + ((r - g) / diff));
421
+ }
422
+ if (h < 0) {
423
+ h = h + 360;
424
+ } // ensures positive hues only
425
+ if (h > 359) {
426
+ h = 359;
427
+ } // ensures we never return 360 for simplicity since it is the same as 0
428
+ // LIGHTNESS
429
+ l = (max + min) / 2;
430
+ // SATURATION
431
+ if (max === 0 || min === 1) { // pure black or white have no saturation
432
+ s = 0;
433
+ }
434
+ else {
435
+ s = (max - l) / (Math.min(l, 1 - l));
436
+ }
437
+ this._hue = h;
438
+ this._saturation = s;
439
+ this._lightness = l;
440
+ }
441
+ getHex(value) {
442
+ var hex = value.toString(16);
443
+ if (hex.length < 2) {
444
+ hex = "0" + hex;
445
+ }
446
+ return hex;
447
+ }
448
+ }
449
+
450
+ const dnnColorPickerCss = ".dnn-color-picker{padding:15px;max-width:400px}.dnn-color-picker .dnn-color-sliders{display:flex;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: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: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:flex;align-items:center;margin-top:15px}.dnn-color-picker .dnn-color-sliders .dnn-color-bar .dnn-color-result{flex-direction:column;width:50px;height:50px;border-radius:50%;background:red}.dnn-color-picker .dnn-color-sliders .dnn-color-bar .dnn-color-hue{flex:auto;margin-left:10px;height:16px;border:1px solid #ccc;position:relative;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:flex;flex-direction:column;justify-content:space-between}.dnn-color-picker .dnn-color-fields .dnn-color-mode-switch{display:flex;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:flex;justify-content:space-evenly}.dnn-color-picker .dnn-color-fields .dnn-rgb-color-fields .dnn-rgb-color-field{display:flex;flex-direction:column;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:flex;justify-content:space-evenly}.dnn-color-picker .dnn-color-fields .dnn-hsl-color-fields .dnn-hsl-color-field{display:flex;flex-direction:column;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:flex;justify-content:space-evenly}.dnn-color-picker .dnn-color-fields .dnn-hex-color-fields .dnn-hex-color-field{display:flex;flex-direction:column;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}";
451
+
452
+ /** Reusable DNN UI component to pick a color
453
+ * @copyright Copyright (c) .NET Foundation. All rights reserved.
454
+ * @license MIT
455
+ */
456
+ var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
457
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
458
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
459
+ r = Reflect.decorate(decorators, target, key, desc);
460
+ else
461
+ for (var i = decorators.length - 1; i >= 0; i--)
462
+ if (d = decorators[i])
463
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
464
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
465
+ };
466
+ let DnnColorPicker = class {
467
+ constructor(hostRef) {
468
+ registerInstance(this, hostRef);
469
+ this.colorChanged = createEvent(this, "colorChanged", 7);
470
+ /** Sets the initial color, must be a valid 8 character hexadecimal string without the # sign. */
471
+ this.color = "FFFFFF";
472
+ /** Sets the width-height ratio of the color picker saturation-lightness box.
473
+ * @example 100% renders a perfect square
474
+ */
475
+ this.colorBoxHeight = "50%";
476
+ this.rgbDisplay = "flex";
477
+ this.hslDisplay = "none";
478
+ this.hexDisplay = "none";
479
+ this.handleSaturationLightnessMouseDown = (e) => {
480
+ e.preventDefault();
481
+ this.handleDragLightnessSaturation(e);
482
+ window.addEventListener('mousemove', this.handleDragLightnessSaturation);
483
+ window.addEventListener('mouseup', this.handleSaturationLightnessMouseUp);
484
+ };
485
+ this.handleDragLightnessSaturation = (e) => {
486
+ const rect = this.saturationLightnessBox.getBoundingClientRect();
487
+ let x = e.clientX - rect.left;
488
+ if (x < 0) {
489
+ x = 0;
490
+ }
491
+ if (x > rect.width) {
492
+ x = rect.width;
493
+ }
494
+ x = x / rect.width;
495
+ let y = e.clientY - rect.top;
496
+ if (y < 0) {
497
+ y = 0;
498
+ }
499
+ if (y > rect.height) {
500
+ y = rect.height;
501
+ }
502
+ y = 1 - (y / rect.height);
503
+ const newColor = new ColorInfo();
504
+ newColor.hue = this.currentColor.hue;
505
+ newColor.saturation = x;
506
+ newColor.lightness = y;
507
+ this.currentColor = newColor;
508
+ };
509
+ this.handleSaturationLightnessMouseUp = () => {
510
+ window.removeEventListener('mousemove', this.handleDragLightnessSaturation);
511
+ window.removeEventListener('mouseup', this.handleSaturationLightnessMouseUp);
512
+ };
513
+ this.handleHueMouseDown = (e) => {
514
+ e.preventDefault();
515
+ this.handleDragHue(e);
516
+ window.addEventListener('mousemove', this.handleDragHue);
517
+ window.addEventListener('mouseup', this.handleHueMouseUp);
518
+ };
519
+ this.handleHueMouseUp = () => {
520
+ window.removeEventListener('mousemove', this.handleDragHue);
521
+ window.removeEventListener('mouseup', this.handleHueMouseUp);
522
+ };
523
+ this.handleDragHue = (e) => {
524
+ const rect = this.hueRange.getBoundingClientRect();
525
+ let x = e.clientX - rect.left;
526
+ if (x < 0) {
527
+ x = 0;
528
+ }
529
+ if (x > rect.width) {
530
+ x = rect.width;
531
+ }
532
+ x = x / rect.width * 360;
533
+ const newColor = new ColorInfo();
534
+ newColor.hue = x;
535
+ newColor.saturation = this.currentColor.saturation;
536
+ newColor.lightness = this.currentColor.lightness;
537
+ this.currentColor = newColor;
538
+ };
539
+ this.handleComponentValueChange = (e, channel) => {
540
+ let value = parseInt(e.target.value);
541
+ if (isNaN(value)) {
542
+ return;
543
+ }
544
+ const newColor = new ColorInfo();
545
+ if (value < 0) {
546
+ value = 0;
547
+ }
548
+ if (value > 255) {
549
+ value = 255;
550
+ }
551
+ let r = this.currentColor.red;
552
+ let g = this.currentColor.green;
553
+ let b = this.currentColor.blue;
554
+ switch (channel) {
555
+ case 'red':
556
+ r = value;
557
+ break;
558
+ case 'green':
559
+ g = value;
560
+ break;
561
+ case 'blue':
562
+ b = value;
563
+ break;
564
+ }
565
+ newColor.green = g;
566
+ newColor.red = r;
567
+ newColor.blue = b;
568
+ this.currentColor = newColor;
569
+ };
570
+ this.handleHSLChange = (e, component) => {
571
+ let value = parseInt(e.target.value);
572
+ if (isNaN(value)) {
573
+ return;
574
+ }
575
+ const newColor = new ColorInfo();
576
+ if (value != null) {
577
+ let h = this.currentColor.hue;
578
+ let s = this.currentColor.saturation;
579
+ let l = this.currentColor.lightness;
580
+ switch (component) {
581
+ case "hue":
582
+ if (value < 0) {
583
+ value = 0;
584
+ }
585
+ if (value > 359) {
586
+ value = 0;
587
+ }
588
+ h = value;
589
+ break;
590
+ case "saturation":
591
+ if (value < 0) {
592
+ value = 0;
593
+ }
594
+ if (value > 100) {
595
+ value = 100;
596
+ }
597
+ s = value / 100;
598
+ break;
599
+ case "lightness":
600
+ if (value < 0) {
601
+ value = 0;
602
+ }
603
+ if (value > 100) {
604
+ value = 100;
605
+ }
606
+ l = value / 100;
607
+ break;
608
+ }
609
+ newColor.hue = h;
610
+ newColor.saturation = s;
611
+ newColor.lightness = l;
612
+ this.currentColor = newColor;
613
+ }
614
+ };
615
+ this.handleSaturationLightnessKeyDown = (e) => {
616
+ let newColor = new ColorInfo();
617
+ newColor.hue = this.currentColor.hue;
618
+ newColor.saturation = this.currentColor.saturation;
619
+ newColor.lightness = this.currentColor.lightness;
620
+ let value = 0.01;
621
+ if (e.shiftKey) {
622
+ value = 0.1;
623
+ }
624
+ switch (e.key) {
625
+ case "ArrowUp":
626
+ newColor.lightness += value;
627
+ break;
628
+ case "ArrowDown":
629
+ newColor.lightness -= value;
630
+ break;
631
+ case "ArrowLeft":
632
+ newColor.saturation -= value;
633
+ break;
634
+ case "ArrowRight":
635
+ newColor.saturation += value;
636
+ }
637
+ this.currentColor = newColor;
638
+ };
639
+ this.handleHueKeyDown = (e) => {
640
+ let newColor = new ColorInfo();
641
+ newColor.hue = this.currentColor.hue;
642
+ newColor.saturation = this.currentColor.saturation;
643
+ newColor.lightness = this.currentColor.lightness;
644
+ let value = 1;
645
+ if (e.shiftKey) {
646
+ value = 10;
647
+ }
648
+ switch (e.key) {
649
+ case "ArrowLeft":
650
+ newColor.hue -= value;
651
+ break;
652
+ case "ArrowRight":
653
+ newColor.hue += value;
654
+ }
655
+ this.currentColor = newColor;
656
+ };
657
+ }
658
+ colorChangedHandler(color) {
659
+ this.colorChanged.emit(color);
660
+ }
661
+ handeCurrentColorChanged(newValue) {
662
+ this.colorChangedHandler(newValue);
663
+ }
664
+ componentWillLoad() {
665
+ this.handleHexChange(this.color);
666
+ }
667
+ componentDidLoad() {
668
+ this.el.style.setProperty("--color-box-height", this.colorBoxHeight.toString());
669
+ }
670
+ getHex() {
671
+ return this.getDoublet(this.currentColor.red) + this.getDoublet(this.currentColor.green) + this.getDoublet(this.currentColor.blue);
672
+ }
673
+ getContrast() {
674
+ return this.currentColor.contrastColor;
675
+ }
676
+ getDoublet(value) {
677
+ const valueString = value.toString(16).toUpperCase();
678
+ if (valueString.length === 1) {
679
+ return '0' + valueString;
680
+ }
681
+ return valueString;
682
+ }
683
+ handleHexChange(value) {
684
+ const newColor = new ColorInfo();
685
+ if (value.match(/^(?:[\da-f]{3}|[\da-f]{6})$/i).length > 0) {
686
+ if (value.length === 3) {
687
+ let expanded = value[0] + value[0] + value[1] + value[1] + value[2] + value[2];
688
+ value = expanded;
689
+ }
690
+ newColor.red = parseInt(value.substr(0, 2), 16);
691
+ newColor.green = parseInt(value.substr(2, 2), 16);
692
+ newColor.blue = parseInt(value.substr(4, 2), 16);
693
+ }
694
+ else {
695
+ newColor.red = this.currentColor.red;
696
+ newColor.green = this.currentColor.green;
697
+ newColor.blue = this.currentColor.blue;
698
+ }
699
+ this.currentColor = newColor;
700
+ }
701
+ switchColorMode(e) {
702
+ switch (e.target.id) {
703
+ case "rgb-switch":
704
+ this.rgbDisplay = "none";
705
+ this.hslDisplay = "none";
706
+ this.hexDisplay = "flex";
707
+ break;
708
+ case "hex-switch":
709
+ this.rgbDisplay = "none";
710
+ this.hslDisplay = "flex";
711
+ this.hexDisplay = "none";
712
+ break;
713
+ case "hsl-switch":
714
+ this.rgbDisplay = "flex";
715
+ this.hslDisplay = "none";
716
+ this.hexDisplay = "none";
717
+ break;
718
+ default:
719
+ this.rgbDisplay = "flex";
720
+ this.hslDisplay = "none";
721
+ this.hexDisplay = "none";
722
+ }
723
+ }
724
+ render() {
725
+ const hue = this.currentColor.hue;
726
+ const saturation = this.currentColor.saturation;
727
+ const lightness = this.currentColor.lightness;
728
+ const red = this.currentColor.red;
729
+ const green = this.currentColor.green;
730
+ const blue = this.currentColor.blue;
731
+ return (h("div", { class: "dnn-color-picker" }, h("div", { class: "dnn-color-sliders" }, h("div", { class: "dnn-color-s-b", ref: (element) => this.saturationLightnessBox = element, style: { backgroundColor: `hsl(${hue},100%,50%)` }, onMouseDown: this.handleSaturationLightnessMouseDown.bind(this) }, h("button", { class: "dnn-s-b-picker", "aria-label": "Press up or down to adjust lightness, left or right to adjust saturation, hold shift to move by 10%", role: "slider", "aria-valuemin": "0", "aria-valuemax": "100", "aria-valuetext": `Saturation: ${Math.round(this.currentColor.saturation * 100)}%, Lightness: ${Math.round(this.currentColor.lightness * 100)}%`, style: {
732
+ left: Math.round(saturation * 100) + "%",
733
+ bottom: Math.round(lightness * 100) + "%"
734
+ }, onKeyDown: (e) => this.handleSaturationLightnessKeyDown(e) })), h("div", { class: "dnn-color-bar" }, h("div", { class: "dnn-color-result", style: {
735
+ backgroundColor: '#' + this.getHex(),
736
+ boxShadow: "0 0 2px 1px " + "#" + this.getContrast()
737
+ } }), h("div", { class: "dnn-color-hue", ref: (element) => this.hueRange = element, onMouseDown: this.handleHueMouseDown.bind(this) }, h("button", { class: "dnn-hue-picker", "aria-label": "Press left or right to adjust hue, hold shift to move by 10 degrees", role: "slider", "aria-valuemin": "0", "aria-valuemax": "359", "aria-valuenow": Math.round(hue), style: { left: (hue / 359 * 100).toString() + "%" }, onKeyDown: (e) => this.handleHueKeyDown(e) })))), h("div", { class: "dnn-color-fields" }, h("div", { class: "dnn-rgb-color-fields", style: { display: this.rgbDisplay } }, h("div", { class: "dnn-rgb-color-field" }, h("label", null, "R"), h("input", { type: "number", min: "0", max: "255", step: "1", class: "red", value: red, "aria-label": "red value", onChange: (e) => this.handleComponentValueChange(e, 'red') })), h("div", { class: "dnn-rgb-color-field" }, h("label", null, "G"), h("input", { type: "number", min: "0", max: "255", class: "green", value: green, "aria-label": "green value", onChange: (e) => this.handleComponentValueChange(e, 'green') })), h("div", { class: "dnn-rgb-color-field" }, h("label", null, "B"), h("input", { type: "number", min: "0", max: "255", class: "blue", value: blue, "aria-label": "blue value", onChange: (e) => this.handleComponentValueChange(e, 'blue') })), h("div", { class: "dnn-color-mode-switch" }, h("button", { id: "rgb-switch", onClick: this.switchColorMode.bind(this), "aria-label": "switch to hexadecimal value entry" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))), h("div", { class: "dnn-hsl-color-fields", style: { display: this.hslDisplay } }, h("div", { class: "dnn-hsl-color-field" }, h("label", null, "H"), h("input", { type: "number", min: "0", max: "359", step: 1, value: Math.round(hue), "aria-label": "Hue", onChange: (e) => this.handleHSLChange(e, 'hue') })), h("div", { class: "dnn-hsl-color-field" }, h("label", null, "S"), h("input", { type: "number", min: "0", max: "100", step: 1, value: Math.round(saturation * 100), "aria-label": "Saturation", onChange: (e) => this.handleHSLChange(e, 'saturation') })), h("div", { class: "dnn-hsl-color-field" }, h("label", null, "L"), h("input", { type: "number", min: "0", max: "100", step: 1, value: Math.round(lightness * 100), "aria-label": "Lightness", onChange: (e) => this.handleHSLChange(e, 'lightness') })), h("div", { class: "dnn-color-mode-switch" }, h("button", { id: "hsl-switch", onClick: this.switchColorMode.bind(this), "aria-label": "Switch to red, green, blue entry mode" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))), h("div", { class: "dnn-hex-color-fields", style: { display: this.hexDisplay } }, h("div", { class: "dnn-hex-color-field" }, h("label", null, "HEX"), h("div", { class: "hex-input" }, h("input", { type: "text", "aria-label": "Hexadecimal value", value: this.getHex(), onChange: e => this.handleHexChange(e.target.value) }), h("button", { class: "copy", "aria-label": "copy value" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" }))))), h("div", { class: "dnn-color-mode-switch" }, h("button", { id: "hex-switch", onClick: this.switchColorMode.bind(this), "aria-label": "Switch to hue saturation lightness values" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z" }))))))));
738
+ }
739
+ get el() { return getElement(this); }
740
+ static get watchers() { return {
741
+ "currentColor": ["handeCurrentColorChanged"]
742
+ }; }
743
+ };
744
+ __decorate$1([
745
+ Debounce(100)
746
+ ], DnnColorPicker.prototype, "colorChangedHandler", null);
747
+ DnnColorPicker.style = dnnColorPickerCss;
748
+
749
+ 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:flex;flex-direction:column;gap:1rem;text-align:center;border:2px dashed var(--border-color);border-radius:var(--border-radius);padding:1rem;transition:all 300ms ease-in-out}:host(.dropping){background-color:var(--drop-background-color)}p{margin:0;padding:0}button{display:flex;justify-content: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:flex;justify-content:center;align-items:center;cursor:pointer}label.upload-file input{display:none}.video-preview{display:flex;flex-direction:column;align-items:center}.video-preview button{margin:1rem}";
750
+
751
+ let DnnDropzone = class {
752
+ constructor(hostRef) {
753
+ registerInstance(this, hostRef);
754
+ this.filesSelected = createEvent(this, "filesSelected", 7);
755
+ /** Localization strings */
756
+ this.resx = {
757
+ dragAndDropFile: "Drag and drop a file",
758
+ capture: "Capture",
759
+ or: "or",
760
+ takePicture: "Take a picture",
761
+ uploadFile: "Upload a file",
762
+ };
763
+ /**
764
+ * If true, will allow the user to take a snapshot
765
+ * using the device camera. (only works over https).
766
+ */
767
+ this.allowCameraMode = false;
768
+ /**
769
+ * Specifies the jpeg quality for when the device
770
+ * camera is used to generate a picture.
771
+ * Needs to be a number between 0 and 1 and defaults to 0.8
772
+ */
773
+ this.captureQuality = 0.8;
774
+ this.canTakeSnapshots = false;
775
+ this.takingPicture = false;
776
+ this.handleDragOver = (event) => {
777
+ event.stopPropagation();
778
+ event.preventDefault();
779
+ event.dataTransfer.dropEffect = "copy";
780
+ this.dropzone.classList.add("dropping");
781
+ };
782
+ this.handleDrop = (dropEvent) => {
783
+ dropEvent.stopPropagation();
784
+ dropEvent.preventDefault();
785
+ const files = dropEvent.dataTransfer.files;
786
+ if (this.hasInvalidExtensions(files)) {
787
+ return;
788
+ }
789
+ var fileList = this.getFilesFromFileList(files);
790
+ this.filesSelected.emit(fileList);
791
+ };
792
+ }
793
+ componentDidLoad() {
794
+ if (this.allowCameraMode) {
795
+ this.checkIfBrowserCanTakeSnapshots()
796
+ .then(result => this.canTakeSnapshots = result);
797
+ }
798
+ if (this.allowedExtensions != undefined && this.allowedExtensions.length > 0) {
799
+ var extensionsWithDots = this.allowedExtensions.map(e => `.${e}`);
800
+ var extensionsList = extensionsWithDots.join(",");
801
+ this.fileInput.accept = extensionsList;
802
+ }
803
+ }
804
+ checkIfBrowserCanTakeSnapshots() {
805
+ return new Promise((resolve) => {
806
+ const mediaDevices = navigator.mediaDevices;
807
+ if (mediaDevices == undefined || mediaDevices.enumerateDevices == undefined) {
808
+ resolve(false);
809
+ }
810
+ mediaDevices.enumerateDevices()
811
+ .then(devices => {
812
+ var result = devices.some(device => device.kind == "videoinput");
813
+ resolve(result);
814
+ });
815
+ });
816
+ }
817
+ getFilesFromFileList(files) {
818
+ var fileList = [];
819
+ for (let index = 0; index < files.length; index++) {
820
+ const file = files[index];
821
+ fileList.push(file);
822
+ }
823
+ return fileList;
824
+ }
825
+ handleUploadButton(element) {
826
+ let files = this.getFilesFromFileList(element.files);
827
+ this.filesSelected.emit(files);
828
+ }
829
+ hasInvalidExtensions(files) {
830
+ var hasInvalid = false;
831
+ for (let fileIndex = 0; fileIndex < files.length; fileIndex++) {
832
+ const file = files[fileIndex];
833
+ var regex = /(?:\.([^.]+))?$/;
834
+ const fileExtension = regex.exec(file.name)[1];
835
+ if (fileExtension == undefined) {
836
+ hasInvalid = true;
837
+ }
838
+ if (this.allowedExtensions != undefined && !this.allowedExtensions.includes(fileExtension)) {
839
+ hasInvalid = true;
840
+ }
841
+ return hasInvalid;
842
+ }
843
+ }
844
+ takeSnapshot() {
845
+ this.takingPicture = true;
846
+ navigator.mediaDevices.getUserMedia({ video: true, audio: false })
847
+ .then(stream => {
848
+ this.videoPreview.srcObject = stream;
849
+ this.videoPreview.play()
850
+ .then(() => {
851
+ this.videoSettings = stream.getVideoTracks()[0].getSettings();
852
+ });
853
+ })
854
+ .catch(error => alert(error));
855
+ }
856
+ applySnapshot() {
857
+ var canvas = document.createElement("canvas");
858
+ const context = canvas.getContext("2d");
859
+ canvas.width = this.videoSettings.width;
860
+ canvas.height = this.videoSettings.height;
861
+ context.drawImage(this.videoPreview, 0, 0);
862
+ canvas.toBlob(blob => {
863
+ var file = new File([blob], "image.jpeg", { type: "image/jpeg" });
864
+ this.takingPicture = false;
865
+ var fileList = [file];
866
+ this.filesSelected.emit(fileList);
867
+ }, "image/jpeg", this.captureQuality);
868
+ }
869
+ render() {
870
+ var _a, _b, _c, _d, _e, _f;
871
+ return (h(Host, { ref: e => this.dropzone = e, class: "dropzone", onDragOver: this.handleDragOver, onDrop: this.handleDrop, onDragLeave: () => this.dropzone.classList.remove("dropping") }, !this.takingPicture &&
872
+ [
873
+ h("p", null, (_a = this.resx) === null || _a === void 0 ? void 0 : _a.dragAndDropFile),
874
+ h("p", null, "- ", (_b = this.resx) === null || _b === void 0 ? void 0 :
875
+ _b.or, " -"),
876
+ 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 :
877
+ _c.uploadFile),
878
+ this.canTakeSnapshots &&
879
+ [
880
+ h("p", null, "- ", (_d = this.resx) === null || _d === void 0 ? void 0 :
881
+ _d.or, " -"),
882
+ 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 :
883
+ _e.takePicture)
884
+ ]
885
+ ], this.takingPicture &&
886
+ 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 :
887
+ _f.capture))));
888
+ }
889
+ };
890
+ DnnDropzone.style = dnnDropzoneCss;
891
+
892
+ var CornerType;
893
+ (function (CornerType) {
894
+ CornerType[CornerType["nw"] = 0] = "nw";
895
+ CornerType[CornerType["ne"] = 1] = "ne";
896
+ CornerType[CornerType["se"] = 2] = "se";
897
+ CornerType[CornerType["sw"] = 3] = "sw";
898
+ })(CornerType || (CornerType = {}));
899
+
900
+ const dnnImageCropperCss = ":host{display:block}canvas{display:none}.view{visibility:hidden;opacity:0;height:0;overflow:hidden;transition:all 300ms ease-in-out}.view.visible{visibility:visible;opacity:1;height:initial;overflow:visible}.view .cropper{position:relative;width:100%}.view .cropper img{width:100%;display:block;margin:0 auto}.view .cropper .backdrop{backdrop-filter:saturate(0.5);backdrop-filter:brightness(0.5);position:absolute;left:0;top:0;width:100%;height:100%}.view .cropper .crop{position:absolute;top:0;left:0;width:100%;height:100%;outline:2px dashed white;box-shadow:black 0 0 0px 2px;backdrop-filter:saturate(2);backdrop-filter:brightness(2);cursor:move}.view .cropper .crop>div{width:20px;height:20px;background-color:white;border:2px solid rgba(0, 0, 0, 0.5);position:absolute}.view .cropper .crop>div.nw,.view .cropper .crop>div.ne{top:-17px}.view .cropper .crop>div.ne,.view .cropper .crop>div.se{right:-17px}.view .cropper .crop>div.se,.view .cropper .crop>div.sw{bottom:-17px}.view .cropper .crop>div.sw,.view .cropper .crop>div.nw{left:-17px}.view .cropper .crop>div.nw,.view .cropper .crop>div.se{cursor:nwse-resize}.view .cropper .crop>div.ne,.view .cropper .crop>div.sw{cursor:nesw-resize}dnn-modal{--max-width:512px}";
901
+
902
+ let DnnImageCropper = class {
903
+ constructor(hostRef) {
904
+ registerInstance(this, hostRef);
905
+ this.imageCropChanged = createEvent(this, "imageCropChanged", 7);
906
+ /** Sets the desired final image width. */
907
+ this.width = 600;
908
+ /** Sets the desired final image height. */
909
+ this.height = 600;
910
+ /** Can be used to customize controls text.
911
+ * Some values support tokens, see default values for examples.
912
+ */
913
+ this.resx = {
914
+ capture: "Capture",
915
+ dragAndDropFile: "Drag and drop an image",
916
+ or: "or",
917
+ takePicture: "Take a picture",
918
+ uploadFile: "Upload an image",
919
+ imageTooSmall: "The image you are attempting to upload does not meet the minimum size requirement of {width} pixels by {height} pixels. Please upload a larger image.",
920
+ modalCloseText: "Close",
921
+ };
922
+ /** Sets the output quality of the corpped image (number between 0 and 1). */
923
+ this.quality = 0.8;
924
+ /** When set to true, prevents cropping an image smaller than the required size, which would blow pixel and make the final picture look blurry. */
925
+ this.preventUndersized = false;
926
+ this.handleCropMouseDown = (event) => {
927
+ event.stopPropagation();
928
+ event.preventDefault();
929
+ const element = event.target;
930
+ const className = element.classList[0];
931
+ document.addEventListener("mouseup", this.handleImageCropFinished, false);
932
+ document.addEventListener("touchend", this.handleImageCropFinished, false);
933
+ switch (className) {
934
+ case "crop":
935
+ document.addEventListener("mousemove", this.handleCropDrag, false);
936
+ document.addEventListener("touchmove", this.handleCropDrag, false);
937
+ document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleCropDrag));
938
+ document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleCropDrag));
939
+ break;
940
+ case "nw":
941
+ document.addEventListener("mousemove", this.handleNwMouseMove, false);
942
+ document.addEventListener("touchmove", this.handleNwMouseMove, false);
943
+ document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleNwMouseMove));
944
+ document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleNwMouseMove));
945
+ break;
946
+ case "ne":
947
+ document.addEventListener("mousemove", this.handleNeMouseMove, false);
948
+ document.addEventListener("touchmove", this.handleNeMouseMove, false);
949
+ document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleNeMouseMove));
950
+ document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleNeMouseMove));
951
+ break;
952
+ case "se":
953
+ document.addEventListener("mousemove", this.handleSeMouseMove, false);
954
+ document.addEventListener("touchmove", this.handleSeMouseMove, false);
955
+ document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleSeMouseMove));
956
+ document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleSeMouseMove));
957
+ break;
958
+ case "sw":
959
+ document.addEventListener("mousemove", this.handleSwMouseMove, false);
960
+ document.addEventListener("touchmove", this.handleSwMouseMove, false);
961
+ document.addEventListener("mouseup", () => document.removeEventListener("mousemove", this.handleSwMouseMove));
962
+ document.addEventListener("touchend", () => document.removeEventListener("touchmove", this.handleSwMouseMove));
963
+ break;
964
+ }
965
+ };
966
+ this.handleImageCropFinished = (_ev) => {
967
+ this.emitImage();
968
+ document.removeEventListener("mouseup", this.handleImageCropFinished);
969
+ this.previousTouch = undefined;
970
+ };
971
+ this.handleNwMouseMove = (event) => {
972
+ this.handleCornerDrag(event, CornerType.nw);
973
+ };
974
+ this.handleNeMouseMove = (event) => {
975
+ this.handleCornerDrag(event, CornerType.ne);
976
+ };
977
+ this.handleSeMouseMove = (event) => {
978
+ this.handleCornerDrag(event, CornerType.se);
979
+ };
980
+ this.handleSwMouseMove = (event) => {
981
+ this.handleCornerDrag(event, CornerType.sw);
982
+ };
983
+ this.handleCornerDrag = (event, corner) => {
984
+ if (!this.isMouseStillInTarget(event)) {
985
+ return;
986
+ }
987
+ let { left, top } = this.getCornerLeftTop(corner);
988
+ let newWidth = 0;
989
+ let newHeight = 0;
990
+ let orientation = "horizontal";
991
+ const wantedRatio = this.width / this.height;
992
+ const cropRect = this.crop.getBoundingClientRect();
993
+ const imageRect = this.image.getBoundingClientRect();
994
+ let { movementX, movementY } = this.getMouvementFromEvent(event);
995
+ if (Math.abs(movementX) < Math.abs(movementY)) {
996
+ orientation = "vertical";
997
+ }
998
+ if (orientation == "horizontal") {
999
+ switch (corner) {
1000
+ case CornerType.nw:
1001
+ case CornerType.sw:
1002
+ newWidth = cropRect.width - movementX;
1003
+ newHeight = newWidth / wantedRatio;
1004
+ break;
1005
+ case CornerType.ne:
1006
+ case CornerType.se:
1007
+ newWidth = cropRect.width + movementX;
1008
+ newHeight = newWidth / wantedRatio;
1009
+ break;
1010
+ }
1011
+ }
1012
+ else {
1013
+ switch (corner) {
1014
+ case CornerType.nw:
1015
+ case CornerType.ne:
1016
+ newHeight = cropRect.height - movementY;
1017
+ newWidth = newHeight * wantedRatio;
1018
+ break;
1019
+ case CornerType.se:
1020
+ case CornerType.sw:
1021
+ newHeight = cropRect.height + movementY;
1022
+ newWidth = newHeight * wantedRatio;
1023
+ break;
1024
+ }
1025
+ }
1026
+ switch (corner) {
1027
+ case CornerType.ne:
1028
+ case CornerType.nw:
1029
+ const topOffset = cropRect.height - newHeight;
1030
+ top = this.crop.offsetTop + topOffset;
1031
+ }
1032
+ switch (corner) {
1033
+ case CornerType.nw:
1034
+ case CornerType.sw:
1035
+ const leftOffset = cropRect.width - newWidth;
1036
+ left = this.crop.offsetLeft + leftOffset;
1037
+ if (left < 0)
1038
+ left = 0;
1039
+ if (left > imageRect.width)
1040
+ left = imageRect.width;
1041
+ if (top < 0)
1042
+ top = 0;
1043
+ if (top > imageRect.height)
1044
+ top = imageRect.height;
1045
+ if (left + newWidth > imageRect.width)
1046
+ newWidth = imageRect.width - left;
1047
+ if (top + newHeight > imageRect.height)
1048
+ newHeight = imageRect.height - top;
1049
+ break;
1050
+ case CornerType.ne:
1051
+ case CornerType.se:
1052
+ if (top < 0)
1053
+ top = 0;
1054
+ if (top > imageRect.height)
1055
+ top = imageRect.height;
1056
+ if (left + newWidth > imageRect.width)
1057
+ newWidth = imageRect.width - left;
1058
+ if (top + newHeight > imageRect.height)
1059
+ newHeight = imageRect.height - top;
1060
+ break;
1061
+ }
1062
+ if (newWidth / newHeight != wantedRatio) {
1063
+ return;
1064
+ }
1065
+ if (this.preventUndersized) {
1066
+ const zoomRatio = this.image.width / this.image.naturalWidth;
1067
+ if (newWidth / zoomRatio < this.width || newHeight / zoomRatio < this.height) {
1068
+ return;
1069
+ }
1070
+ }
1071
+ switch (corner) {
1072
+ case CornerType.ne:
1073
+ this.crop.style.top = `${top}px`;
1074
+ this.crop.style.width = `${newWidth}px`;
1075
+ this.crop.style.height = `${newHeight}px`;
1076
+ break;
1077
+ case CornerType.nw:
1078
+ this.crop.style.left = `${left}px`;
1079
+ this.crop.style.top = `${top}px`;
1080
+ this.crop.style.width = `${newWidth}px`;
1081
+ this.crop.style.height = `${newHeight}px`;
1082
+ break;
1083
+ case CornerType.se:
1084
+ this.crop.style.width = `${newWidth}px`;
1085
+ this.crop.style.height = `${newHeight}px`;
1086
+ break;
1087
+ case CornerType.sw:
1088
+ this.crop.style.left = `${left}px`;
1089
+ this.crop.style.width = `${newWidth}px`;
1090
+ this.crop.style.height = `${newHeight}px`;
1091
+ break;
1092
+ }
1093
+ };
1094
+ this.handleCropDrag = (ev) => {
1095
+ if (!this.isMouseStillInTarget(ev)) {
1096
+ return;
1097
+ }
1098
+ let { movementX, movementY } = this.getMouvementFromEvent(ev);
1099
+ let newLeft = this.crop.offsetLeft + movementX;
1100
+ let newTop = this.crop.offsetTop + movementY;
1101
+ var imageRect = this.image.getBoundingClientRect();
1102
+ var cropRect = this.crop.getBoundingClientRect();
1103
+ if (newLeft < 0) {
1104
+ newLeft = 0;
1105
+ }
1106
+ if (newTop < 0) {
1107
+ newTop = 0;
1108
+ }
1109
+ if (newLeft + cropRect.width > imageRect.width) {
1110
+ newLeft = this.crop.offsetLeft;
1111
+ }
1112
+ if (newTop + cropRect.height > imageRect.height) {
1113
+ newTop = this.crop.offsetTop;
1114
+ }
1115
+ this.crop.style.left = newLeft + "px";
1116
+ this.crop.style.top = newTop + "px";
1117
+ };
1118
+ }
1119
+ componentDidLoad() {
1120
+ this.setView("noPictureView");
1121
+ }
1122
+ setView(newView) {
1123
+ const views = this.host.shadowRoot.querySelectorAll(".view");
1124
+ views.forEach(v => v.classList.remove("visible"));
1125
+ switch (newView) {
1126
+ case "noPictureView":
1127
+ this.noPictureView.classList.add("visible");
1128
+ break;
1129
+ case "hasPictureView":
1130
+ this.hasPictureView.classList.add("visible");
1131
+ break;
1132
+ }
1133
+ this.view = newView;
1134
+ }
1135
+ initCrop() {
1136
+ var wantedRatio = this.width / this.height;
1137
+ var imageRect = this.image.getBoundingClientRect();
1138
+ var imageRatio = imageRect.width / imageRect.height;
1139
+ if (wantedRatio > imageRatio) {
1140
+ var wantedHeight = imageRect.width / wantedRatio;
1141
+ var diff = imageRect.height - wantedHeight;
1142
+ this.crop.style.top = Math.round(diff / 2).toString() + "px";
1143
+ this.crop.style.height = Math.round(wantedHeight).toString() + "px";
1144
+ }
1145
+ else {
1146
+ var wantedWidth = imageRect.height * wantedRatio;
1147
+ var diff = imageRect.width - wantedWidth;
1148
+ this.crop.style.left = Math.round(diff / 2).toString() + "px";
1149
+ this.crop.style.width = Math.round(wantedWidth).toString() + "px";
1150
+ }
1151
+ }
1152
+ setImage() {
1153
+ this.image.addEventListener('load', () => {
1154
+ this.initCrop();
1155
+ this.emitImage();
1156
+ });
1157
+ this.image.src = this.canvas.toDataURL();
1158
+ }
1159
+ handleNewFile(file) {
1160
+ if (file.type.split('/')[0] != "image") {
1161
+ return;
1162
+ }
1163
+ var reader = new FileReader();
1164
+ reader.onload = readerLoadEvent => {
1165
+ var img = new Image();
1166
+ img.onload = () => {
1167
+ this.canvas.width = img.width;
1168
+ this.canvas.height = img.height;
1169
+ if (this.preventUndersized && (img.width < this.width || img.height < this.height)) {
1170
+ this.imageTooSmallModal.show();
1171
+ return;
1172
+ }
1173
+ var ctx = this.canvas.getContext("2d");
1174
+ ctx.drawImage(img, 0, 0);
1175
+ this.setView("hasPictureView");
1176
+ this.setImage();
1177
+ };
1178
+ img.src = readerLoadEvent.target.result.toString();
1179
+ };
1180
+ reader.readAsDataURL(file);
1181
+ }
1182
+ emitImage() {
1183
+ var x = this.crop.offsetLeft / this.image.width * this.image.naturalWidth;
1184
+ var y = this.crop.offsetTop / this.image.height * this.image.naturalHeight;
1185
+ var cropRect = this.crop.getBoundingClientRect();
1186
+ var width = cropRect.width / this.image.width * this.image.naturalWidth;
1187
+ var height = cropRect.height / this.image.height * this.image.naturalHeight;
1188
+ if (x < 0)
1189
+ x = 0;
1190
+ if (x > this.image.naturalWidth)
1191
+ x = this.image.naturalWidth;
1192
+ if (y < 0)
1193
+ y = 0;
1194
+ if (y > this.image.naturalWidth)
1195
+ y = this.image.naturalWidth;
1196
+ if (width > this.image.naturalWidth)
1197
+ width = this.image.naturalWidth;
1198
+ if (height > this.image.naturalHeight)
1199
+ height = this.image.naturalHeight;
1200
+ var dataUrl = this.generateCroppedImage(x, y, width, height, this.width, this.height);
1201
+ this.imageCropChanged.emit(dataUrl);
1202
+ }
1203
+ generateCroppedImage(x, y, width, height, desiredWidth, desiredHeight) {
1204
+ this.canvas.width = desiredWidth;
1205
+ this.canvas.height = desiredHeight;
1206
+ const context = this.canvas.getContext("2d");
1207
+ context.clearRect(0, 0, desiredWidth, desiredHeight);
1208
+ context.drawImage(this.image, x, y, width, height, 0, 0, desiredWidth, desiredHeight);
1209
+ return this.canvas.toDataURL("image/jpeg", this.quality);
1210
+ }
1211
+ getCornerLeftTop(corner) {
1212
+ let left = 0;
1213
+ let top = 0;
1214
+ switch (corner) {
1215
+ case CornerType.se:
1216
+ left = this.crop.offsetLeft;
1217
+ top = this.crop.offsetTop;
1218
+ break;
1219
+ case CornerType.sw:
1220
+ top = this.crop.offsetTop;
1221
+ break;
1222
+ }
1223
+ return { top, left };
1224
+ }
1225
+ getMouvementFromEvent(event) {
1226
+ let movementX = 0;
1227
+ let movementY = 0;
1228
+ if (event instanceof MouseEvent) {
1229
+ movementX = event.movementX;
1230
+ movementY = event.movementY;
1231
+ }
1232
+ if (typeof TouchEvent !== "undefined") {
1233
+ if (event instanceof TouchEvent) {
1234
+ let touch = event.touches[0];
1235
+ if (this.previousTouch != undefined) {
1236
+ movementX = touch.pageX - this.previousTouch.pageX;
1237
+ movementY = touch.pageY - this.previousTouch.pageY;
1238
+ }
1239
+ this.previousTouch = touch;
1240
+ }
1241
+ }
1242
+ return { movementX, movementY };
1243
+ }
1244
+ isMouseStillInTarget(event) {
1245
+ var inside = false;
1246
+ let mouseX;
1247
+ let mouseY;
1248
+ const imageRect = this.image.getBoundingClientRect();
1249
+ if (event instanceof MouseEvent) {
1250
+ mouseX = event.clientX;
1251
+ mouseY = event.clientY;
1252
+ }
1253
+ if (typeof TouchEvent !== "undefined") {
1254
+ if (event instanceof TouchEvent) {
1255
+ var touch = event.touches[0];
1256
+ mouseX = touch.clientX;
1257
+ mouseY = touch.clientY;
1258
+ }
1259
+ }
1260
+ if (mouseX >= imageRect.x &&
1261
+ mouseY >= imageRect.y &&
1262
+ mouseX <= imageRect.left + imageRect.width &&
1263
+ mouseY <= imageRect.top + imageRect.height) {
1264
+ inside = true;
1265
+ }
1266
+ var corners = this.crop.querySelectorAll("div");
1267
+ corners.forEach(corner => {
1268
+ var cornerRect = corner.getBoundingClientRect();
1269
+ if (mouseX >= cornerRect.x &&
1270
+ mouseY >= cornerRect.y &&
1271
+ mouseX <= cornerRect.left + cornerRect.width &&
1272
+ mouseY <= cornerRect.top + cornerRect.height) {
1273
+ inside = true;
1274
+ }
1275
+ });
1276
+ return inside;
1277
+ }
1278
+ render() {
1279
+ return (h(Host, { ref: el => this.host = el }, h("canvas", { ref: el => this.canvas = el }), h("div", { class: "view", ref: el => this.hasPictureView = el }, h("div", { class: "cropper" }, h("img", { ref: el => this.image = el }), h("div", { class: "backdrop" }), h("div", { class: "crop", ref: e => this.crop = e, onMouseDown: this.handleCropMouseDown, onTouchStart: this.handleCropMouseDown }, h("div", { class: "nw" }), h("div", { class: "ne" }), h("div", { class: "se" }), h("div", { class: "sw" })))), h("div", { class: "view", ref: el => this.noPictureView = el }, h("dnn-dropzone", { allowCameraMode: true, onFilesSelected: e => this.handleNewFile(e.detail[0]), resx: {
1280
+ capture: this.resx.capture,
1281
+ dragAndDropFile: this.resx.dragAndDropFile,
1282
+ or: this.resx.or,
1283
+ takePicture: this.resx.takePicture,
1284
+ uploadFile: this.resx.uploadFile,
1285
+ } })), h("dnn-modal", { ref: el => this.imageTooSmallModal = el, "close-text": this.resx.modalCloseText }, h("p", null, this.resx.imageTooSmall.replace("{width}", this.width.toString()).replace("{height}", this.height.toString())))));
1286
+ }
1287
+ };
1288
+ DnnImageCropper.style = dnnImageCropperCss;
1289
+
1290
+ const dnnModalCss = ":host{display:block}:host .overlay{background-color:rgba(0, 0, 0, 0.5);position:fixed;top:0;left:0;width:100%;height:100%;z-index:1;display:flex;justify-content:center;align-items:center;backdrop-filter:blur(2px);transition:all 300ms ease-in-out;visibility:hidden;opacity:0}:host .overlay .modal{max-width:var(--max-width, 1200px);background-color:white;padding:30px;transform:scale(2);transition:all 300ms ease-in-out;z-index:2;position:relative;margin:10%;max-height:80%;border-radius:var(--dnn-controls-radius, 5px);box-shadow:10px 10px 20px 0 rgba(0, 0, 0, 0.5);display:block}:host .overlay .modal .close{position:absolute;background-color:white;border:2px solid white;border-radius:50%;padding:0;margin:0;top:-12px;right:-12px;outline:none;display:flex;justify-content:center;align-items:center}:host .overlay .modal .close:focus,:host .overlay .modal .close:hover{box-shadow:0 0 2px 2px var(--dnn-color-primary, blue)}:host .overlay .modal .close svg{width:24px;height:24px;color:grey}:host .overlay.visible{visibility:visible;opacity:1}:host .overlay.visible .modal{transform:scale(1);box-shadow:4px 4px 10px 0px rgba(0, 0, 0, 0.5);display:block}";
1291
+
1292
+ let DnnModal = class {
1293
+ constructor(hostRef) {
1294
+ registerInstance(this, hostRef);
1295
+ this.dismissed = createEvent(this, "dismissed", 7);
1296
+ /**
1297
+ * Pass false to remove the backdrop click auto-dismiss feature.
1298
+ */
1299
+ this.backdropDismiss = true;
1300
+ /**
1301
+ * Optionally pass the aria-label text for the close button.
1302
+ * Defaults to "Close modal" if not provided.
1303
+ */
1304
+ this.closeText = "Close modal";
1305
+ /**
1306
+ * Optionally you can pass false to not show the close button.
1307
+ * If you decide to do so, you should either not also prevent dismissal by clicking the backdrop
1308
+ * or provide your own dismissal logic in the modal content.
1309
+ */
1310
+ this.showCloseButton = true;
1311
+ this.visible = false;
1312
+ }
1313
+ /**
1314
+ * Shows the modal
1315
+ */
1316
+ async show() {
1317
+ this.visible = true;
1318
+ }
1319
+ /**
1320
+ * Hides the modal
1321
+ */
1322
+ async hide() {
1323
+ this.visible = false;
1324
+ }
1325
+ handleDismiss() {
1326
+ this.visible = false;
1327
+ this.dismissed.emit();
1328
+ }
1329
+ handleBackdropClick(e) {
1330
+ const element = e.target;
1331
+ if (element.id === "backdrop" && this.backdropDismiss) {
1332
+ this.handleDismiss();
1333
+ }
1334
+ }
1335
+ render() {
1336
+ return (h(Host, null, h("div", { id: "backdrop", class: this.visible ? 'overlay visible' : 'overlay', onClick: e => this.handleBackdropClick(e) }, h("div", { class: "modal" }, this.showCloseButton &&
1337
+ h("button", { class: "close", "aria-label": this.closeText, onClick: () => this.handleDismiss() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z" }))), h("slot", null)))));
1338
+ }
1339
+ get el() { return getElement(this); }
1340
+ };
1341
+ DnnModal.style = dnnModalCss;
1342
+
1343
+ const dnnSearchboxCss = ":host{position:relative;display:flex;justify-content:space-between;--background-color:transparent;--color:#333;--border-size:1px;--border-color:grey;--border-active-color:black;--border-radius:var(--dnn-controls-radius, 5px);--padding:var(--dnn-controls-padding, 5px);--focus-color:var(--dnn-color-primary, blue)}:host input{width:100%;border:var(--border-size) solid var(--border-color);outline:none;border-radius:var(--border-radius);padding:var(--padding);padding-right:32px;transition:all 300ms ease-in-out}:host input:focus,:host input:hover{outline:none;box-shadow:0 0 2px 2px var(--focus-color)}:host svg{position:absolute;top:0;right:0;height:100%;transform:scale(0.7);fill:var(--color);outline:var(--color);color:var(--color);transition:all 300ms ease-in-out}:host button{background:transparent;border:0;margin:0;padding:0}:host button:focus svg,:host button:hover svg{fill:var(--focus-color);outline:var(--focus-color);color:var(--focus-color)}";
1344
+
1345
+ var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1346
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1347
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1348
+ r = Reflect.decorate(decorators, target, key, desc);
1349
+ else
1350
+ for (var i = decorators.length - 1; i >= 0; i--)
1351
+ if (d = decorators[i])
1352
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1353
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1354
+ };
1355
+ let DnnSearchbox = class {
1356
+ constructor(hostRef) {
1357
+ registerInstance(this, hostRef);
1358
+ this.queryChanged = createEvent(this, "queryChanged", 7);
1359
+ /**
1360
+ * Sets the field placeholder text.
1361
+ */
1362
+ this.placeholder = "";
1363
+ /**
1364
+ * Debounces the queryChanged by 500ms.
1365
+ */
1366
+ this.debounced = true;
1367
+ /** Sets the query */
1368
+ this.query = "";
1369
+ }
1370
+ fireQueryChanged() {
1371
+ if (this.debounced) {
1372
+ this.debouncedHandleQueryChanged();
1373
+ }
1374
+ else {
1375
+ this.handleQueryChanged();
1376
+ }
1377
+ }
1378
+ handleQueryChanged() {
1379
+ this.queryChanged.emit(this.query);
1380
+ }
1381
+ debouncedHandleQueryChanged() {
1382
+ this.handleQueryChanged();
1383
+ }
1384
+ render() {
1385
+ return (h(Host, null, h("input", { type: "text", value: this.query, placeholder: this.placeholder, onInput: e => this.query = e.target.value }), this.query !== "" ?
1386
+ h("button", { class: "svg clear", onClick: () => this.query = "" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z" })))
1387
+ :
1388
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M0 0h24v24H0z", fill: "none" }), h("path", { d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" }))));
1389
+ }
1390
+ static get watchers() { return {
1391
+ "query": ["fireQueryChanged"]
1392
+ }; }
1393
+ };
1394
+ __decorate([
1395
+ Debounce(500)
1396
+ ], DnnSearchbox.prototype, "debouncedHandleQueryChanged", null);
1397
+ DnnSearchbox.style = dnnSearchboxCss;
1398
+
1399
+ const dnnSortIconCss = ":host{display:inline-block}button{outline:none;border:none;margin:0;padding:0;background-color:transparent;outline:none;display:inline-block;line-height:1em;position:relative;top:0.25em}button svg{height:1.5em;width:auto;fill:var(--color, #888)}button.active svg{fill:var(--color-sorted, var(--dnn-color-primary, #028bff))}button:hover svg,button:focus svg{fill:var(--color-hover, var(--dnn-color-primary-light, #36a1ff))}";
1400
+
1401
+ let DnnSortIcon = class {
1402
+ constructor(hostRef) {
1403
+ registerInstance(this, hostRef);
1404
+ this.sortChanged = createEvent(this, "sortChanged", 7);
1405
+ /** Defines the current sort direction */
1406
+ this.sortDirection = "none";
1407
+ }
1408
+ changeSort() {
1409
+ switch (this.sortDirection) {
1410
+ case "asc":
1411
+ this.sortDirection = "desc";
1412
+ break;
1413
+ case "desc":
1414
+ this.sortDirection = "asc";
1415
+ break;
1416
+ case "none":
1417
+ this.sortDirection = "asc";
1418
+ break;
1419
+ }
1420
+ this.sortChanged.emit(this.sortDirection);
1421
+ }
1422
+ render() {
1423
+ return (h(Host, null, h("button", { class: { "active": this.sortDirection != "none" }, onClick: () => this.changeSort() }, this.sortDirection == "none" &&
1424
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 16" }, h("path", { d: "M 0 7 H 12 L 6 0 Z M 0 9 H 12 L 6 16 Z" })), this.sortDirection == "asc" &&
1425
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 16" }, h("path", { d: "M 0 7 H 12 L 6 0 Z" })), this.sortDirection == "desc" &&
1426
+ h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 12 16" }, h("path", { d: "M 0 9 H 12 L 6 16 Z" })))));
1427
+ }
1428
+ };
1429
+ DnnSortIcon.style = dnnSortIconCss;
1430
+
1431
+ const dnnTabCss = "";
1432
+
1433
+ let DnnTab = class {
1434
+ constructor(hostRef) {
1435
+ registerInstance(this, hostRef);
1436
+ this.visible = false;
1437
+ }
1438
+ /** Shows the tab. */
1439
+ async show() {
1440
+ this.visible = true;
1441
+ }
1442
+ /** Hides the modal */
1443
+ async hide() {
1444
+ this.visible = false;
1445
+ }
1446
+ render() {
1447
+ return (h(Host, null, this.visible &&
1448
+ h("slot", null)));
1449
+ }
1450
+ };
1451
+ DnnTab.style = dnnTabCss;
1452
+
1453
+ const dnnTabsCss = ":host{display:block;--color-background:var(--dnn-color-secondary-dark, lightgray);--color-text:var(--dnn-color-secondary-contrast, #333);--color-visible:var(--dnn-color-primary, #3792ED);--color-visible-text:var(--dnn-color-primary-contrast, #FFF);--color-focus:var(--dnn-color-primary, #3792ed)}.tabTitles{display:flex;background-color:var(--color-background);color:var(--color-text)}.tabTitles button{padding:0.5rem 1rem;border:0;margin:0;background-color:transparent}.tabTitles button.visible{background-color:var(--color-visible);color:var(--color-bisible-text)}.tabTitles button:focus,.tabTitles button:hover{outline:none;box-shadow:0 0 2px 2px var(--color-focus)}.currentTab{border:1px solid var(--color-background);padding:1rem}";
1454
+
1455
+ let DnnTabs = class {
1456
+ constructor(hostRef) {
1457
+ registerInstance(this, hostRef);
1458
+ this.tabTitles = [];
1459
+ this.selectedTabTitle = "";
1460
+ }
1461
+ componentDidLoad() {
1462
+ this.updateTitles();
1463
+ this.showFirstTab();
1464
+ }
1465
+ getTabs() {
1466
+ return this.component.shadowRoot.querySelector("slot").assignedElements();
1467
+ }
1468
+ updateTitles() {
1469
+ const tabs = this.getTabs();
1470
+ tabs.forEach(tab => this.tabTitles = [...this.tabTitles, tab.tabTitle]);
1471
+ }
1472
+ showFirstTab() {
1473
+ const tab = this.getTabs()[0];
1474
+ tab.show();
1475
+ this.selectedTabTitle = tab.tabTitle;
1476
+ }
1477
+ showTab(tabTitle) {
1478
+ const tabs = this.getTabs();
1479
+ tabs.forEach(tab => {
1480
+ if (tab.tabTitle == tabTitle) {
1481
+ tab.show();
1482
+ return;
1483
+ }
1484
+ tab.hide();
1485
+ });
1486
+ this.selectedTabTitle = tabTitle;
1487
+ }
1488
+ render() {
1489
+ return (h(Host, { ref: el => this.component = el }, h("div", { class: "tabTitles" }, this.tabTitles.map(tabTitle => h("button", { class: this.selectedTabTitle == tabTitle ? "visible" : "", onClick: () => this.showTab(tabTitle) }, tabTitle))), h("div", { class: "currentTab" }, h("slot", null))));
1490
+ }
1491
+ };
1492
+ DnnTabs.style = dnnTabsCss;
1493
+
1494
+ const dnnToggleCss = ":host{display:inline-block;outline:none;cursor:pointer}button{height:1.5em;width:2.5em;outline:none;background-color:var(--background, #888);border:0;border-radius:var(--border-radius, var(--dnn-controls-radius, 0.75em));padding:0.1em;position:relative;margin:0;transition:background-color 300ms ease-in-out;position:relative;cursor:pointer}button:hover,button:focus{box-shadow:0 0 2px 2px var(--dnn-color-primary)}button.checked{background-color:var(--background-checked, var(--dnn-color-primary, blue))}button.checked .handle{left:calc(1em + 4px)}button:disabled{opacity:0.5;cursor:not-allowed;box-shadow:none}button .handle{transition:all 300ms ease-in-out;background-color:white;width:1em;height:1em;border-radius:var(--dnn-controls-radius, 50%);position:absolute;top:calc(50% - 0.5em);left:2px}";
1495
+
1496
+ let DnnToggle = class {
1497
+ constructor(hostRef) {
1498
+ registerInstance(this, hostRef);
1499
+ this.checkChanged = createEvent(this, "checkChanged", 7);
1500
+ /** If 'true' the toggle is checked (on). */
1501
+ this.checked = false;
1502
+ /** If 'true' the toggle is not be interacted with. */
1503
+ this.disabled = false;
1504
+ }
1505
+ checkedChanged(isChecked) {
1506
+ this.checkChanged.emit({ checked: isChecked });
1507
+ }
1508
+ render() {
1509
+ return (h(Host, null, h("button", { disabled: this.disabled, class: { 'checked': this.checked }, onClick: () => {
1510
+ if (!this.disabled) {
1511
+ this.checked = !this.checked;
1512
+ }
1513
+ } }, h("div", { class: "handle" }))));
1514
+ }
1515
+ get element() { return getElement(this); }
1516
+ static get watchers() { return {
1517
+ "checked": ["checkedChanged"]
1518
+ }; }
1519
+ };
1520
+ DnnToggle.style = dnnToggleCss;
1521
+
1522
+ const dnnTreeviewItemCss = ":host{display:flex;overflow:hidden}.expander{width:24px;height:24px}.expander button{transition:all 150ms ease-in-out;background-color:transparent;border:none;padding:0;margin:0;outline:none;height:1em;display:flex;justify-content:center;align-items:center;cursor:pointer;position:relative;top:2px}.expander button svg :first-child{transition:all 150ms ease-in-out;fill:white;stroke:black}.expander.expanded button{transform:rotate(45deg)}.expander.expanded button svg :first-child{fill:black;stroke:black}div.item .item-slot{display:flex;align-items:center;gap:0.25em}div.item div.children{overflow:hidden;height:0;transition:all 150ms ease-in-out}";
1523
+
1524
+ let DnnTreeviewItem = class {
1525
+ constructor(hostRef) {
1526
+ registerInstance(this, hostRef);
1527
+ /** Defines if the current node is expanded */
1528
+ this.expanded = false;
1529
+ this.hasChildren = false;
1530
+ }
1531
+ componentDidLoad() {
1532
+ const children = this.childrenElement.children[0];
1533
+ const count = children.assignedElements().length;
1534
+ if (count > 0) {
1535
+ this.hasChildren = true;
1536
+ }
1537
+ if (this.expanded) {
1538
+ this.expander.classList.add("expanded");
1539
+ this.collapsible.expanded = false;
1540
+ setTimeout(() => {
1541
+ this.collapsible.expanded = true;
1542
+ }, 300);
1543
+ }
1544
+ }
1545
+ toggleCollapse() {
1546
+ this.expanded = !this.expanded;
1547
+ if (this.expanded) {
1548
+ this.expander.classList.add("expanded");
1549
+ return;
1550
+ }
1551
+ this.expander.classList.remove("expanded");
1552
+ }
1553
+ render() {
1554
+ return (h(Host, null, h("div", { class: "expander", ref: el => this.expander = el }, this.hasChildren &&
1555
+ h("button", { onClick: () => this.toggleCollapse() }, h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 0 24 24", width: "24px", fill: "#000000" }, h("path", { d: "M10 17l5-5-5-5v10z" }), h("path", { d: "M0 24V0h24v24H0z", fill: "none" })))), h("div", { class: "item" }, h("div", { class: "item-slot" }, h("slot", null)), h("dnn-collapsible", { ref: el => this.collapsible = el, expanded: this.expanded }, h("div", { ref: el => this.childrenElement = el }, h("slot", { name: "children" }))))));
1556
+ }
1557
+ get el() { return getElement(this); }
1558
+ };
1559
+ DnnTreeviewItem.style = dnnTreeviewItemCss;
1560
+
1561
+ export { DnnButton as dnn_button, DnnCheckbox as dnn_checkbox, DnnChevron as dnn_chevron, DnnCollapsible as dnn_collapsible, DnnColorPicker as dnn_color_picker, DnnDropzone as dnn_dropzone, DnnImageCropper as dnn_image_cropper, DnnModal as dnn_modal, DnnSearchbox as dnn_searchbox, DnnSortIcon as dnn_sort_icon, DnnTab as dnn_tab, DnnTabs as dnn_tabs, DnnToggle as dnn_toggle, DnnTreeviewItem as dnn_treeview_item };
1562
+
1563
+ //# sourceMappingURL=dnn-button_14.entry.js.map