ngwr 16.6.0 → 16.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/avatar/styles/_index.scss +39 -0
- package/button/styles/_index.scss +45 -2
- package/checkbox/styles/_index.scss +4 -0
- package/copy-value/styles/_index.scss +4 -0
- package/dropdown/styles/_index.scss +17 -0
- package/fesm2022/ngwr-affix.mjs +3 -3
- package/fesm2022/ngwr-alert.mjs +3 -3
- package/fesm2022/ngwr-anchor.mjs +3 -3
- package/fesm2022/ngwr-animations-aurora.mjs +3 -3
- package/fesm2022/ngwr-animations-blur-reveal.mjs +3 -3
- package/fesm2022/ngwr-animations-click-sparks.mjs +3 -3
- package/fesm2022/ngwr-animations-confetti.mjs +3 -3
- package/fesm2022/ngwr-animations-decode.mjs +3 -3
- package/fesm2022/ngwr-animations-destruct.mjs +3 -3
- package/fesm2022/ngwr-animations-dot-grid.mjs +3 -3
- package/fesm2022/ngwr-animations-falling-letters.mjs +3 -3
- package/fesm2022/ngwr-animations-flow-lines.mjs +3 -3
- package/fesm2022/ngwr-animations-fluid-cursor.mjs +3 -3
- package/fesm2022/ngwr-animations-glitch.mjs +3 -3
- package/fesm2022/ngwr-animations-glow-border.mjs +3 -3
- package/fesm2022/ngwr-animations-gradient-flow.mjs +3 -3
- package/fesm2022/ngwr-animations-marquee.mjs +4 -3
- package/fesm2022/ngwr-animations-marquee.mjs.map +1 -1
- package/fesm2022/ngwr-animations-orbit.mjs +3 -3
- package/fesm2022/ngwr-animations-reveal.mjs +3 -3
- package/fesm2022/ngwr-animations-ripple-grid.mjs +3 -3
- package/fesm2022/ngwr-animations-rotate-reveal.mjs +3 -3
- package/fesm2022/ngwr-animations-shimmer.mjs +3 -3
- package/fesm2022/ngwr-animations-spotlight.mjs +3 -3
- package/fesm2022/ngwr-animations-thread-lines.mjs +3 -3
- package/fesm2022/ngwr-animations-tilt.mjs +3 -3
- package/fesm2022/ngwr-animations-typewriter.mjs +3 -3
- package/fesm2022/ngwr-avatar.mjs +171 -6
- package/fesm2022/ngwr-avatar.mjs.map +1 -1
- package/fesm2022/ngwr-back-top.mjs +3 -3
- package/fesm2022/ngwr-badge.mjs +6 -6
- package/fesm2022/ngwr-breadcrumbs.mjs +9 -8
- package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
- package/fesm2022/ngwr-burger.mjs +3 -3
- package/fesm2022/ngwr-button.mjs +26 -6
- package/fesm2022/ngwr-button.mjs.map +1 -1
- package/fesm2022/ngwr-calendar.mjs +3 -3
- package/fesm2022/ngwr-card.mjs +9 -9
- package/fesm2022/ngwr-carousel.mjs +6 -6
- package/fesm2022/ngwr-cascader.mjs +5 -5
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-boxplot-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-bullet-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +3 -3
- package/fesm2022/ngwr-charts-candlestick-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-chart-legend.mjs +9 -9
- package/fesm2022/ngwr-charts-core.mjs +6 -6
- package/fesm2022/ngwr-charts-donut-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-funnel-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-gauge.mjs +3 -3
- package/fesm2022/ngwr-charts-heatmap-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-line-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-meter-group.mjs +3 -3
- package/fesm2022/ngwr-charts-radar-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-scatter-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-sparkline.mjs +3 -3
- package/fesm2022/ngwr-charts-treemap-chart.mjs +3 -3
- package/fesm2022/ngwr-charts-waterfall-chart.mjs +3 -3
- package/fesm2022/ngwr-checkbox.mjs +6 -6
- package/fesm2022/ngwr-clipboard.mjs +3 -3
- package/fesm2022/ngwr-collapse.mjs +9 -9
- package/fesm2022/ngwr-color-picker.mjs +6 -6
- package/fesm2022/ngwr-command-palette.mjs +3 -3
- package/fesm2022/ngwr-comment.mjs +7 -6
- package/fesm2022/ngwr-comment.mjs.map +1 -1
- package/fesm2022/ngwr-compare.mjs +3 -3
- package/fesm2022/ngwr-context-menu.mjs +12 -12
- package/fesm2022/ngwr-cookie.mjs +3 -3
- package/fesm2022/ngwr-copy-value.mjs +3 -3
- package/fesm2022/ngwr-counter.mjs +6 -6
- package/fesm2022/ngwr-date-picker-testing.mjs +35 -0
- package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +103 -53
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-date-stamp.mjs +3 -3
- package/fesm2022/ngwr-date.mjs +40 -16
- package/fesm2022/ngwr-date.mjs.map +1 -1
- package/fesm2022/ngwr-density.mjs +6 -6
- package/fesm2022/ngwr-descriptions.mjs +6 -6
- package/fesm2022/ngwr-dialog.mjs +19 -18
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +181 -18
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-divider.mjs +3 -3
- package/fesm2022/ngwr-drawer.mjs +18 -18
- package/fesm2022/ngwr-dropdown-testing.mjs +5 -1
- package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +59 -16
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +6 -5
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-empty.mjs +3 -3
- package/fesm2022/ngwr-event-calendar.mjs +7 -6
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload-testing.mjs +5 -0
- package/fesm2022/ngwr-file-upload-testing.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload.mjs +68 -13
- package/fesm2022/ngwr-file-upload.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs +18 -16
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-graph-testing.mjs +30 -0
- package/fesm2022/ngwr-graph-testing.mjs.map +1 -1
- package/fesm2022/ngwr-graph.mjs +100 -11
- package/fesm2022/ngwr-graph.mjs.map +1 -1
- package/fesm2022/ngwr-hotkey.mjs +6 -6
- package/fesm2022/ngwr-i18n-ar.mjs +6 -2
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +6 -2
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +6 -2
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +6 -2
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +6 -2
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +6 -2
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +6 -2
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +6 -2
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +6 -2
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +6 -2
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +6 -2
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-kk.mjs +520 -0
- package/fesm2022/ngwr-i18n-kk.mjs.map +1 -0
- package/fesm2022/ngwr-i18n-ko.mjs +6 -2
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +6 -2
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +6 -2
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +6 -2
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +6 -2
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +6 -2
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +6 -2
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +6 -2
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +6 -2
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +6 -2
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +6 -2
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +9 -9
- package/fesm2022/ngwr-icon.mjs +6 -6
- package/fesm2022/ngwr-image-cropper.mjs +8 -4
- package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +3 -3
- package/fesm2022/ngwr-input-otp.mjs +3 -3
- package/fesm2022/ngwr-input.mjs +15 -15
- package/fesm2022/ngwr-keyboard.mjs +3 -3
- package/fesm2022/ngwr-knob.mjs +3 -3
- package/fesm2022/ngwr-layout.mjs +15 -15
- package/fesm2022/ngwr-lightbox.mjs +8 -8
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +8 -8
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-load-state.mjs +16 -15
- package/fesm2022/ngwr-load-state.mjs.map +1 -1
- package/fesm2022/ngwr-loading-bar.mjs +6 -6
- package/fesm2022/ngwr-mention.mjs +6 -6
- package/fesm2022/ngwr-meta.mjs +6 -6
- package/fesm2022/ngwr-overlay.mjs +9 -9
- package/fesm2022/ngwr-page-header.mjs +3 -3
- package/fesm2022/ngwr-pagination-testing.mjs +3 -0
- package/fesm2022/ngwr-pagination-testing.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +32 -5
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +27 -27
- package/fesm2022/ngwr-platform.mjs +9 -9
- package/fesm2022/ngwr-popconfirm.mjs +7 -6
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +126 -16
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-progress.mjs +75 -10
- package/fesm2022/ngwr-progress.mjs.map +1 -1
- package/fesm2022/ngwr-pull-to-refresh.mjs +3 -3
- package/fesm2022/ngwr-qr.mjs +3 -3
- package/fesm2022/ngwr-radio.mjs +6 -6
- package/fesm2022/ngwr-rating.mjs +3 -3
- package/fesm2022/ngwr-resizable.mjs +3 -3
- package/fesm2022/ngwr-result.mjs +12 -12
- package/fesm2022/ngwr-schema-form.mjs +10 -6
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-scroll.mjs +255 -7
- package/fesm2022/ngwr-scroll.mjs.map +1 -1
- package/fesm2022/ngwr-segmented.mjs +3 -3
- package/fesm2022/ngwr-select.mjs +28 -19
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-sidebar-testing.mjs +17 -1
- package/fesm2022/ngwr-sidebar-testing.mjs.map +1 -1
- package/fesm2022/ngwr-sidebar.mjs +66 -11
- package/fesm2022/ngwr-sidebar.mjs.map +1 -1
- package/fesm2022/ngwr-skeleton.mjs +3 -3
- package/fesm2022/ngwr-slider.mjs +3 -3
- package/fesm2022/ngwr-sortable-list.mjs +11 -11
- package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
- package/fesm2022/ngwr-speed-dial.mjs +3 -3
- package/fesm2022/ngwr-spinner.mjs +3 -3
- package/fesm2022/ngwr-splitter.mjs +3 -3
- package/fesm2022/ngwr-statistic.mjs +9 -9
- package/fesm2022/ngwr-stepper.mjs +6 -6
- package/fesm2022/ngwr-storage.mjs +3 -3
- package/fesm2022/ngwr-switch.mjs +3 -3
- package/fesm2022/ngwr-table-router.mjs +89 -0
- package/fesm2022/ngwr-table-router.mjs.map +1 -0
- package/fesm2022/ngwr-table-testing.mjs +5 -0
- package/fesm2022/ngwr-table-testing.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +282 -43
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-tabs-router.mjs +11 -7
- package/fesm2022/ngwr-tabs-router.mjs.map +1 -1
- package/fesm2022/ngwr-tabs-testing.mjs +8 -1
- package/fesm2022/ngwr-tabs-testing.mjs.map +1 -1
- package/fesm2022/ngwr-tabs.mjs +60 -10
- package/fesm2022/ngwr-tabs.mjs.map +1 -1
- package/fesm2022/ngwr-textarea.mjs +3 -3
- package/fesm2022/ngwr-theme.mjs +3 -3
- package/fesm2022/ngwr-timeline.mjs +6 -6
- package/fesm2022/ngwr-toast.mjs +15 -15
- package/fesm2022/ngwr-toolbar.mjs +3 -3
- package/fesm2022/ngwr-tour.mjs +7 -6
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-transfer.mjs +4 -3
- package/fesm2022/ngwr-transfer.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +3 -3
- package/fesm2022/ngwr-typography.mjs +3 -3
- package/fesm2022/ngwr-utils-router.mjs +3 -3
- package/fesm2022/ngwr-utils.mjs +30 -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-virtual-scroll.mjs +3 -3
- package/fesm2022/ngwr-window.mjs +18 -13
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/file-upload/styles/_index.scss +16 -0
- package/graph/styles/_index.scss +48 -0
- package/i18n/ar.json +4 -2
- package/i18n/cs.json +4 -2
- package/i18n/de.json +4 -2
- package/i18n/en.json +4 -2
- package/i18n/es.json +4 -2
- package/i18n/fr.json +4 -2
- package/i18n/he.json +4 -2
- package/i18n/hi.json +4 -2
- package/i18n/id.json +4 -2
- package/i18n/it.json +4 -2
- package/i18n/ja.json +4 -2
- package/i18n/kk.json +567 -0
- package/i18n/ko.json +4 -2
- package/i18n/nl.json +4 -2
- package/i18n/pl.json +4 -2
- package/i18n/pt.json +4 -2
- package/i18n/ru.json +4 -2
- package/i18n/sv.json +4 -2
- package/i18n/tr.json +4 -2
- package/i18n/uk.json +4 -2
- package/i18n/vi.json +4 -2
- package/i18n/zh-TW.json +4 -2
- package/i18n/zh.json +4 -2
- package/llms-full.txt +29 -18
- package/llms.txt +4 -1
- package/package.json +15 -7
- package/pagination/styles/_index.scss +6 -0
- package/popover/styles/_index.scss +4 -2
- package/progress/styles/_index.scss +64 -0
- package/radio/styles/_index.scss +4 -0
- package/schematics/use/symbol-map.json +5 -0
- package/sidebar/styles/_index.scss +58 -6
- package/skills/ngwr/SKILL.md +7 -6
- package/skills/ngwr/references/catalog.md +6 -4
- package/switch/styles/_index.scss +4 -0
- package/table/styles/_index.scss +128 -32
- package/tabs/styles/_index.scss +9 -0
- package/theme/styles/_focus.scss +3 -1
- package/tour/styles/_index.scss +3 -2
- package/types/ngwr-avatar.d.ts +39 -0
- package/types/ngwr-button.d.ts +12 -0
- package/types/ngwr-date-picker-testing.d.ts +22 -0
- package/types/ngwr-date-picker.d.ts +84 -17
- package/types/ngwr-date.d.ts +51 -0
- package/types/ngwr-directives.d.ts +45 -0
- package/types/ngwr-dropdown-testing.d.ts +8 -1
- package/types/ngwr-dropdown.d.ts +29 -0
- package/types/ngwr-file-upload-testing.d.ts +10 -0
- package/types/ngwr-file-upload.d.ts +55 -1
- package/types/ngwr-form.d.ts +3 -1
- package/types/ngwr-graph-testing.d.ts +28 -1
- package/types/ngwr-graph.d.ts +53 -3
- package/types/ngwr-i18n-kk.d.ts +3 -0
- package/types/ngwr-image-cropper.d.ts +6 -0
- package/types/ngwr-pagination-testing.d.ts +8 -0
- package/types/ngwr-pagination.d.ts +16 -0
- package/types/ngwr-popover.d.ts +39 -0
- package/types/ngwr-progress.d.ts +63 -1
- package/types/ngwr-scroll.d.ts +95 -0
- package/types/ngwr-select.d.ts +31 -12
- package/types/ngwr-sidebar-testing.d.ts +21 -7
- package/types/ngwr-sidebar.d.ts +66 -4
- package/types/ngwr-table-router.d.ts +49 -0
- package/types/ngwr-table-testing.d.ts +7 -0
- package/types/ngwr-table.d.ts +185 -6
- package/types/ngwr-tabs-router.d.ts +4 -5
- package/types/ngwr-tabs-testing.d.ts +5 -1
- package/types/ngwr-tabs.d.ts +34 -1
- package/types/ngwr-utils.d.ts +13 -0
- package/types/ngwr-version.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-file-upload-testing.mjs","names":[],"sources":["../../../projects/lib/file-upload/testing/wr-file-upload-harness.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, type EventData, HarnessPredicate, type TestElement } from '@angular/cdk/testing';\n\nimport type { WrFileUploadSize, WrFileUploadState } from 'ngwr/file-upload';\n\nimport type { WrFileUploadHarnessFilters } from './types';\n\n/**\n * A `DataTransfer` carrying `files`.\n *\n * `FileList` has no constructor anywhere — a browser mints one only as a side\n * effect of `new DataTransfer()`, and jsdom ships neither (`new FileList()` is an\n * illegal constructor there, and the `files` IDL setter refuses anything that is\n * not the genuine article). So: the real thing where it can be had, and an\n * array-like stand-in otherwise, which is all the component ever reads — it does\n * `Array.from(files)` and nothing else.\n */\nfunction dataTransferFor(files: readonly File[]): DataTransfer {\n const Transfer = (globalThis as { DataTransfer?: new () => DataTransfer }).DataTransfer;\n\n if (Transfer) {\n try {\n const transfer = new Transfer();\n for (const file of files) transfer.items.add(file);\n return transfer;\n } catch {\n // A DataTransfer that cannot take items is no use — fall through.\n }\n }\n\n const list: Record<PropertyKey, unknown> = { ...files };\n list['length'] = files.length;\n list['item'] = (index: number): File | null => files[index] ?? null;\n list[Symbol.iterator] = function* (): Generator<File> {\n yield* files;\n };\n\n return {\n dropEffect: 'none',\n effectAllowed: 'all',\n files: list,\n items: [],\n types: files.length > 0 ? ['Files'] : [],\n } as unknown as DataTransfer;\n}\n\n/**\n * The payload `TestElement.dispatchEvent` merges onto the event it fires.\n *\n * One transfer is shared by every event of a drag, the way a real one is: the\n * component writes `dropEffect` on it during `dragover` and reads `files` back\n * out on `drop`.\n */\nfunction dragPayload(transfer: DataTransfer): Record<string, EventData> {\n return { dataTransfer: transfer } as unknown as Record<string, EventData>;\n}\n\n/** The native element behind a `TestElement`, or `null` when there is no DOM to reach. */\nfunction nativeElement(element: TestElement): Element | null {\n const candidate = (element as Partial<{ element: unknown }>).element;\n return typeof Element !== 'undefined' && candidate instanceof Element ? candidate : null;\n}\n\nfunction isFileInput(element: Element | null): element is HTMLInputElement {\n return element !== null && element.tagName === 'INPUT' && (element as HTMLInputElement).type === 'file';\n}\n\n/** Put `files` on the picker, whichever way this environment allows. */\nfunction setPickerFiles(input: HTMLInputElement, files: readonly File[]): void {\n const list = dataTransferFor(files).files;\n\n try {\n input.files = list;\n if (input.files?.length === files.length) return;\n } catch {\n // jsdom's IDL setter refuses a stand-in FileList. Shadow the accessor instead.\n }\n\n // An own data property wins over the prototype accessor, so the component still\n // reads its files off the REAL input — which matters, because the alternative\n // (forging `event.target`) would let a harness pass on a component that never\n // touches the element the user operated.\n Object.defineProperty(input, 'files', { configurable: true, value: list });\n}\n\n/**\n * Test harness for `<wr-file-upload>`.\n *\n * The control a user operates is the `.wr-file-upload__zone` — a `role=\"button\"`\n * div that is the single tab stop; the `<input type=\"file\">` behind it is\n * `aria-hidden` and `tabindex=\"-1\"`, and exists only so a click can be forwarded\n * to it. So focus, drag and disabled state are all read off the zone, plus the\n * `wr-file-upload--*` host modifiers and the rendered file list. The picker is\n * touched only where it is the one that carries the state — `accept` and\n * `multiple` land on it, and {@link selectFiles} has to hand it the files.\n *\n * What this component does NOT have, so this harness does not either:\n * - **no upload.** `<wr-file-upload>` picks files and uploading them is the app's\n * job. What the app says through `[status]` is readable, per file, with\n * {@link getFileStatus}; the percent is on the row's `wr-progress`.\n * - **no thumbnail pixels.** {@link hasPreview} says a thumbnail is in the row.\n * jsdom decodes no image, so whether it shows the file cannot be read.\n * - **no rendered error.** A file refused for its type, its size or the file count\n * leaves NOTHING in the DOM — no `aria-invalid`, no message, and a list that\n * simply did not grow. The `(rejected)` output is the only channel, so a spec\n * asserts on the host's handler. See {@link selectFiles}.\n * - **no `maxSize` / `maxFiles` readback.** Neither reaches the DOM (unlike\n * `accept` and `multiple`, which land on the picker), so they can only be\n * observed by offering a file that breaks them.\n *\n * Two traps worth knowing before writing assertions. The bound value's SHAPE\n * follows `multiple` — a bare `File` (or `null`) in single mode, a `File[]` in\n * multi — and `[showList]=\"false\"` renders no list at all, so {@link getFileNames}\n * answers `[]` for a component that is holding files. Assert the bound value in\n * that case.\n *\n * @example\n * ```ts\n * const upload = await loader.getHarness(WrFileUploadHarness.with({ label: 'Avatar' }));\n * await upload.selectFiles(new File(['…'], 'me.png', { type: 'image/png' }));\n *\n * expect(await upload.getFileNames()).toEqual(['me.png']);\n * await upload.removeFileNamed('me.png');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrFileUploadHarness extends ComponentHarness {\n static hostSelector = 'wr-file-upload';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrFileUploadHarnessFilters = {}): HarnessPredicate<WrFileUploadHarness> {\n return new HarnessPredicate(WrFileUploadHarness, options)\n .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))\n .addOption('multiple', options.multiple, async (harness, multiple) => (await harness.isMultiple()) === multiple)\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled);\n }\n\n private readonly zone = this.locatorFor('.wr-file-upload__zone');\n private readonly picker = this.locatorFor('input.wr-file-upload__picker');\n private readonly items = this.locatorForAll('.wr-file-upload__item');\n private readonly names = this.locatorForAll('.wr-file-upload__name');\n private readonly sizes = this.locatorForAll('.wr-file-upload__size');\n private readonly removeButtons = this.locatorForAll('.wr-file-upload__remove');\n\n /**\n * The accessible name of the trigger — what a screen-reader user is told this\n * control is.\n *\n * The `dropZoneLabel` override when one is set, read off `aria-label`. Otherwise\n * the text of what `aria-labelledby` points at, in order: the field's label\n * inside a `<wr-form-field>`, then the zone's visible copy. Resolved through the\n * ids rather than read off the zone's own text, because the field's label sits\n * outside the zone.\n */\n async getLabel(): Promise<string> {\n const zone = await this.zone();\n const override = await zone.getAttribute('aria-label');\n if (override) return override;\n\n const ids = ((await zone.getAttribute('aria-labelledby')) ?? '').split(/\\s+/).filter(Boolean);\n const root = this.documentRootLocatorFactory();\n const parts = await Promise.all(ids.map(async id => (await root.locatorForOptional(`[id=\"${id}\"]`)())?.text()));\n return parts\n .filter((part): part is string => !!part)\n .join(' ')\n .replace(/\\s+/g, ' ')\n .trim();\n }\n\n /** The visible call-to-action line — the `pickLabel` input. */\n async getPickText(): Promise<string> {\n return (await this.locatorFor('.wr-file-upload__hint strong')()).text();\n }\n\n /** The visible instruction below the CTA — the `dropLabel` input. */\n async getDropText(): Promise<string> {\n return (await this.locatorFor('.wr-file-upload__hint span')()).text();\n }\n\n /** The optional `helperText` line, or `null` when the component was given none. */\n async getHelperText(): Promise<string | null> {\n const helper = await this.locatorForOptional('.wr-file-upload__hint small')();\n return helper === null ? null : helper.text();\n }\n\n /** The `accept` list the picker advertises, or `null` when it accepts anything. */\n async getAccept(): Promise<string | null> {\n return (await this.picker()).getAttribute('accept');\n }\n\n /**\n * Whether more than one file can be held.\n *\n * Read as the DOM PROPERTY: the template writes the attribute as an empty string\n * (`[attr.multiple]=\"multiple() ? '' : null\"`), and `''` is falsy — an attribute\n * read would report a multi-file upload as single.\n */\n async isMultiple(): Promise<boolean> {\n return (await this.picker()).getProperty<boolean>('multiple');\n }\n\n /** The control size. `'md'` is the default and paints no modifier of its own. */\n async getSize(): Promise<WrFileUploadSize> {\n const host = await this.host();\n if (await host.hasClass('wr-file-upload--sm')) return 'sm';\n if (await host.hasClass('wr-file-upload--lg')) return 'lg';\n return 'md';\n }\n\n /**\n * Whether the control refuses interaction.\n *\n * Read from the zone's `aria-disabled`. The host also carries\n * `wr-file-upload--disabled` and the picker its own `disabled`, but the zone is\n * a `role=\"button\"` div — `aria-disabled` is the only one of the three that\n * tells a screen-reader user the trigger is inert.\n */\n async isDisabled(): Promise<boolean> {\n return (await (await this.zone()).getAttribute('aria-disabled')) === 'true';\n }\n\n /**\n * Whether the zone is armed for a drop.\n *\n * The `wr-file-upload--dragging` host modifier is the whole signal — a drop\n * target has no ARIA state, so there is nothing better to read here.\n */\n async isDragging(): Promise<boolean> {\n return (await this.host()).hasClass('wr-file-upload--dragging');\n }\n\n /** How many files the list is RENDERING. Zero with `[showList]=\"false\"`, always. */\n async getFileCount(): Promise<number> {\n return (await this.items()).length;\n }\n\n /** The file names in the rendered list, in order. */\n async getFileNames(): Promise<string[]> {\n const names = await this.names();\n return Promise.all(names.map(name => name.text()));\n }\n\n /**\n * The file sizes in the rendered list, as SHOWN — `'4.9 KB'`, not `5000`.\n *\n * The component formats bytes for display and the byte count never reaches the\n * DOM, so this is the string a user reads. Assert the `File` itself if the exact\n * size matters.\n */\n async getFileSizes(): Promise<string[]> {\n const sizes = await this.sizes();\n return Promise.all(sizes.map(size => size.text()));\n }\n\n /**\n * Hand files to the picker, the way choosing them in the browser dialog does.\n *\n * This is the one method that reaches past `TestElement` to the native\n * `<input type=\"file\">`, and it has to: `TestElement` has no file API, and it\n * cannot grow one portably, because a `FileList` is not constructible and a\n * remote WebDriver session cannot be handed a `File` object at all. Everything\n * else on this harness is environment-agnostic; this needs a DOM behind it\n * (`TestbedHarnessEnvironment`), and says so with an error when it does not have\n * one. The input is found through this harness's own locator rather than a\n * `document` query, so it is still THIS component's picker that gets the files.\n *\n * Rejected files are silent: nothing appears in the DOM, so pair this with the\n * host's `(rejected)` handler when a file is meant to be refused. In single mode\n * the LAST accepted file wins, which is also how a drop of several files onto a\n * single-file zone behaves.\n *\n * @throws if called with no files, on a disabled upload, or outside a DOM\n * environment.\n */\n async selectFiles(...files: File[]): Promise<void> {\n if (files.length === 0) {\n throw new Error(\n 'WrFileUploadHarness.selectFiles(): pass at least one file. Cancelling the browser dialog fires no ' +\n '`change` at all, so \"picked nothing\" is not a state a user can put the component in.'\n );\n }\n\n if (await this.isDisabled()) {\n // The component guards its drop handler but not its `change` handler — it\n // does not need to, since a disabled `<input type=\"file\">` cannot be\n // operated. Forcing the event through anyway would smuggle a file past the\n // disabled state and leave a consumer's spec proving something no user can do.\n throw new Error(\n 'WrFileUploadHarness.selectFiles(): the upload is disabled, and a disabled picker cannot be opened. ' +\n 'Enable it first, or use dropFiles() to assert that a disabled zone refuses what is dropped on it.'\n );\n }\n\n const picker = await this.picker();\n const input = nativeElement(picker);\n\n if (!isFileInput(input)) {\n throw new Error(\n 'WrFileUploadHarness.selectFiles(): no DOM element behind the harness. Files can only be handed to a ' +\n 'real <input type=\"file\">, so this method needs TestbedHarnessEnvironment; a remote WebDriver ' +\n 'environment cannot carry a File across. Every other method on this harness works in both.'\n );\n }\n\n setPickerFiles(input, files);\n await picker.dispatchEvent('change');\n }\n\n /**\n * Drag files over the zone and drop them.\n *\n * Driven by dispatching the drag sequence AT the zone rather than by coordinates:\n * nothing has layout in a unit test — `getBoundingClientRect` is all zeros — so a\n * pointer-driven drag would land nowhere. From the component's side it is the\n * same event either way; it reads `dataTransfer.files` and never a position.\n *\n * A disabled upload refuses the drop itself, so this stays a no-op there rather\n * than throwing the way {@link selectFiles} does — that refusal is the\n * component's own, and worth asserting.\n */\n async dropFiles(...files: File[]): Promise<void> {\n const zone = await this.zone();\n const payload = dragPayload(dataTransferFor(files));\n\n await zone.dispatchEvent('dragenter', payload);\n await zone.dispatchEvent('dragover', payload);\n await zone.dispatchEvent('drop', payload);\n }\n\n /** Drag over the zone without letting go — arms {@link isDragging}. */\n async dragOver(): Promise<void> {\n const zone = await this.zone();\n const payload = dragPayload(dataTransferFor([]));\n\n await zone.dispatchEvent('dragenter', payload);\n await zone.dispatchEvent('dragover', payload);\n }\n\n /**\n * Drag back out of the zone, disarming {@link isDragging}.\n *\n * Dispatched at the zone itself on purpose: the component ignores a `dragleave`\n * whose target is one of the zone's children, because crossing the icon or the\n * hint text is not leaving the zone.\n */\n async dragLeave(): Promise<void> {\n await (await this.zone()).dispatchEvent('dragleave');\n }\n\n /**\n * Remove the file at `index` from the rendered list.\n *\n * On a disabled upload the remove buttons are disabled too, so this is a no-op\n * there — assert the result rather than assuming it.\n */\n async removeFile(index: number): Promise<void> {\n const buttons = await this.removeButtons();\n\n if (index < 0 || index >= buttons.length) {\n throw new Error(\n `WrFileUploadHarness.removeFile(${index}): the rendered list holds ${buttons.length} file(s). ` +\n 'With [showList]=\"false\" it holds none no matter what is selected.'\n );\n }\n\n await buttons[index].click();\n }\n\n /** Remove the file with this name. Names come from {@link getFileNames}. */\n async removeFileNamed(name: string): Promise<void> {\n await this.removeFile(await this.indexNamed('removeFileNamed', name));\n }\n\n /**\n * The upload state the app set for this file through `[status]`: `'pending'`,\n * `'uploading'`, `'done'` or `'error'`, or `null` for a file with no entry.\n *\n * Read off the row's `wr-file-upload__item--<state>` modifier, the one place\n * every state leaves a mark: `pending` draws no part of its own.\n */\n async getFileStatus(name: string): Promise<WrFileUploadState | null> {\n const row = await this.rowNamed('getFileStatus', name);\n for (const state of ['pending', 'uploading', 'done', 'error'] as const) {\n if (await row.hasClass(`wr-file-upload__item--${state}`)) return state;\n }\n return null;\n }\n\n /**\n * Press the retry button of this file's row, which emits `(retry)` with the file.\n *\n * @throws if the file is not in the `error` state: only a failed row has the button.\n */\n async retry(name: string): Promise<void> {\n const index = await this.indexNamed('retry', name);\n const button = await this.locatorForOptional(\n `.wr-file-upload__item:nth-child(${index + 1}) .wr-file-upload__retry`\n )();\n\n if (button === null) {\n throw new Error(\n `WrFileUploadHarness.retry(${JSON.stringify(name)}): the row has no retry button. Only a file whose ` +\n `status is 'error' has one; this one is ${JSON.stringify(await this.getFileStatus(name))}.`\n );\n }\n\n await button.click();\n }\n\n /**\n * Whether this file's row shows a thumbnail: `[previews]` is on and the file\n * is an image. jsdom has no `URL.createObjectURL`, so a spec that expects\n * `true` has to stub it.\n */\n async hasPreview(name: string): Promise<boolean> {\n const index = await this.indexNamed('hasPreview', name);\n const image = await this.locatorForOptional(\n `.wr-file-upload__item:nth-child(${index + 1}) img.wr-file-upload__preview`\n )();\n return image !== null;\n }\n\n /** Index of the row with this name, or a throw that says what the list holds. */\n private async indexNamed(method: string, name: string): Promise<number> {\n const names = await this.getFileNames();\n const index = names.indexOf(name);\n\n if (index === -1) {\n const holding = names.length > 0 ? names.map(n => JSON.stringify(n)).join(', ') : 'no files';\n throw new Error(`WrFileUploadHarness.${method}(${JSON.stringify(name)}): the rendered list holds ${holding}.`);\n }\n\n return index;\n }\n\n private async rowNamed(method: string, name: string): Promise<TestElement> {\n return (await this.items())[await this.indexNamed(method, name)];\n }\n\n /** Move keyboard focus to the zone — the control's only tab stop. */\n async focus(): Promise<void> {\n return (await this.zone()).focus();\n }\n\n /** Whether the zone has focus. */\n async isFocused(): Promise<boolean> {\n return (await this.zone()).isFocused();\n }\n}\n"],"mappings":";;;;;;;AAuBA,SAAS,gBAAgB,OAAsB;CAC7C,MAAM,WAAY,WAAyD;CAE3E,IAAI,UAC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AAI;EAItD,OAAO,MAHa,KAAK,mBACvB,mCAAmC,QAAQ,EAAC,8BAA+B,CAC5E,CAAA,MACgB;CACnB;CAGQ,MAAM,WAAW,QAAgB,MAAY;EACnD,MAAM,QAAQ,MAAM,KAAK,aAAY;EACrC,MAAM,QAAQ,MAAM,QAAQ,IAAI;EAEhC,IAAI,UAAU,IAAI;GAChB,MAAM,UAAU,MAAM,SAAS,IAAI,MAAM,KAAI,MAAK,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI;GAClF,MAAM,IAAI,MAAM,uBAAuB,OAAM,GAAI,KAAK,UAAU,IAAI,EAAC,6BAA8B,QAAO,EAAG;EAC/G;EAEA,OAAO;CACT;CAEQ,MAAM,SAAS,QAAgB,MAAY;EACjD,QAAQ,MAAM,KAAK,MAAK,EAAA,CAAI,MAAM,KAAK,WAAW,QAAQ,IAAI;CAChE;CAGA,MAAM,QAAK;EACT,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,MAAK;CAClC;CAGA,MAAM,YAAS;EACb,QAAQ,MAAM,KAAK,KAAI,EAAA,CAAI,UAAS;CACtC"}
|
|
1
|
+
{"version":3,"file":"ngwr-file-upload-testing.mjs","names":[],"sources":["../../../projects/lib/file-upload/testing/wr-file-upload-harness.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, type EventData, HarnessPredicate, type TestElement } from '@angular/cdk/testing';\n\nimport type { WrFileUploadSize, WrFileUploadState } from 'ngwr/file-upload';\n\nimport type { WrFileUploadHarnessFilters } from './types';\n\n/**\n * A `DataTransfer` carrying `files`.\n *\n * `FileList` has no constructor anywhere — a browser mints one only as a side\n * effect of `new DataTransfer()`, and jsdom ships neither (`new FileList()` is an\n * illegal constructor there, and the `files` IDL setter refuses anything that is\n * not the genuine article). So: the real thing where it can be had, and an\n * array-like stand-in otherwise, which is all the component ever reads — it does\n * `Array.from(files)` and nothing else.\n */\nfunction dataTransferFor(files: readonly File[]): DataTransfer {\n const Transfer = (globalThis as { DataTransfer?: new () => DataTransfer }).DataTransfer;\n\n if (Transfer) {\n try {\n const transfer = new Transfer();\n for (const file of files) transfer.items.add(file);\n return transfer;\n } catch {\n // A DataTransfer that cannot take items is no use — fall through.\n }\n }\n\n const list: Record<PropertyKey, unknown> = { ...files };\n list['length'] = files.length;\n list['item'] = (index: number): File | null => files[index] ?? null;\n list[Symbol.iterator] = function* (): Generator<File> {\n yield* files;\n };\n\n return {\n dropEffect: 'none',\n effectAllowed: 'all',\n files: list,\n items: [],\n types: files.length > 0 ? ['Files'] : [],\n } as unknown as DataTransfer;\n}\n\n/**\n * The payload `TestElement.dispatchEvent` merges onto the event it fires.\n *\n * One transfer is shared by every event of a drag, the way a real one is: the\n * component writes `dropEffect` on it during `dragover` and reads `files` back\n * out on `drop`.\n */\nfunction dragPayload(transfer: DataTransfer): Record<string, EventData> {\n return { dataTransfer: transfer } as unknown as Record<string, EventData>;\n}\n\n/** The native element behind a `TestElement`, or `null` when there is no DOM to reach. */\nfunction nativeElement(element: TestElement): Element | null {\n const candidate = (element as Partial<{ element: unknown }>).element;\n return typeof Element !== 'undefined' && candidate instanceof Element ? candidate : null;\n}\n\nfunction isFileInput(element: Element | null): element is HTMLInputElement {\n return element !== null && element.tagName === 'INPUT' && (element as HTMLInputElement).type === 'file';\n}\n\n/** Put `files` on the picker, whichever way this environment allows. */\nfunction setPickerFiles(input: HTMLInputElement, files: readonly File[]): void {\n const list = dataTransferFor(files).files;\n\n try {\n input.files = list;\n if (input.files?.length === files.length) return;\n } catch {\n // jsdom's IDL setter refuses a stand-in FileList. Shadow the accessor instead.\n }\n\n // An own data property wins over the prototype accessor, so the component still\n // reads its files off the REAL input — which matters, because the alternative\n // (forging `event.target`) would let a harness pass on a component that never\n // touches the element the user operated.\n Object.defineProperty(input, 'files', { configurable: true, value: list });\n}\n\n/**\n * Test harness for `<wr-file-upload>`.\n *\n * Stored files (`[stored]`) are rows like any other: they count in\n * {@link getFileCount}, {@link getFileNames} and {@link getFileSizes}, come first,\n * and {@link removeFile} / {@link removeFileNamed} press their remove button, which\n * emits `(storedRemove)` rather than changing the bound value.\n *\n * The control a user operates is the `.wr-file-upload__zone` — a `role=\"button\"`\n * div that is the single tab stop; the `<input type=\"file\">` behind it is\n * `aria-hidden` and `tabindex=\"-1\"`, and exists only so a click can be forwarded\n * to it. So focus, drag and disabled state are all read off the zone, plus the\n * `wr-file-upload--*` host modifiers and the rendered file list. The picker is\n * touched only where it is the one that carries the state — `accept` and\n * `multiple` land on it, and {@link selectFiles} has to hand it the files.\n *\n * What this component does NOT have, so this harness does not either:\n * - **no upload.** `<wr-file-upload>` picks files and uploading them is the app's\n * job. What the app says through `[status]` is readable, per file, with\n * {@link getFileStatus}; the percent is on the row's `wr-progress`.\n * - **no thumbnail pixels.** {@link hasPreview} says a thumbnail is in the row.\n * jsdom decodes no image, so whether it shows the file cannot be read.\n * - **no rendered error.** A file refused for its type, its size or the file count\n * leaves NOTHING in the DOM — no `aria-invalid`, no message, and a list that\n * simply did not grow. The `(rejected)` output is the only channel, so a spec\n * asserts on the host's handler. See {@link selectFiles}.\n * - **no `maxSize` / `maxFiles` readback.** Neither reaches the DOM (unlike\n * `accept` and `multiple`, which land on the picker), so they can only be\n * observed by offering a file that breaks them.\n *\n * Two traps worth knowing before writing assertions. The bound value's SHAPE\n * follows `multiple` — a bare `File` (or `null`) in single mode, a `File[]` in\n * multi — and `[showList]=\"false\"` renders no list at all, so {@link getFileNames}\n * answers `[]` for a component that is holding files. Assert the bound value in\n * that case.\n *\n * @example\n * ```ts\n * const upload = await loader.getHarness(WrFileUploadHarness.with({ label: 'Avatar' }));\n * await upload.selectFiles(new File(['…'], 'me.png', { type: 'image/png' }));\n *\n * expect(await upload.getFileNames()).toEqual(['me.png']);\n * await upload.removeFileNamed('me.png');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrFileUploadHarness extends ComponentHarness {\n static hostSelector = 'wr-file-upload';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrFileUploadHarnessFilters = {}): HarnessPredicate<WrFileUploadHarness> {\n return new HarnessPredicate(WrFileUploadHarness, options)\n .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabel(), label))\n .addOption('multiple', options.multiple, async (harness, multiple) => (await harness.isMultiple()) === multiple)\n .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) === disabled);\n }\n\n private readonly zone = this.locatorFor('.wr-file-upload__zone');\n private readonly picker = this.locatorFor('input.wr-file-upload__picker');\n private readonly items = this.locatorForAll('.wr-file-upload__item');\n private readonly names = this.locatorForAll('.wr-file-upload__name');\n private readonly sizes = this.locatorForAll('.wr-file-upload__size');\n private readonly removeButtons = this.locatorForAll('.wr-file-upload__remove');\n\n /**\n * The accessible name of the trigger — what a screen-reader user is told this\n * control is.\n *\n * The `dropZoneLabel` override when one is set, read off `aria-label`. Otherwise\n * the text of what `aria-labelledby` points at, in order: the field's label\n * inside a `<wr-form-field>`, then the zone's visible copy. Resolved through the\n * ids rather than read off the zone's own text, because the field's label sits\n * outside the zone.\n */\n async getLabel(): Promise<string> {\n const zone = await this.zone();\n const override = await zone.getAttribute('aria-label');\n if (override) return override;\n\n const ids = ((await zone.getAttribute('aria-labelledby')) ?? '').split(/\\s+/).filter(Boolean);\n const root = this.documentRootLocatorFactory();\n const parts = await Promise.all(ids.map(async id => (await root.locatorForOptional(`[id=\"${id}\"]`)())?.text()));\n return parts\n .filter((part): part is string => !!part)\n .join(' ')\n .replace(/\\s+/g, ' ')\n .trim();\n }\n\n /** The visible call-to-action line — the `pickLabel` input. */\n async getPickText(): Promise<string> {\n return (await this.locatorFor('.wr-file-upload__hint strong')()).text();\n }\n\n /** The visible instruction below the CTA — the `dropLabel` input. */\n async getDropText(): Promise<string> {\n return (await this.locatorFor('.wr-file-upload__hint span')()).text();\n }\n\n /** The optional `helperText` line, or `null` when the component was given none. */\n async getHelperText(): Promise<string | null> {\n const helper = await this.locatorForOptional('.wr-file-upload__hint small')();\n return helper === null ? null : helper.text();\n }\n\n /** The `accept` list the picker advertises, or `null` when it accepts anything. */\n async getAccept(): Promise<string | null> {\n return (await this.picker()).getAttribute('accept');\n }\n\n /**\n * Whether more than one file can be held.\n *\n * Read as the DOM PROPERTY: the template writes the attribute as an empty string\n * (`[attr.multiple]=\"multiple() ? '' : null\"`), and `''` is falsy — an attribute\n * read would report a multi-file upload as single.\n */\n async isMultiple(): Promise<boolean> {\n return (await this.picker()).getProperty<boolean>('multiple');\n }\n\n /** The control size. `'md'` is the default and paints no modifier of its own. */\n async getSize(): Promise<WrFileUploadSize> {\n const host = await this.host();\n if (await host.hasClass('wr-file-upload--sm')) return 'sm';\n if (await host.hasClass('wr-file-upload--lg')) return 'lg';\n return 'md';\n }\n\n /**\n * Whether the control refuses interaction.\n *\n * Read from the zone's `aria-disabled`. The host also carries\n * `wr-file-upload--disabled` and the picker its own `disabled`, but the zone is\n * a `role=\"button\"` div — `aria-disabled` is the only one of the three that\n * tells a screen-reader user the trigger is inert.\n */\n async isDisabled(): Promise<boolean> {\n return (await (await this.zone()).getAttribute('aria-disabled')) === 'true';\n }\n\n /**\n * Whether the zone is armed for a drop.\n *\n * The `wr-file-upload--dragging` host modifier is the whole signal — a drop\n * target has no ARIA state, so there is nothing better to read here.\n */\n async isDragging(): Promise<boolean> {\n return (await this.host()).hasClass('wr-file-upload--dragging');\n }\n\n /** How many files the list is RENDERING. Zero with `[showList]=\"false\"`, always. */\n async getFileCount(): Promise<number> {\n return (await this.items()).length;\n }\n\n /** The file names in the rendered list, in order. */\n async getFileNames(): Promise<string[]> {\n const names = await this.names();\n return Promise.all(names.map(name => name.text()));\n }\n\n /**\n * The file sizes in the rendered list, as SHOWN — `'4.9 KB'`, not `5000`.\n *\n * The component formats bytes for display and the byte count never reaches the\n * DOM, so this is the string a user reads. Assert the `File` itself if the exact\n * size matters.\n */\n async getFileSizes(): Promise<string[]> {\n const sizes = await this.sizes();\n return Promise.all(sizes.map(size => size.text()));\n }\n\n /**\n * Hand files to the picker, the way choosing them in the browser dialog does.\n *\n * This is the one method that reaches past `TestElement` to the native\n * `<input type=\"file\">`, and it has to: `TestElement` has no file API, and it\n * cannot grow one portably, because a `FileList` is not constructible and a\n * remote WebDriver session cannot be handed a `File` object at all. Everything\n * else on this harness is environment-agnostic; this needs a DOM behind it\n * (`TestbedHarnessEnvironment`), and says so with an error when it does not have\n * one. The input is found through this harness's own locator rather than a\n * `document` query, so it is still THIS component's picker that gets the files.\n *\n * Rejected files are silent: nothing appears in the DOM, so pair this with the\n * host's `(rejected)` handler when a file is meant to be refused. In single mode\n * the LAST accepted file wins, which is also how a drop of several files onto a\n * single-file zone behaves.\n *\n * @throws if called with no files, on a disabled upload, or outside a DOM\n * environment.\n */\n async selectFiles(...files: File[]): Promise<void> {\n if (files.length === 0) {\n throw new Error(\n 'WrFileUploadHarness.selectFiles(): pass at least one file. Cancelling the browser dialog fires no ' +\n '`change` at all, so \"picked nothing\" is not a state a user can put the component in.'\n );\n }\n\n if (await this.isDisabled()) {\n // The component guards its drop handler but not its `change` handler — it\n // does not need to, since a disabled `<input type=\"file\">` cannot be\n // operated. Forcing the event through anyway would smuggle a file past the\n // disabled state and leave a consumer's spec proving something no user can do.\n throw new Error(\n 'WrFileUploadHarness.selectFiles(): the upload is disabled, and a disabled picker cannot be opened. ' +\n 'Enable it first, or use dropFiles() to assert that a disabled zone refuses what is dropped on it.'\n );\n }\n\n const picker = await this.picker();\n const input = nativeElement(picker);\n\n if (!isFileInput(input)) {\n throw new Error(\n 'WrFileUploadHarness.selectFiles(): no DOM element behind the harness. Files can only be handed to a ' +\n 'real <input type=\"file\">, so this method needs TestbedHarnessEnvironment; a remote WebDriver ' +\n 'environment cannot carry a File across. Every other method on this harness works in both.'\n );\n }\n\n setPickerFiles(input, files);\n await picker.dispatchEvent('change');\n }\n\n /**\n * Drag files over the zone and drop them.\n *\n * Driven by dispatching the drag sequence AT the zone rather than by coordinates:\n * nothing has layout in a unit test — `getBoundingClientRect` is all zeros — so a\n * pointer-driven drag would land nowhere. From the component's side it is the\n * same event either way; it reads `dataTransfer.files` and never a position.\n *\n * A disabled upload refuses the drop itself, so this stays a no-op there rather\n * than throwing the way {@link selectFiles} does — that refusal is the\n * component's own, and worth asserting.\n */\n async dropFiles(...files: File[]): Promise<void> {\n const zone = await this.zone();\n const payload = dragPayload(dataTransferFor(files));\n\n await zone.dispatchEvent('dragenter', payload);\n await zone.dispatchEvent('dragover', payload);\n await zone.dispatchEvent('drop', payload);\n }\n\n /** Drag over the zone without letting go — arms {@link isDragging}. */\n async dragOver(): Promise<void> {\n const zone = await this.zone();\n const payload = dragPayload(dataTransferFor([]));\n\n await zone.dispatchEvent('dragenter', payload);\n await zone.dispatchEvent('dragover', payload);\n }\n\n /**\n * Drag back out of the zone, disarming {@link isDragging}.\n *\n * Dispatched at the zone itself on purpose: the component ignores a `dragleave`\n * whose target is one of the zone's children, because crossing the icon or the\n * hint text is not leaving the zone.\n */\n async dragLeave(): Promise<void> {\n await (await this.zone()).dispatchEvent('dragleave');\n }\n\n /**\n * Remove the file at `index` from the rendered list.\n *\n * On a disabled upload the remove buttons are disabled too, so this is a no-op\n * there — assert the result rather than assuming it.\n */\n async removeFile(index: number): Promise<void> {\n const buttons = await this.removeButtons();\n\n if (index < 0 || index >= buttons.length) {\n throw new Error(\n `WrFileUploadHarness.removeFile(${index}): the rendered list holds ${buttons.length} file(s). ` +\n 'With [showList]=\"false\" it holds none no matter what is selected.'\n );\n }\n\n await buttons[index].click();\n }\n\n /** Remove the file with this name. Names come from {@link getFileNames}. */\n async removeFileNamed(name: string): Promise<void> {\n await this.removeFile(await this.indexNamed('removeFileNamed', name));\n }\n\n /**\n * The upload state the app set for this file through `[status]`: `'pending'`,\n * `'uploading'`, `'done'` or `'error'`, or `null` for a file with no entry.\n *\n * Read off the row's `wr-file-upload__item--<state>` modifier, the one place\n * every state leaves a mark: `pending` draws no part of its own.\n */\n async getFileStatus(name: string): Promise<WrFileUploadState | null> {\n const row = await this.rowNamed('getFileStatus', name);\n for (const state of ['pending', 'uploading', 'done', 'error'] as const) {\n if (await row.hasClass(`wr-file-upload__item--${state}`)) return state;\n }\n return null;\n }\n\n /**\n * Press the retry button of this file's row, which emits `(retry)` with the file.\n *\n * @throws if the file is not in the `error` state: only a failed row has the button.\n */\n async retry(name: string): Promise<void> {\n const index = await this.indexNamed('retry', name);\n const button = await this.locatorForOptional(\n `.wr-file-upload__item:nth-child(${index + 1}) .wr-file-upload__retry`\n )();\n\n if (button === null) {\n throw new Error(\n `WrFileUploadHarness.retry(${JSON.stringify(name)}): the row has no retry button. Only a file whose ` +\n `status is 'error' has one; this one is ${JSON.stringify(await this.getFileStatus(name))}.`\n );\n }\n\n await button.click();\n }\n\n /**\n * Whether this file's row shows a thumbnail: `[previews]` is on and the file\n * is an image. jsdom has no `URL.createObjectURL`, so a spec that expects\n * `true` has to stub it.\n */\n async hasPreview(name: string): Promise<boolean> {\n const index = await this.indexNamed('hasPreview', name);\n const image = await this.locatorForOptional(\n `.wr-file-upload__item:nth-child(${index + 1}) img.wr-file-upload__preview`\n )();\n return image !== null;\n }\n\n /**\n * The `href` of this row's link, or `null` for a row whose name is plain text.\n * Only a stored file (`[stored]`) with a `url` has one.\n */\n async getLink(name: string): Promise<string | null> {\n const index = await this.indexNamed('getLink', name);\n const link = await this.locatorForOptional(\n `.wr-file-upload__item:nth-child(${index + 1}) a.wr-file-upload__link`\n )();\n return link === null ? null : link.getAttribute('href');\n }\n\n /** Index of the row with this name, or a throw that says what the list holds. */\n private async indexNamed(method: string, name: string): Promise<number> {\n const names = await this.getFileNames();\n const index = names.indexOf(name);\n\n if (index === -1) {\n const holding = names.length > 0 ? names.map(n => JSON.stringify(n)).join(', ') : 'no files';\n throw new Error(`WrFileUploadHarness.${method}(${JSON.stringify(name)}): the rendered list holds ${holding}.`);\n }\n\n return index;\n }\n\n private async rowNamed(method: string, name: string): Promise<TestElement> {\n return (await this.items())[await this.indexNamed(method, name)];\n }\n\n /** Move keyboard focus to the zone — the control's only tab stop. */\n async focus(): Promise<void> {\n return (await this.zone()).focus();\n }\n\n /** Whether the zone has focus. */\n async isFocused(): Promise<boolean> {\n return (await this.zone()).isFocused();\n }\n}\n"],"mappings":";;;;;;;AAuBA,SAAS,gBAAgB,OAAsB;CAC7C,MAAM,WAAY,WAAyD;CAE3E,IAAI,UACF,IAAI;EACF,MAAM,WAAW,IAAI,SAAQ;EAC7B,KAAK,MAAM,QAAQ,OAAO,SAAS,MAAM,IAAI,IAAI;EACjD,OAAO;CACT,QAAQ,CAER;CAGF,MAAM,OAAqC,EAAE,GAAG,MAAK;CACrD,KAAK,YAAY,MAAM;CACvB,KAAK,WAAW,UAA+B,MAAM,UAAU;CAC/D,KAAK,OAAO,YAAY,aAAS;EAC/B,OAAO;CACT;CAEA,OAAO;EACL,YAAY;EACZ,eAAe;EACf,OAAO;EACP,OAAO,CAAA;EACP,OAAO,MAAM,SAAS,IAAI,CAAC,OAAO,IAAI,CAAA;CACZ;AAC9B;AASA,SAAS,YAAY,UAAsB;CACzC,OAAO,EAAE,cAAc,SAAQ;AACjC;AAGA,SAAS,cAAc,SAAoB;CACzC,MAAM,YAAa,QAA0C;CAC7D,OAAO,OAAO,YAAY,eAAe,qBAAqB,UAAU,YAAY;AACtF;AAEA,SAAS,YAAY,SAAuB;CAC1C,OAAO,YAAY,QAAQ,QAAQ,YAAY,WAAY,QAA6B,SAAS;AACnG;AAGA,SAAS,eAAe,OAAyB,OAAsB;CACrE,MAAM,OAAO,gBAAgB,KAAK,CAAC,CAAC;CAEpC,IAAI;EACF,MAAM,QAAQ;EACd,IAAI,MAAM,OAAO,WAAW,MAAM,QAAQ;CAC5C,QAAQ,CAER;CAMA,OAAO,eAAe,OAAO,SAAS;EAAE,cAAc;EAAM,OAAO;CAAI,CAAE;AAC3E;AAi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tC"}
|
|
@@ -53,6 +53,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
53
53
|
transform: coerceBooleanProperty
|
|
54
54
|
});
|
|
55
55
|
status = input(null, ...ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []);
|
|
56
|
+
stored = input([], ...ngDevMode ? [{ debugName: "stored" }] : /* istanbul ignore next */ []);
|
|
56
57
|
previews = input(false, {
|
|
57
58
|
...ngDevMode ? { debugName: "previews" } : /* istanbul ignore next */ {},
|
|
58
59
|
transform: coerceBooleanProperty
|
|
@@ -83,6 +84,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
83
84
|
const given = this.removeFileLabel();
|
|
84
85
|
return given ? given.replace(/\{\{\s*name\s*\}\}/g, () => name) : this.removeText({ name });
|
|
85
86
|
}
|
|
87
|
+
openText = useI18nFormatter("fileUpload.openFile", "{{name}} (opens in a new tab)");
|
|
86
88
|
resolvedRetry = useI18nText(this.retryLabel, "fileUpload.retry", "Try again");
|
|
87
89
|
resolvedUploading = useI18nText(this.uploadingLabel, "fileUpload.uploading", "Uploading");
|
|
88
90
|
resolvedUploaded = useI18nText(this.uploadedLabel, "fileUpload.uploaded", "Uploaded");
|
|
@@ -91,6 +93,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
91
93
|
helperText = input("", ...ngDevMode ? [{ debugName: "helperText" }] : /* istanbul ignore next */ []);
|
|
92
94
|
value = model(null, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
93
95
|
rejected = output();
|
|
96
|
+
storedRemove = output();
|
|
94
97
|
retry = output();
|
|
95
98
|
touch = output();
|
|
96
99
|
picker = viewChild.required("picker", ...ngDevMode ? [{ debugName: "picker" }] : /* istanbul ignore next */ []);
|
|
@@ -120,6 +123,11 @@ var WrFileUpload = class WrFileUpload {
|
|
|
120
123
|
};
|
|
121
124
|
});
|
|
122
125
|
}, ...ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []);
|
|
126
|
+
storedRows = computed(() => this.stored().map((stored) => ({
|
|
127
|
+
stored,
|
|
128
|
+
url: stored.url ?? null,
|
|
129
|
+
size: typeof stored.size === "number" && Number.isFinite(stored.size) && stored.size >= 0 ? stored.size : null
|
|
130
|
+
})), ...ngDevMode ? [{ debugName: "storedRows" }] : /* istanbul ignore next */ []);
|
|
123
131
|
busy = computed(() => this.rows().some((row) => row.state === "uploading"), ...ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []);
|
|
124
132
|
announcement = signal("", ...ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []);
|
|
125
133
|
lastStates = null;
|
|
@@ -137,7 +145,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
137
145
|
value: this.number(0, 0),
|
|
138
146
|
unit: this.unitTexts[0]()
|
|
139
147
|
});
|
|
140
|
-
const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), this.unitTexts.length - 1);
|
|
148
|
+
const i = Math.max(0, Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), this.unitTexts.length - 1));
|
|
141
149
|
const v = bytes / 1024 ** i;
|
|
142
150
|
const digits = v >= 100 || i === 0 ? 0 : 1;
|
|
143
151
|
return this.sizeText({
|
|
@@ -162,6 +170,13 @@ var WrFileUpload = class WrFileUpload {
|
|
|
162
170
|
}
|
|
163
171
|
constructor() {
|
|
164
172
|
if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("file-upload");
|
|
173
|
+
effect(() => {
|
|
174
|
+
const stored = this.stored();
|
|
175
|
+
const pending = this.focusAfterStored;
|
|
176
|
+
if (!pending || stored.includes(pending.stored)) return;
|
|
177
|
+
this.focusAfterStored = null;
|
|
178
|
+
untracked(() => this.focusRemoveNear(() => pending.index, true));
|
|
179
|
+
});
|
|
165
180
|
effect(() => {
|
|
166
181
|
const v = this.value();
|
|
167
182
|
untracked(() => {
|
|
@@ -237,7 +252,28 @@ var WrFileUpload = class WrFileUpload {
|
|
|
237
252
|
if (!hadFocus) return;
|
|
238
253
|
afterNextRender(() => {
|
|
239
254
|
if (button?.isConnected) return;
|
|
240
|
-
this.host.nativeElement.querySelectorAll(".wr-file-upload__remove")[index]?.focus();
|
|
255
|
+
this.host.nativeElement.querySelectorAll(".wr-file-upload__remove")[this.stored().length + index]?.focus();
|
|
256
|
+
}, { injector: this.injector });
|
|
257
|
+
}
|
|
258
|
+
removeStored(row, index) {
|
|
259
|
+
if (this.disabled() || this.readonly()) return;
|
|
260
|
+
const focused = this.host.nativeElement.ownerDocument.activeElement;
|
|
261
|
+
const hadFocus = !!focused?.matches(".wr-file-upload__remove") && this.host.nativeElement.contains(focused);
|
|
262
|
+
this.focusAfterStored = hadFocus ? {
|
|
263
|
+
stored: row.stored,
|
|
264
|
+
index
|
|
265
|
+
} : null;
|
|
266
|
+
this.storedRemove.emit(row.stored);
|
|
267
|
+
}
|
|
268
|
+
focusAfterStored = null;
|
|
269
|
+
focusRemoveNear(at, onlyIfLost = false) {
|
|
270
|
+
afterNextRender(() => {
|
|
271
|
+
const doc = this.host.nativeElement.ownerDocument;
|
|
272
|
+
const active = doc.activeElement;
|
|
273
|
+
if (onlyIfLost && active && active !== doc.body) return;
|
|
274
|
+
const index = at();
|
|
275
|
+
const buttons = this.host.nativeElement.querySelectorAll(".wr-file-upload__remove");
|
|
276
|
+
(buttons[Math.min(index, buttons.length - 1)] ?? this.zone().nativeElement).focus();
|
|
241
277
|
}, { injector: this.injector });
|
|
242
278
|
}
|
|
243
279
|
removeAt(index) {
|
|
@@ -248,10 +284,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
248
284
|
this.files.set(next);
|
|
249
285
|
this.emit();
|
|
250
286
|
if (!hadFocus) return;
|
|
251
|
-
|
|
252
|
-
const buttons = this.host.nativeElement.querySelectorAll(".wr-file-upload__remove");
|
|
253
|
-
(buttons[Math.min(index, buttons.length - 1)] ?? this.zone().nativeElement).focus();
|
|
254
|
-
}, { injector: this.injector });
|
|
287
|
+
this.focusRemoveNear(() => this.stored().length + index);
|
|
255
288
|
}
|
|
256
289
|
acceptFiles(incoming) {
|
|
257
290
|
if (this.disabled() || this.readonly()) return;
|
|
@@ -271,7 +304,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
271
304
|
if (this.multiple()) {
|
|
272
305
|
const listed = this.files();
|
|
273
306
|
const maxFiles = this.maxFiles();
|
|
274
|
-
const room = maxFiles > 0 ? Math.max(0, maxFiles - listed.length) : accepted.length;
|
|
307
|
+
const room = maxFiles > 0 ? Math.max(0, maxFiles - listed.length - this.stored().length) : accepted.length;
|
|
275
308
|
for (const file of accepted.slice(room)) rejections.push({
|
|
276
309
|
file,
|
|
277
310
|
reason: "count"
|
|
@@ -327,7 +360,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
327
360
|
}
|
|
328
361
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
329
362
|
minVersion: "12.0.0",
|
|
330
|
-
version: "22.
|
|
363
|
+
version: "22.3.0",
|
|
331
364
|
ngImport: i0,
|
|
332
365
|
type: WrFileUpload,
|
|
333
366
|
deps: [],
|
|
@@ -335,7 +368,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
335
368
|
});
|
|
336
369
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
337
370
|
minVersion: "17.0.0",
|
|
338
|
-
version: "22.
|
|
371
|
+
version: "22.3.0",
|
|
339
372
|
type: WrFileUpload,
|
|
340
373
|
isStandalone: true,
|
|
341
374
|
selector: "wr-file-upload",
|
|
@@ -403,6 +436,13 @@ var WrFileUpload = class WrFileUpload {
|
|
|
403
436
|
isRequired: false,
|
|
404
437
|
transformFunction: null
|
|
405
438
|
},
|
|
439
|
+
stored: {
|
|
440
|
+
classPropertyName: "stored",
|
|
441
|
+
publicName: "stored",
|
|
442
|
+
isSignal: true,
|
|
443
|
+
isRequired: false,
|
|
444
|
+
transformFunction: null
|
|
445
|
+
},
|
|
406
446
|
previews: {
|
|
407
447
|
classPropertyName: "previews",
|
|
408
448
|
publicName: "previews",
|
|
@@ -491,6 +531,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
491
531
|
outputs: {
|
|
492
532
|
value: "valueChange",
|
|
493
533
|
rejected: "rejected",
|
|
534
|
+
storedRemove: "storedRemove",
|
|
494
535
|
retry: "retry",
|
|
495
536
|
touch: "touch"
|
|
496
537
|
},
|
|
@@ -512,7 +553,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
512
553
|
isSignal: true
|
|
513
554
|
}],
|
|
514
555
|
ngImport: i0,
|
|
515
|
-
template: "<div\n #zone\n class=\"wr-file-upload__zone\"\n role=\"button\"\n tabindex=\"0\"\n [attr.aria-label]=\"zoneName()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"openPicker()\"\n (keydown)=\"onZoneKey($event)\"\n (dragenter)=\"onDragEnter($event)\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave()\"\n (drop)=\"onDrop($event)\"\n (paste)=\"onPaste($event)\"\n>\n <svg class=\"wr-file-upload__icon\" width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M12 16V4M12 4l-4 4M12 4l4 4M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n <div class=\"wr-file-upload__hint\" [id]=\"hintId\">\n <strong>{{ resolvedPick() }}</strong>\n <span>{{ resolvedDrop() }}</span>\n @if (helperText()) {\n <small>{{ helperText() }}</small>\n }\n </div>\n</div>\n\n<!--\n The real <input type=\"file\"> is never operated directly — the zone above is\n the control and forwards clicks here, so the input is visually hidden and kept\n OUTSIDE the zone: inside, it nested one interactive element within another\n (the zone is role=\"button\") and put two tab stops where users see one. It is\n positioned absolutely and clipped, so being a sibling changes nothing visually.\n aria-hidden must be paired with tabindex=\"-1\", or hiding a focusable element is\n itself a violation.\n-->\n<input\n #picker\n class=\"wr-file-upload__picker\"\n type=\"file\"\n aria-hidden=\"true\"\n tabindex=\"-1\"\n [attr.accept]=\"accept() || null\"\n [attr.multiple]=\"multiple() ? '' : null\"\n [disabled]=\"disabled() || readonly()\"\n (change)=\"onPickerChange($event)\"\n/>\n\n@if (showList() && files().length > 0) {\n <ul class=\"wr-file-upload__list\" [attr.aria-busy]=\"busy() || null\">\n @for (row of rows(); track $index) {\n <li [class]=\"row.classes\">\n @if (row.preview; as url) {\n <img class=\"wr-file-upload__preview\" alt=\"\" [src]=\"url\" />\n }\n <span\n class=\"wr-file-upload__name\"\n [attr.id]=\"row.state === 'error' ? `${nameId}-${$index}` : null\"\n [title]=\"row.file.name\"\n >{{ row.file.name }}</span\n >\n <span class=\"wr-file-upload__size\">{{ formatBytes(row.file.size) }}</span>\n @switch (row.state) {\n @case ('done') {\n <span class=\"wr-file-upload__done\" role=\"img\" [attr.aria-label]=\"resolvedUploaded()\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M20 6 9 17l-5-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </span>\n }\n @case ('error') {\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-file-upload__retry\"\n [attr.aria-describedby]=\"`${nameId}-${$index}`\"\n [disabled]=\"disabled()\"\n (click)=\"onRetry(row.file, $index)\"\n >\n {{ resolvedRetry() }}\n </button>\n }\n }\n <button\n type=\"button\"\n class=\"wr-file-upload__remove\"\n [attr.aria-label]=\"removeName(row.file.name)\"\n [disabled]=\"disabled() || readonly()\"\n (click)=\"removeAt($index)\"\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <path\n d=\"M2 2 L10 10 M10 2 L2 10\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n />\n </svg>\n </button>\n @if (row.state === 'uploading') {\n <wr-progress\n class=\"wr-file-upload__progress\"\n size=\"sm\"\n [indeterminate]=\"row.percent === null\"\n [value]=\"row.percent ?? 0\"\n [ariaLabel]=\"statusText({ name: row.file.name, status: resolvedUploading() })\"\n />\n } @else if (row.state === 'error') {\n <span class=\"wr-file-upload__error\">{{ row.message ?? resolvedFailed() }}</span>\n }\n </li>\n }\n </ul>\n}\n\n<!-- One live region for the whole list, in the DOM before any state changes: a\n region inserted together with its text is often not read. -->\n@if (status() !== null) {\n <span class=\"wr-file-upload__announce\" role=\"status\" aria-live=\"polite\">{{ announcement() }}</span>\n}\n",
|
|
556
|
+
template: "<div\n #zone\n class=\"wr-file-upload__zone\"\n role=\"button\"\n tabindex=\"0\"\n [attr.aria-label]=\"zoneName()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"openPicker()\"\n (keydown)=\"onZoneKey($event)\"\n (dragenter)=\"onDragEnter($event)\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave()\"\n (drop)=\"onDrop($event)\"\n (paste)=\"onPaste($event)\"\n>\n <svg class=\"wr-file-upload__icon\" width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M12 16V4M12 4l-4 4M12 4l4 4M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n <div class=\"wr-file-upload__hint\" [id]=\"hintId\">\n <strong>{{ resolvedPick() }}</strong>\n <span>{{ resolvedDrop() }}</span>\n @if (helperText()) {\n <small>{{ helperText() }}</small>\n }\n </div>\n</div>\n\n<!--\n The real <input type=\"file\"> is never operated directly — the zone above is\n the control and forwards clicks here, so the input is visually hidden and kept\n OUTSIDE the zone: inside, it nested one interactive element within another\n (the zone is role=\"button\") and put two tab stops where users see one. It is\n positioned absolutely and clipped, so being a sibling changes nothing visually.\n aria-hidden must be paired with tabindex=\"-1\", or hiding a focusable element is\n itself a violation.\n-->\n<input\n #picker\n class=\"wr-file-upload__picker\"\n type=\"file\"\n aria-hidden=\"true\"\n tabindex=\"-1\"\n [attr.accept]=\"accept() || null\"\n [attr.multiple]=\"multiple() ? '' : null\"\n [disabled]=\"disabled() || readonly()\"\n (change)=\"onPickerChange($event)\"\n/>\n\n@if (showList() && (files().length > 0 || storedRows().length > 0)) {\n <ul class=\"wr-file-upload__list\" [attr.aria-busy]=\"busy() || null\">\n @for (row of storedRows(); track row.stored) {\n <li class=\"wr-file-upload__item wr-file-upload__item--stored\">\n <span class=\"wr-file-upload__name\" [title]=\"row.stored.name\">\n @if (row.url; as url) {\n <a\n class=\"wr-file-upload__link\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n [href]=\"url\"\n [attr.aria-label]=\"openText({ name: row.stored.name })\"\n >{{ row.stored.name }}</a\n >\n } @else {\n {{ row.stored.name }}\n }\n </span>\n @if (row.size !== null) {\n <span class=\"wr-file-upload__size\">{{ formatBytes(row.size) }}</span>\n }\n <button\n type=\"button\"\n class=\"wr-file-upload__remove\"\n [attr.aria-label]=\"removeName(row.stored.name)\"\n [disabled]=\"disabled() || readonly()\"\n (click)=\"removeStored(row, $index)\"\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <path\n d=\"M2 2 L10 10 M10 2 L2 10\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n />\n </svg>\n </button>\n </li>\n }\n @for (row of rows(); track $index) {\n <li [class]=\"row.classes\">\n @if (row.preview; as url) {\n <img class=\"wr-file-upload__preview\" alt=\"\" [src]=\"url\" />\n }\n <span\n class=\"wr-file-upload__name\"\n [attr.id]=\"row.state === 'error' ? `${nameId}-${$index}` : null\"\n [title]=\"row.file.name\"\n >{{ row.file.name }}</span\n >\n <span class=\"wr-file-upload__size\">{{ formatBytes(row.file.size) }}</span>\n @switch (row.state) {\n @case ('done') {\n <span class=\"wr-file-upload__done\" role=\"img\" [attr.aria-label]=\"resolvedUploaded()\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M20 6 9 17l-5-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </span>\n }\n @case ('error') {\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-file-upload__retry\"\n [attr.aria-describedby]=\"`${nameId}-${$index}`\"\n [disabled]=\"disabled()\"\n (click)=\"onRetry(row.file, $index)\"\n >\n {{ resolvedRetry() }}\n </button>\n }\n }\n <button\n type=\"button\"\n class=\"wr-file-upload__remove\"\n [attr.aria-label]=\"removeName(row.file.name)\"\n [disabled]=\"disabled() || readonly()\"\n (click)=\"removeAt($index)\"\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <path\n d=\"M2 2 L10 10 M10 2 L2 10\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n />\n </svg>\n </button>\n @if (row.state === 'uploading') {\n <wr-progress\n class=\"wr-file-upload__progress\"\n size=\"sm\"\n [indeterminate]=\"row.percent === null\"\n [value]=\"row.percent ?? 0\"\n [ariaLabel]=\"statusText({ name: row.file.name, status: resolvedUploading() })\"\n />\n } @else if (row.state === 'error') {\n <span class=\"wr-file-upload__error\">{{ row.message ?? resolvedFailed() }}</span>\n }\n </li>\n }\n </ul>\n}\n\n<!-- One live region for the whole list, in the DOM before any state changes: a\n region inserted together with its text is often not read. -->\n@if (status() !== null) {\n <span class=\"wr-file-upload__announce\" role=\"status\" aria-live=\"polite\">{{ announcement() }}</span>\n}\n",
|
|
516
557
|
dependencies: [{
|
|
517
558
|
kind: "component",
|
|
518
559
|
type: WrButton,
|
|
@@ -525,6 +566,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
525
566
|
"iconPosition",
|
|
526
567
|
"disabled",
|
|
527
568
|
"outlined",
|
|
569
|
+
"ghost",
|
|
528
570
|
"block",
|
|
529
571
|
"loading",
|
|
530
572
|
"disabledWhenLoading"
|
|
@@ -538,7 +580,8 @@ var WrFileUpload = class WrFileUpload {
|
|
|
538
580
|
"color",
|
|
539
581
|
"size",
|
|
540
582
|
"value",
|
|
541
|
-
"indeterminate"
|
|
583
|
+
"indeterminate",
|
|
584
|
+
"marks"
|
|
542
585
|
]
|
|
543
586
|
}],
|
|
544
587
|
encapsulation: i0.ViewEncapsulation.None
|
|
@@ -546,7 +589,7 @@ var WrFileUpload = class WrFileUpload {
|
|
|
546
589
|
};
|
|
547
590
|
i0.ɵɵngDeclareClassMetadata({
|
|
548
591
|
minVersion: "12.0.0",
|
|
549
|
-
version: "22.
|
|
592
|
+
version: "22.3.0",
|
|
550
593
|
ngImport: i0,
|
|
551
594
|
type: WrFileUpload,
|
|
552
595
|
decorators: [{
|
|
@@ -559,7 +602,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
559
602
|
"[class]": "classes()"
|
|
560
603
|
},
|
|
561
604
|
imports: [WrButton, WrProgress],
|
|
562
|
-
template: "<div\n #zone\n class=\"wr-file-upload__zone\"\n role=\"button\"\n tabindex=\"0\"\n [attr.aria-label]=\"zoneName()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"openPicker()\"\n (keydown)=\"onZoneKey($event)\"\n (dragenter)=\"onDragEnter($event)\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave()\"\n (drop)=\"onDrop($event)\"\n (paste)=\"onPaste($event)\"\n>\n <svg class=\"wr-file-upload__icon\" width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M12 16V4M12 4l-4 4M12 4l4 4M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n <div class=\"wr-file-upload__hint\" [id]=\"hintId\">\n <strong>{{ resolvedPick() }}</strong>\n <span>{{ resolvedDrop() }}</span>\n @if (helperText()) {\n <small>{{ helperText() }}</small>\n }\n </div>\n</div>\n\n<!--\n The real <input type=\"file\"> is never operated directly — the zone above is\n the control and forwards clicks here, so the input is visually hidden and kept\n OUTSIDE the zone: inside, it nested one interactive element within another\n (the zone is role=\"button\") and put two tab stops where users see one. It is\n positioned absolutely and clipped, so being a sibling changes nothing visually.\n aria-hidden must be paired with tabindex=\"-1\", or hiding a focusable element is\n itself a violation.\n-->\n<input\n #picker\n class=\"wr-file-upload__picker\"\n type=\"file\"\n aria-hidden=\"true\"\n tabindex=\"-1\"\n [attr.accept]=\"accept() || null\"\n [attr.multiple]=\"multiple() ? '' : null\"\n [disabled]=\"disabled() || readonly()\"\n (change)=\"onPickerChange($event)\"\n/>\n\n@if (showList() && files().length > 0) {\n <ul class=\"wr-file-upload__list\" [attr.aria-busy]=\"busy() || null\">\n @for (row of rows(); track $index) {\n <li [class]=\"row.classes\">\n @if (row.preview; as url) {\n <img class=\"wr-file-upload__preview\" alt=\"\" [src]=\"url\" />\n }\n <span\n class=\"wr-file-upload__name\"\n [attr.id]=\"row.state === 'error' ? `${nameId}-${$index}` : null\"\n [title]=\"row.file.name\"\n >{{ row.file.name }}</span\n >\n <span class=\"wr-file-upload__size\">{{ formatBytes(row.file.size) }}</span>\n @switch (row.state) {\n @case ('done') {\n <span class=\"wr-file-upload__done\" role=\"img\" [attr.aria-label]=\"resolvedUploaded()\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M20 6 9 17l-5-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </span>\n }\n @case ('error') {\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-file-upload__retry\"\n [attr.aria-describedby]=\"`${nameId}-${$index}`\"\n [disabled]=\"disabled()\"\n (click)=\"onRetry(row.file, $index)\"\n >\n {{ resolvedRetry() }}\n </button>\n }\n }\n <button\n type=\"button\"\n class=\"wr-file-upload__remove\"\n [attr.aria-label]=\"removeName(row.file.name)\"\n [disabled]=\"disabled() || readonly()\"\n (click)=\"removeAt($index)\"\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <path\n d=\"M2 2 L10 10 M10 2 L2 10\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n />\n </svg>\n </button>\n @if (row.state === 'uploading') {\n <wr-progress\n class=\"wr-file-upload__progress\"\n size=\"sm\"\n [indeterminate]=\"row.percent === null\"\n [value]=\"row.percent ?? 0\"\n [ariaLabel]=\"statusText({ name: row.file.name, status: resolvedUploading() })\"\n />\n } @else if (row.state === 'error') {\n <span class=\"wr-file-upload__error\">{{ row.message ?? resolvedFailed() }}</span>\n }\n </li>\n }\n </ul>\n}\n\n<!-- One live region for the whole list, in the DOM before any state changes: a\n region inserted together with its text is often not read. -->\n@if (status() !== null) {\n <span class=\"wr-file-upload__announce\" role=\"status\" aria-live=\"polite\">{{ announcement() }}</span>\n}\n"
|
|
605
|
+
template: "<div\n #zone\n class=\"wr-file-upload__zone\"\n role=\"button\"\n tabindex=\"0\"\n [attr.aria-label]=\"zoneName()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.aria-invalid]=\"fieldAria.ariaInvalid()\"\n [attr.aria-describedby]=\"fieldAria.describedBy()\"\n (click)=\"openPicker()\"\n (keydown)=\"onZoneKey($event)\"\n (dragenter)=\"onDragEnter($event)\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave()\"\n (drop)=\"onDrop($event)\"\n (paste)=\"onPaste($event)\"\n>\n <svg class=\"wr-file-upload__icon\" width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M12 16V4M12 4l-4 4M12 4l4 4M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n <div class=\"wr-file-upload__hint\" [id]=\"hintId\">\n <strong>{{ resolvedPick() }}</strong>\n <span>{{ resolvedDrop() }}</span>\n @if (helperText()) {\n <small>{{ helperText() }}</small>\n }\n </div>\n</div>\n\n<!--\n The real <input type=\"file\"> is never operated directly — the zone above is\n the control and forwards clicks here, so the input is visually hidden and kept\n OUTSIDE the zone: inside, it nested one interactive element within another\n (the zone is role=\"button\") and put two tab stops where users see one. It is\n positioned absolutely and clipped, so being a sibling changes nothing visually.\n aria-hidden must be paired with tabindex=\"-1\", or hiding a focusable element is\n itself a violation.\n-->\n<input\n #picker\n class=\"wr-file-upload__picker\"\n type=\"file\"\n aria-hidden=\"true\"\n tabindex=\"-1\"\n [attr.accept]=\"accept() || null\"\n [attr.multiple]=\"multiple() ? '' : null\"\n [disabled]=\"disabled() || readonly()\"\n (change)=\"onPickerChange($event)\"\n/>\n\n@if (showList() && (files().length > 0 || storedRows().length > 0)) {\n <ul class=\"wr-file-upload__list\" [attr.aria-busy]=\"busy() || null\">\n @for (row of storedRows(); track row.stored) {\n <li class=\"wr-file-upload__item wr-file-upload__item--stored\">\n <span class=\"wr-file-upload__name\" [title]=\"row.stored.name\">\n @if (row.url; as url) {\n <a\n class=\"wr-file-upload__link\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n [href]=\"url\"\n [attr.aria-label]=\"openText({ name: row.stored.name })\"\n >{{ row.stored.name }}</a\n >\n } @else {\n {{ row.stored.name }}\n }\n </span>\n @if (row.size !== null) {\n <span class=\"wr-file-upload__size\">{{ formatBytes(row.size) }}</span>\n }\n <button\n type=\"button\"\n class=\"wr-file-upload__remove\"\n [attr.aria-label]=\"removeName(row.stored.name)\"\n [disabled]=\"disabled() || readonly()\"\n (click)=\"removeStored(row, $index)\"\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <path\n d=\"M2 2 L10 10 M10 2 L2 10\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n />\n </svg>\n </button>\n </li>\n }\n @for (row of rows(); track $index) {\n <li [class]=\"row.classes\">\n @if (row.preview; as url) {\n <img class=\"wr-file-upload__preview\" alt=\"\" [src]=\"url\" />\n }\n <span\n class=\"wr-file-upload__name\"\n [attr.id]=\"row.state === 'error' ? `${nameId}-${$index}` : null\"\n [title]=\"row.file.name\"\n >{{ row.file.name }}</span\n >\n <span class=\"wr-file-upload__size\">{{ formatBytes(row.file.size) }}</span>\n @switch (row.state) {\n @case ('done') {\n <span class=\"wr-file-upload__done\" role=\"img\" [attr.aria-label]=\"resolvedUploaded()\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path\n d=\"M20 6 9 17l-5-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </span>\n }\n @case ('error') {\n <button\n wr-btn\n type=\"button\"\n size=\"sm\"\n outlined\n class=\"wr-file-upload__retry\"\n [attr.aria-describedby]=\"`${nameId}-${$index}`\"\n [disabled]=\"disabled()\"\n (click)=\"onRetry(row.file, $index)\"\n >\n {{ resolvedRetry() }}\n </button>\n }\n }\n <button\n type=\"button\"\n class=\"wr-file-upload__remove\"\n [attr.aria-label]=\"removeName(row.file.name)\"\n [disabled]=\"disabled() || readonly()\"\n (click)=\"removeAt($index)\"\n >\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <path\n d=\"M2 2 L10 10 M10 2 L2 10\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n />\n </svg>\n </button>\n @if (row.state === 'uploading') {\n <wr-progress\n class=\"wr-file-upload__progress\"\n size=\"sm\"\n [indeterminate]=\"row.percent === null\"\n [value]=\"row.percent ?? 0\"\n [ariaLabel]=\"statusText({ name: row.file.name, status: resolvedUploading() })\"\n />\n } @else if (row.state === 'error') {\n <span class=\"wr-file-upload__error\">{{ row.message ?? resolvedFailed() }}</span>\n }\n </li>\n }\n </ul>\n}\n\n<!-- One live region for the whole list, in the DOM before any state changes: a\n region inserted together with its text is often not read. -->\n@if (status() !== null) {\n <span class=\"wr-file-upload__announce\" role=\"status\" aria-live=\"polite\">{{ announcement() }}</span>\n}\n"
|
|
563
606
|
}]
|
|
564
607
|
}],
|
|
565
608
|
ctorParameters: () => [],
|
|
@@ -636,6 +679,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
636
679
|
required: false
|
|
637
680
|
}]
|
|
638
681
|
}],
|
|
682
|
+
stored: [{
|
|
683
|
+
type: i0.Input,
|
|
684
|
+
args: [{
|
|
685
|
+
isSignal: true,
|
|
686
|
+
alias: "stored",
|
|
687
|
+
required: false
|
|
688
|
+
}]
|
|
689
|
+
}],
|
|
639
690
|
previews: [{
|
|
640
691
|
type: i0.Input,
|
|
641
692
|
args: [{
|
|
@@ -739,6 +790,10 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
739
790
|
type: i0.Output,
|
|
740
791
|
args: ["rejected"]
|
|
741
792
|
}],
|
|
793
|
+
storedRemove: [{
|
|
794
|
+
type: i0.Output,
|
|
795
|
+
args: ["storedRemove"]
|
|
796
|
+
}],
|
|
742
797
|
retry: [{
|
|
743
798
|
type: i0.Output,
|
|
744
799
|
args: ["retry"]
|