@oslokommune/punkt-elements 18.3.1 → 18.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/dist/{accordion-4eAsO-Sr.js → accordion-D814csFx.js} +6 -6
- package/dist/{accordion-DOa5vubf.cjs → accordion-E0-pLzBq.cjs} +6 -6
- package/dist/{alert-DKNJTlMQ.js → alert-DNZtr3gd.js} +39 -31
- package/dist/alert-DqM9l5as.cjs +40 -0
- package/dist/{backlink-CA5R69FX.cjs → backlink-DYO8qA9C.cjs} +1 -1
- package/dist/{button-Dqolsuwj.js → button-Drwt7Qe5.js} +29 -26
- package/dist/button-jJfzE9C7.cjs +32 -0
- package/dist/{card-DgRvtnnk.js → card-BhmJZOGh.js} +90 -70
- package/dist/card-D-1JMn_h.cjs +64 -0
- package/dist/{combobox-q8kzy-S_.js → combobox-BNstYIC5.js} +20 -20
- package/dist/{combobox-D3zyAi_o.cjs → combobox-CRdBlMz1.cjs} +17 -17
- package/dist/components/alert/alert.d.ts +2 -0
- package/dist/components/button/button.d.ts +4 -21
- package/dist/components/button/index.d.ts +1 -1
- package/dist/components/card/card.d.ts +12 -3
- package/dist/components/index.d.ts +1 -1
- package/dist/components/linkcard/linkcard.d.ts +1 -1
- package/dist/components/loader/loader.d.ts +2 -2
- package/dist/components/messagebox/messagebox.d.ts +1 -1
- package/dist/components/progressbar/progressbar.d.ts +2 -6
- package/dist/{consent-Cqetmc5Q.cjs → consent-DaOFbopy.cjs} +1 -1
- package/dist/{consent-Dkyp-UbI.js → consent-Yvw7gZI_.js} +1 -1
- package/dist/{datepicker-8KnaI9Xj.cjs → datepicker-DjvL_Nb8.cjs} +16 -16
- package/dist/{datepicker-9ulmApjN.js → datepicker-DzTdWHkX.js} +3 -3
- package/dist/docs/components/button.d.ts +0 -1
- package/dist/{fileupload-XQAilDRd.js → fileupload-B8Uhfx2d.js} +24 -24
- package/dist/{fileupload-EWBE4h3V.cjs → fileupload-BJVYPl8u.cjs} +15 -15
- package/dist/{footer-BpuYmm5V.cjs → footer-BGC5PkLa.cjs} +1 -1
- package/dist/{footer-BXmN43ol.js → footer-BPxKLaut.js} +2 -2
- package/dist/{header-BPQHiw4v.js → header-BPzlBRhY.js} +30 -30
- package/dist/{header-BQ32MqUl.cjs → header-CAqegPzW.cjs} +34 -34
- package/dist/{header-menu-DpQbRKcm.cjs → header-menu-DBy7Yrd_.cjs} +1 -1
- package/dist/{header-menu-Dgem4HO9.js → header-menu-DWiPoQ58.js} +1 -1
- package/dist/{helptext-Ds8Q9IGV.cjs → helptext-BwDhf6VB.cjs} +2 -2
- package/dist/{helptext-BzLJKMMO.js → helptext-mf-67-fv.js} +2 -2
- package/dist/{input-wrapper-DzEgz7nZ.js → input-wrapper-BetB7OLQ.js} +16 -15
- package/dist/{input-wrapper-B0eSdZs3.cjs → input-wrapper-CS0qrYcm.cjs} +8 -7
- package/dist/{link-CpwR3BLX.cjs → link-DXnoMJIo.cjs} +3 -3
- package/dist/{link-C9xAIILf.js → link-DkO7a3Fs.js} +3 -3
- package/dist/{linkcard-Bzv3CEw5.cjs → linkcard-2l6z1M2U.cjs} +3 -3
- package/dist/{linkcard-C6ljKc0B.js → linkcard-aVKL5JPP.js} +8 -8
- package/dist/{loader-D6dau_7w.js → loader-CRVUJ-HU.js} +1 -1
- package/dist/{loader-Bv-1vwju.cjs → loader-D23kzlaR.cjs} +1 -1
- package/dist/{messagebox-CmhjIh0n.js → messagebox-CqI6_Ah7.js} +2 -2
- package/dist/{messagebox-DNUfv2FN.cjs → messagebox-DP06cyqc.cjs} +1 -1
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +1 -1
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +1 -1
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-header-menu.cjs +1 -1
- package/dist/pkt-header-menu.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +31 -31
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +1 -1
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +1 -1
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +1 -1
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +1 -1
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-searchinput.cjs +1 -1
- package/dist/pkt-searchinput.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +1 -1
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/progressbar-BPHLC7ce.js +117 -0
- package/dist/progressbar-BpcsDCnG.cjs +31 -0
- package/dist/{radiobutton-B_j_nYCC.js → radiobutton-B2e9Vyp8.js} +0 -1
- package/dist/{radiobutton-DsL-FNDd.cjs → radiobutton-C3nmL9rA.cjs} +0 -1
- package/dist/{searchinput-Dm3T0tGS.cjs → searchinput-CiPB8xvh.cjs} +3 -2
- package/dist/{searchinput-D7Dd2W2z.js → searchinput-DrUcPajl.js} +14 -12
- package/dist/{select-BqAZsLKy.js → select-B7TvZGIL.js} +15 -16
- package/dist/{select-VqzZdE-T.cjs → select-qxjHJ8bu.cjs} +13 -14
- package/dist/shared-types/button.d.ts +45 -0
- package/dist/shared-types/index.d.ts +2 -0
- package/dist/{tabs-DPdDkHSk.js → tabs-C_tCCdBK.js} +18 -18
- package/dist/{tabs-nvIpMwHK.cjs → tabs-DBanbSG1.cjs} +15 -15
- package/dist/tag-BDlwKjgT.cjs +27 -0
- package/dist/{tag-DBCzfbPE.js → tag-CdiDs9zb.js} +10 -10
- package/dist/{textarea-D17CiySU.cjs → textarea-DgFwd2LY.cjs} +10 -10
- package/dist/{textarea-C0a-K05x.js → textarea-YL6JYsB5.js} +14 -14
- package/dist/{textinput-D0QasOZ9.cjs → textinput-CIxMtaIo.cjs} +10 -10
- package/dist/{textinput-DKl04Y3e.js → textinput-CrJYDOHb.js} +12 -12
- package/dist/{timepicker-DVvI4uEk.js → timepicker-BHWOqlr8.js} +11 -11
- package/dist/{timepicker-BcnFL6Bj.cjs → timepicker-avaMu1hN.cjs} +8 -8
- package/package.json +2 -2
- package/src/components/accordion/accordion.ts +2 -1
- package/src/components/alert/alert.test.ts +2 -1
- package/src/components/alert/alert.ts +21 -3
- package/src/components/button/button.test.ts +0 -3
- package/src/components/button/button.ts +57 -62
- package/src/components/button/index.ts +0 -2
- package/src/components/card/card.test.ts +7 -7
- package/src/components/card/card.ts +99 -80
- package/src/components/helptext/helptext.ts +2 -2
- package/src/components/index.ts +0 -2
- package/src/components/input-wrapper/input-wrapper.ts +1 -0
- package/src/components/link/link.ts +4 -2
- package/src/components/linkcard/linkcard.test.ts +3 -3
- package/src/components/linkcard/linkcard.ts +1 -1
- package/src/components/loader/loader.test.ts +1 -1
- package/src/components/loader/loader.ts +3 -3
- package/src/components/messagebox/messagebox.test.ts +1 -1
- package/src/components/messagebox/messagebox.ts +2 -2
- package/src/components/progressbar/progressbar.test.ts +10 -8
- package/src/components/progressbar/progressbar.ts +63 -84
- package/src/components/radiobutton/radiobutton.ts +0 -1
- package/src/components/searchinput/searchinput.ts +3 -1
- package/src/components/select/select.test.ts +2 -1
- package/src/components/select/select.ts +0 -1
- package/dist/alert-BlHM1zEi.cjs +0 -35
- package/dist/button-CVMhQT3X.cjs +0 -30
- package/dist/card-DMKvuvNv.cjs +0 -87
- package/dist/progressbar-Bk_RsEjW.js +0 -112
- package/dist/progressbar-T5_MpZGN.cjs +0 -17
- package/dist/tag-Bp9gJnYh.cjs +0 -27
- package/dist/{backlink-BYUtL8cO.js → backlink-BHtxOlTw.js} +1 -1
|
@@ -1,38 +1,21 @@
|
|
|
1
1
|
import { PktElementWithSlot } from '../../base-elements/element-with-slot';
|
|
2
2
|
import { PktIconName } from '@oslokommune/punkt-assets/dist/icons/icon';
|
|
3
|
-
import { Booleanish, THTMLButtonType } from '../../shared-types';
|
|
3
|
+
import { Booleanish, IPktButtonBase, TPktButtonSize, TPktButtonColor, TPktButtonSkin, TPktButtonVariant, TPktButtonState, THTMLButtonType } from '../../shared-types';
|
|
4
4
|
import { PropertyValues } from 'lit';
|
|
5
|
-
export type
|
|
6
|
-
export
|
|
7
|
-
export type TPktButtonColor = 'blue' | 'blue-outline' | 'green' | 'green-outline' | 'green-dark' | 'green-dark-outline' | 'beige-light' | 'beige-dark-outline' | 'yellow' | 'yellow-outline' | 'red' | 'red-outline';
|
|
8
|
-
export type TPktButtonSkin = 'primary' | 'secondary' | 'tertiary';
|
|
9
|
-
export type TPktButtonVariant = 'label-only' | 'icon-left' | 'icon-right' | 'icon-only' | 'icons-right-and-left';
|
|
10
|
-
export type TPktButtonState = 'normal' | 'focus' | 'hover' | 'active';
|
|
11
|
-
export type TPktButtonType = THTMLButtonType;
|
|
12
|
-
export interface IPktButton {
|
|
5
|
+
export type { TPktButtonSize, TPktButtonColor, TPktButtonSkin, TPktButtonVariant, TPktButtonState, };
|
|
6
|
+
export interface IPktButton extends Omit<IPktButtonBase, 'iconName' | 'secondIconName' | 'fullWidth' | 'fullWidthOnMobile' | 'isLoading' | 'disabled'> {
|
|
13
7
|
iconName?: PktIconName;
|
|
14
8
|
secondIconName?: PktIconName;
|
|
15
|
-
iconPath?: string;
|
|
16
|
-
secondIconPath?: string;
|
|
17
|
-
mode?: TPktButtonMode;
|
|
18
|
-
size?: TPktButtonSize;
|
|
19
9
|
fullWidth?: Booleanish;
|
|
20
10
|
fullWidthOnMobile?: Booleanish;
|
|
21
|
-
color?: TPktButtonColor;
|
|
22
|
-
skin?: TPktButtonSkin;
|
|
23
|
-
variant?: TPktButtonVariant;
|
|
24
|
-
state?: TPktButtonState;
|
|
25
|
-
type?: TPktButtonType;
|
|
26
11
|
isLoading?: Booleanish;
|
|
27
12
|
disabled?: Booleanish;
|
|
28
|
-
loadingAnimationPath?: string;
|
|
29
13
|
}
|
|
30
14
|
export declare class PktButton extends PktElementWithSlot<IPktButton> implements IPktButton {
|
|
31
15
|
iconName: string;
|
|
32
16
|
secondIconName: string;
|
|
33
17
|
iconPath: string | undefined;
|
|
34
18
|
secondIconPath: string | undefined;
|
|
35
|
-
mode?: TPktButtonMode;
|
|
36
19
|
size: TPktButtonSize;
|
|
37
20
|
fullWidth: Booleanish;
|
|
38
21
|
fullWidthOnMobile: Booleanish;
|
|
@@ -40,7 +23,7 @@ export declare class PktButton extends PktElementWithSlot<IPktButton> implements
|
|
|
40
23
|
skin: TPktButtonSkin;
|
|
41
24
|
variant: TPktButtonVariant;
|
|
42
25
|
state?: TPktButtonState;
|
|
43
|
-
type:
|
|
26
|
+
type: THTMLButtonType;
|
|
44
27
|
form: string | undefined;
|
|
45
28
|
isLoading: Booleanish;
|
|
46
29
|
disabled: Booleanish;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PktButton } from './button';
|
|
2
|
-
export type { IPktButton,
|
|
2
|
+
export type { IPktButton, TPktButtonSize, TPktButtonColor, TPktButtonSkin, TPktButtonVariant, TPktButtonState, } from './button';
|
|
3
3
|
export { PktButton };
|
|
4
4
|
export default PktButton;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nothing } from 'lit';
|
|
1
2
|
import { IPktTag } from '../tag';
|
|
2
3
|
import { PktElementWithSlot } from '../../base-elements/element-with-slot';
|
|
3
4
|
import { IPktHeading } from '../heading';
|
|
@@ -5,6 +6,7 @@ import { IAriaAttributes, TCardSkin, TLayout } from '../../shared-types';
|
|
|
5
6
|
export type { TCardSkin, TLayout };
|
|
6
7
|
export type TCardPadding = 'none' | 'default';
|
|
7
8
|
export type TCardImageShape = 'square' | 'round';
|
|
9
|
+
export type TCardImageAspect = 'auto' | '1-1' | '4-3' | '3-2' | '16-9' | '19-10';
|
|
8
10
|
export type TCardTagPosition = 'top' | 'bottom';
|
|
9
11
|
export interface IPktCard {
|
|
10
12
|
ariaLabel?: IAriaAttributes['aria-label'];
|
|
@@ -18,9 +20,12 @@ export interface IPktCard {
|
|
|
18
20
|
alt: string;
|
|
19
21
|
};
|
|
20
22
|
imageShape?: TCardImageShape;
|
|
23
|
+
imageAspect?: TCardImageAspect | null;
|
|
24
|
+
restrictImageHeight?: boolean | null;
|
|
21
25
|
clickCardLink?: string | null;
|
|
22
26
|
openLinkInNewTab?: boolean | null;
|
|
23
27
|
borderOnHover?: boolean | null;
|
|
28
|
+
zoom?: boolean | null;
|
|
24
29
|
padding?: TCardPadding;
|
|
25
30
|
skin?: TCardSkin;
|
|
26
31
|
subheading?: string;
|
|
@@ -33,11 +38,14 @@ export declare class PktCard extends PktElementWithSlot implements IPktCard {
|
|
|
33
38
|
ariaLabel: string;
|
|
34
39
|
metaLead: string | null;
|
|
35
40
|
borderOnHover: boolean;
|
|
41
|
+
zoom: boolean;
|
|
42
|
+
imageAspect: TCardImageAspect | null;
|
|
43
|
+
restrictImageHeight: boolean;
|
|
36
44
|
clickCardLink: IPktCard['clickCardLink'];
|
|
37
45
|
metaTrail: string | null;
|
|
38
46
|
layout: TLayout;
|
|
39
47
|
heading: string;
|
|
40
|
-
|
|
48
|
+
headingLevel: IPktHeading['level'];
|
|
41
49
|
image: {
|
|
42
50
|
src: string;
|
|
43
51
|
alt: string;
|
|
@@ -54,8 +62,9 @@ export declare class PktCard extends PktElementWithSlot implements IPktCard {
|
|
|
54
62
|
connectedCallback(): void;
|
|
55
63
|
render(): import('lit-html').TemplateResult<1>;
|
|
56
64
|
renderImage(): import('lit-html').TemplateResult<1>;
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
private renderHeadingTag;
|
|
66
|
+
renderHeading(): typeof nothing | import('lit-html').TemplateResult<1>;
|
|
67
|
+
renderLinkHeading(): typeof nothing | import('lit-html').TemplateResult<1>;
|
|
59
68
|
renderSubheading(): import('lit-html').TemplateResult<1>;
|
|
60
69
|
renderHeader(): import('lit-html').TemplateResult<1>;
|
|
61
70
|
renderTags(): import('lit-html').TemplateResult<1>;
|
|
@@ -34,7 +34,7 @@ export { PktSelect } from './select';
|
|
|
34
34
|
export { PktSearchInput } from './searchinput';
|
|
35
35
|
export { PktTimepicker } from './timepicker';
|
|
36
36
|
export type { IPktAccordion, IPktAccordionItem, TPktAccordionSkin } from './accordion';
|
|
37
|
-
export type { IPktButton,
|
|
37
|
+
export type { IPktButton, TPktButtonSize, TPktButtonColor, TPktButtonSkin, TPktButtonVariant, TPktButtonState, } from './button';
|
|
38
38
|
export type { User as IPktHeaderUser, Representing as IPktHeaderRepresenting, UserMenuItem as IPktHeaderUserMenuItem, THeaderMenu, TLogOutButtonPlacement as TPktHeaderLogOutButtonPlacement, THeaderPosition, THeaderScrollBehavior, TSlotMenuVariant, THeaderType, TGlobalHeaderMenu, IPktHeader, IPktHeaderGlobal, } from './header';
|
|
39
39
|
export type { IPktHeaderMenu } from './header-menu';
|
|
40
40
|
export type { IPktProgressbar, TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, TProgressbarStatusType, TProgressbarTitlePosition, } from './progressbar';
|
|
@@ -26,8 +26,8 @@ export interface IPktLoader {
|
|
|
26
26
|
*/
|
|
27
27
|
size?: TPktSize;
|
|
28
28
|
/**
|
|
29
|
-
* The variant of the loader. Default is "
|
|
30
|
-
*
|
|
29
|
+
* The variant of the loader. Default is "rainbow".
|
|
30
|
+
* "shapes" is the OSLO wave loader, "blue" a blue spinner.
|
|
31
31
|
*/
|
|
32
32
|
variant?: TPktLoaderVariant;
|
|
33
33
|
/**
|
|
@@ -13,7 +13,7 @@ export declare class PktMessagebox extends PktElementWithSlot implements IPktMes
|
|
|
13
13
|
closable: boolean;
|
|
14
14
|
compact: boolean;
|
|
15
15
|
title: string;
|
|
16
|
-
skin
|
|
16
|
+
skin?: TMessageboxSkin;
|
|
17
17
|
_isClosed: boolean;
|
|
18
18
|
protected updated(_changedProperties: PropertyValues): void;
|
|
19
19
|
render(): import('lit-html').TemplateResult<1>;
|
|
@@ -35,15 +35,11 @@ export declare class PktProgressbar extends PktElement implements IPktProgressba
|
|
|
35
35
|
valueMin: number;
|
|
36
36
|
private labelWidth;
|
|
37
37
|
private progressbarId;
|
|
38
|
-
private
|
|
39
|
-
private computedAriaValueText;
|
|
38
|
+
private resolvedRole;
|
|
40
39
|
private labelRef;
|
|
41
40
|
private progressBarRef;
|
|
42
|
-
|
|
41
|
+
protected willUpdate(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
43
42
|
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
44
43
|
render(): import('lit-html').TemplateResult<1>;
|
|
45
|
-
private setComputedValues;
|
|
46
|
-
private syncAttributes;
|
|
47
|
-
private _handleAttribute;
|
|
48
44
|
}
|
|
49
45
|
export default PktProgressbar;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs");require("./button-
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs");require("./button-jJfzE9C7.cjs");var t={i18n:{nb:{contentPresentation:{title:`Oslo kommune bruker informasjonskapsler`,description:[`For at nettstedet skal fungere og være trygt, bruker Oslo kommune informasjonskapsler. Noen er teknisk nødvendige, mens andre sikrer ulik funksjonalitet.`,`Godtar du alle informasjonskapsler, tillater du også at vi samler inn data om statistikk og brukeradferd. Da hjelper du oss med å lage et bedre nettsted uten at du trenger å dele noe personlig informasjon med oss.`],buttons:{accept:`Godta alle`,reject:`Kun nødvendige`,settings:`Innstillinger for informasjonskapsler`}},contentSettings:{title:`Innstillinger for informasjonskapsler`,description:[`Her kan du velge hvilke typer informasjonskapsler du vil tillate. Tillatelsen gjelder i 90 dager. Husk at nødvendige informasjonskapsler ikke kan velges bort.`,`Du kan når som helst endre innstillingene og finne mer informasjon nederst på nettstedet under «Innstillinger for informasjonskapsler» og «Personvern og informasjonskapsler».`],buttons:{back:`Tilbake`,save:`Lagre innstillinger`}}},en:{contentPresentation:{title:`Before you visit Oslo kommune ...`,description:[`This website uses cookies to make improvements. In this context, we need your consent to measure the traffic on the website in relation to statistics and feedback.`,`To read more about what we use cookies for, go to our privacy declaration which you will find at the bottom of our websites.`],buttons:{accept:`Yes, I accept`,reject:`Only necessary`,settings:`Go to settings`}},contentSettings:{title:`Her kan du aktivt velge mellom ulike informasjonskapsler`,description:[`For å lese mer om hva vi bruker informasjonskapsler til gå til vår personvernserklering som du finner på våre nettsider`],buttons:{back:`Back`,save:`Save settings`}}}},cookies:[{name:`statistics`,defaultValue:null,i18n:{nb:{title:`Statistikk og analyse`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler til å innhente data om statistikk og brukeradferd.`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Statistics and analytics`,description:`Select your preference for statistics and analytics`,buttons:{yes:`Yes`,no:`No`}}}},{name:`survey`,defaultValue:null,i18n:{nb:{title:`Skriftlige tilbakemeldinger`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler til å vise responsfelt og registrere tilbakemeldinger.`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Survey`,description:`Select your preference for survey`,buttons:{yes:`Yes`,no:`No`}}}},{name:`functional`,defaultValue:!0,i18n:{nb:{title:`Funksjonelle informasjonskapsler`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler for å gjøre ulike funksjoner på nettstedet mulige (for eksempel skjemaer og barnehagevelger).`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Functional cookies`,description:`For the website to function optimally, we recommend that you accept these cookies`,buttons:{yes:`Yes`,no:`No`}}}}]},n=null;function r(){return n||(n=new Promise((e,t)=>{if(document.querySelector(`#oslo-consent-script`)){e();return}let n=document.createElement(`script`);n.src=`https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js`,n.id=`oslo-consent-script`,n.onload=()=>e(),n.onerror=t,document.head.appendChild(n);let r=document.createElement(`link`);r.href=`https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css`,r.type=`text/css`,r.rel=`stylesheet`,r.id=`oslo-consent-styles`,document.head.appendChild(r)}),n)}var i=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}},a=e=>i(e.value).items.reduce((e,t)=>(e[t.name]=t.consent,e),{}),o=class extends e.t{constructor(...e){super(...e),this.devMode=!1,this.hotjarId=null,this.googleAnalyticsId=null,this.cookieDomain=null,this.cookieSecure=null,this.cookieExpiryDays=null,this.triggerType=`button`,this.triggerText=null,this.i18nLanguage=`nb`}connectedCallback(){super.connectedCallback();let e=this.i18nLanguage;this.triggerText=this.triggerText||t.i18n[e].contentPresentation.buttons.settings}disconnectedCallback(){super.disconnectedCallback(),this._cookieEventHandler&&window.__cookieEvents?.off(`CookieManager.setCookie`,this._cookieEventHandler)}returnJsonOrObject(e){return i(e)}emitCookieConsents(e){this.dispatchEvent(new CustomEvent(`toggle-consent`,{detail:a(e),bubbles:!0,cancelable:!1}))}async firstUpdated(e){window.cookieBanner_googleAnalyticsId=this.googleAnalyticsId,window.cookieBanner_hotjarId=this.hotjarId,this.cookieDomain&&(window.cookieBanner_cookieDomain=this.cookieDomain),this.cookieSecure&&(window.cookieBanner_cookieSecure=this.cookieSecure),this.cookieExpiryDays&&(window.cookieBanner_cookieExpiryDays=this.cookieExpiryDays),this.devMode&&(window.cookieBanner_devMode=this.devMode),await r(),this.triggerInit()}triggerInit(){window.document.dispatchEvent(new Event(`CookieBannerReady`,{bubbles:!0,cancelable:!0}));let e=window.cookieBanner,t=window.__cookieEvents;!e||!t||e.cookieConsent.validateConsentCookie().then(n=>{if(!n)return;let r=e.cookieConsent.getConsentCookie();window.setTimeout(()=>this.emitCookieConsents({value:r}),0),this._cookieEventHandler&&t.off(`CookieManager.setCookie`,this._cookieEventHandler),this._cookieEventHandler=e=>this.emitCookieConsents(e),t.on(`CookieManager.setCookie`,this._cookieEventHandler)})}openModal(e){e.preventDefault(),window.cookieBanner?.cookieConsent||this.triggerInit(),setTimeout(()=>window.cookieBanner?.openCookieModal())}render(){return this.triggerType===`link`?e._`<a href="#" class="pkt-link" aria-haspopup="dialog" @click=${this.openModal}
|
|
2
2
|
>${this.triggerText}</a
|
|
3
3
|
>`:this.triggerType===`footerlink`?e._`<a
|
|
4
4
|
href="#"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./element-with-slot-MkibfzHp.cjs");require("./icon-DBFTFd-J.cjs");const
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./element-with-slot-MkibfzHp.cjs");require("./icon-DBFTFd-J.cjs");const i=require("./ref-BkV4Cd8U.cjs"),a=require("./converters-BJ9Fe0kW.cjs");require("./calendar-Cc0bjLPC.cjs"),require("./tag-BDlwKjgT.cjs");const o=require("./repeat-uBgVG8Ch.cjs"),s=require("./utils-63cRpWut.cjs"),c=require("./input-element-KpXXnGi0.cjs");require("./input-wrapper-CS0qrYcm.cjs");var l=class extends e.t{constructor(...e){super(...e),this.dates=[],this.dateformat=`dd.MM.yyyy`,this.className=`pkt-datepicker__tags`,this.idBase=s.n()}render(){return this.classes={"pkt-date-tags":!0,[this.className]:!0},e._`
|
|
2
2
|
<div class=${t.t(this.classes)} aria-live="polite">
|
|
3
3
|
${Array.isArray(this.dates)&&this.dates[0]?o.t(a.h((this.dates??[]).filter(Boolean)),e=>e,t=>e._` <pkt-tag
|
|
4
4
|
id=${this.idBase+t+`-tag`}
|
|
@@ -54,9 +54,9 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
54
54
|
.type=${this.inputType}
|
|
55
55
|
id="${this.id}-input"
|
|
56
56
|
.value=${this.value}
|
|
57
|
-
min=${
|
|
58
|
-
max=${
|
|
59
|
-
placeholder=${
|
|
57
|
+
min=${n.t(this.min)}
|
|
58
|
+
max=${n.t(this.max)}
|
|
59
|
+
placeholder=${n.t(this.placeholder)}
|
|
60
60
|
?readonly=${this.isInputReadonly}
|
|
61
61
|
aria-describedby="${this.id}-input-helptext"
|
|
62
62
|
@click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
@@ -71,7 +71,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
71
71
|
/>
|
|
72
72
|
${this.renderCalendarButton()}
|
|
73
73
|
</div>
|
|
74
|
-
`}};e.n([e.u({type:String})],M.prototype,`value`,void 0);try{e.d(`pkt-datepicker-single`)(M)}catch{console.warn(`Forsøker å definere <pkt-datepicker-single>, men den er allerede definert`)}var N=class extends j{constructor(...e){super(...e),this.value=[],this.label=``,this.showRangeLabels=!1,this.inputRefTo=i.t()}get inputElementTo(){return this.inputRefTo.value}render(){let
|
|
74
|
+
`}};e.n([e.u({type:String})],M.prototype,`value`,void 0);try{e.d(`pkt-datepicker-single`)(M)}catch{console.warn(`Forsøker å definere <pkt-datepicker-single>, men den er allerede definert`)}var N=class extends j{constructor(...e){super(...e),this.value=[],this.label=``,this.showRangeLabels=!1,this.inputRefTo=i.t()}get inputElementTo(){return this.inputRefTo.value}render(){let r=D.getRangeLabelClasses(this.showRangeLabels);return e._`
|
|
75
75
|
<div class="pkt-input__container">
|
|
76
76
|
${this.showRangeLabels?e._` <div class="pkt-input-prefix">${this.pktStrings.get(`generic`).from}</div> `:e.h}
|
|
77
77
|
<input
|
|
@@ -80,9 +80,9 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
80
80
|
id="${this.id}-input"
|
|
81
81
|
aria-label="${this.label} ${this.pktStrings.get(`generic`).from}"
|
|
82
82
|
.value=${this.value[0]??``}
|
|
83
|
-
min=${
|
|
84
|
-
max=${
|
|
85
|
-
placeholder=${
|
|
83
|
+
min=${n.t(this.min)}
|
|
84
|
+
max=${n.t(this.max)}
|
|
85
|
+
placeholder=${n.t(this.placeholder)}
|
|
86
86
|
?readonly=${this.isInputReadonly}
|
|
87
87
|
?disabled=${this.disabled}
|
|
88
88
|
@click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
@@ -94,7 +94,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
94
94
|
@change=${e=>{this.dispatchChange(e),e.stopImmediatePropagation()}}
|
|
95
95
|
${i.n(this.inputRef)}
|
|
96
96
|
/>
|
|
97
|
-
<div class="${t.t(
|
|
97
|
+
<div class="${t.t(r)}" id="${this.id}-to-label">
|
|
98
98
|
${this.pktStrings.get(`generic`).to}
|
|
99
99
|
</div>
|
|
100
100
|
${this.showRangeLabels?e.h:e._` <div class="pkt-input-separator">–</div> `}
|
|
@@ -104,9 +104,9 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
104
104
|
id="${this.id}-to"
|
|
105
105
|
aria-label="${this.label} ${this.pktStrings.get(`generic`).to}"
|
|
106
106
|
.value=${this.value[1]??``}
|
|
107
|
-
min=${
|
|
108
|
-
max=${
|
|
109
|
-
placeholder=${
|
|
107
|
+
min=${n.t(this.min)}
|
|
108
|
+
max=${n.t(this.max)}
|
|
109
|
+
placeholder=${n.t(this.placeholder)}
|
|
110
110
|
?readonly=${this.isInputReadonly}
|
|
111
111
|
?disabled=${this.disabled}
|
|
112
112
|
@click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
@@ -126,9 +126,9 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
126
126
|
class=${t.t(this.inputClasses)}
|
|
127
127
|
.type=${this.inputType}
|
|
128
128
|
id="${this.id}-input"
|
|
129
|
-
min=${
|
|
130
|
-
max=${
|
|
131
|
-
placeholder=${
|
|
129
|
+
min=${n.t(this.min)}
|
|
130
|
+
max=${n.t(this.max)}
|
|
131
|
+
placeholder=${n.t(this.placeholder)}
|
|
132
132
|
?readonly=${this.isInputReadonly}
|
|
133
133
|
?disabled=${this.isInputDisabled}
|
|
134
134
|
@click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
@@ -261,7 +261,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
261
261
|
.ariaDescribedby=${this.ariaDescribedby}
|
|
262
262
|
.size=${this.inputSize}
|
|
263
263
|
>
|
|
264
|
-
<div class="pkt-contents" slot="helptext">${
|
|
264
|
+
<div class="pkt-contents" slot="helptext">${r.n(this,`helptext`)}</div>
|
|
265
265
|
${this.multiple?e._`<pkt-date-tags
|
|
266
266
|
.dates=${this._value}
|
|
267
267
|
dateformat=${this.dateformat}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, s as a, t as o, u as s } from "./element-e2MAMNEP.js";
|
|
2
2
|
import { t as c } from "./class-map-BL_YL_Ed.js";
|
|
3
|
+
import { t as l } from "./if-defined-r8tKY4tG.js";
|
|
3
4
|
import { n as ee } from "./element-with-slot-COOwQUxM.js";
|
|
4
5
|
import "./icon-jEFbKTB_.js";
|
|
5
|
-
import { t as l } from "./if-defined-r8tKY4tG.js";
|
|
6
6
|
import { n as u, t as d } from "./ref-lE1mGUOL.js";
|
|
7
7
|
import { a as f, c as p, d as m, h, i as g, m as _, n as v, r as y, s as b, t as x, u as S } from "./converters-CkjLSYpa.js";
|
|
8
8
|
import "./calendar-iXilYFBa.js";
|
|
9
|
-
import "./tag-
|
|
9
|
+
import "./tag-CdiDs9zb.js";
|
|
10
10
|
import { t as C } from "./repeat-CCnTfedv.js";
|
|
11
11
|
import { n as w, t as T } from "./utils-BwF4QSrq.js";
|
|
12
12
|
import { t as E } from "./input-element-DxHRTZ3K.js";
|
|
13
|
-
import "./input-wrapper-
|
|
13
|
+
import "./input-wrapper-BetB7OLQ.js";
|
|
14
14
|
//#region src/components/datepicker/date-tags.ts
|
|
15
15
|
var D = class extends o {
|
|
16
16
|
constructor(...e) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { _ as e, d as t, l as n, n as r, s as i, t as a, u as o } from "./element-e2MAMNEP.js";
|
|
2
2
|
import { t as s } from "./class-map-BL_YL_Ed.js";
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
3
|
+
import { t as c } from "./if-defined-r8tKY4tG.js";
|
|
4
|
+
import { n as l, t as u } from "./format-BTeSVkED.js";
|
|
5
|
+
import "./alert-DNZtr3gd.js";
|
|
5
6
|
import "./icon-jEFbKTB_.js";
|
|
6
|
-
import { t as u } from "./if-defined-r8tKY4tG.js";
|
|
7
7
|
import { t as d } from "./converters-CkjLSYpa.js";
|
|
8
8
|
import { n as f } from "./utils-BwF4QSrq.js";
|
|
9
|
-
import "./input-wrapper-
|
|
9
|
+
import "./input-wrapper-BetB7OLQ.js";
|
|
10
10
|
import { r as p } from "./focus-trap-DG3pEuyJ.js";
|
|
11
11
|
import "./modal-C7eV5vJr.js";
|
|
12
|
-
import "./progressbar-
|
|
12
|
+
import "./progressbar-BPHLC7ce.js";
|
|
13
13
|
//#region ../../shared-utils/fileupload/size.ts
|
|
14
14
|
function m(e) {
|
|
15
15
|
if (e == null || e === "") return;
|
|
@@ -246,7 +246,7 @@ var j = class extends a {
|
|
|
246
246
|
file: e,
|
|
247
247
|
attributes: { targetFilename: e.name }
|
|
248
248
|
})), r = this.pktStrings.get("fileupload");
|
|
249
|
-
this.setAddedAnnouncement(n.length === 1 ?
|
|
249
|
+
this.setAddedAnnouncement(n.length === 1 ? u(r.srFileAdded, { filename: n[0].attributes.targetFilename }) : u(r.srFilesAdded, { count: n.length }));
|
|
250
250
|
let i = this.getCurrentFiles(), a = this.multiple ? [...i, ...n] : [n[0]];
|
|
251
251
|
this.commitFiles(a, "add", n.map((e) => e.fileId)), this.uploadStrategy === "custom" && n.forEach((e) => {
|
|
252
252
|
this.dispatchEvent(new CustomEvent("file-upload-requested", {
|
|
@@ -379,20 +379,20 @@ var j = class extends a {
|
|
|
379
379
|
let { totalCount: e, uploadedCount: t } = k(this.getCurrentFiles(), this.transfers);
|
|
380
380
|
if (e === 0 || t === 0) return "";
|
|
381
381
|
let n = this.pktStrings.get("fileupload");
|
|
382
|
-
return
|
|
382
|
+
return u(n.srFilesUploadedOfTotal, {
|
|
383
383
|
uploaded: t,
|
|
384
384
|
total: e,
|
|
385
|
-
label:
|
|
385
|
+
label: l(e, n.fileLabelOne, n.fileLabelOther)
|
|
386
386
|
});
|
|
387
387
|
}
|
|
388
388
|
getSrErrorsMessage() {
|
|
389
389
|
let { totalCount: e, failedCount: t } = k(this.getCurrentFiles(), this.transfers);
|
|
390
390
|
if (e === 0 || t === 0) return "";
|
|
391
391
|
let n = this.pktStrings.get("fileupload");
|
|
392
|
-
return
|
|
392
|
+
return u(n.srFilesFailedOfTotal, {
|
|
393
393
|
failed: t,
|
|
394
394
|
total: e,
|
|
395
|
-
label:
|
|
395
|
+
label: l(e, n.fileLabelOne, n.fileLabelOther)
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
398
|
syncFormSubmitListener() {
|
|
@@ -712,7 +712,7 @@ var M = "comments", N = (e) => {
|
|
|
712
712
|
>${o}</span
|
|
713
713
|
>` : null}
|
|
714
714
|
`;
|
|
715
|
-
}, K = ({ file: t, disabled: n, inputName: r, operations: i, activeOperationId: a, onActivateOperation: o, onCloseOperation: s, getFileAttribute:
|
|
715
|
+
}, K = ({ file: t, disabled: n, inputName: r, operations: i, activeOperationId: a, onActivateOperation: o, onCloseOperation: s, getFileAttribute: l, setFileAttribute: u }) => {
|
|
716
716
|
let d = i.find((e) => e.id === a);
|
|
717
717
|
if (d?.renderInlineUI || d?.renderExtendedUI) return null;
|
|
718
718
|
let f = i.map((i) => {
|
|
@@ -724,15 +724,15 @@ var M = "comments", N = (e) => {
|
|
|
724
724
|
isActive: i.id === a,
|
|
725
725
|
onActivateOperation: o,
|
|
726
726
|
onCloseOperation: s,
|
|
727
|
-
getFileAttribute:
|
|
728
|
-
setFileAttribute:
|
|
727
|
+
getFileAttribute: l,
|
|
728
|
+
setFileAttribute: u
|
|
729
729
|
}), f = typeof i.title == "function" ? i.title(t) : i.title;
|
|
730
730
|
if (!f) return null;
|
|
731
731
|
let p = typeof i.ariaLabel == "function" ? i.ariaLabel(t) : i.ariaLabel;
|
|
732
732
|
return e`<button
|
|
733
733
|
type="button"
|
|
734
734
|
class="pkt-fileupload__queue-display__item__operation"
|
|
735
|
-
aria-label=${
|
|
735
|
+
aria-label=${c(p)}
|
|
736
736
|
?disabled=${n}
|
|
737
737
|
@click=${() => {
|
|
738
738
|
(i.renderInlineUI || i.renderExtendedUI) && d.activate(), i.onClick?.(d);
|
|
@@ -800,8 +800,8 @@ var M = "comments", N = (e) => {
|
|
|
800
800
|
></pkt-icon>
|
|
801
801
|
${B(i, n, r)}
|
|
802
802
|
`;
|
|
803
|
-
}, Z = ({ file: t, thumbnailUrl: n, previewEnabled: r, canOpenPreview: a, truncateTail: o, onOpenPreview:
|
|
804
|
-
let f = A(t), p = !!n, m = !!r && !!a, h = m && !!
|
|
803
|
+
}, Z = ({ file: t, thumbnailUrl: n, previewEnabled: r, canOpenPreview: a, truncateTail: o, onOpenPreview: l, onThumbnailImageError: d }) => {
|
|
804
|
+
let f = A(t), p = !!n, m = !!r && !!a, h = m && !!l;
|
|
805
805
|
return e`
|
|
806
806
|
<div
|
|
807
807
|
class=${s({
|
|
@@ -812,10 +812,10 @@ var M = "comments", N = (e) => {
|
|
|
812
812
|
<button
|
|
813
813
|
type="button"
|
|
814
814
|
class="pkt-fileupload__queue-display__item__thumbnail__image-wrapper pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--label-only"
|
|
815
|
-
aria-label=${
|
|
815
|
+
aria-label=${u(i.fileupload.previewImage, { filename: f })}
|
|
816
816
|
?disabled=${!h}
|
|
817
817
|
@click=${() => {
|
|
818
|
-
!h || !
|
|
818
|
+
!h || !l || l(t.fileId);
|
|
819
819
|
}}
|
|
820
820
|
>
|
|
821
821
|
<span class="pkt-btn__text">
|
|
@@ -825,7 +825,7 @@ var M = "comments", N = (e) => {
|
|
|
825
825
|
aria-hidden="true"
|
|
826
826
|
></pkt-icon>` : null}
|
|
827
827
|
${p ? e`<img
|
|
828
|
-
src=${
|
|
828
|
+
src=${c(n)}
|
|
829
829
|
alt=${f}
|
|
830
830
|
@error=${() => d?.(t.fileId)}
|
|
831
831
|
/>` : e`<pkt-icon
|
|
@@ -1139,15 +1139,15 @@ var M = "comments", N = (e) => {
|
|
|
1139
1139
|
<input
|
|
1140
1140
|
id=${`${this.id}-input`}
|
|
1141
1141
|
type="file"
|
|
1142
|
-
name=${
|
|
1142
|
+
name=${c(this.uploadStrategy === "form" ? this.name : void 0)}
|
|
1143
1143
|
?multiple=${this.multiple}
|
|
1144
1144
|
?disabled=${this.disabled}
|
|
1145
1145
|
?required=${this.required && this.uploadStrategy === "form"}
|
|
1146
1146
|
accept=${this.getResolvedAcceptValue()}
|
|
1147
|
-
aria-label=${
|
|
1148
|
-
aria-required=${
|
|
1149
|
-
aria-invalid=${
|
|
1150
|
-
aria-describedby=${
|
|
1147
|
+
aria-label=${c(this.label ? void 0 : this.multiple ? "Velg filer" : "Velg fil")}
|
|
1148
|
+
aria-required=${c(this.required ? "true" : void 0)}
|
|
1149
|
+
aria-invalid=${c(this.hasEffectiveError ? "true" : void 0)}
|
|
1150
|
+
aria-describedby=${c(a)}
|
|
1151
1151
|
@change=${this.onNativeFileChange}
|
|
1152
1152
|
/>
|
|
1153
1153
|
${this.uploadStrategy === "custom" ? t.map((t) => e`<input type="hidden" name=${this.name} value=${t.fileId} />`) : null}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./format-B8meU8Tm.cjs");require("./alert-BlHM1zEi.cjs"),require("./icon-DBFTFd-J.cjs");const r=require("./if-defined-BeVQnl3C.cjs"),i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-B0eSdZs3.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-Bh0DGVfN.cjs"),require("./progressbar-T5_MpZGN.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),!this.disabled&&this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),!this.disabled&&(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{!this.required||this.uploadStrategy!==`custom`||this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault())}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.hasInitializedValue||=(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),!0),this.value!==void 0&&this.defaultValue!==void 0&&this.warnInvalidValueCombo()}willUpdate(e){super.willUpdate(e),this.hasInitializedValue&&this.isControlled&&(e.has(`value`)||e.has(`itemRenderer`)||e.has(`enableImagePreview`))&&(this.files=this.value??[],this.syncThumbnailUrls(this.files))}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(!(!e||typeof DataTransfer>`u`))try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let r=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(r.length===1?n.t(i.srFileAdded,{filename:r[0].attributes.targetFilename}):n.t(i.srFilesAdded,{count:r.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...r]:[r[0]];this.commitFiles(s,`add`,r.map(e=>e.fileId)),this.uploadStrategy===`custom`&&r.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(!(typeof URL<`u`&&typeof URL.createObjectURL==`function`&&typeof URL.revokeObjectURL==`function`)){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){if(typeof URL>`u`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear()}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesUploadedOfTotal,{uploaded:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let r=this.pktStrings.get(`fileupload`);return n.t(r.srFilesFailedOfTotal,{failed:t,total:e,label:n.n(e,r.fileLabelOne,r.fileLabelOther)})}syncFormSubmitListener(){let e=this.closest(`form`);this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:`${String(t.getDate()).padStart(2,`0`)}.${String(t.getMonth()+1).padStart(2,`0`)}.${t.getFullYear()} kl. ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),j=()=>({id:`rename`,title:`Rediger`,ariaLabel:`Rediger filnavn`,renderInlineUI:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``,r=`pkt-fileupload-rename-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(`targetFilename`,e),t.close()};return e._`
|
|
1
|
+
const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),n=require("./if-defined-BeVQnl3C.cjs"),r=require("./format-B8meU8Tm.cjs");require("./alert-DqM9l5as.cjs"),require("./icon-DBFTFd-J.cjs");const i=require("./converters-BJ9Fe0kW.cjs"),a=require("./utils-63cRpWut.cjs");require("./input-wrapper-CS0qrYcm.cjs");const o=require("./focus-trap-DSv4Ifqm.cjs");require("./modal-Bh0DGVfN.cjs"),require("./progressbar-BpcsDCnG.cjs");function s(e){if(e==null||e===``)return;if(typeof e==`number`)return Number.isFinite(e)&&e>0?e:void 0;let t=String(e).trim(),n=Number(t);if(!Number.isNaN(n)&&n>0)return n;let r=t.match(/^(\d+(?:\.\d+)?)\s*(B|KB|MB|GB)$/i);if(!r){console.warn(`PktFileUpload: Invalid maxFileSize format "${t}". Use format like "5MB", "500KB", "1GB", or bytes.`);return}let i=parseFloat(r[1]);switch(r[2].toUpperCase()){case`B`:return i;case`KB`:return i*1024;case`MB`:return i*1024*1024;case`GB`:return i*1024*1024*1024;default:return}}function c(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} KB`:e<1073741824?`${Math.round(e/1048576)} MB`:`${Math.round(e/1073741824)} GB`}function l(e){return Array.isArray(e)?e.map(e=>String(e).trim().toLowerCase()).filter(Boolean):[]}function u(e){return e?e.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function d(e,t,n){let r=e.toLowerCase().replace(/^\./,``);if(r.includes(`/`)){if(r.endsWith(`/*`)){let e=r.replace(`/*`,``);return n.startsWith(`${e}/`)}return n===r}return t===r}function f(e,t){let n=l(t);if(n.length===0)return!0;let r=e.name.split(`.`).pop()?.toLowerCase()??``,i=e.type.toLowerCase();return n.some(e=>d(e,r,i))}function p(e,t){let n=(e??``).trim();if(n)return n;let r=l(t);return r.length===0?``:r.map(e=>e.includes(`/`)||e.startsWith(`.`)?e:`.${e}`).join(`, `)}function m(e){return e.includes(`/`)?e:e.replace(/^\./,``).toUpperCase()}function h(e,t){let n=l(e);if(n.length>0)return n.map(m).join(`, `);let r=u(t);return r.length>0?r.map(m).join(`, `):``}function g(e,t,n){return((e??``).trim()||t).replace(/\{(\w+)\}/g,(e,t)=>n[t]??`{${t}}`)}function _(t,n){let r=l(n.allowedFormats);if(r.length>0&&!f(t,r)){let t=r.join(`, `),i=e.s.fileupload.invalidFormat;return g(n.formatErrorMessage,i,{formats:t})}let i=s(n.maxFileSize);if(i!==void 0&&t.size>i){let t=c(i),r=e.s.fileupload.sizeTooLarge;return g(n.sizeErrorMessage,r,{maxSize:t})}if(n.onFileValidation){let e=n.onFileValidation(t);if(e)return e}return null}function v(e){let t=e.file;if(t?.type?.startsWith(`image/`))return!0;let n=e.attributes?.targetFilename||t?.name||``;return/\.(jpe?g|png|gif|webp|heic|heif|bmp|svg)$/i.test(n)}function y(e){return typeof e==`number`?`in-progress`:e===`error`?`error`:`idle`}function b(e,t,n){let r={"in-progress":0,error:1,idle:2};return e.map(e=>{let r=t?.find(t=>t.fileId===e.fileId);return{...e,progress:r?.progress??(n===`form`?`done`:`queued`),errorMessage:r?.errorMessage,showProgress:r?.showProgress,lastProgress:r?.lastProgress}}).sort((e,t)=>r[y(e.progress)]-r[y(t.progress)])}function x(e,t){return!t||t<=0||e.length<=t+3?null:{head:e.slice(0,e.length-t),tail:e.slice(-t)}}function S(e,t,n){return n<=0?0:t===`prev`?e<=0?n-1:e-1:e>=n-1?0:e+1}function C(e,t){let n=e.length;if(n===0||!t||t.length===0)return{totalCount:n,uploadedCount:0,failedCount:0};let r=0,i=0;for(let n of e){let e=t.find(e=>e.fileId===n.fileId);e?.progress===`done`?r++:e?.progress===`error`&&i++}return{totalCount:n,uploadedCount:r,failedCount:i}}function w(t,n=e.s.fileupload.unknownFilename){return t.attributes?.targetFilename||t.file?.name||n}var T=class extends e.t{constructor(...e){super(...e),this.id=`pkt-fileupload-${a.n()}`,this.name=`files`,this.label=``,this.helptext=``,this.helptextDropdown=``,this.required=!1,this.multiple=!1,this.disabled=!1,this.fullwidth=!1,this.uploadStrategy=`form`,this.itemRenderer=`filename`,this.accept=``,this.allowedFormats=[],this.formatErrorMessage=``,this.sizeErrorMessage=``,this.transfers=[],this.addCommentsEnabled=!1,this.renameFilesEnabled=!1,this.extraOperations=[],this.enableImagePreview=!1,this.hasError=!1,this.errorMessage=``,this.optionalTag=!1,this.requiredTag=!1,this.tagText=null,this.truncateTail=4,this.files=[],this.isDragActive=!1,this.validationErrorMessage=null,this.addedAnnouncement=``,this.thumbnailUrls={},this.hasInitializedValue=!1,this.hasWarnedInvalidValueCombo=!1,this.thumbnailFileById=new Map,this.connectedForm=null,this.addedAnnouncementTimer=null,this.onNativeFileChange=e=>{let t=e.target;this.addFiles(t.files?Array.from(t.files):[]),this.uploadStrategy===`custom`&&(t.value=``)},this.openFileDialog=e=>{e.preventDefault(),e.stopPropagation(),!this.disabled&&this.querySelector(`#${this.id}-input`)?.click()},this.onDropZoneClick=e=>{this.disabled||e.target.closest(`.pkt-fileupload__drop-zone__placeholder__title__open-file-dialog`)||this.querySelector(`#${this.id}-input`)?.click()},this.onDragOver=e=>{e.preventDefault(),!this.disabled&&(this.isDragActive=!0)},this.onDragLeave=()=>{this.isDragActive=!1},this.onDrop=e=>{if(e.preventDefault(),this.isDragActive=!1,this.disabled)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this.addFiles(t)},this.onHostFormSubmit=e=>{!this.required||this.uploadStrategy!==`custom`||this.getCurrentFiles().length>0||(this.validationErrorMessage=this.requiredSelectionMessage,e.preventDefault())}}get requiredSelectionMessage(){return this.pktStrings.get(`fileupload`).requiredMissing}get isControlled(){return this.value!==void 0}get hasEffectiveError(){return!!this.validationErrorMessage||this.hasError||!!this.errorMessage.trim()}get effectiveErrorMessage(){return this.validationErrorMessage??this.errorMessage??``}get hasValidationError(){return!!this.validationErrorMessage}firstUpdated(e){super.firstUpdated?.(e),this.hasInitializedValue||=(this.files=this.value??this.defaultValue??[],this.syncThumbnailUrls(this.files),!0),this.value!==void 0&&this.defaultValue!==void 0&&this.warnInvalidValueCombo()}willUpdate(e){super.willUpdate(e),this.hasInitializedValue&&this.isControlled&&(e.has(`value`)||e.has(`itemRenderer`)||e.has(`enableImagePreview`))&&(this.files=this.value??[],this.syncThumbnailUrls(this.files))}updated(e){super.updated(e),(e.has(`uploadStrategy`)||e.has(`required`)||e.has(`value`))&&this.syncFormSubmitListener(),this.uploadStrategy===`form`&&(e.has(`value`)||e.has(`files`)||e.has(`uploadStrategy`))&&this.syncNativeInputFiles()}syncNativeInputFiles(){let e=this.querySelector(`#${this.id}-input`);if(!(!e||typeof DataTransfer>`u`))try{let t=new DataTransfer;for(let e of this.getCurrentFiles())e.file&&t.items.add(e.file);e.files=t.files}catch{}}warnInvalidValueCombo(){this.hasWarnedInvalidValueCombo||=(console.warn(`PktFileUpload: Både value og defaultValue er angitt. Komponenten kan være enten kontrollert eller ukontrollert, ikke begge. value vil bli prioritert.`),!0)}disconnectedCallback(){this.teardownFormSubmitListener(),this.addedAnnouncementTimer&&=(clearTimeout(this.addedAnnouncementTimer),null),super.disconnectedCallback(),this.revokeAllThumbnailUrls()}setAddedAnnouncement(e){this.addedAnnouncement=e,this.addedAnnouncementTimer&&clearTimeout(this.addedAnnouncementTimer),this.addedAnnouncementTimer=setTimeout(()=>{this.addedAnnouncement=``,this.addedAnnouncementTimer=null},1500)}connectedCallback(){super.connectedCallback(),this.syncFormSubmitListener()}addFiles(e){if(e.length===0)return;let t=this.multiple?e:[e[0]];for(let e of t){let t=this.validateFile(e);if(t){this.validationErrorMessage=t;return}}this.validationErrorMessage=null;let n=t.map(e=>({fileId:a.n(),file:e,attributes:{targetFilename:e.name}})),i=this.pktStrings.get(`fileupload`);this.setAddedAnnouncement(n.length===1?r.t(i.srFileAdded,{filename:n[0].attributes.targetFilename}):r.t(i.srFilesAdded,{count:n.length}));let o=this.getCurrentFiles(),s=this.multiple?[...o,...n]:[n[0]];this.commitFiles(s,`add`,n.map(e=>e.fileId)),this.uploadStrategy===`custom`&&n.forEach(e=>{this.dispatchEvent(new CustomEvent(`file-upload-requested`,{detail:{fileId:e.fileId,file:e.file,attributes:e.attributes},bubbles:!0,composed:!0}))})}getCurrentFiles(){return this.isControlled?this.value??[]:this.files}cancelTransfer(e){if(this.disabled)return;let t=this.getCurrentFiles().find(t=>t.fileId===e);t&&(this.removeFileItem(e),this.dispatchEvent(new CustomEvent(`transfer-cancelled`,{detail:{fileId:t.fileId,file:t.file,attributes:t.attributes},bubbles:!0,composed:!0})))}removeFileItem(e){if(this.disabled)return;let t=this.getCurrentFiles(),n=t.filter(t=>t.fileId!==e);n.length!==t.length&&this.commitFiles(n,`remove`,[e])}updateFileItem(e,t){let n=this.getCurrentFiles().map(n=>n.fileId===e?{...n,...t}:n);this.commitFiles(n,`update`,[e])}commitFiles(e,t,n){this.isControlled||(this.files=e,this.syncThumbnailUrls(e)),this.validationErrorMessage===this.requiredSelectionMessage&&e.length>0&&(this.validationErrorMessage=null),this.dispatchEvent(new CustomEvent(`files-changed`,{detail:{files:e,reason:t,changedFileIds:n},bubbles:!0,composed:!0}))}getThumbnailUrl(e){return this.thumbnailUrls[e.fileId]}getTransferProgress(e){let t=this.transfers.find(t=>t.fileId===e);return t?t.progress:this.uploadStrategy===`form`?`done`:`queued`}getTransferForFile(e){return this.transfers.find(t=>t.fileId===e)}isImageFile(e){return v(e)}formatFileSize(e){return c(e)}getResolvedAcceptValue(){return p(this.accept,this.allowedFormats)}getSupportedFormatsText(){return h(this.allowedFormats,this.accept)}getSortedFilesAndTransfers(){return b(this.getCurrentFiles(),this.transfers,this.uploadStrategy)}validateFile(e){let t=_(e,{allowedFormats:this.allowedFormats,maxFileSize:this.maxFileSize,formatErrorMessage:this.formatErrorMessage,sizeErrorMessage:this.sizeErrorMessage,onFileValidation:this.onFileValidation});if(t)return t;let n={file:e,errorMessage:null},r=new CustomEvent(`file-validate`,{detail:n,bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(r),n.errorMessage?n.errorMessage:r.defaultPrevented?this.pktStrings.get(`fileupload`).genericValidationRejection:null}syncThumbnailUrls(e){if(!(typeof URL<`u`&&typeof URL.createObjectURL==`function`&&typeof URL.revokeObjectURL==`function`)){this.thumbnailUrls={},this.thumbnailFileById.clear();return}let t=new Set(e.map(e=>e.fileId)),n={};for(let[e,n]of Object.entries(this.thumbnailUrls))t.has(e)||(URL.revokeObjectURL(n),this.thumbnailFileById.delete(e));for(let t of e){let e=this.thumbnailUrls[t.fileId],r=this.thumbnailFileById.get(t.fileId);if(!t.file||!this.isImageFile(t)){e&&(URL.revokeObjectURL(e),this.thumbnailFileById.delete(t.fileId));continue}if(e&&r===t.file){n[t.fileId]=e;continue}e&&r!==t.file&&URL.revokeObjectURL(e);let i=URL.createObjectURL(t.file);this.thumbnailFileById.set(t.fileId,t.file),n[t.fileId]=i}this.thumbnailUrls=n}revokeAllThumbnailUrls(){if(typeof URL>`u`||typeof URL.revokeObjectURL!=`function`){this.thumbnailUrls={},this.thumbnailFileById.clear();return}Object.values(this.thumbnailUrls).forEach(e=>URL.revokeObjectURL(e)),this.thumbnailUrls={},this.thumbnailFileById.clear()}getSrUploadedMessage(){if(this.addedAnnouncement)return this.addedAnnouncement;let{totalCount:e,uploadedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesUploadedOfTotal,{uploaded:t,total:e,label:r.n(e,n.fileLabelOne,n.fileLabelOther)})}getSrErrorsMessage(){let{totalCount:e,failedCount:t}=C(this.getCurrentFiles(),this.transfers);if(e===0||t===0)return``;let n=this.pktStrings.get(`fileupload`);return r.t(n.srFilesFailedOfTotal,{failed:t,total:e,label:r.n(e,n.fileLabelOne,n.fileLabelOther)})}syncFormSubmitListener(){let e=this.closest(`form`);this.connectedForm!==e&&(this.teardownFormSubmitListener(),this.connectedForm=e,this.connectedForm&&this.connectedForm.addEventListener(`submit`,this.onHostFormSubmit))}teardownFormSubmitListener(){this.connectedForm&&=(this.connectedForm.removeEventListener(`submit`,this.onHostFormSubmit),null)}};e.n([e.u({type:String})],T.prototype,`id`,void 0),e.n([e.u({type:String})],T.prototype,`name`,void 0),e.n([e.u({type:String})],T.prototype,`label`,void 0),e.n([e.u({type:String})],T.prototype,`helptext`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown`})],T.prototype,`helptextDropdown`,void 0),e.n([e.u({type:String,attribute:`helptext-dropdown-button`})],T.prototype,`helptextDropdownButton`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`required`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`multiple`,void 0),e.n([e.u({type:Boolean,reflect:!0})],T.prototype,`disabled`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`fullwidth`})],T.prototype,`fullwidth`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`upload-strategy`})],T.prototype,`uploadStrategy`,void 0),e.n([e.u({type:String,reflect:!0,attribute:`item-renderer`})],T.prototype,`itemRenderer`,void 0),e.n([e.u({type:String})],T.prototype,`accept`,void 0),e.n([e.u({converter:i.t.csvToArray,attribute:`allowed-formats`})],T.prototype,`allowedFormats`,void 0),e.n([e.u({type:String,attribute:`format-error-message`})],T.prototype,`formatErrorMessage`,void 0),e.n([e.u({attribute:`max-file-size`})],T.prototype,`maxFileSize`,void 0),e.n([e.u({type:String,attribute:`size-error-message`})],T.prototype,`sizeErrorMessage`,void 0),e.n([e.u({attribute:!1})],T.prototype,`onFileValidation`,void 0),e.n([e.u({attribute:!1})],T.prototype,`transfers`,void 0),e.n([e.u({type:Boolean,attribute:`add-comments-enabled`})],T.prototype,`addCommentsEnabled`,void 0),e.n([e.u({type:Boolean,attribute:`rename-files-enabled`})],T.prototype,`renameFilesEnabled`,void 0),e.n([e.u({attribute:!1})],T.prototype,`extraOperations`,void 0),e.n([e.u({type:Boolean,reflect:!0,attribute:`enable-image-preview`})],T.prototype,`enableImagePreview`,void 0),e.n([e.u({type:Boolean,attribute:`has-error`})],T.prototype,`hasError`,void 0),e.n([e.u({type:String,attribute:`error-message`})],T.prototype,`errorMessage`,void 0),e.n([e.u({type:Boolean,attribute:`optional-tag`})],T.prototype,`optionalTag`,void 0),e.n([e.u({type:String,attribute:`optional-text`})],T.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean,attribute:`required-tag`})],T.prototype,`requiredTag`,void 0),e.n([e.u({type:String,attribute:`required-text`})],T.prototype,`requiredText`,void 0),e.n([e.u({type:String,attribute:`tag-text`})],T.prototype,`tagText`,void 0),e.n([e.u({type:Number,attribute:`truncate-tail`})],T.prototype,`truncateTail`,void 0),e.n([e.u({attribute:!1})],T.prototype,`value`,void 0),e.n([e.u({attribute:!1})],T.prototype,`defaultValue`,void 0),e.n([e.l()],T.prototype,`files`,void 0),e.n([e.l()],T.prototype,`isDragActive`,void 0),e.n([e.l()],T.prototype,`validationErrorMessage`,void 0),e.n([e.l()],T.prototype,`addedAnnouncement`,void 0),e.n([e.l()],T.prototype,`thumbnailUrls`,void 0);var E=`comments`,D=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:`${String(t.getDate()).padStart(2,`0`)}.${String(t.getMonth()+1).padStart(2,`0`)}.${t.getFullYear()} kl. ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`},O=(e,t,n)=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t()),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())},k=(e,t,n)=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),t())},A=e=>({id:`remove`,title:`Slett`,ariaLabel:`Slett fil`,onClick:({file:t})=>e(t.fileId)}),j=()=>({id:`rename`,title:`Rediger`,ariaLabel:`Rediger filnavn`,renderInlineUI:t=>{let n=t.getAttribute(`targetFilename`)||t.file.attributes?.targetFilename||t.file.file?.name||``,r=`pkt-fileupload-rename-${t.file.fileId}`,i=()=>{let e=document.getElementById(r)?.value?.trim();e&&t.setAttribute(`targetFilename`,e),t.close()};return e._`
|
|
2
2
|
<label for=${r} class="pkt-sr-only">Endre filnavn</label>
|
|
3
3
|
<input
|
|
4
4
|
id=${r}
|
|
@@ -164,11 +164,11 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
164
164
|
${o?e._`<span class="pkt-fileupload__queue-display__item__error-message"
|
|
165
165
|
>${o}</span
|
|
166
166
|
>`:null}
|
|
167
|
-
`},B=({file:t,disabled:
|
|
167
|
+
`},B=({file:t,disabled:r,inputName:i,operations:a,activeOperationId:o,onActivateOperation:s,onCloseOperation:c,getFileAttribute:l,setFileAttribute:u})=>{let d=a.find(e=>e.id===o);if(d?.renderInlineUI||d?.renderExtendedUI)return null;let f=a.map(a=>{let d=L({operationId:a.id,file:t,inputName:i,disabled:r,isActive:a.id===o,onActivateOperation:s,onCloseOperation:c,getFileAttribute:l,setFileAttribute:u}),f=typeof a.title==`function`?a.title(t):a.title;if(!f)return null;let p=typeof a.ariaLabel==`function`?a.ariaLabel(t):a.ariaLabel;return e._`<button
|
|
168
168
|
type="button"
|
|
169
169
|
class="pkt-fileupload__queue-display__item__operation"
|
|
170
|
-
aria-label=${
|
|
171
|
-
?disabled=${
|
|
170
|
+
aria-label=${n.t(p)}
|
|
171
|
+
?disabled=${r}
|
|
172
172
|
@click=${()=>{(a.renderInlineUI||a.renderExtendedUI)&&d.activate(),a.onClick?.(d)}}
|
|
173
173
|
>
|
|
174
174
|
${f}
|
|
@@ -190,7 +190,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
190
190
|
<button
|
|
191
191
|
type="button"
|
|
192
192
|
class="pkt-fileupload__queue-display__item__thumbnail__image-wrapper pkt-btn pkt-btn--medium pkt-btn--secondary pkt-btn--label-only"
|
|
193
|
-
aria-label=${
|
|
193
|
+
aria-label=${r.t(e.s.fileupload.previewImage,{filename:d})}
|
|
194
194
|
?disabled=${!m}
|
|
195
195
|
@click=${()=>{!m||!l||l(i.fileId)}}
|
|
196
196
|
>
|
|
@@ -201,7 +201,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
201
201
|
aria-hidden="true"
|
|
202
202
|
></pkt-icon>`:null}
|
|
203
203
|
${f?e._`<img
|
|
204
|
-
src=${
|
|
204
|
+
src=${n.t(a)}
|
|
205
205
|
alt=${d}
|
|
206
206
|
@error=${()=>u?.(i.fileId)}
|
|
207
207
|
/>`:e._`<pkt-icon
|
|
@@ -272,7 +272,7 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
272
272
|
>
|
|
273
273
|
${n}
|
|
274
274
|
</pkt-input-wrapper>
|
|
275
|
-
`:n}renderContent(){let
|
|
275
|
+
`:n}renderContent(){let r=this.getSortedFilesAndTransfers(),i=this.getPreviewableImages(r),a=this.pktStrings.get(`fileupload`),o=this.getSupportedFormatsText(),s=[!this.label&&this.helptext?`${this.id}-helptext`:void 0,this.hasEffectiveError?`${this.id}-error`:void 0].filter(Boolean).join(` `)||void 0,c=this.itemRenderer===`thumbnail`?this.multiple?{dragInactive:a.dropZoneDragMultipleThumbnail,dragActive:a.dropZoneDragActiveMultipleThumbnail,openFileDialog:a.dropZoneOpenFileDialogMultipleThumbnail}:{dragInactive:a.dropZoneDragSingleThumbnail,dragActive:a.dropZoneDragActiveSingleThumbnail,openFileDialog:a.dropZoneOpenFileDialogSingleThumbnail}:this.multiple?{dragInactive:a.dropZoneDragMultiple,dragActive:a.dropZoneDragActiveMultiple,openFileDialog:a.dropZoneOpenFileDialogMultiple}:{dragInactive:a.dropZoneDragSingle,dragActive:a.dropZoneDragActiveSingle,openFileDialog:a.dropZoneOpenFileDialogSingle};return e._`
|
|
276
276
|
<div
|
|
277
277
|
class=${t.t({"pkt-fileupload":!0,"pkt-fileupload--full-width":this.fullwidth,"pkt-fileupload--error":this.hasEffectiveError,"pkt-fileupload--disabled":this.disabled})}
|
|
278
278
|
aria-disabled=${String(this.disabled)}
|
|
@@ -294,18 +294,18 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
294
294
|
<input
|
|
295
295
|
id=${`${this.id}-input`}
|
|
296
296
|
type="file"
|
|
297
|
-
name=${
|
|
297
|
+
name=${n.t(this.uploadStrategy===`form`?this.name:void 0)}
|
|
298
298
|
?multiple=${this.multiple}
|
|
299
299
|
?disabled=${this.disabled}
|
|
300
300
|
?required=${this.required&&this.uploadStrategy===`form`}
|
|
301
301
|
accept=${this.getResolvedAcceptValue()}
|
|
302
|
-
aria-label=${
|
|
303
|
-
aria-required=${
|
|
304
|
-
aria-invalid=${
|
|
305
|
-
aria-describedby=${
|
|
302
|
+
aria-label=${n.t(this.label?void 0:this.multiple?`Velg filer`:`Velg fil`)}
|
|
303
|
+
aria-required=${n.t(this.required?`true`:void 0)}
|
|
304
|
+
aria-invalid=${n.t(this.hasEffectiveError?`true`:void 0)}
|
|
305
|
+
aria-describedby=${n.t(s)}
|
|
306
306
|
@change=${this.onNativeFileChange}
|
|
307
307
|
/>
|
|
308
|
-
${this.uploadStrategy===`custom`?
|
|
308
|
+
${this.uploadStrategy===`custom`?r.map(t=>e._`<input type="hidden" name=${this.name} value=${t.fileId} />`):null}
|
|
309
309
|
<div class="pkt-fileupload__drop-zone__placeholder">
|
|
310
310
|
<pkt-icon
|
|
311
311
|
name="attachment"
|
|
@@ -339,8 +339,8 @@ const e=require("./element-DRc10X2R.cjs"),t=require("./class-map-BEib48YL.cjs"),
|
|
|
339
339
|
${this.effectiveErrorMessage}
|
|
340
340
|
</pkt-alert>
|
|
341
341
|
`:null}
|
|
342
|
-
${
|
|
343
|
-
${
|
|
342
|
+
${r.length>0?e._`<ul class="pkt-fileupload__queue-display">
|
|
343
|
+
${r.map(e=>this.renderQueueItem(e,i))}
|
|
344
344
|
</ul>`:null}
|
|
345
345
|
${this.renderPreviewModal(i)}
|
|
346
346
|
</div>
|