@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,112 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-eede7745.js');
|
|
6
|
+
const debounce = require('./debounce-1de79bc7.js');
|
|
7
|
+
|
|
8
|
+
const dnnCollapsibleCss = ":host{display:block}:host #container{height:0;overflow:hidden;transition:height 300ms ease-in-out}";
|
|
9
|
+
|
|
10
|
+
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
13
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
14
|
+
else
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
16
|
+
if (d = decorators[i])
|
|
17
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
18
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
|
+
};
|
|
20
|
+
let DnnCollapsible = class {
|
|
21
|
+
constructor(hostRef) {
|
|
22
|
+
index.registerInstance(this, hostRef);
|
|
23
|
+
this.dnnCollapsibleHeightChanged = index.createEvent(this, "dnnCollapsibleHeightChanged", 7);
|
|
24
|
+
/** Defines if the panel is expanded or not. */
|
|
25
|
+
this.expanded = false;
|
|
26
|
+
/** Defines the transition time in ms, defaults to 100ms */
|
|
27
|
+
this.transitionDuration = 150;
|
|
28
|
+
this.animating = false;
|
|
29
|
+
}
|
|
30
|
+
handleExpandedChanged(newValue) {
|
|
31
|
+
this.animating = true;
|
|
32
|
+
requestAnimationFrame(() => {
|
|
33
|
+
const container = this.el.shadowRoot.querySelector("#container");
|
|
34
|
+
if (newValue) {
|
|
35
|
+
container.style.height = container.scrollHeight + "px";
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
container.style.height = "0px";
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
requestAnimationFrame(() => {
|
|
42
|
+
this.animating = false;
|
|
43
|
+
this.dnnCollapsibleHeightChanged.emit();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** Updates the component height, use to update after a slot content changes. */
|
|
47
|
+
async updateSize() {
|
|
48
|
+
this.updateComponentSize();
|
|
49
|
+
}
|
|
50
|
+
updateComponentSize() {
|
|
51
|
+
if (this.expanded) {
|
|
52
|
+
this.animating = true;
|
|
53
|
+
requestAnimationFrame(() => {
|
|
54
|
+
const container = this.el.shadowRoot.querySelector("#container");
|
|
55
|
+
let newHeight = 0;
|
|
56
|
+
container.querySelector('slot').assignedElements().forEach(node => {
|
|
57
|
+
newHeight += node.scrollHeight;
|
|
58
|
+
});
|
|
59
|
+
container.style.height = newHeight + "px";
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
handleOtherCollapsibleHeightChanged() {
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
this.updateComponentSize();
|
|
66
|
+
}, this.transitionDuration);
|
|
67
|
+
}
|
|
68
|
+
handleMutation(mutationList) {
|
|
69
|
+
mutationList.forEach(mutation => {
|
|
70
|
+
requestAnimationFrame(() => {
|
|
71
|
+
mutation.target.closest('dnn-collapsible').updateSize();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
componentWillLoad() {
|
|
76
|
+
this.mutationObserver = new MutationObserver((mutationList) => {
|
|
77
|
+
this.handleMutation(mutationList);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
componentDidLoad() {
|
|
81
|
+
const container = this.el.shadowRoot.querySelector('#container');
|
|
82
|
+
container.style.transitionDuration = this.transitionDuration + 'ms';
|
|
83
|
+
// Monitor for content changes and update own height
|
|
84
|
+
const childNodes = [this.el];
|
|
85
|
+
childNodes.forEach(element => {
|
|
86
|
+
this.mutationObserver.observe(element, { attributes: true, characterData: true, childList: true, subtree: true });
|
|
87
|
+
});
|
|
88
|
+
const slot = this.el.shadowRoot.querySelector('slot');
|
|
89
|
+
slot.addEventListener("slotchange", () => {
|
|
90
|
+
this.updateSize();
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
disconnectedCallback() {
|
|
94
|
+
this.mutationObserver.disconnect();
|
|
95
|
+
}
|
|
96
|
+
/*eslint-enable @stencil/own-methods-must-be-private */
|
|
97
|
+
render() {
|
|
98
|
+
return (index.h(index.Host, null, index.h("div", { id: "container" }, index.h("slot", null))));
|
|
99
|
+
}
|
|
100
|
+
get el() { return index.getElement(this); }
|
|
101
|
+
static get watchers() { return {
|
|
102
|
+
"expanded": ["handleExpandedChanged"]
|
|
103
|
+
}; }
|
|
104
|
+
};
|
|
105
|
+
__decorate([
|
|
106
|
+
debounce.Debounce()
|
|
107
|
+
], DnnCollapsible.prototype, "updateSize", null);
|
|
108
|
+
DnnCollapsible.style = dnnCollapsibleCss;
|
|
109
|
+
|
|
110
|
+
exports.dnn_collapsible = DnnCollapsible;
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=dnn-collapsible.cjs.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"dnn-collapsible.entry.cjs.js","mappings":"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","names":["h","Host","Debounce"],"sources":["./src/components/dnn-collapsible/dnn-collapsible.scss?tag=dnn-collapsible&encapsulation=shadow","./src/components/dnn-collapsible/dnn-collapsible.tsx"],"sourcesContent":[":host {\r\n display: block;\r\n #container{\r\n height:0;\r\n overflow: hidden;\r\n transition: height 300ms ease-in-out;\r\n }\r\n}","import { Component, Host, h, Prop, Element, Watch, State, Method, Event, EventEmitter, Listen } from '@stencil/core';\r\nimport { Debounce } from '../../utilities/debounce';\r\n\r\n@Component({\r\n tag: \"dnn-collapsible\",\r\n styleUrl: \"dnn-collapsible.scss\",\r\n shadow: true\r\n})\r\nexport class DnnCollapsible {\r\n\r\n @Element() el: HTMLDnnCollapsibleElement;\r\n\r\n /** Defines if the panel is expanded or not. */\r\n @Prop({reflect: true}) expanded: boolean = false;\r\n\r\n /** Defines the transition time in ms, defaults to 100ms */\r\n @Prop() transitionDuration?: number = 150;\r\n\r\n @State() animating: boolean = false;\r\n\r\n @Watch(\"expanded\")\r\n handleExpandedChanged(newValue: boolean){\r\n this.animating = true;\r\n requestAnimationFrame(() => {\r\n const container = this.el.shadowRoot.querySelector(\"#container\") as HTMLDivElement;\r\n if (newValue){\r\n container.style.height = container.scrollHeight + \"px\";\r\n }\r\n else{\r\n container.style.height = \"0px\";\r\n }\r\n });\r\n \r\n requestAnimationFrame(() => {\r\n this.animating = false;\r\n this.dnnCollapsibleHeightChanged.emit();\r\n });\r\n }\r\n\r\n /** Updates the component height, use to update after a slot content changes. */\r\n @Debounce()\r\n @Method()\r\n async updateSize() {\r\n this.updateComponentSize();\r\n }\r\n\r\n private updateComponentSize(){\r\n if (this.expanded){\r\n this.animating = true;\r\n requestAnimationFrame(() => {\r\n const container = this.el.shadowRoot.querySelector(\"#container\") as HTMLDivElement;\r\n let newHeight = 0;\r\n container.querySelector('slot').assignedElements().forEach(node => {\r\n newHeight += node.scrollHeight;\r\n });\r\n container.style.height = newHeight + \"px\";\r\n });\r\n }\r\n }\r\n\r\n /** Fires whenever the collapsible height has changed */\r\n @Event() dnnCollapsibleHeightChanged: EventEmitter<void>;\r\n\r\n @Listen('dnnCollapsibleHeightChanged')\r\n handleOtherCollapsibleHeightChanged(){\r\n setTimeout(() => {\r\n this.updateComponentSize();\r\n }, this.transitionDuration);\r\n }\r\n\r\n private mutationObserver: MutationObserver;\r\n\r\n private handleMutation(mutationList){\r\n mutationList.forEach(mutation => {\r\n requestAnimationFrame(() => {\r\n mutation.target.closest('dnn-collapsible').updateSize();\r\n });\r\n });\r\n }\r\n\r\n componentWillLoad() {\r\n this.mutationObserver = new MutationObserver((mutationList) => {\r\n this.handleMutation(mutationList);\r\n });\r\n }\r\n\r\n componentDidLoad(){\r\n const container = this.el.shadowRoot.querySelector('#container') as HTMLDivElement;\r\n container.style.transitionDuration = this.transitionDuration + 'ms';\r\n\r\n // Monitor for content changes and update own height\r\n const childNodes = [this.el];\r\n childNodes.forEach(element => {\r\n this.mutationObserver.observe(element, {attributes: true, characterData: true, childList: true, subtree: true});\r\n });\r\n\r\n const slot = this.el.shadowRoot.querySelector('slot');\r\n slot.addEventListener(\"slotchange\", () => {\r\n this.updateSize();\r\n });\r\n }\r\n\r\n disconnectedCallback(){\r\n this.mutationObserver.disconnect();\r\n }\r\n /*eslint-enable @stencil/own-methods-must-be-private */\r\n\r\n render() {\r\n return (\r\n <Host>\r\n <div id=\"container\">\r\n <slot></slot>\r\n </div>\r\n </Host>\r\n );\r\n }\r\n\r\n}\r\n"],"version":3}
|
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-eede7745.js');
|
|
6
|
+
const debounce = require('./debounce-1de79bc7.js');
|
|
7
|
+
|
|
8
|
+
/** Color utility class with hsl and rgb converters
|
|
9
|
+
* based on math at https://en.wikipedia.org/wiki/HSL_and_HSV
|
|
10
|
+
* @copyright Copyright (c) .NET Foundation. All rights reserved.
|
|
11
|
+
* @license MIT
|
|
12
|
+
*/
|
|
13
|
+
class ColorInfo {
|
|
14
|
+
constructor() {
|
|
15
|
+
this._hue = 0;
|
|
16
|
+
this._saturation = 0;
|
|
17
|
+
this._lightness = 0;
|
|
18
|
+
}
|
|
19
|
+
/** gets the color hue
|
|
20
|
+
* @returns a number between 0 and 359, could contain decimals
|
|
21
|
+
*/
|
|
22
|
+
get hue() { return this._hue; }
|
|
23
|
+
set hue(value) {
|
|
24
|
+
if (value < 0) {
|
|
25
|
+
value = 0;
|
|
26
|
+
}
|
|
27
|
+
if (value > 359) {
|
|
28
|
+
value = 359;
|
|
29
|
+
}
|
|
30
|
+
this._hue = value;
|
|
31
|
+
}
|
|
32
|
+
/** gets the color saturation
|
|
33
|
+
* @returns a number between 0 and 1, could contain decimals
|
|
34
|
+
*/
|
|
35
|
+
get saturation() { return this._saturation; }
|
|
36
|
+
set saturation(value) {
|
|
37
|
+
if (value < 0) {
|
|
38
|
+
value = 0;
|
|
39
|
+
}
|
|
40
|
+
if (value > 1) {
|
|
41
|
+
value = 1;
|
|
42
|
+
}
|
|
43
|
+
this._saturation = value;
|
|
44
|
+
}
|
|
45
|
+
/** gets the color lightness
|
|
46
|
+
* @returns a number between 0 and 1, could contain decimals
|
|
47
|
+
*/
|
|
48
|
+
get lightness() { return this._lightness; }
|
|
49
|
+
set lightness(value) {
|
|
50
|
+
if (value < 0) {
|
|
51
|
+
value = 0;
|
|
52
|
+
}
|
|
53
|
+
if (value > 1) {
|
|
54
|
+
value = 1;
|
|
55
|
+
}
|
|
56
|
+
this._lightness = value;
|
|
57
|
+
}
|
|
58
|
+
/** gets or sets the red component
|
|
59
|
+
* @returns an integer between 0 and 255
|
|
60
|
+
*/
|
|
61
|
+
get red() {
|
|
62
|
+
return this.getRGB().red;
|
|
63
|
+
}
|
|
64
|
+
set red(value) {
|
|
65
|
+
this.setHSL(value, this.green, this.blue);
|
|
66
|
+
}
|
|
67
|
+
/** gets or sets the green component
|
|
68
|
+
* @returns an integer between 0 and 255
|
|
69
|
+
*/
|
|
70
|
+
get green() {
|
|
71
|
+
return this.getRGB().green;
|
|
72
|
+
}
|
|
73
|
+
set green(value) {
|
|
74
|
+
this.setHSL(this.red, value, this.blue);
|
|
75
|
+
}
|
|
76
|
+
/** gets or sets the blue component
|
|
77
|
+
* @returns an integer between 0 and 255
|
|
78
|
+
*/
|
|
79
|
+
get blue() {
|
|
80
|
+
return this.getRGB().blue;
|
|
81
|
+
}
|
|
82
|
+
set blue(value) {
|
|
83
|
+
this.setHSL(this.red, this.green, value);
|
|
84
|
+
}
|
|
85
|
+
/** gets or sets the hex color value, expresses as 6 hexadecimal characters.
|
|
86
|
+
* @returns hex representation of the color
|
|
87
|
+
*/
|
|
88
|
+
get hex() {
|
|
89
|
+
var r = this.getHex(this.red);
|
|
90
|
+
var g = this.getHex(this.green);
|
|
91
|
+
var b = this.getHex(this.blue);
|
|
92
|
+
return r + g + b;
|
|
93
|
+
}
|
|
94
|
+
set hex(value) {
|
|
95
|
+
this.red = parseInt(value.substr(0, 2));
|
|
96
|
+
this.green = parseInt(value.substr(2, 2));
|
|
97
|
+
this.blue = parseInt(value.substr(4, 2));
|
|
98
|
+
}
|
|
99
|
+
/** gets white or black color that is a good oposite to the current color
|
|
100
|
+
* @returns - "000000" or "FFFFFF"
|
|
101
|
+
*/
|
|
102
|
+
get contrastColor() {
|
|
103
|
+
const brightness = (this.red * 299 + this.green * 587 + this.blue * 114) / 1000;
|
|
104
|
+
if (brightness > 127) {
|
|
105
|
+
return "000000";
|
|
106
|
+
}
|
|
107
|
+
return "FFFFFF";
|
|
108
|
+
}
|
|
109
|
+
getRGB() {
|
|
110
|
+
const chroma = (1 - Math.abs((2 * this._lightness) - 1)) * this.saturation;
|
|
111
|
+
// find the quandrant of the hue
|
|
112
|
+
const quadrant = this._hue / 60;
|
|
113
|
+
// calculate the offset from the quandrant center
|
|
114
|
+
const offset = chroma * (1 - Math.abs(quadrant % 2 - 1));
|
|
115
|
+
// Apply the chroma to the primary component and the offset to the 2nd most important component
|
|
116
|
+
let r = 0, g = 0, b = 0;
|
|
117
|
+
if (0 <= quadrant && quadrant <= 1) {
|
|
118
|
+
r = chroma;
|
|
119
|
+
g = offset; // red to yellow
|
|
120
|
+
}
|
|
121
|
+
else if (1 <= quadrant && quadrant <= 2) {
|
|
122
|
+
g = chroma;
|
|
123
|
+
r = offset; // yellow to green
|
|
124
|
+
}
|
|
125
|
+
else if (2 <= quadrant && quadrant <= 3) {
|
|
126
|
+
g = chroma;
|
|
127
|
+
b = offset; // green to cyan
|
|
128
|
+
}
|
|
129
|
+
else if (3 <= quadrant && quadrant <= 4) {
|
|
130
|
+
b = chroma;
|
|
131
|
+
g = offset; // cyan to blue
|
|
132
|
+
}
|
|
133
|
+
else if (4 <= quadrant && quadrant <= 5) {
|
|
134
|
+
b = chroma;
|
|
135
|
+
r = offset; // blue to magenta
|
|
136
|
+
}
|
|
137
|
+
else if (5 <= quadrant && quadrant <= 6) {
|
|
138
|
+
r = chroma;
|
|
139
|
+
b = offset; // magenta to red
|
|
140
|
+
}
|
|
141
|
+
// calculate the bias to add to all channels to match the lightness
|
|
142
|
+
const bias = this._lightness - (chroma / 2);
|
|
143
|
+
return {
|
|
144
|
+
red: Math.round((r + bias) * 255),
|
|
145
|
+
green: Math.round((g + bias) * 255),
|
|
146
|
+
blue: Math.round((b + bias) * 255)
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
setHSL(red, green, blue) {
|
|
150
|
+
// GENERAL DATA
|
|
151
|
+
// all math is based on values from 0 to 1
|
|
152
|
+
const r = red / 255, g = green / 255, b = blue / 255;
|
|
153
|
+
// we need to max, min and the difference between them to derive hsl
|
|
154
|
+
const min = Math.min(r, g, b);
|
|
155
|
+
const max = Math.max(r, g, b);
|
|
156
|
+
const diff = max - min;
|
|
157
|
+
let h = 0, s = 0, l = 0;
|
|
158
|
+
// HUE
|
|
159
|
+
if (diff === 0) { // neutral
|
|
160
|
+
h = 0;
|
|
161
|
+
}
|
|
162
|
+
else if (max === r) { // red (magenta to yellow range)
|
|
163
|
+
h = 60 * ((g - b) / diff);
|
|
164
|
+
}
|
|
165
|
+
else if (max === g) { // green (yellow to cyan range)
|
|
166
|
+
h = 60 * (2 + ((b - r) / diff));
|
|
167
|
+
}
|
|
168
|
+
else if (max === b) { // blue (cyan to magenta range)
|
|
169
|
+
h = 60 * (4 + ((r - g) / diff));
|
|
170
|
+
}
|
|
171
|
+
if (h < 0) {
|
|
172
|
+
h = h + 360;
|
|
173
|
+
} // ensures positive hues only
|
|
174
|
+
if (h > 359) {
|
|
175
|
+
h = 359;
|
|
176
|
+
} // ensures we never return 360 for simplicity since it is the same as 0
|
|
177
|
+
// LIGHTNESS
|
|
178
|
+
l = (max + min) / 2;
|
|
179
|
+
// SATURATION
|
|
180
|
+
if (max === 0 || min === 1) { // pure black or white have no saturation
|
|
181
|
+
s = 0;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
s = (max - l) / (Math.min(l, 1 - l));
|
|
185
|
+
}
|
|
186
|
+
this._hue = h;
|
|
187
|
+
this._saturation = s;
|
|
188
|
+
this._lightness = l;
|
|
189
|
+
}
|
|
190
|
+
getHex(value) {
|
|
191
|
+
var hex = value.toString(16);
|
|
192
|
+
if (hex.length < 2) {
|
|
193
|
+
hex = "0" + hex;
|
|
194
|
+
}
|
|
195
|
+
return hex;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
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}";
|
|
200
|
+
|
|
201
|
+
/** Reusable DNN UI component to pick a color
|
|
202
|
+
* @copyright Copyright (c) .NET Foundation. All rights reserved.
|
|
203
|
+
* @license MIT
|
|
204
|
+
*/
|
|
205
|
+
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
206
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
207
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
208
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
209
|
+
else
|
|
210
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
211
|
+
if (d = decorators[i])
|
|
212
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
213
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
214
|
+
};
|
|
215
|
+
let DnnColorPicker = class {
|
|
216
|
+
constructor(hostRef) {
|
|
217
|
+
index.registerInstance(this, hostRef);
|
|
218
|
+
this.colorChanged = index.createEvent(this, "colorChanged", 7);
|
|
219
|
+
/** Sets the initial color, must be a valid 8 character hexadecimal string without the # sign. */
|
|
220
|
+
this.color = "FFFFFF";
|
|
221
|
+
/** Sets the width-height ratio of the color picker saturation-lightness box.
|
|
222
|
+
* @example 100% renders a perfect square
|
|
223
|
+
*/
|
|
224
|
+
this.colorBoxHeight = "50%";
|
|
225
|
+
this.rgbDisplay = "flex";
|
|
226
|
+
this.hslDisplay = "none";
|
|
227
|
+
this.hexDisplay = "none";
|
|
228
|
+
this.handleSaturationLightnessMouseDown = (e) => {
|
|
229
|
+
e.preventDefault();
|
|
230
|
+
this.handleDragLightnessSaturation(e);
|
|
231
|
+
window.addEventListener('mousemove', this.handleDragLightnessSaturation);
|
|
232
|
+
window.addEventListener('mouseup', this.handleSaturationLightnessMouseUp);
|
|
233
|
+
};
|
|
234
|
+
this.handleDragLightnessSaturation = (e) => {
|
|
235
|
+
const rect = this.saturationLightnessBox.getBoundingClientRect();
|
|
236
|
+
let x = e.clientX - rect.left;
|
|
237
|
+
if (x < 0) {
|
|
238
|
+
x = 0;
|
|
239
|
+
}
|
|
240
|
+
if (x > rect.width) {
|
|
241
|
+
x = rect.width;
|
|
242
|
+
}
|
|
243
|
+
x = x / rect.width;
|
|
244
|
+
let y = e.clientY - rect.top;
|
|
245
|
+
if (y < 0) {
|
|
246
|
+
y = 0;
|
|
247
|
+
}
|
|
248
|
+
if (y > rect.height) {
|
|
249
|
+
y = rect.height;
|
|
250
|
+
}
|
|
251
|
+
y = 1 - (y / rect.height);
|
|
252
|
+
const newColor = new ColorInfo();
|
|
253
|
+
newColor.hue = this.currentColor.hue;
|
|
254
|
+
newColor.saturation = x;
|
|
255
|
+
newColor.lightness = y;
|
|
256
|
+
this.currentColor = newColor;
|
|
257
|
+
};
|
|
258
|
+
this.handleSaturationLightnessMouseUp = () => {
|
|
259
|
+
window.removeEventListener('mousemove', this.handleDragLightnessSaturation);
|
|
260
|
+
window.removeEventListener('mouseup', this.handleSaturationLightnessMouseUp);
|
|
261
|
+
};
|
|
262
|
+
this.handleHueMouseDown = (e) => {
|
|
263
|
+
e.preventDefault();
|
|
264
|
+
this.handleDragHue(e);
|
|
265
|
+
window.addEventListener('mousemove', this.handleDragHue);
|
|
266
|
+
window.addEventListener('mouseup', this.handleHueMouseUp);
|
|
267
|
+
};
|
|
268
|
+
this.handleHueMouseUp = () => {
|
|
269
|
+
window.removeEventListener('mousemove', this.handleDragHue);
|
|
270
|
+
window.removeEventListener('mouseup', this.handleHueMouseUp);
|
|
271
|
+
};
|
|
272
|
+
this.handleDragHue = (e) => {
|
|
273
|
+
const rect = this.hueRange.getBoundingClientRect();
|
|
274
|
+
let x = e.clientX - rect.left;
|
|
275
|
+
if (x < 0) {
|
|
276
|
+
x = 0;
|
|
277
|
+
}
|
|
278
|
+
if (x > rect.width) {
|
|
279
|
+
x = rect.width;
|
|
280
|
+
}
|
|
281
|
+
x = x / rect.width * 360;
|
|
282
|
+
const newColor = new ColorInfo();
|
|
283
|
+
newColor.hue = x;
|
|
284
|
+
newColor.saturation = this.currentColor.saturation;
|
|
285
|
+
newColor.lightness = this.currentColor.lightness;
|
|
286
|
+
this.currentColor = newColor;
|
|
287
|
+
};
|
|
288
|
+
this.handleComponentValueChange = (e, channel) => {
|
|
289
|
+
let value = parseInt(e.target.value);
|
|
290
|
+
if (isNaN(value)) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
const newColor = new ColorInfo();
|
|
294
|
+
if (value < 0) {
|
|
295
|
+
value = 0;
|
|
296
|
+
}
|
|
297
|
+
if (value > 255) {
|
|
298
|
+
value = 255;
|
|
299
|
+
}
|
|
300
|
+
let r = this.currentColor.red;
|
|
301
|
+
let g = this.currentColor.green;
|
|
302
|
+
let b = this.currentColor.blue;
|
|
303
|
+
switch (channel) {
|
|
304
|
+
case 'red':
|
|
305
|
+
r = value;
|
|
306
|
+
break;
|
|
307
|
+
case 'green':
|
|
308
|
+
g = value;
|
|
309
|
+
break;
|
|
310
|
+
case 'blue':
|
|
311
|
+
b = value;
|
|
312
|
+
break;
|
|
313
|
+
default:
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
newColor.green = g;
|
|
317
|
+
newColor.red = r;
|
|
318
|
+
newColor.blue = b;
|
|
319
|
+
this.currentColor = newColor;
|
|
320
|
+
};
|
|
321
|
+
this.handleHSLChange = (e, component) => {
|
|
322
|
+
let value = parseInt(e.target.value);
|
|
323
|
+
if (isNaN(value)) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const newColor = new ColorInfo();
|
|
327
|
+
if (value != null) {
|
|
328
|
+
let h = this.currentColor.hue;
|
|
329
|
+
let s = this.currentColor.saturation;
|
|
330
|
+
let l = this.currentColor.lightness;
|
|
331
|
+
switch (component) {
|
|
332
|
+
case "hue":
|
|
333
|
+
if (value < 0) {
|
|
334
|
+
value = 0;
|
|
335
|
+
}
|
|
336
|
+
if (value > 359) {
|
|
337
|
+
value = 0;
|
|
338
|
+
}
|
|
339
|
+
h = value;
|
|
340
|
+
break;
|
|
341
|
+
case "saturation":
|
|
342
|
+
if (value < 0) {
|
|
343
|
+
value = 0;
|
|
344
|
+
}
|
|
345
|
+
if (value > 100) {
|
|
346
|
+
value = 100;
|
|
347
|
+
}
|
|
348
|
+
s = value / 100;
|
|
349
|
+
break;
|
|
350
|
+
case "lightness":
|
|
351
|
+
if (value < 0) {
|
|
352
|
+
value = 0;
|
|
353
|
+
}
|
|
354
|
+
if (value > 100) {
|
|
355
|
+
value = 100;
|
|
356
|
+
}
|
|
357
|
+
l = value / 100;
|
|
358
|
+
break;
|
|
359
|
+
default:
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
newColor.hue = h;
|
|
363
|
+
newColor.saturation = s;
|
|
364
|
+
newColor.lightness = l;
|
|
365
|
+
this.currentColor = newColor;
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
this.handleSaturationLightnessKeyDown = (e) => {
|
|
369
|
+
let newColor = new ColorInfo();
|
|
370
|
+
newColor.hue = this.currentColor.hue;
|
|
371
|
+
newColor.saturation = this.currentColor.saturation;
|
|
372
|
+
newColor.lightness = this.currentColor.lightness;
|
|
373
|
+
let value = 0.01;
|
|
374
|
+
if (e.shiftKey) {
|
|
375
|
+
value = 0.1;
|
|
376
|
+
}
|
|
377
|
+
switch (e.key) {
|
|
378
|
+
case "ArrowUp":
|
|
379
|
+
newColor.lightness += value;
|
|
380
|
+
break;
|
|
381
|
+
case "ArrowDown":
|
|
382
|
+
newColor.lightness -= value;
|
|
383
|
+
break;
|
|
384
|
+
case "ArrowLeft":
|
|
385
|
+
newColor.saturation -= value;
|
|
386
|
+
break;
|
|
387
|
+
case "ArrowRight":
|
|
388
|
+
newColor.saturation += value;
|
|
389
|
+
default:
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
this.currentColor = newColor;
|
|
393
|
+
};
|
|
394
|
+
this.handleHueKeyDown = (e) => {
|
|
395
|
+
let newColor = new ColorInfo();
|
|
396
|
+
newColor.hue = this.currentColor.hue;
|
|
397
|
+
newColor.saturation = this.currentColor.saturation;
|
|
398
|
+
newColor.lightness = this.currentColor.lightness;
|
|
399
|
+
let value = 1;
|
|
400
|
+
if (e.shiftKey) {
|
|
401
|
+
value = 10;
|
|
402
|
+
}
|
|
403
|
+
switch (e.key) {
|
|
404
|
+
case "ArrowLeft":
|
|
405
|
+
newColor.hue -= value;
|
|
406
|
+
break;
|
|
407
|
+
case "ArrowRight":
|
|
408
|
+
newColor.hue += value;
|
|
409
|
+
default:
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
this.currentColor = newColor;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
colorChangedHandler(color) {
|
|
416
|
+
this.colorChanged.emit(color);
|
|
417
|
+
}
|
|
418
|
+
handeCurrentColorChanged(newValue) {
|
|
419
|
+
this.colorChangedHandler(newValue);
|
|
420
|
+
}
|
|
421
|
+
componentWillLoad() {
|
|
422
|
+
this.handleHexChange(this.color);
|
|
423
|
+
}
|
|
424
|
+
componentDidLoad() {
|
|
425
|
+
this.el.style.setProperty("--color-box-height", this.colorBoxHeight.toString());
|
|
426
|
+
}
|
|
427
|
+
getHex() {
|
|
428
|
+
return this.getDoublet(this.currentColor.red) + this.getDoublet(this.currentColor.green) + this.getDoublet(this.currentColor.blue);
|
|
429
|
+
}
|
|
430
|
+
getContrast() {
|
|
431
|
+
return this.currentColor.contrastColor;
|
|
432
|
+
}
|
|
433
|
+
getDoublet(value) {
|
|
434
|
+
const valueString = value.toString(16).toUpperCase();
|
|
435
|
+
if (valueString.length === 1) {
|
|
436
|
+
return '0' + valueString;
|
|
437
|
+
}
|
|
438
|
+
return valueString;
|
|
439
|
+
}
|
|
440
|
+
handleHexChange(value) {
|
|
441
|
+
const newColor = new ColorInfo();
|
|
442
|
+
if (value.match(/^(?:[\da-f]{3}|[\da-f]{6})$/i).length > 0) {
|
|
443
|
+
if (value.length === 3) {
|
|
444
|
+
let expanded = value[0] + value[0] + value[1] + value[1] + value[2] + value[2];
|
|
445
|
+
value = expanded;
|
|
446
|
+
}
|
|
447
|
+
newColor.red = parseInt(value.substr(0, 2), 16);
|
|
448
|
+
newColor.green = parseInt(value.substr(2, 2), 16);
|
|
449
|
+
newColor.blue = parseInt(value.substr(4, 2), 16);
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
newColor.red = this.currentColor.red;
|
|
453
|
+
newColor.green = this.currentColor.green;
|
|
454
|
+
newColor.blue = this.currentColor.blue;
|
|
455
|
+
}
|
|
456
|
+
this.currentColor = newColor;
|
|
457
|
+
}
|
|
458
|
+
switchColorMode(e) {
|
|
459
|
+
switch (e.target.id) {
|
|
460
|
+
case "rgb-switch":
|
|
461
|
+
this.rgbDisplay = "none";
|
|
462
|
+
this.hslDisplay = "none";
|
|
463
|
+
this.hexDisplay = "flex";
|
|
464
|
+
break;
|
|
465
|
+
case "hex-switch":
|
|
466
|
+
this.rgbDisplay = "none";
|
|
467
|
+
this.hslDisplay = "flex";
|
|
468
|
+
this.hexDisplay = "none";
|
|
469
|
+
break;
|
|
470
|
+
case "hsl-switch":
|
|
471
|
+
this.rgbDisplay = "flex";
|
|
472
|
+
this.hslDisplay = "none";
|
|
473
|
+
this.hexDisplay = "none";
|
|
474
|
+
break;
|
|
475
|
+
default:
|
|
476
|
+
this.rgbDisplay = "flex";
|
|
477
|
+
this.hslDisplay = "none";
|
|
478
|
+
this.hexDisplay = "none";
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
render() {
|
|
482
|
+
const hue = this.currentColor.hue;
|
|
483
|
+
const saturation = this.currentColor.saturation;
|
|
484
|
+
const lightness = this.currentColor.lightness;
|
|
485
|
+
const red = this.currentColor.red;
|
|
486
|
+
const green = this.currentColor.green;
|
|
487
|
+
const blue = this.currentColor.blue;
|
|
488
|
+
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: {
|
|
489
|
+
left: Math.round(saturation * 100) + "%",
|
|
490
|
+
bottom: Math.round(lightness * 100) + "%"
|
|
491
|
+
}, onKeyDown: (e) => this.handleSaturationLightnessKeyDown(e) })), index.h("div", { class: "dnn-color-bar" }, index.h("div", { class: "dnn-color-result", style: {
|
|
492
|
+
backgroundColor: '#' + this.getHex(),
|
|
493
|
+
boxShadow: "0 0 2px 1px " + "#" + this.getContrast()
|
|
494
|
+
} }), 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" }))))))));
|
|
495
|
+
}
|
|
496
|
+
get el() { return index.getElement(this); }
|
|
497
|
+
static get watchers() { return {
|
|
498
|
+
"currentColor": ["handeCurrentColorChanged"]
|
|
499
|
+
}; }
|
|
500
|
+
};
|
|
501
|
+
__decorate([
|
|
502
|
+
debounce.Debounce(100)
|
|
503
|
+
], DnnColorPicker.prototype, "colorChangedHandler", null);
|
|
504
|
+
DnnColorPicker.style = dnnColorPickerCss;
|
|
505
|
+
|
|
506
|
+
exports.dnn_color_picker = DnnColorPicker;
|
|
507
|
+
|
|
508
|
+
//# sourceMappingURL=dnn-color-picker.cjs.entry.js.map
|