ngwr 16.0.0 → 16.2.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/badge/styles/_tag.scss +8 -4
- package/button/styles/_index.scss +13 -7
- package/cascader/styles/_rules.scss +4 -2
- package/checkbox/styles/_index.scss +4 -2
- package/date-picker/styles/_index.scss +95 -3
- package/date-stamp/styles/_index.scss +38 -0
- package/dialog/styles/_index.scss +38 -0
- package/dropdown/styles/_index.scss +37 -1
- package/fesm2022/internal-CVLvP9b_.mjs +33 -0
- package/fesm2022/internal-CVLvP9b_.mjs.map +1 -0
- package/fesm2022/ngwr-alert.mjs +11 -7
- package/fesm2022/ngwr-alert.mjs.map +1 -1
- package/fesm2022/ngwr-avatar.mjs +11 -7
- package/fesm2022/ngwr-avatar.mjs.map +1 -1
- package/fesm2022/ngwr-back-top.mjs +10 -6
- package/fesm2022/ngwr-back-top.mjs.map +1 -1
- package/fesm2022/ngwr-badge.mjs +18 -6
- package/fesm2022/ngwr-badge.mjs.map +1 -1
- package/fesm2022/ngwr-burger.mjs +9 -6
- package/fesm2022/ngwr-burger.mjs.map +1 -1
- package/fesm2022/ngwr-button.mjs +8 -4
- package/fesm2022/ngwr-button.mjs.map +1 -1
- package/fesm2022/ngwr-calendar.mjs +19 -8
- package/fesm2022/ngwr-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-card.mjs +9 -5
- package/fesm2022/ngwr-card.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +11 -5
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +5 -2
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
- package/fesm2022/ngwr-checkbox.mjs +10 -6
- package/fesm2022/ngwr-checkbox.mjs.map +1 -1
- package/fesm2022/ngwr-clipboard.mjs +2 -1
- package/fesm2022/ngwr-clipboard.mjs.map +1 -1
- package/fesm2022/ngwr-collapse.mjs +9 -5
- package/fesm2022/ngwr-collapse.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +4 -2
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-comment.mjs +13 -7
- package/fesm2022/ngwr-comment.mjs.map +1 -1
- package/fesm2022/ngwr-compare.mjs +9 -3
- package/fesm2022/ngwr-compare.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +4 -2
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value.mjs +11 -6
- package/fesm2022/ngwr-copy-value.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker-testing.mjs +18 -0
- package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +238 -38
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-date-stamp-testing.mjs +34 -0
- package/fesm2022/ngwr-date-stamp-testing.mjs.map +1 -0
- package/fesm2022/ngwr-date-stamp.mjs +213 -0
- package/fesm2022/ngwr-date-stamp.mjs.map +1 -0
- package/fesm2022/ngwr-date.mjs +364 -54
- package/fesm2022/ngwr-date.mjs.map +1 -1
- package/fesm2022/ngwr-descriptions.mjs +9 -5
- package/fesm2022/ngwr-descriptions.mjs.map +1 -1
- package/fesm2022/ngwr-dialog-testing.mjs +23 -2
- package/fesm2022/ngwr-dialog-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +45 -16
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +102 -11
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-divider.mjs +4 -2
- package/fesm2022/ngwr-divider.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +29 -3
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown-testing.mjs +38 -3
- package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +362 -26
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +5 -2
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-event-calendar.mjs +4 -2
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload.mjs +9 -3
- package/fesm2022/ngwr-file-upload.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs +18 -6
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ar.mjs +9 -2
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +9 -2
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +9 -2
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +9 -2
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +9 -2
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +9 -2
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +9 -2
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +9 -2
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +9 -2
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +9 -2
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +9 -2
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +9 -2
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +9 -2
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +9 -2
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +9 -2
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +9 -2
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +9 -2
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +9 -2
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +9 -2
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +9 -2
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +9 -2
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +9 -2
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +34 -8
- package/fesm2022/ngwr-i18n.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +9 -3
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input-otp.mjs +4 -2
- package/fesm2022/ngwr-input-otp.mjs.map +1 -1
- package/fesm2022/ngwr-input.mjs +20 -10
- package/fesm2022/ngwr-input.mjs.map +1 -1
- package/fesm2022/ngwr-keyboard.mjs +9 -3
- package/fesm2022/ngwr-keyboard.mjs.map +1 -1
- package/fesm2022/ngwr-knob.mjs +9 -3
- package/fesm2022/ngwr-knob.mjs.map +1 -1
- package/fesm2022/ngwr-layout.mjs +13 -5
- package/fesm2022/ngwr-layout.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox-testing.mjs +26 -0
- package/fesm2022/ngwr-lightbox-testing.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +255 -15
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +13 -5
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-load-state.mjs +9 -5
- package/fesm2022/ngwr-load-state.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +84 -1
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +3 -2
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +47 -9
- package/fesm2022/ngwr-pipes.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +93 -4
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-progress.mjs +4 -2
- package/fesm2022/ngwr-progress.mjs.map +1 -1
- package/fesm2022/ngwr-radio.mjs +9 -5
- package/fesm2022/ngwr-radio.mjs.map +1 -1
- package/fesm2022/ngwr-rating.mjs +9 -3
- package/fesm2022/ngwr-rating.mjs.map +1 -1
- package/fesm2022/ngwr-resizable.mjs +503 -0
- package/fesm2022/ngwr-resizable.mjs.map +1 -0
- package/fesm2022/ngwr-result.mjs +9 -5
- package/fesm2022/ngwr-result.mjs.map +1 -1
- package/fesm2022/ngwr-schema-form.mjs +3 -0
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-segmented.mjs +4 -2
- package/fesm2022/ngwr-segmented.mjs.map +1 -1
- package/fesm2022/ngwr-select.mjs +13 -5
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-skeleton.mjs +4 -2
- package/fesm2022/ngwr-skeleton.mjs.map +1 -1
- package/fesm2022/ngwr-slider-testing.mjs +17 -0
- package/fesm2022/ngwr-slider-testing.mjs.map +1 -1
- package/fesm2022/ngwr-slider.mjs +91 -13
- package/fesm2022/ngwr-slider.mjs.map +1 -1
- package/fesm2022/ngwr-sortable-list-testing.mjs +103 -0
- package/fesm2022/ngwr-sortable-list-testing.mjs.map +1 -0
- package/fesm2022/ngwr-sortable-list.mjs +257 -53
- package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
- package/fesm2022/ngwr-speed-dial.mjs +4 -2
- package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
- package/fesm2022/ngwr-spinner.mjs +4 -2
- package/fesm2022/ngwr-spinner.mjs.map +1 -1
- package/fesm2022/ngwr-splitter.mjs +17 -21
- package/fesm2022/ngwr-splitter.mjs.map +1 -1
- package/fesm2022/ngwr-stepper.mjs +9 -3
- package/fesm2022/ngwr-stepper.mjs.map +1 -1
- package/fesm2022/ngwr-switch.mjs +9 -5
- package/fesm2022/ngwr-switch.mjs.map +1 -1
- package/fesm2022/ngwr-table-testing.mjs +5 -1
- package/fesm2022/ngwr-table-testing.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +167 -10
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-textarea.mjs +9 -3
- package/fesm2022/ngwr-textarea.mjs.map +1 -1
- package/fesm2022/ngwr-timeline.mjs +18 -8
- package/fesm2022/ngwr-timeline.mjs.map +1 -1
- package/fesm2022/ngwr-toast-testing.mjs +6 -1
- package/fesm2022/ngwr-toast-testing.mjs.map +1 -1
- package/fesm2022/ngwr-toast.mjs +529 -104
- package/fesm2022/ngwr-toast.mjs.map +1 -1
- package/fesm2022/ngwr-transfer.mjs +4 -2
- package/fesm2022/ngwr-transfer.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +4 -2
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-typography.mjs +9 -3
- package/fesm2022/ngwr-typography.mjs.map +1 -1
- package/fesm2022/ngwr-utils-router.mjs +18 -2
- package/fesm2022/ngwr-utils-router.mjs.map +1 -1
- package/fesm2022/ngwr-utils.mjs +9 -2
- package/fesm2022/ngwr-utils.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-window.mjs +7 -4
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/fesm2022/ngwr.mjs.map +1 -1
- package/i18n/ar.json +13 -2
- package/i18n/cs.json +13 -2
- package/i18n/de.json +13 -2
- package/i18n/en.json +13 -2
- package/i18n/es.json +13 -2
- package/i18n/fr.json +13 -2
- package/i18n/he.json +13 -2
- package/i18n/hi.json +13 -2
- package/i18n/id.json +13 -2
- package/i18n/it.json +13 -2
- package/i18n/ja.json +13 -2
- package/i18n/ko.json +13 -2
- package/i18n/nl.json +13 -2
- package/i18n/pl.json +13 -2
- package/i18n/pt.json +13 -2
- package/i18n/ru.json +13 -2
- package/i18n/sv.json +13 -2
- package/i18n/tr.json +13 -2
- package/i18n/uk.json +13 -2
- package/i18n/vi.json +13 -2
- package/i18n/zh-TW.json +13 -2
- package/i18n/zh.json +13 -2
- package/input/styles/_index.scss +10 -5
- package/input-number/styles/_index.scss +6 -3
- package/input-otp/styles/_index.scss +4 -2
- package/lightbox/styles/_rules.scss +96 -0
- package/llms-full.txt +40 -17
- package/llms.txt +20 -4
- package/package.json +19 -1
- package/radio/styles/_index.scss +4 -2
- package/resizable/styles/_index.scss +154 -0
- package/schematics/use/rule.js +1 -0
- package/schematics/use/symbol-map.json +5 -0
- package/select/styles/_index.scss +6 -3
- package/skills/ngwr/SKILL.md +1 -1
- package/skills/ngwr/references/catalog.md +6 -2
- package/skills/ngwr/references/setup.md +3 -0
- package/slider/styles/_index.scss +106 -0
- package/sortable-list/styles/_rules.scss +23 -1
- package/switch/styles/_index.scss +4 -2
- package/table/styles/_index.scss +53 -0
- package/textarea/styles/_index.scss +4 -2
- package/theme/styles/_motion.scss +6 -0
- package/toast/styles/_index.scss +19 -0
- package/types/ngwr-burger.d.ts +0 -1
- package/types/ngwr-calendar.d.ts +7 -0
- package/types/ngwr-charts-calendar-heatmap.d.ts +2 -1
- package/types/ngwr-clipboard.d.ts +7 -0
- package/types/ngwr-date-picker-testing.d.ts +17 -0
- package/types/ngwr-date-picker.d.ts +88 -4
- package/types/ngwr-date-stamp-testing.d.ts +47 -0
- package/types/ngwr-date-stamp.d.ts +127 -0
- package/types/ngwr-date.d.ts +251 -37
- package/types/ngwr-dialog-testing.d.ts +10 -0
- package/types/ngwr-dialog.d.ts +72 -4
- package/types/ngwr-directives.d.ts +36 -1
- package/types/ngwr-drawer.d.ts +21 -0
- package/types/ngwr-dropdown-testing.d.ts +53 -5
- package/types/ngwr-dropdown.d.ts +100 -0
- package/types/ngwr-i18n.d.ts +44 -14
- package/types/ngwr-lightbox-testing.d.ts +27 -0
- package/types/ngwr-lightbox.d.ts +71 -6
- package/types/ngwr-overlay.d.ts +36 -0
- package/types/ngwr-pipes.d.ts +48 -13
- package/types/ngwr-popover.d.ts +39 -1
- package/types/ngwr-resizable.d.ts +228 -0
- package/types/ngwr-slider-testing.d.ts +8 -1
- package/types/ngwr-slider.d.ts +89 -3
- package/types/ngwr-sortable-list-testing.d.ts +79 -0
- package/types/ngwr-sortable-list.d.ts +113 -10
- package/types/ngwr-table-testing.d.ts +3 -1
- package/types/ngwr-table.d.ts +120 -4
- package/types/ngwr-toast-testing.d.ts +12 -1
- package/types/ngwr-toast.d.ts +215 -18
- package/types/ngwr-utils-router.d.ts +22 -0
- package/types/ngwr-utils.d.ts +8 -1
- package/types/ngwr-version.d.ts +1 -1
- package/types/ngwr.d.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-charts-calendar-heatmap.mjs","names":[],"sources":["../../../projects/lib/charts/calendar-heatmap/calendar-heatmap.ts","../../../projects/lib/charts/calendar-heatmap/calendar-heatmap.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n ViewEncapsulation,\n afterNextRender,\n computed,\n inject,\n input,\n signal,\n viewChild,\n} from '@angular/core';\n\nimport { WrChartTable, type WrChartTableData, useChartNumbers } from 'ngwr/charts/core';\nimport { WR_DATE_LOCALE } from 'ngwr/date';\nimport { useI18nFormatter, useI18nText } from 'ngwr/i18n';\nimport { useChartTooltip } from 'ngwr/popover';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrHeatmapDatum } from './types';\n\ninterface Cell {\n readonly iso: string;\n /** The day as the reader's locale writes it — see `cellTitle`. */\n readonly date: Date;\n readonly value: number;\n readonly intensity: number;\n readonly week: number;\n readonly day: number;\n}\n\nfunction toIso(d: Date): string {\n const y = d.getFullYear();\n const m = String(d.getMonth() + 1).padStart(2, '0');\n const day = String(d.getDate()).padStart(2, '0');\n return `${y}-${m}-${day}`;\n}\n\nfunction parseInput(value: string | Date): Date {\n return value instanceof Date ? new Date(value) : new Date(`${value}T00:00:00`);\n}\n\n/** Which rows carry a weekday label: three of seven, or they do not fit. */\nconst LABELLED_ROWS = new Set([1, 3, 5]);\n\n/**\n * A day's contribution, with anything non-finite read as `0`.\n *\n * One `NaN` used to flatten the entire rendered window rather than its own day:\n * `Math.max(a, NaN)` is `NaN`, so the data set's maximum became `NaN`, `max > 0`\n * was false, and every cell fell to intensity 0 — a map that reads as a stretch\n * with no activity at all. The bad day also printed the literal text `NaN` in its\n * `title`.\n */\nfunction amount(raw: number): number {\n return Number.isFinite(raw) ? raw : 0;\n}\n\n/**\n * GitHub-style year-grid heatmap. One column per ISO week, one row per\n * weekday — cells coloured by `value` relative to the data set's max.\n *\n * **A year does not reflow.** Its 53 columns are a fixed cell size, so in a container\n * narrower than the grid the host scrolls sideways. While it does, it is a tab stop with\n * the shared focus ring, so the keyboard can scroll it too — WebKit makes no scroller\n * focusable by itself — and it opens on the inline END, the newest weeks, rather than on\n * the oldest. The stop carries no name of its own: focus lands on the grid's picture,\n * named by `ariaLabel`.\n *\n * **What a screen reader gets.** The grid is one named `role=\"img\"` and every square is\n * hidden, so the days' values are not in text anywhere unless `dataTable` renders them;\n * without it, say what the year shows in `ariaLabel`.\n *\n * @example\n * ```html\n * <wr-calendar-heatmap [data]=\"contributions\" />\n * <wr-calendar-heatmap [data]=\"data\" [endDate]=\"today\" [weeks]=\"26\" color=\"#10b981\" />\n * ```\n *\n * @see https://ngwr.dev/charts/calendar-heatmap\n */\n@Component({\n selector: 'wr-calendar-heatmap',\n templateUrl: './calendar-heatmap.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-calendar-heatmap',\n // A tab stop only while the year is wider than its container: see `scrollable`.\n '[attr.tabindex]': 'scrollable() ? 0 : null',\n },\n imports: [WrChartTable],\n})\nexport class WrCalendarHeatmap {\n /**\n * One entry per day — `{ date, value }`. Days you pass nothing for render as\n * empty cells, so a sparse array is the normal shape rather than a gap.\n */\n readonly data = input<readonly WrHeatmapDatum[]>([]);\n\n /**\n * Accessible name of the whole grid. Its cells are bare spans whose `title` a screen\n * reader on a role-less element does not read, so the map used to be several hundred\n * anonymous nodes with no name. Falls back to `calendarHeatmap.label`.\n */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'calendarHeatmap.label', 'Calendar heatmap');\n\n private readonly cellText = useI18nFormatter('calendarHeatmap.cell', '{{date}}: {{count}}');\n\n /**\n * A cell's tooltip, with both halves formatted and the sentence in the catalog.\n *\n * It used to be `` `${cell.iso}: ${cell.value}` `` — a raw ISO date beside an\n * unformatted number, joined by a hard-coded `': '`. Three things were wrong\n * at once and none of them are visible from the template: `2026-09-10` is not\n * how most of the world writes a date, `1234` is not how every locale groups\n * digits (`ar-SA` does not even use these ones), and the separator and order\n * were frozen into a shape a translator could not reach.\n *\n * Both halves go through `Intl`: the date in `WR_DATE_LOCALE`, which the weekday\n * and month labels use too and which follows Angular's `LOCALE_ID` unless\n * `withDates()` pins it, and the count in `LOCALE_ID` itself — or through\n * `valueFormat` — as every chart writes its numbers. The key ships as\n * `{{date}}: {{count}}` everywhere, so nothing reorders today and every locale can.\n */\n protected cellTitle(cell: { readonly date: Date; readonly value: number }): string {\n return this.cellText({ date: this.dateFormat().format(cell.date), count: this.numbers.value(cell.value) });\n }\n\n /**\n * The formatters, built once. They were built per call, and with `tooltip` off\n * the template asks for every square's title on every pass — so each `mousemove`\n * over the grid, which still marks the view for check, built 740 of them: 44,400\n * for 60 moves, measured in dev mode at 907–931ms against 348–358ms with the\n * tooltip on.\n */\n private readonly dateFormat = computed(() => new Intl.DateTimeFormat(this.locale, { dateStyle: 'medium' }));\n\n /**\n * Every square's `title`, and only while the tooltip is off — the tooltip carries the\n * same sentence, and the browser would open a second copy a moment later. Worked out\n * when the days or the catalog change, not on every pass of the template.\n */\n protected readonly titles = computed(() => (this.tooltip() ? null : this.cells().map(cell => this.cellTitle(cell))));\n\n /** Last day to render. @default today */\n readonly endDate = input<string | Date | null>(null);\n\n /** Number of weeks (columns) to render. @default 53 */\n readonly weeks = input(53, { transform: (v: unknown): number => Math.max(4, coerceNumberProperty(v, 53)) });\n\n /** Cell side in CSS pixels. @default 11 */\n readonly cellSize = input(11, { transform: (v: unknown): number => Math.max(4, coerceNumberProperty(v, 11)) });\n\n /** Pixel gap between cells. @default 2 */\n readonly cellGap = input(2, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 2)) });\n\n /** Cell fill colour at full intensity. @default 'var(--wr-color-primary)' */\n readonly color = input<string>('var(--wr-color-primary)');\n\n /** Background colour for zero-value days. @default color-mix(in srgb, var(--wr-border-base) 50%, transparent) */\n readonly emptyColor = input<string>('color-mix(in srgb, var(--wr-border-base) 50%, transparent)');\n\n /** Show the weekday + month labels around the grid. @default true */\n readonly showLabels = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Show a tooltip with the day and its count on hover. It is the sentence the\n * square's `title` carried, so the `title` is written only while this is off —\n * or the browser would open a second copy a moment later. @default true\n */\n readonly tooltip = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Writes each day's count in the tooltip, the `title` and the data table. `null` uses\n * `Intl.NumberFormat` in `LOCALE_ID`.\n */\n readonly valueFormat = input<((value: number) => string) | null>(null);\n\n /**\n * Render the days' values as a table that only assistive technology reaches: a row per\n * week, headed by its dates, and a column per weekday, each day's count written the way\n * the tooltip writes it. A day after the last one drawn is an empty cell.\n *\n * The grid is one named `role=\"img\"`, which hides everything inside it, so without the\n * table the values are nowhere a screen reader can walk. It is rendered beside the grid,\n * clipped to nothing: it takes no room, draws nothing and holds no tab stop.\n * @default false\n */\n readonly dataTable = input(false, { transform: coerceBooleanProperty });\n\n /** A day's count as the tooltip, the `title` and the data table write it, in `LOCALE_ID`: never compact. */\n private readonly numbers = useChartNumbers(this.valueFormat);\n\n private readonly daysEl = viewChild<ElementRef<HTMLElement>>('days');\n\n private readonly gridEl = viewChild<ElementRef<HTMLElement>>('grid');\n\n /**\n * Whether the year is wider than the host, which then scrolls it — and is a tab stop\n * while it does. `axe`'s `scrollable-region-focusable` named the scroller with no stop\n * at all, and in WebKit, which makes no scroller focusable by itself, a keyboard could\n * not reach the newest weeks. Measured in the browser after render and on every resize;\n * `false` on the server and in jsdom, which lay nothing out.\n */\n protected readonly scrollable = signal(false);\n\n private readonly locale = inject(WR_DATE_LOCALE);\n\n /**\n * Weekday names from the locale rather than a hard-coded English list — the row order is\n * Sunday-first, matching the grid's own alignment, so 7 Jan 2024 (a Sunday) is the\n * reference. Rows without a label stay blank on purpose: seven labels do not fit.\n */\n protected readonly weekdayLabels = computed<readonly string[]>(() => {\n const formatter = new Intl.DateTimeFormat(this.locale, { weekday: 'short' });\n const sunday = new Date(2024, 0, 7);\n return Array.from({ length: 7 }, (_, row) => {\n if (!LABELLED_ROWS.has(row)) return '';\n const day = new Date(sunday);\n day.setDate(sunday.getDate() + row);\n return formatter.format(day);\n });\n });\n\n private readonly monthNames = computed<readonly string[]>(() => {\n const formatter = new Intl.DateTimeFormat(this.locale, { month: 'short' });\n return Array.from({ length: 12 }, (_, month) => formatter.format(new Date(2024, month, 15)));\n });\n\n protected readonly cells = computed<readonly Cell[]>(() => {\n const end = this.endDate() ? parseInput(this.endDate()!) : new Date();\n end.setHours(0, 0, 0, 0);\n const weeks = this.weeks();\n\n // Build value lookup.\n const map = new Map<string, number>();\n for (const d of this.data()) {\n const iso = toIso(parseInput(d.date));\n map.set(iso, (map.get(iso) ?? 0) + amount(d.value));\n }\n const max = [...map.values()].reduce((a, b) => Math.max(a, b), 0);\n\n // Walk backwards from end day; arrange into columns by week, rows by weekday.\n const out: Cell[] = [];\n // Exactly `weeks` columns, the last of them the week `end` falls in, every\n // column starting on a Sunday (matches GitHub).\n //\n // Counted in WEEKS rather than in days. It used to allocate `weeks * 7`\n // days and then align the start back to a Sunday, which adds up to six\n // more — so any alignment at all produced one column more than asked for:\n // 54 for the default 53, with `--wr-calendar-heatmap-columns` reporting 54 and a\n // container sized from `weeks * (cellSize + cellGap)` one column short.\n const start = new Date(end);\n start.setDate(end.getDate() - end.getDay() - (weeks - 1) * 7);\n\n const cursor = new Date(start);\n let column = 0;\n while (cursor <= end) {\n for (let row = 0; row < 7; row++) {\n // Stop at `end`. The inner loop always walks a whole week, so once the\n // cursor crossed `end` mid-week it kept going to Saturday — up to six\n // days AFTER the last day to render, drawn as ordinary `value: 0`\n // squares and indistinguishable from a past day of no activity. With\n // the default that is today plus five future days.\n if (cursor > end) break;\n const iso = toIso(cursor);\n const value = map.get(iso) ?? 0;\n // Clamped at the BOTTOM as well as the top. A negative value produced a\n // negative intensity, which is not zero — so `colorFor` painted it in\n // the accent colour and `opacityFor` put it in the lightest band,\n // rendering a day of negative activity exactly like a day of light\n // activity, and unlike the empty day it should have matched. The scale\n // has no negative half; the honest floor is \"nothing\".\n const intensity = max > 0 ? Math.min(1, Math.max(0, value / max)) : 0;\n out.push({ iso, date: new Date(cursor), value, intensity, week: column, day: row });\n cursor.setDate(cursor.getDate() + 1);\n }\n column++;\n }\n return out;\n });\n\n /** Every weekday's full name, Sunday first as the rows are: the data table's columns. */\n private readonly weekdayNames = computed<readonly string[]>(() => {\n const formatter = new Intl.DateTimeFormat(this.locale, { weekday: 'long' });\n return Array.from({ length: 7 }, (_, row) => formatter.format(new Date(2024, 0, 7 + row)));\n });\n\n /**\n * The figures for `dataTable`: the grid's name as the caption, a column per weekday and\n * a row per week, headed by the week's first and last day drawn — `formatRange`, so the\n * locale writes the span its own way — and every day's count as the tooltip writes it.\n */\n protected readonly tableData = computed<WrChartTableData>(() => {\n const range = this.dateFormat();\n const weeks: (Cell | undefined)[][] = [];\n for (const cell of this.cells()) (weeks[cell.week] ??= [])[cell.day] = cell;\n return {\n caption: this.resolvedAriaLabel(),\n columns: this.weekdayNames(),\n groups: [\n {\n rows: weeks.map(days => {\n const drawn = days.filter((day): day is Cell => day !== undefined);\n return {\n header: range.formatRange(drawn[0].date, drawn[drawn.length - 1].date),\n cells: Array.from({ length: 7 }, (_, d) => (days[d] ? this.numbers.value(days[d].value) : '')),\n };\n }),\n },\n ],\n };\n });\n\n protected readonly monthLabels = computed(() => {\n // Pull the first cell of each visible month → render a label centered\n // over its column.\n const cells = this.cells();\n const seen = new Set<string>();\n return cells\n .filter(cell => {\n const date = new Date(`${cell.iso}T00:00:00`);\n if (date.getDate() !== 1) return false;\n const key = `${date.getFullYear()}-${date.getMonth()}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n })\n .map(cell => ({\n label: this.monthNames()[new Date(`${cell.iso}T00:00:00`).getMonth()],\n week: cell.week,\n }));\n });\n\n protected readonly columnCount = computed(() => {\n const cells = this.cells();\n return cells.length === 0 ? 0 : cells[cells.length - 1].week + 1;\n });\n\n /** Each day's position in `cells()`, for the square the pointer lands on. */\n private readonly indexByIso = computed(() => new Map(this.cells().map((cell, index) => [cell.iso, index])));\n\n /**\n * One tooltip for the whole year, pointing at the hovered day: above its square,\n * below it when there is no room above, and slid along the viewport edge for the\n * first and last weeks with the arrow still on the square. A listener on the grid\n * rather than one per square: a year is 371 of them.\n *\n * The box is the square's LAYOUT box rather than its client rect. The hovered square\n * grows by `:hover` over a transition, and a rect read part way through it would\n * move the chip by up to a fifth of a square depending on when it was measured;\n * the scale is centred, so the layout box is the rect's centre and the square's\n * own size.\n */\n protected readonly tip = useChartTooltip(this.tooltip, index => {\n const cell = this.cells()[index];\n // The squares are the container's only children, drawn in `cells()` order.\n const square = cell ? this.daysEl()?.nativeElement.children.item(index) : null;\n if (!cell || !(square instanceof HTMLElement)) return null;\n const rect = square.getBoundingClientRect();\n const width = square.offsetWidth;\n const height = square.offsetHeight;\n return {\n datum: { value: this.cellTitle(cell) },\n anchor: {\n x: (rect.left + rect.right - width) / 2,\n y: (rect.top + rect.bottom - height) / 2,\n width,\n height,\n },\n };\n });\n\n /**\n * Which square the pointer is on, from a `mousemove` on the grid. Over the gap\n * between two squares it is on none, and the tooltip starts to leave.\n */\n protected onCellsPointer(event: MouseEvent): void {\n const iso = (event.target as Element | null)?.closest<HTMLElement>('.wr-calendar-heatmap__cell')?.dataset['date'];\n const index = iso === undefined ? undefined : this.indexByIso().get(iso);\n if (index === undefined) this.tip.leave(event);\n else this.tip.enter(index);\n }\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('charts/calendar-heatmap');\n const host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n const destroyRef = inject(DestroyRef);\n // Measured after render, in a browser, and again whenever the host or the grid changes\n // size: the host when its container does, the grid when `weeks` or `cellSize` does.\n // The observer's first report is the first measurement, so a year that boots narrower\n // than its container opens on its newest weeks, and so does one that starts to\n // overflow later — a chart that booted hidden, a window made narrow. A host that\n // already scrolled is left where the reader put it.\n afterNextRender(() => {\n const grid = this.gridEl()?.nativeElement;\n if (typeof ResizeObserver === 'undefined') return;\n const measure = (): void => {\n const overflows = host.scrollWidth > host.clientWidth;\n if (overflows && !this.scrollable()) WrCalendarHeatmap.scrollToEnd(host);\n this.scrollable.set(overflows);\n };\n const observer = new ResizeObserver(measure);\n observer.observe(host);\n if (grid) observer.observe(grid);\n destroyRef.onDestroy(() => observer.disconnect());\n });\n }\n\n /**\n * Scrolls the host to its inline end, where the newest weeks are: the right in LTR and\n * the left under RTL, where `scrollLeft` runs from 0 down to minus the overflow. The\n * value is clamped by the browser, so either sign of the whole width lands on the end.\n */\n private static scrollToEnd(host: HTMLElement): void {\n const rtl = getComputedStyle(host).direction === 'rtl';\n host.scrollLeft = rtl ? -host.scrollWidth : host.scrollWidth;\n }\n\n protected colorFor(intensity: number): string {\n if (intensity === 0) return this.emptyColor();\n return this.color();\n }\n\n protected opacityFor(intensity: number): number {\n if (intensity === 0) return 1;\n // 4 levels — match the GitHub aesthetic.\n if (intensity < 0.25) return 0.25;\n if (intensity < 0.5) return 0.5;\n if (intensity < 0.75) return 0.75;\n return 1;\n }\n}\n\nexport type { WrHeatmapDatum } from './types';\n","<div\n #grid\n class=\"wr-calendar-heatmap__grid\"\n role=\"img\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [style.--wr-calendar-heatmap-cell-size.px]=\"cellSize()\"\n [style.--wr-calendar-heatmap-cell-gap.px]=\"cellGap()\"\n [style.--wr-calendar-heatmap-columns]=\"columnCount()\"\n>\n @if (showLabels()) {\n <div class=\"wr-calendar-heatmap__weekdays\">\n @for (label of weekdayLabels(); track $index) {\n <span class=\"wr-calendar-heatmap__weekday\">{{ label }}</span>\n }\n </div>\n }\n\n <div #days class=\"wr-calendar-heatmap__cells\" (mousemove)=\"onCellsPointer($event)\" (mouseleave)=\"tip.leave($event)\">\n @for (cell of cells(); track cell.iso) {\n <span\n class=\"wr-calendar-heatmap__cell\"\n [style.background]=\"colorFor(cell.intensity)\"\n [style.opacity]=\"opacityFor(cell.intensity)\"\n [style.grid-column]=\"cell.week + 1\"\n [style.grid-row]=\"cell.day + 1\"\n [attr.title]=\"titles()?.[$index] ?? null\"\n [attr.data-date]=\"cell.iso\"\n [attr.data-value]=\"cell.value\"\n aria-hidden=\"true\"\n ></span>\n }\n </div>\n\n @if (showLabels()) {\n <div class=\"wr-calendar-heatmap__months\">\n @for (m of monthLabels(); track $index) {\n <span class=\"wr-calendar-heatmap__month\" [style.grid-column]=\"m.week + 1\">{{ m.label }}</span>\n }\n </div>\n }\n</div>\n\n@if (dataTable()) {\n <!-- The figures for a screen reader, beside the grid's `img` and never inside it: `img`\n makes everything it holds presentational. Clipped to nothing by its own stylesheet,\n so it takes no room, draws nothing and adds nothing to the scroll. -->\n <wr-chart-table [data]=\"tableData()\" />\n}\n"],"mappings":";;;;;;;;;;;;;;AAuCA,SAAS,MAAM,GAAO;CAIpB,OAAO,GAHG,EAAE,YAGF,EAAC,GAFD,OAAO,EAAE,SAAQ,IAAK,CAAC,CAAC,CAAC,SAAS,GAAG,GAEhC,EAAC,GADJ,OAAO,EAAE,QAAO,CAAE,CAAC,CAAC,SAAS,GAAG,GACxB;AACtB;AAEA,SAAS,WAAW,OAAoB;CACtC,OAAO,iBAAiB,OAAO,IAAI,KAAK,KAAK,oBAAI,IAAI,KAAK,GAAG,MAAK,UAAW;AAC/E;AAGA,MAAM,gCAAgB,IAAI,IAAI;CAAC;CAAG;CAAG;AAAC,CAAC;AAWvC,SAAS,OAAO,KAAW;CACzB,OAAO,OAAO,SAAS,GAAG,IAAI,MAAM;AACtC;AAoCA,IAAa,oBAAb,MAAa,kBAAiB;CAKnB,OAAO,MAAiC,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAO3C,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAE5B,oBAAoB,YAAY,KAAK,WAAW,yBAAyB,kBAAkB;CAE7F,WAAW,iBAAiB,wBAAwB,qBAAqB;CAkBhF,UAAU,MAAqD;EACvE,OAAO,KAAK,SAAS;GAAE,MAAM,KAAK,WAAU,CAAE,CAAC,OAAO,KAAK,IAAI;GAAG,OAAO,KAAK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A;GAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,aAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,QAAM,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAEN,QAAM,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-charts-calendar-heatmap.mjs","names":[],"sources":["../../../projects/lib/charts/calendar-heatmap/calendar-heatmap.ts","../../../projects/lib/charts/calendar-heatmap/calendar-heatmap.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n DestroyRef,\n ElementRef,\n ViewEncapsulation,\n afterNextRender,\n computed,\n inject,\n input,\n signal,\n viewChild,\n} from '@angular/core';\n\nimport { WrChartTable, type WrChartTableData, useChartNumbers } from 'ngwr/charts/core';\nimport { wrDateLocale } from 'ngwr/date';\nimport { useI18nFormatter, useI18nText } from 'ngwr/i18n';\nimport { useChartTooltip } from 'ngwr/popover';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrHeatmapDatum } from './types';\n\ninterface Cell {\n readonly iso: string;\n /** The day as the reader's locale writes it — see `cellTitle`. */\n readonly date: Date;\n readonly value: number;\n readonly intensity: number;\n readonly week: number;\n readonly day: number;\n}\n\nfunction toIso(d: Date): string {\n const y = d.getFullYear();\n const m = String(d.getMonth() + 1).padStart(2, '0');\n const day = String(d.getDate()).padStart(2, '0');\n return `${y}-${m}-${day}`;\n}\n\nfunction parseInput(value: string | Date): Date {\n return value instanceof Date ? new Date(value) : new Date(`${value}T00:00:00`);\n}\n\n/** Which rows carry a weekday label: three of seven, or they do not fit. */\nconst LABELLED_ROWS = new Set([1, 3, 5]);\n\n/**\n * A day's contribution, with anything non-finite read as `0`.\n *\n * One `NaN` used to flatten the entire rendered window rather than its own day:\n * `Math.max(a, NaN)` is `NaN`, so the data set's maximum became `NaN`, `max > 0`\n * was false, and every cell fell to intensity 0 — a map that reads as a stretch\n * with no activity at all. The bad day also printed the literal text `NaN` in its\n * `title`.\n */\nfunction amount(raw: number): number {\n return Number.isFinite(raw) ? raw : 0;\n}\n\n/**\n * GitHub-style year-grid heatmap. One column per ISO week, one row per\n * weekday — cells coloured by `value` relative to the data set's max.\n *\n * **A year does not reflow.** Its 53 columns are a fixed cell size, so in a container\n * narrower than the grid the host scrolls sideways. While it does, it is a tab stop with\n * the shared focus ring, so the keyboard can scroll it too — WebKit makes no scroller\n * focusable by itself — and it opens on the inline END, the newest weeks, rather than on\n * the oldest. The stop carries no name of its own: focus lands on the grid's picture,\n * named by `ariaLabel`.\n *\n * **What a screen reader gets.** The grid is one named `role=\"img\"` and every square is\n * hidden, so the days' values are not in text anywhere unless `dataTable` renders them;\n * without it, say what the year shows in `ariaLabel`.\n *\n * @example\n * ```html\n * <wr-calendar-heatmap [data]=\"contributions\" />\n * <wr-calendar-heatmap [data]=\"data\" [endDate]=\"today\" [weeks]=\"26\" color=\"#10b981\" />\n * ```\n *\n * @see https://ngwr.dev/charts/calendar-heatmap\n */\n@Component({\n selector: 'wr-calendar-heatmap',\n templateUrl: './calendar-heatmap.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-calendar-heatmap',\n // A tab stop only while the year is wider than its container: see `scrollable`.\n '[attr.tabindex]': 'scrollable() ? 0 : null',\n },\n imports: [WrChartTable],\n})\nexport class WrCalendarHeatmap {\n /**\n * One entry per day — `{ date, value }`. Days you pass nothing for render as\n * empty cells, so a sparse array is the normal shape rather than a gap.\n */\n readonly data = input<readonly WrHeatmapDatum[]>([]);\n\n /**\n * Accessible name of the whole grid. Its cells are bare spans whose `title` a screen\n * reader on a role-less element does not read, so the map used to be several hundred\n * anonymous nodes with no name. Falls back to `calendarHeatmap.label`.\n */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'calendarHeatmap.label', 'Calendar heatmap');\n\n private readonly cellText = useI18nFormatter('calendarHeatmap.cell', '{{date}}: {{count}}');\n\n /**\n * A cell's tooltip, with both halves formatted and the sentence in the catalog.\n *\n * It used to be `` `${cell.iso}: ${cell.value}` `` — a raw ISO date beside an\n * unformatted number, joined by a hard-coded `': '`. Three things were wrong\n * at once and none of them are visible from the template: `2026-09-10` is not\n * how most of the world writes a date, `1234` is not how every locale groups\n * digits (`ar-SA` does not even use these ones), and the separator and order\n * were frozen into a shape a translator could not reach.\n *\n * Both halves go through `Intl`: the date in `WR_DATE_LOCALE`, which the weekday\n * and month labels use too and which follows Angular's `LOCALE_ID` unless\n * `withDates()` pins it, and the count in `LOCALE_ID` itself — or through\n * `valueFormat` — as every chart writes its numbers. The key ships as\n * `{{date}}: {{count}}` everywhere, so nothing reorders today and every locale can.\n */\n protected cellTitle(cell: { readonly date: Date; readonly value: number }): string {\n return this.cellText({ date: this.dateFormat().format(cell.date), count: this.numbers.value(cell.value) });\n }\n\n /**\n * The formatters, built once. They were built per call, and with `tooltip` off\n * the template asks for every square's title on every pass — so each `mousemove`\n * over the grid, which still marks the view for check, built 740 of them: 44,400\n * for 60 moves, measured in dev mode at 907–931ms against 348–358ms with the\n * tooltip on.\n */\n private readonly dateFormat = computed(() => new Intl.DateTimeFormat(this.locale, { dateStyle: 'medium' }));\n\n /**\n * Every square's `title`, and only while the tooltip is off — the tooltip carries the\n * same sentence, and the browser would open a second copy a moment later. Worked out\n * when the days or the catalog change, not on every pass of the template.\n */\n protected readonly titles = computed(() => (this.tooltip() ? null : this.cells().map(cell => this.cellTitle(cell))));\n\n /** Last day to render. @default today */\n readonly endDate = input<string | Date | null>(null);\n\n /** Number of weeks (columns) to render. @default 53 */\n readonly weeks = input(53, { transform: (v: unknown): number => Math.max(4, coerceNumberProperty(v, 53)) });\n\n /** Cell side in CSS pixels. @default 11 */\n readonly cellSize = input(11, { transform: (v: unknown): number => Math.max(4, coerceNumberProperty(v, 11)) });\n\n /** Pixel gap between cells. @default 2 */\n readonly cellGap = input(2, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 2)) });\n\n /** Cell fill colour at full intensity. @default 'var(--wr-color-primary)' */\n readonly color = input<string>('var(--wr-color-primary)');\n\n /** Background colour for zero-value days. @default color-mix(in srgb, var(--wr-border-base) 50%, transparent) */\n readonly emptyColor = input<string>('color-mix(in srgb, var(--wr-border-base) 50%, transparent)');\n\n /** Show the weekday + month labels around the grid. @default true */\n readonly showLabels = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Show a tooltip with the day and its count on hover. It is the sentence the\n * square's `title` carried, so the `title` is written only while this is off —\n * or the browser would open a second copy a moment later. @default true\n */\n readonly tooltip = input(true, { transform: coerceBooleanProperty });\n\n /**\n * Writes each day's count in the tooltip, the `title` and the data table. `null` uses\n * `Intl.NumberFormat` in `LOCALE_ID`.\n */\n readonly valueFormat = input<((value: number) => string) | null>(null);\n\n /**\n * Render the days' values as a table that only assistive technology reaches: a row per\n * week, headed by its dates, and a column per weekday, each day's count written the way\n * the tooltip writes it. A day after the last one drawn is an empty cell.\n *\n * The grid is one named `role=\"img\"`, which hides everything inside it, so without the\n * table the values are nowhere a screen reader can walk. It is rendered beside the grid,\n * clipped to nothing: it takes no room, draws nothing and holds no tab stop.\n * @default false\n */\n readonly dataTable = input(false, { transform: coerceBooleanProperty });\n\n /** A day's count as the tooltip, the `title` and the data table write it, in `LOCALE_ID`: never compact. */\n private readonly numbers = useChartNumbers(this.valueFormat);\n\n private readonly daysEl = viewChild<ElementRef<HTMLElement>>('days');\n\n private readonly gridEl = viewChild<ElementRef<HTMLElement>>('grid');\n\n /**\n * Whether the year is wider than the host, which then scrolls it — and is a tab stop\n * while it does. `axe`'s `scrollable-region-focusable` named the scroller with no stop\n * at all, and in WebKit, which makes no scroller focusable by itself, a keyboard could\n * not reach the newest weeks. Measured in the browser after render and on every resize;\n * `false` on the server and in jsdom, which lay nothing out.\n */\n protected readonly scrollable = signal(false);\n\n private readonly dateLocale = wrDateLocale();\n\n private get locale(): string {\n return this.dateLocale();\n }\n\n /**\n * Weekday names from the locale rather than a hard-coded English list — the row order is\n * Sunday-first, matching the grid's own alignment, so 7 Jan 2024 (a Sunday) is the\n * reference. Rows without a label stay blank on purpose: seven labels do not fit.\n */\n protected readonly weekdayLabels = computed<readonly string[]>(() => {\n const formatter = new Intl.DateTimeFormat(this.locale, { weekday: 'short' });\n const sunday = new Date(2024, 0, 7);\n return Array.from({ length: 7 }, (_, row) => {\n if (!LABELLED_ROWS.has(row)) return '';\n const day = new Date(sunday);\n day.setDate(sunday.getDate() + row);\n return formatter.format(day);\n });\n });\n\n private readonly monthNames = computed<readonly string[]>(() => {\n const formatter = new Intl.DateTimeFormat(this.locale, { month: 'short' });\n return Array.from({ length: 12 }, (_, month) => formatter.format(new Date(2024, month, 15)));\n });\n\n protected readonly cells = computed<readonly Cell[]>(() => {\n const end = this.endDate() ? parseInput(this.endDate()!) : new Date();\n end.setHours(0, 0, 0, 0);\n const weeks = this.weeks();\n\n // Build value lookup.\n const map = new Map<string, number>();\n for (const d of this.data()) {\n const iso = toIso(parseInput(d.date));\n map.set(iso, (map.get(iso) ?? 0) + amount(d.value));\n }\n const max = [...map.values()].reduce((a, b) => Math.max(a, b), 0);\n\n // Walk backwards from end day; arrange into columns by week, rows by weekday.\n const out: Cell[] = [];\n // Exactly `weeks` columns, the last of them the week `end` falls in, every\n // column starting on a Sunday (matches GitHub).\n //\n // Counted in WEEKS rather than in days. It used to allocate `weeks * 7`\n // days and then align the start back to a Sunday, which adds up to six\n // more — so any alignment at all produced one column more than asked for:\n // 54 for the default 53, with `--wr-calendar-heatmap-columns` reporting 54 and a\n // container sized from `weeks * (cellSize + cellGap)` one column short.\n const start = new Date(end);\n start.setDate(end.getDate() - end.getDay() - (weeks - 1) * 7);\n\n const cursor = new Date(start);\n let column = 0;\n while (cursor <= end) {\n for (let row = 0; row < 7; row++) {\n // Stop at `end`. The inner loop always walks a whole week, so once the\n // cursor crossed `end` mid-week it kept going to Saturday — up to six\n // days AFTER the last day to render, drawn as ordinary `value: 0`\n // squares and indistinguishable from a past day of no activity. With\n // the default that is today plus five future days.\n if (cursor > end) break;\n const iso = toIso(cursor);\n const value = map.get(iso) ?? 0;\n // Clamped at the BOTTOM as well as the top. A negative value produced a\n // negative intensity, which is not zero — so `colorFor` painted it in\n // the accent colour and `opacityFor` put it in the lightest band,\n // rendering a day of negative activity exactly like a day of light\n // activity, and unlike the empty day it should have matched. The scale\n // has no negative half; the honest floor is \"nothing\".\n const intensity = max > 0 ? Math.min(1, Math.max(0, value / max)) : 0;\n out.push({ iso, date: new Date(cursor), value, intensity, week: column, day: row });\n cursor.setDate(cursor.getDate() + 1);\n }\n column++;\n }\n return out;\n });\n\n /** Every weekday's full name, Sunday first as the rows are: the data table's columns. */\n private readonly weekdayNames = computed<readonly string[]>(() => {\n const formatter = new Intl.DateTimeFormat(this.locale, { weekday: 'long' });\n return Array.from({ length: 7 }, (_, row) => formatter.format(new Date(2024, 0, 7 + row)));\n });\n\n /**\n * The figures for `dataTable`: the grid's name as the caption, a column per weekday and\n * a row per week, headed by the week's first and last day drawn — `formatRange`, so the\n * locale writes the span its own way — and every day's count as the tooltip writes it.\n */\n protected readonly tableData = computed<WrChartTableData>(() => {\n const range = this.dateFormat();\n const weeks: (Cell | undefined)[][] = [];\n for (const cell of this.cells()) (weeks[cell.week] ??= [])[cell.day] = cell;\n return {\n caption: this.resolvedAriaLabel(),\n columns: this.weekdayNames(),\n groups: [\n {\n rows: weeks.map(days => {\n const drawn = days.filter((day): day is Cell => day !== undefined);\n return {\n header: range.formatRange(drawn[0].date, drawn[drawn.length - 1].date),\n cells: Array.from({ length: 7 }, (_, d) => (days[d] ? this.numbers.value(days[d].value) : '')),\n };\n }),\n },\n ],\n };\n });\n\n protected readonly monthLabels = computed(() => {\n // Pull the first cell of each visible month → render a label centered\n // over its column.\n const cells = this.cells();\n const seen = new Set<string>();\n return cells\n .filter(cell => {\n const date = new Date(`${cell.iso}T00:00:00`);\n if (date.getDate() !== 1) return false;\n const key = `${date.getFullYear()}-${date.getMonth()}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n })\n .map(cell => ({\n label: this.monthNames()[new Date(`${cell.iso}T00:00:00`).getMonth()],\n week: cell.week,\n }));\n });\n\n protected readonly columnCount = computed(() => {\n const cells = this.cells();\n return cells.length === 0 ? 0 : cells[cells.length - 1].week + 1;\n });\n\n /** Each day's position in `cells()`, for the square the pointer lands on. */\n private readonly indexByIso = computed(() => new Map(this.cells().map((cell, index) => [cell.iso, index])));\n\n /**\n * One tooltip for the whole year, pointing at the hovered day: above its square,\n * below it when there is no room above, and slid along the viewport edge for the\n * first and last weeks with the arrow still on the square. A listener on the grid\n * rather than one per square: a year is 371 of them.\n *\n * The box is the square's LAYOUT box rather than its client rect. The hovered square\n * grows by `:hover` over a transition, and a rect read part way through it would\n * move the chip by up to a fifth of a square depending on when it was measured;\n * the scale is centred, so the layout box is the rect's centre and the square's\n * own size.\n */\n protected readonly tip = useChartTooltip(this.tooltip, index => {\n const cell = this.cells()[index];\n // The squares are the container's only children, drawn in `cells()` order.\n const square = cell ? this.daysEl()?.nativeElement.children.item(index) : null;\n if (!cell || !(square instanceof HTMLElement)) return null;\n const rect = square.getBoundingClientRect();\n const width = square.offsetWidth;\n const height = square.offsetHeight;\n return {\n datum: { value: this.cellTitle(cell) },\n anchor: {\n x: (rect.left + rect.right - width) / 2,\n y: (rect.top + rect.bottom - height) / 2,\n width,\n height,\n },\n };\n });\n\n /**\n * Which square the pointer is on, from a `mousemove` on the grid. Over the gap\n * between two squares it is on none, and the tooltip starts to leave.\n */\n protected onCellsPointer(event: MouseEvent): void {\n const iso = (event.target as Element | null)?.closest<HTMLElement>('.wr-calendar-heatmap__cell')?.dataset['date'];\n const index = iso === undefined ? undefined : this.indexByIso().get(iso);\n if (index === undefined) this.tip.leave(event);\n else this.tip.enter(index);\n }\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('charts/calendar-heatmap');\n const host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n const destroyRef = inject(DestroyRef);\n // Measured after render, in a browser, and again whenever the host or the grid changes\n // size: the host when its container does, the grid when `weeks` or `cellSize` does.\n // The observer's first report is the first measurement, so a year that boots narrower\n // than its container opens on its newest weeks, and so does one that starts to\n // overflow later — a chart that booted hidden, a window made narrow. A host that\n // already scrolled is left where the reader put it.\n afterNextRender(() => {\n const grid = this.gridEl()?.nativeElement;\n if (typeof ResizeObserver === 'undefined') return;\n const measure = (): void => {\n const overflows = host.scrollWidth > host.clientWidth;\n if (overflows && !this.scrollable()) WrCalendarHeatmap.scrollToEnd(host);\n this.scrollable.set(overflows);\n };\n const observer = new ResizeObserver(measure);\n observer.observe(host);\n if (grid) observer.observe(grid);\n destroyRef.onDestroy(() => observer.disconnect());\n });\n }\n\n /**\n * Scrolls the host to its inline end, where the newest weeks are: the right in LTR and\n * the left under RTL, where `scrollLeft` runs from 0 down to minus the overflow. The\n * value is clamped by the browser, so either sign of the whole width lands on the end.\n */\n private static scrollToEnd(host: HTMLElement): void {\n const rtl = getComputedStyle(host).direction === 'rtl';\n host.scrollLeft = rtl ? -host.scrollWidth : host.scrollWidth;\n }\n\n protected colorFor(intensity: number): string {\n if (intensity === 0) return this.emptyColor();\n return this.color();\n }\n\n protected opacityFor(intensity: number): number {\n if (intensity === 0) return 1;\n // 4 levels — match the GitHub aesthetic.\n if (intensity < 0.25) return 0.25;\n if (intensity < 0.5) return 0.5;\n if (intensity < 0.75) return 0.75;\n return 1;\n }\n}\n\nexport type { WrHeatmapDatum } from './types';\n","<div\n #grid\n class=\"wr-calendar-heatmap__grid\"\n role=\"img\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [style.--wr-calendar-heatmap-cell-size.px]=\"cellSize()\"\n [style.--wr-calendar-heatmap-cell-gap.px]=\"cellGap()\"\n [style.--wr-calendar-heatmap-columns]=\"columnCount()\"\n>\n @if (showLabels()) {\n <div class=\"wr-calendar-heatmap__weekdays\">\n @for (label of weekdayLabels(); track $index) {\n <span class=\"wr-calendar-heatmap__weekday\">{{ label }}</span>\n }\n </div>\n }\n\n <div #days class=\"wr-calendar-heatmap__cells\" (mousemove)=\"onCellsPointer($event)\" (mouseleave)=\"tip.leave($event)\">\n @for (cell of cells(); track cell.iso) {\n <span\n class=\"wr-calendar-heatmap__cell\"\n [style.background]=\"colorFor(cell.intensity)\"\n [style.opacity]=\"opacityFor(cell.intensity)\"\n [style.grid-column]=\"cell.week + 1\"\n [style.grid-row]=\"cell.day + 1\"\n [attr.title]=\"titles()?.[$index] ?? null\"\n [attr.data-date]=\"cell.iso\"\n [attr.data-value]=\"cell.value\"\n aria-hidden=\"true\"\n ></span>\n }\n </div>\n\n @if (showLabels()) {\n <div class=\"wr-calendar-heatmap__months\">\n @for (m of monthLabels(); track $index) {\n <span class=\"wr-calendar-heatmap__month\" [style.grid-column]=\"m.week + 1\">{{ m.label }}</span>\n }\n </div>\n }\n</div>\n\n@if (dataTable()) {\n <!-- The figures for a screen reader, beside the grid's `img` and never inside it: `img`\n makes everything it holds presentational. Clipped to nothing by its own stylesheet,\n so it takes no room, draws nothing and adds nothing to the scroll. -->\n <wr-chart-table [data]=\"tableData()\" />\n}\n"],"mappings":";;;;;;;;;;;;;;AAuCA,SAAS,MAAM,GAAO;CAIpB,OAAO,GAHG,EAAE,YAGF,EAAC,GAFD,OAAO,EAAE,SAAQ,IAAK,CAAC,CAAC,CAAC,SAAS,GAAG,GAEhC,EAAC,GADJ,OAAO,EAAE,QAAO,CAAE,CAAC,CAAC,SAAS,GAAG,GACxB;AACtB;AAEA,SAAS,WAAW,OAAoB;CACtC,OAAO,iBAAiB,OAAO,IAAI,KAAK,KAAK,oBAAI,IAAI,KAAK,GAAG,MAAK,UAAW;AAC/E;AAGA,MAAM,gCAAgB,IAAI,IAAI;CAAC;CAAG;CAAG;AAAC,CAAC;AAWvC,SAAS,OAAO,KAAW;CACzB,OAAO,OAAO,SAAS,GAAG,IAAI,MAAM;AACtC;AAoCA,IAAa,oBAAb,MAAa,kBAAiB;CAKnB,OAAO,MAAiC,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAO3C,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAE5B,oBAAoB,YAAY,KAAK,WAAW,yBAAyB,kBAAkB;CAE7F,WAAW,iBAAiB,wBAAwB,qBAAqB;CAkBhF,UAAU,MAAqD;EACvE,OAAO,KAAK,SAAS;GAAE,MAAM,KAAK,WAAU,CAAE,CAAC,OAAO,KAAK,IAAI;GAAG,OAAO,KAAK,QA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,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,aAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,QAAM,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAEN,QAAM,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -62,7 +62,7 @@ var WrCheckbox = class WrCheckbox {
|
|
|
62
62
|
ariaInvalid = computed(() => this.group ? null : this.fieldAria.ariaInvalid(), ...ngDevMode ? [{ debugName: "ariaInvalid" }] : /* istanbul ignore next */ []);
|
|
63
63
|
describedBy = computed(() => this.group ? null : this.fieldAria.describedBy(), ...ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []);
|
|
64
64
|
classes = computed(() => {
|
|
65
|
-
const parts = [
|
|
65
|
+
const parts = [];
|
|
66
66
|
const size = this.size();
|
|
67
67
|
if (size !== "md") parts.push(`wr-checkbox--${size}`);
|
|
68
68
|
if (this.indeterminate()) parts.push("wr-checkbox--indeterminate");
|
|
@@ -184,11 +184,14 @@ var WrCheckbox = class WrCheckbox {
|
|
|
184
184
|
checked: "checkedChange",
|
|
185
185
|
touch: "touch"
|
|
186
186
|
},
|
|
187
|
-
host: {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
187
|
+
host: {
|
|
188
|
+
properties: {
|
|
189
|
+
"class": "classes()",
|
|
190
|
+
"attr.id": "null",
|
|
191
|
+
"attr.data-checkbox-value": "reflectedValue()"
|
|
192
|
+
},
|
|
193
|
+
classAttribute: "wr-checkbox"
|
|
194
|
+
},
|
|
192
195
|
viewQueries: [{
|
|
193
196
|
propertyName: "native",
|
|
194
197
|
first: true,
|
|
@@ -218,6 +221,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
218
221
|
selector: "wr-checkbox",
|
|
219
222
|
encapsulation: ViewEncapsulation.None,
|
|
220
223
|
host: {
|
|
224
|
+
class: "wr-checkbox",
|
|
221
225
|
"[class]": "classes()",
|
|
222
226
|
"[attr.id]": "null",
|
|
223
227
|
"[attr.data-checkbox-value]": "reflectedValue()"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-checkbox.mjs","names":[],"sources":["../../../projects/lib/checkbox/tokens/checkbox-group.token.ts","../../../projects/lib/checkbox/checkbox.ts","../../../projects/lib/checkbox/checkbox.html","../../../projects/lib/checkbox/checkbox-group.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrCheckboxGroupContext } from '../types';\n\n/**\n * Token a `<wr-checkbox>` injects to read selection state from — and\n * toggle values in — its parent `<wr-checkbox-group>` (when present).\n *\n * @internal\n */\nexport const WR_CHECKBOX_GROUP = new InjectionToken<WrCheckboxGroupContext>('WR_CHECKBOX_GROUP');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n type ElementRef,\n ViewEncapsulation,\n computed,\n inject,\n input,\n model,\n output,\n viewChild,\n} from '@angular/core';\nimport type { FormCheckboxControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { WrIcon, type WrIconName } from 'ngwr/icon';\nimport { wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_CHECKBOX_GROUP } from './tokens';\n\n/**\n * Two-state checkbox.\n *\n * A signal-forms native control: it implements `FormCheckboxControl`, so\n * `[formField]` binds straight to its `checked` model — no\n * `ControlValueAccessor` in between. `[(checked)]` works standalone, and\n * classic `[(ngModel)]` / reactive forms keep working through Angular's bridge.\n *\n * @example\n * ```html\n * <wr-checkbox [(checked)]=\"agree\">I agree</wr-checkbox>\n * <wr-checkbox [formField]=\"form.agree\">I agree</wr-checkbox>\n * ```\n *\n * **Inside `<wr-checkbox-group>`** — the checkbox's `checkboxValue` is added to\n * or removed from the group's array, and the group is the native form control.\n * (The identity input is `checkboxValue`, not `value`, because\n * `FormCheckboxControl` reserves `value` — its form state is the boolean\n * `checked`.)\n *\n * @example\n * ```html\n * <wr-checkbox-group [formField]=\"form.features\">\n * <wr-checkbox checkboxValue=\"autosave\">Autosave</wr-checkbox>\n * <wr-checkbox checkboxValue=\"notifications\">Notifications</wr-checkbox>\n * </wr-checkbox-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/checkbox\n */\nexport type WrCheckboxSize = 'sm' | 'md' | 'lg';\n\n@Component({\n selector: 'wr-checkbox',\n templateUrl: './checkbox.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n '[class]': 'classes()',\n // The `id` input belongs to the native input, not to this element. A static\n // `id=\"x\"` in a consumer's template is written to the host as a plain\n // attribute AS WELL as fed to the input, which put two elements with the\n // same id in the document and made `<label for>` resolve through\n // `getElementById` to the host — not a labelable element, so `input.labels`\n // went from 1 to 0 and `document.getElementById(id)` returned the wrong node.\n '[attr.id]': 'null',\n // The group identity, reflected so a HARNESS can read it. It is the only\n // way: `checkboxValue` is an `unknown`-typed TypeScript value that reaches\n // no attribute otherwise, and `WrCheckboxHarness.getCheckboxValue()` read\n // `value` off the inner `<input>` — which nothing writes, so it answered\n // `null` for every checkbox in every state. A harness method that answers\n // the same for a working component and a broken one is the one thing the\n // harness rules forbid outright.\n //\n // `data-`, deliberately, and NOT `value`: a leftover static `value=\"x\"` from\n // before v9 still lands on this host as a plain attribute, so reading\n // `value` here would report the identity a consumer THOUGHT they set while\n // the component used `null`. That is the exact confusion migration-v9\n // exists to end.\n '[attr.data-checkbox-value]': 'reflectedValue()',\n },\n imports: [WrIcon],\n})\nexport class WrCheckbox implements FormCheckboxControl {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('checkbox');\n }\n\n /**\n * Stable id used to associate the native input with its label. Lands on the\n * inner `<input>`; the host never keeps it.\n *\n * @default Randomly generated\n */\n readonly id = input<string>(wrRandomId('wr-checkbox'));\n\n /**\n * This checkbox's identity when inside a `<wr-checkbox-group>` — the value\n * added to / removed from the group's array. Ignored in standalone mode.\n * (Named `checkboxValue`, not `value`, because `FormCheckboxControl` reserves\n * `value`.)\n */\n readonly checkboxValue = input<unknown>(null);\n\n /**\n * `checkboxValue` as an attribute, when it can be one.\n *\n * A primitive round-trips through the DOM and is what a group identity is in\n * practice. Anything else — an object, an array — has no honest attribute\n * form, so the attribute is ABSENT rather than `[object Object]`: a harness\n * reading it then gets `null`, which is true, instead of a string that looks\n * like data and identifies nothing.\n */\n protected readonly reflectedValue = computed(() => {\n const value = this.checkboxValue();\n // Narrowed inline rather than through a `typeof` held in a variable, which\n // TypeScript does not follow — and the linter is right to refuse it: the\n // point of this guard is that `String()` never sees an object.\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n return null;\n });\n\n /**\n * Accessible name for a checkbox used WITHOUT projected text — a selection\n * cell in a table, say. The wrapping `<label>` names the control whenever\n * content is projected; with none, the native input has no name, and an\n * `aria-label` put on the host lands on a `<wr-checkbox>` element that no\n * screen reader ever announces.\n */\n readonly ariaLabel = input<string | null>(null);\n\n /**\n * Ids of the elements that name this checkbox, space-separated, for a box\n * whose name is already on screen somewhere else — a table row's label cell,\n * say, joined to an action word. Lands on the inner `<input>` as\n * `aria-labelledby`, which wins over `ariaLabel` and over projected text.\n *\n * The ids have to resolve in the same document; one that matches nothing is\n * skipped, and with none left the box falls back to `ariaLabel`.\n *\n * @default null\n */\n readonly ariaLabelledby = input<string | null>(null);\n\n /**\n * Checked state — the form value. Bound by `[formField]`, two-way via\n * `[(checked)]`, or `[(ngModel)]`. Ignored inside a `<wr-checkbox-group>`,\n * where the group's array is the source of truth.\n */\n readonly checked = model<boolean>(false);\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n /**\n * Disable the checkbox. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse edits while staying focusable and submittable. Bound automatically\n * from the field's readonly state when used with `[formField]`.\n *\n * A native `<input type=\"checkbox\">` ignores the `readonly` attribute, so this\n * cancels the click's activation behaviour instead — which covers Space too,\n * since a checkbox turns Space into a click — and mirrors the state as\n * `aria-readonly`, which role `checkbox` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** Control size — shares the `--wr-control-*` contract. @default 'md' */\n readonly size = input<WrCheckboxSize>('md');\n\n /**\n * Optional icon name rendered inside the box when checked, in place of the\n * default checkmark. Use any registered NGWR icon.\n */\n readonly icon = input<WrIconName | null>(null);\n\n /**\n * Show the indeterminate (\"mixed\") state — a dash instead of a check. Visual\n * only and controlled: set it yourself for a parent \"select all\" whose\n * children are partly checked, and clear it on the next toggle. Takes visual\n * precedence over `checked`; the native input reports `aria-checked=\"mixed\"`.\n * A click the host does not answer still toggles `checked` underneath, and the\n * dash and the mixed state both stay until the binding turns `false`.\n *\n * @default false\n */\n readonly indeterminate = input(false, { transform: coerceBooleanProperty });\n\n private readonly group = inject(WR_CHECKBOX_GROUP, { optional: true });\n\n private readonly native = viewChild.required<ElementRef<HTMLInputElement>>('native');\n\n /** Rendered \"is checked\" — reads the group when grouped, else the `checked` model. */\n protected readonly isChecked = computed(() =>\n this.group ? this.group.isSelected(this.checkboxValue()) : this.checked()\n );\n\n /** Effective disabled — the `disabled` input wins, then the group. */\n protected readonly effectiveDisabled = computed(() => {\n if (this.disabled()) return true;\n return this.group ? this.group.isDisabled() : false;\n });\n\n /** Effective readonly — this box's own `readonly` input, or the group's. */\n protected readonly effectiveReadonly = computed(() => {\n if (this.readonly()) return true;\n return this.group ? this.group.isReadonly() : false;\n });\n\n /**\n * The surrounding `<wr-form-field>`'s error state, mirrored onto the native\n * input. Inside a `<wr-checkbox-group>` the GROUP is the bound control and\n * carries the state, so a grouped box shields itself and stays silent — nine\n * boxes each announcing the group's one error is noise, not information.\n */\n private readonly fieldAria = useFormFieldAria();\n protected readonly ariaInvalid = computed(() => (this.group ? null : this.fieldAria.ariaInvalid()));\n protected readonly describedBy = computed(() => (this.group ? null : this.fieldAria.describedBy()));\n\n protected readonly classes = computed(() => {\n const parts = ['wr-checkbox'];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-checkbox--${size}`);\n if (this.indeterminate()) parts.push('wr-checkbox--indeterminate');\n else if (this.isChecked()) parts.push('wr-checkbox--checked');\n if (this.effectiveDisabled()) parts.push('wr-checkbox--disabled');\n else if (this.effectiveReadonly()) parts.push('wr-checkbox--readonly');\n return parts.join(' ');\n });\n\n /**\n * Focus the checkbox — what Signal Forms calls to focus this control. The\n * native input takes it, since the host has no tab stop of its own; a disabled\n * box refuses, as a disabled input always does.\n */\n focus(options?: FocusOptions): void {\n this.native().nativeElement.focus(options);\n }\n\n // Template handlers\n\n /**\n * Cancel the toggle while readonly. `change` never fires for a click whose\n * default was prevented, so this is the only guard the pointer and Space\n * paths need; `onInputChange` keeps its own for a synthetic `change`.\n */\n protected onInputClick(event: Event): void {\n if (this.effectiveReadonly()) event.preventDefault();\n }\n\n protected onInputChange(event: Event): void {\n const inputEl = event.target as HTMLInputElement;\n // Activating a checkbox clears its own `indeterminate` before `change` fires,\n // and the `[indeterminate]` binding never writes again while the bound value\n // stays `true` — so the box kept painting the dash while the accessibility\n // tree announced \"checked\". The input is controlled: the mixed state holds\n // until the host clears it, and a host that does clears it through the\n // binding on the next change detection.\n inputEl.indeterminate = this.indeterminate();\n\n if (this.effectiveReadonly()) {\n // A synthetic `change` cannot be prevented — put the DOM back instead.\n inputEl.checked = this.isChecked();\n return;\n }\n if (this.group) {\n this.group.toggle(this.checkboxValue());\n return;\n }\n this.checked.set(inputEl.checked);\n }\n\n protected onInputBlur(): void {\n // Inside a group the GROUP is the bound control, and its own `touch` is\n // what a form listens to; the child's output is wired to nothing there.\n if (this.group) this.group.blurred();\n this.touch.emit();\n }\n}\n","<label class=\"wr-checkbox__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-checkbox__input\"\n type=\"checkbox\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-labelledby]=\"ariaLabelledby()\"\n [checked]=\"isChecked()\"\n [indeterminate]=\"indeterminate()\"\n [disabled]=\"effectiveDisabled()\"\n [attr.aria-readonly]=\"effectiveReadonly() || null\"\n [attr.aria-invalid]=\"ariaInvalid()\"\n [attr.aria-describedby]=\"describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-checkbox__box\" aria-hidden=\"true\">\n @if (indeterminate()) {\n <svg viewBox=\"0 0 16 16\" class=\"wr-checkbox__dash\">\n <line x1=\"3.5\" y1=\"8\" x2=\"12.5\" y2=\"8\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" />\n </svg>\n } @else if (icon(); as iconName) {\n <wr-icon class=\"wr-checkbox__icon\" [name]=\"iconName\" />\n } @else {\n <svg viewBox=\"0 0 16 16\" class=\"wr-checkbox__mark\">\n <polyline\n points=\"3.5 8.5 6.5 11.5 12.5 5\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n }\n </span>\n\n <span class=\"wr-checkbox__text\">\n <ng-content />\n </span>\n</label>\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 {\n Component,\n ElementRef,\n HostAttributeToken,\n ViewEncapsulation,\n computed,\n forwardRef,\n inject,\n input,\n model,\n output,\n} from '@angular/core';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_CHECKBOX_GROUP } from './tokens';\nimport type { WrCheckboxGroupContext } from './types';\n\n/**\n * Manages a group of `<wr-checkbox>` children as a single form value — an\n * array of the checked items' **`checkboxValue`** inputs, not their `value`.\n * `FormCheckboxControl` reserves `value` for the form value, so a child's\n * boolean state is `checked` and its group identity is `checkboxValue`; a\n * leftover static `value=\"x\"` lands on the host as a plain DOM attribute, and\n * every box in the group keeps the default identity `null` and toggles\n * together.\n *\n * A signal-forms native control: it implements `FormValueControl<unknown[]>`,\n * so `[formField]` binds to its `value` model. `[(value)]` works standalone,\n * and classic `[(ngModel)]` / reactive forms keep working through the bridge.\n *\n * @example\n * ```html\n * <wr-checkbox-group [formField]=\"form.features\">\n * <wr-checkbox checkboxValue=\"autosave\">Autosave</wr-checkbox>\n * <wr-checkbox checkboxValue=\"notifications\">Notifications</wr-checkbox>\n * <wr-checkbox checkboxValue=\"darkmode\">Dark mode</wr-checkbox>\n * </wr-checkbox-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/checkbox\n */\n@Component({\n selector: 'wr-checkbox-group',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-checkbox-group',\n role: 'group',\n // `<label for>` binds only to a labelable element, which a `role=\"group\"`\n // is not, so the field's own label reached this host through nothing and\n // the group announced no name at all. Same call `wr-radio-group` and\n // `wr-rating` already make.\n '[attr.aria-labelledby]': 'labelledBy()',\n '[attr.aria-invalid]': 'fieldAria.ariaInvalid()',\n '[attr.aria-describedby]': 'fieldAria.describedBy()',\n },\n providers: [\n {\n provide: WR_CHECKBOX_GROUP,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrCheckboxGroup),\n },\n ],\n})\nexport class WrCheckboxGroup implements FormValueControl<unknown[]>, WrCheckboxGroupContext {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('checkbox');\n }\n\n /**\n * Disable every child checkbox. Bound automatically from the field's\n * disabled state when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse edits on every child while they stay focusable and the value still\n * submits. Bound automatically from the field's readonly state when used with\n * `[formField]`.\n *\n * No `aria-readonly` on the host: role `group` does not support it (the state\n * is not global), so each child box mirrors its own instead.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n /**\n * The author's own `aria-labelledby`, read as a static host attribute.\n *\n * A host binding WRITES the attribute, so binding the field's label\n * unconditionally would REMOVE a reference the consumer put there by hand:\n * `<wr-segmented aria-labelledby=\"range-question\">` went nameless the moment\n * the field's label was `null`, which a harness spec caught one commit after\n * it was introduced. `HostAttributeToken` reads it at construction without\n * touching the DOM, so this stays SSR-safe, and the author's own reference\n * wins — the same precedence `[ariaLabel]` has everywhere else.\n */\n private readonly ownLabelledBy = inject(new HostAttributeToken('aria-labelledby'), { optional: true });\n\n /** The surrounding field's label, unless the author named the control. */\n protected readonly labelledBy = computed(() => this.ownLabelledBy ?? this.fieldAria.labelledBy());\n\n /** The checked items' values. Bound by `[formField]`, or two-way via `[(value)]`. */\n readonly value = model<unknown[]>([]);\n\n /** Emitted when a child toggles so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n // The current selection as a guaranteed array — a classic-forms binding can\n // write null even though the type is `unknown[]`, so normalise every read.\n private readonly selected = computed<readonly unknown[]>(() => {\n const v = this.value();\n return Array.isArray(v) ? v : [];\n });\n\n /** Effective disabled state (WrCheckboxGroupContext). */\n readonly isDisabled = computed(() => this.disabled());\n\n /** Effective readonly state (WrCheckboxGroupContext). */\n readonly isReadonly = computed(() => this.readonly());\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Focus the group — what Signal Forms calls to focus this control. The first\n * enabled box takes it, which is where Tab lands: the host is a `role=\"group\"`\n * with no tab stop of its own, and a disabled box has none either.\n */\n focus(options?: FocusOptions): void {\n this.host.nativeElement.querySelector<HTMLInputElement>('.wr-checkbox__input:not(:disabled)')?.focus(options);\n }\n\n // WrCheckboxGroupContext\n\n isSelected(value: unknown): boolean {\n return this.selected().includes(value);\n }\n\n toggle(value: unknown): void {\n if (this.isDisabled() || this.isReadonly()) return;\n const current = this.selected();\n const next = current.includes(value) ? current.filter(v => v !== value) : [...current, value];\n this.value.set(next);\n this.touch.emit();\n }\n\n /** @internal A child checkbox lost focus — see {@link WrCheckboxGroupContext.blurred}. */\n blurred(): void {\n this.touch.emit();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,oBAAoB,IAAI,eAAuC,mBAAmB;;;;;;;ACwE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SAAA;CAAA,UAAA;CAAA,MAAA;CAAe,YAAA,CAAA;EAvB3B,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;GACV,eAAe,kBAAkB;GACjC,MAAM;IACJ,OAAO;IACP,MAAM;IAKN,0BAA0B;IAC1B,uBAAuB;IACvB,2BAA2B;GAC5B;GACD,WAAW,CACT;IACE,SAAS;IAET,aAAa,iBAAgB,eAAgB;GAC9C,CACF;EACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-checkbox.mjs","names":[],"sources":["../../../projects/lib/checkbox/tokens/checkbox-group.token.ts","../../../projects/lib/checkbox/checkbox.ts","../../../projects/lib/checkbox/checkbox.html","../../../projects/lib/checkbox/checkbox-group.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrCheckboxGroupContext } from '../types';\n\n/**\n * Token a `<wr-checkbox>` injects to read selection state from — and\n * toggle values in — its parent `<wr-checkbox-group>` (when present).\n *\n * @internal\n */\nexport const WR_CHECKBOX_GROUP = new InjectionToken<WrCheckboxGroupContext>('WR_CHECKBOX_GROUP');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n type ElementRef,\n ViewEncapsulation,\n computed,\n inject,\n input,\n model,\n output,\n viewChild,\n} from '@angular/core';\nimport type { FormCheckboxControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { WrIcon, type WrIconName } from 'ngwr/icon';\nimport { wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_CHECKBOX_GROUP } from './tokens';\n\n/**\n * Two-state checkbox.\n *\n * A signal-forms native control: it implements `FormCheckboxControl`, so\n * `[formField]` binds straight to its `checked` model — no\n * `ControlValueAccessor` in between. `[(checked)]` works standalone, and\n * classic `[(ngModel)]` / reactive forms keep working through Angular's bridge.\n *\n * @example\n * ```html\n * <wr-checkbox [(checked)]=\"agree\">I agree</wr-checkbox>\n * <wr-checkbox [formField]=\"form.agree\">I agree</wr-checkbox>\n * ```\n *\n * **Inside `<wr-checkbox-group>`** — the checkbox's `checkboxValue` is added to\n * or removed from the group's array, and the group is the native form control.\n * (The identity input is `checkboxValue`, not `value`, because\n * `FormCheckboxControl` reserves `value` — its form state is the boolean\n * `checked`.)\n *\n * @example\n * ```html\n * <wr-checkbox-group [formField]=\"form.features\">\n * <wr-checkbox checkboxValue=\"autosave\">Autosave</wr-checkbox>\n * <wr-checkbox checkboxValue=\"notifications\">Notifications</wr-checkbox>\n * </wr-checkbox-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/checkbox\n */\nexport type WrCheckboxSize = 'sm' | 'md' | 'lg';\n\n@Component({\n selector: 'wr-checkbox',\n templateUrl: './checkbox.html',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-checkbox',\n '[class]': 'classes()',\n // The `id` input belongs to the native input, not to this element. A static\n // `id=\"x\"` in a consumer's template is written to the host as a plain\n // attribute AS WELL as fed to the input, which put two elements with the\n // same id in the document and made `<label for>` resolve through\n // `getElementById` to the host — not a labelable element, so `input.labels`\n // went from 1 to 0 and `document.getElementById(id)` returned the wrong node.\n '[attr.id]': 'null',\n // The group identity, reflected so a HARNESS can read it. It is the only\n // way: `checkboxValue` is an `unknown`-typed TypeScript value that reaches\n // no attribute otherwise, and `WrCheckboxHarness.getCheckboxValue()` read\n // `value` off the inner `<input>` — which nothing writes, so it answered\n // `null` for every checkbox in every state. A harness method that answers\n // the same for a working component and a broken one is the one thing the\n // harness rules forbid outright.\n //\n // `data-`, deliberately, and NOT `value`: a leftover static `value=\"x\"` from\n // before v9 still lands on this host as a plain attribute, so reading\n // `value` here would report the identity a consumer THOUGHT they set while\n // the component used `null`. That is the exact confusion migration-v9\n // exists to end.\n '[attr.data-checkbox-value]': 'reflectedValue()',\n },\n imports: [WrIcon],\n})\nexport class WrCheckbox implements FormCheckboxControl {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('checkbox');\n }\n\n /**\n * Stable id used to associate the native input with its label. Lands on the\n * inner `<input>`; the host never keeps it.\n *\n * @default Randomly generated\n */\n readonly id = input<string>(wrRandomId('wr-checkbox'));\n\n /**\n * This checkbox's identity when inside a `<wr-checkbox-group>` — the value\n * added to / removed from the group's array. Ignored in standalone mode.\n * (Named `checkboxValue`, not `value`, because `FormCheckboxControl` reserves\n * `value`.)\n */\n readonly checkboxValue = input<unknown>(null);\n\n /**\n * `checkboxValue` as an attribute, when it can be one.\n *\n * A primitive round-trips through the DOM and is what a group identity is in\n * practice. Anything else — an object, an array — has no honest attribute\n * form, so the attribute is ABSENT rather than `[object Object]`: a harness\n * reading it then gets `null`, which is true, instead of a string that looks\n * like data and identifies nothing.\n */\n protected readonly reflectedValue = computed(() => {\n const value = this.checkboxValue();\n // Narrowed inline rather than through a `typeof` held in a variable, which\n // TypeScript does not follow — and the linter is right to refuse it: the\n // point of this guard is that `String()` never sees an object.\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n return null;\n });\n\n /**\n * Accessible name for a checkbox used WITHOUT projected text — a selection\n * cell in a table, say. The wrapping `<label>` names the control whenever\n * content is projected; with none, the native input has no name, and an\n * `aria-label` put on the host lands on a `<wr-checkbox>` element that no\n * screen reader ever announces.\n */\n readonly ariaLabel = input<string | null>(null);\n\n /**\n * Ids of the elements that name this checkbox, space-separated, for a box\n * whose name is already on screen somewhere else — a table row's label cell,\n * say, joined to an action word. Lands on the inner `<input>` as\n * `aria-labelledby`, which wins over `ariaLabel` and over projected text.\n *\n * The ids have to resolve in the same document; one that matches nothing is\n * skipped, and with none left the box falls back to `ariaLabel`.\n *\n * @default null\n */\n readonly ariaLabelledby = input<string | null>(null);\n\n /**\n * Checked state — the form value. Bound by `[formField]`, two-way via\n * `[(checked)]`, or `[(ngModel)]`. Ignored inside a `<wr-checkbox-group>`,\n * where the group's array is the source of truth.\n */\n readonly checked = model<boolean>(false);\n\n /** Emitted on blur so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n /**\n * Disable the checkbox. Bound automatically from the field's disabled state\n * when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse edits while staying focusable and submittable. Bound automatically\n * from the field's readonly state when used with `[formField]`.\n *\n * A native `<input type=\"checkbox\">` ignores the `readonly` attribute, so this\n * cancels the click's activation behaviour instead — which covers Space too,\n * since a checkbox turns Space into a click — and mirrors the state as\n * `aria-readonly`, which role `checkbox` supports.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** Control size — shares the `--wr-control-*` contract. @default 'md' */\n readonly size = input<WrCheckboxSize>('md');\n\n /**\n * Optional icon name rendered inside the box when checked, in place of the\n * default checkmark. Use any registered NGWR icon.\n */\n readonly icon = input<WrIconName | null>(null);\n\n /**\n * Show the indeterminate (\"mixed\") state — a dash instead of a check. Visual\n * only and controlled: set it yourself for a parent \"select all\" whose\n * children are partly checked, and clear it on the next toggle. Takes visual\n * precedence over `checked`; the native input reports `aria-checked=\"mixed\"`.\n * A click the host does not answer still toggles `checked` underneath, and the\n * dash and the mixed state both stay until the binding turns `false`.\n *\n * @default false\n */\n readonly indeterminate = input(false, { transform: coerceBooleanProperty });\n\n private readonly group = inject(WR_CHECKBOX_GROUP, { optional: true });\n\n private readonly native = viewChild.required<ElementRef<HTMLInputElement>>('native');\n\n /** Rendered \"is checked\" — reads the group when grouped, else the `checked` model. */\n protected readonly isChecked = computed(() =>\n this.group ? this.group.isSelected(this.checkboxValue()) : this.checked()\n );\n\n /** Effective disabled — the `disabled` input wins, then the group. */\n protected readonly effectiveDisabled = computed(() => {\n if (this.disabled()) return true;\n return this.group ? this.group.isDisabled() : false;\n });\n\n /** Effective readonly — this box's own `readonly` input, or the group's. */\n protected readonly effectiveReadonly = computed(() => {\n if (this.readonly()) return true;\n return this.group ? this.group.isReadonly() : false;\n });\n\n /**\n * The surrounding `<wr-form-field>`'s error state, mirrored onto the native\n * input. Inside a `<wr-checkbox-group>` the GROUP is the bound control and\n * carries the state, so a grouped box shields itself and stays silent — nine\n * boxes each announcing the group's one error is noise, not information.\n */\n private readonly fieldAria = useFormFieldAria();\n protected readonly ariaInvalid = computed(() => (this.group ? null : this.fieldAria.ariaInvalid()));\n protected readonly describedBy = computed(() => (this.group ? null : this.fieldAria.describedBy()));\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n const size = this.size();\n if (size !== 'md') parts.push(`wr-checkbox--${size}`);\n if (this.indeterminate()) parts.push('wr-checkbox--indeterminate');\n else if (this.isChecked()) parts.push('wr-checkbox--checked');\n if (this.effectiveDisabled()) parts.push('wr-checkbox--disabled');\n else if (this.effectiveReadonly()) parts.push('wr-checkbox--readonly');\n return parts.join(' ');\n });\n\n /**\n * Focus the checkbox — what Signal Forms calls to focus this control. The\n * native input takes it, since the host has no tab stop of its own; a disabled\n * box refuses, as a disabled input always does.\n */\n focus(options?: FocusOptions): void {\n this.native().nativeElement.focus(options);\n }\n\n // Template handlers\n\n /**\n * Cancel the toggle while readonly. `change` never fires for a click whose\n * default was prevented, so this is the only guard the pointer and Space\n * paths need; `onInputChange` keeps its own for a synthetic `change`.\n */\n protected onInputClick(event: Event): void {\n if (this.effectiveReadonly()) event.preventDefault();\n }\n\n protected onInputChange(event: Event): void {\n const inputEl = event.target as HTMLInputElement;\n // Activating a checkbox clears its own `indeterminate` before `change` fires,\n // and the `[indeterminate]` binding never writes again while the bound value\n // stays `true` — so the box kept painting the dash while the accessibility\n // tree announced \"checked\". The input is controlled: the mixed state holds\n // until the host clears it, and a host that does clears it through the\n // binding on the next change detection.\n inputEl.indeterminate = this.indeterminate();\n\n if (this.effectiveReadonly()) {\n // A synthetic `change` cannot be prevented — put the DOM back instead.\n inputEl.checked = this.isChecked();\n return;\n }\n if (this.group) {\n this.group.toggle(this.checkboxValue());\n return;\n }\n this.checked.set(inputEl.checked);\n }\n\n protected onInputBlur(): void {\n // Inside a group the GROUP is the bound control, and its own `touch` is\n // what a form listens to; the child's output is wired to nothing there.\n if (this.group) this.group.blurred();\n this.touch.emit();\n }\n}\n","<label class=\"wr-checkbox__label\" [for]=\"id()\">\n <input\n #native\n class=\"wr-checkbox__input\"\n type=\"checkbox\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-labelledby]=\"ariaLabelledby()\"\n [checked]=\"isChecked()\"\n [indeterminate]=\"indeterminate()\"\n [disabled]=\"effectiveDisabled()\"\n [attr.aria-readonly]=\"effectiveReadonly() || null\"\n [attr.aria-invalid]=\"ariaInvalid()\"\n [attr.aria-describedby]=\"describedBy()\"\n (click)=\"onInputClick($event)\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-checkbox__box\" aria-hidden=\"true\">\n @if (indeterminate()) {\n <svg viewBox=\"0 0 16 16\" class=\"wr-checkbox__dash\">\n <line x1=\"3.5\" y1=\"8\" x2=\"12.5\" y2=\"8\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" />\n </svg>\n } @else if (icon(); as iconName) {\n <wr-icon class=\"wr-checkbox__icon\" [name]=\"iconName\" />\n } @else {\n <svg viewBox=\"0 0 16 16\" class=\"wr-checkbox__mark\">\n <polyline\n points=\"3.5 8.5 6.5 11.5 12.5 5\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n }\n </span>\n\n <span class=\"wr-checkbox__text\">\n <ng-content />\n </span>\n</label>\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 {\n Component,\n ElementRef,\n HostAttributeToken,\n ViewEncapsulation,\n computed,\n forwardRef,\n inject,\n input,\n model,\n output,\n} from '@angular/core';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nimport { useFormFieldAria } from 'ngwr/form';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_CHECKBOX_GROUP } from './tokens';\nimport type { WrCheckboxGroupContext } from './types';\n\n/**\n * Manages a group of `<wr-checkbox>` children as a single form value — an\n * array of the checked items' **`checkboxValue`** inputs, not their `value`.\n * `FormCheckboxControl` reserves `value` for the form value, so a child's\n * boolean state is `checked` and its group identity is `checkboxValue`; a\n * leftover static `value=\"x\"` lands on the host as a plain DOM attribute, and\n * every box in the group keeps the default identity `null` and toggles\n * together.\n *\n * A signal-forms native control: it implements `FormValueControl<unknown[]>`,\n * so `[formField]` binds to its `value` model. `[(value)]` works standalone,\n * and classic `[(ngModel)]` / reactive forms keep working through the bridge.\n *\n * @example\n * ```html\n * <wr-checkbox-group [formField]=\"form.features\">\n * <wr-checkbox checkboxValue=\"autosave\">Autosave</wr-checkbox>\n * <wr-checkbox checkboxValue=\"notifications\">Notifications</wr-checkbox>\n * <wr-checkbox checkboxValue=\"darkmode\">Dark mode</wr-checkbox>\n * </wr-checkbox-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/checkbox\n */\n@Component({\n selector: 'wr-checkbox-group',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-checkbox-group',\n role: 'group',\n // `<label for>` binds only to a labelable element, which a `role=\"group\"`\n // is not, so the field's own label reached this host through nothing and\n // the group announced no name at all. Same call `wr-radio-group` and\n // `wr-rating` already make.\n '[attr.aria-labelledby]': 'labelledBy()',\n '[attr.aria-invalid]': 'fieldAria.ariaInvalid()',\n '[attr.aria-describedby]': 'fieldAria.describedBy()',\n },\n providers: [\n {\n provide: WR_CHECKBOX_GROUP,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrCheckboxGroup),\n },\n ],\n})\nexport class WrCheckboxGroup implements FormValueControl<unknown[]>, WrCheckboxGroupContext {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('checkbox');\n }\n\n /**\n * Disable every child checkbox. Bound automatically from the field's\n * disabled state when used with `[formField]`.\n *\n * @default false\n */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Refuse edits on every child while they stay focusable and the value still\n * submits. Bound automatically from the field's readonly state when used with\n * `[formField]`.\n *\n * No `aria-readonly` on the host: role `group` does not support it (the state\n * is not global), so each child box mirrors its own instead.\n *\n * @default false\n */\n readonly readonly = input(false, { transform: coerceBooleanProperty });\n\n /** The surrounding `<wr-form-field>`'s error state. @internal */\n protected readonly fieldAria = useFormFieldAria();\n /**\n * The author's own `aria-labelledby`, read as a static host attribute.\n *\n * A host binding WRITES the attribute, so binding the field's label\n * unconditionally would REMOVE a reference the consumer put there by hand:\n * `<wr-segmented aria-labelledby=\"range-question\">` went nameless the moment\n * the field's label was `null`, which a harness spec caught one commit after\n * it was introduced. `HostAttributeToken` reads it at construction without\n * touching the DOM, so this stays SSR-safe, and the author's own reference\n * wins — the same precedence `[ariaLabel]` has everywhere else.\n */\n private readonly ownLabelledBy = inject(new HostAttributeToken('aria-labelledby'), { optional: true });\n\n /** The surrounding field's label, unless the author named the control. */\n protected readonly labelledBy = computed(() => this.ownLabelledBy ?? this.fieldAria.labelledBy());\n\n /** The checked items' values. Bound by `[formField]`, or two-way via `[(value)]`. */\n readonly value = model<unknown[]>([]);\n\n /** Emitted when a child toggles so a bound field can mark itself touched. */\n readonly touch = output<void>();\n\n // The current selection as a guaranteed array — a classic-forms binding can\n // write null even though the type is `unknown[]`, so normalise every read.\n private readonly selected = computed<readonly unknown[]>(() => {\n const v = this.value();\n return Array.isArray(v) ? v : [];\n });\n\n /** Effective disabled state (WrCheckboxGroupContext). */\n readonly isDisabled = computed(() => this.disabled());\n\n /** Effective readonly state (WrCheckboxGroupContext). */\n readonly isReadonly = computed(() => this.readonly());\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Focus the group — what Signal Forms calls to focus this control. The first\n * enabled box takes it, which is where Tab lands: the host is a `role=\"group\"`\n * with no tab stop of its own, and a disabled box has none either.\n */\n focus(options?: FocusOptions): void {\n this.host.nativeElement.querySelector<HTMLInputElement>('.wr-checkbox__input:not(:disabled)')?.focus(options);\n }\n\n // WrCheckboxGroupContext\n\n isSelected(value: unknown): boolean {\n return this.selected().includes(value);\n }\n\n toggle(value: unknown): void {\n if (this.isDisabled() || this.isReadonly()) return;\n const current = this.selected();\n const next = current.includes(value) ? current.filter(v => v !== value) : [...current, value];\n this.value.set(next);\n this.touch.emit();\n }\n\n /** @internal A child checkbox lost focus — see {@link WrCheckboxGroupContext.blurred}. */\n blurred(): void {\n this.touch.emit();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,oBAAoB,IAAI,eAAuC,mBAAmB;;;;;;;ACyE/F,IAAa,aAAb,MAAa,WAAU;CACrB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,UAAU;CAC7E;CAQS,KAAK,MAAc,WAAW,aAAa,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAQ7C,gBAAgB,MAAe,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,gBAAA,CAAA,+BAAA,CAAA,CAAA;CAW1B,iBAAiB,eAAc;EAChD,MAAM,QAAQ,KAAK,cAAa;EAIhC,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW,OAAO,OAAO,KAAK;EAChF,OAAO;CACT,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,iBAAA,CAAA,+BAAA,CAAA,CAAA;CASO,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EA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,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAe,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,UAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,UAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,SAAA;GAAA,OAAA;GAAA,OAAA;EAAA;EAAA,MAAA;GAAA,YAAA,EAAA,QAAA,QAAA;GAAA,YAAA;IAAA,wBAAA;IAAA,qBAAA;IAAA,yBAAA;GAAA;GAAA,gBAAA;EAAA;EAAA,WARf,CACT;GACE,SAAS;GAET,aAAa,iBAAiB,eAAe;EAC9C,CACF;EAAA,UAAA;EAAA,UAnBS;EAAgB,UAAA;EAAA,eAAA,GAAA,kBAAA;CAAA,CAAA;;AAqBf,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAe,YAAA,CAAA;EAvB3B,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;GACV,eAAe,kBAAkB;GACjC,MAAM;IACJ,OAAO;IACP,MAAM;IAKN,0BAA0B;IAC1B,uBAAuB;IACvB,2BAA2B;GAC5B;GACD,WAAW,CACT;IACE,SAAS;IAET,aAAa,iBAAgB,eAAgB;GAC9C,CACF;EACF,CAAA"}
|
|
@@ -9,6 +9,7 @@ import { FocusMonitor } from "@angular/cdk/a11y";
|
|
|
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 WR_COPIED_DURATION = 1500;
|
|
12
13
|
var WrClipboard = class WrClipboard {
|
|
13
14
|
focusMonitor = inject(FocusMonitor);
|
|
14
15
|
doc = inject(DOCUMENT$1);
|
|
@@ -95,6 +96,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
95
96
|
type: WrClipboard,
|
|
96
97
|
decorators: [{ type: Service }]
|
|
97
98
|
});
|
|
98
|
-
export { WrClipboard };
|
|
99
|
+
export { WR_COPIED_DURATION, WrClipboard };
|
|
99
100
|
|
|
100
101
|
//# sourceMappingURL=ngwr-clipboard.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-clipboard.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/clipboard/clipboard.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 { FocusMonitor } from '@angular/cdk/a11y';\nimport { DOCUMENT } from '@angular/common';\nimport { Service, inject } from '@angular/core';\n\nimport { wrRestoreFocus } from 'ngwr/utils';\n\nimport type { WrClipboardPermission } from './types';\n\n/**\n * Programmatic clipboard read / write.\n *\n * - **Write** uses `navigator.clipboard.writeText` with a hidden\n * `<textarea>` + `execCommand('copy')` fallback for non-secure contexts.\n * - **Read** uses `navigator.clipboard.readText` (no fallback — older\n * browsers expose no equivalent).\n * - **Available** / **permission** check what the current browser allows\n * so UI can disable the action when it would silently no-op.\n *\n * SSR-safe: every method short-circuits when there's no `document.defaultView`.\n *\n * @example\n * ```ts\n * const clip = inject(WrClipboard);\n *\n * await clip.write('Hello'); // resolves to true on success\n * const text = await clip.read(); // string | null\n * clip.available(); // boolean\n * await clip.permission('write'); // 'granted' | 'denied' | 'prompt' | 'unsupported'\n * ```\n *\n * @see https://ngwr.dev/reference/services/clipboard\n */\n@Service()\nexport class WrClipboard {\n private readonly focusMonitor = inject(FocusMonitor);\n private readonly doc = inject(DOCUMENT);\n\n /** Is any clipboard write path available (async API or `execCommand`)? */\n available(): boolean {\n const view = this.doc.defaultView;\n if (!view) return false;\n if (view.navigator?.clipboard) return true;\n return typeof this.doc.execCommand === 'function';\n }\n\n /**\n * Write text. Resolves to `true` on success, `false` on failure (denied\n * permission, no clipboard, etc).\n */\n async write(text: string): Promise<boolean> {\n const view = this.doc.defaultView;\n if (!view) return false;\n\n try {\n if (view.navigator?.clipboard) {\n await view.navigator.clipboard.writeText(text);\n return true;\n }\n return this.legacyWrite(text);\n } catch {\n return this.legacyWrite(text);\n }\n }\n\n /**\n * Read text from the clipboard. Returns `null` when unsupported or\n * when the user denied the permission prompt.\n */\n async read(): Promise<string | null> {\n const view = this.doc.defaultView;\n if (!view?.navigator?.clipboard?.readText) return null;\n try {\n return await view.navigator.clipboard.readText();\n } catch {\n return null;\n }\n }\n\n /**\n * Report whether clipboard read / write is available and, when the\n * browser exposes it, what the user has granted.\n *\n * The answer is grounded in the actual Clipboard API capability\n * (`writeText` / `readText`), then refined by the Permissions API when\n * it can speak for the requested name. `clipboard-read` / `clipboard-write`\n * are not recognised everywhere — Firefox and Safari throw on the query —\n * so a missing or throwing Permissions API is treated as \"supported,\n * will resolve at use time\" (`'prompt'`), not `'unsupported'`. We only\n * return `'unsupported'` when the capability genuinely isn't there.\n */\n async permission(name: 'read' | 'write'): Promise<WrClipboardPermission> {\n const view = this.doc.defaultView;\n if (!view) return 'unsupported';\n\n const clipboard = view.navigator?.clipboard;\n const capable =\n name === 'write'\n ? typeof clipboard?.writeText === 'function' || typeof this.doc.execCommand === 'function'\n : typeof clipboard?.readText === 'function';\n if (!capable) return 'unsupported';\n\n // Capability exists; ask the Permissions API to refine the state when it can.\n if (typeof view.navigator?.permissions?.query !== 'function') return 'prompt';\n try {\n const status = await view.navigator.permissions.query({\n name: `clipboard-${name}` as PermissionName,\n });\n return status.state;\n } catch {\n // Name not recognised by this browser — capability is still present.\n return 'prompt';\n }\n }\n\n // Internals\n\n /**\n * Hidden-textarea + `execCommand('copy')` write. Synchronous, no permissions.\n *\n * `select()` takes focus, and the textarea is removed a moment later — so\n * without putting focus back, every copy on a non-secure origin (plain\n * `http://`, which is exactly where the async clipboard is missing) leaves\n * focus on `<body>` and the user's next Tab restarts from the top of the page.\n */\n private legacyWrite(text: string): boolean {\n const previouslyFocused = this.doc.activeElement;\n const node = this.doc.createElement('textarea');\n node.value = text;\n node.setAttribute('readonly', '');\n node.style.position = 'fixed';\n node.style.top = '0';\n node.style.left = '0';\n node.style.opacity = '0';\n node.style.pointerEvents = 'none';\n this.doc.body.appendChild(node);\n node.select();\n try {\n return this.doc.execCommand('copy');\n } catch {\n return false;\n } finally {\n this.doc.body.removeChild(node);\n // Guarded on `isConnected`: the copy handler may well have re-rendered\n // whatever was focused, and focusing a detached node throws focus away\n // just as thoroughly as not restoring it.\n if (previouslyFocused instanceof HTMLElement && previouslyFocused.isConnected) {\n wrRestoreFocus(previouslyFocused, this.focusMonitor);\n }\n }\n }\n}\n\nexport type { WrClipboardPermission } from './types';\n"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ngwr-clipboard.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/clipboard/clipboard.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 { FocusMonitor } from '@angular/cdk/a11y';\nimport { DOCUMENT } from '@angular/common';\nimport { Service, inject } from '@angular/core';\n\nimport { wrRestoreFocus } from 'ngwr/utils';\n\nimport type { WrClipboardPermission } from './types';\n\n/**\n * How long a \"Copied\" confirmation stays, in ms: `<wr-copy-value>` and\n * `[wrCopyToClipboard]` share it.\n *\n * @internal\n */\nexport const WR_COPIED_DURATION = 1500;\n\n/**\n * Programmatic clipboard read / write.\n *\n * - **Write** uses `navigator.clipboard.writeText` with a hidden\n * `<textarea>` + `execCommand('copy')` fallback for non-secure contexts.\n * - **Read** uses `navigator.clipboard.readText` (no fallback — older\n * browsers expose no equivalent).\n * - **Available** / **permission** check what the current browser allows\n * so UI can disable the action when it would silently no-op.\n *\n * SSR-safe: every method short-circuits when there's no `document.defaultView`.\n *\n * @example\n * ```ts\n * const clip = inject(WrClipboard);\n *\n * await clip.write('Hello'); // resolves to true on success\n * const text = await clip.read(); // string | null\n * clip.available(); // boolean\n * await clip.permission('write'); // 'granted' | 'denied' | 'prompt' | 'unsupported'\n * ```\n *\n * @see https://ngwr.dev/reference/services/clipboard\n */\n@Service()\nexport class WrClipboard {\n private readonly focusMonitor = inject(FocusMonitor);\n private readonly doc = inject(DOCUMENT);\n\n /** Is any clipboard write path available (async API or `execCommand`)? */\n available(): boolean {\n const view = this.doc.defaultView;\n if (!view) return false;\n if (view.navigator?.clipboard) return true;\n return typeof this.doc.execCommand === 'function';\n }\n\n /**\n * Write text. Resolves to `true` on success, `false` on failure (denied\n * permission, no clipboard, etc).\n */\n async write(text: string): Promise<boolean> {\n const view = this.doc.defaultView;\n if (!view) return false;\n\n try {\n if (view.navigator?.clipboard) {\n await view.navigator.clipboard.writeText(text);\n return true;\n }\n return this.legacyWrite(text);\n } catch {\n return this.legacyWrite(text);\n }\n }\n\n /**\n * Read text from the clipboard. Returns `null` when unsupported or\n * when the user denied the permission prompt.\n */\n async read(): Promise<string | null> {\n const view = this.doc.defaultView;\n if (!view?.navigator?.clipboard?.readText) return null;\n try {\n return await view.navigator.clipboard.readText();\n } catch {\n return null;\n }\n }\n\n /**\n * Report whether clipboard read / write is available and, when the\n * browser exposes it, what the user has granted.\n *\n * The answer is grounded in the actual Clipboard API capability\n * (`writeText` / `readText`), then refined by the Permissions API when\n * it can speak for the requested name. `clipboard-read` / `clipboard-write`\n * are not recognised everywhere — Firefox and Safari throw on the query —\n * so a missing or throwing Permissions API is treated as \"supported,\n * will resolve at use time\" (`'prompt'`), not `'unsupported'`. We only\n * return `'unsupported'` when the capability genuinely isn't there.\n */\n async permission(name: 'read' | 'write'): Promise<WrClipboardPermission> {\n const view = this.doc.defaultView;\n if (!view) return 'unsupported';\n\n const clipboard = view.navigator?.clipboard;\n const capable =\n name === 'write'\n ? typeof clipboard?.writeText === 'function' || typeof this.doc.execCommand === 'function'\n : typeof clipboard?.readText === 'function';\n if (!capable) return 'unsupported';\n\n // Capability exists; ask the Permissions API to refine the state when it can.\n if (typeof view.navigator?.permissions?.query !== 'function') return 'prompt';\n try {\n const status = await view.navigator.permissions.query({\n name: `clipboard-${name}` as PermissionName,\n });\n return status.state;\n } catch {\n // Name not recognised by this browser — capability is still present.\n return 'prompt';\n }\n }\n\n // Internals\n\n /**\n * Hidden-textarea + `execCommand('copy')` write. Synchronous, no permissions.\n *\n * `select()` takes focus, and the textarea is removed a moment later — so\n * without putting focus back, every copy on a non-secure origin (plain\n * `http://`, which is exactly where the async clipboard is missing) leaves\n * focus on `<body>` and the user's next Tab restarts from the top of the page.\n */\n private legacyWrite(text: string): boolean {\n const previouslyFocused = this.doc.activeElement;\n const node = this.doc.createElement('textarea');\n node.value = text;\n node.setAttribute('readonly', '');\n node.style.position = 'fixed';\n node.style.top = '0';\n node.style.left = '0';\n node.style.opacity = '0';\n node.style.pointerEvents = 'none';\n this.doc.body.appendChild(node);\n node.select();\n try {\n return this.doc.execCommand('copy');\n } catch {\n return false;\n } finally {\n this.doc.body.removeChild(node);\n // Guarded on `isConnected`: the copy handler may well have re-rendered\n // whatever was focused, and focusing a detached node throws focus away\n // just as thoroughly as not restoring it.\n if (previouslyFocused instanceof HTMLElement && previouslyFocused.isConnected) {\n wrRestoreFocus(previouslyFocused, this.focusMonitor);\n }\n }\n }\n}\n\nexport type { WrClipboardPermission } from './types';\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,qBAAqB;AA2BlC,IAAa,cAAb,MAAa,YAAW;CACL,eAAe,OAAO,YAAY;CAClC,MAAM,OAAOA,UAAQ;CAGtC,YAAS;EACP,MAAM,OAAO,KAAK,IAAI;EACtB,IAAI,CAAC,MAAM,OAAO;EAClB,IAAI,KAAK,WAAW,WAAW,OAAO;EACtC,OAAO,OAAO,KAAK,IAAI,gBAAgB;CACzC;CAMA,MAAM,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pC,QAAQ;GACN,OAAO;EACT,UAAU;GACR,KAAK,IAAI,KAAK,YAAY,IAAI;GAI9B,IAAI,6BAA6B,eAAe,kBAAkB,aAChE,eAAe,mBAAmB,KAAK,YAAY;EAEvD;CACF;CApHW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAW,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAX,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAW,CAAA;;AAAX,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAW,YAAA,CAAA,EADvB,MAAA,Q"}
|
|
@@ -32,7 +32,7 @@ var WrCollapse = class WrCollapse {
|
|
|
32
32
|
group = inject(WR_COLLAPSE_GROUP, { optional: true });
|
|
33
33
|
destroyRef = inject(DestroyRef);
|
|
34
34
|
classes = computed(() => {
|
|
35
|
-
const parts = [
|
|
35
|
+
const parts = [];
|
|
36
36
|
if (this.open()) parts.push("wr-collapse--open");
|
|
37
37
|
if (!this.bordered()) parts.push("wr-collapse--flat");
|
|
38
38
|
if (this.disabled()) parts.push("wr-collapse--disabled");
|
|
@@ -114,10 +114,13 @@ var WrCollapse = class WrCollapse {
|
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
outputs: { open: "openChange" },
|
|
117
|
-
host: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
host: {
|
|
118
|
+
properties: {
|
|
119
|
+
"class": "classes()",
|
|
120
|
+
"attr.title": "null"
|
|
121
|
+
},
|
|
122
|
+
classAttribute: "wr-collapse"
|
|
123
|
+
},
|
|
121
124
|
ngImport: i0,
|
|
122
125
|
template: "<button\n type=\"button\"\n class=\"wr-collapse__header\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"bodyId\"\n [disabled]=\"disabled()\"\n (click)=\"toggle()\"\n>\n <span class=\"wr-collapse__title\">{{ title() }}</span>\n @if (indicator() === 'plus') {\n <svg\n class=\"wr-icon__svg wr-collapse__plus\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M5 12h14\" />\n <path class=\"wr-collapse__plus-bar\" d=\"M12 5v14\" />\n </svg>\n } @else {\n <svg\n class=\"wr-icon__svg wr-collapse__chevron\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n }\n</button>\n\n<div\n class=\"wr-collapse__body\"\n [attr.id]=\"bodyId\"\n [class.wr-collapse__body--open]=\"open()\"\n [attr.aria-hidden]=\"!open()\"\n [attr.inert]=\"!open() ? '' : null\"\n>\n <div class=\"wr-collapse__content\">\n <div class=\"wr-collapse__inner\">\n <ng-content />\n </div>\n </div>\n</div>\n",
|
|
123
126
|
encapsulation: i0.ViewEncapsulation.None
|
|
@@ -134,6 +137,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
134
137
|
selector: "wr-collapse",
|
|
135
138
|
encapsulation: ViewEncapsulation.None,
|
|
136
139
|
host: {
|
|
140
|
+
class: "wr-collapse",
|
|
137
141
|
"[class]": "classes()",
|
|
138
142
|
"[attr.title]": "null"
|
|
139
143
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-collapse.mjs","names":[],"sources":["../../../projects/lib/collapse/tokens/collapse-group.token.ts","../../../projects/lib/collapse/collapse.ts","../../../projects/lib/collapse/collapse.html","../../../projects/lib/collapse/collapse-group.ts","../../../projects/lib/collapse/accordion.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrCollapseGroupContext } from '../types';\n\n/**\n * Token a `<wr-collapse>` injects to register itself with — and notify of\n * open events — its parent `<wr-collapse-group>`. Drives the accordion\n * behaviour when the group has `accordion` enabled.\n *\n * @internal\n */\nexport const WR_COLLAPSE_GROUP = new InjectionToken<WrCollapseGroupContext>('WR_COLLAPSE_GROUP');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, DestroyRef, ViewEncapsulation, computed, effect, inject, input, model } from '@angular/core';\n\nimport { wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\nimport type { WrCollapseIndicator } from './types';\n\n/**\n * Expandable panel with a clickable header. Two-way binds the `open`\n * state. When wrapped in `<wr-collapse-group accordion>`, only one\n * sibling can be open at a time.\n *\n * @example\n * ```html\n * <wr-collapse title=\"Section title\">\n * Section body…\n * </wr-collapse>\n *\n * <wr-collapse-group accordion>\n * <wr-collapse title=\"A\">…</wr-collapse>\n * <wr-collapse title=\"B\">…</wr-collapse>\n * </wr-collapse-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-collapse',\n templateUrl: './collapse.html',\n encapsulation: ViewEncapsulation.None,\n // See `WrAlert`: a static `title=` feeds the input AND lands on the host,\n // where the browser draws it as a tooltip over the whole component.\n host: { '[class]': 'classes()', '[attr.title]': 'null' },\n})\nexport class WrCollapse {\n /** Header text. */\n readonly title = input.required<string>();\n\n /** Two-way bindable open/closed state. @default false */\n readonly open = model<boolean>(false);\n\n /** Disable interaction. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Draws the frame, the panel background and the rounded corners. Turn it off for a\n * flat list: no frame, rows split by a divider line between neighbours.\n * @default true\n */\n readonly bordered = input(true, { transform: coerceBooleanProperty });\n\n /**\n * The header glyph: `chevron` turns over, `plus` becomes a minus while open.\n * @default 'chevron'\n */\n readonly indicator = input<WrCollapseIndicator>('chevron');\n\n /** Identity used by the parent group when tracking children. @internal */\n readonly id = { name: wrRandomId('wr-collapse') };\n\n /** DOM id for the body element, referenced by header's `aria-controls`. */\n protected readonly bodyId = `wr-collapse-body-${this.id.name}`;\n\n private readonly group = inject(WR_COLLAPSE_GROUP, { optional: true });\n private readonly destroyRef = inject(DestroyRef);\n\n protected readonly classes = computed(() => {\n const parts = ['wr-collapse'];\n if (this.open()) parts.push('wr-collapse--open');\n if (!this.bordered()) parts.push('wr-collapse--flat');\n if (this.disabled()) parts.push('wr-collapse--disabled');\n return parts.join(' ');\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n if (this.group) {\n this.group.register({ id: this.id, close: () => this.open.set(false) });\n this.destroyRef.onDestroy(() => this.group?.unregister(this.id));\n\n // Tell the group whenever we open — group decides whether to close siblings.\n effect(() => {\n if (this.open()) this.group?.notifyOpened(this.id);\n });\n }\n }\n\n /** Open the panel. */\n openPanel(): void {\n if (this.disabled()) return;\n this.open.set(true);\n }\n\n /** Close the panel. */\n close(): void {\n this.open.set(false);\n }\n\n /** Toggle the panel. */\n toggle(): void {\n if (this.disabled()) return;\n this.open.update(v => !v);\n }\n}\n","<button\n type=\"button\"\n class=\"wr-collapse__header\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"bodyId\"\n [disabled]=\"disabled()\"\n (click)=\"toggle()\"\n>\n <span class=\"wr-collapse__title\">{{ title() }}</span>\n @if (indicator() === 'plus') {\n <svg\n class=\"wr-icon__svg wr-collapse__plus\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M5 12h14\" />\n <path class=\"wr-collapse__plus-bar\" d=\"M12 5v14\" />\n </svg>\n } @else {\n <svg\n class=\"wr-icon__svg wr-collapse__chevron\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n }\n</button>\n\n<div\n class=\"wr-collapse__body\"\n [attr.id]=\"bodyId\"\n [class.wr-collapse__body--open]=\"open()\"\n [attr.aria-hidden]=\"!open()\"\n [attr.inert]=\"!open() ? '' : null\"\n>\n <div class=\"wr-collapse__content\">\n <div class=\"wr-collapse__inner\">\n <ng-content />\n </div>\n </div>\n</div>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, forwardRef, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\nimport type { WrCollapseGroupContext, WrCollapseGroupMember } from './types';\n\n/**\n * Visual + behavioral grouping of `<wr-collapse>` children. When\n * `accordion` is true, opening one child closes the others.\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-collapse-group',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-collapse-group' },\n providers: [\n {\n provide: WR_COLLAPSE_GROUP,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrCollapseGroup),\n },\n ],\n})\nexport class WrCollapseGroup implements WrCollapseGroupContext {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n }\n\n /** When true, only one child may be open at a time. @default false */\n readonly accordion = input(false, { transform: coerceBooleanProperty });\n\n private readonly members = new Map<object, WrCollapseGroupMember>();\n\n register(member: WrCollapseGroupMember): void {\n this.members.set(member.id, member);\n }\n\n unregister(memberId: object): void {\n this.members.delete(memberId);\n }\n\n notifyOpened(opener: object): void {\n if (!this.accordion()) return;\n for (const [id, member] of this.members) {\n if (id !== opener) member.close();\n }\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, forwardRef, signal } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\nimport type { WrCollapseGroupContext, WrCollapseGroupMember } from './types';\n\n/**\n * Accordion — a `<wr-collapse>` container that enforces single-open\n * behavior: opening a child closes its siblings.\n *\n * Use `<wr-collapse-group>` when you only need visual grouping without\n * the mutually-exclusive open semantics.\n *\n * @example\n * ```html\n * <wr-accordion>\n * <wr-collapse title=\"Profile\">…</wr-collapse>\n * <wr-collapse title=\"Security\">…</wr-collapse>\n * <wr-collapse title=\"Notifications\">…</wr-collapse>\n * </wr-accordion>\n * ```\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-accordion',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-collapse-group wr-collapse-group--accordion' },\n providers: [\n {\n provide: WR_COLLAPSE_GROUP,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrAccordion),\n },\n ],\n})\nexport class WrAccordion implements WrCollapseGroupContext {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n }\n\n /** Always behaves as an accordion. Provided for context-interface symmetry. */\n readonly accordion = signal(true).asReadonly();\n\n private readonly members = new Map<object, WrCollapseGroupMember>();\n\n register(member: WrCollapseGroupMember): void {\n this.members.set(member.id, member);\n }\n\n unregister(memberId: object): void {\n this.members.delete(memberId);\n }\n\n notifyOpened(opener: object): void {\n for (const [id, member] of this.members) {\n if (id !== opener) member.close();\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAkBA,MAAa,oBAAoB,IAAI,eAAuC,mBAAmB;;;;;;;ACwB/F,IAAa,aAAb,MAAa,WAAU;CAEZ,QAAQ,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAGhC,OAAO,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAG5B,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAO1D,WAAW,MAAM,MAAI;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAMzD,YAAY,MAA2B,WAAU,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAGjD,KAAK,EAAE,MAAM,WAAW,aAAa,EAAC;CAG5B,SAAS,oBAAoB,KAAK,GAAG;CAEvC,QAAQ,OAAO,mBAAmB,EAAE,UAAU,KAAI,CAAE;CACpD,aAAa,OAAO,UAAU;CAE5B,UAAU,eAAc;EACzC,MAAM,QAAQ,CAAC,aAAa;EAC5B,IAAI,KAAK,KAAI,GAAI,MAAM,KAAK,mBAAmB;EAC/C,IAAI,CAAC,KAAK,SAAQ,GAAI,MAAM,KAAK,mBAAmB;EACpD,IAAI,KAAK,SAAQ,GAAI,MAAM,KAAK,uBAAuB;EACvD,OAAO,MAAM,KAAK,GAAG;CACvB,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAEF,cAAA;EACE,IAAI,O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yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAW,YAAA,CAAA;EAbvB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;GACV,eAAe,kBAAkB;GACjC,MAAM,EAAE,OAAO,iDAAgD;GAC/D,WAAW,CACT;IACE,SAAS;IAET,aAAa,iBAAgB,WAAY;GAC1C,CACF;EACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"ngwr-collapse.mjs","names":[],"sources":["../../../projects/lib/collapse/tokens/collapse-group.token.ts","../../../projects/lib/collapse/collapse.ts","../../../projects/lib/collapse/collapse.html","../../../projects/lib/collapse/collapse-group.ts","../../../projects/lib/collapse/accordion.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrCollapseGroupContext } from '../types';\n\n/**\n * Token a `<wr-collapse>` injects to register itself with — and notify of\n * open events — its parent `<wr-collapse-group>`. Drives the accordion\n * behaviour when the group has `accordion` enabled.\n *\n * @internal\n */\nexport const WR_COLLAPSE_GROUP = new InjectionToken<WrCollapseGroupContext>('WR_COLLAPSE_GROUP');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, DestroyRef, ViewEncapsulation, computed, effect, inject, input, model } from '@angular/core';\n\nimport { wrRandomId, wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\nimport type { WrCollapseIndicator } from './types';\n\n/**\n * Expandable panel with a clickable header. Two-way binds the `open`\n * state. When wrapped in `<wr-collapse-group accordion>`, only one\n * sibling can be open at a time.\n *\n * @example\n * ```html\n * <wr-collapse title=\"Section title\">\n * Section body…\n * </wr-collapse>\n *\n * <wr-collapse-group accordion>\n * <wr-collapse title=\"A\">…</wr-collapse>\n * <wr-collapse title=\"B\">…</wr-collapse>\n * </wr-collapse-group>\n * ```\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-collapse',\n templateUrl: './collapse.html',\n encapsulation: ViewEncapsulation.None,\n // See `WrAlert`: a static `title=` feeds the input AND lands on the host,\n // where the browser draws it as a tooltip over the whole component.\n host: { class: 'wr-collapse', '[class]': 'classes()', '[attr.title]': 'null' },\n})\nexport class WrCollapse {\n /** Header text. */\n readonly title = input.required<string>();\n\n /** Two-way bindable open/closed state. @default false */\n readonly open = model<boolean>(false);\n\n /** Disable interaction. @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Draws the frame, the panel background and the rounded corners. Turn it off for a\n * flat list: no frame, rows split by a divider line between neighbours.\n * @default true\n */\n readonly bordered = input(true, { transform: coerceBooleanProperty });\n\n /**\n * The header glyph: `chevron` turns over, `plus` becomes a minus while open.\n * @default 'chevron'\n */\n readonly indicator = input<WrCollapseIndicator>('chevron');\n\n /** Identity used by the parent group when tracking children. @internal */\n readonly id = { name: wrRandomId('wr-collapse') };\n\n /** DOM id for the body element, referenced by header's `aria-controls`. */\n protected readonly bodyId = `wr-collapse-body-${this.id.name}`;\n\n private readonly group = inject(WR_COLLAPSE_GROUP, { optional: true });\n private readonly destroyRef = inject(DestroyRef);\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.open()) parts.push('wr-collapse--open');\n if (!this.bordered()) parts.push('wr-collapse--flat');\n if (this.disabled()) parts.push('wr-collapse--disabled');\n return parts.join(' ');\n });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n if (this.group) {\n this.group.register({ id: this.id, close: () => this.open.set(false) });\n this.destroyRef.onDestroy(() => this.group?.unregister(this.id));\n\n // Tell the group whenever we open — group decides whether to close siblings.\n effect(() => {\n if (this.open()) this.group?.notifyOpened(this.id);\n });\n }\n }\n\n /** Open the panel. */\n openPanel(): void {\n if (this.disabled()) return;\n this.open.set(true);\n }\n\n /** Close the panel. */\n close(): void {\n this.open.set(false);\n }\n\n /** Toggle the panel. */\n toggle(): void {\n if (this.disabled()) return;\n this.open.update(v => !v);\n }\n}\n","<button\n type=\"button\"\n class=\"wr-collapse__header\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"bodyId\"\n [disabled]=\"disabled()\"\n (click)=\"toggle()\"\n>\n <span class=\"wr-collapse__title\">{{ title() }}</span>\n @if (indicator() === 'plus') {\n <svg\n class=\"wr-icon__svg wr-collapse__plus\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M5 12h14\" />\n <path class=\"wr-collapse__plus-bar\" d=\"M12 5v14\" />\n </svg>\n } @else {\n <svg\n class=\"wr-icon__svg wr-collapse__chevron\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n }\n</button>\n\n<div\n class=\"wr-collapse__body\"\n [attr.id]=\"bodyId\"\n [class.wr-collapse__body--open]=\"open()\"\n [attr.aria-hidden]=\"!open()\"\n [attr.inert]=\"!open() ? '' : null\"\n>\n <div class=\"wr-collapse__content\">\n <div class=\"wr-collapse__inner\">\n <ng-content />\n </div>\n </div>\n</div>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, forwardRef, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\nimport type { WrCollapseGroupContext, WrCollapseGroupMember } from './types';\n\n/**\n * Visual + behavioral grouping of `<wr-collapse>` children. When\n * `accordion` is true, opening one child closes the others.\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-collapse-group',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-collapse-group' },\n providers: [\n {\n provide: WR_COLLAPSE_GROUP,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrCollapseGroup),\n },\n ],\n})\nexport class WrCollapseGroup implements WrCollapseGroupContext {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n }\n\n /** When true, only one child may be open at a time. @default false */\n readonly accordion = input(false, { transform: coerceBooleanProperty });\n\n private readonly members = new Map<object, WrCollapseGroupMember>();\n\n register(member: WrCollapseGroupMember): void {\n this.members.set(member.id, member);\n }\n\n unregister(memberId: object): void {\n this.members.delete(memberId);\n }\n\n notifyOpened(opener: object): void {\n if (!this.accordion()) return;\n for (const [id, member] of this.members) {\n if (id !== opener) member.close();\n }\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, forwardRef, signal } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_COLLAPSE_GROUP } from './tokens';\nimport type { WrCollapseGroupContext, WrCollapseGroupMember } from './types';\n\n/**\n * Accordion — a `<wr-collapse>` container that enforces single-open\n * behavior: opening a child closes its siblings.\n *\n * Use `<wr-collapse-group>` when you only need visual grouping without\n * the mutually-exclusive open semantics.\n *\n * @example\n * ```html\n * <wr-accordion>\n * <wr-collapse title=\"Profile\">…</wr-collapse>\n * <wr-collapse title=\"Security\">…</wr-collapse>\n * <wr-collapse title=\"Notifications\">…</wr-collapse>\n * </wr-accordion>\n * ```\n *\n * @see https://ngwr.dev/reference/components/collapse\n */\n@Component({\n selector: 'wr-accordion',\n template: '<ng-content />',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-collapse-group wr-collapse-group--accordion' },\n providers: [\n {\n provide: WR_COLLAPSE_GROUP,\n // eslint-disable-next-line @angular-eslint/no-forward-ref\n useExisting: forwardRef(() => WrAccordion),\n },\n ],\n})\nexport class WrAccordion implements WrCollapseGroupContext {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('collapse');\n }\n\n /** Always behaves as an accordion. Provided for context-interface symmetry. */\n readonly accordion = signal(true).asReadonly();\n\n private readonly members = new Map<object, WrCollapseGroupMember>();\n\n register(member: WrCollapseGroupMember): void {\n this.members.set(member.id, member);\n }\n\n unregister(memberId: object): void {\n this.members.delete(memberId);\n }\n\n notifyOpened(opener: object): void {\n for (const [id, member] of this.members) {\n if (id !== opener) member.close();\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAkBA,MAAa,oBAAoB,IAAI,eAAuC,mBAAmB;;;;;;;ACwB/F,IAAa,aAAb,MAAa,WAAU;CAEZ,QAAQ,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAGhC,OAAO,MAAe,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAG5B,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAO1D,WAAW,MAAM,MAAI;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAMzD,YAAY,MAA2B,WAAU,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAGjD,KAAK,EAAE,MAAM,WAAW,aAAa,EAA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I,WAAW,KAAK,SAC9B,IAAI,OAAO,QAAQ,OAAO,MAAK;CAEnC;CAtBW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAW,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAX,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAW,cAAA;EAAA,UAAA;EAAA,MAAA,EAAA,gBAAA,iDAAA;EAAA,WARX,CACT;GACE,SAAS;GAET,aAAa,iBAAiB,WAAW;EAC1C,CACF;EAAA,UAAA;EAAA,UATS;EAAgB,UAAA;EAAA,eAAA,GAAA,kBAAA;CAAA,CAAA;;AAWf,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAW,YAAA,CAAA;EAbvB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;GACV,eAAe,kBAAkB;GACjC,MAAM,EAAE,OAAO,iDAAgD;GAC/D,WAAW,CACT;IACE,SAAS;IAET,aAAa,iBAAgB,WAAY;GAC1C,CACF;EACF,CAAA"}
|
|
@@ -340,7 +340,7 @@ var WrColorPicker = class WrColorPicker {
|
|
|
340
340
|
}
|
|
341
341
|
], ...ngDevMode ? [{ debugName: "tabOptions" }] : /* istanbul ignore next */ []);
|
|
342
342
|
classes = computed(() => {
|
|
343
|
-
const parts = [
|
|
343
|
+
const parts = [];
|
|
344
344
|
if (this.alpha()) parts.push("wr-color-picker--alpha");
|
|
345
345
|
if (this.disabled()) parts.push("wr-color-picker--disabled");
|
|
346
346
|
else if (this.readonly()) parts.push("wr-color-picker--readonly");
|
|
@@ -626,7 +626,8 @@ var WrColorPicker = class WrColorPicker {
|
|
|
626
626
|
"attr.aria-labelledby": "labelledBy()",
|
|
627
627
|
"style.--wr-color-picker-hue": "hueCss()",
|
|
628
628
|
"style.--wr-color-picker-color": "opaqueCss()"
|
|
629
|
-
}
|
|
629
|
+
},
|
|
630
|
+
classAttribute: "wr-color-picker"
|
|
630
631
|
},
|
|
631
632
|
providers: [{
|
|
632
633
|
provide: WR_FORM_FIELD,
|
|
@@ -672,6 +673,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
672
673
|
selector: "wr-color-picker",
|
|
673
674
|
encapsulation: ViewEncapsulation.None,
|
|
674
675
|
host: {
|
|
676
|
+
class: "wr-color-picker",
|
|
675
677
|
"[class]": "classes()",
|
|
676
678
|
role: "group",
|
|
677
679
|
"[attr.aria-labelledby]": "labelledBy()",
|