ngwr 16.7.0 → 16.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/checkbox/styles/_index.scss +4 -0
- package/fesm2022/ngwr-date-picker.mjs +1 -0
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +11 -1
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-scroll.mjs +39 -16
- package/fesm2022/ngwr-scroll.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +17 -4
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-tabs-router.mjs +3 -3
- package/fesm2022/ngwr-tabs-router.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/package.json +1 -1
- package/radio/styles/_index.scss +4 -0
- package/switch/styles/_index.scss +4 -0
- package/table/styles/_index.scss +7 -0
- package/types/ngwr-date-picker.d.ts +8 -2
- package/types/ngwr-popover.d.ts +3 -3
- package/types/ngwr-scroll.d.ts +11 -2
- package/types/ngwr-table.d.ts +1 -0
- package/types/ngwr-tabs-router.d.ts +3 -4
- package/types/ngwr-version.d.ts +1 -1
package/fesm2022/ngwr-scroll.mjs
CHANGED
|
@@ -182,7 +182,7 @@ var WrScrollFollow = class WrScrollFollow {
|
|
|
182
182
|
read(scrolled) {
|
|
183
183
|
const top = this.el.nativeElement.scrollTop;
|
|
184
184
|
const distance = this.distance();
|
|
185
|
-
if (top < this.lastTop
|
|
185
|
+
if (top < this.lastTop) this.atEnd.set(distance <= 1);
|
|
186
186
|
else if (scrolled && top > this.lastTop && distance <= this.wrScrollFollowThreshold()) this.atEnd.set(true);
|
|
187
187
|
this.lastTop = top;
|
|
188
188
|
}
|
|
@@ -214,26 +214,49 @@ var WrScrollFollow = class WrScrollFollow {
|
|
|
214
214
|
const anchors = [];
|
|
215
215
|
let parent = host;
|
|
216
216
|
for (let depth = 0; depth < WRAPPER_DEPTH; depth++) {
|
|
217
|
-
|
|
218
|
-
let boxes = 0;
|
|
219
|
-
for (let child = parent.lastElementChild; child; child = child.previousElementSibling) {
|
|
220
|
-
const rect = child.getBoundingClientRect();
|
|
221
|
-
if (!rect.width && !rect.height) continue;
|
|
222
|
-
boxes++;
|
|
223
|
-
if (!found && rect.top < box.bottom) found = {
|
|
224
|
-
node: child,
|
|
225
|
-
offset: rect.top - box.top
|
|
226
|
-
};
|
|
227
|
-
if (found && boxes > 1) break;
|
|
228
|
-
}
|
|
217
|
+
const found = this.lowestInView(parent, box);
|
|
229
218
|
if (!found) break;
|
|
230
|
-
anchors.push(found);
|
|
231
|
-
if (
|
|
232
|
-
parent = found.node;
|
|
219
|
+
anchors.push(found.anchor);
|
|
220
|
+
if (found.others) break;
|
|
221
|
+
parent = found.anchor.node;
|
|
233
222
|
}
|
|
234
223
|
this.anchors = anchors;
|
|
235
224
|
this.anchorsTop = host.scrollTop;
|
|
236
225
|
}
|
|
226
|
+
lowestInView(parent, box) {
|
|
227
|
+
const children = parent.children;
|
|
228
|
+
const sized = (index) => {
|
|
229
|
+
const rect = children[index].getBoundingClientRect();
|
|
230
|
+
return rect.width || rect.height ? rect : null;
|
|
231
|
+
};
|
|
232
|
+
let found = -1;
|
|
233
|
+
let foundRect = null;
|
|
234
|
+
let low = 0;
|
|
235
|
+
let high = children.length - 1;
|
|
236
|
+
while (low <= high) {
|
|
237
|
+
const mid = Math.floor((low + high) / 2);
|
|
238
|
+
let probe = mid;
|
|
239
|
+
let rect = sized(probe);
|
|
240
|
+
while (!rect && probe > low) rect = sized(--probe);
|
|
241
|
+
if (!rect) low = mid + 1;
|
|
242
|
+
else if (rect.top < box.bottom) {
|
|
243
|
+
found = probe;
|
|
244
|
+
foundRect = rect;
|
|
245
|
+
low = mid + 1;
|
|
246
|
+
} else high = probe - 1;
|
|
247
|
+
}
|
|
248
|
+
if (!foundRect) return null;
|
|
249
|
+
let others = false;
|
|
250
|
+
for (let i = found - 1; i >= 0 && !others; i--) others = sized(i) !== null;
|
|
251
|
+
for (let i = found + 1; i < children.length && !others; i++) others = sized(i) !== null;
|
|
252
|
+
return {
|
|
253
|
+
anchor: {
|
|
254
|
+
node: children[found],
|
|
255
|
+
offset: foundRect.top - box.top
|
|
256
|
+
},
|
|
257
|
+
others
|
|
258
|
+
};
|
|
259
|
+
}
|
|
237
260
|
restore() {
|
|
238
261
|
const host = this.el.nativeElement;
|
|
239
262
|
const scrolledSince = host.scrollTop - this.anchorsTop;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-scroll.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/scroll/wr-scroll.ts","../../../projects/lib/scroll/scroll-follow.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 { DOCUMENT } from '@angular/common';\nimport { Service, inject } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\n\nimport type { WrScrollOptions, WrScrollTarget } from './types';\n\n/**\n * Smooth-scroll utility. Resolves `id` / selector / element / coords\n * targets; subtracts an `offset` (for sticky headers); respects\n * `prefers-reduced-motion` — automatically falls back to instant\n * scrolling when the user has opted out.\n *\n * SSR-safe — all methods no-op on the server.\n *\n * @example\n * ```ts\n * const scroll = inject(WrScroll);\n * scroll.to('#section-three', { offset: 80 });\n * scroll.toTop({ smooth: false });\n * scroll.intoView(myEl, { offset: 64 });\n * ```\n *\n * @see https://ngwr.dev/reference/services/scroll\n */\n@Service()\nexport class WrScroll {\n private readonly doc = inject(DOCUMENT);\n private readonly platform = inject(WrPlatform);\n\n /** Scroll to an arbitrary target. */\n to(target: WrScrollTarget, options: WrScrollOptions = {}): void {\n if (!this.platform.isBrowser) return;\n const win = this.doc.defaultView;\n if (!win) return;\n\n const offset = options.offset ?? 0;\n const behavior = this.behavior(options.smooth);\n const container = options.container ?? win;\n\n if (typeof target === 'object' && 'top' in target) {\n this.scroll(container, {\n top: target.top - offset,\n ...(target.left === undefined ? {} : { left: target.left }),\n behavior,\n });\n return;\n }\n\n const el = typeof target === 'string' ? this.resolveSelector(target) : target;\n if (!el) return;\n\n const rect = el.getBoundingClientRect();\n if (container === win) {\n const top = rect.top + win.scrollY - offset;\n this.scroll(container, { top, behavior });\n } else {\n const ctx = container as Element;\n const ctxRect = ctx.getBoundingClientRect();\n const top = rect.top - ctxRect.top + ctx.scrollTop - offset;\n this.scroll(container, { top, behavior });\n }\n }\n\n /** Convenience for an element — accepts the same options. */\n intoView(el: Element, options: WrScrollOptions = {}): void {\n this.to(el, options);\n }\n\n /** Scroll the page (or container) to the top. */\n toTop(options: WrScrollOptions = {}): void {\n this.to({ top: 0 }, options);\n }\n\n // Internals\n\n private resolveSelector(value: string): Element | null {\n if (value.startsWith('#')) {\n return this.doc.getElementById(value.slice(1));\n }\n try {\n return this.doc.querySelector(value);\n } catch {\n return null;\n }\n }\n\n /** `instant`, not `auto`: `auto` follows the container's `scroll-behavior`, which may be smooth. */\n private behavior(requested: boolean | undefined): ScrollBehavior {\n if (requested === false) return 'instant';\n if (this.platform.prefersReducedMotion()) return 'instant';\n return 'smooth';\n }\n\n private scroll(container: Window | Element, options: ScrollToOptions): void {\n if (container instanceof Window) container.scrollTo(options);\n else container.scrollTo(options);\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 { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n type Signal,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\n\nimport type { WrScrollOptions } from './types';\nimport { WrScroll } from './wr-scroll';\n\n/** A row the view is held to, and where its top edge sat under the container's. */\ninterface Anchor {\n readonly node: Element;\n readonly offset: number;\n}\n\n/** A wrapper around the rows is looked through this many levels deep. */\nconst WRAPPER_DEPTH = 3;\n\n/**\n * Keeps a scroll container at its end while content grows, and holds the\n * reader's place while they are somewhere else.\n *\n * The container starts at its end and stays there as rows are added, as a row\n * grows (streamed text, an image that loads) and as the container is resized.\n * Scrolling up stops the following at once; scrolling back to within\n * `wrScrollFollowThreshold` of the end resumes it. While it is not following,\n * the lowest row in view keeps its place when content above it changes, so\n * older rows loaded at the top do not push the page down.\n *\n * `following` says which of the two it is doing, for a \"jump to latest\" button,\n * and `toEnd()` is what that button calls.\n *\n * The rows are the container's children, or the children of its only child.\n * The container scrolls vertically in the normal direction: RTL changes\n * nothing, and a `column-reverse` container is not supported. Nothing runs on\n * the server.\n *\n * @example\n * ```html\n * <div class=\"log\" wrScrollFollow #log=\"wrScrollFollow\">\n * @for (message of messages(); track message.id) {\n * <p>{{ message.text }}</p>\n * }\n * </div>\n * @if (!log.following()) {\n * <button type=\"button\" (click)=\"log.toEnd()\">Jump to latest</button>\n * }\n * ```\n *\n * @see https://ngwr.dev/reference/services/scroll\n */\n@Directive({\n selector: '[wrScrollFollow]',\n exportAs: 'wrScrollFollow',\n host: {\n // The browser's own scroll anchoring would move the view a second time.\n '[style.overflow-anchor]': 'wrScrollFollow() ? \"none\" : null',\n },\n})\nexport class WrScrollFollow {\n /** `false` switches it off and hands scroll anchoring back to the browser. Bare `wrScrollFollow` is on. */\n readonly wrScrollFollow = input(true, { transform: coerceBooleanProperty });\n\n /** How close to the end, in pixels, the reader has to scroll back for the following to resume. */\n readonly wrScrollFollowThreshold = input(80, {\n transform: (value: unknown) => Math.max(0, coerceNumberProperty(value, 80)),\n });\n\n private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly scroll = inject(WrScroll);\n\n private readonly atEnd = signal(true);\n\n /** Whether the container is held at its end. `false` once the reader scrolls up, and while switched off. */\n readonly following: Signal<boolean> = computed(() => this.wrScrollFollow() && this.atEnd());\n\n private started = false;\n private lastTop = 0;\n private anchors: Anchor[] = [];\n /** `scrollTop` when `anchors` was measured, so a scroll since then is not undone. */\n private anchorsTop = 0;\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n\n afterNextRender(() => {\n const host = this.el.nativeElement;\n const onScroll = (): void => this.onScroll();\n const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => this.sync());\n const mutation = new MutationObserver(records => {\n for (const record of records) {\n if (record.target !== host) continue;\n for (const node of record.addedNodes) if (node instanceof Element) resize?.observe(node);\n for (const node of record.removedNodes) if (node instanceof Element) resize?.unobserve(node);\n }\n this.sync();\n });\n\n host.addEventListener('scroll', onScroll, { passive: true });\n // The host for its own height, its children for growth no mutation reports (an image, a font).\n resize?.observe(host);\n for (const child of host.children) resize?.observe(child);\n mutation.observe(host, { childList: true, characterData: true, subtree: true });\n\n this.started = true;\n this.sync();\n\n destroyRef.onDestroy(() => {\n host.removeEventListener('scroll', onScroll);\n resize?.disconnect();\n mutation.disconnect();\n });\n });\n\n effect(() => {\n const on = this.wrScrollFollow();\n if (!this.started) return;\n untracked(() => {\n if (on) this.atEnd.set(this.distance() <= this.wrScrollFollowThreshold());\n this.sync();\n });\n });\n }\n\n /**\n * Scroll to the end and follow again. Smooth unless `smooth` is `false` or\n * the reader prefers reduced motion.\n */\n toEnd(options: Pick<WrScrollOptions, 'smooth'> = {}): void {\n if (!this.started) return;\n const host = this.el.nativeElement;\n this.atEnd.set(true);\n this.anchors = [];\n this.scroll.to({ top: host.scrollHeight }, { ...options, container: host });\n }\n\n private distance(): number {\n const host = this.el.nativeElement;\n return host.scrollHeight - host.scrollTop - host.clientHeight;\n }\n\n private onScroll(): void {\n this.read(true);\n if (this.following()) {\n this.anchors = [];\n return;\n }\n if (!this.wrScrollFollow()) return;\n // A row above may have changed size with its resize callback still to come\n // (scroll events run first): correct for it before the anchor is replaced.\n this.restore();\n this.lastTop = this.el.nativeElement.scrollTop;\n this.capture();\n }\n\n /**\n * Any move up stops the following, so a reader can leave while text streams\n * in; within a pixel of the end it is the browser clamping to shorter content.\n * Only a move down resumes it: the directive's own writes are never read as one.\n */\n private read(scrolled: boolean): void {\n const top = this.el.nativeElement.scrollTop;\n const distance = this.distance();\n\n if (top < this.lastTop && distance > 1) this.atEnd.set(false);\n else if (scrolled && top > this.lastTop && distance <= this.wrScrollFollowThreshold()) this.atEnd.set(true);\n\n this.lastTop = top;\n }\n\n /** Content or the container changed size: hold the end, or hold the reader's place. */\n private sync(): void {\n const host = this.el.nativeElement;\n // A scroll whose event is still on its way must not be pinned over, and a\n // move down into the threshold resumes following here, before `lastTop`\n // moves past it and the scroll event finds nothing to read.\n this.read(true);\n\n if (!this.wrScrollFollow()) {\n this.anchors = [];\n return;\n }\n\n if (this.atEnd()) {\n this.move(host.scrollHeight);\n this.anchors = [];\n } else {\n this.restore();\n this.capture();\n }\n this.lastTop = host.scrollTop;\n }\n\n /** Instant whatever `scroll-behavior` the container has: an animated correction is a visible jump. */\n private move(top: number): void {\n this.el.nativeElement.scrollTo({ top, behavior: 'instant' });\n }\n\n /** Remember the lowest row in view. A row at the top would be the \"load older\" button. */\n private capture(): void {\n const host = this.el.nativeElement;\n const box = host.getBoundingClientRect();\n const anchors: Anchor[] = [];\n\n let parent: Element = host;\n for (let depth = 0; depth < WRAPPER_DEPTH; depth++) {\n let found: Anchor | null = null;\n let boxes = 0;\n for (let child = parent.lastElementChild; child; child = child.previousElementSibling) {\n const rect = child.getBoundingClientRect();\n // `display: none` and `display: contents` have no box to hold on to.\n if (!rect.width && !rect.height) continue;\n boxes++;\n if (!found && rect.top < box.bottom) found = { node: child, offset: rect.top - box.top };\n if (found && boxes > 1) break;\n }\n if (!found) break;\n anchors.push(found);\n // An only child is a wrapper, and its top does not move when rows are added inside it.\n if (boxes > 1) break;\n parent = found.node;\n }\n\n this.anchors = anchors;\n this.anchorsTop = host.scrollTop;\n }\n\n /** Put the remembered row back where it was. */\n private restore(): void {\n const host = this.el.nativeElement;\n const scrolledSince = host.scrollTop - this.anchorsTop;\n\n for (let i = this.anchors.length - 1; i >= 0; i--) {\n const { node, offset } = this.anchors[i];\n if (!host.contains(node)) continue;\n const rect = node.getBoundingClientRect();\n if (!rect.width && !rect.height) continue;\n\n const delta = rect.top - host.getBoundingClientRect().top - (offset - scrolledSince);\n if (Math.abs(delta) >= 1) this.move(host.scrollTop + delta);\n return;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAiCA,IAAa,WAAb,MAAa,SAAQ;CACF,MAAM,OAAOA,UAAQ;CACrB,WAAW,OAAO,UAAU;CAG7C,GAAG,QAAwB,UAA2B,CAAA,GAAE;EACtD,IAAI,CAAC,KAAK,SAAS,WAAW;EAC9B,MAAM,MAAM,KAAK,IAAI;EACrB,IAAI,CAAC,KAAK;EAEV,MAAM,SAAS,QAAQ,UAAU;EACjC,MAAM,WAAW,KAAK,SAAS,QAAQ,MAAM;EAC7C,MAAM,YAAY,QAAQ,aAAa;EAEvC,IAAI,OAAO,WAAW,YAAY,SAAS,QAAQ;GACjD,KAAK,OAAO,WAAW;IACrB,KAAK,OAAO,MAAM;IAClB,GAAI,OAAO,SAAS,SAAY,CAAA,IAAK,EAAE,MAAM,OAAO,KAAI;IACxD;GACD,CAAA;GACD;EACF;EAEA,MAAM,KAAK,OAAO,WAAW,WAAW,KAAK,gBAAgB,MAAM,IAAI;EACvE,IAAI,CAAC,IAAI;EAET,MAAM,OAAO,GAAG,sBAAqB;EACrC,IAAI,cAAc,KAAK;GACrB,MAAM,MAAM,KAAK,MAAM,IAAI,UAAU;GACrC,KAAK,OAAO,WAAW;IAAE;IAAK;GAAQ,CAAE;EAC1C,OAAO;GACL,MAAM,MAAM;GACZ,MAAM,UAAU,IAAI,sBAAqB;GACzC,MAAM,MAAM,KAAK,MAAM,QAAQ,MAAM,IAAI,YAAY;GACrD,KAAK,OAAO,WAAW;IAAE;IAAK;GAAQ,CAAE;EAC1C;CACF;CAGA,SAAS,IAAa,UAA2B,CAAA,GAAE;EACjD,KAAK,GAAG,IAAI,OAAO;CACrB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A;EAAc,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAd,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAc,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,gBAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,yBAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA,EAAA,YAAA,EAAA,yBAAA,qCAAA,EAAA;EAAA,UAAA,CAAA,gBAAA;EAAA,UAAA;CAAA,CAAA;;AAAd,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAc,YAAA,CAAA;EAR1B,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;GACV,MAAM,EAEJ,2BAA2B,qCAC5B;EACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-scroll.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/scroll/wr-scroll.ts","../../../projects/lib/scroll/scroll-follow.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 { DOCUMENT } from '@angular/common';\nimport { Service, inject } from '@angular/core';\n\nimport { WrPlatform } from 'ngwr/platform';\n\nimport type { WrScrollOptions, WrScrollTarget } from './types';\n\n/**\n * Smooth-scroll utility. Resolves `id` / selector / element / coords\n * targets; subtracts an `offset` (for sticky headers); respects\n * `prefers-reduced-motion` — automatically falls back to instant\n * scrolling when the user has opted out.\n *\n * SSR-safe — all methods no-op on the server.\n *\n * @example\n * ```ts\n * const scroll = inject(WrScroll);\n * scroll.to('#section-three', { offset: 80 });\n * scroll.toTop({ smooth: false });\n * scroll.intoView(myEl, { offset: 64 });\n * ```\n *\n * @see https://ngwr.dev/reference/services/scroll\n */\n@Service()\nexport class WrScroll {\n private readonly doc = inject(DOCUMENT);\n private readonly platform = inject(WrPlatform);\n\n /** Scroll to an arbitrary target. */\n to(target: WrScrollTarget, options: WrScrollOptions = {}): void {\n if (!this.platform.isBrowser) return;\n const win = this.doc.defaultView;\n if (!win) return;\n\n const offset = options.offset ?? 0;\n const behavior = this.behavior(options.smooth);\n const container = options.container ?? win;\n\n if (typeof target === 'object' && 'top' in target) {\n this.scroll(container, {\n top: target.top - offset,\n ...(target.left === undefined ? {} : { left: target.left }),\n behavior,\n });\n return;\n }\n\n const el = typeof target === 'string' ? this.resolveSelector(target) : target;\n if (!el) return;\n\n const rect = el.getBoundingClientRect();\n if (container === win) {\n const top = rect.top + win.scrollY - offset;\n this.scroll(container, { top, behavior });\n } else {\n const ctx = container as Element;\n const ctxRect = ctx.getBoundingClientRect();\n const top = rect.top - ctxRect.top + ctx.scrollTop - offset;\n this.scroll(container, { top, behavior });\n }\n }\n\n /** Convenience for an element — accepts the same options. */\n intoView(el: Element, options: WrScrollOptions = {}): void {\n this.to(el, options);\n }\n\n /** Scroll the page (or container) to the top. */\n toTop(options: WrScrollOptions = {}): void {\n this.to({ top: 0 }, options);\n }\n\n // Internals\n\n private resolveSelector(value: string): Element | null {\n if (value.startsWith('#')) {\n return this.doc.getElementById(value.slice(1));\n }\n try {\n return this.doc.querySelector(value);\n } catch {\n return null;\n }\n }\n\n /** `instant`, not `auto`: `auto` follows the container's `scroll-behavior`, which may be smooth. */\n private behavior(requested: boolean | undefined): ScrollBehavior {\n if (requested === false) return 'instant';\n if (this.platform.prefersReducedMotion()) return 'instant';\n return 'smooth';\n }\n\n private scroll(container: Window | Element, options: ScrollToOptions): void {\n if (container instanceof Window) container.scrollTo(options);\n else container.scrollTo(options);\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 { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n type Signal,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n signal,\n untracked,\n} from '@angular/core';\n\nimport type { WrScrollOptions } from './types';\nimport { WrScroll } from './wr-scroll';\n\n/** A row the view is held to, and where its top edge sat under the container's. */\ninterface Anchor {\n readonly node: Element;\n readonly offset: number;\n}\n\n/** A wrapper around the rows is looked through this many levels deep. */\nconst WRAPPER_DEPTH = 3;\n\n/**\n * Keeps a scroll container at its end while content grows, and holds the\n * reader's place while they are somewhere else.\n *\n * The container starts at its end and stays there as rows are added, as a row\n * grows (streamed text, an image that loads) and as the container is resized.\n * Scrolling up stops the following at once; scrolling back to within\n * `wrScrollFollowThreshold` of the end resumes it. While it is not following,\n * the lowest row in view keeps its place when content above it changes, so\n * older rows loaded at the top do not push the page down.\n *\n * `following` says which of the two it is doing, for a \"jump to latest\" button,\n * and `toEnd()` is what that button calls.\n *\n * The rows are the container's children, or the children of its only child.\n * The container scrolls vertically in the normal direction: RTL changes\n * nothing, and a `column-reverse` container is not supported. Nothing runs on\n * the server.\n *\n * @example\n * ```html\n * <div class=\"log\" wrScrollFollow #log=\"wrScrollFollow\">\n * @for (message of messages(); track message.id) {\n * <p>{{ message.text }}</p>\n * }\n * </div>\n * @if (!log.following()) {\n * <button type=\"button\" (click)=\"log.toEnd()\">Jump to latest</button>\n * }\n * ```\n *\n * @see https://ngwr.dev/reference/services/scroll\n */\n@Directive({\n selector: '[wrScrollFollow]',\n exportAs: 'wrScrollFollow',\n host: {\n // The browser's own scroll anchoring would move the view a second time.\n '[style.overflow-anchor]': 'wrScrollFollow() ? \"none\" : null',\n },\n})\nexport class WrScrollFollow {\n /** `false` switches it off and hands scroll anchoring back to the browser. Bare `wrScrollFollow` is on. */\n readonly wrScrollFollow = input(true, { transform: coerceBooleanProperty });\n\n /** How close to the end, in pixels, the reader has to scroll back for the following to resume. */\n readonly wrScrollFollowThreshold = input(80, {\n transform: (value: unknown) => Math.max(0, coerceNumberProperty(value, 80)),\n });\n\n private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly scroll = inject(WrScroll);\n\n private readonly atEnd = signal(true);\n\n /** Whether the container is held at its end. `false` once the reader scrolls up, and while switched off. */\n readonly following: Signal<boolean> = computed(() => this.wrScrollFollow() && this.atEnd());\n\n private started = false;\n private lastTop = 0;\n private anchors: Anchor[] = [];\n /** `scrollTop` when `anchors` was measured, so a scroll since then is not undone. */\n private anchorsTop = 0;\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n\n afterNextRender(() => {\n const host = this.el.nativeElement;\n const onScroll = (): void => this.onScroll();\n const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => this.sync());\n const mutation = new MutationObserver(records => {\n for (const record of records) {\n if (record.target !== host) continue;\n for (const node of record.addedNodes) if (node instanceof Element) resize?.observe(node);\n for (const node of record.removedNodes) if (node instanceof Element) resize?.unobserve(node);\n }\n this.sync();\n });\n\n host.addEventListener('scroll', onScroll, { passive: true });\n // The host for its own height, its children for growth no mutation reports (an image, a font).\n resize?.observe(host);\n for (const child of host.children) resize?.observe(child);\n mutation.observe(host, { childList: true, characterData: true, subtree: true });\n\n this.started = true;\n this.sync();\n\n destroyRef.onDestroy(() => {\n host.removeEventListener('scroll', onScroll);\n resize?.disconnect();\n mutation.disconnect();\n });\n });\n\n effect(() => {\n const on = this.wrScrollFollow();\n if (!this.started) return;\n untracked(() => {\n if (on) this.atEnd.set(this.distance() <= this.wrScrollFollowThreshold());\n this.sync();\n });\n });\n }\n\n /**\n * Scroll to the end and follow again. Smooth unless `smooth` is `false` or\n * the reader prefers reduced motion.\n */\n toEnd(options: Pick<WrScrollOptions, 'smooth'> = {}): void {\n if (!this.started) return;\n const host = this.el.nativeElement;\n this.atEnd.set(true);\n this.anchors = [];\n this.scroll.to({ top: host.scrollHeight }, { ...options, container: host });\n }\n\n private distance(): number {\n const host = this.el.nativeElement;\n return host.scrollHeight - host.scrollTop - host.clientHeight;\n }\n\n private onScroll(): void {\n this.read(true);\n if (this.following()) {\n this.anchors = [];\n return;\n }\n if (!this.wrScrollFollow()) return;\n // A row above may have changed size with its resize callback still to come\n // (scroll events run first): correct for it before the anchor is replaced.\n this.restore();\n this.lastTop = this.el.nativeElement.scrollTop;\n this.capture();\n }\n\n /**\n * Any move up stops the following, so a reader can leave while text streams\n * in; one that lands within a pixel of the end is the browser clamping to\n * shorter content, and it follows again, since nothing is left to scroll back\n * to. Only a move down resumes it: the directive's own writes are never read as one.\n */\n private read(scrolled: boolean): void {\n const top = this.el.nativeElement.scrollTop;\n const distance = this.distance();\n\n if (top < this.lastTop) this.atEnd.set(distance <= 1);\n else if (scrolled && top > this.lastTop && distance <= this.wrScrollFollowThreshold()) this.atEnd.set(true);\n\n this.lastTop = top;\n }\n\n /** Content or the container changed size: hold the end, or hold the reader's place. */\n private sync(): void {\n const host = this.el.nativeElement;\n // A scroll whose event is still on its way must not be pinned over, and a\n // move down into the threshold resumes following here, before `lastTop`\n // moves past it and the scroll event finds nothing to read.\n this.read(true);\n\n if (!this.wrScrollFollow()) {\n this.anchors = [];\n return;\n }\n\n if (this.atEnd()) {\n this.move(host.scrollHeight);\n this.anchors = [];\n } else {\n this.restore();\n this.capture();\n }\n this.lastTop = host.scrollTop;\n }\n\n /** Instant whatever `scroll-behavior` the container has: an animated correction is a visible jump. */\n private move(top: number): void {\n this.el.nativeElement.scrollTo({ top, behavior: 'instant' });\n }\n\n /** Remember the lowest row in view. A row at the top would be the \"load older\" button. */\n private capture(): void {\n const host = this.el.nativeElement;\n const box = host.getBoundingClientRect();\n const anchors: Anchor[] = [];\n\n let parent: Element = host;\n for (let depth = 0; depth < WRAPPER_DEPTH; depth++) {\n const found = this.lowestInView(parent, box);\n if (!found) break;\n anchors.push(found.anchor);\n // An only child is a wrapper, and its top does not move when rows are added inside it.\n if (found.others) break;\n parent = found.anchor.node;\n }\n\n this.anchors = anchors;\n this.anchorsTop = host.scrollTop;\n }\n\n /**\n * The last child of `parent` that starts above the bottom of `box`, found by\n * bisection: rows stack top to bottom, so only the ones around the view are\n * measured, not every row below it. A child without a box (`display: none`,\n * `display: contents`) has nothing to hold on to and is stepped over.\n * `others` is whether `parent` has a second child with a box.\n */\n private lowestInView(parent: Element, box: DOMRect): { anchor: Anchor; others: boolean } | null {\n const children = parent.children;\n const sized = (index: number): DOMRect | null => {\n const rect = children[index].getBoundingClientRect();\n return rect.width || rect.height ? rect : null;\n };\n\n let found = -1;\n let foundRect: DOMRect | null = null;\n let low = 0;\n let high = children.length - 1;\n while (low <= high) {\n const mid = Math.floor((low + high) / 2);\n let probe = mid;\n let rect = sized(probe);\n while (!rect && probe > low) rect = sized(--probe);\n if (!rect) {\n low = mid + 1;\n } else if (rect.top < box.bottom) {\n found = probe;\n foundRect = rect;\n low = mid + 1;\n } else {\n high = probe - 1;\n }\n }\n if (!foundRect) return null;\n\n let others = false;\n for (let i = found - 1; i >= 0 && !others; i--) others = sized(i) !== null;\n for (let i = found + 1; i < children.length && !others; i++) others = sized(i) !== null;\n return { anchor: { node: children[found], offset: foundRect.top - box.top }, others };\n }\n\n /** Put the remembered row back where it was. */\n private restore(): void {\n const host = this.el.nativeElement;\n const scrolledSince = host.scrollTop - this.anchorsTop;\n\n for (let i = this.anchors.length - 1; i >= 0; i--) {\n const { node, offset } = this.anchors[i];\n if (!host.contains(node)) continue;\n const rect = node.getBoundingClientRect();\n if (!rect.width && !rect.height) continue;\n\n const delta = rect.top - host.getBoundingClientRect().top - (offset - scrolledSince);\n if (Math.abs(delta) >= 1) this.move(host.scrollTop + delta);\n return;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAiCA,IAAa,WAAb,MAAa,SAAQ;CACF,MAAM,OAAOA,UAAQ;CACrB,WAAW,OAAO,UAAU;CAG7C,GAAG,QAAwB,UAA2B,CAAA,GAAE;EACtD,IAAI,CAAC,KAAK,SAAS,WAAW;EAC9B,MAAM,MAAM,KAAK,IAAI;EACrB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KAAK,sBAAqB,CAAE,CAAC,OAAO,SAAS;GACtE,IAAI,KAAK,IAAI,KAAK,KAAK,GAAG,KAAK,KAAK,KAAK,YAAY,KAAK;GAC1D;EACF;CACF;CAxNW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAc,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAd,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAc,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,gBAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,yBAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA,EAAA,YAAA,EAAA,yBAAA,qCAAA,EAAA;EAAA,UAAA,CAAA,gBAAA;EAAA,UAAA;CAAA,CAAA;;AAAd,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAc,YAAA,CAAA;EAR1B,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;GACV,MAAM,EAEJ,2BAA2B,qCAC5B;EACF,CAAA"}
|
package/fesm2022/ngwr-table.mjs
CHANGED
|
@@ -1063,6 +1063,7 @@ var WrTable = class WrTable {
|
|
|
1063
1063
|
}
|
|
1064
1064
|
rowLink = input(null, ...ngDevMode ? [{ debugName: "rowLink" }] : /* istanbul ignore next */ []);
|
|
1065
1065
|
routing = inject(WR_TABLE_ROUTING, { optional: true });
|
|
1066
|
+
warnedNoRouting = false;
|
|
1066
1067
|
rowLinks = computed(() => {
|
|
1067
1068
|
const links = /* @__PURE__ */ new Map();
|
|
1068
1069
|
const rowLink = this.rowLink();
|
|
@@ -1079,7 +1080,10 @@ var WrTable = class WrTable {
|
|
|
1079
1080
|
href: routing.href(link),
|
|
1080
1081
|
routed: link
|
|
1081
1082
|
});
|
|
1082
|
-
else if (typeof ngDevMode === "undefined" || ngDevMode)
|
|
1083
|
+
else if (!this.warnedNoRouting && (typeof ngDevMode === "undefined" || ngDevMode)) {
|
|
1084
|
+
this.warnedNoRouting = true;
|
|
1085
|
+
console.error("[NGWR] <wr-table>: `rowLink` returned router commands, but no routing adapter is provided. Add `WrTableRouting` from `ngwr/table/router` to the table, or return an href string.");
|
|
1086
|
+
}
|
|
1083
1087
|
}
|
|
1084
1088
|
return links;
|
|
1085
1089
|
}, ...ngDevMode ? [{ debugName: "rowLinks" }] : /* istanbul ignore next */ []);
|
|
@@ -2075,7 +2079,16 @@ var WrTable = class WrTable {
|
|
|
2075
2079
|
break;
|
|
2076
2080
|
}
|
|
2077
2081
|
break;
|
|
2078
|
-
case WR_KEYS.ENTER:
|
|
2082
|
+
case WR_KEYS.ENTER: {
|
|
2083
|
+
const anchor = this.rowLinks().has(entry.row) ? els[index].nativeElement.querySelector(":scope > td > .wr-table__row-link") : null;
|
|
2084
|
+
if (anchor) {
|
|
2085
|
+
anchor.click();
|
|
2086
|
+
break;
|
|
2087
|
+
}
|
|
2088
|
+
if (!this.rowSelection()) return;
|
|
2089
|
+
this.toggleRow(entry.row, !this.isRowSelected(entry.row));
|
|
2090
|
+
break;
|
|
2091
|
+
}
|
|
2079
2092
|
case WR_KEYS.SPACE:
|
|
2080
2093
|
if (!this.rowSelection()) return;
|
|
2081
2094
|
this.toggleRow(entry.row, !this.isRowSelected(entry.row));
|
|
@@ -3034,7 +3047,7 @@ var WrTable = class WrTable {
|
|
|
3034
3047
|
}
|
|
3035
3048
|
],
|
|
3036
3049
|
ngImport: i0,
|
|
3037
|
-
template: "@switch (loadingForm()) {\n @case ('overlay') {\n <div class=\"wr-table__loading\" role=\"status\">\n <span class=\"wr-table__sr-only\">{{ resolvedLoadingLabel() }}</span>\n <wr-spinner size=\"lg\" />\n </div>\n }\n @case ('bar') {\n <div class=\"wr-table__loading-bar\" role=\"status\">\n <span class=\"wr-table__sr-only\">{{ resolvedLoadingLabel() }}</span>\n </div>\n }\n}\n\n@if (columnChooser()) {\n <div class=\"wr-table__toolbar\">\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-table__columns-btn\"\n position=\"bottom-end\"\n [wrPopover]=\"chooser\"\n [ariaLabel]=\"resolvedColumnsLabel()\"\n >\n {{ resolvedColumnsLabel() }}\n </button>\n <ng-template #chooser>\n <div class=\"wr-table__columns\">\n <wr-table-column-chooser [table]=\"this\" [ariaLabel]=\"resolvedColumnsLabel()\" />\n </div>\n </ng-template>\n </div>\n}\n\n<!-- The selection bar lies over the header: a box of no height in front of\n the scroll area, so the bar stays put while the columns scroll under it.\n The count is announced from a region that is in the DOM before it has\n anything to say, and the drawn copy is hidden from it. -->\n@if (hasSelectionBar()) {\n <div class=\"wr-table__selection\">\n <span class=\"wr-table__selection-status\" role=\"status\">{{ selectionBar() ? selectionCountText() : '' }}</span>\n @if (selectionBar(); as tpl) {\n <div\n #selectionBarEl\n class=\"wr-table__selection-bar\"\n [class.wr-table__selection-bar--inset]=\"rowSelection() === 'multiple'\"\n [style.--wr-table-selection-bar-height.px]=\"selectionBarHeight()\"\n >\n <span class=\"wr-table__selection-count\" aria-hidden=\"true\">{{ selectionCountText() }}</span>\n <button wr-btn type=\"button\" size=\"sm\" class=\"wr-table__selection-clear\" (click)=\"clearSelection()\">\n {{ resolvedClearSelectionLabel() }}\n </button>\n <div class=\"wr-table__selection-actions\">\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"selectionContext()\" />\n </div>\n </div>\n }\n </div>\n}\n\n<!-- With a selection bar the scroll area takes focus from script, for the bar\n to hand it to when it leaves a table that has no checkbox to take it. -->\n<div\n class=\"wr-table__scroll\"\n #scroll\n [style.--wr-table-scroll-height]=\"scrollHeight()\"\n [style.--wr-table-head-height.px]=\"stickyEdges().head\"\n [style.--wr-table-foot-height.px]=\"stickyEdges().foot\"\n [attr.tabindex]=\"scrollable() ? 0 : hasSelectionBar() ? -1 : null\"\n>\n <table\n class=\"wr-table__table\"\n [class.wr-table__table--fixed]=\"clippedLayout()\"\n [class.wr-table__table--layout-fixed]=\"layout() === 'fixed'\"\n [style.--wr-table-row-h.px]=\"rowHeightVar()\"\n [attr.aria-rowcount]=\"virtualized() ? renderRows().length + 1 + (hasSummary() && items()?.length ? 1 : 0) : null\"\n [attr.role]=\"treeMode() ? 'treegrid' : editGrid() ? 'grid' : null\"\n [attr.aria-multiselectable]=\"treeMode() && rowSelection() === 'multiple' ? true : null\"\n >\n <colgroup>\n @if (rowSelection()) {\n <col class=\"wr-table__col--lead\" />\n }\n @if (expandable()) {\n <col class=\"wr-table__col--lead\" />\n }\n @for (col of cellColumns(); track col.key) {\n <col [style.width.px]=\"col.width\" />\n }\n </colgroup>\n <thead #head>\n <tr\n cdkDropList\n cdkDropListOrientation=\"horizontal\"\n [cdkDropListSortPredicate]=\"sortPredicate\"\n (cdkDropListDropped)=\"onColumnDrop($event)\"\n (cdkDropListSorted)=\"onColumnListSorted($event)\"\n (cdkDropListEntered)=\"onColumnListEntered()\"\n (cdkDropListExited)=\"onColumnListExited()\"\n >\n @if (rowSelection()) {\n <th class=\"wr-table__th wr-table__th--select\">\n @if (rowSelection() === 'multiple') {\n <!-- Disabled with nothing to sweep, the way `wr-transfer` guards its\n own select-all. `[checked]` is a one-way binding over a checkbox\n that owns its state, and on zero rows `allSelected()` answers\n `false` before and after the click — an unchanged input is never\n written back, so the box latched CHECKED over an empty table and\n stayed that way when rows returned. -->\n <wr-checkbox\n size=\"sm\"\n [checked]=\"allSelected()\"\n [indeterminate]=\"someSelected()\"\n [disabled]=\"selectAllKeys().size === 0\"\n (checkedChange)=\"toggleAll($event)\"\n [ariaLabel]=\"resolvedSelectAllLabel()\"\n />\n }\n </th>\n }\n @if (expandable()) {\n <th class=\"wr-table__th wr-table__th--expand\"></th>\n }\n <!-- `inert` under the selection bar: a control the bar covers takes no\n focus and no click. The select-all cell stays out from under it. -->\n @for (col of cellColumns(); track col.key) {\n <!-- The click is a pointer shortcut for the sort button, which stays\n the one control and the keyboard path. -->\n <th\n #thCell\n (click)=\"onHeaderClick($event, col.key, col.column.sortable)\"\n cdkDrag\n [attr.inert]=\"selectionBar() ? '' : null\"\n [cdkDragDisabled]=\"!reorderable() || col.pinned\"\n (cdkDragStarted)=\"onColumnDragStart($event)\"\n (cdkDragMoved)=\"onColumnDragMoved($event)\"\n (cdkDragEnded)=\"onColumnDragEnd()\"\n [class]=\"col.thClass\"\n [attr.aria-sort]=\"ariaSortFor(col.key, col.column.sortable)\"\n [attr.aria-label]=\"col.column.title ? null : (col.column.headerHint ?? null)\"\n [class.wr-table__th--sortable]=\"col.column.sortable\"\n [class.wr-table__th--draggable]=\"reorderable() && !col.pinned\"\n [class.wr-table__th--pin-left]=\"col.pinLeft\"\n [class.wr-table__th--pin-right]=\"col.pinRight\"\n [class.wr-table__th--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__th--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n <div class=\"wr-table__th-inner\">\n <span class=\"wr-table__title\">{{ col.column.title }}</span>\n\n @if (col.column.sortable) {\n <button\n type=\"button\"\n class=\"wr-table__sort-btn\"\n [attr.aria-label]=\"sortLabelFor(headerName(col.column))\"\n (click)=\"cycleSort(col.key)\"\n >\n <wr-table-sort [direction]=\"directionFor(col.key)\" />\n </button>\n <!-- A column's place in a multi-column sort. Drawn, because only the\n primary key announces `aria-sort` (see ariaSortFor). Beside the\n button rather than in it: inside, the digit is visible text the\n button's name (\"Sort Role\") does not contain, which is a WCAG\n 2.5.3 label-in-name failure. Hidden, so the column header's own\n name stays its title. -->\n @if (sortOrderFor(col.key); as order) {\n <span class=\"wr-table__sort-order\" aria-hidden=\"true\">{{ order }}</span>\n }\n }\n\n @if (col.column.filterItems; as filterItems) {\n @if (filterItems.length) {\n <wr-table-filter\n [items]=\"filterItems\"\n [column]=\"headerName(col.column)\"\n (selectionChange)=\"onFilter(col.key, $event)\"\n />\n }\n }\n </div>\n\n @if (col.column.resizable) {\n <span\n class=\"wr-table__resize-handle\"\n aria-hidden=\"true\"\n (pointerdown)=\"onResizeStart($event, col.key, thCell)\"\n (pointermove)=\"onResizeMove($event)\"\n (pointerup)=\"onResizeEnd($event)\"\n (pointercancel)=\"onResizeEnd($event)\"\n (mousedown)=\"$event.stopPropagation()\"\n (touchstart)=\"$event.stopPropagation()\"\n ></span>\n }\n </th>\n }\n </tr>\n </thead>\n\n <!-- One delegated listener for `rowClick`, which is pointer only by contract:\n the body is no control, and a row's keyboard path is the consumer's own\n button or link in a cell, or the row's own link under `rowLink`. The\n other three serve inline editing and return at once in a table with\n no edit template. -->\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <tbody\n (click)=\"onBodyClick($event)\"\n (dblclick)=\"onCellDblclick($event)\"\n (keydown)=\"onCellKeydown($event)\"\n (focusin)=\"onCellFocusin($event)\"\n >\n @if (visibleItems()) {\n @if (virtualized() && virtualWindow().padTop > 0) {\n <tr class=\"wr-table__spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"totalCols()\" [style.height.px]=\"virtualWindow().padTop\"></td>\n </tr>\n }\n @let edit = editing();\n @let links = rowLinks();\n @for (entry of windowRows(); track entry.id; let i = $index) {\n @if (entry.kind === 'group') {\n <tr class=\"wr-table__group-row\" [class.wr-table__group-row--collapsed]=\"entry.group.collapsed\">\n <td class=\"wr-table__group-cell\" [attr.colspan]=\"totalCols()\">\n <!-- The cell spans the full table width; this inner box is what sticks. -->\n <div class=\"wr-table__group-inner\">\n @if (rowSelection() === 'multiple') {\n <wr-checkbox\n class=\"wr-table__group-select\"\n size=\"sm\"\n [checked]=\"groupChecked(entry.group.rows)\"\n [indeterminate]=\"groupIndeterminate(entry.group.rows)\"\n (checkedChange)=\"toggleGroupSelection(entry.group.rows, $event)\"\n [ariaLabelledby]=\"groupControlLabelledby('select-group', entry.id)\"\n />\n }\n @if (groupTemplate(); as tpl) {\n <button\n type=\"button\"\n class=\"wr-table__group-toggle wr-table__group-toggle--icon\"\n [attr.aria-expanded]=\"!entry.group.collapsed\"\n [attr.aria-labelledby]=\"groupControlLabelledby('toggle-group', entry.id)\"\n (click)=\"toggleGroupCollapse(entry.group.value)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__group-icon\"\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 </button>\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"entry.group\" />\n <!-- The group's name for the two controls above. A custom header\n is the consumer's markup, with nothing in it to point at. -->\n <span hidden [id]=\"groupLabelId(entry.id)\">{{ entry.group.label }}</span>\n } @else {\n <button\n type=\"button\"\n class=\"wr-table__group-toggle\"\n [attr.aria-expanded]=\"!entry.group.collapsed\"\n [attr.aria-labelledby]=\"groupToggleLabelledby(entry.id)\"\n (click)=\"toggleGroupCollapse(entry.group.value)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__group-icon\"\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 <span class=\"wr-table__group-label\" [id]=\"groupLabelId(entry.id)\">{{ entry.group.label }}</span>\n @if (showGroupCount()) {\n <!-- A real space between the label and the count. Whitespace\n alone draws nothing in a flex row, and without it the\n button's text reads \"admin2\" — which the name\n \"Toggle group admin 2\" does not contain, a label-in-name\n mismatch for any tool that compares the two. -->\n &ngsp;<span class=\"wr-table__group-count\" [id]=\"groupCountId(entry.id)\">{{\n entry.group.count\n }}</span>\n }\n </button>\n }\n </div>\n </td>\n </tr>\n } @else if (entry.kind === 'group-foot') {\n <tr class=\"wr-table__group-foot-row\">\n @if (rowSelection()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @if (expandable()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @for (col of cellColumns(); track col.key) {\n <td\n [class]=\"col.footClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n {{ entry.summaries.get(col.key) ?? '' }}\n </td>\n }\n </tr>\n } @else {\n @let link = links.get(entry.row) ?? null;\n <tr\n #rowEl\n [class]=\"rowClasses(entry.row, i, link !== null)\"\n [class.wr-table__tr--selected]=\"rowSelection() && isRowSelected(entry.row)\"\n [class.wr-table__tr--child]=\"entry.depth > 0\"\n [attr.aria-rowindex]=\"virtualized() ? windowStart() + i + 2 : null\"\n [attr.aria-level]=\"treeMode() ? entry.depth + 1 : null\"\n [attr.aria-posinset]=\"treeMode() ? entry.posinset : null\"\n [attr.aria-setsize]=\"treeMode() ? entry.setsize : null\"\n [attr.aria-expanded]=\"entry.open\"\n [attr.aria-selected]=\"treeMode() && rowSelection() ? isRowSelected(entry.row) : null\"\n [attr.tabindex]=\"treeMode() ? (entry.id === tabStopRowId() ? 0 : -1) : null\"\n [style.--wr-table-depth]=\"treeMode() ? entry.depth : null\"\n >\n @if (rowSelection()) {\n <td class=\"wr-table__td wr-table__td--select\">\n <wr-checkbox\n size=\"sm\"\n [checked]=\"isRowSelected(entry.row)\"\n (checkedChange)=\"toggleRow(entry.row, $event)\"\n [ariaLabelledby]=\"rowControlLabelledby('select-row', entry.id)\"\n />\n </td>\n }\n @if (expandable()) {\n <td class=\"wr-table__td wr-table__td--expand\">\n <button\n type=\"button\"\n class=\"wr-table__expand-btn\"\n [class.wr-table__expand-btn--open]=\"isExpanded(entry.row)\"\n [attr.aria-expanded]=\"isExpanded(entry.row)\"\n [attr.aria-labelledby]=\"rowControlLabelledby('expand-row', entry.id)\"\n (click)=\"toggleExpand(entry.row)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__expand-icon\"\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 </button>\n </td>\n }\n @for (col of cellColumns(); track col.key) {\n @let cellEdit = edit !== null && edit.row === entry.row && edit.key === col.key ? edit : null;\n <td\n [class]=\"col.tdClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n [style.max-width.px]=\"col.maxWidth\"\n [attr.data-label]=\"col.column.title\"\n [attr.id]=\"col.label ? rowLabelId(entry.id) : null\"\n [attr.tabindex]=\"editGrid() ? cellTabindex(entry, col) : null\"\n [class.wr-table__td--editable]=\"col.editTemplate ? cellEditable(entry.row, col) : false\"\n [class.wr-table__td--editing]=\"cellEdit !== null\"\n >\n <!-- Empty, and laid under the whole row by the stylesheet: the\n cell's content is the consumer's and may hold controls,\n which an anchor cannot wrap. Gone while its cell is edited,\n where the editor is sized as the cell's only child. -->\n @if (link && col.link && !cellEdit) {\n <!-- eslint-disable-next-line @angular-eslint/template/elements-content -->\n <a\n class=\"wr-table__row-link\"\n [attr.href]=\"link.href\"\n [attr.aria-labelledby]=\"rowLabelId(entry.id)\"\n ></a>\n }\n @if (col.tree) {\n <span class=\"wr-table__tree-lead\">\n @if (entry.parent) {\n <button\n type=\"button\"\n class=\"wr-table__tree-toggle\"\n [class.wr-table__tree-toggle--open]=\"entry.open\"\n [attr.aria-expanded]=\"entry.open\"\n [attr.aria-labelledby]=\"rowControlLabelledby('toggle-row', entry.id)\"\n (click)=\"toggleTreeRow(entry.row)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__tree-icon\"\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 </button>\n } @else {\n <span class=\"wr-table__tree-toggle wr-table__tree-toggle--leaf\" aria-hidden=\"true\"></span>\n }\n </span>\n }\n @if (cellEdit) {\n <ng-container\n [ngTemplateOutlet]=\"col.editTemplate ?? null\"\n [ngTemplateOutletContext]=\"cellEdit.context\"\n />\n } @else if (col.template; as tpl) {\n @if (col.actions) {\n <div class=\"wr-table__actions\">\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"cellContext(entry.row, col)\"\n />\n </div>\n } @else {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"cellContext(entry.row, col)\" />\n }\n } @else {\n {{ cellText(entry.row, col.key, col.column) }}\n }\n </td>\n }\n </tr>\n @if (expandable() && isExpanded(entry.row)) {\n <tr class=\"wr-table__detail-row\">\n <td class=\"wr-table__detail\" [attr.colspan]=\"totalCols()\">\n <ng-container\n [ngTemplateOutlet]=\"expandTemplate() ?? null\"\n [ngTemplateOutletContext]=\"expandContext(entry.row)\"\n />\n </td>\n </tr>\n }\n }\n }\n @if (virtualized() && virtualWindow().padBottom > 0) {\n <tr class=\"wr-table__spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"totalCols()\" [style.height.px]=\"virtualWindow().padBottom\"></td>\n </tr>\n }\n }\n <!-- Sibling of the row loop rather than its `@empty` branch, and gated on\n `loading()`. As the `@empty` branch it lived INSIDE `@if (visibleItems())`,\n which passes a nullish `[items]` straight through — so the input's own\n default rendered a header over a blank body with no \"No data\" anywhere,\n the opposite of what `items`'s docs promise. And the veil is translucent,\n so on the documented `[items]=\"[]\" [loading]=\"true\"` pair the row read\n \"No data\" through the spinner. -->\n @if (!loading() && !renderRows().length) {\n <tr>\n <td class=\"wr-table__empty\" [attr.colspan]=\"totalCols()\">{{ resolvedEmptyLabel() }}</td>\n </tr>\n }\n </tbody>\n\n @if (hasSummary() && items()?.length) {\n <tfoot #foot>\n <tr class=\"wr-table__foot-row\">\n @if (rowSelection()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @if (expandable()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @for (col of cellColumns(); track col.key) {\n <td\n [class]=\"col.footClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n {{ summaryFor(col.key) }}\n </td>\n }\n </tr>\n </tfoot>\n }\n </table>\n</div>\n\n@if (showPager()) {\n <div class=\"wr-table__pager\">\n <wr-pagination\n [page]=\"page()\"\n (pageChange)=\"onPagerPage($event)\"\n [pageSize]=\"currentPageSize()\"\n (pageSizeChange)=\"onPageSizeChange($event)\"\n [total]=\"resolvedTotal()\"\n [size]=\"paginationSize()\"\n [showSizeChanger]=\"pageSizeOptions().length > 0\"\n [pageSizeOptions]=\"pageSizeOptions()\"\n />\n </div>\n}\n\n<!-- The table's one tooltip, for a header hint or a cut cell (see `tip`). -->\n@if (tip(); as shown) {\n <span hidden [wrPopover]=\"shown.text\" mode=\"tooltip\" [wrPopoverOrigin]=\"shown.el\"></span>\n}\n\n<!-- The action words the row and group controls are named with, once per table.\n `aria-labelledby` reads a hidden element it points at, so each control joins\n one of these to its own row's (or group's) label. Only the words a control\n in this table uses are rendered. -->\n@if (rowSelection() || expandable() || treeMode() || groupBy() !== null) {\n <div hidden>\n @if (rowSelection()) {\n <span [id]=\"actionId('select-row')\">{{ resolvedSelectRowLabel() }}</span>\n }\n @if (expandable()) {\n <span [id]=\"actionId('expand-row')\">{{ resolvedExpandRowLabel() }}</span>\n }\n @if (treeMode()) {\n <span [id]=\"actionId('toggle-row')\">{{ resolvedToggleRowLabel() }}</span>\n }\n @if (groupBy() !== null) {\n @if (rowSelection() === 'multiple') {\n <span [id]=\"actionId('select-group')\">{{ resolvedSelectGroupLabel() }}</span>\n }\n <span [id]=\"actionId('toggle-group')\">{{ resolvedToggleGroupLabel() }}</span>\n }\n </div>\n}\n",
|
|
3050
|
+
template: "@switch (loadingForm()) {\n @case ('overlay') {\n <div class=\"wr-table__loading\" role=\"status\">\n <span class=\"wr-table__sr-only\">{{ resolvedLoadingLabel() }}</span>\n <wr-spinner size=\"lg\" />\n </div>\n }\n @case ('bar') {\n <div class=\"wr-table__loading-bar\" role=\"status\">\n <span class=\"wr-table__sr-only\">{{ resolvedLoadingLabel() }}</span>\n </div>\n }\n}\n\n@if (columnChooser()) {\n <div class=\"wr-table__toolbar\">\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-table__columns-btn\"\n position=\"bottom-end\"\n [wrPopover]=\"chooser\"\n [ariaLabel]=\"resolvedColumnsLabel()\"\n >\n {{ resolvedColumnsLabel() }}\n </button>\n <ng-template #chooser>\n <div class=\"wr-table__columns\">\n <wr-table-column-chooser [table]=\"this\" [ariaLabel]=\"resolvedColumnsLabel()\" />\n </div>\n </ng-template>\n </div>\n}\n\n<!-- The selection bar lies over the header: a box of no height in front of\n the scroll area, so the bar stays put while the columns scroll under it.\n The count is announced from a region that is in the DOM before it has\n anything to say, and the drawn copy is hidden from it. -->\n@if (hasSelectionBar()) {\n <div class=\"wr-table__selection\">\n <span class=\"wr-table__selection-status\" role=\"status\">{{ selectionBar() ? selectionCountText() : '' }}</span>\n @if (selectionBar(); as tpl) {\n <div\n #selectionBarEl\n class=\"wr-table__selection-bar\"\n [class.wr-table__selection-bar--inset]=\"rowSelection() === 'multiple'\"\n [style.--wr-table-selection-bar-height.px]=\"selectionBarHeight()\"\n >\n <span class=\"wr-table__selection-count\" aria-hidden=\"true\">{{ selectionCountText() }}</span>\n <button wr-btn type=\"button\" size=\"sm\" class=\"wr-table__selection-clear\" (click)=\"clearSelection()\">\n {{ resolvedClearSelectionLabel() }}\n </button>\n <div class=\"wr-table__selection-actions\">\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"selectionContext()\" />\n </div>\n </div>\n }\n </div>\n}\n\n<!-- With a selection bar the scroll area takes focus from script, for the bar\n to hand it to when it leaves a table that has no checkbox to take it. -->\n<div\n class=\"wr-table__scroll\"\n #scroll\n [style.--wr-table-scroll-height]=\"scrollHeight()\"\n [style.--wr-table-head-height.px]=\"stickyEdges().head\"\n [style.--wr-table-foot-height.px]=\"stickyEdges().foot\"\n [attr.tabindex]=\"scrollable() ? 0 : hasSelectionBar() ? -1 : null\"\n>\n <table\n class=\"wr-table__table\"\n [class.wr-table__table--fixed]=\"clippedLayout()\"\n [class.wr-table__table--layout-fixed]=\"layout() === 'fixed'\"\n [style.--wr-table-row-h.px]=\"rowHeightVar()\"\n [attr.aria-rowcount]=\"virtualized() ? renderRows().length + 1 + (hasSummary() && items()?.length ? 1 : 0) : null\"\n [attr.role]=\"treeMode() ? 'treegrid' : editGrid() ? 'grid' : null\"\n [attr.aria-multiselectable]=\"treeMode() && rowSelection() === 'multiple' ? true : null\"\n >\n <colgroup>\n @if (rowSelection()) {\n <col class=\"wr-table__col--lead\" />\n }\n @if (expandable()) {\n <col class=\"wr-table__col--lead\" />\n }\n @for (col of cellColumns(); track col.key) {\n <col [style.width.px]=\"col.width\" />\n }\n </colgroup>\n <thead #head>\n <tr\n cdkDropList\n cdkDropListOrientation=\"horizontal\"\n [cdkDropListSortPredicate]=\"sortPredicate\"\n (cdkDropListDropped)=\"onColumnDrop($event)\"\n (cdkDropListSorted)=\"onColumnListSorted($event)\"\n (cdkDropListEntered)=\"onColumnListEntered()\"\n (cdkDropListExited)=\"onColumnListExited()\"\n >\n @if (rowSelection()) {\n <th class=\"wr-table__th wr-table__th--select\">\n @if (rowSelection() === 'multiple') {\n <!-- Disabled with nothing to sweep, the way `wr-transfer` guards its\n own select-all. `[checked]` is a one-way binding over a checkbox\n that owns its state, and on zero rows `allSelected()` answers\n `false` before and after the click — an unchanged input is never\n written back, so the box latched CHECKED over an empty table and\n stayed that way when rows returned. -->\n <wr-checkbox\n size=\"sm\"\n [checked]=\"allSelected()\"\n [indeterminate]=\"someSelected()\"\n [disabled]=\"selectAllKeys().size === 0\"\n (checkedChange)=\"toggleAll($event)\"\n [ariaLabel]=\"resolvedSelectAllLabel()\"\n />\n }\n </th>\n }\n @if (expandable()) {\n <th class=\"wr-table__th wr-table__th--expand\"></th>\n }\n <!-- `inert` under the selection bar: a control the bar covers takes no\n focus and no click. The select-all cell stays out from under it. -->\n @for (col of cellColumns(); track col.key) {\n <!-- The click is a pointer shortcut for the sort button, which stays\n the one control and the keyboard path. -->\n <th\n #thCell\n (click)=\"onHeaderClick($event, col.key, col.column.sortable)\"\n cdkDrag\n [cdkDragPreviewClass]=\"size() === 'sm' ? 'wr-table__th--preview-sm' : ''\"\n [attr.inert]=\"selectionBar() ? '' : null\"\n [cdkDragDisabled]=\"!reorderable() || col.pinned\"\n (cdkDragStarted)=\"onColumnDragStart($event)\"\n (cdkDragMoved)=\"onColumnDragMoved($event)\"\n (cdkDragEnded)=\"onColumnDragEnd()\"\n [class]=\"col.thClass\"\n [attr.aria-sort]=\"ariaSortFor(col.key, col.column.sortable)\"\n [attr.aria-label]=\"col.column.title ? null : (col.column.headerHint ?? null)\"\n [class.wr-table__th--sortable]=\"col.column.sortable\"\n [class.wr-table__th--draggable]=\"reorderable() && !col.pinned\"\n [class.wr-table__th--pin-left]=\"col.pinLeft\"\n [class.wr-table__th--pin-right]=\"col.pinRight\"\n [class.wr-table__th--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__th--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n <div class=\"wr-table__th-inner\">\n <span class=\"wr-table__title\">{{ col.column.title }}</span>\n\n @if (col.column.sortable) {\n <button\n type=\"button\"\n class=\"wr-table__sort-btn\"\n [attr.aria-label]=\"sortLabelFor(headerName(col.column))\"\n (click)=\"cycleSort(col.key)\"\n >\n <wr-table-sort [direction]=\"directionFor(col.key)\" />\n </button>\n <!-- A column's place in a multi-column sort. Drawn, because only the\n primary key announces `aria-sort` (see ariaSortFor). Beside the\n button rather than in it: inside, the digit is visible text the\n button's name (\"Sort Role\") does not contain, which is a WCAG\n 2.5.3 label-in-name failure. Hidden, so the column header's own\n name stays its title. -->\n @if (sortOrderFor(col.key); as order) {\n <span class=\"wr-table__sort-order\" aria-hidden=\"true\">{{ order }}</span>\n }\n }\n\n @if (col.column.filterItems; as filterItems) {\n @if (filterItems.length) {\n <wr-table-filter\n [items]=\"filterItems\"\n [column]=\"headerName(col.column)\"\n (selectionChange)=\"onFilter(col.key, $event)\"\n />\n }\n }\n </div>\n\n @if (col.column.resizable) {\n <span\n class=\"wr-table__resize-handle\"\n aria-hidden=\"true\"\n (pointerdown)=\"onResizeStart($event, col.key, thCell)\"\n (pointermove)=\"onResizeMove($event)\"\n (pointerup)=\"onResizeEnd($event)\"\n (pointercancel)=\"onResizeEnd($event)\"\n (mousedown)=\"$event.stopPropagation()\"\n (touchstart)=\"$event.stopPropagation()\"\n ></span>\n }\n </th>\n }\n </tr>\n </thead>\n\n <!-- One delegated listener for `rowClick`, which is pointer only by contract:\n the body is no control, and a row's keyboard path is the consumer's own\n button or link in a cell, or the row's own link under `rowLink`. The\n other three serve inline editing and return at once in a table with\n no edit template. -->\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <tbody\n (click)=\"onBodyClick($event)\"\n (dblclick)=\"onCellDblclick($event)\"\n (keydown)=\"onCellKeydown($event)\"\n (focusin)=\"onCellFocusin($event)\"\n >\n @if (visibleItems()) {\n @if (virtualized() && virtualWindow().padTop > 0) {\n <tr class=\"wr-table__spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"totalCols()\" [style.height.px]=\"virtualWindow().padTop\"></td>\n </tr>\n }\n @let edit = editing();\n @let links = rowLinks();\n @for (entry of windowRows(); track entry.id; let i = $index) {\n @if (entry.kind === 'group') {\n <tr class=\"wr-table__group-row\" [class.wr-table__group-row--collapsed]=\"entry.group.collapsed\">\n <td class=\"wr-table__group-cell\" [attr.colspan]=\"totalCols()\">\n <!-- The cell spans the full table width; this inner box is what sticks. -->\n <div class=\"wr-table__group-inner\">\n @if (rowSelection() === 'multiple') {\n <wr-checkbox\n class=\"wr-table__group-select\"\n size=\"sm\"\n [checked]=\"groupChecked(entry.group.rows)\"\n [indeterminate]=\"groupIndeterminate(entry.group.rows)\"\n (checkedChange)=\"toggleGroupSelection(entry.group.rows, $event)\"\n [ariaLabelledby]=\"groupControlLabelledby('select-group', entry.id)\"\n />\n }\n @if (groupTemplate(); as tpl) {\n <button\n type=\"button\"\n class=\"wr-table__group-toggle wr-table__group-toggle--icon\"\n [attr.aria-expanded]=\"!entry.group.collapsed\"\n [attr.aria-labelledby]=\"groupControlLabelledby('toggle-group', entry.id)\"\n (click)=\"toggleGroupCollapse(entry.group.value)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__group-icon\"\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 </button>\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"entry.group\" />\n <!-- The group's name for the two controls above. A custom header\n is the consumer's markup, with nothing in it to point at. -->\n <span hidden [id]=\"groupLabelId(entry.id)\">{{ entry.group.label }}</span>\n } @else {\n <button\n type=\"button\"\n class=\"wr-table__group-toggle\"\n [attr.aria-expanded]=\"!entry.group.collapsed\"\n [attr.aria-labelledby]=\"groupToggleLabelledby(entry.id)\"\n (click)=\"toggleGroupCollapse(entry.group.value)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__group-icon\"\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 <span class=\"wr-table__group-label\" [id]=\"groupLabelId(entry.id)\">{{ entry.group.label }}</span>\n @if (showGroupCount()) {\n <!-- A real space between the label and the count. Whitespace\n alone draws nothing in a flex row, and without it the\n button's text reads \"admin2\" — which the name\n \"Toggle group admin 2\" does not contain, a label-in-name\n mismatch for any tool that compares the two. -->\n &ngsp;<span class=\"wr-table__group-count\" [id]=\"groupCountId(entry.id)\">{{\n entry.group.count\n }}</span>\n }\n </button>\n }\n </div>\n </td>\n </tr>\n } @else if (entry.kind === 'group-foot') {\n <tr class=\"wr-table__group-foot-row\">\n @if (rowSelection()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @if (expandable()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @for (col of cellColumns(); track col.key) {\n <td\n [class]=\"col.footClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n {{ entry.summaries.get(col.key) ?? '' }}\n </td>\n }\n </tr>\n } @else {\n @let link = links.get(entry.row) ?? null;\n <tr\n #rowEl\n [class]=\"rowClasses(entry.row, i, link !== null)\"\n [class.wr-table__tr--selected]=\"rowSelection() && isRowSelected(entry.row)\"\n [class.wr-table__tr--child]=\"entry.depth > 0\"\n [attr.aria-rowindex]=\"virtualized() ? windowStart() + i + 2 : null\"\n [attr.aria-level]=\"treeMode() ? entry.depth + 1 : null\"\n [attr.aria-posinset]=\"treeMode() ? entry.posinset : null\"\n [attr.aria-setsize]=\"treeMode() ? entry.setsize : null\"\n [attr.aria-expanded]=\"entry.open\"\n [attr.aria-selected]=\"treeMode() && rowSelection() ? isRowSelected(entry.row) : null\"\n [attr.tabindex]=\"treeMode() ? (entry.id === tabStopRowId() ? 0 : -1) : null\"\n [style.--wr-table-depth]=\"treeMode() ? entry.depth : null\"\n >\n @if (rowSelection()) {\n <td class=\"wr-table__td wr-table__td--select\">\n <wr-checkbox\n size=\"sm\"\n [checked]=\"isRowSelected(entry.row)\"\n (checkedChange)=\"toggleRow(entry.row, $event)\"\n [ariaLabelledby]=\"rowControlLabelledby('select-row', entry.id)\"\n />\n </td>\n }\n @if (expandable()) {\n <td class=\"wr-table__td wr-table__td--expand\">\n <button\n type=\"button\"\n class=\"wr-table__expand-btn\"\n [class.wr-table__expand-btn--open]=\"isExpanded(entry.row)\"\n [attr.aria-expanded]=\"isExpanded(entry.row)\"\n [attr.aria-labelledby]=\"rowControlLabelledby('expand-row', entry.id)\"\n (click)=\"toggleExpand(entry.row)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__expand-icon\"\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 </button>\n </td>\n }\n @for (col of cellColumns(); track col.key) {\n @let cellEdit = edit !== null && edit.row === entry.row && edit.key === col.key ? edit : null;\n <td\n [class]=\"col.tdClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n [style.max-width.px]=\"col.maxWidth\"\n [attr.data-label]=\"col.column.title\"\n [attr.id]=\"col.label ? rowLabelId(entry.id) : null\"\n [attr.tabindex]=\"editGrid() ? cellTabindex(entry, col) : null\"\n [class.wr-table__td--editable]=\"col.editTemplate ? cellEditable(entry.row, col) : false\"\n [class.wr-table__td--editing]=\"cellEdit !== null\"\n >\n <!-- Empty, and laid under the whole row by the stylesheet: the\n cell's content is the consumer's and may hold controls,\n which an anchor cannot wrap. Gone while its cell is edited,\n where the editor is sized as the cell's only child. -->\n @if (link && col.link && !cellEdit) {\n <!-- eslint-disable-next-line @angular-eslint/template/elements-content -->\n <a\n class=\"wr-table__row-link\"\n [attr.href]=\"link.href\"\n [attr.tabindex]=\"treeMode() ? -1 : null\"\n [attr.aria-labelledby]=\"rowLabelId(entry.id)\"\n ></a>\n }\n @if (col.tree) {\n <span class=\"wr-table__tree-lead\">\n @if (entry.parent) {\n <button\n type=\"button\"\n class=\"wr-table__tree-toggle\"\n [class.wr-table__tree-toggle--open]=\"entry.open\"\n [attr.aria-expanded]=\"entry.open\"\n [attr.aria-labelledby]=\"rowControlLabelledby('toggle-row', entry.id)\"\n (click)=\"toggleTreeRow(entry.row)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__tree-icon\"\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 </button>\n } @else {\n <span class=\"wr-table__tree-toggle wr-table__tree-toggle--leaf\" aria-hidden=\"true\"></span>\n }\n </span>\n }\n @if (cellEdit) {\n <ng-container\n [ngTemplateOutlet]=\"col.editTemplate ?? null\"\n [ngTemplateOutletContext]=\"cellEdit.context\"\n />\n } @else if (col.template; as tpl) {\n @if (col.actions) {\n <div class=\"wr-table__actions\">\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"cellContext(entry.row, col)\"\n />\n </div>\n } @else {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"cellContext(entry.row, col)\" />\n }\n } @else {\n {{ cellText(entry.row, col.key, col.column) }}\n }\n </td>\n }\n </tr>\n @if (expandable() && isExpanded(entry.row)) {\n <tr class=\"wr-table__detail-row\">\n <td class=\"wr-table__detail\" [attr.colspan]=\"totalCols()\">\n <ng-container\n [ngTemplateOutlet]=\"expandTemplate() ?? null\"\n [ngTemplateOutletContext]=\"expandContext(entry.row)\"\n />\n </td>\n </tr>\n }\n }\n }\n @if (virtualized() && virtualWindow().padBottom > 0) {\n <tr class=\"wr-table__spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"totalCols()\" [style.height.px]=\"virtualWindow().padBottom\"></td>\n </tr>\n }\n }\n <!-- Sibling of the row loop rather than its `@empty` branch, and gated on\n `loading()`. As the `@empty` branch it lived INSIDE `@if (visibleItems())`,\n which passes a nullish `[items]` straight through — so the input's own\n default rendered a header over a blank body with no \"No data\" anywhere,\n the opposite of what `items`'s docs promise. And the veil is translucent,\n so on the documented `[items]=\"[]\" [loading]=\"true\"` pair the row read\n \"No data\" through the spinner. -->\n @if (!loading() && !renderRows().length) {\n <tr>\n <td class=\"wr-table__empty\" [attr.colspan]=\"totalCols()\">{{ resolvedEmptyLabel() }}</td>\n </tr>\n }\n </tbody>\n\n @if (hasSummary() && items()?.length) {\n <tfoot #foot>\n <tr class=\"wr-table__foot-row\">\n @if (rowSelection()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @if (expandable()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @for (col of cellColumns(); track col.key) {\n <td\n [class]=\"col.footClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n {{ summaryFor(col.key) }}\n </td>\n }\n </tr>\n </tfoot>\n }\n </table>\n</div>\n\n@if (showPager()) {\n <div class=\"wr-table__pager\">\n <wr-pagination\n [page]=\"page()\"\n (pageChange)=\"onPagerPage($event)\"\n [pageSize]=\"currentPageSize()\"\n (pageSizeChange)=\"onPageSizeChange($event)\"\n [total]=\"resolvedTotal()\"\n [size]=\"paginationSize()\"\n [showSizeChanger]=\"pageSizeOptions().length > 0\"\n [pageSizeOptions]=\"pageSizeOptions()\"\n />\n </div>\n}\n\n<!-- The table's one tooltip, for a header hint or a cut cell (see `tip`). -->\n@if (tip(); as shown) {\n <span hidden [wrPopover]=\"shown.text\" mode=\"tooltip\" [wrPopoverOrigin]=\"shown.el\"></span>\n}\n\n<!-- The action words the row and group controls are named with, once per table.\n `aria-labelledby` reads a hidden element it points at, so each control joins\n one of these to its own row's (or group's) label. Only the words a control\n in this table uses are rendered. -->\n@if (rowSelection() || expandable() || treeMode() || groupBy() !== null) {\n <div hidden>\n @if (rowSelection()) {\n <span [id]=\"actionId('select-row')\">{{ resolvedSelectRowLabel() }}</span>\n }\n @if (expandable()) {\n <span [id]=\"actionId('expand-row')\">{{ resolvedExpandRowLabel() }}</span>\n }\n @if (treeMode()) {\n <span [id]=\"actionId('toggle-row')\">{{ resolvedToggleRowLabel() }}</span>\n }\n @if (groupBy() !== null) {\n @if (rowSelection() === 'multiple') {\n <span [id]=\"actionId('select-group')\">{{ resolvedSelectGroupLabel() }}</span>\n }\n <span [id]=\"actionId('toggle-group')\">{{ resolvedToggleGroupLabel() }}</span>\n }\n </div>\n}\n",
|
|
3038
3051
|
dependencies: [
|
|
3039
3052
|
{
|
|
3040
3053
|
kind: "directive",
|
|
@@ -3258,7 +3271,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3258
3271
|
WrTableSort,
|
|
3259
3272
|
WrTableFilter
|
|
3260
3273
|
],
|
|
3261
|
-
template: "@switch (loadingForm()) {\n @case ('overlay') {\n <div class=\"wr-table__loading\" role=\"status\">\n <span class=\"wr-table__sr-only\">{{ resolvedLoadingLabel() }}</span>\n <wr-spinner size=\"lg\" />\n </div>\n }\n @case ('bar') {\n <div class=\"wr-table__loading-bar\" role=\"status\">\n <span class=\"wr-table__sr-only\">{{ resolvedLoadingLabel() }}</span>\n </div>\n }\n}\n\n@if (columnChooser()) {\n <div class=\"wr-table__toolbar\">\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-table__columns-btn\"\n position=\"bottom-end\"\n [wrPopover]=\"chooser\"\n [ariaLabel]=\"resolvedColumnsLabel()\"\n >\n {{ resolvedColumnsLabel() }}\n </button>\n <ng-template #chooser>\n <div class=\"wr-table__columns\">\n <wr-table-column-chooser [table]=\"this\" [ariaLabel]=\"resolvedColumnsLabel()\" />\n </div>\n </ng-template>\n </div>\n}\n\n<!-- The selection bar lies over the header: a box of no height in front of\n the scroll area, so the bar stays put while the columns scroll under it.\n The count is announced from a region that is in the DOM before it has\n anything to say, and the drawn copy is hidden from it. -->\n@if (hasSelectionBar()) {\n <div class=\"wr-table__selection\">\n <span class=\"wr-table__selection-status\" role=\"status\">{{ selectionBar() ? selectionCountText() : '' }}</span>\n @if (selectionBar(); as tpl) {\n <div\n #selectionBarEl\n class=\"wr-table__selection-bar\"\n [class.wr-table__selection-bar--inset]=\"rowSelection() === 'multiple'\"\n [style.--wr-table-selection-bar-height.px]=\"selectionBarHeight()\"\n >\n <span class=\"wr-table__selection-count\" aria-hidden=\"true\">{{ selectionCountText() }}</span>\n <button wr-btn type=\"button\" size=\"sm\" class=\"wr-table__selection-clear\" (click)=\"clearSelection()\">\n {{ resolvedClearSelectionLabel() }}\n </button>\n <div class=\"wr-table__selection-actions\">\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"selectionContext()\" />\n </div>\n </div>\n }\n </div>\n}\n\n<!-- With a selection bar the scroll area takes focus from script, for the bar\n to hand it to when it leaves a table that has no checkbox to take it. -->\n<div\n class=\"wr-table__scroll\"\n #scroll\n [style.--wr-table-scroll-height]=\"scrollHeight()\"\n [style.--wr-table-head-height.px]=\"stickyEdges().head\"\n [style.--wr-table-foot-height.px]=\"stickyEdges().foot\"\n [attr.tabindex]=\"scrollable() ? 0 : hasSelectionBar() ? -1 : null\"\n>\n <table\n class=\"wr-table__table\"\n [class.wr-table__table--fixed]=\"clippedLayout()\"\n [class.wr-table__table--layout-fixed]=\"layout() === 'fixed'\"\n [style.--wr-table-row-h.px]=\"rowHeightVar()\"\n [attr.aria-rowcount]=\"virtualized() ? renderRows().length + 1 + (hasSummary() && items()?.length ? 1 : 0) : null\"\n [attr.role]=\"treeMode() ? 'treegrid' : editGrid() ? 'grid' : null\"\n [attr.aria-multiselectable]=\"treeMode() && rowSelection() === 'multiple' ? true : null\"\n >\n <colgroup>\n @if (rowSelection()) {\n <col class=\"wr-table__col--lead\" />\n }\n @if (expandable()) {\n <col class=\"wr-table__col--lead\" />\n }\n @for (col of cellColumns(); track col.key) {\n <col [style.width.px]=\"col.width\" />\n }\n </colgroup>\n <thead #head>\n <tr\n cdkDropList\n cdkDropListOrientation=\"horizontal\"\n [cdkDropListSortPredicate]=\"sortPredicate\"\n (cdkDropListDropped)=\"onColumnDrop($event)\"\n (cdkDropListSorted)=\"onColumnListSorted($event)\"\n (cdkDropListEntered)=\"onColumnListEntered()\"\n (cdkDropListExited)=\"onColumnListExited()\"\n >\n @if (rowSelection()) {\n <th class=\"wr-table__th wr-table__th--select\">\n @if (rowSelection() === 'multiple') {\n <!-- Disabled with nothing to sweep, the way `wr-transfer` guards its\n own select-all. `[checked]` is a one-way binding over a checkbox\n that owns its state, and on zero rows `allSelected()` answers\n `false` before and after the click — an unchanged input is never\n written back, so the box latched CHECKED over an empty table and\n stayed that way when rows returned. -->\n <wr-checkbox\n size=\"sm\"\n [checked]=\"allSelected()\"\n [indeterminate]=\"someSelected()\"\n [disabled]=\"selectAllKeys().size === 0\"\n (checkedChange)=\"toggleAll($event)\"\n [ariaLabel]=\"resolvedSelectAllLabel()\"\n />\n }\n </th>\n }\n @if (expandable()) {\n <th class=\"wr-table__th wr-table__th--expand\"></th>\n }\n <!-- `inert` under the selection bar: a control the bar covers takes no\n focus and no click. The select-all cell stays out from under it. -->\n @for (col of cellColumns(); track col.key) {\n <!-- The click is a pointer shortcut for the sort button, which stays\n the one control and the keyboard path. -->\n <th\n #thCell\n (click)=\"onHeaderClick($event, col.key, col.column.sortable)\"\n cdkDrag\n [attr.inert]=\"selectionBar() ? '' : null\"\n [cdkDragDisabled]=\"!reorderable() || col.pinned\"\n (cdkDragStarted)=\"onColumnDragStart($event)\"\n (cdkDragMoved)=\"onColumnDragMoved($event)\"\n (cdkDragEnded)=\"onColumnDragEnd()\"\n [class]=\"col.thClass\"\n [attr.aria-sort]=\"ariaSortFor(col.key, col.column.sortable)\"\n [attr.aria-label]=\"col.column.title ? null : (col.column.headerHint ?? null)\"\n [class.wr-table__th--sortable]=\"col.column.sortable\"\n [class.wr-table__th--draggable]=\"reorderable() && !col.pinned\"\n [class.wr-table__th--pin-left]=\"col.pinLeft\"\n [class.wr-table__th--pin-right]=\"col.pinRight\"\n [class.wr-table__th--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__th--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n <div class=\"wr-table__th-inner\">\n <span class=\"wr-table__title\">{{ col.column.title }}</span>\n\n @if (col.column.sortable) {\n <button\n type=\"button\"\n class=\"wr-table__sort-btn\"\n [attr.aria-label]=\"sortLabelFor(headerName(col.column))\"\n (click)=\"cycleSort(col.key)\"\n >\n <wr-table-sort [direction]=\"directionFor(col.key)\" />\n </button>\n <!-- A column's place in a multi-column sort. Drawn, because only the\n primary key announces `aria-sort` (see ariaSortFor). Beside the\n button rather than in it: inside, the digit is visible text the\n button's name (\"Sort Role\") does not contain, which is a WCAG\n 2.5.3 label-in-name failure. Hidden, so the column header's own\n name stays its title. -->\n @if (sortOrderFor(col.key); as order) {\n <span class=\"wr-table__sort-order\" aria-hidden=\"true\">{{ order }}</span>\n }\n }\n\n @if (col.column.filterItems; as filterItems) {\n @if (filterItems.length) {\n <wr-table-filter\n [items]=\"filterItems\"\n [column]=\"headerName(col.column)\"\n (selectionChange)=\"onFilter(col.key, $event)\"\n />\n }\n }\n </div>\n\n @if (col.column.resizable) {\n <span\n class=\"wr-table__resize-handle\"\n aria-hidden=\"true\"\n (pointerdown)=\"onResizeStart($event, col.key, thCell)\"\n (pointermove)=\"onResizeMove($event)\"\n (pointerup)=\"onResizeEnd($event)\"\n (pointercancel)=\"onResizeEnd($event)\"\n (mousedown)=\"$event.stopPropagation()\"\n (touchstart)=\"$event.stopPropagation()\"\n ></span>\n }\n </th>\n }\n </tr>\n </thead>\n\n <!-- One delegated listener for `rowClick`, which is pointer only by contract:\n the body is no control, and a row's keyboard path is the consumer's own\n button or link in a cell, or the row's own link under `rowLink`. The\n other three serve inline editing and return at once in a table with\n no edit template. -->\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <tbody\n (click)=\"onBodyClick($event)\"\n (dblclick)=\"onCellDblclick($event)\"\n (keydown)=\"onCellKeydown($event)\"\n (focusin)=\"onCellFocusin($event)\"\n >\n @if (visibleItems()) {\n @if (virtualized() && virtualWindow().padTop > 0) {\n <tr class=\"wr-table__spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"totalCols()\" [style.height.px]=\"virtualWindow().padTop\"></td>\n </tr>\n }\n @let edit = editing();\n @let links = rowLinks();\n @for (entry of windowRows(); track entry.id; let i = $index) {\n @if (entry.kind === 'group') {\n <tr class=\"wr-table__group-row\" [class.wr-table__group-row--collapsed]=\"entry.group.collapsed\">\n <td class=\"wr-table__group-cell\" [attr.colspan]=\"totalCols()\">\n <!-- The cell spans the full table width; this inner box is what sticks. -->\n <div class=\"wr-table__group-inner\">\n @if (rowSelection() === 'multiple') {\n <wr-checkbox\n class=\"wr-table__group-select\"\n size=\"sm\"\n [checked]=\"groupChecked(entry.group.rows)\"\n [indeterminate]=\"groupIndeterminate(entry.group.rows)\"\n (checkedChange)=\"toggleGroupSelection(entry.group.rows, $event)\"\n [ariaLabelledby]=\"groupControlLabelledby('select-group', entry.id)\"\n />\n }\n @if (groupTemplate(); as tpl) {\n <button\n type=\"button\"\n class=\"wr-table__group-toggle wr-table__group-toggle--icon\"\n [attr.aria-expanded]=\"!entry.group.collapsed\"\n [attr.aria-labelledby]=\"groupControlLabelledby('toggle-group', entry.id)\"\n (click)=\"toggleGroupCollapse(entry.group.value)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__group-icon\"\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 </button>\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"entry.group\" />\n <!-- The group's name for the two controls above. A custom header\n is the consumer's markup, with nothing in it to point at. -->\n <span hidden [id]=\"groupLabelId(entry.id)\">{{ entry.group.label }}</span>\n } @else {\n <button\n type=\"button\"\n class=\"wr-table__group-toggle\"\n [attr.aria-expanded]=\"!entry.group.collapsed\"\n [attr.aria-labelledby]=\"groupToggleLabelledby(entry.id)\"\n (click)=\"toggleGroupCollapse(entry.group.value)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__group-icon\"\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 <span class=\"wr-table__group-label\" [id]=\"groupLabelId(entry.id)\">{{ entry.group.label }}</span>\n @if (showGroupCount()) {\n <!-- A real space between the label and the count. Whitespace\n alone draws nothing in a flex row, and without it the\n button's text reads \"admin2\" — which the name\n \"Toggle group admin 2\" does not contain, a label-in-name\n mismatch for any tool that compares the two. -->\n &ngsp;<span class=\"wr-table__group-count\" [id]=\"groupCountId(entry.id)\">{{\n entry.group.count\n }}</span>\n }\n </button>\n }\n </div>\n </td>\n </tr>\n } @else if (entry.kind === 'group-foot') {\n <tr class=\"wr-table__group-foot-row\">\n @if (rowSelection()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @if (expandable()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @for (col of cellColumns(); track col.key) {\n <td\n [class]=\"col.footClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n {{ entry.summaries.get(col.key) ?? '' }}\n </td>\n }\n </tr>\n } @else {\n @let link = links.get(entry.row) ?? null;\n <tr\n #rowEl\n [class]=\"rowClasses(entry.row, i, link !== null)\"\n [class.wr-table__tr--selected]=\"rowSelection() && isRowSelected(entry.row)\"\n [class.wr-table__tr--child]=\"entry.depth > 0\"\n [attr.aria-rowindex]=\"virtualized() ? windowStart() + i + 2 : null\"\n [attr.aria-level]=\"treeMode() ? entry.depth + 1 : null\"\n [attr.aria-posinset]=\"treeMode() ? entry.posinset : null\"\n [attr.aria-setsize]=\"treeMode() ? entry.setsize : null\"\n [attr.aria-expanded]=\"entry.open\"\n [attr.aria-selected]=\"treeMode() && rowSelection() ? isRowSelected(entry.row) : null\"\n [attr.tabindex]=\"treeMode() ? (entry.id === tabStopRowId() ? 0 : -1) : null\"\n [style.--wr-table-depth]=\"treeMode() ? entry.depth : null\"\n >\n @if (rowSelection()) {\n <td class=\"wr-table__td wr-table__td--select\">\n <wr-checkbox\n size=\"sm\"\n [checked]=\"isRowSelected(entry.row)\"\n (checkedChange)=\"toggleRow(entry.row, $event)\"\n [ariaLabelledby]=\"rowControlLabelledby('select-row', entry.id)\"\n />\n </td>\n }\n @if (expandable()) {\n <td class=\"wr-table__td wr-table__td--expand\">\n <button\n type=\"button\"\n class=\"wr-table__expand-btn\"\n [class.wr-table__expand-btn--open]=\"isExpanded(entry.row)\"\n [attr.aria-expanded]=\"isExpanded(entry.row)\"\n [attr.aria-labelledby]=\"rowControlLabelledby('expand-row', entry.id)\"\n (click)=\"toggleExpand(entry.row)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__expand-icon\"\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 </button>\n </td>\n }\n @for (col of cellColumns(); track col.key) {\n @let cellEdit = edit !== null && edit.row === entry.row && edit.key === col.key ? edit : null;\n <td\n [class]=\"col.tdClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n [style.max-width.px]=\"col.maxWidth\"\n [attr.data-label]=\"col.column.title\"\n [attr.id]=\"col.label ? rowLabelId(entry.id) : null\"\n [attr.tabindex]=\"editGrid() ? cellTabindex(entry, col) : null\"\n [class.wr-table__td--editable]=\"col.editTemplate ? cellEditable(entry.row, col) : false\"\n [class.wr-table__td--editing]=\"cellEdit !== null\"\n >\n <!-- Empty, and laid under the whole row by the stylesheet: the\n cell's content is the consumer's and may hold controls,\n which an anchor cannot wrap. Gone while its cell is edited,\n where the editor is sized as the cell's only child. -->\n @if (link && col.link && !cellEdit) {\n <!-- eslint-disable-next-line @angular-eslint/template/elements-content -->\n <a\n class=\"wr-table__row-link\"\n [attr.href]=\"link.href\"\n [attr.aria-labelledby]=\"rowLabelId(entry.id)\"\n ></a>\n }\n @if (col.tree) {\n <span class=\"wr-table__tree-lead\">\n @if (entry.parent) {\n <button\n type=\"button\"\n class=\"wr-table__tree-toggle\"\n [class.wr-table__tree-toggle--open]=\"entry.open\"\n [attr.aria-expanded]=\"entry.open\"\n [attr.aria-labelledby]=\"rowControlLabelledby('toggle-row', entry.id)\"\n (click)=\"toggleTreeRow(entry.row)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__tree-icon\"\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 </button>\n } @else {\n <span class=\"wr-table__tree-toggle wr-table__tree-toggle--leaf\" aria-hidden=\"true\"></span>\n }\n </span>\n }\n @if (cellEdit) {\n <ng-container\n [ngTemplateOutlet]=\"col.editTemplate ?? null\"\n [ngTemplateOutletContext]=\"cellEdit.context\"\n />\n } @else if (col.template; as tpl) {\n @if (col.actions) {\n <div class=\"wr-table__actions\">\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"cellContext(entry.row, col)\"\n />\n </div>\n } @else {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"cellContext(entry.row, col)\" />\n }\n } @else {\n {{ cellText(entry.row, col.key, col.column) }}\n }\n </td>\n }\n </tr>\n @if (expandable() && isExpanded(entry.row)) {\n <tr class=\"wr-table__detail-row\">\n <td class=\"wr-table__detail\" [attr.colspan]=\"totalCols()\">\n <ng-container\n [ngTemplateOutlet]=\"expandTemplate() ?? null\"\n [ngTemplateOutletContext]=\"expandContext(entry.row)\"\n />\n </td>\n </tr>\n }\n }\n }\n @if (virtualized() && virtualWindow().padBottom > 0) {\n <tr class=\"wr-table__spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"totalCols()\" [style.height.px]=\"virtualWindow().padBottom\"></td>\n </tr>\n }\n }\n <!-- Sibling of the row loop rather than its `@empty` branch, and gated on\n `loading()`. As the `@empty` branch it lived INSIDE `@if (visibleItems())`,\n which passes a nullish `[items]` straight through — so the input's own\n default rendered a header over a blank body with no \"No data\" anywhere,\n the opposite of what `items`'s docs promise. And the veil is translucent,\n so on the documented `[items]=\"[]\" [loading]=\"true\"` pair the row read\n \"No data\" through the spinner. -->\n @if (!loading() && !renderRows().length) {\n <tr>\n <td class=\"wr-table__empty\" [attr.colspan]=\"totalCols()\">{{ resolvedEmptyLabel() }}</td>\n </tr>\n }\n </tbody>\n\n @if (hasSummary() && items()?.length) {\n <tfoot #foot>\n <tr class=\"wr-table__foot-row\">\n @if (rowSelection()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @if (expandable()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @for (col of cellColumns(); track col.key) {\n <td\n [class]=\"col.footClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n {{ summaryFor(col.key) }}\n </td>\n }\n </tr>\n </tfoot>\n }\n </table>\n</div>\n\n@if (showPager()) {\n <div class=\"wr-table__pager\">\n <wr-pagination\n [page]=\"page()\"\n (pageChange)=\"onPagerPage($event)\"\n [pageSize]=\"currentPageSize()\"\n (pageSizeChange)=\"onPageSizeChange($event)\"\n [total]=\"resolvedTotal()\"\n [size]=\"paginationSize()\"\n [showSizeChanger]=\"pageSizeOptions().length > 0\"\n [pageSizeOptions]=\"pageSizeOptions()\"\n />\n </div>\n}\n\n<!-- The table's one tooltip, for a header hint or a cut cell (see `tip`). -->\n@if (tip(); as shown) {\n <span hidden [wrPopover]=\"shown.text\" mode=\"tooltip\" [wrPopoverOrigin]=\"shown.el\"></span>\n}\n\n<!-- The action words the row and group controls are named with, once per table.\n `aria-labelledby` reads a hidden element it points at, so each control joins\n one of these to its own row's (or group's) label. Only the words a control\n in this table uses are rendered. -->\n@if (rowSelection() || expandable() || treeMode() || groupBy() !== null) {\n <div hidden>\n @if (rowSelection()) {\n <span [id]=\"actionId('select-row')\">{{ resolvedSelectRowLabel() }}</span>\n }\n @if (expandable()) {\n <span [id]=\"actionId('expand-row')\">{{ resolvedExpandRowLabel() }}</span>\n }\n @if (treeMode()) {\n <span [id]=\"actionId('toggle-row')\">{{ resolvedToggleRowLabel() }}</span>\n }\n @if (groupBy() !== null) {\n @if (rowSelection() === 'multiple') {\n <span [id]=\"actionId('select-group')\">{{ resolvedSelectGroupLabel() }}</span>\n }\n <span [id]=\"actionId('toggle-group')\">{{ resolvedToggleGroupLabel() }}</span>\n }\n </div>\n}\n"
|
|
3274
|
+
template: "@switch (loadingForm()) {\n @case ('overlay') {\n <div class=\"wr-table__loading\" role=\"status\">\n <span class=\"wr-table__sr-only\">{{ resolvedLoadingLabel() }}</span>\n <wr-spinner size=\"lg\" />\n </div>\n }\n @case ('bar') {\n <div class=\"wr-table__loading-bar\" role=\"status\">\n <span class=\"wr-table__sr-only\">{{ resolvedLoadingLabel() }}</span>\n </div>\n }\n}\n\n@if (columnChooser()) {\n <div class=\"wr-table__toolbar\">\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-table__columns-btn\"\n position=\"bottom-end\"\n [wrPopover]=\"chooser\"\n [ariaLabel]=\"resolvedColumnsLabel()\"\n >\n {{ resolvedColumnsLabel() }}\n </button>\n <ng-template #chooser>\n <div class=\"wr-table__columns\">\n <wr-table-column-chooser [table]=\"this\" [ariaLabel]=\"resolvedColumnsLabel()\" />\n </div>\n </ng-template>\n </div>\n}\n\n<!-- The selection bar lies over the header: a box of no height in front of\n the scroll area, so the bar stays put while the columns scroll under it.\n The count is announced from a region that is in the DOM before it has\n anything to say, and the drawn copy is hidden from it. -->\n@if (hasSelectionBar()) {\n <div class=\"wr-table__selection\">\n <span class=\"wr-table__selection-status\" role=\"status\">{{ selectionBar() ? selectionCountText() : '' }}</span>\n @if (selectionBar(); as tpl) {\n <div\n #selectionBarEl\n class=\"wr-table__selection-bar\"\n [class.wr-table__selection-bar--inset]=\"rowSelection() === 'multiple'\"\n [style.--wr-table-selection-bar-height.px]=\"selectionBarHeight()\"\n >\n <span class=\"wr-table__selection-count\" aria-hidden=\"true\">{{ selectionCountText() }}</span>\n <button wr-btn type=\"button\" size=\"sm\" class=\"wr-table__selection-clear\" (click)=\"clearSelection()\">\n {{ resolvedClearSelectionLabel() }}\n </button>\n <div class=\"wr-table__selection-actions\">\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"selectionContext()\" />\n </div>\n </div>\n }\n </div>\n}\n\n<!-- With a selection bar the scroll area takes focus from script, for the bar\n to hand it to when it leaves a table that has no checkbox to take it. -->\n<div\n class=\"wr-table__scroll\"\n #scroll\n [style.--wr-table-scroll-height]=\"scrollHeight()\"\n [style.--wr-table-head-height.px]=\"stickyEdges().head\"\n [style.--wr-table-foot-height.px]=\"stickyEdges().foot\"\n [attr.tabindex]=\"scrollable() ? 0 : hasSelectionBar() ? -1 : null\"\n>\n <table\n class=\"wr-table__table\"\n [class.wr-table__table--fixed]=\"clippedLayout()\"\n [class.wr-table__table--layout-fixed]=\"layout() === 'fixed'\"\n [style.--wr-table-row-h.px]=\"rowHeightVar()\"\n [attr.aria-rowcount]=\"virtualized() ? renderRows().length + 1 + (hasSummary() && items()?.length ? 1 : 0) : null\"\n [attr.role]=\"treeMode() ? 'treegrid' : editGrid() ? 'grid' : null\"\n [attr.aria-multiselectable]=\"treeMode() && rowSelection() === 'multiple' ? true : null\"\n >\n <colgroup>\n @if (rowSelection()) {\n <col class=\"wr-table__col--lead\" />\n }\n @if (expandable()) {\n <col class=\"wr-table__col--lead\" />\n }\n @for (col of cellColumns(); track col.key) {\n <col [style.width.px]=\"col.width\" />\n }\n </colgroup>\n <thead #head>\n <tr\n cdkDropList\n cdkDropListOrientation=\"horizontal\"\n [cdkDropListSortPredicate]=\"sortPredicate\"\n (cdkDropListDropped)=\"onColumnDrop($event)\"\n (cdkDropListSorted)=\"onColumnListSorted($event)\"\n (cdkDropListEntered)=\"onColumnListEntered()\"\n (cdkDropListExited)=\"onColumnListExited()\"\n >\n @if (rowSelection()) {\n <th class=\"wr-table__th wr-table__th--select\">\n @if (rowSelection() === 'multiple') {\n <!-- Disabled with nothing to sweep, the way `wr-transfer` guards its\n own select-all. `[checked]` is a one-way binding over a checkbox\n that owns its state, and on zero rows `allSelected()` answers\n `false` before and after the click — an unchanged input is never\n written back, so the box latched CHECKED over an empty table and\n stayed that way when rows returned. -->\n <wr-checkbox\n size=\"sm\"\n [checked]=\"allSelected()\"\n [indeterminate]=\"someSelected()\"\n [disabled]=\"selectAllKeys().size === 0\"\n (checkedChange)=\"toggleAll($event)\"\n [ariaLabel]=\"resolvedSelectAllLabel()\"\n />\n }\n </th>\n }\n @if (expandable()) {\n <th class=\"wr-table__th wr-table__th--expand\"></th>\n }\n <!-- `inert` under the selection bar: a control the bar covers takes no\n focus and no click. The select-all cell stays out from under it. -->\n @for (col of cellColumns(); track col.key) {\n <!-- The click is a pointer shortcut for the sort button, which stays\n the one control and the keyboard path. -->\n <th\n #thCell\n (click)=\"onHeaderClick($event, col.key, col.column.sortable)\"\n cdkDrag\n [cdkDragPreviewClass]=\"size() === 'sm' ? 'wr-table__th--preview-sm' : ''\"\n [attr.inert]=\"selectionBar() ? '' : null\"\n [cdkDragDisabled]=\"!reorderable() || col.pinned\"\n (cdkDragStarted)=\"onColumnDragStart($event)\"\n (cdkDragMoved)=\"onColumnDragMoved($event)\"\n (cdkDragEnded)=\"onColumnDragEnd()\"\n [class]=\"col.thClass\"\n [attr.aria-sort]=\"ariaSortFor(col.key, col.column.sortable)\"\n [attr.aria-label]=\"col.column.title ? null : (col.column.headerHint ?? null)\"\n [class.wr-table__th--sortable]=\"col.column.sortable\"\n [class.wr-table__th--draggable]=\"reorderable() && !col.pinned\"\n [class.wr-table__th--pin-left]=\"col.pinLeft\"\n [class.wr-table__th--pin-right]=\"col.pinRight\"\n [class.wr-table__th--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__th--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n <div class=\"wr-table__th-inner\">\n <span class=\"wr-table__title\">{{ col.column.title }}</span>\n\n @if (col.column.sortable) {\n <button\n type=\"button\"\n class=\"wr-table__sort-btn\"\n [attr.aria-label]=\"sortLabelFor(headerName(col.column))\"\n (click)=\"cycleSort(col.key)\"\n >\n <wr-table-sort [direction]=\"directionFor(col.key)\" />\n </button>\n <!-- A column's place in a multi-column sort. Drawn, because only the\n primary key announces `aria-sort` (see ariaSortFor). Beside the\n button rather than in it: inside, the digit is visible text the\n button's name (\"Sort Role\") does not contain, which is a WCAG\n 2.5.3 label-in-name failure. Hidden, so the column header's own\n name stays its title. -->\n @if (sortOrderFor(col.key); as order) {\n <span class=\"wr-table__sort-order\" aria-hidden=\"true\">{{ order }}</span>\n }\n }\n\n @if (col.column.filterItems; as filterItems) {\n @if (filterItems.length) {\n <wr-table-filter\n [items]=\"filterItems\"\n [column]=\"headerName(col.column)\"\n (selectionChange)=\"onFilter(col.key, $event)\"\n />\n }\n }\n </div>\n\n @if (col.column.resizable) {\n <span\n class=\"wr-table__resize-handle\"\n aria-hidden=\"true\"\n (pointerdown)=\"onResizeStart($event, col.key, thCell)\"\n (pointermove)=\"onResizeMove($event)\"\n (pointerup)=\"onResizeEnd($event)\"\n (pointercancel)=\"onResizeEnd($event)\"\n (mousedown)=\"$event.stopPropagation()\"\n (touchstart)=\"$event.stopPropagation()\"\n ></span>\n }\n </th>\n }\n </tr>\n </thead>\n\n <!-- One delegated listener for `rowClick`, which is pointer only by contract:\n the body is no control, and a row's keyboard path is the consumer's own\n button or link in a cell, or the row's own link under `rowLink`. The\n other three serve inline editing and return at once in a table with\n no edit template. -->\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <tbody\n (click)=\"onBodyClick($event)\"\n (dblclick)=\"onCellDblclick($event)\"\n (keydown)=\"onCellKeydown($event)\"\n (focusin)=\"onCellFocusin($event)\"\n >\n @if (visibleItems()) {\n @if (virtualized() && virtualWindow().padTop > 0) {\n <tr class=\"wr-table__spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"totalCols()\" [style.height.px]=\"virtualWindow().padTop\"></td>\n </tr>\n }\n @let edit = editing();\n @let links = rowLinks();\n @for (entry of windowRows(); track entry.id; let i = $index) {\n @if (entry.kind === 'group') {\n <tr class=\"wr-table__group-row\" [class.wr-table__group-row--collapsed]=\"entry.group.collapsed\">\n <td class=\"wr-table__group-cell\" [attr.colspan]=\"totalCols()\">\n <!-- The cell spans the full table width; this inner box is what sticks. -->\n <div class=\"wr-table__group-inner\">\n @if (rowSelection() === 'multiple') {\n <wr-checkbox\n class=\"wr-table__group-select\"\n size=\"sm\"\n [checked]=\"groupChecked(entry.group.rows)\"\n [indeterminate]=\"groupIndeterminate(entry.group.rows)\"\n (checkedChange)=\"toggleGroupSelection(entry.group.rows, $event)\"\n [ariaLabelledby]=\"groupControlLabelledby('select-group', entry.id)\"\n />\n }\n @if (groupTemplate(); as tpl) {\n <button\n type=\"button\"\n class=\"wr-table__group-toggle wr-table__group-toggle--icon\"\n [attr.aria-expanded]=\"!entry.group.collapsed\"\n [attr.aria-labelledby]=\"groupControlLabelledby('toggle-group', entry.id)\"\n (click)=\"toggleGroupCollapse(entry.group.value)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__group-icon\"\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 </button>\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"entry.group\" />\n <!-- The group's name for the two controls above. A custom header\n is the consumer's markup, with nothing in it to point at. -->\n <span hidden [id]=\"groupLabelId(entry.id)\">{{ entry.group.label }}</span>\n } @else {\n <button\n type=\"button\"\n class=\"wr-table__group-toggle\"\n [attr.aria-expanded]=\"!entry.group.collapsed\"\n [attr.aria-labelledby]=\"groupToggleLabelledby(entry.id)\"\n (click)=\"toggleGroupCollapse(entry.group.value)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__group-icon\"\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 <span class=\"wr-table__group-label\" [id]=\"groupLabelId(entry.id)\">{{ entry.group.label }}</span>\n @if (showGroupCount()) {\n <!-- A real space between the label and the count. Whitespace\n alone draws nothing in a flex row, and without it the\n button's text reads \"admin2\" — which the name\n \"Toggle group admin 2\" does not contain, a label-in-name\n mismatch for any tool that compares the two. -->\n &ngsp;<span class=\"wr-table__group-count\" [id]=\"groupCountId(entry.id)\">{{\n entry.group.count\n }}</span>\n }\n </button>\n }\n </div>\n </td>\n </tr>\n } @else if (entry.kind === 'group-foot') {\n <tr class=\"wr-table__group-foot-row\">\n @if (rowSelection()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @if (expandable()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @for (col of cellColumns(); track col.key) {\n <td\n [class]=\"col.footClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n {{ entry.summaries.get(col.key) ?? '' }}\n </td>\n }\n </tr>\n } @else {\n @let link = links.get(entry.row) ?? null;\n <tr\n #rowEl\n [class]=\"rowClasses(entry.row, i, link !== null)\"\n [class.wr-table__tr--selected]=\"rowSelection() && isRowSelected(entry.row)\"\n [class.wr-table__tr--child]=\"entry.depth > 0\"\n [attr.aria-rowindex]=\"virtualized() ? windowStart() + i + 2 : null\"\n [attr.aria-level]=\"treeMode() ? entry.depth + 1 : null\"\n [attr.aria-posinset]=\"treeMode() ? entry.posinset : null\"\n [attr.aria-setsize]=\"treeMode() ? entry.setsize : null\"\n [attr.aria-expanded]=\"entry.open\"\n [attr.aria-selected]=\"treeMode() && rowSelection() ? isRowSelected(entry.row) : null\"\n [attr.tabindex]=\"treeMode() ? (entry.id === tabStopRowId() ? 0 : -1) : null\"\n [style.--wr-table-depth]=\"treeMode() ? entry.depth : null\"\n >\n @if (rowSelection()) {\n <td class=\"wr-table__td wr-table__td--select\">\n <wr-checkbox\n size=\"sm\"\n [checked]=\"isRowSelected(entry.row)\"\n (checkedChange)=\"toggleRow(entry.row, $event)\"\n [ariaLabelledby]=\"rowControlLabelledby('select-row', entry.id)\"\n />\n </td>\n }\n @if (expandable()) {\n <td class=\"wr-table__td wr-table__td--expand\">\n <button\n type=\"button\"\n class=\"wr-table__expand-btn\"\n [class.wr-table__expand-btn--open]=\"isExpanded(entry.row)\"\n [attr.aria-expanded]=\"isExpanded(entry.row)\"\n [attr.aria-labelledby]=\"rowControlLabelledby('expand-row', entry.id)\"\n (click)=\"toggleExpand(entry.row)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__expand-icon\"\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 </button>\n </td>\n }\n @for (col of cellColumns(); track col.key) {\n @let cellEdit = edit !== null && edit.row === entry.row && edit.key === col.key ? edit : null;\n <td\n [class]=\"col.tdClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n [style.max-width.px]=\"col.maxWidth\"\n [attr.data-label]=\"col.column.title\"\n [attr.id]=\"col.label ? rowLabelId(entry.id) : null\"\n [attr.tabindex]=\"editGrid() ? cellTabindex(entry, col) : null\"\n [class.wr-table__td--editable]=\"col.editTemplate ? cellEditable(entry.row, col) : false\"\n [class.wr-table__td--editing]=\"cellEdit !== null\"\n >\n <!-- Empty, and laid under the whole row by the stylesheet: the\n cell's content is the consumer's and may hold controls,\n which an anchor cannot wrap. Gone while its cell is edited,\n where the editor is sized as the cell's only child. -->\n @if (link && col.link && !cellEdit) {\n <!-- eslint-disable-next-line @angular-eslint/template/elements-content -->\n <a\n class=\"wr-table__row-link\"\n [attr.href]=\"link.href\"\n [attr.tabindex]=\"treeMode() ? -1 : null\"\n [attr.aria-labelledby]=\"rowLabelId(entry.id)\"\n ></a>\n }\n @if (col.tree) {\n <span class=\"wr-table__tree-lead\">\n @if (entry.parent) {\n <button\n type=\"button\"\n class=\"wr-table__tree-toggle\"\n [class.wr-table__tree-toggle--open]=\"entry.open\"\n [attr.aria-expanded]=\"entry.open\"\n [attr.aria-labelledby]=\"rowControlLabelledby('toggle-row', entry.id)\"\n (click)=\"toggleTreeRow(entry.row)\"\n >\n <svg\n class=\"wr-icon__svg wr-table__tree-icon\"\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 </button>\n } @else {\n <span class=\"wr-table__tree-toggle wr-table__tree-toggle--leaf\" aria-hidden=\"true\"></span>\n }\n </span>\n }\n @if (cellEdit) {\n <ng-container\n [ngTemplateOutlet]=\"col.editTemplate ?? null\"\n [ngTemplateOutletContext]=\"cellEdit.context\"\n />\n } @else if (col.template; as tpl) {\n @if (col.actions) {\n <div class=\"wr-table__actions\">\n <ng-container\n [ngTemplateOutlet]=\"tpl\"\n [ngTemplateOutletContext]=\"cellContext(entry.row, col)\"\n />\n </div>\n } @else {\n <ng-container [ngTemplateOutlet]=\"tpl\" [ngTemplateOutletContext]=\"cellContext(entry.row, col)\" />\n }\n } @else {\n {{ cellText(entry.row, col.key, col.column) }}\n }\n </td>\n }\n </tr>\n @if (expandable() && isExpanded(entry.row)) {\n <tr class=\"wr-table__detail-row\">\n <td class=\"wr-table__detail\" [attr.colspan]=\"totalCols()\">\n <ng-container\n [ngTemplateOutlet]=\"expandTemplate() ?? null\"\n [ngTemplateOutletContext]=\"expandContext(entry.row)\"\n />\n </td>\n </tr>\n }\n }\n }\n @if (virtualized() && virtualWindow().padBottom > 0) {\n <tr class=\"wr-table__spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"totalCols()\" [style.height.px]=\"virtualWindow().padBottom\"></td>\n </tr>\n }\n }\n <!-- Sibling of the row loop rather than its `@empty` branch, and gated on\n `loading()`. As the `@empty` branch it lived INSIDE `@if (visibleItems())`,\n which passes a nullish `[items]` straight through — so the input's own\n default rendered a header over a blank body with no \"No data\" anywhere,\n the opposite of what `items`'s docs promise. And the veil is translucent,\n so on the documented `[items]=\"[]\" [loading]=\"true\"` pair the row read\n \"No data\" through the spinner. -->\n @if (!loading() && !renderRows().length) {\n <tr>\n <td class=\"wr-table__empty\" [attr.colspan]=\"totalCols()\">{{ resolvedEmptyLabel() }}</td>\n </tr>\n }\n </tbody>\n\n @if (hasSummary() && items()?.length) {\n <tfoot #foot>\n <tr class=\"wr-table__foot-row\">\n @if (rowSelection()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @if (expandable()) {\n <td class=\"wr-table__foot-cell wr-table__foot-cell--lead\"></td>\n }\n @for (col of cellColumns(); track col.key) {\n <td\n [class]=\"col.footClass\"\n [class.wr-table__td--pin-left]=\"col.pinLeft\"\n [class.wr-table__td--pin-right]=\"col.pinRight\"\n [class.wr-table__td--pin-edge-left]=\"col.edgeLeft\"\n [class.wr-table__td--pin-edge-right]=\"col.edgeRight\"\n [style.inset-inline-start.px]=\"col.start\"\n [style.inset-inline-end.px]=\"col.end\"\n >\n {{ summaryFor(col.key) }}\n </td>\n }\n </tr>\n </tfoot>\n }\n </table>\n</div>\n\n@if (showPager()) {\n <div class=\"wr-table__pager\">\n <wr-pagination\n [page]=\"page()\"\n (pageChange)=\"onPagerPage($event)\"\n [pageSize]=\"currentPageSize()\"\n (pageSizeChange)=\"onPageSizeChange($event)\"\n [total]=\"resolvedTotal()\"\n [size]=\"paginationSize()\"\n [showSizeChanger]=\"pageSizeOptions().length > 0\"\n [pageSizeOptions]=\"pageSizeOptions()\"\n />\n </div>\n}\n\n<!-- The table's one tooltip, for a header hint or a cut cell (see `tip`). -->\n@if (tip(); as shown) {\n <span hidden [wrPopover]=\"shown.text\" mode=\"tooltip\" [wrPopoverOrigin]=\"shown.el\"></span>\n}\n\n<!-- The action words the row and group controls are named with, once per table.\n `aria-labelledby` reads a hidden element it points at, so each control joins\n one of these to its own row's (or group's) label. Only the words a control\n in this table uses are rendered. -->\n@if (rowSelection() || expandable() || treeMode() || groupBy() !== null) {\n <div hidden>\n @if (rowSelection()) {\n <span [id]=\"actionId('select-row')\">{{ resolvedSelectRowLabel() }}</span>\n }\n @if (expandable()) {\n <span [id]=\"actionId('expand-row')\">{{ resolvedExpandRowLabel() }}</span>\n }\n @if (treeMode()) {\n <span [id]=\"actionId('toggle-row')\">{{ resolvedToggleRowLabel() }}</span>\n }\n @if (groupBy() !== null) {\n @if (rowSelection() === 'multiple') {\n <span [id]=\"actionId('select-group')\">{{ resolvedSelectGroupLabel() }}</span>\n }\n <span [id]=\"actionId('toggle-group')\">{{ resolvedToggleGroupLabel() }}</span>\n }\n </div>\n}\n"
|
|
3262
3275
|
}]
|
|
3263
3276
|
}],
|
|
3264
3277
|
ctorParameters: () => [],
|