ember-primitives 0.63.0 → 0.63.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.
@@ -76,8 +76,8 @@ interface PrivateListSignature {
76
76
  }>;
77
77
  onPointerMove: (event: PointerEvent) => void;
78
78
  onClick: (event: MouseEvent) => void;
79
- Item: ListSignature["Blocks"]["default"][0]["Item"];
80
- LinkItem: ListSignature["Blocks"]["default"][0]["LinkItem"];
79
+ item: ListSignature["Blocks"]["default"][0]["Item"];
80
+ linkItem: ListSignature["Blocks"]["default"][0]["LinkItem"];
81
81
  };
82
82
  Blocks: ListSignature["Blocks"];
83
83
  }
@@ -266,7 +266,7 @@ export interface BlockSignature {
266
266
  /**
267
267
  * The listbox the rows are rendered into.
268
268
  */
269
- List: WithBoundArgs<typeof List, "id" | "register" | "onPointerMove" | "onClick" | "Item" | "LinkItem">;
269
+ List: WithBoundArgs<typeof List, "id" | "register" | "onPointerMove" | "onClick" | "item" | "linkItem">;
270
270
  }
271
271
  ];
272
272
  };
@@ -87,7 +87,7 @@ class LinkItem extends Component {
87
87
  * rows and tell a screen reader about neither, so the pointer sets the same
88
88
  * state the arrow keys do instead of painting its own.
89
89
  */
90
- const List = setComponentTemplate(precompileTemplate("<div id={{@id}} role=\"listbox\" {{@register}} {{on \"click\" @onClick}} {{on \"pointermove\" @onPointerMove}} ...attributes>\n {{yield (hash Item=@Item LinkItem=@LinkItem)}}\n</div>", {
90
+ const List = setComponentTemplate(precompileTemplate("<div id={{@id}} role=\"listbox\" {{@register}} {{on \"click\" @onClick}} {{on \"pointermove\" @onPointerMove}} ...attributes>\n {{yield (hash Item=@item LinkItem=@linkItem)}}\n</div>", {
91
91
  strictMode: true,
92
92
  scope: () => ({
93
93
  on,
@@ -349,7 +349,7 @@ class CommandPalette extends Component {
349
349
  this.#select(option, event);
350
350
  };
351
351
  static {
352
- setComponentTemplate(precompileTemplate("{{#let (component Input listId=this.listId activeId=this.activeId query=this.query onInput=this.handleInput onKeydown=this.handleKeydown) (component List id=this.listId register=this.registerList onPointerMove=this.handlePointerMove onClick=this.handleClick Item=(component Item activeId=this.activeId) LinkItem=(component LinkItem activeId=this.activeId)) as |PaletteInput PaletteList|}}\n {{#if this.hasItems}}\n {{#if (has-block)}}{{this.bothGiven}}{{/if}}\n\n <PaletteInput class=\"ember-primitives__command-palette__input\" placeholder={{this.placeholder}} aria-label={{this.placeholder}} />\n\n <PaletteList class=\"ember-primitives__command-palette__list\" as |l|>\n {{#each @items as |item|}}\n <l.Item class=\"ember-primitives__command-palette__item\">\n {{#if (iconOf item)}}\n <span class=\"ember-primitives__command-palette__icon\">{{iconOf item}}</span>\n {{/if}}\n <span class=\"ember-primitives__command-palette__label\">{{labelOf item}}</span>\n {{#if (descriptionOf item)}}\n <span class=\"ember-primitives__command-palette__description\">{{descriptionOf item}}</span>\n {{/if}}\n </l.Item>\n {{/each}}\n </PaletteList>\n\n <VisuallyHidden role=\"status\">{{this.resultsText}}</VisuallyHidden>\n {{else}}\n {{yield (hash query=this.query setQuery=this.setQuery Input=PaletteInput List=PaletteList)}}\n {{/if}}\n{{/let}}", {
352
+ setComponentTemplate(precompileTemplate("{{#let (component Input listId=this.listId activeId=this.activeId query=this.query onInput=this.handleInput onKeydown=this.handleKeydown) (component List id=this.listId register=this.registerList onPointerMove=this.handlePointerMove onClick=this.handleClick item=(component Item activeId=this.activeId) linkItem=(component LinkItem activeId=this.activeId)) as |PaletteInput PaletteList|}}\n {{#if this.hasItems}}\n {{#if (has-block)}}{{this.bothGiven}}{{/if}}\n\n <PaletteInput class=\"ember-primitives__command-palette__input\" placeholder={{this.placeholder}} aria-label={{this.placeholder}} />\n\n <PaletteList class=\"ember-primitives__command-palette__list\" as |l|>\n {{#each @items as |item|}}\n <l.Item class=\"ember-primitives__command-palette__item\">\n {{#if (iconOf item)}}\n <span class=\"ember-primitives__command-palette__icon\">{{iconOf item}}</span>\n {{/if}}\n <span class=\"ember-primitives__command-palette__label\">{{labelOf item}}</span>\n {{#if (descriptionOf item)}}\n <span class=\"ember-primitives__command-palette__description\">{{descriptionOf item}}</span>\n {{/if}}\n </l.Item>\n {{/each}}\n </PaletteList>\n\n <VisuallyHidden role=\"status\">{{this.resultsText}}</VisuallyHidden>\n {{else}}\n {{yield (hash query=this.query setQuery=this.setQuery Input=PaletteInput List=PaletteList)}}\n {{/if}}\n{{/let}}", {
353
353
  strictMode: true,
354
354
  scope: () => ({
355
355
  Input,
@@ -1 +1 @@
1
- {"version":3,"file":"command-palette.js","sources":["../../src/components/command-palette.gts"],"sourcesContent":["/**\n * References:\n * - https://www.w3.org/WAI/ARIA/apg/patterns/combobox/\n * - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-activedescendant\n *\n * A combobox (the input) over a listbox (the results).\n *\n * Focus never leaves the input; `aria-activedescendant` is what moves. This is\n * why there is no tabster mover here: the arrow keys must not move focus, or\n * the user stops being able to type. Tabster still does the finding.\n *\n * Filtering is not this component's job. Render the results you want, in the\n * order you want.\n */\nimport Component from \"@glimmer/component\";\nimport { tracked } from \"@glimmer/tracking\";\nimport { assert } from \"@ember/debug\";\nimport { registerDestructor } from \"@ember/destroyable\";\nimport { hash } from \"@ember/helper\";\nimport { on } from \"@ember/modifier\";\nimport { guidFor } from \"@ember/object/internals\";\n\nimport { modifier as eModifier } from \"ember-modifier\";\nimport { getTabster } from \"tabster\";\n// temp\n// https://github.com/tracked-tools/tracked-toolbox/issues/38\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-expect-error\nimport { localCopy } from \"tracked-toolbox\";\n\nimport { Link, type Signature as LinkSignature } from \"./link.gts\";\nimport { VisuallyHidden } from \"./visually-hidden.gts\";\n\nimport type { TOC } from \"@ember/component/template-only\";\nimport type Owner from \"@ember/owner\";\nimport type { ModifierLike, WithBoundArgs } from \"@glint/template\";\n\nconst OPTION = '[role=\"option\"]';\n\nfunction isMac() {\n return navigator.userAgent.includes(\"Mac OS\");\n}\n\n/**\n * Matches a hotkey description, such as `\"mod+k\"`, against a keyboard event.\n *\n * `mod` is <kbd>Meta</kbd> on macOS and <kbd>Control</kbd> everywhere else,\n * the same normalization `<KeyCombo>` uses to render one.\n */\nfunction matches(event: KeyboardEvent, hotkey: string) {\n const parts = hotkey\n .toLowerCase()\n .split(\"+\")\n .map((part) => part.trim());\n const key = parts.pop();\n const modifiers = new Set(parts);\n const mod = modifiers.has(\"mod\");\n\n return (\n event.key.toLowerCase() === key &&\n event.metaKey === (modifiers.has(\"meta\") || (mod && isMac())) &&\n event.ctrlKey === (modifiers.has(\"ctrl\") || (mod && !isMac())) &&\n event.altKey === modifiers.has(\"alt\") &&\n event.shiftKey === modifiers.has(\"shift\")\n );\n}\n\nexport interface ItemSignature {\n Element: HTMLDivElement;\n Blocks: { default: [] };\n}\n\ninterface PrivateItemSignature {\n Element: ItemSignature[\"Element\"];\n Args: { activeId: string | undefined };\n Blocks: ItemSignature[\"Blocks\"];\n}\n\nclass Item extends Component<PrivateItemSignature> {\n id = guidFor(this);\n\n get isActive() {\n return this.args.activeId === this.id;\n }\n\n <template>\n <div\n id={{this.id}}\n role=\"option\"\n tabindex=\"-1\"\n aria-selected=\"{{this.isActive}}\"\n data-active=\"{{this.isActive}}\"\n ...attributes\n >\n {{yield}}\n </div>\n </template>\n}\n\nexport interface LinkItemSignature {\n Element: HTMLAnchorElement;\n Args: LinkSignature[\"Args\"];\n Blocks: { default: [] };\n}\n\ninterface PrivateLinkItemSignature {\n Element: LinkItemSignature[\"Element\"];\n Args: LinkItemSignature[\"Args\"] & { activeId: string | undefined };\n Blocks: LinkItemSignature[\"Blocks\"];\n}\n\n/**\n * An option that is also a link. <kbd>Enter</kbd> dispatches a real click on\n * the anchor, so the router navigates exactly as it would have for a mouse.\n */\nclass LinkItem extends Component<PrivateLinkItemSignature> {\n id = guidFor(this);\n\n get isActive() {\n return this.args.activeId === this.id;\n }\n\n <template>\n <Link\n id={{this.id}}\n role=\"option\"\n tabindex=\"-1\"\n aria-selected=\"{{this.isActive}}\"\n data-active=\"{{this.isActive}}\"\n @href={{@href}}\n @includeActiveQueryParams={{@includeActiveQueryParams}}\n @activeOnSubPaths={{@activeOnSubPaths}}\n ...attributes\n >\n {{yield}}\n </Link>\n </template>\n}\n\nexport interface ListSignature {\n Element: HTMLDivElement;\n Blocks: {\n default: [\n {\n Item: WithBoundArgs<typeof Item, \"activeId\">;\n LinkItem: WithBoundArgs<typeof LinkItem, \"activeId\">;\n },\n ];\n };\n}\n\ninterface PrivateListSignature {\n Element: ListSignature[\"Element\"];\n Args: {\n id: string;\n register: ModifierLike<{ Element: HTMLElement }>;\n onPointerMove: (event: PointerEvent) => void;\n onClick: (event: MouseEvent) => void;\n Item: ListSignature[\"Blocks\"][\"default\"][0][\"Item\"];\n LinkItem: ListSignature[\"Blocks\"][\"default\"][0][\"LinkItem\"];\n };\n Blocks: ListSignature[\"Blocks\"];\n}\n\n/**\n * The pointer is handled here rather than on each option, and on\n * `pointermove` rather than `pointerenter`, so that an option under a resting\n * cursor re-activates when the cursor moves after the keyboard has activated\n * something else. Native menus behave this way.\n *\n * `:hover` cannot do this job. There is one active option, it is what\n * <kbd>Enter</kbd> chooses, and it is what `aria-activedescendant` reports.\n * Hovering while the keyboard has a different option active would light two\n * rows and tell a screen reader about neither, so the pointer sets the same\n * state the arrow keys do instead of painting its own.\n */\nconst List: TOC<PrivateListSignature> = <template>\n <div\n id={{@id}}\n role=\"listbox\"\n {{@register}}\n {{on \"click\" @onClick}}\n {{on \"pointermove\" @onPointerMove}}\n ...attributes\n >\n {{yield (hash Item=@Item LinkItem=@LinkItem)}}\n </div>\n</template>;\n\nexport interface InputSignature {\n Element: HTMLInputElement;\n}\n\ninterface PrivateInputSignature {\n Element: InputSignature[\"Element\"];\n Args: {\n listId: string;\n activeId: string | undefined;\n query: string;\n onInput: (event: Event) => void;\n onKeydown: (event: KeyboardEvent) => void;\n };\n}\n\nconst Input: TOC<PrivateInputSignature> = <template>\n <input\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n aria-autocomplete=\"list\"\n aria-expanded=\"true\"\n aria-controls={{@listId}}\n aria-activedescendant={{@activeId}}\n value={{@query}}\n {{on \"input\" @onInput}}\n {{on \"keydown\" @onKeydown}}\n ...attributes\n />\n</template>;\n\n/**\n * One entry in the default layout. A bare string is the label.\n */\nexport type PaletteItem =\n | string\n | {\n label: string;\n description?: string;\n icon?: string;\n };\n\nconst labelOf = (item: PaletteItem) => (typeof item === \"string\" ? item : item.label);\nconst descriptionOf = (item: PaletteItem) =>\n typeof item === \"string\" ? undefined : item.description;\nconst iconOf = (item: PaletteItem) => (typeof item === \"string\" ? undefined : item.icon);\n\n/**\n * The default layout: hand it the rows and it renders the whole palette.\n */\nexport interface ItemsSignature {\n Args: {\n /**\n * The text in the input.\n *\n * The state is managed internally, so this does not need to be a\n * maintained value, but whenever it changes, the input reflects it. Pair\n * it with `@onQueryChange` to keep the query somewhere else, such as a\n * query param.\n */\n query?: string;\n /**\n * Called with the input's text every time it changes.\n */\n onQueryChange?: (query: string) => void;\n /**\n * A key combination that calls `@onOpen` from anywhere on the page, such\n * as `\"mod+k\"`. `mod` is <kbd>Meta</kbd> on macOS and <kbd>Control</kbd>\n * everywhere else.\n *\n * Needs `@onOpen` to have anything to do. No listener is installed\n * without both.\n */\n hotkey?: string;\n /**\n * Called when `@hotkey` is pressed. Hand it the `open` of whatever the\n * palette is in:\n *\n * ```hbs\n * <CommandPalette @hotkey=\"mod+k\" @onOpen={{d.open}} />\n * ```\n */\n onOpen?: () => void;\n /**\n * The entries to render. Each is a string, or an object with a `label`\n * and optionally a `description` and an `icon`.\n */\n items: PaletteItem[];\n /**\n * Called every time a row is chosen, with the entry that was chosen.\n * This is where a modal palette closes itself:\n *\n * ```hbs\n * <Dialog as |d|>\n * <CommandPalette @items={{this.commands}} @onSelect={{d.close}} />\n * </Dialog>\n * ```\n *\n * Also where a row's own action goes, since the entry it is handed says\n * which row was chosen.\n */\n onSelect?: (item: PaletteItem, event: Event) => void;\n /**\n * The input's placeholder, and its accessible name.\n *\n * Defaults to \"Search\".\n */\n placeholder?: string;\n /**\n * What a screen reader announces when the number of results changes.\n *\n * Defaults to \"1 result\" and \"3 results\".\n */\n resultsText?: (count: number) => string;\n };\n /**\n * No blocks: this form renders the rows. Passing one is an error.\n */\n Blocks: Record<string, never>;\n}\n\n/**\n * The composed form: you render the rows.\n */\nexport interface BlockSignature {\n Args: {\n /**\n * The text in the input.\n *\n * The state is managed internally, so this does not need to be a\n * maintained value, but whenever it changes, the input reflects it. Pair\n * it with `@onQueryChange` to keep the query somewhere else, such as a\n * query param.\n */\n query?: string;\n /**\n * Called with the input's text every time it changes.\n */\n onQueryChange?: (query: string) => void;\n /**\n * A key combination that calls `@onOpen` from anywhere on the page, such\n * as `\"mod+k\"`. `mod` is <kbd>Meta</kbd> on macOS and <kbd>Control</kbd>\n * everywhere else.\n *\n * Needs `@onOpen` to have anything to do. No listener is installed\n * without both.\n */\n hotkey?: string;\n /**\n * Called when `@hotkey` is pressed. Hand it the `open` of whatever the\n * palette is in:\n *\n * ```hbs\n * <CommandPalette @hotkey=\"mod+k\" @onOpen={{d.open}} />\n * ```\n */\n onOpen?: () => void;\n /**\n * Not for this form: the rows come from the block.\n */\n items?: never;\n /**\n * Not for this form: set it on `Input` yourself.\n */\n placeholder?: never;\n /**\n * Not for this form: the rows are yours, and so is announcing them.\n */\n resultsText?: never;\n /**\n * Called every time a row is chosen. Hand it `close` to make a modal\n * palette close itself.\n *\n * The rows are yours here, so there is no entry to hand back. Which row\n * was chosen is `event.target.closest(\"[role=option]\")`.\n */\n onSelect?: (event: Event) => void;\n };\n Blocks: {\n default: [\n {\n /**\n * The current text of the input.\n */\n query: string;\n /**\n * Sets the text of the input, for a \"clear\" button or a suggestion.\n */\n setQuery: (query: string) => void;\n /**\n * The `<input>`, wired as a combobox over `List`.\n *\n * It needs a name: pass `aria-label`, or an `id` and a `<label>`.\n */\n Input: WithBoundArgs<\n typeof Input,\n \"listId\" | \"activeId\" | \"query\" | \"onInput\" | \"onKeydown\"\n >;\n /**\n * The listbox the rows are rendered into.\n */\n List: WithBoundArgs<\n typeof List,\n \"id\" | \"register\" | \"onPointerMove\" | \"onClick\" | \"Item\" | \"LinkItem\"\n >;\n },\n ];\n };\n}\n\nexport type Signature = ItemsSignature | BlockSignature;\n\nexport class CommandPalette extends Component<Signature> {\n listId = guidFor(this);\n\n /**\n * Held rather than looked up by id, because `document.getElementById` does\n * not cross into a shadow root. A plain field: it is read when a key is\n * pressed, never while rendering.\n */\n #list: HTMLElement | undefined;\n\n /**\n * Which row is active, as an id rather than an element or a focus state.\n *\n * This is unusual for this library, where keyboard navigation means tabster\n * moving focus. A combobox cannot do that: focus has to stay in the\n * `<input>` or the reader stops being able to type. So nothing among the\n * rows is ever focused, there is no focus for tabster to track, and what\n * moves instead is `aria-activedescendant` -- which is an id, on the input,\n * pointing at a row. Holding the id is holding exactly what that attribute\n * needs.\n *\n * Tabster still does the finding, in `#find`. This only remembers which of\n * the rows it landed on.\n */\n @tracked activeId: string | undefined;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n @localCopy(\"args.query\") declare _query: string;\n\n constructor(owner: Owner, args: Signature[\"Args\"]) {\n super(owner, args);\n\n document.addEventListener(\"keydown\", this.handleHotkey);\n\n registerDestructor(this, () => {\n document.removeEventListener(\"keydown\", this.handleHotkey);\n });\n }\n\n get placeholder() {\n return this.args.placeholder ?? \"Search\";\n }\n\n get resultsText() {\n const count = this.args.items?.length ?? 0;\n const custom = this.args.resultsText?.(count);\n\n return custom ?? (count === 1 ? \"1 result\" : `${count} results`);\n }\n\n /**\n * Whether `@items` was passed, not whether it has anything in it: an empty\n * array is falsy in a template, and a palette whose results have gone away\n * still has to render the input they would be typed into.\n */\n get hasItems() {\n return this.args.items !== undefined;\n }\n\n /**\n * Each form is called the way its own type describes: with the entry that\n * was chosen, or with the event alone when the rows are the caller's.\n *\n * `@items` is what tells the two apart, and it is `never` on the form that\n * does not take it, so testing it narrows `this.args` to one of them.\n */\n #select(option: HTMLElement, event: Event) {\n if (this.args.items === undefined) {\n this.args.onSelect?.(event);\n\n return;\n }\n\n const entry = this.#entryFor(option, this.args.items);\n\n assert(\n \"[BUG] a row of the default layout was chosen, but is not among `@items`\",\n entry !== undefined,\n );\n\n this.args.onSelect?.(entry, event);\n }\n\n /**\n * `@items` and a block are two ways to say the same thing, and saying both\n * means one of them is being quietly ignored.\n */\n get bothGiven() {\n assert(\n \"<CommandPalette> was given both `@items` and a block. Use one: `@items` renders the rows for you, a block renders them yourself.\",\n false,\n );\n\n return \"\";\n }\n\n get query() {\n return this._query ?? \"\";\n }\n set query(value: string) {\n this._query = value;\n }\n\n registerList = eModifier((element: HTMLElement) => {\n this.#list = element;\n });\n\n get #activeElement() {\n const { activeId } = this;\n\n if (!activeId) return undefined;\n\n // scoped to the listbox, so this works inside a shadow root\n return this.#list?.querySelector<HTMLElement>(`[id=\"${activeId}\"]`) ?? undefined;\n }\n\n /**\n * The next, previous, first or last option.\n *\n * Tabster does the finding, so hidden and inert options are skipped by the\n * same rules as everything else that moves around the page. It has to be\n * set up by the app, the same way `<Menu>` requires it.\n */\n #find(direction: \"next\" | \"prev\" | \"first\" | \"last\") {\n const container = this.#list;\n\n if (!container) return undefined;\n\n const tabster = getTabster(window);\n\n assert(\n \"<CommandPalette> needs tabster, which the application sets up. \" +\n \"Call `setupTabster` from 'ember-primitives/tabster' in your application route. \" +\n \"See https://tabster.io/docs/core\",\n tabster,\n );\n\n const options = { container, includeProgrammaticallyFocusable: true };\n const currentElement = this.#activeElement;\n const { focusable } = tabster;\n\n if (direction === \"first\") return focusable.findFirst(options);\n if (direction === \"last\") return focusable.findLast(options);\n\n if (!currentElement) {\n return direction === \"next\" ? focusable.findFirst(options) : focusable.findLast(options);\n }\n\n const found =\n direction === \"next\"\n ? focusable.findNext({ ...options, currentElement })\n : focusable.findPrev({ ...options, currentElement });\n\n // wrap, rather than stop, at either end\n return (\n found ?? (direction === \"next\" ? focusable.findFirst(options) : focusable.findLast(options))\n );\n }\n\n #activate(element: HTMLElement | null | undefined) {\n if (!element) return;\n\n this.activeId = element.id;\n element.scrollIntoView({ block: \"nearest\" });\n }\n\n setQuery = (query: string) => {\n this.query = query;\n // the results are about to be somebody else's; whatever was active is not\n this.activeId = undefined;\n this.args.onQueryChange?.(query);\n };\n\n handleInput = (event: Event) => {\n const { target } = event;\n\n assert(\"[BUG] input event without an input\", target instanceof HTMLInputElement);\n\n this.setQuery(target.value);\n };\n\n handlePointerMove = (event: PointerEvent) => {\n const { target } = event;\n\n if (!(target instanceof Element)) return;\n\n const option = target.closest<HTMLElement>(OPTION);\n\n if (option) {\n this.activeId = option.id;\n }\n };\n\n handleKeydown = (event: KeyboardEvent) => {\n // mid-composition (IME), the arrow keys belong to the candidate window\n if (event.isComposing) return;\n\n switch (event.key) {\n case \"ArrowDown\": {\n event.preventDefault();\n this.#activate(this.#find(\"next\"));\n\n return;\n }\n case \"ArrowUp\": {\n event.preventDefault();\n this.#activate(this.#find(\"prev\"));\n\n return;\n }\n case \"Enter\": {\n // nothing arrowed yet chooses the first result, so a reader can type\n // and press Enter without leaving the keys they were already on\n const active = this.#activeElement ?? this.#find(\"first\");\n\n if (!active) return;\n\n event.preventDefault();\n // a real click, so one handler covers the mouse and the keyboard, and\n // an anchor navigates the way the browser would have\n active.click();\n\n return;\n }\n /**\n * Home and End are left to the browser: in an editable combobox they\n * move the caret, which is what the APG asks for.\n */\n }\n };\n\n handleHotkey = (event: KeyboardEvent) => {\n const { hotkey, onOpen } = this.args;\n\n if (!hotkey || !onOpen) return;\n if (!matches(event, hotkey)) return;\n\n event.preventDefault();\n onOpen();\n };\n\n /**\n * The entry a row came from, for the default layout. Rows are rendered one\n * per entry and in order, so a row's position among the options is its\n * entry's position in `@items`. A block form has no entries, and gets\n * `undefined`.\n */\n #entryFor(option: HTMLElement, items: PaletteItem[]) {\n const options = this.#list?.querySelectorAll<HTMLElement>(OPTION);\n\n for (let i = 0; i < (options?.length ?? 0); i++) {\n if (options?.[i] === option) return items[i];\n }\n\n return undefined;\n }\n\n /**\n * Choosing is delegated, so a row is markup rather than a listener, and\n * `@onSelect` is reached the same way however the rows were rendered.\n */\n handleClick = (event: MouseEvent) => {\n const { target } = event;\n\n if (!(target instanceof Element)) return;\n\n const option = target.closest<HTMLElement>(OPTION);\n\n if (!option) return;\n\n /**\n * A modified click on a link opens it somewhere else and leaves the\n * reader where they are, so the palette stays where they left it.\n */\n if (option.closest(\"a\")) {\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n if (event.button !== 0) return;\n }\n\n this.#select(option, event);\n };\n\n <template>\n {{#let\n (component\n Input\n listId=this.listId\n activeId=this.activeId\n query=this.query\n onInput=this.handleInput\n onKeydown=this.handleKeydown\n )\n (component\n List\n id=this.listId\n register=this.registerList\n onPointerMove=this.handlePointerMove\n onClick=this.handleClick\n Item=(component Item activeId=this.activeId)\n LinkItem=(component LinkItem activeId=this.activeId)\n )\n as |PaletteInput PaletteList|\n }}\n {{#if this.hasItems}}\n {{#if (has-block)}}{{this.bothGiven}}{{/if}}\n\n <PaletteInput\n class=\"ember-primitives__command-palette__input\"\n placeholder={{this.placeholder}}\n aria-label={{this.placeholder}}\n />\n\n <PaletteList class=\"ember-primitives__command-palette__list\" as |l|>\n {{#each @items as |item|}}\n <l.Item class=\"ember-primitives__command-palette__item\">\n {{#if (iconOf item)}}\n <span class=\"ember-primitives__command-palette__icon\">{{iconOf item}}</span>\n {{/if}}\n <span class=\"ember-primitives__command-palette__label\">{{labelOf item}}</span>\n {{#if (descriptionOf item)}}\n <span class=\"ember-primitives__command-palette__description\">{{descriptionOf\n item\n }}</span>\n {{/if}}\n </l.Item>\n {{/each}}\n </PaletteList>\n\n <VisuallyHidden role=\"status\">{{this.resultsText}}</VisuallyHidden>\n {{else}}\n {{yield (hash query=this.query setQuery=this.setQuery Input=PaletteInput List=PaletteList)}}\n {{/if}}\n {{/let}}\n </template>\n}\n\nexport default CommandPalette;\n"],"names":["OPTION","isMac","navigator","userAgent","includes","matches","event","hotkey","parts","toLowerCase","split","map","part","trim","key","pop","modifiers","Set","mod","has","metaKey","ctrlKey","altKey","shiftKey","Item","Component","id","guidFor","isActive","args","activeId","setComponentTemplate","precompileTemplate","strictMode","LinkItem","scope","Link","List","on","hash","templateOnly","Input","labelOf","item","label","descriptionOf","undefined","description","iconOf","icon","CommandPalette","listId","g","prototype","tracked","i","localCopy","constructor","owner","document","addEventListener","handleHotkey","registerDestructor","removeEventListener","placeholder","resultsText","count","items","length","custom","hasItems","#select","option","onSelect","entry","assert","bothGiven","query","_query","value","registerList","eModifier","element","#activeElement","querySelector","#find","direction","container","tabster","getTabster","window","options","includeProgrammaticallyFocusable","currentElement","focusable","findFirst","findLast","found","findNext","findPrev","#activate","scrollIntoView","block","setQuery","onQueryChange","handleInput","target","HTMLInputElement","handlePointerMove","Element","closest","handleKeydown","isComposing","preventDefault","active","click","onOpen","#entryFor","querySelectorAll","handleClick","button","VisuallyHidden"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;AAaC;AAwBD,MAAMA,MAAA,GAAS,iBAAA;AAEf,SAASC,KAAAA,GAAA;AACP,EAAA,OAAOC,SAAA,CAAUC,SAAS,CAACC,QAAQ,CAAC,QAAA,CAAA;AACtC;AAEA;;;;;AAKC;AACD,SAASC,OAAAA,CAAQC,KAAoB,EAAEC,MAAc,EAAA;EACnD,MAAMC,KAAA,GAAQD,MAAA,CACXE,WAAW,EAAA,CACXC,KAAK,CAAC,GAAA,CAAA,CACNC,GAAG,CAAEC,IAAA,IAASA,IAAA,CAAKC,IAAI,EAAA,CAAA;AAC1B,EAAA,MAAMC,GAAA,GAAMN,MAAMO,GAAG,EAAA;AACrB,EAAA,MAAMC,SAAA,GAAY,IAAIC,GAAA,CAAIT,KAAA,CAAA;AAC1B,EAAA,MAAMU,GAAA,GAAMF,SA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AAC1B,IAAA;AAEA,IAAA,IAAI,CAAC,OAAO,CAAChD,MAAA,EAAQlE,KAAA,CAAA;EACvB,CAAA;AAEA,EAAA;IAAAyB,oBAAA,CAAAC,kBAAA,CAAA,06CAAA,EAmDA;MAAAC,UAAA,EAAA,IAAA;AAAAE,MAAAA,KAAA,EAAAA,OAAA;QAAAM,KAAA;QAAAJ,IAAA;QAAAb,IAAA;QAAAU,QAAA;QAAAc,MAAA;QAAAN,OAAA;QAAAG,aAAA;QAAA4E,cAAA;AAAAlF,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
1
+ {"version":3,"file":"command-palette.js","sources":["../../src/components/command-palette.gts"],"sourcesContent":["/**\n * References:\n * - https://www.w3.org/WAI/ARIA/apg/patterns/combobox/\n * - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-activedescendant\n *\n * A combobox (the input) over a listbox (the results).\n *\n * Focus never leaves the input; `aria-activedescendant` is what moves. This is\n * why there is no tabster mover here: the arrow keys must not move focus, or\n * the user stops being able to type. Tabster still does the finding.\n *\n * Filtering is not this component's job. Render the results you want, in the\n * order you want.\n */\nimport Component from \"@glimmer/component\";\nimport { tracked } from \"@glimmer/tracking\";\nimport { assert } from \"@ember/debug\";\nimport { registerDestructor } from \"@ember/destroyable\";\nimport { hash } from \"@ember/helper\";\nimport { on } from \"@ember/modifier\";\nimport { guidFor } from \"@ember/object/internals\";\n\nimport { modifier as eModifier } from \"ember-modifier\";\nimport { getTabster } from \"tabster\";\n// temp\n// https://github.com/tracked-tools/tracked-toolbox/issues/38\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-expect-error\nimport { localCopy } from \"tracked-toolbox\";\n\nimport { Link, type Signature as LinkSignature } from \"./link.gts\";\nimport { VisuallyHidden } from \"./visually-hidden.gts\";\n\nimport type { TOC } from \"@ember/component/template-only\";\nimport type Owner from \"@ember/owner\";\nimport type { ModifierLike, WithBoundArgs } from \"@glint/template\";\n\nconst OPTION = '[role=\"option\"]';\n\nfunction isMac() {\n return navigator.userAgent.includes(\"Mac OS\");\n}\n\n/**\n * Matches a hotkey description, such as `\"mod+k\"`, against a keyboard event.\n *\n * `mod` is <kbd>Meta</kbd> on macOS and <kbd>Control</kbd> everywhere else,\n * the same normalization `<KeyCombo>` uses to render one.\n */\nfunction matches(event: KeyboardEvent, hotkey: string) {\n const parts = hotkey\n .toLowerCase()\n .split(\"+\")\n .map((part) => part.trim());\n const key = parts.pop();\n const modifiers = new Set(parts);\n const mod = modifiers.has(\"mod\");\n\n return (\n event.key.toLowerCase() === key &&\n event.metaKey === (modifiers.has(\"meta\") || (mod && isMac())) &&\n event.ctrlKey === (modifiers.has(\"ctrl\") || (mod && !isMac())) &&\n event.altKey === modifiers.has(\"alt\") &&\n event.shiftKey === modifiers.has(\"shift\")\n );\n}\n\nexport interface ItemSignature {\n Element: HTMLDivElement;\n Blocks: { default: [] };\n}\n\ninterface PrivateItemSignature {\n Element: ItemSignature[\"Element\"];\n Args: { activeId: string | undefined };\n Blocks: ItemSignature[\"Blocks\"];\n}\n\nclass Item extends Component<PrivateItemSignature> {\n id = guidFor(this);\n\n get isActive() {\n return this.args.activeId === this.id;\n }\n\n <template>\n <div\n id={{this.id}}\n role=\"option\"\n tabindex=\"-1\"\n aria-selected=\"{{this.isActive}}\"\n data-active=\"{{this.isActive}}\"\n ...attributes\n >\n {{yield}}\n </div>\n </template>\n}\n\nexport interface LinkItemSignature {\n Element: HTMLAnchorElement;\n Args: LinkSignature[\"Args\"];\n Blocks: { default: [] };\n}\n\ninterface PrivateLinkItemSignature {\n Element: LinkItemSignature[\"Element\"];\n Args: LinkItemSignature[\"Args\"] & { activeId: string | undefined };\n Blocks: LinkItemSignature[\"Blocks\"];\n}\n\n/**\n * An option that is also a link. <kbd>Enter</kbd> dispatches a real click on\n * the anchor, so the router navigates exactly as it would have for a mouse.\n */\nclass LinkItem extends Component<PrivateLinkItemSignature> {\n id = guidFor(this);\n\n get isActive() {\n return this.args.activeId === this.id;\n }\n\n <template>\n <Link\n id={{this.id}}\n role=\"option\"\n tabindex=\"-1\"\n aria-selected=\"{{this.isActive}}\"\n data-active=\"{{this.isActive}}\"\n @href={{@href}}\n @includeActiveQueryParams={{@includeActiveQueryParams}}\n @activeOnSubPaths={{@activeOnSubPaths}}\n ...attributes\n >\n {{yield}}\n </Link>\n </template>\n}\n\nexport interface ListSignature {\n Element: HTMLDivElement;\n Blocks: {\n default: [\n {\n Item: WithBoundArgs<typeof Item, \"activeId\">;\n LinkItem: WithBoundArgs<typeof LinkItem, \"activeId\">;\n },\n ];\n };\n}\n\ninterface PrivateListSignature {\n Element: ListSignature[\"Element\"];\n Args: {\n id: string;\n register: ModifierLike<{ Element: HTMLElement }>;\n onPointerMove: (event: PointerEvent) => void;\n onClick: (event: MouseEvent) => void;\n item: ListSignature[\"Blocks\"][\"default\"][0][\"Item\"];\n linkItem: ListSignature[\"Blocks\"][\"default\"][0][\"LinkItem\"];\n };\n Blocks: ListSignature[\"Blocks\"];\n}\n\n/**\n * The pointer is handled here rather than on each option, and on\n * `pointermove` rather than `pointerenter`, so that an option under a resting\n * cursor re-activates when the cursor moves after the keyboard has activated\n * something else. Native menus behave this way.\n *\n * `:hover` cannot do this job. There is one active option, it is what\n * <kbd>Enter</kbd> chooses, and it is what `aria-activedescendant` reports.\n * Hovering while the keyboard has a different option active would light two\n * rows and tell a screen reader about neither, so the pointer sets the same\n * state the arrow keys do instead of painting its own.\n */\nconst List: TOC<PrivateListSignature> = <template>\n <div\n id={{@id}}\n role=\"listbox\"\n {{@register}}\n {{on \"click\" @onClick}}\n {{on \"pointermove\" @onPointerMove}}\n ...attributes\n >\n {{yield (hash Item=@item LinkItem=@linkItem)}}\n </div>\n</template>;\n\nexport interface InputSignature {\n Element: HTMLInputElement;\n}\n\ninterface PrivateInputSignature {\n Element: InputSignature[\"Element\"];\n Args: {\n listId: string;\n activeId: string | undefined;\n query: string;\n onInput: (event: Event) => void;\n onKeydown: (event: KeyboardEvent) => void;\n };\n}\n\nconst Input: TOC<PrivateInputSignature> = <template>\n <input\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n aria-autocomplete=\"list\"\n aria-expanded=\"true\"\n aria-controls={{@listId}}\n aria-activedescendant={{@activeId}}\n value={{@query}}\n {{on \"input\" @onInput}}\n {{on \"keydown\" @onKeydown}}\n ...attributes\n />\n</template>;\n\n/**\n * One entry in the default layout. A bare string is the label.\n */\nexport type PaletteItem =\n | string\n | {\n label: string;\n description?: string;\n icon?: string;\n };\n\nconst labelOf = (item: PaletteItem) => (typeof item === \"string\" ? item : item.label);\nconst descriptionOf = (item: PaletteItem) =>\n typeof item === \"string\" ? undefined : item.description;\nconst iconOf = (item: PaletteItem) => (typeof item === \"string\" ? undefined : item.icon);\n\n/**\n * The default layout: hand it the rows and it renders the whole palette.\n */\nexport interface ItemsSignature {\n Args: {\n /**\n * The text in the input.\n *\n * The state is managed internally, so this does not need to be a\n * maintained value, but whenever it changes, the input reflects it. Pair\n * it with `@onQueryChange` to keep the query somewhere else, such as a\n * query param.\n */\n query?: string;\n /**\n * Called with the input's text every time it changes.\n */\n onQueryChange?: (query: string) => void;\n /**\n * A key combination that calls `@onOpen` from anywhere on the page, such\n * as `\"mod+k\"`. `mod` is <kbd>Meta</kbd> on macOS and <kbd>Control</kbd>\n * everywhere else.\n *\n * Needs `@onOpen` to have anything to do. No listener is installed\n * without both.\n */\n hotkey?: string;\n /**\n * Called when `@hotkey` is pressed. Hand it the `open` of whatever the\n * palette is in:\n *\n * ```hbs\n * <CommandPalette @hotkey=\"mod+k\" @onOpen={{d.open}} />\n * ```\n */\n onOpen?: () => void;\n /**\n * The entries to render. Each is a string, or an object with a `label`\n * and optionally a `description` and an `icon`.\n */\n items: PaletteItem[];\n /**\n * Called every time a row is chosen, with the entry that was chosen.\n * This is where a modal palette closes itself:\n *\n * ```hbs\n * <Dialog as |d|>\n * <CommandPalette @items={{this.commands}} @onSelect={{d.close}} />\n * </Dialog>\n * ```\n *\n * Also where a row's own action goes, since the entry it is handed says\n * which row was chosen.\n */\n onSelect?: (item: PaletteItem, event: Event) => void;\n /**\n * The input's placeholder, and its accessible name.\n *\n * Defaults to \"Search\".\n */\n placeholder?: string;\n /**\n * What a screen reader announces when the number of results changes.\n *\n * Defaults to \"1 result\" and \"3 results\".\n */\n resultsText?: (count: number) => string;\n };\n /**\n * No blocks: this form renders the rows. Passing one is an error.\n */\n Blocks: Record<string, never>;\n}\n\n/**\n * The composed form: you render the rows.\n */\nexport interface BlockSignature {\n Args: {\n /**\n * The text in the input.\n *\n * The state is managed internally, so this does not need to be a\n * maintained value, but whenever it changes, the input reflects it. Pair\n * it with `@onQueryChange` to keep the query somewhere else, such as a\n * query param.\n */\n query?: string;\n /**\n * Called with the input's text every time it changes.\n */\n onQueryChange?: (query: string) => void;\n /**\n * A key combination that calls `@onOpen` from anywhere on the page, such\n * as `\"mod+k\"`. `mod` is <kbd>Meta</kbd> on macOS and <kbd>Control</kbd>\n * everywhere else.\n *\n * Needs `@onOpen` to have anything to do. No listener is installed\n * without both.\n */\n hotkey?: string;\n /**\n * Called when `@hotkey` is pressed. Hand it the `open` of whatever the\n * palette is in:\n *\n * ```hbs\n * <CommandPalette @hotkey=\"mod+k\" @onOpen={{d.open}} />\n * ```\n */\n onOpen?: () => void;\n /**\n * Not for this form: the rows come from the block.\n */\n items?: never;\n /**\n * Not for this form: set it on `Input` yourself.\n */\n placeholder?: never;\n /**\n * Not for this form: the rows are yours, and so is announcing them.\n */\n resultsText?: never;\n /**\n * Called every time a row is chosen. Hand it `close` to make a modal\n * palette close itself.\n *\n * The rows are yours here, so there is no entry to hand back. Which row\n * was chosen is `event.target.closest(\"[role=option]\")`.\n */\n onSelect?: (event: Event) => void;\n };\n Blocks: {\n default: [\n {\n /**\n * The current text of the input.\n */\n query: string;\n /**\n * Sets the text of the input, for a \"clear\" button or a suggestion.\n */\n setQuery: (query: string) => void;\n /**\n * The `<input>`, wired as a combobox over `List`.\n *\n * It needs a name: pass `aria-label`, or an `id` and a `<label>`.\n */\n Input: WithBoundArgs<\n typeof Input,\n \"listId\" | \"activeId\" | \"query\" | \"onInput\" | \"onKeydown\"\n >;\n /**\n * The listbox the rows are rendered into.\n */\n List: WithBoundArgs<\n typeof List,\n \"id\" | \"register\" | \"onPointerMove\" | \"onClick\" | \"item\" | \"linkItem\"\n >;\n },\n ];\n };\n}\n\nexport type Signature = ItemsSignature | BlockSignature;\n\nexport class CommandPalette extends Component<Signature> {\n listId = guidFor(this);\n\n /**\n * Held rather than looked up by id, because `document.getElementById` does\n * not cross into a shadow root. A plain field: it is read when a key is\n * pressed, never while rendering.\n */\n #list: HTMLElement | undefined;\n\n /**\n * Which row is active, as an id rather than an element or a focus state.\n *\n * This is unusual for this library, where keyboard navigation means tabster\n * moving focus. A combobox cannot do that: focus has to stay in the\n * `<input>` or the reader stops being able to type. So nothing among the\n * rows is ever focused, there is no focus for tabster to track, and what\n * moves instead is `aria-activedescendant` -- which is an id, on the input,\n * pointing at a row. Holding the id is holding exactly what that attribute\n * needs.\n *\n * Tabster still does the finding, in `#find`. This only remembers which of\n * the rows it landed on.\n */\n @tracked activeId: string | undefined;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n @localCopy(\"args.query\") declare _query: string;\n\n constructor(owner: Owner, args: Signature[\"Args\"]) {\n super(owner, args);\n\n document.addEventListener(\"keydown\", this.handleHotkey);\n\n registerDestructor(this, () => {\n document.removeEventListener(\"keydown\", this.handleHotkey);\n });\n }\n\n get placeholder() {\n return this.args.placeholder ?? \"Search\";\n }\n\n get resultsText() {\n const count = this.args.items?.length ?? 0;\n const custom = this.args.resultsText?.(count);\n\n return custom ?? (count === 1 ? \"1 result\" : `${count} results`);\n }\n\n /**\n * Whether `@items` was passed, not whether it has anything in it: an empty\n * array is falsy in a template, and a palette whose results have gone away\n * still has to render the input they would be typed into.\n */\n get hasItems() {\n return this.args.items !== undefined;\n }\n\n /**\n * Each form is called the way its own type describes: with the entry that\n * was chosen, or with the event alone when the rows are the caller's.\n *\n * `@items` is what tells the two apart, and it is `never` on the form that\n * does not take it, so testing it narrows `this.args` to one of them.\n */\n #select(option: HTMLElement, event: Event) {\n if (this.args.items === undefined) {\n this.args.onSelect?.(event);\n\n return;\n }\n\n const entry = this.#entryFor(option, this.args.items);\n\n assert(\n \"[BUG] a row of the default layout was chosen, but is not among `@items`\",\n entry !== undefined,\n );\n\n this.args.onSelect?.(entry, event);\n }\n\n /**\n * `@items` and a block are two ways to say the same thing, and saying both\n * means one of them is being quietly ignored.\n */\n get bothGiven() {\n assert(\n \"<CommandPalette> was given both `@items` and a block. Use one: `@items` renders the rows for you, a block renders them yourself.\",\n false,\n );\n\n return \"\";\n }\n\n get query() {\n return this._query ?? \"\";\n }\n set query(value: string) {\n this._query = value;\n }\n\n registerList = eModifier((element: HTMLElement) => {\n this.#list = element;\n });\n\n get #activeElement() {\n const { activeId } = this;\n\n if (!activeId) return undefined;\n\n // scoped to the listbox, so this works inside a shadow root\n return this.#list?.querySelector<HTMLElement>(`[id=\"${activeId}\"]`) ?? undefined;\n }\n\n /**\n * The next, previous, first or last option.\n *\n * Tabster does the finding, so hidden and inert options are skipped by the\n * same rules as everything else that moves around the page. It has to be\n * set up by the app, the same way `<Menu>` requires it.\n */\n #find(direction: \"next\" | \"prev\" | \"first\" | \"last\") {\n const container = this.#list;\n\n if (!container) return undefined;\n\n const tabster = getTabster(window);\n\n assert(\n \"<CommandPalette> needs tabster, which the application sets up. \" +\n \"Call `setupTabster` from 'ember-primitives/tabster' in your application route. \" +\n \"See https://tabster.io/docs/core\",\n tabster,\n );\n\n const options = { container, includeProgrammaticallyFocusable: true };\n const currentElement = this.#activeElement;\n const { focusable } = tabster;\n\n if (direction === \"first\") return focusable.findFirst(options);\n if (direction === \"last\") return focusable.findLast(options);\n\n if (!currentElement) {\n return direction === \"next\" ? focusable.findFirst(options) : focusable.findLast(options);\n }\n\n const found =\n direction === \"next\"\n ? focusable.findNext({ ...options, currentElement })\n : focusable.findPrev({ ...options, currentElement });\n\n // wrap, rather than stop, at either end\n return (\n found ?? (direction === \"next\" ? focusable.findFirst(options) : focusable.findLast(options))\n );\n }\n\n #activate(element: HTMLElement | null | undefined) {\n if (!element) return;\n\n this.activeId = element.id;\n element.scrollIntoView({ block: \"nearest\" });\n }\n\n setQuery = (query: string) => {\n this.query = query;\n // the results are about to be somebody else's; whatever was active is not\n this.activeId = undefined;\n this.args.onQueryChange?.(query);\n };\n\n handleInput = (event: Event) => {\n const { target } = event;\n\n assert(\"[BUG] input event without an input\", target instanceof HTMLInputElement);\n\n this.setQuery(target.value);\n };\n\n handlePointerMove = (event: PointerEvent) => {\n const { target } = event;\n\n if (!(target instanceof Element)) return;\n\n const option = target.closest<HTMLElement>(OPTION);\n\n if (option) {\n this.activeId = option.id;\n }\n };\n\n handleKeydown = (event: KeyboardEvent) => {\n // mid-composition (IME), the arrow keys belong to the candidate window\n if (event.isComposing) return;\n\n switch (event.key) {\n case \"ArrowDown\": {\n event.preventDefault();\n this.#activate(this.#find(\"next\"));\n\n return;\n }\n case \"ArrowUp\": {\n event.preventDefault();\n this.#activate(this.#find(\"prev\"));\n\n return;\n }\n case \"Enter\": {\n // nothing arrowed yet chooses the first result, so a reader can type\n // and press Enter without leaving the keys they were already on\n const active = this.#activeElement ?? this.#find(\"first\");\n\n if (!active) return;\n\n event.preventDefault();\n // a real click, so one handler covers the mouse and the keyboard, and\n // an anchor navigates the way the browser would have\n active.click();\n\n return;\n }\n /**\n * Home and End are left to the browser: in an editable combobox they\n * move the caret, which is what the APG asks for.\n */\n }\n };\n\n handleHotkey = (event: KeyboardEvent) => {\n const { hotkey, onOpen } = this.args;\n\n if (!hotkey || !onOpen) return;\n if (!matches(event, hotkey)) return;\n\n event.preventDefault();\n onOpen();\n };\n\n /**\n * The entry a row came from, for the default layout. Rows are rendered one\n * per entry and in order, so a row's position among the options is its\n * entry's position in `@items`. A block form has no entries, and gets\n * `undefined`.\n */\n #entryFor(option: HTMLElement, items: PaletteItem[]) {\n const options = this.#list?.querySelectorAll<HTMLElement>(OPTION);\n\n for (let i = 0; i < (options?.length ?? 0); i++) {\n if (options?.[i] === option) return items[i];\n }\n\n return undefined;\n }\n\n /**\n * Choosing is delegated, so a row is markup rather than a listener, and\n * `@onSelect` is reached the same way however the rows were rendered.\n */\n handleClick = (event: MouseEvent) => {\n const { target } = event;\n\n if (!(target instanceof Element)) return;\n\n const option = target.closest<HTMLElement>(OPTION);\n\n if (!option) return;\n\n /**\n * A modified click on a link opens it somewhere else and leaves the\n * reader where they are, so the palette stays where they left it.\n */\n if (option.closest(\"a\")) {\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n if (event.button !== 0) return;\n }\n\n this.#select(option, event);\n };\n\n <template>\n {{#let\n (component\n Input\n listId=this.listId\n activeId=this.activeId\n query=this.query\n onInput=this.handleInput\n onKeydown=this.handleKeydown\n )\n (component\n List\n id=this.listId\n register=this.registerList\n onPointerMove=this.handlePointerMove\n onClick=this.handleClick\n item=(component Item activeId=this.activeId)\n linkItem=(component LinkItem activeId=this.activeId)\n )\n as |PaletteInput PaletteList|\n }}\n {{#if this.hasItems}}\n {{#if (has-block)}}{{this.bothGiven}}{{/if}}\n\n <PaletteInput\n class=\"ember-primitives__command-palette__input\"\n placeholder={{this.placeholder}}\n aria-label={{this.placeholder}}\n />\n\n <PaletteList class=\"ember-primitives__command-palette__list\" as |l|>\n {{#each @items as |item|}}\n <l.Item class=\"ember-primitives__command-palette__item\">\n {{#if (iconOf item)}}\n <span class=\"ember-primitives__command-palette__icon\">{{iconOf item}}</span>\n {{/if}}\n <span class=\"ember-primitives__command-palette__label\">{{labelOf item}}</span>\n {{#if (descriptionOf item)}}\n <span class=\"ember-primitives__command-palette__description\">{{descriptionOf\n item\n }}</span>\n {{/if}}\n </l.Item>\n {{/each}}\n </PaletteList>\n\n <VisuallyHidden role=\"status\">{{this.resultsText}}</VisuallyHidden>\n {{else}}\n {{yield (hash query=this.query setQuery=this.setQuery Input=PaletteInput List=PaletteList)}}\n {{/if}}\n {{/let}}\n </template>\n}\n\nexport default CommandPalette;\n"],"names":["OPTION","isMac","navigator","userAgent","includes","matches","event","hotkey","parts","toLowerCase","split","map","part","trim","key","pop","modifiers","Set","mod","has","metaKey","ctrlKey","altKey","shiftKey","Item","Component","id","guidFor","isActive","args","activeId","setComponentTemplate","precompileTemplate","strictMode","LinkItem","scope","Link","List","on","hash","templateOnly","Input","labelOf","item","label","descriptionOf","undefined","description","iconOf","icon","CommandPalette","listId","g","prototype","tracked","i","localCopy","constructor","owner","document","addEventListener","handleHotkey","registerDestructor","removeEventListener","placeholder","resultsText","count","items","length","custom","hasItems","#select","option","onSelect","entry","assert","bothGiven","query","_query","value","registerList","eModifier","element","#activeElement","querySelector","#find","direction","container","tabster","getTabster","window","options","includeProgrammaticallyFocusable","currentElement","focusable","findFirst","findLast","found","findNext","findPrev","#activate","scrollIntoView","block","setQuery","onQueryChange","handleInput","target","HTMLInputElement","handlePointerMove","Element","closest","handleKeydown","isComposing","preventDefault","active","click","onOpen","#entryFor","querySelectorAll","handleClick","button","VisuallyHidden"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;AAaC;AAwBD,MAAMA,MAAA,GAAS,iBAAA;AAEf,SAASC,KAAAA,GAAA;AACP,EAAA,OAAOC,SAAA,CAAUC,SAAS,CAACC,QAAQ,CAAC,QAAA,CAAA;AACtC;AAEA;;;;;AAKC;AACD,SAASC,OAAAA,CAAQC,KAAoB,EAAEC,MAAc,EAAA;EACnD,MAAMC,KAAA,GAAQD,MAAA,CACXE,WAAW,EAAA,CACXC,KAAK,CAAC,GAAA,CAAA,CACNC,GAAG,CAAEC,IAAA,IAASA,IAAA,CAAKC,IAAI,EAAA,CAAA;AAC1B,EAAA,MAAMC,GAAA,GAAMN,MAAMO,GAAG,EAAA;AACrB,EAAA,M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,KAAA,CAAMgB,MAAM,EAAE;AACtE,MAAA,IAAIhB,KAAA,CAAMkH,MAAM,KAAK,CAAA,EAAG;AAC1B,IAAA;AAEA,IAAA,IAAI,CAAC,OAAO,CAAChD,MAAA,EAAQlE,KAAA,CAAA;EACvB,CAAA;AAEA,EAAA;IAAAyB,oBAAA,CAAAC,kBAAA,CAAA,06CAAA,EAmDA;MAAAC,UAAA,EAAA,IAAA;AAAAE,MAAAA,KAAA,EAAAA,OAAA;QAAAM,KAAA;QAAAJ,IAAA;QAAAb,IAAA;QAAAU,QAAA;QAAAc,MAAA;QAAAN,OAAA;QAAAG,aAAA;QAAA4E,cAAA;AAAAlF,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-primitives",
3
- "version": "0.63.0",
3
+ "version": "0.63.1",
4
4
  "description": "Making apps easier to build",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -28,7 +28,7 @@
28
28
  "tabster": "^8.7.0",
29
29
  "tracked-built-ins": "^4.1.0",
30
30
  "tracked-toolbox": "^3.0.0",
31
- "which-heading-do-i-need": "0.4.1"
31
+ "which-heading-do-i-need": "0.4.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@arethetypeswrong/cli": "^0.18.0",
@@ -156,8 +156,8 @@ interface PrivateListSignature {
156
156
  register: ModifierLike<{ Element: HTMLElement }>;
157
157
  onPointerMove: (event: PointerEvent) => void;
158
158
  onClick: (event: MouseEvent) => void;
159
- Item: ListSignature["Blocks"]["default"][0]["Item"];
160
- LinkItem: ListSignature["Blocks"]["default"][0]["LinkItem"];
159
+ item: ListSignature["Blocks"]["default"][0]["Item"];
160
+ linkItem: ListSignature["Blocks"]["default"][0]["LinkItem"];
161
161
  };
162
162
  Blocks: ListSignature["Blocks"];
163
163
  }
@@ -183,7 +183,7 @@ const List: TOC<PrivateListSignature> = <template>
183
183
  {{on "pointermove" @onPointerMove}}
184
184
  ...attributes
185
185
  >
186
- {{yield (hash Item=@Item LinkItem=@LinkItem)}}
186
+ {{yield (hash Item=@item LinkItem=@linkItem)}}
187
187
  </div>
188
188
  </template>;
189
189
 
@@ -393,7 +393,7 @@ export interface BlockSignature {
393
393
  */
394
394
  List: WithBoundArgs<
395
395
  typeof List,
396
- "id" | "register" | "onPointerMove" | "onClick" | "Item" | "LinkItem"
396
+ "id" | "register" | "onPointerMove" | "onClick" | "item" | "linkItem"
397
397
  >;
398
398
  },
399
399
  ];
@@ -700,8 +700,8 @@ export class CommandPalette extends Component<Signature> {
700
700
  register=this.registerList
701
701
  onPointerMove=this.handlePointerMove
702
702
  onClick=this.handleClick
703
- Item=(component Item activeId=this.activeId)
704
- LinkItem=(component LinkItem activeId=this.activeId)
703
+ item=(component Item activeId=this.activeId)
704
+ linkItem=(component LinkItem activeId=this.activeId)
705
705
  )
706
706
  as |PaletteInput PaletteList|
707
707
  }}