blue-web 1.18.0 → 1.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/odometer.bundle.js +1 -0
- package/dist/js/odometer.d.ts +17 -0
- package/dist/js/odometer.js +97 -0
- package/dist/js/searchbox.bundle.js +2 -0
- package/dist/js/searchbox.bundle.js.LICENSE.txt +11 -0
- package/dist/js/searchbox.d.ts +16 -0
- package/dist/js/searchbox.js +158 -0
- package/dist/js/select-list.bundle.js +1 -1
- package/dist/js/select-list.js +0 -1
- package/dist/merged.scss +1 -1
- package/dist/style.css +1 -1
- package/dist/style.min.css +1 -1
- package/dist/style.scss +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{"use strict";var t={};t.d=(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);class e extends HTMLElement{static get observedAttributes(){return["value","max"]}constructor(){var t,e,n;super(),t=this,n=!1,(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e="_initialized"))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,this.attachShadow({mode:"open"})}connectedCallback(){this._initialized||(this.setup(),this._initialized=!0,this.updateValue(this.value))}setup(){const t=document.createElement("style");t.textContent="\n :host {\n display: inline-flex;\n min-width: 1em;\n height: 1em;\n text-align: center;\n overflow: hidden;\n line-height: 1em;\n transition: background-color 0.3s;\n }\n .numbers {\n display: flex;\n flex-direction: column;\n transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);\n }\n .numbers span {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 1em;\n }";const e=document.createElement("span");e.classList.add("numbers"),e.setAttribute("aria-hidden","true"),this.shadowRoot.append(t,e),this.wrapper=e,this.rebuildNumbers()}rebuildNumbers(){this.wrapper.innerHTML="";const t=this.max;for(let e=0;e<=t;e++){const t=document.createElement("span");t.textContent=String(e),this.wrapper.appendChild(t)}const e=document.createElement("span");e.textContent="".concat(t,"+"),this.wrapper.appendChild(e),this._initialized&&this.updateValue(this.value)}attributeChangedCallback(t,e,n){n!==e&&this._initialized&&("value"===t?this.updateValue(parseInt(null!=n?n:"0",10)):"max"===t&&this.rebuildNumbers())}updateValue(t){const e=this.max,n=t>e?e+1:Math.max(0,t),i=this.wrapper.getBoundingClientRect().height||16;this.wrapper.style.transform="translateY(-".concat(n*i,"px)");const a=t>e?"".concat(e,"+"):"".concat(t);this.setAttribute("aria-label",a)}set value(t){this.value!==t&&(this.setAttribute("value",String(t)),this._initialized&&(this.updateValue(t),this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0,composed:!0}))))}get value(){return parseInt(this.getAttribute("value")||"0",10)||0}set max(t){this.setAttribute("max",String(t))}get max(){return parseInt(this.getAttribute("max")||"9",10)||9}}customElements.get("bl-odometer")||customElements.define("bl-odometer",e)})();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare class Odometer extends HTMLElement {
|
|
2
|
+
private wrapper;
|
|
3
|
+
private _initialized;
|
|
4
|
+
static get observedAttributes(): string[];
|
|
5
|
+
constructor();
|
|
6
|
+
connectedCallback(): void;
|
|
7
|
+
private setup;
|
|
8
|
+
private rebuildNumbers;
|
|
9
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
10
|
+
private updateValue;
|
|
11
|
+
set value(value: number);
|
|
12
|
+
get value(): number;
|
|
13
|
+
set max(value: number);
|
|
14
|
+
get max(): number;
|
|
15
|
+
}
|
|
16
|
+
export { Odometer };
|
|
17
|
+
export default Odometer;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
class Odometer extends HTMLElement {
|
|
5
|
+
static get observedAttributes() {
|
|
6
|
+
return ["value", "max"];
|
|
7
|
+
}
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
_defineProperty(this, "_initialized", false);
|
|
11
|
+
this.attachShadow({
|
|
12
|
+
mode: "open"
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
if (!this._initialized) {
|
|
17
|
+
this.setup();
|
|
18
|
+
this._initialized = true;
|
|
19
|
+
// Initialen Wert anwenden (Markup-Attribut oder default)
|
|
20
|
+
this.updateValue(this.value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
setup() {
|
|
24
|
+
const style = document.createElement("style");
|
|
25
|
+
style.textContent = /* CSS */"\n :host {\n display: inline-flex;\n min-width: 1em;\n height: 1em;\n text-align: center;\n overflow: hidden;\n line-height: 1em;\n transition: background-color 0.3s;\n }\n .numbers {\n display: flex;\n flex-direction: column;\n transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);\n }\n .numbers span {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 1em;\n }";
|
|
26
|
+
const wrapper = document.createElement("span");
|
|
27
|
+
wrapper.classList.add("numbers");
|
|
28
|
+
wrapper.setAttribute("aria-hidden", "true");
|
|
29
|
+
this.shadowRoot.append(style, wrapper);
|
|
30
|
+
this.wrapper = wrapper;
|
|
31
|
+
this.rebuildNumbers();
|
|
32
|
+
}
|
|
33
|
+
rebuildNumbers() {
|
|
34
|
+
this.wrapper.innerHTML = "";
|
|
35
|
+
const max = this.max;
|
|
36
|
+
for (let i = 0; i <= max; i++) {
|
|
37
|
+
const s = document.createElement("span");
|
|
38
|
+
s.textContent = String(i);
|
|
39
|
+
this.wrapper.appendChild(s);
|
|
40
|
+
}
|
|
41
|
+
const plus = document.createElement("span");
|
|
42
|
+
plus.textContent = "".concat(max, "+");
|
|
43
|
+
this.wrapper.appendChild(plus);
|
|
44
|
+
|
|
45
|
+
// Aktuellen Wert neu anwenden
|
|
46
|
+
if (this._initialized) {
|
|
47
|
+
this.updateValue(this.value);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
51
|
+
if (newValue !== oldValue && this._initialized) {
|
|
52
|
+
if (name === "value") {
|
|
53
|
+
this.updateValue(parseInt(newValue !== null && newValue !== void 0 ? newValue : "0", 10));
|
|
54
|
+
} else if (name === "max") {
|
|
55
|
+
this.rebuildNumbers();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
updateValue(value) {
|
|
60
|
+
const max = this.max;
|
|
61
|
+
const index = value > max ? max + 1 : Math.max(0, value);
|
|
62
|
+
const height = this.wrapper.getBoundingClientRect().height || 16;
|
|
63
|
+
this.wrapper.style.transform = "translateY(-".concat(index * height, "px)");
|
|
64
|
+
const displayValue = value > max ? "".concat(max, "+") : "".concat(value);
|
|
65
|
+
this.setAttribute("aria-label", displayValue);
|
|
66
|
+
}
|
|
67
|
+
set value(value) {
|
|
68
|
+
const current = this.value;
|
|
69
|
+
if (current !== value) {
|
|
70
|
+
this.setAttribute("value", String(value));
|
|
71
|
+
if (this._initialized) {
|
|
72
|
+
this.updateValue(value);
|
|
73
|
+
this.dispatchEvent(new CustomEvent("change", {
|
|
74
|
+
detail: {
|
|
75
|
+
value
|
|
76
|
+
},
|
|
77
|
+
bubbles: true,
|
|
78
|
+
composed: true
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
get value() {
|
|
84
|
+
return parseInt(this.getAttribute("value") || "0", 10) || 0;
|
|
85
|
+
}
|
|
86
|
+
set max(value) {
|
|
87
|
+
this.setAttribute("max", String(value));
|
|
88
|
+
}
|
|
89
|
+
get max() {
|
|
90
|
+
return parseInt(this.getAttribute("max") || "9", 10) || 9;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (!customElements.get("bl-odometer")) {
|
|
94
|
+
customElements.define("bl-odometer", Odometer);
|
|
95
|
+
}
|
|
96
|
+
export { Odometer };
|
|
97
|
+
export default Odometer;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see searchbox.bundle.js.LICENSE.txt */
|
|
2
|
+
(()=>{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),r=new WeakMap;class s{constructor(t,e,r){if(this._$cssResult$=!0,r!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=r.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&r.set(i,t))}return t}toString(){return this.cssText}}const n=(i,r)=>{if(e)i.adoptedStyleSheets=r.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const e of r){const r=document.createElement("style"),s=t.litNonce;void 0!==s&&r.setAttribute("nonce",s),r.textContent=e.cssText,i.appendChild(r)}},o=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new s("string"==typeof t?t:t+"",void 0,i))(e)})(t):t,{is:a,defineProperty:l,getOwnPropertyDescriptor:c,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:p}=Object,u=globalThis,f=u.trustedTypes,m=f?f.emptyScript:"",y=u.reactiveElementPolyfillSupport,v=(t,e)=>t,$={toAttribute(t,e){switch(e){case Boolean:t=t?m:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){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}},g=(t,e)=>!a(t,e),_={attribute:!0,type:String,converter:$,reflect:!1,useDefault:!1,hasChanged:g};Symbol.metadata??=Symbol("metadata"),u.litPropertyMetadata??=new WeakMap;class A 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,e=_){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(t,i,e);void 0!==r&&l(this.prototype,t,r)}}static getPropertyDescriptor(t,e,i){const{get:r,set:s}=c(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:r,set(e){const n=r?.call(this);s?.call(this,e),this.requestUpdate(t,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??_}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=p(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(o(t))}else void 0!==t&&e.push(o(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,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,e=this.constructor.elementProperties;for(const i of e.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 n(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){const i=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,i);if(void 0!==r&&!0===i.reflect){const s=(void 0!==i.converter?.toAttribute?i.converter:$).toAttribute(e,i.type);this._$Em=t,null==s?this.removeAttribute(r):this.setAttribute(r,s),this._$Em=null}}_$AK(t,e){const i=this.constructor,r=i._$Eh.get(t);if(void 0!==r&&this._$Em!==r){const t=i.getPropertyOptions(r),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:$;this._$Em=r;const n=s.fromAttribute(e,t.type);this[r]=n??this._$Ej?.get(r)??n,this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){const r=this.constructor,s=this[t];if(i??=r.getPropertyOptions(t),!((i.hasChanged??g)(s,e)||i.useDefault&&i.reflect&&s===this._$Ej?.get(t)&&!this.hasAttribute(r._$Eu(t,i))))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:r,wrapped:s},n){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,n??e??this[t]),!0!==s||void 0!==n)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),!0===r&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;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,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t){const{wrapped:t}=i,r=this[e];!0!==t||this._$AL.has(e)||void 0===r||this.C(e,void 0,i,r)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}}A.elementStyles=[],A.shadowRootOptions={mode:"open"},A[v("elementProperties")]=new Map,A[v("finalized")]=new Map,y?.({ReactiveElement:A}),(u.reactiveElementVersions??=[]).push("2.1.1");const b=globalThis,E=b.trustedTypes,w=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,k="$lit$",x=`lit$${Math.random().toFixed(9).slice(2)}$`,S="?"+x,C=`<${S}>`,P=document,O=()=>P.createComment(""),T=t=>null===t||"object"!=typeof t&&"function"!=typeof t,U=Array.isArray,D="[ \t\n\f\r]",M=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,R=/-->/g,H=/>/g,I=RegExp(`>|${D}(?:([^\\s"'>=/]+)(${D}*=${D}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),N=/'/g,z=/"/g,j=/^(?:script|style|textarea|title)$/i,L=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),q=L(1),B=(L(2),L(3),Symbol.for("lit-noChange")),F=Symbol.for("lit-nothing"),W=new WeakMap,V=P.createTreeWalker(P,129);function K(t,e){if(!U(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==w?w.createHTML(e):e}const J=(t,e)=>{const i=t.length-1,r=[];let s,n=2===e?"<svg>":3===e?"<math>":"",o=M;for(let e=0;e<i;e++){const i=t[e];let a,l,c=-1,h=0;for(;h<i.length&&(o.lastIndex=h,l=o.exec(i),null!==l);)h=o.lastIndex,o===M?"!--"===l[1]?o=R:void 0!==l[1]?o=H:void 0!==l[2]?(j.test(l[2])&&(s=RegExp("</"+l[2],"g")),o=I):void 0!==l[3]&&(o=I):o===I?">"===l[0]?(o=s??M,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?I:'"'===l[3]?z:N):o===z||o===N?o=I:o===R||o===H?o=M:(o=I,s=void 0);const d=o===I&&t[e+1].startsWith("/>")?" ":"";n+=o===M?i+C:c>=0?(r.push(a),i.slice(0,c)+k+i.slice(c)+x+d):i+x+(-2===c?e:d)}return[K(t,n+(t[i]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),r]};class Z{constructor({strings:t,_$litType$:e},i){let r;this.parts=[];let s=0,n=0;const o=t.length-1,a=this.parts,[l,c]=J(t,e);if(this.el=Z.createElement(l,i),V.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=V.nextNode())&&a.length<o;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(k)){const e=c[n++],i=r.getAttribute(t).split(x),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:s,name:o[2],strings:i,ctor:"."===o[1]?tt:"?"===o[1]?et:"@"===o[1]?it:Y}),r.removeAttribute(t)}else t.startsWith(x)&&(a.push({type:6,index:s}),r.removeAttribute(t));if(j.test(r.tagName)){const t=r.textContent.split(x),e=t.length-1;if(e>0){r.textContent=E?E.emptyScript:"";for(let i=0;i<e;i++)r.append(t[i],O()),V.nextNode(),a.push({type:2,index:++s});r.append(t[e],O())}}}else if(8===r.nodeType)if(r.data===S)a.push({type:2,index:s});else{let t=-1;for(;-1!==(t=r.data.indexOf(x,t+1));)a.push({type:7,index:s}),t+=x.length-1}s++}}static createElement(t,e){const i=P.createElement("template");return i.innerHTML=t,i}}function G(t,e,i=t,r){if(e===B)return e;let s=void 0!==r?i._$Co?.[r]:i._$Cl;const n=T(e)?void 0:e._$litDirective$;return s?.constructor!==n&&(s?._$AO?.(!1),void 0===n?s=void 0:(s=new n(t),s._$AT(t,i,r)),void 0!==r?(i._$Co??=[])[r]=s:i._$Cl=s),void 0!==s&&(e=G(t,s._$AS(t,e.values),s,r)),e}class Q{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,r=(t?.creationScope??P).importNode(e,!0);V.currentNode=r;let s=V.nextNode(),n=0,o=0,a=i[0];for(;void 0!==a;){if(n===a.index){let e;2===a.type?e=new X(s,s.nextSibling,this,t):1===a.type?e=new a.ctor(s,a.name,a.strings,this,t):6===a.type&&(e=new rt(s,this,t)),this._$AV.push(e),a=i[++o]}n!==a?.index&&(s=V.nextNode(),n++)}return V.currentNode=P,r}p(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,i,r){this.type=2,this._$AH=F,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=G(this,t,e),T(t)?t===F||null==t||""===t?(this._$AH!==F&&this._$AR(),this._$AH=F):t!==this._$AH&&t!==B&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>U(t)||"function"==typeof t?.[Symbol.iterator])(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!==F&&T(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:i}=t,r="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=Z.createElement(K(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===r)this._$AH.p(e);else{const t=new Q(r,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=W.get(t.strings);return void 0===e&&W.set(t.strings,e=new Z(t)),e}k(t){U(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,r=0;for(const s of t)r===e.length?e.push(i=new X(this.O(O()),this.O(O()),this,this.options)):i=e[r],i._$AI(s),r++;r<e.length&&(this._$AR(i&&i._$AB.nextSibling,r),e.length=r)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class Y{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,r,s){this.type=1,this._$AH=F,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=s,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=F}_$AI(t,e=this,i,r){const s=this.strings;let n=!1;if(void 0===s)t=G(this,t,e,0),n=!T(t)||t!==this._$AH&&t!==B,n&&(this._$AH=t);else{const r=t;let o,a;for(t=s[0],o=0;o<s.length-1;o++)a=G(this,r[i+o],e,o),a===B&&(a=this._$AH[o]),n||=!T(a)||a!==this._$AH[o],a===F?t=F:t!==F&&(t+=(a??"")+s[o+1]),this._$AH[o]=a}n&&!r&&this.j(t)}j(t){t===F?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class tt extends Y{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===F?void 0:t}}class et extends Y{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==F)}}class it extends Y{constructor(t,e,i,r,s){super(t,e,i,r,s),this.type=5}_$AI(t,e=this){if((t=G(this,t,e,0)??F)===B)return;const i=this._$AH,r=t===F&&i!==F||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,s=t!==F&&(i===F||r);r&&this.element.removeEventListener(this.name,this,i),s&&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 rt{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){G(this,t)}}const st=b.litHtmlPolyfillSupport;st?.(Z,X),(b.litHtmlVersions??=[]).push("3.3.1");const nt=globalThis;class ot extends A{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 e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,i)=>{const r=i?.renderBefore??e;let s=r._$litPart$;if(void 0===s){const t=i?.renderBefore??null;r._$litPart$=s=new X(e.insertBefore(O(),t),t,void 0,i??{})}return s._$AI(t),s})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return B}}ot._$litElement$=!0,ot.finalized=!0,nt.litElementHydrateSupport?.({LitElement:ot});const at=nt.litElementPolyfillSupport;at?.({LitElement:ot}),(nt.litElementVersions??=[]).push("4.2.1");const lt={attribute:!0,type:String,converter:$,reflect:!1,hasChanged:g},ct=(t=lt,e,i)=>{const{kind:r,metadata:s}=i;let n=globalThis.litPropertyMetadata.get(s);if(void 0===n&&globalThis.litPropertyMetadata.set(s,n=new Map),"setter"===r&&((t=Object.create(t)).wrapped=!0),n.set(i.name,t),"accessor"===r){const{name:r}=i;return{set(i){const s=e.get.call(this);e.set.call(this,i),this.requestUpdate(r,s,t)},init(e){return void 0!==e&&this.C(r,void 0,t,e),e}}}if("setter"===r){const{name:r}=i;return function(i){const s=this[r];e.call(this,i),this.requestUpdate(r,s,t)}}throw Error("Unsupported decorator location: "+r)};function ht(t){return(e,i)=>"object"==typeof i?ct(t,e,i):((t,e,i)=>{const r=e.hasOwnProperty(i);return e.constructor.createProperty(i,t),r?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}var pt,ut,ft,mt;function yt(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function vt(){vt=function(){return t};var t={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(t,e){["method","field"].forEach(function(i){e.forEach(function(e){e.kind===i&&"own"===e.placement&&this.defineClassElement(t,e)},this)},this)},initializeClassElements:function(t,e){var i=t.prototype;["method","field"].forEach(function(r){e.forEach(function(e){var s=e.placement;if(e.kind===r&&("static"===s||"prototype"===s)){var n="static"===s?t:i;this.defineClassElement(n,e)}},this)},this)},defineClassElement:function(t,e){var i=e.descriptor;if("field"===e.kind){var r=e.initializer;i={enumerable:i.enumerable,writable:i.writable,configurable:i.configurable,value:void 0===r?void 0:r.call(t)}}Object.defineProperty(t,e.key,i)},decorateClass:function(t,e){var i=[],r=[],s={static:[],prototype:[],own:[]};if(t.forEach(function(t){this.addElementPlacement(t,s)},this),t.forEach(function(t){if(!_t(t))return i.push(t);var e=this.decorateElement(t,s);i.push(e.element),i.push.apply(i,e.extras),r.push.apply(r,e.finishers)},this),!e)return{elements:i,finishers:r};var n=this.decorateConstructor(i,e);return r.push.apply(r,n.finishers),n.finishers=r,n},addElementPlacement:function(t,e,i){var r=e[t.placement];if(!i&&-1!==r.indexOf(t.key))throw new TypeError("Duplicated element ("+t.key+")");r.push(t.key)},decorateElement:function(t,e){for(var i=[],r=[],s=t.decorators,n=s.length-1;n>=0;n--){var o=e[t.placement];o.splice(o.indexOf(t.key),1);var a=this.fromElementDescriptor(t),l=this.toElementFinisherExtras((0,s[n])(a)||a);t=l.element,this.addElementPlacement(t,e),l.finisher&&r.push(l.finisher);var c=l.extras;if(c){for(var h=0;h<c.length;h++)this.addElementPlacement(c[h],e);i.push.apply(i,c)}}return{element:t,finishers:r,extras:i}},decorateConstructor:function(t,e){for(var i=[],r=e.length-1;r>=0;r--){var s=this.fromClassDescriptor(t),n=this.toClassDescriptor((0,e[r])(s)||s);if(void 0!==n.finisher&&i.push(n.finisher),void 0!==n.elements){t=n.elements;for(var o=0;o<t.length-1;o++)for(var a=o+1;a<t.length;a++)if(t[o].key===t[a].key&&t[o].placement===t[a].placement)throw new TypeError("Duplicated element ("+t[o].key+")")}}return{elements:t,finishers:i}},fromElementDescriptor:function(t){var e={kind:t.kind,key:t.key,placement:t.placement,descriptor:t.descriptor};return Object.defineProperty(e,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===t.kind&&(e.initializer=t.initializer),e},toElementDescriptors:function(t){if(void 0!==t)return(e=t,function(t){if(Array.isArray(t))return t}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return wt(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?wt(t,e):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map(function(t){var e=this.toElementDescriptor(t);return this.disallowProperty(t,"finisher","An element descriptor"),this.disallowProperty(t,"extras","An element descriptor"),e},this);var e},toElementDescriptor:function(t){var e=t.kind+"";if("method"!==e&&"field"!==e)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+e+'"');var i=Et(t.key),r=t.placement+"";if("static"!==r&&"prototype"!==r&&"own"!==r)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+r+'"');var s=t.descriptor;this.disallowProperty(t,"elements","An element descriptor");var n={kind:e,key:i,placement:r,descriptor:Object.assign({},s)};return"field"!==e?this.disallowProperty(t,"initializer","A method descriptor"):(this.disallowProperty(s,"get","The property descriptor of a field descriptor"),this.disallowProperty(s,"set","The property descriptor of a field descriptor"),this.disallowProperty(s,"value","The property descriptor of a field descriptor"),n.initializer=t.initializer),n},toElementFinisherExtras:function(t){return{element:this.toElementDescriptor(t),finisher:bt(t,"finisher"),extras:this.toElementDescriptors(t.extras)}},fromClassDescriptor:function(t){var e={kind:"class",elements:t.map(this.fromElementDescriptor,this)};return Object.defineProperty(e,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),e},toClassDescriptor:function(t){var e=t.kind+"";if("class"!==e)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+e+'"');this.disallowProperty(t,"key","A class descriptor"),this.disallowProperty(t,"placement","A class descriptor"),this.disallowProperty(t,"descriptor","A class descriptor"),this.disallowProperty(t,"initializer","A class descriptor"),this.disallowProperty(t,"extras","A class descriptor");var i=bt(t,"finisher");return{elements:this.toElementDescriptors(t.elements),finisher:i}},runClassFinishers:function(t,e){for(var i=0;i<e.length;i++){var r=(0,e[i])(t);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");t=r}}return t},disallowProperty:function(t,e,i){if(void 0!==t[e])throw new TypeError(i+" can't have a ."+e+" property.")}};return t}function $t(t){var e,i=Et(t.key);"method"===t.kind?e={value:t.value,writable:!0,configurable:!0,enumerable:!1}:"get"===t.kind?e={get:t.value,configurable:!0,enumerable:!1}:"set"===t.kind?e={set:t.value,configurable:!0,enumerable:!1}:"field"===t.kind&&(e={configurable:!0,writable:!0,enumerable:!0});var r={kind:"field"===t.kind?"field":"method",key:i,placement:t.static?"static":"field"===t.kind?"own":"prototype",descriptor:e};return t.decorators&&(r.decorators=t.decorators),"field"===t.kind&&(r.initializer=t.value),r}function gt(t,e){void 0!==t.descriptor.get?e.descriptor.get=t.descriptor.get:e.descriptor.set=t.descriptor.set}function _t(t){return t.decorators&&t.decorators.length}function At(t){return void 0!==t&&!(void 0===t.value&&void 0===t.writable)}function bt(t,e){var i=t[e];if(void 0!==i&&"function"!=typeof i)throw new TypeError("Expected '"+e+"' to be a function");return i}function Et(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}function wt(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}!function(t,e,i){var r=vt(),s=e(function(t){r.initializeInstanceElements(t,n.elements)},i),n=r.decorateClass(function(t){for(var e=[],i=function(t){return"method"===t.kind&&t.key===n.key&&t.placement===n.placement},r=0;r<t.length;r++){var s,n=t[r];if("method"===n.kind&&(s=e.find(i)))if(At(n.descriptor)||At(s.descriptor)){if(_t(n)||_t(s))throw new ReferenceError("Duplicated methods ("+n.key+") can't be decorated.");s.descriptor=n.descriptor}else{if(_t(n)){if(_t(s))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+n.key+").");s.decorators=n.decorators}gt(n,s)}else e.push(n)}return e}(s.d.map($t)),t);r.initializeClassElements(s.F,n.elements),r.runClassFinishers(s.F,n.finishers)}([(t=>(e,i)=>{void 0!==i?i.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)})("blue-searchbox")],function(t,e){return{F:class extends e{constructor(){super(...arguments),t(this)}},d:[{kind:"field",static:!0,key:"styles",value:()=>((t,...e)=>{const r=1===t.length?t[0]:e.reduce((e,i,r)=>e+(t=>{if(!0===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.")})(i)+t[r+1],t[0]);return new s(r,t,i)})(pt||(pt=yt(['\n :host {\n display: block;\n position: relative;\n max-width: 400px;\n font-family: system-ui, sans-serif;\n }\n\n .search-container {\n position: relative;\n }\n\n input {\n width: 100%;\n padding: 0.5rem 0.75rem;\n border: 1px solid #ccc;\n border-radius: 0.375rem;\n font-size: 1rem;\n }\n\n .results {\n background: white;\n border: 1px solid #ccc;\n border-radius: 0.375rem;\n margin-top: 0.25rem;\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0.5rem;\n padding: 0.5rem;\n box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);\n z-index: 10;\n }\n\n .group {\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n }\n\n .group-title {\n font-weight: 600;\n font-size: 0.875rem;\n margin-bottom: 0.25rem;\n }\n\n [role="option"] {\n padding: 0.25rem 0.5rem;\n border-radius: 0.25rem;\n cursor: pointer;\n }\n\n [role="option"].active,\n [role="option"]:hover {\n background: #e8f0fe;\n outline: none;\n }\n '])))},{kind:"field",decorators:[ht({type:Array})],key:"people",value:()=>["Alice","Bob","Charlie"]},{kind:"field",decorators:[ht({type:Array})],key:"documents",value:()=>["Spec.docx","Roadmap.pdf","Meeting Notes.txt"]},{kind:"field",decorators:[dt()],key:"query",value:()=>""},{kind:"field",decorators:[dt()],key:"activeIndex",value:()=>-1},{kind:"field",decorators:[dt()],key:"expanded",value:()=>!1},{kind:"field",decorators:[dt()],key:"results",value:()=>[]},{kind:"method",key:"render",value:function(){return q(ut||(ut=yt(['\n <div\n class="search-container"\n role="combobox"\n aria-haspopup="listbox"\n aria-expanded=','\n aria-owns="results-list"\n >\n <input\n type="text"\n placeholder="Search..."\n .value=',"\n @input=","\n @keydown=",'\n aria-controls="results-list"\n aria-activedescendant=','\n aria-autocomplete="list"\n />\n\n ',"\n </div>\n "])),this.expanded,this.query,this.onInput,this.onKeyDown,this.activeIndex>=0?"opt-"+this.activeIndex:"",this.expanded?q(ft||(ft=yt(['\n <div class="results" id="results-list" role="listbox">\n <div class="group">\n <div class="group-title">People</div>\n ','\n </div>\n <div class="group">\n <div class="group-title">Documents</div>\n ',"\n </div>\n </div>\n "])),this.people.filter(t=>t.toLowerCase().includes(this.query.toLowerCase())).map(t=>this.renderOption(t,"People")),this.documents.filter(t=>t.toLowerCase().includes(this.query.toLowerCase())).map(t=>this.renderOption(t,"Documents"))):null)}},{kind:"method",key:"renderOption",value:function(t,e){const i=this.results.findIndex(i=>i.label===t&&i.group===e),r=i===this.activeIndex;return q(mt||(mt=yt(['\n <div\n role="option"\n id="opt-','"\n class=',"\n @click=","\n >\n ","\n </div>\n "])),i,r?"active":"",()=>this.selectOption(i),t)}},{kind:"method",key:"onInput",value:function(t){const e=t.target.value;this.query=e,this.updateResults(),this.expanded=this.results.length>0,this.activeIndex=-1}},{kind:"method",key:"updateResults",value:function(){const t=this.query.toLowerCase();this.results=[...this.people.filter(e=>e.toLowerCase().includes(t)).map(t=>({group:"People",label:t})),...this.documents.filter(e=>e.toLowerCase().includes(t)).map(t=>({group:"Documents",label:t}))]}},{kind:"method",key:"onKeyDown",value:function(t){if(!this.expanded&&"ArrowDown"===t.key)return this.expanded=!0,void this.updateResults();"ArrowDown"===t.key?(t.preventDefault(),this.activeIndex=(this.activeIndex+1)%this.results.length,this.requestUpdate()):"ArrowUp"===t.key?(t.preventDefault(),this.activeIndex=(this.activeIndex-1+this.results.length)%this.results.length,this.requestUpdate()):"Enter"===t.key&&this.activeIndex>=0?this.selectOption(this.activeIndex):"Escape"===t.key&&(this.expanded=!1)}},{kind:"method",key:"selectOption",value:function(t){const e=this.results[t];e&&(this.query=e.label,this.expanded=!1,this.activeIndex=-1,this.dispatchEvent(new CustomEvent("select",{detail:e})))}}]}},ot)})();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
export declare class BlueSearchBox extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult;
|
|
4
|
+
people: string[];
|
|
5
|
+
documents: string[];
|
|
6
|
+
private query;
|
|
7
|
+
private activeIndex;
|
|
8
|
+
private expanded;
|
|
9
|
+
private results;
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
private renderOption;
|
|
12
|
+
private onInput;
|
|
13
|
+
private updateResults;
|
|
14
|
+
private onKeyDown;
|
|
15
|
+
private selectOption;
|
|
16
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
2
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
3
|
+
function _decorate(e, r, t, i) { var o = _getDecoratorsApi(); if (i) for (var n = 0; n < i.length; n++) o = i[n](o); var s = r(function (e) { o.initializeInstanceElements(e, a.elements); }, t), a = o.decorateClass(_coalesceClassElements(s.d.map(_createElementDescriptor)), e); return o.initializeClassElements(s.F, a.elements), o.runClassFinishers(s.F, a.finishers); }
|
|
4
|
+
function _getDecoratorsApi() { _getDecoratorsApi = function () { return e; }; var e = { elementsDefinitionOrder: [["method"], ["field"]], initializeInstanceElements: function (e, r) { ["method", "field"].forEach(function (t) { r.forEach(function (r) { r.kind === t && "own" === r.placement && this.defineClassElement(e, r); }, this); }, this); }, initializeClassElements: function (e, r) { var t = e.prototype; ["method", "field"].forEach(function (i) { r.forEach(function (r) { var o = r.placement; if (r.kind === i && ("static" === o || "prototype" === o)) { var n = "static" === o ? e : t; this.defineClassElement(n, r); } }, this); }, this); }, defineClassElement: function (e, r) { var t = r.descriptor; if ("field" === r.kind) { var i = r.initializer; t = { enumerable: t.enumerable, writable: t.writable, configurable: t.configurable, value: void 0 === i ? void 0 : i.call(e) }; } Object.defineProperty(e, r.key, t); }, decorateClass: function (e, r) { var t = [], i = [], o = { static: [], prototype: [], own: [] }; if (e.forEach(function (e) { this.addElementPlacement(e, o); }, this), e.forEach(function (e) { if (!_hasDecorators(e)) return t.push(e); var r = this.decorateElement(e, o); t.push(r.element), t.push.apply(t, r.extras), i.push.apply(i, r.finishers); }, this), !r) return { elements: t, finishers: i }; var n = this.decorateConstructor(t, r); return i.push.apply(i, n.finishers), n.finishers = i, n; }, addElementPlacement: function (e, r, t) { var i = r[e.placement]; if (!t && -1 !== i.indexOf(e.key)) throw new TypeError("Duplicated element (" + e.key + ")"); i.push(e.key); }, decorateElement: function (e, r) { for (var t = [], i = [], o = e.decorators, n = o.length - 1; n >= 0; n--) { var s = r[e.placement]; s.splice(s.indexOf(e.key), 1); var a = this.fromElementDescriptor(e), l = this.toElementFinisherExtras((0, o[n])(a) || a); e = l.element, this.addElementPlacement(e, r), l.finisher && i.push(l.finisher); var c = l.extras; if (c) { for (var p = 0; p < c.length; p++) this.addElementPlacement(c[p], r); t.push.apply(t, c); } } return { element: e, finishers: i, extras: t }; }, decorateConstructor: function (e, r) { for (var t = [], i = r.length - 1; i >= 0; i--) { var o = this.fromClassDescriptor(e), n = this.toClassDescriptor((0, r[i])(o) || o); if (void 0 !== n.finisher && t.push(n.finisher), void 0 !== n.elements) { e = n.elements; for (var s = 0; s < e.length - 1; s++) for (var a = s + 1; a < e.length; a++) if (e[s].key === e[a].key && e[s].placement === e[a].placement) throw new TypeError("Duplicated element (" + e[s].key + ")"); } } return { elements: e, finishers: t }; }, fromElementDescriptor: function (e) { var r = { kind: e.kind, key: e.key, placement: e.placement, descriptor: e.descriptor }; return Object.defineProperty(r, Symbol.toStringTag, { value: "Descriptor", configurable: !0 }), "field" === e.kind && (r.initializer = e.initializer), r; }, toElementDescriptors: function (e) { if (void 0 !== e) return _toArray(e).map(function (e) { var r = this.toElementDescriptor(e); return this.disallowProperty(e, "finisher", "An element descriptor"), this.disallowProperty(e, "extras", "An element descriptor"), r; }, this); }, toElementDescriptor: function (e) { var r = e.kind + ""; if ("method" !== r && "field" !== r) throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "' + r + '"'); var t = _toPropertyKey(e.key), i = e.placement + ""; if ("static" !== i && "prototype" !== i && "own" !== i) throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "' + i + '"'); var o = e.descriptor; this.disallowProperty(e, "elements", "An element descriptor"); var n = { kind: r, key: t, placement: i, descriptor: Object.assign({}, o) }; return "field" !== r ? this.disallowProperty(e, "initializer", "A method descriptor") : (this.disallowProperty(o, "get", "The property descriptor of a field descriptor"), this.disallowProperty(o, "set", "The property descriptor of a field descriptor"), this.disallowProperty(o, "value", "The property descriptor of a field descriptor"), n.initializer = e.initializer), n; }, toElementFinisherExtras: function (e) { return { element: this.toElementDescriptor(e), finisher: _optionalCallableProperty(e, "finisher"), extras: this.toElementDescriptors(e.extras) }; }, fromClassDescriptor: function (e) { var r = { kind: "class", elements: e.map(this.fromElementDescriptor, this) }; return Object.defineProperty(r, Symbol.toStringTag, { value: "Descriptor", configurable: !0 }), r; }, toClassDescriptor: function (e) { var r = e.kind + ""; if ("class" !== r) throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "' + r + '"'); this.disallowProperty(e, "key", "A class descriptor"), this.disallowProperty(e, "placement", "A class descriptor"), this.disallowProperty(e, "descriptor", "A class descriptor"), this.disallowProperty(e, "initializer", "A class descriptor"), this.disallowProperty(e, "extras", "A class descriptor"); var t = _optionalCallableProperty(e, "finisher"); return { elements: this.toElementDescriptors(e.elements), finisher: t }; }, runClassFinishers: function (e, r) { for (var t = 0; t < r.length; t++) { var i = (0, r[t])(e); if (void 0 !== i) { if ("function" != typeof i) throw new TypeError("Finishers must return a constructor."); e = i; } } return e; }, disallowProperty: function (e, r, t) { if (void 0 !== e[r]) throw new TypeError(t + " can't have a ." + r + " property."); } }; return e; }
|
|
5
|
+
function _createElementDescriptor(e) { var r, t = _toPropertyKey(e.key); "method" === e.kind ? r = { value: e.value, writable: !0, configurable: !0, enumerable: !1 } : "get" === e.kind ? r = { get: e.value, configurable: !0, enumerable: !1 } : "set" === e.kind ? r = { set: e.value, configurable: !0, enumerable: !1 } : "field" === e.kind && (r = { configurable: !0, writable: !0, enumerable: !0 }); var i = { kind: "field" === e.kind ? "field" : "method", key: t, placement: e.static ? "static" : "field" === e.kind ? "own" : "prototype", descriptor: r }; return e.decorators && (i.decorators = e.decorators), "field" === e.kind && (i.initializer = e.value), i; }
|
|
6
|
+
function _coalesceGetterSetter(e, r) { void 0 !== e.descriptor.get ? r.descriptor.get = e.descriptor.get : r.descriptor.set = e.descriptor.set; }
|
|
7
|
+
function _coalesceClassElements(e) { for (var r = [], isSameElement = function (e) { return "method" === e.kind && e.key === o.key && e.placement === o.placement; }, t = 0; t < e.length; t++) { var i, o = e[t]; if ("method" === o.kind && (i = r.find(isSameElement))) { if (_isDataDescriptor(o.descriptor) || _isDataDescriptor(i.descriptor)) { if (_hasDecorators(o) || _hasDecorators(i)) throw new ReferenceError("Duplicated methods (" + o.key + ") can't be decorated."); i.descriptor = o.descriptor; } else { if (_hasDecorators(o)) { if (_hasDecorators(i)) throw new ReferenceError("Decorators can't be placed on different accessors with for the same property (" + o.key + ")."); i.decorators = o.decorators; } _coalesceGetterSetter(o, i); } } else r.push(o); } return r; }
|
|
8
|
+
function _hasDecorators(e) { return e.decorators && e.decorators.length; }
|
|
9
|
+
function _isDataDescriptor(e) { return void 0 !== e && !(void 0 === e.value && void 0 === e.writable); }
|
|
10
|
+
function _optionalCallableProperty(e, r) { var t = e[r]; if (void 0 !== t && "function" != typeof t) throw new TypeError("Expected '" + r + "' to be a function"); return t; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
|
|
14
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
16
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
17
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
18
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
19
|
+
import { LitElement, html, css } from "lit";
|
|
20
|
+
import { customElement, state, property } from "lit/decorators.js";
|
|
21
|
+
export let BlueSearchBox = _decorate([customElement("blue-searchbox")], function (_initialize, _LitElement) {
|
|
22
|
+
class BlueSearchBox extends _LitElement {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
_initialize(this);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
F: BlueSearchBox,
|
|
30
|
+
d: [{
|
|
31
|
+
kind: "field",
|
|
32
|
+
static: true,
|
|
33
|
+
key: "styles",
|
|
34
|
+
value() {
|
|
35
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n :host {\n display: block;\n position: relative;\n max-width: 400px;\n font-family: system-ui, sans-serif;\n }\n\n .search-container {\n position: relative;\n }\n\n input {\n width: 100%;\n padding: 0.5rem 0.75rem;\n border: 1px solid #ccc;\n border-radius: 0.375rem;\n font-size: 1rem;\n }\n\n .results {\n background: white;\n border: 1px solid #ccc;\n border-radius: 0.375rem;\n margin-top: 0.25rem;\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0.5rem;\n padding: 0.5rem;\n box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);\n z-index: 10;\n }\n\n .group {\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n }\n\n .group-title {\n font-weight: 600;\n font-size: 0.875rem;\n margin-bottom: 0.25rem;\n }\n\n [role=\"option\"] {\n padding: 0.25rem 0.5rem;\n border-radius: 0.25rem;\n cursor: pointer;\n }\n\n [role=\"option\"].active,\n [role=\"option\"]:hover {\n background: #e8f0fe;\n outline: none;\n }\n "])));
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
38
|
+
kind: "field",
|
|
39
|
+
decorators: [property({
|
|
40
|
+
type: Array
|
|
41
|
+
})],
|
|
42
|
+
key: "people",
|
|
43
|
+
value() {
|
|
44
|
+
return ["Alice", "Bob", "Charlie"];
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
kind: "field",
|
|
48
|
+
decorators: [property({
|
|
49
|
+
type: Array
|
|
50
|
+
})],
|
|
51
|
+
key: "documents",
|
|
52
|
+
value() {
|
|
53
|
+
return ["Spec.docx", "Roadmap.pdf", "Meeting Notes.txt"];
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
kind: "field",
|
|
57
|
+
decorators: [state()],
|
|
58
|
+
key: "query",
|
|
59
|
+
value() {
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
kind: "field",
|
|
64
|
+
decorators: [state()],
|
|
65
|
+
key: "activeIndex",
|
|
66
|
+
value() {
|
|
67
|
+
return -1;
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
kind: "field",
|
|
71
|
+
decorators: [state()],
|
|
72
|
+
key: "expanded",
|
|
73
|
+
value() {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
kind: "field",
|
|
78
|
+
decorators: [state()],
|
|
79
|
+
key: "results",
|
|
80
|
+
value() {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
kind: "method",
|
|
85
|
+
key: "render",
|
|
86
|
+
value: function render() {
|
|
87
|
+
return html(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n <div\n class=\"search-container\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded=", "\n aria-owns=\"results-list\"\n >\n <input\n type=\"text\"\n placeholder=\"Search...\"\n .value=", "\n @input=", "\n @keydown=", "\n aria-controls=\"results-list\"\n aria-activedescendant=", "\n aria-autocomplete=\"list\"\n />\n\n ", "\n </div>\n "])), this.expanded, this.query, this.onInput, this.onKeyDown, this.activeIndex >= 0 ? "opt-" + this.activeIndex : "", this.expanded ? html(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n <div class=\"results\" id=\"results-list\" role=\"listbox\">\n <div class=\"group\">\n <div class=\"group-title\">People</div>\n ", "\n </div>\n <div class=\"group\">\n <div class=\"group-title\">Documents</div>\n ", "\n </div>\n </div>\n "])), this.people.filter(p => p.toLowerCase().includes(this.query.toLowerCase())).map(p => this.renderOption(p, "People")), this.documents.filter(d => d.toLowerCase().includes(this.query.toLowerCase())).map(d => this.renderOption(d, "Documents"))) : null);
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
kind: "method",
|
|
91
|
+
key: "renderOption",
|
|
92
|
+
value: function renderOption(label, group) {
|
|
93
|
+
const index = this.results.findIndex(r => r.label === label && r.group === group);
|
|
94
|
+
const isActive = index === this.activeIndex;
|
|
95
|
+
return html(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n <div\n role=\"option\"\n id=\"opt-", "\"\n class=", "\n @click=", "\n >\n ", "\n </div>\n "])), index, isActive ? "active" : "", () => this.selectOption(index), label);
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
kind: "method",
|
|
99
|
+
key: "onInput",
|
|
100
|
+
value: function onInput(e) {
|
|
101
|
+
const value = e.target.value;
|
|
102
|
+
this.query = value;
|
|
103
|
+
this.updateResults();
|
|
104
|
+
this.expanded = this.results.length > 0;
|
|
105
|
+
this.activeIndex = -1;
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
kind: "method",
|
|
109
|
+
key: "updateResults",
|
|
110
|
+
value: function updateResults() {
|
|
111
|
+
const q = this.query.toLowerCase();
|
|
112
|
+
this.results = [...this.people.filter(p => p.toLowerCase().includes(q)).map(label => ({
|
|
113
|
+
group: "People",
|
|
114
|
+
label
|
|
115
|
+
})), ...this.documents.filter(d => d.toLowerCase().includes(q)).map(label => ({
|
|
116
|
+
group: "Documents",
|
|
117
|
+
label
|
|
118
|
+
}))];
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
kind: "method",
|
|
122
|
+
key: "onKeyDown",
|
|
123
|
+
value: function onKeyDown(e) {
|
|
124
|
+
if (!this.expanded && e.key === "ArrowDown") {
|
|
125
|
+
this.expanded = true;
|
|
126
|
+
this.updateResults();
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (e.key === "ArrowDown") {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
this.activeIndex = (this.activeIndex + 1) % this.results.length;
|
|
132
|
+
this.requestUpdate();
|
|
133
|
+
} else if (e.key === "ArrowUp") {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
this.activeIndex = (this.activeIndex - 1 + this.results.length) % this.results.length;
|
|
136
|
+
this.requestUpdate();
|
|
137
|
+
} else if (e.key === "Enter" && this.activeIndex >= 0) {
|
|
138
|
+
this.selectOption(this.activeIndex);
|
|
139
|
+
} else if (e.key === "Escape") {
|
|
140
|
+
this.expanded = false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
kind: "method",
|
|
145
|
+
key: "selectOption",
|
|
146
|
+
value: function selectOption(index) {
|
|
147
|
+
const item = this.results[index];
|
|
148
|
+
if (!item) return;
|
|
149
|
+
this.query = item.label;
|
|
150
|
+
this.expanded = false;
|
|
151
|
+
this.activeIndex = -1;
|
|
152
|
+
this.dispatchEvent(new CustomEvent("select", {
|
|
153
|
+
detail: item
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
}]
|
|
157
|
+
};
|
|
158
|
+
}, LitElement);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";class t extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML='<slot style="border-radius: inherit"></slot>',this.activeIndex=-1,this.items=[],this.inputElement=null}connectedCallback(){this.setAttribute("role","listbox"),this.tabIndex=-1,this.updateItems();const t=this.getAttribute("for");this.inputElement=t?document.getElementById(t):null,this.inputElement&&(this.inputElement.setAttribute("role","combobox"),this.inputElement.setAttribute("aria-controls",this.id),this.inputElement.setAttribute("aria-expanded","true"),this.inputElement.addEventListener("keydown",this.onKeyDown.bind(this))),this.addEventListener("keydown",this.onKeyDown.bind(this)),this.addEventListener("click",t=>{const e=t.target instanceof Element?t.target.closest("[data-blue-select-list-index]"):null;if(e&&e.hasAttribute("data-blue-select-list-index")){const t=Number(e.getAttribute("data-blue-select-list-index"));this.select(t)}})}updateItems(){this.items=Array.from(this.children),this.items.forEach((t,e)=>{t.hasAttribute("id")||t.setAttribute("id","".concat(this.id,"-option-").concat(e)),t.setAttribute("data-blue-select-list-index",e.toString()),t.setAttribute("aria-selected","false"),t.setAttribute("role","option"),t.tabIndex=-1})}onKeyDown(t){if(
|
|
1
|
+
(()=>{"use strict";class t extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML='<slot style="border-radius: inherit"></slot>',this.activeIndex=-1,this.items=[],this.inputElement=null}connectedCallback(){this.setAttribute("role","listbox"),this.tabIndex=-1,this.updateItems();const t=this.getAttribute("for");this.inputElement=t?document.getElementById(t):null,this.inputElement&&(this.inputElement.setAttribute("role","combobox"),this.inputElement.setAttribute("aria-controls",this.id),this.inputElement.setAttribute("aria-expanded","true"),this.inputElement.addEventListener("keydown",this.onKeyDown.bind(this))),this.addEventListener("keydown",this.onKeyDown.bind(this)),this.addEventListener("click",t=>{const e=t.target instanceof Element?t.target.closest("[data-blue-select-list-index]"):null;if(e&&e.hasAttribute("data-blue-select-list-index")){const t=Number(e.getAttribute("data-blue-select-list-index"));this.select(t)}})}updateItems(){this.items=Array.from(this.children),this.items.forEach((t,e)=>{t.hasAttribute("id")||t.setAttribute("id","".concat(this.id,"-option-").concat(e)),t.setAttribute("data-blue-select-list-index",e.toString()),t.setAttribute("aria-selected","false"),t.setAttribute("role","option"),t.tabIndex=-1})}onKeyDown(t){if(this.items.length)if("ArrowDown"===t.key)t.preventDefault(),this.activeIndex=(this.activeIndex+1)%this.items.length,this.updateActiveItem();else if("ArrowUp"===t.key)t.preventDefault(),this.activeIndex=(this.activeIndex-1+this.items.length)%this.items.length,this.updateActiveItem();else if("Enter"===t.key&&this.activeIndex>=0){const t=this.items[this.activeIndex];null==t||t.click()}}updateActiveItem(){this.items.forEach((t,e)=>{const i=e===this.activeIndex;t.classList.toggle("active",i),t.setAttribute("aria-selected",i.toString())});const t=this.items[this.activeIndex];t&&this.inputElement&&(this.inputElement.setAttribute("aria-activedescendant",t.id),t.scrollIntoView({block:"nearest"}))}select(t){this.activeIndex=t,this.updateActiveItem();const e=this.items[t];e&&(this.dispatchEvent(new CustomEvent("bl-select",{detail:{index:t,item:e},bubbles:!0,composed:!0})),e.click())}}customElements.define("bl-select-list",t)})();
|
package/dist/js/select-list.js
CHANGED
package/dist/merged.scss
CHANGED
package/dist/style.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@charset "UTF-8";
|
|
2
2
|
/*!
|
|
3
|
-
* Blue Web v1.
|
|
3
|
+
* Blue Web v1.19.1 (https://bruegmann.github.io/blue-web)
|
|
4
4
|
* Licensed under GNU General Public License v3.0 (https://github.com/bruegmann/blue-web/blob/master/LICENSE).
|
|
5
5
|
*/
|
|
6
6
|
:root {
|
package/dist/style.min.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@charset "UTF-8";/*!
|
|
2
|
-
* Blue Web v1.
|
|
2
|
+
* Blue Web v1.19.1 (https://bruegmann.github.io/blue-web)
|
|
3
3
|
* Licensed under GNU General Public License v3.0 (https://github.com/bruegmann/blue-web/blob/master/LICENSE).
|
|
4
4
|
*/:root{--blue-app-bg:hsl(217,10%,94%);--blue-scrollbar-thumb-color-rgb:255,255,255;--blue-sidebar-width:16.563rem;--blue-sidebar-color:hsl(217,11%,15%);--blue-theme:var(--theme,hsl(217,10%,94%));--blue-shimmering:0.9;--blue-sidebar-bg:hsl(217,10%,94%);--blue-header-bg:hsl(217,10%,94%);--blue-header-color:hsl(217,11%,15%);--blue-action-link-bg-color:var(--blue-theme);--blue-menu-item-indicator-bg:hsl(221,97%,53%);--blue-menu-item-height:calc(var(--bs-btn-border-width,1px) + var(--bs-btn-padding-y,0.375rem) + var(--bs-btn-font-size,1rem) * var(--bs-btn-line-height,1.5) + var(--bs-btn-padding-y,0.375rem) + var(--bs-btn-border-width,1px))}[data-bs-theme=dark]{--blue-app-bg:hsl(217,10%,8%);--blue-sidebar-color:#fff;--blue-sidebar-bg:hsl(217,10%,8%);--blue-header-bg:hsl(217,10%,8%);--blue-header-color:#fff;--blue-menu-item-indicator-bg:#fff}@keyframes fade-in{from{opacity:0}to{opacity:1}}@keyframes blAppearUp{from{margin-top:2.5rem}to{margin-top:0}}@keyframes blue-menu-item-dropdown{from{transform:translateY(-50%);opacity:0}}@keyframes enabledBlueAppPage{from{transform:scale(0.98);opacity:0}to{opacity:1}}@keyframes fadeInDown{from{opacity:0;transform:translate3d(0,-100%,0)}to{opacity:1;transform:none}}@keyframes alert-in{from{transform:scale(0,0);opacity:0.2;transition:0s}}@keyframes circlebounce{0%,100%{transform:scale(0)}50%{transform:scale(1)}}@keyframes scrolling{from{transform:translateX(-100%)}to{transform:translateX(100%)}}/*!
|
|
5
5
|
* Bootstrap v5.3.8 (https://getbootstrap.com/)
|
package/dist/style.scss
CHANGED