@kodaris/krubble-components 1.0.0
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/custom-elements.json +2156 -0
- package/dist/accordion/accordion.d.ts +35 -0
- package/dist/accordion/accordion.d.ts.map +1 -0
- package/dist/accordion/accordion.js +120 -0
- package/dist/accordion/accordion.js.map +1 -0
- package/dist/alert.d.ts +35 -0
- package/dist/alert.d.ts.map +1 -0
- package/dist/alert.js +204 -0
- package/dist/alert.js.map +1 -0
- package/dist/button/button.d.ts +30 -0
- package/dist/button/button.d.ts.map +1 -0
- package/dist/button/button.js +133 -0
- package/dist/button/button.js.map +1 -0
- package/dist/code-demo/code-demo.d.ts +44 -0
- package/dist/code-demo/code-demo.d.ts.map +1 -0
- package/dist/code-demo/code-demo.js +277 -0
- package/dist/code-demo/code-demo.js.map +1 -0
- package/dist/context-menu/context-menu.d.ts +54 -0
- package/dist/context-menu/context-menu.d.ts.map +1 -0
- package/dist/context-menu/context-menu.js +179 -0
- package/dist/context-menu/context-menu.js.map +1 -0
- package/dist/dialog/dialog.d.ts +58 -0
- package/dist/dialog/dialog.d.ts.map +1 -0
- package/dist/dialog/dialog.js +142 -0
- package/dist/dialog/dialog.js.map +1 -0
- package/dist/form/index.d.ts +2 -0
- package/dist/form/index.d.ts.map +1 -0
- package/dist/form/index.js +3 -0
- package/dist/form/index.js.map +1 -0
- package/dist/form/text-field/text-field.d.ts +91 -0
- package/dist/form/text-field/text-field.d.ts.map +1 -0
- package/dist/form/text-field/text-field.js +281 -0
- package/dist/form/text-field/text-field.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/krubble.bundled.js +1402 -0
- package/dist/krubble.bundled.js.map +1 -0
- package/dist/krubble.bundled.min.js +739 -0
- package/dist/krubble.bundled.min.js.map +1 -0
- package/dist/krubble.umd.js +1411 -0
- package/dist/krubble.umd.js.map +1 -0
- package/dist/krubble.umd.min.js +739 -0
- package/dist/krubble.umd.min.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,1402 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
const t$3=globalThis,e$7=t$3.ShadowRoot&&(void 0===t$3.ShadyCSS||t$3.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$5=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$2)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$7&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$5.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$5.set(s,t));}return t}toString(){return this.cssText}};const r$4=t=>new n$3("string"==typeof t?t:t+"",void 0,s$2),i$4=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(true===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new n$3(o,t,s$2)},S$1=(s,o)=>{if(e$7)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$3.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$7?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$4(e)})(t):t;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @license
|
|
10
|
+
* Copyright 2017 Google LLC
|
|
11
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
|
+
*/const{is:i$3,defineProperty:e$6,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$3,getOwnPropertySymbols:o$4,getPrototypeOf:n$2}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$2=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$2={toAttribute(t,s){switch(s){case Boolean:t=t?l$2:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$2=(t,s)=>!i$3(t,s),b={attribute:true,type:String,converter:u$2,reflect:false,useDefault:false,hasChanged:f$2};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let y$1 = class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$6(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$3(t),...o$4(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u$2).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$2;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f$2)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}};y$1.elementStyles=[],y$1.shadowRootOptions={mode:"open"},y$1[d$1("elementProperties")]=new Map,y$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y$1}),(a$1.reactiveElementVersions??=[]).push("2.1.1");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2017 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
|
+
*/
|
|
19
|
+
const t$2=globalThis,i$2=t$2.trustedTypes,s$1=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$5="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$3="?"+h,n$1=`<${o$3}>`,r$2=document,l$1=()=>r$2.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u$1=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f$1=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m$1=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r$2.createTreeWalker(r$2,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$1?s$1.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f$1;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f$1?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m$1):void 0!==u[3]&&(c=m$1):c===m$1?">"===u[0]?(c=r??f$1,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m$1:'"'===u[3]?g:p):c===g||c===p?c=m$1:c===v||c===_?c=f$1:(c=m$1,r=void 0);const x=c===m$1&&t[i+1].startsWith("/>")?" ":"";l+=c===f$1?s+n$1:d>=0?(o.push(a),s.slice(0,d)+e$5+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$5)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$2?i$2.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l$1()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l$1());}}}else if(8===r.nodeType)if(r.data===o$3)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r$2.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r$2).importNode(i,true);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r$2,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u$1(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r$2.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l$1()),this.O(l$1()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(false,true,i);t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t$2.litHtmlPolyfillSupport;j?.(N,R),(t$2.litHtmlVersions??=[]).push("3.3.1");const B=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l$1(),t),t,void 0,s??{});}return h._$AI(t),h};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2017 Google LLC
|
|
24
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
25
|
+
*/const s=globalThis;let i$1 = class i extends y$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(r,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(true);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(false);}render(){return T}};i$1._$litElement$=true,i$1["finalized"]=true,s.litElementHydrateSupport?.({LitElement:i$1});const o$2=s.litElementPolyfillSupport;o$2?.({LitElement:i$1});(s.litElementVersions??=[]).push("4.2.1");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @license
|
|
29
|
+
* Copyright 2017 Google LLC
|
|
30
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
31
|
+
*/
|
|
32
|
+
const t$1=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @license
|
|
36
|
+
* Copyright 2017 Google LLC
|
|
37
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
|
+
*/const o$1={attribute:true,type:String,converter:u$2,reflect:false,hasChanged:f$2},r$1=(t=o$1,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===n&&((t=Object.create(t)).wrapped=true),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n(t){return (e,o)=>"object"==typeof o?r$1(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @license
|
|
42
|
+
* Copyright 2017 Google LLC
|
|
43
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
44
|
+
*/function r(r){return n({...r,state:true,attribute:false})}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @license
|
|
48
|
+
* Copyright 2017 Google LLC
|
|
49
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
50
|
+
*/
|
|
51
|
+
const e$4=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright 2017 Google LLC
|
|
56
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
+
*/function e$3(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$4(n,s,{get(){return o(this)}})}}
|
|
58
|
+
|
|
59
|
+
var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
60
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
61
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
62
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
63
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Accordion component for collapsible content sections.
|
|
67
|
+
*
|
|
68
|
+
* ## Usage
|
|
69
|
+
* ```html
|
|
70
|
+
* <kr-accordion header="Basic Information" expanded>
|
|
71
|
+
* <div>Content here</div>
|
|
72
|
+
* </kr-accordion>
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @slot - The collapsible content
|
|
76
|
+
*
|
|
77
|
+
* @property {string} header - Section header text
|
|
78
|
+
* @property {boolean} expanded - Whether the accordion is expanded
|
|
79
|
+
*/
|
|
80
|
+
let KRAccordion = class KRAccordion extends i$1 {
|
|
81
|
+
constructor() {
|
|
82
|
+
super(...arguments);
|
|
83
|
+
/**
|
|
84
|
+
* Section header text
|
|
85
|
+
*/
|
|
86
|
+
this.header = '';
|
|
87
|
+
/**
|
|
88
|
+
* Whether the accordion is expanded
|
|
89
|
+
*/
|
|
90
|
+
this.expanded = false;
|
|
91
|
+
}
|
|
92
|
+
toggle() {
|
|
93
|
+
this.expanded = !this.expanded;
|
|
94
|
+
}
|
|
95
|
+
render() {
|
|
96
|
+
return x `
|
|
97
|
+
<div class="header" @click=${this.toggle}>
|
|
98
|
+
<span class="header__title">${this.header}</span>
|
|
99
|
+
<svg class="header__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
100
|
+
<path d="M6 9l6 6 6-6"/>
|
|
101
|
+
</svg>
|
|
102
|
+
</div>
|
|
103
|
+
<div class="content">
|
|
104
|
+
<div class="content__inner">
|
|
105
|
+
<div class="content__body">
|
|
106
|
+
<slot></slot>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
`;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
KRAccordion.styles = i$4 `
|
|
114
|
+
:host {
|
|
115
|
+
display: block;
|
|
116
|
+
margin-bottom: 16px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.header {
|
|
120
|
+
display: flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: space-between;
|
|
123
|
+
padding: 12px 16px;
|
|
124
|
+
background: #f7f8f9;
|
|
125
|
+
border-radius: 8px;
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
user-select: none;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.header__title {
|
|
131
|
+
font-size: 15px;
|
|
132
|
+
font-weight: 600;
|
|
133
|
+
color: #111827;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.header__icon {
|
|
137
|
+
width: 20px;
|
|
138
|
+
height: 20px;
|
|
139
|
+
color: #9ca3af;
|
|
140
|
+
transition: transform 0.2s ease;
|
|
141
|
+
flex-shrink: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
:host([expanded]) .header__icon {
|
|
145
|
+
transform: rotate(180deg);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.content {
|
|
149
|
+
display: grid;
|
|
150
|
+
grid-template-rows: 0fr;
|
|
151
|
+
transition: grid-template-rows 0.2s ease;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
:host([expanded]) .content {
|
|
155
|
+
grid-template-rows: 1fr;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.content__inner {
|
|
159
|
+
overflow: hidden;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.content__body {
|
|
163
|
+
padding: 16px 16px 8px 16px;
|
|
164
|
+
}
|
|
165
|
+
`;
|
|
166
|
+
__decorate$6([
|
|
167
|
+
n({ type: String })
|
|
168
|
+
], KRAccordion.prototype, "header", void 0);
|
|
169
|
+
__decorate$6([
|
|
170
|
+
n({ type: Boolean, reflect: true })
|
|
171
|
+
], KRAccordion.prototype, "expanded", void 0);
|
|
172
|
+
KRAccordion = __decorate$6([
|
|
173
|
+
t$1('kr-accordion')
|
|
174
|
+
], KRAccordion);
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @license
|
|
178
|
+
* Copyright 2017 Google LLC
|
|
179
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
180
|
+
*/
|
|
181
|
+
const t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4},e$2=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @license
|
|
185
|
+
* Copyright 2018 Google LLC
|
|
186
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
187
|
+
*/const e$1=e$2(class extends i{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter((s=>t[s])).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return T}});
|
|
188
|
+
|
|
189
|
+
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
190
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
191
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
192
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
193
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* A customizable alert component for displaying important information to users.
|
|
197
|
+
*
|
|
198
|
+
* @slot - The alert message content
|
|
199
|
+
* @fires dismiss - Fired when the dismiss button is clicked
|
|
200
|
+
*/
|
|
201
|
+
let KRAlert = class KRAlert extends i$1 {
|
|
202
|
+
constructor() {
|
|
203
|
+
super(...arguments);
|
|
204
|
+
/**
|
|
205
|
+
* The alert type/severity
|
|
206
|
+
*/
|
|
207
|
+
this.type = 'info';
|
|
208
|
+
/**
|
|
209
|
+
* Whether the alert can be dismissed
|
|
210
|
+
*/
|
|
211
|
+
this.dismissible = false;
|
|
212
|
+
/**
|
|
213
|
+
* Whether the alert is visible
|
|
214
|
+
*/
|
|
215
|
+
this.visible = true;
|
|
216
|
+
}
|
|
217
|
+
/** Handles dismiss button click */
|
|
218
|
+
_handleDismiss() {
|
|
219
|
+
this.visible = false;
|
|
220
|
+
this.dispatchEvent(new CustomEvent('dismiss', { bubbles: true, composed: true }));
|
|
221
|
+
}
|
|
222
|
+
render() {
|
|
223
|
+
const icons = {
|
|
224
|
+
info: x `<svg class="icon" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"/></svg>`,
|
|
225
|
+
success: x `<svg class="icon" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/></svg>`,
|
|
226
|
+
warning: x `<svg class="icon" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd"/></svg>`,
|
|
227
|
+
error: x `<svg class="icon" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/></svg>`,
|
|
228
|
+
};
|
|
229
|
+
return x `
|
|
230
|
+
<div
|
|
231
|
+
class=${e$1({
|
|
232
|
+
'alert': true,
|
|
233
|
+
['alert--' + this.type]: true,
|
|
234
|
+
'alert--hidden': !this.visible
|
|
235
|
+
})}
|
|
236
|
+
role="alert"
|
|
237
|
+
>
|
|
238
|
+
${icons[this.type]}
|
|
239
|
+
<div class="content">
|
|
240
|
+
${this.header
|
|
241
|
+
? x `<h4 class="header">${this.header}</h4>`
|
|
242
|
+
: E}
|
|
243
|
+
<div class="message">
|
|
244
|
+
<slot></slot>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
${this.dismissible
|
|
248
|
+
? x `
|
|
249
|
+
<button
|
|
250
|
+
class="dismiss"
|
|
251
|
+
type="button"
|
|
252
|
+
aria-label="Dismiss alert"
|
|
253
|
+
@click=${this._handleDismiss}
|
|
254
|
+
>
|
|
255
|
+
<svg viewBox="0 0 20 20" fill="currentColor" width="16" height="16">
|
|
256
|
+
<path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"/>
|
|
257
|
+
</svg>
|
|
258
|
+
</button>
|
|
259
|
+
`
|
|
260
|
+
: E}
|
|
261
|
+
</div>
|
|
262
|
+
`;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
KRAlert.styles = i$4 `
|
|
266
|
+
:host {
|
|
267
|
+
display: block;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.alert {
|
|
271
|
+
display: flex;
|
|
272
|
+
align-items: center;
|
|
273
|
+
gap: 12px;
|
|
274
|
+
padding: 12px 16px;
|
|
275
|
+
border-radius: 8px;
|
|
276
|
+
border-left: 4px solid;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.alert--hidden {
|
|
280
|
+
display: none;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/* Variants */
|
|
284
|
+
.alert--info {
|
|
285
|
+
background-color: #eff6ff;
|
|
286
|
+
border-left-color: #3b82f6;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.alert--info .icon {
|
|
290
|
+
color: #2563eb;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.alert--success {
|
|
294
|
+
background-color: #f0fdf4;
|
|
295
|
+
border-left-color: #22c55e;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.alert--success .icon {
|
|
299
|
+
color: #16a34a;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.alert--warning {
|
|
303
|
+
background-color: #fffbeb;
|
|
304
|
+
border-left-color: #f59e0b;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.alert--warning .icon {
|
|
308
|
+
color: #d97706;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.alert--error {
|
|
312
|
+
background-color: #fef2f2;
|
|
313
|
+
border-left-color: #ef4444;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.alert--error .icon {
|
|
317
|
+
color: #dc2626;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.icon {
|
|
321
|
+
flex-shrink: 0;
|
|
322
|
+
width: 20px;
|
|
323
|
+
height: 20px;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.content {
|
|
327
|
+
flex: 1;
|
|
328
|
+
min-width: 0;
|
|
329
|
+
display: flex;
|
|
330
|
+
flex-direction: column;
|
|
331
|
+
gap: 6px;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.header {
|
|
335
|
+
font-size: 14px;
|
|
336
|
+
font-weight: 600;
|
|
337
|
+
color: #111827;
|
|
338
|
+
margin: 0;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.message {
|
|
342
|
+
font-size: 14px;
|
|
343
|
+
color: #374151;
|
|
344
|
+
margin: 0;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.dismiss {
|
|
348
|
+
flex-shrink: 0;
|
|
349
|
+
display: flex;
|
|
350
|
+
align-items: center;
|
|
351
|
+
justify-content: center;
|
|
352
|
+
width: 24px;
|
|
353
|
+
height: 24px;
|
|
354
|
+
padding: 0;
|
|
355
|
+
background: none;
|
|
356
|
+
border: none;
|
|
357
|
+
border-radius: 4px;
|
|
358
|
+
color: #6b7280;
|
|
359
|
+
cursor: pointer;
|
|
360
|
+
transition: background 0.15s ease, color 0.15s ease;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.dismiss:hover {
|
|
364
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
365
|
+
color: #374151;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.dismiss:focus-visible {
|
|
369
|
+
outline: 2px solid #3b82f6;
|
|
370
|
+
outline-offset: 2px;
|
|
371
|
+
}
|
|
372
|
+
`;
|
|
373
|
+
__decorate$5([
|
|
374
|
+
n({ type: String })
|
|
375
|
+
], KRAlert.prototype, "type", void 0);
|
|
376
|
+
__decorate$5([
|
|
377
|
+
n({ type: String })
|
|
378
|
+
], KRAlert.prototype, "header", void 0);
|
|
379
|
+
__decorate$5([
|
|
380
|
+
n({ type: Boolean })
|
|
381
|
+
], KRAlert.prototype, "dismissible", void 0);
|
|
382
|
+
__decorate$5([
|
|
383
|
+
n({ type: Boolean })
|
|
384
|
+
], KRAlert.prototype, "visible", void 0);
|
|
385
|
+
KRAlert = __decorate$5([
|
|
386
|
+
t$1('kr-alert')
|
|
387
|
+
], KRAlert);
|
|
388
|
+
|
|
389
|
+
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
390
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
391
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
392
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
393
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
396
|
+
* A customizable button component.
|
|
397
|
+
*
|
|
398
|
+
* @slot - The button content
|
|
399
|
+
* @csspart button - The button element
|
|
400
|
+
* @fires click - Fired when the button is clicked
|
|
401
|
+
*/
|
|
402
|
+
let KRButton = class KRButton extends i$1 {
|
|
403
|
+
constructor() {
|
|
404
|
+
super(...arguments);
|
|
405
|
+
/**
|
|
406
|
+
* The button variant style
|
|
407
|
+
*/
|
|
408
|
+
this.variant = 'primary';
|
|
409
|
+
/**
|
|
410
|
+
* The button size
|
|
411
|
+
*/
|
|
412
|
+
this.size = 'medium';
|
|
413
|
+
/**
|
|
414
|
+
* Whether the button is disabled
|
|
415
|
+
*/
|
|
416
|
+
this.disabled = false;
|
|
417
|
+
}
|
|
418
|
+
render() {
|
|
419
|
+
const sizeClass = this.size !== 'medium' ? this.size : '';
|
|
420
|
+
return x `
|
|
421
|
+
<button
|
|
422
|
+
part="button"
|
|
423
|
+
class="${this.variant} ${sizeClass}"
|
|
424
|
+
?disabled=${this.disabled}
|
|
425
|
+
>
|
|
426
|
+
<slot></slot>
|
|
427
|
+
</button>
|
|
428
|
+
`;
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
KRButton.styles = i$4 `
|
|
432
|
+
:host {
|
|
433
|
+
display: inline-block;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
button {
|
|
437
|
+
font-family: inherit;
|
|
438
|
+
font-size: 14px;
|
|
439
|
+
font-weight: 400;
|
|
440
|
+
letter-spacing: 0.01em;
|
|
441
|
+
padding: 0 22px;
|
|
442
|
+
height: 36px;
|
|
443
|
+
line-height: 36px;
|
|
444
|
+
border: none;
|
|
445
|
+
border-radius: 20px;
|
|
446
|
+
cursor: pointer;
|
|
447
|
+
transition: background 0.15s ease;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
button:active:not(:disabled) {
|
|
451
|
+
transform: scale(0.98);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
button:disabled {
|
|
455
|
+
opacity: 0.5;
|
|
456
|
+
cursor: not-allowed;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/* Variants */
|
|
460
|
+
button.primary {
|
|
461
|
+
background: #163052;
|
|
462
|
+
color: white;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
button.primary:hover:not(:disabled) {
|
|
466
|
+
background: #0e1f35;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
button.secondary {
|
|
470
|
+
background: #f3f4f6;
|
|
471
|
+
color: #374151;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
button.secondary:hover:not(:disabled) {
|
|
475
|
+
background: #e5e7eb;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
button.outline {
|
|
479
|
+
background: transparent;
|
|
480
|
+
border: 1px solid #d1d5db;
|
|
481
|
+
color: #374151;
|
|
482
|
+
box-shadow: none;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
button.outline:hover:not(:disabled) {
|
|
486
|
+
background: #f9fafb;
|
|
487
|
+
border-color: #9ca3af;
|
|
488
|
+
box-shadow: none;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/* Sizes */
|
|
492
|
+
button.small {
|
|
493
|
+
font-size: 0.75rem;
|
|
494
|
+
height: 28px;
|
|
495
|
+
line-height: 28px;
|
|
496
|
+
padding: 0 10px;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
button.large {
|
|
500
|
+
font-size: 1rem;
|
|
501
|
+
height: 44px;
|
|
502
|
+
line-height: 44px;
|
|
503
|
+
padding: 0 24px;
|
|
504
|
+
}
|
|
505
|
+
`;
|
|
506
|
+
__decorate$4([
|
|
507
|
+
n({ type: String })
|
|
508
|
+
], KRButton.prototype, "variant", void 0);
|
|
509
|
+
__decorate$4([
|
|
510
|
+
n({ type: String })
|
|
511
|
+
], KRButton.prototype, "size", void 0);
|
|
512
|
+
__decorate$4([
|
|
513
|
+
n({ type: Boolean })
|
|
514
|
+
], KRButton.prototype, "disabled", void 0);
|
|
515
|
+
KRButton = __decorate$4([
|
|
516
|
+
t$1('kr-button')
|
|
517
|
+
], KRButton);
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* @license
|
|
521
|
+
* Copyright 2017 Google LLC
|
|
522
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
523
|
+
*/class e extends i{constructor(i){if(super(i),this.it=E,i.type!==t.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===E||null==r)return this._t=void 0,this.it=r;if(r===T)return r;if("string"!=typeof r)throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName="unsafeHTML",e.resultType=1;const o=e$2(e);
|
|
524
|
+
|
|
525
|
+
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
526
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
527
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
528
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
529
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
530
|
+
};
|
|
531
|
+
/**
|
|
532
|
+
* Code demo component with Preview/Code tabs and syntax highlighting.
|
|
533
|
+
*
|
|
534
|
+
* Usage:
|
|
535
|
+
* ```html
|
|
536
|
+
* <kr-code-demo language="html">
|
|
537
|
+
* <div slot="preview">
|
|
538
|
+
* <kr-button>Click me</kr-button>
|
|
539
|
+
* </div>
|
|
540
|
+
* <script slot="code" type="text/plain">
|
|
541
|
+
* <kr-button>Click me</kr-button>
|
|
542
|
+
* </script>
|
|
543
|
+
* </kr-code-demo>
|
|
544
|
+
* ```
|
|
545
|
+
*
|
|
546
|
+
* Requires Prism.js to be loaded globally for syntax highlighting.
|
|
547
|
+
*/
|
|
548
|
+
let KRCodeDemo = class KRCodeDemo extends i$1 {
|
|
549
|
+
constructor() {
|
|
550
|
+
super(...arguments);
|
|
551
|
+
this.language = 'html';
|
|
552
|
+
this.code = '';
|
|
553
|
+
this.activeTab = 'preview';
|
|
554
|
+
this.copied = false;
|
|
555
|
+
}
|
|
556
|
+
setTab(tab) {
|
|
557
|
+
this.activeTab = tab;
|
|
558
|
+
}
|
|
559
|
+
getHighlightedCode() {
|
|
560
|
+
if (!this.code)
|
|
561
|
+
return '';
|
|
562
|
+
if (window.Prism && window.Prism.languages[this.language]) {
|
|
563
|
+
return window.Prism.highlight(this.code, window.Prism.languages[this.language], this.language);
|
|
564
|
+
}
|
|
565
|
+
// Fallback: escape HTML and return plain text
|
|
566
|
+
return this.escapeHtml(this.code);
|
|
567
|
+
}
|
|
568
|
+
escapeHtml(text) {
|
|
569
|
+
const div = document.createElement('div');
|
|
570
|
+
div.textContent = text;
|
|
571
|
+
return div.innerHTML;
|
|
572
|
+
}
|
|
573
|
+
async copyCode() {
|
|
574
|
+
if (!this.code)
|
|
575
|
+
return;
|
|
576
|
+
try {
|
|
577
|
+
await navigator.clipboard.writeText(this.code);
|
|
578
|
+
this.copied = true;
|
|
579
|
+
setTimeout(() => {
|
|
580
|
+
this.copied = false;
|
|
581
|
+
}, 2000);
|
|
582
|
+
}
|
|
583
|
+
catch (err) {
|
|
584
|
+
console.error('Failed to copy code:', err);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
render() {
|
|
588
|
+
return x `
|
|
589
|
+
<div class="tabs">
|
|
590
|
+
<button
|
|
591
|
+
class=${e$1({ tab: true, 'tab--active': this.activeTab === 'preview' })}
|
|
592
|
+
@click=${() => this.setTab('preview')}
|
|
593
|
+
>
|
|
594
|
+
Preview
|
|
595
|
+
</button>
|
|
596
|
+
<button
|
|
597
|
+
class=${e$1({ tab: true, 'tab--active': this.activeTab === 'code' })}
|
|
598
|
+
@click=${() => this.setTab('code')}
|
|
599
|
+
>
|
|
600
|
+
Code
|
|
601
|
+
</button>
|
|
602
|
+
</div>
|
|
603
|
+
|
|
604
|
+
<div class=${e$1({ panel: true, 'panel--active': this.activeTab === 'preview', preview: true })}>
|
|
605
|
+
<slot name="preview"></slot>
|
|
606
|
+
</div>
|
|
607
|
+
|
|
608
|
+
<div class=${e$1({ panel: true, 'panel--active': this.activeTab === 'code', 'code-container': true })}>
|
|
609
|
+
<button
|
|
610
|
+
class=${e$1({ 'copy-btn': true, 'copy-btn--copied': this.copied })}
|
|
611
|
+
@click=${this.copyCode}
|
|
612
|
+
>
|
|
613
|
+
${this.copied ? 'Copied!' : 'Copy'}
|
|
614
|
+
</button>
|
|
615
|
+
<pre class="code"><code>${o(this.getHighlightedCode())}</code></pre>
|
|
616
|
+
</div>
|
|
617
|
+
|
|
618
|
+
`;
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
KRCodeDemo.styles = i$4 `
|
|
622
|
+
:host {
|
|
623
|
+
display: block;
|
|
624
|
+
border: 1px solid #e9ecef;
|
|
625
|
+
border-radius: 8px;
|
|
626
|
+
overflow: hidden;
|
|
627
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
.tabs {
|
|
631
|
+
display: flex;
|
|
632
|
+
background: #f8f9fa;
|
|
633
|
+
border-bottom: 1px solid #e9ecef;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
.tab {
|
|
637
|
+
padding: 10px 20px;
|
|
638
|
+
background: none;
|
|
639
|
+
border: none;
|
|
640
|
+
color: #6c757d;
|
|
641
|
+
font-size: 14px;
|
|
642
|
+
font-weight: 500;
|
|
643
|
+
font-family: inherit;
|
|
644
|
+
cursor: pointer;
|
|
645
|
+
position: relative;
|
|
646
|
+
transition: color 0.15s;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.tab:hover {
|
|
650
|
+
color: #495057;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
.tab--active {
|
|
654
|
+
color: #1a1a2e;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
.tab--active::after {
|
|
658
|
+
content: '';
|
|
659
|
+
position: absolute;
|
|
660
|
+
bottom: -1px;
|
|
661
|
+
left: 0;
|
|
662
|
+
right: 0;
|
|
663
|
+
height: 2px;
|
|
664
|
+
background: #4f46e5;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
.panel {
|
|
668
|
+
display: none;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
.panel--active {
|
|
672
|
+
display: block;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
.preview {
|
|
676
|
+
padding: 24px;
|
|
677
|
+
background: #ffffff;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
.code-container {
|
|
681
|
+
position: relative;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
.code {
|
|
685
|
+
margin: 0;
|
|
686
|
+
padding: 20px;
|
|
687
|
+
background: #1e1e2e;
|
|
688
|
+
overflow-x: auto;
|
|
689
|
+
font-family: 'SF Mono', 'Fira Code', 'Monaco', 'Consolas', monospace;
|
|
690
|
+
font-size: 13px;
|
|
691
|
+
line-height: 1.6;
|
|
692
|
+
color: #cdd6f4;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
.code code {
|
|
696
|
+
font-family: inherit;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
.copy-btn {
|
|
700
|
+
position: absolute;
|
|
701
|
+
top: 12px;
|
|
702
|
+
right: 12px;
|
|
703
|
+
padding: 6px 12px;
|
|
704
|
+
background: rgba(255, 255, 255, 0.1);
|
|
705
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
706
|
+
border-radius: 6px;
|
|
707
|
+
color: rgba(255, 255, 255, 0.7);
|
|
708
|
+
font-size: 12px;
|
|
709
|
+
font-family: inherit;
|
|
710
|
+
cursor: pointer;
|
|
711
|
+
transition: background 0.15s, color 0.15s;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
.copy-btn:hover {
|
|
715
|
+
background: rgba(255, 255, 255, 0.15);
|
|
716
|
+
color: white;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
.copy-btn--copied {
|
|
720
|
+
background: rgba(34, 197, 94, 0.2);
|
|
721
|
+
border-color: rgba(34, 197, 94, 0.3);
|
|
722
|
+
color: #4ade80;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/* Prism.js theme overrides for dark mode */
|
|
726
|
+
.code .token.comment,
|
|
727
|
+
.code .token.prolog,
|
|
728
|
+
.code .token.doctype,
|
|
729
|
+
.code .token.cdata {
|
|
730
|
+
color: #6c7086;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
.code .token.punctuation {
|
|
734
|
+
color: #9399b2;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
.code .token.property,
|
|
738
|
+
.code .token.tag,
|
|
739
|
+
.code .token.boolean,
|
|
740
|
+
.code .token.number,
|
|
741
|
+
.code .token.constant,
|
|
742
|
+
.code .token.symbol,
|
|
743
|
+
.code .token.deleted {
|
|
744
|
+
color: #f38ba8;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
.code .token.selector,
|
|
748
|
+
.code .token.attr-name,
|
|
749
|
+
.code .token.string,
|
|
750
|
+
.code .token.char,
|
|
751
|
+
.code .token.builtin,
|
|
752
|
+
.code .token.inserted {
|
|
753
|
+
color: #a6e3a1;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
.code .token.operator,
|
|
757
|
+
.code .token.entity,
|
|
758
|
+
.code .token.url,
|
|
759
|
+
.code .language-css .token.string,
|
|
760
|
+
.code .style .token.string {
|
|
761
|
+
color: #94e2d5;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
.code .token.atrule,
|
|
765
|
+
.code .token.attr-value,
|
|
766
|
+
.code .token.keyword {
|
|
767
|
+
color: #cba6f7;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
.code .token.function,
|
|
771
|
+
.code .token.class-name {
|
|
772
|
+
color: #89b4fa;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
.code .token.regex,
|
|
776
|
+
.code .token.important,
|
|
777
|
+
.code .token.variable {
|
|
778
|
+
color: #fab387;
|
|
779
|
+
}
|
|
780
|
+
`;
|
|
781
|
+
__decorate$3([
|
|
782
|
+
n({ type: String })
|
|
783
|
+
], KRCodeDemo.prototype, "language", void 0);
|
|
784
|
+
__decorate$3([
|
|
785
|
+
n({ type: String })
|
|
786
|
+
], KRCodeDemo.prototype, "code", void 0);
|
|
787
|
+
__decorate$3([
|
|
788
|
+
r()
|
|
789
|
+
], KRCodeDemo.prototype, "activeTab", void 0);
|
|
790
|
+
__decorate$3([
|
|
791
|
+
r()
|
|
792
|
+
], KRCodeDemo.prototype, "copied", void 0);
|
|
793
|
+
KRCodeDemo = __decorate$3([
|
|
794
|
+
t$1('kr-code-demo')
|
|
795
|
+
], KRCodeDemo);
|
|
796
|
+
|
|
797
|
+
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
798
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
799
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
800
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
801
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
802
|
+
};
|
|
803
|
+
/**
|
|
804
|
+
* Context menu component that can be opened programmatically.
|
|
805
|
+
*
|
|
806
|
+
* Usage:
|
|
807
|
+
* ```ts
|
|
808
|
+
* const result = await ContextMenu.open({
|
|
809
|
+
* x: event.clientX,
|
|
810
|
+
* y: event.clientY,
|
|
811
|
+
* items: [
|
|
812
|
+
* { id: 'edit', label: 'Edit Item' },
|
|
813
|
+
* { id: 'divider', label: '', divider: true },
|
|
814
|
+
* { id: 'add-above', label: 'Add Item Above' },
|
|
815
|
+
* { id: 'add-below', label: 'Add Item Below' },
|
|
816
|
+
* ]
|
|
817
|
+
* });
|
|
818
|
+
*
|
|
819
|
+
* if (result) {
|
|
820
|
+
* console.log('Selected:', result.id);
|
|
821
|
+
* }
|
|
822
|
+
* ```
|
|
823
|
+
*/
|
|
824
|
+
let KRContextMenu = class KRContextMenu extends i$1 {
|
|
825
|
+
constructor() {
|
|
826
|
+
super(...arguments);
|
|
827
|
+
this.items = [];
|
|
828
|
+
this.resolvePromise = null;
|
|
829
|
+
this.boundHandleOutsideClick = this.handleOutsideClick.bind(this);
|
|
830
|
+
this.boundHandleKeyDown = this.handleKeyDown.bind(this);
|
|
831
|
+
}
|
|
832
|
+
static async open(options) {
|
|
833
|
+
// Remove any existing context menu
|
|
834
|
+
const existing = document.querySelector('kr-context-menu');
|
|
835
|
+
if (existing) {
|
|
836
|
+
existing.remove();
|
|
837
|
+
}
|
|
838
|
+
// Create and position the menu
|
|
839
|
+
const menu = document.createElement('kr-context-menu');
|
|
840
|
+
document.body.appendChild(menu);
|
|
841
|
+
return menu.show(options);
|
|
842
|
+
}
|
|
843
|
+
async show(options) {
|
|
844
|
+
this.items = options.items;
|
|
845
|
+
this.style.left = `${options.x}px`;
|
|
846
|
+
this.style.top = `${options.y}px`;
|
|
847
|
+
// Adjust position if menu would go off screen
|
|
848
|
+
await this.updateComplete;
|
|
849
|
+
const rect = this.getBoundingClientRect();
|
|
850
|
+
if (rect.right > window.innerWidth) {
|
|
851
|
+
this.style.left = `${options.x - rect.width}px`;
|
|
852
|
+
}
|
|
853
|
+
if (rect.bottom > window.innerHeight) {
|
|
854
|
+
this.style.top = `${options.y - rect.height}px`;
|
|
855
|
+
}
|
|
856
|
+
// Add event listeners after a microtask to avoid the current event triggering close
|
|
857
|
+
requestAnimationFrame(() => {
|
|
858
|
+
document.addEventListener('click', this.boundHandleOutsideClick);
|
|
859
|
+
document.addEventListener('contextmenu', this.boundHandleOutsideClick);
|
|
860
|
+
document.addEventListener('keydown', this.boundHandleKeyDown);
|
|
861
|
+
});
|
|
862
|
+
return new Promise((resolve) => {
|
|
863
|
+
this.resolvePromise = resolve;
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
handleOutsideClick(e) {
|
|
867
|
+
if (!this.contains(e.target)) {
|
|
868
|
+
this.close(null);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
handleKeyDown(e) {
|
|
872
|
+
if (e.key === 'Escape') {
|
|
873
|
+
this.close(null);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
handleItemClick(item) {
|
|
877
|
+
if (!item.disabled && !item.divider) {
|
|
878
|
+
this.close(item);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
close(result) {
|
|
882
|
+
document.removeEventListener('click', this.boundHandleOutsideClick);
|
|
883
|
+
document.removeEventListener('contextmenu', this.boundHandleOutsideClick);
|
|
884
|
+
document.removeEventListener('keydown', this.boundHandleKeyDown);
|
|
885
|
+
if (this.resolvePromise) {
|
|
886
|
+
this.resolvePromise(result);
|
|
887
|
+
this.resolvePromise = null;
|
|
888
|
+
}
|
|
889
|
+
this.remove();
|
|
890
|
+
}
|
|
891
|
+
render() {
|
|
892
|
+
return x `
|
|
893
|
+
<div class="menu">
|
|
894
|
+
${this.items.map(item => item.divider
|
|
895
|
+
? x `<div class="menu__divider"></div>`
|
|
896
|
+
: x `
|
|
897
|
+
<button
|
|
898
|
+
class="menu__item"
|
|
899
|
+
?disabled=${item.disabled}
|
|
900
|
+
@click=${() => this.handleItemClick(item)}
|
|
901
|
+
>
|
|
902
|
+
${item.icon ? x `<span class="menu__item-icon">${item.icon}</span>` : null}
|
|
903
|
+
${item.label}
|
|
904
|
+
</button>
|
|
905
|
+
`)}
|
|
906
|
+
</div>
|
|
907
|
+
`;
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
KRContextMenu.styles = i$4 `
|
|
911
|
+
:host {
|
|
912
|
+
position: fixed;
|
|
913
|
+
z-index: 10000;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
.menu {
|
|
917
|
+
background: #1a1a2e;
|
|
918
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
919
|
+
border-radius: 8px;
|
|
920
|
+
padding: 4px;
|
|
921
|
+
min-width: 180px;
|
|
922
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
.menu__item {
|
|
926
|
+
display: flex;
|
|
927
|
+
align-items: center;
|
|
928
|
+
gap: 12px;
|
|
929
|
+
width: 100%;
|
|
930
|
+
padding: 10px 12px;
|
|
931
|
+
background: none;
|
|
932
|
+
border: none;
|
|
933
|
+
color: rgba(255, 255, 255, 0.8);
|
|
934
|
+
font-size: 13px;
|
|
935
|
+
font-family: inherit;
|
|
936
|
+
text-align: left;
|
|
937
|
+
cursor: pointer;
|
|
938
|
+
border-radius: 6px;
|
|
939
|
+
transition: background 0.15s ease;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
.menu__item:hover:not(:disabled) {
|
|
943
|
+
background: rgba(255, 255, 255, 0.05);
|
|
944
|
+
color: #ffffff;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
.menu__item:disabled {
|
|
948
|
+
opacity: 0.5;
|
|
949
|
+
cursor: not-allowed;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
.menu__item-icon {
|
|
953
|
+
width: 16px;
|
|
954
|
+
height: 16px;
|
|
955
|
+
display: flex;
|
|
956
|
+
align-items: center;
|
|
957
|
+
justify-content: center;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
.menu__divider {
|
|
961
|
+
height: 1px;
|
|
962
|
+
background: rgba(255, 255, 255, 0.1);
|
|
963
|
+
margin: 4px 0;
|
|
964
|
+
}
|
|
965
|
+
`;
|
|
966
|
+
__decorate$2([
|
|
967
|
+
r()
|
|
968
|
+
], KRContextMenu.prototype, "items", void 0);
|
|
969
|
+
KRContextMenu = __decorate$2([
|
|
970
|
+
t$1('kr-context-menu')
|
|
971
|
+
], KRContextMenu);
|
|
972
|
+
|
|
973
|
+
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
974
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
975
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
976
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
977
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
978
|
+
};
|
|
979
|
+
class DialogRef {
|
|
980
|
+
constructor() {
|
|
981
|
+
this.resolvePromise = null;
|
|
982
|
+
this.dialogElement = null;
|
|
983
|
+
this.promise = new Promise((resolve) => {
|
|
984
|
+
this.resolvePromise = resolve;
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
/** @internal */
|
|
988
|
+
setDialogElement(el) {
|
|
989
|
+
this.dialogElement = el;
|
|
990
|
+
}
|
|
991
|
+
close(result) {
|
|
992
|
+
if (this.resolvePromise) {
|
|
993
|
+
this.resolvePromise(result);
|
|
994
|
+
this.resolvePromise = null;
|
|
995
|
+
}
|
|
996
|
+
this.dialogElement?.remove();
|
|
997
|
+
}
|
|
998
|
+
afterClosed() {
|
|
999
|
+
return this.promise;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Generic dialog component that renders a Lit component inside a dialog shell.
|
|
1004
|
+
*
|
|
1005
|
+
* Usage:
|
|
1006
|
+
* ```ts
|
|
1007
|
+
* // Define your dialog content component
|
|
1008
|
+
* class EditItemDialog extends LitElement {
|
|
1009
|
+
* // Injected by KRDialog
|
|
1010
|
+
* dialogRef: DialogRef<{ label: string }>;
|
|
1011
|
+
* data: { label: string };
|
|
1012
|
+
*
|
|
1013
|
+
* save() {
|
|
1014
|
+
* this.dialogRef.close({ label: this.label });
|
|
1015
|
+
* }
|
|
1016
|
+
* }
|
|
1017
|
+
*
|
|
1018
|
+
* // Open the dialog
|
|
1019
|
+
* const dialogRef = KRDialog.open(EditItemDialog, {
|
|
1020
|
+
* data: { label: 'Dashboard' }
|
|
1021
|
+
* });
|
|
1022
|
+
*
|
|
1023
|
+
* const result = await dialogRef.afterClosed();
|
|
1024
|
+
* if (result) {
|
|
1025
|
+
* console.log('Saved:', result.label);
|
|
1026
|
+
* }
|
|
1027
|
+
* ```
|
|
1028
|
+
*/
|
|
1029
|
+
let KRDialog = class KRDialog extends i$1 {
|
|
1030
|
+
constructor() {
|
|
1031
|
+
super(...arguments);
|
|
1032
|
+
this.contentElement = null;
|
|
1033
|
+
this.dialogRef = null;
|
|
1034
|
+
this.boundHandleKeyDown = this.handleKeyDown.bind(this);
|
|
1035
|
+
}
|
|
1036
|
+
static open(component, config) {
|
|
1037
|
+
const existing = document.querySelector('kr-dialog');
|
|
1038
|
+
if (existing) {
|
|
1039
|
+
existing.remove();
|
|
1040
|
+
}
|
|
1041
|
+
const dialogRef = new DialogRef();
|
|
1042
|
+
const dialog = document.createElement('kr-dialog');
|
|
1043
|
+
dialogRef.setDialogElement(dialog);
|
|
1044
|
+
dialog.dialogRef = dialogRef;
|
|
1045
|
+
// Create the content component
|
|
1046
|
+
const content = new component();
|
|
1047
|
+
content.dialogRef = dialogRef;
|
|
1048
|
+
if (config?.data) {
|
|
1049
|
+
content.data = config.data;
|
|
1050
|
+
}
|
|
1051
|
+
dialog.contentElement = content;
|
|
1052
|
+
document.body.appendChild(dialog);
|
|
1053
|
+
document.addEventListener('keydown', dialog.boundHandleKeyDown);
|
|
1054
|
+
return dialogRef;
|
|
1055
|
+
}
|
|
1056
|
+
handleKeyDown(e) {
|
|
1057
|
+
if (e.key === 'Escape') {
|
|
1058
|
+
this.dialogRef?.close(undefined);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
handleBackdropClick(e) {
|
|
1062
|
+
if (e.target.classList.contains('backdrop')) {
|
|
1063
|
+
this.dialogRef?.close(undefined);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
disconnectedCallback() {
|
|
1067
|
+
super.disconnectedCallback();
|
|
1068
|
+
document.removeEventListener('keydown', this.boundHandleKeyDown);
|
|
1069
|
+
}
|
|
1070
|
+
render() {
|
|
1071
|
+
return x `
|
|
1072
|
+
<div class="backdrop" @click=${this.handleBackdropClick}></div>
|
|
1073
|
+
<div class="dialog">
|
|
1074
|
+
${this.contentElement}
|
|
1075
|
+
</div>
|
|
1076
|
+
`;
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
KRDialog.styles = i$4 `
|
|
1080
|
+
:host {
|
|
1081
|
+
position: fixed;
|
|
1082
|
+
inset: 0;
|
|
1083
|
+
z-index: 10000;
|
|
1084
|
+
display: flex;
|
|
1085
|
+
align-items: center;
|
|
1086
|
+
justify-content: center;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
.backdrop {
|
|
1090
|
+
position: absolute;
|
|
1091
|
+
inset: 0;
|
|
1092
|
+
background: rgba(0, 0, 0, 0.5);
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
.dialog {
|
|
1096
|
+
position: relative;
|
|
1097
|
+
background: #1a1a2e;
|
|
1098
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
1099
|
+
border-radius: 12px;
|
|
1100
|
+
box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
|
|
1101
|
+
max-height: 90vh;
|
|
1102
|
+
overflow: auto;
|
|
1103
|
+
}
|
|
1104
|
+
`;
|
|
1105
|
+
__decorate$1([
|
|
1106
|
+
r()
|
|
1107
|
+
], KRDialog.prototype, "contentElement", void 0);
|
|
1108
|
+
KRDialog = __decorate$1([
|
|
1109
|
+
t$1('kr-dialog')
|
|
1110
|
+
], KRDialog);
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* @license
|
|
1114
|
+
* Copyright 2020 Google LLC
|
|
1115
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1116
|
+
*/const f=o=>void 0===o.strings,u={},m=(o,t=u)=>o._$AH=t;
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* @license
|
|
1120
|
+
* Copyright 2020 Google LLC
|
|
1121
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1122
|
+
*/const l=e$2(class extends i{constructor(r){if(super(r),r.type!==t.PROPERTY&&r.type!==t.ATTRIBUTE&&r.type!==t.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!f(r))throw Error("`live` bindings can only contain a single expression")}render(r){return r}update(i,[t$1]){if(t$1===T||t$1===E)return t$1;const o=i.element,l=i.name;if(i.type===t.PROPERTY){if(t$1===o[l])return T}else if(i.type===t.BOOLEAN_ATTRIBUTE){if(!!t$1===o.hasAttribute(l))return T}else if(i.type===t.ATTRIBUTE&&o.getAttribute(l)===t$1+"")return T;return m(i),t$1}});
|
|
1123
|
+
|
|
1124
|
+
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1125
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1126
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1127
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1128
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1129
|
+
};
|
|
1130
|
+
/**
|
|
1131
|
+
* A text field component that works with native browser forms.
|
|
1132
|
+
*
|
|
1133
|
+
* Uses ElementInternals for form association, allowing the component
|
|
1134
|
+
* to participate in form submission, validation, and reset.
|
|
1135
|
+
*
|
|
1136
|
+
* Native input and change events bubble up from the inner input element.
|
|
1137
|
+
*/
|
|
1138
|
+
let KRTextField = class KRTextField extends i$1 {
|
|
1139
|
+
constructor() {
|
|
1140
|
+
super();
|
|
1141
|
+
/**
|
|
1142
|
+
* The input label text
|
|
1143
|
+
*/
|
|
1144
|
+
this.label = '';
|
|
1145
|
+
/**
|
|
1146
|
+
* The input name for form submission
|
|
1147
|
+
*/
|
|
1148
|
+
this.name = '';
|
|
1149
|
+
/**
|
|
1150
|
+
* The current value
|
|
1151
|
+
*/
|
|
1152
|
+
this.value = '';
|
|
1153
|
+
/**
|
|
1154
|
+
* Placeholder text
|
|
1155
|
+
*/
|
|
1156
|
+
this.placeholder = '';
|
|
1157
|
+
/**
|
|
1158
|
+
* Input type (text, email, password, tel, url, search)
|
|
1159
|
+
*/
|
|
1160
|
+
this.type = 'text';
|
|
1161
|
+
/**
|
|
1162
|
+
* Whether the field is required
|
|
1163
|
+
*/
|
|
1164
|
+
this.required = false;
|
|
1165
|
+
/**
|
|
1166
|
+
* Whether the field is disabled
|
|
1167
|
+
*/
|
|
1168
|
+
this.disabled = false;
|
|
1169
|
+
/**
|
|
1170
|
+
* Whether the field is readonly
|
|
1171
|
+
*/
|
|
1172
|
+
this.readonly = false;
|
|
1173
|
+
/**
|
|
1174
|
+
* Autocomplete attribute value
|
|
1175
|
+
*/
|
|
1176
|
+
this.autocomplete = '';
|
|
1177
|
+
/**
|
|
1178
|
+
* Helper text shown below the input
|
|
1179
|
+
*/
|
|
1180
|
+
this.hint = '';
|
|
1181
|
+
this._touched = false;
|
|
1182
|
+
this._dirty = false;
|
|
1183
|
+
this._internals = this.attachInternals();
|
|
1184
|
+
}
|
|
1185
|
+
// Form-associated custom element callbacks
|
|
1186
|
+
get form() {
|
|
1187
|
+
return this._internals.form;
|
|
1188
|
+
}
|
|
1189
|
+
get validity() {
|
|
1190
|
+
return this._internals.validity;
|
|
1191
|
+
}
|
|
1192
|
+
get validationMessage() {
|
|
1193
|
+
return this._internals.validationMessage;
|
|
1194
|
+
}
|
|
1195
|
+
get willValidate() {
|
|
1196
|
+
return this._internals.willValidate;
|
|
1197
|
+
}
|
|
1198
|
+
checkValidity() {
|
|
1199
|
+
return this._internals.checkValidity();
|
|
1200
|
+
}
|
|
1201
|
+
reportValidity() {
|
|
1202
|
+
return this._internals.reportValidity();
|
|
1203
|
+
}
|
|
1204
|
+
formResetCallback() {
|
|
1205
|
+
this.value = '';
|
|
1206
|
+
this._touched = false;
|
|
1207
|
+
this._dirty = false;
|
|
1208
|
+
this._internals.setFormValue('');
|
|
1209
|
+
this._internals.setValidity({});
|
|
1210
|
+
}
|
|
1211
|
+
formStateRestoreCallback(state) {
|
|
1212
|
+
this.value = state;
|
|
1213
|
+
}
|
|
1214
|
+
_handleInput(e) {
|
|
1215
|
+
this.value = e.target.value;
|
|
1216
|
+
this._dirty = true;
|
|
1217
|
+
this._internals.setFormValue(this.value);
|
|
1218
|
+
this._internals.setValidity(this._input.validity, this._input.validationMessage, this._input);
|
|
1219
|
+
}
|
|
1220
|
+
_handleChange(e) {
|
|
1221
|
+
this.value = e.target.value;
|
|
1222
|
+
this._internals.setFormValue(this.value);
|
|
1223
|
+
}
|
|
1224
|
+
_handleBlur() {
|
|
1225
|
+
this._touched = true;
|
|
1226
|
+
this._internals.setValidity(this._input.validity, this._input.validationMessage, this._input);
|
|
1227
|
+
}
|
|
1228
|
+
render() {
|
|
1229
|
+
let validationMessage = '';
|
|
1230
|
+
if (this._touched && this._input && !this._input.validity.valid) {
|
|
1231
|
+
validationMessage = this._input.validationMessage;
|
|
1232
|
+
}
|
|
1233
|
+
return x `
|
|
1234
|
+
<div class="wrapper">
|
|
1235
|
+
${this.label
|
|
1236
|
+
? x `
|
|
1237
|
+
<label for="input">
|
|
1238
|
+
${this.label}
|
|
1239
|
+
${this.required ? x `<span class="required" aria-hidden="true">*</span>` : ''}
|
|
1240
|
+
</label>
|
|
1241
|
+
`
|
|
1242
|
+
: ''}
|
|
1243
|
+
<input
|
|
1244
|
+
id="input"
|
|
1245
|
+
type=${this.type}
|
|
1246
|
+
name=${this.name}
|
|
1247
|
+
.value=${l(this.value)}
|
|
1248
|
+
placeholder=${this.placeholder}
|
|
1249
|
+
?required=${this.required}
|
|
1250
|
+
?disabled=${this.disabled}
|
|
1251
|
+
?readonly=${this.readonly}
|
|
1252
|
+
minlength=${this.minlength ?? ''}
|
|
1253
|
+
maxlength=${this.maxlength ?? ''}
|
|
1254
|
+
pattern=${this.pattern ?? ''}
|
|
1255
|
+
autocomplete=${this.autocomplete}
|
|
1256
|
+
@input=${this._handleInput}
|
|
1257
|
+
@change=${this._handleChange}
|
|
1258
|
+
@blur=${this._handleBlur}
|
|
1259
|
+
/>
|
|
1260
|
+
${validationMessage
|
|
1261
|
+
? x `<div class="validation-message">${validationMessage}</div>`
|
|
1262
|
+
: this.hint
|
|
1263
|
+
? x `<div class="hint">${this.hint}</div>`
|
|
1264
|
+
: ''}
|
|
1265
|
+
</div>
|
|
1266
|
+
`;
|
|
1267
|
+
}
|
|
1268
|
+
// Public methods for programmatic control
|
|
1269
|
+
focus() {
|
|
1270
|
+
this._input?.focus();
|
|
1271
|
+
}
|
|
1272
|
+
blur() {
|
|
1273
|
+
this._input?.blur();
|
|
1274
|
+
}
|
|
1275
|
+
select() {
|
|
1276
|
+
this._input?.select();
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
KRTextField.styles = i$4 `
|
|
1280
|
+
:host {
|
|
1281
|
+
display: block;
|
|
1282
|
+
font-family: inherit;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
.wrapper {
|
|
1286
|
+
display: flex;
|
|
1287
|
+
flex-direction: column;
|
|
1288
|
+
gap: 0.25rem;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
label {
|
|
1292
|
+
font-size: 13px;
|
|
1293
|
+
font-weight: 500;
|
|
1294
|
+
color: var(--kr-text-field-label-color, #374151);
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
.required {
|
|
1298
|
+
color: var(--kr-text-field-required-color, #ef4444);
|
|
1299
|
+
margin-left: 0.125rem;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
input {
|
|
1303
|
+
font-family: inherit;
|
|
1304
|
+
font-size: 14px;
|
|
1305
|
+
padding: 0.5rem 0.75rem;
|
|
1306
|
+
border: 1px solid var(--kr-text-field-border-color, #d1d5db);
|
|
1307
|
+
border-radius: 4px;
|
|
1308
|
+
background-color: var(--kr-text-field-bg, #fff);
|
|
1309
|
+
color: var(--kr-text-field-color, #111827);
|
|
1310
|
+
transition: border-color 0.2s, box-shadow 0.2s;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
input:focus {
|
|
1314
|
+
outline: none;
|
|
1315
|
+
border-color: var(--kr-text-field-focus-border-color, #2563eb);
|
|
1316
|
+
box-shadow: 0 0 0 3px var(--kr-text-field-focus-ring-color, rgba(37, 99, 235, 0.1));
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
input:disabled {
|
|
1320
|
+
background-color: var(--kr-text-field-disabled-bg, #f3f4f6);
|
|
1321
|
+
color: var(--kr-text-field-disabled-color, #9ca3af);
|
|
1322
|
+
cursor: not-allowed;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
input::placeholder {
|
|
1326
|
+
color: var(--kr-text-field-placeholder-color, #9ca3af);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
:host(:invalid) input {
|
|
1330
|
+
border-color: var(--kr-text-field-error-border-color, #ef4444);
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
:host(:invalid) input:focus {
|
|
1334
|
+
box-shadow: 0 0 0 3px var(--kr-text-field-error-ring-color, rgba(239, 68, 68, 0.1));
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
.validation-message {
|
|
1338
|
+
font-size: 0.75rem;
|
|
1339
|
+
color: var(--kr-text-field-error-color, #ef4444);
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
.hint {
|
|
1343
|
+
font-size: 0.75rem;
|
|
1344
|
+
color: var(--kr-text-field-helper-color, #6b7280);
|
|
1345
|
+
}
|
|
1346
|
+
`;
|
|
1347
|
+
// Enable form association
|
|
1348
|
+
KRTextField.formAssociated = true;
|
|
1349
|
+
__decorate([
|
|
1350
|
+
n({ type: String })
|
|
1351
|
+
], KRTextField.prototype, "label", void 0);
|
|
1352
|
+
__decorate([
|
|
1353
|
+
n({ type: String })
|
|
1354
|
+
], KRTextField.prototype, "name", void 0);
|
|
1355
|
+
__decorate([
|
|
1356
|
+
n({ type: String })
|
|
1357
|
+
], KRTextField.prototype, "value", void 0);
|
|
1358
|
+
__decorate([
|
|
1359
|
+
n({ type: String })
|
|
1360
|
+
], KRTextField.prototype, "placeholder", void 0);
|
|
1361
|
+
__decorate([
|
|
1362
|
+
n({ type: String })
|
|
1363
|
+
], KRTextField.prototype, "type", void 0);
|
|
1364
|
+
__decorate([
|
|
1365
|
+
n({ type: Boolean })
|
|
1366
|
+
], KRTextField.prototype, "required", void 0);
|
|
1367
|
+
__decorate([
|
|
1368
|
+
n({ type: Boolean })
|
|
1369
|
+
], KRTextField.prototype, "disabled", void 0);
|
|
1370
|
+
__decorate([
|
|
1371
|
+
n({ type: Boolean })
|
|
1372
|
+
], KRTextField.prototype, "readonly", void 0);
|
|
1373
|
+
__decorate([
|
|
1374
|
+
n({ type: Number })
|
|
1375
|
+
], KRTextField.prototype, "minlength", void 0);
|
|
1376
|
+
__decorate([
|
|
1377
|
+
n({ type: Number })
|
|
1378
|
+
], KRTextField.prototype, "maxlength", void 0);
|
|
1379
|
+
__decorate([
|
|
1380
|
+
n({ type: String })
|
|
1381
|
+
], KRTextField.prototype, "pattern", void 0);
|
|
1382
|
+
__decorate([
|
|
1383
|
+
n({ type: String })
|
|
1384
|
+
], KRTextField.prototype, "autocomplete", void 0);
|
|
1385
|
+
__decorate([
|
|
1386
|
+
n({ type: String })
|
|
1387
|
+
], KRTextField.prototype, "hint", void 0);
|
|
1388
|
+
__decorate([
|
|
1389
|
+
e$3('input')
|
|
1390
|
+
], KRTextField.prototype, "_input", void 0);
|
|
1391
|
+
__decorate([
|
|
1392
|
+
r()
|
|
1393
|
+
], KRTextField.prototype, "_touched", void 0);
|
|
1394
|
+
__decorate([
|
|
1395
|
+
r()
|
|
1396
|
+
], KRTextField.prototype, "_dirty", void 0);
|
|
1397
|
+
KRTextField = __decorate([
|
|
1398
|
+
t$1('kr-text-field')
|
|
1399
|
+
], KRTextField);
|
|
1400
|
+
|
|
1401
|
+
export { DialogRef, KRAccordion, KRAlert, KRButton, KRCodeDemo, KRContextMenu, KRDialog, KRTextField };
|
|
1402
|
+
//# sourceMappingURL=krubble.bundled.js.map
|