@su-labs/select 19.0.0 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/fesm2022/su-labs-select.mjs +505 -300
- package/fesm2022/su-labs-select.mjs.map +1 -1
- package/package.json +7 -6
- package/types/su-labs-select.d.ts +131 -0
- package/index.d.ts +0 -5
- package/lib/select/select.component.d.ts +0 -70
- package/public-api.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"su-labs-select.mjs","sources":["../../../../compat/angular-19/build/select/src/lib/select/select.component.ts","../../../../compat/angular-19/build/select/src/lib/select/select.component.html","../../../../compat/angular-19/build/select/src/su-labs-select.ts"],"sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport { afterRenderEffect, booleanAttribute, ChangeDetectionStrategy, Component, computed, DestroyRef, effect, ElementRef, inject, input, model, output, signal, untracked, viewChild } from '@angular/core';\nimport { SU_SELECT_LABELS, SuSelectController, suSelectGroups, SuSelectLabels, SuSelectMove, SuSelectOption } from '@su-labs/core/select';\nimport { suTooltipPosition } from '@su-labs/core/tooltip';\n\nlet nextSelectId = 0;\n\nconst MOVES: Readonly<Record<string, SuSelectMove>> = {\n ArrowDown: 'next',\n ArrowUp: 'previous',\n Home: 'first',\n End: 'last',\n PageDown: 'last',\n PageUp: 'first',\n};\n\n/**\n * A select over `SuSelectController` from `@su-labs/core/select`, with its own styled list instead of the browser's\n * popup: `<su-lib-select [options]=\"sizes\" [(value)]=\"size\" />`. The trigger is a `combobox` button and the list a\n * `listbox` in the top layer (`popover`), placed below the trigger or above it when there's no room. It follows the\n * WAI-ARIA select-only combobox pattern: arrows, Home and End, type-ahead, Enter or Space to choose, Escape to close\n * and Tab to choose and move on. With `searchable`, a search field at the top of the list filters the options.\n */\n@Component({\n selector: 'su-lib-select',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './select.component.html',\n styleUrl: './select.component.scss',\n host: {\n class: 'su-select',\n '[class.su-select-open]': 'open()',\n '[class.su-select-disabled]': 'disabled()',\n '(focusout)': 'onFocusOut($event)',\n },\n})\nexport class SuSelectComponent<T> {\n /** The choices: `{ value, label, disabled?, group? }`; options sharing a `group` should follow one another */\n readonly options = input<readonly SuSelectOption<T>[]>([]);\n /** The chosen value, or `null` while nothing is chosen */\n readonly value = model<T | null>(null);\n /** Whether the list is open; setting it opens or closes it */\n readonly open = model(false);\n /** Set once focus has left the select, for forms that show errors after the user moved on */\n readonly touched = model(false);\n /** A search field at the top of the list that filters the options @default false */\n readonly searchable = input(false, { transform: booleanAttribute });\n /** Can't be opened or focused @default false */\n readonly disabled = input(false, { transform: booleanAttribute });\n /** Opens with a short fade and slide; off when the user prefers less motion @default true */\n readonly animated = input(true, { transform: booleanAttribute });\n /** Shown while nothing is chosen @default labels.placeholder */\n readonly placeholder = input<string>();\n /** The select's name for screen readers, when no `<label>` wraps it and no `ariaLabelledby` names it */\n readonly ariaLabel = input<string>();\n /** The id of the element that names the select */\n readonly ariaLabelledby = input<string>();\n /** Texts to replace, e.g. in the page's language */\n readonly labels = input<Partial<SuSelectLabels>>({});\n /** The user chose an option (never emitted for a value set from outside): its value */\n readonly chosen = output<T>();\n\n protected readonly id = `su-select-${nextSelectId++}`;\n protected readonly listId = `${this.id}-list`;\n protected readonly texts = computed<SuSelectLabels>(() => ({\n ...SU_SELECT_LABELS,\n ...this.labels(),\n }));\n\n private readonly controller = new SuSelectController<T>();\n protected readonly state = signal(this.controller.state.get());\n protected readonly groups = computed(() =>\n suSelectGroups(this.state().visible)\n );\n protected readonly selected = computed(() => {\n this.state();\n return this.controller.selected;\n });\n protected readonly activeId = computed(() => {\n const { open, active } = this.state();\n return open && active >= 0 ? this.optionId(active) : null;\n });\n\n private readonly host: ElementRef<HTMLElement> = inject(ElementRef);\n private readonly document = inject(DOCUMENT);\n private readonly trigger =\n viewChild.required<ElementRef<HTMLButtonElement>>('trigger');\n private readonly panel = viewChild.required<ElementRef<HTMLElement>>('panel');\n private readonly search = viewChild<ElementRef<HTMLInputElement>>('search');\n\n constructor() {\n let previous = this.controller.state.get();\n const unsubscribe = this.controller.state.subscribe(state => {\n this.state.set(state);\n if (state.value !== previous.value) {\n this.value.set(state.value);\n }\n if (state.open !== previous.open) {\n this.open.set(state.open);\n }\n previous = state;\n });\n inject(DestroyRef).onDestroy(unsubscribe);\n\n effect(() => {\n const options = this.options();\n untracked(() => this.controller.setOptions(options));\n });\n\n effect(() => {\n const value = this.value();\n untracked(() => this.controller.setValue(value));\n });\n\n effect(() => {\n const open = this.open() && !this.disabled();\n untracked(() =>\n open ? this.controller.open() : this.controller.close()\n );\n });\n\n effect(onCleanup => {\n if (!this.state().open) {\n return;\n }\n const onPointerDown = (event: PointerEvent) =>\n this.onDocumentPointerDown(event);\n const onMove = () => this.follow();\n const view = this.document.defaultView;\n this.document.addEventListener('pointerdown', onPointerDown);\n view?.addEventListener('scroll', onMove, true);\n view?.addEventListener('resize', onMove);\n onCleanup(() => {\n this.document.removeEventListener('pointerdown', onPointerDown);\n view?.removeEventListener('scroll', onMove, true);\n view?.removeEventListener('resize', onMove);\n });\n });\n\n afterRenderEffect(() => {\n const open = this.state().open;\n untracked(() => (open ? this.reveal() : this.conceal()));\n });\n\n afterRenderEffect(() => {\n const id = this.activeId();\n const option = id ? this.document.getElementById(id) : null;\n if (option && typeof option.scrollIntoView === 'function') {\n option.scrollIntoView({ block: 'nearest' });\n }\n });\n }\n\n /** Moves focus to the trigger */\n focus(): void {\n this.trigger().nativeElement.focus();\n }\n\n protected optionId(index: number): string {\n return `${this.id}-option-${index}`;\n }\n\n protected isSelected(option: SuSelectOption<T>): boolean {\n return option === this.selected();\n }\n\n protected toggle(): void {\n if (!this.disabled()) {\n this.controller.toggle();\n }\n }\n\n protected choose(index: number): void {\n this.byUser(() => this.pick(index));\n }\n\n protected activate(index: number): void {\n if (index !== this.state().active) {\n this.controller.activate(index);\n }\n }\n\n protected onSearch(event: Event): void {\n if (event.target instanceof HTMLInputElement) {\n this.controller.search(event.target.value);\n }\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n if (this.disabled() || event.ctrlKey || event.metaKey) {\n return;\n }\n this.byUser(() =>\n this.state().open\n ? this.onOpenKeydown(event)\n : this.onClosedKeydown(event)\n );\n }\n\n protected onFocusOut(event: FocusEvent): void {\n const next = event.relatedTarget;\n if (next instanceof Node && this.host.nativeElement.contains(next)) {\n return;\n }\n this.controller.close();\n this.touched.set(true);\n }\n\n private onClosedKeydown(event: KeyboardEvent): void {\n const move = MOVES[event.key];\n if (move || event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.controller.open();\n if (move === 'first' || move === 'last') {\n this.controller.move(move);\n }\n return;\n }\n if (isPrintable(event)) {\n event.preventDefault();\n this.controller.typeAhead(event.key);\n }\n }\n\n private onOpenKeydown(event: KeyboardEvent): void {\n const searching = this.searchable();\n const move = MOVES[event.key];\n if (event.key === 'ArrowUp' && event.altKey) {\n event.preventDefault();\n this.pick(this.state().active);\n } else if (\n move &&\n !(searching && (event.key === 'Home' || event.key === 'End'))\n ) {\n event.preventDefault();\n this.controller.move(move);\n } else if (event.key === 'Enter' || (event.key === ' ' && !searching)) {\n event.preventDefault();\n this.pick(this.state().active);\n } else if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n this.controller.close();\n this.focus();\n } else if (event.key === 'Tab') {\n this.controller.choose();\n this.controller.close();\n } else if (!searching && isPrintable(event)) {\n event.preventDefault();\n this.controller.typeAhead(event.key);\n }\n }\n\n private pick(index: number): void {\n if (this.controller.choose(index)) {\n this.focus();\n }\n }\n\n private byUser(action: () => void): void {\n const before = this.controller.state.get().value;\n action();\n const after = this.controller.state.get().value;\n if (after !== null && after !== before) {\n this.chosen.emit(after);\n }\n }\n\n private onDocumentPointerDown(event: PointerEvent): void {\n const target = event.target;\n if (\n !(target instanceof Node) ||\n !this.host.nativeElement.contains(target)\n ) {\n this.controller.close();\n }\n }\n\n private reveal(): void {\n const panel = this.panel().nativeElement;\n panel.classList.add('su-select-shown');\n if (\n typeof panel.showPopover === 'function' &&\n !panel.matches(':popover-open')\n ) {\n panel.showPopover();\n }\n this.place();\n const search = this.search()?.nativeElement;\n if (search) {\n search.value = '';\n search.focus();\n }\n }\n\n private conceal(): void {\n const panel = this.panel().nativeElement;\n panel.classList.remove('su-select-shown');\n if (\n typeof panel.hidePopover === 'function' &&\n panel.matches(':popover-open')\n ) {\n panel.hidePopover();\n }\n }\n\n private follow(): void {\n const trigger = this.trigger().nativeElement.getBoundingClientRect();\n const height = this.document.defaultView?.innerHeight ?? 0;\n if (trigger.bottom <= 0 || trigger.top >= height) {\n this.controller.close();\n return;\n }\n this.place();\n }\n\n private place(): void {\n if (!this.state().open) {\n return;\n }\n const panel = this.panel().nativeElement;\n const trigger = this.trigger().nativeElement.getBoundingClientRect();\n const view = this.document.defaultView;\n panel.style.minWidth = `${trigger.width}px`;\n const position = suTooltipPosition(\n trigger,\n { width: panel.offsetWidth, height: panel.offsetHeight },\n {\n placement: 'bottom-start',\n offset: 4,\n viewport: {\n width: this.document.documentElement.clientWidth,\n height: view?.innerHeight ?? 0,\n },\n rtl:\n view?.getComputedStyle(this.host.nativeElement).direction === 'rtl',\n }\n );\n panel.dataset['side'] = position.side;\n panel.style.left = `${position.x}px`;\n panel.style.top = `${position.y}px`;\n }\n}\n\nfunction isPrintable(event: KeyboardEvent): boolean {\n return event.key.length === 1 && event.key !== ' ' && !event.altKey;\n}\n","<button\n #trigger\n type=\"button\"\n class=\"su-select-trigger\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n [id]=\"id\"\n [disabled]=\"disabled()\"\n [attr.aria-expanded]=\"state().open\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"searchable() ? null : activeId()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"ariaLabelledby() ?? null\"\n (click)=\"toggle()\"\n (keydown)=\"onKeydown($event)\">\n <span class=\"su-select-value\" [class.su-select-placeholder]=\"!selected()\">{{ selected()?.label ?? placeholder() ?? texts().placeholder }}</span>\n <svg class=\"su-select-chevron\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"m6 9 6 6 6-6\" /></svg>\n</button>\n<div #panel popover=\"manual\" class=\"su-select-panel\" [class.su-select-animated]=\"animated()\">\n @if (searchable()) {\n <input\n #search\n type=\"text\"\n class=\"su-select-search\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n aria-autocomplete=\"list\"\n aria-expanded=\"true\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"activeId()\"\n [attr.aria-label]=\"texts().search\"\n [placeholder]=\"texts().search\"\n (input)=\"onSearch($event)\"\n (keydown)=\"onKeydown($event)\" />\n }\n <ul class=\"su-select-list\" role=\"listbox\" tabindex=\"-1\" [id]=\"listId\" [attr.aria-label]=\"ariaLabel() ?? null\" [attr.aria-labelledby]=\"ariaLabel() ? null : (ariaLabelledby() ?? id)\" (mousedown)=\"$event.preventDefault()\">\n @for (group of groups(); track $index) {\n <li role=\"presentation\">\n <ul class=\"su-select-group\" [attr.role]=\"group.label ? 'group' : 'presentation'\" [attr.aria-labelledby]=\"group.label ? id + '-group-' + $index : null\">\n @if (group.label) {\n <li role=\"presentation\" class=\"su-select-group-label\" [id]=\"id + '-group-' + $index\">{{ group.label }}</li>\n }\n @for (item of group.options; track item.index) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -- the combobox handles the keyboard through aria-activedescendant -->\n <li\n role=\"option\"\n class=\"su-select-option\"\n [id]=\"optionId(item.index)\"\n [class.su-select-active]=\"item.index === state().active\"\n [attr.aria-selected]=\"isSelected(item.option)\"\n [attr.aria-disabled]=\"item.option.disabled ? true : null\"\n (click)=\"choose(item.index)\"\n (pointermove)=\"activate(item.index)\">\n <span class=\"su-select-option-label\">{{ item.option.label }}</span>\n <svg class=\"su-select-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\" /></svg>\n </li>\n }\n </ul>\n </li>\n } @empty {\n <li role=\"presentation\" class=\"su-select-empty\">{{ texts().empty }}</li>\n }\n </ul>\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAKA,IAAI,YAAY,GAAG,CAAC;AAEpB,MAAM,KAAK,GAA2C;AACpD,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,OAAO,EAAE,UAAU;AACnB,IAAA,IAAI,EAAE,OAAO;AACb,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,QAAQ,EAAE,MAAM;AAChB,IAAA,MAAM,EAAE,OAAO;CAChB;AAED;;;;;;AAMG;MAaU,iBAAiB,CAAA;;AAEnB,IAAA,OAAO,GAAG,KAAK,CAA+B,EAAE,CAAC;;AAEjD,IAAA,KAAK,GAAG,KAAK,CAAW,IAAI,CAAC;;AAE7B,IAAA,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC;;AAEnB,IAAA,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC;;IAEtB,UAAU,GAAG,KAAK,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;;IAE1D,QAAQ,GAAG,KAAK,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;;IAExD,QAAQ,GAAG,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;;IAEvD,WAAW,GAAG,KAAK,EAAU;;IAE7B,SAAS,GAAG,KAAK,EAAU;;IAE3B,cAAc,GAAG,KAAK,EAAU;;AAEhC,IAAA,MAAM,GAAG,KAAK,CAA0B,EAAE,CAAC;;IAE3C,MAAM,GAAG,MAAM,EAAK;AAEV,IAAA,EAAE,GAAG,CAAA,UAAA,EAAa,YAAY,EAAE,EAAE;AAClC,IAAA,MAAM,GAAG,CAAA,EAA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VA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"su-labs-select.mjs","names":[],"sources":["../../../../projects/su-labs/select/src/lib/select/select.component.ts","../../../../projects/su-labs/select/src/lib/select/select.component.html"],"sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport { afterRenderEffect, booleanAttribute, ChangeDetectionStrategy, Component, computed, DestroyRef, effect, ElementRef, inject, input, model, output, signal, untracked, viewChild } from '@angular/core';\nimport { SU_SELECT_LABELS, SuSelectController, suSelectGroups, SuSelectLabels, SuSelectMove, SuSelectOption } from '@su-labs/core/select';\nimport { suTooltipPosition } from '@su-labs/core/tooltip';\n\nlet nextSelectId = 0;\n\nconst MOVES: Readonly<Record<string, SuSelectMove>> = {\n ArrowDown: 'next',\n ArrowUp: 'previous',\n Home: 'first',\n End: 'last',\n PageDown: 'last',\n PageUp: 'first',\n};\n\n/**\n * A select over `SuSelectController` from `@su-labs/core/select`, with its own styled list instead of the browser's\n * popup: `<su-lib-select [options]=\"sizes\" [(value)]=\"size\" />`. The trigger is a `combobox` button and the list a\n * `listbox` in the top layer (`popover`), placed below the trigger or above it when there's no room. It follows the\n * WAI-ARIA select-only combobox pattern: arrows, Home and End, type-ahead, Enter or Space to choose, Escape to close\n * and Tab to choose and move on. With `searchable`, a search field at the top of the list filters the options.\n */\n@Component({\n selector: 'su-lib-select',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './select.component.html',\n styleUrl: './select.component.scss',\n host: {\n class: 'su-select',\n '[class.su-select-open]': 'open()',\n '[class.su-select-disabled]': 'disabled()',\n '(focusout)': 'onFocusOut($event)',\n },\n})\nexport class SuSelectComponent<T> {\n /** The choices: `{ value, label, disabled?, group? }`; options sharing a `group` should follow one another */\n readonly options = input<readonly SuSelectOption<T>[]>([]);\n /** The chosen value, or `null` while nothing is chosen */\n readonly value = model<T | null>(null);\n /** Whether the list is open; setting it opens or closes it */\n readonly open = model(false);\n /** Set once focus has left the select, for forms that show errors after the user moved on */\n readonly touched = model(false);\n /** A search field at the top of the list that filters the options @default false */\n readonly searchable = input(false, { transform: booleanAttribute });\n /** Can't be opened or focused @default false */\n readonly disabled = input(false, { transform: booleanAttribute });\n /** Opens with a short fade and slide; off when the user prefers less motion @default true */\n readonly animated = input(true, { transform: booleanAttribute });\n /** Shown while nothing is chosen @default labels.placeholder */\n readonly placeholder = input<string>();\n /** The select's name for screen readers, when no `<label>` wraps it and no `ariaLabelledby` names it */\n readonly ariaLabel = input<string>();\n /** The id of the element that names the select */\n readonly ariaLabelledby = input<string>();\n /** Texts to replace, e.g. in the page's language */\n readonly labels = input<Partial<SuSelectLabels>>({});\n /** The user chose an option (never emitted for a value set from outside): its value */\n readonly chosen = output<T>();\n\n protected readonly id = `su-select-${nextSelectId++}`;\n protected readonly listId = `${this.id}-list`;\n protected readonly texts = computed<SuSelectLabels>(() => ({\n ...SU_SELECT_LABELS,\n ...this.labels(),\n }));\n\n private readonly controller = new SuSelectController<T>();\n protected readonly state = signal(this.controller.state.get());\n protected readonly groups = computed(() =>\n suSelectGroups(this.state().visible)\n );\n protected readonly selected = computed(() => {\n this.state();\n return this.controller.selected;\n });\n protected readonly activeId = computed(() => {\n const { open, active } = this.state();\n return open && active >= 0 ? this.optionId(active) : null;\n });\n\n private readonly host: ElementRef<HTMLElement> = inject(ElementRef);\n private readonly document = inject(DOCUMENT);\n private readonly trigger =\n viewChild.required<ElementRef<HTMLButtonElement>>('trigger');\n private readonly panel = viewChild.required<ElementRef<HTMLElement>>('panel');\n private readonly search = viewChild<ElementRef<HTMLInputElement>>('search');\n\n constructor() {\n let previous = this.controller.state.get();\n const unsubscribe = this.controller.state.subscribe(state => {\n this.state.set(state);\n if (state.value !== previous.value) {\n this.value.set(state.value);\n }\n if (state.open !== previous.open) {\n this.open.set(state.open);\n }\n previous = state;\n });\n inject(DestroyRef).onDestroy(unsubscribe);\n\n effect(() => {\n const options = this.options();\n untracked(() => this.controller.setOptions(options));\n });\n\n effect(() => {\n const value = this.value();\n untracked(() => this.controller.setValue(value));\n });\n\n effect(() => {\n const open = this.open() && !this.disabled();\n untracked(() =>\n open ? this.controller.open() : this.controller.close()\n );\n });\n\n effect(onCleanup => {\n if (!this.state().open) {\n return;\n }\n const onPointerDown = (event: PointerEvent) =>\n this.onDocumentPointerDown(event);\n const onMove = () => this.follow();\n const view = this.document.defaultView;\n this.document.addEventListener('pointerdown', onPointerDown);\n view?.addEventListener('scroll', onMove, true);\n view?.addEventListener('resize', onMove);\n onCleanup(() => {\n this.document.removeEventListener('pointerdown', onPointerDown);\n view?.removeEventListener('scroll', onMove, true);\n view?.removeEventListener('resize', onMove);\n });\n });\n\n afterRenderEffect(() => {\n const open = this.state().open;\n untracked(() => (open ? this.reveal() : this.conceal()));\n });\n\n afterRenderEffect(() => {\n const id = this.activeId();\n const option = id ? this.document.getElementById(id) : null;\n if (option && typeof option.scrollIntoView === 'function') {\n option.scrollIntoView({ block: 'nearest' });\n }\n });\n }\n\n /** Moves focus to the trigger */\n focus(): void {\n this.trigger().nativeElement.focus();\n }\n\n protected optionId(index: number): string {\n return `${this.id}-option-${index}`;\n }\n\n protected isSelected(option: SuSelectOption<T>): boolean {\n return option === this.selected();\n }\n\n protected toggle(): void {\n if (!this.disabled()) {\n this.controller.toggle();\n }\n }\n\n protected choose(index: number): void {\n this.byUser(() => this.pick(index));\n }\n\n protected activate(index: number): void {\n if (index !== this.state().active) {\n this.controller.activate(index);\n }\n }\n\n protected onSearch(event: Event): void {\n if (event.target instanceof HTMLInputElement) {\n this.controller.search(event.target.value);\n }\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n if (this.disabled() || event.ctrlKey || event.metaKey) {\n return;\n }\n this.byUser(() =>\n this.state().open\n ? this.onOpenKeydown(event)\n : this.onClosedKeydown(event)\n );\n }\n\n protected onFocusOut(event: FocusEvent): void {\n const next = event.relatedTarget;\n if (next instanceof Node && this.host.nativeElement.contains(next)) {\n return;\n }\n this.controller.close();\n this.touched.set(true);\n }\n\n private onClosedKeydown(event: KeyboardEvent): void {\n const move = MOVES[event.key];\n if (move || event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.controller.open();\n if (move === 'first' || move === 'last') {\n this.controller.move(move);\n }\n return;\n }\n if (isPrintable(event)) {\n event.preventDefault();\n this.controller.typeAhead(event.key);\n }\n }\n\n private onOpenKeydown(event: KeyboardEvent): void {\n const searching = this.searchable();\n const move = MOVES[event.key];\n if (event.key === 'ArrowUp' && event.altKey) {\n event.preventDefault();\n this.pick(this.state().active);\n } else if (\n move &&\n !(searching && (event.key === 'Home' || event.key === 'End'))\n ) {\n event.preventDefault();\n this.controller.move(move);\n } else if (event.key === 'Enter' || (event.key === ' ' && !searching)) {\n event.preventDefault();\n this.pick(this.state().active);\n } else if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n this.controller.close();\n this.focus();\n } else if (event.key === 'Tab') {\n this.controller.choose();\n this.controller.close();\n } else if (!searching && isPrintable(event)) {\n event.preventDefault();\n this.controller.typeAhead(event.key);\n }\n }\n\n private pick(index: number): void {\n if (this.controller.choose(index)) {\n this.focus();\n }\n }\n\n private byUser(action: () => void): void {\n const before = this.controller.state.get().value;\n action();\n const after = this.controller.state.get().value;\n if (after !== null && after !== before) {\n this.chosen.emit(after);\n }\n }\n\n private onDocumentPointerDown(event: PointerEvent): void {\n const target = event.target;\n if (\n !(target instanceof Node) ||\n !this.host.nativeElement.contains(target)\n ) {\n this.controller.close();\n }\n }\n\n private reveal(): void {\n const panel = this.panel().nativeElement;\n panel.classList.add('su-select-shown');\n if (\n typeof panel.showPopover === 'function' &&\n !panel.matches(':popover-open')\n ) {\n panel.showPopover();\n }\n this.place();\n const search = this.search()?.nativeElement;\n if (search) {\n search.value = '';\n search.focus();\n }\n }\n\n private conceal(): void {\n const panel = this.panel().nativeElement;\n panel.classList.remove('su-select-shown');\n if (\n typeof panel.hidePopover === 'function' &&\n panel.matches(':popover-open')\n ) {\n panel.hidePopover();\n }\n }\n\n private follow(): void {\n const trigger = this.trigger().nativeElement.getBoundingClientRect();\n const height = this.document.defaultView?.innerHeight ?? 0;\n if (trigger.bottom <= 0 || trigger.top >= height) {\n this.controller.close();\n return;\n }\n this.place();\n }\n\n private place(): void {\n if (!this.state().open) {\n return;\n }\n const panel = this.panel().nativeElement;\n const trigger = this.trigger().nativeElement.getBoundingClientRect();\n const view = this.document.defaultView;\n panel.style.minWidth = `${trigger.width}px`;\n const position = suTooltipPosition(\n trigger,\n { width: panel.offsetWidth, height: panel.offsetHeight },\n {\n placement: 'bottom-start',\n offset: 4,\n viewport: {\n width: this.document.documentElement.clientWidth,\n height: view?.innerHeight ?? 0,\n },\n rtl:\n view?.getComputedStyle(this.host.nativeElement).direction === 'rtl',\n }\n );\n panel.dataset['side'] = position.side;\n panel.style.left = `${position.x}px`;\n panel.style.top = `${position.y}px`;\n }\n}\n\nfunction isPrintable(event: KeyboardEvent): boolean {\n return event.key.length === 1 && event.key !== ' ' && !event.altKey;\n}\n","<button\n #trigger\n type=\"button\"\n class=\"su-select-trigger\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n [id]=\"id\"\n [disabled]=\"disabled()\"\n [attr.aria-expanded]=\"state().open\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"searchable() ? null : activeId()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"ariaLabelledby() ?? null\"\n (click)=\"toggle()\"\n (keydown)=\"onKeydown($event)\">\n <span class=\"su-select-value\" [class.su-select-placeholder]=\"!selected()\">{{ selected()?.label ?? placeholder() ?? texts().placeholder }}</span>\n <svg class=\"su-select-chevron\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"m6 9 6 6 6-6\" /></svg>\n</button>\n<div #panel popover=\"manual\" class=\"su-select-panel\" [class.su-select-animated]=\"animated()\">\n @if (searchable()) {\n <input\n #search\n type=\"text\"\n class=\"su-select-search\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n aria-autocomplete=\"list\"\n aria-expanded=\"true\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"activeId()\"\n [attr.aria-label]=\"texts().search\"\n [placeholder]=\"texts().search\"\n (input)=\"onSearch($event)\"\n (keydown)=\"onKeydown($event)\" />\n }\n <ul class=\"su-select-list\" role=\"listbox\" tabindex=\"-1\" [id]=\"listId\" [attr.aria-label]=\"ariaLabel() ?? null\" [attr.aria-labelledby]=\"ariaLabel() ? null : (ariaLabelledby() ?? id)\" (mousedown)=\"$event.preventDefault()\">\n @for (group of groups(); track $index) {\n <li role=\"presentation\">\n <ul class=\"su-select-group\" [attr.role]=\"group.label ? 'group' : 'presentation'\" [attr.aria-labelledby]=\"group.label ? id + '-group-' + $index : null\">\n @if (group.label) {\n <li role=\"presentation\" class=\"su-select-group-label\" [id]=\"id + '-group-' + $index\">{{ group.label }}</li>\n }\n @for (item of group.options; track item.index) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -- the combobox handles the keyboard through aria-activedescendant -->\n <li\n role=\"option\"\n class=\"su-select-option\"\n [id]=\"optionId(item.index)\"\n [class.su-select-active]=\"item.index === state().active\"\n [attr.aria-selected]=\"isSelected(item.option)\"\n [attr.aria-disabled]=\"item.option.disabled ? true : null\"\n (click)=\"choose(item.index)\"\n (pointermove)=\"activate(item.index)\">\n <span class=\"su-select-option-label\">{{ item.option.label }}</span>\n <svg class=\"su-select-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\" /></svg>\n </li>\n }\n </ul>\n </li>\n } @empty {\n <li role=\"presentation\" class=\"su-select-empty\">{{ texts().empty }}</li>\n }\n </ul>\n</div>\n"],"mappings":";;;;;AAKA,IAAI,eAAe;AAEnB,MAAM,QAAgD;CACpD,WAAW;CACX,SAAS;CACT,MAAM;CACN,KAAK;CACL,UAAU;CACV,QAAQ;AACT;AAqBD,IAAa,oBAAb,MAAa,kBAAiB;CAEnB,UA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AAW,KAAK,MAAM,QAAQ,OAAO,CAAC,MAAM;AAC/D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@su-labs/select",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.0.0",
|
|
4
4
|
"description": "An accessible Angular select with its own styled list instead of the native popup: search, groups, disabled options, full keyboard support and type-ahead, opening in the top layer and flipping above when there is no room, themeable with CSS variables.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"url": "https://github.com/Greezaaa/settings-utils-lib/issues"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@angular/common": "^
|
|
34
|
-
"@angular/core": "^
|
|
33
|
+
"@angular/common": "^22.0.0",
|
|
34
|
+
"@angular/core": "^22.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@su-labs/core": "1.13.0",
|
|
@@ -40,14 +40,15 @@
|
|
|
40
40
|
"sideEffects": false,
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"module": "fesm2022/su-labs-select.mjs",
|
|
43
|
-
"typings": "
|
|
43
|
+
"typings": "types/su-labs-select.d.ts",
|
|
44
44
|
"exports": {
|
|
45
45
|
"./package.json": {
|
|
46
46
|
"default": "./package.json"
|
|
47
47
|
},
|
|
48
48
|
".": {
|
|
49
|
-
"types": "./
|
|
49
|
+
"types": "./types/su-labs-select.d.ts",
|
|
50
50
|
"default": "./fesm2022/su-labs-select.mjs"
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
},
|
|
53
|
+
"type": "module"
|
|
53
54
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { SuSelectLabels, SuSelectOption } from "@su-labs/core/select";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* A select over `SuSelectController` from `@su-labs/core/select`, with its own styled list instead of the browser's
|
|
5
|
+
* popup: `<su-lib-select [options]="sizes" [(value)]="size" />`. The trigger is a `combobox` button and the list a
|
|
6
|
+
* `listbox` in the top layer (`popover`), placed below the trigger or above it when there's no room. It follows the
|
|
7
|
+
* WAI-ARIA select-only combobox pattern: arrows, Home and End, type-ahead, Enter or Space to choose, Escape to close
|
|
8
|
+
* and Tab to choose and move on. With `searchable`, a search field at the top of the list filters the options.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SuSelectComponent<T> {
|
|
11
|
+
/** The choices: `{ value, label, disabled?, group? }`; options sharing a `group` should follow one another */
|
|
12
|
+
readonly options: import("@angular/core").InputSignal<readonly SuSelectOption<T>[]>;
|
|
13
|
+
/** The chosen value, or `null` while nothing is chosen */
|
|
14
|
+
readonly value: import("@angular/core").ModelSignal<T | null>;
|
|
15
|
+
/** Whether the list is open; setting it opens or closes it */
|
|
16
|
+
readonly open: import("@angular/core").ModelSignal<boolean>;
|
|
17
|
+
/** Set once focus has left the select, for forms that show errors after the user moved on */
|
|
18
|
+
readonly touched: import("@angular/core").ModelSignal<boolean>;
|
|
19
|
+
/** A search field at the top of the list that filters the options @default false */
|
|
20
|
+
readonly searchable: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
21
|
+
/** Can't be opened or focused @default false */
|
|
22
|
+
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
23
|
+
/** Opens with a short fade and slide; off when the user prefers less motion @default true */
|
|
24
|
+
readonly animated: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
25
|
+
/** Shown while nothing is chosen @default labels.placeholder */
|
|
26
|
+
readonly placeholder: import("@angular/core").InputSignal<string | undefined>;
|
|
27
|
+
/** The select's name for screen readers, when no `<label>` wraps it and no `ariaLabelledby` names it */
|
|
28
|
+
readonly ariaLabel: import("@angular/core").InputSignal<string | undefined>;
|
|
29
|
+
/** The id of the element that names the select */
|
|
30
|
+
readonly ariaLabelledby: import("@angular/core").InputSignal<string | undefined>;
|
|
31
|
+
/** Texts to replace, e.g. in the page's language */
|
|
32
|
+
readonly labels: import("@angular/core").InputSignal<Partial<SuSelectLabels>>;
|
|
33
|
+
/** The user chose an option (never emitted for a value set from outside): its value */
|
|
34
|
+
readonly chosen: import("@angular/core").OutputEmitterRef<T>;
|
|
35
|
+
protected readonly id: string;
|
|
36
|
+
protected readonly listId: string;
|
|
37
|
+
protected readonly texts: import("@angular/core").Signal<SuSelectLabels>;
|
|
38
|
+
private readonly controller;
|
|
39
|
+
protected readonly state: import("@angular/core").WritableSignal<import("@su-labs/core/select").SuSelectState<T>>;
|
|
40
|
+
protected readonly groups: import("@angular/core").Signal<readonly import("@su-labs/core/select").SuSelectGroup<T>[]>;
|
|
41
|
+
protected readonly selected: import("@angular/core").Signal<SuSelectOption<T> | undefined>;
|
|
42
|
+
protected readonly activeId: import("@angular/core").Signal<string | null>;
|
|
43
|
+
private readonly host;
|
|
44
|
+
private readonly document;
|
|
45
|
+
private readonly trigger;
|
|
46
|
+
private readonly panel;
|
|
47
|
+
private readonly search;
|
|
48
|
+
constructor();
|
|
49
|
+
/** Moves focus to the trigger */
|
|
50
|
+
focus(): void;
|
|
51
|
+
protected optionId(index: number): string;
|
|
52
|
+
protected isSelected(option: SuSelectOption<T>): boolean;
|
|
53
|
+
protected toggle(): void;
|
|
54
|
+
protected choose(index: number): void;
|
|
55
|
+
protected activate(index: number): void;
|
|
56
|
+
protected onSearch(event: Event): void;
|
|
57
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
58
|
+
protected onFocusOut(event: FocusEvent): void;
|
|
59
|
+
private onClosedKeydown;
|
|
60
|
+
private onOpenKeydown;
|
|
61
|
+
private pick;
|
|
62
|
+
private byUser;
|
|
63
|
+
private onDocumentPointerDown;
|
|
64
|
+
private reveal;
|
|
65
|
+
private conceal;
|
|
66
|
+
private follow;
|
|
67
|
+
private place;
|
|
68
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SuSelectComponent<any>, never>;
|
|
69
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SuSelectComponent<any>, "su-lib-select", never, {
|
|
70
|
+
"options": {
|
|
71
|
+
"alias": "options";
|
|
72
|
+
"required": false;
|
|
73
|
+
"isSignal": true;
|
|
74
|
+
};
|
|
75
|
+
"value": {
|
|
76
|
+
"alias": "value";
|
|
77
|
+
"required": false;
|
|
78
|
+
"isSignal": true;
|
|
79
|
+
};
|
|
80
|
+
"open": {
|
|
81
|
+
"alias": "open";
|
|
82
|
+
"required": false;
|
|
83
|
+
"isSignal": true;
|
|
84
|
+
};
|
|
85
|
+
"touched": {
|
|
86
|
+
"alias": "touched";
|
|
87
|
+
"required": false;
|
|
88
|
+
"isSignal": true;
|
|
89
|
+
};
|
|
90
|
+
"searchable": {
|
|
91
|
+
"alias": "searchable";
|
|
92
|
+
"required": false;
|
|
93
|
+
"isSignal": true;
|
|
94
|
+
};
|
|
95
|
+
"disabled": {
|
|
96
|
+
"alias": "disabled";
|
|
97
|
+
"required": false;
|
|
98
|
+
"isSignal": true;
|
|
99
|
+
};
|
|
100
|
+
"animated": {
|
|
101
|
+
"alias": "animated";
|
|
102
|
+
"required": false;
|
|
103
|
+
"isSignal": true;
|
|
104
|
+
};
|
|
105
|
+
"placeholder": {
|
|
106
|
+
"alias": "placeholder";
|
|
107
|
+
"required": false;
|
|
108
|
+
"isSignal": true;
|
|
109
|
+
};
|
|
110
|
+
"ariaLabel": {
|
|
111
|
+
"alias": "ariaLabel";
|
|
112
|
+
"required": false;
|
|
113
|
+
"isSignal": true;
|
|
114
|
+
};
|
|
115
|
+
"ariaLabelledby": {
|
|
116
|
+
"alias": "ariaLabelledby";
|
|
117
|
+
"required": false;
|
|
118
|
+
"isSignal": true;
|
|
119
|
+
};
|
|
120
|
+
"labels": {
|
|
121
|
+
"alias": "labels";
|
|
122
|
+
"required": false;
|
|
123
|
+
"isSignal": true;
|
|
124
|
+
};
|
|
125
|
+
}, {
|
|
126
|
+
"value": "valueChange";
|
|
127
|
+
"open": "openChange";
|
|
128
|
+
"touched": "touchedChange";
|
|
129
|
+
"chosen": "chosen";
|
|
130
|
+
}, never, never, true, never>;
|
|
131
|
+
}
|
package/index.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { SuSelectLabels, SuSelectOption } from '@su-labs/core/select';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
/**
|
|
4
|
-
* A select over `SuSelectController` from `@su-labs/core/select`, with its own styled list instead of the browser's
|
|
5
|
-
* popup: `<su-lib-select [options]="sizes" [(value)]="size" />`. The trigger is a `combobox` button and the list a
|
|
6
|
-
* `listbox` in the top layer (`popover`), placed below the trigger or above it when there's no room. It follows the
|
|
7
|
-
* WAI-ARIA select-only combobox pattern: arrows, Home and End, type-ahead, Enter or Space to choose, Escape to close
|
|
8
|
-
* and Tab to choose and move on. With `searchable`, a search field at the top of the list filters the options.
|
|
9
|
-
*/
|
|
10
|
-
export declare class SuSelectComponent<T> {
|
|
11
|
-
/** The choices: `{ value, label, disabled?, group? }`; options sharing a `group` should follow one another */
|
|
12
|
-
readonly options: import("@angular/core").InputSignal<readonly SuSelectOption<T>[]>;
|
|
13
|
-
/** The chosen value, or `null` while nothing is chosen */
|
|
14
|
-
readonly value: import("@angular/core").ModelSignal<T | null>;
|
|
15
|
-
/** Whether the list is open; setting it opens or closes it */
|
|
16
|
-
readonly open: import("@angular/core").ModelSignal<boolean>;
|
|
17
|
-
/** Set once focus has left the select, for forms that show errors after the user moved on */
|
|
18
|
-
readonly touched: import("@angular/core").ModelSignal<boolean>;
|
|
19
|
-
/** A search field at the top of the list that filters the options @default false */
|
|
20
|
-
readonly searchable: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
21
|
-
/** Can't be opened or focused @default false */
|
|
22
|
-
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
23
|
-
/** Opens with a short fade and slide; off when the user prefers less motion @default true */
|
|
24
|
-
readonly animated: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
25
|
-
/** Shown while nothing is chosen @default labels.placeholder */
|
|
26
|
-
readonly placeholder: import("@angular/core").InputSignal<string | undefined>;
|
|
27
|
-
/** The select's name for screen readers, when no `<label>` wraps it and no `ariaLabelledby` names it */
|
|
28
|
-
readonly ariaLabel: import("@angular/core").InputSignal<string | undefined>;
|
|
29
|
-
/** The id of the element that names the select */
|
|
30
|
-
readonly ariaLabelledby: import("@angular/core").InputSignal<string | undefined>;
|
|
31
|
-
/** Texts to replace, e.g. in the page's language */
|
|
32
|
-
readonly labels: import("@angular/core").InputSignal<Partial<SuSelectLabels>>;
|
|
33
|
-
/** The user chose an option (never emitted for a value set from outside): its value */
|
|
34
|
-
readonly chosen: import("@angular/core").OutputEmitterRef<T>;
|
|
35
|
-
protected readonly id: string;
|
|
36
|
-
protected readonly listId: string;
|
|
37
|
-
protected readonly texts: import("@angular/core").Signal<SuSelectLabels>;
|
|
38
|
-
private readonly controller;
|
|
39
|
-
protected readonly state: import("@angular/core").WritableSignal<import("@su-labs/core/select").SuSelectState<T>>;
|
|
40
|
-
protected readonly groups: import("@angular/core").Signal<readonly import("@su-labs/core/select").SuSelectGroup<T>[]>;
|
|
41
|
-
protected readonly selected: import("@angular/core").Signal<SuSelectOption<T> | undefined>;
|
|
42
|
-
protected readonly activeId: import("@angular/core").Signal<string | null>;
|
|
43
|
-
private readonly host;
|
|
44
|
-
private readonly document;
|
|
45
|
-
private readonly trigger;
|
|
46
|
-
private readonly panel;
|
|
47
|
-
private readonly search;
|
|
48
|
-
constructor();
|
|
49
|
-
/** Moves focus to the trigger */
|
|
50
|
-
focus(): void;
|
|
51
|
-
protected optionId(index: number): string;
|
|
52
|
-
protected isSelected(option: SuSelectOption<T>): boolean;
|
|
53
|
-
protected toggle(): void;
|
|
54
|
-
protected choose(index: number): void;
|
|
55
|
-
protected activate(index: number): void;
|
|
56
|
-
protected onSearch(event: Event): void;
|
|
57
|
-
protected onKeydown(event: KeyboardEvent): void;
|
|
58
|
-
protected onFocusOut(event: FocusEvent): void;
|
|
59
|
-
private onClosedKeydown;
|
|
60
|
-
private onOpenKeydown;
|
|
61
|
-
private pick;
|
|
62
|
-
private byUser;
|
|
63
|
-
private onDocumentPointerDown;
|
|
64
|
-
private reveal;
|
|
65
|
-
private conceal;
|
|
66
|
-
private follow;
|
|
67
|
-
private place;
|
|
68
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<SuSelectComponent<any>, never>;
|
|
69
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<SuSelectComponent<any>, "su-lib-select", never, { "options": { "alias": "options"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "open": { "alias": "open"; "required": false; "isSignal": true; }; "touched": { "alias": "touched"; "required": false; "isSignal": true; }; "searchable": { "alias": "searchable"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "animated": { "alias": "animated"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "ariaLabelledby"; "required": false; "isSignal": true; }; "labels": { "alias": "labels"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "open": "openChange"; "touched": "touchedChange"; "chosen": "chosen"; }, never, never, true, never>;
|
|
70
|
-
}
|
package/public-api.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/select/select.component';
|