@duetds/components 4.33.0 → 4.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hydrate/index.js +82 -40
- package/lib/cjs/duet-alert.cjs.entry.js +1 -1
- package/lib/cjs/duet-badge.cjs.entry.js +1 -1
- package/lib/cjs/duet-button_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-caption_4.cjs.entry.js +1 -1
- package/lib/cjs/duet-card.cjs.entry.js +1 -1
- package/lib/cjs/duet-checkbox.cjs.entry.js +1 -1
- package/lib/cjs/duet-choice_2.cjs.entry.js +2 -3
- package/lib/cjs/duet-collapsible.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-button.cjs.entry.js +89 -0
- package/lib/cjs/{duet-upload.cjs.entry.js → duet-editable-table_4.cjs.entry.js} +386 -30
- package/lib/cjs/duet-empty-state.cjs.entry.js +1 -1
- package/lib/cjs/duet-fieldset.cjs.entry.js +62 -0
- 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 +16 -6
- 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-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-select.cjs.entry.js +1 -1
- package/lib/cjs/duet-step_2.cjs.entry.js +1 -1
- package/lib/cjs/duet-tab_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 +100 -0
- package/lib/cjs/duet-visually-hidden.cjs.entry.js +1 -1
- package/lib/cjs/duet.cjs.js +2 -2
- package/lib/cjs/{focus-utils-a7a1fb8b.js → focus-utils-b609a7a5.js} +1 -1
- package/lib/cjs/{index-b724d698.js → index-9a57d969.js} +8 -1
- package/lib/cjs/loader.cjs.js +2 -2
- package/lib/collection/collection-manifest.json +9 -8
- package/lib/collection/components/duet-choice/duet-choice.js +0 -1
- package/lib/collection/components/duet-icon/icon-utils.js +15 -5
- package/lib/collection/components/duet-upload/duet-upload.js +72 -47
- package/lib/collection/components/duet-upload/{duet-upload-editable-item-error.js → upload-editable-item-error.js} +0 -0
- package/lib/collection/components/duet-upload/{duet-upload-editable-item-inprogres.js → upload-editable-item-inprogres.js} +0 -0
- package/lib/collection/components/duet-upload/{duet-upload-editable-item-success.js → upload-editable-item-success.js} +0 -0
- package/lib/collection/components/duet-upload/{duet-upload-validators.js → upload-validators.js} +0 -0
- package/lib/collection/components/{duet-upload → duet-upload-aria-status}/duet-upload-aria-status.js +3 -3
- package/lib/custom-elements-bundle/index.js +75 -36
- package/lib/duet/duet.esm.js +1 -1
- package/lib/duet/duet.js +1 -1
- package/lib/duet/{p-a207b008.entry.js → p-00210a63.entry.js} +1 -1
- package/lib/duet/{p-8cb7416d.entry.js → p-0205162d.entry.js} +1 -1
- package/lib/duet/{p-d744d188.system.entry.js → p-020a2c42.system.entry.js} +1 -1
- package/lib/duet/{p-c36b4da0.entry.js → p-079795e5.entry.js} +1 -1
- package/lib/duet/{p-6e6e76db.system.entry.js → p-09013a48.system.entry.js} +1 -1
- package/lib/duet/p-0a89315d.entry.js +4 -0
- package/lib/duet/{p-6cc3be76.system.entry.js → p-0e90f075.system.entry.js} +1 -1
- package/lib/duet/{p-8f826843.system.entry.js → p-19d7d9d5.system.entry.js} +1 -1
- package/lib/duet/{p-c2e77278.entry.js → p-1cbc6269.entry.js} +1 -1
- package/lib/duet/{p-a5b9c192.system.entry.js → p-2297d13f.system.entry.js} +1 -1
- package/lib/duet/{p-263bc9cd.system.entry.js → p-2a822e91.system.entry.js} +1 -1
- package/lib/duet/{p-2bb1460c.entry.js → p-2fdcff82.entry.js} +1 -1
- package/lib/duet/{p-67d9a9a9.system.entry.js → p-3013c9bb.system.entry.js} +1 -1
- package/lib/duet/{p-c34329f3.entry.js → p-3212a556.entry.js} +1 -1
- package/lib/duet/{p-b32224fe.system.entry.js → p-323643af.system.entry.js} +1 -1
- package/lib/duet/{p-a9859a82.entry.js → p-32b7397d.entry.js} +1 -1
- package/lib/duet/{p-6a19b5ec.entry.js → p-360086f8.entry.js} +1 -1
- package/lib/duet/{p-bf93a991.entry.js → p-37cda933.entry.js} +1 -1
- package/lib/duet/{p-af41d894.system.entry.js → p-3ba62cf1.system.entry.js} +1 -1
- package/lib/duet/{p-4a87e9ab.system.entry.js → p-3fd9190b.system.entry.js} +1 -1
- package/lib/duet/{p-acc57c77.entry.js → p-43847557.entry.js} +1 -1
- package/lib/duet/{p-374fb7e6.system.entry.js → p-4b6e8558.system.entry.js} +1 -1
- package/lib/duet/p-4c5eedf8.entry.js +4 -0
- package/lib/duet/{p-a6a84ec6.entry.js → p-4c827f0d.entry.js} +1 -1
- package/lib/duet/{p-b42d81c3.system.js → p-51955fc0.system.js} +1 -1
- package/lib/duet/{p-e964d062.entry.js → p-5cfc53f9.entry.js} +1 -1
- package/lib/duet/{p-2443bdca.system.entry.js → p-5decc259.system.entry.js} +1 -1
- package/lib/duet/{p-548d484e.js → p-5e0071d6.js} +1 -1
- package/lib/duet/p-5e77432e.system.entry.js +4 -0
- package/lib/duet/{p-58750bae.system.entry.js → p-6024e484.system.entry.js} +1 -1
- package/lib/duet/{p-9d73343a.entry.js → p-68008644.entry.js} +1 -1
- package/lib/duet/p-69385972.system.entry.js +4 -0
- package/lib/duet/{p-4e28da18.system.entry.js → p-6a4d85ed.system.entry.js} +1 -1
- package/lib/duet/{p-984576c9.entry.js → p-6a5ab3eb.entry.js} +1 -1
- package/lib/duet/{p-aba68b7b.entry.js → p-6e4b1c0d.entry.js} +1 -1
- package/lib/duet/{p-27d80cef.system.entry.js → p-6f36f647.system.entry.js} +1 -1
- package/lib/duet/{p-7e8d5bb9.system.entry.js → p-6fa6c4fb.system.entry.js} +1 -1
- package/lib/duet/{p-d1c19f04.system.entry.js → p-71a77368.system.entry.js} +1 -1
- package/lib/duet/p-73f9db25.system.entry.js +4 -0
- package/lib/duet/{p-63d5bf73.system.entry.js → p-74f4a0d8.system.entry.js} +1 -1
- package/lib/duet/{p-aef1b720.system.entry.js → p-7530be48.system.entry.js} +1 -1
- package/lib/duet/{p-9481e312.entry.js → p-75edcaed.entry.js} +1 -1
- package/lib/duet/{p-237e47b4.system.entry.js → p-7a8597c2.system.entry.js} +1 -1
- package/lib/duet/p-85ad012a.system.entry.js +4 -0
- package/lib/duet/{p-cdd70b93.entry.js → p-85e52be8.entry.js} +1 -1
- package/lib/duet/{p-94169303.entry.js → p-8aaf3383.entry.js} +1 -1
- package/lib/duet/{p-86daec1c.entry.js → p-9e79e033.entry.js} +1 -1
- package/lib/duet/{p-4607af59.entry.js → p-9f35d682.entry.js} +1 -1
- package/lib/duet/{p-d3a3c3c7.system.entry.js → p-a2a00146.system.entry.js} +1 -1
- package/lib/duet/{p-1208c84f.entry.js → p-a545398c.entry.js} +1 -1
- package/lib/duet/{p-00735436.entry.js → p-af49d4f9.entry.js} +1 -1
- package/lib/duet/p-b25edbbe.entry.js +4 -0
- package/lib/duet/{p-e12f2b8b.system.js → p-b314348c.system.js} +2 -2
- package/lib/duet/{p-751542a0.system.entry.js → p-b4111e88.system.entry.js} +1 -1
- package/lib/duet/{p-7fee0d23.system.entry.js → p-b5c7d304.system.entry.js} +1 -1
- package/lib/duet/{p-16c48c5d.entry.js → p-b6e9860a.entry.js} +1 -1
- package/lib/duet/{p-060d79be.entry.js → p-ba18b56e.entry.js} +1 -1
- package/lib/duet/{p-387823af.system.entry.js → p-bf4596bd.system.entry.js} +1 -1
- package/lib/duet/{p-8b5ca0e7.system.entry.js → p-bf9f6d80.system.entry.js} +1 -1
- package/lib/duet/{p-e2a44156.js → p-c1a1ea1b.js} +1 -1
- package/lib/duet/{p-7368b14e.system.entry.js → p-c742856b.system.entry.js} +1 -1
- package/lib/duet/{p-48d1eb1f.system.entry.js → p-cbdb9e98.system.entry.js} +1 -1
- package/lib/duet/{p-b4e87f02.system.entry.js → p-cf319832.system.entry.js} +1 -1
- package/lib/duet/p-d67fff56.entry.js +4 -0
- package/lib/duet/{p-4b6ebe40.system.entry.js → p-dd76db9b.system.entry.js} +1 -1
- package/lib/duet/{p-d4118b6e.system.entry.js → p-de5ec54e.system.entry.js} +1 -1
- package/lib/duet/{p-5826523b.entry.js → p-df6f39a3.entry.js} +1 -1
- package/lib/duet/p-e1dc86b5.system.js +4 -0
- package/lib/duet/{p-b3744481.entry.js → p-e2596ea0.entry.js} +1 -1
- package/lib/duet/{p-e76b722f.entry.js → p-e370c18b.entry.js} +1 -1
- package/lib/duet/{p-9dca5c22.system.entry.js → p-e48f3a32.system.entry.js} +1 -1
- package/lib/duet/p-e5031543.entry.js +4 -0
- package/lib/duet/{p-597d99c7.entry.js → p-e60ee8b0.entry.js} +1 -1
- package/lib/duet/{p-794659ac.entry.js → p-e70088d5.entry.js} +1 -1
- package/lib/duet/{p-aee24388.system.entry.js → p-e7b90769.system.entry.js} +1 -1
- package/lib/duet/{p-f8ce39fb.entry.js → p-e8123a53.entry.js} +1 -1
- package/lib/duet/{p-a890da72.entry.js → p-ef7251bf.entry.js} +1 -1
- package/lib/duet/p-f0cfe033.system.entry.js +4 -0
- package/lib/duet/{p-1a08fc22.system.entry.js → p-f2a087a8.system.entry.js} +1 -1
- package/lib/duet/{p-3af5d66f.entry.js → p-f5a55b3c.entry.js} +1 -1
- package/lib/duet/p-fd613733.entry.js +4 -0
- package/lib/esm/duet-alert.entry.js +1 -1
- package/lib/esm/duet-badge.entry.js +1 -1
- package/lib/esm/duet-button_2.entry.js +1 -1
- package/lib/esm/duet-caption_4.entry.js +1 -1
- package/lib/esm/duet-card.entry.js +1 -1
- package/lib/esm/duet-checkbox.entry.js +1 -1
- package/lib/esm/duet-choice_2.entry.js +2 -3
- package/lib/esm/duet-collapsible.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-button.entry.js +85 -0
- package/lib/esm/{duet-upload.entry.js → duet-editable-table_4.entry.js} +384 -31
- package/lib/esm/duet-empty-state.entry.js +1 -1
- package/lib/esm/duet-fieldset.entry.js +58 -0
- 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 +16 -6
- 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-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-select.entry.js +1 -1
- package/lib/esm/duet-step_2.entry.js +1 -1
- package/lib/esm/duet-tab_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 +96 -0
- package/lib/esm/duet-visually-hidden.entry.js +1 -1
- package/lib/esm/duet.js +2 -2
- package/lib/esm/{focus-utils-1fe0dcd0.js → focus-utils-aeb6ca93.js} +1 -1
- package/lib/esm/{index-84d97bd1.js → index-e8c7d36f.js} +8 -2
- package/lib/esm/loader.js +2 -2
- 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 +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 +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.entry.js +4 -0
- package/lib/esm-es5/duet-editable-table_4.entry.js +4 -0
- package/lib/esm-es5/duet-empty-state.entry.js +1 -1
- package/lib/esm-es5/duet-fieldset.entry.js +4 -0
- 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 +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 +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-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 +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 +4 -0
- 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-aeb6ca93.js +4 -0
- package/lib/esm-es5/{index-84d97bd1.js → index-e8c7d36f.js} +2 -2
- package/lib/esm-es5/loader.js +1 -1
- package/lib/html.html-data.json +4906 -0
- package/lib/types/components/duet-icon/icon-utils.d.ts +1 -1
- package/lib/types/components/duet-upload/duet-upload.d.ts +42 -18
- package/lib/types/components/duet-upload/{duet-upload-editable-item-error.d.ts → upload-editable-item-error.d.ts} +0 -0
- package/lib/types/components/duet-upload/{duet-upload-editable-item-inprogres.d.ts → upload-editable-item-inprogres.d.ts} +0 -0
- package/lib/types/components/duet-upload/{duet-upload-editable-item-success.d.ts → upload-editable-item-success.d.ts} +0 -0
- package/lib/types/components/duet-upload/{duet-upload-validators.d.ts → upload-validators.d.ts} +0 -0
- package/lib/types/components/{duet-upload → duet-upload-aria-status}/duet-upload-aria-status.d.ts +2 -2
- package/lib/types/components.d.ts +25 -25
- package/package.json +6 -5
- package/lib/cjs/duet-editable-table-button_3.cjs.entry.js +0 -232
- package/lib/cjs/duet-editable-table_3.cjs.entry.js +0 -336
- package/lib/cjs/js-utils-33a9dbe3.js +0 -16
- package/lib/duet/p-10deead0.system.js +0 -4
- package/lib/duet/p-155ef581.system.entry.js +0 -4
- package/lib/duet/p-1797df7b.system.entry.js +0 -4
- package/lib/duet/p-28e02c08.entry.js +0 -4
- package/lib/duet/p-33c58756.entry.js +0 -4
- package/lib/duet/p-5ea0cd19.entry.js +0 -4
- package/lib/duet/p-81867417.system.js +0 -4
- package/lib/duet/p-b25d3769.js +0 -4
- package/lib/duet/p-de07c7d7.entry.js +0 -4
- package/lib/duet/p-dfe79666.system.entry.js +0 -4
- package/lib/duet/p-f0a4b68d.system.entry.js +0 -4
- package/lib/duet/p-f364eb96.entry.js +0 -4
- package/lib/esm/duet-editable-table-button_3.entry.js +0 -226
- package/lib/esm/duet-editable-table_3.entry.js +0 -330
- package/lib/esm/js-utils-b69f17df.js +0 -14
- package/lib/esm-es5/duet-editable-table-button_3.entry.js +0 -4
- package/lib/esm-es5/duet-editable-table_3.entry.js +0 -4
- package/lib/esm-es5/duet-upload.entry.js +0 -4
- package/lib/esm-es5/focus-utils-1fe0dcd0.js +0 -4
- package/lib/esm-es5/js-utils-b69f17df.js +0 -4
|
@@ -1,13 +1,342 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built with Duet Design System
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { d as debounce } from './js-utils-b69f17df.js';
|
|
7
|
-
import { g as getLocaleString } from './language-utils-344d894c.js';
|
|
4
|
+
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-e8c7d36f.js';
|
|
5
|
+
import { s as sanitizeString, g as getLocaleString } from './language-utils-344d894c.js';
|
|
8
6
|
import { i as inheritGlobalTheme } from './themeable-component-572685dd.js';
|
|
7
|
+
import { m as mediaQueryMedium, h as mediaQueryLarge, i as mediaQueryXLarge, j as mediaQueryXxLarge, k as mediaQueryXxxLarge, l as mediaQuerySmall, n as sizeNavigation, s as sizeHeader } from './tokens.module-49cbf963.js';
|
|
8
|
+
import { c as createID } from './create-id-981107da.js';
|
|
9
9
|
import './string-utils-2f1793b8.js';
|
|
10
10
|
|
|
11
|
+
const debounce = (func, timeout = 50) => {
|
|
12
|
+
let timer;
|
|
13
|
+
return (...args) => {
|
|
14
|
+
clearTimeout(timer);
|
|
15
|
+
timer = setTimeout(() => {
|
|
16
|
+
func.apply(undefined, args);
|
|
17
|
+
}, timeout);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const duetEditableTableCss = "duet-editable-table{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}.duet-editable-table-header tr .duet-editable-table-header-hidden{padding:0 !important;font-size:0;border-bottom:0}";
|
|
22
|
+
|
|
23
|
+
let DuetEditableTable = class {
|
|
24
|
+
constructor(hostRef) {
|
|
25
|
+
registerInstance(this, hostRef);
|
|
26
|
+
/**
|
|
27
|
+
* State() variables
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
this.tick = Date.now();
|
|
31
|
+
/**
|
|
32
|
+
* Map of items that contain list of things.
|
|
33
|
+
*/
|
|
34
|
+
this.items = new Map();
|
|
35
|
+
/**
|
|
36
|
+
* Array of internationalized defaults for the default groups labels.
|
|
37
|
+
*/
|
|
38
|
+
this.groupsLabelDefaults = {
|
|
39
|
+
fi: "Kaikki",
|
|
40
|
+
en: "All items",
|
|
41
|
+
sv: "Alla objekt",
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Array of internationalized defaults for the default action labels.
|
|
45
|
+
*/
|
|
46
|
+
this.actionLabelDefaults = {
|
|
47
|
+
fi: "Toiminnot",
|
|
48
|
+
en: "Actions",
|
|
49
|
+
sv: "Handlingar",
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Array of group names that you want the editable table to display (can be used to hide or show groups depending on conditions).
|
|
53
|
+
* @default { id: "all", label: this.groupsLabelDefaults, actionLabel: this.actionLabelDefaults }.
|
|
54
|
+
* @example [{ id: "success", label: {fi: "Onnistunut", en: "Success", sv: "Alt klart", }}].
|
|
55
|
+
*/
|
|
56
|
+
this.groups = [
|
|
57
|
+
{ id: "all", label: this.groupsLabelDefaults, actionLabel: this.actionLabelDefaults },
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Array of actions that are mapped via the map variable to the various groups defined in group.
|
|
61
|
+
* @default undefined
|
|
62
|
+
* @example [{
|
|
63
|
+
variation: "default",
|
|
64
|
+
icon: "action-edit-2",
|
|
65
|
+
id: "edit",
|
|
66
|
+
map: ["success"],
|
|
67
|
+
label: {
|
|
68
|
+
fi: " Label",
|
|
69
|
+
en: " Label",
|
|
70
|
+
sv: " Label",
|
|
71
|
+
}
|
|
72
|
+
}]
|
|
73
|
+
*/
|
|
74
|
+
this.actions = undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Shows or hides the table labels.
|
|
77
|
+
*/
|
|
78
|
+
this.hideGroups = false;
|
|
79
|
+
/**
|
|
80
|
+
* Exposes the aria role for optimizing accessibility.
|
|
81
|
+
*/
|
|
82
|
+
this.accessibleRole = undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Private methods.
|
|
85
|
+
*/
|
|
86
|
+
this.kick = debounce(() => {
|
|
87
|
+
this.tick = Date.now();
|
|
88
|
+
}, 100); // will trigger re-render
|
|
89
|
+
this.filterMap = needle => {
|
|
90
|
+
if (needle === "all") {
|
|
91
|
+
return Array.from(this.items);
|
|
92
|
+
}
|
|
93
|
+
return Array.from(this.items).filter(item => needle === item[1].group);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Component lifecycle events.
|
|
98
|
+
*/
|
|
99
|
+
componentWillLoad() {
|
|
100
|
+
if (typeof this.groups === "string") {
|
|
101
|
+
this.internalGroupArray = sanitizeString(this.groups);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this.internalGroupArray = this.groups;
|
|
105
|
+
}
|
|
106
|
+
if (typeof this.actions === "string") {
|
|
107
|
+
this.internalActionsArray = sanitizeString(this.actions);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.internalActionsArray = this.actions;
|
|
111
|
+
}
|
|
112
|
+
inheritGlobalTheme(this);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Method to force an update of a tabular data array.
|
|
116
|
+
* when called the method will rerender the entire tabular structure.
|
|
117
|
+
*/
|
|
118
|
+
async updateTable(passedItems = undefined) {
|
|
119
|
+
this.items = new Map(passedItems || this.items);
|
|
120
|
+
this.kick();
|
|
121
|
+
}
|
|
122
|
+
render() {
|
|
123
|
+
return (h(Host, { class: {
|
|
124
|
+
"duet-theme-turva": this.theme === "turva",
|
|
125
|
+
} }, this.internalGroupArray.map(group => {
|
|
126
|
+
const currentGroup = this.filterMap(group.id);
|
|
127
|
+
if (!currentGroup.length) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
return (h("duet-table", { variation: "plain", breakpoint: "none", role: "", margin: this.hideGroups ? "none" : "auto" }, h("table", { class: "duet-editable-table", "aria-role": this.accessibleRole }, h("thead", { class: "duet-editable-table-header" }, h("tr", null, h("th", { class: {
|
|
131
|
+
"duet-editable-table-header-hidden": this.hideGroups,
|
|
132
|
+
} }, !this.hideGroups ? (getLocaleString(group.label)) : (h("duet-visually-hidden", null, getLocaleString(group.label)))), h("th", { class: {
|
|
133
|
+
"duet-editable-table-header-hidden": this.hideGroups,
|
|
134
|
+
} }, h("duet-visually-hidden", null, group.actionLabel
|
|
135
|
+
? getLocaleString(group.actionLabel)
|
|
136
|
+
: getLocaleString(this.actionLabelDefaults))))), h("tbody", null, currentGroup.map(dataAsArray => {
|
|
137
|
+
const [key, value] = dataAsArray;
|
|
138
|
+
return (h("duet-editable-table-item", { keyName: key, data: Object.assign({}, value), groupId: group.id, part: group.id, actions: this.internalActionsArray }));
|
|
139
|
+
})))));
|
|
140
|
+
})));
|
|
141
|
+
}
|
|
142
|
+
get element() { return getElement(this); }
|
|
143
|
+
};
|
|
144
|
+
DuetEditableTable.style = duetEditableTableCss;
|
|
145
|
+
|
|
146
|
+
//simple functional component that renders the data in the table
|
|
147
|
+
const TableData = ({ data, groupId }, _children) => {
|
|
148
|
+
if (typeof data === "string") {
|
|
149
|
+
return h("td", { innerHTML: data, class: "duet-editable-table-content", part: `${groupId}content` });
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
return (h("td", { class: "duet-editable-table-content", part: `${groupId}content` }, data));
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const duetEditableTableItemCss = "*,*::after,*::before{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}:host{display:table-row;height:32px}.duet-editable-table-content,.duet-editable-table-actions{height:32px;padding:12px 0;vertical-align:middle;break-word:break-all;border-bottom:1px solid #e1e3e6}.duet-editable-table-actions-items{display:flex;justify-content:flex-end}.duet-editable-table-actions-items duet-editable-table-button{padding-left:8px}.duet-editable-table .editable-item-small{font-size:0.75rem;font-weight:400}";
|
|
157
|
+
|
|
158
|
+
let DuetEditableTableItem = class {
|
|
159
|
+
constructor(hostRef) {
|
|
160
|
+
registerInstance(this, hostRef);
|
|
161
|
+
this.duetEditableItemAction = createEvent(this, "duetEditableItemAction", 7);
|
|
162
|
+
this.isHovering = false;
|
|
163
|
+
/**
|
|
164
|
+
* Theme of the empty state component.
|
|
165
|
+
*/
|
|
166
|
+
this.theme = "";
|
|
167
|
+
/**
|
|
168
|
+
* Actions that can be performed on the element
|
|
169
|
+
*/
|
|
170
|
+
this.actions = undefined;
|
|
171
|
+
/**
|
|
172
|
+
* GroupId used to pierce the shadowdom - gets concatenated with "content & actions" and used as part="groupIDcontent/actions" to pierce the content/Action item
|
|
173
|
+
* @internal
|
|
174
|
+
*/
|
|
175
|
+
this.groupId = "";
|
|
176
|
+
/**
|
|
177
|
+
* Key used to identify item, when running actions
|
|
178
|
+
*/
|
|
179
|
+
this.keyName = "";
|
|
180
|
+
/**
|
|
181
|
+
* Object of data itemsused to render the entire row
|
|
182
|
+
*/
|
|
183
|
+
this.data = undefined;
|
|
184
|
+
}
|
|
185
|
+
watchPropHandler(_newValue, _oldValue) {
|
|
186
|
+
// console.log("The new value of activated is: ", _newValue)
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
/**
|
|
190
|
+
* Component lifecycle events.
|
|
191
|
+
*/
|
|
192
|
+
componentWillLoad() {
|
|
193
|
+
inheritGlobalTheme(this);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
/**
|
|
197
|
+
* private functions
|
|
198
|
+
*/
|
|
199
|
+
/**
|
|
200
|
+
* render() function
|
|
201
|
+
* Always the last one in the class.
|
|
202
|
+
*/
|
|
203
|
+
render() {
|
|
204
|
+
return (h(Host, { role: "row" }, h(TableData, { data: this.data.item, groupId: this.groupId }), h("td", { class: "duet-editable-table-actions" }, h("div", { class: "duet-editable-table-actions-items", part: `${this.groupId}actions` }, this.actions.map(result => {
|
|
205
|
+
const { map = undefined } = result;
|
|
206
|
+
// if map has been specified, only show the current action if groupID matches the map array
|
|
207
|
+
if (map && !map.includes(this.groupId)) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
return (h("duet-editable-table-button", { keyName: this.keyName, group: this.data.group, uid: this.data.uid, actions: result, theme: this.theme }));
|
|
211
|
+
})))));
|
|
212
|
+
}
|
|
213
|
+
get el() { return getElement(this); }
|
|
214
|
+
static get watchers() { return {
|
|
215
|
+
"data": ["watchPropHandler"]
|
|
216
|
+
}; }
|
|
217
|
+
};
|
|
218
|
+
DuetEditableTableItem.style = duetEditableTableItemCss;
|
|
219
|
+
|
|
220
|
+
const duetTableCss = "duet-table{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none;margin-bottom:20px !important;display:block;font-variant-numeric:tabular-nums}duet-table table,duet-table thead,duet-table tbody,duet-table tfoot,duet-table th,duet-table td,duet-table tr{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none}duet-table.duet-m-0{margin:0 !important}duet-table table{width:100%;font-family:\"localtapiola-sans\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";font-size:1rem;text-align:left;border-spacing:0;border-collapse:separate}duet-table.duet-theme-turva table{font-family:\"turva-sans\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"}duet-table td{-webkit-hyphens:auto;hyphens:auto;color:#00294d}duet-table.duet-theme-turva td{color:#171c3a}duet-table th{font-weight:600;line-height:1.25;color:#657787;text-align:left}duet-table.duet-theme-turva th{color:#747475}duet-table tbody th{font-weight:600;color:#00294d}duet-table.duet-theme-turva tbody th{color:#171c3a}.duet-table-flattened table,.duet-table-flattened thead,.duet-table-flattened tbody,.duet-table-flattened tfoot,.duet-table-flattened th,.duet-table-flattened td,.duet-table-flattened tr{display:block}.duet-table-flattened thead tr{position:absolute !important;top:0;width:1px !important;height:1px !important;padding:0 !important;overflow:hidden !important;clip:rect(1px, 1px, 1px, 1px) !important;border:0 !important}.duet-table-flattened td{line-height:1.25}.duet-table-flattened td:not(:last-child){margin-bottom:16px !important}.duet-table-flattened tbody td,.duet-table-flattened tbody th,.duet-table-flattened tfoot td{padding:0 !important;text-align:left !important}.duet-table-flattened tbody th{font-weight:600;line-height:1.25;color:#657787;text-align:left}.duet-table-flattened td[data-heading]::before{margin-bottom:4px !important;display:block;font-size:1rem;font-weight:600;color:#00294d;content:attr(data-heading)}.duet-table-flattened.duet-theme-turva td[data-heading]::before{color:#171c3a}.duet-table-sticky thead th{position:sticky;top:0;background:white}.duet-table-striped td,.duet-table-striped th{padding:20px !important}@media (max-width: 35.9375em){.duet-table-striped td,.duet-table-striped th{padding:20px 12px !important}}.duet-table-striped tbody th{background:white}.duet-table-striped.duet-table-sticky thead th{border-bottom:1px solid #e1e3e6}.duet-table-striped.duet-table-sticky.duet-theme-turva thead th{border-bottom-color:#e4e4e6}.duet-table-striped tbody:not(:first-of-type) th{padding-top:40px !important}.duet-table-striped tbody:only-of-type tr:nth-of-type(odd){background:rgba(0, 80, 128, 0.04)}.duet-table-striped.duet-theme-turva tbody:only-of-type tr:nth-of-type(odd){background:rgba(23, 28, 58, 0.04)}.duet-table-striped tbody:not(:only-of-type) tr:nth-of-type(even){background:rgba(0, 80, 128, 0.04)}.duet-table-striped.duet-theme-turva tbody:not(:only-of-type) tr:nth-of-type(even){background:rgba(23, 28, 58, 0.04)}.duet-table-striped tfoot td{border-top:1px solid #e1e3e6}.duet-table-striped.duet-theme-turva tfoot td{border-top-color:#e4e4e6}.duet-table-striped.duet-table-flattened tbody:not(:first-of-type) th{padding-top:20px !important}.duet-table-striped.duet-table-flattened tr{padding:20px !important}.duet-table-striped.duet-table-flattened tfoot td{border-top:0}.duet-table-striped.duet-table-flattened tfoot tr{border-top:1px solid #e1e3e6}.duet-table-striped.duet-table-flattened.duet-theme-turva tfoot tr{border-top-color:#e4e4e6}.duet-table-minimal th,.duet-table-plain th{padding:16px !important;border-bottom:1px solid #657787}.duet-table-minimal th:first-child,.duet-table-plain th:first-child{padding-left:0 !important}.duet-table-minimal th:last-child,.duet-table-plain th:last-child{padding-right:0 !important}.duet-theme-turva.duet-table-minimal th,.duet-theme-turva.duet-table-plain th{border-bottom-color:#444445}.duet-table-minimal tbody th,.duet-table-plain tbody th{padding-top:40px !important;border-bottom-color:#e1e3e6}.duet-theme-turva.duet-table-minimal tbody th,.duet-theme-turva.duet-table-plain tbody th{border-bottom-color:#e4e4e6}.duet-table-minimal td,.duet-table-plain td{padding:16px !important}.duet-table-minimal td:first-child,.duet-table-plain td:first-child{padding-left:0 !important}.duet-table-minimal td:last-child,.duet-table-plain td:last-child{padding-right:0 !important}.duet-table-minimal tbody td,.duet-table-plain tbody td{border-bottom:1px solid #e1e3e6}.duet-theme-turva.duet-table-minimal tbody td,.duet-theme-turva.duet-table-plain tbody td{border-bottom-color:#e4e4e6}.duet-table-flattened.duet-table-minimal tbody:first-of-type th,.duet-table-flattened.duet-table-plain tbody:first-of-type th{padding-top:0 !important}.duet-table-flattened.duet-table-minimal td,.duet-table-flattened.duet-table-plain td,.duet-table-flattened.duet-table-minimal tbody th,.duet-table-flattened.duet-table-plain tbody th{border-bottom:0}.duet-table-flattened.duet-table-minimal tr,.duet-table-flattened.duet-table-plain tr{padding:20px 0 !important}.duet-table-flattened.duet-table-minimal tbody th,.duet-table-flattened.duet-table-plain tbody th{padding-top:20px !important}.duet-table-flattened.duet-table-minimal tfoot td,.duet-table-flattened.duet-table-plain tfoot td{margin-bottom:4px !important}.duet-table-flattened.duet-table-minimal tbody:not(:only-of-type) tr:first-child,.duet-table-flattened.duet-table-plain tbody:not(:only-of-type) tr:first-child{border-bottom:0}.duet-table-plain.duet-table-flattened tbody tr{border-bottom:1px solid #e1e3e6}.duet-table-plain.duet-table-flattened.duet-theme-turva tbody tr{border-bottom-color:#e4e4e6}.duet-table-minimal tbody tr,.duet-table-minimal tbody tr td{vertical-align:top;border-bottom:0 none}.duet-table-minimal tbody tr:last-of-type,.duet-table-minimal tbody tr:last-of-type td{border-bottom:1px solid #e1e3e6}.duet-table-minimal.duet-table-flattened tbody tr,.duet-table-minimal.duet-table-flattened tbody tr td{border-bottom:0 none}.duet-table-minimal.duet-table-flattened tbody tr td[data-heading]::before{display:none}.duet-table-minimal.duet-table-flattened tfoot{border-top:1px solid #e1e3e6}.duet-table-minimal.duet-table-flattened.duet-theme-turva tfoot{border-top-color:#e4e4e6}.duet-table-scrollable{position:relative;width:100%;overflow-x:auto;background:linear-gradient(90deg, #fff 0%, rgba(255, 255, 255, 0)), linear-gradient(-90deg, #fff 0%, rgba(255, 255, 255, 0)) 100% 0, radial-gradient(farthest-side at 0% 50%, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0)), radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0)) 100% 0%;background-repeat:no-repeat;background-attachment:local, local, scroll, scroll;background-size:100px 100%, 100px 100%, 12px 100%, 12px 100%}.duet-table-selected-column{background:rgba(0, 119, 179, 0.08)}.duet-theme-turva .duet-table-selected-column{background:rgba(68, 68, 69, 0.08)}";
|
|
221
|
+
|
|
222
|
+
// remove wrapping speech marks.
|
|
223
|
+
// media query tokens are wrapped in speech marks,
|
|
224
|
+
// which need to be removed before use with matchMedia.
|
|
225
|
+
const unwrap = (str) => str.substring(1, str.length - 1);
|
|
226
|
+
const breakpointToToken = {
|
|
227
|
+
none: "all",
|
|
228
|
+
"none-scrollable": "all",
|
|
229
|
+
small: unwrap(mediaQuerySmall),
|
|
230
|
+
medium: unwrap(mediaQueryMedium),
|
|
231
|
+
large: unwrap(mediaQueryLarge),
|
|
232
|
+
"x-large": unwrap(mediaQueryXLarge),
|
|
233
|
+
"xx-large": unwrap(mediaQueryXxLarge),
|
|
234
|
+
"xxx-large": unwrap(mediaQueryXxxLarge),
|
|
235
|
+
};
|
|
236
|
+
const stickyTopValues = {
|
|
237
|
+
none: 0,
|
|
238
|
+
"with-links": parseFloat(sizeNavigation) * 16,
|
|
239
|
+
"without-links": parseFloat(sizeHeader) * 16,
|
|
240
|
+
};
|
|
241
|
+
let DuetTable = class {
|
|
242
|
+
constructor(hostRef) {
|
|
243
|
+
registerInstance(this, hostRef);
|
|
244
|
+
/**
|
|
245
|
+
* Tracks whether the breakpoint is matched. This is set to true by default so that JavaScript disabled in SSR mode we get accessible table data first.
|
|
246
|
+
*/
|
|
247
|
+
this.matchesBreakpoint = true;
|
|
248
|
+
/**
|
|
249
|
+
* Controls the margin of the component.
|
|
250
|
+
*/
|
|
251
|
+
this.margin = "auto";
|
|
252
|
+
/**
|
|
253
|
+
* Style variation of the table.
|
|
254
|
+
*/
|
|
255
|
+
this.variation = "striped";
|
|
256
|
+
/**
|
|
257
|
+
* Controls whether the table has a sticky header.
|
|
258
|
+
* Sticky headers are not compatible with breakpoint="none-scrollable".
|
|
259
|
+
*/
|
|
260
|
+
this.sticky = false;
|
|
261
|
+
/**
|
|
262
|
+
* Adjust the distance from top of the viewport (in pixels) when the
|
|
263
|
+
* table header becomes sticky.
|
|
264
|
+
*/
|
|
265
|
+
this.stickyDistance = "with-links";
|
|
266
|
+
/**
|
|
267
|
+
* By default the table is responsive - it will be flattened at narrow viewport widths.
|
|
268
|
+
* This prop controls the breakpoint at which the table should be rendered as a _regular_ table.
|
|
269
|
+
* Set to "none" to disable the responsive functionality.
|
|
270
|
+
* Set to "none-scrollable" to disable responsive functionality _and_ allow horizontal scrolling -
|
|
271
|
+
* this is useful for comparison tables where it's important to maintain column and row layout.
|
|
272
|
+
*/
|
|
273
|
+
this.breakpoint = "small";
|
|
274
|
+
this.handleMediaQueryChange = (mq) => {
|
|
275
|
+
this.matchesBreakpoint = mq.matches;
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
connectedCallback() {
|
|
279
|
+
this.mq = matchMedia(breakpointToToken[this.breakpoint]);
|
|
280
|
+
this.mq.addListener(this.handleMediaQueryChange);
|
|
281
|
+
this.handleMediaQueryChange(this.mq);
|
|
282
|
+
this.observer = new MutationObserver(() => this.copyHeadingsToCells());
|
|
283
|
+
this.observer.observe(this.element, {
|
|
284
|
+
childList: true,
|
|
285
|
+
subtree: true,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
componentWillLoad() {
|
|
289
|
+
inheritGlobalTheme(this);
|
|
290
|
+
this.copyHeadingsToCells();
|
|
291
|
+
if (this.sticky && this.breakpoint === "none-scrollable") {
|
|
292
|
+
console.warn(`[DUET WARNING]: sticky and breakpoint="none-scrollable" are incompatible. Scrollable takes precedence`);
|
|
293
|
+
}
|
|
294
|
+
if (this.sticky) {
|
|
295
|
+
const stickyTop = stickyTopValues[this.stickyDistance];
|
|
296
|
+
const headingElements = this.element.querySelectorAll("thead th");
|
|
297
|
+
headingElements.forEach(th => (th.style.top = `${stickyTop}px`));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
componentDidLoad() {
|
|
301
|
+
// this clears all pending mutations,
|
|
302
|
+
// that way we avoid dealing with any initial changes
|
|
303
|
+
// and only get genuine mutations as rows are added/removed
|
|
304
|
+
this.observer.takeRecords();
|
|
305
|
+
}
|
|
306
|
+
disconnectedCallback() {
|
|
307
|
+
this.observer.disconnect();
|
|
308
|
+
this.observer = null;
|
|
309
|
+
this.mq.removeListener(this.handleMediaQueryChange);
|
|
310
|
+
this.mq = null;
|
|
311
|
+
this.matchesBreakpoint = true;
|
|
312
|
+
}
|
|
313
|
+
copyHeadingsToCells() {
|
|
314
|
+
const headingElements = this.element.querySelectorAll("thead th");
|
|
315
|
+
const rowElements = this.element.querySelectorAll("tbody tr");
|
|
316
|
+
const headings = Array.from(headingElements).map(th => th.textContent.trim());
|
|
317
|
+
rowElements.forEach(tr => {
|
|
318
|
+
tr.querySelectorAll("td").forEach((td, i) => {
|
|
319
|
+
if (headings[i]) {
|
|
320
|
+
td.dataset.heading = headings[i];
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
render() {
|
|
326
|
+
return (h(Host, { class: {
|
|
327
|
+
[`duet-table-${this.variation}`]: true,
|
|
328
|
+
"duet-table-flattened": !this.matchesBreakpoint,
|
|
329
|
+
// sticky only valid when in regular table layout
|
|
330
|
+
"duet-table-sticky": this.matchesBreakpoint && this.sticky,
|
|
331
|
+
"duet-table-scrollable": this.breakpoint === "none-scrollable",
|
|
332
|
+
"duet-m-0": this.margin === "none",
|
|
333
|
+
"duet-theme-turva": this.theme === "turva",
|
|
334
|
+
} }, h("slot", null)));
|
|
335
|
+
}
|
|
336
|
+
get element() { return getElement(this); }
|
|
337
|
+
};
|
|
338
|
+
DuetTable.style = duetTableCss;
|
|
339
|
+
|
|
11
340
|
const errorCodes = [
|
|
12
341
|
{
|
|
13
342
|
type: "default",
|
|
@@ -360,7 +689,7 @@ let DuetUpload = class {
|
|
|
360
689
|
this.filesInProgress = new Map();
|
|
361
690
|
this.fileMaxReached = false;
|
|
362
691
|
this.bytesMaxReached = false;
|
|
363
|
-
|
|
692
|
+
this.internalStatusMessageLabel = undefined;
|
|
364
693
|
/**
|
|
365
694
|
* Properties
|
|
366
695
|
*/
|
|
@@ -379,12 +708,12 @@ let DuetUpload = class {
|
|
|
379
708
|
*/
|
|
380
709
|
this.external = false;
|
|
381
710
|
/**
|
|
382
|
-
* If set the upload component will not display an upload button, you will have to create
|
|
383
|
-
* and call the exposed
|
|
711
|
+
* If set the upload component will not display an upload button, you will have to create one yourself
|
|
712
|
+
* and call the exposed method startUpload
|
|
384
713
|
*/
|
|
385
714
|
this.hideButton = false;
|
|
386
715
|
/**
|
|
387
|
-
* Default actions added to
|
|
716
|
+
* Default actions added to the internally used duet-editable-table
|
|
388
717
|
*/
|
|
389
718
|
this.actions = [
|
|
390
719
|
{
|
|
@@ -413,17 +742,43 @@ let DuetUpload = class {
|
|
|
413
742
|
},
|
|
414
743
|
];
|
|
415
744
|
/**
|
|
416
|
-
* If enabled the
|
|
745
|
+
* If enabled the editable-table will display links on successfully uploaded items,
|
|
417
746
|
* this requires the server can respond with link URIs in the correct format
|
|
747
|
+
* and that the files are accessible to the user
|
|
418
748
|
*/
|
|
419
749
|
this.showLinks = false;
|
|
420
750
|
/**
|
|
421
751
|
* Property to change the aria upload progress text read aloud by screenreaders
|
|
422
752
|
* @default {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
753
|
+
* fi: {
|
|
754
|
+
* inProgress: "Lähetetään {filesUploaded} lähetettävästä {filesTotal} tiedostosta",
|
|
755
|
+
* inProgressWithErrors:
|
|
756
|
+
* "Lähetetään {filesInProgress} tiedostoa, lähetetty {filesUploaded} lähetettävästä {filesTotal} tiedostosta, {filesWithErrors} tiedostossa on virheitä",
|
|
757
|
+
* done: "Kaikki {filesTotal} tiedostoa lähetetty onnistuneesti",
|
|
758
|
+
* doneWithErrors:
|
|
759
|
+
* "Lähetys valmis, {filesUploaded} tiedostoa on lähetetty onnistuneesti, {filesWithErrors} tiedostossa oli virheitä",
|
|
760
|
+
* files: "tiedostot",
|
|
761
|
+
* file: "tiedosto",
|
|
762
|
+
* },
|
|
763
|
+
* sv: {
|
|
764
|
+
* inProgress: "Adding {filesUploaded} of {filesTotal}",
|
|
765
|
+
* inProgressWithErrors:
|
|
766
|
+
* "Laddar upp {filesInProgress}, {filesUploaded} uppladdad av {filesTotal}, {filesWithErrors} misslyckades",
|
|
767
|
+
* done: "Alla {filesTotal} har lagts till",
|
|
768
|
+
* doneWithErrors: "Handling slutförd, {filesUploaded} har lagts till, {filesWithErrors} misslyckades",
|
|
769
|
+
* files: "filer",
|
|
770
|
+
* file: "fil",
|
|
771
|
+
* },
|
|
772
|
+
* en: {
|
|
773
|
+
* inProgress: "Adding {filesUploaded} of {filesTotal}",
|
|
774
|
+
* inProgressWithErrors:
|
|
775
|
+
* "Uploading {filesInProgress}, {filesUploaded} uploaded of {filesTotal}, {filesWithErrors} failed",
|
|
776
|
+
* done: "All {filesTotal} added successfully",
|
|
777
|
+
* doneWithErrors: "Action completed, {filesUploaded} has been added successfully, {filesWithErrors} had errors",
|
|
778
|
+
* files: "tiedostoa",
|
|
779
|
+
* file: "tiedosto",
|
|
780
|
+
* },
|
|
781
|
+
* }
|
|
427
782
|
*/
|
|
428
783
|
this.statusLabelDefaults = {
|
|
429
784
|
fi: {
|
|
@@ -456,8 +811,7 @@ let DuetUpload = class {
|
|
|
456
811
|
*/
|
|
457
812
|
this.statusMessageLabel = getLocaleString(this.statusLabelDefaults);
|
|
458
813
|
/**
|
|
459
|
-
* Property to change
|
|
460
|
-
* normally you would handle these strings on an application level and override @label when needed
|
|
814
|
+
* Property to change button label defaults on the component.
|
|
461
815
|
* @default {
|
|
462
816
|
fi: "Lisää liite",
|
|
463
817
|
sv: "Lägg till en bilaga",
|
|
@@ -475,7 +829,7 @@ let DuetUpload = class {
|
|
|
475
829
|
*/
|
|
476
830
|
this.buttonLabel = getLocaleString(this.buttonLabelDefaults);
|
|
477
831
|
/**
|
|
478
|
-
* accessible Label of button
|
|
832
|
+
* accessible aria-Label of button
|
|
479
833
|
*/
|
|
480
834
|
this.accessibleButtonLabel = undefined;
|
|
481
835
|
/**
|
|
@@ -507,7 +861,7 @@ let DuetUpload = class {
|
|
|
507
861
|
*/
|
|
508
862
|
this.files = new Map();
|
|
509
863
|
/**
|
|
510
|
-
* Property to read if
|
|
864
|
+
* Property to read if the internally used editable-table contains errors or not
|
|
511
865
|
*/
|
|
512
866
|
this.valid = !this.required;
|
|
513
867
|
/**
|
|
@@ -527,7 +881,6 @@ let DuetUpload = class {
|
|
|
527
881
|
this.label = getLocaleString(this.labelDefaults);
|
|
528
882
|
/**
|
|
529
883
|
* Property to change descriptionDefaults defaults on the component.
|
|
530
|
-
* normally you would handle these strings on an application level and override @label when needed
|
|
531
884
|
* @default {
|
|
532
885
|
fi: "Voit liittää {filetypes}-muotoisia tiedostoja sekä yleisimpiä videotiedostoja. Voit lähettää {maxbytes} verran tiedostoja yhdellä kertaa, ja lisätä enintään {maxfiles} liitettä kerrallaan.",
|
|
533
886
|
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.",
|
|
@@ -601,7 +954,6 @@ let DuetUpload = class {
|
|
|
601
954
|
* by default this is off, setting this to true will limit the users choices to what has been explicitly set
|
|
602
955
|
*/
|
|
603
956
|
this.limitSelection = false;
|
|
604
|
-
//region Private functions
|
|
605
957
|
/**
|
|
606
958
|
* Private functions
|
|
607
959
|
*/
|
|
@@ -699,7 +1051,6 @@ let DuetUpload = class {
|
|
|
699
1051
|
}
|
|
700
1052
|
};
|
|
701
1053
|
this.updateProgress = (ev, name) => {
|
|
702
|
-
console.log(this.filesInProgress.size);
|
|
703
1054
|
const updateProgressHelper = percentComplete => {
|
|
704
1055
|
this.updateValueInMap(name, "progress", percentComplete);
|
|
705
1056
|
this.onProgress(name, percentComplete, ev);
|
|
@@ -743,6 +1094,10 @@ let DuetUpload = class {
|
|
|
743
1094
|
* We reset the form fields to always be able to re-upload files
|
|
744
1095
|
* and because we handle all uploads and states internally in the component (not relying on native form elements)
|
|
745
1096
|
*/
|
|
1097
|
+
/* TODO: it may be a good idea to just update the list so that this always matches what is in the files map,
|
|
1098
|
+
* TODO: this would remove the capability of Re-uploading, unless we can catch and remove the user file from the form filelist before the upload is canceled by the browser
|
|
1099
|
+
* TODO: but for now we'll just reset the form fields
|
|
1100
|
+
*/
|
|
746
1101
|
this.nativeInput.value = "";
|
|
747
1102
|
};
|
|
748
1103
|
this.startUpload = async (ev, metaData = undefined) => {
|
|
@@ -754,8 +1109,6 @@ let DuetUpload = class {
|
|
|
754
1109
|
ev.preventDefault();
|
|
755
1110
|
return;
|
|
756
1111
|
};
|
|
757
|
-
//endregion
|
|
758
|
-
//region Eventlisteners for the XHR requests
|
|
759
1112
|
/**
|
|
760
1113
|
* Eventlisteners for the XHR requests
|
|
761
1114
|
*/
|
|
@@ -884,11 +1237,16 @@ let DuetUpload = class {
|
|
|
884
1237
|
this.kick();
|
|
885
1238
|
}
|
|
886
1239
|
}
|
|
887
|
-
//endregion
|
|
888
1240
|
/**
|
|
889
1241
|
* Component lifecycle events.
|
|
890
1242
|
*/
|
|
891
1243
|
componentWillLoad() {
|
|
1244
|
+
if (typeof this.statusMessageLabel === "string") {
|
|
1245
|
+
this.internalStatusMessageLabel = sanitizeString(this.groups);
|
|
1246
|
+
}
|
|
1247
|
+
else {
|
|
1248
|
+
this.internalStatusMessageLabel = this.statusMessageLabel;
|
|
1249
|
+
}
|
|
892
1250
|
inheritGlobalTheme(this);
|
|
893
1251
|
this.listenForActionEvents();
|
|
894
1252
|
}
|
|
@@ -896,8 +1254,6 @@ let DuetUpload = class {
|
|
|
896
1254
|
// listen to the events from the component
|
|
897
1255
|
this.verifyValidity();
|
|
898
1256
|
}
|
|
899
|
-
//endregion
|
|
900
|
-
//region XHR requests
|
|
901
1257
|
/**
|
|
902
1258
|
* XHR request utilities
|
|
903
1259
|
*/
|
|
@@ -945,8 +1301,6 @@ let DuetUpload = class {
|
|
|
945
1301
|
onProgress: this.trackProgress,
|
|
946
1302
|
});
|
|
947
1303
|
}
|
|
948
|
-
//endregion
|
|
949
|
-
//region EventHandlers
|
|
950
1304
|
/**
|
|
951
1305
|
* Component event handling.
|
|
952
1306
|
*/
|
|
@@ -1021,7 +1375,6 @@ let DuetUpload = class {
|
|
|
1021
1375
|
component: "duet-upload",
|
|
1022
1376
|
});
|
|
1023
1377
|
}
|
|
1024
|
-
//endregion
|
|
1025
1378
|
/**
|
|
1026
1379
|
* Sets focus on the specified `duet-input`. Use this method instead of the global
|
|
1027
1380
|
* `input.focus()`.
|
|
@@ -1051,7 +1404,7 @@ let DuetUpload = class {
|
|
|
1051
1404
|
return this.getFilesAsArray();
|
|
1052
1405
|
}
|
|
1053
1406
|
/**
|
|
1054
|
-
* Convenience method for updating
|
|
1407
|
+
* Convenience method for updating the value of a key:value inside an item in the files attribute
|
|
1055
1408
|
*/
|
|
1056
1409
|
async updateValue(item, key, value) {
|
|
1057
1410
|
this.updateValueInMap(item, key, value);
|
|
@@ -1069,7 +1422,7 @@ let DuetUpload = class {
|
|
|
1069
1422
|
"duet-upload-filelist-empty": !this.files.size,
|
|
1070
1423
|
"duet-upload-filelist": true,
|
|
1071
1424
|
"duet-upload-filelist-filled": this.files.size,
|
|
1072
|
-
}, id: this.labelId, for: identifier }, this.fileListEmpty)), !!this.files.size && h("slot", { name: "fileheader" }), !!this.files.size && (h("duet-upload-aria-status", { invalid: this.getFilesAsArray().invalid.length, valid: this.getFilesAsArray().valid.length, inprogress: this.filesInProgress.size, total: this.files.size, statusMessageLabel: this.
|
|
1425
|
+
}, id: this.labelId, for: identifier }, this.fileListEmpty)), !!this.files.size && h("slot", { name: "fileheader" }), !!this.files.size && (h("duet-upload-aria-status", { invalid: this.getFilesAsArray().invalid.length, valid: this.getFilesAsArray().valid.length, inprogress: this.filesInProgress.size, total: this.files.size, statusMessageLabel: this.internalStatusMessageLabel })), !!this.files.size && (h("duet-editable-table", { "aria-live": "polite", "aria-relevant": "removals", accessibleRole: "log", id: this.editableTableId, groups: this.groups, actions: this.actions, hideGroups: this.hideGroups, items: this.convertToDuetEditableTableItems() })), !!this.files.size && h("slot", { name: "filefooter" }), h("duet-spacer", { size: "large" }), !this.hideButton && (h("duet-button", { id: this.buttonId, onClick: this.startUpload, "accessible-controls": identifier, disabled: this.fileMaxReached, "accessible-label": this.accessibleButtonLabel, "accessible-owns": identifier, size: "small", variation: "secondary", fixed: true, icon: "action-add-circle" }, this.buttonLabel)), h("duet-spacer", { size: "medium" }), (this.fileMaxReached || this.bytesMaxReached) && (h("duet-alert", null, this.fileMaxReached && getI18nError("duet-upload-301"), this.bytesMaxReached && getI18nError("duet-upload-202"))), h("duet-spacer", { size: "medium" }), h("duet-visually-hidden", null, h("input", { ref: input => {
|
|
1073
1426
|
this.nativeInput = input;
|
|
1074
1427
|
}, accept: !this.limitSelection ? undefined : `${this.allowedMimetypes},${this.allowedExtensions}`, onBlur: this.onBlur, onFocus: this.onFocus, onChange: e => this.onChange(e), type: "file", class: {
|
|
1075
1428
|
"duet-upload": true,
|
|
@@ -1082,4 +1435,4 @@ let DuetUpload = class {
|
|
|
1082
1435
|
};
|
|
1083
1436
|
DuetUpload.style = duetUploadCss;
|
|
1084
1437
|
|
|
1085
|
-
export { DuetUpload as duet_upload };
|
|
1438
|
+
export { DuetEditableTable as duet_editable_table, DuetEditableTableItem as duet_editable_table_item, DuetTable as duet_table, DuetUpload as duet_upload };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built with Duet Design System
|
|
3
3
|
*/
|
|
4
|
-
import { r as registerInstance, h, H as Host } from './index-
|
|
4
|
+
import { r as registerInstance, h, H as Host } from './index-e8c7d36f.js';
|
|
5
5
|
import { i as inheritGlobalTheme } from './themeable-component-572685dd.js';
|
|
6
6
|
|
|
7
7
|
const duetEmptyStateCss = "*,*::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;display:block;width:100%;height:100%}.duet-empty-state{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none;width:100%;height:100%;padding:48px;color:#00294d;text-align:center;background:#f5f8fa;border-radius:4px}.duet-empty-state.duet-theme-turva{color:#171c3a;background:#f5f5f7}";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Built with Duet Design System
|
|
3
|
+
*/
|
|
4
|
+
import { r as registerInstance, h, H as Host, g as getElement } from './index-e8c7d36f.js';
|
|
5
|
+
import { c as createID } from './create-id-981107da.js';
|
|
6
|
+
import { i as inheritGlobalTheme } from './themeable-component-572685dd.js';
|
|
7
|
+
|
|
8
|
+
const duetFieldsetCss = "*,*::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;margin-bottom:12px !important;display:block;width:100%}:host(.duet-m-0){margin:0 !important}fieldset{border:0}legend{position:absolute !important;top:0;width:1px !important;height:1px !important;padding:0 !important;overflow:hidden !important;clip:rect(1px, 1px, 1px, 1px) !important;border:0 !important}.duet-legend-wrapper{position:relative;display:block;width:100%;font-family:\"localtapiola-sans\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";font-size:1rem;font-weight:600;line-height:1.5;color:#00294d;text-align:left;background:transparent}.duet-theme-turva .duet-legend-wrapper{font-family:\"turva-sans\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";color:#171c3a}.duet-fieldset-label{margin-bottom:12px !important;margin-top:8px}.duet-legend-has-caption .duet-fieldset-label{margin-bottom:6px !important}.duet-legend-has-tooltip .duet-fieldset-label{padding-right:36px}@media (min-width: 48em){.duet-legend-has-tooltip .duet-fieldset-label{margin-bottom:3px !important;padding-right:0}}@media (min-width: 48em){.duet-legend-has-tooltip.duet-legend-has-caption .duet-fieldset-label{margin-bottom:-3px !important}}.duet-fieldset-caption{margin-bottom:12px !important}.duet-fieldset-help{display:block;font-family:\"localtapiola-sans\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";font-size:0.875rem;font-weight:400;line-height:1.25;color:#de2362;border-radius:4px}.duet-fieldset-help span{display:block;margin-top:12px}.duet-theme-turva .duet-fieldset-help{color:#e02a0d}::slotted(duet-tooltip){position:absolute;top:4px;right:0}@media (min-width: 48em){::slotted(duet-tooltip){position:relative;right:auto}}.duet-legend-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);border:0}";
|
|
9
|
+
|
|
10
|
+
let DuetFieldset = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
registerInstance(this, hostRef);
|
|
13
|
+
this.errorId = createID("DuetError");
|
|
14
|
+
this.labelId = createID("DuetLabel");
|
|
15
|
+
this.hasTooltip = false;
|
|
16
|
+
/**
|
|
17
|
+
* Theme of the fieldset.
|
|
18
|
+
*/
|
|
19
|
+
this.theme = "";
|
|
20
|
+
/**
|
|
21
|
+
* Controls the margin of the component.
|
|
22
|
+
*/
|
|
23
|
+
this.margin = "auto";
|
|
24
|
+
/**
|
|
25
|
+
* Visually hide the label, but still show it to screen readers.
|
|
26
|
+
*/
|
|
27
|
+
this.labelHidden = false;
|
|
28
|
+
this.checkHasTooltip = () => {
|
|
29
|
+
this.hasTooltip = !!this.element.querySelector("[slot='tooltip']");
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Component lifecycle events.
|
|
34
|
+
*/
|
|
35
|
+
componentWillLoad() {
|
|
36
|
+
inheritGlobalTheme(this);
|
|
37
|
+
this.checkHasTooltip();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* render() function
|
|
41
|
+
* Always the last one in the class.
|
|
42
|
+
*/
|
|
43
|
+
render() {
|
|
44
|
+
return (h(Host, { class: { "duet-m-0": this.margin === "none" } }, h("fieldset", { "aria-labelledby": `${this.labelId} ${this.errorId}`, class: {
|
|
45
|
+
"duet-fieldset": true,
|
|
46
|
+
"duet-theme-turva": this.theme === "turva",
|
|
47
|
+
} }, h("legend", { id: this.labelId }, h("span", null, this.label), this.caption && h("span", null, this.caption)), h("div", { class: {
|
|
48
|
+
"duet-legend-wrapper": true,
|
|
49
|
+
"duet-legend-has-caption": !!this.caption,
|
|
50
|
+
"duet-legend-has-tooltip": this.hasTooltip,
|
|
51
|
+
"duet-legend-hidden": this.labelHidden,
|
|
52
|
+
} }, h("div", { class: "duet-fieldset-label" }, h("span", { "aria-hidden": "true" }, this.label), h("slot", { onSlotchange: this.checkHasTooltip, name: "tooltip" })), this.caption && (h("div", { class: "duet-fieldset-caption", "aria-hidden": "true" }, h("duet-caption", { margin: "none" }, this.caption)))), h("slot", null), h("span", { class: "duet-fieldset-help", id: this.errorId, "aria-live": "assertive", "aria-relevant": "additions removals" }, this.error && h("span", null, this.error)))));
|
|
53
|
+
}
|
|
54
|
+
get element() { return getElement(this); }
|
|
55
|
+
};
|
|
56
|
+
DuetFieldset.style = duetFieldsetCss;
|
|
57
|
+
|
|
58
|
+
export { DuetFieldset as duet_fieldset };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built with Duet Design System
|
|
3
3
|
*/
|
|
4
|
-
import { r as registerInstance, c as createEvent$1, h, F as Fragment, g as getElement } from './index-
|
|
4
|
+
import { r as registerInstance, c as createEvent$1, h, F as Fragment, g as getElement } from './index-e8c7d36f.js';
|
|
5
5
|
import { a as actionNewWindowSmall } from './action-new-window-small-1945be91.js';
|
|
6
6
|
import { D as DuetStringsExternalDefaults } from './common-strings-97e04e4b.js';
|
|
7
7
|
import { a as getLanguage, g as getLocaleString } from './language-utils-344d894c.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built with Duet Design System
|
|
3
3
|
*/
|
|
4
|
-
import { r as registerInstance, h, g as getElement, H as Host } from './index-
|
|
4
|
+
import { r as registerInstance, h, g as getElement, H as Host } from './index-e8c7d36f.js';
|
|
5
5
|
import { w as watchForOptions, a as watchForElement } from './watch-options-dd55bce8.js';
|
|
6
6
|
import { i as inheritGlobalTheme } from './themeable-component-572685dd.js';
|
|
7
7
|
|