@dataengineeringformachinelearning/viking-ui 4.0.3 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataengineeringformachinelearning/viking-ui",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "description": "Universal Viking-UI design system for Astro, Angular, and Django.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -48,10 +48,7 @@ export class VikingCardWc extends HTMLElementBase {
48
48
  "viking-card-interactive",
49
49
  this.hasAttribute("interactive"),
50
50
  );
51
- this.classList.toggle(
52
- "viking-card-loading",
53
- this.hasAttribute("loading"),
54
- );
51
+ this.classList.toggle("viking-card-loading", this.hasAttribute("loading"));
55
52
 
56
53
  const title = this.getAttribute("title");
57
54
  if (title) {
@@ -125,6 +125,7 @@ export class VikingSearchPaletteWc extends HTMLElementBase {
125
125
 
126
126
  connectedCallback(): void {
127
127
  this.render();
128
+ this.removeAttribute("open");
128
129
  this.syncOpen();
129
130
  this.bindGlobalShortcut();
130
131
  this.dialogEl?.addEventListener("close", this.onClose);
@@ -917,7 +917,7 @@ declare class VikingSiteFooter {
917
917
  readonly year: _angular_core.InputSignal<number>;
918
918
  readonly cookieSettings: _angular_core.OutputEmitterRef<Event>;
919
919
  readonly bugReport: _angular_core.OutputEmitterRef<Event>;
920
- readonly usaBadgeHover: _angular_core.OutputEmitterRef<MouseEvent>;
920
+ readonly usaBadgeHover: _angular_core.OutputEmitterRef<Event>;
921
921
  protected readonly columns: readonly _dataengineeringformachinelearning_viking_ui.SiteFooterColumn[];
922
922
  protected readonly cookieSettingsUrl: () => string;
923
923
  protected resolveHref: (link: SiteFooterLink) => string;
@@ -1325,7 +1325,7 @@ input:disabled {
1325
1325
  <footer class="viking-modal-footer" part="footer"><slot name="actions"></slot></footer>
1326
1326
  </div>
1327
1327
  </dialog>
1328
- `,this.dialogEl=this.shadow.querySelector("dialog"),this.shadow.querySelector(".viking-modal-close")?.addEventListener("click",()=>this.closeModal()),this.dialogEl?.addEventListener("keydown",i=>{i.key==="Escape"&&this.dismissible&&(i.preventDefault(),this.closeModal())})}},Q=()=>{c(m.tag,m),d(m.legacyTag,m),d(m.dialogTag,m)};var it=t=>{let e=t.getAttribute("items");if(!e)return[];try{let i=JSON.parse(e);return Array.isArray(i)?i:[]}catch{return[]}},nt=(t,e)=>[t.title,t.snippet??"",t.group??"",t.href,...t.keywords??[]].join(" ").toLowerCase().includes(e),rt=(t,e)=>{let i=e.trim().toLowerCase();return i?t.filter(n=>nt(n,i)):t},at=t=>{let e=new Map;return t.forEach(i=>{let n=i.group??null,r=e.get(n)??[];r.push(i),e.set(n,r)}),Array.from(e.entries()).map(([i,n])=>({group:i,items:n}))},b=class extends l{static tag="viking-command-palette";static searchTag="viking-search-palette";static legacyTag="viking-search-palette-wc";static get observedAttributes(){return["open","placeholder","items","global-shortcut"]}shadow;dialogEl=null;inputEl=null;resultsEl=null;globalKeyHandler=null;resultsId=x("viking-search-results");inputId=x("viking-search-input");query="";activeIndex=0;flatResults=[];constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),v(this.shadow,Le)}connectedCallback(){this.render(),this.syncOpen(),this.bindGlobalShortcut(),this.dialogEl?.addEventListener("close",this.onClose),this.dialogEl?.addEventListener("click",this.onBackdropClick),this.inputEl?.addEventListener("input",this.onInput),this.inputEl?.addEventListener("keydown",this.onInputKeydown)}disconnectedCallback(){this.dialogEl?.removeEventListener("close",this.onClose),this.dialogEl?.removeEventListener("click",this.onBackdropClick),this.inputEl?.removeEventListener("input",this.onInput),this.inputEl?.removeEventListener("keydown",this.onInputKeydown),this.unbindGlobalShortcut()}attributeChangedCallback(e){if(this.isConnected&&(e==="open"&&this.syncOpen(),e==="global-shortcut"&&(this.unbindGlobalShortcut(),this.bindGlobalShortcut()),e==="items"||e==="placeholder"))if(e==="placeholder"&&this.inputEl){let i=this.getAttribute("placeholder")??"Search documentation, dashboard, API\u2026";this.inputEl.placeholder=i,this.inputEl.setAttribute("aria-label",i)}else this.renderResults()}openPalette(){this.setAttribute("open",""),this.syncOpen()}closePalette(){this.removeAttribute("open"),T(this.dialogEl)}search(e){this.query=e,this.inputEl&&(this.inputEl.value=e),this.activeIndex=0,this.renderResults(),this.dispatchEvent(new CustomEvent("viking-query",{bubbles:!0,composed:!0,detail:{query:this.query}}))}onClose=()=>{this.removeAttribute("open"),this.query="",this.activeIndex=0,this.inputEl&&(this.inputEl.value=""),this.dispatchEvent(new CustomEvent("viking-close",{bubbles:!0,composed:!0}))};onBackdropClick=e=>{e.target===this.dialogEl&&this.closePalette()};onInput=e=>{this.query=e.target.value??this.inputEl?.value??"",this.activeIndex=0,this.renderResults(),this.dispatchEvent(new CustomEvent("viking-query",{bubbles:!0,composed:!0,detail:{query:this.query}}))};onInputKeydown=e=>{if(this.flatResults.length===0){e.key==="Escape"&&(e.preventDefault(),this.closePalette());return}if(e.key==="ArrowDown"){e.preventDefault(),this.activeIndex=Math.min(this.flatResults.length-1,this.activeIndex+1),this.renderResults(),this.scrollActiveIntoView();return}if(e.key==="ArrowUp"){e.preventDefault(),this.activeIndex=Math.max(0,this.activeIndex-1),this.renderResults(),this.scrollActiveIntoView();return}if(e.key==="Enter"){e.preventDefault();let i=this.flatResults[this.activeIndex];i&&this.activateItem(i)}};bindGlobalShortcut(){h(this,"global-shortcut")&&(this.globalKeyHandler=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="k"&&(e.preventDefault(),this.hasAttribute("open")?this.closePalette():this.openPalette())},document.addEventListener("keydown",this.globalKeyHandler))}unbindGlobalShortcut(){this.globalKeyHandler&&(document.removeEventListener("keydown",this.globalKeyHandler),this.globalKeyHandler=null)}syncOpen(){if(!this.dialogEl)return;let e=this.hasAttribute("open");e&&!this.dialogEl.open?(this.dialogEl.removeAttribute("aria-hidden"),G(this.dialogEl),this.activeIndex=0,this.renderResults(),queueMicrotask(()=>this.inputEl?.focus())):!e&&this.dialogEl.open?(T(this.dialogEl),this.dialogEl.setAttribute("aria-hidden","true")):e||this.dialogEl.setAttribute("aria-hidden","true")}scrollActiveIntoView(){this.resultsEl?.querySelector(".viking-search-result.is-selected")?.scrollIntoView({block:"nearest"})}activateItem(e){if(this.dispatchEvent(new CustomEvent("viking-select",{bubbles:!0,composed:!0,detail:{item:e}})),this.closePalette(),e.action==="cookie-settings"){globalThis.DemlWidgets?.openCookieSettings?.();return}if(e.action==="bug-report"){let i=globalThis.DemlWidgets;if(i?.openBugReport){i.openBugReport();return}}e.href&&e.href!=="#"&&window.location.assign(e.href)}renderResults(){if(!this.resultsEl)return;let e=it(this),i=this.query.trim().toLowerCase(),n=rt(e,i);if(this.flatResults=n,n.length===0){let p=this.query.trim();this.resultsEl.innerHTML=`<p class="viking-search-empty" role="status">${p?"No results found":"Start typing to search\u2026"}</p>`,this.inputEl?.removeAttribute("aria-activedescendant");return}this.activeIndex>=n.length&&(this.activeIndex=n.length-1);let r=0,s=at(n).map(({group:p,items:k})=>{let y=p?`<p class="viking-search-group-label" role="presentation">${a(p)}</p>`:"",L=k.map(V=>{let re=`${this.resultsId}-result-${r}`,P=r===this.activeIndex;return r+=1,`
1328
+ `,this.dialogEl=this.shadow.querySelector("dialog"),this.shadow.querySelector(".viking-modal-close")?.addEventListener("click",()=>this.closeModal()),this.dialogEl?.addEventListener("keydown",i=>{i.key==="Escape"&&this.dismissible&&(i.preventDefault(),this.closeModal())})}},Q=()=>{c(m.tag,m),d(m.legacyTag,m),d(m.dialogTag,m)};var it=t=>{let e=t.getAttribute("items");if(!e)return[];try{let i=JSON.parse(e);return Array.isArray(i)?i:[]}catch{return[]}},nt=(t,e)=>[t.title,t.snippet??"",t.group??"",t.href,...t.keywords??[]].join(" ").toLowerCase().includes(e),rt=(t,e)=>{let i=e.trim().toLowerCase();return i?t.filter(n=>nt(n,i)):t},at=t=>{let e=new Map;return t.forEach(i=>{let n=i.group??null,r=e.get(n)??[];r.push(i),e.set(n,r)}),Array.from(e.entries()).map(([i,n])=>({group:i,items:n}))},b=class extends l{static tag="viking-command-palette";static searchTag="viking-search-palette";static legacyTag="viking-search-palette-wc";static get observedAttributes(){return["open","placeholder","items","global-shortcut"]}shadow;dialogEl=null;inputEl=null;resultsEl=null;globalKeyHandler=null;resultsId=x("viking-search-results");inputId=x("viking-search-input");query="";activeIndex=0;flatResults=[];constructor(){super(),this.shadow=this.attachShadow({mode:"open"}),v(this.shadow,Le)}connectedCallback(){this.render(),this.removeAttribute("open"),this.syncOpen(),this.bindGlobalShortcut(),this.dialogEl?.addEventListener("close",this.onClose),this.dialogEl?.addEventListener("click",this.onBackdropClick),this.inputEl?.addEventListener("input",this.onInput),this.inputEl?.addEventListener("keydown",this.onInputKeydown)}disconnectedCallback(){this.dialogEl?.removeEventListener("close",this.onClose),this.dialogEl?.removeEventListener("click",this.onBackdropClick),this.inputEl?.removeEventListener("input",this.onInput),this.inputEl?.removeEventListener("keydown",this.onInputKeydown),this.unbindGlobalShortcut()}attributeChangedCallback(e){if(this.isConnected&&(e==="open"&&this.syncOpen(),e==="global-shortcut"&&(this.unbindGlobalShortcut(),this.bindGlobalShortcut()),e==="items"||e==="placeholder"))if(e==="placeholder"&&this.inputEl){let i=this.getAttribute("placeholder")??"Search documentation, dashboard, API\u2026";this.inputEl.placeholder=i,this.inputEl.setAttribute("aria-label",i)}else this.renderResults()}openPalette(){this.setAttribute("open",""),this.syncOpen()}closePalette(){this.removeAttribute("open"),T(this.dialogEl)}search(e){this.query=e,this.inputEl&&(this.inputEl.value=e),this.activeIndex=0,this.renderResults(),this.dispatchEvent(new CustomEvent("viking-query",{bubbles:!0,composed:!0,detail:{query:this.query}}))}onClose=()=>{this.removeAttribute("open"),this.query="",this.activeIndex=0,this.inputEl&&(this.inputEl.value=""),this.dispatchEvent(new CustomEvent("viking-close",{bubbles:!0,composed:!0}))};onBackdropClick=e=>{e.target===this.dialogEl&&this.closePalette()};onInput=e=>{this.query=e.target.value??this.inputEl?.value??"",this.activeIndex=0,this.renderResults(),this.dispatchEvent(new CustomEvent("viking-query",{bubbles:!0,composed:!0,detail:{query:this.query}}))};onInputKeydown=e=>{if(this.flatResults.length===0){e.key==="Escape"&&(e.preventDefault(),this.closePalette());return}if(e.key==="ArrowDown"){e.preventDefault(),this.activeIndex=Math.min(this.flatResults.length-1,this.activeIndex+1),this.renderResults(),this.scrollActiveIntoView();return}if(e.key==="ArrowUp"){e.preventDefault(),this.activeIndex=Math.max(0,this.activeIndex-1),this.renderResults(),this.scrollActiveIntoView();return}if(e.key==="Enter"){e.preventDefault();let i=this.flatResults[this.activeIndex];i&&this.activateItem(i)}};bindGlobalShortcut(){h(this,"global-shortcut")&&(this.globalKeyHandler=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="k"&&(e.preventDefault(),this.hasAttribute("open")?this.closePalette():this.openPalette())},document.addEventListener("keydown",this.globalKeyHandler))}unbindGlobalShortcut(){this.globalKeyHandler&&(document.removeEventListener("keydown",this.globalKeyHandler),this.globalKeyHandler=null)}syncOpen(){if(!this.dialogEl)return;let e=this.hasAttribute("open");e&&!this.dialogEl.open?(this.dialogEl.removeAttribute("aria-hidden"),G(this.dialogEl),this.activeIndex=0,this.renderResults(),queueMicrotask(()=>this.inputEl?.focus())):!e&&this.dialogEl.open?(T(this.dialogEl),this.dialogEl.setAttribute("aria-hidden","true")):e||this.dialogEl.setAttribute("aria-hidden","true")}scrollActiveIntoView(){this.resultsEl?.querySelector(".viking-search-result.is-selected")?.scrollIntoView({block:"nearest"})}activateItem(e){if(this.dispatchEvent(new CustomEvent("viking-select",{bubbles:!0,composed:!0,detail:{item:e}})),this.closePalette(),e.action==="cookie-settings"){globalThis.DemlWidgets?.openCookieSettings?.();return}if(e.action==="bug-report"){let i=globalThis.DemlWidgets;if(i?.openBugReport){i.openBugReport();return}}e.href&&e.href!=="#"&&window.location.assign(e.href)}renderResults(){if(!this.resultsEl)return;let e=it(this),i=this.query.trim().toLowerCase(),n=rt(e,i);if(this.flatResults=n,n.length===0){let p=this.query.trim();this.resultsEl.innerHTML=`<p class="viking-search-empty" role="status">${p?"No results found":"Start typing to search\u2026"}</p>`,this.inputEl?.removeAttribute("aria-activedescendant");return}this.activeIndex>=n.length&&(this.activeIndex=n.length-1);let r=0,s=at(n).map(({group:p,items:k})=>{let y=p?`<p class="viking-search-group-label" role="presentation">${a(p)}</p>`:"",L=k.map(V=>{let re=`${this.resultsId}-result-${r}`,P=r===this.activeIndex;return r+=1,`
1329
1329
  <a
1330
1330
  id="${re}"
1331
1331
  class="viking-search-result${P?" is-selected":""}"