@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
|
@@ -5,183 +5,129 @@
|
|
|
5
5
|
|
|
6
6
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7
7
|
|
|
8
|
-
const index = require('./index-
|
|
8
|
+
const index = require('./index-b724d698.js');
|
|
9
9
|
const createId = require('./create-id-c3b984b1.js');
|
|
10
|
-
const
|
|
10
|
+
const jsUtils = require('./js-utils-33a9dbe3.js');
|
|
11
|
+
const languageUtils = require('./language-utils-aa282901.js');
|
|
11
12
|
const themeableComponent = require('./themeable-component-0c1be552.js');
|
|
13
|
+
require('./string-utils-267e3dbb.js');
|
|
12
14
|
|
|
13
|
-
const
|
|
14
|
-
if (bytes === 0) {
|
|
15
|
-
return "0 Bytes";
|
|
16
|
-
}
|
|
17
|
-
const k = 1024;
|
|
18
|
-
const dm = decimals < 0 ? 0 : decimals;
|
|
19
|
-
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
20
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
21
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const DuetUploadFileList = ({ data, onDelete, onCancel, getError }) => {
|
|
25
|
-
if (data.invalid.length === 0 && data.valid.length === 0) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
return (index.h("ol", { class: "duet-upload-filelist" },
|
|
29
|
-
data.valid.length !== 0 && (index.h("li", null,
|
|
30
|
-
index.h("duet-visually-hidden", null, "Files"),
|
|
31
|
-
index.h("ul", null, data.valid.length !== 0 &&
|
|
32
|
-
data.valid.map(e => (index.h("li", { class: "duet-upload-file" },
|
|
33
|
-
index.h("div", { class: "duet-upload-file-container" },
|
|
34
|
-
index.h("div", { class: "duet-upload-file-link" }, e.url ? (index.h("duet-button", { variation: "plain", icon: "messaging-attachment", url: e.url },
|
|
35
|
-
e.item.name,
|
|
36
|
-
" (",
|
|
37
|
-
formatBytes(e.item.size),
|
|
38
|
-
")")) : (`${e.item.name} (${formatBytes(e.item.size)})`)),
|
|
39
|
-
index.h("ul", { class: "duet-upload-file-actions", role: "menubar", "aria-label": "file actions" },
|
|
40
|
-
e.progress < 100 && (index.h("li", { role: "none" },
|
|
41
|
-
index.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) }))),
|
|
42
|
-
e.progress === 100 && (index.h("li", { role: "none" },
|
|
43
|
-
index.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) }))))),
|
|
44
|
-
e.progress < 100 && (index.h("div", { class: "duet-upload-file-progress" },
|
|
45
|
-
index.h("progress", { value: e.progress, max: "100" },
|
|
46
|
-
index.h("div", { class: "progress-bar" },
|
|
47
|
-
index.h("span", { style: { width: `${e.progress}%;` } },
|
|
48
|
-
"Progress: ",
|
|
49
|
-
e.progress,
|
|
50
|
-
"%"))))))))))),
|
|
51
|
-
data.invalid.length !== 0 && (index.h("li", null,
|
|
52
|
-
index.h("duet-visually-hidden", null, "Files with Errors"),
|
|
53
|
-
index.h("ul", null, data.invalid.map(e => {
|
|
54
|
-
return (index.h("li", { class: "duet-upload-file duet-upload-file-errors" },
|
|
55
|
-
index.h("div", { class: "duet-upload-file-container" },
|
|
56
|
-
index.h("div", { class: "duet-upload-file-link duet-upload-file-link-error" },
|
|
57
|
-
index.h("div", null,
|
|
58
|
-
e.item.name,
|
|
59
|
-
" (",
|
|
60
|
-
formatBytes(e.item.size),
|
|
61
|
-
")"),
|
|
62
|
-
index.h("div", { "data-error-type": e.error.type, "data-error-message": e.error.system_message }, getError(e.error.type))),
|
|
63
|
-
index.h("ul", { class: "duet-upload-file-actions", role: "menubar", "aria-label": "file actions" },
|
|
64
|
-
index.h("li", { role: "none" },
|
|
65
|
-
index.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) }))))));
|
|
66
|
-
}))))));
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const errorcodes = [
|
|
15
|
+
const errorCodes = [
|
|
70
16
|
{
|
|
71
17
|
type: "default",
|
|
72
18
|
system_message: "unknown error",
|
|
73
19
|
message: {
|
|
74
|
-
fi: "",
|
|
75
|
-
sv: "",
|
|
76
|
-
en: "An unknown error occured, please try again"
|
|
20
|
+
fi: "Tapahtui tuntematon virhe, ole hyvä ja yritä uudelleen.",
|
|
21
|
+
sv: "Ett okänt fel uppstod, försök igen.",
|
|
22
|
+
en: "An unknown error occured, please try again."
|
|
77
23
|
}
|
|
78
24
|
},
|
|
79
25
|
{
|
|
80
26
|
type: "400",
|
|
81
27
|
system_message: "Bad Request: The server could not understand the request due to invalid syntax.",
|
|
82
28
|
message: {
|
|
83
|
-
fi: "",
|
|
84
|
-
sv: "",
|
|
85
|
-
en: "The server rejected your file"
|
|
29
|
+
fi: "Tiedostoa ei hyväksytty.",
|
|
30
|
+
sv: "Servern avvisade din fil.",
|
|
31
|
+
en: "The server rejected your file."
|
|
86
32
|
}
|
|
87
33
|
},
|
|
88
34
|
{
|
|
89
35
|
type: "401",
|
|
90
|
-
system_message: "Not Authenticated: The client must authenticate itself to get the requested response
|
|
36
|
+
system_message: "Not Authenticated: The client must authenticate itself to get the requested response...",
|
|
91
37
|
message: {
|
|
92
|
-
fi: "",
|
|
93
|
-
sv: "",
|
|
94
|
-
en: "You need to be logged in to upload files"
|
|
38
|
+
fi: "Vain kirjautunut käyttäjä voi lähettää tiedostoja.",
|
|
39
|
+
sv: "Du måste vara inloggad för att ladda upp filer.",
|
|
40
|
+
en: "You need to be logged in to upload files."
|
|
95
41
|
}
|
|
96
42
|
},
|
|
97
43
|
{
|
|
98
44
|
type: "403",
|
|
99
|
-
system_message: "No Access: The client does not have access rights to the content
|
|
45
|
+
system_message: "No Access: The client does not have access rights to the content.",
|
|
100
46
|
message: {
|
|
101
|
-
fi: "",
|
|
102
|
-
sv: "",
|
|
103
|
-
en: "You do not have the correct access rights to upload files"
|
|
47
|
+
fi: "Ei oikeuksia lähettää tiedostoja.",
|
|
48
|
+
sv: "Du har inte rätt åtkomsträttigheter för att ladda upp filer.",
|
|
49
|
+
en: "You do not have the correct access rights to upload files."
|
|
104
50
|
}
|
|
105
51
|
},
|
|
106
52
|
{
|
|
107
53
|
type: "413",
|
|
108
54
|
system_message: "Payload too large",
|
|
109
55
|
message: {
|
|
110
|
-
fi: "",
|
|
111
|
-
sv: "",
|
|
112
|
-
en: "The file was to large for the server to handle"
|
|
56
|
+
fi: "Tiedosto oli liian vastaanotettavaksi.",
|
|
57
|
+
sv: "Filen var för stor för servern att hantera.",
|
|
58
|
+
en: "The file was to large for the server to handle."
|
|
113
59
|
}
|
|
114
60
|
},
|
|
115
61
|
{
|
|
116
62
|
type: "415",
|
|
117
63
|
system_message: "Unsupported media type",
|
|
118
64
|
message: {
|
|
119
|
-
fi: "",
|
|
120
|
-
sv: "",
|
|
121
|
-
en: "The server rejected the file because it had the wrong type"
|
|
65
|
+
fi: "Tiedoston tyyppi oli väärä.",
|
|
66
|
+
sv: "Servern avvisade filen eftersom den hade fel typ.",
|
|
67
|
+
en: "The server rejected the file because it had the wrong type."
|
|
122
68
|
}
|
|
123
69
|
},
|
|
124
70
|
{
|
|
125
71
|
type: "429",
|
|
126
72
|
system_message: "Too many request from same address",
|
|
127
73
|
message: {
|
|
128
|
-
fi: "",
|
|
129
|
-
sv: "",
|
|
130
|
-
en: "The server has received to many request from you, please try again later"
|
|
74
|
+
fi: "Liian monta yritystä, ole hyvä ja yritä myöhemmin uudelleen.",
|
|
75
|
+
sv: "Servern har fått många förfrågningar från dig, försök igen senare.",
|
|
76
|
+
en: "The server has received to many request from you, please try again later."
|
|
131
77
|
}
|
|
132
78
|
},
|
|
133
79
|
{
|
|
134
80
|
type: "500",
|
|
135
81
|
system_message: "Internal Server Error",
|
|
136
82
|
message: {
|
|
137
|
-
fi: "",
|
|
138
|
-
sv: "",
|
|
139
|
-
en: "The server reported an unknown error and the upload failed"
|
|
83
|
+
fi: "Palvelin ilmoitti tuntemattomasta virheestä ja lataus epäonnistui.",
|
|
84
|
+
sv: "Servern rapporterade ett okänt fel och uppladdningen misslyckades.",
|
|
85
|
+
en: "The server reported an unknown error and the upload failed."
|
|
140
86
|
}
|
|
141
87
|
},
|
|
142
88
|
{
|
|
143
89
|
type: "duet-upload-100",
|
|
144
90
|
system_message: "File extension not allowed",
|
|
145
91
|
message: {
|
|
146
|
-
fi: "",
|
|
147
|
-
sv: "",
|
|
148
|
-
en: "You cannot upload files with that extension"
|
|
92
|
+
fi: "Tiedoston tyyppi ei ole sallittu.",
|
|
93
|
+
sv: "Du kan inte ladda upp filer av den type.",
|
|
94
|
+
en: "You cannot upload files with that extension."
|
|
149
95
|
}
|
|
150
96
|
},
|
|
151
97
|
{
|
|
152
98
|
type: "duet-upload-001",
|
|
153
99
|
system_message: "File transfer failed",
|
|
154
100
|
message: {
|
|
155
|
-
fi: "",
|
|
156
|
-
sv: "",
|
|
157
|
-
en: "Your connection to the server was interrupted, try again"
|
|
101
|
+
fi: "Tiedoston lähetys keskeytyi, ole hyvä ja yritä uudelleen.",
|
|
102
|
+
sv: "Din anslutning till servern avbröts, försök igen.",
|
|
103
|
+
en: "Your connection to the server was interrupted, try again."
|
|
158
104
|
}
|
|
159
105
|
},
|
|
160
106
|
{
|
|
161
107
|
type: "duet-upload-101",
|
|
162
108
|
system_message: "File mimetype not allowed",
|
|
163
109
|
message: {
|
|
164
|
-
fi: "",
|
|
165
|
-
sv: "",
|
|
166
|
-
en: "You cannot upload files of that type"
|
|
110
|
+
fi: "Tiedoston tyyppi ei ole sallittu.",
|
|
111
|
+
sv: "Du kan inte ladda upp filer av den typ.",
|
|
112
|
+
en: "You cannot upload files of that type."
|
|
167
113
|
}
|
|
168
114
|
},
|
|
169
115
|
{
|
|
170
116
|
type: "duet-upload-201",
|
|
171
117
|
system_message: "File is too large",
|
|
172
118
|
message: {
|
|
173
|
-
fi: "",
|
|
174
|
-
sv: "",
|
|
175
|
-
en: "The file is larger than permitted"
|
|
119
|
+
fi: "Tiedosto on liian iso.",
|
|
120
|
+
sv: "Filen är större än tillåtet.",
|
|
121
|
+
en: "The file is larger than permitted."
|
|
176
122
|
}
|
|
177
123
|
},
|
|
178
124
|
{
|
|
179
125
|
type: "duet-upload-202",
|
|
180
126
|
system_message: "The combined size of all files is too large",
|
|
181
127
|
message: {
|
|
182
|
-
fi: "",
|
|
183
|
-
sv: "",
|
|
184
|
-
en: "You have reached the maximum combined filesize"
|
|
128
|
+
fi: "Tiedostojen yhteenlaskettu koko on liian iso.",
|
|
129
|
+
sv: "Du har nått den maximala kombinerade filstorleken.",
|
|
130
|
+
en: "You have reached the maximum combined filesize."
|
|
185
131
|
}
|
|
186
132
|
},
|
|
187
133
|
{
|
|
@@ -189,7 +135,7 @@ const errorcodes = [
|
|
|
189
135
|
system_message: "The maximum file limit has been reached",
|
|
190
136
|
message: {
|
|
191
137
|
fi: "Liitteiden maksimimäärä saavutettu.",
|
|
192
|
-
sv: "",
|
|
138
|
+
sv: "Maximalt antal bilagor har uppnåtts.",
|
|
193
139
|
en: "Maximum number of attachments reached."
|
|
194
140
|
}
|
|
195
141
|
}
|
|
@@ -201,16 +147,81 @@ const getError = (code) => {
|
|
|
201
147
|
system_message: undefined,
|
|
202
148
|
message: undefined,
|
|
203
149
|
};
|
|
204
|
-
error =
|
|
205
|
-
|
|
150
|
+
error = errorCodes.filter(errorItem => {
|
|
151
|
+
// the == is intentional we may be comparing numbers to strings - and that is ok here
|
|
152
|
+
return errorItem.type == code;
|
|
206
153
|
})[0];
|
|
207
154
|
if (!error) {
|
|
208
|
-
error =
|
|
155
|
+
error = errorCodes.filter(errorItem => {
|
|
209
156
|
return errorItem.type === "default";
|
|
210
157
|
})[0];
|
|
211
158
|
}
|
|
212
159
|
return error;
|
|
213
160
|
};
|
|
161
|
+
const getI18nError = (errorCode) => {
|
|
162
|
+
const errorFromJson = getError(errorCode);
|
|
163
|
+
const i18String = languageUtils.getLocaleString(errorFromJson.message);
|
|
164
|
+
if (i18String === "" || !i18String) {
|
|
165
|
+
return errorFromJson.system_message;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return i18String;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const ErrorItem = ({ data }) => {
|
|
173
|
+
const { item, error } = data;
|
|
174
|
+
const { name } = item;
|
|
175
|
+
const { type } = error;
|
|
176
|
+
return (index.h("span", { class: "duet-upload-item-error", role: "status" },
|
|
177
|
+
index.h("duet-paragraph", { class: "duet-upload-item-name", color: "danger", margin: "none", weight: "semi-bold" },
|
|
178
|
+
index.h("duet-icon", { margin: "none", size: "xx-small", name: "messaging-attachment" }),
|
|
179
|
+
" ",
|
|
180
|
+
name),
|
|
181
|
+
index.h("duet-paragraph", { class: "duet-upload-item-error-label", size: "small", margin: "none", color: "danger" }, getI18nError(type))));
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const ProgressItem = ({ progress, name }) => (index.h("span", null,
|
|
185
|
+
index.h("duet-paragraph", { color: "secondary", margin: "none", size: "small" }, name),
|
|
186
|
+
index.h("duet-spacer", { size: "xx-small" }),
|
|
187
|
+
index.h("duet-progress", { progress: Math.ceil(progress), "aria-hidden": true })));
|
|
188
|
+
|
|
189
|
+
const formatBytes = (bytes, decimals = 2) => {
|
|
190
|
+
if (bytes === 0) {
|
|
191
|
+
return "0 Bytes";
|
|
192
|
+
}
|
|
193
|
+
const k = 1024;
|
|
194
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
195
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
196
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
197
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const SuccessItem = ({ data, showLinks }) => {
|
|
201
|
+
const { item, size, uploaded, url, meta } = data;
|
|
202
|
+
const { name } = item;
|
|
203
|
+
const ContentName = (index.h("span", { class: "duet-upload-item-name" },
|
|
204
|
+
index.h("duet-icon", { margin: "none", size: "xx-small", name: "messaging-attachment" }),
|
|
205
|
+
index.h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
|
|
206
|
+
name));
|
|
207
|
+
const SizeText = (index.h("span", { class: "duet-upload-item-size", style: { fontSize: "14px", fontWeight: "400" } },
|
|
208
|
+
"(",
|
|
209
|
+
formatBytes(size),
|
|
210
|
+
")"));
|
|
211
|
+
const FilenameLine = uploaded && url && showLinks ? (index.h("duet-paragraph", { color: "secondary", margin: "none", weight: "semi-bold" },
|
|
212
|
+
index.h("duet-link", { url: url, external: true }, ContentName),
|
|
213
|
+
index.h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
|
|
214
|
+
SizeText)) : (index.h("duet-paragraph", { color: "secondary", margin: "none", weight: "semi-bold" },
|
|
215
|
+
ContentName,
|
|
216
|
+
index.h("duet-spacer", { size: "xx-small", direction: "horizontal" }),
|
|
217
|
+
SizeText));
|
|
218
|
+
const Badges = meta && meta.badges ? (index.h("span", null,
|
|
219
|
+
index.h("duet-spacer", { size: "xx-small" }),
|
|
220
|
+
meta.badges.map(badgeText => (index.h("duet-badge", { color: "primary" }, badgeText))))) : undefined;
|
|
221
|
+
return (index.h("span", { class: "duet-upload-item-success" },
|
|
222
|
+
index.h("div", null, FilenameLine),
|
|
223
|
+
Badges));
|
|
224
|
+
};
|
|
214
225
|
|
|
215
226
|
const validateFileExtension = (name, allowedExtensions) => {
|
|
216
227
|
if (!allowedExtensions) {
|
|
@@ -301,12 +312,8 @@ const validateTotalAmountIsAboveMax = (filelist, maxFiles) => {
|
|
|
301
312
|
return false;
|
|
302
313
|
};
|
|
303
314
|
|
|
304
|
-
const makeXhrRequest = (payload, options, onFailure, onSuccess, onProgress) => {
|
|
305
|
-
const { type, xhr, uri, argument, headers } =
|
|
306
|
-
type: "POST",
|
|
307
|
-
argument: null,
|
|
308
|
-
headers: null,
|
|
309
|
-
}, options);
|
|
315
|
+
const makeXhrRequest = ({ payload, options, onFailure, onSuccess, onProgress }) => {
|
|
316
|
+
const { type = "POST", xhr, uri, argument = null, headers = null } = options;
|
|
310
317
|
xhr.open(type, `${uri}${argument || ""}`, true);
|
|
311
318
|
const { data, name } = payload;
|
|
312
319
|
// headers must be added after open
|
|
@@ -333,7 +340,7 @@ const makeXhrRequest = (payload, options, onFailure, onSuccess, onProgress) => {
|
|
|
333
340
|
return xhr;
|
|
334
341
|
};
|
|
335
342
|
|
|
336
|
-
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}:
|
|
343
|
+
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}";
|
|
337
344
|
|
|
338
345
|
let DuetUpload = class {
|
|
339
346
|
constructor(hostRef) {
|
|
@@ -353,9 +360,19 @@ let DuetUpload = class {
|
|
|
353
360
|
this.buttonId = createId.createID("DuetButton");
|
|
354
361
|
this.labelId = createId.createID("DuetLabel");
|
|
355
362
|
this.uploadId = createId.createID("DuetUpload");
|
|
363
|
+
this.editableTableId = createId.createID("DuetEditableTable");
|
|
356
364
|
this.filesInProgress = new Map();
|
|
357
365
|
this.fileMaxReached = false;
|
|
358
366
|
this.bytesMaxReached = false;
|
|
367
|
+
//region Internally exposed properties
|
|
368
|
+
/**
|
|
369
|
+
* Properties
|
|
370
|
+
*/
|
|
371
|
+
this.DefaultGroups = {
|
|
372
|
+
inprogress: "inprogress",
|
|
373
|
+
success: "success",
|
|
374
|
+
failure: "failure",
|
|
375
|
+
};
|
|
359
376
|
/**
|
|
360
377
|
* State() variables
|
|
361
378
|
*/
|
|
@@ -365,9 +382,91 @@ let DuetUpload = class {
|
|
|
365
382
|
* it will be up to you to handle the upload and return progress information to the upload-component
|
|
366
383
|
*/
|
|
367
384
|
this.external = false;
|
|
385
|
+
/**
|
|
386
|
+
* If set the upload component will not display an upload button, you will have to create on yourself
|
|
387
|
+
* and call the exposed methods startUpload
|
|
388
|
+
*/
|
|
389
|
+
this.hideButton = false;
|
|
390
|
+
/**
|
|
391
|
+
* Default actions added to all files
|
|
392
|
+
*/
|
|
393
|
+
this.actions = [
|
|
394
|
+
{
|
|
395
|
+
icon: "action-delete",
|
|
396
|
+
color: "color-danger",
|
|
397
|
+
color_hover: "category-home",
|
|
398
|
+
id: "delete",
|
|
399
|
+
map: ["success", "failure"],
|
|
400
|
+
label: {
|
|
401
|
+
fi: "Poista tiedosto",
|
|
402
|
+
en: "Poista tiedosto",
|
|
403
|
+
sv: "Ta bort filen",
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
icon: "navigation-close",
|
|
408
|
+
color: "primary",
|
|
409
|
+
color_hover: "category-home",
|
|
410
|
+
id: "cancel",
|
|
411
|
+
map: ["inprogress"],
|
|
412
|
+
label: {
|
|
413
|
+
fi: "Keskeytä lähetys",
|
|
414
|
+
en: "Cancel the upload",
|
|
415
|
+
sv: "Stop överföringen",
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
];
|
|
419
|
+
/**
|
|
420
|
+
* If enabled the filelist will create links on successfully uploaded items,
|
|
421
|
+
* this requires the server can respond with link URIs in the correct format
|
|
422
|
+
*/
|
|
423
|
+
this.showLinks = false;
|
|
424
|
+
/**
|
|
425
|
+
* Property to change the aria upload progress text read aloud by screenreaders
|
|
426
|
+
* @default {
|
|
427
|
+
fi: "Lisää liite",
|
|
428
|
+
sv: "Lägg till en bilaga",
|
|
429
|
+
en: "Choose files",
|
|
430
|
+
}
|
|
431
|
+
*/
|
|
432
|
+
this.statusLabelDefaults = {
|
|
433
|
+
fi: {
|
|
434
|
+
inProgress: "Lähetetään {filesUploaded} lähetettävästä {filesTotal} tiedostosta",
|
|
435
|
+
inProgressWithErrors: "Lähetetään {filesInProgress} tiedostoa, lähetetty {filesUploaded} lähetettävästä {filesTotal} tiedostosta, {filesWithErrors} tiedostossa on virheitä",
|
|
436
|
+
done: "Kaikki {filesTotal} tiedostoa lähetetty onnistuneesti",
|
|
437
|
+
doneWithErrors: "Lähetys valmis, {filesUploaded} tiedostoa on lähetetty onnistuneesti, {filesWithErrors} tiedostossa oli virheitä",
|
|
438
|
+
files: "tiedostot",
|
|
439
|
+
file: "tiedosto",
|
|
440
|
+
},
|
|
441
|
+
sv: {
|
|
442
|
+
inProgress: "Adding {filesUploaded} of {filesTotal}",
|
|
443
|
+
inProgressWithErrors: "Laddar upp {filesInProgress}, {filesUploaded} uppladdad av {filesTotal}, {filesWithErrors} misslyckades",
|
|
444
|
+
done: "Alla {filesTotal} har lagts till",
|
|
445
|
+
doneWithErrors: "Handling slutförd, {filesUploaded} har lagts till, {filesWithErrors} misslyckades",
|
|
446
|
+
files: "filer",
|
|
447
|
+
file: "fil",
|
|
448
|
+
},
|
|
449
|
+
en: {
|
|
450
|
+
inProgress: "Adding {filesUploaded} of {filesTotal}",
|
|
451
|
+
inProgressWithErrors: "Uploading {filesInProgress}, {filesUploaded} uploaded of {filesTotal}, {filesWithErrors} failed",
|
|
452
|
+
done: "All {filesTotal} added successfully",
|
|
453
|
+
doneWithErrors: "Action completed, {filesUploaded} has been added successfully, {filesWithErrors} had errors",
|
|
454
|
+
files: "tiedostoa",
|
|
455
|
+
file: "tiedosto",
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
* Strings used for the status aria-label
|
|
460
|
+
*/
|
|
461
|
+
this.statusMessageLabel = languageUtils.getLocaleString(this.statusLabelDefaults);
|
|
368
462
|
/**
|
|
369
463
|
* Property to change descriptionDefaults defaults on the component.
|
|
370
464
|
* normally you would handle these strings on an application level and override @label when needed
|
|
465
|
+
* @default {
|
|
466
|
+
fi: "Lisää liite",
|
|
467
|
+
sv: "Lägg till en bilaga",
|
|
468
|
+
en: "Add an attachment",
|
|
469
|
+
}
|
|
371
470
|
*/
|
|
372
471
|
this.buttonLabelDefaults = {
|
|
373
472
|
fi: "Lisää liite",
|
|
@@ -403,6 +502,10 @@ let DuetUpload = class {
|
|
|
403
502
|
* browser from displaying its own validation errors.
|
|
404
503
|
*/
|
|
405
504
|
this.required = false;
|
|
505
|
+
/**
|
|
506
|
+
* Visually hides the groups labels in the editable table list used to display the list of files
|
|
507
|
+
*/
|
|
508
|
+
this.hideGroups = false;
|
|
406
509
|
/**
|
|
407
510
|
* Map of string that contain list of uploaded files.
|
|
408
511
|
*/
|
|
@@ -414,6 +517,7 @@ let DuetUpload = class {
|
|
|
414
517
|
/**
|
|
415
518
|
* Property to change labelDefaults defaults on the component.
|
|
416
519
|
* normally you would handle these strings on an application level and override @label when needed
|
|
520
|
+
* @default { fi: "Lisää liite",sv: "Lägg till en bilaga",en: "Add attachments"}
|
|
417
521
|
*/
|
|
418
522
|
this.labelDefaults = {
|
|
419
523
|
fi: "Lisää liite",
|
|
@@ -428,6 +532,11 @@ let DuetUpload = class {
|
|
|
428
532
|
/**
|
|
429
533
|
* Property to change descriptionDefaults defaults on the component.
|
|
430
534
|
* normally you would handle these strings on an application level and override @label when needed
|
|
535
|
+
* @default {
|
|
536
|
+
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.",
|
|
537
|
+
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.",
|
|
538
|
+
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.",
|
|
539
|
+
}
|
|
431
540
|
*/
|
|
432
541
|
this.descriptionDefaults = {
|
|
433
542
|
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.",
|
|
@@ -436,12 +545,20 @@ let DuetUpload = class {
|
|
|
436
545
|
};
|
|
437
546
|
/**
|
|
438
547
|
* Description for the upload component.
|
|
439
|
-
* @default
|
|
548
|
+
* @default {
|
|
549
|
+
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.",
|
|
550
|
+
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.",
|
|
551
|
+
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.",
|
|
552
|
+
}
|
|
440
553
|
*/
|
|
441
554
|
this.description = languageUtils.getLocaleString(this.descriptionDefaults);
|
|
442
555
|
/**
|
|
443
556
|
* Defaults for the filelist's empty state.
|
|
444
|
-
* @default {
|
|
557
|
+
* @default {
|
|
558
|
+
fi: "Ei vielä lisättyjä tiedostoja.",
|
|
559
|
+
sv: "Inga filer har lagts till ännu.",
|
|
560
|
+
en: "No files added yet.",
|
|
561
|
+
}
|
|
445
562
|
*/
|
|
446
563
|
this.fileListEmptyDefaults = {
|
|
447
564
|
fi: "Ei vielä lisättyjä tiedostoja.",
|
|
@@ -457,21 +574,6 @@ let DuetUpload = class {
|
|
|
457
574
|
* Display the input in error state along with an error message.
|
|
458
575
|
*/
|
|
459
576
|
this.error = "";
|
|
460
|
-
/**
|
|
461
|
-
* Visually hide the label, but still show it to screen readers.
|
|
462
|
-
*/
|
|
463
|
-
this.labelHidden = false;
|
|
464
|
-
/**
|
|
465
|
-
* if set, allows capture of media from user camera / microphone
|
|
466
|
-
* The capture attribute value is a string that specifies which camera to use for capture
|
|
467
|
-
* of image or video data, if the accept attribute indicates that the input should be of
|
|
468
|
-
* one of those types. A value of user indicates that the user-facing camera and/or
|
|
469
|
-
* microphone should be used. A value of environment specifies that the outward-facing
|
|
470
|
-
* camera and/or microphone should be used. If this attribute is missing, the user agent
|
|
471
|
-
* is free to decide on its own what to do. If the requested facing mode isn't available,
|
|
472
|
-
* the user agent may fall back to its preferred default mode.
|
|
473
|
-
*/
|
|
474
|
-
this.capture = undefined;
|
|
475
577
|
/**
|
|
476
578
|
* Use maxBytes to specify the maximum size in Bytes of a file that can be uploaded.
|
|
477
579
|
*/
|
|
@@ -503,10 +605,94 @@ let DuetUpload = class {
|
|
|
503
605
|
* by default this is off, setting this to true will limit the users choices to what has been explicitly set
|
|
504
606
|
*/
|
|
505
607
|
this.limitSelection = false;
|
|
608
|
+
//region Private functions
|
|
506
609
|
/**
|
|
507
610
|
* Private functions
|
|
508
611
|
*/
|
|
509
|
-
this.
|
|
612
|
+
this.listenForActionEvents = () => {
|
|
613
|
+
this.element.addEventListener("duetEditableItemAction", (e) => {
|
|
614
|
+
const detail = e.detail;
|
|
615
|
+
const { action, keyName, originalEvent } = detail;
|
|
616
|
+
switch (action) {
|
|
617
|
+
case "delete":
|
|
618
|
+
this.onDelete(keyName, originalEvent);
|
|
619
|
+
break;
|
|
620
|
+
case "cancel":
|
|
621
|
+
this.onCancel(keyName, originalEvent);
|
|
622
|
+
break;
|
|
623
|
+
// code block
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
this.verifyValidity = () => {
|
|
628
|
+
const { invalid, valid } = this.getFilesAsArray();
|
|
629
|
+
const oldValid = this.valid;
|
|
630
|
+
this.valid = invalid.length === 0 && valid.length !== 0;
|
|
631
|
+
if (this.valid !== oldValid) {
|
|
632
|
+
this.duetState.emit({
|
|
633
|
+
originalEvent: undefined,
|
|
634
|
+
data: { valid: this.valid, from: "componentWillRender" },
|
|
635
|
+
component: "duet-upload",
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
this.getGroupFromItemData = (item) => {
|
|
640
|
+
if (item.valid && item.progress === 100) {
|
|
641
|
+
// if the item has a group, move the file to that group instead
|
|
642
|
+
// of into the standard success group
|
|
643
|
+
if (item.group) {
|
|
644
|
+
return item.group;
|
|
645
|
+
}
|
|
646
|
+
return this.DefaultGroups.success;
|
|
647
|
+
}
|
|
648
|
+
else if (item.progress > 0 && item.progress !== 100) {
|
|
649
|
+
return this.DefaultGroups.inprogress;
|
|
650
|
+
}
|
|
651
|
+
else if (!item.valid) {
|
|
652
|
+
return this.DefaultGroups.failure;
|
|
653
|
+
}
|
|
654
|
+
else if (item.group) {
|
|
655
|
+
return item.group;
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
return "none";
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
this.getItemHTMLFromItemData = (data, group) => {
|
|
662
|
+
if (group === this.DefaultGroups.success) {
|
|
663
|
+
return index.h(SuccessItem, { data: data, showLinks: this.showLinks });
|
|
664
|
+
}
|
|
665
|
+
else if (group === this.DefaultGroups.inprogress) {
|
|
666
|
+
return index.h(ProgressItem, { progress: data.progress, name: data.item.name });
|
|
667
|
+
}
|
|
668
|
+
else if (group === this.DefaultGroups.failure) {
|
|
669
|
+
return index.h(ErrorItem, { data: data });
|
|
670
|
+
}
|
|
671
|
+
else if (data.group) {
|
|
672
|
+
return data.html;
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
return "none";
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
this.convertToDuetEditableTableItems = () => {
|
|
679
|
+
// we're always recreating the map - in order to force an update down stream.
|
|
680
|
+
const itemData = new Map();
|
|
681
|
+
//walk the files Map and convert to DuetEditableTableItemData
|
|
682
|
+
this.files.forEach((data, key, _originalMap) => {
|
|
683
|
+
const group = this.getGroupFromItemData(data);
|
|
684
|
+
const item = this.getItemHTMLFromItemData(data, group);
|
|
685
|
+
itemData.set(key, {
|
|
686
|
+
uid: data.uid,
|
|
687
|
+
item,
|
|
688
|
+
group,
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
return itemData;
|
|
692
|
+
};
|
|
693
|
+
this.kick = jsUtils.debounce(() => {
|
|
694
|
+
this.tick = Date.now();
|
|
695
|
+
}, 30); // will trigger re-render
|
|
510
696
|
this.genHashName = () => Date.now().toString(36) + Math.random();
|
|
511
697
|
this.updateValueInMap = (item, key, value, kick = true) => {
|
|
512
698
|
const fileItem = this.files.get(item);
|
|
@@ -517,10 +703,14 @@ let DuetUpload = class {
|
|
|
517
703
|
}
|
|
518
704
|
};
|
|
519
705
|
this.updateProgress = (ev, name) => {
|
|
520
|
-
|
|
521
|
-
|
|
706
|
+
console.log(this.filesInProgress.size);
|
|
707
|
+
const updateProgressHelper = percentComplete => {
|
|
522
708
|
this.updateValueInMap(name, "progress", percentComplete);
|
|
523
709
|
this.onProgress(name, percentComplete, ev);
|
|
710
|
+
};
|
|
711
|
+
if (ev.lengthComputable) {
|
|
712
|
+
const percentComplete = (ev.loaded / ev.total) * 100;
|
|
713
|
+
updateProgressHelper(percentComplete);
|
|
524
714
|
}
|
|
525
715
|
else {
|
|
526
716
|
console.log("cant read progress");
|
|
@@ -559,16 +749,17 @@ let DuetUpload = class {
|
|
|
559
749
|
*/
|
|
560
750
|
this.nativeInput.value = "";
|
|
561
751
|
};
|
|
562
|
-
this.
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}
|
|
752
|
+
this.startUpload = async (ev, metaData = undefined) => {
|
|
753
|
+
await this.setFocus();
|
|
754
|
+
this.metaData = metaData;
|
|
755
|
+
this.nativeInput.click();
|
|
756
|
+
this.onUpload(ev, metaData);
|
|
757
|
+
ev.stopPropagation();
|
|
758
|
+
ev.preventDefault();
|
|
759
|
+
return;
|
|
571
760
|
};
|
|
761
|
+
//endregion
|
|
762
|
+
//region Eventlisteners for the XHR requests
|
|
572
763
|
/**
|
|
573
764
|
* Eventlisteners for the XHR requests
|
|
574
765
|
*/
|
|
@@ -578,6 +769,7 @@ let DuetUpload = class {
|
|
|
578
769
|
};
|
|
579
770
|
this.transferDone = (xhr, name, status) => {
|
|
580
771
|
this.updateValueInMap(name, "status", status, false);
|
|
772
|
+
this.updateValueInMap(name, "uploaded", true, false);
|
|
581
773
|
try {
|
|
582
774
|
const response = JSON.parse(xhr.response);
|
|
583
775
|
this.updateValueInMap(name, "url", response.url);
|
|
@@ -591,12 +783,13 @@ let DuetUpload = class {
|
|
|
591
783
|
this.transferDoneWithFailure = (xhr, name, status) => {
|
|
592
784
|
try {
|
|
593
785
|
const { error } = JSON.parse(xhr.response);
|
|
594
|
-
this.updateValueInMap(name, "error", { message: error.message, type: error.type });
|
|
786
|
+
this.updateValueInMap(name, "error", { message: error.message, type: error.type }, false);
|
|
595
787
|
}
|
|
596
788
|
catch (e) {
|
|
597
789
|
console.error("Server did not respond with expected response error:{message: string, type: int}");
|
|
598
|
-
this.updateValueInMap(name, "error", { type: status });
|
|
790
|
+
this.updateValueInMap(name, "error", { type: status }, false);
|
|
599
791
|
}
|
|
792
|
+
this.updateValueInMap(name, "valid", false, true);
|
|
600
793
|
};
|
|
601
794
|
this.transferFailed = name => {
|
|
602
795
|
this.updateValueInMap(name, "error", getError("duet-upload-001"));
|
|
@@ -627,15 +820,15 @@ let DuetUpload = class {
|
|
|
627
820
|
this.files.delete(key);
|
|
628
821
|
this.validateTotals();
|
|
629
822
|
this.kick();
|
|
630
|
-
if (!this.external) {
|
|
631
|
-
this.makeXHRDeleteRequest(deletedItem);
|
|
632
|
-
}
|
|
633
|
-
this.resetFormFields();
|
|
634
823
|
this.duetDelete.emit({
|
|
635
824
|
originalEvent: ev,
|
|
636
825
|
data: { deletion: deletedItem },
|
|
637
826
|
component: "duet-upload",
|
|
638
827
|
});
|
|
828
|
+
if (!this.external) {
|
|
829
|
+
this.makeXHRDeleteRequest(deletedItem);
|
|
830
|
+
}
|
|
831
|
+
this.resetFormFields();
|
|
639
832
|
};
|
|
640
833
|
this.onCancel = (key, ev) => {
|
|
641
834
|
const cancelledItem = this.files.get(key);
|
|
@@ -654,9 +847,10 @@ let DuetUpload = class {
|
|
|
654
847
|
component: "duet-upload",
|
|
655
848
|
});
|
|
656
849
|
};
|
|
657
|
-
this.onUpload = (ev) => {
|
|
850
|
+
this.onUpload = (ev, metaData) => {
|
|
658
851
|
this.duetUpload.emit({
|
|
659
852
|
originalEvent: ev,
|
|
853
|
+
metaData,
|
|
660
854
|
component: "duet-upload",
|
|
661
855
|
});
|
|
662
856
|
};
|
|
@@ -688,37 +882,26 @@ let DuetUpload = class {
|
|
|
688
882
|
data: { files: this.files },
|
|
689
883
|
});
|
|
690
884
|
};
|
|
691
|
-
this.startUpload = async (ev) => {
|
|
692
|
-
await this.setFocus();
|
|
693
|
-
this.nativeInput.click();
|
|
694
|
-
this.onUpload(ev);
|
|
695
|
-
ev.stopPropagation();
|
|
696
|
-
ev.preventDefault();
|
|
697
|
-
};
|
|
698
885
|
}
|
|
699
886
|
watchValidHandler(newValue, oldValue) {
|
|
700
887
|
if (newValue !== oldValue) {
|
|
701
888
|
this.kick();
|
|
702
889
|
}
|
|
703
890
|
}
|
|
891
|
+
//endregion
|
|
704
892
|
/**
|
|
705
893
|
* Component lifecycle events.
|
|
706
894
|
*/
|
|
707
895
|
componentWillLoad() {
|
|
708
896
|
themeableComponent.inheritGlobalTheme(this);
|
|
897
|
+
this.listenForActionEvents();
|
|
709
898
|
}
|
|
710
899
|
componentWillRender() {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
this.valid = invalid.length === 0 && valid.length !== 0;
|
|
714
|
-
if (this.valid !== oldValid) {
|
|
715
|
-
this.duetState.emit({
|
|
716
|
-
originalEvent: undefined,
|
|
717
|
-
data: { valid: this.valid, from: "componentWillRender" },
|
|
718
|
-
component: "duet-upload",
|
|
719
|
-
});
|
|
720
|
-
}
|
|
900
|
+
// listen to the events from the component
|
|
901
|
+
this.verifyValidity();
|
|
721
902
|
}
|
|
903
|
+
//endregion
|
|
904
|
+
//region XHR requests
|
|
722
905
|
/**
|
|
723
906
|
* XHR request utilities
|
|
724
907
|
*/
|
|
@@ -737,23 +920,37 @@ let DuetUpload = class {
|
|
|
737
920
|
xhr.upload.addEventListener("abort", () => {
|
|
738
921
|
this.transferCanceled(name);
|
|
739
922
|
});
|
|
740
|
-
return makeXhrRequest({
|
|
923
|
+
return makeXhrRequest({
|
|
924
|
+
payload: { data, name },
|
|
925
|
+
options: { type: "POST", uri: this.uri, xhr, argument: null, headers: null },
|
|
926
|
+
onFailure: this.transferDoneWithFailure,
|
|
927
|
+
onSuccess: this.transferDone,
|
|
928
|
+
onProgress: this.trackProgress,
|
|
929
|
+
});
|
|
741
930
|
}
|
|
742
931
|
makeXHRDeleteRequest(data) {
|
|
743
932
|
const { uid, item } = data;
|
|
744
933
|
const xhr = new XMLHttpRequest();
|
|
745
934
|
// don't present server issues to user on deletes, just remove them from the visible list
|
|
746
|
-
return makeXhrRequest({
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
935
|
+
return makeXhrRequest({
|
|
936
|
+
payload: { data: null, name },
|
|
937
|
+
options: {
|
|
938
|
+
type: "DELETE",
|
|
939
|
+
xhr,
|
|
940
|
+
uri: this.uri,
|
|
941
|
+
arguments: `?key=${uid}&name=${item.name}`,
|
|
942
|
+
headers: {
|
|
943
|
+
"x-fileuid": uid,
|
|
944
|
+
"x-filename": item.name,
|
|
945
|
+
},
|
|
754
946
|
},
|
|
755
|
-
|
|
947
|
+
onFailure: this.transferDoneWithFailure,
|
|
948
|
+
onSuccess: this.transferDone,
|
|
949
|
+
onProgress: this.trackProgress,
|
|
950
|
+
});
|
|
756
951
|
}
|
|
952
|
+
//endregion
|
|
953
|
+
//region EventHandlers
|
|
757
954
|
/**
|
|
758
955
|
* Component event handling.
|
|
759
956
|
*/
|
|
@@ -762,7 +959,7 @@ let DuetUpload = class {
|
|
|
762
959
|
const selectedFiles = Array.from((_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.files);
|
|
763
960
|
// FileList is a nice array like structure but
|
|
764
961
|
// to ensure uniqueness of files we use a mapping structure and
|
|
765
|
-
// key to the name (makes it easier to delete)
|
|
962
|
+
// key to the name (makes it easier to delete as well)
|
|
766
963
|
if (selectedFiles) {
|
|
767
964
|
for (const item of selectedFiles) {
|
|
768
965
|
const { valid, errorMessage, errorType, errorSystem } = validateFile(item, {
|
|
@@ -775,6 +972,8 @@ let DuetUpload = class {
|
|
|
775
972
|
uid,
|
|
776
973
|
item: item,
|
|
777
974
|
size: item.size,
|
|
975
|
+
meta: this.metaData,
|
|
976
|
+
uploaded: false,
|
|
778
977
|
valid,
|
|
779
978
|
error: {
|
|
780
979
|
type: valid ? undefined : errorType,
|
|
@@ -803,8 +1002,14 @@ let DuetUpload = class {
|
|
|
803
1002
|
data.append("file", item);
|
|
804
1003
|
data.append("uid", uid);
|
|
805
1004
|
data.append("name", item.name);
|
|
806
|
-
data.append("metadata", JSON.stringify({ uid, url: this.uri, size: item.size }));
|
|
807
|
-
|
|
1005
|
+
data.append("metadata", JSON.stringify({ uid, url: this.uri, size: item.size, meta: fileListItem.meta }));
|
|
1006
|
+
try {
|
|
1007
|
+
fileListItem.xhr = await this.makeXHRPostRequest(data);
|
|
1008
|
+
}
|
|
1009
|
+
catch (e) {
|
|
1010
|
+
// in case one of the global maxes have been reached, invalidate the file
|
|
1011
|
+
this.updateValueInMap(item.name, "valid", false, false);
|
|
1012
|
+
}
|
|
808
1013
|
}
|
|
809
1014
|
// kick the stat to force update
|
|
810
1015
|
this.kick();
|
|
@@ -812,12 +1017,15 @@ let DuetUpload = class {
|
|
|
812
1017
|
}
|
|
813
1018
|
// reset the form, so that a user may upload a file again (with the same name)
|
|
814
1019
|
this.resetFormFields();
|
|
1020
|
+
// reset the internal metaData state
|
|
1021
|
+
this.metaData = undefined;
|
|
815
1022
|
this.duetChange.emit({
|
|
816
1023
|
originalEvent: ev,
|
|
817
1024
|
data: { files: this.files },
|
|
818
1025
|
component: "duet-upload",
|
|
819
1026
|
});
|
|
820
1027
|
}
|
|
1028
|
+
//endregion
|
|
821
1029
|
/**
|
|
822
1030
|
* Sets focus on the specified `duet-input`. Use this method instead of the global
|
|
823
1031
|
* `input.focus()`.
|
|
@@ -828,6 +1036,15 @@ let DuetUpload = class {
|
|
|
828
1036
|
}
|
|
829
1037
|
return;
|
|
830
1038
|
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Method for invoking the upload sequence
|
|
1041
|
+
*/
|
|
1042
|
+
async upload(metaData = undefined) {
|
|
1043
|
+
await this.setFocus();
|
|
1044
|
+
this.metaData = metaData;
|
|
1045
|
+
this.nativeInput.click();
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
831
1048
|
/**
|
|
832
1049
|
* Get list of files, divided in errors and valid sections
|
|
833
1050
|
*/
|
|
@@ -837,6 +1054,12 @@ let DuetUpload = class {
|
|
|
837
1054
|
}
|
|
838
1055
|
return this.getFilesAsArray();
|
|
839
1056
|
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Convenience method for updating a of an item in the files attribute
|
|
1059
|
+
*/
|
|
1060
|
+
async updateValue(item, key, value) {
|
|
1061
|
+
this.updateValueInMap(item, key, value);
|
|
1062
|
+
}
|
|
840
1063
|
/**
|
|
841
1064
|
* render() function
|
|
842
1065
|
* Always the last one in the class.
|
|
@@ -846,13 +1069,13 @@ let DuetUpload = class {
|
|
|
846
1069
|
let caption = this.description.replace(/{maxfiles}/g, this.maxFiles.toString());
|
|
847
1070
|
caption = caption.replace(/{maxbytes}/g, `${Math.floor(this.maxBytes / 1024 / 1024)} MB`);
|
|
848
1071
|
caption = caption.replace(/{filetypes}/g, this.allowedExtensions.split(",").join(", "));
|
|
849
|
-
return (index.h(index.Host, { class: { "duet-m-0": this.margin === "none" } }, index.h("duet-fieldset", { label: this.label, caption: caption }, index.h("slot", { name: "header" }), index.h("duet-label", { theme: this.theme === "turva" ? "turva" : "default", size: "small", class: {
|
|
1072
|
+
return (index.h(index.Host, { class: { "duet-m-0": this.margin === "none" } }, index.h("duet-fieldset", { label: this.label, caption: caption }, index.h("slot", { name: "header" }), !this.files.size && (index.h("duet-label", { theme: this.theme === "turva" ? "turva" : "default", size: "small", class: {
|
|
850
1073
|
"duet-upload-filelist-empty": !this.files.size,
|
|
851
1074
|
"duet-upload-filelist": true,
|
|
852
1075
|
"duet-upload-filelist-filled": this.files.size,
|
|
853
|
-
}, id: this.labelId, for: identifier },
|
|
1076
|
+
}, id: this.labelId, for: identifier }, this.fileListEmpty)), !!this.files.size && index.h("slot", { name: "fileheader" }), !!this.files.size && (index.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 && (index.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 && index.h("slot", { name: "filefooter" }), index.h("duet-spacer", { size: "large" }), !this.hideButton && (index.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)), index.h("duet-spacer", { size: "medium" }), (this.fileMaxReached || this.bytesMaxReached) && (index.h("duet-alert", null, this.fileMaxReached && getI18nError("duet-upload-301"), this.bytesMaxReached && getI18nError("duet-upload-202"))), index.h("duet-spacer", { size: "medium" }), index.h("duet-visually-hidden", null, index.h("input", { ref: input => {
|
|
854
1077
|
this.nativeInput = input;
|
|
855
|
-
}, accept: this.limitSelection ? undefined : `${this.allowedMimetypes},${this.allowedExtensions}`, onBlur: this.onBlur, onFocus: this.onFocus, onChange: e => this.onChange(e), type: "file", class: {
|
|
1078
|
+
}, accept: !this.limitSelection ? undefined : `${this.allowedMimetypes},${this.allowedExtensions}`, onBlur: this.onBlur, onFocus: this.onFocus, onChange: e => this.onChange(e), type: "file", class: {
|
|
856
1079
|
"duet-upload": true,
|
|
857
1080
|
}, disabled: this.disabled, "aria-hidden": "true", required: this.required, name: this.name, id: this.identifier, multiple: this.multiple, capture: "user" })))));
|
|
858
1081
|
}
|