@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
|
@@ -5,13 +5,342 @@
|
|
|
5
5
|
|
|
6
6
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7
7
|
|
|
8
|
-
const index = require('./index-
|
|
9
|
-
const createId = require('./create-id-c3b984b1.js');
|
|
10
|
-
const jsUtils = require('./js-utils-33a9dbe3.js');
|
|
8
|
+
const index = require('./index-9a57d969.js');
|
|
11
9
|
const languageUtils = require('./language-utils-aa282901.js');
|
|
12
10
|
const themeableComponent = require('./themeable-component-0c1be552.js');
|
|
11
|
+
const tokens_module = require('./tokens.module-6b2df1c2.js');
|
|
12
|
+
const createId = require('./create-id-c3b984b1.js');
|
|
13
13
|
require('./string-utils-267e3dbb.js');
|
|
14
14
|
|
|
15
|
+
const debounce = (func, timeout = 50) => {
|
|
16
|
+
let timer;
|
|
17
|
+
return (...args) => {
|
|
18
|
+
clearTimeout(timer);
|
|
19
|
+
timer = setTimeout(() => {
|
|
20
|
+
func.apply(undefined, args);
|
|
21
|
+
}, timeout);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
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}";
|
|
26
|
+
|
|
27
|
+
let DuetEditableTable = class {
|
|
28
|
+
constructor(hostRef) {
|
|
29
|
+
index.registerInstance(this, hostRef);
|
|
30
|
+
/**
|
|
31
|
+
* State() variables
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
this.tick = Date.now();
|
|
35
|
+
/**
|
|
36
|
+
* Map of items that contain list of things.
|
|
37
|
+
*/
|
|
38
|
+
this.items = new Map();
|
|
39
|
+
/**
|
|
40
|
+
* Array of internationalized defaults for the default groups labels.
|
|
41
|
+
*/
|
|
42
|
+
this.groupsLabelDefaults = {
|
|
43
|
+
fi: "Kaikki",
|
|
44
|
+
en: "All items",
|
|
45
|
+
sv: "Alla objekt",
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Array of internationalized defaults for the default action labels.
|
|
49
|
+
*/
|
|
50
|
+
this.actionLabelDefaults = {
|
|
51
|
+
fi: "Toiminnot",
|
|
52
|
+
en: "Actions",
|
|
53
|
+
sv: "Handlingar",
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Array of group names that you want the editable table to display (can be used to hide or show groups depending on conditions).
|
|
57
|
+
* @default { id: "all", label: this.groupsLabelDefaults, actionLabel: this.actionLabelDefaults }.
|
|
58
|
+
* @example [{ id: "success", label: {fi: "Onnistunut", en: "Success", sv: "Alt klart", }}].
|
|
59
|
+
*/
|
|
60
|
+
this.groups = [
|
|
61
|
+
{ id: "all", label: this.groupsLabelDefaults, actionLabel: this.actionLabelDefaults },
|
|
62
|
+
];
|
|
63
|
+
/**
|
|
64
|
+
* Array of actions that are mapped via the map variable to the various groups defined in group.
|
|
65
|
+
* @default undefined
|
|
66
|
+
* @example [{
|
|
67
|
+
variation: "default",
|
|
68
|
+
icon: "action-edit-2",
|
|
69
|
+
id: "edit",
|
|
70
|
+
map: ["success"],
|
|
71
|
+
label: {
|
|
72
|
+
fi: " Label",
|
|
73
|
+
en: " Label",
|
|
74
|
+
sv: " Label",
|
|
75
|
+
}
|
|
76
|
+
}]
|
|
77
|
+
*/
|
|
78
|
+
this.actions = undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Shows or hides the table labels.
|
|
81
|
+
*/
|
|
82
|
+
this.hideGroups = false;
|
|
83
|
+
/**
|
|
84
|
+
* Exposes the aria role for optimizing accessibility.
|
|
85
|
+
*/
|
|
86
|
+
this.accessibleRole = undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Private methods.
|
|
89
|
+
*/
|
|
90
|
+
this.kick = debounce(() => {
|
|
91
|
+
this.tick = Date.now();
|
|
92
|
+
}, 100); // will trigger re-render
|
|
93
|
+
this.filterMap = needle => {
|
|
94
|
+
if (needle === "all") {
|
|
95
|
+
return Array.from(this.items);
|
|
96
|
+
}
|
|
97
|
+
return Array.from(this.items).filter(item => needle === item[1].group);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Component lifecycle events.
|
|
102
|
+
*/
|
|
103
|
+
componentWillLoad() {
|
|
104
|
+
if (typeof this.groups === "string") {
|
|
105
|
+
this.internalGroupArray = languageUtils.sanitizeString(this.groups);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.internalGroupArray = this.groups;
|
|
109
|
+
}
|
|
110
|
+
if (typeof this.actions === "string") {
|
|
111
|
+
this.internalActionsArray = languageUtils.sanitizeString(this.actions);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.internalActionsArray = this.actions;
|
|
115
|
+
}
|
|
116
|
+
themeableComponent.inheritGlobalTheme(this);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Method to force an update of a tabular data array.
|
|
120
|
+
* when called the method will rerender the entire tabular structure.
|
|
121
|
+
*/
|
|
122
|
+
async updateTable(passedItems = undefined) {
|
|
123
|
+
this.items = new Map(passedItems || this.items);
|
|
124
|
+
this.kick();
|
|
125
|
+
}
|
|
126
|
+
render() {
|
|
127
|
+
return (index.h(index.Host, { class: {
|
|
128
|
+
"duet-theme-turva": this.theme === "turva",
|
|
129
|
+
} }, this.internalGroupArray.map(group => {
|
|
130
|
+
const currentGroup = this.filterMap(group.id);
|
|
131
|
+
if (!currentGroup.length) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
return (index.h("duet-table", { variation: "plain", breakpoint: "none", role: "", margin: this.hideGroups ? "none" : "auto" }, index.h("table", { class: "duet-editable-table", "aria-role": this.accessibleRole }, index.h("thead", { class: "duet-editable-table-header" }, index.h("tr", null, index.h("th", { class: {
|
|
135
|
+
"duet-editable-table-header-hidden": this.hideGroups,
|
|
136
|
+
} }, !this.hideGroups ? (languageUtils.getLocaleString(group.label)) : (index.h("duet-visually-hidden", null, languageUtils.getLocaleString(group.label)))), index.h("th", { class: {
|
|
137
|
+
"duet-editable-table-header-hidden": this.hideGroups,
|
|
138
|
+
} }, index.h("duet-visually-hidden", null, group.actionLabel
|
|
139
|
+
? languageUtils.getLocaleString(group.actionLabel)
|
|
140
|
+
: languageUtils.getLocaleString(this.actionLabelDefaults))))), index.h("tbody", null, currentGroup.map(dataAsArray => {
|
|
141
|
+
const [key, value] = dataAsArray;
|
|
142
|
+
return (index.h("duet-editable-table-item", { keyName: key, data: Object.assign({}, value), groupId: group.id, part: group.id, actions: this.internalActionsArray }));
|
|
143
|
+
})))));
|
|
144
|
+
})));
|
|
145
|
+
}
|
|
146
|
+
get element() { return index.getElement(this); }
|
|
147
|
+
};
|
|
148
|
+
DuetEditableTable.style = duetEditableTableCss;
|
|
149
|
+
|
|
150
|
+
//simple functional component that renders the data in the table
|
|
151
|
+
const TableData = ({ data, groupId }, _children) => {
|
|
152
|
+
if (typeof data === "string") {
|
|
153
|
+
return index.h("td", { innerHTML: data, class: "duet-editable-table-content", part: `${groupId}content` });
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
return (index.h("td", { class: "duet-editable-table-content", part: `${groupId}content` }, data));
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
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}";
|
|
161
|
+
|
|
162
|
+
let DuetEditableTableItem = class {
|
|
163
|
+
constructor(hostRef) {
|
|
164
|
+
index.registerInstance(this, hostRef);
|
|
165
|
+
this.duetEditableItemAction = index.createEvent(this, "duetEditableItemAction", 7);
|
|
166
|
+
this.isHovering = false;
|
|
167
|
+
/**
|
|
168
|
+
* Theme of the empty state component.
|
|
169
|
+
*/
|
|
170
|
+
this.theme = "";
|
|
171
|
+
/**
|
|
172
|
+
* Actions that can be performed on the element
|
|
173
|
+
*/
|
|
174
|
+
this.actions = undefined;
|
|
175
|
+
/**
|
|
176
|
+
* GroupId used to pierce the shadowdom - gets concatenated with "content & actions" and used as part="groupIDcontent/actions" to pierce the content/Action item
|
|
177
|
+
* @internal
|
|
178
|
+
*/
|
|
179
|
+
this.groupId = "";
|
|
180
|
+
/**
|
|
181
|
+
* Key used to identify item, when running actions
|
|
182
|
+
*/
|
|
183
|
+
this.keyName = "";
|
|
184
|
+
/**
|
|
185
|
+
* Object of data itemsused to render the entire row
|
|
186
|
+
*/
|
|
187
|
+
this.data = undefined;
|
|
188
|
+
}
|
|
189
|
+
watchPropHandler(_newValue, _oldValue) {
|
|
190
|
+
// console.log("The new value of activated is: ", _newValue)
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
/**
|
|
194
|
+
* Component lifecycle events.
|
|
195
|
+
*/
|
|
196
|
+
componentWillLoad() {
|
|
197
|
+
themeableComponent.inheritGlobalTheme(this);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
/**
|
|
201
|
+
* private functions
|
|
202
|
+
*/
|
|
203
|
+
/**
|
|
204
|
+
* render() function
|
|
205
|
+
* Always the last one in the class.
|
|
206
|
+
*/
|
|
207
|
+
render() {
|
|
208
|
+
return (index.h(index.Host, { role: "row" }, index.h(TableData, { data: this.data.item, groupId: this.groupId }), index.h("td", { class: "duet-editable-table-actions" }, index.h("div", { class: "duet-editable-table-actions-items", part: `${this.groupId}actions` }, this.actions.map(result => {
|
|
209
|
+
const { map = undefined } = result;
|
|
210
|
+
// if map has been specified, only show the current action if groupID matches the map array
|
|
211
|
+
if (map && !map.includes(this.groupId)) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
return (index.h("duet-editable-table-button", { keyName: this.keyName, group: this.data.group, uid: this.data.uid, actions: result, theme: this.theme }));
|
|
215
|
+
})))));
|
|
216
|
+
}
|
|
217
|
+
get el() { return index.getElement(this); }
|
|
218
|
+
static get watchers() { return {
|
|
219
|
+
"data": ["watchPropHandler"]
|
|
220
|
+
}; }
|
|
221
|
+
};
|
|
222
|
+
DuetEditableTableItem.style = duetEditableTableItemCss;
|
|
223
|
+
|
|
224
|
+
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)}";
|
|
225
|
+
|
|
226
|
+
// remove wrapping speech marks.
|
|
227
|
+
// media query tokens are wrapped in speech marks,
|
|
228
|
+
// which need to be removed before use with matchMedia.
|
|
229
|
+
const unwrap = (str) => str.substring(1, str.length - 1);
|
|
230
|
+
const breakpointToToken = {
|
|
231
|
+
none: "all",
|
|
232
|
+
"none-scrollable": "all",
|
|
233
|
+
small: unwrap(tokens_module.mediaQuerySmall),
|
|
234
|
+
medium: unwrap(tokens_module.mediaQueryMedium),
|
|
235
|
+
large: unwrap(tokens_module.mediaQueryLarge),
|
|
236
|
+
"x-large": unwrap(tokens_module.mediaQueryXLarge),
|
|
237
|
+
"xx-large": unwrap(tokens_module.mediaQueryXxLarge),
|
|
238
|
+
"xxx-large": unwrap(tokens_module.mediaQueryXxxLarge),
|
|
239
|
+
};
|
|
240
|
+
const stickyTopValues = {
|
|
241
|
+
none: 0,
|
|
242
|
+
"with-links": parseFloat(tokens_module.sizeNavigation) * 16,
|
|
243
|
+
"without-links": parseFloat(tokens_module.sizeHeader) * 16,
|
|
244
|
+
};
|
|
245
|
+
let DuetTable = class {
|
|
246
|
+
constructor(hostRef) {
|
|
247
|
+
index.registerInstance(this, hostRef);
|
|
248
|
+
/**
|
|
249
|
+
* 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.
|
|
250
|
+
*/
|
|
251
|
+
this.matchesBreakpoint = true;
|
|
252
|
+
/**
|
|
253
|
+
* Controls the margin of the component.
|
|
254
|
+
*/
|
|
255
|
+
this.margin = "auto";
|
|
256
|
+
/**
|
|
257
|
+
* Style variation of the table.
|
|
258
|
+
*/
|
|
259
|
+
this.variation = "striped";
|
|
260
|
+
/**
|
|
261
|
+
* Controls whether the table has a sticky header.
|
|
262
|
+
* Sticky headers are not compatible with breakpoint="none-scrollable".
|
|
263
|
+
*/
|
|
264
|
+
this.sticky = false;
|
|
265
|
+
/**
|
|
266
|
+
* Adjust the distance from top of the viewport (in pixels) when the
|
|
267
|
+
* table header becomes sticky.
|
|
268
|
+
*/
|
|
269
|
+
this.stickyDistance = "with-links";
|
|
270
|
+
/**
|
|
271
|
+
* By default the table is responsive - it will be flattened at narrow viewport widths.
|
|
272
|
+
* This prop controls the breakpoint at which the table should be rendered as a _regular_ table.
|
|
273
|
+
* Set to "none" to disable the responsive functionality.
|
|
274
|
+
* Set to "none-scrollable" to disable responsive functionality _and_ allow horizontal scrolling -
|
|
275
|
+
* this is useful for comparison tables where it's important to maintain column and row layout.
|
|
276
|
+
*/
|
|
277
|
+
this.breakpoint = "small";
|
|
278
|
+
this.handleMediaQueryChange = (mq) => {
|
|
279
|
+
this.matchesBreakpoint = mq.matches;
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
connectedCallback() {
|
|
283
|
+
this.mq = matchMedia(breakpointToToken[this.breakpoint]);
|
|
284
|
+
this.mq.addListener(this.handleMediaQueryChange);
|
|
285
|
+
this.handleMediaQueryChange(this.mq);
|
|
286
|
+
this.observer = new MutationObserver(() => this.copyHeadingsToCells());
|
|
287
|
+
this.observer.observe(this.element, {
|
|
288
|
+
childList: true,
|
|
289
|
+
subtree: true,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
componentWillLoad() {
|
|
293
|
+
themeableComponent.inheritGlobalTheme(this);
|
|
294
|
+
this.copyHeadingsToCells();
|
|
295
|
+
if (this.sticky && this.breakpoint === "none-scrollable") {
|
|
296
|
+
console.warn(`[DUET WARNING]: sticky and breakpoint="none-scrollable" are incompatible. Scrollable takes precedence`);
|
|
297
|
+
}
|
|
298
|
+
if (this.sticky) {
|
|
299
|
+
const stickyTop = stickyTopValues[this.stickyDistance];
|
|
300
|
+
const headingElements = this.element.querySelectorAll("thead th");
|
|
301
|
+
headingElements.forEach(th => (th.style.top = `${stickyTop}px`));
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
componentDidLoad() {
|
|
305
|
+
// this clears all pending mutations,
|
|
306
|
+
// that way we avoid dealing with any initial changes
|
|
307
|
+
// and only get genuine mutations as rows are added/removed
|
|
308
|
+
this.observer.takeRecords();
|
|
309
|
+
}
|
|
310
|
+
disconnectedCallback() {
|
|
311
|
+
this.observer.disconnect();
|
|
312
|
+
this.observer = null;
|
|
313
|
+
this.mq.removeListener(this.handleMediaQueryChange);
|
|
314
|
+
this.mq = null;
|
|
315
|
+
this.matchesBreakpoint = true;
|
|
316
|
+
}
|
|
317
|
+
copyHeadingsToCells() {
|
|
318
|
+
const headingElements = this.element.querySelectorAll("thead th");
|
|
319
|
+
const rowElements = this.element.querySelectorAll("tbody tr");
|
|
320
|
+
const headings = Array.from(headingElements).map(th => th.textContent.trim());
|
|
321
|
+
rowElements.forEach(tr => {
|
|
322
|
+
tr.querySelectorAll("td").forEach((td, i) => {
|
|
323
|
+
if (headings[i]) {
|
|
324
|
+
td.dataset.heading = headings[i];
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
render() {
|
|
330
|
+
return (index.h(index.Host, { class: {
|
|
331
|
+
[`duet-table-${this.variation}`]: true,
|
|
332
|
+
"duet-table-flattened": !this.matchesBreakpoint,
|
|
333
|
+
// sticky only valid when in regular table layout
|
|
334
|
+
"duet-table-sticky": this.matchesBreakpoint && this.sticky,
|
|
335
|
+
"duet-table-scrollable": this.breakpoint === "none-scrollable",
|
|
336
|
+
"duet-m-0": this.margin === "none",
|
|
337
|
+
"duet-theme-turva": this.theme === "turva",
|
|
338
|
+
} }, index.h("slot", null)));
|
|
339
|
+
}
|
|
340
|
+
get element() { return index.getElement(this); }
|
|
341
|
+
};
|
|
342
|
+
DuetTable.style = duetTableCss;
|
|
343
|
+
|
|
15
344
|
const errorCodes = [
|
|
16
345
|
{
|
|
17
346
|
type: "default",
|
|
@@ -364,7 +693,7 @@ let DuetUpload = class {
|
|
|
364
693
|
this.filesInProgress = new Map();
|
|
365
694
|
this.fileMaxReached = false;
|
|
366
695
|
this.bytesMaxReached = false;
|
|
367
|
-
|
|
696
|
+
this.internalStatusMessageLabel = undefined;
|
|
368
697
|
/**
|
|
369
698
|
* Properties
|
|
370
699
|
*/
|
|
@@ -383,12 +712,12 @@ let DuetUpload = class {
|
|
|
383
712
|
*/
|
|
384
713
|
this.external = false;
|
|
385
714
|
/**
|
|
386
|
-
* If set the upload component will not display an upload button, you will have to create
|
|
387
|
-
* and call the exposed
|
|
715
|
+
* If set the upload component will not display an upload button, you will have to create one yourself
|
|
716
|
+
* and call the exposed method startUpload
|
|
388
717
|
*/
|
|
389
718
|
this.hideButton = false;
|
|
390
719
|
/**
|
|
391
|
-
* Default actions added to
|
|
720
|
+
* Default actions added to the internally used duet-editable-table
|
|
392
721
|
*/
|
|
393
722
|
this.actions = [
|
|
394
723
|
{
|
|
@@ -417,17 +746,43 @@ let DuetUpload = class {
|
|
|
417
746
|
},
|
|
418
747
|
];
|
|
419
748
|
/**
|
|
420
|
-
* If enabled the
|
|
749
|
+
* If enabled the editable-table will display links on successfully uploaded items,
|
|
421
750
|
* this requires the server can respond with link URIs in the correct format
|
|
751
|
+
* and that the files are accessible to the user
|
|
422
752
|
*/
|
|
423
753
|
this.showLinks = false;
|
|
424
754
|
/**
|
|
425
755
|
* Property to change the aria upload progress text read aloud by screenreaders
|
|
426
756
|
* @default {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
757
|
+
* fi: {
|
|
758
|
+
* inProgress: "Lähetetään {filesUploaded} lähetettävästä {filesTotal} tiedostosta",
|
|
759
|
+
* inProgressWithErrors:
|
|
760
|
+
* "Lähetetään {filesInProgress} tiedostoa, lähetetty {filesUploaded} lähetettävästä {filesTotal} tiedostosta, {filesWithErrors} tiedostossa on virheitä",
|
|
761
|
+
* done: "Kaikki {filesTotal} tiedostoa lähetetty onnistuneesti",
|
|
762
|
+
* doneWithErrors:
|
|
763
|
+
* "Lähetys valmis, {filesUploaded} tiedostoa on lähetetty onnistuneesti, {filesWithErrors} tiedostossa oli virheitä",
|
|
764
|
+
* files: "tiedostot",
|
|
765
|
+
* file: "tiedosto",
|
|
766
|
+
* },
|
|
767
|
+
* sv: {
|
|
768
|
+
* inProgress: "Adding {filesUploaded} of {filesTotal}",
|
|
769
|
+
* inProgressWithErrors:
|
|
770
|
+
* "Laddar upp {filesInProgress}, {filesUploaded} uppladdad av {filesTotal}, {filesWithErrors} misslyckades",
|
|
771
|
+
* done: "Alla {filesTotal} har lagts till",
|
|
772
|
+
* doneWithErrors: "Handling slutförd, {filesUploaded} har lagts till, {filesWithErrors} misslyckades",
|
|
773
|
+
* files: "filer",
|
|
774
|
+
* file: "fil",
|
|
775
|
+
* },
|
|
776
|
+
* en: {
|
|
777
|
+
* inProgress: "Adding {filesUploaded} of {filesTotal}",
|
|
778
|
+
* inProgressWithErrors:
|
|
779
|
+
* "Uploading {filesInProgress}, {filesUploaded} uploaded of {filesTotal}, {filesWithErrors} failed",
|
|
780
|
+
* done: "All {filesTotal} added successfully",
|
|
781
|
+
* doneWithErrors: "Action completed, {filesUploaded} has been added successfully, {filesWithErrors} had errors",
|
|
782
|
+
* files: "tiedostoa",
|
|
783
|
+
* file: "tiedosto",
|
|
784
|
+
* },
|
|
785
|
+
* }
|
|
431
786
|
*/
|
|
432
787
|
this.statusLabelDefaults = {
|
|
433
788
|
fi: {
|
|
@@ -460,8 +815,7 @@ let DuetUpload = class {
|
|
|
460
815
|
*/
|
|
461
816
|
this.statusMessageLabel = languageUtils.getLocaleString(this.statusLabelDefaults);
|
|
462
817
|
/**
|
|
463
|
-
* Property to change
|
|
464
|
-
* normally you would handle these strings on an application level and override @label when needed
|
|
818
|
+
* Property to change button label defaults on the component.
|
|
465
819
|
* @default {
|
|
466
820
|
fi: "Lisää liite",
|
|
467
821
|
sv: "Lägg till en bilaga",
|
|
@@ -479,7 +833,7 @@ let DuetUpload = class {
|
|
|
479
833
|
*/
|
|
480
834
|
this.buttonLabel = languageUtils.getLocaleString(this.buttonLabelDefaults);
|
|
481
835
|
/**
|
|
482
|
-
* accessible Label of button
|
|
836
|
+
* accessible aria-Label of button
|
|
483
837
|
*/
|
|
484
838
|
this.accessibleButtonLabel = undefined;
|
|
485
839
|
/**
|
|
@@ -511,7 +865,7 @@ let DuetUpload = class {
|
|
|
511
865
|
*/
|
|
512
866
|
this.files = new Map();
|
|
513
867
|
/**
|
|
514
|
-
* Property to read if
|
|
868
|
+
* Property to read if the internally used editable-table contains errors or not
|
|
515
869
|
*/
|
|
516
870
|
this.valid = !this.required;
|
|
517
871
|
/**
|
|
@@ -531,7 +885,6 @@ let DuetUpload = class {
|
|
|
531
885
|
this.label = languageUtils.getLocaleString(this.labelDefaults);
|
|
532
886
|
/**
|
|
533
887
|
* Property to change descriptionDefaults defaults on the component.
|
|
534
|
-
* normally you would handle these strings on an application level and override @label when needed
|
|
535
888
|
* @default {
|
|
536
889
|
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
890
|
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.",
|
|
@@ -605,7 +958,6 @@ let DuetUpload = class {
|
|
|
605
958
|
* by default this is off, setting this to true will limit the users choices to what has been explicitly set
|
|
606
959
|
*/
|
|
607
960
|
this.limitSelection = false;
|
|
608
|
-
//region Private functions
|
|
609
961
|
/**
|
|
610
962
|
* Private functions
|
|
611
963
|
*/
|
|
@@ -690,7 +1042,7 @@ let DuetUpload = class {
|
|
|
690
1042
|
});
|
|
691
1043
|
return itemData;
|
|
692
1044
|
};
|
|
693
|
-
this.kick =
|
|
1045
|
+
this.kick = debounce(() => {
|
|
694
1046
|
this.tick = Date.now();
|
|
695
1047
|
}, 30); // will trigger re-render
|
|
696
1048
|
this.genHashName = () => Date.now().toString(36) + Math.random();
|
|
@@ -703,7 +1055,6 @@ let DuetUpload = class {
|
|
|
703
1055
|
}
|
|
704
1056
|
};
|
|
705
1057
|
this.updateProgress = (ev, name) => {
|
|
706
|
-
console.log(this.filesInProgress.size);
|
|
707
1058
|
const updateProgressHelper = percentComplete => {
|
|
708
1059
|
this.updateValueInMap(name, "progress", percentComplete);
|
|
709
1060
|
this.onProgress(name, percentComplete, ev);
|
|
@@ -747,6 +1098,10 @@ let DuetUpload = class {
|
|
|
747
1098
|
* We reset the form fields to always be able to re-upload files
|
|
748
1099
|
* and because we handle all uploads and states internally in the component (not relying on native form elements)
|
|
749
1100
|
*/
|
|
1101
|
+
/* TODO: it may be a good idea to just update the list so that this always matches what is in the files map,
|
|
1102
|
+
* 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
|
|
1103
|
+
* TODO: but for now we'll just reset the form fields
|
|
1104
|
+
*/
|
|
750
1105
|
this.nativeInput.value = "";
|
|
751
1106
|
};
|
|
752
1107
|
this.startUpload = async (ev, metaData = undefined) => {
|
|
@@ -758,8 +1113,6 @@ let DuetUpload = class {
|
|
|
758
1113
|
ev.preventDefault();
|
|
759
1114
|
return;
|
|
760
1115
|
};
|
|
761
|
-
//endregion
|
|
762
|
-
//region Eventlisteners for the XHR requests
|
|
763
1116
|
/**
|
|
764
1117
|
* Eventlisteners for the XHR requests
|
|
765
1118
|
*/
|
|
@@ -888,11 +1241,16 @@ let DuetUpload = class {
|
|
|
888
1241
|
this.kick();
|
|
889
1242
|
}
|
|
890
1243
|
}
|
|
891
|
-
//endregion
|
|
892
1244
|
/**
|
|
893
1245
|
* Component lifecycle events.
|
|
894
1246
|
*/
|
|
895
1247
|
componentWillLoad() {
|
|
1248
|
+
if (typeof this.statusMessageLabel === "string") {
|
|
1249
|
+
this.internalStatusMessageLabel = languageUtils.sanitizeString(this.groups);
|
|
1250
|
+
}
|
|
1251
|
+
else {
|
|
1252
|
+
this.internalStatusMessageLabel = this.statusMessageLabel;
|
|
1253
|
+
}
|
|
896
1254
|
themeableComponent.inheritGlobalTheme(this);
|
|
897
1255
|
this.listenForActionEvents();
|
|
898
1256
|
}
|
|
@@ -900,8 +1258,6 @@ let DuetUpload = class {
|
|
|
900
1258
|
// listen to the events from the component
|
|
901
1259
|
this.verifyValidity();
|
|
902
1260
|
}
|
|
903
|
-
//endregion
|
|
904
|
-
//region XHR requests
|
|
905
1261
|
/**
|
|
906
1262
|
* XHR request utilities
|
|
907
1263
|
*/
|
|
@@ -949,8 +1305,6 @@ let DuetUpload = class {
|
|
|
949
1305
|
onProgress: this.trackProgress,
|
|
950
1306
|
});
|
|
951
1307
|
}
|
|
952
|
-
//endregion
|
|
953
|
-
//region EventHandlers
|
|
954
1308
|
/**
|
|
955
1309
|
* Component event handling.
|
|
956
1310
|
*/
|
|
@@ -1025,7 +1379,6 @@ let DuetUpload = class {
|
|
|
1025
1379
|
component: "duet-upload",
|
|
1026
1380
|
});
|
|
1027
1381
|
}
|
|
1028
|
-
//endregion
|
|
1029
1382
|
/**
|
|
1030
1383
|
* Sets focus on the specified `duet-input`. Use this method instead of the global
|
|
1031
1384
|
* `input.focus()`.
|
|
@@ -1055,7 +1408,7 @@ let DuetUpload = class {
|
|
|
1055
1408
|
return this.getFilesAsArray();
|
|
1056
1409
|
}
|
|
1057
1410
|
/**
|
|
1058
|
-
* Convenience method for updating
|
|
1411
|
+
* Convenience method for updating the value of a key:value inside an item in the files attribute
|
|
1059
1412
|
*/
|
|
1060
1413
|
async updateValue(item, key, value) {
|
|
1061
1414
|
this.updateValueInMap(item, key, value);
|
|
@@ -1073,7 +1426,7 @@ let DuetUpload = class {
|
|
|
1073
1426
|
"duet-upload-filelist-empty": !this.files.size,
|
|
1074
1427
|
"duet-upload-filelist": true,
|
|
1075
1428
|
"duet-upload-filelist-filled": this.files.size,
|
|
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.
|
|
1429
|
+
}, 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.internalStatusMessageLabel })), !!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 => {
|
|
1077
1430
|
this.nativeInput = input;
|
|
1078
1431
|
}, accept: !this.limitSelection ? undefined : `${this.allowedMimetypes},${this.allowedExtensions}`, onBlur: this.onBlur, onFocus: this.onFocus, onChange: e => this.onChange(e), type: "file", class: {
|
|
1079
1432
|
"duet-upload": true,
|
|
@@ -1086,4 +1439,7 @@ let DuetUpload = class {
|
|
|
1086
1439
|
};
|
|
1087
1440
|
DuetUpload.style = duetUploadCss;
|
|
1088
1441
|
|
|
1442
|
+
exports.duet_editable_table = DuetEditableTable;
|
|
1443
|
+
exports.duet_editable_table_item = DuetEditableTableItem;
|
|
1444
|
+
exports.duet_table = DuetTable;
|
|
1089
1445
|
exports.duet_upload = DuetUpload;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7
7
|
|
|
8
|
-
const index = require('./index-
|
|
8
|
+
const index = require('./index-9a57d969.js');
|
|
9
9
|
const themeableComponent = require('./themeable-component-0c1be552.js');
|
|
10
10
|
|
|
11
11
|
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,62 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Built with Duet Design System
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7
|
+
|
|
8
|
+
const index = require('./index-9a57d969.js');
|
|
9
|
+
const createId = require('./create-id-c3b984b1.js');
|
|
10
|
+
const themeableComponent = require('./themeable-component-0c1be552.js');
|
|
11
|
+
|
|
12
|
+
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}";
|
|
13
|
+
|
|
14
|
+
let DuetFieldset = class {
|
|
15
|
+
constructor(hostRef) {
|
|
16
|
+
index.registerInstance(this, hostRef);
|
|
17
|
+
this.errorId = createId.createID("DuetError");
|
|
18
|
+
this.labelId = createId.createID("DuetLabel");
|
|
19
|
+
this.hasTooltip = false;
|
|
20
|
+
/**
|
|
21
|
+
* Theme of the fieldset.
|
|
22
|
+
*/
|
|
23
|
+
this.theme = "";
|
|
24
|
+
/**
|
|
25
|
+
* Controls the margin of the component.
|
|
26
|
+
*/
|
|
27
|
+
this.margin = "auto";
|
|
28
|
+
/**
|
|
29
|
+
* Visually hide the label, but still show it to screen readers.
|
|
30
|
+
*/
|
|
31
|
+
this.labelHidden = false;
|
|
32
|
+
this.checkHasTooltip = () => {
|
|
33
|
+
this.hasTooltip = !!this.element.querySelector("[slot='tooltip']");
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Component lifecycle events.
|
|
38
|
+
*/
|
|
39
|
+
componentWillLoad() {
|
|
40
|
+
themeableComponent.inheritGlobalTheme(this);
|
|
41
|
+
this.checkHasTooltip();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* render() function
|
|
45
|
+
* Always the last one in the class.
|
|
46
|
+
*/
|
|
47
|
+
render() {
|
|
48
|
+
return (index.h(index.Host, { class: { "duet-m-0": this.margin === "none" } }, index.h("fieldset", { "aria-labelledby": `${this.labelId} ${this.errorId}`, class: {
|
|
49
|
+
"duet-fieldset": true,
|
|
50
|
+
"duet-theme-turva": this.theme === "turva",
|
|
51
|
+
} }, index.h("legend", { id: this.labelId }, index.h("span", null, this.label), this.caption && index.h("span", null, this.caption)), index.h("div", { class: {
|
|
52
|
+
"duet-legend-wrapper": true,
|
|
53
|
+
"duet-legend-has-caption": !!this.caption,
|
|
54
|
+
"duet-legend-has-tooltip": this.hasTooltip,
|
|
55
|
+
"duet-legend-hidden": this.labelHidden,
|
|
56
|
+
} }, index.h("div", { class: "duet-fieldset-label" }, index.h("span", { "aria-hidden": "true" }, this.label), index.h("slot", { onSlotchange: this.checkHasTooltip, name: "tooltip" })), this.caption && (index.h("div", { class: "duet-fieldset-caption", "aria-hidden": "true" }, index.h("duet-caption", { margin: "none" }, this.caption)))), index.h("slot", null), index.h("span", { class: "duet-fieldset-help", id: this.errorId, "aria-live": "assertive", "aria-relevant": "additions removals" }, this.error && index.h("span", null, this.error)))));
|
|
57
|
+
}
|
|
58
|
+
get element() { return index.getElement(this); }
|
|
59
|
+
};
|
|
60
|
+
DuetFieldset.style = duetFieldsetCss;
|
|
61
|
+
|
|
62
|
+
exports.duet_fieldset = DuetFieldset;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7
7
|
|
|
8
|
-
const index = require('./index-
|
|
8
|
+
const index = require('./index-9a57d969.js');
|
|
9
9
|
const actionNewWindowSmall = require('./action-new-window-small-fa51dfb9.js');
|
|
10
10
|
const commonStrings = require('./common-strings-de17f887.js');
|
|
11
11
|
const languageUtils = require('./language-utils-aa282901.js');
|