kempo 1.1.0 → 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/dist/components/Icon.js +1 -1
- package/dist/utils/cli.js +1 -1
- package/docs/components/_template.html +0 -4
- package/docs/components/card.html +0 -4
- package/docs/components/codeeditor.html +0 -4
- package/docs/components/component.html +0 -4
- package/docs/components/dialog.html +21 -5
- package/docs/components/icon.html +18 -4
- package/docs/components/import.html +0 -4
- package/docs/components/lazycomponent.html +0 -4
- package/docs/components/resize.html +0 -4
- package/docs/components/show-more.html +0 -4
- package/docs/components/sidemenu.html +0 -4
- package/docs/components/split.html +0 -4
- package/docs/components/tabs.html +0 -4
- package/docs/components/toggle.html +0 -4
- package/docs/components/websnippeteditor.html +0 -4
- package/docs/index.html +0 -4
- package/docs/kempo/components/CodeEditor.js +1 -1
- package/docs/kempo/components/Dialog.js +1 -1
- package/docs/kempo/components/Icon.js +1 -1
- package/docs/kempo/utils/cli.js +1 -1
- package/docs/styles/_template.html +0 -4
- package/docs/styles/borders-spacing.html +0 -4
- package/docs/styles/buttons.html +0 -4
- package/docs/styles/colors.html +0 -4
- package/docs/styles/displays-layouts.html +0 -4
- package/docs/styles/embed-1.html +0 -4
- package/docs/styles/inputs.html +0 -4
- package/docs/styles/tables.html +0 -4
- package/docs/styles/typography.html +0 -4
- package/package.json +3 -2
- package/scripts/build.js +4 -11
- package/scripts/docs.js +31 -3
- package/src/components/CodeEditor.js +11 -8
- package/src/components/Dialog.js +22 -5
- package/src/components/Icon.js +14 -5
- package/src/utils/cli.js +33 -2
- package/docs/kempo/components/Collapse.js +0 -1
- package/docs/src/icons/arrow-down-double.svg +0 -1
- package/docs/src/icons/arrow-up-double.svg +0 -1
- package/docs/src/icons/close.svg +0 -2
- package/docs/src/icons/compare.svg +0 -1
- package/docs/src/icons/dark-mode.svg +0 -1
- package/docs/src/icons/delete.svg +0 -1
- package/docs/src/icons/filter-off.svg +0 -1
- package/docs/src/icons/filter.svg +0 -1
- package/docs/src/icons/light-mode.svg +0 -1
- package/docs/src/icons/menu.svg +0 -1
- package/docs/src/icons/pause.svg +0 -1
- package/docs/src/icons/play.svg +0 -1
- package/docs/src/icons/search.svg +0 -1
- package/docs/src/icons/settings.svg +0 -1
- package/docs/src/icons/storage.svg +0 -1
- package/docs/src/icons/trash-x.svg +0 -1
- package/src/kempo.js +0 -48
- /package/docs/{kempo/icons → icons}/arrow-down-double.svg +0 -0
- /package/docs/{kempo/icons → icons}/arrow-up-double.svg +0 -0
- /package/docs/{kempo/icons → icons}/close.svg +0 -0
- /package/docs/{kempo/icons → icons}/compare.svg +0 -0
- /package/docs/{kempo/icons → icons}/dark-mode.svg +0 -0
- /package/docs/{kempo/icons → icons}/delete.svg +0 -0
- /package/docs/{kempo/icons → icons}/filter-off.svg +0 -0
- /package/docs/{kempo/icons → icons}/filter.svg +0 -0
- /package/docs/{kempo/icons → icons}/light-mode.svg +0 -0
- /package/docs/{kempo/icons → icons}/menu.svg +0 -0
- /package/docs/{kempo/icons → icons}/pause.svg +0 -0
- /package/docs/{kempo/icons → icons}/play.svg +0 -0
- /package/docs/{kempo/icons → icons}/search.svg +0 -0
- /package/docs/{kempo/icons → icons}/settings.svg +0 -0
- /package/docs/{kempo/icons → icons}/storage.svg +0 -0
- /package/docs/{kempo/icons → icons}/trash-x.svg +0 -0
|
@@ -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/dist/components/Icon.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import Component from"./Component.js";export default class Icon extends Component{constructor(){super(),this.registerAttributes({src:"",name:""})}async render(t){
|
|
1
|
+
import Component from"./Component.js";export default class Icon extends Component{constructor(){super(),this.registerAttributes({src:"",name:""})}async render(t){if(await super.render(t)){if(this.src){const t=await fetch(this.src);200===t.status?(this.innerHTML=await t.text(),this.fixSVG()):this.innerHTML.length||(this.innerHTML=Icon.fallback)}else if(this.name){const t=await fetch(`${Icon.pathToIcons}/${this.name}.svg`);200===t.status?(this.innerHTML=await t.text(),this.fixSVG()):this.innerHTML.length||(this.innerHTML=Icon.fallback)}else this.rendered=!1,this.innerHTML.length||(this.innerHTML=Icon.fallback);return!0}return!1}attributeChangedCallback(t,e,n){["src","name"].includes(t)&&this.render(!0)}fixSVG(){const t=this.querySelector("svg");t.removeAttribute("width"),t.removeAttribute("height"),t.querySelectorAll("path, rect, circle").forEach((t=>{t.setAttribute("fill","currentColor")}))}get shadowStyles(){return"\n :host {\n display: inline-block;\n vertical-align: bottom;\n }\n ::slotted(svg){\n height: 1.35em;\n vertical-align: middle;\n }\n "}static observedAttributes=["name","src"];static pathToIcons="/icons";static fallback='\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currnetColor" d="M480-79q-16 0-30.5-6T423-102L102-423q-11-12-17-26.5T79-480q0-16 6-31t17-26l321-321q12-12 26.5-17.5T480-881q16 0 31 5.5t26 17.5l321 321q12 11 17.5 26t5.5 31q0 16-5.5 30.5T858-423L537-102q-11 11-26 17t-31 6Zm0-80 321-321-321-321-321 321 321 321Zm-40-281h80v-240h-80v240Zm40 120q17 0 28.5-11.5T520-360q0-17-11.5-28.5T480-400q-17 0-28.5 11.5T440-360q0 17 11.5 28.5T480-320Zm0-160Z"/></svg>\n '}window.customElements.define("k-icon",Icon);
|
package/dist/utils/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const args={};let win={};"undefined"!=typeof window?win=window:"undefined"!=typeof global&&(win=global),win.log=(...e)=>{args.debug&&console.log(...e)};export
|
|
1
|
+
import{spawn}from"child_process";const args={};let win={};"undefined"!=typeof window?win=window:"undefined"!=typeof global&&(win=global),win.log=(...e)=>{args.debug&&console.log(...e)};export const getArgs=(e={d:"debug"})=>{let s="",o=[];const r=()=>{s&&(0===o.length?args[s]=!0:1===o.length?"false"===o[0]?args[s]=!1:args[s]=o[0]:args[s]=o)};for(let t=2;t<process.argv.length;t++){const n=process.argv[t];n.startsWith("-")?(r(),n.startsWith("--")?s=n.slice(2):(s=n.slice(1),e[s]&&(s=e[s])),o=[]):o.push(n)}return r(),args};export const runChildProcess=e=>new Promise(((s,o)=>{const[r,...t]=e.split(" ");spawn(r,t).on("close",(e=>{0===e?s(`child process exited with code ${e}`):o(new Error(`child process exited with code ${e}`))}))}));export const runChildNodeProcess=(e,s={})=>{const o=`node ${e} ${Object.entries(s).flatMap((([e,s])=>!0===s?[`--${e}`]:[`--${e}`,s])).join(" ")}`;return runChildProcess(o)};
|
|
@@ -25,10 +25,6 @@
|
|
|
25
25
|
|
|
26
26
|
</main>
|
|
27
27
|
<div style="height:33vh"></div>
|
|
28
|
-
<script type="module">
|
|
29
|
-
import Icon from '../kempo/components/Icon.js';
|
|
30
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
31
|
-
</script>
|
|
32
28
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
33
29
|
<script type="module" src="../kempo/components/Card.js"></script>
|
|
34
30
|
</body>
|
|
@@ -19,10 +19,6 @@
|
|
|
19
19
|
</k-code-editor>
|
|
20
20
|
</k-code-editor>
|
|
21
21
|
</main>
|
|
22
|
-
<script type="module">
|
|
23
|
-
import Icon from '../kempo/components/Icon.js';
|
|
24
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
25
|
-
</script>
|
|
26
22
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
27
23
|
<script type="module" src="../kempo/components/CodeEditor.js"></script>
|
|
28
24
|
</body>
|
|
@@ -79,10 +79,6 @@
|
|
|
79
79
|
|
|
80
80
|
</main>
|
|
81
81
|
<div style="height:33vh"></div>
|
|
82
|
-
<script type="module">
|
|
83
|
-
import Icon from '../kempo/components/Icon.js';
|
|
84
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
85
|
-
</script>
|
|
86
82
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
87
83
|
</body>
|
|
88
84
|
</html>
|
|
@@ -66,21 +66,37 @@
|
|
|
66
66
|
<p class="p">Ranch is gross</p>
|
|
67
67
|
</k-dialog>
|
|
68
68
|
|
|
69
|
+
<h3>JavaScript Usage</h3>
|
|
70
|
+
<h5>Create Dialog</h5>
|
|
71
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d7"</span>></span>Open Dialog<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Dialog <span class="hljs-keyword">from</span> <span class="hljs-string">'/kempo/components/Dialog.js'</span>;<br /> <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'d7'</span>).addEventListener(<span class="hljs-string">'click'</span>, () => {<br /> Dialog.create(<span class="hljs-string">'<p>Hello World</p>'</span>);<br /> });<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
72
|
+
<button id="d7" class="mb">Open Dialog</button>
|
|
73
|
+
<script type="module">
|
|
74
|
+
import Dialog from '/kempo/components/Dialog.js';
|
|
75
|
+
document.getElementById('d7').addEventListener('click', () => {
|
|
76
|
+
Dialog.create('<p>Hello World</p>');
|
|
77
|
+
});
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<h5>Error Dialog</h5>
|
|
81
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"d8"</span>></span>Open Dialog<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Dialog <span class="hljs-keyword">from</span> <span class="hljs-string">'/kempo/components/Dialog.js'</span>;<br /> <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'d8'</span>).addEventListener(<span class="hljs-string">'click'</span>, () => {<br /> Dialog.error(<span class="hljs-string">"<p>Oh no, don't do that!</p>"</span>);<br /> });<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
82
|
+
<button id="d8" class="mb">Open Dialog</button>
|
|
83
|
+
<script type="module">
|
|
84
|
+
import Dialog from '/kempo/components/Dialog.js';
|
|
85
|
+
document.getElementById('d8').addEventListener('click', () => {
|
|
86
|
+
Dialog.error("Oh no, don't do that!");
|
|
87
|
+
});
|
|
88
|
+
</script>
|
|
89
|
+
|
|
69
90
|
|
|
70
91
|
|
|
71
92
|
</main>
|
|
72
93
|
<div style="height:33vh"></div>
|
|
73
|
-
<script type="module">
|
|
74
|
-
import Icon from '../kempo/components/Icon.js';
|
|
75
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
76
|
-
</script>
|
|
77
94
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
78
95
|
<script type="module" src="../kempo/components/Dialog.js"></script>
|
|
79
96
|
<script>
|
|
80
97
|
document.querySelectorAll('.openDialog').forEach( $btn => {
|
|
81
98
|
$btn.addEventListener('click', () => {
|
|
82
99
|
const $dialog = document.getElementById($btn.dataset.dialog);
|
|
83
|
-
console.log($dialog);
|
|
84
100
|
if($dialog) $dialog.open();
|
|
85
101
|
});
|
|
86
102
|
});
|
|
@@ -43,6 +43,24 @@
|
|
|
43
43
|
</div>
|
|
44
44
|
</div>
|
|
45
45
|
|
|
46
|
+
<h3>Fallback Icon</h3>
|
|
47
|
+
<p>Put an SVG inside of the <code>k-icon</code> to be the fallback if one is not found that matches the provided name or source. Otherwise a <k-icon></k-icon> will be the fallback icon.</p>
|
|
48
|
+
<div class="row -mx mb">
|
|
49
|
+
<div class="col d-span-6 m-span-12 px">
|
|
50
|
+
<k-card label="HTML">
|
|
51
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-icon</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"invalid"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-icon</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">k-icon</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"invalid"</span>></span><br /> <span class="hljs-tag"><<span class="hljs-name">svg</span> <span class="hljs-attr">xmlns</span>=<span class="hljs-string">"http://www.w3.org/2000/svg"</span> <span class="hljs-attr">viewBox</span>=<span class="hljs-string">"0 -960 960 960"</span>></span><span class="hljs-tag"><<span class="hljs-name">path</span> <span class="hljs-attr">fill</span>=<span class="hljs-string">"currentColor"</span> <span class="hljs-attr">d</span>=<span class="hljs-string">"M240-280h200v-80H240v80Zm400 0h80v-80h-80v80ZM240-440h200v-80H240v80Zm400 0h80v-240h-80v240ZM240-600h200v-80H240v80Zm-80 480q-33 0-56.5-23.5T80-200v-560q0-33 23.5-56.5T160-840h640q33 0 56.5 23.5T880-760v560q0 33-23.5 56.5T800-120H160Zm0-80h640v-560H160v560Zm0 0v-560 560Z"</span>/></span><span class="hljs-tag"></<span class="hljs-name">svg</span>></span><br /><span class="hljs-tag"></<span class="hljs-name">k-icon</span>></span></code></pre>
|
|
52
|
+
</k-card>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="col d-span-6 m-span-12 px">
|
|
55
|
+
<k-card label="Output*">
|
|
56
|
+
<k-icon name="invalid"></k-icon>
|
|
57
|
+
<k-icon name="invalid">
|
|
58
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M240-280h200v-80H240v80Zm400 0h80v-80h-80v80ZM240-440h200v-80H240v80Zm400 0h80v-240h-80v240ZM240-600h200v-80H240v80Zm-80 480q-33 0-56.5-23.5T80-200v-560q0-33 23.5-56.5T160-840h640q33 0 56.5 23.5T880-760v560q0 33-23.5 56.5T800-120H160Zm0-80h640v-560H160v560Zm0 0v-560 560Z"/></svg>
|
|
59
|
+
</k-icon>
|
|
60
|
+
</k-card>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
46
64
|
<h3>Changing the icon directory location</h3>
|
|
47
65
|
<p>To change the location of the directory holding the icons import the <code>Icon</code> class, and set the static member <code>pathToIcons</code> to point to the correct location, do this before icons are loaded (for example in the head of the document).</p>
|
|
48
66
|
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Icon <span class="hljs-keyword">from</span> <span class="hljs-string">'/kempo/components/Icon.js'</span>;<br /> Icon.pathToIcons = <span class="hljs-string">'./pathTo/icons'</span>;<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
@@ -63,10 +81,6 @@
|
|
|
63
81
|
</div>
|
|
64
82
|
</main>
|
|
65
83
|
<div style="height:33vh"></div>
|
|
66
|
-
<script type="module">
|
|
67
|
-
import Icon from '../kempo/components/Icon.js';
|
|
68
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
69
|
-
</script>
|
|
70
84
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
71
85
|
<script type="module" src="../kempo/components/Card.js"></script>
|
|
72
86
|
</body>
|
|
@@ -24,10 +24,6 @@
|
|
|
24
24
|
</k-card>
|
|
25
25
|
</main>
|
|
26
26
|
<div style="height:33vh"></div>
|
|
27
|
-
<script type="module">
|
|
28
|
-
import Icon from '../kempo/components/Icon.js';
|
|
29
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
30
|
-
</script>
|
|
31
27
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
32
28
|
<script type="module" src="../kempo/components/Card.js"></script>
|
|
33
29
|
</body>
|
|
@@ -41,10 +41,6 @@
|
|
|
41
41
|
<p>This class <b class="tc-danger">can not</b> be instatiated directly, but rather <b class="tc-success">should be</b> extended, optionally passing in the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow#options" target="_blank">shadowOptions</a>.</p>
|
|
42
42
|
|
|
43
43
|
</main>
|
|
44
|
-
<script type="module">
|
|
45
|
-
import Icon from '../kempo/components/Icon.js';
|
|
46
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
47
|
-
</script>
|
|
48
44
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
49
45
|
</body>
|
|
50
46
|
</html>
|
|
@@ -97,10 +97,6 @@
|
|
|
97
97
|
|
|
98
98
|
</main>
|
|
99
99
|
<div style="height:33vh"></div>
|
|
100
|
-
<script type="module">
|
|
101
|
-
import Icon from '../kempo/components/Icon.js';
|
|
102
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
103
|
-
</script>
|
|
104
100
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
105
101
|
<script type="module" src="../kempo/components/Resize.js"></script>
|
|
106
102
|
</body>
|
|
@@ -6,10 +6,6 @@
|
|
|
6
6
|
<title>ShowMore - Components - Kempo Docs - A Web Components Solution</title>
|
|
7
7
|
<link rel="stylesheet" href="../kempo/kempo-vars.css" /><link rel="stylesheet" href="../kempo/kempo-styles.css" />
|
|
8
8
|
<link rel="stylesheet" href="../kempo/kempo-hljs.css" />
|
|
9
|
-
<script type="module">
|
|
10
|
-
import Icon from '../kempo/components/Icon.js';
|
|
11
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
12
|
-
</script>
|
|
13
9
|
</head>
|
|
14
10
|
<body>
|
|
15
11
|
<k-import src="../nav-1.inc.html"></k-import>
|
|
@@ -87,10 +87,6 @@
|
|
|
87
87
|
</div>
|
|
88
88
|
</main>
|
|
89
89
|
<div style="height:33vh"></div>
|
|
90
|
-
<script type="module">
|
|
91
|
-
import Icon from '../kempo/components/Icon.js';
|
|
92
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
93
|
-
</script>
|
|
94
90
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
95
91
|
<script type="module" src="../kempo/components/SideMenu.js"></script>
|
|
96
92
|
</body>
|
|
@@ -59,10 +59,6 @@
|
|
|
59
59
|
|
|
60
60
|
</main>
|
|
61
61
|
<div style="height:33vh"></div>
|
|
62
|
-
<script type="module">
|
|
63
|
-
import Icon from '../kempo/components/Icon.js';
|
|
64
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
65
|
-
</script>
|
|
66
62
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
67
63
|
<script type="module" src="../kempo/components/Card.js"></script>
|
|
68
64
|
<script type="module" src="../kempo/components/Split.js"></script>
|
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
</k-tabs>
|
|
24
24
|
</main>
|
|
25
25
|
<div style="height:33vh"></div>
|
|
26
|
-
<script type="module">
|
|
27
|
-
import Icon from '../kempo/components/Icon.js';
|
|
28
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
29
|
-
</script>
|
|
30
26
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
31
27
|
<script type="module" src="../kempo/components/Tabs.js"></script>
|
|
32
28
|
</body>
|
|
@@ -146,10 +146,6 @@
|
|
|
146
146
|
|
|
147
147
|
</main>
|
|
148
148
|
<div style="height:33vh"></div>
|
|
149
|
-
<script type="module">
|
|
150
|
-
import Icon from '../kempo/components/Icon.js';
|
|
151
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
152
|
-
</script>
|
|
153
149
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
154
150
|
<script type="module" src="../kempo/components/Toggle.js"></script>
|
|
155
151
|
</body>
|
|
@@ -32,10 +32,6 @@ document.getElementById('hello').addEventListener('click', () => {
|
|
|
32
32
|
</k-web-snippet-editor>
|
|
33
33
|
</main>
|
|
34
34
|
<div style="height:33vh"></div>
|
|
35
|
-
<script type="module">
|
|
36
|
-
import Icon from '../kempo/components/Icon.js';
|
|
37
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
38
|
-
</script>
|
|
39
35
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
40
36
|
<script type="module" src="../kempo/components/WebSnippetEditor.js"></script>
|
|
41
37
|
</body>
|
package/docs/index.html
CHANGED
|
@@ -8,10 +8,6 @@
|
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
10
10
|
<k-import src="./nav.inc.html"></k-import>
|
|
11
|
-
<script type="module">
|
|
12
|
-
import Icon from './kempo/components/Icon.js';
|
|
13
|
-
Icon.pathToIcons = './kempo/icons';
|
|
14
|
-
</script>
|
|
15
11
|
<script type="module" src="./kempo/components/Import.js"></script>
|
|
16
12
|
</body>
|
|
17
13
|
</html>
|
|
@@ -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";export default class Icon extends Component{constructor(){super(),this.registerAttributes({src:"",name:""})}async render(t){
|
|
1
|
+
import Component from"./Component.js";export default class Icon extends Component{constructor(){super(),this.registerAttributes({src:"",name:""})}async render(t){if(await super.render(t)){if(this.src){const t=await fetch(this.src);200===t.status?(this.innerHTML=await t.text(),this.fixSVG()):this.innerHTML.length||(this.innerHTML=Icon.fallback)}else if(this.name){const t=await fetch(`${Icon.pathToIcons}/${this.name}.svg`);200===t.status?(this.innerHTML=await t.text(),this.fixSVG()):this.innerHTML.length||(this.innerHTML=Icon.fallback)}else this.rendered=!1,this.innerHTML.length||(this.innerHTML=Icon.fallback);return!0}return!1}attributeChangedCallback(t,e,n){["src","name"].includes(t)&&this.render(!0)}fixSVG(){const t=this.querySelector("svg");t.removeAttribute("width"),t.removeAttribute("height"),t.querySelectorAll("path, rect, circle").forEach((t=>{t.setAttribute("fill","currentColor")}))}get shadowStyles(){return"\n :host {\n display: inline-block;\n vertical-align: bottom;\n }\n ::slotted(svg){\n height: 1.35em;\n vertical-align: middle;\n }\n "}static observedAttributes=["name","src"];static pathToIcons="/icons";static fallback='\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currnetColor" d="M480-79q-16 0-30.5-6T423-102L102-423q-11-12-17-26.5T79-480q0-16 6-31t17-26l321-321q12-12 26.5-17.5T480-881q16 0 31 5.5t26 17.5l321 321q12 11 17.5 26t5.5 31q0 16-5.5 30.5T858-423L537-102q-11 11-26 17t-31 6Zm0-80 321-321-321-321-321 321 321 321Zm-40-281h80v-240h-80v240Zm40 120q17 0 28.5-11.5T520-360q0-17-11.5-28.5T480-400q-17 0-28.5 11.5T440-360q0 17 11.5 28.5T480-320Zm0-160Z"/></svg>\n '}window.customElements.define("k-icon",Icon);
|
package/docs/kempo/utils/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const args={};let win={};"undefined"!=typeof window?win=window:"undefined"!=typeof global&&(win=global),win.log=(...e)=>{args.debug&&console.log(...e)};export
|
|
1
|
+
import{spawn}from"child_process";const args={};let win={};"undefined"!=typeof window?win=window:"undefined"!=typeof global&&(win=global),win.log=(...e)=>{args.debug&&console.log(...e)};export const getArgs=(e={d:"debug"})=>{let s="",o=[];const r=()=>{s&&(0===o.length?args[s]=!0:1===o.length?"false"===o[0]?args[s]=!1:args[s]=o[0]:args[s]=o)};for(let t=2;t<process.argv.length;t++){const n=process.argv[t];n.startsWith("-")?(r(),n.startsWith("--")?s=n.slice(2):(s=n.slice(1),e[s]&&(s=e[s])),o=[]):o.push(n)}return r(),args};export const runChildProcess=e=>new Promise(((s,o)=>{const[r,...t]=e.split(" ");spawn(r,t).on("close",(e=>{0===e?s(`child process exited with code ${e}`):o(new Error(`child process exited with code ${e}`))}))}));export const runChildNodeProcess=(e,s={})=>{const o=`node ${e} ${Object.entries(s).flatMap((([e,s])=>!0===s?[`--${e}`]:[`--${e}`,s])).join(" ")}`;return runChildProcess(o)};
|
|
@@ -184,10 +184,6 @@
|
|
|
184
184
|
|
|
185
185
|
|
|
186
186
|
</main>
|
|
187
|
-
<script type="module">
|
|
188
|
-
import Icon from '../kempo/components/Icon.js';
|
|
189
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
190
|
-
</script>
|
|
191
187
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
192
188
|
</body>
|
|
193
189
|
</html>
|
package/docs/styles/buttons.html
CHANGED
|
@@ -103,10 +103,6 @@
|
|
|
103
103
|
</div>
|
|
104
104
|
</main>
|
|
105
105
|
<div style="height:33vh"></div>
|
|
106
|
-
<script type="module">
|
|
107
|
-
import Icon from '../kempo/components/Icon.js';
|
|
108
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
109
|
-
</script>
|
|
110
106
|
<script type="module" src="../kempo/components/Card.js"></script>
|
|
111
107
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
112
108
|
</body>
|
package/docs/styles/colors.html
CHANGED
|
@@ -55,10 +55,6 @@
|
|
|
55
55
|
<h3>* Notes</h3>
|
|
56
56
|
<p><i>Additional styles may be added to the example output (borders, spacing, colors) for demonstration.</i></p>
|
|
57
57
|
</main>
|
|
58
|
-
<script type="module">
|
|
59
|
-
import Icon from '../kempo/components/Icon.js';
|
|
60
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
61
|
-
</script>
|
|
62
58
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
63
59
|
<script type="module" src="../kempo/components/Card.js"></script>
|
|
64
60
|
</body>
|
|
@@ -147,10 +147,6 @@
|
|
|
147
147
|
<h3>* Notes</h3>
|
|
148
148
|
<p><i>Additional styles may be added to the example output (borders, spacing, colors) for demonstration.</i></p>
|
|
149
149
|
</main>
|
|
150
|
-
<script type="module">
|
|
151
|
-
import Icon from '../kempo/components/Icon.js';
|
|
152
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
153
|
-
</script>
|
|
154
150
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
155
151
|
</body>
|
|
156
152
|
</html>
|
package/docs/styles/embed-1.html
CHANGED
|
@@ -26,10 +26,6 @@
|
|
|
26
26
|
col d-span-3 t-span-6 m-span-12
|
|
27
27
|
</div>
|
|
28
28
|
</div>
|
|
29
|
-
<script type="module">
|
|
30
|
-
import Icon from '../kempo/components/Icon.js';
|
|
31
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
32
|
-
</script>
|
|
33
29
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
34
30
|
</body>
|
|
35
31
|
</html>
|
package/docs/styles/inputs.html
CHANGED
|
@@ -79,10 +79,6 @@
|
|
|
79
79
|
</div>
|
|
80
80
|
</div>
|
|
81
81
|
</main>
|
|
82
|
-
<script type="module">
|
|
83
|
-
import Icon from '../kempo/components/Icon.js';
|
|
84
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
85
|
-
</script>
|
|
86
82
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
87
83
|
<script type="module" src="../kempo/components/Card.js"></script>
|
|
88
84
|
</body>
|
package/docs/styles/tables.html
CHANGED
|
@@ -132,10 +132,6 @@
|
|
|
132
132
|
</div>
|
|
133
133
|
</main>
|
|
134
134
|
<div style="height: 33vh"></div>
|
|
135
|
-
<script type="module">
|
|
136
|
-
import Icon from '../kempo/components/Icon.js';
|
|
137
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
138
|
-
</script>
|
|
139
135
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
140
136
|
<script type="module" src="../kempo/components/Card.js"></script>
|
|
141
137
|
<script type="module" src="../kempo/components/Resize.js"></script>
|
|
@@ -107,10 +107,6 @@
|
|
|
107
107
|
</div>
|
|
108
108
|
</div>
|
|
109
109
|
</main>
|
|
110
|
-
<script type="module">
|
|
111
|
-
import Icon from '../kempo/components/Icon.js';
|
|
112
|
-
Icon.pathToIcons = '../kempo/icons';
|
|
113
|
-
</script>
|
|
114
110
|
<script type="module" src="../kempo/components/Import.js"></script>
|
|
115
111
|
</body>
|
|
116
112
|
</html>
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kempo",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A web component library",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "node ./scrips/test.js",
|
|
9
9
|
"build": "node ./scripts/build.js",
|
|
10
|
-
"docs": "node ./scripts/
|
|
10
|
+
"docs": "node ./scripts/docs.js",
|
|
11
|
+
"docs-src": "node ./scripts/docs.js -s"
|
|
11
12
|
},
|
|
12
13
|
"author": "Dustin Poissant",
|
|
13
14
|
"license": "MIT",
|
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');
|
|
@@ -121,11 +114,11 @@ const minifiedKempoHljsCSS = kempoHljsCSS.replace(/\s*\{\s*/g, '{').replace(/\s*
|
|
|
121
114
|
console.log('Saving kempo-hljs.css');
|
|
122
115
|
await fs.writeFile('./dist/kempo-hljs.css', minifiedKempoHljsCSS, 'utf-8');
|
|
123
116
|
|
|
124
|
-
console.log('Copying dist/ to docs/
|
|
125
|
-
await fse.ensureDir('./docs/
|
|
117
|
+
console.log('Copying dist/ to docs/');
|
|
118
|
+
await fse.ensureDir('./docs/icons'); // will also ensure docs/kempo
|
|
126
119
|
await fse.copy('./dist', './docs/kempo')
|
|
127
120
|
|
|
128
|
-
console.log('Copying icons/ to docs/
|
|
129
|
-
await fse.copy('./icons', './docs/
|
|
121
|
+
console.log('Copying icons/ to docs/icons/');
|
|
122
|
+
await fse.copy('./icons', './docs/icons')
|
|
130
123
|
|
|
131
124
|
console.log('Build Complete');
|
package/scripts/docs.js
CHANGED
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import {
|
|
5
|
+
getArgs,
|
|
6
|
+
runChildNodeProcess
|
|
7
|
+
} from '../src/utils/cli.js';
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = dirname(__filename);
|
|
11
|
+
|
|
12
|
+
const options = getArgs({
|
|
13
|
+
p: 'port',
|
|
14
|
+
b: 'build',
|
|
15
|
+
s: 'src'
|
|
16
|
+
});
|
|
3
17
|
|
|
4
18
|
const {
|
|
5
|
-
|
|
6
|
-
|
|
19
|
+
port = 8083,
|
|
20
|
+
build = true,
|
|
21
|
+
src = false
|
|
22
|
+
} = options;
|
|
23
|
+
|
|
24
|
+
console.log(port, build, src);
|
|
25
|
+
|
|
26
|
+
if(build){
|
|
27
|
+
runChildNodeProcess(join(__dirname, 'build.js'));
|
|
28
|
+
}
|
|
7
29
|
|
|
8
30
|
const app = express();
|
|
9
31
|
|
|
32
|
+
if(src){
|
|
33
|
+
app.use('/kempo', express.static('src'));
|
|
34
|
+
app.use('/icons', express.static('icons'));
|
|
35
|
+
}
|
|
10
36
|
app.use(express.static('docs'));
|
|
11
37
|
|
|
38
|
+
|
|
39
|
+
|
|
12
40
|
app.listen(port, () => {
|
|
13
41
|
console.log(`Docs Running on: http://localhost:${port}`);
|
|
14
42
|
});
|
|
@@ -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/components/Dialog.js
CHANGED
|
@@ -156,8 +156,11 @@ export default class Dialog extends Component {
|
|
|
156
156
|
${super.shadowStyles}
|
|
157
157
|
:host {
|
|
158
158
|
display: inline;
|
|
159
|
-
height:
|
|
160
|
-
width:
|
|
159
|
+
height: 1px;
|
|
160
|
+
width: 1px;
|
|
161
|
+
position: fixed; /* The browser seems to sometimes lazy load this if its out of view, this seems to fix it*/
|
|
162
|
+
top: 0;
|
|
163
|
+
left: 0;
|
|
161
164
|
}
|
|
162
165
|
:host(:not([opened])){
|
|
163
166
|
display: none;
|
|
@@ -251,11 +254,14 @@ export default class Dialog extends Component {
|
|
|
251
254
|
} else {
|
|
252
255
|
$dialog.innerHTML = contents;
|
|
253
256
|
}
|
|
254
|
-
document.body.
|
|
257
|
+
document.body.prepend($dialog);
|
|
258
|
+
$dialog.open();
|
|
255
259
|
}
|
|
256
|
-
static confirm(text, responseCallback, options
|
|
260
|
+
static confirm(text, responseCallback, options = {
|
|
261
|
+
title: 'Confirm'
|
|
262
|
+
}){
|
|
257
263
|
Dialog.create(`
|
|
258
|
-
<h5 slot="title" class="pyh px m0"
|
|
264
|
+
<h5 slot="title" class="pyh px m0">${options.title}</h5>
|
|
259
265
|
<p class="p">${text}</p>
|
|
260
266
|
`, {
|
|
261
267
|
...options,
|
|
@@ -273,5 +279,16 @@ export default class Dialog extends Component {
|
|
|
273
279
|
}
|
|
274
280
|
});
|
|
275
281
|
}
|
|
282
|
+
static error(text, responseCallback, options = {
|
|
283
|
+
title: 'Error'
|
|
284
|
+
}){
|
|
285
|
+
Dialog.create(`
|
|
286
|
+
<h5 slot="title" class="pyh px m0 tc-danger">${options.title}</h5>
|
|
287
|
+
<p class="p">${text}</p>
|
|
288
|
+
`, {
|
|
289
|
+
...options,
|
|
290
|
+
cancelText: 'Ok'
|
|
291
|
+
});
|
|
292
|
+
}
|
|
276
293
|
}
|
|
277
294
|
window.customElements.define('k-dialog', Dialog);
|
package/src/components/Icon.js
CHANGED
|
@@ -11,14 +11,20 @@ export default class Icon extends Component {
|
|
|
11
11
|
async render(force){
|
|
12
12
|
if(await super.render(force)){
|
|
13
13
|
if(this.src){
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const response = await fetch(this.src);
|
|
15
|
+
if(response.status === 200){
|
|
16
|
+
this.innerHTML = await (response).text();
|
|
17
|
+
this.fixSVG();
|
|
18
|
+
} else if(!this.innerHTML.length) this.innerHTML = Icon.fallback;
|
|
16
19
|
} else if(this.name){
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
const response = await fetch(`${Icon.pathToIcons}/${this.name}.svg`);
|
|
21
|
+
if(response.status === 200){
|
|
22
|
+
this.innerHTML = await (response).text();
|
|
23
|
+
this.fixSVG();
|
|
24
|
+
} else if(!this.innerHTML.length) this.innerHTML = Icon.fallback;
|
|
19
25
|
} else {
|
|
20
26
|
this.rendered = false;
|
|
21
|
-
this.innerHTML =
|
|
27
|
+
if(!this.innerHTML.length) this.innerHTML = Icon.fallback;
|
|
22
28
|
}
|
|
23
29
|
return true;
|
|
24
30
|
}
|
|
@@ -56,5 +62,8 @@ export default class Icon extends Component {
|
|
|
56
62
|
];
|
|
57
63
|
|
|
58
64
|
static pathToIcons = '/icons';
|
|
65
|
+
static fallback = /*html*/`
|
|
66
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currnetColor" d="M480-79q-16 0-30.5-6T423-102L102-423q-11-12-17-26.5T79-480q0-16 6-31t17-26l321-321q12-12 26.5-17.5T480-881q16 0 31 5.5t26 17.5l321 321q12 11 17.5 26t5.5 31q0 16-5.5 30.5T858-423L537-102q-11 11-26 17t-31 6Zm0-80 321-321-321-321-321 321 321 321Zm-40-281h80v-240h-80v240Zm40 120q17 0 28.5-11.5T520-360q0-17-11.5-28.5T480-400q-17 0-28.5 11.5T440-360q0 17 11.5 28.5T480-320Zm0-160Z"/></svg>
|
|
67
|
+
`;
|
|
59
68
|
}
|
|
60
69
|
window.customElements.define('k-icon', Icon);
|
package/src/utils/cli.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
|
|
1
3
|
const args = {};
|
|
2
4
|
let win = {};
|
|
3
5
|
if(typeof(window) !== 'undefined'){
|
|
@@ -11,7 +13,7 @@ win.log = (...messages) => {
|
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
export
|
|
16
|
+
export const getArgs = (shortMap = {
|
|
15
17
|
d: 'debug'
|
|
16
18
|
}) => {
|
|
17
19
|
let name = '';
|
|
@@ -21,7 +23,11 @@ export default (shortMap = {
|
|
|
21
23
|
if(values.length === 0){ // flag
|
|
22
24
|
args[name] = true;
|
|
23
25
|
} else if(values.length === 1){ // single value
|
|
24
|
-
|
|
26
|
+
if(values[0] === 'false'){
|
|
27
|
+
args[name] = false;
|
|
28
|
+
} else {
|
|
29
|
+
args[name] = values[0];
|
|
30
|
+
}
|
|
25
31
|
} else { // multiple values
|
|
26
32
|
args[name] = values;
|
|
27
33
|
}
|
|
@@ -52,3 +58,28 @@ export default (shortMap = {
|
|
|
52
58
|
save();
|
|
53
59
|
return args;
|
|
54
60
|
}
|
|
61
|
+
|
|
62
|
+
export const runChildProcess = (command) => new Promise((resolve, reject) => {
|
|
63
|
+
const [cmd, ...args] = command.split(' ');
|
|
64
|
+
const child = spawn(cmd, args);
|
|
65
|
+
|
|
66
|
+
child.on('close', (code) => {
|
|
67
|
+
if (code === 0) {
|
|
68
|
+
resolve(`child process exited with code ${code}`);
|
|
69
|
+
} else {
|
|
70
|
+
reject(new Error(`child process exited with code ${code}`));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export const runChildNodeProcess = (scriptPath, argsObj = {}) => {
|
|
76
|
+
const args = Object.entries(argsObj).flatMap(([key, value]) => {
|
|
77
|
+
if (value === true) {
|
|
78
|
+
return [`--${key}`];
|
|
79
|
+
} else {
|
|
80
|
+
return [`--${key}`, value];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const command = `node ${scriptPath} ${args.join(' ')}`;
|
|
84
|
+
return runChildProcess(command);
|
|
85
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import ReactiveLazyComponent from"./ReactiveLazyComponent.js";import{onEvent,offEvent,dispatchEvent}from"../utils/element.js";const toggleClickHandler=Symbol("toggleClickHandler");export default class Collapse extends ReactiveLazyComponent{constructor(){super(),this[toggleClickHandler]=()=>{this.toggle(),this.shadowRoot.getElementById("toggle").focus()},this.registerAttribute("opened",!1)}async render(e){return!!super.render(e)&&(onEvent(this.shadowRoot.getElementById("toggle"),"click",this[toggleClickHandler]),!0)}disconnectedCallback(){offEvent(this.shadowRoot.getElementById("toggle"),"click",this[toggleClickHandler]),super.disconnectedCallback()}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),"opened"===e&&dispatchEvent(this,n?"change opened":"change closed")}open(){this.opened=!0}close(){this.opened=!1}toggle(){this.opened=!this.opened,dispatchEvent(this,"toggle")}get shadowTemplate(){return`\n <button\n id="toggle"\n class="no-btn p"\n >\n <slot name="${this.opened?"closeText":"openText"}">${this.opened?"Hide Content":"Show Content"}</slot>\n </button>\n ${this.renderIf(this.opened,`\n <div id="content">\n ${super.shadowTemplate}\n </div>\n `)}\n `}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n display: block;\n }\n #toggle {\n width: 100%;\n }\n `}static renderOnChange=["opened"];static observedAttributes=this.renderOnChange}window.customElements.define("k-collapse",Collapse);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M480-200 240-440l56-56 184 183 184-183 56 56-240 240Zm0-240L240-680l56-56 184 183 184-183 56 56-240 240Z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="m296-224-56-56 240-240 240 240-56 56-184-183-184 183Zm0-240-56-56 240-240 240 240-56 56-184-183-184 183Z"/></svg>
|
package/docs/src/icons/close.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M400-40v-80H200q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h200v-80h80v880h-80ZM200-240h200v-240L200-240Zm360 120v-360l200 240v-520H560v-80h200q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H560Z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M480-120q-150 0-255-105T120-480q0-150 105-255t255-105q14 0 27.5 1t26.5 3q-41 29-65.5 75.5T444-660q0 90 63 153t153 63q55 0 101-24.5t75-65.5q2 13 3 26.5t1 27.5q0 150-105 255T480-120Zm0-80q88 0 158-48.5T740-375q-20 5-40 8t-40 3q-123 0-209.5-86.5T364-660q0-20 3-40t8-40q-78 32-126.5 102T200-480q0 116 82 198t198 82Zm-10-270Z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="m592-481-57-57 143-182H353l-80-80h487q25 0 36 22t-4 42L592-481ZM791-56 560-287v87q0 17-11.5 28.5T520-160h-80q-17 0-28.5-11.5T400-200v-247L56-791l56-57 736 736-57 56ZM535-538Z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M440-160q-17 0-28.5-11.5T400-200v-240L168-736q-15-20-4.5-42t36.5-22h560q26 0 36.5 22t-4.5 42L560-440v240q0 17-11.5 28.5T520-160h-80Zm40-308 198-252H282l198 252Zm0 0Z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M480-360q50 0 85-35t35-85q0-50-35-85t-85-35q-50 0-85 35t-35 85q0 50 35 85t85 35Zm0 80q-83 0-141.5-58.5T280-480q0-83 58.5-141.5T480-680q83 0 141.5 58.5T680-480q0 83-58.5 141.5T480-280ZM200-440H40v-80h160v80Zm720 0H760v-80h160v80ZM440-760v-160h80v160h-80Zm0 720v-160h80v160h-80ZM256-650l-101-97 57-59 96 100-52 56Zm492 496-97-101 53-55 101 97-57 59Zm-98-550 97-101 59 57-100 96-56-52ZM154-212l101-97 55 53-97 101-59-57Zm326-268Z"/></svg>
|
package/docs/src/icons/menu.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z"/></svg>
|
package/docs/src/icons/pause.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path fill="currentColor" d="M28.25 38V10H36v28ZM12 38V10h7.75v28Z"/></svg>
|
package/docs/src/icons/play.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path fill="currentColor" d="M16 37.85v-28l22 14Z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" ><path fill="currentColor" d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M120-160v-160h720v160H120Zm80-40h80v-80h-80v80Zm-80-440v-160h720v160H120Zm80-40h80v-80h-80v80Zm-80 280v-160h720v160H120Zm80-40h80v-80h-80v80Z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="m376-300 104-104 104 104 56-56-104-104 104-104-56-56-104 104-104-104-56 56 104 104-104 104 56 56Zm-96 180q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520Zm-400 0v520-520Z"/></svg>
|
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');
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|