kempo 1.1.1 → 1.1.2
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/dist/components/CodeEditor.js +1 -1
- package/dist/components/Dialog.js +1 -1
- package/docs/kempo/components/CodeEditor.js +1 -1
- package/docs/kempo/components/Dialog.js +1 -1
- package/package.json +1 -1
- package/scripts/build.js +0 -7
- package/src/components/CodeEditor.js +11 -8
- package/src/kempo.js +0 -48
|
@@ -1 +1 @@
|
|
|
1
|
-
import Component from"./Component.js";import
|
|
1
|
+
import Component from"./Component.js";import{escapeHTML}from"../utils/string.js";const keyDownHandler=Symbol(),lastValue=Symbol();export default class CodeEditor extends Component{constructor(){super(),this[lastValue]="",this[keyDownHandler]=e=>{const{key:t}=e;"Tab"==t?(e.preventDefault(),document.execCommand("insertText",!1," ")):(e.ctrlKey||e.metaKey)&&"z"===e.key&&(e.preventDefault(),document.execCommand("undo",!1,null))},this.registerAttribute("language","")}async connectedCallback(){super.connectedCallback();this.shadowRoot.getElementById("editor").addEventListener("keydown",this[keyDownHandler]),this.addEventListener("blur",this.highlight),this.value=escapeHTML(this.textContent.trim())}disconnectedCallback(){super.disconnectedCallback(),this.shadowRoot.getElementById("editor").removeEventListener("keydown",this[keyDownHandler])}highlight(){let e;this.value!==this[lastValue]&&this.dispatchEvent(new CustomEvent("change")),e="undefined"!=typeof hljs?this.language?hljs.highlight(this.value,{language:this.language}).value:hljs.highlightAuto(this.value).value:this.value,this.shadowRoot.getElementById("editor").innerHTML=e.split("\n").map((e=>`<div class="line">${e}</div>`)).join(""),this[lastValue]=this.value}get value(){return[...this.shadowRoot.getElementById("editor").querySelectorAll(".line")].map((e=>e.textContent)).join("\n")}set value(e){this.shadowRoot.getElementById("editor").innerHTML=e.split("\n").map((e=>`<div class="line">${e}</div>`)).join(""),this.highlight()}get shadowTemplate(){return'\n <link rel="stylesheet" href="../kempo/kempo-hljs.css" />\n <pre id="editor" contenteditable="true"></pre>\n '}get shadowStyles(){return`\n ${super.shadowStyles}\n :root {\n --d_caret: white;\n --l_caret: black;\n --caret: var(--l_caret);\n }\n @media (prefers-color-scheme: light) { \n :root:not([theme="dark"]) {\n --caret: var(--l_caret);\n }\n }\n :root[theme="light"] {\n --caret: var(--l_caret);\n }\n @media (prefers-color-scheme: dark) {\n :root:not([theme="light"]) {\n --caret: var(--d_caret);\n }\n }\n :root[theme="dark"] {\n --caret: var(--d_caret);\n }\n :host {\n display: block;\n border: 1px solid var(--c_border);\n border-radius: var(--radius);\n max-height: 20rem;\n overflow: auto;\n caret-color: var(--caret);\n }\n :host(:focus-within){\n box-shadow: var(--focus_shadow);\n }\n #editor {\n min-height: 6rem;\n outline: none;\n font-family: var(--ff_mono);\n resize: vertical;\n padding: var(--spacer);\n margin-bottom: 0;\n resize: vertical;\n counter-reset: line-number;\n white-space: pre-wrap;\n padding-left: 2.5rem;\n position: relative;\n }\n #editor .line::before {\n content: counter(line-number); /* Use the counter value as content */\n counter-increment: line-number; /* Increment the counter */\n display: inline-block;\n width: 2rem;\n text-align: right; /* Align numbers to the right */\n opacity: 0.65;\n position: absolute;\n left: 0;\n user-select: none;\n }\n .line {\n width: 100%;\n overflow-wrap: break-word;\n word-break: break-all;\n }\n `}}window.customElements.define("k-code-editor",CodeEditor);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Component from"./Component.js";import"./FocusCapture.js";import"./Icon.js";import{firstFocusable,onEvent,offEvent,dispatchEvent}from"../utils/element.js";export default class Dialog extends Component{constructor({opened:
|
|
1
|
+
import Component from"./Component.js";import"./FocusCapture.js";import"./Icon.js";import{firstFocusable,onEvent,offEvent,dispatchEvent}from"../utils/element.js";export default class Dialog extends Component{constructor({opened:e=!1,closeBtn:n=!0,overlayClose:t=!0,confirmText:o="",confirmClasses:i="success ml",confirmAction:s=(()=>{}),cancelText:a="",cancelClasses:l="",cancelAction:c=(()=>{}),closeCallback:r=(()=>{})}={}){super(),this.registerAttributes({opened:e,closeBtn:n,overlayClose:t,confirmText:o,confirmClasses:i,cancelText:a,cancelClasses:l}),this.registerProps({confirmAction:s,cancelAction:c,closeCallback:r,previousFocus:null,_clickHandler:e=>{const{target:{id:n}}=e;"overlay"==n&&this.overlayClose||"close"==n?this.close():"cancel"==n?(this.cancelAction(e),e.defaultPrevented||this.close()):"confirm"==n&&(this.confirmAction(e),e.defaultPrevented||this.close())},_keydownHandler:({keyCode:e})=>{27===e&&this.close()},_hasTitle:()=>!!this.querySelector('[slot="title"]')})}connectedCallback(){super.connectedCallback(),onEvent(this.shadowRoot,"click",this._clickHandler)}disconnectedCallback(){super.connectedCallback(),offEvent(this.shadowRoot,"click",this._clickHandler),offEvent(window,"keydown",this._keydownHandler)}attributeChangedCallback(e,n,t){super.attributeChangedCallback(e,n,t),"opened"===name&&dispatchEvent(this,t?"opened":"closed")}open(){this.opened=!0;const e=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);e&&e.focus(),onEvent(window,"keydown",this._keydownHandler)}close(){this.opened=!1,this.blur(),this.closeCallback(),offEvent(window,"keydown",this._keydownHandler)}toggle(){this.opened?this.close():this.open()}focus(){const e=firstFocusable(this.shadowRoot);e&&(this.previousFocus=document.activeElement,e.focus())}blur(){this.previousFocus&&this.previousFocus.focus()}get shadowTemplate(){return`\n <k-focus-capture>\n <button id="overlay" aria-label="Close the Dialog"></button>\n <div id="wrapper">\n <div\n id="dialog"\n role="dialog"\n aria-modal="true"\n aria-labelledby="title"\n >\n <div\n id="header"\n class="${this._hasTitle()?"has-title":""}"\n >\n <div\n id="title"\n ><slot name="title"></slot></div>\n ${this.renderIf(this.closeBtn,'\n <button\n id="close"\n >\n <k-icon name="close"></k-icon>\n </button>\n ')}\n </div>\n <div id="body">\n ${super.shadowTemplate}\n </div>\n ${this.renderIf(this.cancelText||this.confirmText,`\n <div id="footer">\n ${this.renderIf(this.cancelText,`\n <button id="cancel" class="${this.cancelClasses}">\n ${this.cancelText}\n </button>\n `)}\n ${this.renderIf(this.confirmText,`\n <button id="confirm" class="${this.confirmClasses}">\n ${this.confirmText}\n </button>\n `)}\n </div>\n `)}\n </div>\n </div>\n </k-focus-capture>\n `}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n display: inline;\n height: 1px;\n width: 1px;\n position: fixed; /* The browser seems to sometimes lazy load this if its out of view, this seems to fix it*/\n top: 0;\n left: 0;\n }\n :host(:not([opened])){\n display: none;\n }\n #overlay {\n position: fixed;\n width: 100vw;\n height: 100vh;\n top: 0;\n left: 0;\n background-color: var(--c_overlay);\n z-index: 100;\n border: 0px solid transparent;\n box-shadow: 0 0 0 transparent;\n }\n #wrapper {\n display: flex;\n justify-content: center;\n align-items: center;\n position: fixed;\n width: 100vw;\n height: 100vh;\n top: 0;\n left: 0;\n z-index: 101;\n pointer-events: none;\n }\n #dialog {\n display: flex;\n flex-direction: column;\n min-width: var(--min_width, 20rem);\n width: var(--width, fit-content);\n max-width: var(--max_width, calc(100vw - 2rem));\n min-height: var(--min_height, 12rem);\n height: var(--height, fit-content);\n max-height: var(--max_height, calc(100vh - 2rem));\n background-color: var(--c_bg);\n box-shadow: var(--drop_shadow);\n border-radius: var(--radius);\n pointer-events: all;\n }\n #header {\n display: flex;\n align-items: center;\n }\n #header.has-title {\n border-bottom: 1px solid var(--c_border);\n }\n #title {\n flex: 1 1 auto;\n }\n #close {\n border: 0px;\n background: transparent;\n box-shadow: 0 0 0 transparent;\n color: var(--tc);\n }\n #close k-icon {\n pointer-events: none;\n }\n #body {\n flex: 1 1 auto;\n }\n #footer {\n display: flex;\n justify-content: flex-end;\n padding: var(--spacer_h);\n }\n `}static renderOnChange=["opened","closeBtn","overlayClose","title","confirmText","cancelText"];static create(e="",n={}){const t=new Dialog({opened:!0,...n});onEvent(t,"close",t.remove),e instanceof HTMLElement||e instanceof DocumentFragment?t.appendChild(e):e instanceof NodeList?e.forEach((e=>t.appendChild(e))):t.innerHTML=e,document.body.prepend(t),t.open()}static confirm(e,n,t={title:"Confirm"}){Dialog.create(`\n <h5 slot="title" class="pyh px m0">${t.title}</h5>\n <p class="p">${e}</p>\n `,{...t,closeBtn:!1,overlayClose:!1,confirmText:"Yes",confirmClasses:"success ml",confirmAction:()=>n(!0),cancelText:"No",cancelClasses:"danger",cancelAction:()=>n(!1)})}static error(e,n,t={title:"Error"}){Dialog.create(`\n <h5 slot="title" class="pyh px m0 tc-danger">${t.title}</h5>\n <p class="p">${e}</p>\n `,{...t,cancelText:"Ok"})}}window.customElements.define("k-dialog",Dialog);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Component from"./Component.js";import
|
|
1
|
+
import Component from"./Component.js";import{escapeHTML}from"../utils/string.js";const keyDownHandler=Symbol(),lastValue=Symbol();export default class CodeEditor extends Component{constructor(){super(),this[lastValue]="",this[keyDownHandler]=e=>{const{key:t}=e;"Tab"==t?(e.preventDefault(),document.execCommand("insertText",!1," ")):(e.ctrlKey||e.metaKey)&&"z"===e.key&&(e.preventDefault(),document.execCommand("undo",!1,null))},this.registerAttribute("language","")}async connectedCallback(){super.connectedCallback();this.shadowRoot.getElementById("editor").addEventListener("keydown",this[keyDownHandler]),this.addEventListener("blur",this.highlight),this.value=escapeHTML(this.textContent.trim())}disconnectedCallback(){super.disconnectedCallback(),this.shadowRoot.getElementById("editor").removeEventListener("keydown",this[keyDownHandler])}highlight(){let e;this.value!==this[lastValue]&&this.dispatchEvent(new CustomEvent("change")),e="undefined"!=typeof hljs?this.language?hljs.highlight(this.value,{language:this.language}).value:hljs.highlightAuto(this.value).value:this.value,this.shadowRoot.getElementById("editor").innerHTML=e.split("\n").map((e=>`<div class="line">${e}</div>`)).join(""),this[lastValue]=this.value}get value(){return[...this.shadowRoot.getElementById("editor").querySelectorAll(".line")].map((e=>e.textContent)).join("\n")}set value(e){this.shadowRoot.getElementById("editor").innerHTML=e.split("\n").map((e=>`<div class="line">${e}</div>`)).join(""),this.highlight()}get shadowTemplate(){return'\n <link rel="stylesheet" href="../kempo/kempo-hljs.css" />\n <pre id="editor" contenteditable="true"></pre>\n '}get shadowStyles(){return`\n ${super.shadowStyles}\n :root {\n --d_caret: white;\n --l_caret: black;\n --caret: var(--l_caret);\n }\n @media (prefers-color-scheme: light) { \n :root:not([theme="dark"]) {\n --caret: var(--l_caret);\n }\n }\n :root[theme="light"] {\n --caret: var(--l_caret);\n }\n @media (prefers-color-scheme: dark) {\n :root:not([theme="light"]) {\n --caret: var(--d_caret);\n }\n }\n :root[theme="dark"] {\n --caret: var(--d_caret);\n }\n :host {\n display: block;\n border: 1px solid var(--c_border);\n border-radius: var(--radius);\n max-height: 20rem;\n overflow: auto;\n caret-color: var(--caret);\n }\n :host(:focus-within){\n box-shadow: var(--focus_shadow);\n }\n #editor {\n min-height: 6rem;\n outline: none;\n font-family: var(--ff_mono);\n resize: vertical;\n padding: var(--spacer);\n margin-bottom: 0;\n resize: vertical;\n counter-reset: line-number;\n white-space: pre-wrap;\n padding-left: 2.5rem;\n position: relative;\n }\n #editor .line::before {\n content: counter(line-number); /* Use the counter value as content */\n counter-increment: line-number; /* Increment the counter */\n display: inline-block;\n width: 2rem;\n text-align: right; /* Align numbers to the right */\n opacity: 0.65;\n position: absolute;\n left: 0;\n user-select: none;\n }\n .line {\n width: 100%;\n overflow-wrap: break-word;\n word-break: break-all;\n }\n `}}window.customElements.define("k-code-editor",CodeEditor);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Component from"./Component.js";import"./FocusCapture.js";import"./Icon.js";import{firstFocusable,onEvent,offEvent,dispatchEvent}from"../utils/element.js";export default class Dialog extends Component{constructor({opened:
|
|
1
|
+
import Component from"./Component.js";import"./FocusCapture.js";import"./Icon.js";import{firstFocusable,onEvent,offEvent,dispatchEvent}from"../utils/element.js";export default class Dialog extends Component{constructor({opened:e=!1,closeBtn:n=!0,overlayClose:t=!0,confirmText:o="",confirmClasses:i="success ml",confirmAction:s=(()=>{}),cancelText:a="",cancelClasses:l="",cancelAction:c=(()=>{}),closeCallback:r=(()=>{})}={}){super(),this.registerAttributes({opened:e,closeBtn:n,overlayClose:t,confirmText:o,confirmClasses:i,cancelText:a,cancelClasses:l}),this.registerProps({confirmAction:s,cancelAction:c,closeCallback:r,previousFocus:null,_clickHandler:e=>{const{target:{id:n}}=e;"overlay"==n&&this.overlayClose||"close"==n?this.close():"cancel"==n?(this.cancelAction(e),e.defaultPrevented||this.close()):"confirm"==n&&(this.confirmAction(e),e.defaultPrevented||this.close())},_keydownHandler:({keyCode:e})=>{27===e&&this.close()},_hasTitle:()=>!!this.querySelector('[slot="title"]')})}connectedCallback(){super.connectedCallback(),onEvent(this.shadowRoot,"click",this._clickHandler)}disconnectedCallback(){super.connectedCallback(),offEvent(this.shadowRoot,"click",this._clickHandler),offEvent(window,"keydown",this._keydownHandler)}attributeChangedCallback(e,n,t){super.attributeChangedCallback(e,n,t),"opened"===name&&dispatchEvent(this,t?"opened":"closed")}open(){this.opened=!0;const e=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);e&&e.focus(),onEvent(window,"keydown",this._keydownHandler)}close(){this.opened=!1,this.blur(),this.closeCallback(),offEvent(window,"keydown",this._keydownHandler)}toggle(){this.opened?this.close():this.open()}focus(){const e=firstFocusable(this.shadowRoot);e&&(this.previousFocus=document.activeElement,e.focus())}blur(){this.previousFocus&&this.previousFocus.focus()}get shadowTemplate(){return`\n <k-focus-capture>\n <button id="overlay" aria-label="Close the Dialog"></button>\n <div id="wrapper">\n <div\n id="dialog"\n role="dialog"\n aria-modal="true"\n aria-labelledby="title"\n >\n <div\n id="header"\n class="${this._hasTitle()?"has-title":""}"\n >\n <div\n id="title"\n ><slot name="title"></slot></div>\n ${this.renderIf(this.closeBtn,'\n <button\n id="close"\n >\n <k-icon name="close"></k-icon>\n </button>\n ')}\n </div>\n <div id="body">\n ${super.shadowTemplate}\n </div>\n ${this.renderIf(this.cancelText||this.confirmText,`\n <div id="footer">\n ${this.renderIf(this.cancelText,`\n <button id="cancel" class="${this.cancelClasses}">\n ${this.cancelText}\n </button>\n `)}\n ${this.renderIf(this.confirmText,`\n <button id="confirm" class="${this.confirmClasses}">\n ${this.confirmText}\n </button>\n `)}\n </div>\n `)}\n </div>\n </div>\n </k-focus-capture>\n `}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n display: inline;\n height: 1px;\n width: 1px;\n position: fixed; /* The browser seems to sometimes lazy load this if its out of view, this seems to fix it*/\n top: 0;\n left: 0;\n }\n :host(:not([opened])){\n display: none;\n }\n #overlay {\n position: fixed;\n width: 100vw;\n height: 100vh;\n top: 0;\n left: 0;\n background-color: var(--c_overlay);\n z-index: 100;\n border: 0px solid transparent;\n box-shadow: 0 0 0 transparent;\n }\n #wrapper {\n display: flex;\n justify-content: center;\n align-items: center;\n position: fixed;\n width: 100vw;\n height: 100vh;\n top: 0;\n left: 0;\n z-index: 101;\n pointer-events: none;\n }\n #dialog {\n display: flex;\n flex-direction: column;\n min-width: var(--min_width, 20rem);\n width: var(--width, fit-content);\n max-width: var(--max_width, calc(100vw - 2rem));\n min-height: var(--min_height, 12rem);\n height: var(--height, fit-content);\n max-height: var(--max_height, calc(100vh - 2rem));\n background-color: var(--c_bg);\n box-shadow: var(--drop_shadow);\n border-radius: var(--radius);\n pointer-events: all;\n }\n #header {\n display: flex;\n align-items: center;\n }\n #header.has-title {\n border-bottom: 1px solid var(--c_border);\n }\n #title {\n flex: 1 1 auto;\n }\n #close {\n border: 0px;\n background: transparent;\n box-shadow: 0 0 0 transparent;\n color: var(--tc);\n }\n #close k-icon {\n pointer-events: none;\n }\n #body {\n flex: 1 1 auto;\n }\n #footer {\n display: flex;\n justify-content: flex-end;\n padding: var(--spacer_h);\n }\n `}static renderOnChange=["opened","closeBtn","overlayClose","title","confirmText","cancelText"];static create(e="",n={}){const t=new Dialog({opened:!0,...n});onEvent(t,"close",t.remove),e instanceof HTMLElement||e instanceof DocumentFragment?t.appendChild(e):e instanceof NodeList?e.forEach((e=>t.appendChild(e))):t.innerHTML=e,document.body.prepend(t),t.open()}static confirm(e,n,t={title:"Confirm"}){Dialog.create(`\n <h5 slot="title" class="pyh px m0">${t.title}</h5>\n <p class="p">${e}</p>\n `,{...t,closeBtn:!1,overlayClose:!1,confirmText:"Yes",confirmClasses:"success ml",confirmAction:()=>n(!0),cancelText:"No",cancelClasses:"danger",cancelAction:()=>n(!1)})}static error(e,n,t={title:"Error"}){Dialog.create(`\n <h5 slot="title" class="pyh px m0 tc-danger">${t.title}</h5>\n <p class="p">${e}</p>\n `,{...t,cancelText:"Ok"})}}window.customElements.define("k-dialog",Dialog);
|
package/package.json
CHANGED
package/scripts/build.js
CHANGED
|
@@ -93,13 +93,6 @@ const minifiedMain = (await minify(main)).code;
|
|
|
93
93
|
console.log('Saving minified main entry file');
|
|
94
94
|
await fs.writeFile('./dist/index.js', minifiedMain, 'utf-8');
|
|
95
95
|
|
|
96
|
-
console.log('Loading kempo.js');
|
|
97
|
-
const kempoJS = await fs.readFile('./src/kempo.js', 'utf-8');
|
|
98
|
-
console.log('Minifying kempo.js');
|
|
99
|
-
const minifiedKempoJs = (await minify(kempoJS)).code;
|
|
100
|
-
console.log('Saving minfiied kempo.js');
|
|
101
|
-
await fs.writeFile('./dist/kempo.js', minifiedKempoJs, 'utf-8');
|
|
102
|
-
|
|
103
96
|
console.log('Loading kempo-vars.css');
|
|
104
97
|
const kempoVarsCSS = await fs.readFile('./src/kempo-vars.css', 'utf-8');
|
|
105
98
|
console.log('Minifying kempo-vars.css');
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Component from './Component.js';
|
|
2
|
-
import hljs from 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/es/highlight.min.js';
|
|
3
2
|
import {
|
|
4
3
|
escapeHTML
|
|
5
4
|
} from '../utils/string.js';
|
|
@@ -45,15 +44,19 @@ export default class CodeEditor extends Component {
|
|
|
45
44
|
this.dispatchEvent(new CustomEvent('change'));
|
|
46
45
|
}
|
|
47
46
|
let result;
|
|
48
|
-
if(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
if(typeof(hljs) !== 'undefined'){
|
|
48
|
+
if(this.language){
|
|
49
|
+
result = (hljs.highlight(
|
|
50
|
+
this.value,
|
|
51
|
+
{ language: this.language }
|
|
52
|
+
)).value;
|
|
53
|
+
} else {
|
|
54
|
+
result = (hljs.highlightAuto(this.value)).value;
|
|
55
|
+
}
|
|
53
56
|
} else {
|
|
54
|
-
result =
|
|
57
|
+
result = this.value;
|
|
55
58
|
}
|
|
56
|
-
this.shadowRoot.getElementById('editor').innerHTML = result.
|
|
59
|
+
this.shadowRoot.getElementById('editor').innerHTML = result.split('\n').map(p=>`<div class="line">${p}</div>`).join('');
|
|
57
60
|
this[lastValue] = this.value;
|
|
58
61
|
}
|
|
59
62
|
|
package/src/kempo.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const components = {
|
|
2
|
-
'k-card': 'Card',
|
|
3
|
-
'k-code-editor': 'CodeEditor',
|
|
4
|
-
'k-dialog': 'Dialog',
|
|
5
|
-
'k-icon': 'Icon',
|
|
6
|
-
'k-import': 'Import',
|
|
7
|
-
'k-resize': 'Resize',
|
|
8
|
-
'k-search': 'Search',
|
|
9
|
-
'k-show-more': 'ShowMore',
|
|
10
|
-
'k-side-menu': 'SideMenu',
|
|
11
|
-
'k-split': 'Split',
|
|
12
|
-
'k-tabs': 'Tabs',
|
|
13
|
-
'k-web-snippet-editor': 'WebSnippetEditor'
|
|
14
|
-
}
|
|
15
|
-
const lookFor = new Set(Object.keys(components));
|
|
16
|
-
window.kempo = Object.assign({}, {
|
|
17
|
-
pathToRoot: './',
|
|
18
|
-
pathToKempoFromRoot: './kempo/',
|
|
19
|
-
pathToIconsFromRoot: './kempo/icons/',
|
|
20
|
-
autoLoadComponents: () => {
|
|
21
|
-
lookFor.forEach( async component => {
|
|
22
|
-
if(document.querySelector(component)){
|
|
23
|
-
const path = `${kempo.pathToRoot}${kempo.pathToKempoFromRoot}components/${components[component]}.js`;
|
|
24
|
-
console.log(path);
|
|
25
|
-
import(path);
|
|
26
|
-
lookFor.delete(component);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
_darkModeQuery: window.matchMedia('(prefers-color-scheme: dark)'),
|
|
31
|
-
_theme: 'auto',
|
|
32
|
-
_themeListener: (e) => {
|
|
33
|
-
if(window.kempo._theme === 'auto'){
|
|
34
|
-
document.documentElement.setAttribute('theme', e.matches?'dark':'light');
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
setTheme: (theme) => {
|
|
38
|
-
window.kempo._theme = theme;
|
|
39
|
-
if(window.kempo._theme === 'auto'){
|
|
40
|
-
document.documentElement.setAttribute('theme', window.kempo._darkModeQuery.matches?'dark':'light');
|
|
41
|
-
} else {
|
|
42
|
-
document.documentElement.setAttribute('theme', theme);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}, window.kempo || {});
|
|
46
|
-
window.kempo.autoLoadComponents();
|
|
47
|
-
window.kempo._darkModeQuery.addEventListener('change', window.kempo._themeListener);
|
|
48
|
-
window.kempo.setTheme(document.documentElement.getAttribute('theme') || 'auto');
|