ngwr 15.7.0 → 15.9.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/button/styles/_index.scss +3 -1
- package/collapse/styles/_index.scss +55 -3
- package/fesm2022/ngwr-breadcrumbs.mjs +2 -2
- package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +2 -2
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-collapse-testing.mjs +8 -0
- package/fesm2022/ngwr-collapse-testing.mjs.map +1 -1
- package/fesm2022/ngwr-collapse.mjs +39 -3
- package/fesm2022/ngwr-collapse.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +7 -1
- package/fesm2022/ngwr-i18n.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +2 -2
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +2 -2
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +2 -2
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-sortable-list.mjs +2 -2
- package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +34 -7
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/input/styles/_index.scss +12 -3
- package/llms-full.txt +1 -1
- package/llms.txt +5 -3
- package/package.json +1 -1
- package/pagination/styles/_index.scss +8 -0
- package/schematics/migrations/v15/index.js +2 -2
- package/skills/ngwr/references/setup.md +8 -4
- package/styles/_reset.scss +131 -119
- package/table/styles/_index.scss +7 -1
- package/theme/styles/_focus.scss +6 -0
- package/types/ngwr-collapse-testing.d.ts +16 -0
- package/types/ngwr-collapse.d.ts +66 -37
- package/types/ngwr-i18n.d.ts +12 -0
- package/types/ngwr-table.d.ts +19 -7
- package/types/ngwr-version.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-cascader.mjs","names":[],"sources":["../../../projects/lib/cascader/cascader.ts","../../../projects/lib/cascader/cascader.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n Injector,\n TemplateRef,\n ViewContainerRef,\n ViewEncapsulation,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n untracked,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { useI18nText } from 'ngwr/i18n';\nimport { WR_OVERLAY, WrOutsideClick, wrFollowDirection } from 'ngwr/overlay';\nimport { isPrintableKey, toClassList, type WrClassInput } from 'ngwr/utils';\n\nimport type { WrCascaderOption } from './types';\n\nlet panelUid = 0;\n\n/**\n * Whether a keydown is a Tab that takes focus out of the open panel. The pane\n * lives in the overlay container at the end of `<body>`, so the browser's own Tab\n * out of it went to `<body>` — the top of the page — with the panel left standing.\n * The caller focuses the trigger synchronously and does NOT `preventDefault`, so\n * the browser's Tab carries on from there to the trigger's real neighbour — the\n * move `wr-dropdown` makes for its menu.\n *\n * Every Tab inside the pane leaves it, in either direction: the panel holds ONE\n * tab stop (the roving one, see `tabStop`), so there is nowhere else inside it for\n * Tab to go. Asking \"is there a later stop\" instead would also answer wrongly for\n * the moment between an arrow key moving focus and the render that moves the\n * `tabindex=\"0\"` after it.\n */\nfunction tabLeavesPane(pane: HTMLElement, event: KeyboardEvent): boolean {\n if (event.key !== 'Tab' || event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return false;\n const active = pane.ownerDocument.activeElement;\n return !!active && pane.contains(active);\n}\n\n/** How long a pause ends a type-ahead run, in milliseconds — the figure APG's examples use. */\nconst TYPEAHEAD_MS = 500;\n\n/**\n * Multi-level select — drills down through hierarchical categories\n * (e.g. country → state → city). Each level renders as a column; clicks\n * advance to the next column. Selecting a leaf (no children) commits\n * the full path.\n *\n * A signal-forms native control: it implements `FormValueControl<unknown>`,\n * so `[formField]` binds straight to its `value` model — no\n * `ControlValueAccessor` in between. `[(value)]` works standalone. The value\n * is the path through the tree (an array from root to leaf).\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-cascader [options]=\"locations\" [formField]=\"form.path\" placeholder=\"Pick a location\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-cascader [options]=\"locations\" [(value)]=\"path\" placeholder=\"Pick a location\" />\n * ```\n *\n * ```ts\n * locations: WrCascaderOption[] = [\n * {\n * value: 'us', label: 'United States', children: [\n * { value: 'ny', label: 'New York', children: [\n * { value: 'nyc', label: 'NYC' },\n * { value: 'buf', label: 'Buffalo' },\n * ] },\n * ],\n * },\n * ];\n * ```\n *\n * @see https://ngwr.dev/reference/components/cascader\n */\nexport type WrCascaderSize = 'sm' | 'md' | 'lg';\n\n@Component({\n selector: 'wr-cascader',\n templateUrl: './cascader.html',\n styleUrl: './cascader.scss',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n})\nexport class WrCascader<T = string> implements FormValueControl<unknown> {\n /** Accessible name. Falls back to `select.clearSelection`, then `'Clear selection'`. */\n readonly clearLabel = input<string | null>(null);\n\n protected readonly resolvedClearLabel = useI18nText(this.clearLabel, 'select.clearSelection', 'Clear selection');\n\n /** Root-level options. Each may have `children` for deeper levels. */\n readonly options = input.required<readonly WrCascaderOption<T>[]>();\n\n /** Placeholder shown when no path is selected. @default '' */\n readonly placeholder = input<string>('');\n\n /**\n * Accessible name of the trigger. Falls back to the placeholder, then to\n * `select.label` — a `role=\"combobox\"` with nothing selected and no\n * placeholder otherwise has no name at all.\n */\n readonly ariaLabel = input<string | null>(null);\n\n private readonly labelText = useI18nText(this.ariaLabel, 'select.label', 'Select');\n protected readonly resolvedAriaLabel = computed(() => {\n // Not `??`: an empty placeholder must fall through to the catalog string.\n const explicit = this.ariaLabel();\n if (explicit) return explicit;\n const placeholder = this.placeholder();\n return placeholder ? placeholder : this.labelText();\n });\n\n /**\n * Disable the cascader. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse changes while the trigger stays focusable and the path still submits.\n * Bound automatically from the field's readonly state when used with\n * `[formField]`.\n *\n * The panel is where every edit happens, so a read-only cascader simply does\n * not open — there is nothing to browse that is not already on the trigger —\n * and the clear button goes away with it. Mirrored as `aria-readonly`, which\n * role `combobox` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /**\n * The field's own label, when it renders one — `null` otherwise, and `null`\n * when `[ariaLabel]` was set deliberately.\n *\n * `aria-label` outranks a `<label for>` in the accname order, so without this\n * a cascader inside `<wr-form-field label=\"Region\">` announced its\n * PLACEHOLDER, or the generic `select.label` default, and the visible label\n * reached nobody. Nothing catches it: the control has a name, so axe is\n * satisfied, and the name is plausible, so a reader is too — it fails WCAG\n * 2.5.3, where the visible label has to be IN the accessible name. Same call\n * `wr-rating` and `wr-knob` already make.\n */\n protected readonly labelledBy = computed(() => (this.ariaLabel() ? null : this.fieldAria.labelledBy()));\n\n /** `null` once `aria-labelledby` is carrying the name — see {@link labelledBy}. */\n protected readonly nameLabel = computed(() => (this.labelledBy() ? null : this.resolvedAriaLabel()));\n\n /** Control size — shares the `--wr-control-*` contract. @default 'md' */\n readonly size = input<WrCascaderSize>('md');\n\n /** Show a clear-all (×) button on the trigger when a path is selected. @default true */\n readonly clearable = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Allow selecting non-leaf (parent) nodes. When `false`, only leaves\n * (nodes without children) commit a selection. @default false\n */\n readonly changeOnSelect = input(false, { transform: coerceBooleanProperty });\n\n /** Separator between labels in the trigger display. @default '/' */\n readonly separator = input<string>('/');\n\n /**\n * Extra CSS classes for the column panel's overlay pane.\n *\n * The pane is appended to the overlay container, not to this component, so\n * nothing in the consumer's own template encloses it and no descendant rule\n * written around the trigger can reach it. This input is the only per-instance\n * handle on it. A space-separated string works as well as an array.\n */\n readonly panelClass = input<WrClassInput>(null);\n\n /**\n * Committed selection path (full array from root to leaf). Bound by\n * `[formField]`, or two-way via `[(value)]`.\n */\n readonly value = model<unknown>([]);\n\n /** Emitted on blur / commit so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n /** Committed selection path (full T[] from root to leaf). @internal */\n protected readonly path = signal<readonly T[]>([]);\n\n /** Currently-expanded column path — drives which columns the panel shows. @internal */\n protected readonly activePath = signal<readonly T[]>([]);\n\n protected readonly open = signal(false);\n\n /**\n * The option the user last moved to inside the open panel — `null` until they\n * move, and again on every open. Written by an option's `focus` event, so\n * whatever moved the caret (an arrow, a click, a harness, a type-ahead letter)\n * moves the tab stop with it.\n */\n private readonly cursor = signal<{ readonly col: number; readonly value: T } | null>(null);\n\n /**\n * The panel's ONE tab stop, as in the APG tree pattern: the option the user\n * moved to, else the selected path's leaf, else the first enabled root. Every\n * other option carries `tabindex=\"-1\"` and is reached with the arrows, so a\n * deep tree is one Tab to enter and one to leave instead of a stop per option.\n *\n * Validated against what is ON SCREEN rather than trusted: choosing a sibling\n * prunes the deeper columns, and a value written from outside replaces the\n * path, so a remembered position can name an option that is gone. A disabled\n * option is never the stop — `focus()` would land on a choice nobody can make.\n * When the leaf itself is not on screen or is disabled, the deepest ancestor on\n * the path that is takes its place.\n */\n protected readonly tabStop = computed<{ readonly col: number; readonly value: T } | null>(() => {\n const cols = this.columns();\n const enabledAt = (col: number, value: T): boolean => !!cols[col]?.some(o => o.value === value && !o.disabled);\n\n const at = this.cursor();\n if (at && enabledAt(at.col, at.value)) return at;\n\n const path = this.path();\n const active = this.activePath();\n for (let col = Math.min(path.length, cols.length) - 1; col >= 0; col--) {\n // Column `col` lists the children of the ACTIVE path above it, so the path's\n // node at that depth is on screen only while the two agree that far down.\n if (!this.pathsEqual(path.slice(0, col), active.slice(0, col))) continue;\n if (enabledAt(col, path[col])) return { col, value: path[col] };\n }\n\n const first = cols[0]?.find(o => !o.disabled);\n return first ? { col: 0, value: first.value } : null;\n });\n\n /** Letters typed in quick succession, for type-ahead. */\n private typeahead = '';\n private typeaheadAt = 0;\n\n /** Panel id used by the trigger's `aria-controls`. */\n protected readonly panelId = `wr-cascader-panel-${++panelUid}`;\n\n /**\n * Columns visible in the panel. Each column shows the children of the\n * preceding activePath entry. Column 0 = root options. The last\n * column is whatever the deepest active node's children resolve to —\n * we only render a column when there are children to show.\n */\n protected readonly columns = computed<readonly (readonly WrCascaderOption<T>[])[]>(() => {\n const cols: (readonly WrCascaderOption<T>[])[] = [this.options()];\n const trail = this.activePath();\n let list: readonly WrCascaderOption<T>[] = this.options();\n for (const v of trail) {\n const node = list.find(o => o.value === v);\n if (!node?.children?.length) break;\n cols.push(node.children);\n list = node.children;\n }\n return cols;\n });\n\n /** Label trail joined by `separator()` — what the trigger shows. */\n protected readonly displayLabel = computed(() => {\n const p = this.path();\n if (p.length === 0) return null;\n const labels: string[] = [];\n let list: readonly WrCascaderOption<T>[] = this.options();\n for (const v of p) {\n const node = list.find(o => o.value === v);\n if (!node) return null;\n labels.push(node.label);\n list = node.children ?? [];\n }\n const sep = ` ${this.separator()} `;\n return labels.join(sep);\n });\n\n protected readonly hasSelection = computed(() => this.path().length > 0);\n\n protected readonly classes = computed(() => {\n const parts = ['wr-cascader'];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-cascader--${size}`);\n if (this.open()) parts.push('wr-cascader--open');\n if (this.disabled()) parts.push('wr-cascader--disabled');\n else if (this.readonly()) parts.push('wr-cascader--readonly');\n return parts.join(' ');\n });\n\n protected readonly panelTpl = viewChild.required('panelTpl', { read: TemplateRef });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly overlay = inject(WR_OVERLAY);\n private readonly outsideClick = inject(WrOutsideClick);\n private readonly vcr = inject(ViewContainerRef);\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n /**\n * Ambient reading direction, for the open panel alone — nothing in this\n * component reads it directly. Optional so a bare `TestBed` needs no\n * provider; `Directionality` is root-provided anyway, and a missing one\n * simply reads as `ltr`.\n */\n private readonly dir = inject(Directionality, { optional: true });\n private overlayRef: OverlayRef | null = null;\n\n constructor() {\n // Same contract as wr-select / wr-dropdown / wr-lightbox: an overlay lives in\n // the CDK container, not in this component's view, so destroying the\n // component while the panel is open would strand the pane and its scroll\n // strategy.\n this.destroyRef.onDestroy(() => this.closeOverlay());\n\n effect(() => {\n if (this.open()) {\n this.openOverlay();\n } else {\n this.closeOverlay();\n }\n });\n\n // Close the panel if the control becomes disabled or read-only while open.\n effect(() => {\n if (this.disabled() || this.readonly()) this.open.set(false);\n });\n\n // Mirror an external `value` write into the internal path/activePath\n // (the old `writeValue`). Skipped when the write merely echoes the\n // committed path, so a live drill-down can never be clobbered.\n effect(() => {\n // Coerce null/undefined/non-array to an empty path — a classic-forms\n // binding can write null, which the old `writeValue(value: unknown)`\n // treated as \"no selection\" too.\n const value = this.value();\n untracked(() => {\n const next: readonly T[] = Array.isArray(value) ? (value as readonly T[]) : [];\n if (this.pathsEqual(this.path(), next)) return;\n this.path.set(next);\n this.activePath.set(next);\n });\n });\n }\n\n /**\n * Focus the trigger — what Signal Forms calls to focus this control. The\n * panel stays shut: ArrowDown or a click opens it, the way it does after Tab.\n */\n focus(options?: FocusOptions): void {\n this.host.nativeElement.querySelector<HTMLElement>('.wr-cascader__trigger')?.focus(options);\n }\n\n // Template handlers\n\n protected onTriggerClick(): void {\n if (this.disabled() || this.readonly()) return;\n if (!this.open()) this.activePath.set(this.path());\n this.open.update(v => !v);\n }\n\n /**\n * ArrowDown / ArrowUp open the panel, Alt+ArrowDown included — the combobox way in,\n * and the shape `wr-dropdown`'s trigger uses. Enter and Space need no branch: the\n * trigger is a real `<button>`, so the browser turns them into the click above.\n *\n * Only while closed. Once the panel is up the caret is inside it, and its options\n * own their own keys.\n */\n protected onTriggerKeydown(event: KeyboardEvent): void {\n if (this.disabled() || this.readonly() || this.open()) return;\n\n // Backspace is the × from the keyboard, and it has to be: the × is a\n // `tabindex=\"-1\"` span INSIDE this button, and a keydown goes to the focused\n // element, so the `(keydown.enter)` / `(keydown.space)` it used to carry could\n // never fire. Clearing was reachable by pointer alone — a WCAG 2.1.1 failure,\n // not a missing convenience. The span stays unfocusable, because a focusable\n // child of a button is `nested-interactive`. Same key, same gating as\n // `wr-select`: `clearable()` IS the clear control, so a consumer who turned\n // the × off did not ask for a keyboard twin of it.\n if (event.key === 'Backspace') {\n if (!this.clearable() || !this.hasSelection()) return;\n event.preventDefault();\n this.clearSelection(event);\n return;\n }\n\n if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return;\n event.preventDefault();\n this.activePath.set(this.path());\n this.open.set(true);\n }\n\n protected onOptionClick(colIndex: number, opt: WrCascaderOption<T>, event: Event): void {\n event.stopPropagation();\n if (opt.disabled || this.disabled() || this.readonly()) return;\n\n const head = this.activePath().slice(0, colIndex);\n const newPath = [...head, opt.value];\n\n const hasChildren = !!opt.children?.length;\n\n // Always update active column for visual feedback / next column.\n this.activePath.set(newPath);\n // A pointer click focuses the option anyway (see `onOptionFocus`); a scripted\n // `click()` does not, and the tab stop belongs where the choice was made.\n this.cursor.set({ col: colIndex, value: opt.value });\n\n // Commit when we've reached a leaf, or when changeOnSelect is on.\n if (!hasChildren || this.changeOnSelect()) {\n this.path.set(newPath);\n this.value.set(newPath);\n this.touch.emit();\n // Close once we hit a true leaf — parent commits keep the panel open.\n if (!hasChildren) this.open.set(false);\n }\n }\n\n /**\n * The tree keys the panel's roles promise, per the APG tree pattern: Up / Down\n * within a column, Home / End to its ends, the inline-end arrow into a branch's\n * children — opening the next column on the way — and the inline-start arrow back\n * to the option the column belongs to, or, from a root, closing the column it\n * opened. A letter moves to the next option in the column whose label starts with\n * what was typed. Enter and Space stay the commit.\n *\n * These are the ONLY way between options: the panel holds one tab stop (see\n * {@link tabStop}), and Tab leaves it.\n */\n protected onOptionKeydown(colIndex: number, opt: WrCascaderOption<T>, event: KeyboardEvent): void {\n const current = event.currentTarget as HTMLElement;\n const column = current.closest<HTMLElement>('[role=\"group\"]');\n if (!column) return;\n // Before the modifier check, because Shift is how a capital letter is typed.\n if (isPrintableKey(event) && event.key !== ' ') {\n this.typeAhead(column, current, event.key);\n event.preventDefault();\n return;\n }\n if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;\n const rtl = this.dir?.value === 'rtl';\n const inward = rtl ? 'ArrowLeft' : 'ArrowRight';\n const outward = rtl ? 'ArrowRight' : 'ArrowLeft';\n const enabled = [...column.querySelectorAll<HTMLElement>('[role=\"treeitem\"]')].filter(\n o => o.getAttribute('aria-disabled') !== 'true'\n );\n const at = enabled.indexOf(current);\n\n switch (event.key) {\n case 'ArrowDown':\n enabled[at + 1]?.focus();\n break;\n case 'ArrowUp':\n if (at > 0) enabled[at - 1].focus();\n break;\n case 'Home':\n enabled[0]?.focus();\n break;\n case 'End':\n enabled[enabled.length - 1]?.focus();\n break;\n case inward: {\n if (opt.disabled || !opt.children?.length || this.disabled() || this.readonly()) break;\n this.activePath.set([...this.activePath().slice(0, colIndex), opt.value]);\n // The column is not in the DOM until the render this write schedules.\n afterNextRender(\n () =>\n this.overlayRef?.overlayElement\n .querySelector<HTMLElement>(\n `#${this.columnId(colIndex + 1)} [role=\"treeitem\"]:not([aria-disabled=\"true\"])`\n )\n ?.focus(),\n { injector: this.injector }\n );\n break;\n }\n case outward: {\n if (colIndex > 0) {\n const parent = this.parentOptionId(colIndex);\n if (parent) this.overlayRef?.overlayElement.querySelector<HTMLElement>(`#${parent}`)?.focus();\n } else if (opt.children?.length && this.isActiveAt(colIndex, opt.value)) {\n this.activePath.set([]);\n }\n break;\n }\n case ' ':\n // The commit is `(keydown.space)`'s; the page scrolling a screen under the\n // panel is the browser's, and it went with every Space on an option.\n break;\n default:\n return;\n }\n event.preventDefault();\n }\n\n /** The caret reached an option, by whatever route — the tab stop follows it. */\n protected onOptionFocus(colIndex: number, opt: WrCascaderOption<T>): void {\n if (opt.disabled) return;\n this.cursor.set({ col: colIndex, value: opt.value });\n }\n\n /** Whether this option is the panel's one `tabindex=\"0\"`. */\n protected isTabStop(colIndex: number, opt: WrCascaderOption<T>): boolean {\n const stop = this.tabStop();\n return !opt.disabled && stop !== null && stop.col === colIndex && stop.value === opt.value;\n }\n\n /**\n * Move to the next enabled option in `column` whose label starts with the letters\n * typed so far. A pause of {@link TYPEAHEAD_MS} starts a new run. One letter\n * pressed again cycles through the options that start with it; a longer run keeps\n * the option it already matches, so `g` then `e` stays on \"Germany\".\n */\n private typeAhead(column: HTMLElement, current: HTMLElement, key: string): void {\n const now = Date.now();\n this.typeahead = now - this.typeaheadAt > TYPEAHEAD_MS ? key : this.typeahead + key;\n this.typeaheadAt = now;\n\n const typed = this.typeahead.toLocaleLowerCase();\n const repeated = [...typed].every(ch => ch === typed[0]);\n const search = repeated ? typed[0] : typed;\n const enabled = [...column.querySelectorAll<HTMLElement>('[role=\"treeitem\"]')].filter(\n o => o.getAttribute('aria-disabled') !== 'true'\n );\n const from = enabled.indexOf(current);\n // A fresh letter (or a repeated one) starts AFTER the current option; a longer\n // run starts AT it, so the option that matched the first letters can keep the\n // match.\n const start = search.length === 1 ? from + 1 : Math.max(from, 0);\n const label = (o: HTMLElement): string =>\n (o.querySelector('.wr-cascader__opt-label')?.textContent ?? '').trim().toLocaleLowerCase();\n for (let i = 0; i < enabled.length; i++) {\n const candidate = enabled[(start + i) % enabled.length];\n if (label(candidate).startsWith(search)) {\n candidate.focus();\n return;\n }\n }\n }\n\n protected clearSelection(event: Event): void {\n event.stopPropagation();\n if (this.disabled() || this.readonly()) return;\n this.path.set([]);\n this.activePath.set([]);\n this.value.set([]);\n this.touch.emit();\n }\n\n protected isActiveAt(colIndex: number, value: T): boolean {\n return this.activePath()[colIndex] === value;\n }\n\n /**\n * Whether this option is the committed choice — `null` when it is not a\n * choice at all.\n *\n * Two questions the panel has to keep apart, and `--active` answers only the\n * first: `activePath()` is where the user has NAVIGATED to, `path()` is what\n * they have COMMITTED. They agree once a leaf is picked and diverge for the\n * whole walk down.\n *\n * `null` — the attribute absent — on a branch while `changeOnSelect` is off,\n * because such a branch genuinely cannot be chosen; ARIA reads a missing\n * `aria-selected` as \"not selectable\", which is exactly true here. That makes\n * this binding the first expression the `changeOnSelect` contract has ever had\n * in ARIA, in both directions.\n */\n protected isSelectedAt(colIndex: number, opt: WrCascaderOption<T>): boolean | null {\n const committable = !opt.children?.length || this.changeOnSelect();\n if (!committable) return null;\n const path = this.path();\n return colIndex === path.length - 1 && path[colIndex] === opt.value;\n }\n\n /** Stable id for one option — what a column's `aria-labelledby` points at. */\n protected optionId(colIndex: number, optIndex: number): string {\n return `${this.panelId}-opt-${colIndex}-${optIndex}`;\n }\n\n /** Stable id for one column — what an expanded branch's `aria-controls` points at. */\n protected columnId(colIndex: number): string {\n return `${this.panelId}-col-${colIndex}`;\n }\n\n /**\n * The option whose children a column holds, by id — its accessible name.\n *\n * The columns are DOM SIBLINGS, so nothing in the markup says the second one\n * belongs to \"Europe\". Column 0 has no parent and stays unnamed; the tree\n * itself already carries the control's name.\n */\n protected parentOptionId(colIndex: number): string | null {\n if (colIndex === 0) return null;\n const parent = this.columns()[colIndex - 1] ?? [];\n const index = parent.findIndex(o => this.isActiveAt(colIndex - 1, o.value));\n return index < 0 ? null : this.optionId(colIndex - 1, index);\n }\n\n private pathsEqual(a: readonly T[], b: readonly T[]): boolean {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n }\n\n // Overlay\n\n private openOverlay(): void {\n if (this.overlayRef) return;\n // Each open starts from the selected path, not from where the last visit ended.\n this.cursor.set(null);\n\n const positionStrategy = this.overlay\n .position()\n .flexibleConnectedTo(this.host)\n .withPositions([\n { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },\n ])\n .withPush(true);\n\n this.overlayRef = this.overlay.create({\n positionStrategy,\n scrollStrategy: this.scrollStrategies.reposition(),\n panelClass: toClassList('wr-cascader-overlay', this.panelClass()),\n });\n\n // The columns cascade inline-wards, and the CDK captured the direction as a\n // string when this ref was created — so a flip while the panel is open left\n // the whole cascade running the other way from the page around it.\n wrFollowDirection(this.overlayRef, this.dir, this.injector);\n\n const portal = new TemplatePortal(this.panelTpl(), this.vcr);\n this.overlayRef.attach(portal);\n\n // Move the caret into the panel it just opened. Nothing did, and the pane is\n // appended to `<body>`, so an opened cascader left focus on the trigger and its\n // options were reachable only by tabbing past the whole rest of the page —\n // `wr-tree` and `wr-context-menu` were the same defect. `closeOverlay` below\n // already assumes this is where the caret lives.\n //\n // `afterNextRender`, NOT `queueMicrotask`: under zoneless CD change detection runs\n // in a macrotask, so a microtask queued here fires before the columns are in the\n // DOM — the trap that once left `wr-calendar`'s ring and its real focus on\n // different days.\n afterNextRender(() => this.focusPanelOption(), { injector: this.injector });\n\n this.outsideClick\n .outsidePointerEvents(this.overlayRef)\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (this.host.nativeElement.contains(event.target as Node)) return;\n this.open.set(false);\n });\n\n this.overlayRef\n .keydownEvents()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (event.key === 'Escape') {\n event.preventDefault();\n this.open.set(false);\n return;\n }\n if (this.overlayRef && tabLeavesPane(this.overlayRef.overlayElement, event)) {\n this.host.nativeElement.querySelector<HTMLElement>('.wr-cascader__trigger')?.focus();\n this.open.set(false);\n }\n });\n }\n\n /**\n * The option the panel opens on: its tab stop, which on open is the selected path's\n * leaf, else the first enabled root (see {@link tabStop}). A disabled option is\n * never the stop, so `focus()` cannot land on a choice nobody can make.\n */\n private focusPanelOption(): void {\n this.overlayRef?.overlayElement.querySelector<HTMLElement>('[role=\"treeitem\"][tabindex=\"0\"]')?.focus();\n }\n\n private closeOverlay(): void {\n if (!this.overlayRef) return;\n // Opening moves the caret onto the panel's tab stop and every option commits\n // on Enter, so on the keyboard the caret is INSIDE the pane by design — and\n // the ordinary way to finish choosing (`onOptionClick` on a leaf) closes it.\n // Disposing without handing focus back dropped it on `<body>` on the SUCCESS\n // path, not merely on dismissal: a keyboard user who had just picked a value\n // then had to Tab from the top of the document to get back to the control.\n // Untouched when focus had already moved elsewhere — that click is usually\n // what closed us, and stealing the caret back would fight the user for it.\n const pane = this.overlayRef.overlayElement;\n const focusWasInside = pane.contains(this.host.nativeElement.ownerDocument.activeElement);\n this.overlayRef.dispose();\n this.overlayRef = null;\n if (focusWasInside) this.host.nativeElement.querySelector<HTMLElement>('.wr-cascader__trigger')?.focus();\n }\n}\n\nexport type { WrCascaderOption } from './types';\n","<button\n type=\"button\"\n class=\"wr-cascader__trigger\"\n role=\"combobox\"\n [attr.aria-label]=\"nameLabel()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [disabled]=\"disabled()\"\n [attr.aria-haspopup]=\"'tree'\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"panelId\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onTriggerClick()\"\n (keydown)=\"onTriggerKeydown($event)\"\n (blur)=\"touch.emit()\"\n>\n @if (displayLabel(); as label) {\n <span class=\"wr-cascader__value\">{{ label }}</span>\n } @else {\n <span class=\"wr-cascader__placeholder\">{{ placeholder() }}</span>\n }\n\n @if (clearable() && hasSelection() && !disabled() && !readonly()) {\n <span\n class=\"wr-cascader__clear\"\n role=\"button\"\n [attr.aria-label]=\"resolvedClearLabel()\"\n tabindex=\"-1\"\n (click)=\"clearSelection($event)\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </span>\n }\n\n <svg\n class=\"wr-icon__svg wr-cascader__chevron\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n</button>\n\n<ng-template #panelTpl>\n <div\n class=\"wr-cascader-panel\"\n [class.wr-cascader-panel--sm]=\"size() === 'sm'\"\n [class.wr-cascader-panel--lg]=\"size() === 'lg'\"\n role=\"tree\"\n [attr.id]=\"panelId\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n >\n <!--\n tree / group / treeitem, and NOT menu. A combobox's popup may be a listbox,\n a tree, a grid or a dialog and nothing else, so `aria-haspopup=\"menu\"` on\n the trigger was an author error — and a `menu` may own menuitems and\n groups, never other menus, so the columns were a second one. Neither is\n visible to axe: `menu` is a valid token for the global `aria-haspopup`, and\n `aria-required-children` passes a menu-inside-menu (measured against this\n exact fragment). A tree is what this control has always been — the value is\n a PATH, and only `treeitem` supports aria-expanded, aria-level,\n aria-setsize, aria-posinset and aria-selected at once.\n\n The columns stay `group` rather than collapsing to `role=\"presentation\"`,\n which is also axe-clean: the DOM is column-MAJOR, so a flat tree would\n leave level plus document order as the only structure, and \"Germany\"\n (level 2) would read as a child of \"Antarctica\" (level 1, the item\n immediately before it in source order).\n -->\n @for (col of columns(); track $index; let colIndex = $index) {\n <ul\n class=\"wr-cascader__col\"\n role=\"group\"\n [attr.id]=\"columnId(colIndex)\"\n [attr.aria-labelledby]=\"parentOptionId(colIndex)\"\n >\n @for (opt of col; track opt.value; let optIndex = $index) {\n <!--\n `aria-expanded` is exactly `isActiveAt`: `columns()` renders the next\n column for the active option and only when it has children, so the\n state can never claim a column that is not on screen — and\n `aria-controls` rides that same invariant, which is what makes\n \"expanded\" refer to something when the expanded content is a SIBLING\n rather than a descendant. It is emitted only while expanded: a\n reference to an absent id is a violation with `aria-expanded=\"true\"`\n and clean while collapsed.\n\n `aria-level` is load-bearing rather than decorative. The columns are\n siblings, so the DOM ancestry represents no level at all and every\n option would read as level 1. `aria-setsize` / `aria-posinset` are\n not strictly required — each column IS a complete sibling set — and\n are written anyway, because a tree that owns sibling groups is the\n uncommon shape where browser/AT pairs are known to miscompute both.\n\n `aria-selected` is written on every option that can be COMMITTED,\n `false` included, matching `wr-tree`. The alternative a reviewer may\n prefer: only the selected node, leaning on treeitem's implicit false,\n which is quieter in a long column and loses the \"this row is\n selectable\" signal that presence carries.\n\n `tabindex` is a ROVING stop, as in the APG tree pattern: one option\n carries `0` (see `tabStop`) and every other one `-1`, so the panel is\n one Tab to enter and one to leave, and the arrows move between options.\n -->\n <li\n class=\"wr-cascader__opt\"\n role=\"treeitem\"\n [attr.id]=\"optionId(colIndex, optIndex)\"\n [class.wr-cascader__opt--active]=\"isActiveAt(colIndex, opt.value)\"\n [class.wr-cascader__opt--disabled]=\"opt.disabled\"\n [attr.tabindex]=\"isTabStop(colIndex, opt) ? 0 : -1\"\n [attr.aria-disabled]=\"opt.disabled ? true : null\"\n [attr.aria-level]=\"colIndex + 1\"\n [attr.aria-setsize]=\"$count\"\n [attr.aria-posinset]=\"optIndex + 1\"\n [attr.aria-selected]=\"isSelectedAt(colIndex, opt)\"\n [attr.aria-expanded]=\"opt.children?.length ? isActiveAt(colIndex, opt.value) : null\"\n [attr.aria-controls]=\"\n opt.children?.length && isActiveAt(colIndex, opt.value) ? columnId(colIndex + 1) : null\n \"\n (click)=\"onOptionClick(colIndex, opt, $event)\"\n (focus)=\"onOptionFocus(colIndex, opt)\"\n (keydown)=\"onOptionKeydown(colIndex, opt, $event)\"\n (keydown.enter)=\"onOptionClick(colIndex, opt, $event)\"\n (keydown.space)=\"onOptionClick(colIndex, opt, $event)\"\n >\n <span class=\"wr-cascader__opt-label\">{{ opt.label }}</span>\n @if (opt.children?.length) {\n <svg\n class=\"wr-icon__svg wr-cascader__opt-arrow\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n }\n </li>\n }\n </ul>\n }\n </div>\n</ng-template>\n"],"mappings":";;;;;;;;;;;;;;;;;AAwCA,IAAI,WAAW;AAgBf,SAAS,cAAc,MAAmB,OAAoB;CAC5D,IAAI,MAAM,QAAQ,SAAS,MAAM,oBAAoB,MAAM,UAAU,MAAM,WAAW,MAAM,SAAS,OAAO;CAC5G,MAAM,SAAS,KAAK,cAAc;CAClC,OAAO,CAAC,CAAC,UAAU,KAAK,SAAS,MAAM;AACzC;AAGA,MAAM,eAAe;AA8CrB,IAAa,aAAb,MAAa,WAAU;CAEZ,aAAa,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;CAE7B,qBAAqB,YAAY,KAAK,YAAY,yBAAyB,iBAAiB;CAGtG,UAAU,MAAM,SAA0C,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAG1D,cAAc,MAAc,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,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AAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,MAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,gBAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,aAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,YAAU;IAAI,MAAM;IAAa,UAAA;GAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-cascader.mjs","names":[],"sources":["../../../projects/lib/cascader/cascader.ts","../../../projects/lib/cascader/cascader.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n Injector,\n TemplateRef,\n ViewContainerRef,\n ViewEncapsulation,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n untracked,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { useI18nText } from 'ngwr/i18n';\nimport { WR_OVERLAY, WrOutsideClick, wrFollowDirection } from 'ngwr/overlay';\nimport { isPrintableKey, toClassList, type WrClassInput } from 'ngwr/utils';\n\nimport type { WrCascaderOption } from './types';\n\nlet panelUid = 0;\n\n/**\n * Whether a keydown is a Tab that takes focus out of the open panel. The pane\n * lives in the overlay container at the end of `<body>`, so the browser's own Tab\n * out of it went to `<body>` — the top of the page — with the panel left standing.\n * The caller focuses the trigger synchronously and does NOT `preventDefault`, so\n * the browser's Tab carries on from there to the trigger's real neighbour — the\n * move `wr-dropdown` makes for its menu.\n *\n * Every Tab inside the pane leaves it, in either direction: the panel holds ONE\n * tab stop (the roving one, see `tabStop`), so there is nowhere else inside it for\n * Tab to go. Asking \"is there a later stop\" instead would also answer wrongly for\n * the moment between an arrow key moving focus and the render that moves the\n * `tabindex=\"0\"` after it.\n */\nfunction tabLeavesPane(pane: HTMLElement, event: KeyboardEvent): boolean {\n if (event.key !== 'Tab' || event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return false;\n const active = pane.ownerDocument.activeElement;\n return !!active && pane.contains(active);\n}\n\n/** How long a pause ends a type-ahead run, in milliseconds — the figure APG's examples use. */\nconst TYPEAHEAD_MS = 500;\n\n/**\n * Multi-level select — drills down through hierarchical categories\n * (e.g. country → state → city). Each level renders as a column; clicks\n * advance to the next column. Selecting a leaf (no children) commits\n * the full path.\n *\n * A signal-forms native control: it implements `FormValueControl<unknown>`,\n * so `[formField]` binds straight to its `value` model — no\n * `ControlValueAccessor` in between. `[(value)]` works standalone. The value\n * is the path through the tree (an array from root to leaf).\n *\n * @example\n * ```html\n * <!-- signal forms -->\n * <wr-cascader [options]=\"locations\" [formField]=\"form.path\" placeholder=\"Pick a location\" />\n *\n * <!-- standalone two-way binding -->\n * <wr-cascader [options]=\"locations\" [(value)]=\"path\" placeholder=\"Pick a location\" />\n * ```\n *\n * ```ts\n * locations: WrCascaderOption[] = [\n * {\n * value: 'us', label: 'United States', children: [\n * { value: 'ny', label: 'New York', children: [\n * { value: 'nyc', label: 'NYC' },\n * { value: 'buf', label: 'Buffalo' },\n * ] },\n * ],\n * },\n * ];\n * ```\n *\n * @see https://ngwr.dev/reference/components/cascader\n */\nexport type WrCascaderSize = 'sm' | 'md' | 'lg';\n\n@Component({\n selector: 'wr-cascader',\n templateUrl: './cascader.html',\n styleUrl: './cascader.scss',\n encapsulation: ViewEncapsulation.None,\n host: { '[class]': 'classes()' },\n})\nexport class WrCascader<T = string> implements FormValueControl<unknown> {\n /** Accessible name. Falls back to `select.clearSelection`, then `'Clear selection'`. */\n readonly clearLabel = input<string | null>(null);\n\n protected readonly resolvedClearLabel = useI18nText(this.clearLabel, 'select.clearSelection', 'Clear selection');\n\n /** Root-level options. Each may have `children` for deeper levels. */\n readonly options = input.required<readonly WrCascaderOption<T>[]>();\n\n /** Placeholder shown when no path is selected. @default '' */\n readonly placeholder = input<string>('');\n\n /**\n * Accessible name of the trigger. Falls back to the placeholder, then to\n * `select.label` — a `role=\"combobox\"` with nothing selected and no\n * placeholder otherwise has no name at all.\n */\n readonly ariaLabel = input<string | null>(null);\n\n private readonly labelText = useI18nText(this.ariaLabel, 'select.label', 'Select');\n protected readonly resolvedAriaLabel = computed(() => {\n // Not `??`: an empty placeholder must fall through to the catalog string.\n const explicit = this.ariaLabel();\n if (explicit) return explicit;\n const placeholder = this.placeholder();\n return placeholder ? placeholder : this.labelText();\n });\n\n /**\n * Disable the cascader. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse changes while the trigger stays focusable and the path still submits.\n * Bound automatically from the field's readonly state when used with\n * `[formField]`.\n *\n * The panel is where every edit happens, so a read-only cascader simply does\n * not open — there is nothing to browse that is not already on the trigger —\n * and the clear button goes away with it. Mirrored as `aria-readonly`, which\n * role `combobox` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n\n /**\n * The field's own label, when it renders one — `null` otherwise, and `null`\n * when `[ariaLabel]` was set deliberately.\n *\n * `aria-label` outranks a `<label for>` in the accname order, so without this\n * a cascader inside `<wr-form-field label=\"Region\">` announced its\n * PLACEHOLDER, or the generic `select.label` default, and the visible label\n * reached nobody. Nothing catches it: the control has a name, so axe is\n * satisfied, and the name is plausible, so a reader is too — it fails WCAG\n * 2.5.3, where the visible label has to be IN the accessible name. Same call\n * `wr-rating` and `wr-knob` already make.\n */\n protected readonly labelledBy = computed(() => (this.ariaLabel() ? null : this.fieldAria.labelledBy()));\n\n /** `null` once `aria-labelledby` is carrying the name — see {@link labelledBy}. */\n protected readonly nameLabel = computed(() => (this.labelledBy() ? null : this.resolvedAriaLabel()));\n\n /** Control size — shares the `--wr-control-*` contract. @default 'md' */\n readonly size = input<WrCascaderSize>('md');\n\n /** Show a clear-all (×) button on the trigger when a path is selected. @default true */\n readonly clearable = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Allow selecting non-leaf (parent) nodes. When `false`, only leaves\n * (nodes without children) commit a selection. @default false\n */\n readonly changeOnSelect = input(false, { transform: coerceBooleanProperty });\n\n /** Separator between labels in the trigger display. @default '/' */\n readonly separator = input<string>('/');\n\n /**\n * Extra CSS classes for the column panel's overlay pane.\n *\n * The pane is appended to the overlay container, not to this component, so\n * nothing in the consumer's own template encloses it and no descendant rule\n * written around the trigger can reach it. This input is the only per-instance\n * handle on it. A space-separated string works as well as an array.\n */\n readonly panelClass = input<WrClassInput>(null);\n\n /**\n * Committed selection path (full array from root to leaf). Bound by\n * `[formField]`, or two-way via `[(value)]`.\n */\n readonly value = model<unknown>([]);\n\n /** Emitted on blur / commit so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n /** Committed selection path (full T[] from root to leaf). @internal */\n protected readonly path = signal<readonly T[]>([]);\n\n /** Currently-expanded column path — drives which columns the panel shows. @internal */\n protected readonly activePath = signal<readonly T[]>([]);\n\n protected readonly open = signal(false);\n\n /**\n * The option the user last moved to inside the open panel — `null` until they\n * move, and again on every open. Written by an option's `focus` event, so\n * whatever moved the caret (an arrow, a click, a harness, a type-ahead letter)\n * moves the tab stop with it.\n */\n private readonly cursor = signal<{ readonly col: number; readonly value: T } | null>(null);\n\n /**\n * The panel's ONE tab stop, as in the APG tree pattern: the option the user\n * moved to, else the selected path's leaf, else the first enabled root. Every\n * other option carries `tabindex=\"-1\"` and is reached with the arrows, so a\n * deep tree is one Tab to enter and one to leave instead of a stop per option.\n *\n * Validated against what is ON SCREEN rather than trusted: choosing a sibling\n * prunes the deeper columns, and a value written from outside replaces the\n * path, so a remembered position can name an option that is gone. A disabled\n * option is never the stop — `focus()` would land on a choice nobody can make.\n * When the leaf itself is not on screen or is disabled, the deepest ancestor on\n * the path that is takes its place.\n */\n protected readonly tabStop = computed<{ readonly col: number; readonly value: T } | null>(() => {\n const cols = this.columns();\n const enabledAt = (col: number, value: T): boolean => !!cols[col]?.some(o => o.value === value && !o.disabled);\n\n const at = this.cursor();\n if (at && enabledAt(at.col, at.value)) return at;\n\n const path = this.path();\n const active = this.activePath();\n for (let col = Math.min(path.length, cols.length) - 1; col >= 0; col--) {\n // Column `col` lists the children of the ACTIVE path above it, so the path's\n // node at that depth is on screen only while the two agree that far down.\n if (!this.pathsEqual(path.slice(0, col), active.slice(0, col))) continue;\n if (enabledAt(col, path[col])) return { col, value: path[col] };\n }\n\n const first = cols[0]?.find(o => !o.disabled);\n return first ? { col: 0, value: first.value } : null;\n });\n\n /** Letters typed in quick succession, for type-ahead. */\n private typeahead = '';\n private typeaheadAt = 0;\n\n /** Panel id used by the trigger's `aria-controls`. */\n protected readonly panelId = `wr-cascader-panel-${++panelUid}`;\n\n /**\n * Columns visible in the panel. Each column shows the children of the\n * preceding activePath entry. Column 0 = root options. The last\n * column is whatever the deepest active node's children resolve to —\n * we only render a column when there are children to show.\n */\n protected readonly columns = computed<readonly (readonly WrCascaderOption<T>[])[]>(() => {\n const cols: (readonly WrCascaderOption<T>[])[] = [this.options()];\n const trail = this.activePath();\n let list: readonly WrCascaderOption<T>[] = this.options();\n for (const v of trail) {\n const node = list.find(o => o.value === v);\n if (!node?.children?.length) break;\n cols.push(node.children);\n list = node.children;\n }\n return cols;\n });\n\n /** Label trail joined by `separator()` — what the trigger shows. */\n protected readonly displayLabel = computed(() => {\n const p = this.path();\n if (p.length === 0) return null;\n const labels: string[] = [];\n let list: readonly WrCascaderOption<T>[] = this.options();\n for (const v of p) {\n const node = list.find(o => o.value === v);\n if (!node) return null;\n labels.push(node.label);\n list = node.children ?? [];\n }\n const sep = ` ${this.separator()} `;\n return labels.join(sep);\n });\n\n protected readonly hasSelection = computed(() => this.path().length > 0);\n\n protected readonly classes = computed(() => {\n const parts = ['wr-cascader'];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-cascader--${size}`);\n if (this.open()) parts.push('wr-cascader--open');\n if (this.disabled()) parts.push('wr-cascader--disabled');\n else if (this.readonly()) parts.push('wr-cascader--readonly');\n return parts.join(' ');\n });\n\n protected readonly panelTpl = viewChild.required('panelTpl', { read: TemplateRef });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly overlay = inject(WR_OVERLAY);\n private readonly outsideClick = inject(WrOutsideClick);\n private readonly vcr = inject(ViewContainerRef);\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly destroyRef = inject(DestroyRef);\n private readonly injector = inject(Injector);\n /**\n * Ambient reading direction, for the open panel alone — nothing in this\n * component reads it directly. Optional so a bare `TestBed` needs no\n * provider; `Directionality` is root-provided anyway, and a missing one\n * simply reads as `ltr`.\n */\n private readonly dir = inject(Directionality, { optional: true });\n private overlayRef: OverlayRef | null = null;\n\n constructor() {\n // Same contract as wr-select / wr-dropdown / wr-lightbox: an overlay lives in\n // the CDK container, not in this component's view, so destroying the\n // component while the panel is open would strand the pane and its scroll\n // strategy.\n this.destroyRef.onDestroy(() => this.closeOverlay());\n\n effect(() => {\n if (this.open()) {\n this.openOverlay();\n } else {\n this.closeOverlay();\n }\n });\n\n // Close the panel if the control becomes disabled or read-only while open.\n effect(() => {\n if (this.disabled() || this.readonly()) this.open.set(false);\n });\n\n // Mirror an external `value` write into the internal path/activePath\n // (the old `writeValue`). Skipped when the write merely echoes the\n // committed path, so a live drill-down can never be clobbered.\n effect(() => {\n // Coerce null/undefined/non-array to an empty path — a classic-forms\n // binding can write null, which the old `writeValue(value: unknown)`\n // treated as \"no selection\" too.\n const value = this.value();\n untracked(() => {\n const next: readonly T[] = Array.isArray(value) ? (value as readonly T[]) : [];\n if (this.pathsEqual(this.path(), next)) return;\n this.path.set(next);\n this.activePath.set(next);\n });\n });\n }\n\n /**\n * Focus the trigger — what Signal Forms calls to focus this control. The\n * panel stays shut: ArrowDown or a click opens it, the way it does after Tab.\n */\n focus(options?: FocusOptions): void {\n this.host.nativeElement.querySelector<HTMLElement>('.wr-cascader__trigger')?.focus(options);\n }\n\n // Template handlers\n\n protected onTriggerClick(): void {\n if (this.disabled() || this.readonly()) return;\n if (!this.open()) this.activePath.set(this.path());\n this.open.update(v => !v);\n }\n\n /**\n * ArrowDown / ArrowUp open the panel, Alt+ArrowDown included — the combobox way in,\n * and the shape `wr-dropdown`'s trigger uses. Enter and Space need no branch: the\n * trigger is a real `<button>`, so the browser turns them into the click above.\n *\n * Only while closed. Once the panel is up the caret is inside it, and its options\n * own their own keys.\n */\n protected onTriggerKeydown(event: KeyboardEvent): void {\n if (this.disabled() || this.readonly() || this.open()) return;\n\n // Backspace is the × from the keyboard, and it has to be: the × is a\n // `tabindex=\"-1\"` span INSIDE this button, and a keydown goes to the focused\n // element, so the `(keydown.enter)` / `(keydown.space)` it used to carry could\n // never fire. Clearing was reachable by pointer alone — a WCAG 2.1.1 failure,\n // not a missing convenience. The span stays unfocusable, because a focusable\n // child of a button is `nested-interactive`. Same key, same gating as\n // `wr-select`: `clearable()` IS the clear control, so a consumer who turned\n // the × off did not ask for a keyboard twin of it.\n if (event.key === 'Backspace') {\n if (!this.clearable() || !this.hasSelection()) return;\n event.preventDefault();\n this.clearSelection(event);\n return;\n }\n\n if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return;\n event.preventDefault();\n this.activePath.set(this.path());\n this.open.set(true);\n }\n\n protected onOptionClick(colIndex: number, opt: WrCascaderOption<T>, event: Event): void {\n event.stopPropagation();\n if (opt.disabled || this.disabled() || this.readonly()) return;\n\n const head = this.activePath().slice(0, colIndex);\n const newPath = [...head, opt.value];\n\n const hasChildren = !!opt.children?.length;\n\n // Always update active column for visual feedback / next column.\n this.activePath.set(newPath);\n // A pointer click focuses the option anyway (see `onOptionFocus`); a scripted\n // `click()` does not, and the tab stop belongs where the choice was made.\n this.cursor.set({ col: colIndex, value: opt.value });\n\n // Commit when we've reached a leaf, or when changeOnSelect is on.\n if (!hasChildren || this.changeOnSelect()) {\n this.path.set(newPath);\n this.value.set(newPath);\n this.touch.emit();\n // Close once we hit a true leaf — parent commits keep the panel open.\n if (!hasChildren) this.open.set(false);\n }\n }\n\n /**\n * The tree keys the panel's roles promise, per the APG tree pattern: Up / Down\n * within a column, Home / End to its ends, the inline-end arrow into a branch's\n * children — opening the next column on the way — and the inline-start arrow back\n * to the option the column belongs to, or, from a root, closing the column it\n * opened. A letter moves to the next option in the column whose label starts with\n * what was typed. Enter and Space stay the commit.\n *\n * These are the ONLY way between options: the panel holds one tab stop (see\n * {@link tabStop}), and Tab leaves it.\n */\n protected onOptionKeydown(colIndex: number, opt: WrCascaderOption<T>, event: KeyboardEvent): void {\n const current = event.currentTarget as HTMLElement;\n const column = current.closest<HTMLElement>('[role=\"group\"]');\n if (!column) return;\n // Before the modifier check, because Shift is how a capital letter is typed.\n if (isPrintableKey(event) && event.key !== ' ') {\n this.typeAhead(column, current, event.key);\n event.preventDefault();\n return;\n }\n if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;\n const rtl = this.dir?.value === 'rtl';\n const inward = rtl ? 'ArrowLeft' : 'ArrowRight';\n const outward = rtl ? 'ArrowRight' : 'ArrowLeft';\n const enabled = [...column.querySelectorAll<HTMLElement>('[role=\"treeitem\"]')].filter(\n o => o.getAttribute('aria-disabled') !== 'true'\n );\n const at = enabled.indexOf(current);\n\n switch (event.key) {\n case 'ArrowDown':\n enabled[at + 1]?.focus();\n break;\n case 'ArrowUp':\n if (at > 0) enabled[at - 1].focus();\n break;\n case 'Home':\n enabled[0]?.focus();\n break;\n case 'End':\n enabled[enabled.length - 1]?.focus();\n break;\n case inward: {\n if (opt.disabled || !opt.children?.length || this.disabled() || this.readonly()) break;\n this.activePath.set([...this.activePath().slice(0, colIndex), opt.value]);\n // The column is not in the DOM until the render this write schedules.\n afterNextRender(\n () =>\n this.overlayRef?.overlayElement\n .querySelector<HTMLElement>(\n `#${this.columnId(colIndex + 1)} [role=\"treeitem\"]:not([aria-disabled=\"true\"])`\n )\n ?.focus(),\n { injector: this.injector }\n );\n break;\n }\n case outward: {\n if (colIndex > 0) {\n const parent = this.parentOptionId(colIndex);\n if (parent) this.overlayRef?.overlayElement.querySelector<HTMLElement>(`#${parent}`)?.focus();\n } else if (opt.children?.length && this.isActiveAt(colIndex, opt.value)) {\n this.activePath.set([]);\n }\n break;\n }\n case ' ':\n // The commit is `(keydown.space)`'s; the page scrolling a screen under the\n // panel is the browser's, and it went with every Space on an option.\n break;\n default:\n return;\n }\n event.preventDefault();\n }\n\n /** The caret reached an option, by whatever route — the tab stop follows it. */\n protected onOptionFocus(colIndex: number, opt: WrCascaderOption<T>): void {\n if (opt.disabled) return;\n this.cursor.set({ col: colIndex, value: opt.value });\n }\n\n /** Whether this option is the panel's one `tabindex=\"0\"`. */\n protected isTabStop(colIndex: number, opt: WrCascaderOption<T>): boolean {\n const stop = this.tabStop();\n return !opt.disabled && stop !== null && stop.col === colIndex && stop.value === opt.value;\n }\n\n /**\n * Move to the next enabled option in `column` whose label starts with the letters\n * typed so far. A pause of {@link TYPEAHEAD_MS} starts a new run. One letter\n * pressed again cycles through the options that start with it; a longer run keeps\n * the option it already matches, so `g` then `e` stays on \"Germany\".\n */\n private typeAhead(column: HTMLElement, current: HTMLElement, key: string): void {\n const now = Date.now();\n this.typeahead = now - this.typeaheadAt > TYPEAHEAD_MS ? key : this.typeahead + key;\n this.typeaheadAt = now;\n\n const typed = this.typeahead.toLocaleLowerCase();\n const repeated = [...typed].every(ch => ch === typed[0]);\n const search = repeated ? typed[0] : typed;\n const enabled = [...column.querySelectorAll<HTMLElement>('[role=\"treeitem\"]')].filter(\n o => o.getAttribute('aria-disabled') !== 'true'\n );\n const from = enabled.indexOf(current);\n // A fresh letter (or a repeated one) starts AFTER the current option; a longer\n // run starts AT it, so the option that matched the first letters can keep the\n // match.\n const start = search.length === 1 ? from + 1 : Math.max(from, 0);\n const label = (o: HTMLElement): string =>\n (o.querySelector('.wr-cascader__opt-label')?.textContent ?? '').trim().toLocaleLowerCase();\n for (let i = 0; i < enabled.length; i++) {\n const candidate = enabled[(start + i) % enabled.length];\n if (label(candidate).startsWith(search)) {\n candidate.focus();\n return;\n }\n }\n }\n\n protected clearSelection(event: Event): void {\n event.stopPropagation();\n if (this.disabled() || this.readonly()) return;\n this.path.set([]);\n this.activePath.set([]);\n this.value.set([]);\n this.touch.emit();\n }\n\n protected isActiveAt(colIndex: number, value: T): boolean {\n return this.activePath()[colIndex] === value;\n }\n\n /**\n * Whether this option is the committed choice — `null` when it is not a\n * choice at all.\n *\n * Two questions the panel has to keep apart, and `--active` answers only the\n * first: `activePath()` is where the user has NAVIGATED to, `path()` is what\n * they have COMMITTED. They agree once a leaf is picked and diverge for the\n * whole walk down.\n *\n * `null` — the attribute absent — on a branch while `changeOnSelect` is off,\n * because such a branch genuinely cannot be chosen; ARIA reads a missing\n * `aria-selected` as \"not selectable\", which is exactly true here. That makes\n * this binding the first expression the `changeOnSelect` contract has ever had\n * in ARIA, in both directions.\n */\n protected isSelectedAt(colIndex: number, opt: WrCascaderOption<T>): boolean | null {\n const committable = !opt.children?.length || this.changeOnSelect();\n if (!committable) return null;\n const path = this.path();\n return colIndex === path.length - 1 && path[colIndex] === opt.value;\n }\n\n /** Stable id for one option — what a column's `aria-labelledby` points at. */\n protected optionId(colIndex: number, optIndex: number): string {\n return `${this.panelId}-opt-${colIndex}-${optIndex}`;\n }\n\n /** Stable id for one column — what an expanded branch's `aria-controls` points at. */\n protected columnId(colIndex: number): string {\n return `${this.panelId}-col-${colIndex}`;\n }\n\n /**\n * The option whose children a column holds, by id — its accessible name.\n *\n * The columns are DOM SIBLINGS, so nothing in the markup says the second one\n * belongs to \"Europe\". Column 0 has no parent and stays unnamed; the tree\n * itself already carries the control's name.\n */\n protected parentOptionId(colIndex: number): string | null {\n if (colIndex === 0) return null;\n const parent = this.columns()[colIndex - 1] ?? [];\n const index = parent.findIndex(o => this.isActiveAt(colIndex - 1, o.value));\n return index < 0 ? null : this.optionId(colIndex - 1, index);\n }\n\n private pathsEqual(a: readonly T[], b: readonly T[]): boolean {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n }\n\n // Overlay\n\n private openOverlay(): void {\n if (this.overlayRef) return;\n // Each open starts from the selected path, not from where the last visit ended.\n this.cursor.set(null);\n\n const positionStrategy = this.overlay\n .position()\n .flexibleConnectedTo(this.host)\n .withPositions([\n { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },\n { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },\n ])\n .withPush(true);\n\n this.overlayRef = this.overlay.create({\n positionStrategy,\n scrollStrategy: this.scrollStrategies.reposition(),\n panelClass: toClassList('wr-cascader-overlay', this.panelClass()),\n });\n\n // The columns cascade inline-wards, and the CDK captured the direction as a\n // string when this ref was created — so a flip while the panel is open left\n // the whole cascade running the other way from the page around it.\n wrFollowDirection(this.overlayRef, this.dir, this.injector);\n\n const portal = new TemplatePortal(this.panelTpl(), this.vcr);\n this.overlayRef.attach(portal);\n\n // Move the caret into the panel it just opened. Nothing did, and the pane is\n // appended to `<body>`, so an opened cascader left focus on the trigger and its\n // options were reachable only by tabbing past the whole rest of the page —\n // `wr-tree` and `wr-context-menu` were the same defect. `closeOverlay` below\n // already assumes this is where the caret lives.\n //\n // `afterNextRender`, NOT `queueMicrotask`: under zoneless CD change detection runs\n // in a macrotask, so a microtask queued here fires before the columns are in the\n // DOM — the trap that once left `wr-calendar`'s ring and its real focus on\n // different days.\n afterNextRender(() => this.focusPanelOption(), { injector: this.injector });\n\n this.outsideClick\n .outsidePointerEvents(this.overlayRef)\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (this.host.nativeElement.contains(event.target as Node)) return;\n this.open.set(false);\n });\n\n this.overlayRef\n .keydownEvents()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (event.key === 'Escape') {\n event.preventDefault();\n this.open.set(false);\n return;\n }\n if (this.overlayRef && tabLeavesPane(this.overlayRef.overlayElement, event)) {\n this.host.nativeElement.querySelector<HTMLElement>('.wr-cascader__trigger')?.focus();\n this.open.set(false);\n }\n });\n }\n\n /**\n * The option the panel opens on: its tab stop, which on open is the selected path's\n * leaf, else the first enabled root (see {@link tabStop}). A disabled option is\n * never the stop, so `focus()` cannot land on a choice nobody can make.\n */\n private focusPanelOption(): void {\n this.overlayRef?.overlayElement.querySelector<HTMLElement>('[role=\"treeitem\"][tabindex=\"0\"]')?.focus();\n }\n\n private closeOverlay(): void {\n if (!this.overlayRef) return;\n // Opening moves the caret onto the panel's tab stop and every option commits\n // on Enter, so on the keyboard the caret is INSIDE the pane by design — and\n // the ordinary way to finish choosing (`onOptionClick` on a leaf) closes it.\n // Disposing without handing focus back dropped it on `<body>` on the SUCCESS\n // path, not merely on dismissal: a keyboard user who had just picked a value\n // then had to Tab from the top of the document to get back to the control.\n // Untouched when focus had already moved elsewhere — that click is usually\n // what closed us, and stealing the caret back would fight the user for it.\n const pane = this.overlayRef.overlayElement;\n const focusWasInside = pane.contains(this.host.nativeElement.ownerDocument.activeElement);\n this.overlayRef.dispose();\n this.overlayRef = null;\n if (focusWasInside) this.host.nativeElement.querySelector<HTMLElement>('.wr-cascader__trigger')?.focus();\n }\n}\n\nexport type { WrCascaderOption } from './types';\n","<button\n type=\"button\"\n class=\"wr-cascader__trigger\"\n role=\"combobox\"\n [attr.aria-label]=\"nameLabel()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [disabled]=\"disabled()\"\n [attr.aria-haspopup]=\"'tree'\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"panelId\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"onTriggerClick()\"\n (keydown)=\"onTriggerKeydown($event)\"\n (blur)=\"touch.emit()\"\n>\n @if (displayLabel(); as label) {\n <span class=\"wr-cascader__value\">{{ label }}</span>\n } @else {\n <span class=\"wr-cascader__placeholder\">{{ placeholder() }}</span>\n }\n\n @if (clearable() && hasSelection() && !disabled() && !readonly()) {\n <span\n class=\"wr-cascader__clear\"\n role=\"button\"\n [attr.aria-label]=\"resolvedClearLabel()\"\n tabindex=\"-1\"\n (click)=\"clearSelection($event)\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </span>\n }\n\n <svg\n class=\"wr-icon__svg wr-cascader__chevron\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n</button>\n\n<ng-template #panelTpl>\n <div\n class=\"wr-cascader-panel\"\n [class.wr-cascader-panel--sm]=\"size() === 'sm'\"\n [class.wr-cascader-panel--lg]=\"size() === 'lg'\"\n role=\"tree\"\n [attr.id]=\"panelId\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n >\n <!--\n tree / group / treeitem, and NOT menu. A combobox's popup may be a listbox,\n a tree, a grid or a dialog and nothing else, so `aria-haspopup=\"menu\"` on\n the trigger was an author error — and a `menu` may own menuitems and\n groups, never other menus, so the columns were a second one. Neither is\n visible to axe: `menu` is a valid token for the global `aria-haspopup`, and\n `aria-required-children` passes a menu-inside-menu (measured against this\n exact fragment). A tree is what this control has always been — the value is\n a PATH, and only `treeitem` supports aria-expanded, aria-level,\n aria-setsize, aria-posinset and aria-selected at once.\n\n The columns stay `group` rather than collapsing to `role=\"presentation\"`,\n which is also axe-clean: the DOM is column-MAJOR, so a flat tree would\n leave level plus document order as the only structure, and \"Germany\"\n (level 2) would read as a child of \"Antarctica\" (level 1, the item\n immediately before it in source order).\n -->\n @for (col of columns(); track $index; let colIndex = $index) {\n <ul\n class=\"wr-cascader__col\"\n role=\"group\"\n [attr.id]=\"columnId(colIndex)\"\n [attr.aria-labelledby]=\"parentOptionId(colIndex)\"\n >\n @for (opt of col; track opt.value; let optIndex = $index) {\n <!--\n `aria-expanded` is exactly `isActiveAt`: `columns()` renders the next\n column for the active option and only when it has children, so the\n state can never claim a column that is not on screen — and\n `aria-controls` rides that same invariant, which is what makes\n \"expanded\" refer to something when the expanded content is a SIBLING\n rather than a descendant. It is emitted only while expanded: a\n reference to an absent id is a violation with `aria-expanded=\"true\"`\n and clean while collapsed.\n\n `aria-level` is load-bearing rather than decorative. The columns are\n siblings, so the DOM ancestry represents no level at all and every\n option would read as level 1. `aria-setsize` / `aria-posinset` are\n not strictly required — each column IS a complete sibling set — and\n are written anyway, because a tree that owns sibling groups is the\n uncommon shape where browser/AT pairs are known to miscompute both.\n\n `aria-selected` is written on every option that can be COMMITTED,\n `false` included, matching `wr-tree`. The alternative a reviewer may\n prefer: only the selected node, leaning on treeitem's implicit false,\n which is quieter in a long column and loses the \"this row is\n selectable\" signal that presence carries.\n\n `tabindex` is a ROVING stop, as in the APG tree pattern: one option\n carries `0` (see `tabStop`) and every other one `-1`, so the panel is\n one Tab to enter and one to leave, and the arrows move between options.\n -->\n <li\n class=\"wr-cascader__opt\"\n role=\"treeitem\"\n [attr.id]=\"optionId(colIndex, optIndex)\"\n [class.wr-cascader__opt--active]=\"isActiveAt(colIndex, opt.value)\"\n [class.wr-cascader__opt--disabled]=\"opt.disabled\"\n [attr.tabindex]=\"isTabStop(colIndex, opt) ? 0 : -1\"\n [attr.aria-disabled]=\"opt.disabled ? true : null\"\n [attr.aria-level]=\"colIndex + 1\"\n [attr.aria-setsize]=\"$count\"\n [attr.aria-posinset]=\"optIndex + 1\"\n [attr.aria-selected]=\"isSelectedAt(colIndex, opt)\"\n [attr.aria-expanded]=\"opt.children?.length ? isActiveAt(colIndex, opt.value) : null\"\n [attr.aria-controls]=\"\n opt.children?.length && isActiveAt(colIndex, opt.value) ? columnId(colIndex + 1) : null\n \"\n (click)=\"onOptionClick(colIndex, opt, $event)\"\n (focus)=\"onOptionFocus(colIndex, opt)\"\n (keydown)=\"onOptionKeydown(colIndex, opt, $event)\"\n (keydown.enter)=\"onOptionClick(colIndex, opt, $event)\"\n (keydown.space)=\"onOptionClick(colIndex, opt, $event)\"\n >\n <span class=\"wr-cascader__opt-label\">{{ opt.label }}</span>\n @if (opt.children?.length) {\n <svg\n class=\"wr-icon__svg wr-cascader__opt-arrow\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n }\n </li>\n }\n </ul>\n }\n </div>\n</ng-template>\n"],"mappings":";;;;;;;;;;;;;;;;;AAwCA,IAAI,WAAW;AAgBf,SAAS,cAAc,MAAmB,OAAoB;CAC5D,IAAI,MAAM,QAAQ,SAAS,MAAM,oBAAoB,MAAM,UAAU,MAAM,WAAW,MAAM,SAAS,OAAO;CAC5G,MAAM,SAAS,KAAK,cAAc;CAClC,OAAO,CAAC,CAAC,UAAU,KAAK,SAAS,MAAM;AACzC;AAGA,MAAM,eAAe;AA8CrB,IAAa,aAAb,MAAa,WAAU;CAEZ,aAAa,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;CAE7B,qBAAqB,YAAY,KAAK,YAAY,yBAAyB,iBAAiB;CAGtG,UAAU,MAAM,SAA0C,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAG1D,cAAc,MAAc,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAO/B,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAE9B,YAAY,YAAY,KAAK,WAAW,gBAAgB,QAAQ;CAC9D,oBAAoB,eAAc;EAEnD,MAAM,WAAW,KAAK,UAAS;EAC/B,IAAI,UAAU,OAAO;EACrB,MAAM,cAAc,KAAK,YAAW;EACpC,OAAO,cAAc,cAAc,KAAK,UAA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AAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,GAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,aAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,OAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,YAAU;IAAI,MAAM;IAAa,UAAA;GAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -21,6 +21,14 @@ var WrCollapseHarness = class WrCollapseHarness extends ComponentHarness {
|
|
|
21
21
|
async isDisabled() {
|
|
22
22
|
return (await this.header()).getProperty("disabled");
|
|
23
23
|
}
|
|
24
|
+
async getIndicator() {
|
|
25
|
+
if (await this.locatorForOptional(".wr-collapse__plus")()) return "plus";
|
|
26
|
+
if (await this.locatorForOptional(".wr-collapse__chevron")()) return "chevron";
|
|
27
|
+
throw new Error(`WrCollapseHarness.getIndicator(): "${await this.getTitle()}" renders neither .wr-collapse__chevron nor .wr-collapse__plus. The component draws one of them unconditionally, so its absence is the bug.`);
|
|
28
|
+
}
|
|
29
|
+
async isFlat() {
|
|
30
|
+
return (await this.host()).hasClass("wr-collapse--flat");
|
|
31
|
+
}
|
|
24
32
|
async getRegionId() {
|
|
25
33
|
return (await this.header()).getAttribute("aria-controls");
|
|
26
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-collapse-testing.mjs","names":[],"sources":["../../../projects/lib/collapse/testing/wr-collapse-harness.ts","../../../projects/lib/collapse/testing/wr-collapse-group-harness.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrCollapseHarnessFilters } from './types';\n\n/**\n * Test harness for one `<wr-collapse>` — a disclosure: a header button, and the region\n * it opens. {@link WrCollapseGroupHarness} is the container several of them sit in.\n *\n * Open and closed are read from the header's `aria-expanded`, never from the panel's\n * size, and that is not merely a jsdom workaround. The body animates through\n * `grid-template-rows: 0fr → 1fr`, so a measured box answers with whatever frame the\n * transition happens to be on; a unit test has no layout at all, which makes every box\n * 0×0 and every such answer wrong in the same direction. The attribute is also the only\n * thing a screen-reader user gets — a panel that slides open without flipping it is\n * closed as far as they are concerned.\n *\n * The body stays in the DOM while the panel is closed. It has to: there would be no\n * height to animate otherwise. So its text is READABLE from a spec long before it is\n * visible on screen, which is why {@link getContentText} refuses to answer for a closed\n * panel instead of handing back invisible text, and why {@link isContentHidden} exists\n * to assert that a closed panel really is out of reach.\n *\n * The region itself is a plain `<div>` — the component gives it no `role=\"region\"` — so\n * `aria-expanded` plus `aria-controls` is the whole of the wiring, and\n * {@link isRegionBound} is how a spec checks it still points at this panel's own body.\n *\n * @example\n * ```ts\n * const loader = TestbedHarnessEnvironment.loader(fixture);\n * const shipping = await loader.getHarness(WrCollapseHarness.with({ title: 'Shipping' }));\n *\n * await shipping.open();\n * expect(await shipping.getContentText()).toContain('Ships Monday');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrCollapseHarness extends ComponentHarness {\n static hostSelector = 'wr-collapse';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrCollapseHarnessFilters = {}): HarnessPredicate<WrCollapseHarness> {\n return new HarnessPredicate(WrCollapseHarness, options)\n .addOption('title', options.title, (harness, title) => HarnessPredicate.stringMatches(harness.getTitle(), title))\n .addOption('open', options.open, async (harness, open) => (await harness.isOpen()) === open)\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled);\n }\n\n private readonly header = this.locatorFor('button.wr-collapse__header');\n private readonly body = this.locatorFor('.wr-collapse__body');\n\n /**\n * The header text, trimmed.\n *\n * Read from `.wr-collapse__title` rather than from the header button. Reading the\n * button would return the same string today — the chevron beside the title is an\n * `<svg>`, and an `<svg>` contributes no text — but the title element is the thing that\n * holds the name, so an icon that ever grows a `<text>` node or a label, or a badge\n * added next to the title, cannot leak into it.\n */\n async getTitle(): Promise<string> {\n return (await this.locatorFor('.wr-collapse__title')()).text();\n }\n\n /**\n * Whether the panel is open, from the header's `aria-expanded`.\n *\n * The `wr-collapse--open` modifier on the host is equally public and says the same\n * thing today, but the attribute is the one a screen reader acts on: a panel that\n * looks open while announcing `false` is the bug worth catching, and reading the class\n * would agree with the animation and miss it.\n */\n async isOpen(): Promise<boolean> {\n return (await (await this.header()).getAttribute('aria-expanded')) === 'true';\n }\n\n /**\n * Whether the panel refuses interaction.\n *\n * From the header's own `disabled` property — the thing that actually turns a click\n * away, and what the CDK consults before dispatching one — rather than from the\n * `wr-collapse--disabled` modifier the host also carries. Both are public, but the\n * class is styling: a panel could lose it and still refuse every click, and what a\n * spec wants to know is whether the control is inert.\n */\n async isDisabled(): Promise<boolean> {\n return (await this.header()).getProperty<boolean>('disabled');\n }\n\n /**\n * The id the header's `aria-controls` names, or `null` when it names nothing.\n *\n * Per-instance and generated, so a spec cannot predict it — what it can do is check\n * that two panels do not share one, and {@link isRegionBound} does the rest.\n */\n async getRegionId(): Promise<string | null> {\n return (await this.header()).getAttribute('aria-controls');\n }\n\n /**\n * Whether the header points at THIS panel's body, and at nothing else on the page.\n *\n * Both halves matter, and neither is provable from the header alone. The id is\n * resolved inside the host first, so a header naming a SIBLING panel's body — which\n * resolves perfectly well from the document and would look correctly wired — fails\n * here. Then it is counted across the document, because two bodies answering to one\n * id hand every reference to whichever comes first, and the second panel's region\n * becomes unreachable to anything that follows the reference.\n */\n async isRegionBound(): Promise<boolean> {\n const id = await this.getRegionId();\n if (id === null) return false;\n\n const own = await this.locatorForOptional(`.wr-collapse__body#${id}`)();\n if (!own) return false;\n\n const everywhere = await this.documentRootLocatorFactory().locatorForAll(`#${id}`)();\n return everywhere.length === 1;\n }\n\n /**\n * Whether the region is hidden from assistive tech AND from the keyboard.\n *\n * Two attributes, because a closed panel needs both and they cover different people:\n * `aria-hidden` keeps the content out of the screen reader's document, `inert` keeps\n * Tab from landing on a link inside a panel nobody can see. The body is never removed\n * from the DOM — the height animation needs it — so these are the only thing standing\n * between a collapsed panel and a keyboard user, and losing either is invisible on\n * screen.\n *\n * They are asserted together on purpose: this answers \"is the closed content actually\n * out of reach\", and half of it is not.\n */\n async isContentHidden(): Promise<boolean> {\n const body = await this.body();\n const hiddenFromAt = (await body.getAttribute('aria-hidden')) === 'true';\n const inert = (await body.getAttribute('inert')) !== null;\n return hiddenFromAt && inert;\n }\n\n /**\n * The text of an OPEN panel's region, trimmed.\n *\n * Throws while the panel is closed rather than answering, because the body is still in\n * the DOM and the text would come back exactly as it does when open — a spec asserting\n * it would be pinning content the user cannot see, and would keep passing if the panel\n * stopped opening at all.\n */\n async getContentText(): Promise<string> {\n if (!(await this.isOpen())) {\n throw new Error(\n `WrCollapseHarness.getContentText(): \"${await this.getTitle()}\" is closed. Its content stays in the ` +\n 'DOM while collapsed — the body has to be there for the height to animate — so reading it now would ' +\n 'assert text nobody can see. Open the panel first, or ask isContentHidden().'\n );\n }\n return (await this.locatorFor('.wr-collapse__inner')()).text();\n }\n\n /** Open the panel. An already-open one is left alone; a disabled one throws. */\n async open(): Promise<void> {\n if (await this.isOpen()) return;\n await this.toggle();\n\n if (!(await this.isOpen())) {\n throw new Error(\n `WrCollapseHarness.open(): \"${await this.getTitle()}\" did not open. A disabled panel refuses its own ` +\n 'header — the button carries `disabled`, and the component checks it again before toggling.'\n );\n }\n }\n\n /** Close the panel. An already-closed one is left alone; a disabled one throws. */\n async close(): Promise<void> {\n if (!(await this.isOpen())) return;\n await this.toggle();\n\n if (await this.isOpen()) {\n throw new Error(\n `WrCollapseHarness.close(): \"${await this.getTitle()}\" did not close. A disabled panel that was opened ` +\n 'through `[open]` cannot be closed from the page at all: the toggle refuses while `disabled` is set, ' +\n 'whichever direction the click would have gone.'\n );\n }\n }\n\n /**\n * Click the header — the panel's entire interactive surface.\n *\n * A click rather than Enter / Space, and nothing is lost by it: the header is a native\n * `<button>`, so a real keyboard activation is the BROWSER synthesising a click from\n * the key press, and jsdom synthesises none. The click is dispatched onto the header\n * itself, so it needs no coordinate and cannot miss in a test that has no layout.\n *\n * A disabled panel ignores this and stays as it was, twice over: the CDK withholds the\n * `click` from an element carrying `disabled`, and the component checks `disabled`\n * again inside its own toggle. Assert rather than assume, or reach for {@link open} /\n * {@link close}, which say so.\n */\n async toggle(): Promise<void> {\n return (await this.header()).click();\n }\n\n /**\n * Move keyboard focus to the header — the only focusable element the component itself\n * renders. Projected content can of course hold its own (which is why a closed panel is\n * `inert`), but that belongs to the consumer, not to this harness.\n */\n async focus(): Promise<void> {\n return (await this.header()).focus();\n }\n\n /** Whether the header currently holds focus. */\n async isFocused(): Promise<boolean> {\n return (await this.header()).isFocused();\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrCollapseGroupHarnessFilters, WrCollapseHarnessFilters } from './types';\nimport { WrCollapseHarness } from './wr-collapse-harness';\n\n/**\n * Test harness for `<wr-collapse-group>` and `<wr-accordion>` — the container a set of\n * {@link WrCollapseHarness} panels sits in, matched in both of its element shapes.\n *\n * There is deliberately no `isAccordion()`, and the reason is worth knowing before a\n * spec goes looking for one: single-open behaviour is not written down anywhere on the\n * page. `<wr-accordion>` carries the marker class `wr-collapse-group--accordion`, but\n * `<wr-collapse-group [accordion]=\"true\">` enforces exactly the same rule and carries\n * nothing — a bound input reaches the component without touching the DOM, and even the\n * literal `accordion` attribute survives only because Angular leaves a static attribute\n * alone. So the class answers \"which element did the template use\", not \"does this group\n * close siblings\", and a harness reporting it would call the group form false. Assert the\n * BEHAVIOUR instead: open two panels and read {@link getOpenTitles} — the assertion that\n * would catch a broken accordion anyway.\n *\n * A collapse group is also not a composite widget. Every header is a native `<button>`\n * in the normal tab order, with no roving `tabindex` and no arrow-key navigation (the\n * APG lists both as optional for an accordion), so there is no \"active\" panel to tell\n * apart from the open one — {@link getFocusedTitle} is the only cursor there is.\n *\n * @example\n * ```ts\n * const settings = await loader.getHarness(WrCollapseGroupHarness.with({ panelTitle: 'Profile' }));\n *\n * await settings.openPanel({ title: 'Security' });\n * expect(await settings.getOpenTitles()).toEqual(['Security']);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrCollapseGroupHarness extends ComponentHarness {\n /** Both shapes the container ships in: the plain group, and the always-accordion one. */\n static hostSelector = 'wr-collapse-group, wr-accordion';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrCollapseGroupHarnessFilters = {}): HarnessPredicate<WrCollapseGroupHarness> {\n return new HarnessPredicate(WrCollapseGroupHarness, options)\n .addOption('panelTitle', options.panelTitle, async (harness, title) => {\n for (const panel of await harness.getPanelTitles()) {\n if (await HarnessPredicate.stringMatches(panel, title)) return true;\n }\n return false;\n })\n .addOption('openPanelTitle', options.openPanelTitle, async (harness, title) => {\n for (const open of await harness.getOpenTitles()) {\n if (await HarnessPredicate.stringMatches(open, title)) return true;\n }\n return false;\n });\n }\n\n /**\n * The group's panels, in DOM order.\n *\n * Every `<wr-collapse>` inside the host, which includes one nested in another panel's\n * content and every panel of a nested group — the group scopes no more tightly than\n * the DOM does, and a nested accordion's children are still descendants of this one.\n */\n async getPanels(filters: WrCollapseHarnessFilters = {}): Promise<WrCollapseHarness[]> {\n return this.locatorForAll(WrCollapseHarness.with(filters))();\n }\n\n /** The header text of every panel, in DOM order. */\n async getPanelTitles(): Promise<string[]> {\n const panels = await this.getPanels();\n return Promise.all(panels.map(panel => panel.getTitle()));\n }\n\n /** The first panel matching the filters, or a failure naming the panels that exist. */\n async getPanel(filters: WrCollapseHarnessFilters): Promise<WrCollapseHarness> {\n const [panel] = await this.getPanels(filters);\n if (!panel) {\n throw new Error(\n `WrCollapseGroupHarness.getPanel(): no panel matched ${JSON.stringify(filters)}. This group holds: ` +\n `${(await this.getPanelTitles()).join(', ')}.`\n );\n }\n return panel;\n }\n\n /**\n * The panel at a 0-based position in DOM order — the other half of \"by text or by\n * index\", and the only way to address a panel whose title is not unique.\n *\n * Throws for an index past the end rather than resolving to nothing, and says how many\n * panels there are: an out-of-range index is a mistake in the spec, and a `undefined`\n * handed back would surface three lines later as a failure about something else.\n */\n async getPanelAt(index: number): Promise<WrCollapseHarness> {\n const panels = await this.getPanels();\n const panel = panels[index];\n if (!panel) {\n throw new Error(\n `WrCollapseGroupHarness.getPanelAt(): index ${index} is out of range — this group holds ` +\n `${panels.length} panel(s), so the last index is ${panels.length - 1}.`\n );\n }\n return panel;\n }\n\n /** The panels that are open, in DOM order. In accordion mode there is at most one. */\n async getOpenPanels(): Promise<WrCollapseHarness[]> {\n return this.getPanels({ open: true });\n }\n\n /**\n * The header text of every open panel, in DOM order.\n *\n * The assertion an accordion is worth pinning with: opening a second panel has to leave\n * this a list of ONE, and it reads the state from each header's `aria-expanded`, so a\n * sibling that collapsed on screen while still announcing itself open fails here.\n */\n async getOpenTitles(): Promise<string[]> {\n const open = await this.getOpenPanels();\n return Promise.all(open.map(panel => panel.getTitle()));\n }\n\n /**\n * Open the first panel matching the filters.\n *\n * In accordion mode this is also what CLOSES the siblings — the group is told by the\n * panel that opened, not by the click — so a spec that opens two panels in a row is\n * asserting the mode, and {@link getOpenTitles} is where the answer shows up. Throws\n * when nothing matched, and again when the panel refused to open (it is disabled).\n */\n async openPanel(filters: WrCollapseHarnessFilters): Promise<void> {\n await (await this.getPanel(filters)).open();\n }\n\n /** Close the first panel matching the filters. */\n async closePanel(filters: WrCollapseHarnessFilters): Promise<void> {\n await (await this.getPanel(filters)).close();\n }\n\n /**\n * Close every open panel.\n *\n * The open panels are resolved first and then closed one at a time. Every click a\n * harness makes already awaits its own change detection, so closing them concurrently\n * would work too — this reads in the order a user would click, and keeps each failure\n * attributable to the panel that caused it. A disabled panel that was opened through\n * `[open]` cannot be closed from the page and throws — the same failure\n * {@link WrCollapseHarness.close} reports, for the same reason.\n */\n async closeAll(): Promise<void> {\n for (const panel of await this.getOpenPanels()) {\n await panel.close();\n }\n }\n\n /**\n * The header text of the panel whose header holds focus, or `null` when focus is\n * elsewhere.\n *\n * Every header is its own tab stop here, so this reports where focus actually IS\n * rather than where the group would send it — there is no roving tab stop to diverge\n * from.\n */\n async getFocusedTitle(): Promise<string | null> {\n for (const panel of await this.getPanels()) {\n if (await panel.isFocused()) return panel.getTitle();\n }\n return null;\n }\n}\n"],"mappings":";;;;;;;AA4CA,IAAa,oBAAb,MAAa,0BAA0B,iBAAgB;CACrD,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAoC,CAAA,GAAE;EAChD,OAAO,IAAI,iBAAiB,mBAAmB,OAAO,CAAC,CACpD,UAAU,SAAS,QAAQ,QAAQ,SAAS,UAAU,iBAAiB,cAAc,QAAQ,SAAQ,GAAI,KAAK,CAAC,CAAC,CAChH,UAAU,QAAQ,QAAQ,MAAM,OAAO,SAAS,SAAU,MAAM,QAAQ,OAAM,MAAQ,IAAI,CAAC,CAC3F,UAAU,YAAY,QAAQ,UAAU,OAAO,SAAS,aAAc,MAAM,QAAQ,WAAU,MAAQ,QAAQ;CACnH;CAEiB,SAAS,KAAK,WAAW,4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AAI,CAAC,OACH,MAAM,IAAI,MACR,uDAAuD,KAAK,UAAU,OAAO,EAAC,uBACxE,MAAM,KAAK,eAAc,EAAA,CAAI,KAAK,IAAI,EAAC,EAAG;EAGpD,OAAO;CACT;CAUA,MAAM,WAAW,OAAa;EAC5B,MAAM,SAAS,MAAM,KAAK,UAAS;EACnC,MAAM,QAAQ,OAAO;EACrB,IAAI,CAAC,OACH,MAAM,IAAI,MACR,8CAA8C,MAAK,sCAC9C,OAAO,OAAM,kCAAmC,OAAO,SAAS,EAAC,EAAG;EAG7E,OAAO;CACT;CAGA,MAAM,gBAAa;EACjB,OAAO,KAAK,UAAU,EAAE,MAAM,KAAI,CAAE;CACtC;CASA,MAAM,gBAAa;EACjB,MAAM,OAAO,MAAM,KAAK,cAAa;EACrC,OAAO,QAAQ,IAAI,KAAK,KAAI,UAAS,MAAM,SAAQ,CAAE,CAAC;CACxD;CAUA,MAAM,UAAU,SAAiC;EAC/C,OAAO,MAAM,KAAK,SAAS,OAAO,EAAA,CAAG,KAAI;CAC3C;CAGA,MAAM,WAAW,SAAiC;EAChD,OAAO,MAAM,KAAK,SAAS,OAAO,EAAA,CAAG,MAAK;CAC5C;CAYA,MAAM,WAAQ;EACZ,KAAK,MAAM,SAAS,MAAM,KAAK,cAAa,GAC1C,MAAM,MAAM,MAAK;CAErB;CAUA,MAAM,kBAAe;EACnB,KAAK,MAAM,SAAS,MAAM,KAAK,UAAS,GACtC,IAAI,MAAM,MAAM,UAAS,GAAI,OAAO,MAAM,SAAQ;EAEpD,OAAO;CACT"}
|
|
1
|
+
{"version":3,"file":"ngwr-collapse-testing.mjs","names":[],"sources":["../../../projects/lib/collapse/testing/wr-collapse-harness.ts","../../../projects/lib/collapse/testing/wr-collapse-group-harness.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrCollapseIndicator } from 'ngwr/collapse';\n\nimport type { WrCollapseHarnessFilters } from './types';\n\n/**\n * Test harness for one `<wr-collapse>` — a disclosure: a header button, and the region\n * it opens. {@link WrCollapseGroupHarness} is the container several of them sit in.\n *\n * Open and closed are read from the header's `aria-expanded`, never from the panel's\n * size, and that is not merely a jsdom workaround. The body animates through\n * `grid-template-rows: 0fr → 1fr`, so a measured box answers with whatever frame the\n * transition happens to be on; a unit test has no layout at all, which makes every box\n * 0×0 and every such answer wrong in the same direction. The attribute is also the only\n * thing a screen-reader user gets — a panel that slides open without flipping it is\n * closed as far as they are concerned.\n *\n * The body stays in the DOM while the panel is closed. It has to: there would be no\n * height to animate otherwise. So its text is READABLE from a spec long before it is\n * visible on screen, which is why {@link getContentText} refuses to answer for a closed\n * panel instead of handing back invisible text, and why {@link isContentHidden} exists\n * to assert that a closed panel really is out of reach.\n *\n * The region itself is a plain `<div>` — the component gives it no `role=\"region\"` — so\n * `aria-expanded` plus `aria-controls` is the whole of the wiring, and\n * {@link isRegionBound} is how a spec checks it still points at this panel's own body.\n *\n * @example\n * ```ts\n * const loader = TestbedHarnessEnvironment.loader(fixture);\n * const shipping = await loader.getHarness(WrCollapseHarness.with({ title: 'Shipping' }));\n *\n * await shipping.open();\n * expect(await shipping.getContentText()).toContain('Ships Monday');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrCollapseHarness extends ComponentHarness {\n static hostSelector = 'wr-collapse';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrCollapseHarnessFilters = {}): HarnessPredicate<WrCollapseHarness> {\n return new HarnessPredicate(WrCollapseHarness, options)\n .addOption('title', options.title, (harness, title) => HarnessPredicate.stringMatches(harness.getTitle(), title))\n .addOption('open', options.open, async (harness, open) => (await harness.isOpen()) === open)\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled);\n }\n\n private readonly header = this.locatorFor('button.wr-collapse__header');\n private readonly body = this.locatorFor('.wr-collapse__body');\n\n /**\n * The header text, trimmed.\n *\n * Read from `.wr-collapse__title` rather than from the header button. Reading the\n * button would return the same string today — the chevron beside the title is an\n * `<svg>`, and an `<svg>` contributes no text — but the title element is the thing that\n * holds the name, so an icon that ever grows a `<text>` node or a label, or a badge\n * added next to the title, cannot leak into it.\n */\n async getTitle(): Promise<string> {\n return (await this.locatorFor('.wr-collapse__title')()).text();\n }\n\n /**\n * Whether the panel is open, from the header's `aria-expanded`.\n *\n * The `wr-collapse--open` modifier on the host is equally public and says the same\n * thing today, but the attribute is the one a screen reader acts on: a panel that\n * looks open while announcing `false` is the bug worth catching, and reading the class\n * would agree with the animation and miss it.\n */\n async isOpen(): Promise<boolean> {\n return (await (await this.header()).getAttribute('aria-expanded')) === 'true';\n }\n\n /**\n * Whether the panel refuses interaction.\n *\n * From the header's own `disabled` property — the thing that actually turns a click\n * away, and what the CDK consults before dispatching one — rather than from the\n * `wr-collapse--disabled` modifier the host also carries. Both are public, but the\n * class is styling: a panel could lose it and still refuse every click, and what a\n * spec wants to know is whether the control is inert.\n */\n async isDisabled(): Promise<boolean> {\n return (await this.header()).getProperty<boolean>('disabled');\n }\n\n /**\n * The header glyph (`indicator`): `'chevron'` or `'plus'`, from which element the\n * header renders, since the two are different elements.\n *\n * Throws when the header holds neither rather than answering `'chevron'` by default:\n * a header that lost its glyph would otherwise read as the default exactly when the\n * glyph is what broke.\n */\n async getIndicator(): Promise<WrCollapseIndicator> {\n if (await this.locatorForOptional('.wr-collapse__plus')()) return 'plus';\n if (await this.locatorForOptional('.wr-collapse__chevron')()) return 'chevron';\n throw new Error(\n `WrCollapseHarness.getIndicator(): \"${await this.getTitle()}\" renders neither .wr-collapse__chevron nor ` +\n '.wr-collapse__plus. The component draws one of them unconditionally, so its absence is the bug.'\n );\n }\n\n /**\n * Whether the panel is drawn flat (`[bordered]=\"false\"`): no frame or background, rows\n * split by a divider. Read from the public `wr-collapse--flat` modifier, which is\n * styling and not state.\n */\n async isFlat(): Promise<boolean> {\n return (await this.host()).hasClass('wr-collapse--flat');\n }\n\n /**\n * The id the header's `aria-controls` names, or `null` when it names nothing.\n *\n * Per-instance and generated, so a spec cannot predict it — what it can do is check\n * that two panels do not share one, and {@link isRegionBound} does the rest.\n */\n async getRegionId(): Promise<string | null> {\n return (await this.header()).getAttribute('aria-controls');\n }\n\n /**\n * Whether the header points at THIS panel's body, and at nothing else on the page.\n *\n * Both halves matter, and neither is provable from the header alone. The id is\n * resolved inside the host first, so a header naming a SIBLING panel's body — which\n * resolves perfectly well from the document and would look correctly wired — fails\n * here. Then it is counted across the document, because two bodies answering to one\n * id hand every reference to whichever comes first, and the second panel's region\n * becomes unreachable to anything that follows the reference.\n */\n async isRegionBound(): Promise<boolean> {\n const id = await this.getRegionId();\n if (id === null) return false;\n\n const own = await this.locatorForOptional(`.wr-collapse__body#${id}`)();\n if (!own) return false;\n\n const everywhere = await this.documentRootLocatorFactory().locatorForAll(`#${id}`)();\n return everywhere.length === 1;\n }\n\n /**\n * Whether the region is hidden from assistive tech AND from the keyboard.\n *\n * Two attributes, because a closed panel needs both and they cover different people:\n * `aria-hidden` keeps the content out of the screen reader's document, `inert` keeps\n * Tab from landing on a link inside a panel nobody can see. The body is never removed\n * from the DOM — the height animation needs it — so these are the only thing standing\n * between a collapsed panel and a keyboard user, and losing either is invisible on\n * screen.\n *\n * They are asserted together on purpose: this answers \"is the closed content actually\n * out of reach\", and half of it is not.\n */\n async isContentHidden(): Promise<boolean> {\n const body = await this.body();\n const hiddenFromAt = (await body.getAttribute('aria-hidden')) === 'true';\n const inert = (await body.getAttribute('inert')) !== null;\n return hiddenFromAt && inert;\n }\n\n /**\n * The text of an OPEN panel's region, trimmed.\n *\n * Throws while the panel is closed rather than answering, because the body is still in\n * the DOM and the text would come back exactly as it does when open — a spec asserting\n * it would be pinning content the user cannot see, and would keep passing if the panel\n * stopped opening at all.\n */\n async getContentText(): Promise<string> {\n if (!(await this.isOpen())) {\n throw new Error(\n `WrCollapseHarness.getContentText(): \"${await this.getTitle()}\" is closed. Its content stays in the ` +\n 'DOM while collapsed — the body has to be there for the height to animate — so reading it now would ' +\n 'assert text nobody can see. Open the panel first, or ask isContentHidden().'\n );\n }\n return (await this.locatorFor('.wr-collapse__inner')()).text();\n }\n\n /** Open the panel. An already-open one is left alone; a disabled one throws. */\n async open(): Promise<void> {\n if (await this.isOpen()) return;\n await this.toggle();\n\n if (!(await this.isOpen())) {\n throw new Error(\n `WrCollapseHarness.open(): \"${await this.getTitle()}\" did not open. A disabled panel refuses its own ` +\n 'header — the button carries `disabled`, and the component checks it again before toggling.'\n );\n }\n }\n\n /** Close the panel. An already-closed one is left alone; a disabled one throws. */\n async close(): Promise<void> {\n if (!(await this.isOpen())) return;\n await this.toggle();\n\n if (await this.isOpen()) {\n throw new Error(\n `WrCollapseHarness.close(): \"${await this.getTitle()}\" did not close. A disabled panel that was opened ` +\n 'through `[open]` cannot be closed from the page at all: the toggle refuses while `disabled` is set, ' +\n 'whichever direction the click would have gone.'\n );\n }\n }\n\n /**\n * Click the header — the panel's entire interactive surface.\n *\n * A click rather than Enter / Space, and nothing is lost by it: the header is a native\n * `<button>`, so a real keyboard activation is the BROWSER synthesising a click from\n * the key press, and jsdom synthesises none. The click is dispatched onto the header\n * itself, so it needs no coordinate and cannot miss in a test that has no layout.\n *\n * A disabled panel ignores this and stays as it was, twice over: the CDK withholds the\n * `click` from an element carrying `disabled`, and the component checks `disabled`\n * again inside its own toggle. Assert rather than assume, or reach for {@link open} /\n * {@link close}, which say so.\n */\n async toggle(): Promise<void> {\n return (await this.header()).click();\n }\n\n /**\n * Move keyboard focus to the header — the only focusable element the component itself\n * renders. Projected content can of course hold its own (which is why a closed panel is\n * `inert`), but that belongs to the consumer, not to this harness.\n */\n async focus(): Promise<void> {\n return (await this.header()).focus();\n }\n\n /** Whether the header currently holds focus. */\n async isFocused(): Promise<boolean> {\n return (await this.header()).isFocused();\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrCollapseGroupHarnessFilters, WrCollapseHarnessFilters } from './types';\nimport { WrCollapseHarness } from './wr-collapse-harness';\n\n/**\n * Test harness for `<wr-collapse-group>` and `<wr-accordion>` — the container a set of\n * {@link WrCollapseHarness} panels sits in, matched in both of its element shapes.\n *\n * There is deliberately no `isAccordion()`, and the reason is worth knowing before a\n * spec goes looking for one: single-open behaviour is not written down anywhere on the\n * page. `<wr-accordion>` carries the marker class `wr-collapse-group--accordion`, but\n * `<wr-collapse-group [accordion]=\"true\">` enforces exactly the same rule and carries\n * nothing — a bound input reaches the component without touching the DOM, and even the\n * literal `accordion` attribute survives only because Angular leaves a static attribute\n * alone. So the class answers \"which element did the template use\", not \"does this group\n * close siblings\", and a harness reporting it would call the group form false. Assert the\n * BEHAVIOUR instead: open two panels and read {@link getOpenTitles} — the assertion that\n * would catch a broken accordion anyway.\n *\n * A collapse group is also not a composite widget. Every header is a native `<button>`\n * in the normal tab order, with no roving `tabindex` and no arrow-key navigation (the\n * APG lists both as optional for an accordion), so there is no \"active\" panel to tell\n * apart from the open one — {@link getFocusedTitle} is the only cursor there is.\n *\n * @example\n * ```ts\n * const settings = await loader.getHarness(WrCollapseGroupHarness.with({ panelTitle: 'Profile' }));\n *\n * await settings.openPanel({ title: 'Security' });\n * expect(await settings.getOpenTitles()).toEqual(['Security']);\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrCollapseGroupHarness extends ComponentHarness {\n /** Both shapes the container ships in: the plain group, and the always-accordion one. */\n static hostSelector = 'wr-collapse-group, wr-accordion';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrCollapseGroupHarnessFilters = {}): HarnessPredicate<WrCollapseGroupHarness> {\n return new HarnessPredicate(WrCollapseGroupHarness, options)\n .addOption('panelTitle', options.panelTitle, async (harness, title) => {\n for (const panel of await harness.getPanelTitles()) {\n if (await HarnessPredicate.stringMatches(panel, title)) return true;\n }\n return false;\n })\n .addOption('openPanelTitle', options.openPanelTitle, async (harness, title) => {\n for (const open of await harness.getOpenTitles()) {\n if (await HarnessPredicate.stringMatches(open, title)) return true;\n }\n return false;\n });\n }\n\n /**\n * The group's panels, in DOM order.\n *\n * Every `<wr-collapse>` inside the host, which includes one nested in another panel's\n * content and every panel of a nested group — the group scopes no more tightly than\n * the DOM does, and a nested accordion's children are still descendants of this one.\n */\n async getPanels(filters: WrCollapseHarnessFilters = {}): Promise<WrCollapseHarness[]> {\n return this.locatorForAll(WrCollapseHarness.with(filters))();\n }\n\n /** The header text of every panel, in DOM order. */\n async getPanelTitles(): Promise<string[]> {\n const panels = await this.getPanels();\n return Promise.all(panels.map(panel => panel.getTitle()));\n }\n\n /** The first panel matching the filters, or a failure naming the panels that exist. */\n async getPanel(filters: WrCollapseHarnessFilters): Promise<WrCollapseHarness> {\n const [panel] = await this.getPanels(filters);\n if (!panel) {\n throw new Error(\n `WrCollapseGroupHarness.getPanel(): no panel matched ${JSON.stringify(filters)}. This group holds: ` +\n `${(await this.getPanelTitles()).join(', ')}.`\n );\n }\n return panel;\n }\n\n /**\n * The panel at a 0-based position in DOM order — the other half of \"by text or by\n * index\", and the only way to address a panel whose title is not unique.\n *\n * Throws for an index past the end rather than resolving to nothing, and says how many\n * panels there are: an out-of-range index is a mistake in the spec, and a `undefined`\n * handed back would surface three lines later as a failure about something else.\n */\n async getPanelAt(index: number): Promise<WrCollapseHarness> {\n const panels = await this.getPanels();\n const panel = panels[index];\n if (!panel) {\n throw new Error(\n `WrCollapseGroupHarness.getPanelAt(): index ${index} is out of range — this group holds ` +\n `${panels.length} panel(s), so the last index is ${panels.length - 1}.`\n );\n }\n return panel;\n }\n\n /** The panels that are open, in DOM order. In accordion mode there is at most one. */\n async getOpenPanels(): Promise<WrCollapseHarness[]> {\n return this.getPanels({ open: true });\n }\n\n /**\n * The header text of every open panel, in DOM order.\n *\n * The assertion an accordion is worth pinning with: opening a second panel has to leave\n * this a list of ONE, and it reads the state from each header's `aria-expanded`, so a\n * sibling that collapsed on screen while still announcing itself open fails here.\n */\n async getOpenTitles(): Promise<string[]> {\n const open = await this.getOpenPanels();\n return Promise.all(open.map(panel => panel.getTitle()));\n }\n\n /**\n * Open the first panel matching the filters.\n *\n * In accordion mode this is also what CLOSES the siblings — the group is told by the\n * panel that opened, not by the click — so a spec that opens two panels in a row is\n * asserting the mode, and {@link getOpenTitles} is where the answer shows up. Throws\n * when nothing matched, and again when the panel refused to open (it is disabled).\n */\n async openPanel(filters: WrCollapseHarnessFilters): Promise<void> {\n await (await this.getPanel(filters)).open();\n }\n\n /** Close the first panel matching the filters. */\n async closePanel(filters: WrCollapseHarnessFilters): Promise<void> {\n await (await this.getPanel(filters)).close();\n }\n\n /**\n * Close every open panel.\n *\n * The open panels are resolved first and then closed one at a time. Every click a\n * harness makes already awaits its own change detection, so closing them concurrently\n * would work too — this reads in the order a user would click, and keeps each failure\n * attributable to the panel that caused it. A disabled panel that was opened through\n * `[open]` cannot be closed from the page and throws — the same failure\n * {@link WrCollapseHarness.close} reports, for the same reason.\n */\n async closeAll(): Promise<void> {\n for (const panel of await this.getOpenPanels()) {\n await panel.close();\n }\n }\n\n /**\n * The header text of the panel whose header holds focus, or `null` when focus is\n * elsewhere.\n *\n * Every header is its own tab stop here, so this reports where focus actually IS\n * rather than where the group would send it — there is no roving tab stop to diverge\n * from.\n */\n async getFocusedTitle(): Promise<string | null> {\n for (const panel of await this.getPanels()) {\n if (await panel.isFocused()) return panel.getTitle();\n }\n return null;\n }\n}\n"],"mappings":";;;;;;;AA8CA,IAAa,oBAAb,MAAa,0BAA0B,iBAAgB;CACrD,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAoC,CAAA,GAAE;EAChD,OAAO,IAAI,iBAAiB,mBAAmB,OAAO,CAAC,CACpD,UAAU,SAAS,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GA,MAAM,WAAW,SAAiC;EAChD,OAAO,MAAM,KAAK,SAAS,OAAO,EAAA,CAAG,MAAK;CAC5C;CAYA,MAAM,WAAQ;EACZ,KAAK,MAAM,SAAS,MAAM,KAAK,cAAa,GAC1C,MAAM,MAAM,MAAK;CAErB;CAUA,MAAM,kBAAe;EACnB,KAAK,MAAM,SAAS,MAAM,KAAK,UAAS,GACtC,IAAI,MAAM,MAAM,UAAS,GAAI,OAAO,MAAM,SAAQ;EAEpD,OAAO;CACT"}
|
|
@@ -22,6 +22,11 @@ var WrCollapse = class WrCollapse {
|
|
|
22
22
|
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
23
23
|
transform: coerceBooleanProperty
|
|
24
24
|
});
|
|
25
|
+
bordered = input(true, {
|
|
26
|
+
...ngDevMode ? { debugName: "bordered" } : /* istanbul ignore next */ {},
|
|
27
|
+
transform: coerceBooleanProperty
|
|
28
|
+
});
|
|
29
|
+
indicator = input("chevron", ...ngDevMode ? [{ debugName: "indicator" }] : /* istanbul ignore next */ []);
|
|
25
30
|
id = { name: randomId("wr-collapse") };
|
|
26
31
|
bodyId = `wr-collapse-body-${this.id.name}`;
|
|
27
32
|
group = inject(WR_COLLAPSE_GROUP, { optional: true });
|
|
@@ -29,6 +34,7 @@ var WrCollapse = class WrCollapse {
|
|
|
29
34
|
classes = computed(() => {
|
|
30
35
|
const parts = ["wr-collapse"];
|
|
31
36
|
if (this.open()) parts.push("wr-collapse--open");
|
|
37
|
+
if (!this.bordered()) parts.push("wr-collapse--flat");
|
|
32
38
|
if (this.disabled()) parts.push("wr-collapse--disabled");
|
|
33
39
|
return parts.join(" ");
|
|
34
40
|
}, ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
|
|
@@ -65,7 +71,7 @@ var WrCollapse = class WrCollapse {
|
|
|
65
71
|
target: i0.ɵɵFactoryTarget.Component
|
|
66
72
|
});
|
|
67
73
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
68
|
-
minVersion: "17.
|
|
74
|
+
minVersion: "17.0.0",
|
|
69
75
|
version: "22.2.5",
|
|
70
76
|
type: WrCollapse,
|
|
71
77
|
isStandalone: true,
|
|
@@ -91,6 +97,20 @@ var WrCollapse = class WrCollapse {
|
|
|
91
97
|
isSignal: true,
|
|
92
98
|
isRequired: false,
|
|
93
99
|
transformFunction: null
|
|
100
|
+
},
|
|
101
|
+
bordered: {
|
|
102
|
+
classPropertyName: "bordered",
|
|
103
|
+
publicName: "bordered",
|
|
104
|
+
isSignal: true,
|
|
105
|
+
isRequired: false,
|
|
106
|
+
transformFunction: null
|
|
107
|
+
},
|
|
108
|
+
indicator: {
|
|
109
|
+
classPropertyName: "indicator",
|
|
110
|
+
publicName: "indicator",
|
|
111
|
+
isSignal: true,
|
|
112
|
+
isRequired: false,
|
|
113
|
+
transformFunction: null
|
|
94
114
|
}
|
|
95
115
|
},
|
|
96
116
|
outputs: { open: "openChange" },
|
|
@@ -99,7 +119,7 @@ var WrCollapse = class WrCollapse {
|
|
|
99
119
|
"attr.title": "null"
|
|
100
120
|
} },
|
|
101
121
|
ngImport: i0,
|
|
102
|
-
template: "<button\n type=\"button\"\n class=\"wr-collapse__header\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"bodyId\"\n [disabled]=\"disabled()\"\n (click)=\"toggle()\"\n>\n <span class=\"wr-collapse__title\">{{ title() }}</span>\n <svg\n class=\"wr-icon__svg wr-collapse__chevron\"\n
|
|
122
|
+
template: "<button\n type=\"button\"\n class=\"wr-collapse__header\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"bodyId\"\n [disabled]=\"disabled()\"\n (click)=\"toggle()\"\n>\n <span class=\"wr-collapse__title\">{{ title() }}</span>\n @if (indicator() === 'plus') {\n <svg\n class=\"wr-icon__svg wr-collapse__plus\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M5 12h14\" />\n <path class=\"wr-collapse__plus-bar\" d=\"M12 5v14\" />\n </svg>\n } @else {\n <svg\n class=\"wr-icon__svg wr-collapse__chevron\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n }\n</button>\n\n<div\n class=\"wr-collapse__body\"\n [attr.id]=\"bodyId\"\n [class.wr-collapse__body--open]=\"open()\"\n [attr.aria-hidden]=\"!open()\"\n [attr.inert]=\"!open() ? '' : null\"\n>\n <div class=\"wr-collapse__content\">\n <div class=\"wr-collapse__inner\">\n <ng-content />\n </div>\n </div>\n</div>\n",
|
|
103
123
|
encapsulation: i0.ViewEncapsulation.None
|
|
104
124
|
});
|
|
105
125
|
};
|
|
@@ -117,7 +137,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
117
137
|
"[class]": "classes()",
|
|
118
138
|
"[attr.title]": "null"
|
|
119
139
|
},
|
|
120
|
-
template: "<button\n type=\"button\"\n class=\"wr-collapse__header\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"bodyId\"\n [disabled]=\"disabled()\"\n (click)=\"toggle()\"\n>\n <span class=\"wr-collapse__title\">{{ title() }}</span>\n <svg\n class=\"wr-icon__svg wr-collapse__chevron\"\n
|
|
140
|
+
template: "<button\n type=\"button\"\n class=\"wr-collapse__header\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"bodyId\"\n [disabled]=\"disabled()\"\n (click)=\"toggle()\"\n>\n <span class=\"wr-collapse__title\">{{ title() }}</span>\n @if (indicator() === 'plus') {\n <svg\n class=\"wr-icon__svg wr-collapse__plus\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M5 12h14\" />\n <path class=\"wr-collapse__plus-bar\" d=\"M12 5v14\" />\n </svg>\n } @else {\n <svg\n class=\"wr-icon__svg wr-collapse__chevron\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n }\n</button>\n\n<div\n class=\"wr-collapse__body\"\n [attr.id]=\"bodyId\"\n [class.wr-collapse__body--open]=\"open()\"\n [attr.aria-hidden]=\"!open()\"\n [attr.inert]=\"!open() ? '' : null\"\n>\n <div class=\"wr-collapse__content\">\n <div class=\"wr-collapse__inner\">\n <ng-content />\n </div>\n </div>\n</div>\n"
|
|
121
141
|
}]
|
|
122
142
|
}],
|
|
123
143
|
ctorParameters: () => [],
|
|
@@ -148,6 +168,22 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
148
168
|
alias: "disabled",
|
|
149
169
|
required: false
|
|
150
170
|
}]
|
|
171
|
+
}],
|
|
172
|
+
bordered: [{
|
|
173
|
+
type: i0.Input,
|
|
174
|
+
args: [{
|
|
175
|
+
isSignal: true,
|
|
176
|
+
alias: "bordered",
|
|
177
|
+
required: false
|
|
178
|
+
}]
|
|
179
|
+
}],
|
|
180
|
+
indicator: [{
|
|
181
|
+
type: i0.Input,
|
|
182
|
+
args: [{
|
|
183
|
+
isSignal: true,
|
|
184
|
+
alias: "indicator",
|
|
185
|
+
required: false
|
|
186
|
+
}]
|
|
151
187
|
}]
|
|
152
188
|
}
|
|
153
189
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-collapse.mjs","names":[],"sources":["../../../projects/lib/collapse/tokens/collapse-group.token.ts","../../../projects/lib/collapse/collapse.ts","../../../projects/lib/collapse/collapse.html","../../../projects/lib/collapse/collapse-group.ts","../../../projects/lib/collapse/accordion.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrCollapseGroupContext } from '../types';\n\n/**\n * Token a `<wr-collapse>` injects to register itself with — and notify of\n * open events — its parent `<wr-collapse-group>`. Drives the accordion\n * behaviour when the group has `accordion` enabled.\n *\n * @internal\n */\nexport const WR_COLLAPSE_GROUP = new InjectionToken<WrCollapseGroupContext>('WR_COLLAPSE_GROUP');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, DestroyRef, ViewEncapsulation, computed, effect, inject, input, model } from '@angular/core';\n\nimport { randomId, wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\n\n/**\n * Expandable panel with a clickable header. Two-way binds the `open`\n * state. When wrapped in `<wr-collapse-group accordion>`, only one\n * sibling can be open at a time.\n *\n * @example\n * ```html\n * <wr-collapse title=\"Section title\">\n * Section body…\n * </wr-collapse>\n *\n * <wr-collapse-group accordion>\n * <wr-collapse title=\"A\">…</wr-collapse>\n * <wr-collapse title=\"B\">…</wr-collapse>\n * </wr-collapse-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-collapse',\n templateUrl: './collapse.html',\n encapsulation: ViewEncapsulation.None,\n // See `WrAlert`: a static `title=` feeds the input AND lands on the host,\n // where the browser draws it as a tooltip over the whole component.\n host: { '[class]': 'classes()', '[attr.title]': 'null' },\n})\nexport class WrCollapse {\n /** Header text. */\n readonly title = input.required<string>();\n\n /** Two-way bindable open/closed state. @default false */\n readonly open = model<boolean>(false);\n\n /** Disable interaction. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /** Identity used by the parent group when tracking children. @internal */\n readonly id = { name: randomId('wr-collapse') };\n\n /** DOM id for the body element, referenced by header's `aria-controls`. */\n protected readonly bodyId = `wr-collapse-body-${this.id.name}`;\n\n private readonly group = inject(WR_COLLAPSE_GROUP, { optional: true });\n private readonly destroyRef = inject(DestroyRef);\n\n protected readonly classes = computed(() => {\n const parts = ['wr-collapse'];\n if (this.open()) parts.push('wr-collapse--open');\n if (this.disabled()) parts.push('wr-collapse--disabled');\n return parts.join(' ');\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n if (this.group) {\n this.group.register({ id: this.id, close: () => this.open.set(false) });\n this.destroyRef.onDestroy(() => this.group?.unregister(this.id));\n\n // Tell the group whenever we open — group decides whether to close siblings.\n effect(() => {\n if (this.open()) this.group?.notifyOpened(this.id);\n });\n }\n }\n\n /** Open the panel. */\n openPanel(): void {\n if (this.disabled()) return;\n this.open.set(true);\n }\n\n /** Close the panel. */\n close(): void {\n this.open.set(false);\n }\n\n /** Toggle the panel. */\n toggle(): void {\n if (this.disabled()) return;\n this.open.update(v => !v);\n }\n}\n","<button\n type=\"button\"\n class=\"wr-collapse__header\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"bodyId\"\n [disabled]=\"disabled()\"\n (click)=\"toggle()\"\n>\n <span class=\"wr-collapse__title\">{{ title() }}</span>\n <svg\n class=\"wr-icon__svg wr-collapse__chevron\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n</button>\n\n<div\n class=\"wr-collapse__body\"\n [attr.id]=\"bodyId\"\n [class.wr-collapse__body--open]=\"open()\"\n [attr.aria-hidden]=\"!open()\"\n [attr.inert]=\"!open() ? '' : null\"\n>\n <div class=\"wr-collapse__content\">\n <div class=\"wr-collapse__inner\">\n <ng-content />\n </div>\n </div>\n</div>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, forwardRef, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\nimport type { WrCollapseGroupContext, WrCollapseGroupMember } from './types';\n\n/**\n * Visual + behavioral grouping of `<wr-collapse>` children. When\n * `accordion` is true, opening one child closes the others.\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-collapse-group',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-collapse-group' },\n providers: [\n {\n provide: WR_COLLAPSE_GROUP,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrCollapseGroup),\n },\n ],\n})\nexport class WrCollapseGroup implements WrCollapseGroupContext {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n }\n\n /** When true, only one child may be open at a time. @default false */\n readonly accordion = input(false, { transform: coerceBooleanProperty });\n\n private readonly members = new Map<object, WrCollapseGroupMember>();\n\n register(member: WrCollapseGroupMember): void {\n this.members.set(member.id, member);\n }\n\n unregister(memberId: object): void {\n this.members.delete(memberId);\n }\n\n notifyOpened(opener: object): void {\n if (!this.accordion()) return;\n for (const [id, member] of this.members) {\n if (id !== opener) member.close();\n }\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, forwardRef, signal } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\nimport type { WrCollapseGroupContext, WrCollapseGroupMember } from './types';\n\n/**\n * Accordion — a `<wr-collapse>` container that enforces single-open\n * behavior: opening a child closes its siblings.\n *\n * Use `<wr-collapse-group>` when you only need visual grouping without\n * the mutually-exclusive open semantics.\n *\n * @example\n * ```html\n * <wr-accordion>\n * <wr-collapse title=\"Profile\">…</wr-collapse>\n * <wr-collapse title=\"Security\">…</wr-collapse>\n * <wr-collapse title=\"Notifications\">…</wr-collapse>\n * </wr-accordion>\n * ```\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-accordion',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-collapse-group wr-collapse-group--accordion' },\n providers: [\n {\n provide: WR_COLLAPSE_GROUP,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrAccordion),\n },\n ],\n})\nexport class WrAccordion implements WrCollapseGroupContext {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n }\n\n /** Always behaves as an accordion. Provided for context-interface symmetry. */\n readonly accordion = signal(true).asReadonly();\n\n private readonly members = new Map<object, WrCollapseGroupMember>();\n\n register(member: WrCollapseGroupMember): void {\n this.members.set(member.id, member);\n }\n\n unregister(memberId: object): void {\n this.members.delete(memberId);\n }\n\n notifyOpened(opener: object): void {\n for (const [id, member] of this.members) {\n if (id !== opener) member.close();\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAkBA,MAAa,oBAAoB,IAAI,eAAuC,mBAAmB;;;;;;;ACuB/F,IAAa,aAAb,MAAa,WAAU;CAEZ,QAAQ,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAGhC,OAAO,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,C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A,SAAA;EAAA,UAAA;EAAA,MAAA;EAAW,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAX,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAW,cAAA;EAAA,UAAA;EAAA,MAAA,EAAA,gBAAA,iDAAA;EAAA,WARX,CACT;GACE,SAAS;GAET,aAAa,iBAAiB,WAAW;EAC1C,CACF;EAAA,UAAA;EAAA,UATS;EAAgB,UAAA;EAAA,eAAA,GAAA,kBAAA;CAAA,CAAA;;AAWf,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAW,YAAA,CAAA;EAbvB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;GACV,eAAe,kBAAkB;GACjC,MAAM,EAAE,OAAO,iDAAgD;GAC/D,WAAW,CACT;IACE,SAAS;IAET,aAAa,iBAAgB,WAAY;GAC1C,CACF;EACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-collapse.mjs","names":[],"sources":["../../../projects/lib/collapse/tokens/collapse-group.token.ts","../../../projects/lib/collapse/collapse.ts","../../../projects/lib/collapse/collapse.html","../../../projects/lib/collapse/collapse-group.ts","../../../projects/lib/collapse/accordion.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrCollapseGroupContext } from '../types';\n\n/**\n * Token a `<wr-collapse>` injects to register itself with — and notify of\n * open events — its parent `<wr-collapse-group>`. Drives the accordion\n * behaviour when the group has `accordion` enabled.\n *\n * @internal\n */\nexport const WR_COLLAPSE_GROUP = new InjectionToken<WrCollapseGroupContext>('WR_COLLAPSE_GROUP');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, DestroyRef, ViewEncapsulation, computed, effect, inject, input, model } from '@angular/core';\n\nimport { randomId, wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\nimport type { WrCollapseIndicator } from './types';\n\n/**\n * Expandable panel with a clickable header. Two-way binds the `open`\n * state. When wrapped in `<wr-collapse-group accordion>`, only one\n * sibling can be open at a time.\n *\n * @example\n * ```html\n * <wr-collapse title=\"Section title\">\n * Section body…\n * </wr-collapse>\n *\n * <wr-collapse-group accordion>\n * <wr-collapse title=\"A\">…</wr-collapse>\n * <wr-collapse title=\"B\">…</wr-collapse>\n * </wr-collapse-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-collapse',\n templateUrl: './collapse.html',\n encapsulation: ViewEncapsulation.None,\n // See `WrAlert`: a static `title=` feeds the input AND lands on the host,\n // where the browser draws it as a tooltip over the whole component.\n host: { '[class]': 'classes()', '[attr.title]': 'null' },\n})\nexport class WrCollapse {\n /** Header text. */\n readonly title = input.required<string>();\n\n /** Two-way bindable open/closed state. @default false */\n readonly open = model<boolean>(false);\n\n /** Disable interaction. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Draws the frame, the panel background and the rounded corners. Turn it off for a\n * flat list: no frame, rows split by a divider line between neighbours.\n * @default true\n */\n readonly bordered = input(true, { transform: coerceBooleanProperty });\n\n /**\n * The header glyph: `chevron` turns over, `plus` becomes a minus while open.\n * @default 'chevron'\n */\n readonly indicator = input<WrCollapseIndicator>('chevron');\n\n /** Identity used by the parent group when tracking children. @internal */\n readonly id = { name: randomId('wr-collapse') };\n\n /** DOM id for the body element, referenced by header's `aria-controls`. */\n protected readonly bodyId = `wr-collapse-body-${this.id.name}`;\n\n private readonly group = inject(WR_COLLAPSE_GROUP, { optional: true });\n private readonly destroyRef = inject(DestroyRef);\n\n protected readonly classes = computed(() => {\n const parts = ['wr-collapse'];\n if (this.open()) parts.push('wr-collapse--open');\n if (!this.bordered()) parts.push('wr-collapse--flat');\n if (this.disabled()) parts.push('wr-collapse--disabled');\n return parts.join(' ');\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n if (this.group) {\n this.group.register({ id: this.id, close: () => this.open.set(false) });\n this.destroyRef.onDestroy(() => this.group?.unregister(this.id));\n\n // Tell the group whenever we open — group decides whether to close siblings.\n effect(() => {\n if (this.open()) this.group?.notifyOpened(this.id);\n });\n }\n }\n\n /** Open the panel. */\n openPanel(): void {\n if (this.disabled()) return;\n this.open.set(true);\n }\n\n /** Close the panel. */\n close(): void {\n this.open.set(false);\n }\n\n /** Toggle the panel. */\n toggle(): void {\n if (this.disabled()) return;\n this.open.update(v => !v);\n }\n}\n","<button\n type=\"button\"\n class=\"wr-collapse__header\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"bodyId\"\n [disabled]=\"disabled()\"\n (click)=\"toggle()\"\n>\n <span class=\"wr-collapse__title\">{{ title() }}</span>\n @if (indicator() === 'plus') {\n <svg\n class=\"wr-icon__svg wr-collapse__plus\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M5 12h14\" />\n <path class=\"wr-collapse__plus-bar\" d=\"M12 5v14\" />\n </svg>\n } @else {\n <svg\n class=\"wr-icon__svg wr-collapse__chevron\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n }\n</button>\n\n<div\n class=\"wr-collapse__body\"\n [attr.id]=\"bodyId\"\n [class.wr-collapse__body--open]=\"open()\"\n [attr.aria-hidden]=\"!open()\"\n [attr.inert]=\"!open() ? '' : null\"\n>\n <div class=\"wr-collapse__content\">\n <div class=\"wr-collapse__inner\">\n <ng-content />\n </div>\n </div>\n</div>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, forwardRef, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\nimport type { WrCollapseGroupContext, WrCollapseGroupMember } from './types';\n\n/**\n * Visual + behavioral grouping of `<wr-collapse>` children. When\n * `accordion` is true, opening one child closes the others.\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-collapse-group',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-collapse-group' },\n providers: [\n {\n provide: WR_COLLAPSE_GROUP,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrCollapseGroup),\n },\n ],\n})\nexport class WrCollapseGroup implements WrCollapseGroupContext {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n }\n\n /** When true, only one child may be open at a time. @default false */\n readonly accordion = input(false, { transform: coerceBooleanProperty });\n\n private readonly members = new Map<object, WrCollapseGroupMember>();\n\n register(member: WrCollapseGroupMember): void {\n this.members.set(member.id, member);\n }\n\n unregister(memberId: object): void {\n this.members.delete(memberId);\n }\n\n notifyOpened(opener: object): void {\n if (!this.accordion()) return;\n for (const [id, member] of this.members) {\n if (id !== opener) member.close();\n }\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, forwardRef, signal } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\nimport type { WrCollapseGroupContext, WrCollapseGroupMember } from './types';\n\n/**\n * Accordion — a `<wr-collapse>` container that enforces single-open\n * behavior: opening a child closes its siblings.\n *\n * Use `<wr-collapse-group>` when you only need visual grouping without\n * the mutually-exclusive open semantics.\n *\n * @example\n * ```html\n * <wr-accordion>\n * <wr-collapse title=\"Profile\">…</wr-collapse>\n * <wr-collapse title=\"Security\">…</wr-collapse>\n * <wr-collapse title=\"Notifications\">…</wr-collapse>\n * </wr-accordion>\n * ```\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-accordion',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-collapse-group wr-collapse-group--accordion' },\n providers: [\n {\n provide: WR_COLLAPSE_GROUP,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrAccordion),\n },\n ],\n})\nexport class WrAccordion implements WrCollapseGroupContext {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n }\n\n /** Always behaves as an accordion. Provided for context-interface symmetry. */\n readonly accordion = signal(true).asReadonly();\n\n private readonly members = new Map<object, WrCollapseGroupMember>();\n\n register(member: WrCollapseGroupMember): void {\n this.members.set(member.id, member);\n }\n\n unregister(memberId: object): void {\n this.members.delete(memberId);\n }\n\n notifyOpened(opener: object): void {\n for (const [id, member] of this.members) {\n if (id !== opener) member.close();\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAkBA,MAAa,oBAAoB,IAAI,eAAuC,mBAAmB;;;;;;;ACwB/F,IAAa,aAAb,MAAa,WAAU;CAEZ,QAAQ,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAGhC,OAAO,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+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Aa,cAAb,MAAa,YAAW;CACtB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,UAAU;CAC7E;CAGS,YAAY,OAAO,IAAI,CAAC,CAAC,WAAU;CAE3B,0BAAU,IAAI,IAAG;CAElC,SAAS,QAA6B;EACpC,KAAK,QAAQ,IAAI,OAAO,IAAI,MAAM;CACpC;CAEA,WAAW,UAAgB;EACzB,KAAK,QAAQ,OAAO,QAAQ;CAC9B;CAEA,aAAa,QAAc;EACzB,KAAK,MAAM,CAAC,IAAI,WAAW,KAAK,SAC9B,IAAI,OAAO,QAAQ,OAAO,MAAK;CAEnC;CAtBW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAW,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAX,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAW,cAAA;EAAA,UAAA;EAAA,MAAA,EAAA,gBAAA,iDAAA;EAAA,WARX,CACT;GACE,SAAS;GAET,aAAa,iBAAiB,WAAW;EAC1C,CACF;EAAA,UAAA;EAAA,UATS;EAAgB,UAAA;EAAA,eAAA,GAAA,kBAAA;CAAA,CAAA;;AAWf,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAW,YAAA,CAAA;EAbvB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;GACV,eAAe,kBAAkB;GACjC,MAAM,EAAE,OAAO,iDAAgD;GAC/D,WAAW,CACT;IACE,SAAS;IAET,aAAa,iBAAgB,WAAY;GAC1C,CACF;EACF,CAAA"}
|
package/fesm2022/ngwr-i18n.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { Directive, ElementRef, InjectionToken, LOCALE_ID, Pipe, Service, computed, effect, inject, input, isDevMode, makeEnvironmentProviders, signal } from "@angular/core";
|
|
2
|
+
import { ApplicationRef, Directive, ElementRef, EnvironmentInjector, InjectionToken, LOCALE_ID, Pipe, Service, computed, effect, inject, input, isDevMode, makeEnvironmentProviders, provideEnvironmentInitializer, signal } from "@angular/core";
|
|
3
3
|
import { catchError, firstValueFrom, of } from "rxjs";
|
|
4
4
|
import { WrStorage } from "ngwr/storage";
|
|
5
5
|
import { HttpClient } from "@angular/common/http";
|
|
@@ -393,6 +393,12 @@ function provideWrI18n(options = {}) {
|
|
|
393
393
|
provide: WR_I18N_LOADER,
|
|
394
394
|
useValue: loader
|
|
395
395
|
});
|
|
396
|
+
if (typeof ngDevMode === "undefined" || ngDevMode) providers.push(provideEnvironmentInitializer(() => {
|
|
397
|
+
const here = inject(EnvironmentInjector);
|
|
398
|
+
if (here === inject(ApplicationRef, { optional: true })?.injector) return;
|
|
399
|
+
if (here.get(WrI18n, null, { self: true })) return;
|
|
400
|
+
console.warn("[NGWR] provideWrI18n() is in a route or child injector. WrI18n is a root service, so this configuration is ignored. Move provideWrI18n() and the catalogs to the application's root providers, and switch a lazy area with inject(WrI18n).use(locale).");
|
|
401
|
+
}));
|
|
396
402
|
return makeEnvironmentProviders(providers);
|
|
397
403
|
}
|
|
398
404
|
function provideWrI18nStaticLoader(catalogs, scopes) {
|