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-pipes.mjs","names":[],"sources":["../../../projects/lib/pipes/bytes.ts","../../../projects/lib/pipes/date.ts","../../../projects/lib/pipes/duration.ts","../../../projects/lib/pipes/initials.ts","../../../projects/lib/pipes/mark.ts","../../../projects/lib/pipes/number.ts","../../../projects/lib/pipes/plural.ts","../../../projects/lib/pipes/range.ts","../../../projects/lib/pipes/truncate.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 { LOCALE_ID, Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\n/**\n * Binary magnitudes, as the `Intl` unit that labels each one. The COUNTING is\n * 1024-based and these names are decimal — which is the same thing the old\n * hand-written `['B', 'KB', 'MB', …]` table did, and what almost every file\n * manager does. Strictly, 1024 bytes is a kibibyte; `Intl` has no unit for it.\n */\nconst UNITS = ['byte', 'kilobyte', 'megabyte', 'gigabyte', 'terabyte', 'petabyte'] as const;\n\n/**\n * `Intl`'s NARROW unit, with one space put back between it and the number.\n *\n * Neither display mode is right on its own. `short` spells the smallest unit\n * as a word — \"512 byte\", \"0 byte\" in English, \"0 Byte\" in German — which is\n * both worse copy than the `B` this pipe has always rendered and a bigger\n * change than the fix is worth. `narrow` gives `B` / `Б` / `o` correctly and\n * then closes the gap: \"1.2kB\".\n *\n * So the parts are reassembled rather than the string. Going through\n * `formatToParts` is what keeps the ORDER the locale's own — Hebrew puts the\n * unit first, and hand-joining `${n} ${unit}` would silently straighten every\n * such locale into English order.\n */\nfunction format(locale: string, value: number, unit: number, fractionDigits: number): string {\n const parts = new Intl.NumberFormat(locale, {\n style: 'unit',\n unit: UNITS[unit],\n unitDisplay: 'narrow',\n minimumFractionDigits: fractionDigits,\n maximumFractionDigits: fractionDigits,\n }).formatToParts(value);\n\n const at = parts.findIndex(part => part.type === 'unit');\n if (at === -1) return parts.map(part => part.value).join('');\n\n const out = parts.map(part => part.value);\n // The slot on the number's side of the unit: already a separator in some\n // locales, absent in others.\n const gap = at === 0 ? 1 : at - 1;\n if (parts[gap]?.type === 'literal') out[gap] = ' ';\n else out.splice(at === 0 ? 1 : at, 0, ' ');\n return out.join('');\n}\n\n/**\n * Humanise a byte count using binary (1024-based) units, in the reader's locale.\n *\n * @example\n * ```html\n * {{ 1234 | wrBytes }} <!-- en: \"1.2 kB\" de: \"1,2 kB\" ru: \"1,2 кБ\" -->\n * {{ 1234567 | wrBytes: 0 }} <!-- en: \"1 MB\" fr: \"1 Mo\" -->\n * {{ 0 | wrBytes }} <!-- en: \"0 B\" ru: \"0 Б\" -->\n * ```\n *\n * **Both halves come from `Intl`, and the unit table is not the catalog's.** The\n * number always did need `LOCALE_ID` — it went through `toFixed`, which writes a\n * full stop in every language, so a German page read `1.2 KB` beside its own\n * `1,2` everywhere else — and the three formatting pipes beside this one\n * (`wrDate`, `wrNumber`, `wrPlural`) had injected it since they shipped.\n *\n * The unit could not follow them into `ngwr/i18n`, and the reason is the pipe\n * rather than the strings: a PURE pipe is re-invoked only when its argument\n * changes, so a catalog that lands after the first render — which is every\n * `provideWrI18nHttpLoader` app — would never reach it, and the pipe would be\n * correct under the static loader and silently English under the other one.\n * `LOCALE_ID` is a constant, so `Intl` has no such failure mode, and it knows\n * every locale ICU ships rather than the twenty-two this package translates.\n *\n * One visible change in English and it is the only one: `KB` became `kB`, which\n * is what CLDR calls that unit. `B`, the space before it and every other\n * magnitude read exactly as they did — see `format` for the part of that which\n * is not free.\n *\n * The other consequence, kept here so nobody rediscovers it as a bug:\n * `<wr-file-upload>` prints its own sizes from `fileUpload.unitKb` and friends,\n * which are public catalog keys a consumer may have overridden, so it renders\n * `KB` where this pipe renders `kB`. Retiring those keys would silently break\n * every override that had been translating them, which is a major-version move.\n *\n * {@link wrFormatBytes} is the same output as a function.\n */\n@Pipe({ name: 'wrBytes' })\nexport class WrBytes implements PipeTransform {\n private readonly locale = inject(LOCALE_ID);\n\n transform(value: number | string | null | undefined, decimals = 1): string {\n return wrFormatBytes(value, this.locale, decimals);\n }\n}\n\n/**\n * A byte count in binary (1024-based) units, in the given locale: the same\n * output as the `wrBytes` pipe, for a string built in TypeScript. `null`,\n * `undefined` and an empty string give an empty string; zero, a negative\n * number and a value that is not a number give `0 B`.\n *\n * @example\n * ```ts\n * wrFormatBytes(1234, 'en-US'); // \"1.2 kB\"\n * wrFormatBytes(1234567, 'fr-FR', 0); // \"1 Mo\"\n * ```\n */\nexport function wrFormatBytes(value: number | string | null | undefined, locale: string, decimals = 1): string {\n if (value === null || value === undefined || value === '') return '';\n const n = Number(value);\n if (!Number.isFinite(n) || n <= 0) return format(locale, 0, 0, 0);\n\n // Floored as well as capped: for `0 < n < 1` the log is negative, so an\n // unclamped index reads `UNITS[-1]` (`undefined`) and divides by `1024 ** -1`,\n // which rendered `0.5` as \"512.0 undefined\".\n const i = Math.min(Math.max(0, Math.floor(Math.log(n) / Math.log(1024))), UNITS.length - 1);\n // Whole bytes never show a fractional part.\n return format(locale, n / 1024 ** i, i, i === 0 ? 0 : Math.max(0, decimals));\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 { Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nimport { type WrDateFormat, WrDateAdapter, wrParseDate } from 'ngwr/date';\n\n/**\n * A date through a `WrDateAdapter`: the same output as the `wrDate` pipe, for a\n * string built in TypeScript. A date-only string (`'2026-01-01'`) is that day in\n * the local zone, as `DatePipe` reads it, and `'2026-01-01 14:30:00'` is read\n * as its `T` form: the value goes through `wrParseDate`. `null`, `undefined`,\n * an empty string and a date the engine refuses give an empty string.\n *\n * The adapter stands where `wrFormatNumber` takes a locale, because the output\n * is the adapter's: the native one formats in `WR_DATE_LOCALE`, and an app's own\n * adapter formats however it formats. Neither can be rebuilt from a locale\n * string, so the caller passes `inject(WrDateAdapter)` once.\n *\n * @example\n * ```ts\n * private readonly dates = inject(WrDateAdapter);\n *\n * wrFormatDate(row.createdAt, this.dates); // shortDate\n * wrFormatDate(row.createdAt, this.dates, 'mediumDateTime'); // named key\n * wrFormatDate(row.createdAt, this.dates, 'dd.MM.yyyy'); // raw token string\n * ```\n */\nexport function wrFormatDate(\n value: Date | string | number | null | undefined,\n adapter: WrDateAdapter<Date>,\n format: WrDateFormat | (string & {}) = 'shortDate'\n): string {\n const date = wrParseDate(value);\n return date === null ? '' : adapter.format(date, format);\n}\n\n/**\n * Locale-aware date formatting. Delegates to `WrDateAdapter` — the native one\n * unless the app provides its own — so both the named format keys\n * (`'shortDate'`, `'longDate'`, …) and raw token strings work with nothing to\n * set up. A date-only string (`'2026-01-01'`) is that day in the local zone,\n * as `DatePipe` reads it, not UTC midnight, and a backend's\n * `'2026-01-01 14:30:00'` is read as its `T` form. {@link wrFormatDate} is the\n * same output as a function.\n *\n * @example\n * ```html\n * {{ now | wrDate }} <!-- shortDate -->\n * {{ now | wrDate: 'mediumDateTime' }} <!-- named key -->\n * {{ now | wrDate: 'dd.MM.yyyy' }} <!-- raw token string -->\n * ```\n */\n@Pipe({ name: 'wrDate' })\nexport class WrDate implements PipeTransform {\n private readonly adapter = inject<WrDateAdapter<Date>>(WrDateAdapter);\n\n transform(\n value: Date | string | number | null | undefined,\n format: WrDateFormat | (string & {}) = 'shortDate'\n ): string {\n return wrFormatDate(value, this.adapter, format);\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 { LOCALE_ID, Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nimport type { WrDurationStyle, WrDurationUnit } from './types';\n\n/** Each unit's length in milliseconds, largest first. */\nconst UNIT_MS: readonly (readonly [WrDurationUnit, number])[] = [\n ['day', 86_400_000],\n ['hour', 3_600_000],\n ['minute', 60_000],\n ['second', 1000],\n ['millisecond', 1],\n];\n\nconst CLOCK_UNITS: ReadonlySet<WrDurationUnit> = new Set(['hour', 'minute', 'second']);\nconst LIST_UNITS: ReadonlySet<WrDurationUnit> = new Set(['day', 'hour', 'minute', 'second']);\n\nfunction formatClock(ms: number, locale: string): string {\n const { hour = 0, minute = 0, second = 0 } = wrSplitDuration(ms, CLOCK_UNITS);\n const digits = (n: number, width: number): string =>\n new Intl.NumberFormat(locale, { useGrouping: false, minimumIntegerDigits: width }).format(n);\n const tail = `${digits(minute, hour > 0 ? 2 : 1)}:${digits(second, 2)}`;\n return hour > 0 ? `${digits(hour, 1)}:${tail}` : tail;\n}\n\nfunction formatUnits(ms: number, locale: string): string {\n const parts = wrSplitDuration(ms, LIST_UNITS);\n const unit = (name: WrDurationUnit, n: number): string =>\n new Intl.NumberFormat(locale, { style: 'unit', unit: name, unitDisplay: 'short' }).format(n);\n\n const words = (Object.entries(parts) as [WrDurationUnit, number][])\n .filter(([, n]) => n > 0)\n .map(([name, n]) => unit(name, n));\n if (words.length === 0) return unit('second', 0);\n return new Intl.ListFormat(locale, { style: 'narrow', type: 'unit' }).format(words);\n}\n\n/**\n * Split a span of milliseconds into the units asked for. A unit left out is\n * carried into the next larger one that is kept, so `['hour', 'minute',\n * 'second']` over three days and an hour reads 73 hours; the smallest unit kept\n * floors whatever remains. Shared with `wr-statistic-countdown`, whose format\n * tokens pick the units.\n *\n * @internal\n */\nexport function wrSplitDuration(\n ms: number,\n units: ReadonlySet<WrDurationUnit>\n): Readonly<Partial<Record<WrDurationUnit, number>>> {\n const out: Partial<Record<WrDurationUnit, number>> = {};\n let rest = ms;\n for (const [unit, size] of UNIT_MS) {\n if (!units.has(unit)) continue;\n const n = Math.floor(rest / size);\n out[unit] = n;\n rest -= n * size;\n }\n return out;\n}\n\n/**\n * A span of milliseconds as text, in the given locale.\n *\n * Two styles. `'clock'` is digits and colons: `1:30:00`, and `5:07` under an\n * hour; days are carried into the hours, since a clock has no day digit, so two\n * days read `48:00:00`. `'units'` is every non-zero unit as a word the locale\n * writes, `1 hr 30 min` in English and `1 h 30 min` in French, through\n * `Intl.NumberFormat`'s unit style and `Intl.ListFormat` — `Intl.DurationFormat`\n * is above the browser floor. The digits are the locale's own in both styles.\n *\n * Whole seconds: a fraction of a second is floored in both styles. Zero reads\n * `0:00` and `0 sec`. A negative span is its absolute value with the locale's\n * minus sign in front, `-5:07`. `null`, `undefined`, an empty string and a value\n * that is not a finite number give an empty string, as `wrFormatNumber` does.\n *\n * The same output as the `wrDuration` pipe, for a string built in TypeScript.\n *\n * @example\n * ```ts\n * wrFormatDuration(5_400_000, 'en-US'); // \"1:30:00\"\n * wrFormatDuration(5_400_000, 'en-US', 'units'); // \"1 hr 30 min\"\n * wrFormatDuration(307_000, 'fr-FR', 'units'); // \"5 min 7 s\"\n * ```\n */\nexport function wrFormatDuration(\n value: number | string | null | undefined,\n locale: string,\n style: WrDurationStyle = 'clock'\n): string {\n if (value === null || value === undefined || value === '') return '';\n const ms = Number(typeof value === 'string' ? value.trim() : value);\n if (!Number.isFinite(ms)) return '';\n\n const span = Math.abs(ms);\n const body = style === 'units' ? formatUnits(span, locale) : formatClock(span, locale);\n // A span that floors to zero carries no sign: `-0:00` states nothing.\n if (ms >= 0 || span < 1000) return body;\n\n const minus = new Intl.NumberFormat(locale).formatToParts(-1).find(part => part.type === 'minusSign');\n return `${minus?.value ?? '-'}${body}`;\n}\n\n/**\n * A span of milliseconds as clock digits or as units, in Angular's `LOCALE_ID`.\n * See {@link wrFormatDuration} for the two styles and the edge cases.\n *\n * @example\n * ```html\n * {{ 5400000 | wrDuration }} <!-- \"1:30:00\" -->\n * {{ 5400000 | wrDuration: 'units' }} <!-- \"1 hr 30 min\" -->\n * {{ 307000 | wrDuration }} <!-- \"5:07\" -->\n * ```\n */\n@Pipe({ name: 'wrDuration' })\nexport class WrDuration implements PipeTransform {\n private readonly locale = inject(LOCALE_ID);\n\n transform(value: number | string | null | undefined, style: WrDurationStyle = 'clock'): string {\n return wrFormatDuration(value, this.locale, style);\n }\n}\n\nexport type { WrDurationStyle, WrDurationUnit } from './types';\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 { LOCALE_ID, Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nimport { wrInitials } from 'ngwr/utils';\n\n/**\n * Up to two initials of a name: `wrInitials()` from `ngwr/utils`, upper-cased\n * in `LOCALE_ID`.\n *\n * @example\n * ```html\n * {{ 'Roman Khegay' | wrInitials }} <!-- \"RK\" -->\n * {{ 'madonna' | wrInitials }} <!-- \"M\" -->\n * {{ '王小明' | wrInitials }} <!-- \"王\" -->\n * ```\n *\n * @see https://ngwr.dev/reference/pipes/wr-initials\n */\n@Pipe({ name: 'wrInitials' })\nexport class WrInitials implements PipeTransform {\n private readonly locale = inject(LOCALE_ID);\n\n transform(value: string | null | undefined): string {\n return wrInitials(value, this.locale);\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 { Pipe, type PipeTransform, inject } from '@angular/core';\nimport { DomSanitizer, type SafeHtml } from '@angular/platform-browser';\n\n/** Escapes RegExp metacharacters so user input is safe to inline. @internal */\nconst RE_META = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** HTML-entities for the four chars that matter inside our `<mark>` wrap. @internal */\nfunction escapeHtml(s: string): string {\n return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"');\n}\n\n/**\n * Wrap every occurrence of `query` in `<mark>` tags. Useful for highlighting\n * search-term matches in autocomplete results, lists, and table cells.\n *\n * The output is `SafeHtml` — bind with `[innerHTML]`. Input is escaped first\n * so user-supplied values can't inject markup.\n *\n * @example\n * ```html\n * <span [innerHTML]=\"row.name | wrMark: query()\"></span>\n *\n * <!-- Case-sensitive: -->\n * <span [innerHTML]=\"row.name | wrMark: query() : true\"></span>\n * ```\n */\n@Pipe({ name: 'wrMark' })\nexport class WrMark implements PipeTransform {\n private readonly sanitizer = inject(DomSanitizer);\n\n /**\n * @param value Source text.\n * @param query Search term to highlight. Empty/null skips the wrap.\n * @param caseSensitive Match exactly. @default false\n */\n transform(value: string | null | undefined, query: string | null | undefined, caseSensitive = false): SafeHtml {\n if (value === null || value === undefined) return '';\n const text = String(value);\n // Escaped on this path too. The output is bound with `[innerHTML]`, so\n // handing back the raw string let markup in `value` render as elements the\n // moment the search box was cleared — the same value drawn as text while a\n // query was typed, as an `<img>` when it was not.\n if (!query) return escapeHtml(text);\n\n // Match the RAW text and escape the pieces afterwards, never the other way\n // round. Escaping first rewrites `&` as `&`, and a query of `m` then lands\n // INSIDE that entity: the `<mark>` splits it and the browser paints the\n // entity's own letters, so `Tom & Jerry` renders as `Tom & Jerry`. The\n // mirror failure is a match that can never happen — `<`, `>` and `\"` no longer\n // exist in escaped text. The pipe's promise is untouched: every piece that came\n // from `value` still goes through `escapeHtml`, matched or not, so the only\n // tags in the output are the `<mark>`s built here.\n const pattern = new RegExp(`(${query.replace(RE_META, '\\\\$&')})`, caseSensitive ? 'g' : 'gi');\n const html = text\n .split(pattern)\n .map((part, index) => (index % 2 ? `<mark>${escapeHtml(part)}</mark>` : escapeHtml(part)))\n .join('');\n\n return this.sanitizer.bypassSecurityTrustHtml(html);\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 { LOCALE_ID, Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nimport type { WrNumberStyle } from './types';\n\n/** Digits with one optional point and a sign: the form `Intl` reads exactly. */\nconst PLAIN_DECIMAL = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)$/;\n\nfunction toOptions(style: WrNumberStyle, currency: string): Intl.NumberFormatOptions {\n switch (style) {\n case 'percent':\n return { style: 'percent', maximumFractionDigits: 2 };\n case 'currency':\n return { style: 'currency', currency };\n case 'decimal':\n default:\n return { style: 'decimal' };\n }\n}\n\n/**\n * A number through `Intl.NumberFormat`, in the given locale: the same output as\n * the `wrNumber` pipe, for a string built in TypeScript. Takes a style shortcut\n * (with an optional currency code) or a full `Intl.NumberFormatOptions` object.\n * `null`, `undefined`, an empty string and a value that is not a finite number\n * give an empty string.\n *\n * @example\n * ```ts\n * wrFormatNumber(1234.5, 'en-US'); // \"1,234.5\"\n * wrFormatNumber(0.875, 'en-US', 'percent'); // \"87.5%\"\n * wrFormatNumber(19.99, 'de-DE', 'currency', 'EUR'); // \"19,99 €\"\n * wrFormatNumber(19.99, 'en-US', { minimumFractionDigits: 2 });\n * ```\n */\nexport function wrFormatNumber(\n value: number | string | null | undefined,\n locale: string,\n styleOrOptions: WrNumberStyle | Intl.NumberFormatOptions = 'decimal',\n currency = 'USD'\n): string {\n if (value === null || value === undefined || value === '') return '';\n const text = typeof value === 'string' ? value.trim() : null;\n const n = Number(text ?? value);\n if (!Number.isFinite(n)) return '';\n\n const options: Intl.NumberFormatOptions =\n typeof styleOrOptions === 'string' ? toOptions(styleOrOptions, currency) : styleOrOptions;\n\n // A plain decimal string goes to `Intl` as it is: through `Number()`,\n // `'12345678901234567.89'` printed as `12,345,678,901,234,568`. Any other\n // form keeps the number, since ICU throws on an exponent of a billion or more.\n // `format()` has read a string since ES2023 (Chrome 106, Firefox 116, Safari\n // 15.4); the ES2022 lib this builds against types it as a number only.\n const exact = text !== null && PLAIN_DECIMAL.test(text) ? (text as unknown as number) : n;\n return new Intl.NumberFormat(locale, options).format(exact);\n}\n\n/**\n * Locale-aware number formatting via `Intl.NumberFormat`. Uses Angular's\n * `LOCALE_ID` as the default locale.\n *\n * Accepts either a style shortcut (with optional currency code) or a full\n * `Intl.NumberFormatOptions` object for fine-grained control.\n * {@link wrFormatNumber} is the same output as a function.\n *\n * @example\n * ```html\n * {{ 1234.5 | wrNumber }} <!-- \"1,234.5\" -->\n * {{ 0.875 | wrNumber: 'percent' }} <!-- \"87.5%\" -->\n * {{ 19.99 | wrNumber: 'currency': 'USD' }} <!-- \"$19.99\" -->\n * {{ 19.99 | wrNumber: { minimumFractionDigits: 2 } }}\n * ```\n */\n@Pipe({ name: 'wrNumber' })\nexport class WrNumber implements PipeTransform {\n private readonly locale = inject(LOCALE_ID);\n\n transform(\n value: number | string | null | undefined,\n styleOrOptions: WrNumberStyle | Intl.NumberFormatOptions = 'decimal',\n currency = 'USD'\n ): string {\n return wrFormatNumber(value, this.locale, styleOrOptions, currency);\n }\n}\n\nexport type { WrNumberStyle } from './types';\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 { LOCALE_ID, Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nimport type { WrPluralForms, WrPluralOptions } from './types';\n\n/**\n * A count and its word form through `Intl.PluralRules`, in the given locale:\n * the same output as the `wrPlural` pipe, for a string built in TypeScript.\n * `options.locale` still wins over `locale`, as it wins over `LOCALE_ID` in the\n * pipe. `null`, `undefined` and a value that is not a finite number give an\n * empty string.\n *\n * @example\n * ```ts\n * wrFormatPlural(1, 'en', { one: 'comment', other: 'comments' }); // \"1 comment\"\n * wrFormatPlural(5, 'ru', { one: 'файл', few: 'файла', other: 'файлов' }); // \"5 файлов\"\n * wrFormatPlural(5, 'en', forms, { includeValue: false }); // \"comments\"\n * ```\n */\nexport function wrFormatPlural(\n value: number | null | undefined,\n locale: string,\n forms: WrPluralForms,\n options: WrPluralOptions = {}\n): string {\n if (value === null || value === undefined || !Number.isFinite(value)) return '';\n const tag = options.locale ?? locale;\n const category = new Intl.PluralRules(tag).select(value);\n const word = forms[category] ?? forms.other;\n if (options.includeValue === false) return word;\n return `${new Intl.NumberFormat(tag).format(value)} ${word}`;\n}\n\n/**\n * Locale-aware pluralization via `Intl.PluralRules`. Picks the right word\n * form for the count — including languages with more than two forms\n * (Russian, Polish, Arabic, …) — without hand-rolled `n % 10` rules.\n *\n * Categories follow CLDR: `zero` / `one` / `two` / `few` / `many` /\n * `other`. Missing categories fall back to `other`. {@link wrFormatPlural} is\n * the same output as a function.\n *\n * @example\n * ```html\n * {{ 1 | wrPlural: { one: 'comment', other: 'comments' } }}\n * <!-- \"1 comment\" -->\n *\n * {{ 5 | wrPlural: { one: 'файл', few: 'файла', other: 'файлов' } }}\n * <!-- \"5 файлов\" (with LOCALE_ID = ru) -->\n *\n * {{ count() | wrPlural: forms : { includeValue: false } }}\n * <!-- word only -->\n * ```\n */\n@Pipe({ name: 'wrPlural' })\nexport class WrPlural implements PipeTransform {\n private readonly locale = inject(LOCALE_ID);\n\n transform(value: number | null | undefined, forms: WrPluralForms, options: WrPluralOptions = {}): string {\n return wrFormatPlural(value, this.locale, forms, options);\n }\n}\n\nexport type { WrPluralForms, WrPluralOptions } from './types';\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 { Pipe } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\n/**\n * Creates an array of sequential indices `[0, 1, 2, ..., n-1]`.\n *\n * Useful for repeating template blocks a fixed number of times.\n *\n * @example\n * ```html\n * @for (i of (5 | wrRange); track i) {\n * <div>Item {{ i }}</div>\n * }\n * ```\n */\n@Pipe({ name: 'wrRange' })\nexport class WrRange implements PipeTransform {\n transform(length: number): number[] {\n return Array.from({ length }, (_, i) => i);\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 { Pipe } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nlet segmenter: Intl.Segmenter | undefined;\n\n/**\n * Clamp a string to `length` characters, appending `ellipsis` when truncated.\n * A character is what a reader sees as one — a grapheme cluster — so an emoji,\n * a flag or a letter with a combining accent is kept whole or dropped whole,\n * never cut into half a surrogate pair that renders as a replacement box.\n *\n * @example\n * ```html\n * {{ 'Hello, world' | wrTruncate: 5 }} <!-- \"Hello…\" -->\n * {{ 'Hello, world' | wrTruncate: 8: '...' }} <!-- \"Hello, w...\" -->\n * ```\n */\n@Pipe({ name: 'wrTruncate' })\nexport class WrTruncate implements PipeTransform {\n transform(value: string | null | undefined, length = 80, ellipsis = '…'): string {\n if (value === null || value === undefined) return '';\n const s = String(value);\n // No more graphemes than UTF-16 units, so a string this short is never cut.\n if (s.length <= length) return s;\n // `slice`'s own coercion of the count, which is what this pipe did before it\n // counted graphemes: a fraction truncates, and NaN or a negative keeps nothing.\n const limit = Math.max(0, Math.trunc(length) || 0);\n segmenter ??= new Intl.Segmenter(undefined, { granularity: 'grapheme' });\n let count = 0;\n for (const { index } of segmenter.segment(s)) {\n if (count === limit) return s.slice(0, index) + ellipsis;\n count++;\n }\n return s;\n }\n}\n"],"mappings":";;;;;;;;;;;AAgBA,MAAM,QAAQ;CAAC;CAAQ;CAAY;CAAY;CAAY;CAAY;AAAU;AAgBjF,SAAS,OAAO,QAAgB,OAAe,MAAc,gBAAsB;CACjF,MAAM,QAAQ,IAAI,KAAK,aAAa,QAAQ;EAC1C,OAAO;EACP,MAAM,MAAM;EACZ,aAAa;EACb,uBAAuB;EACvB,uBAAuB;CACxB,CAAA,CAAC,CAAC,cAAc,KAAK;CAEtB,MAAM,KAAK,MAAM,WAAU,SAAQ,KAAK,SAAS,MAAM;CACvD,IAAI,OAAO,IAAI,OAAO,MAAM,KAAI,SAAQ,KAAK,KAAK,CAAC,CAAC,KAAK,EAAE;CAE3D,MAAM,MAAM,MAAM,KAAI,SAAQ,KAAK,KAAK;CAGxC,MAAM,MAAM,OAAO,IAAI,IAAI,KAAK;CAChC,IAAI,MAAM,IAAI,EAAE,SAAS,WAAW,IAAI,OAAO;MAC1C,IAAI,OAAO,OAAO,IAAI,IAAI,IAAI,GAAG,GAAG;CACzC,OAAO,IAAI,KAAK,EAAE;AACpB;AAwCA,IAAa,UAAb,MAAa,QAAO;CACD,SAAS,OAAO,SAAS;CAE1C,UAAU,OAA2C,WAAW,GAAC;EAC/D,OAAO,cAAc,OAAO,KAAK,QAAQ,QAAQ;CACnD;CALW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAO,MAAA,CAAA;EAAA,Q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,CAAC,GAAG;GAC5C,IAAI,UAAU,OAAO,OAAO,EAAE,MAAM,GAAG,KAAK,IAAI;GAChD;EACF;EACA,OAAO;CACT;CAhBW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAU,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAV,OAAA,QAAA,GAAA,gBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAU,cAAA;EAAA,MAAA;CAAA,CAAA;;AAAV,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA;EADtB,MAAA;EAAK,MAAA,CAAA,EAAE,MAAM,aAAY,CAAE"}
|
|
1
|
+
{"version":3,"file":"ngwr-pipes.mjs","names":[],"sources":["../../../projects/lib/pipes/bytes.ts","../../../projects/lib/pipes/date.ts","../../../projects/lib/pipes/duration.ts","../../../projects/lib/pipes/initials.ts","../../../projects/lib/pipes/mark.ts","../../../projects/lib/pipes/number.ts","../../../projects/lib/pipes/plural.ts","../../../projects/lib/pipes/range.ts","../../../projects/lib/pipes/truncate.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 { LOCALE_ID, Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\n/**\n * Binary magnitudes, as the `Intl` unit that labels each one. The COUNTING is\n * 1024-based and these names are decimal — which is the same thing the old\n * hand-written `['B', 'KB', 'MB', …]` table did, and what almost every file\n * manager does. Strictly, 1024 bytes is a kibibyte; `Intl` has no unit for it.\n */\nconst UNITS = ['byte', 'kilobyte', 'megabyte', 'gigabyte', 'terabyte', 'petabyte'] as const;\n\n/**\n * `Intl`'s NARROW unit, with one space put back between it and the number.\n *\n * Neither display mode is right on its own. `short` spells the smallest unit\n * as a word — \"512 byte\", \"0 byte\" in English, \"0 Byte\" in German — which is\n * both worse copy than the `B` this pipe has always rendered and a bigger\n * change than the fix is worth. `narrow` gives `B` / `Б` / `o` correctly and\n * then closes the gap: \"1.2kB\".\n *\n * So the parts are reassembled rather than the string. Going through\n * `formatToParts` is what keeps the ORDER the locale's own — Hebrew puts the\n * unit first, and hand-joining `${n} ${unit}` would silently straighten every\n * such locale into English order.\n */\nfunction format(locale: string, value: number, unit: number, fractionDigits: number): string {\n const parts = new Intl.NumberFormat(locale, {\n style: 'unit',\n unit: UNITS[unit],\n unitDisplay: 'narrow',\n minimumFractionDigits: fractionDigits,\n maximumFractionDigits: fractionDigits,\n }).formatToParts(value);\n\n const at = parts.findIndex(part => part.type === 'unit');\n if (at === -1) return parts.map(part => part.value).join('');\n\n const out = parts.map(part => part.value);\n // The slot on the number's side of the unit: already a separator in some\n // locales, absent in others.\n const gap = at === 0 ? 1 : at - 1;\n if (parts[gap]?.type === 'literal') out[gap] = ' ';\n else out.splice(at === 0 ? 1 : at, 0, ' ');\n return out.join('');\n}\n\n/**\n * Humanise a byte count using binary (1024-based) units, in the reader's locale.\n *\n * @example\n * ```html\n * {{ 1234 | wrBytes }} <!-- en: \"1.2 kB\" de: \"1,2 kB\" ru: \"1,2 кБ\" -->\n * {{ 1234567 | wrBytes: 0 }} <!-- en: \"1 MB\" fr: \"1 Mo\" -->\n * {{ 0 | wrBytes }} <!-- en: \"0 B\" ru: \"0 Б\" -->\n * ```\n *\n * **Both halves come from `Intl`, and the unit table is not the catalog's.** The\n * number always did need `LOCALE_ID` — it went through `toFixed`, which writes a\n * full stop in every language, so a German page read `1.2 KB` beside its own\n * `1,2` everywhere else — and the three formatting pipes beside this one\n * (`wrDate`, `wrNumber`, `wrPlural`) had injected it since they shipped.\n *\n * The unit could not follow them into `ngwr/i18n`, and the reason is the pipe\n * rather than the strings: a PURE pipe is re-invoked only when its argument\n * changes, so a catalog that lands after the first render — which is every\n * `provideWrI18nHttpLoader` app — would never reach it, and the pipe would be\n * correct under the static loader and silently English under the other one.\n * `LOCALE_ID` is a constant, so `Intl` has no such failure mode, and it knows\n * every locale ICU ships rather than the twenty-two this package translates.\n *\n * One visible change in English and it is the only one: `KB` became `kB`, which\n * is what CLDR calls that unit. `B`, the space before it and every other\n * magnitude read exactly as they did — see `format` for the part of that which\n * is not free.\n *\n * The other consequence, kept here so nobody rediscovers it as a bug:\n * `<wr-file-upload>` prints its own sizes from `fileUpload.unitKb` and friends,\n * which are public catalog keys a consumer may have overridden, so it renders\n * `KB` where this pipe renders `kB`. Retiring those keys would silently break\n * every override that had been translating them, which is a major-version move.\n *\n * {@link wrFormatBytes} is the same output as a function.\n */\n@Pipe({ name: 'wrBytes' })\nexport class WrBytes implements PipeTransform {\n private readonly locale = inject(LOCALE_ID);\n\n transform(value: number | string | null | undefined, decimals = 1): string {\n return wrFormatBytes(value, this.locale, decimals);\n }\n}\n\n/**\n * A byte count in binary (1024-based) units, in the given locale: the same\n * output as the `wrBytes` pipe, for a string built in TypeScript. `null`,\n * `undefined` and an empty string give an empty string; zero, a negative\n * number and a value that is not a number give `0 B`.\n *\n * @example\n * ```ts\n * wrFormatBytes(1234, 'en-US'); // \"1.2 kB\"\n * wrFormatBytes(1234567, 'fr-FR', 0); // \"1 Mo\"\n * ```\n */\nexport function wrFormatBytes(value: number | string | null | undefined, locale: string, decimals = 1): string {\n if (value === null || value === undefined || value === '') return '';\n const n = Number(value);\n if (!Number.isFinite(n) || n <= 0) return format(locale, 0, 0, 0);\n\n // Floored as well as capped: for `0 < n < 1` the log is negative, so an\n // unclamped index reads `UNITS[-1]` (`undefined`) and divides by `1024 ** -1`,\n // which rendered `0.5` as \"512.0 undefined\".\n const i = Math.min(Math.max(0, Math.floor(Math.log(n) / Math.log(1024))), UNITS.length - 1);\n // Whole bytes never show a fractional part.\n return format(locale, n / 1024 ** i, i, i === 0 ? 0 : Math.max(0, decimals));\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 { Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nimport { type WrDateFormat, type WrParseDateOptions, WrDateAdapter, wrIsDateOnly, wrParseDate } from 'ngwr/date';\n\n/**\n * A date through a `WrDateAdapter`: the same output as the `wrDate` pipe, for a\n * string built in TypeScript. A date-only string (`'2026-01-01'`) is that day in\n * the local zone, as `DatePipe` reads it, and `'2026-01-01 14:30:00'` is read\n * as its `T` form: the value goes through `wrParseDate`. `null`, `undefined`,\n * an empty string and a date the engine refuses give an empty string.\n *\n * An instant is printed on the wall clock of `withDates({ timeZone })`, through\n * the adapter's `zoned()`. A date-only string is a calendar day and is not\n * moved: `'2026-01-01'` prints as 1 January in every zone.\n *\n * The value is read as `withDates()` says: `epochUnit` for a number and\n * `zonelessIn` for a date-time string with no offset. The last argument\n * overrides either for one call, for a field whose unit differs from the app's.\n *\n * The adapter stands where `wrFormatNumber` takes a locale, because the output\n * is the adapter's: the native one formats in `WR_DATE_LOCALE`, and an app's own\n * adapter formats however it formats. Neither can be rebuilt from a locale\n * string, so the caller passes `inject(WrDateAdapter)` once.\n *\n * @example\n * ```ts\n * private readonly dates = inject(WrDateAdapter);\n *\n * wrFormatDate(row.createdAt, this.dates); // shortDate\n * wrFormatDate(row.createdAt, this.dates, 'mediumDateTime'); // named key\n * wrFormatDate(row.createdAt, this.dates, 'dd.MM.yyyy'); // raw token string\n * wrFormatDate(row.sentAt, this.dates, 'time', { epochUnit: 'us' }); // microseconds\n * ```\n */\nexport function wrFormatDate(\n value: Date | string | number | null | undefined,\n adapter: WrDateAdapter<Date>,\n format: WrDateFormat | (string & {}) = 'shortDate',\n options?: WrParseDateOptions\n): string {\n const date = wrParseDate(value, { ...adapter.parseOptions(), ...options });\n if (date === null) return '';\n return (wrIsDateOnly(value) ? adapter : adapter.zoned()).format(date, format);\n}\n\n/**\n * Locale-aware date formatting. Delegates to `WrDateAdapter` — the native one\n * unless the app provides its own — so both the named format keys\n * (`'shortDate'`, `'longDate'`, …) and raw token strings work with nothing to\n * set up. A date-only string (`'2026-01-01'`) is that day in the local zone,\n * as `DatePipe` reads it, not UTC midnight, and a backend's\n * `'2026-01-01 14:30:00'` is read as its `T` form. {@link wrFormatDate} is the\n * same output as a function.\n *\n * An instant is printed in the time zone of `withDates({ timeZone })`, and the\n * output follows that zone and the adapter's locale when they change at\n * runtime. A pure pipe cannot: Angular calls it again only when an argument\n * changes. So the pipe is impure and keeps its last result, and a\n * change-detection pass with nothing new costs three comparisons, not a\n * format.\n *\n * @example\n * ```html\n * {{ now | wrDate }} <!-- shortDate -->\n * {{ now | wrDate: 'mediumDateTime' }} <!-- named key -->\n * {{ now | wrDate: 'dd.MM.yyyy' }} <!-- raw token string -->\n * {{ sentAt | wrDate: 'time' : { epochUnit: 'us' } }} <!-- microseconds -->\n * ```\n */\n// eslint-disable-next-line @angular-eslint/no-pipe-impure -- a pure pipe cannot follow the zone or the locale; see above\n@Pipe({ name: 'wrDate', pure: false })\nexport class WrDate implements PipeTransform {\n private readonly adapter = inject<WrDateAdapter<Date>>(WrDateAdapter);\n\n private value: unknown;\n private format = '';\n private key: string | null = null;\n private text = '';\n\n transform(\n value: Date | string | number | null | undefined,\n format: WrDateFormat | (string & {}) = 'shortDate',\n options?: WrParseDateOptions\n ): string {\n // A signal read on the native adapter, which is what makes the template run\n // again when the zone or the locale moves.\n const display = this.adapter.zoned().displayKey();\n const key = options ? `${display}|${options.epochUnit}|${options.zonelessIn}|${options.timeZone}` : display;\n if (key !== this.key || format !== this.format || !Object.is(value, this.value)) {\n this.text = wrFormatDate(value, this.adapter, format, options);\n this.value = value;\n this.format = format;\n this.key = key;\n }\n return this.text;\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 { LOCALE_ID, Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nimport type { WrDurationStyle, WrDurationUnit } from './types';\n\n/** Each unit's length in milliseconds, largest first. */\nconst UNIT_MS: readonly (readonly [WrDurationUnit, number])[] = [\n ['day', 86_400_000],\n ['hour', 3_600_000],\n ['minute', 60_000],\n ['second', 1000],\n ['millisecond', 1],\n];\n\nconst CLOCK_UNITS: ReadonlySet<WrDurationUnit> = new Set(['hour', 'minute', 'second']);\nconst LIST_UNITS: ReadonlySet<WrDurationUnit> = new Set(['day', 'hour', 'minute', 'second']);\n\nfunction formatClock(ms: number, locale: string): string {\n const { hour = 0, minute = 0, second = 0 } = wrSplitDuration(ms, CLOCK_UNITS);\n const digits = (n: number, width: number): string =>\n new Intl.NumberFormat(locale, { useGrouping: false, minimumIntegerDigits: width }).format(n);\n const tail = `${digits(minute, hour > 0 ? 2 : 1)}:${digits(second, 2)}`;\n return hour > 0 ? `${digits(hour, 1)}:${tail}` : tail;\n}\n\nfunction formatTimer(ms: number, locale: string): string {\n const { day = 0, hour = 0, minute = 0, second = 0 } = wrSplitDuration(ms, LIST_UNITS);\n const two = new Intl.NumberFormat(locale, { useGrouping: false, minimumIntegerDigits: 2 });\n const clock = [hour, minute, second].map(n => two.format(n)).join(':');\n if (day === 0) return clock;\n const days = new Intl.NumberFormat(locale, { style: 'unit', unit: 'day', unitDisplay: 'narrow' }).format(day);\n return `${days} ${clock}`;\n}\n\nfunction formatUnits(ms: number, locale: string): string {\n const parts = wrSplitDuration(ms, LIST_UNITS);\n const unit = (name: WrDurationUnit, n: number): string =>\n new Intl.NumberFormat(locale, { style: 'unit', unit: name, unitDisplay: 'short' }).format(n);\n\n const words = (Object.entries(parts) as [WrDurationUnit, number][])\n .filter(([, n]) => n > 0)\n .map(([name, n]) => unit(name, n));\n if (words.length === 0) return unit('second', 0);\n return new Intl.ListFormat(locale, { style: 'narrow', type: 'unit' }).format(words);\n}\n\n/**\n * Split a span of milliseconds into the units asked for. A unit left out is\n * carried into the next larger one that is kept, so `['hour', 'minute',\n * 'second']` over three days and an hour reads 73 hours; the smallest unit kept\n * floors whatever remains. Shared with `wr-statistic-countdown`, whose format\n * tokens pick the units.\n *\n * @internal\n */\nexport function wrSplitDuration(\n ms: number,\n units: ReadonlySet<WrDurationUnit>\n): Readonly<Partial<Record<WrDurationUnit, number>>> {\n const out: Partial<Record<WrDurationUnit, number>> = {};\n let rest = ms;\n for (const [unit, size] of UNIT_MS) {\n if (!units.has(unit)) continue;\n const n = Math.floor(rest / size);\n out[unit] = n;\n rest -= n * size;\n }\n return out;\n}\n\n/**\n * A span of milliseconds as text, in the given locale.\n *\n * Three styles. `'clock'` is digits and colons: `1:30:00`, and `5:07` under an\n * hour; days are carried into the hours, since a clock has no day digit, so two\n * days read `48:00:00`. `'units'` is every non-zero unit as a word the locale\n * writes, `1 hr 30 min` in English and `1 h 30 min` in French, through\n * `Intl.NumberFormat`'s unit style and `Intl.ListFormat` — `Intl.DurationFormat`\n * is above the browser floor. `'timer'` is what an elapsed-time counter shows:\n * always `HH:mm:ss`, each field two digits, `01:02:03` and `00:05:07`; from a\n * day on, the days stand in front as the locale's narrow unit, `1d 02:03:04`.\n * The digits are the locale's own in every style.\n *\n * A span is not an instant: no style reads a time zone, so the output is the\n * same wherever it runs. Formatting an elapsed time as a date would add the\n * display zone's offset to it.\n *\n * Whole seconds: a fraction of a second is floored in every style. Zero reads\n * `0:00`, `0 sec` and `00:00:00`. A negative span is its absolute value with\n * the locale's minus sign in front, `-5:07` and `-00:05:07`. `null`, `undefined`, an empty string and a value\n * that is not a finite number give an empty string, as `wrFormatNumber` does.\n *\n * The same output as the `wrDuration` pipe, for a string built in TypeScript.\n *\n * @example\n * ```ts\n * wrFormatDuration(5_400_000, 'en-US'); // \"1:30:00\"\n * wrFormatDuration(5_400_000, 'en-US', 'units'); // \"1 hr 30 min\"\n * wrFormatDuration(307_000, 'fr-FR', 'units'); // \"5 min 7 s\"\n * wrFormatDuration(3_723_000, 'en-US', 'timer'); // \"01:02:03\"\n * wrFormatDuration(93_784_000, 'en-US', 'timer'); // \"1d 02:03:04\"\n * ```\n */\nexport function wrFormatDuration(\n value: number | string | null | undefined,\n locale: string,\n style: WrDurationStyle = 'clock'\n): string {\n if (value === null || value === undefined || value === '') return '';\n const ms = Number(typeof value === 'string' ? value.trim() : value);\n if (!Number.isFinite(ms)) return '';\n\n const span = Math.abs(ms);\n const body =\n style === 'units'\n ? formatUnits(span, locale)\n : style === 'timer'\n ? formatTimer(span, locale)\n : formatClock(span, locale);\n // A span that floors to zero carries no sign: `-0:00` states nothing.\n if (ms >= 0 || span < 1000) return body;\n\n const minus = new Intl.NumberFormat(locale).formatToParts(-1).find(part => part.type === 'minusSign');\n return `${minus?.value ?? '-'}${body}`;\n}\n\n/**\n * A span of milliseconds as clock digits, as units or as a timer, in Angular's\n * `LOCALE_ID`. See {@link wrFormatDuration} for the three styles and the edge\n * cases.\n *\n * @example\n * ```html\n * {{ 5400000 | wrDuration }} <!-- \"1:30:00\" -->\n * {{ 5400000 | wrDuration: 'units' }} <!-- \"1 hr 30 min\" -->\n * {{ 307000 | wrDuration }} <!-- \"5:07\" -->\n * {{ 3723000 | wrDuration: 'timer' }} <!-- \"01:02:03\" -->\n * ```\n */\n@Pipe({ name: 'wrDuration' })\nexport class WrDuration implements PipeTransform {\n private readonly locale = inject(LOCALE_ID);\n\n transform(value: number | string | null | undefined, style: WrDurationStyle = 'clock'): string {\n return wrFormatDuration(value, this.locale, style);\n }\n}\n\nexport type { WrDurationStyle, WrDurationUnit } from './types';\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 { LOCALE_ID, Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nimport { wrInitials } from 'ngwr/utils';\n\n/**\n * Up to two initials of a name: `wrInitials()` from `ngwr/utils`, upper-cased\n * in `LOCALE_ID`.\n *\n * @example\n * ```html\n * {{ 'Roman Khegay' | wrInitials }} <!-- \"RK\" -->\n * {{ 'madonna' | wrInitials }} <!-- \"M\" -->\n * {{ '王小明' | wrInitials }} <!-- \"王\" -->\n * ```\n *\n * @see https://ngwr.dev/reference/pipes/wr-initials\n */\n@Pipe({ name: 'wrInitials' })\nexport class WrInitials implements PipeTransform {\n private readonly locale = inject(LOCALE_ID);\n\n transform(value: string | null | undefined): string {\n return wrInitials(value, this.locale);\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 { Pipe, type PipeTransform, inject } from '@angular/core';\nimport { DomSanitizer, type SafeHtml } from '@angular/platform-browser';\n\n/** Escapes RegExp metacharacters so user input is safe to inline. @internal */\nconst RE_META = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** HTML-entities for the four chars that matter inside our `<mark>` wrap. @internal */\nfunction escapeHtml(s: string): string {\n return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"');\n}\n\n/**\n * Wrap every occurrence of `query` in `<mark>` tags. Useful for highlighting\n * search-term matches in autocomplete results, lists, and table cells.\n *\n * The output is `SafeHtml` — bind with `[innerHTML]`. Input is escaped first\n * so user-supplied values can't inject markup.\n *\n * @example\n * ```html\n * <span [innerHTML]=\"row.name | wrMark: query()\"></span>\n *\n * <!-- Case-sensitive: -->\n * <span [innerHTML]=\"row.name | wrMark: query() : true\"></span>\n * ```\n */\n@Pipe({ name: 'wrMark' })\nexport class WrMark implements PipeTransform {\n private readonly sanitizer = inject(DomSanitizer);\n\n /**\n * @param value Source text.\n * @param query Search term to highlight. Empty/null skips the wrap.\n * @param caseSensitive Match exactly. @default false\n */\n transform(value: string | null | undefined, query: string | null | undefined, caseSensitive = false): SafeHtml {\n if (value === null || value === undefined) return '';\n const text = String(value);\n // Escaped on this path too. The output is bound with `[innerHTML]`, so\n // handing back the raw string let markup in `value` render as elements the\n // moment the search box was cleared — the same value drawn as text while a\n // query was typed, as an `<img>` when it was not.\n if (!query) return escapeHtml(text);\n\n // Match the RAW text and escape the pieces afterwards, never the other way\n // round. Escaping first rewrites `&` as `&`, and a query of `m` then lands\n // INSIDE that entity: the `<mark>` splits it and the browser paints the\n // entity's own letters, so `Tom & Jerry` renders as `Tom & Jerry`. The\n // mirror failure is a match that can never happen — `<`, `>` and `\"` no longer\n // exist in escaped text. The pipe's promise is untouched: every piece that came\n // from `value` still goes through `escapeHtml`, matched or not, so the only\n // tags in the output are the `<mark>`s built here.\n const pattern = new RegExp(`(${query.replace(RE_META, '\\\\$&')})`, caseSensitive ? 'g' : 'gi');\n const html = text\n .split(pattern)\n .map((part, index) => (index % 2 ? `<mark>${escapeHtml(part)}</mark>` : escapeHtml(part)))\n .join('');\n\n return this.sanitizer.bypassSecurityTrustHtml(html);\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 { LOCALE_ID, Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nimport type { WrNumberStyle } from './types';\n\n/** Digits with one optional point and a sign: the form `Intl` reads exactly. */\nconst PLAIN_DECIMAL = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)$/;\n\nfunction toOptions(style: WrNumberStyle, currency: string): Intl.NumberFormatOptions {\n switch (style) {\n case 'percent':\n return { style: 'percent', maximumFractionDigits: 2 };\n case 'currency':\n return { style: 'currency', currency };\n case 'decimal':\n default:\n return { style: 'decimal' };\n }\n}\n\n/**\n * A number through `Intl.NumberFormat`, in the given locale: the same output as\n * the `wrNumber` pipe, for a string built in TypeScript. Takes a style shortcut\n * (with an optional currency code) or a full `Intl.NumberFormatOptions` object.\n * `null`, `undefined`, an empty string and a value that is not a finite number\n * give an empty string.\n *\n * @example\n * ```ts\n * wrFormatNumber(1234.5, 'en-US'); // \"1,234.5\"\n * wrFormatNumber(0.875, 'en-US', 'percent'); // \"87.5%\"\n * wrFormatNumber(19.99, 'de-DE', 'currency', 'EUR'); // \"19,99 €\"\n * wrFormatNumber(19.99, 'en-US', { minimumFractionDigits: 2 });\n * ```\n */\nexport function wrFormatNumber(\n value: number | string | null | undefined,\n locale: string,\n styleOrOptions: WrNumberStyle | Intl.NumberFormatOptions = 'decimal',\n currency = 'USD'\n): string {\n if (value === null || value === undefined || value === '') return '';\n const text = typeof value === 'string' ? value.trim() : null;\n const n = Number(text ?? value);\n if (!Number.isFinite(n)) return '';\n\n const options: Intl.NumberFormatOptions =\n typeof styleOrOptions === 'string' ? toOptions(styleOrOptions, currency) : styleOrOptions;\n\n // A plain decimal string goes to `Intl` as it is: through `Number()`,\n // `'12345678901234567.89'` printed as `12,345,678,901,234,568`. Any other\n // form keeps the number, since ICU throws on an exponent of a billion or more.\n // `format()` has read a string since ES2023 (Chrome 106, Firefox 116, Safari\n // 15.4); the ES2022 lib this builds against types it as a number only.\n const exact = text !== null && PLAIN_DECIMAL.test(text) ? (text as unknown as number) : n;\n return new Intl.NumberFormat(locale, options).format(exact);\n}\n\n/**\n * Locale-aware number formatting via `Intl.NumberFormat`. Uses Angular's\n * `LOCALE_ID` as the default locale.\n *\n * Accepts either a style shortcut (with optional currency code) or a full\n * `Intl.NumberFormatOptions` object for fine-grained control.\n * {@link wrFormatNumber} is the same output as a function.\n *\n * @example\n * ```html\n * {{ 1234.5 | wrNumber }} <!-- \"1,234.5\" -->\n * {{ 0.875 | wrNumber: 'percent' }} <!-- \"87.5%\" -->\n * {{ 19.99 | wrNumber: 'currency': 'USD' }} <!-- \"$19.99\" -->\n * {{ 19.99 | wrNumber: { minimumFractionDigits: 2 } }}\n * ```\n */\n@Pipe({ name: 'wrNumber' })\nexport class WrNumber implements PipeTransform {\n private readonly locale = inject(LOCALE_ID);\n\n transform(\n value: number | string | null | undefined,\n styleOrOptions: WrNumberStyle | Intl.NumberFormatOptions = 'decimal',\n currency = 'USD'\n ): string {\n return wrFormatNumber(value, this.locale, styleOrOptions, currency);\n }\n}\n\nexport type { WrNumberStyle } from './types';\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 { LOCALE_ID, Pipe, inject } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nimport type { WrPluralForms, WrPluralOptions } from './types';\n\n/**\n * A count and its word form through `Intl.PluralRules`, in the given locale:\n * the same output as the `wrPlural` pipe, for a string built in TypeScript.\n * `options.locale` still wins over `locale`, as it wins over `LOCALE_ID` in the\n * pipe. `null`, `undefined` and a value that is not a finite number give an\n * empty string.\n *\n * @example\n * ```ts\n * wrFormatPlural(1, 'en', { one: 'comment', other: 'comments' }); // \"1 comment\"\n * wrFormatPlural(5, 'ru', { one: 'файл', few: 'файла', other: 'файлов' }); // \"5 файлов\"\n * wrFormatPlural(5, 'en', forms, { includeValue: false }); // \"comments\"\n * ```\n */\nexport function wrFormatPlural(\n value: number | null | undefined,\n locale: string,\n forms: WrPluralForms,\n options: WrPluralOptions = {}\n): string {\n if (value === null || value === undefined || !Number.isFinite(value)) return '';\n const tag = options.locale ?? locale;\n const category = new Intl.PluralRules(tag).select(value);\n const word = forms[category] ?? forms.other;\n if (options.includeValue === false) return word;\n return `${new Intl.NumberFormat(tag).format(value)} ${word}`;\n}\n\n/**\n * Locale-aware pluralization via `Intl.PluralRules`. Picks the right word\n * form for the count — including languages with more than two forms\n * (Russian, Polish, Arabic, …) — without hand-rolled `n % 10` rules.\n *\n * Categories follow CLDR: `zero` / `one` / `two` / `few` / `many` /\n * `other`. Missing categories fall back to `other`. {@link wrFormatPlural} is\n * the same output as a function.\n *\n * @example\n * ```html\n * {{ 1 | wrPlural: { one: 'comment', other: 'comments' } }}\n * <!-- \"1 comment\" -->\n *\n * {{ 5 | wrPlural: { one: 'файл', few: 'файла', other: 'файлов' } }}\n * <!-- \"5 файлов\" (with LOCALE_ID = ru) -->\n *\n * {{ count() | wrPlural: forms : { includeValue: false } }}\n * <!-- word only -->\n * ```\n */\n@Pipe({ name: 'wrPlural' })\nexport class WrPlural implements PipeTransform {\n private readonly locale = inject(LOCALE_ID);\n\n transform(value: number | null | undefined, forms: WrPluralForms, options: WrPluralOptions = {}): string {\n return wrFormatPlural(value, this.locale, forms, options);\n }\n}\n\nexport type { WrPluralForms, WrPluralOptions } from './types';\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 { Pipe } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\n/**\n * Creates an array of sequential indices `[0, 1, 2, ..., n-1]`.\n *\n * Useful for repeating template blocks a fixed number of times.\n *\n * @example\n * ```html\n * @for (i of (5 | wrRange); track i) {\n * <div>Item {{ i }}</div>\n * }\n * ```\n */\n@Pipe({ name: 'wrRange' })\nexport class WrRange implements PipeTransform {\n transform(length: number): number[] {\n return Array.from({ length }, (_, i) => i);\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 { Pipe } from '@angular/core';\nimport type { PipeTransform } from '@angular/core';\n\nlet segmenter: Intl.Segmenter | undefined;\n\n/**\n * Clamp a string to `length` characters, appending `ellipsis` when truncated.\n * A character is what a reader sees as one — a grapheme cluster — so an emoji,\n * a flag or a letter with a combining accent is kept whole or dropped whole,\n * never cut into half a surrogate pair that renders as a replacement box.\n *\n * @example\n * ```html\n * {{ 'Hello, world' | wrTruncate: 5 }} <!-- \"Hello…\" -->\n * {{ 'Hello, world' | wrTruncate: 8: '...' }} <!-- \"Hello, w...\" -->\n * ```\n */\n@Pipe({ name: 'wrTruncate' })\nexport class WrTruncate implements PipeTransform {\n transform(value: string | null | undefined, length = 80, ellipsis = '…'): string {\n if (value === null || value === undefined) return '';\n const s = String(value);\n // No more graphemes than UTF-16 units, so a string this short is never cut.\n if (s.length <= length) return s;\n // `slice`'s own coercion of the count, which is what this pipe did before it\n // counted graphemes: a fraction truncates, and NaN or a negative keeps nothing.\n const limit = Math.max(0, Math.trunc(length) || 0);\n segmenter ??= new Intl.Segmenter(undefined, { granularity: 'grapheme' });\n let count = 0;\n for (const { index } of segmenter.segment(s)) {\n if (count === limit) return s.slice(0, index) + ellipsis;\n count++;\n }\n return s;\n }\n}\n"],"mappings":";;;;;;;;;;;AAgBA,MAAM,QAAQ;CAAC;CAAQ;CAAY;CAAY;CAAY;CAAY;AAAU;AAgBjF,SAAS,OAAO,QAAgB,OAAe,MAAc,gBAAsB;CACjF,MAAM,QAAQ,IAAI,KAAK,aAAa,QAAQ;EAC1C,OAAO;EACP,MAAM,MAAM;EACZ,aAAa;EACb,uBAAuB;EACvB,uBAAuB;CACxB,CAAA,CAAC,CAAC,cAAc,KAAK;CAEtB,MAAM,KAAK,MAAM,WAAU,SAAQ,KAAK,SAAS,MAAM;CACvD,IAAI,OAAO,IAAI,OAAO,MAAM,KAAI,SAAQ,KAAK,KAAK,CAAC,CAAC,KAAK,EAAE;CAE3D,MAAM,MAAM,MAAM,KAAI,SAAQ,KAAK,KAAK;CAGxC,MAAM,MAAM,OAAO,IAAI,IAAI,KAAK;CAChC,IAAI,MAAM,IAAI,EAAE,SAAS,WAAW,IAAI,OAAO;MAC1C,IAAI,OAAO,OAAO,IAAI,IAAI,IAAI,GAAG,GAAG;CACzC,OAAO,IAAI,KAAK,EAAE;AACpB;AAwCA,IAAa,UAAb,MAAa,QAAO;CACD,SAAS,OAAO,SAAS;CAE1C,UAAU,OAA2C,WAAW,GAAC;EAC/D,OAAO,cAAc,OAAO,KAAK,QAAQ,QAAQ;CACnD;CALW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAO,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAP,OAAA,QAAA,GAAA,gBAAA;EAAA,YAAA;EAAA,SAAA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AA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAU,cAAA;EAAA,MAAA;CAAA,CAAA;;AAAV,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA;EADtB,MAAA;EAAK,MAAA,CAAA,EAAE,MAAM,aAAY,CAAE"}
|
|
@@ -735,6 +735,10 @@ var WrPopover = class WrPopover {
|
|
|
735
735
|
...ngDevMode ? { debugName: "hideDelay" } : /* istanbul ignore next */ {},
|
|
736
736
|
transform: wrNumAttr(60)
|
|
737
737
|
});
|
|
738
|
+
origin = input(null, {
|
|
739
|
+
...ngDevMode ? { debugName: "origin" } : /* istanbul ignore next */ {},
|
|
740
|
+
alias: "wrPopoverOrigin"
|
|
741
|
+
});
|
|
738
742
|
ariaLabel = input(null, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
739
743
|
panelClass = input(null, ...ngDevMode ? [{ debugName: "panelClass" }] : /* istanbul ignore next */ []);
|
|
740
744
|
opened = output();
|
|
@@ -756,6 +760,7 @@ var WrPopover = class WrPopover {
|
|
|
756
760
|
resolvedAriaLabel = useI18nText(this.ariaLabel, "popover.label", "Popover");
|
|
757
761
|
resolvedPosition = computed(() => this.position() ?? (this.isTooltip() ? "top" : "bottom"), ...ngDevMode ? [{ debugName: "resolvedPosition" }] : /* istanbul ignore next */ []);
|
|
758
762
|
overlayRef = null;
|
|
763
|
+
connected = null;
|
|
759
764
|
textPanelRef = null;
|
|
760
765
|
hostFocused = false;
|
|
761
766
|
hoverCloseTimer = null;
|
|
@@ -772,6 +777,32 @@ var WrPopover = class WrPopover {
|
|
|
772
777
|
const content = this.content();
|
|
773
778
|
this.textPanelRef?.setInput("text", typeof content === "string" ? content : "");
|
|
774
779
|
});
|
|
780
|
+
effect((onCleanup) => {
|
|
781
|
+
const origin = this.origin();
|
|
782
|
+
if (!origin || !this.isTooltip()) return;
|
|
783
|
+
const show = () => this.scheduleShow();
|
|
784
|
+
const leave = (event) => this.onMouseLeave(event);
|
|
785
|
+
const focus = () => {
|
|
786
|
+
if (this.fromNavigationKey()) this.scheduleShow();
|
|
787
|
+
};
|
|
788
|
+
const blur = () => this.scheduleHide();
|
|
789
|
+
origin.addEventListener("mouseenter", show);
|
|
790
|
+
origin.addEventListener("mouseleave", leave);
|
|
791
|
+
origin.addEventListener("focusin", focus);
|
|
792
|
+
origin.addEventListener("focusout", blur);
|
|
793
|
+
untracked(() => {
|
|
794
|
+
this.connected?.setOrigin(origin);
|
|
795
|
+
afterNextRender(() => this.overlayRef?.updatePosition(), { injector: this.injector });
|
|
796
|
+
this.scheduleShow();
|
|
797
|
+
});
|
|
798
|
+
onCleanup(() => {
|
|
799
|
+
origin.removeEventListener("mouseenter", show);
|
|
800
|
+
origin.removeEventListener("mouseleave", leave);
|
|
801
|
+
origin.removeEventListener("focusin", focus);
|
|
802
|
+
origin.removeEventListener("focusout", blur);
|
|
803
|
+
if (!this.destroyRef.destroyed) this.scheduleHide();
|
|
804
|
+
});
|
|
805
|
+
});
|
|
775
806
|
afterNextRender(() => {
|
|
776
807
|
this.focusMonitor.monitor(this.host).pipe(takeUntilDestroyed(this.destroyRef)).subscribe((origin) => {
|
|
777
808
|
if (origin) {
|
|
@@ -868,7 +899,8 @@ var WrPopover = class WrPopover {
|
|
|
868
899
|
const tooltip = this.isTooltip();
|
|
869
900
|
const position = this.resolvedPosition();
|
|
870
901
|
const paneClass = tooltip ? "wr-tooltip-overlay" : "wr-popover-overlay";
|
|
871
|
-
const connected = this.overlay.position().flexibleConnectedTo(this.host).withPositions(wrMirrorOffsets(wrPopoverPositions(position, paneClass), this.isRtl())).withPush(true).withViewportMargin(8);
|
|
902
|
+
const connected = this.overlay.position().flexibleConnectedTo((tooltip ? this.origin() : null) ?? this.host).withPositions(wrMirrorOffsets(wrPopoverPositions(position, paneClass), this.isRtl())).withPush(true).withViewportMargin(8);
|
|
903
|
+
this.connected = connected;
|
|
872
904
|
const overlayClass = wrToClassList(paneClass, this.panelClass());
|
|
873
905
|
this.overlayRef = this.overlay.create({
|
|
874
906
|
positionStrategy: connected,
|
|
@@ -899,7 +931,7 @@ var WrPopover = class WrPopover {
|
|
|
899
931
|
}
|
|
900
932
|
this.overlayRef.overlayElement.id = this.panelId;
|
|
901
933
|
this.outsideClick.outsidePointerEvents(this.overlayRef).pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
|
|
902
|
-
if (this.
|
|
934
|
+
if (this.isTrigger(event.target)) return;
|
|
903
935
|
this.openState.set(false);
|
|
904
936
|
});
|
|
905
937
|
this.overlayRef.keydownEvents().pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
|
|
@@ -928,6 +960,7 @@ var WrPopover = class WrPopover {
|
|
|
928
960
|
pane.removeEventListener("focusout", this.onPaneFocusOut);
|
|
929
961
|
this.overlayRef.dispose();
|
|
930
962
|
this.overlayRef = null;
|
|
963
|
+
this.connected = null;
|
|
931
964
|
this.textPanelRef = null;
|
|
932
965
|
if (notify) {
|
|
933
966
|
if (focusWasInside) wrRestoreFocus(this.host.nativeElement, this.focusMonitor);
|
|
@@ -961,7 +994,7 @@ var WrPopover = class WrPopover {
|
|
|
961
994
|
}
|
|
962
995
|
onOverlayLeave = (event) => {
|
|
963
996
|
const related = event.relatedTarget;
|
|
964
|
-
if (related && this.
|
|
997
|
+
if (related && this.isTrigger(related)) return;
|
|
965
998
|
if (this.isTooltip()) this.scheduleHide();
|
|
966
999
|
else this.scheduleHoverClose();
|
|
967
1000
|
};
|
|
@@ -979,6 +1012,9 @@ var WrPopover = class WrPopover {
|
|
|
979
1012
|
this.hoverCloseTimer = null;
|
|
980
1013
|
}
|
|
981
1014
|
}
|
|
1015
|
+
isTrigger(node) {
|
|
1016
|
+
return this.host.nativeElement.contains(node) || (this.origin()?.contains(node) ?? false);
|
|
1017
|
+
}
|
|
982
1018
|
isRtl() {
|
|
983
1019
|
return this.dir?.value === "rtl";
|
|
984
1020
|
}
|
|
@@ -1039,6 +1075,13 @@ var WrPopover = class WrPopover {
|
|
|
1039
1075
|
isRequired: false,
|
|
1040
1076
|
transformFunction: null
|
|
1041
1077
|
},
|
|
1078
|
+
origin: {
|
|
1079
|
+
classPropertyName: "origin",
|
|
1080
|
+
publicName: "wrPopoverOrigin",
|
|
1081
|
+
isSignal: true,
|
|
1082
|
+
isRequired: false,
|
|
1083
|
+
transformFunction: null
|
|
1084
|
+
},
|
|
1042
1085
|
ariaLabel: {
|
|
1043
1086
|
classPropertyName: "ariaLabel",
|
|
1044
1087
|
publicName: "ariaLabel",
|
|
@@ -1154,6 +1197,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1154
1197
|
required: false
|
|
1155
1198
|
}]
|
|
1156
1199
|
}],
|
|
1200
|
+
origin: [{
|
|
1201
|
+
type: i0.Input,
|
|
1202
|
+
args: [{
|
|
1203
|
+
isSignal: true,
|
|
1204
|
+
alias: "wrPopoverOrigin",
|
|
1205
|
+
required: false
|
|
1206
|
+
}]
|
|
1207
|
+
}],
|
|
1157
1208
|
ariaLabel: [{
|
|
1158
1209
|
type: i0.Input,
|
|
1159
1210
|
args: [{
|
|
@@ -1180,6 +1231,44 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1180
1231
|
}]
|
|
1181
1232
|
}
|
|
1182
1233
|
});
|
|
1183
|
-
|
|
1234
|
+
/**
|
|
1235
|
+
* @license
|
|
1236
|
+
*
|
|
1237
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1238
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
1239
|
+
*/
|
|
1240
|
+
function wrUseTextTooltip(position = "top") {
|
|
1241
|
+
const host = inject(ElementRef);
|
|
1242
|
+
const overlay = inject(WR_OVERLAY);
|
|
1243
|
+
const dir = inject(Directionality, { optional: true });
|
|
1244
|
+
const scrollStrategies = inject(ScrollStrategyOptions);
|
|
1245
|
+
const injector = inject(Injector);
|
|
1246
|
+
const paneClass = "wr-tooltip-overlay";
|
|
1247
|
+
let overlayRef = null;
|
|
1248
|
+
const hide = () => {
|
|
1249
|
+
overlayRef?.dispose();
|
|
1250
|
+
overlayRef = null;
|
|
1251
|
+
};
|
|
1252
|
+
inject(DestroyRef).onDestroy(hide);
|
|
1253
|
+
return {
|
|
1254
|
+
show(text) {
|
|
1255
|
+
hide();
|
|
1256
|
+
const positions = (rtl) => wrMirrorOffsets(wrPopoverPositions(position, paneClass), rtl);
|
|
1257
|
+
const connected = overlay.position().flexibleConnectedTo(host).withPositions(positions(dir?.value === "rtl")).withPush(true).withViewportMargin(8);
|
|
1258
|
+
overlayRef = overlay.create({
|
|
1259
|
+
positionStrategy: connected,
|
|
1260
|
+
scrollStrategy: scrollStrategies.reposition(),
|
|
1261
|
+
panelClass: paneClass
|
|
1262
|
+
});
|
|
1263
|
+
wrFollowDirection(overlayRef, dir, injector, (direction) => connected.withPositions(positions(direction === "rtl")));
|
|
1264
|
+
const panel = overlayRef.attach(new ComponentPortal(WrPopoverTextPanel, null, injector));
|
|
1265
|
+
panel.setInput("text", text);
|
|
1266
|
+
panel.changeDetectorRef.detectChanges();
|
|
1267
|
+
overlayRef.overlayElement.setAttribute("role", "tooltip");
|
|
1268
|
+
},
|
|
1269
|
+
hide
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
export { WrPopover, useChartTooltip, wrUseTextTooltip };
|
|
1184
1273
|
|
|
1185
1274
|
//# sourceMappingURL=ngwr-popover.mjs.map
|