ngwr 14.1.0 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -22
- package/command-palette/styles/_index.scss +17 -0
- package/fesm2022/ngwr-breadcrumbs.mjs +2 -2
- package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
- package/fesm2022/ngwr-calendar.mjs +4 -2
- package/fesm2022/ngwr-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +2 -2
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-command-palette.mjs +2 -2
- package/fesm2022/ngwr-command-palette.mjs.map +1 -1
- package/fesm2022/ngwr-drag-drop.mjs +2 -2
- package/fesm2022/ngwr-drag-drop.mjs.map +1 -1
- package/fesm2022/ngwr-event-calendar.mjs +17 -5
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs +30 -1
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ar.mjs +429 -0
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-cs.mjs +399 -0
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-de.mjs +418 -0
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-en.mjs +23 -0
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +399 -0
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-fr.mjs +423 -0
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-he.mjs +422 -0
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-hi.mjs +399 -0
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-id.mjs +399 -0
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-it.mjs +418 -0
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-ja.mjs +403 -0
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-ko.mjs +411 -0
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-nl.mjs +415 -0
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-pl.mjs +425 -0
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-pt.mjs +408 -0
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-ru.mjs +11 -0
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +399 -0
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-tr.mjs +423 -0
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-uk.mjs +420 -0
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-vi.mjs +416 -0
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-zh-TW.mjs +407 -0
- package/fesm2022/ngwr-i18n-zh-TW.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-zh.mjs +398 -0
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -0
- package/fesm2022/ngwr-lightbox.mjs +2 -2
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-line-chart.mjs +24 -4
- package/fesm2022/ngwr-line-chart.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +2 -2
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +75 -10
- package/fesm2022/ngwr-pipes.mjs.map +1 -1
- package/fesm2022/ngwr-schema-form.mjs +185 -0
- package/fesm2022/ngwr-schema-form.mjs.map +1 -0
- package/fesm2022/ngwr-select.mjs +2 -2
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-validators.mjs +8 -1
- package/fesm2022/ngwr-validators.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/i18n/ar.json +389 -0
- package/i18n/cs.json +389 -0
- package/i18n/de.json +389 -0
- package/i18n/en.json +10 -2
- package/i18n/es.json +389 -0
- package/i18n/fr.json +389 -0
- package/i18n/he.json +389 -0
- package/i18n/hi.json +389 -0
- package/i18n/id.json +389 -0
- package/i18n/it.json +389 -0
- package/i18n/ja.json +389 -0
- package/i18n/ko.json +389 -0
- package/i18n/nl.json +389 -0
- package/i18n/pl.json +389 -0
- package/i18n/pt.json +389 -0
- package/i18n/ru.json +10 -2
- package/i18n/sv.json +389 -0
- package/i18n/tr.json +389 -0
- package/i18n/uk.json +389 -0
- package/i18n/vi.json +389 -0
- package/i18n/zh-TW.json +389 -0
- package/i18n/zh.json +389 -0
- package/llms-full.txt +87 -1
- package/llms.txt +1 -1
- package/package.json +89 -7
- package/schema-form/styles/_index.scss +15 -0
- package/schematics/migrations/v9/index.js +11 -3
- package/schematics/use/symbol-map.json +1 -0
- package/skills/ngwr/SKILL.md +1 -1
- package/skills/ngwr/references/catalog.md +21 -0
- package/styles.scss +1 -0
- package/theme/styles/_focus.scss +23 -2
- package/types/ngwr-calendar.d.ts +2 -0
- package/types/ngwr-command-palette.d.ts +1 -1
- package/types/ngwr-event-calendar.d.ts +5 -0
- package/types/ngwr-form.d.ts +88 -2
- package/types/ngwr-i18n-ar.d.ts +6 -0
- package/types/ngwr-i18n-cs.d.ts +6 -0
- package/types/ngwr-i18n-de.d.ts +6 -0
- package/types/ngwr-i18n-es.d.ts +6 -0
- package/types/ngwr-i18n-fr.d.ts +6 -0
- package/types/ngwr-i18n-he.d.ts +6 -0
- package/types/ngwr-i18n-hi.d.ts +6 -0
- package/types/ngwr-i18n-id.d.ts +6 -0
- package/types/ngwr-i18n-it.d.ts +6 -0
- package/types/ngwr-i18n-ja.d.ts +6 -0
- package/types/ngwr-i18n-ko.d.ts +6 -0
- package/types/ngwr-i18n-nl.d.ts +6 -0
- package/types/ngwr-i18n-pl.d.ts +6 -0
- package/types/ngwr-i18n-pt.d.ts +6 -0
- package/types/ngwr-i18n-sv.d.ts +6 -0
- package/types/ngwr-i18n-tr.d.ts +6 -0
- package/types/ngwr-i18n-uk.d.ts +6 -0
- package/types/ngwr-i18n-vi.d.ts +6 -0
- package/types/ngwr-i18n-zh-TW.d.ts +6 -0
- package/types/ngwr-i18n-zh.d.ts +6 -0
- package/types/ngwr-line-chart.d.ts +15 -0
- package/types/ngwr-pipes.d.ts +45 -4
- package/types/ngwr-schema-form.d.ts +90 -0
- package/types/ngwr-version.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-lightbox.mjs","sources":["../../../projects/lib/lightbox/lightbox.ts","../../../projects/lib/lightbox/lightbox.html","../../../projects/lib/lightbox/ngwr-lightbox.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 { type ConfigurableFocusTrap, ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { type OverlayRef } from '@angular/cdk/overlay';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport type { TemplateRef } from '@angular/core';\nimport {\n Component,\n DestroyRef,\n ViewContainerRef,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n signal,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { WR_OVERLAY } from 'ngwr/overlay';\n\nlet viewerUid = 0;\n\n/**\n * Image with click-to-zoom lightbox. The thumbnail is a plain `<img>`\n * with whatever sizing/`object-fit` you give it; clicking opens a CDK\n * overlay showing the full image, with Escape + close button + backdrop\n * to dismiss.\n *\n * @example\n * ```html\n * <wr-lightbox\n * src=\"/photo.jpg\"\n * alt=\"Mountain\"\n * style=\"width: 16rem; height: 10rem; object-fit: cover\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/lightbox\n */\n@Component({\n selector: 'wr-lightbox',\n templateUrl: './lightbox.html',\n styleUrl: './lightbox.scss',\n encapsulation: ViewEncapsulation.None,\n host: {\n '[class]': 'classes()',\n '[style.aspect-ratio]': 'aspectRatio()',\n },\n})\nexport class WrLightbox {\n /** Accessible name. Falls back to `image.close`, then `'Close preview'`. */\n /** Accessible name of the thumbnail button. Falls back to `alt`, then `image.open`. */\n readonly openLabel = input<string | null>(null);\n\n readonly closeLabel = input<string | null>(null);\n\n protected readonly resolvedCloseLabel = useI18nText(this.closeLabel, 'image.close', 'Close preview');\n\n /** Image source. */\n readonly src = input.required<string>();\n\n /** Alt text. Required for a11y; falls back to an empty string. @default '' */\n readonly alt = input<string>('');\n\n /**\n * Lighter source for the THUMBNAIL — a small or blurred copy, so the grid does not\n * pull full-size images. The viewer always shows `src`; the thumbnail does not swap\n * to it later.\n */\n readonly preview = input<string | null>(null);\n\n // Both of these were hard-coded English literals in the template, next to a catalog\n // that already carried `image.open` translated and unread. `useI18nText` already\n // does the whole chain — a non-empty binding wins, then the catalog, then the\n // English default — so the alt text (which describes the actual picture) is what\n // gets forwarded, with `openLabel` ahead of it as the explicit override.\n protected readonly resolvedOpenLabel = useI18nText(\n computed(() => {\n // Not `??`: an empty `openLabel` is no label at all, so it has to fall through\n // to the alt text rather than winning as an empty string.\n const explicit = this.openLabel();\n if (explicit) return explicit;\n return this.alt();\n }),\n 'image.open',\n 'Open preview'\n );\n\n protected readonly resolvedViewerLabel = useI18nText(this.alt, 'image.viewer', 'Image preview');\n\n /** Disable the click-to-zoom lightbox. @default false */\n readonly disablePreview = input(false, { transform: coerceBooleanProperty });\n\n /** Caption shown under the full image in the lightbox. */\n readonly caption = input<string>('');\n\n /**\n * Reserve space before the image resolves by fixing the thumbnail's\n * `aspect-ratio` (e.g. `'16 / 9'`, `'4 / 3'`, or a number like `1.5`).\n * Prevents the layout jump when the intrinsic image size isn't known up\n * front — pair it with a `width` and the box keeps its height from first\n * paint. @default null\n */\n readonly aspectRatio = input<string | number | null>(null);\n\n protected readonly open = signal(false);\n protected readonly loaded = signal(false);\n\n /**\n * Id the trigger's `aria-controls` points at while the viewer is open.\n *\n * @internal Public so the host bindings can read it.\n */\n protected readonly viewerId = `wr-lightbox-viewer-${++viewerUid}`;\n\n protected readonly classes = computed(() => {\n const parts = ['wr-lightbox'];\n if (this.open()) parts.push('wr-lightbox--open');\n if (!this.loaded()) parts.push('wr-lightbox--loading');\n return parts.join(' ');\n });\n\n // Query by name — `@if` blocks register their own TemplateRefs, so an\n // unqualified TemplateRef query would grab the thumbnail branch instead.\n protected readonly panelTpl = viewChild.required<TemplateRef<unknown>>('viewerTpl');\n\n private readonly overlay = inject(WR_OVERLAY);\n private readonly vcr = inject(ViewContainerRef);\n private readonly destroyRef = inject(DestroyRef);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private focusTrap: ConfigurableFocusTrap | null = null;\n private previouslyFocused: HTMLElement | null = null;\n private overlayRef: OverlayRef | null = null;\n\n constructor() {\n // Destroying the component while the viewer is open removes the projected\n // content (the portal uses this component's ViewContainerRef) but leaves the\n // overlay pane and its full-screen backdrop behind, with page scroll still\n // blocked. Dispose the overlay explicitly.\n this.destroyRef.onDestroy(() => this.closeOverlay());\n\n effect(() => {\n if (this.open()) this.openOverlay();\n else this.closeOverlay();\n });\n }\n\n protected onClick(): void {\n if (this.disablePreview()) return;\n this.open.set(true);\n }\n\n protected onClose(): void {\n this.open.set(false);\n }\n\n // Swipe-down-to-dismiss on the open viewer. The image follows the finger and\n // fades; releasing past ~20% of the viewer height closes it.\n private viewerStartY = 0;\n private viewerSwiping = false;\n\n protected onViewerSwipeStart(event: TouchEvent): void {\n const touch = event.touches[0];\n if (!touch) return;\n this.viewerStartY = touch.clientY;\n this.viewerSwiping = true;\n }\n\n protected onViewerSwipeMove(event: TouchEvent, viewer: HTMLElement): void {\n if (!this.viewerSwiping) return;\n const touch = event.touches[0];\n if (!touch) return;\n const dy = touch.clientY - this.viewerStartY;\n if (dy <= 0) {\n viewer.style.transform = '';\n viewer.style.opacity = '';\n return;\n }\n event.preventDefault();\n viewer.style.transition = 'none';\n viewer.style.transform = `translateY(${dy}px)`;\n viewer.style.opacity = String(Math.max(0.3, 1 - dy / (viewer.offsetHeight || 1)));\n }\n\n protected onViewerSwipeEnd(event: TouchEvent, viewer: HTMLElement): void {\n if (!this.viewerSwiping) return;\n this.viewerSwiping = false;\n const touch = event.changedTouches[0];\n const dy = touch ? touch.clientY - this.viewerStartY : 0;\n if (dy > (viewer.offsetHeight || 0) * 0.2) {\n this.onClose();\n } else {\n viewer.style.transition = '';\n viewer.style.transform = '';\n viewer.style.opacity = '';\n }\n }\n\n /**\n * The thumbnail has settled, one way or the other. A failure counts: `--loading`\n * animates a shimmer AND sets `opacity: 0` on the image, so a broken `src` with no\n * error path left an invisible box shimmering for ever instead of showing its alt\n * text.\n */\n protected onSettled(): void {\n this.loaded.set(true);\n }\n\n // Overlay\n\n private openOverlay(): void {\n if (this.overlayRef) return;\n\n this.overlayRef = this.overlay.create({\n hasBackdrop: true,\n backdropClass: 'wr-lightbox-backdrop',\n positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),\n scrollStrategy: this.overlay.scrollStrategies.block(),\n panelClass: 'wr-lightbox-overlay',\n });\n\n const portal = new TemplatePortal(this.panelTpl(), this.vcr);\n this.overlayRef.attach(portal);\n\n // The viewer declares role=\"dialog\" + aria-modal=\"true\", which promises the\n // rest of the page is inert. Without a focus trap that promise is a lie:\n // Tab walks straight out of the viewer into the page behind the backdrop.\n const active = document.activeElement;\n this.previouslyFocused = active instanceof HTMLElement ? active : null;\n this.focusTrap = this.focusTrapFactory.create(this.overlayRef.overlayElement);\n void this.focusTrap.focusInitialElementWhenReady();\n\n this.overlayRef\n .backdropClick()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(() => this.open.set(false));\n\n this.overlayRef\n .keydownEvents()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (event.key === 'Escape') {\n event.preventDefault();\n this.open.set(false);\n }\n });\n }\n\n private closeOverlay(): void {\n if (!this.overlayRef) return;\n this.focusTrap?.destroy();\n this.focusTrap = null;\n const restore = this.previouslyFocused;\n this.previouslyFocused = null;\n this.overlayRef.dispose();\n this.overlayRef = null;\n // Send focus back where it came from, or it lands on <body> and the user\n // has to tab from the top of the page again.\n if (restore && typeof restore.focus === 'function') restore.focus();\n }\n}\n","@if (disablePreview()) {\n <img\n class=\"wr-lightbox__thumb\"\n [src]=\"preview() || src()\"\n [alt]=\"alt()\"\n (load)=\"onSettled()\"\n (error)=\"onSettled()\"\n loading=\"lazy\"\n decoding=\"async\"\n />\n} @else {\n <!-- The trigger opens a modal dialog, and used to say so nowhere: no hint that it\n opens anything, and nothing on the page tying it to the viewer it opened. -->\n <button\n type=\"button\"\n class=\"wr-lightbox__trigger\"\n aria-haspopup=\"dialog\"\n [attr.aria-controls]=\"open() ? viewerId : null\"\n [attr.aria-label]=\"resolvedOpenLabel()\"\n (click)=\"onClick()\"\n >\n <img\n class=\"wr-lightbox__thumb\"\n [src]=\"preview() || src()\"\n [alt]=\"alt()\"\n (load)=\"onSettled()\"\n (error)=\"onSettled()\"\n loading=\"lazy\"\n decoding=\"async\"\n />\n </button>\n}\n\n<ng-template #viewerTpl>\n <div\n #viewer\n class=\"wr-lightbox-viewer\"\n [id]=\"viewerId\"\n role=\"dialog\"\n aria-modal=\"true\"\n [attr.aria-label]=\"resolvedViewerLabel()\"\n (touchstart)=\"onViewerSwipeStart($event)\"\n (touchmove)=\"onViewerSwipeMove($event, viewer)\"\n (touchend)=\"onViewerSwipeEnd($event, viewer)\"\n (touchcancel)=\"onViewerSwipeEnd($event, viewer)\"\n >\n <button\n type=\"button\"\n class=\"wr-lightbox-viewer__close\"\n [attr.aria-label]=\"resolvedCloseLabel()\"\n (click)=\"onClose()\"\n (keydown.enter)=\"onClose()\"\n (keydown.space)=\"onClose()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </button>\n <!--\n Styled `cursor: zoom-out`, which is a promise: clicking the image closes. A\n REDUNDANT mouse affordance — the close button, Escape, the backdrop and\n swipe-down all do the same thing and all reach a keyboard — so the image stays\n out of the tab order rather than becoming a second close stop.\n -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <img class=\"wr-lightbox-viewer__full\" [src]=\"src()\" [alt]=\"alt()\" (click)=\"onClose()\" />\n @if (caption()) {\n <div class=\"wr-lightbox-viewer__caption\">{{ caption() }}</div>\n }\n </div>\n</ng-template>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;AAKG;AAwBH,IAAI,SAAS,GAAG,CAAC;AAEjB;;;;;;;;;;;;;;;;AAgBG;MAWU,UAAU,CAAA;;;IAGZ,SAAS,GAAG,KAAK,CAAgB,IAAI;kFAAC;IAEtC,UAAU,GAAG,KAAK,CAAgB,IAAI;mFAAC;IAE7B,kBAAkB,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,E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BAAA,SAAS,EAAE,WAAW;AACtB,wBAAA,sBAAsB,EAAE,eAAe;AACxC,qBAAA,EAAA,QAAA,EAAA,ynFAAA,EAAA,MAAA,EAAA,CAAA,4qOAAA,CAAA,EAAA;+1BA6EsE,WAAW,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AErIpF;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngwr-lightbox.mjs","sources":["../../../projects/lib/lightbox/lightbox.ts","../../../projects/lib/lightbox/lightbox.html","../../../projects/lib/lightbox/ngwr-lightbox.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 { type ConfigurableFocusTrap, ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { type OverlayRef } from '@angular/cdk/overlay';\nimport { TemplatePortal } from '@angular/cdk/portal';\nimport type { TemplateRef } from '@angular/core';\nimport {\n Component,\n DestroyRef,\n ViewContainerRef,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n signal,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { WR_OVERLAY } from 'ngwr/overlay';\n\nlet viewerUid = 0;\n\n/**\n * Image with click-to-zoom lightbox. The thumbnail is a plain `<img>`\n * with whatever sizing/`object-fit` you give it; clicking opens a CDK\n * overlay showing the full image, with Escape + close button + backdrop\n * to dismiss.\n *\n * @example\n * ```html\n * <wr-lightbox\n * src=\"/photo.jpg\"\n * alt=\"Mountain\"\n * style=\"width: 16rem; height: 10rem; object-fit: cover\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/lightbox\n */\n@Component({\n selector: 'wr-lightbox',\n templateUrl: './lightbox.html',\n styleUrl: './lightbox.scss',\n encapsulation: ViewEncapsulation.None,\n host: {\n '[class]': 'classes()',\n '[style.aspect-ratio]': 'aspectRatio()',\n },\n})\nexport class WrLightbox {\n /** Accessible name. Falls back to `image.close`, then `'Close preview'`. */\n /** Accessible name of the thumbnail button. Falls back to `alt`, then `image.open`. */\n readonly openLabel = input<string | null>(null);\n\n readonly closeLabel = input<string | null>(null);\n\n protected readonly resolvedCloseLabel = useI18nText(this.closeLabel, 'image.close', 'Close preview');\n\n /** Image source. */\n readonly src = input.required<string>();\n\n /** Alt text. Required for a11y; falls back to an empty string. @default '' */\n readonly alt = input<string>('');\n\n /**\n * Lighter source for the THUMBNAIL — a small or blurred copy, so the grid does not\n * pull full-size images. The viewer always shows `src`; the thumbnail does not swap\n * to it later.\n */\n readonly preview = input<string | null>(null);\n\n // Both of these were hard-coded English literals in the template, next to a catalog\n // that already carried `image.open` translated and unread. `useI18nText` already\n // does the whole chain — a non-empty binding wins, then the catalog, then the\n // English default — so the alt text (which describes the actual picture) is what\n // gets forwarded, with `openLabel` ahead of it as the explicit override.\n protected readonly resolvedOpenLabel = useI18nText(\n computed(() => {\n // Not `??`: an empty `openLabel` is no label at all, so it has to fall through\n // to the alt text rather than winning as an empty string.\n const explicit = this.openLabel();\n if (explicit) return explicit;\n return this.alt();\n }),\n 'image.open',\n 'Open preview'\n );\n\n protected readonly resolvedViewerLabel = useI18nText(this.alt, 'image.viewer', 'Image preview');\n\n /** Disable the click-to-zoom lightbox. @default false */\n readonly disablePreview = input(false, { transform: coerceBooleanProperty });\n\n /** Caption shown under the full image in the lightbox. */\n readonly caption = input<string>('');\n\n /**\n * Reserve space before the image resolves by fixing the thumbnail's\n * `aspect-ratio` (e.g. `'16 / 9'`, `'4 / 3'`, or a number like `1.5`).\n * Prevents the layout jump when the intrinsic image size isn't known up\n * front — pair it with a `width` and the box keeps its height from first\n * paint. @default null\n */\n readonly aspectRatio = input<string | number | null>(null);\n\n protected readonly open = signal(false);\n protected readonly loaded = signal(false);\n\n /**\n * Id the trigger's `aria-controls` points at while the viewer is open.\n *\n * @internal Public so the host bindings can read it.\n */\n protected readonly viewerId = `wr-lightbox-viewer-${++viewerUid}`;\n\n protected readonly classes = computed(() => {\n const parts = ['wr-lightbox'];\n if (this.open()) parts.push('wr-lightbox--open');\n if (!this.loaded()) parts.push('wr-lightbox--loading');\n return parts.join(' ');\n });\n\n // Query by name — `@if` blocks register their own TemplateRefs, so an\n // unqualified TemplateRef query would grab the thumbnail branch instead.\n protected readonly panelTpl = viewChild.required<TemplateRef<unknown>>('viewerTpl');\n\n private readonly overlay = inject(WR_OVERLAY);\n private readonly vcr = inject(ViewContainerRef);\n private readonly destroyRef = inject(DestroyRef);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private focusTrap: ConfigurableFocusTrap | null = null;\n private previouslyFocused: HTMLElement | null = null;\n private overlayRef: OverlayRef | null = null;\n\n constructor() {\n // Destroying the component while the viewer is open removes the projected\n // content (the portal uses this component's ViewContainerRef) but leaves the\n // overlay pane and its full-screen backdrop behind, with page scroll still\n // blocked. Dispose the overlay explicitly.\n this.destroyRef.onDestroy(() => this.closeOverlay());\n\n effect(() => {\n if (this.open()) this.openOverlay();\n else this.closeOverlay();\n });\n }\n\n protected onClick(): void {\n if (this.disablePreview()) return;\n this.open.set(true);\n }\n\n protected onClose(): void {\n this.open.set(false);\n }\n\n // Swipe-down-to-dismiss on the open viewer. The image follows the finger and\n // fades; releasing past ~20% of the viewer height closes it.\n private viewerStartY = 0;\n private viewerSwiping = false;\n\n protected onViewerSwipeStart(event: TouchEvent): void {\n const touch = event.touches[0];\n if (!touch) return;\n this.viewerStartY = touch.clientY;\n this.viewerSwiping = true;\n }\n\n protected onViewerSwipeMove(event: TouchEvent, viewer: HTMLElement): void {\n if (!this.viewerSwiping) return;\n const touch = event.touches[0];\n if (!touch) return;\n const dy = touch.clientY - this.viewerStartY;\n if (dy <= 0) {\n viewer.style.transform = '';\n viewer.style.opacity = '';\n return;\n }\n event.preventDefault();\n viewer.style.transition = 'none';\n viewer.style.transform = `translateY(${dy}px)`;\n viewer.style.opacity = String(Math.max(0.3, 1 - dy / (viewer.offsetHeight || 1)));\n }\n\n protected onViewerSwipeEnd(event: TouchEvent, viewer: HTMLElement): void {\n if (!this.viewerSwiping) return;\n this.viewerSwiping = false;\n const touch = event.changedTouches[0];\n const dy = touch ? touch.clientY - this.viewerStartY : 0;\n if (dy > (viewer.offsetHeight || 0) * 0.2) {\n this.onClose();\n } else {\n viewer.style.transition = '';\n viewer.style.transform = '';\n viewer.style.opacity = '';\n }\n }\n\n /**\n * The thumbnail has settled, one way or the other. A failure counts: `--loading`\n * animates a shimmer AND sets `opacity: 0` on the image, so a broken `src` with no\n * error path left an invisible box shimmering for ever instead of showing its alt\n * text.\n */\n protected onSettled(): void {\n this.loaded.set(true);\n }\n\n // Overlay\n\n private openOverlay(): void {\n if (this.overlayRef) return;\n\n this.overlayRef = this.overlay.create({\n hasBackdrop: true,\n backdropClass: 'wr-lightbox-backdrop',\n positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),\n scrollStrategy: this.overlay.scrollStrategies.block(),\n panelClass: 'wr-lightbox-overlay',\n });\n\n const portal = new TemplatePortal(this.panelTpl(), this.vcr);\n this.overlayRef.attach(portal);\n\n // The viewer declares role=\"dialog\" + aria-modal=\"true\", which promises the\n // rest of the page is inert. Without a focus trap that promise is a lie:\n // Tab walks straight out of the viewer into the page behind the backdrop.\n const active = document.activeElement;\n this.previouslyFocused = active instanceof HTMLElement ? active : null;\n this.focusTrap = this.focusTrapFactory.create(this.overlayRef.overlayElement);\n void this.focusTrap.focusInitialElementWhenReady();\n\n this.overlayRef\n .backdropClick()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(() => this.open.set(false));\n\n this.overlayRef\n .keydownEvents()\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (event.key === 'Escape') {\n event.preventDefault();\n this.open.set(false);\n }\n });\n }\n\n private closeOverlay(): void {\n if (!this.overlayRef) return;\n this.focusTrap?.destroy();\n this.focusTrap = null;\n const restore = this.previouslyFocused;\n this.previouslyFocused = null;\n this.overlayRef.dispose();\n this.overlayRef = null;\n // Send focus back where it came from, or it lands on <body> and the user\n // has to tab from the top of the page again.\n if (restore && typeof restore.focus === 'function') restore.focus();\n }\n}\n","@if (disablePreview()) {\n <img\n class=\"wr-lightbox__thumb\"\n [src]=\"preview() || src()\"\n [alt]=\"alt()\"\n (load)=\"onSettled()\"\n (error)=\"onSettled()\"\n loading=\"lazy\"\n decoding=\"async\"\n />\n} @else {\n <!-- The trigger opens a modal dialog, and used to say so nowhere: no hint that it\n opens anything, and nothing on the page tying it to the viewer it opened. -->\n <button\n type=\"button\"\n class=\"wr-lightbox__trigger\"\n aria-haspopup=\"dialog\"\n [attr.aria-controls]=\"open() ? viewerId : null\"\n [attr.aria-label]=\"resolvedOpenLabel()\"\n (click)=\"onClick()\"\n >\n <img\n class=\"wr-lightbox__thumb\"\n [src]=\"preview() || src()\"\n [alt]=\"alt()\"\n (load)=\"onSettled()\"\n (error)=\"onSettled()\"\n loading=\"lazy\"\n decoding=\"async\"\n />\n </button>\n}\n\n<ng-template #viewerTpl>\n <div\n #viewer\n class=\"wr-lightbox-viewer\"\n [id]=\"viewerId\"\n role=\"dialog\"\n aria-modal=\"true\"\n [attr.aria-label]=\"resolvedViewerLabel()\"\n (touchstart)=\"onViewerSwipeStart($event)\"\n (touchmove)=\"onViewerSwipeMove($event, viewer)\"\n (touchend)=\"onViewerSwipeEnd($event, viewer)\"\n (touchcancel)=\"onViewerSwipeEnd($event, viewer)\"\n >\n <button\n type=\"button\"\n class=\"wr-lightbox-viewer__close\"\n [attr.aria-label]=\"resolvedCloseLabel()\"\n (click)=\"onClose()\"\n (keydown.enter)=\"onClose()\"\n (keydown.space)=\"onClose()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </button>\n <!--\n Styled `cursor: zoom-out`, which is a promise: clicking the image closes. A\n REDUNDANT mouse affordance — the close button, Escape, the backdrop and\n swipe-down all do the same thing and all reach a keyboard — so the image stays\n out of the tab order rather than becoming a second close stop.\n -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <img class=\"wr-lightbox-viewer__full\" [src]=\"src()\" [alt]=\"alt()\" (click)=\"onClose()\" />\n @if (caption()) {\n <div class=\"wr-lightbox-viewer__caption\">{{ caption() }}</div>\n }\n </div>\n</ng-template>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;AAKG;AAwBH,IAAI,SAAS,GAAG,CAAC;AAEjB;;;;;;;;;;;;;;;;AAgBG;MAWU,UAAU,CAAA;;;IAGZ,SAAS,GAAG,KAAK,CAAgB,IAAI;kFAAC;IAEtC,UAAU,GAAG,KAAK,CAAgB,IAAI;mFAAC;IAE7B,kBAAkB,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,EAAE,eAAe,CAAC;;IAG3F,GAAG,GAAG,KAAK,CAAC,QAAQ;4EAAU;;IAG9B,GAAG,GAAG,KAAK,CAAS,EAAE;4EAAC;AAEhC;;;;AAIG;IACM,OAAO,GAAG,KAAK,CAAgB,IAAI;gFAAC;;;;;;AAO1B,IAAA,iBAAiB,GAAG,WAAW,CAChD,QAAQ,CAAC,MAAK;;;AAGZ,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE;AACjC,QAAA,IAAI,QAAQ;AAAE,YAAA,OAAO,QAAQ;AAC7B,QAAA,OAAO,IAAI,CAAC,GAAG,EAAE;AACnB,IAAA,CAAC,CAAC,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rB,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB;AACtC,QAAA,IAAI,CAAC,iBAAiB,GAAG,IAAI;AAC7B,QAAA,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;AACzB,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI;;;AAGtB,QAAA,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU;YAAE,OAAO,CAAC,KAAK,EAAE;IACrE;uGAlNW,UAAU,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAV,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAU,wyCC1DvB,ynFAkFA,EAAA,MAAA,EAAA,CAAA,6nOAAA,CAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FDxBa,UAAU,EAAA,UAAA,EAAA,CAAA;kBAVtB,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,aAAa,EAAA,aAAA,EAGR,iBAAiB,CAAC,IAAI,EAAA,IAAA,EAC/B;AACJ,wBAAA,SAAS,EAAE,WAAW;AACtB,wBAAA,sBAAsB,EAAE,eAAe;AACxC,qBAAA,EAAA,QAAA,EAAA,ynFAAA,EAAA,MAAA,EAAA,CAAA,6nOAAA,CAAA,EAAA;+1BA6EsE,WAAW,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AErIpF;;AAEG;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { coerceNumberProperty, coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { input, inject, ElementRef, signal, computed, ViewEncapsulation, Component } from '@angular/core';
|
|
4
|
-
import { useI18nText } from 'ngwr/i18n';
|
|
3
|
+
import { input, inject, LOCALE_ID, ElementRef, signal, computed, ViewEncapsulation, Component } from '@angular/core';
|
|
4
|
+
import { useI18nText, useI18nFormatter } from 'ngwr/i18n';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
@@ -44,6 +44,8 @@ class WrLineChart {
|
|
|
44
44
|
ariaLabel = input(null, /* @ts-ignore */
|
|
45
45
|
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
46
46
|
resolvedAriaLabel = useI18nText(this.ariaLabel, 'lineChart.label', 'Line chart');
|
|
47
|
+
locale = inject(LOCALE_ID);
|
|
48
|
+
thousandsText = useI18nFormatter('lineChart.thousands', '{{value}}k');
|
|
47
49
|
/** Labels for the X axis (one per data point). */
|
|
48
50
|
xLabels = input([], /* @ts-ignore */
|
|
49
51
|
...(ngDevMode ? [{ debugName: "xLabels" }] : /* istanbul ignore next */ []));
|
|
@@ -211,10 +213,28 @@ class WrLineChart {
|
|
|
211
213
|
onPointerLeave() {
|
|
212
214
|
this.hoveredIndex.set(null);
|
|
213
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* A Y-axis tick, in the reader's own language.
|
|
218
|
+
*
|
|
219
|
+
* Two halves and both were English. The `k` was a hardcoded Latin
|
|
220
|
+
* abbreviation — `тыс.` in Russian — so it goes through the catalog like every
|
|
221
|
+
* other word the library paints. The digits went through `toFixed`, which
|
|
222
|
+
* always writes a full stop, so a German axis read `1.5` where the rest of the
|
|
223
|
+
* page read `1,5`; they go through `Intl` now, the way `wrNumber`, `wrDate`
|
|
224
|
+
* and `wrPlural` already did.
|
|
225
|
+
*
|
|
226
|
+
* Grouping is OFF deliberately: a tick is a short axis label, and `5,000k`
|
|
227
|
+
* would be both wider and a change to what every existing chart draws.
|
|
228
|
+
*/
|
|
214
229
|
formatTick(v) {
|
|
230
|
+
const digits = (n, fraction) => new Intl.NumberFormat(this.locale, {
|
|
231
|
+
useGrouping: false,
|
|
232
|
+
minimumFractionDigits: fraction,
|
|
233
|
+
maximumFractionDigits: fraction,
|
|
234
|
+
}).format(n);
|
|
215
235
|
if (Math.abs(v) >= 1000)
|
|
216
|
-
return
|
|
217
|
-
return
|
|
236
|
+
return this.thousandsText({ value: digits(v / 1000, v % 1000 === 0 ? 0 : 1) });
|
|
237
|
+
return digits(v, v % 1 === 0 ? 0 : 1);
|
|
218
238
|
}
|
|
219
239
|
viewBox = computed(() => `0 0 ${this.vbW} ${this.vbH}`, /* @ts-ignore */
|
|
220
240
|
...(ngDevMode ? [{ debugName: "viewBox" }] : /* istanbul ignore next */ []));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-line-chart.mjs","sources":["../../../projects/lib/line-chart/line-chart.ts","../../../projects/lib/line-chart/line-chart.html","../../../projects/lib/line-chart/ngwr-line-chart.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 { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport { Component, ElementRef, ViewEncapsulation, computed, inject, input, signal } from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\n\nimport type { WrLineSeries } from './interfaces';\n\nconst FALLBACK_COLORS = [\n 'var(--wr-color-primary)',\n 'var(--wr-color-secondary)',\n 'var(--wr-color-success)',\n 'var(--wr-color-warning)',\n 'var(--wr-color-danger)',\n];\n\n/**\n * Multi-series line chart with axes, gridlines, and a hover tooltip.\n * SVG-only — no external dependency.\n *\n * @example\n * ```html\n * <wr-line-chart\n * [series]=\"[\n * { label: 'Visits', data: [12, 18, 9, 22, 30, 27, 35] },\n * { label: 'Signups', data: [3, 5, 4, 8, 11, 9, 14], color: 'var(--wr-color-success)' }\n * ]\"\n * [xLabels]=\"['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/line-chart\n */\n@Component({\n selector: 'wr-line-chart',\n templateUrl: './line-chart.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-line-chart' },\n})\nexport class WrLineChart {\n readonly series = input<readonly WrLineSeries[]>([]);\n\n /**\n * Accessible name of the chart. The legend carries the series NAMES only — the numbers\n * are nowhere in text — so without this the plot is nothing at all to a screen reader.\n * Falls back to `lineChart.label`.\n */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'lineChart.label', 'Line chart');\n\n /** Labels for the X axis (one per data point). */\n readonly xLabels = input<readonly string[]>([]);\n\n /** Chart pixel height. @default 240 */\n readonly height = input(240, { transform: (v: unknown): number => Math.max(80, coerceNumberProperty(v, 240)) });\n\n /** Show gridlines + axis ticks. @default true */\n readonly showGrid = input(true, { transform: coerceBooleanProperty });\n\n /** Show the legend above the chart. @default true */\n readonly showLegend = input(true, { transform: coerceBooleanProperty });\n\n /** Show dots at each data point. @default true */\n readonly showDots = input(true, { transform: coerceBooleanProperty });\n\n // Drawn in a 600×300 viewBox with reserved space for axis labels.\n protected readonly vbW = 600;\n protected readonly vbH = 300;\n protected readonly padding = { top: 16, right: 16, bottom: 28, left: 36 } as const;\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /** Hovered point index (across all series) — null when no hover. */\n protected readonly hoveredIndex = signal<number | null>(null);\n\n protected readonly resolvedSeries = computed(() =>\n this.series().map((s, i) => ({\n label: s.label,\n // A non-finite point becomes a HOLE at its own index, not a missing element.\n // It cannot stay a number: `Math.min`/`Math.max` over the pooled data are both\n // NaN as soon as one datum is, so every coordinate in EVERY series came out\n // `NaN` — invalid path geometry, and the whole chart vanished rather than the\n // one bad point. But filtering it out closed the gap and slid every LATER point\n // one x-slot to the left, so each of them was drawn under, and reported in the\n // tooltip as, the wrong x label. A gap is kept as a gap and the line is broken\n // across it: interpolating would invent a reading the data never took.\n data: s.data.map(v => (Number.isFinite(v) ? v : null)),\n color: s.color ?? FALLBACK_COLORS[i % FALLBACK_COLORS.length],\n }))\n );\n\n protected readonly bounds = computed(() => {\n const all = this.resolvedSeries().flatMap(s => s.data.filter(v => v !== null));\n if (all.length === 0) return { min: 0, max: 1 };\n const min = Math.min(...all);\n const max = Math.max(...all);\n if (min === max) return { min: min - 1, max: max + 1 };\n // Pad upper bound by ~10% for breathing room.\n return { min: Math.min(0, min), max: max + (max - min) * 0.1 };\n });\n\n protected readonly pointCount = computed(() => {\n const maxLen = this.resolvedSeries().reduce((acc, s) => Math.max(acc, s.data.length), 0);\n return Math.max(maxLen, this.xLabels().length);\n });\n\n /** Y-axis tick marks (5 of them). */\n protected readonly yTicks = computed(() => {\n const { min, max } = this.bounds();\n const step = (max - min) / 4;\n return [0, 1, 2, 3, 4].map(i => {\n const value = max - i * step;\n return { value, y: this.padding.top + ((max - value) / (max - min)) * this.plotHeight() };\n });\n });\n\n protected readonly plotWidth = (): number => this.vbW - this.padding.left - this.padding.right;\n protected readonly plotHeight = (): number => this.vbH - this.padding.top - this.padding.bottom;\n\n /**\n * The SVG path for a series — one subpath per unbroken run, so a hole in the data\n * leaves a hole in the line rather than a straight segment across it.\n */\n protected pathFor(series: { data: readonly (number | null)[] }): string {\n const { min, max } = this.bounds();\n const count = this.pointCount();\n if (count <= 1) return '';\n const pw = this.plotWidth();\n const ph = this.plotHeight();\n\n const commands: string[] = [];\n let run = 0;\n let last = '';\n // A subpath of one `M` is not stroked at all, so a point with a gap on both sides\n // would simply vanish when `showDots` is off. Repeating it gives the round linecap\n // something to paint.\n const closeRun = (): void => {\n if (run === 1) commands.push(`L ${last}`);\n run = 0;\n };\n\n series.data.forEach((v, i) => {\n if (v === null) {\n closeRun();\n return;\n }\n const x = this.padding.left + (i / (count - 1)) * pw;\n const y = this.padding.top + ((max - v) / (max - min)) * ph;\n last = `${x.toFixed(2)} ${y.toFixed(2)}`;\n commands.push(`${run === 0 ? 'M' : 'L'} ${last}`);\n run++;\n });\n closeRun();\n\n return commands.join(' ');\n }\n\n protected pointX(index: number): number {\n const count = this.pointCount();\n if (count <= 1) return this.padding.left;\n return this.padding.left + (index / (count - 1)) * this.plotWidth();\n }\n\n protected pointY(value: number): number {\n const { min, max } = this.bounds();\n return this.padding.top + ((max - value) / (max - min)) * this.plotHeight();\n }\n\n /**\n * A point's x as a percentage of the host's width. The x-label strip and the SVG share\n * that width — the drawing stretches to it — so this is the same space the tooltip and\n * the labels are placed in, at any size.\n */\n protected xPercent(index: number): number {\n return (this.pointX(index) / this.vbW) * 100;\n }\n\n /**\n * How wide an x label may be, as a percentage of the host's width: its own slot — half\n * the distance to a neighbour on each side — cut back to what is left between its point\n * and the end of the strip. Centring a label on its point says nothing about its WIDTH,\n * and with no bound at all twelve month names printed over each other and the last one\n * hung outside the chart. Past this the stylesheet ellipsises.\n */\n protected xMaxPercent(index: number): number {\n const count = this.pointCount();\n // A single label has no neighbour to collide with and the whole strip to sit in.\n if (count <= 1) return 100;\n const slot = (this.plotWidth() / (count - 1) / this.vbW) * 100;\n const x = this.xPercent(index);\n return Math.min(slot, x + slot / 2, 100 - x + slot / 2);\n }\n\n protected readonly hoverPoints = computed(() => {\n const i = this.hoveredIndex();\n if (i === null) return [];\n return this.resolvedSeries().flatMap(s => {\n // Past the end of a short series, or on a hole in a longer one — either way there\n // is no reading at this x, so the series contributes neither a marker nor a row.\n const value = s.data[i];\n if (value === undefined || value === null) return [];\n return [{ label: s.label, value, color: s.color, x: this.pointX(i), y: this.pointY(value) }];\n });\n });\n\n protected readonly hoverLabel = computed(() => {\n const i = this.hoveredIndex();\n if (i === null) return '';\n return this.xLabels()[i] ?? String(i);\n });\n\n protected onPointerMove(event: PointerEvent): void {\n const svg = (event.currentTarget as SVGElement).getBoundingClientRect();\n const ratio = (event.clientX - svg.left) / svg.width;\n const vbX = ratio * this.vbW;\n const count = this.pointCount();\n if (count === 0) return;\n const i = Math.round(((vbX - this.padding.left) / this.plotWidth()) * (count - 1));\n if (i >= 0 && i < count) this.hoveredIndex.set(i);\n }\n\n protected onPointerLeave(): void {\n this.hoveredIndex.set(null);\n }\n\n protected formatTick(v: number): string {\n if (Math.abs(v) >= 1000) return `${(v / 1000).toFixed(v % 1000 === 0 ? 0 : 1)}k`;\n return v.toFixed(v % 1 === 0 ? 0 : 1);\n }\n\n protected readonly viewBox = computed(() => `0 0 ${this.vbW} ${this.vbH}`);\n\n // Convenience accessor so the host can be referenced from the template.\n protected readonly hostEl = this.host.nativeElement;\n}\n\nexport type { WrLineSeries } from './interfaces';\n","@let hovered = hoveredIndex();\n@if (showLegend() && resolvedSeries().length > 0) {\n <ul class=\"wr-line-chart__legend\">\n @for (s of resolvedSeries(); track s.label) {\n <li class=\"wr-line-chart__legend-item\">\n <span class=\"wr-line-chart__swatch\" [style.background]=\"s.color\"></span>\n <span>{{ s.label }}</span>\n </li>\n }\n </ul>\n}\n\n<div class=\"wr-line-chart__plot\" role=\"img\" [attr.aria-label]=\"resolvedAriaLabel()\" [style.height.px]=\"height()\">\n <svg\n [attr.viewBox]=\"viewBox()\"\n preserveAspectRatio=\"none\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerleave)=\"onPointerLeave()\"\n >\n @if (showGrid()) {\n @for (tick of yTicks(); track tick.value) {\n <line\n class=\"wr-line-chart__grid-line\"\n [attr.x1]=\"padding.left\"\n [attr.x2]=\"vbW - padding.right\"\n [attr.y1]=\"tick.y\"\n [attr.y2]=\"tick.y\"\n stroke=\"rgba(var(--wr-color-light-rgb), 0.7)\"\n stroke-width=\"1\"\n vector-effect=\"non-scaling-stroke\"\n />\n <text\n class=\"wr-line-chart__tick\"\n [attr.x]=\"padding.left - 6\"\n [attr.y]=\"tick.y + 4\"\n text-anchor=\"end\"\n fill=\"var(--wr-color-on-surface-muted)\"\n font-size=\"10\"\n font-family=\"var(--wr-font-family-base)\"\n >\n {{ formatTick(tick.value) }}\n </text>\n }\n }\n\n @for (s of resolvedSeries(); track s.label) {\n <path\n class=\"wr-line-chart__line\"\n [attr.d]=\"pathFor(s)\"\n fill=\"none\"\n [attr.stroke]=\"s.color\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n @if (showDots()) {\n @for (v of s.data; track $index; let i = $index) {\n <!-- A hole in the data gets no dot: the index still belongs to it, so the\n points after it stay on their own x. -->\n @if (v !== null) {\n <circle\n class=\"wr-line-chart__dot\"\n [attr.cx]=\"pointX(i)\"\n [attr.cy]=\"pointY(v)\"\n r=\"3\"\n [attr.fill]=\"s.color\"\n />\n }\n }\n }\n }\n\n @if (hovered !== null && hoverPoints().length > 0) {\n <line\n class=\"wr-line-chart__crosshair\"\n [attr.x1]=\"pointX(hovered)\"\n [attr.x2]=\"pointX(hovered)\"\n [attr.y1]=\"padding.top\"\n [attr.y2]=\"vbH - padding.bottom\"\n stroke=\"var(--wr-color-medium)\"\n stroke-width=\"1\"\n stroke-dasharray=\"3 3\"\n vector-effect=\"non-scaling-stroke\"\n />\n @for (p of hoverPoints(); track p.label) {\n <circle\n [attr.cx]=\"p.x\"\n [attr.cy]=\"p.y\"\n r=\"5\"\n fill=\"var(--wr-color-white)\"\n [attr.stroke]=\"p.color\"\n stroke-width=\"2\"\n />\n }\n }\n </svg>\n\n @if (hovered !== null && hoverPoints().length > 0) {\n <div class=\"wr-line-chart__tooltip\" [style.left.%]=\"(pointX(hovered) / vbW) * 100\" [style.top.px]=\"padding.top\">\n <div class=\"wr-line-chart__tooltip-label\">{{ hoverLabel() }}</div>\n @for (p of hoverPoints(); track p.label) {\n <div class=\"wr-line-chart__tooltip-row\">\n <span class=\"wr-line-chart__swatch\" [style.background]=\"p.color\"></span>\n <span class=\"wr-line-chart__tooltip-name\">{{ p.label }}</span>\n <span class=\"wr-line-chart__tooltip-value\">{{ p.value }}</span>\n </div>\n }\n </div>\n }\n</div>\n\n@if (xLabels().length > 0) {\n <div class=\"wr-line-chart__x-labels\">\n @for (label of xLabels(); track $index) {\n <!-- Each label hands the stylesheet two numbers, both percentages of the host's\n width — the space the stretching SVG is in, so they track the drawing at any\n size. The x of the point it names, which the stylesheet centres it on; and the\n widest it may be before it reaches a neighbour or the end of the strip, past\n which the stylesheet ellipsises it. Laying the labels out as equal centred flex\n slots instead is bar-chart geometry: only the middle label landed on its dot,\n and the outer ones sat up to half a column away. -->\n <span\n class=\"wr-line-chart__x-label\"\n [style.--wr-line-chart-x]=\"xPercent($index)\"\n [style.--wr-line-chart-x-max]=\"xMaxPercent($index)\"\n >{{ label }}</span\n >\n }\n </div>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;AASH,MAAM,eAAe,GAAG;IACtB,yBAAyB;IACzB,2BAA2B;IAC3B,yBAAyB;IACzB,yBAAyB;IACzB,wBAAwB;CACzB;AAED;;;;;;;;;;;;;;;;AAgBG;MAOU,WAAW,CAAA;IACb,MAAM,GAAG,KAAK,CAA0B,EAAE;+EAAC;AAEpD;;;;AAIG;IACM,SAAS,GAAG,KAAK,CAAgB,IAAI;kFAAC;IAE5B,iBAAiB,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,EAAE,YAAY,CAAC;;IAG1F,OAAO,GAAG,KAAK,CAAoB,EAAE;gFAAC;;IAGtC,MAAM,GAAG,KAAK,CAAC,GAAG,EAAA,EAAA,IAAA,SAAA,GAAA,EAAA,SAAA,EAAA,QAAA,EAAA,8BAAA,EAAA,CAAA,EAAI,SAAS,EAAE,CAAC,CAAU,KAAa,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAA,CAAG;;IAGtG,QAAQ,GAAG,KAAK,CAAC,IAAI,gFAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;;IAG5D,UAAU,GAAG,KAAK,CAAC,IAAI,kFAAI,SAAS,EAAE,qBAA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AAI,CAAC,GAAG,CAAA,CAAA,EAAI,IAAI,CAAC,GAAG,CAAA,CAAE;gFAAC;;AAGvD,IAAA,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa;uGAnMxC,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAX,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,WAAW,igCC7CxB,ulJAmIA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FDtFa,WAAW,EAAA,UAAA,EAAA,CAAA;kBANvB,SAAS;+BACE,eAAe,EAAA,aAAA,EAEV,iBAAiB,CAAC,IAAI,QAC/B,EAAE,KAAK,EAAE,eAAe,EAAE,EAAA,QAAA,EAAA,ulJAAA,EAAA;;;AE3ClC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngwr-line-chart.mjs","sources":["../../../projects/lib/line-chart/line-chart.ts","../../../projects/lib/line-chart/line-chart.html","../../../projects/lib/line-chart/ngwr-line-chart.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 { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport { Component, ElementRef, LOCALE_ID, ViewEncapsulation, computed, inject, input, signal } from '@angular/core';\n\nimport { useI18nFormatter, useI18nText } from 'ngwr/i18n';\n\nimport type { WrLineSeries } from './interfaces';\n\nconst FALLBACK_COLORS = [\n 'var(--wr-color-primary)',\n 'var(--wr-color-secondary)',\n 'var(--wr-color-success)',\n 'var(--wr-color-warning)',\n 'var(--wr-color-danger)',\n];\n\n/**\n * Multi-series line chart with axes, gridlines, and a hover tooltip.\n * SVG-only — no external dependency.\n *\n * @example\n * ```html\n * <wr-line-chart\n * [series]=\"[\n * { label: 'Visits', data: [12, 18, 9, 22, 30, 27, 35] },\n * { label: 'Signups', data: [3, 5, 4, 8, 11, 9, 14], color: 'var(--wr-color-success)' }\n * ]\"\n * [xLabels]=\"['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/line-chart\n */\n@Component({\n selector: 'wr-line-chart',\n templateUrl: './line-chart.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-line-chart' },\n})\nexport class WrLineChart {\n readonly series = input<readonly WrLineSeries[]>([]);\n\n /**\n * Accessible name of the chart. The legend carries the series NAMES only — the numbers\n * are nowhere in text — so without this the plot is nothing at all to a screen reader.\n * Falls back to `lineChart.label`.\n */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'lineChart.label', 'Line chart');\n\n private readonly locale = inject(LOCALE_ID);\n private readonly thousandsText = useI18nFormatter('lineChart.thousands', '{{value}}k');\n\n /** Labels for the X axis (one per data point). */\n readonly xLabels = input<readonly string[]>([]);\n\n /** Chart pixel height. @default 240 */\n readonly height = input(240, { transform: (v: unknown): number => Math.max(80, coerceNumberProperty(v, 240)) });\n\n /** Show gridlines + axis ticks. @default true */\n readonly showGrid = input(true, { transform: coerceBooleanProperty });\n\n /** Show the legend above the chart. @default true */\n readonly showLegend = input(true, { transform: coerceBooleanProperty });\n\n /** Show dots at each data point. @default true */\n readonly showDots = input(true, { transform: coerceBooleanProperty });\n\n // Drawn in a 600×300 viewBox with reserved space for axis labels.\n protected readonly vbW = 600;\n protected readonly vbH = 300;\n protected readonly padding = { top: 16, right: 16, bottom: 28, left: 36 } as const;\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /** Hovered point index (across all series) — null when no hover. */\n protected readonly hoveredIndex = signal<number | null>(null);\n\n protected readonly resolvedSeries = computed(() =>\n this.series().map((s, i) => ({\n label: s.label,\n // A non-finite point becomes a HOLE at its own index, not a missing element.\n // It cannot stay a number: `Math.min`/`Math.max` over the pooled data are both\n // NaN as soon as one datum is, so every coordinate in EVERY series came out\n // `NaN` — invalid path geometry, and the whole chart vanished rather than the\n // one bad point. But filtering it out closed the gap and slid every LATER point\n // one x-slot to the left, so each of them was drawn under, and reported in the\n // tooltip as, the wrong x label. A gap is kept as a gap and the line is broken\n // across it: interpolating would invent a reading the data never took.\n data: s.data.map(v => (Number.isFinite(v) ? v : null)),\n color: s.color ?? FALLBACK_COLORS[i % FALLBACK_COLORS.length],\n }))\n );\n\n protected readonly bounds = computed(() => {\n const all = this.resolvedSeries().flatMap(s => s.data.filter(v => v !== null));\n if (all.length === 0) return { min: 0, max: 1 };\n const min = Math.min(...all);\n const max = Math.max(...all);\n if (min === max) return { min: min - 1, max: max + 1 };\n // Pad upper bound by ~10% for breathing room.\n return { min: Math.min(0, min), max: max + (max - min) * 0.1 };\n });\n\n protected readonly pointCount = computed(() => {\n const maxLen = this.resolvedSeries().reduce((acc, s) => Math.max(acc, s.data.length), 0);\n return Math.max(maxLen, this.xLabels().length);\n });\n\n /** Y-axis tick marks (5 of them). */\n protected readonly yTicks = computed(() => {\n const { min, max } = this.bounds();\n const step = (max - min) / 4;\n return [0, 1, 2, 3, 4].map(i => {\n const value = max - i * step;\n return { value, y: this.padding.top + ((max - value) / (max - min)) * this.plotHeight() };\n });\n });\n\n protected readonly plotWidth = (): number => this.vbW - this.padding.left - this.padding.right;\n protected readonly plotHeight = (): number => this.vbH - this.padding.top - this.padding.bottom;\n\n /**\n * The SVG path for a series — one subpath per unbroken run, so a hole in the data\n * leaves a hole in the line rather than a straight segment across it.\n */\n protected pathFor(series: { data: readonly (number | null)[] }): string {\n const { min, max } = this.bounds();\n const count = this.pointCount();\n if (count <= 1) return '';\n const pw = this.plotWidth();\n const ph = this.plotHeight();\n\n const commands: string[] = [];\n let run = 0;\n let last = '';\n // A subpath of one `M` is not stroked at all, so a point with a gap on both sides\n // would simply vanish when `showDots` is off. Repeating it gives the round linecap\n // something to paint.\n const closeRun = (): void => {\n if (run === 1) commands.push(`L ${last}`);\n run = 0;\n };\n\n series.data.forEach((v, i) => {\n if (v === null) {\n closeRun();\n return;\n }\n const x = this.padding.left + (i / (count - 1)) * pw;\n const y = this.padding.top + ((max - v) / (max - min)) * ph;\n last = `${x.toFixed(2)} ${y.toFixed(2)}`;\n commands.push(`${run === 0 ? 'M' : 'L'} ${last}`);\n run++;\n });\n closeRun();\n\n return commands.join(' ');\n }\n\n protected pointX(index: number): number {\n const count = this.pointCount();\n if (count <= 1) return this.padding.left;\n return this.padding.left + (index / (count - 1)) * this.plotWidth();\n }\n\n protected pointY(value: number): number {\n const { min, max } = this.bounds();\n return this.padding.top + ((max - value) / (max - min)) * this.plotHeight();\n }\n\n /**\n * A point's x as a percentage of the host's width. The x-label strip and the SVG share\n * that width — the drawing stretches to it — so this is the same space the tooltip and\n * the labels are placed in, at any size.\n */\n protected xPercent(index: number): number {\n return (this.pointX(index) / this.vbW) * 100;\n }\n\n /**\n * How wide an x label may be, as a percentage of the host's width: its own slot — half\n * the distance to a neighbour on each side — cut back to what is left between its point\n * and the end of the strip. Centring a label on its point says nothing about its WIDTH,\n * and with no bound at all twelve month names printed over each other and the last one\n * hung outside the chart. Past this the stylesheet ellipsises.\n */\n protected xMaxPercent(index: number): number {\n const count = this.pointCount();\n // A single label has no neighbour to collide with and the whole strip to sit in.\n if (count <= 1) return 100;\n const slot = (this.plotWidth() / (count - 1) / this.vbW) * 100;\n const x = this.xPercent(index);\n return Math.min(slot, x + slot / 2, 100 - x + slot / 2);\n }\n\n protected readonly hoverPoints = computed(() => {\n const i = this.hoveredIndex();\n if (i === null) return [];\n return this.resolvedSeries().flatMap(s => {\n // Past the end of a short series, or on a hole in a longer one — either way there\n // is no reading at this x, so the series contributes neither a marker nor a row.\n const value = s.data[i];\n if (value === undefined || value === null) return [];\n return [{ label: s.label, value, color: s.color, x: this.pointX(i), y: this.pointY(value) }];\n });\n });\n\n protected readonly hoverLabel = computed(() => {\n const i = this.hoveredIndex();\n if (i === null) return '';\n return this.xLabels()[i] ?? String(i);\n });\n\n protected onPointerMove(event: PointerEvent): void {\n const svg = (event.currentTarget as SVGElement).getBoundingClientRect();\n const ratio = (event.clientX - svg.left) / svg.width;\n const vbX = ratio * this.vbW;\n const count = this.pointCount();\n if (count === 0) return;\n const i = Math.round(((vbX - this.padding.left) / this.plotWidth()) * (count - 1));\n if (i >= 0 && i < count) this.hoveredIndex.set(i);\n }\n\n protected onPointerLeave(): void {\n this.hoveredIndex.set(null);\n }\n\n /**\n * A Y-axis tick, in the reader's own language.\n *\n * Two halves and both were English. The `k` was a hardcoded Latin\n * abbreviation — `тыс.` in Russian — so it goes through the catalog like every\n * other word the library paints. The digits went through `toFixed`, which\n * always writes a full stop, so a German axis read `1.5` where the rest of the\n * page read `1,5`; they go through `Intl` now, the way `wrNumber`, `wrDate`\n * and `wrPlural` already did.\n *\n * Grouping is OFF deliberately: a tick is a short axis label, and `5,000k`\n * would be both wider and a change to what every existing chart draws.\n */\n protected formatTick(v: number): string {\n const digits = (n: number, fraction: number): string =>\n new Intl.NumberFormat(this.locale, {\n useGrouping: false,\n minimumFractionDigits: fraction,\n maximumFractionDigits: fraction,\n }).format(n);\n\n if (Math.abs(v) >= 1000) return this.thousandsText({ value: digits(v / 1000, v % 1000 === 0 ? 0 : 1) });\n return digits(v, v % 1 === 0 ? 0 : 1);\n }\n\n protected readonly viewBox = computed(() => `0 0 ${this.vbW} ${this.vbH}`);\n\n // Convenience accessor so the host can be referenced from the template.\n protected readonly hostEl = this.host.nativeElement;\n}\n\nexport type { WrLineSeries } from './interfaces';\n","@let hovered = hoveredIndex();\n@if (showLegend() && resolvedSeries().length > 0) {\n <ul class=\"wr-line-chart__legend\">\n @for (s of resolvedSeries(); track s.label) {\n <li class=\"wr-line-chart__legend-item\">\n <span class=\"wr-line-chart__swatch\" [style.background]=\"s.color\"></span>\n <span>{{ s.label }}</span>\n </li>\n }\n </ul>\n}\n\n<div class=\"wr-line-chart__plot\" role=\"img\" [attr.aria-label]=\"resolvedAriaLabel()\" [style.height.px]=\"height()\">\n <svg\n [attr.viewBox]=\"viewBox()\"\n preserveAspectRatio=\"none\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerleave)=\"onPointerLeave()\"\n >\n @if (showGrid()) {\n @for (tick of yTicks(); track tick.value) {\n <line\n class=\"wr-line-chart__grid-line\"\n [attr.x1]=\"padding.left\"\n [attr.x2]=\"vbW - padding.right\"\n [attr.y1]=\"tick.y\"\n [attr.y2]=\"tick.y\"\n stroke=\"rgba(var(--wr-color-light-rgb), 0.7)\"\n stroke-width=\"1\"\n vector-effect=\"non-scaling-stroke\"\n />\n <text\n class=\"wr-line-chart__tick\"\n [attr.x]=\"padding.left - 6\"\n [attr.y]=\"tick.y + 4\"\n text-anchor=\"end\"\n fill=\"var(--wr-color-on-surface-muted)\"\n font-size=\"10\"\n font-family=\"var(--wr-font-family-base)\"\n >\n {{ formatTick(tick.value) }}\n </text>\n }\n }\n\n @for (s of resolvedSeries(); track s.label) {\n <path\n class=\"wr-line-chart__line\"\n [attr.d]=\"pathFor(s)\"\n fill=\"none\"\n [attr.stroke]=\"s.color\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n @if (showDots()) {\n @for (v of s.data; track $index; let i = $index) {\n <!-- A hole in the data gets no dot: the index still belongs to it, so the\n points after it stay on their own x. -->\n @if (v !== null) {\n <circle\n class=\"wr-line-chart__dot\"\n [attr.cx]=\"pointX(i)\"\n [attr.cy]=\"pointY(v)\"\n r=\"3\"\n [attr.fill]=\"s.color\"\n />\n }\n }\n }\n }\n\n @if (hovered !== null && hoverPoints().length > 0) {\n <line\n class=\"wr-line-chart__crosshair\"\n [attr.x1]=\"pointX(hovered)\"\n [attr.x2]=\"pointX(hovered)\"\n [attr.y1]=\"padding.top\"\n [attr.y2]=\"vbH - padding.bottom\"\n stroke=\"var(--wr-color-medium)\"\n stroke-width=\"1\"\n stroke-dasharray=\"3 3\"\n vector-effect=\"non-scaling-stroke\"\n />\n @for (p of hoverPoints(); track p.label) {\n <circle\n [attr.cx]=\"p.x\"\n [attr.cy]=\"p.y\"\n r=\"5\"\n fill=\"var(--wr-color-white)\"\n [attr.stroke]=\"p.color\"\n stroke-width=\"2\"\n />\n }\n }\n </svg>\n\n @if (hovered !== null && hoverPoints().length > 0) {\n <div class=\"wr-line-chart__tooltip\" [style.left.%]=\"(pointX(hovered) / vbW) * 100\" [style.top.px]=\"padding.top\">\n <div class=\"wr-line-chart__tooltip-label\">{{ hoverLabel() }}</div>\n @for (p of hoverPoints(); track p.label) {\n <div class=\"wr-line-chart__tooltip-row\">\n <span class=\"wr-line-chart__swatch\" [style.background]=\"p.color\"></span>\n <span class=\"wr-line-chart__tooltip-name\">{{ p.label }}</span>\n <span class=\"wr-line-chart__tooltip-value\">{{ p.value }}</span>\n </div>\n }\n </div>\n }\n</div>\n\n@if (xLabels().length > 0) {\n <div class=\"wr-line-chart__x-labels\">\n @for (label of xLabels(); track $index) {\n <!-- Each label hands the stylesheet two numbers, both percentages of the host's\n width — the space the stretching SVG is in, so they track the drawing at any\n size. The x of the point it names, which the stylesheet centres it on; and the\n widest it may be before it reaches a neighbour or the end of the strip, past\n which the stylesheet ellipsises it. Laying the labels out as equal centred flex\n slots instead is bar-chart geometry: only the middle label landed on its dot,\n and the outer ones sat up to half a column away. -->\n <span\n class=\"wr-line-chart__x-label\"\n [style.--wr-line-chart-x]=\"xPercent($index)\"\n [style.--wr-line-chart-x-max]=\"xMaxPercent($index)\"\n >{{ label }}</span\n >\n }\n </div>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;AASH,MAAM,eAAe,GAAG;IACtB,yBAAyB;IACzB,2BAA2B;IAC3B,yBAAyB;IACzB,yB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,IAAI,CAAC,aAAa;uGA1NxC,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAX,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,WAAW,igCC7CxB,ulJAmIA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FDtFa,WAAW,EAAA,UAAA,EAAA,CAAA;kBANvB,SAAS;+BACE,eAAe,EAAA,aAAA,EAEV,iBAAiB,CAAC,IAAI,QAC/B,EAAE,KAAK,EAAE,eAAe,EAAE,EAAA,QAAA,EAAA,ulJAAA,EAAA;;;AE3ClC;;AAEG;;;;"}
|
package/fesm2022/ngwr-list.mjs
CHANGED
|
@@ -52,14 +52,14 @@ class WrList {
|
|
|
52
52
|
}, /* @ts-ignore */
|
|
53
53
|
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
54
54
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: WrList, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
55
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.5", type: WrList, isStandalone: true, selector: "wr-list", inputs: { bordered: { classPropertyName: "bordered", publicName: "bordered", isSignal: true, isRequired: false, transformFunction: null }, dividers: { classPropertyName: "dividers", publicName: "dividers", isSignal: true, isRequired: false, transformFunction: null }, dense: { classPropertyName: "dense", publicName: "dense", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()", "attr.aria-label": "ariaLabel() || null" } }, ngImport: i0, template: '<ul class="wr-list__items" role="list"><ng-content /></ul>', isInline: true, styles: [".wr-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-table__sort-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-tabs__tab:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-sidebar__entry:focus-visible,.wr-sidebar__group-toggle:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sidebar__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-anchor__link:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-collapse__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-command-palette__option:focus-visible
|
|
55
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.5", type: WrList, isStandalone: true, selector: "wr-list", inputs: { bordered: { classPropertyName: "bordered", publicName: "bordered", isSignal: true, isRequired: false, transformFunction: null }, dividers: { classPropertyName: "dividers", publicName: "dividers", isSignal: true, isRequired: false, transformFunction: null }, dense: { classPropertyName: "dense", publicName: "dense", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "classes()", "attr.aria-label": "ariaLabel() || null" } }, ngImport: i0, template: '<ul class="wr-list__items" role="list"><ng-content /></ul>', isInline: true, styles: [".wr-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-table__sort-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-tabs__tab:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-sidebar__entry:focus-visible,.wr-sidebar__group-toggle:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sidebar__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-anchor__link:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-collapse__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-command-palette__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-mention-panel__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-segmented__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-back-top:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-carousel__nav:focus-visible,.wr-carousel__dot:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-speed-dial__trigger:focus-visible,.wr-speed-dial__action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-stepper__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-window__chrome-action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-date-picker__trigger:focus-visible,.wr-time-picker__step:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-dropdown-item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-alert__close:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-list{--wr-list-item-padding-y: .625rem;--wr-list-item-padding-x: 1rem;--wr-list-item-gap: .75rem;--wr-list-divider-color: var(--wr-color-outline);--wr-list-bg: transparent;--wr-list-hover-bg: var(--wr-color-hover);--wr-list-active-bg: rgba(var(--wr-color-primary-rgb), .08);display:block;font-family:var(--wr-font-family-base);font-size:var(--wr-text-sm);color:var(--wr-color-on-surface);background:var(--wr-list-bg)}.wr-list__items{list-style:none;margin:0;padding:0}.wr-list--bordered{border:1px solid var(--wr-list-divider-color);border-radius:var(--wr-border-radius-base)}@supports (corner-shape: squircle){.wr-list--bordered{corner-shape:squircle;border-radius:calc(var(--wr-border-radius-base) * 1.85)}}.wr-list--bordered{overflow:hidden}.wr-list--dividers .wr-list__item:not(:last-child){border-bottom:1px solid var(--wr-list-divider-color)}.wr-list--dense{--wr-list-item-padding-y: .375rem}.wr-list__item{display:flex;align-items:center;gap:var(--wr-list-item-gap);padding:calc(var(--wr-list-item-padding-y) * var(--wr-density-y, 1)) calc(var(--wr-list-item-padding-x) * var(--wr-density-x, 1));color:inherit;transition:background .12s ease}.wr-list__item--interactive{cursor:pointer}.wr-list__item--interactive:hover{background:var(--wr-list-hover-bg)}.wr-list__item--interactive:active{background:var(--wr-list-active-bg)}.wr-list__item--interactive:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-list__item--disabled{opacity:var(--wr-disabled-opacity);pointer-events:none;cursor:not-allowed}.wr-list__leading,.wr-list__trailing{display:inline-flex;align-items:center;flex:0 0 auto;color:rgba(var(--wr-color-on-surface-rgb),.65)}.wr-list__leading:empty,.wr-list__trailing:empty{display:none}.wr-list__body{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
56
56
|
}
|
|
57
57
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: WrList, decorators: [{
|
|
58
58
|
type: Component,
|
|
59
59
|
args: [{ selector: 'wr-list', template: '<ul class="wr-list__items" role="list"><ng-content /></ul>', encapsulation: ViewEncapsulation.None, host: {
|
|
60
60
|
'[class]': 'classes()',
|
|
61
61
|
'[attr.aria-label]': 'ariaLabel() || null',
|
|
62
|
-
}, styles: [".wr-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-table__sort-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-tabs__tab:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-sidebar__entry:focus-visible,.wr-sidebar__group-toggle:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sidebar__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-anchor__link:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-collapse__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-command-palette__option:focus-visible
|
|
62
|
+
}, styles: [".wr-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-table__sort-btn:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-tabs__tab:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-sidebar__entry:focus-visible,.wr-sidebar__group-toggle:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-sidebar__item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-anchor__link:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-collapse__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-command-palette__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-mention-panel__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-segmented__option:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-back-top:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-carousel__nav:focus-visible,.wr-carousel__dot:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-speed-dial__trigger:focus-visible,.wr-speed-dial__action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-stepper__header:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-window__chrome-action:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-date-picker__trigger:focus-visible,.wr-time-picker__step:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-dropdown-item:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-alert__close:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo)}.wr-list{--wr-list-item-padding-y: .625rem;--wr-list-item-padding-x: 1rem;--wr-list-item-gap: .75rem;--wr-list-divider-color: var(--wr-color-outline);--wr-list-bg: transparent;--wr-list-hover-bg: var(--wr-color-hover);--wr-list-active-bg: rgba(var(--wr-color-primary-rgb), .08);display:block;font-family:var(--wr-font-family-base);font-size:var(--wr-text-sm);color:var(--wr-color-on-surface);background:var(--wr-list-bg)}.wr-list__items{list-style:none;margin:0;padding:0}.wr-list--bordered{border:1px solid var(--wr-list-divider-color);border-radius:var(--wr-border-radius-base)}@supports (corner-shape: squircle){.wr-list--bordered{corner-shape:squircle;border-radius:calc(var(--wr-border-radius-base) * 1.85)}}.wr-list--bordered{overflow:hidden}.wr-list--dividers .wr-list__item:not(:last-child){border-bottom:1px solid var(--wr-list-divider-color)}.wr-list--dense{--wr-list-item-padding-y: .375rem}.wr-list__item{display:flex;align-items:center;gap:var(--wr-list-item-gap);padding:calc(var(--wr-list-item-padding-y) * var(--wr-density-y, 1)) calc(var(--wr-list-item-padding-x) * var(--wr-density-x, 1));color:inherit;transition:background .12s ease}.wr-list__item--interactive{cursor:pointer}.wr-list__item--interactive:hover{background:var(--wr-list-hover-bg)}.wr-list__item--interactive:active{background:var(--wr-list-active-bg)}.wr-list__item--interactive:focus-visible{outline:var(--wr-focus-ring-width) solid var(--wr-focus-ring-color);outline-offset:var(--wr-focus-ring-offset);box-shadow:0 0 0 var(--wr-focus-ring-offset) var(--wr-focus-ring-halo);outline-offset:-2px}.wr-list__item--disabled{opacity:var(--wr-disabled-opacity);pointer-events:none;cursor:not-allowed}.wr-list__leading,.wr-list__trailing{display:inline-flex;align-items:center;flex:0 0 auto;color:rgba(var(--wr-color-on-surface-rgb),.65)}.wr-list__leading:empty,.wr-list__trailing:empty{display:none}.wr-list__body{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n"] }]
|
|
63
63
|
}], propDecorators: { bordered: [{ type: i0.Input, args: [{ isSignal: true, alias: "bordered", required: false }] }], dividers: [{ type: i0.Input, args: [{ isSignal: true, alias: "dividers", required: false }] }], dense: [{ type: i0.Input, args: [{ isSignal: true, alias: "dense", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }] } });
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-list.mjs","sources":["../../../projects/lib/list/list.ts","../../../projects/lib/list/list-item.ts","../../../projects/lib/list/list-item.html","../../../projects/lib/list/ngwr-list.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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\n/**\n * Generic list container. Renders `<ul role=\"list\">` with optional\n * borders, dividers between items, and dense (compact) padding. Project\n * `<wr-list-item>` children — they pick up the container's settings\n * through CSS cascade, no DI needed.\n *\n * @example\n * ```html\n * <wr-list bordered dividers>\n * <wr-list-item>\n * <wr-icon ngProjectAs=\"[wrListItemLeading]\" name=\"folder\" />\n * Reports\n * <span ngProjectAs=\"[wrListItemTrailing]\">12</span>\n * </wr-list-item>\n * <wr-list-item interactive (click)=\"open(item)\">\n * Click anywhere on this row\n * </wr-list-item>\n * </wr-list>\n * ```\n *\n * @see https://ngwr.dev/reference/components/list\n */\n@Component({\n selector: 'wr-list',\n template: '<ul class=\"wr-list__items\" role=\"list\"><ng-content /></ul>',\n styleUrl: './list.scss',\n encapsulation: ViewEncapsulation.None,\n host: {\n '[class]': 'classes()',\n '[attr.aria-label]': 'ariaLabel() || null',\n },\n})\nexport class WrList {\n /** Wrap the list in a card-style border + radius. @default false */\n readonly bordered = input(false, { transform: coerceBooleanProperty });\n\n /** Draw a thin divider between items. @default false */\n readonly dividers = input(false, { transform: coerceBooleanProperty });\n\n /** Use compact padding on every item. @default false */\n readonly dense = input(false, { transform: coerceBooleanProperty });\n\n /** Optional accessible label for the list. */\n readonly ariaLabel = input<string>('');\n\n protected readonly classes = computed(() => {\n const parts = ['wr-list'];\n if (this.bordered()) parts.push('wr-list--bordered');\n if (this.dividers()) parts.push('wr-list--dividers');\n if (this.dense()) parts.push('wr-list--dense');\n return parts.join(' ');\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 } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\n/**\n * Row inside `<wr-list>`. Three projection slots:\n *\n * - `[wrListItemLeading]` — icon, avatar, status dot, etc.\n * - default — main label / body\n * - `[wrListItemTrailing]` — meta value, action button, chevron\n *\n * Set `interactive` to get hover and cursor styles, a tab stop, and Enter /\n * Space activation. The role stays `listitem`: the row lives inside a\n * `<ul role=\"list\">`, where a `button` or `option` child role would break the\n * structure the container promises. That means an interactive row ANNOUNCES as\n * a list item rather than as a control — deliberate, but worth knowing when the\n * whole row is the only way to reach an action. Where the action needs to be\n * announced as one, project a real button into `[wrListItemTrailing]`.\n *\n * @example\n * ```html\n * <wr-list-item>Plain row</wr-list-item>\n *\n * <wr-list-item interactive (click)=\"onPick(item)\">\n * <wr-icon ngProjectAs=\"[wrListItemLeading]\" name=\"folder\" />\n * Reports\n * <span ngProjectAs=\"[wrListItemTrailing]\">12</span>\n * </wr-list-item>\n * ```\n */\n@Component({\n selector: 'wr-list-item',\n templateUrl: './list-item.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n '[class]': 'classes()',\n role: 'listitem',\n '[attr.tabindex]': 'interactive() ? \"0\" : null',\n '[attr.aria-disabled]': 'disabled() || null',\n '(keydown.enter)': 'onActivate($event)',\n '(keydown.space)': 'onActivate($event)',\n },\n})\nexport class WrListItem {\n /** Adds hover / cursor styles + keyboard activation. @default false */\n readonly interactive = input(false, { transform: coerceBooleanProperty });\n\n /** Visual disabled state. Suppresses hover + keyboard activation. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts = ['wr-list__item'];\n if (this.interactive()) parts.push('wr-list__item--interactive');\n if (this.disabled()) parts.push('wr-list__item--disabled');\n return parts.join(' ');\n });\n\n protected onActivate(event: Event): void {\n if (!this.interactive() || this.disabled()) return;\n event.preventDefault();\n (event.currentTarget as HTMLElement).click();\n }\n}\n","<span class=\"wr-list__leading\"><ng-content select=\"[wrListItemLeading]\" /></span>\n<span class=\"wr-list__body\"><ng-content /></span>\n<span class=\"wr-list__trailing\"><ng-content select=\"[wrListItemTrailing]\" /></span>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAKH;;;;;;;;;;;;;;;;;;;;;AAqBG;MAWU,MAAM,CAAA;;IAER,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;;IAG7D,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;;IAG7D,KAAK,GAAG,KAAK,CAAC,KAAK,6EAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;;IAG1D,SAAS,GAAG,KAAK,CAAS,EAAE;kFAAC;AAEnB,IAAA,OAAO,GAAG,QAAQ,CAAC,MAAK;AACzC,QAAA,MAAM,KAAK,GAAG,CAAC,SAAS,CAAC;QACzB,IAAI,IAAI,CAAC,QAAQ,EAAE;AAAE,YAAA,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC;QACpD,IAAI,IAAI,CAAC,QAAQ,EAAE;AAAE,YAAA,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC;QACpD,IAAI,IAAI,CAAC,KAAK,EAAE;AAAE,YAAA,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC;AAC9C,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;IACxB,CAAC;gFAAC;uGAnBS,MAAM,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAN,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAM,uqBARP,4DAA4D,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"ngwr-list.mjs","sources":["../../../projects/lib/list/list.ts","../../../projects/lib/list/list-item.ts","../../../projects/lib/list/list-item.html","../../../projects/lib/list/ngwr-list.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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\n/**\n * Generic list container. Renders `<ul role=\"list\">` with optional\n * borders, dividers between items, and dense (compact) padding. Project\n * `<wr-list-item>` children — they pick up the container's settings\n * through CSS cascade, no DI needed.\n *\n * @example\n * ```html\n * <wr-list bordered dividers>\n * <wr-list-item>\n * <wr-icon ngProjectAs=\"[wrListItemLeading]\" name=\"folder\" />\n * Reports\n * <span ngProjectAs=\"[wrListItemTrailing]\">12</span>\n * </wr-list-item>\n * <wr-list-item interactive (click)=\"open(item)\">\n * Click anywhere on this row\n * </wr-list-item>\n * </wr-list>\n * ```\n *\n * @see https://ngwr.dev/reference/components/list\n */\n@Component({\n selector: 'wr-list',\n template: '<ul class=\"wr-list__items\" role=\"list\"><ng-content /></ul>',\n styleUrl: './list.scss',\n encapsulation: ViewEncapsulation.None,\n host: {\n '[class]': 'classes()',\n '[attr.aria-label]': 'ariaLabel() || null',\n },\n})\nexport class WrList {\n /** Wrap the list in a card-style border + radius. @default false */\n readonly bordered = input(false, { transform: coerceBooleanProperty });\n\n /** Draw a thin divider between items. @default false */\n readonly dividers = input(false, { transform: coerceBooleanProperty });\n\n /** Use compact padding on every item. @default false */\n readonly dense = input(false, { transform: coerceBooleanProperty });\n\n /** Optional accessible label for the list. */\n readonly ariaLabel = input<string>('');\n\n protected readonly classes = computed(() => {\n const parts = ['wr-list'];\n if (this.bordered()) parts.push('wr-list--bordered');\n if (this.dividers()) parts.push('wr-list--dividers');\n if (this.dense()) parts.push('wr-list--dense');\n return parts.join(' ');\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 } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\n/**\n * Row inside `<wr-list>`. Three projection slots:\n *\n * - `[wrListItemLeading]` — icon, avatar, status dot, etc.\n * - default — main label / body\n * - `[wrListItemTrailing]` — meta value, action button, chevron\n *\n * Set `interactive` to get hover and cursor styles, a tab stop, and Enter /\n * Space activation. The role stays `listitem`: the row lives inside a\n * `<ul role=\"list\">`, where a `button` or `option` child role would break the\n * structure the container promises. That means an interactive row ANNOUNCES as\n * a list item rather than as a control — deliberate, but worth knowing when the\n * whole row is the only way to reach an action. Where the action needs to be\n * announced as one, project a real button into `[wrListItemTrailing]`.\n *\n * @example\n * ```html\n * <wr-list-item>Plain row</wr-list-item>\n *\n * <wr-list-item interactive (click)=\"onPick(item)\">\n * <wr-icon ngProjectAs=\"[wrListItemLeading]\" name=\"folder\" />\n * Reports\n * <span ngProjectAs=\"[wrListItemTrailing]\">12</span>\n * </wr-list-item>\n * ```\n */\n@Component({\n selector: 'wr-list-item',\n templateUrl: './list-item.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n '[class]': 'classes()',\n role: 'listitem',\n '[attr.tabindex]': 'interactive() ? \"0\" : null',\n '[attr.aria-disabled]': 'disabled() || null',\n '(keydown.enter)': 'onActivate($event)',\n '(keydown.space)': 'onActivate($event)',\n },\n})\nexport class WrListItem {\n /** Adds hover / cursor styles + keyboard activation. @default false */\n readonly interactive = input(false, { transform: coerceBooleanProperty });\n\n /** Visual disabled state. Suppresses hover + keyboard activation. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts = ['wr-list__item'];\n if (this.interactive()) parts.push('wr-list__item--interactive');\n if (this.disabled()) parts.push('wr-list__item--disabled');\n return parts.join(' ');\n });\n\n protected onActivate(event: Event): void {\n if (!this.interactive() || this.disabled()) return;\n event.preventDefault();\n (event.currentTarget as HTMLElement).click();\n }\n}\n","<span class=\"wr-list__leading\"><ng-content select=\"[wrListItemLeading]\" /></span>\n<span class=\"wr-list__body\"><ng-content /></span>\n<span class=\"wr-list__trailing\"><ng-content select=\"[wrListItemTrailing]\" /></span>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;;;AAKG;A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GA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FD8Ca,UAAU,EAAA,UAAA,EAAA,CAAA;kBAbtB,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,cAAc,EAAA,aAAA,EAET,iBAAiB,CAAC,IAAI,EAAA,IAAA,EAC/B;AACJ,wBAAA,SAAS,EAAE,WAAW;AACtB,wBAAA,IAAI,EAAE,UAAU;AAChB,wBAAA,iBAAiB,EAAE,4BAA4B;AAC/C,wBAAA,sBAAsB,EAAE,oBAAoB;AAC5C,wBAAA,iBAAiB,EAAE,oBAAoB;AACvC,wBAAA,iBAAiB,EAAE,oBAAoB;AACxC,qBAAA,EAAA,QAAA,EAAA,uOAAA,EAAA;;;AE/CH;;AAEG;;;;"}
|
package/fesm2022/ngwr-pipes.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { inject, LOCALE_ID, Pipe } from '@angular/core';
|
|
3
3
|
import { WrDateAdapter } from 'ngwr/date';
|
|
4
4
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
5
5
|
|
|
@@ -9,32 +9,97 @@ import { DomSanitizer } from '@angular/platform-browser';
|
|
|
9
9
|
* Use of this source code is governed by an MIT-style license that can be
|
|
10
10
|
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
11
11
|
*/
|
|
12
|
-
const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* Binary magnitudes, as the `Intl` unit that labels each one. The COUNTING is
|
|
14
|
+
* 1024-based and these names are decimal — which is the same thing the old
|
|
15
|
+
* hand-written `['B', 'KB', 'MB', …]` table did, and what almost every file
|
|
16
|
+
* manager does. Strictly, 1024 bytes is a kibibyte; `Intl` has no unit for it.
|
|
17
|
+
*/
|
|
18
|
+
const UNITS = ['byte', 'kilobyte', 'megabyte', 'gigabyte', 'terabyte', 'petabyte'];
|
|
19
|
+
/**
|
|
20
|
+
* Humanise a byte count using binary (1024-based) units, in the reader's locale.
|
|
15
21
|
*
|
|
16
22
|
* @example
|
|
17
23
|
* ```html
|
|
18
|
-
* {{ 1234 | wrBytes }} <!-- "1.2
|
|
19
|
-
* {{ 1234567 | wrBytes: 0 }} <!-- "1 MB" -->
|
|
20
|
-
* {{ 0 | wrBytes }} <!-- "0 B" -->
|
|
24
|
+
* {{ 1234 | wrBytes }} <!-- en: "1.2 kB" de: "1,2 kB" ru: "1,2 кБ" -->
|
|
25
|
+
* {{ 1234567 | wrBytes: 0 }} <!-- en: "1 MB" fr: "1 Mo" -->
|
|
26
|
+
* {{ 0 | wrBytes }} <!-- en: "0 B" ru: "0 Б" -->
|
|
21
27
|
* ```
|
|
28
|
+
*
|
|
29
|
+
* **Both halves come from `Intl`, and the unit table is not the catalog's.** The
|
|
30
|
+
* number always did need `LOCALE_ID` — it went through `toFixed`, which writes a
|
|
31
|
+
* full stop in every language, so a German page read `1.2 KB` beside its own
|
|
32
|
+
* `1,2` everywhere else — and the three formatting pipes beside this one
|
|
33
|
+
* (`wrDate`, `wrNumber`, `wrPlural`) had injected it since they shipped.
|
|
34
|
+
*
|
|
35
|
+
* The unit could not follow them into `ngwr/i18n`, and the reason is the pipe
|
|
36
|
+
* rather than the strings: a PURE pipe is re-invoked only when its argument
|
|
37
|
+
* changes, so a catalog that lands after the first render — which is every
|
|
38
|
+
* `provideWrI18nHttpLoader` app — would never reach it, and the pipe would be
|
|
39
|
+
* correct under the static loader and silently English under the other one.
|
|
40
|
+
* `LOCALE_ID` is a constant, so `Intl` has no such failure mode, and it knows
|
|
41
|
+
* every locale ICU ships rather than the twenty-two this package translates.
|
|
42
|
+
*
|
|
43
|
+
* One visible change in English and it is the only one: `KB` became `kB`, which
|
|
44
|
+
* is what CLDR calls that unit. `B`, the space before it and every other
|
|
45
|
+
* magnitude read exactly as they did — see `format` for the part of that which
|
|
46
|
+
* is not free.
|
|
47
|
+
*
|
|
48
|
+
* The other consequence, kept here so nobody rediscovers it as a bug:
|
|
49
|
+
* `<wr-file-upload>` prints its own sizes from `fileUpload.unitKb` and friends,
|
|
50
|
+
* which are public catalog keys a consumer may have overridden, so it renders
|
|
51
|
+
* `KB` where this pipe renders `kB`. Retiring those keys would silently break
|
|
52
|
+
* every override that had been translating them, which is a major-version move.
|
|
22
53
|
*/
|
|
23
54
|
class WrBytes {
|
|
55
|
+
locale = inject(LOCALE_ID);
|
|
24
56
|
transform(value, decimals = 1) {
|
|
25
57
|
if (value === null || value === undefined || value === '')
|
|
26
58
|
return '';
|
|
27
59
|
const n = Number(value);
|
|
28
60
|
if (!Number.isFinite(n) || n <= 0)
|
|
29
|
-
return
|
|
61
|
+
return this.format(0, 0, 0);
|
|
30
62
|
// Floored as well as capped: for `0 < n < 1` the log is negative, so an
|
|
31
63
|
// unclamped index reads `UNITS[-1]` (`undefined`) and divides by `1024 ** -1`,
|
|
32
64
|
// which rendered `0.5` as "512.0 undefined".
|
|
33
65
|
const i = Math.min(Math.max(0, Math.floor(Math.log(n) / Math.log(1024))), UNITS.length - 1);
|
|
34
|
-
const v = n / 1024 ** i;
|
|
35
66
|
// Whole bytes never show a fractional part.
|
|
36
|
-
|
|
37
|
-
|
|
67
|
+
return this.format(n / 1024 ** i, i, i === 0 ? 0 : Math.max(0, decimals));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* `Intl`'s NARROW unit, with one space put back between it and the number.
|
|
71
|
+
*
|
|
72
|
+
* Neither display mode is right on its own. `short` spells the smallest unit
|
|
73
|
+
* as a word — "512 byte", "0 byte" in English, "0 Byte" in German — which is
|
|
74
|
+
* both worse copy than the `B` this pipe has always rendered and a bigger
|
|
75
|
+
* change than the fix is worth. `narrow` gives `B` / `Б` / `o` correctly and
|
|
76
|
+
* then closes the gap: "1.2kB".
|
|
77
|
+
*
|
|
78
|
+
* So the parts are reassembled rather than the string. Going through
|
|
79
|
+
* `formatToParts` is what keeps the ORDER the locale's own — Hebrew puts the
|
|
80
|
+
* unit first, and hand-joining `${n} ${unit}` would silently straighten every
|
|
81
|
+
* such locale into English order.
|
|
82
|
+
*/
|
|
83
|
+
format(value, unit, fractionDigits) {
|
|
84
|
+
const parts = new Intl.NumberFormat(this.locale, {
|
|
85
|
+
style: 'unit',
|
|
86
|
+
unit: UNITS[unit],
|
|
87
|
+
unitDisplay: 'narrow',
|
|
88
|
+
minimumFractionDigits: fractionDigits,
|
|
89
|
+
maximumFractionDigits: fractionDigits,
|
|
90
|
+
}).formatToParts(value);
|
|
91
|
+
const at = parts.findIndex(part => part.type === 'unit');
|
|
92
|
+
if (at === -1)
|
|
93
|
+
return parts.map(part => part.value).join('');
|
|
94
|
+
const out = parts.map(part => part.value);
|
|
95
|
+
// The slot on the number's side of the unit: already a separator in some
|
|
96
|
+
// locales, absent in others.
|
|
97
|
+
const gap = at === 0 ? 1 : at - 1;
|
|
98
|
+
if (parts[gap]?.type === 'literal')
|
|
99
|
+
out[gap] = ' ';
|
|
100
|
+
else
|
|
101
|
+
out.splice(at === 0 ? 1 : at, 0, ' ');
|
|
102
|
+
return out.join('');
|
|
38
103
|
}
|
|
39
104
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: WrBytes, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
40
105
|
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.1.5", ngImport: i0, type: WrBytes, isStandalone: true, name: "wrBytes" });
|