@gov-design-system-ce/components 4.6.4 → 4.6.5-b
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/dist/cjs/gov-flex_3.cjs.entry.js +1 -1
- package/dist/cjs/gov-form-file.cjs.entry.js +35 -11
- package/dist/cjs/gov-form-file.cjs.entry.js.map +1 -1
- package/dist/cjs/gov-form-file.entry.cjs.js.map +1 -1
- package/dist/collection/components/gov-form/file/gov-form-file.js +7 -2
- package/dist/collection/components/gov-form/file/gov-form-file.js.map +1 -1
- package/dist/collection/utils/file.utils.js +28 -9
- package/dist/collection/utils/file.utils.js.map +1 -1
- package/dist/components/gov-accordion-item.js +1 -1
- package/dist/components/gov-attachments-item.js +1 -1
- package/dist/components/gov-blockquote.js +1 -1
- package/dist/components/gov-breadcrumbs.js +1 -1
- package/dist/components/gov-breadcrumbs.js.map +1 -1
- package/dist/components/gov-button.js +1 -1
- package/dist/components/gov-card.js +1 -1
- package/dist/components/gov-chip.js +1 -1
- package/dist/components/gov-collapsible.js +1 -1
- package/dist/components/gov-dialog.js +1 -1
- package/dist/components/gov-form-autocomplete.js +1 -1
- package/dist/components/gov-form-checkbox.js +1 -1
- package/dist/components/gov-form-file.js +1 -1
- package/dist/components/gov-form-file.js.map +1 -1
- package/dist/components/gov-form-input.js +1 -1
- package/dist/components/gov-form-multi-select.js +1 -1
- package/dist/components/gov-form-range.js +1 -1
- package/dist/components/gov-form-select.js +1 -1
- package/dist/components/gov-form-switch.js +1 -1
- package/dist/components/gov-icon.js +1 -1
- package/dist/components/gov-infobar.js +1 -1
- package/dist/components/gov-link.js +1 -1
- package/dist/components/gov-loading.js +1 -1
- package/dist/components/gov-pagination.js +1 -1
- package/dist/components/gov-tabs.js +1 -1
- package/dist/components/gov-tag.js +1 -1
- package/dist/components/gov-theme-switch.js +1 -1
- package/dist/components/gov-tile.js +1 -1
- package/dist/components/gov-toast.js +1 -1
- package/dist/components/gov-tooltip-content.js +1 -1
- package/dist/components/gov-wizard-item.js +1 -1
- package/dist/components/{p-ibUK7mfI.js → p-BGK46VRO.js} +2 -2
- package/dist/components/{p-iTwUkISB.js → p-BICk4EuO.js} +2 -2
- package/dist/components/{p-DN5pb9xA.js → p-BNoNH6m-.js} +2 -2
- package/dist/components/{p-C_URF9Su.js → p-ClDhNt_H.js} +2 -2
- package/dist/components/p-DRXiDAHW.js +2 -0
- package/dist/components/{p-CXPP9vec.js.map → p-DRXiDAHW.js.map} +1 -1
- package/dist/components/{p-pJ_vPAO0.js → p-DjGO_trZ.js} +2 -2
- package/dist/components/{p-yIpIIG5A.js → p-DmK9qaKH.js} +2 -2
- package/dist/components/{p-DEthsMuE.js → p-isPjiQbr.js} +2 -2
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/{p-3314505d.entry.js → p-00ab0454.entry.js} +2 -2
- package/dist/core/{p-3314505d.entry.js.map → p-00ab0454.entry.js.map} +1 -1
- package/dist/core/{p-9d9e9401.entry.js → p-05bb35e1.entry.js} +2 -2
- package/dist/core/{p-9d9e9401.entry.js.map → p-05bb35e1.entry.js.map} +1 -1
- package/dist/core/{p-e30968b3.entry.js → p-06497d64.entry.js} +2 -2
- package/dist/core/{p-e30968b3.entry.js.map → p-06497d64.entry.js.map} +1 -1
- package/dist/core/p-0675617d.entry.js +2 -0
- package/dist/core/{p-fca7a0d6.entry.js.map → p-0675617d.entry.js.map} +1 -1
- package/dist/core/{p-4d36cd18.entry.js → p-2493a7f3.entry.js} +2 -2
- package/dist/core/{p-4d36cd18.entry.js.map → p-2493a7f3.entry.js.map} +1 -1
- package/dist/core/p-2e15a654.entry.js +2 -0
- package/dist/core/{p-bd2df430.entry.js.map → p-2e15a654.entry.js.map} +1 -1
- package/dist/core/{p-1626cc67.entry.js → p-30ad7514.entry.js} +2 -2
- package/dist/core/{p-1626cc67.entry.js.map → p-30ad7514.entry.js.map} +1 -1
- package/dist/core/{p-558e75a6.entry.js → p-378cf8de.entry.js} +2 -2
- package/dist/core/{p-558e75a6.entry.js.map → p-378cf8de.entry.js.map} +1 -1
- package/dist/core/{p-be9af807.entry.js → p-3a4799b3.entry.js} +2 -2
- package/dist/core/{p-be9af807.entry.js.map → p-3a4799b3.entry.js.map} +1 -1
- package/dist/core/{p-f7bdb44a.entry.js → p-3ebbe75a.entry.js} +2 -2
- package/dist/core/{p-f7bdb44a.entry.js.map → p-3ebbe75a.entry.js.map} +1 -1
- package/dist/core/p-41bef63a.entry.js +2 -0
- package/dist/core/{p-bec959c4.entry.js.map → p-41bef63a.entry.js.map} +1 -1
- package/dist/core/{p-4e2faea7.entry.js → p-4342c252.entry.js} +2 -2
- package/dist/core/{p-4e2faea7.entry.js.map → p-4342c252.entry.js.map} +1 -1
- package/dist/core/{p-c1b9f1ab.entry.js → p-473afd7d.entry.js} +2 -2
- package/dist/core/{p-c1b9f1ab.entry.js.map → p-473afd7d.entry.js.map} +1 -1
- package/dist/core/{p-5721cf9b.entry.js → p-48b74272.entry.js} +2 -2
- package/dist/core/{p-5721cf9b.entry.js.map → p-48b74272.entry.js.map} +1 -1
- package/dist/core/{p-04ec45ab.entry.js → p-49b67f59.entry.js} +2 -2
- package/dist/core/{p-04ec45ab.entry.js.map → p-49b67f59.entry.js.map} +1 -1
- package/dist/core/{p-6b44890d.entry.js → p-4bd3f101.entry.js} +2 -2
- package/dist/core/{p-6b44890d.entry.js.map → p-4bd3f101.entry.js.map} +1 -1
- package/dist/core/{p-157a1636.entry.js → p-4e534d68.entry.js} +2 -2
- package/dist/core/{p-157a1636.entry.js.map → p-4e534d68.entry.js.map} +1 -1
- package/dist/core/p-6638d034.entry.js +2 -0
- package/dist/core/{p-73bd93f9.entry.js.map → p-6638d034.entry.js.map} +1 -1
- package/dist/core/{p-46824842.entry.js → p-68a5d225.entry.js} +2 -2
- package/dist/core/{p-46824842.entry.js.map → p-68a5d225.entry.js.map} +1 -1
- package/dist/core/{p-8d47e346.entry.js → p-6ac9b0f2.entry.js} +2 -2
- package/dist/core/{p-8d47e346.entry.js.map → p-6ac9b0f2.entry.js.map} +1 -1
- package/dist/core/{p-0af96cc0.entry.js → p-6b0625ee.entry.js} +2 -2
- package/dist/core/{p-0af96cc0.entry.js.map → p-6b0625ee.entry.js.map} +1 -1
- package/dist/core/{p-f75ad657.entry.js → p-78202a44.entry.js} +2 -2
- package/dist/core/{p-f75ad657.entry.js.map → p-78202a44.entry.js.map} +1 -1
- package/dist/core/{p-eb766437.entry.js → p-80052953.entry.js} +2 -2
- package/dist/core/{p-eb766437.entry.js.map → p-80052953.entry.js.map} +1 -1
- package/dist/core/{p-d43959a0.entry.js → p-8ddb6dc6.entry.js} +2 -2
- package/dist/core/{p-d43959a0.entry.js.map → p-8ddb6dc6.entry.js.map} +1 -1
- package/dist/core/{p-d9c574f0.entry.js → p-90cc2ddb.entry.js} +2 -2
- package/dist/core/{p-d9c574f0.entry.js.map → p-90cc2ddb.entry.js.map} +1 -1
- package/dist/core/{p-f3887d6d.entry.js → p-91d5df66.entry.js} +2 -2
- package/dist/core/{p-f3887d6d.entry.js.map → p-91d5df66.entry.js.map} +1 -1
- package/dist/core/{p-187c0eda.entry.js → p-9321fb9d.entry.js} +2 -2
- package/dist/core/{p-187c0eda.entry.js.map → p-9321fb9d.entry.js.map} +1 -1
- package/dist/core/p-943a58b2.entry.js +2 -0
- package/dist/core/{p-33209782.entry.js.map → p-943a58b2.entry.js.map} +1 -1
- package/dist/core/p-B6CqPcY_.js.map +1 -1
- package/dist/core/p-B8TR1oqt.js +3 -0
- package/dist/core/p-B8TR1oqt.js.map +1 -0
- package/dist/core/p-BUmDydor.js.map +1 -1
- package/dist/core/p-BcQO4NH2.js.map +1 -1
- package/dist/core/p-BjcqOprh.js.map +1 -1
- package/dist/core/p-Bo1ROm5Q.js.map +1 -1
- package/dist/core/p-Bz_RzYFb.js.map +1 -1
- package/dist/core/p-C3R1T_pg.js.map +1 -1
- package/dist/core/p-C6JN9gdb.js.map +1 -1
- package/dist/core/p-CDIRBJsi.js.map +1 -1
- package/dist/core/p-CQvUntGY.js.map +1 -1
- package/dist/core/p-Ccwpa1ck.js.map +1 -1
- package/dist/core/p-CgDnDrq5.js.map +1 -1
- package/dist/core/p-Cjg0wpDG.js.map +1 -1
- package/dist/core/p-CoD1xawt.js.map +1 -1
- package/dist/core/p-Cx3bEC5v.js.map +1 -1
- package/dist/core/p-D4TGB274.js.map +1 -1
- package/dist/core/p-DBXGhafv.js.map +1 -1
- package/dist/core/p-DNztiAH0.js.map +1 -1
- package/dist/core/p-DQuL1Twl.js.map +1 -1
- package/dist/core/p-DYcNEwSZ.js.map +1 -1
- package/dist/core/p-EeKNA85D.js.map +1 -1
- package/dist/core/p-GYov8gU1.js.map +1 -1
- package/dist/core/p-NOJjz9dT.js.map +1 -1
- package/dist/core/p-Q99QrOoi.js.map +1 -1
- package/dist/core/p-U40vKHrs.js.map +1 -1
- package/dist/core/p-a4fa2ffc.entry.js +2 -0
- package/dist/core/{p-c4734357.entry.js.map → p-a4fa2ffc.entry.js.map} +1 -1
- package/dist/core/{p-511eed88.entry.js → p-a6f27583.entry.js} +2 -2
- package/dist/core/{p-511eed88.entry.js.map → p-a6f27583.entry.js.map} +1 -1
- package/dist/core/p-a7c322a7.entry.js +2 -0
- package/dist/core/{p-abb7780e.entry.js.map → p-a7c322a7.entry.js.map} +1 -1
- package/dist/core/{p-6d2ce4c7.entry.js → p-ab367b0c.entry.js} +2 -2
- package/dist/core/{p-6d2ce4c7.entry.js.map → p-ab367b0c.entry.js.map} +1 -1
- package/dist/core/{p-c6b55c0a.entry.js → p-ac81cdf6.entry.js} +2 -2
- package/dist/core/{p-c6b55c0a.entry.js.map → p-ac81cdf6.entry.js.map} +1 -1
- package/dist/core/{p-a2c61d50.entry.js → p-ad9227b3.entry.js} +2 -2
- package/dist/core/{p-a2c61d50.entry.js.map → p-ad9227b3.entry.js.map} +1 -1
- package/dist/core/{p-d9d29f50.entry.js → p-af2bd9d3.entry.js} +2 -2
- package/dist/core/{p-d9d29f50.entry.js.map → p-af2bd9d3.entry.js.map} +1 -1
- package/dist/core/{p-70b5555f.entry.js → p-b0d4d6bd.entry.js} +2 -2
- package/dist/core/{p-70b5555f.entry.js.map → p-b0d4d6bd.entry.js.map} +1 -1
- package/dist/core/p-b181f85f.entry.js +2 -0
- package/dist/core/{p-57ca8ac7.entry.js.map → p-b181f85f.entry.js.map} +1 -1
- package/dist/core/{p-5305e82e.entry.js → p-b2648255.entry.js} +2 -2
- package/dist/core/{p-5305e82e.entry.js.map → p-b2648255.entry.js.map} +1 -1
- package/dist/core/{p-65a09763.entry.js → p-b37bd421.entry.js} +2 -2
- package/dist/core/{p-65a09763.entry.js.map → p-b37bd421.entry.js.map} +1 -1
- package/dist/core/{p-91cbee1b.entry.js → p-b5e40f40.entry.js} +2 -2
- package/dist/core/{p-91cbee1b.entry.js.map → p-b5e40f40.entry.js.map} +1 -1
- package/dist/core/{p-19300834.entry.js → p-b77c283e.entry.js} +2 -2
- package/dist/core/{p-19300834.entry.js.map → p-b77c283e.entry.js.map} +1 -1
- package/dist/core/{p-7f513718.entry.js → p-bb5b9ccd.entry.js} +2 -2
- package/dist/core/{p-7f513718.entry.js.map → p-bb5b9ccd.entry.js.map} +1 -1
- package/dist/core/{p-4c02094d.entry.js → p-c9b2f97c.entry.js} +2 -2
- package/dist/core/{p-4c02094d.entry.js.map → p-c9b2f97c.entry.js.map} +1 -1
- package/dist/core/{p-eb3f6808.entry.js → p-caf817d4.entry.js} +2 -2
- package/dist/core/{p-eb3f6808.entry.js.map → p-caf817d4.entry.js.map} +1 -1
- package/dist/core/p-dc0bd1e5.entry.js +2 -0
- package/dist/core/{p-3e07bf07.entry.js.map → p-dc0bd1e5.entry.js.map} +1 -1
- package/dist/core/{p-db860031.entry.js → p-dd390459.entry.js} +2 -2
- package/dist/core/{p-db860031.entry.js.map → p-dd390459.entry.js.map} +1 -1
- package/dist/core/{p-10991f00.entry.js → p-de5dfd70.entry.js} +2 -2
- package/dist/core/{p-10991f00.entry.js.map → p-de5dfd70.entry.js.map} +1 -1
- package/dist/core/p-dfb76a14.entry.js +2 -0
- package/dist/core/p-dfb76a14.entry.js.map +1 -0
- package/dist/core/{p-cd163299.entry.js → p-e17def2b.entry.js} +2 -2
- package/dist/core/{p-cd163299.entry.js.map → p-e17def2b.entry.js.map} +1 -1
- package/dist/core/{p-e39e5dc7.entry.js → p-e1d58751.entry.js} +2 -2
- package/dist/core/{p-e39e5dc7.entry.js.map → p-e1d58751.entry.js.map} +1 -1
- package/dist/core/{p-3e07bf07.entry.js → p-e913cfc8.entry.js} +2 -2
- package/dist/core/{p-90ab65b4.entry.js.map → p-e913cfc8.entry.js.map} +1 -1
- package/dist/core/{p-da997fb3.entry.js → p-ea299832.entry.js} +2 -2
- package/dist/core/{p-da997fb3.entry.js.map → p-ea299832.entry.js.map} +1 -1
- package/dist/core/{p-852310d9.entry.js → p-eff8ffff.entry.js} +2 -2
- package/dist/core/{p-852310d9.entry.js.map → p-eff8ffff.entry.js.map} +1 -1
- package/dist/core/{p-4d902f20.entry.js → p-f2d24551.entry.js} +2 -2
- package/dist/core/{p-4d902f20.entry.js.map → p-f2d24551.entry.js.map} +1 -1
- package/dist/core/{p-5c872d64.entry.js → p-f515d912.entry.js} +2 -2
- package/dist/core/{p-bf573a56.entry.js → p-febff4d1.entry.js} +2 -2
- package/dist/core/{p-bf573a56.entry.js.map → p-febff4d1.entry.js.map} +1 -1
- package/dist/core/p-vN03FcXN.js.map +1 -1
- package/dist/esm/gov-flex_3.entry.js +1 -1
- package/dist/esm/gov-form-file.entry.js +35 -11
- package/dist/esm/gov-form-file.entry.js.map +1 -1
- package/dist/hydrate/index.js +36 -12
- package/dist/hydrate/index.mjs +36 -12
- package/dist/types/components.d.ts +592 -119
- package/dist/types/stencil-public-runtime.d.ts +170 -11
- package/package.json +32 -28
- package/readme.md +1 -2
- package/dist/components/p-CXPP9vec.js +0 -2
- package/dist/core/core.css +0 -14776
- package/dist/core/gov-accordion-item.entry.esm.js.map +0 -1
- package/dist/core/gov-accordion.entry.esm.js.map +0 -1
- package/dist/core/gov-attachments.gov-attachments-item.gov-form-message.entry.esm.js.map +0 -1
- package/dist/core/gov-backdrop.entry.esm.js.map +0 -1
- package/dist/core/gov-banner.entry.esm.js.map +0 -1
- package/dist/core/gov-blockquote.entry.esm.js.map +0 -1
- package/dist/core/gov-breadcrumbs.entry.esm.js.map +0 -1
- package/dist/core/gov-button.entry.esm.js.map +0 -1
- package/dist/core/gov-card.entry.esm.js.map +0 -1
- package/dist/core/gov-chip.entry.esm.js.map +0 -1
- package/dist/core/gov-collapsible.entry.esm.js.map +0 -1
- package/dist/core/gov-container.entry.esm.js.map +0 -1
- package/dist/core/gov-control-group.entry.esm.js.map +0 -1
- package/dist/core/gov-cookiebar.entry.esm.js.map +0 -1
- package/dist/core/gov-dialog.entry.esm.js.map +0 -1
- package/dist/core/gov-dropdown.entry.esm.js.map +0 -1
- package/dist/core/gov-empty.entry.esm.js.map +0 -1
- package/dist/core/gov-error-code.entry.esm.js.map +0 -1
- package/dist/core/gov-flex.gov-icon.gov-theme-switch.entry.esm.js.map +0 -1
- package/dist/core/gov-form-autocomplete.entry.esm.js.map +0 -1
- package/dist/core/gov-form-checkbox-group.entry.esm.js.map +0 -1
- package/dist/core/gov-form-checkbox.entry.esm.js.map +0 -1
- package/dist/core/gov-form-control.entry.esm.js.map +0 -1
- package/dist/core/gov-form-file.entry.esm.js.map +0 -1
- package/dist/core/gov-form-group.entry.esm.js.map +0 -1
- package/dist/core/gov-form-input.gov-skeleton.entry.esm.js.map +0 -1
- package/dist/core/gov-form-label.entry.esm.js.map +0 -1
- package/dist/core/gov-form-multi-select.entry.esm.js.map +0 -1
- package/dist/core/gov-form-password-power.entry.esm.js.map +0 -1
- package/dist/core/gov-form-radio-group.entry.esm.js.map +0 -1
- package/dist/core/gov-form-radio.entry.esm.js.map +0 -1
- package/dist/core/gov-form-range.entry.esm.js.map +0 -1
- package/dist/core/gov-form-search.entry.esm.js.map +0 -1
- package/dist/core/gov-form-select.entry.esm.js.map +0 -1
- package/dist/core/gov-form-switch.entry.esm.js.map +0 -1
- package/dist/core/gov-grid-item.entry.esm.js.map +0 -1
- package/dist/core/gov-grid.entry.esm.js.map +0 -1
- package/dist/core/gov-infobar.entry.esm.js.map +0 -1
- package/dist/core/gov-layout-column.entry.esm.js.map +0 -1
- package/dist/core/gov-layout.entry.esm.js.map +0 -1
- package/dist/core/gov-lifecycle.entry.esm.js.map +0 -1
- package/dist/core/gov-link.entry.esm.js.map +0 -1
- package/dist/core/gov-loading.entry.esm.js.map +0 -1
- package/dist/core/gov-message.entry.esm.js.map +0 -1
- package/dist/core/gov-pagination.entry.esm.js.map +0 -1
- package/dist/core/gov-spacer.entry.esm.js.map +0 -1
- package/dist/core/gov-stepper-item.entry.esm.js.map +0 -1
- package/dist/core/gov-stepper.entry.esm.js.map +0 -1
- package/dist/core/gov-tabs-item.entry.esm.js.map +0 -1
- package/dist/core/gov-tabs.entry.esm.js.map +0 -1
- package/dist/core/gov-tag.entry.esm.js.map +0 -1
- package/dist/core/gov-tile.entry.esm.js.map +0 -1
- package/dist/core/gov-toast.entry.esm.js.map +0 -1
- package/dist/core/gov-tooltip.gov-tooltip-content.entry.esm.js.map +0 -1
- package/dist/core/gov-wizard-item.entry.esm.js.map +0 -1
- package/dist/core/gov-wizard.entry.esm.js.map +0 -1
- package/dist/core/loader.esm.js.map +0 -1
- package/dist/core/p-33209782.entry.js +0 -2
- package/dist/core/p-57ca8ac7.entry.js +0 -2
- package/dist/core/p-73bd93f9.entry.js +0 -2
- package/dist/core/p-90ab65b4.entry.js +0 -2
- package/dist/core/p-ClISz4NF.js +0 -3
- package/dist/core/p-ClISz4NF.js.map +0 -1
- package/dist/core/p-abb7780e.entry.js +0 -2
- package/dist/core/p-afe254cb.entry.js +0 -2
- package/dist/core/p-afe254cb.entry.js.map +0 -1
- package/dist/core/p-bd2df430.entry.js +0 -2
- package/dist/core/p-bec959c4.entry.js +0 -2
- package/dist/core/p-c4734357.entry.js +0 -2
- package/dist/core/p-fca7a0d6.entry.js +0 -2
- /package/dist/components/{p-ibUK7mfI.js.map → p-BGK46VRO.js.map} +0 -0
- /package/dist/components/{p-iTwUkISB.js.map → p-BICk4EuO.js.map} +0 -0
- /package/dist/components/{p-DN5pb9xA.js.map → p-BNoNH6m-.js.map} +0 -0
- /package/dist/components/{p-C_URF9Su.js.map → p-ClDhNt_H.js.map} +0 -0
- /package/dist/components/{p-pJ_vPAO0.js.map → p-DjGO_trZ.js.map} +0 -0
- /package/dist/components/{p-yIpIIG5A.js.map → p-DmK9qaKH.js.map} +0 -0
- /package/dist/components/{p-DEthsMuE.js.map → p-isPjiQbr.js.map} +0 -0
- /package/dist/core/{p-5c872d64.entry.js.map → p-f515d912.entry.js.map} +0 -0
|
@@ -29,18 +29,37 @@ function formatBytes(bytes) {
|
|
|
29
29
|
}
|
|
30
30
|
return n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l];
|
|
31
31
|
}
|
|
32
|
+
// Validates a file against an `accept` attribute value, following the HTML spec
|
|
33
|
+
// (https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept):
|
|
34
|
+
// - ".ext" → matched against the file NAME suffix (case-insensitive)
|
|
35
|
+
// - "type/*" → matched against the file MIME group
|
|
36
|
+
// - "type/sub" → exact MIME match
|
|
37
|
+
// Matching the name (not only file.type) is essential: browsers often report an
|
|
38
|
+
// empty or non-standard MIME for extensions like .jsonld, which the previous
|
|
39
|
+
// MIME-only RegExp check always rejected.
|
|
32
40
|
function fileAcceptValidation(file, accept) {
|
|
33
|
-
if (typeof accept
|
|
34
|
-
return (accept
|
|
35
|
-
.replace(/\s/g, '')
|
|
36
|
-
.split(',')
|
|
37
|
-
.filter(accept => {
|
|
38
|
-
return new RegExp(accept.replace('*', '.*')).test(file.type);
|
|
39
|
-
}).length > 0);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
41
|
+
if (typeof accept !== 'string' || accept.trim().length === 0) {
|
|
42
42
|
return true;
|
|
43
43
|
}
|
|
44
|
+
const fileName = file.name.toLowerCase();
|
|
45
|
+
const fileType = (file.type || '').toLowerCase();
|
|
46
|
+
return accept
|
|
47
|
+
.split(',')
|
|
48
|
+
.map(token => token.trim().toLowerCase())
|
|
49
|
+
.filter(token => token.length > 0)
|
|
50
|
+
.some(token => {
|
|
51
|
+
if (token.startsWith('.')) {
|
|
52
|
+
return fileName.endsWith(token);
|
|
53
|
+
}
|
|
54
|
+
if (token === '*' || token === '*/*') {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
if (token.endsWith('/*')) {
|
|
58
|
+
const group = token.slice(0, token.indexOf('/') + 1);
|
|
59
|
+
return fileType.startsWith(group);
|
|
60
|
+
}
|
|
61
|
+
return fileType === token;
|
|
62
|
+
});
|
|
44
63
|
}
|
|
45
64
|
function fileSizeValidation(file, maxSize) {
|
|
46
65
|
const fileSize = Math.round(file.size);
|
|
@@ -161,10 +180,15 @@ const GovFormFile = class {
|
|
|
161
180
|
}
|
|
162
181
|
validateFiles(files) {
|
|
163
182
|
let filesBuffer = [];
|
|
183
|
+
// Without `multiple`, only a single file is allowed. An incoming batch
|
|
184
|
+
// (drag-drop, framework wrapper, programmatic assignment) can still carry
|
|
185
|
+
// several files, so cap it to the last one — consistent with the
|
|
186
|
+
// "second pick replaces the first" semantics. (Bug #30570313)
|
|
187
|
+
const incoming = this.multiple ? Array.from(files) : Array.from(files).slice(-1);
|
|
164
188
|
if (!this.multiple && this.displayAttachments) {
|
|
165
189
|
this.files = [];
|
|
166
190
|
}
|
|
167
|
-
|
|
191
|
+
incoming.forEach(file => {
|
|
168
192
|
const isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null;
|
|
169
193
|
if (isFile === null || this.ignoreFileDuplicationCheck) {
|
|
170
194
|
const isSizeValid = typeof this.maxFileSize === "number" && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true;
|
|
@@ -240,7 +264,7 @@ const GovFormFile = class {
|
|
|
240
264
|
this.inheritedAttributes = Object.assign(Object.assign({}, this.inheritedAttributes), { [attributeName]: newValue });
|
|
241
265
|
}
|
|
242
266
|
render() {
|
|
243
|
-
return (index.h(index.Host, { key: '
|
|
267
|
+
return (index.h(index.Host, { key: '2d89af24db1447bba2c7987946b5c63bff65a58a', class: this.h.classes([FormFileClass.root]), invalid: template.toBoolAttrIfDefined(this.invalid), expanded: template.toBoolAttrIfDefined(this.expanded) }, index.h("div", { key: '7a37869f8ef203b0f1d6b07cfee8e4f325fe9ecc', class: FormFileClass.area, ref: el => (this.areaRef = el) }, index.h("slot", { key: '10344be7bedf53a4754c8e79bb069c57291b7663' }), index.h("input", Object.assign({ key: '52dc1692d0eaa6310c0166faceb5906627aac73c', class: FormFileClass.input, ref: el => (this.inputRef = el), id: this.identifier || this.fileId, type: "file", name: this.name, accept: this.accept, multiple: this.multiple, onChange: this.onChangeHandler.bind(this), onFocus: this.onFocusHandler.bind(this), onBlur: this.onBlurHandler.bind(this), required: this.required, disabled: this.disabled }, this.inheritedAttributes, { "aria-required": template.toBoolAttrIfDefined(this.required), "aria-invalid": template.toBoolAttrIfDefined(this.invalid), "aria-disabled": template.toBoolAttrIfDefined(this.disabled) })), index.h("div", { key: '1193c6ef7a57894baab2f14619827c2f51441d08', class: FormFileClass.inputFocus })), this.h.hasSlot("attachments") ? (index.h("div", { class: FormFileClass.attachments }, index.h("slot", { name: "attachments" }))) : null, this.files.length && this.displayAttachments ? (index.h("div", { class: FormFileClass.attachments }, index.h("gov-attachments", { label: this.accessibleAttachmentsLabel, "accessible-label": this.accessibleAttachmentsLabel }, this.files.map(item => (index.h("gov-attachments-item", { "accessible-remove-labelledby": item.id, "on-gov-remove": () => this.onRemoveFileHandler(item) }, item.file.name, index.h("span", { slot: "name" }, item.file.name), item.acceptValid === false ? (index.h("gov-form-message", { slot: "message", color: "error" }, index.h("gov-icon", { slot: "icon", name: "exclamation-triangle-fill", type: "components" }), item.acceptValid === false ? this.errorAccept : null)) : null, item.sizeValid === false ? (index.h("gov-form-message", { slot: "message", color: "error" }, index.h("gov-icon", { slot: "icon", name: "exclamation-triangle-fill", type: "components" }), this.errorSize.replace("{FILE_SIZE}", formatBytes(this.maxFileSize)))) : null, index.h("span", { slot: "info" }, "(", formatBytes(item.file.size), ")"))))))) : null));
|
|
244
268
|
}
|
|
245
269
|
onRemoveFileHandler(file) {
|
|
246
270
|
const index = this.files.findIndex(item => item.id === file.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"gov-form-file.entry.cjs.js","mappings":";;;;;;;;;;;;;;;AAAO,MAAM,aAAa,GAAG;AAC5B,IAAA,IAAI,EAAE,eAAe;AACrB,IAAA,IAAI,EAAE,qBAAqB;AAC3B,IAAA,KAAK,EAAE,sBAAsB;AAC7B,IAAA,UAAU,EAAE,4BAA4B;AACxC,IAAA,WAAW,EAAE,4BAA4B;CACzC;;ACNK,SAAU,WAAW,CAAC,KAAU,EAAA;IACrC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;AAC/E,IAAA,IAAI,CAAC,GAAG,CAAC,EACR,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC;AAE7B,IAAA,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,EAAE;AACxB,QAAA,CAAC,GAAG,CAAC,GAAG,IAAI;;IAGb,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC;AAC3D;AAEgB,SAAA,oBAAoB,CAAC,IAAU,EAAE,MAAc,EAAA;IAC9D,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE;AAChD,QAA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A,aAAa,EAAE,CAAC;AAChB,SAAA,CAAC;;AAGK,IAAA,eAAe,CAAC,CAAQ,EAAA;QAC/B,CAAC,CAAC,eAAe,EAAE;;AAGpB;;AAEG;AAEH,IAAA,MAAM,MAAM,GAAA;QACX,OAAO,IAAI,CAAC,QAAQ;;AAGrB;;AAEG;AAEH,IAAA,MAAM,UAAU,GAAA;QACf,OAAO,IAAI,CAAC,OAAO;;AAGpB;;AAEG;AAEH,IAAA,MAAM,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,KAAK,GAAG,EAAE;AACf,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;AAClB,YAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE;YACxB,IAAI,CAAC,oBAAoB,EAAE;;;;;;;;;;;;","names":["createID","govHost","govForm","toBoolAttr","AttributeObserver","ariaAttributes","inheritAriaAttributes","h","Host","toBoolAttrIfDefined"],"sources":["../../../packages/core/src/components/gov-form/file/constants.ts","../../../packages/core/src/utils/file.utils.ts","../../../packages/core/src/components/gov-form/file/gov-form-file.tsx"],"sourcesContent":["export const FormFileClass = {\n\troot: 'gov-form-file',\n\tarea: 'gov-form-file__area',\n\tinput: 'gov-form-file__input',\n\tinputFocus: 'gov-form-file__input-focus',\n\tattachments: 'gov-form-file__attachments',\n}\n","export function formatBytes(bytes: any): string {\n\tconst units = ['bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']\n\tlet l = 0,\n\t\tn = parseInt(bytes, 10) || 0\n\n\twhile (n >= 1024 && ++l) {\n\t\tn = n / 1024\n\t}\n\n\treturn n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l]\n}\n\nexport function fileAcceptValidation(file: File, accept: string): boolean {\n\tif (typeof accept === 'string' && accept.length) {\n\t\treturn (\n\t\t\taccept\n\t\t\t\t.replace(/\\s/g, '')\n\t\t\t\t.split(',')\n\t\t\t\t.filter(accept => {\n\t\t\t\t\treturn new RegExp(accept.replace('*', '.*')).test(file.type)\n\t\t\t\t}).length > 0\n\t\t)\n\t} else {\n\t\treturn true\n\t}\n}\n\nexport function fileSizeValidation(file: File, maxSize: number): boolean {\n\tconst fileSize = Math.round(file.size)\n\treturn fileSize <= maxSize\n}\n","import {Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch} from \"@stencil/core\"\nimport {createID} from \"../../../utils/string.utils\"\nimport {FormFileClass} from \"./constants\"\nimport {govHost, toBoolAttr, toBoolAttrIfDefined} from \"../../../helpers/Dom/template\"\nimport {fileAcceptValidation, fileSizeValidation, formatBytes} from \"../../../utils/file.utils\"\nimport {GovForm} from \"../../../helpers/Dom/form.types\"\nimport {GovHost} from \"../../../helpers/Dom/template.types\"\nimport {govForm} from \"../../../helpers/Dom/form\"\nimport {GovFormFileEvent, GovFormFileItem} from \"./gov-form-file.types\"\nimport {inheritAriaAttributes} from \"../../../helpers/Accessibility/accessibility\";\nimport {AttributeObserver, Attributes} from \"../../../helpers/Dom/attribute\";\nimport {ariaAttributes} from \"../../../helpers/Accessibility/attributes\";\n\n@Component({\n\ttag: \"gov-form-file\",\n})\nexport class GovFormFile {\n\tprivate f: GovForm\n\tprivate readonly h: GovHost\n\n\tprivate areaRef?: HTMLDivElement\n\tprivate inputRef?: HTMLInputElement\n\tprivate readonly fileId: string\n\tprivate attributeObserver: AttributeObserver\n\tprivate eventsRegistered = false\n\n\tconstructor() {\n\t\tthis.fileId = createID(\"GovInputFile\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormFileElement\n\t/**\n\t * Expands the file input to fill 100% of the container width.\n\t */\n\t@Prop() readonly expanded: boolean = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the File component disabled.\n\t * This prevents users from being able to interact with the File, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * After selecting the files, the main input element will be reset.\n\t * The propagation of the event with the selected files will not be affected.\n\t */\n\t@Prop({attribute: \"reset-after-pick\"}) readonly resetAfterPick: boolean = false\n\t/**\n\t * Selected files will not be checked for duplicates based on name and size.\n\t */\n\t@Prop({attribute: \"ignore-file-duplication-check\"}) readonly ignoreFileDuplicationCheck: boolean = false\n\t/**\n\t * Show list of attachments\n\t */\n\t@Prop({attribute: \"display-attachments\"}) readonly displayAttachments: boolean = true\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept\n\t */\n\t@Prop() readonly accept: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple\n\t */\n\t@Prop() readonly multiple: boolean = false\n\t/**\n\t * Maximum embedded file size\n\t */\n\t@Prop({attribute: \"max-file-size\"}) readonly maxFileSize: number = -1\n\t/**\n\t * Custom File identifier.\n\t */\n\t@Prop({attribute: \"identifier\"}) readonly identifier: string\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Error message when the maximum file size is exceeded\n\t */\n\t@Prop({attribute: \"error-size\"}) readonly errorSize: string = \"Soubor je větší než povolená velikost {FILE_SIZE}\"\n\t/**\n\t * Insert unsupported file error message\n\t */\n\t@Prop({attribute: \"error-accept\"}) readonly errorAccept: string = \"Soubor tohoto typu není povolen\"\n\t/**\n\t * Adds accessible label for the list of attachments.\n\t */\n\t@Prop({attribute: \"accessible-attachments-label\"}) readonly accessibleAttachmentsLabel: string = \"Přílohy\"\n\t/**\n\t * Emitted when the File has focus.\n\t */\n\t@Event({eventName: \"gov-focus\"}) govFocus: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Emitted when the File loses focus.\n\t */\n\t@Event({eventName: \"gov-blur\"}) govBlur: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when the list of inserted files is changed\n\t */\n\t@Event({eventName: \"gov-files\"}) govFiles: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a new file is added\n\t */\n\t@Event({eventName: \"gov-add-file\"}) govAddFile: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a file is removed from the list\n\t */\n\t@Event({eventName: \"gov-remove-file\"}) govRemoveFile: EventEmitter<GovFormFileEvent>\n\n\n\t@Watch(\"disabled\")\n\t@Watch(\"invalid\")\n\twatchControlAttrs(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\t@State() files: GovFormFileItem[] = []\n\t@State() inheritedAttributes: Attributes = {}\n\n\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl(\"invalid\", toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl(\"disabled\", toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl(\"type\", \"File\")\n\t}\n\n\n\tprivate registerListeners() {\n\t\tif (this.eventsRegistered) {\n\t\t\treturn\n\t\t}\n\t\tthis.eventsRegistered = true\n\n\t\tfunction highlight() {\n\t\t\tthis.areaRef.classList.add(\"highlight\")\n\t\t}\n\n\t\tfunction unhighlight() {\n\t\t\tthis.areaRef.classList.remove(\"highlight\")\n\t\t}\n\n\t\tthis.inputRef.addEventListener(\n\t\t\t\"change\",\n\t\t\te => {\n\t\t\t\te.preventDefault()\n\t\t\t\te.stopPropagation()\n\t\t\t\tconst files = (e.target as HTMLInputElement).files\n\t\t\t\tif (this.resetAfterPick) {\n\t\t\t\t\tif (files.length) {\n\t\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t}\n\t\t\t},\n\t\t\tfalse,\n\t\t)\n\n\t\tif (this.expanded) {\n\t\t\tconst events = [\"dragover\", \"dragleave\"]\n\t\t\tconst inEvents = [\"dragenter\", \"dragover\", \"mouseenter\"]\n\t\t\tconst outEvents = [\"dragleave\", \"mouseleave\"]\n\n\t\t\tevents.map(eventName => this.inputRef.addEventListener(eventName, this.preventDefaults.bind(this), false))\n\t\t\tinEvents.map(eventName => this.inputRef.addEventListener(eventName, highlight.bind(this), false))\n\t\t\toutEvents.forEach(eventName => this.inputRef.addEventListener(eventName, unhighlight.bind(this), false))\n\t\t}\n\t}\n\n\tpreventDefaults(e) {\n\t\te.preventDefault()\n\t\te.stopPropagation()\n\t}\n\n\thandleDrop(e: DragEvent) {\n\t\tconst dataTransfer = e.dataTransfer\n\t\tthis.validateFiles(dataTransfer.files)\n\t}\n\n\tprivate validateFiles(files: FileList) {\n\t\tlet filesBuffer: GovFormFileItem[] = []\n\t\tif (!this.multiple && this.displayAttachments) {\n\t\t\tthis.files = []\n\t\t}\n\t\tArray.from(files).forEach(file => {\n\t\t\tconst isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null\n\t\t\tif (isFile === null || this.ignoreFileDuplicationCheck) {\n\t\t\t\tconst isSizeValid = typeof this.maxFileSize === \"number\" && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true\n\t\t\t\tconst isAcceptValid = fileAcceptValidation(file, this.accept)\n\t\t\t\tconst newFile = {\n\t\t\t\t\tid: createID(\"GovFormFile\"),\n\t\t\t\t\tfile,\n\t\t\t\t\tacceptValid: isAcceptValid,\n\t\t\t\t\tsizeValid: isSizeValid,\n\t\t\t\t}\n\t\t\t\tif (this.displayAttachments) {\n\t\t\t\t\tthis.files = [...this.files, newFile]\n\t\t\t\t} else {\n\t\t\t\t\tfilesBuffer = [...filesBuffer, newFile]\n\t\t\t\t}\n\t\t\t\tthis.govAddFile.emit({\n\t\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\t\tfile: newFile,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tif (this.displayAttachments) {\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\n\t\tthis.govFiles.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\tfiles: filesBuffer.length ? filesBuffer : this.files,\n\t\t})\n\n\t\tif (this.resetAfterPick) {\n\t\t\tthis.reset().finally()\n\t\t}\n\t}\n\n\t// Keep native <input type=\"file\"> in sync with the visible attachments list so\n\t// that a native form submit / FormData carries exactly the files shown in the UI.\n\t// Invalid items (wrong type or oversize) are intentionally excluded.\n\tprivate syncNativeInputFiles() {\n\t\tif (!this.inputRef || typeof DataTransfer === \"undefined\") {\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst dt = new DataTransfer()\n\t\t\tthis.files\n\t\t\t\t.filter(item => item.acceptValid === true && item.sizeValid === true)\n\t\t\t\t.forEach(item => dt.items.add(item.file))\n\t\t\tthis.inputRef.files = dt.files\n\t\t} catch (e) {\n\t\t\t// Safari < 14.1 / older browsers may reject assigning to .files; nothing safe to fall back to.\n\t\t\tif (typeof process !== \"undefined\" && process.env && process.env.NODE_ENV !== \"production\") {\n\t\t\t\tconsole.warn(\"[gov-form-file] Could not sync native input.files:\", e)\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidLoad() {\n\t\tthis.attributeObserver = new AttributeObserver(this.host, (attributeName, newValue) => {\n\t\t\tthis.onAriaAttributeChange(attributeName, newValue);\n\t\t});\n\n\t\tthis.attributeObserver.startObserving(ariaAttributes);\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tthis.passControlAttrs()\n\t\tthis.inheritedAttributes = inheritAriaAttributes(this.host);\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.registerListeners()\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.attributeObserver?.stopObserving();\n\t}\n\n\tonAriaAttributeChange(attributeName: string, newValue: string) {\n\t\tthis.host.removeAttribute(attributeName)\n\t\tthis.inheritedAttributes = {...this.inheritedAttributes, [attributeName]: newValue};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={this.h.classes([FormFileClass.root])}\n\t\t\t\t invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t expanded={toBoolAttrIfDefined(this.expanded)}>\n\t\t\t\t<div class={FormFileClass.area} ref={el => (this.areaRef = el as HTMLDivElement)}>\n\t\t\t\t\t<slot/>\n\t\t\t\t\t<input\n\t\t\t\t\t\tclass={FormFileClass.input}\n\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\tid={this.identifier || this.fileId}\n\t\t\t\t\t\ttype=\"file\"\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\taccept={this.accept}\n\t\t\t\t\t\tmultiple={this.multiple}\n\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t{...this.inheritedAttributes}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t/>\n\t\t\t\t\t<div class={FormFileClass.inputFocus}/>\n\t\t\t\t</div>\n\n\t\t\t\t{this.h.hasSlot(\"attachments\") ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<slot name={\"attachments\"}/>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\n\t\t\t\t{this.files.length && this.displayAttachments ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<gov-attachments label={this.accessibleAttachmentsLabel}\n\t\t\t\t\t\t\t\t\t\t accessible-label={this.accessibleAttachmentsLabel}>\n\t\t\t\t\t\t\t{this.files.map(item => (\n\t\t\t\t\t\t\t\t<gov-attachments-item accessible-remove-labelledby={item.id}\n\t\t\t\t\t\t\t\t\t\t\t\t\t on-gov-remove={() => this.onRemoveFileHandler(item)}>\n\t\t\t\t\t\t\t\t\t{item.file.name}\n\t\t\t\t\t\t\t\t\t<span slot=\"name\">{item.file.name}</span>\n\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? this.errorAccept : null}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t{item.sizeValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{this.errorSize.replace(\"{FILE_SIZE}\", formatBytes(this.maxFileSize))}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t<span slot=\"info\">({formatBytes(item.file.size)})</span>\n\t\t\t\t\t\t\t\t</gov-attachments-item>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</gov-attachments>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onRemoveFileHandler(file: GovFormFileItem) {\n\t\tconst index = this.files.findIndex(item => item.id === file.id)\n\t\tif (index !== -1) {\n\t\t\tconst files = this.files\n\t\t\tconst removeFile = this.files[index]\n\t\t\tfiles.splice(index, 1)\n\t\t\tthis.files = [...files]\n\t\t\tthis.syncNativeInputFiles()\n\t\t\tthis.govRemoveFile.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfile: removeFile,\n\t\t\t})\n\t\t\tthis.govFiles.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfiles,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\te.stopPropagation()\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Returns the reference of the native area element\n\t */\n\t@Method()\n\tasync getAreaRef(): Promise<HTMLDivElement> {\n\t\treturn this.areaRef\n\t}\n\n\t/**\n\t * Remove all files from component state\n\t */\n\t@Method()\n\tasync reset(): Promise<void> {\n\t\tthis.files = []\n\t\tif (this.inputRef) {\n\t\t\tthis.inputRef.value = ''\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\t}\n}\n"],"version":3}
|
|
1
|
+
{"file":"gov-form-file.entry.cjs.js","mappings":";;;;;;;;;;;;;;;AAAO,MAAM,aAAa,GAAG;AAC5B,IAAA,IAAI,EAAE,eAAe;AACrB,IAAA,IAAI,EAAE,qBAAqB;AAC3B,IAAA,KAAK,EAAE,sBAAsB;AAC7B,IAAA,UAAU,EAAE,4BAA4B;AACxC,IAAA,WAAW,EAAE,4BAA4B;CACzC;;ACNK,SAAU,WAAW,CAAC,KAAU,EAAA;IACrC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,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,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACjB,SAAS,EAAE,aAAa,CAAC,IAAI;AAC7B,YAAA,aAAa,EAAE,CAAC;AAChB,SAAA,CAAC;;AAGK,IAAA,eAAe,CAAC,CAAQ,EAAA;QAC/B,CAAC,CAAC,eAAe,EAAE;;AAGpB;;AAEG;AAEH,IAAA,MAAM,MAAM,GAAA;QACX,OAAO,IAAI,CAAC,QAAQ;;AAGrB;;AAEG;AAEH,IAAA,MAAM,UAAU,GAAA;QACf,OAAO,IAAI,CAAC,OAAO;;AAGpB;;AAEG;AAEH,IAAA,MAAM,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,KAAK,GAAG,EAAE;AACf,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;AAClB,YAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE;YACxB,IAAI,CAAC,oBAAoB,EAAE;;;;;;;;;;;;","names":["createID","govHost","govForm","toBoolAttr","AttributeObserver","ariaAttributes","inheritAriaAttributes","h","Host","toBoolAttrIfDefined"],"sources":["../../../packages/core/src/components/gov-form/file/constants.ts","../../../packages/core/src/utils/file.utils.ts","../../../packages/core/src/components/gov-form/file/gov-form-file.tsx"],"sourcesContent":["export const FormFileClass = {\n\troot: 'gov-form-file',\n\tarea: 'gov-form-file__area',\n\tinput: 'gov-form-file__input',\n\tinputFocus: 'gov-form-file__input-focus',\n\tattachments: 'gov-form-file__attachments',\n}\n","export function formatBytes(bytes: any): string {\n\tconst units = ['bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']\n\tlet l = 0,\n\t\tn = parseInt(bytes, 10) || 0\n\n\twhile (n >= 1024 && ++l) {\n\t\tn = n / 1024\n\t}\n\n\treturn n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l]\n}\n\n// Validates a file against an `accept` attribute value, following the HTML spec\n// (https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept):\n// - \".ext\" → matched against the file NAME suffix (case-insensitive)\n// - \"type/*\" → matched against the file MIME group\n// - \"type/sub\" → exact MIME match\n// Matching the name (not only file.type) is essential: browsers often report an\n// empty or non-standard MIME for extensions like .jsonld, which the previous\n// MIME-only RegExp check always rejected.\nexport function fileAcceptValidation(file: File, accept: string): boolean {\n\tif (typeof accept !== 'string' || accept.trim().length === 0) {\n\t\treturn true\n\t}\n\tconst fileName = file.name.toLowerCase()\n\tconst fileType = (file.type || '').toLowerCase()\n\treturn accept\n\t\t.split(',')\n\t\t.map(token => token.trim().toLowerCase())\n\t\t.filter(token => token.length > 0)\n\t\t.some(token => {\n\t\t\tif (token.startsWith('.')) {\n\t\t\t\treturn fileName.endsWith(token)\n\t\t\t}\n\t\t\tif (token === '*' || token === '*/*') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (token.endsWith('/*')) {\n\t\t\t\tconst group = token.slice(0, token.indexOf('/') + 1)\n\t\t\t\treturn fileType.startsWith(group)\n\t\t\t}\n\t\t\treturn fileType === token\n\t\t})\n}\n\nexport function fileSizeValidation(file: File, maxSize: number): boolean {\n\tconst fileSize = Math.round(file.size)\n\treturn fileSize <= maxSize\n}\n","import {Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch} from \"@stencil/core\"\nimport {createID} from \"../../../utils/string.utils\"\nimport {FormFileClass} from \"./constants\"\nimport {govHost, toBoolAttr, toBoolAttrIfDefined} from \"../../../helpers/Dom/template\"\nimport {fileAcceptValidation, fileSizeValidation, formatBytes} from \"../../../utils/file.utils\"\nimport {GovForm} from \"../../../helpers/Dom/form.types\"\nimport {GovHost} from \"../../../helpers/Dom/template.types\"\nimport {govForm} from \"../../../helpers/Dom/form\"\nimport {GovFormFileEvent, GovFormFileItem} from \"./gov-form-file.types\"\nimport {inheritAriaAttributes} from \"../../../helpers/Accessibility/accessibility\";\nimport {AttributeObserver, Attributes} from \"../../../helpers/Dom/attribute\";\nimport {ariaAttributes} from \"../../../helpers/Accessibility/attributes\";\n\n@Component({\n\ttag: \"gov-form-file\",\n})\nexport class GovFormFile {\n\tprivate f: GovForm\n\tprivate readonly h: GovHost\n\n\tprivate areaRef?: HTMLDivElement\n\tprivate inputRef?: HTMLInputElement\n\tprivate readonly fileId: string\n\tprivate attributeObserver: AttributeObserver\n\tprivate eventsRegistered = false\n\n\tconstructor() {\n\t\tthis.fileId = createID(\"GovInputFile\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormFileElement\n\t/**\n\t * Expands the file input to fill 100% of the container width.\n\t */\n\t@Prop() readonly expanded: boolean = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the File component disabled.\n\t * This prevents users from being able to interact with the File, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * After selecting the files, the main input element will be reset.\n\t * The propagation of the event with the selected files will not be affected.\n\t */\n\t@Prop({attribute: \"reset-after-pick\"}) readonly resetAfterPick: boolean = false\n\t/**\n\t * Selected files will not be checked for duplicates based on name and size.\n\t */\n\t@Prop({attribute: \"ignore-file-duplication-check\"}) readonly ignoreFileDuplicationCheck: boolean = false\n\t/**\n\t * Show list of attachments\n\t */\n\t@Prop({attribute: \"display-attachments\"}) readonly displayAttachments: boolean = true\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept\n\t */\n\t@Prop() readonly accept: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple\n\t */\n\t@Prop() readonly multiple: boolean = false\n\t/**\n\t * Maximum embedded file size\n\t */\n\t@Prop({attribute: \"max-file-size\"}) readonly maxFileSize: number = -1\n\t/**\n\t * Custom File identifier.\n\t */\n\t@Prop({attribute: \"identifier\"}) readonly identifier: string\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Error message when the maximum file size is exceeded\n\t */\n\t@Prop({attribute: \"error-size\"}) readonly errorSize: string = \"Soubor je větší než povolená velikost {FILE_SIZE}\"\n\t/**\n\t * Insert unsupported file error message\n\t */\n\t@Prop({attribute: \"error-accept\"}) readonly errorAccept: string = \"Soubor tohoto typu není povolen\"\n\t/**\n\t * Adds accessible label for the list of attachments.\n\t */\n\t@Prop({attribute: \"accessible-attachments-label\"}) readonly accessibleAttachmentsLabel: string = \"Přílohy\"\n\t/**\n\t * Emitted when the File has focus.\n\t */\n\t@Event({eventName: \"gov-focus\"}) govFocus: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Emitted when the File loses focus.\n\t */\n\t@Event({eventName: \"gov-blur\"}) govBlur: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when the list of inserted files is changed\n\t */\n\t@Event({eventName: \"gov-files\"}) govFiles: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a new file is added\n\t */\n\t@Event({eventName: \"gov-add-file\"}) govAddFile: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a file is removed from the list\n\t */\n\t@Event({eventName: \"gov-remove-file\"}) govRemoveFile: EventEmitter<GovFormFileEvent>\n\n\n\t@Watch(\"disabled\")\n\t@Watch(\"invalid\")\n\twatchControlAttrs(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\t@State() files: GovFormFileItem[] = []\n\t@State() inheritedAttributes: Attributes = {}\n\n\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl(\"invalid\", toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl(\"disabled\", toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl(\"type\", \"File\")\n\t}\n\n\n\tprivate registerListeners() {\n\t\tif (this.eventsRegistered) {\n\t\t\treturn\n\t\t}\n\t\tthis.eventsRegistered = true\n\n\t\tfunction highlight() {\n\t\t\tthis.areaRef.classList.add(\"highlight\")\n\t\t}\n\n\t\tfunction unhighlight() {\n\t\t\tthis.areaRef.classList.remove(\"highlight\")\n\t\t}\n\n\t\tthis.inputRef.addEventListener(\n\t\t\t\"change\",\n\t\t\te => {\n\t\t\t\te.preventDefault()\n\t\t\t\te.stopPropagation()\n\t\t\t\tconst files = (e.target as HTMLInputElement).files\n\t\t\t\tif (this.resetAfterPick) {\n\t\t\t\t\tif (files.length) {\n\t\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t}\n\t\t\t},\n\t\t\tfalse,\n\t\t)\n\n\t\tif (this.expanded) {\n\t\t\tconst events = [\"dragover\", \"dragleave\"]\n\t\t\tconst inEvents = [\"dragenter\", \"dragover\", \"mouseenter\"]\n\t\t\tconst outEvents = [\"dragleave\", \"mouseleave\"]\n\n\t\t\tevents.map(eventName => this.inputRef.addEventListener(eventName, this.preventDefaults.bind(this), false))\n\t\t\tinEvents.map(eventName => this.inputRef.addEventListener(eventName, highlight.bind(this), false))\n\t\t\toutEvents.forEach(eventName => this.inputRef.addEventListener(eventName, unhighlight.bind(this), false))\n\t\t}\n\t}\n\n\tpreventDefaults(e) {\n\t\te.preventDefault()\n\t\te.stopPropagation()\n\t}\n\n\thandleDrop(e: DragEvent) {\n\t\tconst dataTransfer = e.dataTransfer\n\t\tthis.validateFiles(dataTransfer.files)\n\t}\n\n\tprivate validateFiles(files: FileList) {\n\t\tlet filesBuffer: GovFormFileItem[] = []\n\t\t// Without `multiple`, only a single file is allowed. An incoming batch\n\t\t// (drag-drop, framework wrapper, programmatic assignment) can still carry\n\t\t// several files, so cap it to the last one — consistent with the\n\t\t// \"second pick replaces the first\" semantics. (Bug #30570313)\n\t\tconst incoming = this.multiple ? Array.from(files) : Array.from(files).slice(-1)\n\t\tif (!this.multiple && this.displayAttachments) {\n\t\t\tthis.files = []\n\t\t}\n\t\tincoming.forEach(file => {\n\t\t\tconst isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null\n\t\t\tif (isFile === null || this.ignoreFileDuplicationCheck) {\n\t\t\t\tconst isSizeValid = typeof this.maxFileSize === \"number\" && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true\n\t\t\t\tconst isAcceptValid = fileAcceptValidation(file, this.accept)\n\t\t\t\tconst newFile = {\n\t\t\t\t\tid: createID(\"GovFormFile\"),\n\t\t\t\t\tfile,\n\t\t\t\t\tacceptValid: isAcceptValid,\n\t\t\t\t\tsizeValid: isSizeValid,\n\t\t\t\t}\n\t\t\t\tif (this.displayAttachments) {\n\t\t\t\t\tthis.files = [...this.files, newFile]\n\t\t\t\t} else {\n\t\t\t\t\tfilesBuffer = [...filesBuffer, newFile]\n\t\t\t\t}\n\t\t\t\tthis.govAddFile.emit({\n\t\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\t\tfile: newFile,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tif (this.displayAttachments) {\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\n\t\tthis.govFiles.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\tfiles: filesBuffer.length ? filesBuffer : this.files,\n\t\t})\n\n\t\tif (this.resetAfterPick) {\n\t\t\tthis.reset().finally()\n\t\t}\n\t}\n\n\t// Keep native <input type=\"file\"> in sync with the visible attachments list so\n\t// that a native form submit / FormData carries exactly the files shown in the UI.\n\t// Invalid items (wrong type or oversize) are intentionally excluded.\n\tprivate syncNativeInputFiles() {\n\t\tif (!this.inputRef || typeof DataTransfer === \"undefined\") {\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst dt = new DataTransfer()\n\t\t\tthis.files\n\t\t\t\t.filter(item => item.acceptValid === true && item.sizeValid === true)\n\t\t\t\t.forEach(item => dt.items.add(item.file))\n\t\t\tthis.inputRef.files = dt.files\n\t\t} catch (e) {\n\t\t\t// Safari < 14.1 / older browsers may reject assigning to .files; nothing safe to fall back to.\n\t\t\tif (typeof process !== \"undefined\" && process.env && process.env.NODE_ENV !== \"production\") {\n\t\t\t\tconsole.warn(\"[gov-form-file] Could not sync native input.files:\", e)\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidLoad() {\n\t\tthis.attributeObserver = new AttributeObserver(this.host, (attributeName, newValue) => {\n\t\t\tthis.onAriaAttributeChange(attributeName, newValue);\n\t\t});\n\n\t\tthis.attributeObserver.startObserving(ariaAttributes);\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tthis.passControlAttrs()\n\t\tthis.inheritedAttributes = inheritAriaAttributes(this.host);\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.registerListeners()\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.attributeObserver?.stopObserving();\n\t}\n\n\tonAriaAttributeChange(attributeName: string, newValue: string) {\n\t\tthis.host.removeAttribute(attributeName)\n\t\tthis.inheritedAttributes = {...this.inheritedAttributes, [attributeName]: newValue};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={this.h.classes([FormFileClass.root])}\n\t\t\t\t invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t expanded={toBoolAttrIfDefined(this.expanded)}>\n\t\t\t\t<div class={FormFileClass.area} ref={el => (this.areaRef = el as HTMLDivElement)}>\n\t\t\t\t\t<slot/>\n\t\t\t\t\t<input\n\t\t\t\t\t\tclass={FormFileClass.input}\n\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\tid={this.identifier || this.fileId}\n\t\t\t\t\t\ttype=\"file\"\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\taccept={this.accept}\n\t\t\t\t\t\tmultiple={this.multiple}\n\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t{...this.inheritedAttributes}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t/>\n\t\t\t\t\t<div class={FormFileClass.inputFocus}/>\n\t\t\t\t</div>\n\n\t\t\t\t{this.h.hasSlot(\"attachments\") ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<slot name={\"attachments\"}/>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\n\t\t\t\t{this.files.length && this.displayAttachments ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<gov-attachments label={this.accessibleAttachmentsLabel}\n\t\t\t\t\t\t\t\t\t\t accessible-label={this.accessibleAttachmentsLabel}>\n\t\t\t\t\t\t\t{this.files.map(item => (\n\t\t\t\t\t\t\t\t<gov-attachments-item accessible-remove-labelledby={item.id}\n\t\t\t\t\t\t\t\t\t\t\t\t\t on-gov-remove={() => this.onRemoveFileHandler(item)}>\n\t\t\t\t\t\t\t\t\t{item.file.name}\n\t\t\t\t\t\t\t\t\t<span slot=\"name\">{item.file.name}</span>\n\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? this.errorAccept : null}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t{item.sizeValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{this.errorSize.replace(\"{FILE_SIZE}\", formatBytes(this.maxFileSize))}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t<span slot=\"info\">({formatBytes(item.file.size)})</span>\n\t\t\t\t\t\t\t\t</gov-attachments-item>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</gov-attachments>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onRemoveFileHandler(file: GovFormFileItem) {\n\t\tconst index = this.files.findIndex(item => item.id === file.id)\n\t\tif (index !== -1) {\n\t\t\tconst files = this.files\n\t\t\tconst removeFile = this.files[index]\n\t\t\tfiles.splice(index, 1)\n\t\t\tthis.files = [...files]\n\t\t\tthis.syncNativeInputFiles()\n\t\t\tthis.govRemoveFile.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfile: removeFile,\n\t\t\t})\n\t\t\tthis.govFiles.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfiles,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\te.stopPropagation()\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Returns the reference of the native area element\n\t */\n\t@Method()\n\tasync getAreaRef(): Promise<HTMLDivElement> {\n\t\treturn this.areaRef\n\t}\n\n\t/**\n\t * Remove all files from component state\n\t */\n\t@Method()\n\tasync reset(): Promise<void> {\n\t\tthis.files = []\n\t\tif (this.inputRef) {\n\t\t\tthis.inputRef.value = ''\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\t}\n}\n"],"version":3}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gov-form-file.entry.cjs.js","sources":["../../../packages/core/src/components/gov-form/file/constants.ts","../../../packages/core/src/utils/file.utils.ts","../../../packages/core/src/components/gov-form/file/gov-form-file.tsx"],"sourcesContent":["export const FormFileClass = {\n\troot: 'gov-form-file',\n\tarea: 'gov-form-file__area',\n\tinput: 'gov-form-file__input',\n\tinputFocus: 'gov-form-file__input-focus',\n\tattachments: 'gov-form-file__attachments',\n}\n","export function formatBytes(bytes: any): string {\n\tconst units = ['bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']\n\tlet l = 0,\n\t\tn = parseInt(bytes, 10) || 0\n\n\twhile (n >= 1024 && ++l) {\n\t\tn = n / 1024\n\t}\n\n\treturn n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l]\n}\n\nexport function fileAcceptValidation(file: File, accept: string): boolean {\n\tif (typeof accept === 'string' && accept.length) {\n\t\treturn (\n\t\t\taccept\n\t\t\t\t.replace(/\\s/g, '')\n\t\t\t\t.split(',')\n\t\t\t\t.filter(accept => {\n\t\t\t\t\treturn new RegExp(accept.replace('*', '.*')).test(file.type)\n\t\t\t\t}).length > 0\n\t\t)\n\t} else {\n\t\treturn true\n\t}\n}\n\nexport function fileSizeValidation(file: File, maxSize: number): boolean {\n\tconst fileSize = Math.round(file.size)\n\treturn fileSize <= maxSize\n}\n","import {Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch} from \"@stencil/core\"\nimport {createID} from \"../../../utils/string.utils\"\nimport {FormFileClass} from \"./constants\"\nimport {govHost, toBoolAttr, toBoolAttrIfDefined} from \"../../../helpers/Dom/template\"\nimport {fileAcceptValidation, fileSizeValidation, formatBytes} from \"../../../utils/file.utils\"\nimport {GovForm} from \"../../../helpers/Dom/form.types\"\nimport {GovHost} from \"../../../helpers/Dom/template.types\"\nimport {govForm} from \"../../../helpers/Dom/form\"\nimport {GovFormFileEvent, GovFormFileItem} from \"./gov-form-file.types\"\nimport {inheritAriaAttributes} from \"../../../helpers/Accessibility/accessibility\";\nimport {AttributeObserver, Attributes} from \"../../../helpers/Dom/attribute\";\nimport {ariaAttributes} from \"../../../helpers/Accessibility/attributes\";\n\n@Component({\n\ttag: \"gov-form-file\",\n})\nexport class GovFormFile {\n\tprivate f: GovForm\n\tprivate readonly h: GovHost\n\n\tprivate areaRef?: HTMLDivElement\n\tprivate inputRef?: HTMLInputElement\n\tprivate readonly fileId: string\n\tprivate attributeObserver: AttributeObserver\n\tprivate eventsRegistered = false\n\n\tconstructor() {\n\t\tthis.fileId = createID(\"GovInputFile\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormFileElement\n\t/**\n\t * Expands the file input to fill 100% of the container width.\n\t */\n\t@Prop() readonly expanded: boolean = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the File component disabled.\n\t * This prevents users from being able to interact with the File, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * After selecting the files, the main input element will be reset.\n\t * The propagation of the event with the selected files will not be affected.\n\t */\n\t@Prop({attribute: \"reset-after-pick\"}) readonly resetAfterPick: boolean = false\n\t/**\n\t * Selected files will not be checked for duplicates based on name and size.\n\t */\n\t@Prop({attribute: \"ignore-file-duplication-check\"}) readonly ignoreFileDuplicationCheck: boolean = false\n\t/**\n\t * Show list of attachments\n\t */\n\t@Prop({attribute: \"display-attachments\"}) readonly displayAttachments: boolean = true\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept\n\t */\n\t@Prop() readonly accept: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple\n\t */\n\t@Prop() readonly multiple: boolean = false\n\t/**\n\t * Maximum embedded file size\n\t */\n\t@Prop({attribute: \"max-file-size\"}) readonly maxFileSize: number = -1\n\t/**\n\t * Custom File identifier.\n\t */\n\t@Prop({attribute: \"identifier\"}) readonly identifier: string\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Error message when the maximum file size is exceeded\n\t */\n\t@Prop({attribute: \"error-size\"}) readonly errorSize: string = \"Soubor je větší než povolená velikost {FILE_SIZE}\"\n\t/**\n\t * Insert unsupported file error message\n\t */\n\t@Prop({attribute: \"error-accept\"}) readonly errorAccept: string = \"Soubor tohoto typu není povolen\"\n\t/**\n\t * Adds accessible label for the list of attachments.\n\t */\n\t@Prop({attribute: \"accessible-attachments-label\"}) readonly accessibleAttachmentsLabel: string = \"Přílohy\"\n\t/**\n\t * Emitted when the File has focus.\n\t */\n\t@Event({eventName: \"gov-focus\"}) govFocus: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Emitted when the File loses focus.\n\t */\n\t@Event({eventName: \"gov-blur\"}) govBlur: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when the list of inserted files is changed\n\t */\n\t@Event({eventName: \"gov-files\"}) govFiles: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a new file is added\n\t */\n\t@Event({eventName: \"gov-add-file\"}) govAddFile: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a file is removed from the list\n\t */\n\t@Event({eventName: \"gov-remove-file\"}) govRemoveFile: EventEmitter<GovFormFileEvent>\n\n\n\t@Watch(\"disabled\")\n\t@Watch(\"invalid\")\n\twatchControlAttrs(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\t@State() files: GovFormFileItem[] = []\n\t@State() inheritedAttributes: Attributes = {}\n\n\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl(\"invalid\", toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl(\"disabled\", toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl(\"type\", \"File\")\n\t}\n\n\n\tprivate registerListeners() {\n\t\tif (this.eventsRegistered) {\n\t\t\treturn\n\t\t}\n\t\tthis.eventsRegistered = true\n\n\t\tfunction highlight() {\n\t\t\tthis.areaRef.classList.add(\"highlight\")\n\t\t}\n\n\t\tfunction unhighlight() {\n\t\t\tthis.areaRef.classList.remove(\"highlight\")\n\t\t}\n\n\t\tthis.inputRef.addEventListener(\n\t\t\t\"change\",\n\t\t\te => {\n\t\t\t\te.preventDefault()\n\t\t\t\te.stopPropagation()\n\t\t\t\tconst files = (e.target as HTMLInputElement).files\n\t\t\t\tif (this.resetAfterPick) {\n\t\t\t\t\tif (files.length) {\n\t\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t}\n\t\t\t},\n\t\t\tfalse,\n\t\t)\n\n\t\tif (this.expanded) {\n\t\t\tconst events = [\"dragover\", \"dragleave\"]\n\t\t\tconst inEvents = [\"dragenter\", \"dragover\", \"mouseenter\"]\n\t\t\tconst outEvents = [\"dragleave\", \"mouseleave\"]\n\n\t\t\tevents.map(eventName => this.inputRef.addEventListener(eventName, this.preventDefaults.bind(this), false))\n\t\t\tinEvents.map(eventName => this.inputRef.addEventListener(eventName, highlight.bind(this), false))\n\t\t\toutEvents.forEach(eventName => this.inputRef.addEventListener(eventName, unhighlight.bind(this), false))\n\t\t}\n\t}\n\n\tpreventDefaults(e) {\n\t\te.preventDefault()\n\t\te.stopPropagation()\n\t}\n\n\thandleDrop(e: DragEvent) {\n\t\tconst dataTransfer = e.dataTransfer\n\t\tthis.validateFiles(dataTransfer.files)\n\t}\n\n\tprivate validateFiles(files: FileList) {\n\t\tlet filesBuffer: GovFormFileItem[] = []\n\t\tif (!this.multiple && this.displayAttachments) {\n\t\t\tthis.files = []\n\t\t}\n\t\tArray.from(files).forEach(file => {\n\t\t\tconst isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null\n\t\t\tif (isFile === null || this.ignoreFileDuplicationCheck) {\n\t\t\t\tconst isSizeValid = typeof this.maxFileSize === \"number\" && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true\n\t\t\t\tconst isAcceptValid = fileAcceptValidation(file, this.accept)\n\t\t\t\tconst newFile = {\n\t\t\t\t\tid: createID(\"GovFormFile\"),\n\t\t\t\t\tfile,\n\t\t\t\t\tacceptValid: isAcceptValid,\n\t\t\t\t\tsizeValid: isSizeValid,\n\t\t\t\t}\n\t\t\t\tif (this.displayAttachments) {\n\t\t\t\t\tthis.files = [...this.files, newFile]\n\t\t\t\t} else {\n\t\t\t\t\tfilesBuffer = [...filesBuffer, newFile]\n\t\t\t\t}\n\t\t\t\tthis.govAddFile.emit({\n\t\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\t\tfile: newFile,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tif (this.displayAttachments) {\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\n\t\tthis.govFiles.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\tfiles: filesBuffer.length ? filesBuffer : this.files,\n\t\t})\n\n\t\tif (this.resetAfterPick) {\n\t\t\tthis.reset().finally()\n\t\t}\n\t}\n\n\t// Keep native <input type=\"file\"> in sync with the visible attachments list so\n\t// that a native form submit / FormData carries exactly the files shown in the UI.\n\t// Invalid items (wrong type or oversize) are intentionally excluded.\n\tprivate syncNativeInputFiles() {\n\t\tif (!this.inputRef || typeof DataTransfer === \"undefined\") {\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst dt = new DataTransfer()\n\t\t\tthis.files\n\t\t\t\t.filter(item => item.acceptValid === true && item.sizeValid === true)\n\t\t\t\t.forEach(item => dt.items.add(item.file))\n\t\t\tthis.inputRef.files = dt.files\n\t\t} catch (e) {\n\t\t\t// Safari < 14.1 / older browsers may reject assigning to .files; nothing safe to fall back to.\n\t\t\tif (typeof process !== \"undefined\" && process.env && process.env.NODE_ENV !== \"production\") {\n\t\t\t\tconsole.warn(\"[gov-form-file] Could not sync native input.files:\", e)\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidLoad() {\n\t\tthis.attributeObserver = new AttributeObserver(this.host, (attributeName, newValue) => {\n\t\t\tthis.onAriaAttributeChange(attributeName, newValue);\n\t\t});\n\n\t\tthis.attributeObserver.startObserving(ariaAttributes);\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tthis.passControlAttrs()\n\t\tthis.inheritedAttributes = inheritAriaAttributes(this.host);\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.registerListeners()\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.attributeObserver?.stopObserving();\n\t}\n\n\tonAriaAttributeChange(attributeName: string, newValue: string) {\n\t\tthis.host.removeAttribute(attributeName)\n\t\tthis.inheritedAttributes = {...this.inheritedAttributes, [attributeName]: newValue};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={this.h.classes([FormFileClass.root])}\n\t\t\t\t invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t expanded={toBoolAttrIfDefined(this.expanded)}>\n\t\t\t\t<div class={FormFileClass.area} ref={el => (this.areaRef = el as HTMLDivElement)}>\n\t\t\t\t\t<slot/>\n\t\t\t\t\t<input\n\t\t\t\t\t\tclass={FormFileClass.input}\n\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\tid={this.identifier || this.fileId}\n\t\t\t\t\t\ttype=\"file\"\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\taccept={this.accept}\n\t\t\t\t\t\tmultiple={this.multiple}\n\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t{...this.inheritedAttributes}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t/>\n\t\t\t\t\t<div class={FormFileClass.inputFocus}/>\n\t\t\t\t</div>\n\n\t\t\t\t{this.h.hasSlot(\"attachments\") ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<slot name={\"attachments\"}/>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\n\t\t\t\t{this.files.length && this.displayAttachments ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<gov-attachments label={this.accessibleAttachmentsLabel}\n\t\t\t\t\t\t\t\t\t\t accessible-label={this.accessibleAttachmentsLabel}>\n\t\t\t\t\t\t\t{this.files.map(item => (\n\t\t\t\t\t\t\t\t<gov-attachments-item accessible-remove-labelledby={item.id}\n\t\t\t\t\t\t\t\t\t\t\t\t\t on-gov-remove={() => this.onRemoveFileHandler(item)}>\n\t\t\t\t\t\t\t\t\t{item.file.name}\n\t\t\t\t\t\t\t\t\t<span slot=\"name\">{item.file.name}</span>\n\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? this.errorAccept : null}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t{item.sizeValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{this.errorSize.replace(\"{FILE_SIZE}\", formatBytes(this.maxFileSize))}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t<span slot=\"info\">({formatBytes(item.file.size)})</span>\n\t\t\t\t\t\t\t\t</gov-attachments-item>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</gov-attachments>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onRemoveFileHandler(file: GovFormFileItem) {\n\t\tconst index = this.files.findIndex(item => item.id === file.id)\n\t\tif (index !== -1) {\n\t\t\tconst files = this.files\n\t\t\tconst removeFile = this.files[index]\n\t\t\tfiles.splice(index, 1)\n\t\t\tthis.files = [...files]\n\t\t\tthis.syncNativeInputFiles()\n\t\t\tthis.govRemoveFile.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfile: removeFile,\n\t\t\t})\n\t\t\tthis.govFiles.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfiles,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\te.stopPropagation()\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Returns the reference of the native area element\n\t */\n\t@Method()\n\tasync getAreaRef(): Promise<HTMLDivElement> {\n\t\treturn this.areaRef\n\t}\n\n\t/**\n\t * Remove all files from component state\n\t */\n\t@Method()\n\tasync reset(): Promise<void> {\n\t\tthis.files = []\n\t\tif (this.inputRef) {\n\t\t\tthis.inputRef.value = ''\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\t}\n}\n"],"names":["createID","govHost","govForm","toBoolAttr","AttributeObserver","ariaAttributes","inheritAriaAttributes","h","Host","toBoolAttrIfDefined"],"mappings":";;;;;;;;;;;;;;;AAAO,MAAM,aAAa,GAAG;AAC5B,IAAA,IAAI,EAAE,eAAe;AACrB,IAAA,IAAI,EAAE,qBAAqB;AAC3B,IAAA,KAAK,EAAE,sBAAsB;AAC7B,IAAA,UAAU,EAAE,4BAA4B;AACxC,IAAA,WAAW,EAAE,4BAA4B;CACzC;;ACNK,SAAU,WAAW,CAAC,KAAU,EAAA;IACrC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;AAC/E,IAAA,IAAI,CAAC,GAAG,CAAC,EACR,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE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AE,aAAa,CAAC,IAAI;gBAC7B,KAAK;AACL,aAAA,CAAC;;;AAII,IAAA,cAAc,CAAC,CAAa,EAAA;QACnC,CAAC,CAAC,eAAe,EAAE;AACnB,QAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAClB,SAAS,EAAE,aAAa,CAAC,IAAI;AAC7B,YAAA,aAAa,EAAE,CAAC;AAChB,SAAA,CAAC;;AAGK,IAAA,aAAa,CAAC,CAAa,EAAA;QAClC,CAAC,CAAC,eAAe,EAAE;AACnB,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACjB,SAAS,EAAE,aAAa,CAAC,IAAI;AAC7B,YAAA,aAAa,EAAE,CAAC;AAChB,SAAA,CAAC;;AAGK,IAAA,eAAe,CAAC,CAAQ,EAAA;QAC/B,CAAC,CAAC,eAAe,EAAE;;AAGpB;;AAEG;AAEH,IAAA,MAAM,MAAM,GAAA;QACX,OAAO,IAAI,CAAC,QAAQ;;AAGrB;;AAEG;AAEH,IAAA,MAAM,UAAU,GAAA;QACf,OAAO,IAAI,CAAC,OAAO;;AAGpB;;AAEG;AAEH,IAAA,MAAM,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,KAAK,GAAG,EAAE;AACf,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;AAClB,YAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE;YACxB,IAAI,CAAC,oBAAoB,EAAE;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"gov-form-file.entry.cjs.js","sources":["../../../packages/core/src/components/gov-form/file/constants.ts","../../../packages/core/src/utils/file.utils.ts","../../../packages/core/src/components/gov-form/file/gov-form-file.tsx"],"sourcesContent":["export const FormFileClass = {\n\troot: 'gov-form-file',\n\tarea: 'gov-form-file__area',\n\tinput: 'gov-form-file__input',\n\tinputFocus: 'gov-form-file__input-focus',\n\tattachments: 'gov-form-file__attachments',\n}\n","export function formatBytes(bytes: any): string {\n\tconst units = ['bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']\n\tlet l = 0,\n\t\tn = parseInt(bytes, 10) || 0\n\n\twhile (n >= 1024 && ++l) {\n\t\tn = n / 1024\n\t}\n\n\treturn n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l]\n}\n\n// Validates a file against an `accept` attribute value, following the HTML spec\n// (https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept):\n// - \".ext\" → matched against the file NAME suffix (case-insensitive)\n// - \"type/*\" → matched against the file MIME group\n// - \"type/sub\" → exact MIME match\n// Matching the name (not only file.type) is essential: browsers often report an\n// empty or non-standard MIME for extensions like .jsonld, which the previous\n// MIME-only RegExp check always rejected.\nexport function fileAcceptValidation(file: File, accept: string): boolean {\n\tif (typeof accept !== 'string' || accept.trim().length === 0) {\n\t\treturn true\n\t}\n\tconst fileName = file.name.toLowerCase()\n\tconst fileType = (file.type || '').toLowerCase()\n\treturn accept\n\t\t.split(',')\n\t\t.map(token => token.trim().toLowerCase())\n\t\t.filter(token => token.length > 0)\n\t\t.some(token => {\n\t\t\tif (token.startsWith('.')) {\n\t\t\t\treturn fileName.endsWith(token)\n\t\t\t}\n\t\t\tif (token === '*' || token === '*/*') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (token.endsWith('/*')) {\n\t\t\t\tconst group = token.slice(0, token.indexOf('/') + 1)\n\t\t\t\treturn fileType.startsWith(group)\n\t\t\t}\n\t\t\treturn fileType === token\n\t\t})\n}\n\nexport function fileSizeValidation(file: File, maxSize: number): boolean {\n\tconst fileSize = Math.round(file.size)\n\treturn fileSize <= maxSize\n}\n","import {Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch} from \"@stencil/core\"\nimport {createID} from \"../../../utils/string.utils\"\nimport {FormFileClass} from \"./constants\"\nimport {govHost, toBoolAttr, toBoolAttrIfDefined} from \"../../../helpers/Dom/template\"\nimport {fileAcceptValidation, fileSizeValidation, formatBytes} from \"../../../utils/file.utils\"\nimport {GovForm} from \"../../../helpers/Dom/form.types\"\nimport {GovHost} from \"../../../helpers/Dom/template.types\"\nimport {govForm} from \"../../../helpers/Dom/form\"\nimport {GovFormFileEvent, GovFormFileItem} from \"./gov-form-file.types\"\nimport {inheritAriaAttributes} from \"../../../helpers/Accessibility/accessibility\";\nimport {AttributeObserver, Attributes} from \"../../../helpers/Dom/attribute\";\nimport {ariaAttributes} from \"../../../helpers/Accessibility/attributes\";\n\n@Component({\n\ttag: \"gov-form-file\",\n})\nexport class GovFormFile {\n\tprivate f: GovForm\n\tprivate readonly h: GovHost\n\n\tprivate areaRef?: HTMLDivElement\n\tprivate inputRef?: HTMLInputElement\n\tprivate readonly fileId: string\n\tprivate attributeObserver: AttributeObserver\n\tprivate eventsRegistered = false\n\n\tconstructor() {\n\t\tthis.fileId = createID(\"GovInputFile\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormFileElement\n\t/**\n\t * Expands the file input to fill 100% of the container width.\n\t */\n\t@Prop() readonly expanded: boolean = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the File component disabled.\n\t * This prevents users from being able to interact with the File, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * After selecting the files, the main input element will be reset.\n\t * The propagation of the event with the selected files will not be affected.\n\t */\n\t@Prop({attribute: \"reset-after-pick\"}) readonly resetAfterPick: boolean = false\n\t/**\n\t * Selected files will not be checked for duplicates based on name and size.\n\t */\n\t@Prop({attribute: \"ignore-file-duplication-check\"}) readonly ignoreFileDuplicationCheck: boolean = false\n\t/**\n\t * Show list of attachments\n\t */\n\t@Prop({attribute: \"display-attachments\"}) readonly displayAttachments: boolean = true\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept\n\t */\n\t@Prop() readonly accept: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple\n\t */\n\t@Prop() readonly multiple: boolean = false\n\t/**\n\t * Maximum embedded file size\n\t */\n\t@Prop({attribute: \"max-file-size\"}) readonly maxFileSize: number = -1\n\t/**\n\t * Custom File identifier.\n\t */\n\t@Prop({attribute: \"identifier\"}) readonly identifier: string\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Error message when the maximum file size is exceeded\n\t */\n\t@Prop({attribute: \"error-size\"}) readonly errorSize: string = \"Soubor je větší než povolená velikost {FILE_SIZE}\"\n\t/**\n\t * Insert unsupported file error message\n\t */\n\t@Prop({attribute: \"error-accept\"}) readonly errorAccept: string = \"Soubor tohoto typu není povolen\"\n\t/**\n\t * Adds accessible label for the list of attachments.\n\t */\n\t@Prop({attribute: \"accessible-attachments-label\"}) readonly accessibleAttachmentsLabel: string = \"Přílohy\"\n\t/**\n\t * Emitted when the File has focus.\n\t */\n\t@Event({eventName: \"gov-focus\"}) govFocus: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Emitted when the File loses focus.\n\t */\n\t@Event({eventName: \"gov-blur\"}) govBlur: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when the list of inserted files is changed\n\t */\n\t@Event({eventName: \"gov-files\"}) govFiles: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a new file is added\n\t */\n\t@Event({eventName: \"gov-add-file\"}) govAddFile: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a file is removed from the list\n\t */\n\t@Event({eventName: \"gov-remove-file\"}) govRemoveFile: EventEmitter<GovFormFileEvent>\n\n\n\t@Watch(\"disabled\")\n\t@Watch(\"invalid\")\n\twatchControlAttrs(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\t@State() files: GovFormFileItem[] = []\n\t@State() inheritedAttributes: Attributes = {}\n\n\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl(\"invalid\", toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl(\"disabled\", toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl(\"type\", \"File\")\n\t}\n\n\n\tprivate registerListeners() {\n\t\tif (this.eventsRegistered) {\n\t\t\treturn\n\t\t}\n\t\tthis.eventsRegistered = true\n\n\t\tfunction highlight() {\n\t\t\tthis.areaRef.classList.add(\"highlight\")\n\t\t}\n\n\t\tfunction unhighlight() {\n\t\t\tthis.areaRef.classList.remove(\"highlight\")\n\t\t}\n\n\t\tthis.inputRef.addEventListener(\n\t\t\t\"change\",\n\t\t\te => {\n\t\t\t\te.preventDefault()\n\t\t\t\te.stopPropagation()\n\t\t\t\tconst files = (e.target as HTMLInputElement).files\n\t\t\t\tif (this.resetAfterPick) {\n\t\t\t\t\tif (files.length) {\n\t\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t}\n\t\t\t},\n\t\t\tfalse,\n\t\t)\n\n\t\tif (this.expanded) {\n\t\t\tconst events = [\"dragover\", \"dragleave\"]\n\t\t\tconst inEvents = [\"dragenter\", \"dragover\", \"mouseenter\"]\n\t\t\tconst outEvents = [\"dragleave\", \"mouseleave\"]\n\n\t\t\tevents.map(eventName => this.inputRef.addEventListener(eventName, this.preventDefaults.bind(this), false))\n\t\t\tinEvents.map(eventName => this.inputRef.addEventListener(eventName, highlight.bind(this), false))\n\t\t\toutEvents.forEach(eventName => this.inputRef.addEventListener(eventName, unhighlight.bind(this), false))\n\t\t}\n\t}\n\n\tpreventDefaults(e) {\n\t\te.preventDefault()\n\t\te.stopPropagation()\n\t}\n\n\thandleDrop(e: DragEvent) {\n\t\tconst dataTransfer = e.dataTransfer\n\t\tthis.validateFiles(dataTransfer.files)\n\t}\n\n\tprivate validateFiles(files: FileList) {\n\t\tlet filesBuffer: GovFormFileItem[] = []\n\t\t// Without `multiple`, only a single file is allowed. An incoming batch\n\t\t// (drag-drop, framework wrapper, programmatic assignment) can still carry\n\t\t// several files, so cap it to the last one — consistent with the\n\t\t// \"second pick replaces the first\" semantics. (Bug #30570313)\n\t\tconst incoming = this.multiple ? Array.from(files) : Array.from(files).slice(-1)\n\t\tif (!this.multiple && this.displayAttachments) {\n\t\t\tthis.files = []\n\t\t}\n\t\tincoming.forEach(file => {\n\t\t\tconst isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null\n\t\t\tif (isFile === null || this.ignoreFileDuplicationCheck) {\n\t\t\t\tconst isSizeValid = typeof this.maxFileSize === \"number\" && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true\n\t\t\t\tconst isAcceptValid = fileAcceptValidation(file, this.accept)\n\t\t\t\tconst newFile = {\n\t\t\t\t\tid: createID(\"GovFormFile\"),\n\t\t\t\t\tfile,\n\t\t\t\t\tacceptValid: isAcceptValid,\n\t\t\t\t\tsizeValid: isSizeValid,\n\t\t\t\t}\n\t\t\t\tif (this.displayAttachments) {\n\t\t\t\t\tthis.files = [...this.files, newFile]\n\t\t\t\t} else {\n\t\t\t\t\tfilesBuffer = [...filesBuffer, newFile]\n\t\t\t\t}\n\t\t\t\tthis.govAddFile.emit({\n\t\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\t\tfile: newFile,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tif (this.displayAttachments) {\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\n\t\tthis.govFiles.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\tfiles: filesBuffer.length ? filesBuffer : this.files,\n\t\t})\n\n\t\tif (this.resetAfterPick) {\n\t\t\tthis.reset().finally()\n\t\t}\n\t}\n\n\t// Keep native <input type=\"file\"> in sync with the visible attachments list so\n\t// that a native form submit / FormData carries exactly the files shown in the UI.\n\t// Invalid items (wrong type or oversize) are intentionally excluded.\n\tprivate syncNativeInputFiles() {\n\t\tif (!this.inputRef || typeof DataTransfer === \"undefined\") {\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst dt = new DataTransfer()\n\t\t\tthis.files\n\t\t\t\t.filter(item => item.acceptValid === true && item.sizeValid === true)\n\t\t\t\t.forEach(item => dt.items.add(item.file))\n\t\t\tthis.inputRef.files = dt.files\n\t\t} catch (e) {\n\t\t\t// Safari < 14.1 / older browsers may reject assigning to .files; nothing safe to fall back to.\n\t\t\tif (typeof process !== \"undefined\" && process.env && process.env.NODE_ENV !== \"production\") {\n\t\t\t\tconsole.warn(\"[gov-form-file] Could not sync native input.files:\", e)\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidLoad() {\n\t\tthis.attributeObserver = new AttributeObserver(this.host, (attributeName, newValue) => {\n\t\t\tthis.onAriaAttributeChange(attributeName, newValue);\n\t\t});\n\n\t\tthis.attributeObserver.startObserving(ariaAttributes);\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tthis.passControlAttrs()\n\t\tthis.inheritedAttributes = inheritAriaAttributes(this.host);\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.registerListeners()\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.attributeObserver?.stopObserving();\n\t}\n\n\tonAriaAttributeChange(attributeName: string, newValue: string) {\n\t\tthis.host.removeAttribute(attributeName)\n\t\tthis.inheritedAttributes = {...this.inheritedAttributes, [attributeName]: newValue};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={this.h.classes([FormFileClass.root])}\n\t\t\t\t invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t expanded={toBoolAttrIfDefined(this.expanded)}>\n\t\t\t\t<div class={FormFileClass.area} ref={el => (this.areaRef = el as HTMLDivElement)}>\n\t\t\t\t\t<slot/>\n\t\t\t\t\t<input\n\t\t\t\t\t\tclass={FormFileClass.input}\n\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\tid={this.identifier || this.fileId}\n\t\t\t\t\t\ttype=\"file\"\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\taccept={this.accept}\n\t\t\t\t\t\tmultiple={this.multiple}\n\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t{...this.inheritedAttributes}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t/>\n\t\t\t\t\t<div class={FormFileClass.inputFocus}/>\n\t\t\t\t</div>\n\n\t\t\t\t{this.h.hasSlot(\"attachments\") ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<slot name={\"attachments\"}/>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\n\t\t\t\t{this.files.length && this.displayAttachments ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<gov-attachments label={this.accessibleAttachmentsLabel}\n\t\t\t\t\t\t\t\t\t\t accessible-label={this.accessibleAttachmentsLabel}>\n\t\t\t\t\t\t\t{this.files.map(item => (\n\t\t\t\t\t\t\t\t<gov-attachments-item accessible-remove-labelledby={item.id}\n\t\t\t\t\t\t\t\t\t\t\t\t\t on-gov-remove={() => this.onRemoveFileHandler(item)}>\n\t\t\t\t\t\t\t\t\t{item.file.name}\n\t\t\t\t\t\t\t\t\t<span slot=\"name\">{item.file.name}</span>\n\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? this.errorAccept : null}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t{item.sizeValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{this.errorSize.replace(\"{FILE_SIZE}\", formatBytes(this.maxFileSize))}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t<span slot=\"info\">({formatBytes(item.file.size)})</span>\n\t\t\t\t\t\t\t\t</gov-attachments-item>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</gov-attachments>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onRemoveFileHandler(file: GovFormFileItem) {\n\t\tconst index = this.files.findIndex(item => item.id === file.id)\n\t\tif (index !== -1) {\n\t\t\tconst files = this.files\n\t\t\tconst removeFile = this.files[index]\n\t\t\tfiles.splice(index, 1)\n\t\t\tthis.files = [...files]\n\t\t\tthis.syncNativeInputFiles()\n\t\t\tthis.govRemoveFile.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfile: removeFile,\n\t\t\t})\n\t\t\tthis.govFiles.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfiles,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\te.stopPropagation()\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Returns the reference of the native area element\n\t */\n\t@Method()\n\tasync getAreaRef(): Promise<HTMLDivElement> {\n\t\treturn this.areaRef\n\t}\n\n\t/**\n\t * Remove all files from component state\n\t */\n\t@Method()\n\tasync reset(): Promise<void> {\n\t\tthis.files = []\n\t\tif (this.inputRef) {\n\t\t\tthis.inputRef.value = ''\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\t}\n}\n"],"names":["createID","govHost","govForm","toBoolAttr","AttributeObserver","ariaAttributes","inheritAriaAttributes","h","Host","toBoolAttrIfDefined"],"mappings":";;;;;;;;;;;;;;;AAAO,MAAM,aAAa,GAAG;AAC5B,IAAA,IAAI,EAAE,eAAe;AACrB,IAAA,IAAI,EAAE,qBAAqB;AAC3B,IAAA,KAAK,EAAE,sBAAsB;AAC7B,IAAA,UAAU,EAAE,4BAA4B;AACxC,IAAA,WAAW,EAAE,4BAA4B;CACzC;;ACNK,SAAU,WAAW,CAAC,KAAU,EAAA;IACrC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;AAC/E,IAAA,IAAI,CAAC,GAAG,CAAC,EACR,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC;AAE7B,IA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AAQ,EAAA;QAC/B,CAAC,CAAC,eAAe,EAAE;;AAGpB;;AAEG;AAEH,IAAA,MAAM,MAAM,GAAA;QACX,OAAO,IAAI,CAAC,QAAQ;;AAGrB;;AAEG;AAEH,IAAA,MAAM,UAAU,GAAA;QACf,OAAO,IAAI,CAAC,OAAO;;AAGpB;;AAEG;AAEH,IAAA,MAAM,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,KAAK,GAAG,EAAE;AACf,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;AAClB,YAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE;YACxB,IAAI,CAAC,oBAAoB,EAAE;;;;;;;;;;;;"}
|
|
@@ -115,10 +115,15 @@ export class GovFormFile {
|
|
|
115
115
|
}
|
|
116
116
|
validateFiles(files) {
|
|
117
117
|
let filesBuffer = [];
|
|
118
|
+
// Without `multiple`, only a single file is allowed. An incoming batch
|
|
119
|
+
// (drag-drop, framework wrapper, programmatic assignment) can still carry
|
|
120
|
+
// several files, so cap it to the last one — consistent with the
|
|
121
|
+
// "second pick replaces the first" semantics. (Bug #30570313)
|
|
122
|
+
const incoming = this.multiple ? Array.from(files) : Array.from(files).slice(-1);
|
|
118
123
|
if (!this.multiple && this.displayAttachments) {
|
|
119
124
|
this.files = [];
|
|
120
125
|
}
|
|
121
|
-
|
|
126
|
+
incoming.forEach(file => {
|
|
122
127
|
const isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null;
|
|
123
128
|
if (isFile === null || this.ignoreFileDuplicationCheck) {
|
|
124
129
|
const isSizeValid = typeof this.maxFileSize === "number" && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true;
|
|
@@ -196,7 +201,7 @@ export class GovFormFile {
|
|
|
196
201
|
this.inheritedAttributes = Object.assign(Object.assign({}, this.inheritedAttributes), { [attributeName]: newValue });
|
|
197
202
|
}
|
|
198
203
|
render() {
|
|
199
|
-
return (h(Host, { key: '
|
|
204
|
+
return (h(Host, { key: '2d89af24db1447bba2c7987946b5c63bff65a58a', class: this.h.classes([FormFileClass.root]), invalid: toBoolAttrIfDefined(this.invalid), expanded: toBoolAttrIfDefined(this.expanded) }, h("div", { key: '7a37869f8ef203b0f1d6b07cfee8e4f325fe9ecc', class: FormFileClass.area, ref: el => (this.areaRef = el) }, h("slot", { key: '10344be7bedf53a4754c8e79bb069c57291b7663' }), h("input", Object.assign({ key: '52dc1692d0eaa6310c0166faceb5906627aac73c', class: FormFileClass.input, ref: el => (this.inputRef = el), id: this.identifier || this.fileId, type: "file", name: this.name, accept: this.accept, multiple: this.multiple, onChange: this.onChangeHandler.bind(this), onFocus: this.onFocusHandler.bind(this), onBlur: this.onBlurHandler.bind(this), required: this.required, disabled: this.disabled }, this.inheritedAttributes, { "aria-required": toBoolAttrIfDefined(this.required), "aria-invalid": toBoolAttrIfDefined(this.invalid), "aria-disabled": toBoolAttrIfDefined(this.disabled) })), h("div", { key: '1193c6ef7a57894baab2f14619827c2f51441d08', class: FormFileClass.inputFocus })), this.h.hasSlot("attachments") ? (h("div", { class: FormFileClass.attachments }, h("slot", { name: "attachments" }))) : null, this.files.length && this.displayAttachments ? (h("div", { class: FormFileClass.attachments }, h("gov-attachments", { label: this.accessibleAttachmentsLabel, "accessible-label": this.accessibleAttachmentsLabel }, this.files.map(item => (h("gov-attachments-item", { "accessible-remove-labelledby": item.id, "on-gov-remove": () => this.onRemoveFileHandler(item) }, item.file.name, h("span", { slot: "name" }, item.file.name), item.acceptValid === false ? (h("gov-form-message", { slot: "message", color: "error" }, h("gov-icon", { slot: "icon", name: "exclamation-triangle-fill", type: "components" }), item.acceptValid === false ? this.errorAccept : null)) : null, item.sizeValid === false ? (h("gov-form-message", { slot: "message", color: "error" }, h("gov-icon", { slot: "icon", name: "exclamation-triangle-fill", type: "components" }), this.errorSize.replace("{FILE_SIZE}", formatBytes(this.maxFileSize)))) : null, h("span", { slot: "info" }, "(", formatBytes(item.file.size), ")"))))))) : null));
|
|
200
205
|
}
|
|
201
206
|
onRemoveFileHandler(file) {
|
|
202
207
|
const index = this.files.findIndex(item => item.id === file.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gov-form-file.js","sourceRoot":"","sources":["../../../../../../../src/components/gov-form/file/gov-form-file.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,eAAe,CAAA;AAC1G,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAA;AACpD,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAC,MAAM,+BAA+B,CAAA;AACtF,OAAO,EAAC,oBAAoB,EAAE,kBAAkB,EAAE,WAAW,EAAC,MAAM,2BAA2B,CAAA;AAG/F,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAA;AAEjD,OAAO,EAAC,qBAAqB,EAAC,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAC,iBAAiB,EAAa,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAC,cAAc,EAAC,MAAM,2CAA2C,CAAC;AAKzE,MAAM,OAAO,WAAW;IAUvB;QAFQ,qBAAgB,GAAG,KAAK,CAAA;QAUhC;;WAEG;QACc,aAAQ,GAAY,KAAK,CAAA;QAC1C;;;WAGG;QACc,aAAQ,GAAY,KAAK,CAAA;QAC1C;;;WAGG;QAC6B,aAAQ,GAAY,KAAK,CAAA;QACzD;;;WAGG;QAC6C,mBAAc,GAAY,KAAK,CAAA;QAC/E;;WAEG;QAC0D,+BAA0B,GAAY,KAAK,CAAA;QACxG;;WAEG;QACgD,uBAAkB,GAAY,IAAI,CAAA;QAUrF;;;WAGG;QACc,aAAQ,GAAY,KAAK,CAAA;QAC1C;;WAEG;QAC0C,gBAAW,GAAW,CA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;;;;;;;;;;;;;;;;;;;;;;;;CACD","sourcesContent":["import {Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch} from \"@stencil/core\"\nimport {createID} from \"../../../utils/string.utils\"\nimport {FormFileClass} from \"./constants\"\nimport {govHost, toBoolAttr, toBoolAttrIfDefined} from \"../../../helpers/Dom/template\"\nimport {fileAcceptValidation, fileSizeValidation, formatBytes} from \"../../../utils/file.utils\"\nimport {GovForm} from \"../../../helpers/Dom/form.types\"\nimport {GovHost} from \"../../../helpers/Dom/template.types\"\nimport {govForm} from \"../../../helpers/Dom/form\"\nimport {GovFormFileEvent, GovFormFileItem} from \"./gov-form-file.types\"\nimport {inheritAriaAttributes} from \"../../../helpers/Accessibility/accessibility\";\nimport {AttributeObserver, Attributes} from \"../../../helpers/Dom/attribute\";\nimport {ariaAttributes} from \"../../../helpers/Accessibility/attributes\";\n\n@Component({\n\ttag: \"gov-form-file\",\n})\nexport class GovFormFile {\n\tprivate f: GovForm\n\tprivate readonly h: GovHost\n\n\tprivate areaRef?: HTMLDivElement\n\tprivate inputRef?: HTMLInputElement\n\tprivate readonly fileId: string\n\tprivate attributeObserver: AttributeObserver\n\tprivate eventsRegistered = false\n\n\tconstructor() {\n\t\tthis.fileId = createID(\"GovInputFile\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormFileElement\n\t/**\n\t * Expands the file input to fill 100% of the container width.\n\t */\n\t@Prop() readonly expanded: boolean = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the File component disabled.\n\t * This prevents users from being able to interact with the File, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * After selecting the files, the main input element will be reset.\n\t * The propagation of the event with the selected files will not be affected.\n\t */\n\t@Prop({attribute: \"reset-after-pick\"}) readonly resetAfterPick: boolean = false\n\t/**\n\t * Selected files will not be checked for duplicates based on name and size.\n\t */\n\t@Prop({attribute: \"ignore-file-duplication-check\"}) readonly ignoreFileDuplicationCheck: boolean = false\n\t/**\n\t * Show list of attachments\n\t */\n\t@Prop({attribute: \"display-attachments\"}) readonly displayAttachments: boolean = true\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept\n\t */\n\t@Prop() readonly accept: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple\n\t */\n\t@Prop() readonly multiple: boolean = false\n\t/**\n\t * Maximum embedded file size\n\t */\n\t@Prop({attribute: \"max-file-size\"}) readonly maxFileSize: number = -1\n\t/**\n\t * Custom File identifier.\n\t */\n\t@Prop({attribute: \"identifier\"}) readonly identifier: string\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Error message when the maximum file size is exceeded\n\t */\n\t@Prop({attribute: \"error-size\"}) readonly errorSize: string = \"Soubor je větší než povolená velikost {FILE_SIZE}\"\n\t/**\n\t * Insert unsupported file error message\n\t */\n\t@Prop({attribute: \"error-accept\"}) readonly errorAccept: string = \"Soubor tohoto typu není povolen\"\n\t/**\n\t * Adds accessible label for the list of attachments.\n\t */\n\t@Prop({attribute: \"accessible-attachments-label\"}) readonly accessibleAttachmentsLabel: string = \"Přílohy\"\n\t/**\n\t * Emitted when the File has focus.\n\t */\n\t@Event({eventName: \"gov-focus\"}) govFocus: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Emitted when the File loses focus.\n\t */\n\t@Event({eventName: \"gov-blur\"}) govBlur: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when the list of inserted files is changed\n\t */\n\t@Event({eventName: \"gov-files\"}) govFiles: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a new file is added\n\t */\n\t@Event({eventName: \"gov-add-file\"}) govAddFile: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a file is removed from the list\n\t */\n\t@Event({eventName: \"gov-remove-file\"}) govRemoveFile: EventEmitter<GovFormFileEvent>\n\n\n\t@Watch(\"disabled\")\n\t@Watch(\"invalid\")\n\twatchControlAttrs(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\t@State() files: GovFormFileItem[] = []\n\t@State() inheritedAttributes: Attributes = {}\n\n\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl(\"invalid\", toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl(\"disabled\", toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl(\"type\", \"File\")\n\t}\n\n\n\tprivate registerListeners() {\n\t\tif (this.eventsRegistered) {\n\t\t\treturn\n\t\t}\n\t\tthis.eventsRegistered = true\n\n\t\tfunction highlight() {\n\t\t\tthis.areaRef.classList.add(\"highlight\")\n\t\t}\n\n\t\tfunction unhighlight() {\n\t\t\tthis.areaRef.classList.remove(\"highlight\")\n\t\t}\n\n\t\tthis.inputRef.addEventListener(\n\t\t\t\"change\",\n\t\t\te => {\n\t\t\t\te.preventDefault()\n\t\t\t\te.stopPropagation()\n\t\t\t\tconst files = (e.target as HTMLInputElement).files\n\t\t\t\tif (this.resetAfterPick) {\n\t\t\t\t\tif (files.length) {\n\t\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t}\n\t\t\t},\n\t\t\tfalse,\n\t\t)\n\n\t\tif (this.expanded) {\n\t\t\tconst events = [\"dragover\", \"dragleave\"]\n\t\t\tconst inEvents = [\"dragenter\", \"dragover\", \"mouseenter\"]\n\t\t\tconst outEvents = [\"dragleave\", \"mouseleave\"]\n\n\t\t\tevents.map(eventName => this.inputRef.addEventListener(eventName, this.preventDefaults.bind(this), false))\n\t\t\tinEvents.map(eventName => this.inputRef.addEventListener(eventName, highlight.bind(this), false))\n\t\t\toutEvents.forEach(eventName => this.inputRef.addEventListener(eventName, unhighlight.bind(this), false))\n\t\t}\n\t}\n\n\tpreventDefaults(e) {\n\t\te.preventDefault()\n\t\te.stopPropagation()\n\t}\n\n\thandleDrop(e: DragEvent) {\n\t\tconst dataTransfer = e.dataTransfer\n\t\tthis.validateFiles(dataTransfer.files)\n\t}\n\n\tprivate validateFiles(files: FileList) {\n\t\tlet filesBuffer: GovFormFileItem[] = []\n\t\tif (!this.multiple && this.displayAttachments) {\n\t\t\tthis.files = []\n\t\t}\n\t\tArray.from(files).forEach(file => {\n\t\t\tconst isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null\n\t\t\tif (isFile === null || this.ignoreFileDuplicationCheck) {\n\t\t\t\tconst isSizeValid = typeof this.maxFileSize === \"number\" && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true\n\t\t\t\tconst isAcceptValid = fileAcceptValidation(file, this.accept)\n\t\t\t\tconst newFile = {\n\t\t\t\t\tid: createID(\"GovFormFile\"),\n\t\t\t\t\tfile,\n\t\t\t\t\tacceptValid: isAcceptValid,\n\t\t\t\t\tsizeValid: isSizeValid,\n\t\t\t\t}\n\t\t\t\tif (this.displayAttachments) {\n\t\t\t\t\tthis.files = [...this.files, newFile]\n\t\t\t\t} else {\n\t\t\t\t\tfilesBuffer = [...filesBuffer, newFile]\n\t\t\t\t}\n\t\t\t\tthis.govAddFile.emit({\n\t\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\t\tfile: newFile,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tif (this.displayAttachments) {\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\n\t\tthis.govFiles.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\tfiles: filesBuffer.length ? filesBuffer : this.files,\n\t\t})\n\n\t\tif (this.resetAfterPick) {\n\t\t\tthis.reset().finally()\n\t\t}\n\t}\n\n\t// Keep native <input type=\"file\"> in sync with the visible attachments list so\n\t// that a native form submit / FormData carries exactly the files shown in the UI.\n\t// Invalid items (wrong type or oversize) are intentionally excluded.\n\tprivate syncNativeInputFiles() {\n\t\tif (!this.inputRef || typeof DataTransfer === \"undefined\") {\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst dt = new DataTransfer()\n\t\t\tthis.files\n\t\t\t\t.filter(item => item.acceptValid === true && item.sizeValid === true)\n\t\t\t\t.forEach(item => dt.items.add(item.file))\n\t\t\tthis.inputRef.files = dt.files\n\t\t} catch (e) {\n\t\t\t// Safari < 14.1 / older browsers may reject assigning to .files; nothing safe to fall back to.\n\t\t\tif (typeof process !== \"undefined\" && process.env && process.env.NODE_ENV !== \"production\") {\n\t\t\t\tconsole.warn(\"[gov-form-file] Could not sync native input.files:\", e)\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidLoad() {\n\t\tthis.attributeObserver = new AttributeObserver(this.host, (attributeName, newValue) => {\n\t\t\tthis.onAriaAttributeChange(attributeName, newValue);\n\t\t});\n\n\t\tthis.attributeObserver.startObserving(ariaAttributes);\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tthis.passControlAttrs()\n\t\tthis.inheritedAttributes = inheritAriaAttributes(this.host);\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.registerListeners()\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.attributeObserver?.stopObserving();\n\t}\n\n\tonAriaAttributeChange(attributeName: string, newValue: string) {\n\t\tthis.host.removeAttribute(attributeName)\n\t\tthis.inheritedAttributes = {...this.inheritedAttributes, [attributeName]: newValue};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={this.h.classes([FormFileClass.root])}\n\t\t\t\t invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t expanded={toBoolAttrIfDefined(this.expanded)}>\n\t\t\t\t<div class={FormFileClass.area} ref={el => (this.areaRef = el as HTMLDivElement)}>\n\t\t\t\t\t<slot/>\n\t\t\t\t\t<input\n\t\t\t\t\t\tclass={FormFileClass.input}\n\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\tid={this.identifier || this.fileId}\n\t\t\t\t\t\ttype=\"file\"\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\taccept={this.accept}\n\t\t\t\t\t\tmultiple={this.multiple}\n\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t{...this.inheritedAttributes}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t/>\n\t\t\t\t\t<div class={FormFileClass.inputFocus}/>\n\t\t\t\t</div>\n\n\t\t\t\t{this.h.hasSlot(\"attachments\") ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<slot name={\"attachments\"}/>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\n\t\t\t\t{this.files.length && this.displayAttachments ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<gov-attachments label={this.accessibleAttachmentsLabel}\n\t\t\t\t\t\t\t\t\t\t accessible-label={this.accessibleAttachmentsLabel}>\n\t\t\t\t\t\t\t{this.files.map(item => (\n\t\t\t\t\t\t\t\t<gov-attachments-item accessible-remove-labelledby={item.id}\n\t\t\t\t\t\t\t\t\t\t\t\t\t on-gov-remove={() => this.onRemoveFileHandler(item)}>\n\t\t\t\t\t\t\t\t\t{item.file.name}\n\t\t\t\t\t\t\t\t\t<span slot=\"name\">{item.file.name}</span>\n\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? this.errorAccept : null}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t{item.sizeValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{this.errorSize.replace(\"{FILE_SIZE}\", formatBytes(this.maxFileSize))}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t<span slot=\"info\">({formatBytes(item.file.size)})</span>\n\t\t\t\t\t\t\t\t</gov-attachments-item>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</gov-attachments>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onRemoveFileHandler(file: GovFormFileItem) {\n\t\tconst index = this.files.findIndex(item => item.id === file.id)\n\t\tif (index !== -1) {\n\t\t\tconst files = this.files\n\t\t\tconst removeFile = this.files[index]\n\t\t\tfiles.splice(index, 1)\n\t\t\tthis.files = [...files]\n\t\t\tthis.syncNativeInputFiles()\n\t\t\tthis.govRemoveFile.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfile: removeFile,\n\t\t\t})\n\t\t\tthis.govFiles.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfiles,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\te.stopPropagation()\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Returns the reference of the native area element\n\t */\n\t@Method()\n\tasync getAreaRef(): Promise<HTMLDivElement> {\n\t\treturn this.areaRef\n\t}\n\n\t/**\n\t * Remove all files from component state\n\t */\n\t@Method()\n\tasync reset(): Promise<void> {\n\t\tthis.files = []\n\t\tif (this.inputRef) {\n\t\t\tthis.inputRef.value = ''\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"gov-form-file.js","sourceRoot":"","sources":["../../../../../../../src/components/gov-form/file/gov-form-file.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,eAAe,CAAA;AAC1G,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAA;AACpD,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAC,MAAM,+BAA+B,CAAA;AACtF,OAAO,EAAC,oBAAoB,EAAE,kBAAkB,EAAE,WAAW,EAAC,MAAM,2BAA2B,CAAA;AAG/F,OAAO,EAAC,OAA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AAU;QACf,OAAO,IAAI,CAAC,OAAO,CAAA;IACpB,CAAC;IAED;;OAEG;IAEH,KAAK,CAAC,KAAK;QACV,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;QACf,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAA;YACxB,IAAI,CAAC,oBAAoB,EAAE,CAAA;QAC5B,CAAC;IACF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACD","sourcesContent":["import {Component, Element, Event, EventEmitter, h, Host, Method, Prop, State, Watch} from \"@stencil/core\"\nimport {createID} from \"../../../utils/string.utils\"\nimport {FormFileClass} from \"./constants\"\nimport {govHost, toBoolAttr, toBoolAttrIfDefined} from \"../../../helpers/Dom/template\"\nimport {fileAcceptValidation, fileSizeValidation, formatBytes} from \"../../../utils/file.utils\"\nimport {GovForm} from \"../../../helpers/Dom/form.types\"\nimport {GovHost} from \"../../../helpers/Dom/template.types\"\nimport {govForm} from \"../../../helpers/Dom/form\"\nimport {GovFormFileEvent, GovFormFileItem} from \"./gov-form-file.types\"\nimport {inheritAriaAttributes} from \"../../../helpers/Accessibility/accessibility\";\nimport {AttributeObserver, Attributes} from \"../../../helpers/Dom/attribute\";\nimport {ariaAttributes} from \"../../../helpers/Accessibility/attributes\";\n\n@Component({\n\ttag: \"gov-form-file\",\n})\nexport class GovFormFile {\n\tprivate f: GovForm\n\tprivate readonly h: GovHost\n\n\tprivate areaRef?: HTMLDivElement\n\tprivate inputRef?: HTMLInputElement\n\tprivate readonly fileId: string\n\tprivate attributeObserver: AttributeObserver\n\tprivate eventsRegistered = false\n\n\tconstructor() {\n\t\tthis.fileId = createID(\"GovInputFile\")\n\n\t\tthis.h = govHost(this.host)\n\t\tthis.f = govForm(this.h)\n\t}\n\n\t@Element() host: HTMLGovFormFileElement\n\t/**\n\t * Expands the file input to fill 100% of the container width.\n\t */\n\t@Prop() readonly expanded: boolean = false\n\t/**\n\t * Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them.\n\t * When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors.\n\t */\n\t@Prop() readonly required: boolean = false\n\t/**\n\t * Makes the File component disabled.\n\t * This prevents users from being able to interact with the File, and conveys its inactive state to assistive technologies.\n\t */\n\t@Prop({reflect: true}) readonly disabled: boolean = false\n\t/**\n\t * After selecting the files, the main input element will be reset.\n\t * The propagation of the event with the selected files will not be affected.\n\t */\n\t@Prop({attribute: \"reset-after-pick\"}) readonly resetAfterPick: boolean = false\n\t/**\n\t * Selected files will not be checked for duplicates based on name and size.\n\t */\n\t@Prop({attribute: \"ignore-file-duplication-check\"}) readonly ignoreFileDuplicationCheck: boolean = false\n\t/**\n\t * Show list of attachments\n\t */\n\t@Prop({attribute: \"display-attachments\"}) readonly displayAttachments: boolean = true\n\t/**\n\t * Name of the input.\n\t */\n\t@Prop() readonly name: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept\n\t */\n\t@Prop() readonly accept: string\n\t/**\n\t * Same as original parameter\n\t * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/multiple\n\t */\n\t@Prop() readonly multiple: boolean = false\n\t/**\n\t * Maximum embedded file size\n\t */\n\t@Prop({attribute: \"max-file-size\"}) readonly maxFileSize: number = -1\n\t/**\n\t * Custom File identifier.\n\t */\n\t@Prop({attribute: \"identifier\"}) readonly identifier: string\n\t/**\n\t * Indicates the entered value does not conform to the format expected by the application.\n\t */\n\t@Prop() readonly invalid: boolean\n\t/**\n\t * Error message when the maximum file size is exceeded\n\t */\n\t@Prop({attribute: \"error-size\"}) readonly errorSize: string = \"Soubor je větší než povolená velikost {FILE_SIZE}\"\n\t/**\n\t * Insert unsupported file error message\n\t */\n\t@Prop({attribute: \"error-accept\"}) readonly errorAccept: string = \"Soubor tohoto typu není povolen\"\n\t/**\n\t * Adds accessible label for the list of attachments.\n\t */\n\t@Prop({attribute: \"accessible-attachments-label\"}) readonly accessibleAttachmentsLabel: string = \"Přílohy\"\n\t/**\n\t * Emitted when the File has focus.\n\t */\n\t@Event({eventName: \"gov-focus\"}) govFocus: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Emitted when the File loses focus.\n\t */\n\t@Event({eventName: \"gov-blur\"}) govBlur: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when the list of inserted files is changed\n\t */\n\t@Event({eventName: \"gov-files\"}) govFiles: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a new file is added\n\t */\n\t@Event({eventName: \"gov-add-file\"}) govAddFile: EventEmitter<GovFormFileEvent>\n\t/**\n\t * Called when a file is removed from the list\n\t */\n\t@Event({eventName: \"gov-remove-file\"}) govRemoveFile: EventEmitter<GovFormFileEvent>\n\n\n\t@Watch(\"disabled\")\n\t@Watch(\"invalid\")\n\twatchControlAttrs(): void {\n\t\tthis.passControlAttrs()\n\t}\n\n\t@State() files: GovFormFileItem[] = []\n\t@State() inheritedAttributes: Attributes = {}\n\n\n\n\tprivate passControlAttrs() {\n\t\tthis.f.passAttrToControl(\"invalid\", toBoolAttr(this.invalid))\n\t\tthis.f.passAttrToControl(\"disabled\", toBoolAttr(this.disabled))\n\t\tthis.f.passAttrToControl(\"type\", \"File\")\n\t}\n\n\n\tprivate registerListeners() {\n\t\tif (this.eventsRegistered) {\n\t\t\treturn\n\t\t}\n\t\tthis.eventsRegistered = true\n\n\t\tfunction highlight() {\n\t\t\tthis.areaRef.classList.add(\"highlight\")\n\t\t}\n\n\t\tfunction unhighlight() {\n\t\t\tthis.areaRef.classList.remove(\"highlight\")\n\t\t}\n\n\t\tthis.inputRef.addEventListener(\n\t\t\t\"change\",\n\t\t\te => {\n\t\t\t\te.preventDefault()\n\t\t\t\te.stopPropagation()\n\t\t\t\tconst files = (e.target as HTMLInputElement).files\n\t\t\t\tif (this.resetAfterPick) {\n\t\t\t\t\tif (files.length) {\n\t\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.validateFiles(files)\n\t\t\t\t}\n\t\t\t},\n\t\t\tfalse,\n\t\t)\n\n\t\tif (this.expanded) {\n\t\t\tconst events = [\"dragover\", \"dragleave\"]\n\t\t\tconst inEvents = [\"dragenter\", \"dragover\", \"mouseenter\"]\n\t\t\tconst outEvents = [\"dragleave\", \"mouseleave\"]\n\n\t\t\tevents.map(eventName => this.inputRef.addEventListener(eventName, this.preventDefaults.bind(this), false))\n\t\t\tinEvents.map(eventName => this.inputRef.addEventListener(eventName, highlight.bind(this), false))\n\t\t\toutEvents.forEach(eventName => this.inputRef.addEventListener(eventName, unhighlight.bind(this), false))\n\t\t}\n\t}\n\n\tpreventDefaults(e) {\n\t\te.preventDefault()\n\t\te.stopPropagation()\n\t}\n\n\thandleDrop(e: DragEvent) {\n\t\tconst dataTransfer = e.dataTransfer\n\t\tthis.validateFiles(dataTransfer.files)\n\t}\n\n\tprivate validateFiles(files: FileList) {\n\t\tlet filesBuffer: GovFormFileItem[] = []\n\t\t// Without `multiple`, only a single file is allowed. An incoming batch\n\t\t// (drag-drop, framework wrapper, programmatic assignment) can still carry\n\t\t// several files, so cap it to the last one — consistent with the\n\t\t// \"second pick replaces the first\" semantics. (Bug #30570313)\n\t\tconst incoming = this.multiple ? Array.from(files) : Array.from(files).slice(-1)\n\t\tif (!this.multiple && this.displayAttachments) {\n\t\t\tthis.files = []\n\t\t}\n\t\tincoming.forEach(file => {\n\t\t\tconst isFile = this.files.find(item => item.file.name === file.name && item.file.size === file.size) || null\n\t\t\tif (isFile === null || this.ignoreFileDuplicationCheck) {\n\t\t\t\tconst isSizeValid = typeof this.maxFileSize === \"number\" && this.maxFileSize > 0 ? fileSizeValidation(file, this.maxFileSize) : true\n\t\t\t\tconst isAcceptValid = fileAcceptValidation(file, this.accept)\n\t\t\t\tconst newFile = {\n\t\t\t\t\tid: createID(\"GovFormFile\"),\n\t\t\t\t\tfile,\n\t\t\t\t\tacceptValid: isAcceptValid,\n\t\t\t\t\tsizeValid: isSizeValid,\n\t\t\t\t}\n\t\t\t\tif (this.displayAttachments) {\n\t\t\t\t\tthis.files = [...this.files, newFile]\n\t\t\t\t} else {\n\t\t\t\t\tfilesBuffer = [...filesBuffer, newFile]\n\t\t\t\t}\n\t\t\t\tthis.govAddFile.emit({\n\t\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\t\tfile: newFile,\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tif (this.displayAttachments) {\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\n\t\tthis.govFiles.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\tfiles: filesBuffer.length ? filesBuffer : this.files,\n\t\t})\n\n\t\tif (this.resetAfterPick) {\n\t\t\tthis.reset().finally()\n\t\t}\n\t}\n\n\t// Keep native <input type=\"file\"> in sync with the visible attachments list so\n\t// that a native form submit / FormData carries exactly the files shown in the UI.\n\t// Invalid items (wrong type or oversize) are intentionally excluded.\n\tprivate syncNativeInputFiles() {\n\t\tif (!this.inputRef || typeof DataTransfer === \"undefined\") {\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tconst dt = new DataTransfer()\n\t\t\tthis.files\n\t\t\t\t.filter(item => item.acceptValid === true && item.sizeValid === true)\n\t\t\t\t.forEach(item => dt.items.add(item.file))\n\t\t\tthis.inputRef.files = dt.files\n\t\t} catch (e) {\n\t\t\t// Safari < 14.1 / older browsers may reject assigning to .files; nothing safe to fall back to.\n\t\t\tif (typeof process !== \"undefined\" && process.env && process.env.NODE_ENV !== \"production\") {\n\t\t\t\tconsole.warn(\"[gov-form-file] Could not sync native input.files:\", e)\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidLoad() {\n\t\tthis.attributeObserver = new AttributeObserver(this.host, (attributeName, newValue) => {\n\t\t\tthis.onAriaAttributeChange(attributeName, newValue);\n\t\t});\n\n\t\tthis.attributeObserver.startObserving(ariaAttributes);\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.f.passAttrToLabel(\"required\", String(this.required))\n\t\tthis.passControlAttrs()\n\t\tthis.inheritedAttributes = inheritAriaAttributes(this.host);\n\t}\n\n\tasync componentDidRender() {\n\t\tthis.registerListeners()\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.attributeObserver?.stopObserving();\n\t}\n\n\tonAriaAttributeChange(attributeName: string, newValue: string) {\n\t\tthis.host.removeAttribute(attributeName)\n\t\tthis.inheritedAttributes = {...this.inheritedAttributes, [attributeName]: newValue};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<Host class={this.h.classes([FormFileClass.root])}\n\t\t\t\t invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t expanded={toBoolAttrIfDefined(this.expanded)}>\n\t\t\t\t<div class={FormFileClass.area} ref={el => (this.areaRef = el as HTMLDivElement)}>\n\t\t\t\t\t<slot/>\n\t\t\t\t\t<input\n\t\t\t\t\t\tclass={FormFileClass.input}\n\t\t\t\t\t\tref={el => (this.inputRef = el as HTMLInputElement)}\n\t\t\t\t\t\tid={this.identifier || this.fileId}\n\t\t\t\t\t\ttype=\"file\"\n\t\t\t\t\t\tname={this.name}\n\t\t\t\t\t\taccept={this.accept}\n\t\t\t\t\t\tmultiple={this.multiple}\n\t\t\t\t\t\tonChange={this.onChangeHandler.bind(this)}\n\t\t\t\t\t\tonFocus={this.onFocusHandler.bind(this)}\n\t\t\t\t\t\tonBlur={this.onBlurHandler.bind(this)}\n\t\t\t\t\t\trequired={this.required}\n\t\t\t\t\t\tdisabled={this.disabled}\n\t\t\t\t\t\t{...this.inheritedAttributes}\n\t\t\t\t\t\taria-required={toBoolAttrIfDefined(this.required)}\n\t\t\t\t\t\taria-invalid={toBoolAttrIfDefined(this.invalid)}\n\t\t\t\t\t\taria-disabled={toBoolAttrIfDefined(this.disabled)}\n\t\t\t\t\t/>\n\t\t\t\t\t<div class={FormFileClass.inputFocus}/>\n\t\t\t\t</div>\n\n\t\t\t\t{this.h.hasSlot(\"attachments\") ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<slot name={\"attachments\"}/>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\n\t\t\t\t{this.files.length && this.displayAttachments ? (\n\t\t\t\t\t<div class={FormFileClass.attachments}>\n\t\t\t\t\t\t<gov-attachments label={this.accessibleAttachmentsLabel}\n\t\t\t\t\t\t\t\t\t\t accessible-label={this.accessibleAttachmentsLabel}>\n\t\t\t\t\t\t\t{this.files.map(item => (\n\t\t\t\t\t\t\t\t<gov-attachments-item accessible-remove-labelledby={item.id}\n\t\t\t\t\t\t\t\t\t\t\t\t\t on-gov-remove={() => this.onRemoveFileHandler(item)}>\n\t\t\t\t\t\t\t\t\t{item.file.name}\n\t\t\t\t\t\t\t\t\t<span slot=\"name\">{item.file.name}</span>\n\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{item.acceptValid === false ? this.errorAccept : null}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t{item.sizeValid === false ? (\n\t\t\t\t\t\t\t\t\t\t<gov-form-message slot=\"message\" color=\"error\">\n\t\t\t\t\t\t\t\t\t\t\t<gov-icon slot=\"icon\" name=\"exclamation-triangle-fill\" type=\"components\"></gov-icon>\n\t\t\t\t\t\t\t\t\t\t\t{this.errorSize.replace(\"{FILE_SIZE}\", formatBytes(this.maxFileSize))}\n\t\t\t\t\t\t\t\t\t\t</gov-form-message>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t<span slot=\"info\">({formatBytes(item.file.size)})</span>\n\t\t\t\t\t\t\t\t</gov-attachments-item>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</gov-attachments>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t</Host>\n\t\t)\n\t}\n\n\tprivate onRemoveFileHandler(file: GovFormFileItem) {\n\t\tconst index = this.files.findIndex(item => item.id === file.id)\n\t\tif (index !== -1) {\n\t\t\tconst files = this.files\n\t\t\tconst removeFile = this.files[index]\n\t\t\tfiles.splice(index, 1)\n\t\t\tthis.files = [...files]\n\t\t\tthis.syncNativeInputFiles()\n\t\t\tthis.govRemoveFile.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfile: removeFile,\n\t\t\t})\n\t\t\tthis.govFiles.emit({\n\t\t\t\tcomponent: FormFileClass.root,\n\t\t\t\tfiles,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate onFocusHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govFocus.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onBlurHandler(e: FocusEvent) {\n\t\te.stopPropagation()\n\t\tthis.govBlur.emit({\n\t\t\tcomponent: FormFileClass.root,\n\t\t\toriginalEvent: e,\n\t\t})\n\t}\n\n\tprivate onChangeHandler(e: Event) {\n\t\te.stopPropagation()\n\t}\n\n\t/**\n\t * Returns the reference of the native element\n\t */\n\t@Method()\n\tasync getRef(): Promise<HTMLInputElement> {\n\t\treturn this.inputRef\n\t}\n\n\t/**\n\t * Returns the reference of the native area element\n\t */\n\t@Method()\n\tasync getAreaRef(): Promise<HTMLDivElement> {\n\t\treturn this.areaRef\n\t}\n\n\t/**\n\t * Remove all files from component state\n\t */\n\t@Method()\n\tasync reset(): Promise<void> {\n\t\tthis.files = []\n\t\tif (this.inputRef) {\n\t\t\tthis.inputRef.value = ''\n\t\t\tthis.syncNativeInputFiles()\n\t\t}\n\t}\n}\n"]}
|
|
@@ -6,18 +6,37 @@ export function formatBytes(bytes) {
|
|
|
6
6
|
}
|
|
7
7
|
return n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l];
|
|
8
8
|
}
|
|
9
|
+
// Validates a file against an `accept` attribute value, following the HTML spec
|
|
10
|
+
// (https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept):
|
|
11
|
+
// - ".ext" → matched against the file NAME suffix (case-insensitive)
|
|
12
|
+
// - "type/*" → matched against the file MIME group
|
|
13
|
+
// - "type/sub" → exact MIME match
|
|
14
|
+
// Matching the name (not only file.type) is essential: browsers often report an
|
|
15
|
+
// empty or non-standard MIME for extensions like .jsonld, which the previous
|
|
16
|
+
// MIME-only RegExp check always rejected.
|
|
9
17
|
export function fileAcceptValidation(file, accept) {
|
|
10
|
-
if (typeof accept
|
|
11
|
-
return (accept
|
|
12
|
-
.replace(/\s/g, '')
|
|
13
|
-
.split(',')
|
|
14
|
-
.filter(accept => {
|
|
15
|
-
return new RegExp(accept.replace('*', '.*')).test(file.type);
|
|
16
|
-
}).length > 0);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
18
|
+
if (typeof accept !== 'string' || accept.trim().length === 0) {
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
|
+
const fileName = file.name.toLowerCase();
|
|
22
|
+
const fileType = (file.type || '').toLowerCase();
|
|
23
|
+
return accept
|
|
24
|
+
.split(',')
|
|
25
|
+
.map(token => token.trim().toLowerCase())
|
|
26
|
+
.filter(token => token.length > 0)
|
|
27
|
+
.some(token => {
|
|
28
|
+
if (token.startsWith('.')) {
|
|
29
|
+
return fileName.endsWith(token);
|
|
30
|
+
}
|
|
31
|
+
if (token === '*' || token === '*/*') {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if (token.endsWith('/*')) {
|
|
35
|
+
const group = token.slice(0, token.indexOf('/') + 1);
|
|
36
|
+
return fileType.startsWith(group);
|
|
37
|
+
}
|
|
38
|
+
return fileType === token;
|
|
39
|
+
});
|
|
21
40
|
}
|
|
22
41
|
export function fileSizeValidation(file, maxSize) {
|
|
23
42
|
const fileSize = Math.round(file.size);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.utils.js","sourceRoot":"","sources":["../../../../../src/utils/file.utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,KAAU;IACrC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;IAC/E,IAAI,CAAC,GAAG,CAAC,EACR,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,CAAA;IAE7B,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;QACzB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CA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\n\twhile (n >= 1024 && ++l) {\n\t\tn = n / 1024\n\t}\n\n\treturn n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l]\n}\n\n// Validates a file against an `accept` attribute value, following the HTML spec\n// (https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept):\n// - \".ext\" → matched against the file NAME suffix (case-insensitive)\n// - \"type/*\" → matched against the file MIME group\n// - \"type/sub\" → exact MIME match\n// Matching the name (not only file.type) is essential: browsers often report an\n// empty or non-standard MIME for extensions like .jsonld, which the previous\n// MIME-only RegExp check always rejected.\nexport function fileAcceptValidation(file: File, accept: string): boolean {\n\tif (typeof accept !== 'string' || accept.trim().length === 0) {\n\t\treturn true\n\t}\n\tconst fileName = file.name.toLowerCase()\n\tconst fileType = (file.type || '').toLowerCase()\n\treturn accept\n\t\t.split(',')\n\t\t.map(token => token.trim().toLowerCase())\n\t\t.filter(token => token.length > 0)\n\t\t.some(token => {\n\t\t\tif (token.startsWith('.')) {\n\t\t\t\treturn fileName.endsWith(token)\n\t\t\t}\n\t\t\tif (token === '*' || token === '*/*') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (token.endsWith('/*')) {\n\t\t\t\tconst group = token.slice(0, token.indexOf('/') + 1)\n\t\t\t\treturn fileType.startsWith(group)\n\t\t\t}\n\t\t\treturn fileType === token\n\t\t})\n}\n\nexport function fileSizeValidation(file: File, maxSize: number): boolean {\n\tconst fileSize = Math.round(file.size)\n\treturn fileSize <= maxSize\n}\n"]}
|