@substrate-system/actor-typeahead 0.0.2 → 0.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/README.md +45 -11
- package/dist/custom-elements.json +83 -6
- package/dist/index.cjs +150 -38
- package/dist/index.cjs.map +3 -3
- package/dist/index.css +23 -2
- package/dist/index.d.ts +16 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +150 -38
- package/dist/index.js.map +3 -3
- package/dist/index.min.css +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/dist/meta.json +4 -4
- package/package.json +3 -4
package/dist/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var T=Object.defineProperty;var
|
|
1
|
+
var T=Object.defineProperty;var o=(e,t)=>T(e,"name",{value:t,configurable:!0});var k=Object.defineProperty,L=o((e,t)=>k(e,"name",{value:t,configurable:!0}),"__name");function b(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return r?typeof r=="boolean"?r?(t+` ${n}`).trim():t:Array.isArray(r)?t+` ${n}="${r.join(" ")}"`:(t+` ${n}="${r}"`).trim():t},"")}o(b,"toAttributes");L(b,"toAttributes");var x=Object.defineProperty,C=o((e,t)=>x(e,"name",{value:t,configurable:!0}),"__name");function N(e){return document.querySelector(e)}o(N,"qs");C(N,"qs");var S=Object.defineProperty,P=o((e,t)=>S(e,"name",{value:t,configurable:!0}),"__name");function _(e){return document.querySelectorAll(e)}o(_,"qsa");P(_,"qsa");var D=Object.defineProperty,d=o((e,t)=>D(e,"name",{value:t,configurable:!0}),"__name");function p(e){return document.createElement(e).constructor!==window.HTMLElement}o(p,"isRegistered");d(p,"isRegistered");function M(e,t){typeof window>"u"||"customElements"in window&&(p(e)||window.customElements.define(e,t))}o(M,"define");d(M,"define");function h(e,t){return e.matches||(e=e.parentElement),e.matches(t)?e:e.closest(t)}o(h,"match");d(h,"match");var O=Object.defineProperty,l=o((e,t)=>O(e,"name",{value:t,configurable:!0}),"__name"),u=class e extends window.HTMLElement{static{o(this,"WebComponent")}static{l(this,"WebComponent")}static TAG="";TAG="";static reflectedBooleanAttributes=[];static reflectedStringAttributes=[];static get observedAttributes(){return[...new Set([...this.reflectedBooleanAttributes,...this.reflectedStringAttributes])]}static match(t){return h(t,this.TAG)}static create(t){let n=class extends e{static{o(this,"CreatedClass")}static{l(this,"CreatedClass")}static TAG=t;TAG=t;render(){throw new Error("`render` should be implemented by children")}};return n.define=function(){return e.define.call(this)},n.event=function(r){return e.event.call(this,r)},n}static define(){v(this.TAG,this)}attributeChangedCallback(t,n,r){let s=this[A(t)];s&&s.call(this,n,r)}connectedCallback(){this.render()}qs(t){return this.querySelector(t)}qsa(t){return this.querySelectorAll(t)}static event(t){return g(this.TAG,t)}emit(t,n={}){if(t==="*")throw new Error('Do not emit the literal "*"');let{bubbles:r=!0,cancelable:s=!0,detail:a}=n,i=`${this.TAG}:${t}`,c=new CustomEvent(i,{bubbles:r,cancelable:s,detail:a});return this.dispatchEvent(c)}dispatch(t,n={}){let r=new CustomEvent(t,{bubbles:n.bubbles===void 0?!0:n.bubbles,cancelable:n.cancelable===void 0?!0:n.cancelable,detail:n.detail});return this.dispatchEvent(r)}on(t,n,r){let s=e.event.call(this,t);this.addEventListener(s,n,r)}off(t,n,r){let s=e.event.call(this,t);this.removeEventListener(s,n,r)}};function g(e,t){return`${e}:${t}`}o(g,"eventName");l(g,"eventName");var m=Object.create(null);function A(e){return m[e]||(m[e]=`handleChange_${e}`)}o(A,"handlerKey");l(A,"handlerKey");function E(e){return document.createElement(e).constructor!==window.HTMLElement}o(E,"isRegistered");l(E,"isRegistered");function v(e,t){if(typeof window>"u"||!("customElements"in window)||E(e))return;let n=t,r=n.reflectedBooleanAttributes??[],s=n.reflectedStringAttributes??[],a=t.prototype;for(let i of r)i in HTMLElement.prototype||Object.getOwnPropertyDescriptor(a,i)||Object.defineProperty(a,i,{get(){return this.hasAttribute(i)},set(c){this.toggleAttribute(i,!!c)},configurable:!0,enumerable:!0});for(let i of s){if(r.includes(i)){console.warn(`[web-component] "${i}" appears in both reflectedBooleanAttributes and reflectedStringAttributes on <${e}>. Boolean wins.`);continue}i in HTMLElement.prototype||Object.getOwnPropertyDescriptor(a,i)||Object.defineProperty(a,i,{get(){return this.getAttribute(i)},set(c){c==null?this.removeAttribute(i):this.setAttribute(i,String(c))},configurable:!0,enumerable:!0})}window.customElements.define(e,t)}o(v,"define");l(v,"define");var H="https://public.api.bsky.app",$=5,j=150,w=typeof CSS<"u"&&CSS.supports("anchor-scope: --a"),q=0,f=class extends u.create("actor-typeahead"){static{o(this,"ActorTypeahead")}static reflectedStringAttributes=["host","rows"];announce=G;#l=`actor-typeahead-${++q}`;#e=[];#t=-1;#n=null;#r=null;#a=!1;#s;#c=null;constructor(){super(),this.addEventListener("input",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}disconnectedCallback(){this.#o()}get#h(){let t=Number.parseInt(this.rows??"");return Number.isNaN(t)?$:t}handleEvent(t){switch(t.type){case"input":this.#b(t);break;case"keydown":t instanceof KeyboardEvent&&this.#f(t);break;case"focusout":t instanceof FocusEvent&&this.#g(t);break;case"mousedown":t.preventDefault();break;case"click":this.#A(t);break}}#f(t){let n=this.#e.length-1,r=["ArrowDown","ArrowUp","PageDown","PageUp"];if(n<0&&r.includes(t.key)){t.preventDefault();return}switch(t.key){case"ArrowDown":t.preventDefault(),this.#t=Math.min(this.#t+1,n),this.render();break;case"PageDown":t.preventDefault(),this.#t=n,this.render();break;case"ArrowUp":t.preventDefault(),this.#t=this.#t<0?n:this.#t-1,this.render();break;case"PageUp":t.preventDefault(),this.#t=0,this.render();break;case"Escape":this.#e.length&&t.preventDefault(),this.#i();break;case"Enter":if(!this.#e[this.#t]){this.#o();break}t.preventDefault(),this.#u(this.#t);break}}#b(t){if(!(t.target instanceof HTMLInputElement))return;let n=t.target.value;if(!n){this.#i();return}this.#o(),this.#s=setTimeout(()=>this.#p(n),j)}async#p(t){this.#s=void 0;let n=new URL("xrpc/app.bsky.actor.searchActorsTypeahead",this.host??H);n.searchParams.set("q",t),n.searchParams.set("limit",String(this.#h));let r=new AbortController;this.#c=r;let{signal:s}=r,a;try{let i=await fetch(n,{signal:s});if(s.aborted)return;if(!i.ok)throw new Error(`status ${i.status}`);a=await i.json()}catch(i){if(I(i))return;this.#i();return}s.aborted||(this.#e=U(a),this.#t=-1,this.render(),this.#m(this.#e.length))}#m(t){this.#r&&(this.#a=!this.#a,this.#r.textContent=this.announce(t)+(this.#a?"\xA0":""))}#g(t){let n=t.relatedTarget;n instanceof Node&&this.contains(n)||this.#i()}#A(t){let n=t.target instanceof Element?t.target.closest('[role="option"]'):null;n&&this.#u(Number(n.dataset.index))}#u(t){let n=this.#e[t],r=this.qs("input");!n||!r||(r.value=n.handle,r.focus(),this.#i(),this.emit("select",{detail:n}))}#o(){clearTimeout(this.#s),this.#s=void 0,this.#c?.abort(),this.#c=null}#i(){this.#o(),this.#e=[],this.#t=-1,this.render()}render(){this.#n||(this.#n=document.createElement("div"),this.#n.className="suggestion-list",this.#n.id=`${this.#l}-list`,this.#n.setAttribute("role","listbox"),w&&(this.#n.popover="manual"),this.#n.addEventListener("mousedown",this),this.#n.addEventListener("click",this));let t=this.#n;t.parentNode!==this&&this.append(t),this.#r||(this.#r=document.createElement("div"),this.#r.className="suggestion-count",this.#r.setAttribute("role","status"));let n=this.#r;n.parentNode!==this&&this.append(n),this.#e.length||(n.textContent=""),t.replaceChildren(...this.#e.map((a,i)=>{let c=R(a,i,i===this.#t);return c.id=this.#d(i),c}));let r=this.#E(t,this.#e.length>0),s=this.qs("input");if(s){s.setAttribute("role","combobox"),s.setAttribute("aria-autocomplete","list"),s.hasAttribute("autocomplete")||s.setAttribute("autocomplete","off"),s.setAttribute("aria-controls",t.id),s.setAttribute("aria-expanded",String(r));let a=B(s,this);for(let i of["aria-labelledby","aria-label"]){let c=a[i];c?t.setAttribute(i,c):t.removeAttribute(i)}this.#e[this.#t]?s.setAttribute("aria-activedescendant",this.#d(this.#t)):s.removeAttribute("aria-activedescendant")}}#E(t,n){if(!w)return n;if(!t.isConnected)return!1;let r=t.matches(":popover-open");return n&&!r&&t.showPopover(),!n&&r&&t.hidePopover(),t.matches(":popover-open")}#d(t){return`${this.#l}-option-${t}`}};f.define();function R(e,t,n){let r=document.createElement("button");r.type="button",r.tabIndex=-1,r.className="suggestion",r.setAttribute("role","option"),r.setAttribute("aria-selected",String(n)),r.dataset.index=String(t),r.dataset.handle=e.handle;let s=document.createElement("div");s.className="avatar";let a=document.createElement("img");a.className="img",a.alt="",e.avatar&&(a.src=e.avatar);let i=document.createElement("span");return i.className="handle",i.textContent=e.handle,s.append(a),r.append(s,i),r}o(R,"suggestion");function B(e,t){let n=e.getAttribute("aria-labelledby");if(n)return{"aria-labelledby":n};let r=e.getAttribute("aria-label");if(r)return{"aria-label":r};let s=[...e.labels??[]];if(!s.length)return{};if(s.every(i=>i.id))return{"aria-labelledby":s.map(i=>i.id).join(" ")};let a=s.map(i=>F(i,t).trim()).filter(Boolean).join(" ");return a?{"aria-label":a}:{}}o(B,"nameSource");function F(e,t){let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:o(s=>t.contains(s)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT,"acceptNode")}),r="";for(;n.nextNode();)r+=n.currentNode.nodeValue;return r}o(F,"labelText");function G(e){return e===0?"No Suggestions":e===1?"1 Suggestion available":`${e} Suggestions available`}o(G,"defaultAnnounce");function U(e){return!y(e)||!Array.isArray(e.actors)?[]:e.actors.flatMap(t=>!y(t)||typeof t.handle!="string"?[]:[typeof t.avatar=="string"?{handle:t.handle,avatar:t.avatar}:{handle:t.handle}])}o(U,"parseActors");function I(e){return e instanceof DOMException&&e.name==="AbortError"}o(I,"isAbortError");function y(e){return typeof e=="object"&&e!==null}o(y,"isRecord");export{f as ActorTypeahead};
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|
package/dist/index.min.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../node_modules/@substrate-system/web-component/src/attributes.ts", "../node_modules/@substrate-system/web-component/src/qs.ts", "../node_modules/@substrate-system/web-component/src/qsa.ts", "../node_modules/@substrate-system/web-component/src/util.ts", "../node_modules/@substrate-system/web-component/src/index.ts", "../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export type Attrs = Record<string, undefined|null|string|number|boolean|(string|number)[]>\n\n/**\n * Transform an object into an HTML attributes string. The object should be\n * like `{ attributeName: value }`.\n *\n * @param attrs An object for the attributes.\n * @returns {string} A string suitable for use as HTML attributes.\n */\nexport function toAttributes (attrs:Attrs):string {\n return Object.keys(attrs).reduce((acc, k) => {\n const value = attrs[k]\n if (!value) return acc\n\n if (typeof value === 'boolean') {\n if (value) return (acc + ` ${k}`).trim()\n return acc\n }\n\n if (Array.isArray(value)) {\n return (acc + ` ${k}=\"${value.join(' ')}\"`)\n }\n\n return (acc + ` ${k}=\"${value}\"`).trim()\n }, '')\n}\n", "export function qs<K extends keyof HTMLElementTagNameMap> (\n selectors:K\n):HTMLElementTagNameMap[K]|null\n\nexport function qs<K extends keyof SVGElementTagNameMap> (\n selectors:K\n):SVGElementTagNameMap[K]|null\n\nexport function qs<E extends Element = Element> (\n selectors:string\n):E|null\n\nexport function qs (selectors:string):Element|null {\n return document.querySelector(selectors)\n}\n", "export function qsa<K extends keyof HTMLElementTagNameMap> (\n selectors:K\n):NodeListOf<HTMLElementTagNameMap[K]>\n\nexport function qsa<K extends keyof SVGElementTagNameMap> (\n selectors:K\n):NodeListOf<SVGElementTagNameMap[K]>\n\nexport function qsa<E extends Element = Element> (\n selectors:string\n):NodeListOf<E>\n\nexport function qsa (selectors:string):NodeListOf<Element> {\n return document.querySelectorAll(selectors)\n}\n", "export { toAttributes } from './attributes.js'\n\n/**\n * Check if the given tag name has been registered.\n *\n * @see {@link https://stackoverflow.com/a/28210364 stackoverflow}\n * @param {string} elName The custom element tag name.\n * @returns {boolean} True if the given name has been registered already.\n */\nexport function isRegistered (elName:string):boolean {\n return document.createElement(elName).constructor !== window.HTMLElement\n}\n\nexport function define (name:string, element:CustomElementConstructor) {\n if (typeof window === 'undefined') return\n if (!('customElements' in window)) return\n if (!isRegistered(name)) {\n window.customElements.define(name, element)\n }\n}\n\n/**\n * Get the closes parent element matching the given selector.\n * @param el Element to start from\n * @param s Selector for an element\n * @returns {HTMLElement|null} The closes parent element that matches.\n */\nexport function match (el:HTMLElement, s:string):HTMLElement|null {\n if (!el.matches) el = el.parentElement!\n return el.matches(s) ? el : el.closest(s)\n}\n\nexport * from './qs.js'\nexport * from './qsa.js'\n", "import { match as _match } from './util.js'\n\nexport abstract class WebComponent extends window.HTMLElement {\n static TAG:string = ''\n TAG:string = ''\n\n /**\n * Declare boolean attributes that should be reflected as properties.\n * The base class auto-generates getters/setters and includes these in\n * `observedAttributes`. Framework property assignment (e.g. Preact's\n * `el.disabled = true`) will then correctly set the attribute.\n */\n static reflectedBooleanAttributes:string[] = []\n\n /**\n * Declare string attributes that should be reflected as properties.\n * Getter returns `string|null` (null when attribute is absent).\n * Setting `null` or `undefined` removes the attribute.\n */\n static reflectedStringAttributes:string[] = []\n\n /**\n * Auto-derived from `reflectedBooleanAttributes` and\n * `reflectedStringAttributes`. Override with `super.observedAttributes`\n * to add non-reflected observed attributes:\n *\n * ```ts\n * static get observedAttributes () {\n * return [...super.observedAttributes, 'aria-label']\n * }\n * ```\n */\n static get observedAttributes ():string[] {\n return [...new Set([\n ...this.reflectedBooleanAttributes,\n ...this.reflectedStringAttributes,\n ])]\n }\n\n static match (el:HTMLElement):HTMLElement|null {\n return _match(el, this.TAG)\n }\n\n static create<T extends string> (elementName:T):typeof WebComponent & {\n new (...args:any[]):WebComponent & { TAG:T };\n TAG:T;\n define: typeof WebComponent.define;\n event: typeof WebComponent.event;\n } {\n const CreatedClass = class extends WebComponent {\n static TAG = elementName\n TAG = elementName\n render () {\n throw new Error('`render` should be implemented by children')\n }\n }\n\n // Copy static methods with proper binding\n CreatedClass.define = function () {\n return WebComponent.define.call(this)\n }\n CreatedClass.event = function (evType:string) {\n return WebComponent.event.call(this, evType)\n }\n\n return CreatedClass\n }\n\n static define<T extends {\n new (...args:any[]):WebComponent;\n TAG:string;\n }>(this:T) {\n define(this.TAG, this)\n }\n\n /**\n * Runs when the value of an attribute is changed.\n *\n * Depends on `static observedAttributes`.\n *\n * Should name methods like `handleChange_disabled`.\n *\n * @param {string} name The attribute name\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n attributeChangedCallback (\n name:string,\n oldValue:string,\n newValue:string\n ):void {\n const handler = this[handlerKey(name)]\n if (handler) {\n handler.call(this, oldValue, newValue)\n }\n }\n\n connectedCallback () {\n this.render()\n }\n\n abstract render ():any\n\n qs<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):HTMLElementTagNameMap[K]|null;\n\n qs<E extends Element = Element>(selector:string):E|null;\n qs (selector:string):Element|null {\n return this.querySelector(selector)\n }\n\n qsa<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):HTMLElementTagNameMap[K]|null;\n\n qsa<E extends Element = Element>(selector:string):E|null;\n qsa (selector:string):NodeListOf<Element> {\n return this.querySelectorAll(selector)\n }\n\n /**\n * Take a non-namepsaced event name, return namespace event name.\n *\n * @param {string} evType The non-namespace event name\n * @returns {string} Namespaced event name, eg, `my-component:click`\n */\n static event (evType:string):string {\n return eventName(this.TAG, evType)\n }\n\n /**\n * Emit a namespaced event.\n *\n * @param type (non-namespaced) event type string\n * @param opts `bubbles`, `detail`, and `cancelable`. Default is\n * `{ bubbles: true, cancelable: true }`\n * @returns {boolean}\n */\n emit<T = any> (type:string, opts:Partial<{\n bubbles:boolean,\n cancelable:boolean,\n detail:CustomEvent<T>['detail']\n }> = {}):boolean {\n if (type === '*') throw new Error('Do not emit the literal \"*\"')\n\n const { bubbles = true, cancelable = true, detail } = opts\n const namespacedType = `${this.TAG}:${type}`\n\n const event = new CustomEvent(namespacedType, {\n bubbles,\n cancelable,\n detail\n })\n\n return this.dispatchEvent(event)\n }\n\n /**\n * Create and emit an event, no namespacing.\n */\n dispatch<T> (type:string, opts:Partial<{\n bubbles:boolean,\n cancelable:boolean,\n detail:CustomEvent<T>['detail']\n }> = {}):boolean {\n const event = new CustomEvent(type, {\n bubbles: (opts.bubbles === undefined) ? true : opts.bubbles,\n cancelable: (opts.cancelable === undefined) ? true : opts.cancelable,\n detail: opts.detail\n })\n\n return this.dispatchEvent(event)\n }\n\n /**\n * Listen for namespaced events.\n */\n on<T extends Event = Event> (\n evName:string,\n handler:(ev:T)=>any,\n options?:boolean|AddEventListenerOptions\n ):void;\n\n on (\n evName:string,\n handler:EventListenerObject,\n options?:boolean|AddEventListenerOptions\n ):void;\n\n on (\n evName:string,\n handler:((ev:Event)=>any)|EventListenerObject,\n options?:boolean|AddEventListenerOptions\n ):void {\n const fullEvName = WebComponent.event.call(this, evName)\n this.addEventListener(fullEvName, handler as EventListenerOrEventListenerObject, options)\n }\n\n /**\n * Remove a namespaced event listener.\n */\n off<T extends Event = Event> (\n evName:string,\n handler:(ev:T)=>any,\n options?:boolean|EventListenerOptions\n ):void;\n\n off (\n evName:string,\n handler:EventListenerObject,\n options?:boolean|EventListenerOptions\n ):void;\n\n off (\n evName:string,\n handler:((ev:Event)=>any)|EventListenerObject,\n options?:boolean|EventListenerOptions\n ):void {\n const fullEvName = WebComponent.event.call(this, evName)\n this.removeEventListener(fullEvName, handler as EventListenerOrEventListenerObject, options)\n }\n}\n\nfunction eventName (namespace:string, evType:string) {\n return `${namespace}:${evType}`\n}\n\n/**\n * Cache of attribute name -> handler method name (`handleChange_<attr>`).\n * Building the lookup string once per attribute avoids re-allocating it on\n * every `attributeChangedCallback`.\n */\nconst handlerKeys:Record<string, string> = Object.create(null)\nfunction handlerKey (name:string):string {\n return handlerKeys[name] || (handlerKeys[name] = `handleChange_${name}`)\n}\n\n/**\n * Check if the given tag name has been registered.\n *\n * @see {@link https://stackoverflow.com/a/28210364 stackoverflow}\n * @param {string} elName The custom element tag name.\n * @returns {boolean} True if the given name has been registered already.\n */\nexport function isRegistered (elName:string):boolean {\n return document.createElement(elName).constructor !== window.HTMLElement\n}\n\nexport function define (name:string, element:CustomElementConstructor) {\n if (typeof window === 'undefined') return\n if (!('customElements' in window)) return\n if (isRegistered(name)) return\n\n const ctor = element as unknown as typeof WebComponent\n const boolAttrs:string[] = ctor.reflectedBooleanAttributes ?? []\n const strAttrs:string[] = ctor.reflectedStringAttributes ?? []\n const proto = (element as any).prototype\n\n for (const attr of boolAttrs) {\n // Skip built-in IDL attributes on HTMLElement and ancestors\n // (covers Element.prototype, Node.prototype, etc.)\n if (attr in HTMLElement.prototype) continue\n // Skip if the subclass already defines an own-property accessor\n if (Object.getOwnPropertyDescriptor(proto, attr)) continue\n Object.defineProperty(proto, attr, {\n get (this:HTMLElement):boolean {\n return this.hasAttribute(attr)\n },\n set (this:HTMLElement, v:unknown) {\n this.toggleAttribute(attr, Boolean(v))\n },\n configurable: true,\n enumerable: true,\n })\n }\n\n for (const attr of strAttrs) {\n if (boolAttrs.includes(attr)) {\n console.warn(\n `[web-component] \"${attr}\" appears in both ` +\n 'reflectedBooleanAttributes and reflectedStringAttributes ' +\n `on <${name}>. Boolean wins.`\n )\n continue\n }\n if (attr in HTMLElement.prototype) continue\n if (Object.getOwnPropertyDescriptor(proto, attr)) continue\n Object.defineProperty(proto, attr, {\n get (this:HTMLElement):string|null {\n return this.getAttribute(attr)\n },\n set (this:HTMLElement, v:unknown) {\n // null and undefined both remove the attribute\n if (v == null) {\n this.removeAttribute(attr)\n } else {\n this.setAttribute(attr, String(v))\n }\n },\n configurable: true,\n enumerable: true,\n })\n }\n\n window.customElements.define(name, element)\n}\n", "/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n *\n * Copyright (c) 2026 Jake Lazaroff\n *\n * Repository: https://tangled.org/jakelazaroff.com/actor-typeahead\n */\n\nimport { WebComponent } from '@substrate-system/web-component'\n\n// for document.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'actor-typeahead':ActorTypeahead\n }\n}\n\nexport interface Actor {\n handle:string;\n avatar?:string;\n}\n\nconst DEFAULT_HOST = 'https://public.api.bsky.app'\nconst DEFAULT_ROWS = 5\n\n// The Suggestion list is a top-layer popover, positioned against the host\n// with CSS anchor positioning. `anchor-scope` shipped last of that set, so\n// it gates the group. Without it, the old absolute layout is used.\nconst ANCHORED = typeof CSS !== 'undefined' &&\n CSS.supports('anchor-scope: --a')\n\n// counts instances, so each one gets unique element ids\nlet instances = 0\n\n/**\n * @attribute {string} [host] - The host to which to make the typeahead\n * API call.\n * @attribute {number} [rows] - The maximum number of Suggestions to\n * display in the Suggestion list.\n *\n * @fires actor-typeahead:select - A Suggestion was chosen from the\n * Suggestion list. The event `detail` is `{ handle, avatar }`.\n *\n * @cssprop --color-background - Controls the color of the Suggestion list\n * background.\n * @cssprop --color-border - Controls the color of the Suggestion list\n * border.\n * @cssprop --color-shadow - Controls the color of the Suggestion list\n * shadow.\n * @cssprop --color-hover - Controls the background color of each\n * Suggestion on hover.\n * @cssprop --color-avatar-fallback - Controls the background color of an\n * avatar circle if the image fails to load.\n * @cssprop --radius - Controls the corner radius of the Suggestion list.\n * @cssprop --padding-suggestion-list - Controls the padding of the\n * Suggestion list.\n *\n * @summary A small web component that progressively enhances an <input>\n * element into an autocomplete for ATProto handles.\n *\n * @tag actor-typeahead\n */\nexport class ActorTypeahead extends WebComponent.create('actor-typeahead') {\n static reflectedStringAttributes = ['host', 'rows']\n\n declare host:string|null\n declare rows:string|null\n\n #id = `actor-typeahead-${++instances}`\n #actors:Actor[] = []\n #index = -1\n #pressed = false\n #suggestionList:HTMLUListElement|null = null\n\n constructor () {\n super()\n this.addEventListener('input', this)\n this.addEventListener('focusout', this)\n this.addEventListener('keydown', this)\n }\n\n get #limit ():number {\n const rows = Number.parseInt(this.rows ?? '')\n return Number.isNaN(rows) ? DEFAULT_ROWS : rows\n }\n\n handleEvent (evt:Event) {\n switch (evt.type) {\n case 'input':\n this.#oninput(evt)\n break\n\n case 'keydown':\n if (evt instanceof KeyboardEvent) this.#onkeydown(evt)\n break\n\n case 'focusout':\n this.#onfocusout()\n break\n\n case 'pointerdown':\n this.#pressed = true\n break\n\n case 'pointerup':\n this.#onpointerup(evt)\n break\n }\n }\n\n #onkeydown (evt:KeyboardEvent) {\n const last = this.#actors.length - 1\n\n switch (evt.key) {\n case 'ArrowDown':\n evt.preventDefault()\n this.#index = Math.min(this.#index + 1, last)\n this.render()\n break\n\n case 'PageDown':\n evt.preventDefault()\n this.#index = last\n this.render()\n break\n\n case 'ArrowUp':\n evt.preventDefault()\n this.#index = Math.max(this.#index - 1, 0)\n this.render()\n break\n\n case 'PageUp':\n evt.preventDefault()\n this.#index = 0\n this.render()\n break\n\n case 'Escape':\n evt.preventDefault()\n this.#clear()\n break\n\n case 'Enter':\n evt.preventDefault()\n this.#select(this.#index)\n break\n }\n }\n\n async #oninput (evt:Event) {\n if (!(evt.target instanceof HTMLInputElement)) return\n\n const query = evt.target.value\n if (!query) {\n this.#clear()\n return\n }\n\n const url = new URL(\n 'xrpc/app.bsky.actor.searchActorsTypeahead',\n this.host ?? DEFAULT_HOST\n )\n url.searchParams.set('q', query)\n url.searchParams.set('limit', String(this.#limit))\n\n const res = await fetch(url)\n const json:unknown = await res.json()\n this.#actors = parseActors(json)\n this.#index = -1\n this.render()\n }\n\n #onfocusout () {\n if (this.#pressed) return\n this.#clear()\n }\n\n #onpointerup (evt:Event) {\n this.#pressed = false\n\n const option = evt.target instanceof Element ?\n evt.target.closest<HTMLElement>('[role=\"option\"]') :\n null\n\n if (!option) {\n this.qs('input')?.focus()\n return\n }\n\n this.#select(Number(option.dataset.index))\n }\n\n #select (index:number) {\n const actor = this.#actors[index]\n const input = this.qs('input')\n if (!actor || !input) return\n\n input.value = actor.handle\n input.focus()\n this.#clear()\n this.emit<Actor>('select', { detail: actor })\n }\n\n #clear () {\n this.#actors = []\n this.#index = -1\n this.render()\n }\n\n /**\n * Render into light DOM, next to the authored `<input>`. Only the\n * Suggestion list is rebuilt, so the input element, and anything the\n * consumer attached to it, is never replaced. On the input, only the\n * ARIA combobox attributes are written, plus `autocomplete=\"off\"`\n * when the page did not set `autocomplete`.\n */\n render () {\n if (!this.#suggestionList) {\n this.#suggestionList = document.createElement('ul')\n this.#suggestionList.className = 'suggestion-list'\n this.#suggestionList.id = `${this.#id}-list`\n this.#suggestionList.setAttribute('role', 'listbox')\n if (ANCHORED) this.#suggestionList.popover = 'manual'\n this.#suggestionList.addEventListener('pointerdown', this)\n this.#suggestionList.addEventListener('pointerup', this)\n }\n\n const list = this.#suggestionList\n if (list.parentNode !== this) this.append(list)\n\n list.replaceChildren(...this.#actors.map((actor, i) => {\n const option = suggestion(actor, i, i === this.#index)\n option.id = this.#optionId(i)\n return option\n }))\n\n const open = this.#toggle(list, this.#actors.length > 0)\n\n const input = this.qs('input')\n if (input) {\n input.setAttribute('role', 'combobox')\n input.setAttribute('aria-autocomplete', 'list')\n if (!input.hasAttribute('autocomplete')) {\n input.setAttribute('autocomplete', 'off')\n }\n input.setAttribute('aria-controls', list.id)\n input.setAttribute('aria-expanded', String(open))\n\n const labels = [...(input.labels ?? [])]\n .map(label => label.id)\n .filter(Boolean)\n if (labels.length) {\n list.setAttribute('aria-labelledby', labels.join(' '))\n } else {\n list.removeAttribute('aria-labelledby')\n }\n\n if (this.#actors[this.#index]) {\n input.setAttribute(\n 'aria-activedescendant',\n this.#optionId(this.#index)\n )\n } else {\n input.removeAttribute('aria-activedescendant')\n }\n }\n }\n\n /**\n * Show or hide the Suggestion list popover, guarded on its current\n * state so repeated renders neither throw nor toggle. A disconnected\n * popover cannot be shown, e.g. when a response arrives after the host\n * was removed. Returns whether the Suggestion list is open.\n */\n #toggle (list:HTMLElement, open:boolean):boolean {\n if (!ANCHORED) return open\n if (!list.isConnected) return false\n\n const isOpen = list.matches(':popover-open')\n if (open && !isOpen) list.showPopover()\n if (!open && isOpen) list.hidePopover()\n return list.matches(':popover-open')\n }\n\n #optionId (index:number):string {\n return `${this.#id}-option-${index}`\n }\n}\n\nActorTypeahead.define()\n\n/**\n * Build one Suggestion. Values from the API go through `textContent` and\n * properties, never through `innerHTML`.\n */\nfunction suggestion (\n actor:Actor,\n index:number,\n active:boolean\n):HTMLLIElement {\n const li = document.createElement('li')\n li.className = 'suggestion'\n li.setAttribute('role', 'option')\n li.setAttribute('aria-selected', String(active))\n li.dataset.index = String(index)\n li.dataset.handle = actor.handle\n\n const avatar = document.createElement('div')\n avatar.className = 'avatar'\n\n const img = document.createElement('img')\n img.className = 'img'\n img.alt = ''\n if (actor.avatar) img.src = actor.avatar\n\n const handle = document.createElement('span')\n handle.className = 'handle'\n handle.textContent = actor.handle\n\n avatar.append(img)\n li.append(avatar, handle)\n\n return li\n}\n\nfunction parseActors (json:unknown):Actor[] {\n if (!isRecord(json) || !Array.isArray(json.actors)) return []\n\n return json.actors.flatMap((actor:unknown) => {\n if (!isRecord(actor) || typeof actor.handle !== 'string') return []\n\n return [typeof actor.avatar === 'string' ?\n { handle: actor.handle, avatar: actor.avatar } :\n { handle: actor.handle }]\n })\n}\n\nfunction isRecord (value:unknown):value is Record<string, unknown> {\n return typeof value === 'object' && value !== null\n}\n"],
|
|
5
|
-
"mappings": "sKASO,SAASA,EAAcC,EAAoB,CAC9C,OAAO,OAAO,KAAKA,CAAK,EAAE,OAAO,CAACC,EAAKC,IAAM,CACzC,IAAMC,EAAQH,EAAME,CAAC,EACrB,OAAKC,EAED,OAAOA,GAAU,UACbA,GAAeF,EAAM,IAAIC,CAAC,IAAI,KAAK,EAChCD,EAGP,MAAM,QAAQE,CAAK,EACXF,EAAM,IAAIC,CAAC,KAAKC,EAAM,KAAK,GAAG,CAAC,KAGnCF,EAAM,IAAIC,CAAC,KAAKC,CAAK,KAAK,KAA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,EAC/CC,EAAG,QAAQ,MAAQ,OAAOb,CAAK,EAC/Ba,EAAG,QAAQ,OAASZ,EAAM,OAE1B,IAAMa,EAAS,SAAS,cAAc,KAAK,EAC3CA,EAAO,UAAY,SAEnB,IAAMC,EAAM,SAAS,cAAc,KAAK,EACxCA,EAAI,UAAY,MAChBA,EAAI,IAAM,GACNd,EAAM,SAAQc,EAAI,IAAMd,EAAM,QAElC,IAAMe,EAAS,SAAS,cAAc,MAAM,EAC5C,OAAAA,EAAO,UAAY,SACnBA,EAAO,YAAcf,EAAM,OAE3Ba,EAAO,OAAOC,CAAG,EACjBF,EAAG,OAAOC,EAAQE,CAAM,EAEjBH,CACX,CA5BSlC,EAAA0B,EAAA,cA8BT,SAASP,EAAaD,EAAsB,CACxC,MAAI,CAACoB,EAASpB,CAAI,GAAK,CAAC,MAAM,QAAQA,EAAK,MAAM,EAAU,CAAC,EAErDA,EAAK,OAAO,QAASI,GACpB,CAACgB,EAAShB,CAAK,GAAK,OAAOA,EAAM,QAAW,SAAiB,CAAC,EAE3D,CAAC,OAAOA,EAAM,QAAW,SAC5B,CAAE,OAAQA,EAAM,OAAQ,OAAQA,EAAM,MAAO,EAC7C,CAAE,OAAQA,EAAM,MAAO,CAAC,CAC/B,CACL,CAVStB,EAAAmB,EAAA,eAYT,SAASmB,EAAUC,EAAgD,CAC/D,OAAO,OAAOA,GAAU,UAAYA,IAAU,IAClD,CAFSvC,EAAAsC,EAAA",
|
|
6
|
-
"names": ["toAttributes", "attrs", "acc", "k", "value", "__name", "qs", "selectors", "__name", "qsa", "selectors", "__name", "isRegistered", "elName", "__name", "define", "name", "element", "match", "el", "s", "WebComponent", "_WebComponent", "__name", "el", "match", "elementName", "CreatedClass", "evType", "define", "name", "oldValue", "newValue", "handler", "handlerKey", "selector", "eventName", "type", "opts", "bubbles", "cancelable", "detail", "namespacedType", "event", "evName", "options", "fullEvName", "namespace", "handlerKeys", "isRegistered", "elName", "element", "ctor", "boolAttrs", "strAttrs", "proto", "attr", "v", "DEFAULT_HOST", "DEFAULT_ROWS", "ANCHORED", "instances", "ActorTypeahead", "WebComponent", "__name", "#id", "#actors", "#index", "#
|
|
4
|
+
"sourcesContent": ["export type Attrs = Record<string, undefined|null|string|number|boolean|(string|number)[]>\n\n/**\n * Transform an object into an HTML attributes string. The object should be\n * like `{ attributeName: value }`.\n *\n * @param attrs An object for the attributes.\n * @returns {string} A string suitable for use as HTML attributes.\n */\nexport function toAttributes (attrs:Attrs):string {\n return Object.keys(attrs).reduce((acc, k) => {\n const value = attrs[k]\n if (!value) return acc\n\n if (typeof value === 'boolean') {\n if (value) return (acc + ` ${k}`).trim()\n return acc\n }\n\n if (Array.isArray(value)) {\n return (acc + ` ${k}=\"${value.join(' ')}\"`)\n }\n\n return (acc + ` ${k}=\"${value}\"`).trim()\n }, '')\n}\n", "export function qs<K extends keyof HTMLElementTagNameMap> (\n selectors:K\n):HTMLElementTagNameMap[K]|null\n\nexport function qs<K extends keyof SVGElementTagNameMap> (\n selectors:K\n):SVGElementTagNameMap[K]|null\n\nexport function qs<E extends Element = Element> (\n selectors:string\n):E|null\n\nexport function qs (selectors:string):Element|null {\n return document.querySelector(selectors)\n}\n", "export function qsa<K extends keyof HTMLElementTagNameMap> (\n selectors:K\n):NodeListOf<HTMLElementTagNameMap[K]>\n\nexport function qsa<K extends keyof SVGElementTagNameMap> (\n selectors:K\n):NodeListOf<SVGElementTagNameMap[K]>\n\nexport function qsa<E extends Element = Element> (\n selectors:string\n):NodeListOf<E>\n\nexport function qsa (selectors:string):NodeListOf<Element> {\n return document.querySelectorAll(selectors)\n}\n", "export { toAttributes } from './attributes.js'\n\n/**\n * Check if the given tag name has been registered.\n *\n * @see {@link https://stackoverflow.com/a/28210364 stackoverflow}\n * @param {string} elName The custom element tag name.\n * @returns {boolean} True if the given name has been registered already.\n */\nexport function isRegistered (elName:string):boolean {\n return document.createElement(elName).constructor !== window.HTMLElement\n}\n\nexport function define (name:string, element:CustomElementConstructor) {\n if (typeof window === 'undefined') return\n if (!('customElements' in window)) return\n if (!isRegistered(name)) {\n window.customElements.define(name, element)\n }\n}\n\n/**\n * Get the closes parent element matching the given selector.\n * @param el Element to start from\n * @param s Selector for an element\n * @returns {HTMLElement|null} The closes parent element that matches.\n */\nexport function match (el:HTMLElement, s:string):HTMLElement|null {\n if (!el.matches) el = el.parentElement!\n return el.matches(s) ? el : el.closest(s)\n}\n\nexport * from './qs.js'\nexport * from './qsa.js'\n", "import { match as _match } from './util.js'\n\nexport abstract class WebComponent extends window.HTMLElement {\n static TAG:string = ''\n TAG:string = ''\n\n /**\n * Declare boolean attributes that should be reflected as properties.\n * The base class auto-generates getters/setters and includes these in\n * `observedAttributes`. Framework property assignment (e.g. Preact's\n * `el.disabled = true`) will then correctly set the attribute.\n */\n static reflectedBooleanAttributes:string[] = []\n\n /**\n * Declare string attributes that should be reflected as properties.\n * Getter returns `string|null` (null when attribute is absent).\n * Setting `null` or `undefined` removes the attribute.\n */\n static reflectedStringAttributes:string[] = []\n\n /**\n * Auto-derived from `reflectedBooleanAttributes` and\n * `reflectedStringAttributes`. Override with `super.observedAttributes`\n * to add non-reflected observed attributes:\n *\n * ```ts\n * static get observedAttributes () {\n * return [...super.observedAttributes, 'aria-label']\n * }\n * ```\n */\n static get observedAttributes ():string[] {\n return [...new Set([\n ...this.reflectedBooleanAttributes,\n ...this.reflectedStringAttributes,\n ])]\n }\n\n static match (el:HTMLElement):HTMLElement|null {\n return _match(el, this.TAG)\n }\n\n static create<T extends string> (elementName:T):typeof WebComponent & {\n new (...args:any[]):WebComponent & { TAG:T };\n TAG:T;\n define: typeof WebComponent.define;\n event: typeof WebComponent.event;\n } {\n const CreatedClass = class extends WebComponent {\n static TAG = elementName\n TAG = elementName\n render () {\n throw new Error('`render` should be implemented by children')\n }\n }\n\n // Copy static methods with proper binding\n CreatedClass.define = function () {\n return WebComponent.define.call(this)\n }\n CreatedClass.event = function (evType:string) {\n return WebComponent.event.call(this, evType)\n }\n\n return CreatedClass\n }\n\n static define<T extends {\n new (...args:any[]):WebComponent;\n TAG:string;\n }>(this:T) {\n define(this.TAG, this)\n }\n\n /**\n * Runs when the value of an attribute is changed.\n *\n * Depends on `static observedAttributes`.\n *\n * Should name methods like `handleChange_disabled`.\n *\n * @param {string} name The attribute name\n * @param {string} oldValue The old attribute value\n * @param {string} newValue The new attribute value\n */\n attributeChangedCallback (\n name:string,\n oldValue:string,\n newValue:string\n ):void {\n const handler = this[handlerKey(name)]\n if (handler) {\n handler.call(this, oldValue, newValue)\n }\n }\n\n connectedCallback () {\n this.render()\n }\n\n abstract render ():any\n\n qs<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):HTMLElementTagNameMap[K]|null;\n\n qs<E extends Element = Element>(selector:string):E|null;\n qs (selector:string):Element|null {\n return this.querySelector(selector)\n }\n\n qsa<K extends keyof HTMLElementTagNameMap>(\n selector:K\n ):HTMLElementTagNameMap[K]|null;\n\n qsa<E extends Element = Element>(selector:string):E|null;\n qsa (selector:string):NodeListOf<Element> {\n return this.querySelectorAll(selector)\n }\n\n /**\n * Take a non-namepsaced event name, return namespace event name.\n *\n * @param {string} evType The non-namespace event name\n * @returns {string} Namespaced event name, eg, `my-component:click`\n */\n static event (evType:string):string {\n return eventName(this.TAG, evType)\n }\n\n /**\n * Emit a namespaced event.\n *\n * @param type (non-namespaced) event type string\n * @param opts `bubbles`, `detail`, and `cancelable`. Default is\n * `{ bubbles: true, cancelable: true }`\n * @returns {boolean}\n */\n emit<T = any> (type:string, opts:Partial<{\n bubbles:boolean,\n cancelable:boolean,\n detail:CustomEvent<T>['detail']\n }> = {}):boolean {\n if (type === '*') throw new Error('Do not emit the literal \"*\"')\n\n const { bubbles = true, cancelable = true, detail } = opts\n const namespacedType = `${this.TAG}:${type}`\n\n const event = new CustomEvent(namespacedType, {\n bubbles,\n cancelable,\n detail\n })\n\n return this.dispatchEvent(event)\n }\n\n /**\n * Create and emit an event, no namespacing.\n */\n dispatch<T> (type:string, opts:Partial<{\n bubbles:boolean,\n cancelable:boolean,\n detail:CustomEvent<T>['detail']\n }> = {}):boolean {\n const event = new CustomEvent(type, {\n bubbles: (opts.bubbles === undefined) ? true : opts.bubbles,\n cancelable: (opts.cancelable === undefined) ? true : opts.cancelable,\n detail: opts.detail\n })\n\n return this.dispatchEvent(event)\n }\n\n /**\n * Listen for namespaced events.\n */\n on<T extends Event = Event> (\n evName:string,\n handler:(ev:T)=>any,\n options?:boolean|AddEventListenerOptions\n ):void;\n\n on (\n evName:string,\n handler:EventListenerObject,\n options?:boolean|AddEventListenerOptions\n ):void;\n\n on (\n evName:string,\n handler:((ev:Event)=>any)|EventListenerObject,\n options?:boolean|AddEventListenerOptions\n ):void {\n const fullEvName = WebComponent.event.call(this, evName)\n this.addEventListener(fullEvName, handler as EventListenerOrEventListenerObject, options)\n }\n\n /**\n * Remove a namespaced event listener.\n */\n off<T extends Event = Event> (\n evName:string,\n handler:(ev:T)=>any,\n options?:boolean|EventListenerOptions\n ):void;\n\n off (\n evName:string,\n handler:EventListenerObject,\n options?:boolean|EventListenerOptions\n ):void;\n\n off (\n evName:string,\n handler:((ev:Event)=>any)|EventListenerObject,\n options?:boolean|EventListenerOptions\n ):void {\n const fullEvName = WebComponent.event.call(this, evName)\n this.removeEventListener(fullEvName, handler as EventListenerOrEventListenerObject, options)\n }\n}\n\nfunction eventName (namespace:string, evType:string) {\n return `${namespace}:${evType}`\n}\n\n/**\n * Cache of attribute name -> handler method name (`handleChange_<attr>`).\n * Building the lookup string once per attribute avoids re-allocating it on\n * every `attributeChangedCallback`.\n */\nconst handlerKeys:Record<string, string> = Object.create(null)\nfunction handlerKey (name:string):string {\n return handlerKeys[name] || (handlerKeys[name] = `handleChange_${name}`)\n}\n\n/**\n * Check if the given tag name has been registered.\n *\n * @see {@link https://stackoverflow.com/a/28210364 stackoverflow}\n * @param {string} elName The custom element tag name.\n * @returns {boolean} True if the given name has been registered already.\n */\nexport function isRegistered (elName:string):boolean {\n return document.createElement(elName).constructor !== window.HTMLElement\n}\n\nexport function define (name:string, element:CustomElementConstructor) {\n if (typeof window === 'undefined') return\n if (!('customElements' in window)) return\n if (isRegistered(name)) return\n\n const ctor = element as unknown as typeof WebComponent\n const boolAttrs:string[] = ctor.reflectedBooleanAttributes ?? []\n const strAttrs:string[] = ctor.reflectedStringAttributes ?? []\n const proto = (element as any).prototype\n\n for (const attr of boolAttrs) {\n // Skip built-in IDL attributes on HTMLElement and ancestors\n // (covers Element.prototype, Node.prototype, etc.)\n if (attr in HTMLElement.prototype) continue\n // Skip if the subclass already defines an own-property accessor\n if (Object.getOwnPropertyDescriptor(proto, attr)) continue\n Object.defineProperty(proto, attr, {\n get (this:HTMLElement):boolean {\n return this.hasAttribute(attr)\n },\n set (this:HTMLElement, v:unknown) {\n this.toggleAttribute(attr, Boolean(v))\n },\n configurable: true,\n enumerable: true,\n })\n }\n\n for (const attr of strAttrs) {\n if (boolAttrs.includes(attr)) {\n console.warn(\n `[web-component] \"${attr}\" appears in both ` +\n 'reflectedBooleanAttributes and reflectedStringAttributes ' +\n `on <${name}>. Boolean wins.`\n )\n continue\n }\n if (attr in HTMLElement.prototype) continue\n if (Object.getOwnPropertyDescriptor(proto, attr)) continue\n Object.defineProperty(proto, attr, {\n get (this:HTMLElement):string|null {\n return this.getAttribute(attr)\n },\n set (this:HTMLElement, v:unknown) {\n // null and undefined both remove the attribute\n if (v == null) {\n this.removeAttribute(attr)\n } else {\n this.setAttribute(attr, String(v))\n }\n },\n configurable: true,\n enumerable: true,\n })\n }\n\n window.customElements.define(name, element)\n}\n", "/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n *\n * Copyright (c) 2026 Jake Lazaroff\n *\n * Repository: https://tangled.org/jakelazaroff.com/actor-typeahead\n */\n\nimport { WebComponent } from '@substrate-system/web-component'\n\n// for document.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'actor-typeahead':ActorTypeahead\n }\n}\n\nexport interface Actor {\n handle:string;\n avatar?:string;\n}\n\nconst DEFAULT_HOST = 'https://public.api.bsky.app'\nconst DEFAULT_ROWS = 5\n\n// how long the Query must stay unchanged before a Typeahead request\nconst DEBOUNCE_MS = 150\n\n// The Suggestion list is a top-layer popover, positioned against the host\n// with CSS anchor positioning. `anchor-scope` shipped last of that set, so\n// it gates the group. Without it, the old absolute layout is used.\nconst ANCHORED = typeof CSS !== 'undefined' &&\n CSS.supports('anchor-scope: --a')\n\n// counts instances, so each one gets unique element ids\nlet instances = 0\n\n/**\n * @attribute {string} [host] - The host to which to make the typeahead\n * API call.\n * @attribute {number} [rows] - The maximum number of Suggestions to\n * display in the Suggestion list.\n *\n * @fires actor-typeahead:select - A Suggestion was chosen from the\n * Suggestion list. The event `detail` is `{ handle, avatar }`.\n *\n * @cssprop --color-background - Controls the color of the Suggestion list\n * background.\n * @cssprop --color-border - Controls the color of the Suggestion list\n * border.\n * @cssprop --color-shadow - Controls the color of the Suggestion list\n * shadow.\n * @cssprop --color-hover - Controls the background color of each\n * Suggestion on hover.\n * @cssprop --color-avatar-fallback - Controls the background color of an\n * avatar circle if the image fails to load.\n * @cssprop --radius - Controls the corner radius of the Suggestion list.\n * @cssprop --padding-suggestion-list - Controls the padding of the\n * Suggestion list.\n *\n * @summary A small web component that progressively enhances an <input>\n * element into an autocomplete for ATProto handles.\n *\n * @tag actor-typeahead\n */\nexport class ActorTypeahead extends WebComponent.create('actor-typeahead') {\n static reflectedStringAttributes = ['host', 'rows']\n\n declare host:string|null\n declare rows:string|null\n\n /**\n * Returns the text announced when a Typeahead request settles with\n * `count` Suggestions, including 0 when nothing matched the Query.\n * Defaults to English. Replace it to translate; the replacement\n * handles plurals and 0. Read at announce time, so it can be set\n * after connect.\n */\n announce:(count:number) => string = defaultAnnounce\n\n #id = `actor-typeahead-${++instances}`\n #actors:Actor[] = []\n #index = -1\n #suggestionList:HTMLDivElement|null = null\n #suggestionCount:HTMLDivElement|null = null\n #nbsp = false\n #timer:ReturnType<typeof setTimeout>|undefined\n #controller:AbortController|null = null\n\n constructor () {\n super()\n this.addEventListener('input', this)\n this.addEventListener('focusout', this)\n this.addEventListener('keydown', this)\n }\n\n /**\n * Stop any pending Typeahead request. The Suggestion list is left as\n * is; the next Query rebuilds it.\n */\n disconnectedCallback () {\n this.#cancel()\n }\n\n get #limit ():number {\n const rows = Number.parseInt(this.rows ?? '')\n return Number.isNaN(rows) ? DEFAULT_ROWS : rows\n }\n\n handleEvent (evt:Event) {\n switch (evt.type) {\n case 'input':\n this.#oninput(evt)\n break\n\n case 'keydown':\n if (evt instanceof KeyboardEvent) this.#onkeydown(evt)\n break\n\n case 'focusout':\n if (evt instanceof FocusEvent) this.#onfocusout(evt)\n break\n\n case 'mousedown':\n // a press or a tap keeps focus on the Authored input\n evt.preventDefault()\n break\n\n case 'click':\n this.#onclick(evt)\n break\n }\n }\n\n #onkeydown (evt:KeyboardEvent) {\n const last = this.#actors.length - 1\n const moves = ['ArrowDown', 'ArrowUp', 'PageDown', 'PageUp']\n // with no Suggestions there is nothing to move to, and a render\n // would empty a \"No Suggestions\" announcement\n if (last < 0 && moves.includes(evt.key)) {\n evt.preventDefault()\n return\n }\n\n switch (evt.key) {\n case 'ArrowDown':\n evt.preventDefault()\n this.#index = Math.min(this.#index + 1, last)\n this.render()\n break\n\n case 'PageDown':\n evt.preventDefault()\n this.#index = last\n this.render()\n break\n\n case 'ArrowUp':\n evt.preventDefault()\n // wrap from nothing Highlighted to the last Suggestion,\n // and from the first back to nothing (the APG pattern)\n this.#index = this.#index < 0 ? last : this.#index - 1\n this.render()\n break\n\n case 'PageUp':\n evt.preventDefault()\n this.#index = 0\n this.render()\n break\n\n case 'Escape':\n // with the list closed, let a dialog close; still cancel\n // any pending Typeahead request\n if (this.#actors.length) evt.preventDefault()\n this.#clear()\n break\n\n case 'Enter':\n // with nothing Highlighted, let the form submit, and\n // drop any pending Typeahead request\n if (!this.#actors[this.#index]) {\n this.#cancel()\n break\n }\n evt.preventDefault()\n this.#select(this.#index)\n break\n }\n }\n\n #oninput (evt:Event) {\n if (!(evt.target instanceof HTMLInputElement)) return\n\n const query = evt.target.value\n if (!query) {\n this.#clear()\n return\n }\n\n // keep the current Suggestions on screen until the new response\n this.#cancel()\n this.#timer = setTimeout(() => this.#request(query), DEBOUNCE_MS)\n }\n\n async #request (query:string) {\n this.#timer = undefined\n const url = new URL(\n 'xrpc/app.bsky.actor.searchActorsTypeahead',\n this.host ?? DEFAULT_HOST\n )\n url.searchParams.set('q', query)\n url.searchParams.set('limit', String(this.#limit))\n\n const controller = new AbortController()\n this.#controller = controller\n const { signal } = controller\n\n let json:unknown\n try {\n const res = await fetch(url, { signal })\n if (signal.aborted) return\n if (!res.ok) throw new Error(`status ${res.status}`)\n json = await res.json()\n } catch (err) {\n // a newer Query, or a close, cancelled this request\n if (isAbortError(err)) return\n // any other failure closes the Suggestion list, quietly\n this.#clear()\n return\n }\n if (signal.aborted) return\n\n this.#actors = parseActors(json)\n this.#index = -1\n // after render(), which empties the count when there are none\n this.render()\n this.#announce(this.#actors.length)\n }\n\n /**\n * Write the Suggestion count. A trailing no-break space alternates\n * between writes, so screen readers re-read an identical count.\n */\n #announce (count:number) {\n if (!this.#suggestionCount) return\n this.#nbsp = !this.#nbsp\n this.#suggestionCount.textContent = this.announce(count) +\n (this.#nbsp ? '\\u00a0' : '')\n }\n\n /**\n * Close only when focus leaves the host. Some assistive technology\n * focuses a Suggestion before it sends the click that selects it.\n */\n #onfocusout (evt:FocusEvent) {\n const next = evt.relatedTarget\n if (next instanceof Node && this.contains(next)) return\n this.#clear()\n }\n\n #onclick (evt:Event) {\n const option = evt.target instanceof Element ?\n evt.target.closest<HTMLElement>('[role=\"option\"]') :\n null\n if (!option) return\n\n this.#select(Number(option.dataset.index))\n }\n\n #select (index:number) {\n const actor = this.#actors[index]\n const input = this.qs('input')\n if (!actor || !input) return\n\n input.value = actor.handle\n input.focus()\n this.#clear()\n this.emit<Actor>('select', { detail: actor })\n }\n\n /**\n * Stop any pending Typeahead request: the debounce timer, and the\n * request in flight, whose response is then dropped.\n */\n #cancel () {\n clearTimeout(this.#timer)\n this.#timer = undefined\n this.#controller?.abort()\n this.#controller = null\n }\n\n #clear () {\n this.#cancel()\n this.#actors = []\n this.#index = -1\n this.render()\n }\n\n /**\n * Render into light DOM. Only the suggestion list is rebuilt,\n * so the input element, and anything the consumer attached to it,\n * is never replaced. On the input, only the\n * ARIA combobox attributes are written, plus `autocomplete=\"off\"`\n * when the page did not set `autocomplete`.\n */\n render () {\n if (!this.#suggestionList) {\n this.#suggestionList = document.createElement('div')\n this.#suggestionList.className = 'suggestion-list'\n this.#suggestionList.id = `${this.#id}-list`\n this.#suggestionList.setAttribute('role', 'listbox')\n if (ANCHORED) this.#suggestionList.popover = 'manual'\n this.#suggestionList.addEventListener('mousedown', this)\n this.#suggestionList.addEventListener('click', this)\n }\n\n const list = this.#suggestionList\n if (list.parentNode !== this) this.append(list)\n\n // the live region exists empty before its first write, because\n // screen readers often skip a region inserted already filled\n if (!this.#suggestionCount) {\n this.#suggestionCount = document.createElement('div')\n this.#suggestionCount.className = 'suggestion-count'\n this.#suggestionCount.setAttribute('role', 'status')\n }\n const count = this.#suggestionCount\n if (count.parentNode !== this) this.append(count)\n // only a response writes the count; any close empties it, and a\n // response with no Suggestions writes it after this render\n if (!this.#actors.length) count.textContent = ''\n\n list.replaceChildren(...this.#actors.map((actor, i) => {\n const option = suggestion(actor, i, i === this.#index)\n option.id = this.#optionId(i)\n return option\n }))\n\n const open = this.#toggle(list, this.#actors.length > 0)\n\n const input = this.qs('input')\n if (input) {\n input.setAttribute('role', 'combobox')\n input.setAttribute('aria-autocomplete', 'list')\n if (!input.hasAttribute('autocomplete')) {\n input.setAttribute('autocomplete', 'off')\n }\n input.setAttribute('aria-controls', list.id)\n input.setAttribute('aria-expanded', String(open))\n\n // the Suggestion list carries at most one of the two\n const name = nameSource(input, this)\n for (const attr of ['aria-labelledby', 'aria-label'] as const) {\n const value = name[attr]\n if (value) list.setAttribute(attr, value)\n else list.removeAttribute(attr)\n }\n\n if (this.#actors[this.#index]) {\n input.setAttribute(\n 'aria-activedescendant',\n this.#optionId(this.#index)\n )\n } else {\n input.removeAttribute('aria-activedescendant')\n }\n }\n }\n\n /**\n * Show or hide the Suggestion list popover, guarded on its current\n * state so repeated renders neither throw nor toggle. A disconnected\n * popover cannot be shown, e.g. when a response arrives after the host\n * was removed. Returns whether the Suggestion list is open.\n */\n #toggle (list:HTMLElement, open:boolean):boolean {\n if (!ANCHORED) return open\n if (!list.isConnected) return false\n\n const isOpen = list.matches(':popover-open')\n if (open && !isOpen) list.showPopover()\n if (!open && isOpen) list.hidePopover()\n return list.matches(':popover-open')\n }\n\n #optionId (index:number):string {\n return `${this.#id}-option-${index}`\n }\n}\n\nActorTypeahead.define()\n\n/**\n * Build one Suggestion. Values from the API go through `textContent` and\n * properties, never through `innerHTML`.\n */\nfunction suggestion (\n actor:Actor,\n index:number,\n active:boolean\n):HTMLButtonElement {\n const button = document.createElement('button')\n // a button, so every input method can activate it, but not a\n // submit button, and out of the tab order, because focus stays on\n // the Authored input\n button.type = 'button'\n button.tabIndex = -1\n button.className = 'suggestion'\n button.setAttribute('role', 'option')\n button.setAttribute('aria-selected', String(active))\n button.dataset.index = String(index)\n button.dataset.handle = actor.handle\n\n const avatar = document.createElement('div')\n avatar.className = 'avatar'\n\n const img = document.createElement('img')\n img.className = 'img'\n img.alt = ''\n if (actor.avatar) img.src = actor.avatar\n\n const handle = document.createElement('span')\n handle.className = 'handle'\n handle.textContent = actor.handle\n\n avatar.append(img)\n button.append(avatar, handle)\n\n return button\n}\n\n/**\n * What names the Authored input, in the order of accessible name\n * computation, as the attribute the Suggestion list copies it to.\n */\nfunction nameSource (input:HTMLInputElement, host:HTMLElement):{\n 'aria-labelledby'?:string;\n 'aria-label'?:string;\n} {\n const labelledby = input.getAttribute('aria-labelledby')\n if (labelledby) return { 'aria-labelledby': labelledby }\n\n const label = input.getAttribute('aria-label')\n if (label) return { 'aria-label': label }\n\n // reference the labels when they all have ids, otherwise copy their\n // text, because the component never writes ids onto the page\n const labels = [...(input.labels ?? [])]\n if (!labels.length) return {}\n if (labels.every(label => label.id)) {\n return {\n 'aria-labelledby': labels.map(label => label.id).join(' ')\n }\n }\n\n const text = labels\n .map(label => labelText(label, host).trim())\n .filter(Boolean)\n .join(' ')\n return text ? { 'aria-label': text } : {}\n}\n\n/**\n * The text of a label, without the Host element's content, which a\n * label that wraps the Host element would otherwise include.\n */\nfunction labelText (label:HTMLLabelElement, host:HTMLElement):string {\n const walker = document.createTreeWalker(label, NodeFilter.SHOW_TEXT, {\n acceptNode: node => host.contains(node) ?\n NodeFilter.FILTER_REJECT :\n NodeFilter.FILTER_ACCEPT\n })\n\n let text = ''\n while (walker.nextNode()) text += walker.currentNode.nodeValue\n return text\n}\n\n/**\n * The default English Suggestion count announcement.\n */\nfunction defaultAnnounce (count:number):string {\n if (count === 0) return 'No Suggestions'\n return count === 1 ?\n '1 Suggestion available' :\n `${count} Suggestions available`\n}\n\nfunction parseActors (json:unknown):Actor[] {\n if (!isRecord(json) || !Array.isArray(json.actors)) return []\n\n return json.actors.flatMap((actor:unknown) => {\n if (!isRecord(actor) || typeof actor.handle !== 'string') return []\n\n return [typeof actor.avatar === 'string' ?\n { handle: actor.handle, avatar: actor.avatar } :\n { handle: actor.handle }]\n })\n}\n\nfunction isAbortError (err:unknown):boolean {\n return err instanceof DOMException && err.name === 'AbortError'\n}\n\nfunction isRecord (value:unknown):value is Record<string, unknown> {\n return typeof value === 'object' && value !== null\n}\n"],
|
|
5
|
+
"mappings": "sKASO,SAASA,EAAcC,EAAoB,CAC9C,OAAO,OAAO,KAAKA,CAAK,EAAE,OAAO,CAACC,EAAKC,IAAM,CACzC,IAAMC,EAAQH,EAAME,CAAC,EACrB,OAAKC,EAED,OAAOA,GAAU,UACbA,GAAeF,EAAM,IAAIC,CAAC,IAAI,KAAK,EAChCD,EAGP,MAAM,QAAQE,C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AOF,CAAI,EAAE,KAAK,CAAC,EAC1C,OAAO,OAAO,EACd,KAAK,GAAG,EACb,OAAOI,EAAO,CAAE,aAAcA,CAAK,EAAI,CAAC,CAC5C,CAzBS1D,EAAA6C,EAAA,cA+BT,SAASc,EAAWH,EAAwBF,EAAyB,CACjE,IAAMM,EAAS,SAAS,iBAAiBJ,EAAO,WAAW,UAAW,CAClE,WAAYxD,EAAA6D,GAAQP,EAAK,SAASO,CAAI,EAClC,WAAW,cACX,WAAW,cAFH,aAGhB,CAAC,EAEGH,EAAO,GACX,KAAOE,EAAO,SAAS,GAAGF,GAAQE,EAAO,YAAY,UACrD,OAAOF,CACX,CAVS1D,EAAA2D,EAAA,aAeT,SAAS1D,EAAiBgC,EAAqB,CAC3C,OAAIA,IAAU,EAAU,iBACjBA,IAAU,EACb,yBACA,GAAGA,CAAK,wBAChB,CALSjC,EAAAC,EAAA,mBAOT,SAAS8B,EAAaJ,EAAsB,CACxC,MAAI,CAACmC,EAASnC,CAAI,GAAK,CAAC,MAAM,QAAQA,EAAK,MAAM,EAAU,CAAC,EAErDA,EAAK,OAAO,QAASU,GACpB,CAACyB,EAASzB,CAAK,GAAK,OAAOA,EAAM,QAAW,SAAiB,CAAC,EAE3D,CAAC,OAAOA,EAAM,QAAW,SAC5B,CAAE,OAAQA,EAAM,OAAQ,OAAQA,EAAM,MAAO,EAC7C,CAAE,OAAQA,EAAM,MAAO,CAAC,CAC/B,CACL,CAVSrC,EAAA+B,EAAA,eAYT,SAASD,EAAcD,EAAqB,CACxC,OAAOA,aAAe,cAAgBA,EAAI,OAAS,YACvD,CAFS7B,EAAA8B,EAAA,gBAIT,SAASgC,EAAUf,EAAgD,CAC/D,OAAO,OAAOA,GAAU,UAAYA,IAAU,IAClD,CAFS/C,EAAA8D,EAAA",
|
|
6
|
+
"names": ["toAttributes", "attrs", "acc", "k", "value", "__name", "qs", "selectors", "__name", "qsa", "selectors", "__name", "isRegistered", "elName", "__name", "define", "name", "element", "match", "el", "s", "WebComponent", "_WebComponent", "__name", "el", "match", "elementName", "CreatedClass", "evType", "define", "name", "oldValue", "newValue", "handler", "handlerKey", "selector", "eventName", "type", "opts", "bubbles", "cancelable", "detail", "namespacedType", "event", "evName", "options", "fullEvName", "namespace", "handlerKeys", "isRegistered", "elName", "element", "ctor", "boolAttrs", "strAttrs", "proto", "attr", "v", "DEFAULT_HOST", "DEFAULT_ROWS", "DEBOUNCE_MS", "ANCHORED", "instances", "ActorTypeahead", "WebComponent", "__name", "defaultAnnounce", "#id", "#actors", "#index", "#suggestionList", "#suggestionCount", "#nbsp", "#timer", "#controller", "#cancel", "#limit", "rows", "evt", "#oninput", "#onkeydown", "#onfocusout", "#onclick", "last", "moves", "#clear", "#select", "query", "#request", "url", "controller", "signal", "json", "res", "err", "isAbortError", "parseActors", "#announce", "count", "next", "option", "index", "actor", "input", "list", "suggestion", "#optionId", "open", "#toggle", "name", "nameSource", "attr", "value", "isOpen", "active", "button", "avatar", "img", "handle", "host", "labelledby", "label", "labels", "text", "labelText", "walker", "node", "isRecord"]
|
|
7
7
|
}
|
package/dist/meta.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"inputs": {
|
|
3
3
|
"src/index.ts": {
|
|
4
|
-
"bytes":
|
|
4
|
+
"bytes": 16700,
|
|
5
5
|
"imports": [],
|
|
6
6
|
"format": "esm"
|
|
7
7
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"imports": [],
|
|
12
12
|
"exports": [],
|
|
13
13
|
"inputs": {},
|
|
14
|
-
"bytes":
|
|
14
|
+
"bytes": 24371
|
|
15
15
|
},
|
|
16
16
|
"dist/index.js": {
|
|
17
17
|
"imports": [
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"entryPoint": "src/index.ts",
|
|
28
28
|
"inputs": {
|
|
29
29
|
"src/index.ts": {
|
|
30
|
-
"bytesInOutput":
|
|
30
|
+
"bytesInOutput": 11159
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
"bytes":
|
|
33
|
+
"bytes": 11351
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrate-system/actor-typeahead",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "A small web component that progressively enhances an <input> element into an autocomplete for ATProto handles.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"lint": "eslint \"./**/*.{ts,js}\"",
|
|
30
|
-
"test": "esbuild ./test/index.ts --bundle | tapout",
|
|
30
|
+
"test": "esbuild ./test/index.ts --bundle | tapout --timeout 60000",
|
|
31
31
|
"build-css": "lightningcss --nesting src/index.css -o dist/index.css",
|
|
32
32
|
"build-css:min": "lightningcss --nesting --minify src/index.css -o dist/index.min.css",
|
|
33
33
|
"build-cjs": "esbuild src/*.ts --format=cjs --keep-names --tsconfig=tsconfig.build.json --outdir=./dist --out-extension:.js=.cjs --sourcemap",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@custom-elements-manifest/analyzer": "^0.11.0",
|
|
51
51
|
"@substrate-system/dom": "^0.1.17",
|
|
52
|
-
"@substrate-system/input": "^0.0.29",
|
|
53
52
|
"@substrate-system/tapout": "^0.0.44",
|
|
54
53
|
"@substrate-system/tapzero": "^0.10.16",
|
|
55
54
|
"@typescript-eslint/eslint-plugin": "^8.7.0",
|
|
@@ -62,7 +61,7 @@
|
|
|
62
61
|
"lightningcss": "^1.30.2",
|
|
63
62
|
"lightningcss-cli": "^1.33.0",
|
|
64
63
|
"markdown-toc": "^1.2.0",
|
|
65
|
-
"nightralph": "^0.
|
|
64
|
+
"nightralph": "^0.1.4",
|
|
66
65
|
"stylelint": "^17.0.0",
|
|
67
66
|
"stylelint-config-standard": "^40.0.0",
|
|
68
67
|
"typescript": "^6.0.2",
|