@duetds/components 4.30.0 → 4.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hydrate/index.js +1481 -434
- package/lib/cjs/{dom-e89ebf90.js → dom-c850c8d7.js} +1 -1
- package/lib/cjs/duet-alert.cjs.entry.js +4 -2
- package/lib/cjs/duet-badge.cjs.entry.js +2 -2
- package/lib/cjs/duet-button_2.cjs.entry.js +6 -5
- package/lib/cjs/duet-caption_4.cjs.entry.js +21 -15
- package/lib/cjs/duet-card.cjs.entry.js +6 -6
- package/lib/cjs/duet-checkbox.cjs.entry.js +2 -2
- package/lib/cjs/duet-choice_2.cjs.entry.js +56 -25
- package/lib/cjs/duet-collapsible.cjs.entry.js +5 -2
- package/lib/cjs/duet-cookie-consent.cjs.entry.js +1 -1
- package/lib/cjs/duet-date-picker.cjs.entry.js +23 -13
- package/lib/cjs/duet-divider_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-editable-table-button_3.cjs.entry.js +232 -0
- package/lib/cjs/{duet-table.cjs.entry.js → duet-editable-table_3.cjs.entry.js} +206 -2
- package/lib/cjs/duet-empty-state.cjs.entry.js +1 -1
- package/lib/cjs/duet-footer.cjs.entry.js +4 -4
- package/lib/cjs/duet-grid_2.cjs.entry.js +52 -4
- package/lib/cjs/duet-header_2.cjs.entry.js +26 -10
- package/lib/cjs/duet-hero.cjs.entry.js +6 -6
- package/lib/cjs/duet-icon.cjs.entry.js +6 -14
- package/lib/cjs/duet-input_2.cjs.entry.js +7 -7
- package/lib/cjs/duet-layout.cjs.entry.js +1 -1
- package/lib/cjs/duet-list_2.cjs.entry.js +2 -2
- package/lib/cjs/duet-modal.cjs.entry.js +8 -7
- package/lib/cjs/duet-notification_2.cjs.entry.js +6 -5
- package/lib/cjs/duet-number-input.cjs.entry.js +36 -15
- package/lib/cjs/duet-progress.cjs.entry.js +75 -0
- package/lib/cjs/duet-radio_2.cjs.entry.js +2 -2
- package/lib/cjs/duet-range-slider.cjs.entry.js +2 -2
- package/lib/cjs/duet-select.cjs.entry.js +6 -6
- package/lib/cjs/duet-step_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-tab_2.cjs.entry.js +12 -6
- package/lib/cjs/duet-textarea.cjs.entry.js +5 -5
- package/lib/cjs/duet-toggle.cjs.entry.js +1 -1
- package/lib/cjs/duet-tooltip.cjs.entry.js +21 -10
- package/lib/cjs/duet-tray.cjs.entry.js +21 -10
- package/lib/cjs/duet-upload.cjs.entry.js +403 -180
- package/lib/cjs/duet-visually-hidden.cjs.entry.js +1 -1
- package/lib/cjs/duet.cjs.js +4 -4
- package/lib/cjs/{focus-utils-7605778f.js → focus-utils-a7a1fb8b.js} +1 -1
- package/lib/cjs/{index-0c949193.js → index-b724d698.js} +88 -77
- package/lib/cjs/js-utils-33a9dbe3.js +16 -0
- package/lib/cjs/{language-utils-70d6a9a4.js → language-utils-aa282901.js} +28 -9
- package/lib/cjs/loader.cjs.js +3 -3
- package/lib/cjs/{shadow-css-0c8c175b.js → shadow-css-e3edeed1.js} +9 -10
- package/lib/cjs/{string-utils-a6de43d8.js → string-utils-267e3dbb.js} +7 -0
- package/lib/cjs/{token-utils-13e5d13e.js → token-utils-63a9c8dc.js} +1 -1
- package/lib/cjs/{tokens.module-53b3bd92.js → tokens.module-6b2df1c2.js} +2 -0
- package/lib/cjs/{watch-options-3877c082.js → watch-options-d88afac0.js} +29 -6
- package/lib/collection/collection-manifest.json +15 -8
- package/lib/collection/components/duet-alert/duet-alert.js +12 -6
- package/lib/collection/components/duet-badge/duet-badge.css +1 -0
- package/lib/collection/components/duet-button/duet-button.js +17 -15
- package/lib/collection/components/duet-card/duet-card.css +30 -7
- package/lib/collection/components/duet-card/duet-card.js +4 -3
- package/lib/collection/components/duet-checkbox/duet-checkbox.css +1 -1
- package/lib/collection/components/duet-choice/duet-choice.css +16 -3
- package/lib/collection/components/duet-choice/duet-choice.js +123 -36
- package/lib/collection/components/duet-choice-group/duet-choice-group.css +1 -0
- package/lib/collection/components/duet-choice-group/duet-choice-group.js +4 -4
- package/lib/collection/components/duet-date-picker/duet-date-picker.css +1 -1
- package/lib/collection/components/duet-date-picker/duet-date-picker.js +78 -43
- package/lib/collection/components/duet-editable-table/duet-editable-table-button.css +32 -0
- package/lib/collection/components/duet-editable-table/duet-editable-table-button.js +218 -0
- package/lib/collection/components/duet-editable-table/duet-editable-table-item.css +36 -0
- package/lib/collection/components/duet-editable-table/duet-editable-table-item.js +203 -0
- package/lib/collection/components/duet-editable-table/duet-editable-table-tabledata.js +13 -0
- package/lib/collection/components/duet-editable-table/duet-editable-table.css +16 -0
- package/lib/collection/components/duet-editable-table/duet-editable-table.js +348 -0
- package/lib/collection/components/duet-footer/duet-footer.js +17 -15
- package/lib/collection/components/duet-grid/duet-grid.js +57 -6
- package/lib/collection/components/duet-grid-item/duet-grid-item.js +4 -4
- package/lib/collection/components/duet-header/duet-header.js +60 -35
- package/lib/collection/components/duet-heading/duet-heading.css +4 -0
- package/lib/collection/components/duet-heading/duet-heading.js +7 -6
- package/lib/collection/components/duet-hero/duet-hero.js +20 -15
- package/lib/collection/components/duet-icon/duet-icon.js +2 -6
- package/lib/collection/components/duet-icon/icon-utils.js +5 -8
- package/lib/collection/components/duet-input/duet-input.css +15 -0
- package/lib/collection/components/duet-input/duet-input.js +4 -4
- package/lib/collection/components/duet-label/duet-label.css +2 -0
- package/lib/collection/components/duet-link/duet-link.js +18 -19
- package/lib/collection/components/duet-logo/duet-logo.js +4 -4
- package/lib/collection/components/duet-modal/duet-modal.js +22 -17
- package/lib/collection/components/duet-notification/duet-notification.js +8 -8
- package/lib/collection/components/duet-notification-drawer/duet-notification-drawer.js +20 -15
- package/lib/collection/components/duet-number-input/duet-number-input.js +153 -29
- package/lib/collection/components/duet-paragraph/duet-paragraph.css +6 -0
- package/lib/collection/components/duet-paragraph/duet-paragraph.js +34 -3
- package/lib/collection/components/duet-progress/duet-progress.css +103 -0
- package/lib/collection/components/duet-progress/duet-progress.js +240 -0
- package/lib/collection/components/duet-radio/duet-radio.js +6 -6
- package/lib/collection/components/duet-select/duet-select.css +15 -0
- package/lib/collection/components/duet-select/duet-select.js +3 -3
- package/lib/collection/components/duet-step/duet-step.js +8 -8
- package/lib/collection/components/duet-tab-group/duet-tab-group.css +2 -2
- package/lib/collection/components/duet-tab-group/duet-tab-group.js +43 -12
- package/lib/collection/components/duet-textarea/duet-textarea.css +19 -0
- package/lib/collection/components/duet-textarea/duet-textarea.js +5 -4
- package/lib/collection/components/duet-tooltip/duet-tooltip.js +82 -20
- package/lib/collection/components/duet-tray/duet-tray.js +79 -17
- package/lib/collection/components/duet-upload/duet-upload-aria-status.js +217 -0
- package/lib/collection/components/duet-upload/duet-upload-editable-item-error.js +16 -0
- package/lib/collection/components/duet-upload/duet-upload-editable-item-inprogres.js +8 -0
- package/lib/collection/components/duet-upload/duet-upload-editable-item-success.js +30 -0
- package/lib/collection/components/duet-upload/duet-upload.css +17 -86
- package/lib/collection/components/duet-upload/duet-upload.js +551 -153
- package/lib/collection/components/duet-upload/errorcodes.utils.js +16 -4
- package/lib/collection/components/duet-upload/xhr.helpers.js +2 -6
- package/lib/collection/utils/fixture-utils.js +7 -5
- package/lib/collection/utils/js-utils.js +12 -0
- package/lib/collection/utils/language-utils.js +26 -9
- package/lib/collection/utils/string-utils.js +6 -0
- package/lib/collection/utils/watch-options.js +35 -6
- package/lib/custom-elements-bundle/index.d.ts +30 -0
- package/lib/custom-elements-bundle/index.js +1603 -721
- package/lib/duet/duet.esm.js +1 -1
- package/lib/duet/duet.js +1 -1
- package/lib/duet/{p-4a7911fd.entry.js → p-00735436.entry.js} +1 -1
- package/lib/duet/p-060d79be.entry.js +4 -0
- package/lib/duet/p-0d22396e.system.js +16 -0
- package/lib/duet/p-10deead0.system.js +4 -0
- package/lib/duet/p-1208c84f.entry.js +4 -0
- package/lib/duet/p-12721178.js +4 -0
- package/lib/duet/p-155ef581.system.entry.js +4 -0
- package/lib/duet/p-16c48c5d.entry.js +4 -0
- package/lib/duet/p-1797df7b.system.entry.js +4 -0
- package/lib/duet/p-1a08fc22.system.entry.js +4 -0
- package/lib/duet/{p-d1817efe.system.entry.js → p-237e47b4.system.entry.js} +1 -1
- package/lib/duet/p-2443bdca.system.entry.js +4 -0
- package/lib/duet/p-263bc9cd.system.entry.js +4 -0
- package/lib/duet/p-2764f081.js +4 -0
- package/lib/duet/p-27d80cef.system.entry.js +4 -0
- package/lib/duet/p-28e02c08.entry.js +4 -0
- package/lib/duet/{p-f81d8534.entry.js → p-2bb1460c.entry.js} +1 -1
- package/lib/duet/p-33c58756.entry.js +4 -0
- package/lib/duet/{p-bd9a7d8f.js → p-35a3794e.js} +0 -0
- package/lib/duet/{p-bbc229d8.system.entry.js → p-374fb7e6.system.entry.js} +1 -1
- package/lib/duet/p-387823af.system.entry.js +4 -0
- package/lib/duet/p-3af5d66f.entry.js +4 -0
- package/lib/duet/{p-322d1c38.js → p-3c1971d8.js} +1 -1
- package/lib/duet/{p-7e108b7e.entry.js → p-4607af59.entry.js} +1 -1
- package/lib/duet/p-48d1eb1f.system.entry.js +4 -0
- package/lib/duet/p-4a87e9ab.system.entry.js +4 -0
- package/lib/duet/{p-031c2cd8.system.entry.js → p-4b6ebe40.system.entry.js} +1 -1
- package/lib/duet/p-4e28da18.system.entry.js +4 -0
- package/lib/duet/p-548d484e.js +4 -0
- package/lib/duet/p-5826523b.entry.js +4 -0
- package/lib/duet/{p-ce1374a4.system.entry.js → p-58750bae.system.entry.js} +1 -1
- package/lib/duet/p-597d99c7.entry.js +4 -0
- package/lib/duet/p-5ea0cd19.entry.js +4 -0
- package/lib/duet/p-63d5bf73.system.entry.js +4 -0
- package/lib/duet/p-67d9a9a9.system.entry.js +4 -0
- package/lib/duet/p-6a19b5ec.entry.js +4 -0
- package/lib/duet/p-6cc3be76.system.entry.js +4 -0
- package/lib/duet/p-6e363557.system.js +4 -0
- package/lib/duet/p-6e6e76db.system.entry.js +4 -0
- package/lib/duet/p-70fafc98.system.js +4 -0
- package/lib/duet/p-7368b14e.system.entry.js +4 -0
- package/lib/duet/p-751542a0.system.entry.js +4 -0
- package/lib/duet/p-794659ac.entry.js +4 -0
- package/lib/duet/p-7e8d5bb9.system.entry.js +4 -0
- package/lib/duet/p-7fee0d23.system.entry.js +4 -0
- package/lib/duet/p-81867417.system.js +4 -0
- package/lib/duet/p-86daec1c.entry.js +4 -0
- package/lib/duet/{p-4265de16.system.entry.js → p-8b5ca0e7.system.entry.js} +1 -1
- package/lib/duet/{p-66dde4d2.entry.js → p-8cb7416d.entry.js} +1 -1
- package/lib/duet/p-8f826843.system.entry.js +4 -0
- package/lib/duet/p-94169303.entry.js +4 -0
- package/lib/duet/{p-36007600.entry.js → p-9481e312.entry.js} +1 -1
- package/lib/duet/{p-f82709ba.entry.js → p-984576c9.entry.js} +1 -1
- package/lib/duet/p-986779fb.js +4 -0
- package/lib/duet/p-987edcd0.js +15 -0
- package/lib/duet/{p-35e45c19.system.js → p-9a945278.system.js} +1 -1
- package/lib/duet/p-9d73343a.entry.js +4 -0
- package/lib/duet/{p-e26116e0.system.entry.js → p-9dca5c22.system.entry.js} +1 -1
- package/lib/duet/p-a207b008.entry.js +4 -0
- package/lib/duet/p-a5b9c192.system.entry.js +4 -0
- package/lib/duet/p-a6a84ec6.entry.js +4 -0
- package/lib/duet/{p-2d2c45f9.entry.js → p-a890da72.entry.js} +1 -1
- package/lib/duet/p-a9859a82.entry.js +4 -0
- package/lib/duet/p-aba68b7b.entry.js +4 -0
- package/lib/duet/p-acc57c77.entry.js +4 -0
- package/lib/duet/{p-2826f987.js → p-ad07f399.js} +1 -1
- package/lib/duet/p-aee24388.system.entry.js +4 -0
- package/lib/duet/p-aef1b720.system.entry.js +4 -0
- package/lib/duet/{p-62806bb6.system.entry.js → p-af41d894.system.entry.js} +1 -1
- package/lib/duet/p-b25d3769.js +4 -0
- package/lib/duet/{p-dee41056.system.entry.js → p-b32224fe.system.entry.js} +1 -1
- package/lib/duet/p-b3744481.entry.js +4 -0
- package/lib/duet/{p-de2be65b.system.js → p-b42d81c3.system.js} +1 -1
- package/lib/duet/{p-27d538f7.system.entry.js → p-b4e87f02.system.entry.js} +1 -1
- package/lib/duet/{p-f71f12ed.entry.js → p-bf93a991.entry.js} +1 -1
- package/lib/duet/{p-fd98468a.system.js → p-c18a599e.system.js} +0 -0
- package/lib/duet/p-c2e77278.entry.js +4 -0
- package/lib/duet/p-c34329f3.entry.js +4 -0
- package/lib/duet/{p-59a07cf9.entry.js → p-c36b4da0.entry.js} +1 -1
- package/lib/duet/{p-a321a98c.entry.js → p-cdd70b93.entry.js} +1 -1
- package/lib/duet/p-d1c19f04.system.entry.js +4 -0
- package/lib/duet/{p-f71e337e.system.entry.js → p-d3a3c3c7.system.entry.js} +1 -1
- package/lib/duet/{p-345ea4f2.system.entry.js → p-d4118b6e.system.entry.js} +1 -1
- package/lib/duet/{p-3dc9d15d.system.entry.js → p-d744d188.system.entry.js} +1 -1
- package/lib/duet/p-ddb6344c.system.js +4 -0
- package/lib/duet/p-de07c7d7.entry.js +4 -0
- package/lib/duet/p-dfe79666.system.entry.js +4 -0
- package/lib/duet/p-e12f2b8b.system.js +4 -0
- package/lib/duet/p-e2a44156.js +4 -0
- package/lib/duet/p-e76b722f.entry.js +4 -0
- package/lib/duet/p-e964d062.entry.js +4 -0
- package/lib/duet/p-eb55ccd2.system.js +4 -0
- package/lib/duet/p-f0a4b68d.system.entry.js +4 -0
- package/lib/duet/p-f364eb96.entry.js +4 -0
- package/lib/duet/{p-a88df408.entry.js → p-f8ce39fb.entry.js} +1 -1
- package/lib/esm/{dom-21034390.js → dom-58cd15f6.js} +1 -1
- package/lib/esm/duet-alert.entry.js +4 -2
- package/lib/esm/duet-badge.entry.js +2 -2
- package/lib/esm/duet-button_2.entry.js +6 -5
- package/lib/esm/duet-caption_4.entry.js +21 -15
- package/lib/esm/duet-card.entry.js +6 -6
- package/lib/esm/duet-checkbox.entry.js +2 -2
- package/lib/esm/duet-choice_2.entry.js +57 -26
- package/lib/esm/duet-collapsible.entry.js +5 -2
- package/lib/esm/duet-cookie-consent.entry.js +1 -1
- package/lib/esm/duet-date-picker.entry.js +23 -13
- package/lib/esm/duet-divider_2.entry.js +1 -1
- package/lib/esm/duet-editable-table-button_3.entry.js +226 -0
- package/lib/esm/{duet-table.entry.js → duet-editable-table_3.entry.js} +205 -3
- package/lib/esm/duet-empty-state.entry.js +1 -1
- package/lib/esm/duet-footer.entry.js +4 -4
- package/lib/esm/duet-grid_2.entry.js +52 -4
- package/lib/esm/duet-header_2.entry.js +26 -10
- package/lib/esm/duet-hero.entry.js +6 -6
- package/lib/esm/duet-icon.entry.js +6 -14
- package/lib/esm/duet-input_2.entry.js +7 -7
- package/lib/esm/duet-layout.entry.js +1 -1
- package/lib/esm/duet-list_2.entry.js +2 -2
- package/lib/esm/duet-modal.entry.js +8 -7
- package/lib/esm/duet-notification_2.entry.js +6 -5
- package/lib/esm/duet-number-input.entry.js +36 -15
- package/lib/esm/duet-progress.entry.js +71 -0
- package/lib/esm/duet-radio_2.entry.js +2 -2
- package/lib/esm/duet-range-slider.entry.js +2 -2
- package/lib/esm/duet-select.entry.js +6 -6
- package/lib/esm/duet-step_2.entry.js +1 -1
- package/lib/esm/duet-tab_2.entry.js +12 -6
- package/lib/esm/duet-textarea.entry.js +5 -5
- package/lib/esm/duet-toggle.entry.js +1 -1
- package/lib/esm/duet-tooltip.entry.js +21 -10
- package/lib/esm/duet-tray.entry.js +21 -10
- package/lib/esm/duet-upload.entry.js +403 -180
- package/lib/esm/duet-visually-hidden.entry.js +1 -1
- package/lib/esm/duet.js +4 -4
- package/lib/esm/{focus-utils-0b12f0df.js → focus-utils-1fe0dcd0.js} +1 -1
- package/lib/esm/{index-f70ddc7f.js → index-84d97bd1.js} +88 -78
- package/lib/esm/js-utils-b69f17df.js +14 -0
- package/lib/esm/{language-utils-ab9c3afc.js → language-utils-344d894c.js} +28 -10
- package/lib/esm/loader.js +3 -3
- package/lib/esm/{shadow-css-31e2d504.js → shadow-css-7c726abb.js} +9 -10
- package/lib/esm/{string-utils-69cf0d09.js → string-utils-2f1793b8.js} +7 -1
- package/lib/esm/{token-utils-5a35377f.js → token-utils-590d9413.js} +1 -1
- package/lib/esm/{tokens.module-edb66c04.js → tokens.module-49cbf963.js} +3 -1
- package/lib/esm/watch-options-dd55bce8.js +57 -0
- package/lib/esm-es5/{dom-21034390.js → dom-58cd15f6.js} +0 -0
- package/lib/esm-es5/duet-alert.entry.js +1 -1
- package/lib/esm-es5/duet-badge.entry.js +1 -1
- package/lib/esm-es5/duet-button_2.entry.js +1 -1
- package/lib/esm-es5/duet-caption_4.entry.js +2 -2
- package/lib/esm-es5/duet-card.entry.js +1 -1
- package/lib/esm-es5/duet-checkbox.entry.js +1 -1
- package/lib/esm-es5/duet-choice_2.entry.js +2 -2
- package/lib/esm-es5/duet-collapsible.entry.js +1 -1
- package/lib/esm-es5/duet-cookie-consent.entry.js +1 -1
- package/lib/esm-es5/duet-date-picker.entry.js +1 -1
- package/lib/esm-es5/duet-divider_2.entry.js +1 -1
- package/lib/esm-es5/duet-editable-table-button_3.entry.js +4 -0
- package/lib/esm-es5/duet-editable-table_3.entry.js +4 -0
- package/lib/esm-es5/duet-empty-state.entry.js +1 -1
- package/lib/esm-es5/duet-footer.entry.js +1 -1
- package/lib/esm-es5/duet-grid_2.entry.js +2 -2
- package/lib/esm-es5/duet-header_2.entry.js +1 -1
- package/lib/esm-es5/duet-hero.entry.js +1 -1
- package/lib/esm-es5/duet-icon.entry.js +2 -2
- package/lib/esm-es5/duet-input_2.entry.js +1 -1
- package/lib/esm-es5/duet-layout.entry.js +1 -1
- package/lib/esm-es5/duet-list_2.entry.js +1 -1
- package/lib/esm-es5/duet-modal.entry.js +1 -1
- package/lib/esm-es5/duet-notification_2.entry.js +1 -1
- package/lib/esm-es5/duet-number-input.entry.js +2 -2
- package/lib/esm-es5/duet-progress.entry.js +4 -0
- package/lib/esm-es5/duet-radio_2.entry.js +1 -1
- package/lib/esm-es5/duet-range-slider.entry.js +1 -1
- package/lib/esm-es5/duet-select.entry.js +1 -1
- package/lib/esm-es5/duet-step_2.entry.js +1 -1
- package/lib/esm-es5/duet-tab_2.entry.js +2 -2
- package/lib/esm-es5/duet-textarea.entry.js +1 -1
- package/lib/esm-es5/duet-toggle.entry.js +1 -1
- package/lib/esm-es5/duet-tooltip.entry.js +1 -1
- package/lib/esm-es5/duet-tray.entry.js +1 -1
- package/lib/esm-es5/duet-upload.entry.js +2 -2
- package/lib/esm-es5/duet-visually-hidden.entry.js +1 -1
- package/lib/esm-es5/duet.js +1 -1
- package/lib/esm-es5/{focus-utils-0b12f0df.js → focus-utils-1fe0dcd0.js} +1 -1
- package/lib/esm-es5/index-84d97bd1.js +4 -0
- package/lib/esm-es5/js-utils-b69f17df.js +4 -0
- package/lib/esm-es5/language-utils-344d894c.js +4 -0
- package/lib/esm-es5/loader.js +1 -1
- package/lib/esm-es5/shadow-css-7c726abb.js +15 -0
- package/lib/esm-es5/{string-utils-69cf0d09.js → string-utils-2f1793b8.js} +1 -1
- package/lib/esm-es5/{token-utils-5a35377f.js → token-utils-590d9413.js} +1 -1
- package/lib/esm-es5/tokens.module-49cbf963.js +4 -0
- package/lib/esm-es5/watch-options-dd55bce8.js +4 -0
- package/lib/types/components/duet-alert/duet-alert.d.ts +2 -1
- package/lib/types/components/duet-button/duet-button.d.ts +1 -1
- package/lib/types/components/duet-choice/duet-choice.d.ts +24 -5
- package/lib/types/components/duet-date-picker/duet-date-picker.d.ts +15 -9
- package/lib/types/components/duet-editable-table/duet-editable-table-button.d.ts +72 -0
- package/lib/types/components/duet-editable-table/duet-editable-table-item.d.ts +72 -0
- package/lib/types/components/duet-editable-table/duet-editable-table-tabledata.d.ts +7 -0
- package/lib/types/components/duet-editable-table/duet-editable-table.d.ts +84 -0
- package/lib/types/components/duet-footer/duet-footer.d.ts +1 -1
- package/lib/types/components/duet-grid/duet-grid.d.ts +16 -2
- package/lib/types/components/duet-header/duet-header.d.ts +21 -5
- package/lib/types/components/duet-heading/duet-heading.d.ts +2 -2
- package/lib/types/components/duet-hero/duet-hero.d.ts +3 -3
- package/lib/types/components/duet-icon/duet-icon.d.ts +1 -1
- package/lib/types/components/duet-link/duet-link.d.ts +2 -3
- package/lib/types/components/duet-modal/duet-modal.d.ts +3 -3
- package/lib/types/components/duet-notification-drawer/duet-notification-drawer.d.ts +3 -3
- package/lib/types/components/duet-number-input/duet-number-input.d.ts +21 -0
- package/lib/types/components/duet-paragraph/duet-paragraph.d.ts +9 -1
- package/lib/types/components/duet-progress/duet-progress.d.ts +64 -0
- package/lib/types/components/duet-tab-group/duet-tab-group.d.ts +6 -0
- package/lib/types/components/duet-tooltip/duet-tooltip.d.ts +11 -0
- package/lib/types/components/duet-tray/duet-tray.d.ts +11 -0
- package/lib/types/components/duet-upload/duet-upload-aria-status.d.ts +49 -0
- package/lib/types/components/duet-upload/duet-upload-editable-item-error.d.ts +7 -0
- package/lib/types/components/duet-upload/duet-upload-editable-item-inprogres.d.ts +7 -0
- package/lib/types/components/duet-upload/duet-upload-editable-item-success.d.ts +8 -0
- package/lib/types/components/duet-upload/duet-upload.d.ts +94 -25
- package/lib/types/components/duet-upload/errorcodes.utils.d.ts +1 -0
- package/lib/types/components/duet-upload/xhr.helpers.d.ts +7 -1
- package/lib/types/components.d.ts +611 -79
- package/lib/types/utils/js-utils.d.ts +1 -0
- package/lib/types/utils/language-utils.d.ts +8 -3
- package/lib/types/utils/string-utils.d.ts +1 -0
- package/lib/types/utils/watch-options.d.ts +2 -0
- package/package.json +19 -15
- package/hydrate/package.json +0 -6
- package/lib/cjs/duet-fieldset.cjs.entry.js +0 -62
- package/lib/collection/components/duet-upload/duet-upload-file-list.js +0 -49
- package/lib/duet/p-0733c303.system.entry.js +0 -4
- package/lib/duet/p-095060cc.js +0 -4
- package/lib/duet/p-156864a1.system.entry.js +0 -4
- package/lib/duet/p-15c15c6a.js +0 -15
- package/lib/duet/p-1911dfe7.system.entry.js +0 -4
- package/lib/duet/p-1c41525a.entry.js +0 -4
- package/lib/duet/p-1cfe38b1.system.entry.js +0 -4
- package/lib/duet/p-2834a302.entry.js +0 -4
- package/lib/duet/p-28a3d38f.system.entry.js +0 -4
- package/lib/duet/p-2a1a9f9f.entry.js +0 -4
- package/lib/duet/p-2a4d7c5b.system.entry.js +0 -4
- package/lib/duet/p-3eb36e3d.entry.js +0 -4
- package/lib/duet/p-4095dba5.entry.js +0 -4
- package/lib/duet/p-418b2ce7.system.js +0 -4
- package/lib/duet/p-4289b543.entry.js +0 -4
- package/lib/duet/p-43e39d98.system.js +0 -4
- package/lib/duet/p-46a3ae43.system.js +0 -4
- package/lib/duet/p-4a38cf9d.entry.js +0 -4
- package/lib/duet/p-4be8e814.entry.js +0 -4
- package/lib/duet/p-4dcea8fb.system.entry.js +0 -4
- package/lib/duet/p-591b2137.entry.js +0 -4
- package/lib/duet/p-5c5bdb06.system.entry.js +0 -4
- package/lib/duet/p-5f70e318.entry.js +0 -4
- package/lib/duet/p-62c294d6.system.entry.js +0 -4
- package/lib/duet/p-6a356ab1.system.js +0 -4
- package/lib/duet/p-6c2729da.js +0 -4
- package/lib/duet/p-6f107847.system.entry.js +0 -4
- package/lib/duet/p-77a5fe4c.system.js +0 -4
- package/lib/duet/p-7809e78b.system.entry.js +0 -4
- package/lib/duet/p-7a36d76f.system.entry.js +0 -4
- package/lib/duet/p-7ee52f58.entry.js +0 -4
- package/lib/duet/p-884693f1.entry.js +0 -4
- package/lib/duet/p-89db3b94.entry.js +0 -4
- package/lib/duet/p-8cfce39e.system.entry.js +0 -4
- package/lib/duet/p-8ffe1461.system.entry.js +0 -4
- package/lib/duet/p-9381c2d4.entry.js +0 -4
- package/lib/duet/p-9a450c9a.entry.js +0 -4
- package/lib/duet/p-9a89ec39.js +0 -4
- package/lib/duet/p-9bbfe606.system.entry.js +0 -4
- package/lib/duet/p-a6096b05.system.entry.js +0 -4
- package/lib/duet/p-a89d5d7c.entry.js +0 -4
- package/lib/duet/p-b07055fd.system.entry.js +0 -4
- package/lib/duet/p-b4374f0e.entry.js +0 -4
- package/lib/duet/p-b456d684.system.entry.js +0 -4
- package/lib/duet/p-bd18c93f.js +0 -4
- package/lib/duet/p-bddb1c15.system.entry.js +0 -4
- package/lib/duet/p-c0b95b58.entry.js +0 -4
- package/lib/duet/p-c3688975.entry.js +0 -4
- package/lib/duet/p-c4d183e6.entry.js +0 -4
- package/lib/duet/p-c9303f9a.entry.js +0 -4
- package/lib/duet/p-cd4e8ccf.js +0 -4
- package/lib/duet/p-ceb75b35.system.entry.js +0 -4
- package/lib/duet/p-cf243bcb.system.entry.js +0 -4
- package/lib/duet/p-d37c8a05.system.js +0 -4
- package/lib/duet/p-d989af11.entry.js +0 -4
- package/lib/duet/p-e58ca7af.system.js +0 -16
- package/lib/duet/p-e6128d82.system.entry.js +0 -4
- package/lib/duet/p-e86cdc17.entry.js +0 -4
- package/lib/duet/p-eadb29c7.entry.js +0 -4
- package/lib/duet/p-f30b14d6.system.entry.js +0 -4
- package/lib/duet/p-f79f8da1.entry.js +0 -4
- package/lib/duet/p-fc397e03.system.entry.js +0 -4
- package/lib/esm/duet-fieldset.entry.js +0 -58
- package/lib/esm/watch-options-de55ea78.js +0 -35
- package/lib/esm-es5/duet-fieldset.entry.js +0 -4
- package/lib/esm-es5/duet-table.entry.js +0 -4
- package/lib/esm-es5/index-f70ddc7f.js +0 -4
- package/lib/esm-es5/language-utils-ab9c3afc.js +0 -4
- package/lib/esm-es5/shadow-css-31e2d504.js +0 -15
- package/lib/esm-es5/tokens.module-edb66c04.js +0 -4
- package/lib/esm-es5/watch-options-de55ea78.js +0 -4
- package/lib/html.html-data.json +0 -4556
- package/lib/types/components/duet-upload/duet-upload-file-list.d.ts +0 -9
|
@@ -1,183 +1,129 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built with Duet Design System
|
|
3
3
|
*/
|
|
4
|
-
import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-
|
|
4
|
+
import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-84d97bd1.js';
|
|
5
5
|
import { c as createID } from './create-id-981107da.js';
|
|
6
|
-
import {
|
|
6
|
+
import { d as debounce } from './js-utils-b69f17df.js';
|
|
7
|
+
import { g as getLocaleString } from './language-utils-344d894c.js';
|
|
7
8
|
import { i as inheritGlobalTheme } from './themeable-component-572685dd.js';
|
|
9
|
+
import './string-utils-2f1793b8.js';
|
|
8
10
|
|
|
9
|
-
const
|
|
10
|
-
if (bytes === 0) {
|
|
11
|
-
return "0 Bytes";
|
|
12
|
-
}
|
|
13
|
-
const k = 1024;
|
|
14
|
-
const dm = decimals < 0 ? 0 : decimals;
|
|
15
|
-
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
16
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
17
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const DuetUploadFileList = ({ data, onDelete, onCancel, getError }) => {
|
|
21
|
-
if (data.invalid.length === 0 && data.valid.length === 0) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
return (h("ol", { class: "duet-upload-filelist" },
|
|
25
|
-
data.valid.length !== 0 && (h("li", null,
|
|
26
|
-
h("duet-visually-hidden", null, "Files"),
|
|
27
|
-
h("ul", null, data.valid.length !== 0 &&
|
|
28
|
-
data.valid.map(e => (h("li", { class: "duet-upload-file" },
|
|
29
|
-
h("div", { class: "duet-upload-file-container" },
|
|
30
|
-
h("div", { class: "duet-upload-file-link" }, e.url ? (h("duet-button", { variation: "plain", icon: "messaging-attachment", url: e.url },
|
|
31
|
-
e.item.name,
|
|
32
|
-
" (",
|
|
33
|
-
formatBytes(e.item.size),
|
|
34
|
-
")")) : (`${e.item.name} (${formatBytes(e.item.size)})`)),
|
|
35
|
-
h("ul", { class: "duet-upload-file-actions", role: "menubar", "aria-label": "file actions" },
|
|
36
|
-
e.progress < 100 && (h("li", { role: "none" },
|
|
37
|
-
h("duet-button", { role: "menuitem", variation: "plain", icon: "messaging-declined", "icon-only": true, "icon-size": "large", margin: "none", onClick: ev => onCancel(e.item.name, ev) }))),
|
|
38
|
-
e.progress === 100 && (h("li", { role: "none" },
|
|
39
|
-
h("duet-button", { role: "menuitem", variation: "destructive", icon: "action-delete", "icon-only": true, "icon-size": "large", margin: "none", onClick: ev => onDelete(e.item.name, ev) }))))),
|
|
40
|
-
e.progress < 100 && (h("div", { class: "duet-upload-file-progress" },
|
|
41
|
-
h("progress", { value: e.progress, max: "100" },
|
|
42
|
-
h("div", { class: "progress-bar" },
|
|
43
|
-
h("span", { style: { width: `${e.progress}%;` } },
|
|
44
|
-
"Progress: ",
|
|
45
|
-
e.progress,
|
|
46
|
-
"%"))))))))))),
|
|
47
|
-
data.invalid.length !== 0 && (h("li", null,
|
|
48
|
-
h("duet-visually-hidden", null, "Files with Errors"),
|
|
49
|
-
h("ul", null, data.invalid.map(e => {
|
|
50
|
-
return (h("li", { class: "duet-upload-file duet-upload-file-errors" },
|
|
51
|
-
h("div", { class: "duet-upload-file-container" },
|
|
52
|
-
h("div", { class: "duet-upload-file-link duet-upload-file-link-error" },
|
|
53
|
-
h("div", null,
|
|
54
|
-
e.item.name,
|
|
55
|
-
" (",
|
|
56
|
-
formatBytes(e.item.size),
|
|
57
|
-
")"),
|
|
58
|
-
h("div", { "data-error-type": e.error.type, "data-error-message": e.error.system_message }, getError(e.error.type))),
|
|
59
|
-
h("ul", { class: "duet-upload-file-actions", role: "menubar", "aria-label": "file actions" },
|
|
60
|
-
h("li", { role: "none" },
|
|
61
|
-
h("duet-button", { role: "menuitem", variation: "destructive", icon: "action-delete", "icon-only": true, "icon-size": "large", margin: "none", onClick: ev => onDelete(e.item.name, ev) }))))));
|
|
62
|
-
}))))));
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const errorcodes = [
|
|
11
|
+
const errorCodes = [
|
|
66
12
|
{
|
|
67
13
|
type: "default",
|
|
68
14
|
system_message: "unknown error",
|
|
69
15
|
message: {
|
|
70
|
-
fi: "",
|
|
71
|
-
sv: "",
|
|
72
|
-
en: "An unknown error occured, please try again"
|
|
16
|
+
fi: "Tapahtui tuntematon virhe, ole hyvä ja yritä uudelleen.",
|
|
17
|
+
sv: "Ett okänt fel uppstod, försök igen.",
|
|
18
|
+
en: "An unknown error occured, please try again."
|
|
73
19
|
}
|
|
74
20
|
},
|
|
75
21
|
{
|
|
76
22
|
type: "400",
|
|
77
23
|
system_message: "Bad Request: The server could not understand the request due to invalid syntax.",
|
|
78
24
|
message: {
|
|
79
|
-
fi: "",
|
|
80
|
-
sv: "",
|
|
81
|
-
en: "The server rejected your file"
|
|
25
|
+
fi: "Tiedostoa ei hyväksytty.",
|
|
26
|
+
sv: "Servern avvisade din fil.",
|
|
27
|
+
en: "The server rejected your file."
|
|
82
28
|
}
|
|
83
29
|
},
|
|
84
30
|
{
|
|
85
31
|
type: "401",
|
|
86
|
-
system_message: "Not Authenticated: The client must authenticate itself to get the requested response
|
|
32
|
+
system_message: "Not Authenticated: The client must authenticate itself to get the requested response...",
|
|
87
33
|
message: {
|
|
88
|
-
fi: "",
|
|
89
|
-
sv: "",
|
|
90
|
-
en: "You need to be logged in to upload files"
|
|
34
|
+
fi: "Vain kirjautunut käyttäjä voi lähettää tiedostoja.",
|
|
35
|
+
sv: "Du måste vara inloggad för att ladda upp filer.",
|
|
36
|
+
en: "You need to be logged in to upload files."
|
|
91
37
|
}
|
|
92
38
|
},
|
|
93
39
|
{
|
|
94
40
|
type: "403",
|
|
95
|
-
system_message: "No Access: The client does not have access rights to the content
|
|
41
|
+
system_message: "No Access: The client does not have access rights to the content.",
|
|
96
42
|
message: {
|
|
97
|
-
fi: "",
|
|
98
|
-
sv: "",
|
|
99
|
-
en: "You do not have the correct access rights to upload files"
|
|
43
|
+
fi: "Ei oikeuksia lähettää tiedostoja.",
|
|
44
|
+
sv: "Du har inte rätt åtkomsträttigheter för att ladda upp filer.",
|
|
45
|
+
en: "You do not have the correct access rights to upload files."
|
|
100
46
|
}
|
|
101
47
|
},
|
|
102
48
|
{
|
|
103
49
|
type: "413",
|
|
104
50
|
system_message: "Payload too large",
|
|
105
51
|
message: {
|
|
106
|
-
fi: "",
|
|
107
|
-
sv: "",
|
|
108
|
-
en: "The file was to large for the server to handle"
|
|
52
|
+
fi: "Tiedosto oli liian vastaanotettavaksi.",
|
|
53
|
+
sv: "Filen var för stor för servern att hantera.",
|
|
54
|
+
en: "The file was to large for the server to handle."
|
|
109
55
|
}
|
|
110
56
|
},
|
|
111
57
|
{
|
|
112
58
|
type: "415",
|
|
113
59
|
system_message: "Unsupported media type",
|
|
114
60
|
message: {
|
|
115
|
-
fi: "",
|
|
116
|
-
sv: "",
|
|
117
|
-
en: "The server rejected the file because it had the wrong type"
|
|
61
|
+
fi: "Tiedoston tyyppi oli väärä.",
|
|
62
|
+
sv: "Servern avvisade filen eftersom den hade fel typ.",
|
|
63
|
+
en: "The server rejected the file because it had the wrong type."
|
|
118
64
|
}
|
|
119
65
|
},
|
|
120
66
|
{
|
|
121
67
|
type: "429",
|
|
122
68
|
system_message: "Too many request from same address",
|
|
123
69
|
message: {
|
|
124
|
-
fi: "",
|
|
125
|
-
sv: "",
|
|
126
|
-
en: "The server has received to many request from you, please try again later"
|
|
70
|
+
fi: "Liian monta yritystä, ole hyvä ja yritä myöhemmin uudelleen.",
|
|
71
|
+
sv: "Servern har fått många förfrågningar från dig, försök igen senare.",
|
|
72
|
+
en: "The server has received to many request from you, please try again later."
|
|
127
73
|
}
|
|
128
74
|
},
|
|
129
75
|
{
|
|
130
76
|
type: "500",
|
|
131
77
|
system_message: "Internal Server Error",
|
|
132
78
|
message: {
|
|
133
|
-
fi: "",
|
|
134
|
-
sv: "",
|
|
135
|
-
en: "The server reported an unknown error and the upload failed"
|
|
79
|
+
fi: "Palvelin ilmoitti tuntemattomasta virheestä ja lataus epäonnistui.",
|
|
80
|
+
sv: "Servern rapporterade ett okänt fel och uppladdningen misslyckades.",
|
|
81
|
+
en: "The server reported an unknown error and the upload failed."
|
|
136
82
|
}
|
|
137
83
|
},
|
|
138
84
|
{
|
|
139
85
|
type: "duet-upload-100",
|
|
140
86
|
system_message: "File extension not allowed",
|
|
141
87
|
message: {
|
|
142
|
-
fi: "",
|
|
143
|
-
sv: "",
|
|
144
|
-
en: "You cannot upload files with that extension"
|
|
88
|
+
fi: "Tiedoston tyyppi ei ole sallittu.",
|
|
89
|
+
sv: "Du kan inte ladda upp filer av den type.",
|
|
90
|
+
en: "You cannot upload files with that extension."
|
|
145
91
|
}
|
|
146
92
|
},
|
|
147
93
|
{
|
|
148
94
|
type: "duet-upload-001",
|
|
149
95
|
system_message: "File transfer failed",
|
|
150
96
|
message: {
|
|
151
|
-
fi: "",
|
|
152
|
-
sv: "",
|
|
153
|
-
en: "Your connection to the server was interrupted, try again"
|
|
97
|
+
fi: "Tiedoston lähetys keskeytyi, ole hyvä ja yritä uudelleen.",
|
|
98
|
+
sv: "Din anslutning till servern avbröts, försök igen.",
|
|
99
|
+
en: "Your connection to the server was interrupted, try again."
|
|
154
100
|
}
|
|
155
101
|
},
|
|
156
102
|
{
|
|
157
103
|
type: "duet-upload-101",
|
|
158
104
|
system_message: "File mimetype not allowed",
|
|
159
105
|
message: {
|
|
160
|
-
fi: "",
|
|
161
|
-
sv: "",
|
|
162
|
-
en: "You cannot upload files of that type"
|
|
106
|
+
fi: "Tiedoston tyyppi ei ole sallittu.",
|
|
107
|
+
sv: "Du kan inte ladda upp filer av den typ.",
|
|
108
|
+
en: "You cannot upload files of that type."
|
|
163
109
|
}
|
|
164
110
|
},
|
|
165
111
|
{
|
|
166
112
|
type: "duet-upload-201",
|
|
167
113
|
system_message: "File is too large",
|
|
168
114
|
message: {
|
|
169
|
-
fi: "",
|
|
170
|
-
sv: "",
|
|
171
|
-
en: "The file is larger than permitted"
|
|
115
|
+
fi: "Tiedosto on liian iso.",
|
|
116
|
+
sv: "Filen är större än tillåtet.",
|
|
117
|
+
en: "The file is larger than permitted."
|
|
172
118
|
}
|
|
173
119
|
},
|
|
174
120
|
{
|
|
175
121
|
type: "duet-upload-202",
|
|
176
122
|
system_message: "The combined size of all files is too large",
|
|
177
123
|
message: {
|
|
178
|
-
fi: "",
|
|
179
|
-
sv: "",
|
|
180
|
-
en: "You have reached the maximum combined filesize"
|
|
124
|
+
fi: "Tiedostojen yhteenlaskettu koko on liian iso.",
|
|
125
|
+
sv: "Du har nått den maximala kombinerade filstorleken.",
|
|
126
|
+
en: "You have reached the maximum combined filesize."
|
|
181
127
|
}
|
|
182
128
|
},
|
|
183
129
|
{
|
|
@@ -185,7 +131,7 @@ const errorcodes = [
|
|
|
185
131
|
system_message: "The maximum file limit has been reached",
|
|
186
132
|
message: {
|
|
187
133
|
fi: "Liitteiden maksimimäärä saavutettu.",
|
|
188
|
-
sv: "",
|
|
134
|
+
sv: "Maximalt antal bilagor har uppnåtts.",
|
|
189
135
|
en: "Maximum number of attachments reached."
|
|
190
136
|
}
|
|
191
137
|
}
|
|
@@ -197,16 +143,81 @@ const getError = (code) => {
|
|
|
197
143
|
system_message: undefined,
|
|
198
144
|
message: undefined,
|
|
199
145
|
};
|
|
200
|
-
error =
|
|
201
|
-
|
|
146
|
+
error = errorCodes.filter(errorItem => {
|
|
147
|
+
// the == is intentional we may be comparing numbers to strings - and that is ok here
|
|
148
|
+
return errorItem.type == code;
|
|
202
149
|
})[0];
|
|
203
150
|
if (!error) {
|
|
204
|
-
error =
|
|
151
|
+
error = errorCodes.filter(errorItem => {
|
|
205
152
|
return errorItem.type === "default";
|
|
206
153
|
})[0];
|
|
207
154
|
}
|
|
208
155
|
return error;
|
|
209
156
|
};
|
|
157
|
+
const getI18nError = (errorCode) => {
|
|
158
|
+
const errorFromJson = getError(errorCode);
|
|
159
|
+
const i18String = getLocaleString(errorFromJson.message);
|
|
160
|
+
if (i18String === "" || !i18String) {
|
|
161
|
+
return errorFromJson.system_message;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return i18String;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const ErrorItem = ({ data }) => {
|
|
169
|
+
const { item, error } = data;
|
|
170
|
+
const { name } = item;
|
|
171
|
+
const { type } = error;
|
|
172
|
+
return (h("span", { class: "duet-upload-item-error", role: "status" },
|
|
173
|
+
h("duet-paragraph", { class: "duet-upload-item-name", color: "danger", margin: "none", weight: "semi-bold" },
|
|
174
|
+
h("duet-icon", { margin: "none", size: "xx-small", name: "messaging-attachment" }),
|
|
175
|
+
" ",
|
|
176
|
+
name),
|
|
177
|
+
h("duet-paragraph", { class: "duet-upload-item-error-label", size: "small", margin: "none", color: "danger" }, getI18nError(type))));
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const ProgressItem = ({ progress, name }) => (h("span", null,
|
|
181
|
+
h("duet-paragraph", { color: "secondary", margin: "none", size: "small" }, name),
|
|
182
|
+
h("duet-spacer", { size: "xx-small" }),
|
|
183
|
+
h("duet-progress", { progress: Math.ceil(progress), "aria-hidden": true })));
|
|
184
|
+
|
|
185
|
+
const formatBytes = (bytes, decimals = 2) => {
|
|
186
|
+
if (bytes === 0) {
|
|
187
|
+
return "0 Bytes";
|
|
188
|
+
}
|
|
189
|
+
const k = 1024;
|
|
190
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
191
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
192
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
193
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const SuccessItem = ({ data, showLinks }) => {
|
|
197
|
+
const { item, size, uploaded, url, meta } = data;
|
|
198
|
+
const { name } = item;
|
|
199
|
+
const ContentName = (h("span", { class: "duet-upload-item-name" },
|
|
200
|
+
h("duet-icon", { margin: "none", size: "xx-small", name: "messaging-attachment" }),
|
|
201
|
+
h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
|
|
202
|
+
name));
|
|
203
|
+
const SizeText = (h("span", { class: "duet-upload-item-size", style: { fontSize: "14px", fontWeight: "400" } },
|
|
204
|
+
"(",
|
|
205
|
+
formatBytes(size),
|
|
206
|
+
")"));
|
|
207
|
+
const FilenameLine = uploaded && url && showLinks ? (h("duet-paragraph", { color: "secondary", margin: "none", weight: "semi-bold" },
|
|
208
|
+
h("duet-link", { url: url, external: true }, ContentName),
|
|
209
|
+
h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
|
|
210
|
+
SizeText)) : (h("duet-paragraph", { color: "secondary", margin: "none", weight: "semi-bold" },
|
|
211
|
+
ContentName,
|
|
212
|
+
h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
|
|
213
|
+
SizeText));
|
|
214
|
+
const Badges = meta && meta.badges ? (h("span", null,
|
|
215
|
+
h("duet-spacer", { size: "xx-small" }),
|
|
216
|
+
meta.badges.map(badgeText => (h("duet-badge", { color: "primary" }, badgeText))))) : undefined;
|
|
217
|
+
return (h("span", { class: "duet-upload-item-success" },
|
|
218
|
+
h("div", null, FilenameLine),
|
|
219
|
+
Badges));
|
|
220
|
+
};
|
|
210
221
|
|
|
211
222
|
const validateFileExtension = (name, allowedExtensions) => {
|
|
212
223
|
if (!allowedExtensions) {
|
|
@@ -297,12 +308,8 @@ const validateTotalAmountIsAboveMax = (filelist, maxFiles) => {
|
|
|
297
308
|
return false;
|
|
298
309
|
};
|
|
299
310
|
|
|
300
|
-
const makeXhrRequest = (payload, options, onFailure, onSuccess, onProgress) => {
|
|
301
|
-
const { type, xhr, uri, argument, headers } =
|
|
302
|
-
type: "POST",
|
|
303
|
-
argument: null,
|
|
304
|
-
headers: null,
|
|
305
|
-
}, options);
|
|
311
|
+
const makeXhrRequest = ({ payload, options, onFailure, onSuccess, onProgress }) => {
|
|
312
|
+
const { type = "POST", xhr, uri, argument = null, headers = null } = options;
|
|
306
313
|
xhr.open(type, `${uri}${argument || ""}`, true);
|
|
307
314
|
const { data, name } = payload;
|
|
308
315
|
// headers must be added after open
|
|
@@ -329,7 +336,7 @@ const makeXhrRequest = (payload, options, onFailure, onSuccess, onProgress) => {
|
|
|
329
336
|
return xhr;
|
|
330
337
|
};
|
|
331
338
|
|
|
332
|
-
const duetUploadCss = "*,*::after,*::before{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}:host{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}:
|
|
339
|
+
const duetUploadCss = "*,*::after,*::before{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}:host{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}::slotted([slot=header]){margin-bottom:16px}::slotted([slot=fileheader]){margin:16px 0 0 0}::slotted([slot=filefooter]){margin-top:16px}.duet-upload{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}.duet-upload-item-size{font-size:0.75rem;font-weight:400}.duet-upload-filelist{margin-bottom:25px}.duet-upload-filelist-empty{display:flex;align-items:center;justify-content:center;width:100%;height:75px;margin:0 auto;font-size:1rem;font-weight:400;background-color:#f5f8fa}";
|
|
333
340
|
|
|
334
341
|
let DuetUpload = class {
|
|
335
342
|
constructor(hostRef) {
|
|
@@ -349,9 +356,19 @@ let DuetUpload = class {
|
|
|
349
356
|
this.buttonId = createID("DuetButton");
|
|
350
357
|
this.labelId = createID("DuetLabel");
|
|
351
358
|
this.uploadId = createID("DuetUpload");
|
|
359
|
+
this.editableTableId = createID("DuetEditableTable");
|
|
352
360
|
this.filesInProgress = new Map();
|
|
353
361
|
this.fileMaxReached = false;
|
|
354
362
|
this.bytesMaxReached = false;
|
|
363
|
+
//region Internally exposed properties
|
|
364
|
+
/**
|
|
365
|
+
* Properties
|
|
366
|
+
*/
|
|
367
|
+
this.DefaultGroups = {
|
|
368
|
+
inprogress: "inprogress",
|
|
369
|
+
success: "success",
|
|
370
|
+
failure: "failure",
|
|
371
|
+
};
|
|
355
372
|
/**
|
|
356
373
|
* State() variables
|
|
357
374
|
*/
|
|
@@ -361,9 +378,91 @@ let DuetUpload = class {
|
|
|
361
378
|
* it will be up to you to handle the upload and return progress information to the upload-component
|
|
362
379
|
*/
|
|
363
380
|
this.external = false;
|
|
381
|
+
/**
|
|
382
|
+
* If set the upload component will not display an upload button, you will have to create on yourself
|
|
383
|
+
* and call the exposed methods startUpload
|
|
384
|
+
*/
|
|
385
|
+
this.hideButton = false;
|
|
386
|
+
/**
|
|
387
|
+
* Default actions added to all files
|
|
388
|
+
*/
|
|
389
|
+
this.actions = [
|
|
390
|
+
{
|
|
391
|
+
icon: "action-delete",
|
|
392
|
+
color: "color-danger",
|
|
393
|
+
color_hover: "category-home",
|
|
394
|
+
id: "delete",
|
|
395
|
+
map: ["success", "failure"],
|
|
396
|
+
label: {
|
|
397
|
+
fi: "Poista tiedosto",
|
|
398
|
+
en: "Poista tiedosto",
|
|
399
|
+
sv: "Ta bort filen",
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
icon: "navigation-close",
|
|
404
|
+
color: "primary",
|
|
405
|
+
color_hover: "category-home",
|
|
406
|
+
id: "cancel",
|
|
407
|
+
map: ["inprogress"],
|
|
408
|
+
label: {
|
|
409
|
+
fi: "Keskeytä lähetys",
|
|
410
|
+
en: "Cancel the upload",
|
|
411
|
+
sv: "Stop överföringen",
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
];
|
|
415
|
+
/**
|
|
416
|
+
* If enabled the filelist will create links on successfully uploaded items,
|
|
417
|
+
* this requires the server can respond with link URIs in the correct format
|
|
418
|
+
*/
|
|
419
|
+
this.showLinks = false;
|
|
420
|
+
/**
|
|
421
|
+
* Property to change the aria upload progress text read aloud by screenreaders
|
|
422
|
+
* @default {
|
|
423
|
+
fi: "Lisää liite",
|
|
424
|
+
sv: "Lägg till en bilaga",
|
|
425
|
+
en: "Choose files",
|
|
426
|
+
}
|
|
427
|
+
*/
|
|
428
|
+
this.statusLabelDefaults = {
|
|
429
|
+
fi: {
|
|
430
|
+
inProgress: "Lähetetään {filesUploaded} lähetettävästä {filesTotal} tiedostosta",
|
|
431
|
+
inProgressWithErrors: "Lähetetään {filesInProgress} tiedostoa, lähetetty {filesUploaded} lähetettävästä {filesTotal} tiedostosta, {filesWithErrors} tiedostossa on virheitä",
|
|
432
|
+
done: "Kaikki {filesTotal} tiedostoa lähetetty onnistuneesti",
|
|
433
|
+
doneWithErrors: "Lähetys valmis, {filesUploaded} tiedostoa on lähetetty onnistuneesti, {filesWithErrors} tiedostossa oli virheitä",
|
|
434
|
+
files: "tiedostot",
|
|
435
|
+
file: "tiedosto",
|
|
436
|
+
},
|
|
437
|
+
sv: {
|
|
438
|
+
inProgress: "Adding {filesUploaded} of {filesTotal}",
|
|
439
|
+
inProgressWithErrors: "Laddar upp {filesInProgress}, {filesUploaded} uppladdad av {filesTotal}, {filesWithErrors} misslyckades",
|
|
440
|
+
done: "Alla {filesTotal} har lagts till",
|
|
441
|
+
doneWithErrors: "Handling slutförd, {filesUploaded} har lagts till, {filesWithErrors} misslyckades",
|
|
442
|
+
files: "filer",
|
|
443
|
+
file: "fil",
|
|
444
|
+
},
|
|
445
|
+
en: {
|
|
446
|
+
inProgress: "Adding {filesUploaded} of {filesTotal}",
|
|
447
|
+
inProgressWithErrors: "Uploading {filesInProgress}, {filesUploaded} uploaded of {filesTotal}, {filesWithErrors} failed",
|
|
448
|
+
done: "All {filesTotal} added successfully",
|
|
449
|
+
doneWithErrors: "Action completed, {filesUploaded} has been added successfully, {filesWithErrors} had errors",
|
|
450
|
+
files: "tiedostoa",
|
|
451
|
+
file: "tiedosto",
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
/**
|
|
455
|
+
* Strings used for the status aria-label
|
|
456
|
+
*/
|
|
457
|
+
this.statusMessageLabel = getLocaleString(this.statusLabelDefaults);
|
|
364
458
|
/**
|
|
365
459
|
* Property to change descriptionDefaults defaults on the component.
|
|
366
460
|
* normally you would handle these strings on an application level and override @label when needed
|
|
461
|
+
* @default {
|
|
462
|
+
fi: "Lisää liite",
|
|
463
|
+
sv: "Lägg till en bilaga",
|
|
464
|
+
en: "Add an attachment",
|
|
465
|
+
}
|
|
367
466
|
*/
|
|
368
467
|
this.buttonLabelDefaults = {
|
|
369
468
|
fi: "Lisää liite",
|
|
@@ -399,6 +498,10 @@ let DuetUpload = class {
|
|
|
399
498
|
* browser from displaying its own validation errors.
|
|
400
499
|
*/
|
|
401
500
|
this.required = false;
|
|
501
|
+
/**
|
|
502
|
+
* Visually hides the groups labels in the editable table list used to display the list of files
|
|
503
|
+
*/
|
|
504
|
+
this.hideGroups = false;
|
|
402
505
|
/**
|
|
403
506
|
* Map of string that contain list of uploaded files.
|
|
404
507
|
*/
|
|
@@ -410,6 +513,7 @@ let DuetUpload = class {
|
|
|
410
513
|
/**
|
|
411
514
|
* Property to change labelDefaults defaults on the component.
|
|
412
515
|
* normally you would handle these strings on an application level and override @label when needed
|
|
516
|
+
* @default { fi: "Lisää liite",sv: "Lägg till en bilaga",en: "Add attachments"}
|
|
413
517
|
*/
|
|
414
518
|
this.labelDefaults = {
|
|
415
519
|
fi: "Lisää liite",
|
|
@@ -424,6 +528,11 @@ let DuetUpload = class {
|
|
|
424
528
|
/**
|
|
425
529
|
* Property to change descriptionDefaults defaults on the component.
|
|
426
530
|
* normally you would handle these strings on an application level and override @label when needed
|
|
531
|
+
* @default {
|
|
532
|
+
fi: "Voit liittää {filetypes}-muotoisia tiedostoja sekä yleisimpiä videotiedostoja. Voit lähettää {maxbytes} verran tiedostoja yhdellä kertaa, ja lisätä enintään {maxfiles} liitettä kerrallaan.",
|
|
533
|
+
sv: "Du kan bifoga filer i flg. formater {filetypes} samt de vanligaste videofilerna. Du kan ladda upp {maxbytes} filer åt gången och lägga till upp till {maxfiles} bilagor åt gången.",
|
|
534
|
+
en: "You may attach the following filetypes: {filetypes} - as well as the most common video files. You can upload {maxbytes} of files at a time, and add up to {maxfiles} attachments at a time.",
|
|
535
|
+
}
|
|
427
536
|
*/
|
|
428
537
|
this.descriptionDefaults = {
|
|
429
538
|
fi: "Voit liittää {filetypes}-muotoisia tiedostoja sekä yleisimpiä videotiedostoja. Voit lähettää {maxbytes} verran tiedostoja yhdellä kertaa, ja lisätä enintään {maxfiles} liitettä kerrallaan.",
|
|
@@ -432,12 +541,20 @@ let DuetUpload = class {
|
|
|
432
541
|
};
|
|
433
542
|
/**
|
|
434
543
|
* Description for the upload component.
|
|
435
|
-
* @default
|
|
544
|
+
* @default {
|
|
545
|
+
fi: "Voit liittää {filetypes}-muotoisia tiedostoja sekä yleisimpiä videotiedostoja. Voit lähettää {maxbytes} verran tiedostoja yhdellä kertaa, ja lisätä enintään {maxfiles} liitettä kerrallaan.",
|
|
546
|
+
sv: "Du kan bifoga filer i flg. formater {filetypes} samt de vanligaste videofilerna. Du kan ladda upp {maxbytes} filer åt gången och lägga till upp till {maxfiles} bilagor åt gången.",
|
|
547
|
+
en: "You may attach the following filetypes: {filetypes} - as well as the most common video files. You can upload {maxbytes} of files at a time, and add up to {maxfiles} attachments at a time.",
|
|
548
|
+
}
|
|
436
549
|
*/
|
|
437
550
|
this.description = getLocaleString(this.descriptionDefaults);
|
|
438
551
|
/**
|
|
439
552
|
* Defaults for the filelist's empty state.
|
|
440
|
-
* @default {
|
|
553
|
+
* @default {
|
|
554
|
+
fi: "Ei vielä lisättyjä tiedostoja.",
|
|
555
|
+
sv: "Inga filer har lagts till ännu.",
|
|
556
|
+
en: "No files added yet.",
|
|
557
|
+
}
|
|
441
558
|
*/
|
|
442
559
|
this.fileListEmptyDefaults = {
|
|
443
560
|
fi: "Ei vielä lisättyjä tiedostoja.",
|
|
@@ -453,21 +570,6 @@ let DuetUpload = class {
|
|
|
453
570
|
* Display the input in error state along with an error message.
|
|
454
571
|
*/
|
|
455
572
|
this.error = "";
|
|
456
|
-
/**
|
|
457
|
-
* Visually hide the label, but still show it to screen readers.
|
|
458
|
-
*/
|
|
459
|
-
this.labelHidden = false;
|
|
460
|
-
/**
|
|
461
|
-
* if set, allows capture of media from user camera / microphone
|
|
462
|
-
* The capture attribute value is a string that specifies which camera to use for capture
|
|
463
|
-
* of image or video data, if the accept attribute indicates that the input should be of
|
|
464
|
-
* one of those types. A value of user indicates that the user-facing camera and/or
|
|
465
|
-
* microphone should be used. A value of environment specifies that the outward-facing
|
|
466
|
-
* camera and/or microphone should be used. If this attribute is missing, the user agent
|
|
467
|
-
* is free to decide on its own what to do. If the requested facing mode isn't available,
|
|
468
|
-
* the user agent may fall back to its preferred default mode.
|
|
469
|
-
*/
|
|
470
|
-
this.capture = undefined;
|
|
471
573
|
/**
|
|
472
574
|
* Use maxBytes to specify the maximum size in Bytes of a file that can be uploaded.
|
|
473
575
|
*/
|
|
@@ -499,10 +601,94 @@ let DuetUpload = class {
|
|
|
499
601
|
* by default this is off, setting this to true will limit the users choices to what has been explicitly set
|
|
500
602
|
*/
|
|
501
603
|
this.limitSelection = false;
|
|
604
|
+
//region Private functions
|
|
502
605
|
/**
|
|
503
606
|
* Private functions
|
|
504
607
|
*/
|
|
505
|
-
this.
|
|
608
|
+
this.listenForActionEvents = () => {
|
|
609
|
+
this.element.addEventListener("duetEditableItemAction", (e) => {
|
|
610
|
+
const detail = e.detail;
|
|
611
|
+
const { action, keyName, originalEvent } = detail;
|
|
612
|
+
switch (action) {
|
|
613
|
+
case "delete":
|
|
614
|
+
this.onDelete(keyName, originalEvent);
|
|
615
|
+
break;
|
|
616
|
+
case "cancel":
|
|
617
|
+
this.onCancel(keyName, originalEvent);
|
|
618
|
+
break;
|
|
619
|
+
// code block
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
};
|
|
623
|
+
this.verifyValidity = () => {
|
|
624
|
+
const { invalid, valid } = this.getFilesAsArray();
|
|
625
|
+
const oldValid = this.valid;
|
|
626
|
+
this.valid = invalid.length === 0 && valid.length !== 0;
|
|
627
|
+
if (this.valid !== oldValid) {
|
|
628
|
+
this.duetState.emit({
|
|
629
|
+
originalEvent: undefined,
|
|
630
|
+
data: { valid: this.valid, from: "componentWillRender" },
|
|
631
|
+
component: "duet-upload",
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
this.getGroupFromItemData = (item) => {
|
|
636
|
+
if (item.valid && item.progress === 100) {
|
|
637
|
+
// if the item has a group, move the file to that group instead
|
|
638
|
+
// of into the standard success group
|
|
639
|
+
if (item.group) {
|
|
640
|
+
return item.group;
|
|
641
|
+
}
|
|
642
|
+
return this.DefaultGroups.success;
|
|
643
|
+
}
|
|
644
|
+
else if (item.progress > 0 && item.progress !== 100) {
|
|
645
|
+
return this.DefaultGroups.inprogress;
|
|
646
|
+
}
|
|
647
|
+
else if (!item.valid) {
|
|
648
|
+
return this.DefaultGroups.failure;
|
|
649
|
+
}
|
|
650
|
+
else if (item.group) {
|
|
651
|
+
return item.group;
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
return "none";
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
this.getItemHTMLFromItemData = (data, group) => {
|
|
658
|
+
if (group === this.DefaultGroups.success) {
|
|
659
|
+
return h(SuccessItem, { data: data, showLinks: this.showLinks });
|
|
660
|
+
}
|
|
661
|
+
else if (group === this.DefaultGroups.inprogress) {
|
|
662
|
+
return h(ProgressItem, { progress: data.progress, name: data.item.name });
|
|
663
|
+
}
|
|
664
|
+
else if (group === this.DefaultGroups.failure) {
|
|
665
|
+
return h(ErrorItem, { data: data });
|
|
666
|
+
}
|
|
667
|
+
else if (data.group) {
|
|
668
|
+
return data.html;
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
return "none";
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
this.convertToDuetEditableTableItems = () => {
|
|
675
|
+
// we're always recreating the map - in order to force an update down stream.
|
|
676
|
+
const itemData = new Map();
|
|
677
|
+
//walk the files Map and convert to DuetEditableTableItemData
|
|
678
|
+
this.files.forEach((data, key, _originalMap) => {
|
|
679
|
+
const group = this.getGroupFromItemData(data);
|
|
680
|
+
const item = this.getItemHTMLFromItemData(data, group);
|
|
681
|
+
itemData.set(key, {
|
|
682
|
+
uid: data.uid,
|
|
683
|
+
item,
|
|
684
|
+
group,
|
|
685
|
+
});
|
|
686
|
+
});
|
|
687
|
+
return itemData;
|
|
688
|
+
};
|
|
689
|
+
this.kick = debounce(() => {
|
|
690
|
+
this.tick = Date.now();
|
|
691
|
+
}, 30); // will trigger re-render
|
|
506
692
|
this.genHashName = () => Date.now().toString(36) + Math.random();
|
|
507
693
|
this.updateValueInMap = (item, key, value, kick = true) => {
|
|
508
694
|
const fileItem = this.files.get(item);
|
|
@@ -513,10 +699,14 @@ let DuetUpload = class {
|
|
|
513
699
|
}
|
|
514
700
|
};
|
|
515
701
|
this.updateProgress = (ev, name) => {
|
|
516
|
-
|
|
517
|
-
|
|
702
|
+
console.log(this.filesInProgress.size);
|
|
703
|
+
const updateProgressHelper = percentComplete => {
|
|
518
704
|
this.updateValueInMap(name, "progress", percentComplete);
|
|
519
705
|
this.onProgress(name, percentComplete, ev);
|
|
706
|
+
};
|
|
707
|
+
if (ev.lengthComputable) {
|
|
708
|
+
const percentComplete = (ev.loaded / ev.total) * 100;
|
|
709
|
+
updateProgressHelper(percentComplete);
|
|
520
710
|
}
|
|
521
711
|
else {
|
|
522
712
|
console.log("cant read progress");
|
|
@@ -555,16 +745,17 @@ let DuetUpload = class {
|
|
|
555
745
|
*/
|
|
556
746
|
this.nativeInput.value = "";
|
|
557
747
|
};
|
|
558
|
-
this.
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
748
|
+
this.startUpload = async (ev, metaData = undefined) => {
|
|
749
|
+
await this.setFocus();
|
|
750
|
+
this.metaData = metaData;
|
|
751
|
+
this.nativeInput.click();
|
|
752
|
+
this.onUpload(ev, metaData);
|
|
753
|
+
ev.stopPropagation();
|
|
754
|
+
ev.preventDefault();
|
|
755
|
+
return;
|
|
567
756
|
};
|
|
757
|
+
//endregion
|
|
758
|
+
//region Eventlisteners for the XHR requests
|
|
568
759
|
/**
|
|
569
760
|
* Eventlisteners for the XHR requests
|
|
570
761
|
*/
|
|
@@ -574,6 +765,7 @@ let DuetUpload = class {
|
|
|
574
765
|
};
|
|
575
766
|
this.transferDone = (xhr, name, status) => {
|
|
576
767
|
this.updateValueInMap(name, "status", status, false);
|
|
768
|
+
this.updateValueInMap(name, "uploaded", true, false);
|
|
577
769
|
try {
|
|
578
770
|
const response = JSON.parse(xhr.response);
|
|
579
771
|
this.updateValueInMap(name, "url", response.url);
|
|
@@ -587,12 +779,13 @@ let DuetUpload = class {
|
|
|
587
779
|
this.transferDoneWithFailure = (xhr, name, status) => {
|
|
588
780
|
try {
|
|
589
781
|
const { error } = JSON.parse(xhr.response);
|
|
590
|
-
this.updateValueInMap(name, "error", { message: error.message, type: error.type });
|
|
782
|
+
this.updateValueInMap(name, "error", { message: error.message, type: error.type }, false);
|
|
591
783
|
}
|
|
592
784
|
catch (e) {
|
|
593
785
|
console.error("Server did not respond with expected response error:{message: string, type: int}");
|
|
594
|
-
this.updateValueInMap(name, "error", { type: status });
|
|
786
|
+
this.updateValueInMap(name, "error", { type: status }, false);
|
|
595
787
|
}
|
|
788
|
+
this.updateValueInMap(name, "valid", false, true);
|
|
596
789
|
};
|
|
597
790
|
this.transferFailed = name => {
|
|
598
791
|
this.updateValueInMap(name, "error", getError("duet-upload-001"));
|
|
@@ -623,15 +816,15 @@ let DuetUpload = class {
|
|
|
623
816
|
this.files.delete(key);
|
|
624
817
|
this.validateTotals();
|
|
625
818
|
this.kick();
|
|
626
|
-
if (!this.external) {
|
|
627
|
-
this.makeXHRDeleteRequest(deletedItem);
|
|
628
|
-
}
|
|
629
|
-
this.resetFormFields();
|
|
630
819
|
this.duetDelete.emit({
|
|
631
820
|
originalEvent: ev,
|
|
632
821
|
data: { deletion: deletedItem },
|
|
633
822
|
component: "duet-upload",
|
|
634
823
|
});
|
|
824
|
+
if (!this.external) {
|
|
825
|
+
this.makeXHRDeleteRequest(deletedItem);
|
|
826
|
+
}
|
|
827
|
+
this.resetFormFields();
|
|
635
828
|
};
|
|
636
829
|
this.onCancel = (key, ev) => {
|
|
637
830
|
const cancelledItem = this.files.get(key);
|
|
@@ -650,9 +843,10 @@ let DuetUpload = class {
|
|
|
650
843
|
component: "duet-upload",
|
|
651
844
|
});
|
|
652
845
|
};
|
|
653
|
-
this.onUpload = (ev) => {
|
|
846
|
+
this.onUpload = (ev, metaData) => {
|
|
654
847
|
this.duetUpload.emit({
|
|
655
848
|
originalEvent: ev,
|
|
849
|
+
metaData,
|
|
656
850
|
component: "duet-upload",
|
|
657
851
|
});
|
|
658
852
|
};
|
|
@@ -684,37 +878,26 @@ let DuetUpload = class {
|
|
|
684
878
|
data: { files: this.files },
|
|
685
879
|
});
|
|
686
880
|
};
|
|
687
|
-
this.startUpload = async (ev) => {
|
|
688
|
-
await this.setFocus();
|
|
689
|
-
this.nativeInput.click();
|
|
690
|
-
this.onUpload(ev);
|
|
691
|
-
ev.stopPropagation();
|
|
692
|
-
ev.preventDefault();
|
|
693
|
-
};
|
|
694
881
|
}
|
|
695
882
|
watchValidHandler(newValue, oldValue) {
|
|
696
883
|
if (newValue !== oldValue) {
|
|
697
884
|
this.kick();
|
|
698
885
|
}
|
|
699
886
|
}
|
|
887
|
+
//endregion
|
|
700
888
|
/**
|
|
701
889
|
* Component lifecycle events.
|
|
702
890
|
*/
|
|
703
891
|
componentWillLoad() {
|
|
704
892
|
inheritGlobalTheme(this);
|
|
893
|
+
this.listenForActionEvents();
|
|
705
894
|
}
|
|
706
895
|
componentWillRender() {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
this.valid = invalid.length === 0 && valid.length !== 0;
|
|
710
|
-
if (this.valid !== oldValid) {
|
|
711
|
-
this.duetState.emit({
|
|
712
|
-
originalEvent: undefined,
|
|
713
|
-
data: { valid: this.valid, from: "componentWillRender" },
|
|
714
|
-
component: "duet-upload",
|
|
715
|
-
});
|
|
716
|
-
}
|
|
896
|
+
// listen to the events from the component
|
|
897
|
+
this.verifyValidity();
|
|
717
898
|
}
|
|
899
|
+
//endregion
|
|
900
|
+
//region XHR requests
|
|
718
901
|
/**
|
|
719
902
|
* XHR request utilities
|
|
720
903
|
*/
|
|
@@ -733,23 +916,37 @@ let DuetUpload = class {
|
|
|
733
916
|
xhr.upload.addEventListener("abort", () => {
|
|
734
917
|
this.transferCanceled(name);
|
|
735
918
|
});
|
|
736
|
-
return makeXhrRequest({
|
|
919
|
+
return makeXhrRequest({
|
|
920
|
+
payload: { data, name },
|
|
921
|
+
options: { type: "POST", uri: this.uri, xhr, argument: null, headers: null },
|
|
922
|
+
onFailure: this.transferDoneWithFailure,
|
|
923
|
+
onSuccess: this.transferDone,
|
|
924
|
+
onProgress: this.trackProgress,
|
|
925
|
+
});
|
|
737
926
|
}
|
|
738
927
|
makeXHRDeleteRequest(data) {
|
|
739
928
|
const { uid, item } = data;
|
|
740
929
|
const xhr = new XMLHttpRequest();
|
|
741
930
|
// don't present server issues to user on deletes, just remove them from the visible list
|
|
742
|
-
return makeXhrRequest({
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
931
|
+
return makeXhrRequest({
|
|
932
|
+
payload: { data: null, name },
|
|
933
|
+
options: {
|
|
934
|
+
type: "DELETE",
|
|
935
|
+
xhr,
|
|
936
|
+
uri: this.uri,
|
|
937
|
+
arguments: `?key=${uid}&name=${item.name}`,
|
|
938
|
+
headers: {
|
|
939
|
+
"x-fileuid": uid,
|
|
940
|
+
"x-filename": item.name,
|
|
941
|
+
},
|
|
750
942
|
},
|
|
751
|
-
|
|
943
|
+
onFailure: this.transferDoneWithFailure,
|
|
944
|
+
onSuccess: this.transferDone,
|
|
945
|
+
onProgress: this.trackProgress,
|
|
946
|
+
});
|
|
752
947
|
}
|
|
948
|
+
//endregion
|
|
949
|
+
//region EventHandlers
|
|
753
950
|
/**
|
|
754
951
|
* Component event handling.
|
|
755
952
|
*/
|
|
@@ -758,7 +955,7 @@ let DuetUpload = class {
|
|
|
758
955
|
const selectedFiles = Array.from((_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.files);
|
|
759
956
|
// FileList is a nice array like structure but
|
|
760
957
|
// to ensure uniqueness of files we use a mapping structure and
|
|
761
|
-
// key to the name (makes it easier to delete)
|
|
958
|
+
// key to the name (makes it easier to delete as well)
|
|
762
959
|
if (selectedFiles) {
|
|
763
960
|
for (const item of selectedFiles) {
|
|
764
961
|
const { valid, errorMessage, errorType, errorSystem } = validateFile(item, {
|
|
@@ -771,6 +968,8 @@ let DuetUpload = class {
|
|
|
771
968
|
uid,
|
|
772
969
|
item: item,
|
|
773
970
|
size: item.size,
|
|
971
|
+
meta: this.metaData,
|
|
972
|
+
uploaded: false,
|
|
774
973
|
valid,
|
|
775
974
|
error: {
|
|
776
975
|
type: valid ? undefined : errorType,
|
|
@@ -799,8 +998,14 @@ let DuetUpload = class {
|
|
|
799
998
|
data.append("file", item);
|
|
800
999
|
data.append("uid", uid);
|
|
801
1000
|
data.append("name", item.name);
|
|
802
|
-
data.append("metadata", JSON.stringify({ uid, url: this.uri, size: item.size }));
|
|
803
|
-
|
|
1001
|
+
data.append("metadata", JSON.stringify({ uid, url: this.uri, size: item.size, meta: fileListItem.meta }));
|
|
1002
|
+
try {
|
|
1003
|
+
fileListItem.xhr = await this.makeXHRPostRequest(data);
|
|
1004
|
+
}
|
|
1005
|
+
catch (e) {
|
|
1006
|
+
// in case one of the global maxes have been reached, invalidate the file
|
|
1007
|
+
this.updateValueInMap(item.name, "valid", false, false);
|
|
1008
|
+
}
|
|
804
1009
|
}
|
|
805
1010
|
// kick the stat to force update
|
|
806
1011
|
this.kick();
|
|
@@ -808,12 +1013,15 @@ let DuetUpload = class {
|
|
|
808
1013
|
}
|
|
809
1014
|
// reset the form, so that a user may upload a file again (with the same name)
|
|
810
1015
|
this.resetFormFields();
|
|
1016
|
+
// reset the internal metaData state
|
|
1017
|
+
this.metaData = undefined;
|
|
811
1018
|
this.duetChange.emit({
|
|
812
1019
|
originalEvent: ev,
|
|
813
1020
|
data: { files: this.files },
|
|
814
1021
|
component: "duet-upload",
|
|
815
1022
|
});
|
|
816
1023
|
}
|
|
1024
|
+
//endregion
|
|
817
1025
|
/**
|
|
818
1026
|
* Sets focus on the specified `duet-input`. Use this method instead of the global
|
|
819
1027
|
* `input.focus()`.
|
|
@@ -824,6 +1032,15 @@ let DuetUpload = class {
|
|
|
824
1032
|
}
|
|
825
1033
|
return;
|
|
826
1034
|
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Method for invoking the upload sequence
|
|
1037
|
+
*/
|
|
1038
|
+
async upload(metaData = undefined) {
|
|
1039
|
+
await this.setFocus();
|
|
1040
|
+
this.metaData = metaData;
|
|
1041
|
+
this.nativeInput.click();
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
827
1044
|
/**
|
|
828
1045
|
* Get list of files, divided in errors and valid sections
|
|
829
1046
|
*/
|
|
@@ -833,6 +1050,12 @@ let DuetUpload = class {
|
|
|
833
1050
|
}
|
|
834
1051
|
return this.getFilesAsArray();
|
|
835
1052
|
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Convenience method for updating a of an item in the files attribute
|
|
1055
|
+
*/
|
|
1056
|
+
async updateValue(item, key, value) {
|
|
1057
|
+
this.updateValueInMap(item, key, value);
|
|
1058
|
+
}
|
|
836
1059
|
/**
|
|
837
1060
|
* render() function
|
|
838
1061
|
* Always the last one in the class.
|
|
@@ -842,13 +1065,13 @@ let DuetUpload = class {
|
|
|
842
1065
|
let caption = this.description.replace(/{maxfiles}/g, this.maxFiles.toString());
|
|
843
1066
|
caption = caption.replace(/{maxbytes}/g, `${Math.floor(this.maxBytes / 1024 / 1024)} MB`);
|
|
844
1067
|
caption = caption.replace(/{filetypes}/g, this.allowedExtensions.split(",").join(", "));
|
|
845
|
-
return (h(Host, { class: { "duet-m-0": this.margin === "none" } }, h("duet-fieldset", { label: this.label, caption: caption }, h("slot", { name: "header" }), h("duet-label", { theme: this.theme === "turva" ? "turva" : "default", size: "small", class: {
|
|
1068
|
+
return (h(Host, { class: { "duet-m-0": this.margin === "none" } }, h("duet-fieldset", { label: this.label, caption: caption }, h("slot", { name: "header" }), !this.files.size && (h("duet-label", { theme: this.theme === "turva" ? "turva" : "default", size: "small", class: {
|
|
846
1069
|
"duet-upload-filelist-empty": !this.files.size,
|
|
847
1070
|
"duet-upload-filelist": true,
|
|
848
1071
|
"duet-upload-filelist-filled": this.files.size,
|
|
849
|
-
}, id: this.labelId, for: identifier },
|
|
1072
|
+
}, id: this.labelId, for: identifier }, this.fileListEmpty)), !!this.files.size && h("slot", { name: "fileheader" }), !!this.files.size && (h("duet-upload-aria-status", { invalid: this.getFilesAsArray().invalid.length, valid: this.getFilesAsArray().valid.length, inprogress: this.filesInProgress.size, total: this.files.size, statusMessageLabel: this.statusMessageLabel })), !!this.files.size && (h("duet-editable-table", { "aria-live": "polite", "aria-relevant": "removals", accessibleRole: "log", id: this.editableTableId, groups: this.groups, actions: this.actions, hideGroups: this.hideGroups, items: this.convertToDuetEditableTableItems() })), !!this.files.size && h("slot", { name: "filefooter" }), h("duet-spacer", { size: "large" }), !this.hideButton && (h("duet-button", { id: this.buttonId, onClick: this.startUpload, "accessible-controls": identifier, disabled: this.fileMaxReached, "accessible-label": this.accessibleButtonLabel, "accessible-owns": identifier, size: "small", variation: "secondary", fixed: true, icon: "action-add-circle" }, this.buttonLabel)), h("duet-spacer", { size: "medium" }), (this.fileMaxReached || this.bytesMaxReached) && (h("duet-alert", null, this.fileMaxReached && getI18nError("duet-upload-301"), this.bytesMaxReached && getI18nError("duet-upload-202"))), h("duet-spacer", { size: "medium" }), h("duet-visually-hidden", null, h("input", { ref: input => {
|
|
850
1073
|
this.nativeInput = input;
|
|
851
|
-
}, accept: this.limitSelection ? undefined : `${this.allowedMimetypes},${this.allowedExtensions}`, onBlur: this.onBlur, onFocus: this.onFocus, onChange: e => this.onChange(e), type: "file", class: {
|
|
1074
|
+
}, accept: !this.limitSelection ? undefined : `${this.allowedMimetypes},${this.allowedExtensions}`, onBlur: this.onBlur, onFocus: this.onFocus, onChange: e => this.onChange(e), type: "file", class: {
|
|
852
1075
|
"duet-upload": true,
|
|
853
1076
|
}, disabled: this.disabled, "aria-hidden": "true", required: this.required, name: this.name, id: this.identifier, multiple: this.multiple, capture: "user" })))));
|
|
854
1077
|
}
|