@duetds/components 5.1.4 → 5.1.7
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 +132 -27
- package/lib/cjs/duet-action-button.cjs.entry.js +16 -5
- package/lib/cjs/duet-alert.cjs.entry.js +1 -1
- package/lib/cjs/duet-badge.cjs.entry.js +1 -1
- package/lib/cjs/duet-breadcrumb.cjs.entry.js +1 -1
- package/lib/cjs/duet-breadcrumbs.cjs.entry.js +1 -1
- package/lib/cjs/duet-button_2.cjs.entry.js +2 -2
- package/lib/cjs/duet-caption_4.cjs.entry.js +2 -2
- package/lib/cjs/duet-card.cjs.entry.js +2 -2
- package/lib/cjs/duet-checkbox.cjs.entry.js +1 -1
- package/lib/cjs/duet-choice_2.cjs.entry.js +2 -2
- package/lib/cjs/duet-collapsible.cjs.entry.js +1 -1
- package/lib/cjs/duet-combobox.cjs.entry.js +1 -1
- package/lib/cjs/duet-cookie-consent.cjs.entry.js +1 -1
- package/lib/cjs/duet-date-picker.cjs.entry.js +2 -2
- package/lib/cjs/duet-divider_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-editable-table_3.cjs.entry.js +104 -26
- package/lib/cjs/duet-empty-state.cjs.entry.js +1 -1
- package/lib/cjs/duet-fieldset.cjs.entry.js +1 -1
- package/lib/cjs/duet-footer.cjs.entry.js +1 -1
- package/lib/cjs/duet-grid_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-header_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-hero.cjs.entry.js +1 -1
- package/lib/cjs/duet-icon.cjs.entry.js +2 -2
- package/lib/cjs/duet-input_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-layout.cjs.entry.js +1 -1
- package/lib/cjs/duet-list_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-modal.cjs.entry.js +2 -2
- package/lib/cjs/duet-notification_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-number-input.cjs.entry.js +1 -1
- package/lib/cjs/duet-pagination_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-progress.cjs.entry.js +1 -1
- package/lib/cjs/duet-radio_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-range-slider.cjs.entry.js +1 -1
- package/lib/cjs/duet-scrollable_3.cjs.entry.js +1 -1
- package/lib/cjs/duet-select.cjs.entry.js +1 -1
- package/lib/cjs/duet-step_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-textarea.cjs.entry.js +1 -1
- package/lib/cjs/duet-toggle.cjs.entry.js +1 -1
- package/lib/cjs/duet-tooltip.cjs.entry.js +1 -1
- package/lib/cjs/duet-tray.cjs.entry.js +1 -1
- package/lib/cjs/duet-upload-aria-status.cjs.entry.js +1 -1
- package/lib/cjs/duet-visually-hidden.cjs.entry.js +1 -1
- package/lib/cjs/duet.cjs.js +2 -2
- package/lib/cjs/{focus-utils-9ac6d246.js → focus-utils-dacb5c04.js} +1 -1
- package/lib/cjs/{index-c417c983.js → index-3c28214c.js} +1 -1
- package/lib/cjs/loader.cjs.js +2 -2
- package/lib/cjs/{token-utils-d1f8069b.js → token-utils-50a1f7e2.js} +15 -0
- package/lib/collection/components/duet-action-button/duet-action-button.css +2 -2
- package/lib/collection/components/duet-action-button/duet-action-button.js +14 -2
- package/lib/collection/components/duet-table/duet-table.js +1 -1
- package/lib/collection/components/duet-upload/duet-upload.js +136 -27
- package/lib/collection/components/duet-upload/upload-editable-item-pending.js +7 -0
- package/lib/collection/utils/token-utils.js +14 -0
- package/lib/custom-elements-bundle/index.js +133 -30
- package/lib/duet/duet.esm.js +1 -1
- package/lib/duet/duet.js +1 -1
- package/lib/duet/{p-29b73b1b.system.entry.js → p-007e7fd1.system.entry.js} +1 -1
- package/lib/duet/{p-e2074848.system.js → p-017e5a08.system.js} +1 -1
- package/lib/duet/{p-f8b1afeb.system.entry.js → p-019b0bda.system.entry.js} +1 -1
- package/lib/duet/{p-1e5f2840.entry.js → p-030290f4.entry.js} +1 -1
- package/lib/duet/{p-9c9947a8.entry.js → p-038eebd9.entry.js} +1 -1
- package/lib/duet/{p-f597ccbb.system.entry.js → p-0e0d40ae.system.entry.js} +1 -1
- package/lib/duet/{p-3474c348.entry.js → p-0e22e052.entry.js} +1 -1
- package/lib/duet/{p-a980e270.system.entry.js → p-0f2a1f01.system.entry.js} +1 -1
- package/lib/duet/{p-e6aa9737.entry.js → p-1ab0849a.entry.js} +1 -1
- package/lib/duet/{p-460e6137.system.entry.js → p-1b6e8581.system.entry.js} +1 -1
- package/lib/duet/{p-ec1797d8.entry.js → p-20220d27.entry.js} +1 -1
- package/lib/duet/{p-b8e8a024.entry.js → p-25f6c176.entry.js} +1 -1
- package/lib/duet/{p-f2f17151.system.entry.js → p-26798bd0.system.entry.js} +1 -1
- package/lib/duet/{p-b1039960.system.entry.js → p-2c6cd4a3.system.entry.js} +1 -1
- package/lib/duet/{p-99187a3a.system.js → p-31313016.system.js} +1 -1
- package/lib/duet/p-35820b00.entry.js +4 -0
- package/lib/duet/{p-be6e164e.system.entry.js → p-35c9a248.system.entry.js} +1 -1
- package/lib/duet/{p-553366aa.entry.js → p-3638aa71.entry.js} +1 -1
- package/lib/duet/{p-20c86cc5.system.entry.js → p-377ab392.system.entry.js} +1 -1
- package/lib/duet/{p-2fd66459.entry.js → p-39d463ef.entry.js} +1 -1
- package/lib/duet/{p-37217e63.entry.js → p-3bfe748f.entry.js} +1 -1
- package/lib/duet/{p-0356ed8e.entry.js → p-3c51c1b0.entry.js} +1 -1
- package/lib/duet/{p-47053a5e.entry.js → p-3df27412.entry.js} +1 -1
- package/lib/duet/{p-4d95a973.entry.js → p-3f319ed0.entry.js} +1 -1
- package/lib/duet/{p-18d04f2e.system.entry.js → p-3f3fa7a0.system.entry.js} +1 -1
- package/lib/duet/{p-b78ab2f5.system.js → p-485ace7b.system.js} +1 -1
- package/lib/duet/p-4d2dbe9e.js +4 -0
- package/lib/duet/{p-2e959285.system.entry.js → p-5670d324.system.entry.js} +1 -1
- package/lib/duet/{p-e0e35d41.js → p-5cf3316c.js} +1 -1
- package/lib/duet/{p-0e2e056f.system.entry.js → p-5f0ed156.system.entry.js} +1 -1
- package/lib/duet/p-5fcd9397.system.entry.js +4 -0
- package/lib/duet/{p-4c74be13.system.entry.js → p-60d00e2c.system.entry.js} +1 -1
- package/lib/duet/p-6190e2d6.system.js +4 -0
- package/lib/duet/{p-3956c0b8.system.entry.js → p-63a69534.system.entry.js} +1 -1
- package/lib/duet/{p-78ccd8fa.entry.js → p-6429b742.entry.js} +1 -1
- package/lib/duet/{p-e7f60c95.system.entry.js → p-67f357aa.system.entry.js} +1 -1
- package/lib/duet/{p-71d151e6.entry.js → p-6dcbf41c.entry.js} +1 -1
- package/lib/duet/{p-9bf95a5d.entry.js → p-70ac68bd.entry.js} +1 -1
- package/lib/duet/{p-d4d7c619.entry.js → p-72f1bbf5.entry.js} +1 -1
- package/lib/duet/{p-ec06dc8c.system.entry.js → p-75c4b4b0.system.entry.js} +1 -1
- package/lib/duet/{p-b1375931.entry.js → p-765605cb.entry.js} +1 -1
- package/lib/duet/p-79460e68.system.entry.js +4 -0
- package/lib/duet/{p-78d2dfc8.system.entry.js → p-79626865.system.entry.js} +1 -1
- package/lib/duet/{p-4dace9be.system.entry.js → p-7b11807c.system.entry.js} +1 -1
- package/lib/duet/{p-bd8c5946.entry.js → p-7f39ca93.entry.js} +1 -1
- package/lib/duet/{p-30371492.entry.js → p-7fb73896.entry.js} +1 -1
- package/lib/duet/{p-9ce054f9.system.entry.js → p-7fbd5a6f.system.entry.js} +1 -1
- package/lib/duet/p-861046b1.entry.js +4 -0
- package/lib/duet/{p-445d538d.entry.js → p-8a7d3c68.entry.js} +1 -1
- package/lib/duet/{p-3f4ea241.entry.js → p-8cc88eaf.entry.js} +1 -1
- package/lib/duet/{p-4a1a4d2d.system.entry.js → p-8dcd021f.system.entry.js} +1 -1
- package/lib/duet/{p-f650fa99.entry.js → p-8e520b00.entry.js} +1 -1
- package/lib/duet/{p-2aeb9bd2.system.entry.js → p-8f436ae6.system.entry.js} +1 -1
- package/lib/duet/{p-212f7cf5.entry.js → p-9187e214.entry.js} +1 -1
- package/lib/duet/{p-37a36786.entry.js → p-93bcf12a.entry.js} +1 -1
- package/lib/duet/{p-4df9144d.system.entry.js → p-988f0b81.system.entry.js} +1 -1
- package/lib/duet/{p-8a684ac7.system.entry.js → p-99796362.system.entry.js} +1 -1
- package/lib/duet/p-9cca0bb4.js +4 -0
- package/lib/duet/{p-e6eb55cf.system.entry.js → p-9cd00e15.system.entry.js} +1 -1
- package/lib/duet/{p-4bbd7a9c.entry.js → p-9d275136.entry.js} +1 -1
- package/lib/duet/{p-24f41cb3.system.entry.js → p-9ee12daa.system.entry.js} +1 -1
- package/lib/duet/{p-e8340671.entry.js → p-a2a63b2b.entry.js} +1 -1
- package/lib/duet/{p-9f3c3af5.system.entry.js → p-a37dcf98.system.entry.js} +1 -1
- package/lib/duet/{p-6144a827.system.entry.js → p-a447685e.system.entry.js} +1 -1
- package/lib/duet/{p-b49f89cf.system.entry.js → p-a7ba18b5.system.entry.js} +1 -1
- package/lib/duet/{p-f4943cc5.system.entry.js → p-b10db43a.system.entry.js} +1 -1
- package/lib/duet/{p-b6e0ea1d.entry.js → p-b48329a9.entry.js} +1 -1
- package/lib/duet/{p-ab84084f.entry.js → p-ba583a54.entry.js} +1 -1
- package/lib/duet/{p-472da63a.system.entry.js → p-ba66186c.system.entry.js} +1 -1
- package/lib/duet/{p-89042509.system.entry.js → p-baab37cb.system.entry.js} +1 -1
- package/lib/duet/{p-efeac1a1.entry.js → p-bb544c8e.entry.js} +1 -1
- package/lib/duet/{p-2000ef23.entry.js → p-c54340fd.entry.js} +1 -1
- package/lib/duet/{p-078fcf7c.system.entry.js → p-c6c7b718.system.entry.js} +1 -1
- package/lib/duet/{p-b2dfc5bd.system.entry.js → p-c8e5372d.system.entry.js} +1 -1
- package/lib/duet/{p-7af28ef6.entry.js → p-ce511dc5.entry.js} +1 -1
- package/lib/duet/{p-1862208a.system.entry.js → p-cee7aad6.system.entry.js} +1 -1
- package/lib/duet/p-d44434a8.entry.js +4 -0
- package/lib/duet/{p-87900286.entry.js → p-d9cf279a.entry.js} +1 -1
- package/lib/duet/{p-e15afaf5.system.entry.js → p-dff4f263.system.entry.js} +1 -1
- package/lib/duet/{p-8fa8bdab.system.entry.js → p-e4be787a.system.entry.js} +1 -1
- package/lib/duet/{p-64611b86.entry.js → p-e53e48a8.entry.js} +1 -1
- package/lib/duet/{p-24c8d0df.entry.js → p-e934f859.entry.js} +1 -1
- package/lib/duet/{p-85e8d34e.system.entry.js → p-ebc74446.system.entry.js} +1 -1
- package/lib/duet/{p-ecf2860f.entry.js → p-f230db10.entry.js} +1 -1
- package/lib/duet/{p-9903055f.system.entry.js → p-f4526da3.system.entry.js} +1 -1
- package/lib/duet/{p-bf95adc2.entry.js → p-f4e58e80.entry.js} +1 -1
- package/lib/duet/{p-9d681426.system.entry.js → p-fa551382.system.entry.js} +1 -1
- package/lib/duet/{p-4ae75bd5.entry.js → p-fa7e8f3a.entry.js} +1 -1
- package/lib/duet/{p-b7e592bf.entry.js → p-fe1ea738.entry.js} +1 -1
- package/lib/duet/{p-4cab1ba4.system.entry.js → p-ff8b4019.system.entry.js} +1 -1
- package/lib/duet/{p-6440fa65.entry.js → p-ffd8fc7d.entry.js} +1 -1
- package/lib/esm/duet-action-button.entry.js +16 -5
- package/lib/esm/duet-alert.entry.js +1 -1
- package/lib/esm/duet-badge.entry.js +1 -1
- package/lib/esm/duet-breadcrumb.entry.js +1 -1
- package/lib/esm/duet-breadcrumbs.entry.js +1 -1
- package/lib/esm/duet-button_2.entry.js +2 -2
- package/lib/esm/duet-caption_4.entry.js +2 -2
- package/lib/esm/duet-card.entry.js +2 -2
- package/lib/esm/duet-checkbox.entry.js +1 -1
- package/lib/esm/duet-choice_2.entry.js +2 -2
- package/lib/esm/duet-collapsible.entry.js +1 -1
- package/lib/esm/duet-combobox.entry.js +1 -1
- package/lib/esm/duet-cookie-consent.entry.js +1 -1
- package/lib/esm/duet-date-picker.entry.js +2 -2
- package/lib/esm/duet-divider_2.entry.js +1 -1
- package/lib/esm/duet-editable-table_3.entry.js +104 -26
- package/lib/esm/duet-empty-state.entry.js +1 -1
- package/lib/esm/duet-fieldset.entry.js +1 -1
- package/lib/esm/duet-footer.entry.js +1 -1
- package/lib/esm/duet-grid_2.entry.js +1 -1
- package/lib/esm/duet-header_2.entry.js +1 -1
- package/lib/esm/duet-hero.entry.js +1 -1
- package/lib/esm/duet-icon.entry.js +2 -2
- package/lib/esm/duet-input_2.entry.js +1 -1
- package/lib/esm/duet-layout.entry.js +1 -1
- package/lib/esm/duet-list_2.entry.js +1 -1
- package/lib/esm/duet-modal.entry.js +2 -2
- package/lib/esm/duet-notification_2.entry.js +1 -1
- package/lib/esm/duet-number-input.entry.js +1 -1
- package/lib/esm/duet-pagination_2.entry.js +1 -1
- package/lib/esm/duet-progress.entry.js +1 -1
- package/lib/esm/duet-radio_2.entry.js +1 -1
- package/lib/esm/duet-range-slider.entry.js +1 -1
- package/lib/esm/duet-scrollable_3.entry.js +1 -1
- package/lib/esm/duet-select.entry.js +1 -1
- package/lib/esm/duet-step_2.entry.js +1 -1
- package/lib/esm/duet-textarea.entry.js +1 -1
- package/lib/esm/duet-toggle.entry.js +1 -1
- package/lib/esm/duet-tooltip.entry.js +1 -1
- package/lib/esm/duet-tray.entry.js +1 -1
- package/lib/esm/duet-upload-aria-status.entry.js +1 -1
- package/lib/esm/duet-visually-hidden.entry.js +1 -1
- package/lib/esm/duet.js +2 -2
- package/lib/esm/{focus-utils-bcb5b759.js → focus-utils-00743137.js} +1 -1
- package/lib/esm/{index-7dc1fa94.js → index-ef96b4ca.js} +1 -1
- package/lib/esm/loader.js +2 -2
- package/lib/esm/{token-utils-f3b5f7a8.js → token-utils-1f9435bc.js} +15 -1
- package/lib/esm-es5/duet-action-button.entry.js +1 -1
- 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-breadcrumb.entry.js +1 -1
- package/lib/esm-es5/duet-breadcrumbs.entry.js +1 -1
- package/lib/esm-es5/duet-button_2.entry.js +1 -1
- package/lib/esm-es5/duet-caption_4.entry.js +1 -1
- 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 +1 -1
- package/lib/esm-es5/duet-collapsible.entry.js +1 -1
- package/lib/esm-es5/duet-combobox.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_3.entry.js +1 -1
- package/lib/esm-es5/duet-empty-state.entry.js +1 -1
- package/lib/esm-es5/duet-fieldset.entry.js +1 -1
- package/lib/esm-es5/duet-footer.entry.js +1 -1
- package/lib/esm-es5/duet-grid_2.entry.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/lib/esm-es5/duet-pagination_2.entry.js +1 -1
- package/lib/esm-es5/duet-progress.entry.js +1 -1
- 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-scrollable_3.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-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-aria-status.entry.js +1 -1
- 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-00743137.js +4 -0
- package/lib/esm-es5/{index-7dc1fa94.js → index-ef96b4ca.js} +1 -1
- package/lib/esm-es5/loader.js +1 -1
- package/lib/esm-es5/token-utils-1f9435bc.js +4 -0
- package/lib/html.html-data.json +7 -3
- package/lib/types/components/duet-upload/duet-upload.d.ts +18 -1
- package/lib/types/components/duet-upload/upload-editable-item-pending.d.ts +6 -0
- package/lib/types/components.d.ts +14 -2
- package/lib/types/utils/token-utils.d.ts +1 -0
- package/package.json +5 -5
- package/lib/duet/p-32774c23.system.entry.js +0 -4
- package/lib/duet/p-41e4f10e.entry.js +0 -4
- package/lib/duet/p-50363944.js +0 -4
- package/lib/duet/p-5ff75ab0.entry.js +0 -4
- package/lib/duet/p-7212c87c.entry.js +0 -4
- package/lib/duet/p-81ccf6d6.system.entry.js +0 -4
- package/lib/duet/p-9eaccbf3.system.js +0 -4
- package/lib/duet/p-e918a990.js +0 -4
- package/lib/esm-es5/focus-utils-bcb5b759.js +0 -4
- package/lib/esm-es5/token-utils-f3b5f7a8.js +0 -4
|
@@ -9,6 +9,7 @@ import { inheritGlobalTheme } from "../../utils/themeable-component";
|
|
|
9
9
|
import { getError, getI18nError } from "./errorcodes.utils";
|
|
10
10
|
import { ErrorItem } from "./upload-editable-item-error";
|
|
11
11
|
import { ProgressItem } from "./upload-editable-item-inprogres";
|
|
12
|
+
import { PendingItem } from "./upload-editable-item-pending";
|
|
12
13
|
import { SuccessItem } from "./upload-editable-item-success";
|
|
13
14
|
import { validateFile, validateTotalAmountIsAboveMax, validateTotalSizeIsAboveMax } from "./upload-validators";
|
|
14
15
|
import { makeXhrRequest } from "./xhr.helpers";
|
|
@@ -31,9 +32,13 @@ export class DuetUpload {
|
|
|
31
32
|
* it will be up to you to handle the upload and return progress information to the upload-component
|
|
32
33
|
*/
|
|
33
34
|
this.external = false;
|
|
35
|
+
/**
|
|
36
|
+
* If defer-upload is true, duet-upload will not (as recommended) instantly upload files but await a call to uploadPending()
|
|
37
|
+
*/
|
|
38
|
+
this.deferUpload = false;
|
|
34
39
|
/**
|
|
35
40
|
* If set the upload component will not display an upload button, you will have to create one yourself
|
|
36
|
-
* and call the exposed method startUpload
|
|
41
|
+
* and call the exposed method startUpload to open the upload dialog
|
|
37
42
|
*/
|
|
38
43
|
this.hideButton = false;
|
|
39
44
|
/**
|
|
@@ -46,7 +51,7 @@ export class DuetUpload {
|
|
|
46
51
|
size: "x-small",
|
|
47
52
|
background: "gray-lightest",
|
|
48
53
|
name: "delete",
|
|
49
|
-
map: ["success", "failure"],
|
|
54
|
+
map: ["success", "failure", "pending"],
|
|
50
55
|
label: {
|
|
51
56
|
fi: "Poista tiedosto",
|
|
52
57
|
en: "Poista tiedosto",
|
|
@@ -300,6 +305,7 @@ export class DuetUpload {
|
|
|
300
305
|
this.DefaultGroups = {
|
|
301
306
|
inprogress: "inprogress",
|
|
302
307
|
success: "success",
|
|
308
|
+
pending: "pending",
|
|
303
309
|
failure: "failure",
|
|
304
310
|
};
|
|
305
311
|
/**
|
|
@@ -316,6 +322,14 @@ export class DuetUpload {
|
|
|
316
322
|
en: "Files inprogress",
|
|
317
323
|
},
|
|
318
324
|
},
|
|
325
|
+
{
|
|
326
|
+
id: this.DefaultGroups.pending,
|
|
327
|
+
label: {
|
|
328
|
+
en: "Files to upload",
|
|
329
|
+
sv: "Filer att ladda",
|
|
330
|
+
fi: "Tiedostot ladattavat",
|
|
331
|
+
},
|
|
332
|
+
},
|
|
319
333
|
{
|
|
320
334
|
id: this.DefaultGroups.success,
|
|
321
335
|
label: {
|
|
@@ -343,7 +357,6 @@ export class DuetUpload {
|
|
|
343
357
|
this.element.addEventListener("duetActionEvent", (e) => {
|
|
344
358
|
const detail = e.detail;
|
|
345
359
|
const { action, id, originalEvent } = detail;
|
|
346
|
-
console.log(e);
|
|
347
360
|
switch (action) {
|
|
348
361
|
case "delete":
|
|
349
362
|
this.onDelete(id, originalEvent);
|
|
@@ -372,9 +385,6 @@ export class DuetUpload {
|
|
|
372
385
|
if (item.valid && item.progress === 100) {
|
|
373
386
|
// if the item has a group, move the file to that group instead
|
|
374
387
|
// of into the standard success group
|
|
375
|
-
if (item.group) {
|
|
376
|
-
return item.group;
|
|
377
|
-
}
|
|
378
388
|
return this.DefaultGroups.success;
|
|
379
389
|
}
|
|
380
390
|
else if (item.progress > 0 && item.progress !== 100) {
|
|
@@ -383,6 +393,9 @@ export class DuetUpload {
|
|
|
383
393
|
else if (!item.valid) {
|
|
384
394
|
return this.DefaultGroups.failure;
|
|
385
395
|
}
|
|
396
|
+
else if (item.pending) {
|
|
397
|
+
return this.DefaultGroups.pending;
|
|
398
|
+
}
|
|
386
399
|
else if (item.group) {
|
|
387
400
|
return item.group;
|
|
388
401
|
}
|
|
@@ -397,6 +410,9 @@ export class DuetUpload {
|
|
|
397
410
|
else if (group === this.DefaultGroups.inprogress) {
|
|
398
411
|
return h(ProgressItem, { progress: data.progress, name: data.item.name });
|
|
399
412
|
}
|
|
413
|
+
else if (group === this.DefaultGroups.pending) {
|
|
414
|
+
return h(PendingItem, { name: data.item.name });
|
|
415
|
+
}
|
|
400
416
|
else if (group === this.DefaultGroups.failure) {
|
|
401
417
|
return h(ErrorItem, { data: data });
|
|
402
418
|
}
|
|
@@ -409,9 +425,16 @@ export class DuetUpload {
|
|
|
409
425
|
};
|
|
410
426
|
this.genHashName = () => Date.now().toString(36) + Math.random();
|
|
411
427
|
this.updateValueInMap = (item, key, value, kick = true) => {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
428
|
+
try {
|
|
429
|
+
const fileItem = this.files.get(item);
|
|
430
|
+
fileItem[key] = value;
|
|
431
|
+
this.files.set(item, fileItem);
|
|
432
|
+
}
|
|
433
|
+
catch (e) {
|
|
434
|
+
// if a users tries to update entries on a file that doesn't exist,
|
|
435
|
+
// this will blow up - so we're swallowing the errors here on purpose
|
|
436
|
+
// console.warn("operation on missing items")
|
|
437
|
+
}
|
|
415
438
|
if (kick) {
|
|
416
439
|
this.kick();
|
|
417
440
|
}
|
|
@@ -529,6 +552,46 @@ export class DuetUpload {
|
|
|
529
552
|
fileMaxReached: isTotalFileAmountAboveMax,
|
|
530
553
|
};
|
|
531
554
|
};
|
|
555
|
+
this.uploadFile = async (fileListItem, force = false, key) => {
|
|
556
|
+
if (!force && this.deferUpload) {
|
|
557
|
+
this.updateValueInMap(fileListItem.item.name, "pending", true, false);
|
|
558
|
+
this.updateValueInMap(fileListItem.item.name, "group", "pending", true);
|
|
559
|
+
}
|
|
560
|
+
else if (force) {
|
|
561
|
+
this.updateValueInMap(fileListItem.item.name, "pending", false, false);
|
|
562
|
+
this.updateValueInMap(fileListItem.item.name, "group", undefined, true);
|
|
563
|
+
}
|
|
564
|
+
try {
|
|
565
|
+
if (!this.deferUpload || force) {
|
|
566
|
+
// if all is well AND external file upload handling has not been set, start upload
|
|
567
|
+
const data = new FormData();
|
|
568
|
+
data.append("file", fileListItem.item);
|
|
569
|
+
if (key) {
|
|
570
|
+
data.append("key", key);
|
|
571
|
+
}
|
|
572
|
+
data.append("uid", fileListItem.uid);
|
|
573
|
+
data.append("name", fileListItem.item.name);
|
|
574
|
+
data.append("metadata", JSON.stringify({
|
|
575
|
+
uid: fileListItem.uid,
|
|
576
|
+
url: this.uri,
|
|
577
|
+
size: fileListItem.item.size,
|
|
578
|
+
meta: fileListItem.meta,
|
|
579
|
+
}));
|
|
580
|
+
fileListItem.xhr = await this.makeXHRPostRequest(data);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
catch (e) {
|
|
584
|
+
// in case one of the global maxes have been reached, invalidate the file
|
|
585
|
+
this.updateValueInMap(fileListItem.item.name, "valid", false, false);
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
this.uploadPendingFiles = () => {
|
|
589
|
+
for (const [key, value] of this.files.entries()) {
|
|
590
|
+
if (value.group === "pending" && value.pending === true) {
|
|
591
|
+
this.uploadFile(value, true, key);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
};
|
|
532
595
|
this.getItemFromUID = (uid) => {
|
|
533
596
|
for (const [key, value] of this.files.entries()) {
|
|
534
597
|
if (value.uid === uid) {
|
|
@@ -538,7 +601,8 @@ export class DuetUpload {
|
|
|
538
601
|
return null;
|
|
539
602
|
};
|
|
540
603
|
this.onDelete = (key, ev) => {
|
|
541
|
-
const
|
|
604
|
+
const item = this.getItemFromUID(key);
|
|
605
|
+
const retrievedKey = item.key;
|
|
542
606
|
const deletedItem = this.files.get(retrievedKey);
|
|
543
607
|
this.files.delete(retrievedKey);
|
|
544
608
|
this.validateTotals();
|
|
@@ -548,7 +612,8 @@ export class DuetUpload {
|
|
|
548
612
|
data: { deletion: deletedItem },
|
|
549
613
|
component: "duet-upload",
|
|
550
614
|
});
|
|
551
|
-
if
|
|
615
|
+
// don't send a xhr request if the item was pending, just remove it from the list
|
|
616
|
+
if (!this.external && !deletedItem.pending) {
|
|
552
617
|
this.makeXHRDeleteRequest(deletedItem);
|
|
553
618
|
}
|
|
554
619
|
this.resetFormFields();
|
|
@@ -613,6 +678,7 @@ export class DuetUpload {
|
|
|
613
678
|
const all = [...this.files.values()];
|
|
614
679
|
const inprogress = [];
|
|
615
680
|
const failure = [];
|
|
681
|
+
const pending = [];
|
|
616
682
|
const success = [];
|
|
617
683
|
all.forEach(data => {
|
|
618
684
|
const group = this.getGroupFromItemData(data);
|
|
@@ -631,6 +697,13 @@ export class DuetUpload {
|
|
|
631
697
|
group,
|
|
632
698
|
});
|
|
633
699
|
}
|
|
700
|
+
else if (group === this.DefaultGroups.pending) {
|
|
701
|
+
pending.push({
|
|
702
|
+
uid: data.uid,
|
|
703
|
+
item,
|
|
704
|
+
group,
|
|
705
|
+
});
|
|
706
|
+
}
|
|
634
707
|
else if (group === this.DefaultGroups.failure) {
|
|
635
708
|
failure.push({
|
|
636
709
|
uid: data.uid,
|
|
@@ -648,6 +721,7 @@ export class DuetUpload {
|
|
|
648
721
|
});
|
|
649
722
|
return {
|
|
650
723
|
inprogress,
|
|
724
|
+
pending,
|
|
651
725
|
failure,
|
|
652
726
|
success,
|
|
653
727
|
};
|
|
@@ -729,6 +803,12 @@ export class DuetUpload {
|
|
|
729
803
|
this.nativeInput.click();
|
|
730
804
|
return;
|
|
731
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* Method for uploading pending files
|
|
808
|
+
*/
|
|
809
|
+
async uploadPending() {
|
|
810
|
+
this.uploadPendingFiles();
|
|
811
|
+
}
|
|
732
812
|
/**
|
|
733
813
|
* Method for forcing a render of the upload list, element.files can be changed externally
|
|
734
814
|
* But it will only rerender on a new Map or a top Level change - this can be used to update
|
|
@@ -884,19 +964,14 @@ export class DuetUpload {
|
|
|
884
964
|
this.updateValueInMap(item.name, "valid", false, false);
|
|
885
965
|
}
|
|
886
966
|
else if (valid && !this.external) {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
}
|
|
896
|
-
catch (e) {
|
|
897
|
-
// in case one of the global maxes have been reached, invalidate the file
|
|
898
|
-
this.updateValueInMap(item.name, "valid", false, false);
|
|
899
|
-
}
|
|
967
|
+
await this.uploadFile(fileListItem);
|
|
968
|
+
}
|
|
969
|
+
else if (valid && this.external) {
|
|
970
|
+
this.updateValueInMap(fileListItem.item.name, "pending", true, false);
|
|
971
|
+
this.updateValueInMap(fileListItem.item.name, "group", "pending", true);
|
|
972
|
+
}
|
|
973
|
+
else if (!valid) {
|
|
974
|
+
this.updateValueInMap(item.name, "valid", false, true);
|
|
900
975
|
}
|
|
901
976
|
// kick the stat to force update
|
|
902
977
|
this.kick();
|
|
@@ -1007,6 +1082,24 @@ export class DuetUpload {
|
|
|
1007
1082
|
"reflect": false,
|
|
1008
1083
|
"defaultValue": "false"
|
|
1009
1084
|
},
|
|
1085
|
+
"deferUpload": {
|
|
1086
|
+
"type": "boolean",
|
|
1087
|
+
"mutable": false,
|
|
1088
|
+
"complexType": {
|
|
1089
|
+
"original": "boolean",
|
|
1090
|
+
"resolved": "boolean",
|
|
1091
|
+
"references": {}
|
|
1092
|
+
},
|
|
1093
|
+
"required": false,
|
|
1094
|
+
"optional": false,
|
|
1095
|
+
"docs": {
|
|
1096
|
+
"tags": [],
|
|
1097
|
+
"text": "If defer-upload is true, duet-upload will not (as recommended) instantly upload files but await a call to uploadPending()"
|
|
1098
|
+
},
|
|
1099
|
+
"attribute": "defer-upload",
|
|
1100
|
+
"reflect": false,
|
|
1101
|
+
"defaultValue": "false"
|
|
1102
|
+
},
|
|
1010
1103
|
"hideButton": {
|
|
1011
1104
|
"type": "boolean",
|
|
1012
1105
|
"mutable": false,
|
|
@@ -1019,7 +1112,7 @@ export class DuetUpload {
|
|
|
1019
1112
|
"optional": false,
|
|
1020
1113
|
"docs": {
|
|
1021
1114
|
"tags": [],
|
|
1022
|
-
"text": "If set the upload component will not display an upload button, you will have to create one yourself\nand call the exposed method startUpload"
|
|
1115
|
+
"text": "If set the upload component will not display an upload button, you will have to create one yourself\nand call the exposed method startUpload to open the upload dialog"
|
|
1023
1116
|
},
|
|
1024
1117
|
"attribute": "hide-upload-button",
|
|
1025
1118
|
"reflect": false,
|
|
@@ -1044,7 +1137,7 @@ export class DuetUpload {
|
|
|
1044
1137
|
"tags": [],
|
|
1045
1138
|
"text": "Default actions added to the internally used duet-editable-table"
|
|
1046
1139
|
},
|
|
1047
|
-
"defaultValue": "[\n {\n icon: \"action-delete\",\n color: \"color-danger\",\n size: \"x-small\",\n background: \"gray-lightest\",\n name: \"delete\",\n map: [\"success\", \"failure\"],\n label: {\n fi: \"Poista tiedosto\",\n en: \"Poista tiedosto\",\n sv: \"Ta bort filen\",\n },\n },\n {\n icon: \"navigation-close\",\n color: \"primary\",\n size: \"x-small\",\n background: \"gray-lightest\",\n name: \"cancel\",\n map: [\"inprogress\"],\n label: {\n fi: \"Keskeyt\u00E4 l\u00E4hetys\",\n en: \"Cancel the upload\",\n sv: \"Stop \u00F6verf\u00F6ringen\",\n },\n },\n ]"
|
|
1140
|
+
"defaultValue": "[\n {\n icon: \"action-delete\",\n color: \"color-danger\",\n size: \"x-small\",\n background: \"gray-lightest\",\n name: \"delete\",\n map: [\"success\", \"failure\", \"pending\"],\n label: {\n fi: \"Poista tiedosto\",\n en: \"Poista tiedosto\",\n sv: \"Ta bort filen\",\n },\n },\n {\n icon: \"navigation-close\",\n color: \"primary\",\n size: \"x-small\",\n background: \"gray-lightest\",\n name: \"cancel\",\n map: [\"inprogress\"],\n label: {\n fi: \"Keskeyt\u00E4 l\u00E4hetys\",\n en: \"Cancel the upload\",\n sv: \"Stop \u00F6verf\u00F6ringen\",\n },\n },\n ]"
|
|
1048
1141
|
},
|
|
1049
1142
|
"uri": {
|
|
1050
1143
|
"type": "string",
|
|
@@ -1734,7 +1827,7 @@ export class DuetUpload {
|
|
|
1734
1827
|
}],
|
|
1735
1828
|
"text": "Array of group names that you want the editable table to use to display files"
|
|
1736
1829
|
},
|
|
1737
|
-
"defaultValue": "[\n {\n id: this.DefaultGroups.inprogress,\n label: {\n fi: \"Kesken olevat tiedostot\",\n sv: \"Filer inprogress\",\n en: \"Files inprogress\",\n },\n },\n {\n id: this.DefaultGroups.success,\n label: {\n fi: \"Valmiit tiedostot\",\n sv: \"Files success\",\n en: \"Files success\",\n },\n },\n {\n id: this.DefaultGroups.failure,\n label: {\n fi: \"Tiedostot, joissa on virheit\u00E4\",\n sv: \"Filer med fel\",\n en: \"Files with errors\",\n },\n },\n ]"
|
|
1830
|
+
"defaultValue": "[\n {\n id: this.DefaultGroups.inprogress,\n label: {\n fi: \"Kesken olevat tiedostot\",\n sv: \"Filer inprogress\",\n en: \"Files inprogress\",\n },\n },\n {\n id: this.DefaultGroups.pending,\n label: {\n en: \"Files to upload\",\n sv: \"Filer att ladda\",\n fi: \"Tiedostot ladattavat\",\n },\n },\n {\n id: this.DefaultGroups.success,\n label: {\n fi: \"Valmiit tiedostot\",\n sv: \"Files success\",\n en: \"Files success\",\n },\n },\n {\n id: this.DefaultGroups.failure,\n label: {\n fi: \"Tiedostot, joissa on virheit\u00E4\",\n sv: \"Filer med fel\",\n en: \"Files with errors\",\n },\n },\n ]"
|
|
1738
1831
|
}
|
|
1739
1832
|
}; }
|
|
1740
1833
|
static get states() { return {
|
|
@@ -1954,6 +2047,22 @@ export class DuetUpload {
|
|
|
1954
2047
|
"tags": []
|
|
1955
2048
|
}
|
|
1956
2049
|
},
|
|
2050
|
+
"uploadPending": {
|
|
2051
|
+
"complexType": {
|
|
2052
|
+
"signature": "() => Promise<void>",
|
|
2053
|
+
"parameters": [],
|
|
2054
|
+
"references": {
|
|
2055
|
+
"Promise": {
|
|
2056
|
+
"location": "global"
|
|
2057
|
+
}
|
|
2058
|
+
},
|
|
2059
|
+
"return": "Promise<void>"
|
|
2060
|
+
},
|
|
2061
|
+
"docs": {
|
|
2062
|
+
"text": "Method for uploading pending files",
|
|
2063
|
+
"tags": []
|
|
2064
|
+
}
|
|
2065
|
+
},
|
|
1957
2066
|
"refresh": {
|
|
1958
2067
|
"complexType": {
|
|
1959
2068
|
"signature": "() => Promise<void>",
|
|
@@ -103,3 +103,17 @@ export function getFontSizeByName(name) {
|
|
|
103
103
|
export function getFontWeightByName(name) {
|
|
104
104
|
return getTokenByName("fontWeight", name);
|
|
105
105
|
}
|
|
106
|
+
export function shadeRGBColor(color, percent) {
|
|
107
|
+
const f = color.split(","), t = percent < 0 ? 0 : 255, p = percent < 0 ? percent * -1 : percent;
|
|
108
|
+
let R = parseInt(f[0].slice(4)), G = parseInt(f[1]), B = parseInt(f[2]);
|
|
109
|
+
R = Math.round((t - R) * p) + R;
|
|
110
|
+
G = Math.round((t - G) * p) + G;
|
|
111
|
+
B = Math.round((t - B) * p) + B;
|
|
112
|
+
R = R < 0 ? 0 : R;
|
|
113
|
+
R = R > 255 ? 255 : R;
|
|
114
|
+
G = G < 0 ? 0 : G;
|
|
115
|
+
G = G > 255 ? 255 : G;
|
|
116
|
+
B = B < 0 ? 0 : B;
|
|
117
|
+
B = B > 255 ? 255 : B;
|
|
118
|
+
return `rgb(${R},${G},${B})`;
|
|
119
|
+
}
|