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