kempo 1.1.2 → 1.1.4
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/SideMenu.js +1 -1
- package/dist/components/Tabs.js +1 -1
- package/dist/utils/cli.js +1 -1
- package/dist/utils/cookie.js +1 -1
- package/dist/utils/element.js +1 -1
- package/dist/utils/fuzzyMatch.js +1 -1
- package/dist/utils/object.js +1 -1
- package/dist/utils/string.js +1 -1
- package/dist/utils/type.js +1 -1
- package/docs/kempo/components/SideMenu.js +1 -1
- package/docs/kempo/components/Tabs.js +1 -1
- package/docs/kempo/utils/cli.js +1 -1
- package/docs/kempo/utils/cookie.js +1 -1
- package/docs/kempo/utils/element.js +1 -1
- package/docs/kempo/utils/fuzzyMatch.js +1 -1
- package/docs/kempo/utils/object.js +1 -1
- package/docs/kempo/utils/string.js +1 -1
- package/docs/kempo/utils/type.js +1 -1
- package/package.json +1 -1
- package/src/components/SideMenu.js +1 -1
- package/src/components/Tabs.js +7 -0
- package/src/utils/cli.js +6 -0
- package/src/utils/cookie.js +8 -4
- package/src/utils/element.js +10 -1
- package/src/utils/fuzzyMatch.js +6 -1
- package/src/utils/object.js +17 -5
- package/src/utils/string.js +12 -1
- package/src/utils/type.js +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import LazyComponent from"./LazyComponent.js";import"./Icon.js";import"./FocusCapture.js";import{onEvent,offEvent,dispatchEvent}from"../utils/element.js";export class SideMenu extends LazyComponent{constructor(){super(),this.registerAttribute("opened",!1),this.registerAttribute("overlayClose",!0),this.registerProps({_overlayClick:()=>{this.overlayClose&&this.close()}})}disconnectedCallback(){super.disconnectedCallback(),offEvent(this.shadowRoot.getElementById("overlay"),"click",this._overlayClick)}attributeChangedCallback(n,e,t){super.attributeChangedCallback(n,e,t),"opened"===n&&dispatchEvent(this,"true"===t?"change open":"change close")}render(n){super.render(n),onEvent(this.shadowRoot.getElementById("overlay"),"click",this._overlayClick)}open(){this.opened=!0}close(){this.opened=!1}toggle(){this.opened?this.close():this.open(),dispatchEvent(this,"toggle")}get shadowTemplate(){return`\n <k-focus-capture>\n <div id="container">\n <button id="overlay" class="no-btn">\n <k-icon id="overlay-x" name="close"></k-icon>\n </button>\n <div id="menu">\n ${super.shadowTemplate}\n </div>\n </div>\n </k-focus-capture>\n `}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n --bg: var(--c_bg);\n --width: 20rem;\n\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n max-width: 100%;\n height: 100vh;\n z-index: 100;\n pointer-events: none;\n }\n :host([opened]) {\n pointer-events: auto;\n }\n k-focus-capture {\n width: 100%;\n height: 100%;\n }\n #container {\n position: relative;\n width: 100%;\n height: 100%;\n opacity: 0;\n transition: opacity var(--animation_ms, 256ms);\n }\n :host([opened]) #container {\n opacity: 1;\n }\n #overlay {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n background: var(--overlay, rgba(0, 0, 0, 0.5));\n }\n #overlay-x {\n position: absolute;\n top: var(--spacer_h);\n right: var(--spacer_h);\n font-size: 1.75rem;\n cursor: pointer;\n color: var(--tc_light);\n }\n :host([overlay-close="false"]) #overlay-x {\n display: none;\n }\n :host([overlay-close="false"]) #overlay {\n cursor: default;\n }\n #menu {\n position: absolute;\n width: var(--width);\n max-width: calc(100vw - 6rem);\n height: 100vh;\n overflow-y: auto;\n left: calc(var(--width) * -1);\n top: 0;\n background: var(--bg);\n transition: left var(--animation_ms, 256ms);\n padding: var(--menu_padding, var(--spacer))\n }\n :host([opened]) #menu {\n left: 0;\n }\n :host([side="right"]) #menu {\n left: auto;\n transition: right var(--animation_ms, 256ms);\n right: calc(var(--width) * -1);\n }\n :host([opened][side="right"]) #menu {\n right: 0;\n }\n :host([side="right"]) #overlay-x {\n right: auto;\n left: var(--spacer_h);\n }\n `}static get observedAttributes(){return["opened",...super.observedAttributes]}}window.customElements.define("k-side-menu",SideMenu);
|
|
1
|
+
import LazyComponent from"./LazyComponent.js";import"./Icon.js";import"./FocusCapture.js";import{onEvent,offEvent,dispatchEvent}from"../utils/element.js";export default class SideMenu extends LazyComponent{constructor(){super(),this.registerAttribute("opened",!1),this.registerAttribute("overlayClose",!0),this.registerProps({_overlayClick:()=>{this.overlayClose&&this.close()}})}disconnectedCallback(){super.disconnectedCallback(),offEvent(this.shadowRoot.getElementById("overlay"),"click",this._overlayClick)}attributeChangedCallback(n,e,t){super.attributeChangedCallback(n,e,t),"opened"===n&&dispatchEvent(this,"true"===t?"change open":"change close")}render(n){super.render(n),onEvent(this.shadowRoot.getElementById("overlay"),"click",this._overlayClick)}open(){this.opened=!0}close(){this.opened=!1}toggle(){this.opened?this.close():this.open(),dispatchEvent(this,"toggle")}get shadowTemplate(){return`\n <k-focus-capture>\n <div id="container">\n <button id="overlay" class="no-btn">\n <k-icon id="overlay-x" name="close"></k-icon>\n </button>\n <div id="menu">\n ${super.shadowTemplate}\n </div>\n </div>\n </k-focus-capture>\n `}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n --bg: var(--c_bg);\n --width: 20rem;\n\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n max-width: 100%;\n height: 100vh;\n z-index: 100;\n pointer-events: none;\n }\n :host([opened]) {\n pointer-events: auto;\n }\n k-focus-capture {\n width: 100%;\n height: 100%;\n }\n #container {\n position: relative;\n width: 100%;\n height: 100%;\n opacity: 0;\n transition: opacity var(--animation_ms, 256ms);\n }\n :host([opened]) #container {\n opacity: 1;\n }\n #overlay {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n background: var(--overlay, rgba(0, 0, 0, 0.5));\n }\n #overlay-x {\n position: absolute;\n top: var(--spacer_h);\n right: var(--spacer_h);\n font-size: 1.75rem;\n cursor: pointer;\n color: var(--tc_light);\n }\n :host([overlay-close="false"]) #overlay-x {\n display: none;\n }\n :host([overlay-close="false"]) #overlay {\n cursor: default;\n }\n #menu {\n position: absolute;\n width: var(--width);\n max-width: calc(100vw - 6rem);\n height: 100vh;\n overflow-y: auto;\n left: calc(var(--width) * -1);\n top: 0;\n background: var(--bg);\n transition: left var(--animation_ms, 256ms);\n padding: var(--menu_padding, var(--spacer))\n }\n :host([opened]) #menu {\n left: 0;\n }\n :host([side="right"]) #menu {\n left: auto;\n transition: right var(--animation_ms, 256ms);\n right: calc(var(--width) * -1);\n }\n :host([opened][side="right"]) #menu {\n right: 0;\n }\n :host([side="right"]) #overlay-x {\n right: auto;\n left: var(--spacer_h);\n }\n `}static get observedAttributes(){return["opened",...super.observedAttributes]}}window.customElements.define("k-side-menu",SideMenu);
|
package/dist/components/Tabs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import Component from"./Component.js";import{dispatchEvent}from"../utils/element.js";const clickHandler=Symbol();export class Tab extends Component{constructor(){super(),this[clickHandler]=()=>{this.active||(this.tabs.active=this.for)},this.slot="tabs",this.registerAttribute("active",!1)}connectedCallback(){super.connectedCallback(),this.shadowRoot.getElementById("button").addEventListener("click",this[clickHandler])}get for(){const t=this.getAttribute("for");return t||this?.tabs.tabs.indexOf(this)}set for(t){t?this.setAttribute("for",t):this.removeAttribute("for")}get tabs(){return"K-TABS"===this.parentElement.tagName?this.parentElement:null}get shadowTemplate(){return`\n <button id="button">\n ${super.shadowTemplate}\n </button>\n `}get shadowStyles(){return"\n :host {\n margin-bottom: -1px;\n }\n #button {\n padding: var(--spacer_h);\n background-color: transparent;\n border: none;\n cursor: inherit;\n box-shadow: none;\n color: inherit;\n }\n :host(:not([active])) #button {\n cursor: pointer;\n }\n :host([active]){\n border-bottom: 2px solid var(--c_primary);\n margin-bottom: -1px;\n }\n :host([active]) #button {\n color: var(--tc_primary);\n }\n "}}window.customElements.define("k-tab",Tab);export class TabContent extends Component{constructor(){super(),this.registerAttribute("active",!1)}get tabs(){return"K-TABS"===this.parentElement.tagName?this.parentElement:null}get name(){const t=this.getAttribute("name");return t||this?.tabs.contents.indexOf(this)}set name(t){t?this.setAttribute("name",t):this.removeAttribute("name")}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n display: block;\n height: 100%;\n max-height: 100%;\n flex: 1 1 auto;\n overflow: hidden;\n }\n :host([active]) {\n display: block;\n }\n :host(:not([active])) {\n display: none;\n }\n `}}window.customElements.define("k-tab-content",TabContent);export class Tabs extends Component{constructor(){super(),this.registerAttribute("active","")}async connectedCallback(){await super.connectedCallback(),this.active||(this.active=`${this.querySelectorAll("k-tab-content")[0].name}`)}attributeChangedCallback(t,e,n){if("active"===t){const t=this.getActiveTab();t&&(t.active=!1);const e=this.getActiveContent();e&&(e.active=!1);const s=this.getTab(n);s&&(s.active=!0);const o=this.getContent(n);o&&(o.active=!0),dispatchEvent(this,"tab",{tab:n})}}get contents(){return[...this.querySelectorAll(":scope > k-tab-content")]}get tabs(){return[...this.querySelectorAll(":scope > k-tab")]}getTab(t){let e;if("string"==typeof t&&(e=this.querySelector(`k-tab[for="${t}"]`)),!e){let n=parseInt(t);n||(n=0),e=this.querySelectorAll("k-tab")[n]}return e}getActiveTab(){return this.querySelector(':scope > k-tab[active="true"]')}getContent(t){let e;if("string"==typeof t&&(e=this.querySelector(`k-tab-content[name="${t}"]`)),!e){let n=parseInt(t);n||(n=0),e=this.querySelectorAll("k-tab-content")[n]}return e}getActiveContent(){return this.querySelector(':scope > k-tab-content[active="true"]')}get shadowTemplate(){return`\n <div id="wrapper">\n <div id="tabs">\n <slot name="tabs"></slot>\n </div>\n <div id="contents">\n ${super.shadowTemplate}\n </div>\n </div>\n \n `}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n display: block;\n overflow: hidden;\n }\n #wrapper {\n display: flex;\n flex-direction: column;\n max-height: 100%;\n height: 100%;\n overflow: hidden;\n }\n #tabs {\n display: flex;\n border-bottom: 1px solid var(--c_border);\n padding: 0;\n margin-top: calc(0 - var(--spacer));\n align-items: flex-start;\n }\n #contents {\n display: flex;\n flex-direction: column;\n flex: 1;\n max-height: 100%;\n overflow: hidden\n }\n `}static observedAttributes=[...super.observedAttributes,"active"]}window.customElements.define("k-tabs",Tabs);export class TabSpacer extends Component{constructor(){super(),this.slot="tabs"}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n flex: 1 1 auto;\n height: 1px;\n }\n `}}window.customElements.define("k-tab-spacer",TabSpacer);
|
|
1
|
+
import Component from"./Component.js";import{dispatchEvent}from"../utils/element.js";const clickHandler=Symbol();export class Tab extends Component{constructor(){super(),this[clickHandler]=()=>{this.active||(this.tabs.active=this.for)},this.slot="tabs",this.registerAttribute("active",!1)}connectedCallback(){super.connectedCallback(),this.shadowRoot.getElementById("button").addEventListener("click",this[clickHandler])}get for(){const t=this.getAttribute("for");return t||this?.tabs.tabs.indexOf(this)}set for(t){t?this.setAttribute("for",t):this.removeAttribute("for")}get tabs(){return"K-TABS"===this.parentElement.tagName?this.parentElement:null}get shadowTemplate(){return`\n <button id="button">\n ${super.shadowTemplate}\n </button>\n `}get shadowStyles(){return"\n :host {\n margin-bottom: -1px;\n }\n #button {\n padding: var(--spacer_h);\n background-color: transparent;\n border: none;\n cursor: inherit;\n box-shadow: none;\n color: inherit;\n }\n :host(:not([active])) #button {\n cursor: pointer;\n }\n :host([active]){\n border-bottom: 2px solid var(--c_primary);\n margin-bottom: -1px;\n }\n :host([active]) #button {\n color: var(--tc_primary);\n }\n "}}window.customElements.define("k-tab",Tab);export class TabContent extends Component{constructor(){super(),this.registerAttribute("active",!1)}get tabs(){return"K-TABS"===this.parentElement.tagName?this.parentElement:null}get name(){const t=this.getAttribute("name");return t||this?.tabs.contents.indexOf(this)}set name(t){t?this.setAttribute("name",t):this.removeAttribute("name")}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n display: block;\n height: 100%;\n max-height: 100%;\n flex: 1 1 auto;\n overflow: hidden;\n }\n :host([active]) {\n display: block;\n }\n :host(:not([active])) {\n display: none;\n }\n `}}window.customElements.define("k-tab-content",TabContent);export class Tabs extends Component{constructor(){super(),this.registerAttribute("active","")}async connectedCallback(){await super.connectedCallback(),this.active||(this.active=`${this.querySelectorAll("k-tab-content")[0].name}`)}attributeChangedCallback(t,e,n){if("active"===t){const t=this.getActiveTab();t&&(t.active=!1);const e=this.getActiveContent();e&&(e.active=!1);const s=this.getTab(n);s&&(s.active=!0);const o=this.getContent(n);o&&(o.active=!0),dispatchEvent(this,"tab",{tab:n})}}get contents(){return[...this.querySelectorAll(":scope > k-tab-content")]}get tabs(){return[...this.querySelectorAll(":scope > k-tab")]}getTab(t){let e;if("string"==typeof t&&(e=this.querySelector(`k-tab[for="${t}"]`)),!e){let n=parseInt(t);n||(n=0),e=this.querySelectorAll("k-tab")[n]}return e}getActiveTab(){return this.querySelector(':scope > k-tab[active="true"]')}getContent(t){let e;if("string"==typeof t&&(e=this.querySelector(`k-tab-content[name="${t}"]`)),!e){let n=parseInt(t);n||(n=0),e=this.querySelectorAll("k-tab-content")[n]}return e}getActiveContent(){return this.querySelector(':scope > k-tab-content[active="true"]')}get shadowTemplate(){return`\n <div id="wrapper">\n <div id="tabs">\n <slot name="tabs"></slot>\n </div>\n <div id="contents">\n ${super.shadowTemplate}\n </div>\n </div>\n \n `}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n display: block;\n overflow: hidden;\n }\n #wrapper {\n display: flex;\n flex-direction: column;\n max-height: 100%;\n height: 100%;\n overflow: hidden;\n }\n #tabs {\n display: flex;\n border-bottom: 1px solid var(--c_border);\n padding: 0;\n margin-top: calc(0 - var(--spacer));\n align-items: flex-start;\n }\n #contents {\n display: flex;\n flex-direction: column;\n flex: 1;\n max-height: 100%;\n overflow: hidden\n }\n `}static observedAttributes=[...super.observedAttributes,"active"]}window.customElements.define("k-tabs",Tabs);export class TabSpacer extends Component{constructor(){super(),this.slot="tabs"}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n flex: 1 1 auto;\n height: 1px;\n }\n `}}window.customElements.define("k-tab-spacer",TabSpacer);export default{Tab:Tab,TabContent:TabContent,Tabs:Tabs,TabSpacer:TabSpacer};
|
package/dist/utils/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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)};
|
|
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)};export default{getArgs:getArgs,runChildNodeProcess:runChildNodeProcess,runChildNodeProcess:runChildNodeProcess};
|
package/dist/utils/cookie.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const saveCookie=(e,o,t=43200,i="/")=>{const n=new Date(Date.now()+60*t*1e3);document.cookie=`${e}=${o};expires=${n.toUTCString()};path=${i}`}
|
|
1
|
+
export const saveCookie=(e,o,t=43200,i="/")=>{const n=new Date(Date.now()+60*t*1e3);document.cookie=`${e}=${o};expires=${n.toUTCString()};path=${i}`};export const getCookie=e=>{const o=document.cookie.split(";").map((e=>e.trim().split("="))),t=o.find((o=>o[0]===e));return t?t[1]:null};export const deleteCookie=e=>{document.cookie=`${e}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/`};export default{saveCookie:saveCookie,getCookie:getCookie,deleteCookie:deleteCookie};
|
package/dist/utils/element.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import waitFrames from"./waitFrames.js";export const onEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.addEventListener(e,n)})):t instanceof NodeList||t instanceof Array?t.forEach((t=>onEvent(t,e,n))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>onEvent(t,e,n)))};export const offEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.removeEventListener(e,n)})):t instanceof NodeList||t instanceof Array?t.forEach((t=>offEvent(t,e,n))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>offEvent(t,e,n)))};export const dispatchEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.dispatchEvent(new CustomEvent(e,{detail:n}))})):t instanceof NodeList||t instanceof Array?t.forEach((t=>dispatchEvent(t,e,handler))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>dispatchEvent(t,e,handler)))};export const isInView=async t=>{await waitFrames(2);const e=t.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,o=window.innerWidth||document.documentElement.clientWidth;if(e.bottom<0||e.top>n||e.right<0||e.left>o)return!1;for(;t;){const e=getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility)return!1;t=t.parentElement}return!0};export const firstFocusable=t=>t.querySelector('a[href]:not([disabled]), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"])');export const setProp=(t,e,n,o=document)=>{t instanceof HTMLElement?t[e]=n:t instanceof NodeList||t instanceof Array?[...t].forEach((t=>dispatchEvent(t,e,n))):"string"==typeof t&&dispatchEvent(o.querySelectorAll(t),e,n)};
|
|
1
|
+
import waitFrames from"./waitFrames.js";export const onEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.addEventListener(e,n)})):t instanceof NodeList||t instanceof Array?t.forEach((t=>onEvent(t,e,n))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>onEvent(t,e,n)))};export const offEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.removeEventListener(e,n)})):t instanceof NodeList||t instanceof Array?t.forEach((t=>offEvent(t,e,n))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>offEvent(t,e,n)))};export const dispatchEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.dispatchEvent(new CustomEvent(e,{detail:n}))})):t instanceof NodeList||t instanceof Array?t.forEach((t=>dispatchEvent(t,e,handler))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>dispatchEvent(t,e,handler)))};export const isInView=async t=>{await waitFrames(2);const e=t.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,o=window.innerWidth||document.documentElement.clientWidth;if(e.bottom<0||e.top>n||e.right<0||e.left>o)return!1;for(;t;){const e=getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility)return!1;t=t.parentElement}return!0};export const firstFocusable=t=>t.querySelector('a[href]:not([disabled]), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"])');export const setProp=(t,e,n,o=document)=>{t instanceof HTMLElement?t[e]=n:t instanceof NodeList||t instanceof Array?[...t].forEach((t=>dispatchEvent(t,e,n))):"string"==typeof t&&dispatchEvent(o.querySelectorAll(t),e,n)};export default{onEvent:onEvent,offEvent:offEvent,dispatchEvent:dispatchEvent,isInView:isInView,firstFocusable:firstFocusable,setProp:setProp};
|
package/dist/utils/fuzzyMatch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const fuzzyMatch=(t,r)=>{const e=((t,r)=>{const e=t.length,
|
|
1
|
+
export const fuzzyMatch=(t,r)=>{const e=((t,r)=>{const e=t.length,a=r.length,n=Array.from({length:e+1},(()=>Array(a+1).fill(0)));for(let h=0;h<=e;h++)for(let e=0;e<=a;e++)n[h][e]=0===h?e:0===e?h:Math.min(n[h-1][e-1]+(t.charAt(h-1)===r.charAt(e-1)?0:1),n[h][e-1]+1,n[h-1][e]+1);return n[e][a]})(t.toLowerCase(),r.toLowerCase());if(0===e)return 10;const a=Math.max(0,10-e/3),n=Math.min((t.length-e)/t.length,1);return Math.round(5*a+5*n)};export const fuzzyMatchArray=(t,r)=>{const e=t.map((t=>fuzzyMatch(t,r))).filter((t=>0!==t));if(0===e.length)return 0;return e.reduce(((t,r)=>t+r),0)/e.length};export default{fuzzyMatch:fuzzyMatch,fuzzyMatchArray:fuzzyMatchArray};
|
package/dist/utils/object.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{typeOf
|
|
1
|
+
import{typeOf}from"./type.js";export const toJson=e=>JSON.stringify(e,((t,n)=>""!==t&&n===e?"<<Circular Reference>>":"undefined"!=typeof Element&&n instanceof Element?n.outerHTML:"function"===typeOf(n)?`<<Function ${t}>>`:n));export const flattenObject=(e,t=100,n=0,o=[])=>{const r=n+1;return null===e?{}:Object.keys(e).reduce(((n,c)=>{const s=e[c],l=[...o,c].join(".");return"undefined"!==typeOf(Element)&&s instanceof Element?{...n,[l]:s.outerHTML}:null===s?{...n,[l]:null}:"object"==typeof s?t<=r?{...n,[l]:"<<Max Depth Reached>>"}:{...n,...flattenObject(s,t,r,[...o,c])}:{...n,[l]:s}}),{})};export const flattenedObjects=(...e)=>e.map((e=>flattenObject(e)));export const objectSummary=(e,t=100)=>{if("object"==typeof e){const n=flattenObject(e),o=[];return Object.keys(n).forEach((e=>{o.push(`${e} = ${objectSummary(n[e])}`)})),o.join(", ").substring(0,t)}return`${e}`.substring(0,t)};export const clone=e=>{const t=typeof e,n="undefined"==typeof window?class{}:window.Element;return e instanceof n?e.outerHTML:null===e?null:["string","number","boolean","undefined","bigint"].includes(t)?e:"symbol"===t?"<<SYMBOL>>":"function"===t?"<<function>>":e instanceof Array?e.map((e=>clone(e))):"object"===t?Object.keys(e).reduce(((t,n)=>({...t,[n]:clone(e[n])})),{}):e};export const equalObjs=(...e)=>{if(e.length<2)return!0;const t=toJson(e[0]);for(let n=1;n<e.length;n++)if(t!==toJson(e[n]))return!1;return!0};const pruneVar=e=>void 0===e?[void 0,!0]:"string"==typeof e?[e,""===e]:e instanceof Array?[e,0===e.length]:null===e?[e,!1]:"object"==typeof e?pruneObject(e):[e,!1],pruneObject=e=>{const t={};return Object.keys(e).forEach((n=>{const[o,r]=pruneVar(e[n]);r||(t[n]=o)})),[t,0===Object.keys(t).length]};export const prune=e=>pruneObject(e)[0];export const getAllKeys=(...e)=>[...new Set(e.map((e=>Object.keys(e))).flat())];export const getDifferencesKeys=(...e)=>getAllKeys(...e).map((t=>1!==new Set(e.map((e=>e[t]))).size?t:null)).filter((e=>null!==e));export const diff=(e,t)=>{const n={};function o(e,t,o){Array.isArray(t)&&Array.isArray(o)?t.length===o.length&&t.every(((e,t)=>e===o[t]))||(n[e.join(".")]={newValue:t,oldValue:o}):"object"==typeof t&&"object"==typeof o?r([...e],t,o):t!==o&&(n[e.join(".")]={newValue:t,oldValue:o})}function r(e,t,n){for(const r in t)if(t.hasOwnProperty(r)){o([...e,r],t[r],n[r])}}return r([],e,t),n};export default{toJson:toJson,flattenObject:flattenObject,flattenedObjects:flattenedObjects,objectSummary:objectSummary,clone:clone,equalObjs:equalObjs,pruneVars:pruneVars,pruneObject:pruneObject,prune:prune,getAllKeys:getAllKeys,getDifferencesKeys:getDifferencesKeys,diff:diff};
|
package/dist/utils/string.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const camelToDash=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();export const dashToCamel=e=>e.replace(/-([a-z])/g,((e,
|
|
1
|
+
export const camelToDash=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();export const dashToCamel=e=>e.replace(/-([a-z])/g,((e,a)=>a.toUpperCase()));export const isCamelCase=e=>/[a-z][A-Z]/.test(e);export const getCase=e=>isCamelCase(e)?{camel:e,dash:camelToDash(e)}:{camel:dashToCamel(e),dash:e};export const escapeHTML=e=>e.replace(/[&<>"'/]/g,(e=>{switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case"'":return"'";case"/":return"/";default:return e}}));export const unescapeHTML=e=>e.replace(/&|<|>|"|'|//g,(e=>{switch(e){case"&":return"&";case"<":return"<";case">":return">";case""":return'"';case"'":return"'";case"/":return"/";default:return e}}));export const trim=(e,a)=>e.replace(new RegExp(`^[${a}]+|[${a}]+$`,"g"),"");export const compoundKey=e=>trim(e.join("."),".");export default{camelToDash:camelToDash,dashToCamel:dashToCamel,isCamelCase:isCamelCase,getCase:getCase,escapeHTML:escapeHTML,unescapeHTML:unescapeHTML,trim:trim,compoundKey:compoundKey};
|
package/dist/utils/type.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const typeOf=e=>null===e?"null":e instanceof Array?"array":"undefined"!=typeof Element&&e instanceof Element?"element":typeof e;export const isType=(e,
|
|
1
|
+
export const typeOf=e=>null===e?"null":e instanceof Array?"array":"undefined"!=typeof Element&&e instanceof Element?"element":typeof e;export const isType=(e,t)=>typeOf(e)===t;export default{typeOf:typeOf,isType:isType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import LazyComponent from"./LazyComponent.js";import"./Icon.js";import"./FocusCapture.js";import{onEvent,offEvent,dispatchEvent}from"../utils/element.js";export class SideMenu extends LazyComponent{constructor(){super(),this.registerAttribute("opened",!1),this.registerAttribute("overlayClose",!0),this.registerProps({_overlayClick:()=>{this.overlayClose&&this.close()}})}disconnectedCallback(){super.disconnectedCallback(),offEvent(this.shadowRoot.getElementById("overlay"),"click",this._overlayClick)}attributeChangedCallback(n,e,t){super.attributeChangedCallback(n,e,t),"opened"===n&&dispatchEvent(this,"true"===t?"change open":"change close")}render(n){super.render(n),onEvent(this.shadowRoot.getElementById("overlay"),"click",this._overlayClick)}open(){this.opened=!0}close(){this.opened=!1}toggle(){this.opened?this.close():this.open(),dispatchEvent(this,"toggle")}get shadowTemplate(){return`\n <k-focus-capture>\n <div id="container">\n <button id="overlay" class="no-btn">\n <k-icon id="overlay-x" name="close"></k-icon>\n </button>\n <div id="menu">\n ${super.shadowTemplate}\n </div>\n </div>\n </k-focus-capture>\n `}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n --bg: var(--c_bg);\n --width: 20rem;\n\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n max-width: 100%;\n height: 100vh;\n z-index: 100;\n pointer-events: none;\n }\n :host([opened]) {\n pointer-events: auto;\n }\n k-focus-capture {\n width: 100%;\n height: 100%;\n }\n #container {\n position: relative;\n width: 100%;\n height: 100%;\n opacity: 0;\n transition: opacity var(--animation_ms, 256ms);\n }\n :host([opened]) #container {\n opacity: 1;\n }\n #overlay {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n background: var(--overlay, rgba(0, 0, 0, 0.5));\n }\n #overlay-x {\n position: absolute;\n top: var(--spacer_h);\n right: var(--spacer_h);\n font-size: 1.75rem;\n cursor: pointer;\n color: var(--tc_light);\n }\n :host([overlay-close="false"]) #overlay-x {\n display: none;\n }\n :host([overlay-close="false"]) #overlay {\n cursor: default;\n }\n #menu {\n position: absolute;\n width: var(--width);\n max-width: calc(100vw - 6rem);\n height: 100vh;\n overflow-y: auto;\n left: calc(var(--width) * -1);\n top: 0;\n background: var(--bg);\n transition: left var(--animation_ms, 256ms);\n padding: var(--menu_padding, var(--spacer))\n }\n :host([opened]) #menu {\n left: 0;\n }\n :host([side="right"]) #menu {\n left: auto;\n transition: right var(--animation_ms, 256ms);\n right: calc(var(--width) * -1);\n }\n :host([opened][side="right"]) #menu {\n right: 0;\n }\n :host([side="right"]) #overlay-x {\n right: auto;\n left: var(--spacer_h);\n }\n `}static get observedAttributes(){return["opened",...super.observedAttributes]}}window.customElements.define("k-side-menu",SideMenu);
|
|
1
|
+
import LazyComponent from"./LazyComponent.js";import"./Icon.js";import"./FocusCapture.js";import{onEvent,offEvent,dispatchEvent}from"../utils/element.js";export default class SideMenu extends LazyComponent{constructor(){super(),this.registerAttribute("opened",!1),this.registerAttribute("overlayClose",!0),this.registerProps({_overlayClick:()=>{this.overlayClose&&this.close()}})}disconnectedCallback(){super.disconnectedCallback(),offEvent(this.shadowRoot.getElementById("overlay"),"click",this._overlayClick)}attributeChangedCallback(n,e,t){super.attributeChangedCallback(n,e,t),"opened"===n&&dispatchEvent(this,"true"===t?"change open":"change close")}render(n){super.render(n),onEvent(this.shadowRoot.getElementById("overlay"),"click",this._overlayClick)}open(){this.opened=!0}close(){this.opened=!1}toggle(){this.opened?this.close():this.open(),dispatchEvent(this,"toggle")}get shadowTemplate(){return`\n <k-focus-capture>\n <div id="container">\n <button id="overlay" class="no-btn">\n <k-icon id="overlay-x" name="close"></k-icon>\n </button>\n <div id="menu">\n ${super.shadowTemplate}\n </div>\n </div>\n </k-focus-capture>\n `}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n --bg: var(--c_bg);\n --width: 20rem;\n\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n max-width: 100%;\n height: 100vh;\n z-index: 100;\n pointer-events: none;\n }\n :host([opened]) {\n pointer-events: auto;\n }\n k-focus-capture {\n width: 100%;\n height: 100%;\n }\n #container {\n position: relative;\n width: 100%;\n height: 100%;\n opacity: 0;\n transition: opacity var(--animation_ms, 256ms);\n }\n :host([opened]) #container {\n opacity: 1;\n }\n #overlay {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n background: var(--overlay, rgba(0, 0, 0, 0.5));\n }\n #overlay-x {\n position: absolute;\n top: var(--spacer_h);\n right: var(--spacer_h);\n font-size: 1.75rem;\n cursor: pointer;\n color: var(--tc_light);\n }\n :host([overlay-close="false"]) #overlay-x {\n display: none;\n }\n :host([overlay-close="false"]) #overlay {\n cursor: default;\n }\n #menu {\n position: absolute;\n width: var(--width);\n max-width: calc(100vw - 6rem);\n height: 100vh;\n overflow-y: auto;\n left: calc(var(--width) * -1);\n top: 0;\n background: var(--bg);\n transition: left var(--animation_ms, 256ms);\n padding: var(--menu_padding, var(--spacer))\n }\n :host([opened]) #menu {\n left: 0;\n }\n :host([side="right"]) #menu {\n left: auto;\n transition: right var(--animation_ms, 256ms);\n right: calc(var(--width) * -1);\n }\n :host([opened][side="right"]) #menu {\n right: 0;\n }\n :host([side="right"]) #overlay-x {\n right: auto;\n left: var(--spacer_h);\n }\n `}static get observedAttributes(){return["opened",...super.observedAttributes]}}window.customElements.define("k-side-menu",SideMenu);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Component from"./Component.js";import{dispatchEvent}from"../utils/element.js";const clickHandler=Symbol();export class Tab extends Component{constructor(){super(),this[clickHandler]=()=>{this.active||(this.tabs.active=this.for)},this.slot="tabs",this.registerAttribute("active",!1)}connectedCallback(){super.connectedCallback(),this.shadowRoot.getElementById("button").addEventListener("click",this[clickHandler])}get for(){const t=this.getAttribute("for");return t||this?.tabs.tabs.indexOf(this)}set for(t){t?this.setAttribute("for",t):this.removeAttribute("for")}get tabs(){return"K-TABS"===this.parentElement.tagName?this.parentElement:null}get shadowTemplate(){return`\n <button id="button">\n ${super.shadowTemplate}\n </button>\n `}get shadowStyles(){return"\n :host {\n margin-bottom: -1px;\n }\n #button {\n padding: var(--spacer_h);\n background-color: transparent;\n border: none;\n cursor: inherit;\n box-shadow: none;\n color: inherit;\n }\n :host(:not([active])) #button {\n cursor: pointer;\n }\n :host([active]){\n border-bottom: 2px solid var(--c_primary);\n margin-bottom: -1px;\n }\n :host([active]) #button {\n color: var(--tc_primary);\n }\n "}}window.customElements.define("k-tab",Tab);export class TabContent extends Component{constructor(){super(),this.registerAttribute("active",!1)}get tabs(){return"K-TABS"===this.parentElement.tagName?this.parentElement:null}get name(){const t=this.getAttribute("name");return t||this?.tabs.contents.indexOf(this)}set name(t){t?this.setAttribute("name",t):this.removeAttribute("name")}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n display: block;\n height: 100%;\n max-height: 100%;\n flex: 1 1 auto;\n overflow: hidden;\n }\n :host([active]) {\n display: block;\n }\n :host(:not([active])) {\n display: none;\n }\n `}}window.customElements.define("k-tab-content",TabContent);export class Tabs extends Component{constructor(){super(),this.registerAttribute("active","")}async connectedCallback(){await super.connectedCallback(),this.active||(this.active=`${this.querySelectorAll("k-tab-content")[0].name}`)}attributeChangedCallback(t,e,n){if("active"===t){const t=this.getActiveTab();t&&(t.active=!1);const e=this.getActiveContent();e&&(e.active=!1);const s=this.getTab(n);s&&(s.active=!0);const o=this.getContent(n);o&&(o.active=!0),dispatchEvent(this,"tab",{tab:n})}}get contents(){return[...this.querySelectorAll(":scope > k-tab-content")]}get tabs(){return[...this.querySelectorAll(":scope > k-tab")]}getTab(t){let e;if("string"==typeof t&&(e=this.querySelector(`k-tab[for="${t}"]`)),!e){let n=parseInt(t);n||(n=0),e=this.querySelectorAll("k-tab")[n]}return e}getActiveTab(){return this.querySelector(':scope > k-tab[active="true"]')}getContent(t){let e;if("string"==typeof t&&(e=this.querySelector(`k-tab-content[name="${t}"]`)),!e){let n=parseInt(t);n||(n=0),e=this.querySelectorAll("k-tab-content")[n]}return e}getActiveContent(){return this.querySelector(':scope > k-tab-content[active="true"]')}get shadowTemplate(){return`\n <div id="wrapper">\n <div id="tabs">\n <slot name="tabs"></slot>\n </div>\n <div id="contents">\n ${super.shadowTemplate}\n </div>\n </div>\n \n `}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n display: block;\n overflow: hidden;\n }\n #wrapper {\n display: flex;\n flex-direction: column;\n max-height: 100%;\n height: 100%;\n overflow: hidden;\n }\n #tabs {\n display: flex;\n border-bottom: 1px solid var(--c_border);\n padding: 0;\n margin-top: calc(0 - var(--spacer));\n align-items: flex-start;\n }\n #contents {\n display: flex;\n flex-direction: column;\n flex: 1;\n max-height: 100%;\n overflow: hidden\n }\n `}static observedAttributes=[...super.observedAttributes,"active"]}window.customElements.define("k-tabs",Tabs);export class TabSpacer extends Component{constructor(){super(),this.slot="tabs"}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n flex: 1 1 auto;\n height: 1px;\n }\n `}}window.customElements.define("k-tab-spacer",TabSpacer);
|
|
1
|
+
import Component from"./Component.js";import{dispatchEvent}from"../utils/element.js";const clickHandler=Symbol();export class Tab extends Component{constructor(){super(),this[clickHandler]=()=>{this.active||(this.tabs.active=this.for)},this.slot="tabs",this.registerAttribute("active",!1)}connectedCallback(){super.connectedCallback(),this.shadowRoot.getElementById("button").addEventListener("click",this[clickHandler])}get for(){const t=this.getAttribute("for");return t||this?.tabs.tabs.indexOf(this)}set for(t){t?this.setAttribute("for",t):this.removeAttribute("for")}get tabs(){return"K-TABS"===this.parentElement.tagName?this.parentElement:null}get shadowTemplate(){return`\n <button id="button">\n ${super.shadowTemplate}\n </button>\n `}get shadowStyles(){return"\n :host {\n margin-bottom: -1px;\n }\n #button {\n padding: var(--spacer_h);\n background-color: transparent;\n border: none;\n cursor: inherit;\n box-shadow: none;\n color: inherit;\n }\n :host(:not([active])) #button {\n cursor: pointer;\n }\n :host([active]){\n border-bottom: 2px solid var(--c_primary);\n margin-bottom: -1px;\n }\n :host([active]) #button {\n color: var(--tc_primary);\n }\n "}}window.customElements.define("k-tab",Tab);export class TabContent extends Component{constructor(){super(),this.registerAttribute("active",!1)}get tabs(){return"K-TABS"===this.parentElement.tagName?this.parentElement:null}get name(){const t=this.getAttribute("name");return t||this?.tabs.contents.indexOf(this)}set name(t){t?this.setAttribute("name",t):this.removeAttribute("name")}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n display: block;\n height: 100%;\n max-height: 100%;\n flex: 1 1 auto;\n overflow: hidden;\n }\n :host([active]) {\n display: block;\n }\n :host(:not([active])) {\n display: none;\n }\n `}}window.customElements.define("k-tab-content",TabContent);export class Tabs extends Component{constructor(){super(),this.registerAttribute("active","")}async connectedCallback(){await super.connectedCallback(),this.active||(this.active=`${this.querySelectorAll("k-tab-content")[0].name}`)}attributeChangedCallback(t,e,n){if("active"===t){const t=this.getActiveTab();t&&(t.active=!1);const e=this.getActiveContent();e&&(e.active=!1);const s=this.getTab(n);s&&(s.active=!0);const o=this.getContent(n);o&&(o.active=!0),dispatchEvent(this,"tab",{tab:n})}}get contents(){return[...this.querySelectorAll(":scope > k-tab-content")]}get tabs(){return[...this.querySelectorAll(":scope > k-tab")]}getTab(t){let e;if("string"==typeof t&&(e=this.querySelector(`k-tab[for="${t}"]`)),!e){let n=parseInt(t);n||(n=0),e=this.querySelectorAll("k-tab")[n]}return e}getActiveTab(){return this.querySelector(':scope > k-tab[active="true"]')}getContent(t){let e;if("string"==typeof t&&(e=this.querySelector(`k-tab-content[name="${t}"]`)),!e){let n=parseInt(t);n||(n=0),e=this.querySelectorAll("k-tab-content")[n]}return e}getActiveContent(){return this.querySelector(':scope > k-tab-content[active="true"]')}get shadowTemplate(){return`\n <div id="wrapper">\n <div id="tabs">\n <slot name="tabs"></slot>\n </div>\n <div id="contents">\n ${super.shadowTemplate}\n </div>\n </div>\n \n `}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n display: block;\n overflow: hidden;\n }\n #wrapper {\n display: flex;\n flex-direction: column;\n max-height: 100%;\n height: 100%;\n overflow: hidden;\n }\n #tabs {\n display: flex;\n border-bottom: 1px solid var(--c_border);\n padding: 0;\n margin-top: calc(0 - var(--spacer));\n align-items: flex-start;\n }\n #contents {\n display: flex;\n flex-direction: column;\n flex: 1;\n max-height: 100%;\n overflow: hidden\n }\n `}static observedAttributes=[...super.observedAttributes,"active"]}window.customElements.define("k-tabs",Tabs);export class TabSpacer extends Component{constructor(){super(),this.slot="tabs"}get shadowStyles(){return`\n ${super.shadowStyles}\n :host {\n flex: 1 1 auto;\n height: 1px;\n }\n `}}window.customElements.define("k-tab-spacer",TabSpacer);export default{Tab:Tab,TabContent:TabContent,Tabs:Tabs,TabSpacer:TabSpacer};
|
package/docs/kempo/utils/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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)};
|
|
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)};export default{getArgs:getArgs,runChildNodeProcess:runChildNodeProcess,runChildNodeProcess:runChildNodeProcess};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const saveCookie=(e,o,t=43200,i="/")=>{const n=new Date(Date.now()+60*t*1e3);document.cookie=`${e}=${o};expires=${n.toUTCString()};path=${i}`}
|
|
1
|
+
export const saveCookie=(e,o,t=43200,i="/")=>{const n=new Date(Date.now()+60*t*1e3);document.cookie=`${e}=${o};expires=${n.toUTCString()};path=${i}`};export const getCookie=e=>{const o=document.cookie.split(";").map((e=>e.trim().split("="))),t=o.find((o=>o[0]===e));return t?t[1]:null};export const deleteCookie=e=>{document.cookie=`${e}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/`};export default{saveCookie:saveCookie,getCookie:getCookie,deleteCookie:deleteCookie};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import waitFrames from"./waitFrames.js";export const onEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.addEventListener(e,n)})):t instanceof NodeList||t instanceof Array?t.forEach((t=>onEvent(t,e,n))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>onEvent(t,e,n)))};export const offEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.removeEventListener(e,n)})):t instanceof NodeList||t instanceof Array?t.forEach((t=>offEvent(t,e,n))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>offEvent(t,e,n)))};export const dispatchEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.dispatchEvent(new CustomEvent(e,{detail:n}))})):t instanceof NodeList||t instanceof Array?t.forEach((t=>dispatchEvent(t,e,handler))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>dispatchEvent(t,e,handler)))};export const isInView=async t=>{await waitFrames(2);const e=t.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,o=window.innerWidth||document.documentElement.clientWidth;if(e.bottom<0||e.top>n||e.right<0||e.left>o)return!1;for(;t;){const e=getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility)return!1;t=t.parentElement}return!0};export const firstFocusable=t=>t.querySelector('a[href]:not([disabled]), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"])');export const setProp=(t,e,n,o=document)=>{t instanceof HTMLElement?t[e]=n:t instanceof NodeList||t instanceof Array?[...t].forEach((t=>dispatchEvent(t,e,n))):"string"==typeof t&&dispatchEvent(o.querySelectorAll(t),e,n)};
|
|
1
|
+
import waitFrames from"./waitFrames.js";export const onEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.addEventListener(e,n)})):t instanceof NodeList||t instanceof Array?t.forEach((t=>onEvent(t,e,n))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>onEvent(t,e,n)))};export const offEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.removeEventListener(e,n)})):t instanceof NodeList||t instanceof Array?t.forEach((t=>offEvent(t,e,n))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>offEvent(t,e,n)))};export const dispatchEvent=(t,e,n,o=document)=>{t instanceof EventTarget?e.toLowerCase().split(" ").forEach((e=>{t.dispatchEvent(new CustomEvent(e,{detail:n}))})):t instanceof NodeList||t instanceof Array?t.forEach((t=>dispatchEvent(t,e,handler))):"string"==typeof t&&o.querySelectorAll(t).forEach((t=>dispatchEvent(t,e,handler)))};export const isInView=async t=>{await waitFrames(2);const e=t.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,o=window.innerWidth||document.documentElement.clientWidth;if(e.bottom<0||e.top>n||e.right<0||e.left>o)return!1;for(;t;){const e=getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility)return!1;t=t.parentElement}return!0};export const firstFocusable=t=>t.querySelector('a[href]:not([disabled]), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"])');export const setProp=(t,e,n,o=document)=>{t instanceof HTMLElement?t[e]=n:t instanceof NodeList||t instanceof Array?[...t].forEach((t=>dispatchEvent(t,e,n))):"string"==typeof t&&dispatchEvent(o.querySelectorAll(t),e,n)};export default{onEvent:onEvent,offEvent:offEvent,dispatchEvent:dispatchEvent,isInView:isInView,firstFocusable:firstFocusable,setProp:setProp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const fuzzyMatch=(t,r)=>{const e=((t,r)=>{const e=t.length,
|
|
1
|
+
export const fuzzyMatch=(t,r)=>{const e=((t,r)=>{const e=t.length,a=r.length,n=Array.from({length:e+1},(()=>Array(a+1).fill(0)));for(let h=0;h<=e;h++)for(let e=0;e<=a;e++)n[h][e]=0===h?e:0===e?h:Math.min(n[h-1][e-1]+(t.charAt(h-1)===r.charAt(e-1)?0:1),n[h][e-1]+1,n[h-1][e]+1);return n[e][a]})(t.toLowerCase(),r.toLowerCase());if(0===e)return 10;const a=Math.max(0,10-e/3),n=Math.min((t.length-e)/t.length,1);return Math.round(5*a+5*n)};export const fuzzyMatchArray=(t,r)=>{const e=t.map((t=>fuzzyMatch(t,r))).filter((t=>0!==t));if(0===e.length)return 0;return e.reduce(((t,r)=>t+r),0)/e.length};export default{fuzzyMatch:fuzzyMatch,fuzzyMatchArray:fuzzyMatchArray};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{typeOf
|
|
1
|
+
import{typeOf}from"./type.js";export const toJson=e=>JSON.stringify(e,((t,n)=>""!==t&&n===e?"<<Circular Reference>>":"undefined"!=typeof Element&&n instanceof Element?n.outerHTML:"function"===typeOf(n)?`<<Function ${t}>>`:n));export const flattenObject=(e,t=100,n=0,o=[])=>{const r=n+1;return null===e?{}:Object.keys(e).reduce(((n,c)=>{const s=e[c],l=[...o,c].join(".");return"undefined"!==typeOf(Element)&&s instanceof Element?{...n,[l]:s.outerHTML}:null===s?{...n,[l]:null}:"object"==typeof s?t<=r?{...n,[l]:"<<Max Depth Reached>>"}:{...n,...flattenObject(s,t,r,[...o,c])}:{...n,[l]:s}}),{})};export const flattenedObjects=(...e)=>e.map((e=>flattenObject(e)));export const objectSummary=(e,t=100)=>{if("object"==typeof e){const n=flattenObject(e),o=[];return Object.keys(n).forEach((e=>{o.push(`${e} = ${objectSummary(n[e])}`)})),o.join(", ").substring(0,t)}return`${e}`.substring(0,t)};export const clone=e=>{const t=typeof e,n="undefined"==typeof window?class{}:window.Element;return e instanceof n?e.outerHTML:null===e?null:["string","number","boolean","undefined","bigint"].includes(t)?e:"symbol"===t?"<<SYMBOL>>":"function"===t?"<<function>>":e instanceof Array?e.map((e=>clone(e))):"object"===t?Object.keys(e).reduce(((t,n)=>({...t,[n]:clone(e[n])})),{}):e};export const equalObjs=(...e)=>{if(e.length<2)return!0;const t=toJson(e[0]);for(let n=1;n<e.length;n++)if(t!==toJson(e[n]))return!1;return!0};const pruneVar=e=>void 0===e?[void 0,!0]:"string"==typeof e?[e,""===e]:e instanceof Array?[e,0===e.length]:null===e?[e,!1]:"object"==typeof e?pruneObject(e):[e,!1],pruneObject=e=>{const t={};return Object.keys(e).forEach((n=>{const[o,r]=pruneVar(e[n]);r||(t[n]=o)})),[t,0===Object.keys(t).length]};export const prune=e=>pruneObject(e)[0];export const getAllKeys=(...e)=>[...new Set(e.map((e=>Object.keys(e))).flat())];export const getDifferencesKeys=(...e)=>getAllKeys(...e).map((t=>1!==new Set(e.map((e=>e[t]))).size?t:null)).filter((e=>null!==e));export const diff=(e,t)=>{const n={};function o(e,t,o){Array.isArray(t)&&Array.isArray(o)?t.length===o.length&&t.every(((e,t)=>e===o[t]))||(n[e.join(".")]={newValue:t,oldValue:o}):"object"==typeof t&&"object"==typeof o?r([...e],t,o):t!==o&&(n[e.join(".")]={newValue:t,oldValue:o})}function r(e,t,n){for(const r in t)if(t.hasOwnProperty(r)){o([...e,r],t[r],n[r])}}return r([],e,t),n};export default{toJson:toJson,flattenObject:flattenObject,flattenedObjects:flattenedObjects,objectSummary:objectSummary,clone:clone,equalObjs:equalObjs,pruneVars:pruneVars,pruneObject:pruneObject,prune:prune,getAllKeys:getAllKeys,getDifferencesKeys:getDifferencesKeys,diff:diff};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const camelToDash=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();export const dashToCamel=e=>e.replace(/-([a-z])/g,((e,
|
|
1
|
+
export const camelToDash=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();export const dashToCamel=e=>e.replace(/-([a-z])/g,((e,a)=>a.toUpperCase()));export const isCamelCase=e=>/[a-z][A-Z]/.test(e);export const getCase=e=>isCamelCase(e)?{camel:e,dash:camelToDash(e)}:{camel:dashToCamel(e),dash:e};export const escapeHTML=e=>e.replace(/[&<>"'/]/g,(e=>{switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case"'":return"'";case"/":return"/";default:return e}}));export const unescapeHTML=e=>e.replace(/&|<|>|"|'|//g,(e=>{switch(e){case"&":return"&";case"<":return"<";case">":return">";case""":return'"';case"'":return"'";case"/":return"/";default:return e}}));export const trim=(e,a)=>e.replace(new RegExp(`^[${a}]+|[${a}]+$`,"g"),"");export const compoundKey=e=>trim(e.join("."),".");export default{camelToDash:camelToDash,dashToCamel:dashToCamel,isCamelCase:isCamelCase,getCase:getCase,escapeHTML:escapeHTML,unescapeHTML:unescapeHTML,trim:trim,compoundKey:compoundKey};
|
package/docs/kempo/utils/type.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const typeOf=e=>null===e?"null":e instanceof Array?"array":"undefined"!=typeof Element&&e instanceof Element?"element":typeof e;export const isType=(e,
|
|
1
|
+
export const typeOf=e=>null===e?"null":e instanceof Array?"array":"undefined"!=typeof Element&&e instanceof Element?"element":typeof e;export const isType=(e,t)=>typeOf(e)===t;export default{typeOf:typeOf,isType:isType};
|
package/package.json
CHANGED
package/src/components/Tabs.js
CHANGED
package/src/utils/cli.js
CHANGED
package/src/utils/cookie.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
const saveCookie = (name, value, minutes = 30 * 24 * 60, path = '/') => {
|
|
1
|
+
export const saveCookie = (name, value, minutes = 30 * 24 * 60, path = '/') => {
|
|
2
2
|
const expires = new Date(Date.now() + minutes * 60 * 1000);
|
|
3
3
|
document.cookie = `${name}=${value};expires=${expires.toUTCString()};path=${path}`;
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
-
const getCookie = (name) => {
|
|
6
|
+
export const getCookie = (name) => {
|
|
7
7
|
const cookies = document.cookie.split(';').map(cookie => cookie.trim().split('='));
|
|
8
8
|
const cookie = cookies.find(cookie => cookie[0] === name);
|
|
9
9
|
return cookie ? cookie[1] : null;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
const deleteCookie = (name) => {
|
|
12
|
+
export const deleteCookie = (name) => {
|
|
13
13
|
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/`;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export {
|
|
16
|
+
export default {
|
|
17
|
+
saveCookie,
|
|
18
|
+
getCookie,
|
|
19
|
+
deleteCookie
|
|
20
|
+
};
|
package/src/utils/element.js
CHANGED
|
@@ -66,4 +66,13 @@ export const setProp = (element, prop, value, scope = document) => {
|
|
|
66
66
|
} else if(typeof(element) === 'string'){
|
|
67
67
|
dispatchEvent(scope.querySelectorAll(element), prop, value);
|
|
68
68
|
}
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default {
|
|
72
|
+
onEvent,
|
|
73
|
+
offEvent,
|
|
74
|
+
dispatchEvent,
|
|
75
|
+
isInView,
|
|
76
|
+
firstFocusable,
|
|
77
|
+
setProp
|
|
78
|
+
};
|
package/src/utils/fuzzyMatch.js
CHANGED
|
@@ -52,4 +52,9 @@ export const fuzzyMatchArray = (array, targetString) => {
|
|
|
52
52
|
}
|
|
53
53
|
const averageScore = nonZeroScores.reduce((sum, score) => sum + score, 0) / nonZeroScores.length;
|
|
54
54
|
return averageScore;
|
|
55
|
-
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
fuzzyMatch,
|
|
59
|
+
fuzzyMatchArray
|
|
60
|
+
};
|
package/src/utils/object.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
typeOf,
|
|
3
|
-
isType
|
|
4
|
-
} from './type.js';
|
|
1
|
+
import { typeOf } from './type.js';
|
|
5
2
|
|
|
6
3
|
export const toJson = (obj) => {
|
|
7
4
|
return JSON.stringify(obj, (key, value) => {
|
|
@@ -174,4 +171,19 @@ export const diff = (obj1, obj2) => {
|
|
|
174
171
|
|
|
175
172
|
compareObjects([], obj1, obj2);
|
|
176
173
|
return result;
|
|
177
|
-
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export default {
|
|
177
|
+
toJson,
|
|
178
|
+
flattenObject,
|
|
179
|
+
flattenedObjects,
|
|
180
|
+
objectSummary,
|
|
181
|
+
clone,
|
|
182
|
+
equalObjs,
|
|
183
|
+
pruneVars,
|
|
184
|
+
pruneObject,
|
|
185
|
+
prune,
|
|
186
|
+
getAllKeys,
|
|
187
|
+
getDifferencesKeys,
|
|
188
|
+
diff
|
|
189
|
+
};
|
package/src/utils/string.js
CHANGED
|
@@ -51,4 +51,15 @@ export const unescapeHTML = str => str.replace(/&|<|>|"|'|&#x
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
export const trim = (str, chars) => str.replace(new RegExp(`^[${chars}]+|[${chars}]+$`, 'g'), '');
|
|
54
|
-
export const compoundKey = keys => trim(keys.join('.'), '.');
|
|
54
|
+
export const compoundKey = keys => trim(keys.join('.'), '.');
|
|
55
|
+
|
|
56
|
+
export default {
|
|
57
|
+
camelToDash,
|
|
58
|
+
dashToCamel,
|
|
59
|
+
isCamelCase,
|
|
60
|
+
getCase,
|
|
61
|
+
escapeHTML,
|
|
62
|
+
unescapeHTML,
|
|
63
|
+
trim,
|
|
64
|
+
compoundKey
|
|
65
|
+
};
|