@oslokommune/punkt-elements 12.18.12 → 12.19.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/dist/index.d.ts +29 -19
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +2 -2
- package/dist/progressbar-872kMPws.cjs +21 -0
- package/dist/progressbar-KBLmOgxm.js +160 -0
- package/package.json +4 -4
- package/src/components/progressbar/progressbar.ts +108 -59
- package/dist/progressbar-BS_oawSB.js +0 -150
- package/dist/progressbar-CuXkbAhJ.cjs +0 -32
package/dist/index.d.ts
CHANGED
|
@@ -24,18 +24,20 @@ declare interface IPktModal {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export declare interface IPktProgressbar {
|
|
27
|
+
ariaLabel?: string | null;
|
|
28
|
+
ariaLabelledby?: string | null;
|
|
29
|
+
ariaLive?: TAriaLive | null;
|
|
30
|
+
ariaValueText?: string | null;
|
|
31
|
+
id?: string | null;
|
|
32
|
+
role?: TProgressbarRole;
|
|
33
|
+
skin?: TProgressbarSkin;
|
|
34
|
+
statusPlacement?: TProgressbarStatusPlacement;
|
|
35
|
+
statusType?: TProgressbarStatusType;
|
|
36
|
+
title?: string | null;
|
|
37
|
+
titlePosition?: TProgressbarTitlePosition;
|
|
27
38
|
valueCurrent: number;
|
|
28
39
|
valueMax?: number;
|
|
29
40
|
valueMin?: number;
|
|
30
|
-
ariaValueText?: string;
|
|
31
|
-
skin?: TProgressbarSkin;
|
|
32
|
-
title?: string;
|
|
33
|
-
titlePosition?: TProgressbarTitlePosition;
|
|
34
|
-
statusType?: TProgressbarStatusType;
|
|
35
|
-
statusPlacement?: TProgressbarStatusPlacement;
|
|
36
|
-
ariaLabel?: string;
|
|
37
|
-
ariaLabelledby?: string;
|
|
38
|
-
role?: TProgressbarRole;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
declare interface IPktSelect {
|
|
@@ -455,25 +457,33 @@ export declare class PktModal extends PktElement implements IPktModal {
|
|
|
455
457
|
}
|
|
456
458
|
|
|
457
459
|
export declare class PktProgressbar extends PktElement implements IPktProgressbar {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
460
|
+
constructor();
|
|
461
|
+
ariaLabel: string | null;
|
|
462
|
+
ariaLabelledby: string | null;
|
|
463
|
+
ariaValueText: string | null;
|
|
464
|
+
ariaLive: TAriaLive;
|
|
465
|
+
id: string;
|
|
466
|
+
role: TProgressbarRole;
|
|
461
467
|
skin: TProgressbarSkin;
|
|
468
|
+
statusPlacement: TProgressbarStatusPlacement;
|
|
469
|
+
statusType: TProgressbarStatusType;
|
|
462
470
|
title: string;
|
|
463
471
|
titlePosition: TProgressbarTitlePosition;
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
ariaLabelledby: string;
|
|
468
|
-
ariaValueText: string;
|
|
469
|
-
role: TProgressbarRole;
|
|
472
|
+
valueCurrent: number;
|
|
473
|
+
valueMax: number;
|
|
474
|
+
valueMin: number;
|
|
470
475
|
private labelWidth;
|
|
471
|
-
private
|
|
476
|
+
private progressbarId;
|
|
477
|
+
private computedAriaLabelledby;
|
|
478
|
+
private computedAriaValueText;
|
|
472
479
|
private labelRef;
|
|
473
480
|
private progressBarRef;
|
|
474
481
|
firstUpdated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
475
482
|
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
476
483
|
render(): TemplateResult<1>;
|
|
484
|
+
private setComputedValues;
|
|
485
|
+
private syncAttributes;
|
|
486
|
+
private _handleAttribute;
|
|
477
487
|
}
|
|
478
488
|
|
|
479
489
|
/**
|
package/dist/pkt-index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./alert-DfjFhisP.cjs"),u=require("./calendar-QSulz7im.cjs"),d=require("./card-DY2rbosk.cjs"),t=require("./icon-CdMQ6zBT.cjs"),k=require("./pkt-slot-controller-mHT3foJ4.cjs"),i=require("./ref-DCOsLZQg.cjs"),P=require("./class-map-Boa7BqCc.cjs"),b=require("./datepicker-BUUPN2Ak.cjs"),g=require("./helptext-iZEgxz2U.cjs"),h=require("./input-wrapper-DraeSNb6.cjs"),m=require("./link-DTldg4W2.cjs"),f=require("./linkcard-C5GUN22k.cjs"),y=require("./messagebox-DLsgkPtN.cjs"),v=require("./modal-B-n1mhZ1.cjs"),x=require("./progressbar-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./alert-DfjFhisP.cjs"),u=require("./calendar-QSulz7im.cjs"),d=require("./card-DY2rbosk.cjs"),t=require("./icon-CdMQ6zBT.cjs"),k=require("./pkt-slot-controller-mHT3foJ4.cjs"),i=require("./ref-DCOsLZQg.cjs"),P=require("./class-map-Boa7BqCc.cjs"),b=require("./datepicker-BUUPN2Ak.cjs"),g=require("./helptext-iZEgxz2U.cjs"),h=require("./input-wrapper-DraeSNb6.cjs"),m=require("./link-DTldg4W2.cjs"),f=require("./linkcard-C5GUN22k.cjs"),y=require("./messagebox-DLsgkPtN.cjs"),v=require("./modal-B-n1mhZ1.cjs"),x=require("./progressbar-872kMPws.cjs"),C=require("./tag-Du8P8YIp.cjs"),O=require("./textarea-DPTHMOSZ.cjs"),j=require("./textinput-OmztIgoC.cjs"),q=require("./select-CFdjp5Sk.cjs");var S=Object.defineProperty,$=Object.getOwnPropertyDescriptor,o=(a,e,r,s)=>{for(var n=s>1?void 0:s?$(e,r):e,l=a.length-1,p;l>=0;l--)(p=a[l])&&(n=(s?p(e,r,n):p(n))||n);return s&&n&&S(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=i.e(),this.namedSlot=i.e(),this.slotController=new k.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
|
|
2
2
|
<div class="${P.e(e)}">
|
|
3
3
|
<h1 class="pkt-txt-28">${this.string}</h1>
|
|
4
4
|
|
package/dist/pkt-index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { P as N } from "./link-CWGiizQI.js";
|
|
|
14
14
|
import { P as W } from "./linkcard-BkgsoZ7N.js";
|
|
15
15
|
import { P as z } from "./messagebox-CtWD9b0a.js";
|
|
16
16
|
import { P as J } from "./modal-CV7Wyhsa.js";
|
|
17
|
-
import { P as V } from "./progressbar-
|
|
17
|
+
import { P as V } from "./progressbar-KBLmOgxm.js";
|
|
18
18
|
import { P as Y } from "./tag-DlnEKEym.js";
|
|
19
19
|
import { P as tt } from "./textarea-8VOlYKdT.js";
|
|
20
20
|
import { P as rt } from "./textinput-D2uB8zkQ.js";
|
package/dist/pkt-progressbar.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./progressbar-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./progressbar-872kMPws.cjs");Object.defineProperty(exports,"PktProgressbar",{enumerable:!0,get:()=>e.PktProgressbar});exports.default=e.PktProgressbar$1;
|
package/dist/pkt-progressbar.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";const n=require("./class-map-Boa7BqCc.cjs"),e=require("./icon-CdMQ6zBT.cjs"),p=require("./state-SKYD8kRO.cjs"),h=require("./ref-DCOsLZQg.cjs"),b=require("./stringutils-CkVRq4jP.cjs");/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2018 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/const d="important",P=" !"+d,v=e.e(class extends e.i{constructor(l){var t;if(super(l),l.type!==e.t$1.ATTRIBUTE||l.name!=="style"||((t=l.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(l){return Object.keys(l).reduce((t,s)=>{const r=l[s];return r==null?t:t+`${s=s.includes("-")?s:s.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`},"")}update(l,[t]){const{style:s}=l.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(const r of this.ft)t[r]==null&&(this.ft.delete(r),r.includes("-")?s.removeProperty(r):s[r]=null);for(const r in t){const i=t[r];if(i!=null){this.ft.add(r);const o=typeof i=="string"&&i.endsWith(P);r.includes("-")||o?s.setProperty(r,o?i.slice(0,-11):i,o?d:""):s[r]=i}}return e.T}});var f=Object.defineProperty,k=Object.getOwnPropertyDescriptor,a=(l,t,s,r)=>{for(var i=r>1?void 0:r?k(t,s):t,o=l.length-1,u;o>=0;o--)(u=l[o])&&(i=(r?u(t,s,i):u(i))||i);return r&&i&&f(t,s,i),i};exports.PktProgressbar=class extends e.PktElement{constructor(){super(),this.ariaLabel=null,this.ariaLabelledby=null,this.ariaValueText=null,this.ariaLive="polite",this.id=b.uuidish(),this.role="progressbar",this.skin="dark-blue",this.statusPlacement="following",this.statusType="none",this.title="",this.titlePosition="left",this.valueCurrent=0,this.valueMax=100,this.valueMin=0,this.labelWidth=0,this.progressbarId=this.id,this.computedAriaLabelledby=null,this.computedAriaValueText="",this.labelRef=h.e(),this.progressBarRef=h.e()}firstUpdated(t){super.firstUpdated(t),this.setComputedValues(),this.syncAttributes()}updated(t){super.updated(t),t.has("valueCurrent")&&this.labelRef.value&&(this.labelWidth=this.labelRef.value.getBoundingClientRect().width||0),t.has("id")&&this.id&&(this.progressBarId=this.id),(t.has("statusType")||t.has("id")||t.has("ariaLabelledby"))&&(this.progressbarId=this.id||b.uuidish(),this.computedAriaLabelledby=this.ariaLabelledby||`${this.progressbarId}-title`),(t.has("ariaValueText")||t.has("valueCurrent")||t.has("valueMax"))&&(this.computedAriaValueText=this.statusType==="fraction"&&!this.ariaValueText?`${this.valueCurrent} av ${this.valueMax-this.valueMin}`:this.ariaValueText||""),this.syncAttributes()}render(){const t=this.statusType!=="none",s=this.valueMax-this.valueMin,r=this.valueCurrent/s*100,i=this.statusType==="fraction"?Math.round(r):Math.round((this.valueCurrent-this.valueMin)/(this.valueMax-this.valueMin)*100),o=`${this.valueCurrent} av ${s}`,u=n.e({"pkt-progressbar__bar":!0,[`pkt-progressbar__bar--${this.skin}`]:!!this.skin}),c=n.e({"pkt-progressbar__title":!0,"pkt-progressbar__title-center":this.titlePosition==="center"}),g=n.e({"pkt-progressbar__status":!0,"pkt-progressbar__status--center":this.statusPlacement==="center"}),y=n.e({"pkt-progressbar__status-placement--following":this.statusPlacement==="following","pkt-progressbar__status-placement--center":this.statusPlacement==="center","pkt-progressbar__status-placement--left":this.statusPlacement==="left"});return e.x` <div
|
|
6
|
+
class="pkt-progressbar__container"
|
|
7
|
+
.ref=${this.progressBarRef}
|
|
8
|
+
style=${v({"--pkt-progress-label-width":`${this.labelWidth}px`,"--pkt-progress-width":`${i}%`})}
|
|
9
|
+
>
|
|
10
|
+
${this.title?e.x`<p id=${`${this.progressBarId}-title`} class=${c}>${this.title}</p>`:e.E}
|
|
11
|
+
|
|
12
|
+
<div class="pkt-progressbar__bar-wrapper">
|
|
13
|
+
<div class=${u}></div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
${t?e.x`<div class=${g}>
|
|
17
|
+
<span class=${y} ${h.n(this.labelRef)}>
|
|
18
|
+
${this.statusType==="percentage"?`${i}%`:o}
|
|
19
|
+
</span>
|
|
20
|
+
</div>`:e.E}
|
|
21
|
+
</div>`}setComputedValues(){this.progressbarId=this.id||b.uuidish(),this.computedAriaLabelledby=this.ariaLabelledby||`${this.progressbarId}-title`,this.computedAriaValueText=this.statusType==="fraction"&&!this.ariaValueText?`${this.valueCurrent} av ${this.valueMax-this.valueMin}`:this.ariaValueText||""}syncAttributes(){this._handleAttribute("aria-live",this.ariaLive),this._handleAttribute("aria-valuenow",this.valueCurrent),this._handleAttribute("aria-valuemin",this.valueMin),this._handleAttribute("aria-valuemax",this.valueMax),this._handleAttribute("aria-valuetext",this.computedAriaValueText),this._handleAttribute("aria-label",this.ariaLabel),this._handleAttribute("role",this.role),this._handleAttribute("aria-atomic","true"),this._handleAttribute("id",this.progressbarId),this.ariaLabel||this._handleAttribute("aria-labelledby",this.computedAriaLabelledby)}_handleAttribute(t,s){s==null||s===""?this.removeAttribute(t):this.setAttribute(t,String(s))}};a([e.n({type:String})],exports.PktProgressbar.prototype,"ariaLabel",2);a([e.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"ariaLabelledby",2);a([e.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"ariaValueText",2);a([e.n({type:String})],exports.PktProgressbar.prototype,"ariaLive",2);a([e.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"id",2);a([e.n({type:String})],exports.PktProgressbar.prototype,"role",2);a([e.n({type:String})],exports.PktProgressbar.prototype,"skin",2);a([e.n({type:String})],exports.PktProgressbar.prototype,"statusPlacement",2);a([e.n({type:String})],exports.PktProgressbar.prototype,"statusType",2);a([e.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"title",2);a([e.n({type:String})],exports.PktProgressbar.prototype,"titlePosition",2);a([e.n({type:Number,reflect:!0})],exports.PktProgressbar.prototype,"valueCurrent",2);a([e.n({type:Number})],exports.PktProgressbar.prototype,"valueMax",2);a([e.n({type:Number})],exports.PktProgressbar.prototype,"valueMin",2);a([p.r()],exports.PktProgressbar.prototype,"labelWidth",2);a([p.r()],exports.PktProgressbar.prototype,"progressbarId",2);a([p.r()],exports.PktProgressbar.prototype,"computedAriaLabelledby",2);a([p.r()],exports.PktProgressbar.prototype,"computedAriaValueText",2);exports.PktProgressbar=a([e.t("pkt-progressbar")],exports.PktProgressbar);const _=exports.PktProgressbar;exports.PktProgressbar$1=_;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { e as n } from "./class-map-hz16xq5a.js";
|
|
2
|
+
import { e as g, i as _, b as $, T as A, P as x, x as b, E as c, n as u, t as T } from "./icon-wUXeHiBk.js";
|
|
3
|
+
import { r as h } from "./state-BfyXV7EL.js";
|
|
4
|
+
import { e as y, n as k } from "./ref-DuFGTLVX.js";
|
|
5
|
+
import { u as d } from "./stringutils-DJjRa8dG.js";
|
|
6
|
+
/**
|
|
7
|
+
* @license
|
|
8
|
+
* Copyright 2018 Google LLC
|
|
9
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
10
|
+
*/
|
|
11
|
+
const v = "important", C = " !" + v, M = g(class extends _ {
|
|
12
|
+
constructor(t) {
|
|
13
|
+
var e;
|
|
14
|
+
if (super(t), t.type !== $.ATTRIBUTE || t.name !== "style" || ((e = t.strings) == null ? void 0 : e.length) > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
|
|
15
|
+
}
|
|
16
|
+
render(t) {
|
|
17
|
+
return Object.keys(t).reduce((e, a) => {
|
|
18
|
+
const s = t[a];
|
|
19
|
+
return s == null ? e : e + `${a = a.includes("-") ? a : a.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${s};`;
|
|
20
|
+
}, "");
|
|
21
|
+
}
|
|
22
|
+
update(t, [e]) {
|
|
23
|
+
const { style: a } = t.element;
|
|
24
|
+
if (this.ft === void 0) return this.ft = new Set(Object.keys(e)), this.render(e);
|
|
25
|
+
for (const s of this.ft) e[s] == null && (this.ft.delete(s), s.includes("-") ? a.removeProperty(s) : a[s] = null);
|
|
26
|
+
for (const s in e) {
|
|
27
|
+
const l = e[s];
|
|
28
|
+
if (l != null) {
|
|
29
|
+
this.ft.add(s);
|
|
30
|
+
const o = typeof l == "string" && l.endsWith(C);
|
|
31
|
+
s.includes("-") || o ? a.setProperty(s, o ? l.slice(0, -11) : l, o ? v : "") : a[s] = l;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return A;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
var L = Object.defineProperty, S = Object.getOwnPropertyDescriptor, i = (t, e, a, s) => {
|
|
38
|
+
for (var l = s > 1 ? void 0 : s ? S(e, a) : e, o = t.length - 1, p; o >= 0; o--)
|
|
39
|
+
(p = t[o]) && (l = (s ? p(e, a, l) : p(l)) || l);
|
|
40
|
+
return s && l && L(e, a, l), l;
|
|
41
|
+
};
|
|
42
|
+
let r = class extends x {
|
|
43
|
+
constructor() {
|
|
44
|
+
super(), this.ariaLabel = null, this.ariaLabelledby = null, this.ariaValueText = null, this.ariaLive = "polite", this.id = d(), this.role = "progressbar", this.skin = "dark-blue", this.statusPlacement = "following", this.statusType = "none", this.title = "", this.titlePosition = "left", this.valueCurrent = 0, this.valueMax = 100, this.valueMin = 0, this.labelWidth = 0, this.progressbarId = this.id, this.computedAriaLabelledby = null, this.computedAriaValueText = "", this.labelRef = y(), this.progressBarRef = y();
|
|
45
|
+
}
|
|
46
|
+
firstUpdated(t) {
|
|
47
|
+
super.firstUpdated(t), this.setComputedValues(), this.syncAttributes();
|
|
48
|
+
}
|
|
49
|
+
updated(t) {
|
|
50
|
+
super.updated(t), t.has("valueCurrent") && this.labelRef.value && (this.labelWidth = this.labelRef.value.getBoundingClientRect().width || 0), t.has("id") && this.id && (this.progressBarId = this.id), (t.has("statusType") || t.has("id") || t.has("ariaLabelledby")) && (this.progressbarId = this.id || d(), this.computedAriaLabelledby = this.ariaLabelledby || `${this.progressbarId}-title`), (t.has("ariaValueText") || t.has("valueCurrent") || t.has("valueMax")) && (this.computedAriaValueText = this.statusType === "fraction" && !this.ariaValueText ? `${this.valueCurrent} av ${this.valueMax - this.valueMin}` : this.ariaValueText || ""), this.syncAttributes();
|
|
51
|
+
}
|
|
52
|
+
render() {
|
|
53
|
+
const t = this.statusType !== "none", e = this.valueMax - this.valueMin, a = this.valueCurrent / e * 100, s = this.statusType === "fraction" ? Math.round(a) : Math.round((this.valueCurrent - this.valueMin) / (this.valueMax - this.valueMin) * 100), l = `${this.valueCurrent} av ${e}`, o = n({
|
|
54
|
+
"pkt-progressbar__bar": !0,
|
|
55
|
+
[`pkt-progressbar__bar--${this.skin}`]: !!this.skin
|
|
56
|
+
}), p = n({
|
|
57
|
+
"pkt-progressbar__title": !0,
|
|
58
|
+
"pkt-progressbar__title-center": this.titlePosition === "center"
|
|
59
|
+
}), f = n({
|
|
60
|
+
"pkt-progressbar__status": !0,
|
|
61
|
+
"pkt-progressbar__status--center": this.statusPlacement === "center"
|
|
62
|
+
}), m = n({
|
|
63
|
+
"pkt-progressbar__status-placement--following": this.statusPlacement === "following",
|
|
64
|
+
"pkt-progressbar__status-placement--center": this.statusPlacement === "center",
|
|
65
|
+
"pkt-progressbar__status-placement--left": this.statusPlacement === "left"
|
|
66
|
+
});
|
|
67
|
+
return b` <div
|
|
68
|
+
class="pkt-progressbar__container"
|
|
69
|
+
.ref=${this.progressBarRef}
|
|
70
|
+
style=${M({
|
|
71
|
+
"--pkt-progress-label-width": `${this.labelWidth}px`,
|
|
72
|
+
"--pkt-progress-width": `${s}%`
|
|
73
|
+
})}
|
|
74
|
+
>
|
|
75
|
+
${this.title ? b`<p id=${`${this.progressBarId}-title`} class=${p}>${this.title}</p>` : c}
|
|
76
|
+
|
|
77
|
+
<div class="pkt-progressbar__bar-wrapper">
|
|
78
|
+
<div class=${o}></div>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
${t ? b`<div class=${f}>
|
|
82
|
+
<span class=${m} ${k(this.labelRef)}>
|
|
83
|
+
${this.statusType === "percentage" ? `${s}%` : l}
|
|
84
|
+
</span>
|
|
85
|
+
</div>` : c}
|
|
86
|
+
</div>`;
|
|
87
|
+
}
|
|
88
|
+
// methods
|
|
89
|
+
setComputedValues() {
|
|
90
|
+
this.progressbarId = this.id || d(), this.computedAriaLabelledby = this.ariaLabelledby || `${this.progressbarId}-title`, this.computedAriaValueText = this.statusType === "fraction" && !this.ariaValueText ? `${this.valueCurrent} av ${this.valueMax - this.valueMin}` : this.ariaValueText || "";
|
|
91
|
+
}
|
|
92
|
+
syncAttributes() {
|
|
93
|
+
this._handleAttribute("aria-live", this.ariaLive), this._handleAttribute("aria-valuenow", this.valueCurrent), this._handleAttribute("aria-valuemin", this.valueMin), this._handleAttribute("aria-valuemax", this.valueMax), this._handleAttribute("aria-valuetext", this.computedAriaValueText), this._handleAttribute("aria-label", this.ariaLabel), this._handleAttribute("role", this.role), this._handleAttribute("aria-atomic", "true"), this._handleAttribute("id", this.progressbarId), this.ariaLabel || this._handleAttribute("aria-labelledby", this.computedAriaLabelledby);
|
|
94
|
+
}
|
|
95
|
+
_handleAttribute(t, e) {
|
|
96
|
+
e == null || e === "" ? this.removeAttribute(t) : this.setAttribute(t, String(e));
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
i([
|
|
100
|
+
u({ type: String })
|
|
101
|
+
], r.prototype, "ariaLabel", 2);
|
|
102
|
+
i([
|
|
103
|
+
u({ type: String, reflect: !0 })
|
|
104
|
+
], r.prototype, "ariaLabelledby", 2);
|
|
105
|
+
i([
|
|
106
|
+
u({ type: String, reflect: !0 })
|
|
107
|
+
], r.prototype, "ariaValueText", 2);
|
|
108
|
+
i([
|
|
109
|
+
u({ type: String })
|
|
110
|
+
], r.prototype, "ariaLive", 2);
|
|
111
|
+
i([
|
|
112
|
+
u({ type: String, reflect: !0 })
|
|
113
|
+
], r.prototype, "id", 2);
|
|
114
|
+
i([
|
|
115
|
+
u({ type: String })
|
|
116
|
+
], r.prototype, "role", 2);
|
|
117
|
+
i([
|
|
118
|
+
u({ type: String })
|
|
119
|
+
], r.prototype, "skin", 2);
|
|
120
|
+
i([
|
|
121
|
+
u({ type: String })
|
|
122
|
+
], r.prototype, "statusPlacement", 2);
|
|
123
|
+
i([
|
|
124
|
+
u({ type: String })
|
|
125
|
+
], r.prototype, "statusType", 2);
|
|
126
|
+
i([
|
|
127
|
+
u({ type: String, reflect: !0 })
|
|
128
|
+
], r.prototype, "title", 2);
|
|
129
|
+
i([
|
|
130
|
+
u({ type: String })
|
|
131
|
+
], r.prototype, "titlePosition", 2);
|
|
132
|
+
i([
|
|
133
|
+
u({ type: Number, reflect: !0 })
|
|
134
|
+
], r.prototype, "valueCurrent", 2);
|
|
135
|
+
i([
|
|
136
|
+
u({ type: Number })
|
|
137
|
+
], r.prototype, "valueMax", 2);
|
|
138
|
+
i([
|
|
139
|
+
u({ type: Number })
|
|
140
|
+
], r.prototype, "valueMin", 2);
|
|
141
|
+
i([
|
|
142
|
+
h()
|
|
143
|
+
], r.prototype, "labelWidth", 2);
|
|
144
|
+
i([
|
|
145
|
+
h()
|
|
146
|
+
], r.prototype, "progressbarId", 2);
|
|
147
|
+
i([
|
|
148
|
+
h()
|
|
149
|
+
], r.prototype, "computedAriaLabelledby", 2);
|
|
150
|
+
i([
|
|
151
|
+
h()
|
|
152
|
+
], r.prototype, "computedAriaValueText", 2);
|
|
153
|
+
r = i([
|
|
154
|
+
T("pkt-progressbar")
|
|
155
|
+
], r);
|
|
156
|
+
const O = r;
|
|
157
|
+
export {
|
|
158
|
+
r as P,
|
|
159
|
+
O as a
|
|
160
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.19.0",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"urlpattern-polyfill": "^10.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@oslokommune/punkt-assets": "^12.
|
|
33
|
-
"@oslokommune/punkt-css": "^12.
|
|
32
|
+
"@oslokommune/punkt-assets": "^12.19.0",
|
|
33
|
+
"@oslokommune/punkt-css": "^12.19.0",
|
|
34
34
|
"sass": "^1.78.0",
|
|
35
35
|
"typescript": "^5.6.2",
|
|
36
36
|
"vite": "^5.4.4",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
58
58
|
},
|
|
59
59
|
"license": "MIT",
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "56c70c1a657240f64050e148fe4cd72d93e98631"
|
|
61
61
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
2
1
|
import { classMap } from 'lit/directives/class-map.js'
|
|
3
2
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
4
|
-
import { html } from 'lit'
|
|
3
|
+
import { html, nothing } from 'lit'
|
|
5
4
|
import { PktElement } from '@/base-elements/element'
|
|
6
5
|
import { Ref, createRef, ref } from 'lit/directives/ref.js'
|
|
7
6
|
import { styleMap } from 'lit/directives/style-map.js'
|
|
8
7
|
import { uuidish } from '@/utils/stringutils'
|
|
9
8
|
|
|
10
9
|
import '@/components/icon'
|
|
10
|
+
import { TAriaLive } from '@/types/aria'
|
|
11
11
|
|
|
12
12
|
export type TProgressbarRole = 'progressbar' | 'meter'
|
|
13
13
|
export type TProgressbarSkin = 'dark-blue' | 'light-blue' | 'green' | 'red'
|
|
@@ -16,76 +16,101 @@ export type TProgressbarStatusType = 'none' | 'percentage' | 'fraction'
|
|
|
16
16
|
export type TProgressbarTitlePosition = 'left' | 'center'
|
|
17
17
|
|
|
18
18
|
export interface IPktProgressbar {
|
|
19
|
+
ariaLabel?: string | null
|
|
20
|
+
ariaLabelledby?: string | null
|
|
21
|
+
ariaLive?: TAriaLive | null
|
|
22
|
+
ariaValueText?: string | null
|
|
23
|
+
id?: string | null
|
|
24
|
+
role?: TProgressbarRole
|
|
25
|
+
skin?: TProgressbarSkin
|
|
26
|
+
statusPlacement?: TProgressbarStatusPlacement
|
|
27
|
+
statusType?: TProgressbarStatusType
|
|
28
|
+
title?: string | null
|
|
29
|
+
titlePosition?: TProgressbarTitlePosition
|
|
19
30
|
valueCurrent: number
|
|
20
31
|
valueMax?: number
|
|
21
32
|
valueMin?: number
|
|
22
|
-
ariaValueText?: string
|
|
23
|
-
skin?: TProgressbarSkin
|
|
24
|
-
title?: string
|
|
25
|
-
titlePosition?: TProgressbarTitlePosition
|
|
26
|
-
statusType?: TProgressbarStatusType
|
|
27
|
-
statusPlacement?: TProgressbarStatusPlacement
|
|
28
|
-
ariaLabel?: string
|
|
29
|
-
ariaLabelledby?: string
|
|
30
|
-
role?: TProgressbarRole
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
@customElement('pkt-progressbar')
|
|
34
36
|
export class PktProgressbar extends PktElement implements IPktProgressbar {
|
|
37
|
+
constructor() {
|
|
38
|
+
super()
|
|
39
|
+
}
|
|
35
40
|
// Public properties
|
|
36
|
-
@property({ type:
|
|
37
|
-
@property({ type:
|
|
38
|
-
@property({ type:
|
|
39
|
-
@property({ type: String
|
|
40
|
-
@property({ type: String, reflect: true })
|
|
41
|
-
@property({ type: String
|
|
42
|
-
@property({ type: String
|
|
43
|
-
@property({ type: String
|
|
44
|
-
|
|
45
|
-
@property({ type: String, reflect: true })
|
|
46
|
-
@property({ type: String
|
|
47
|
-
@property({ type:
|
|
48
|
-
@property({ type:
|
|
41
|
+
@property({ type: String }) ariaLabel: string | null = null
|
|
42
|
+
@property({ type: String, reflect: true }) ariaLabelledby: string | null = null
|
|
43
|
+
@property({ type: String, reflect: true }) ariaValueText: string | null = null
|
|
44
|
+
@property({ type: String }) ariaLive: TAriaLive = 'polite'
|
|
45
|
+
@property({ type: String, reflect: true }) id: string = uuidish()
|
|
46
|
+
@property({ type: String }) role: TProgressbarRole = 'progressbar'
|
|
47
|
+
@property({ type: String }) skin: TProgressbarSkin = 'dark-blue'
|
|
48
|
+
@property({ type: String }) statusPlacement: TProgressbarStatusPlacement = 'following'
|
|
49
|
+
@property({ type: String }) statusType: TProgressbarStatusType = 'none'
|
|
50
|
+
@property({ type: String, reflect: true }) title = ''
|
|
51
|
+
@property({ type: String }) titlePosition: TProgressbarTitlePosition = 'left'
|
|
52
|
+
@property({ type: Number, reflect: true }) valueCurrent = 0
|
|
53
|
+
@property({ type: Number }) valueMax = 100
|
|
54
|
+
@property({ type: Number }) valueMin = 0
|
|
49
55
|
|
|
50
56
|
// State
|
|
51
|
-
@state() private labelWidth
|
|
52
|
-
@state() private
|
|
57
|
+
@state() private labelWidth = 0
|
|
58
|
+
@state() private progressbarId: string = this.id
|
|
59
|
+
@state() private computedAriaLabelledby: string | null = null
|
|
60
|
+
@state() private computedAriaValueText = ''
|
|
53
61
|
|
|
54
|
-
// Private
|
|
62
|
+
// Private refs
|
|
55
63
|
private labelRef: Ref<HTMLSpanElement> = createRef()
|
|
56
64
|
private progressBarRef: Ref<HTMLDivElement> = createRef()
|
|
57
65
|
|
|
58
66
|
firstUpdated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
59
67
|
super.firstUpdated(changedProperties)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
} else {
|
|
63
|
-
this.progressBarId = this.id
|
|
64
|
-
}
|
|
68
|
+
this.setComputedValues()
|
|
69
|
+
this.syncAttributes()
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
updated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
68
73
|
super.updated(changedProperties)
|
|
74
|
+
|
|
69
75
|
if (changedProperties.has('valueCurrent') && this.labelRef.value) {
|
|
70
76
|
this.labelWidth = this.labelRef.value.getBoundingClientRect().width || 0
|
|
71
77
|
}
|
|
72
78
|
if (changedProperties.has('id') && this.id) {
|
|
73
79
|
this.progressBarId = this.id
|
|
74
80
|
}
|
|
81
|
+
|
|
82
|
+
if (
|
|
83
|
+
changedProperties.has('statusType') ||
|
|
84
|
+
changedProperties.has('id') ||
|
|
85
|
+
changedProperties.has('ariaLabelledby')
|
|
86
|
+
) {
|
|
87
|
+
this.progressbarId = this.id || uuidish()
|
|
88
|
+
this.computedAriaLabelledby = this.ariaLabelledby || `${this.progressbarId}-title`
|
|
89
|
+
}
|
|
90
|
+
if (
|
|
91
|
+
changedProperties.has('ariaValueText') ||
|
|
92
|
+
changedProperties.has('valueCurrent') ||
|
|
93
|
+
changedProperties.has('valueMax')
|
|
94
|
+
) {
|
|
95
|
+
this.computedAriaValueText =
|
|
96
|
+
this.statusType === 'fraction' && !this.ariaValueText
|
|
97
|
+
? `${this.valueCurrent} av ${this.valueMax - this.valueMin}`
|
|
98
|
+
: this.ariaValueText || ''
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
this.syncAttributes()
|
|
75
102
|
}
|
|
76
103
|
|
|
77
104
|
render() {
|
|
105
|
+
const hasStatus = this.statusType !== 'none'
|
|
78
106
|
const totalSteps = this.valueMax - this.valueMin
|
|
79
107
|
const percentageOfSteps = (this.valueCurrent / totalSteps) * 100
|
|
80
108
|
const currentPercentage =
|
|
81
|
-
this.
|
|
109
|
+
this.statusType === 'fraction'
|
|
82
110
|
? Math.round(percentageOfSteps)
|
|
83
|
-
: this.valueCurrent
|
|
84
|
-
const formattedTitle = `${this.valueCurrent} av ${this.valueMax}`
|
|
85
|
-
const hasStatus = this.statusType !== 'none'
|
|
111
|
+
: Math.round(((this.valueCurrent - this.valueMin) / (this.valueMax - this.valueMin)) * 100)
|
|
86
112
|
|
|
87
|
-
const
|
|
88
|
-
this.ariaLabelledby || (this.progressBarId && `${this.progressBarId}-title`)
|
|
113
|
+
const formattedTitle = `${this.valueCurrent} av ${totalSteps}`
|
|
89
114
|
|
|
90
115
|
const barClasses = classMap({
|
|
91
116
|
'pkt-progressbar__bar': true,
|
|
@@ -106,7 +131,6 @@ export class PktProgressbar extends PktElement implements IPktProgressbar {
|
|
|
106
131
|
})
|
|
107
132
|
|
|
108
133
|
return html` <div
|
|
109
|
-
id=${this.progressBarId}
|
|
110
134
|
class="pkt-progressbar__container"
|
|
111
135
|
.ref=${this.progressBarRef}
|
|
112
136
|
style=${styleMap({
|
|
@@ -114,31 +138,56 @@ export class PktProgressbar extends PktElement implements IPktProgressbar {
|
|
|
114
138
|
'--pkt-progress-width': `${currentPercentage}%`,
|
|
115
139
|
})}
|
|
116
140
|
>
|
|
117
|
-
${this.title
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
role=${this.role as any}
|
|
123
|
-
class="pkt-progressbar__bar-wrapper"
|
|
124
|
-
aria-valuemin=${this.valueMin}
|
|
125
|
-
aria-valuemax=${this.valueMax}
|
|
126
|
-
aria-valuenow=${this.valueCurrent}
|
|
127
|
-
aria-labelledby=${ifDefined(ariaLabelledbyText)}
|
|
128
|
-
aria-label=${ifDefined(this.ariaLabel)}
|
|
129
|
-
aria-valuetext=${ifDefined(this.ariaValueText)}
|
|
130
|
-
>
|
|
141
|
+
${this.title
|
|
142
|
+
? html`<p id=${`${this.progressBarId}-title`} class=${titleClasses}>${this.title}</p>`
|
|
143
|
+
: nothing}
|
|
144
|
+
|
|
145
|
+
<div class="pkt-progressbar__bar-wrapper">
|
|
131
146
|
<div class=${barClasses}></div>
|
|
132
147
|
</div>
|
|
133
148
|
|
|
134
|
-
${hasStatus
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
149
|
+
${hasStatus
|
|
150
|
+
? html`<div class=${statusClasses}>
|
|
151
|
+
<span class=${placementClasses} ${ref(this.labelRef)}>
|
|
152
|
+
${this.statusType === 'percentage' ? `${currentPercentage}%` : formattedTitle}
|
|
153
|
+
</span>
|
|
154
|
+
</div>`
|
|
155
|
+
: nothing}
|
|
140
156
|
</div>`
|
|
141
157
|
}
|
|
158
|
+
|
|
159
|
+
// methods
|
|
160
|
+
private setComputedValues() {
|
|
161
|
+
this.progressbarId = this.id || uuidish()
|
|
162
|
+
this.computedAriaLabelledby = this.ariaLabelledby || `${this.progressbarId}-title`
|
|
163
|
+
this.computedAriaValueText =
|
|
164
|
+
this.statusType === 'fraction' && !this.ariaValueText
|
|
165
|
+
? `${this.valueCurrent} av ${this.valueMax - this.valueMin}`
|
|
166
|
+
: this.ariaValueText || ''
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private syncAttributes() {
|
|
170
|
+
this._handleAttribute('aria-live', this.ariaLive)
|
|
171
|
+
this._handleAttribute('aria-valuenow', this.valueCurrent)
|
|
172
|
+
this._handleAttribute('aria-valuemin', this.valueMin)
|
|
173
|
+
this._handleAttribute('aria-valuemax', this.valueMax)
|
|
174
|
+
this._handleAttribute('aria-valuetext', this.computedAriaValueText)
|
|
175
|
+
this._handleAttribute('aria-label', this.ariaLabel)
|
|
176
|
+
this._handleAttribute('role', this.role)
|
|
177
|
+
this._handleAttribute('aria-atomic', 'true')
|
|
178
|
+
this._handleAttribute('id', this.progressbarId)
|
|
179
|
+
if (!this.ariaLabel) {
|
|
180
|
+
this._handleAttribute('aria-labelledby', this.computedAriaLabelledby)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private _handleAttribute(name: string, value: string | number | null) {
|
|
185
|
+
if (value == null || value === '') {
|
|
186
|
+
this.removeAttribute(name)
|
|
187
|
+
} else {
|
|
188
|
+
this.setAttribute(name, String(value))
|
|
189
|
+
}
|
|
190
|
+
}
|
|
142
191
|
}
|
|
143
192
|
|
|
144
193
|
export default PktProgressbar
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { o as h } from "./if-defined-ZFE4ti2t.js";
|
|
2
|
-
import { e as u } from "./class-map-hz16xq5a.js";
|
|
3
|
-
import { e as m, i as $, b as _, T as P, P as k, x as c, n as o, t as x } from "./icon-wUXeHiBk.js";
|
|
4
|
-
import { r as b } from "./state-BfyXV7EL.js";
|
|
5
|
-
import { e as d, n as w } from "./ref-DuFGTLVX.js";
|
|
6
|
-
import { u as B } from "./stringutils-DJjRa8dG.js";
|
|
7
|
-
/**
|
|
8
|
-
* @license
|
|
9
|
-
* Copyright 2018 Google LLC
|
|
10
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/
|
|
12
|
-
const f = "important", C = " !" + f, T = m(class extends $ {
|
|
13
|
-
constructor(e) {
|
|
14
|
-
var s;
|
|
15
|
-
if (super(e), e.type !== _.ATTRIBUTE || e.name !== "style" || ((s = e.strings) == null ? void 0 : s.length) > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
|
|
16
|
-
}
|
|
17
|
-
render(e) {
|
|
18
|
-
return Object.keys(e).reduce((s, r) => {
|
|
19
|
-
const t = e[r];
|
|
20
|
-
return t == null ? s : s + `${r = r.includes("-") ? r : r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${t};`;
|
|
21
|
-
}, "");
|
|
22
|
-
}
|
|
23
|
-
update(e, [s]) {
|
|
24
|
-
const { style: r } = e.element;
|
|
25
|
-
if (this.ft === void 0) return this.ft = new Set(Object.keys(s)), this.render(s);
|
|
26
|
-
for (const t of this.ft) s[t] == null && (this.ft.delete(t), t.includes("-") ? r.removeProperty(t) : r[t] = null);
|
|
27
|
-
for (const t in s) {
|
|
28
|
-
const i = s[t];
|
|
29
|
-
if (i != null) {
|
|
30
|
-
this.ft.add(t);
|
|
31
|
-
const p = typeof i == "string" && i.endsWith(C);
|
|
32
|
-
t.includes("-") || p ? r.setProperty(t, p ? i.slice(0, -11) : i, p ? f : "") : r[t] = i;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return P;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
var M = Object.defineProperty, S = Object.getOwnPropertyDescriptor, l = (e, s, r, t) => {
|
|
39
|
-
for (var i = t > 1 ? void 0 : t ? S(s, r) : s, p = e.length - 1, n; p >= 0; p--)
|
|
40
|
-
(n = e[p]) && (i = (t ? n(s, r, i) : n(i)) || i);
|
|
41
|
-
return t && i && M(s, r, i), i;
|
|
42
|
-
};
|
|
43
|
-
let a = class extends k {
|
|
44
|
-
constructor() {
|
|
45
|
-
super(...arguments), this.valueCurrent = 0, this.valueMax = 100, this.valueMin = 0, this.skin = "dark-blue", this.title = "", this.titlePosition = "left", this.statusType = "none", this.statusPlacement = "following", this.ariaLabel = "", this.ariaLabelledby = "", this.ariaValueText = "", this.role = "progressbar", this.labelWidth = 0, this.progressBarId = this.id, this.labelRef = d(), this.progressBarRef = d();
|
|
46
|
-
}
|
|
47
|
-
firstUpdated(e) {
|
|
48
|
-
super.firstUpdated(e), this.id ? this.progressBarId = this.id : this.progressBarId = B();
|
|
49
|
-
}
|
|
50
|
-
updated(e) {
|
|
51
|
-
super.updated(e), e.has("valueCurrent") && this.labelRef.value && (this.labelWidth = this.labelRef.value.getBoundingClientRect().width || 0), e.has("id") && this.id && (this.progressBarId = this.id);
|
|
52
|
-
}
|
|
53
|
-
render() {
|
|
54
|
-
const e = this.valueMax - this.valueMin, s = this.valueCurrent / e * 100, r = this.valueMax !== 100 || this.valueMin !== 0 ? Math.round(s) : this.valueCurrent, t = `${this.valueCurrent} av ${this.valueMax}`, i = this.statusType !== "none", p = this.ariaLabelledby || this.progressBarId && `${this.progressBarId}-title`, n = u({
|
|
55
|
-
"pkt-progressbar__bar": !0,
|
|
56
|
-
[`pkt-progressbar__bar--${this.skin}`]: !!this.skin
|
|
57
|
-
}), g = u({
|
|
58
|
-
"pkt-progressbar__title": !0,
|
|
59
|
-
"pkt-progressbar__title-center": this.titlePosition === "center"
|
|
60
|
-
}), y = u({
|
|
61
|
-
"pkt-progressbar__status": !0,
|
|
62
|
-
"pkt-progressbar__status--center": this.statusPlacement === "center"
|
|
63
|
-
}), v = u({
|
|
64
|
-
"pkt-progressbar__status-placement--following": this.statusPlacement === "following",
|
|
65
|
-
"pkt-progressbar__status-placement--center": this.statusPlacement === "center",
|
|
66
|
-
"pkt-progressbar__status-placement--left": this.statusPlacement === "left"
|
|
67
|
-
});
|
|
68
|
-
return c` <div
|
|
69
|
-
id=${this.progressBarId}
|
|
70
|
-
class="pkt-progressbar__container"
|
|
71
|
-
.ref=${this.progressBarRef}
|
|
72
|
-
style=${T({
|
|
73
|
-
"--pkt-progress-label-width": `${this.labelWidth}px`,
|
|
74
|
-
"--pkt-progress-width": `${r}%`
|
|
75
|
-
})}
|
|
76
|
-
>
|
|
77
|
-
${this.title && c`<p id=${`${this.progressBarId}-title`} class=${g}>${this.title}</p>`}
|
|
78
|
-
|
|
79
|
-
<div
|
|
80
|
-
.id=${this.progressBarId}
|
|
81
|
-
role=${this.role}
|
|
82
|
-
class="pkt-progressbar__bar-wrapper"
|
|
83
|
-
aria-valuemin=${this.valueMin}
|
|
84
|
-
aria-valuemax=${this.valueMax}
|
|
85
|
-
aria-valuenow=${this.valueCurrent}
|
|
86
|
-
aria-labelledby=${h(p)}
|
|
87
|
-
aria-label=${h(this.ariaLabel)}
|
|
88
|
-
aria-valuetext=${h(this.ariaValueText)}
|
|
89
|
-
>
|
|
90
|
-
<div class=${n}></div>
|
|
91
|
-
</div>
|
|
92
|
-
|
|
93
|
-
${i && c`<div class=${y}>
|
|
94
|
-
<span class=${v} ${w(this.labelRef)}>
|
|
95
|
-
${this.statusType === "percentage" ? `${r}%` : t}
|
|
96
|
-
</span>
|
|
97
|
-
</div>`}
|
|
98
|
-
</div>`;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
l([
|
|
102
|
-
o({ type: Number, reflect: !0 })
|
|
103
|
-
], a.prototype, "valueCurrent", 2);
|
|
104
|
-
l([
|
|
105
|
-
o({ type: Number, reflect: !0 })
|
|
106
|
-
], a.prototype, "valueMax", 2);
|
|
107
|
-
l([
|
|
108
|
-
o({ type: Number, reflect: !0 })
|
|
109
|
-
], a.prototype, "valueMin", 2);
|
|
110
|
-
l([
|
|
111
|
-
o({ type: String, reflect: !0 })
|
|
112
|
-
], a.prototype, "skin", 2);
|
|
113
|
-
l([
|
|
114
|
-
o({ type: String, reflect: !0 })
|
|
115
|
-
], a.prototype, "title", 2);
|
|
116
|
-
l([
|
|
117
|
-
o({ type: String, reflect: !0 })
|
|
118
|
-
], a.prototype, "titlePosition", 2);
|
|
119
|
-
l([
|
|
120
|
-
o({ type: String, reflect: !0 })
|
|
121
|
-
], a.prototype, "statusType", 2);
|
|
122
|
-
l([
|
|
123
|
-
o({ type: String, reflect: !0 })
|
|
124
|
-
], a.prototype, "statusPlacement", 2);
|
|
125
|
-
l([
|
|
126
|
-
o({ type: String, reflect: !0 })
|
|
127
|
-
], a.prototype, "ariaLabel", 2);
|
|
128
|
-
l([
|
|
129
|
-
o({ type: String, reflect: !0 })
|
|
130
|
-
], a.prototype, "ariaLabelledby", 2);
|
|
131
|
-
l([
|
|
132
|
-
o({ type: String, reflect: !0 })
|
|
133
|
-
], a.prototype, "ariaValueText", 2);
|
|
134
|
-
l([
|
|
135
|
-
o({ type: String, reflect: !0 })
|
|
136
|
-
], a.prototype, "role", 2);
|
|
137
|
-
l([
|
|
138
|
-
b()
|
|
139
|
-
], a.prototype, "labelWidth", 2);
|
|
140
|
-
l([
|
|
141
|
-
b()
|
|
142
|
-
], a.prototype, "progressBarId", 2);
|
|
143
|
-
a = l([
|
|
144
|
-
x("pkt-progressbar")
|
|
145
|
-
], a);
|
|
146
|
-
const E = a;
|
|
147
|
-
export {
|
|
148
|
-
a as P,
|
|
149
|
-
E as a
|
|
150
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";const u=require("./if-defined-DEDlGbAc.cjs"),p=require("./class-map-Boa7BqCc.cjs"),r=require("./icon-CdMQ6zBT.cjs"),c=require("./state-SKYD8kRO.cjs"),h=require("./ref-DCOsLZQg.cjs"),y=require("./stringutils-CkVRq4jP.cjs");/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2018 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const b="important",v=" !"+b,k=r.e(class extends r.i{constructor(l){var t;if(super(l),l.type!==r.t$1.ATTRIBUTE||l.name!=="style"||((t=l.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(l){return Object.keys(l).reduce((t,s)=>{const e=l[s];return e==null?t:t+`${s=s.includes("-")?s:s.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${e};`},"")}update(l,[t]){const{style:s}=l.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(const e of this.ft)t[e]==null&&(this.ft.delete(e),e.includes("-")?s.removeProperty(e):s[e]=null);for(const e in t){const a=t[e];if(a!=null){this.ft.add(e);const o=typeof a=="string"&&a.endsWith(v);e.includes("-")||o?s.setProperty(e,o?a.slice(0,-11):a,o?b:""):s[e]=a}}return r.T}});var $=Object.defineProperty,_=Object.getOwnPropertyDescriptor,i=(l,t,s,e)=>{for(var a=e>1?void 0:e?_(t,s):t,o=l.length-1,n;o>=0;o--)(n=l[o])&&(a=(e?n(t,s,a):n(a))||a);return e&&a&&$(t,s,a),a};exports.PktProgressbar=class extends r.PktElement{constructor(){super(...arguments),this.valueCurrent=0,this.valueMax=100,this.valueMin=0,this.skin="dark-blue",this.title="",this.titlePosition="left",this.statusType="none",this.statusPlacement="following",this.ariaLabel="",this.ariaLabelledby="",this.ariaValueText="",this.role="progressbar",this.labelWidth=0,this.progressBarId=this.id,this.labelRef=h.e(),this.progressBarRef=h.e()}firstUpdated(t){super.firstUpdated(t),this.id?this.progressBarId=this.id:this.progressBarId=y.uuidish()}updated(t){super.updated(t),t.has("valueCurrent")&&this.labelRef.value&&(this.labelWidth=this.labelRef.value.getBoundingClientRect().width||0),t.has("id")&&this.id&&(this.progressBarId=this.id)}render(){const t=this.valueMax-this.valueMin,s=this.valueCurrent/t*100,e=this.valueMax!==100||this.valueMin!==0?Math.round(s):this.valueCurrent,a=`${this.valueCurrent} av ${this.valueMax}`,o=this.statusType!=="none",n=this.ariaLabelledby||this.progressBarId&&`${this.progressBarId}-title`,g=p.e({"pkt-progressbar__bar":!0,[`pkt-progressbar__bar--${this.skin}`]:!!this.skin}),d=p.e({"pkt-progressbar__title":!0,"pkt-progressbar__title-center":this.titlePosition==="center"}),P=p.e({"pkt-progressbar__status":!0,"pkt-progressbar__status--center":this.statusPlacement==="center"}),f=p.e({"pkt-progressbar__status-placement--following":this.statusPlacement==="following","pkt-progressbar__status-placement--center":this.statusPlacement==="center","pkt-progressbar__status-placement--left":this.statusPlacement==="left"});return r.x` <div
|
|
6
|
-
id=${this.progressBarId}
|
|
7
|
-
class="pkt-progressbar__container"
|
|
8
|
-
.ref=${this.progressBarRef}
|
|
9
|
-
style=${k({"--pkt-progress-label-width":`${this.labelWidth}px`,"--pkt-progress-width":`${e}%`})}
|
|
10
|
-
>
|
|
11
|
-
${this.title&&r.x`<p id=${`${this.progressBarId}-title`} class=${d}>${this.title}</p>`}
|
|
12
|
-
|
|
13
|
-
<div
|
|
14
|
-
.id=${this.progressBarId}
|
|
15
|
-
role=${this.role}
|
|
16
|
-
class="pkt-progressbar__bar-wrapper"
|
|
17
|
-
aria-valuemin=${this.valueMin}
|
|
18
|
-
aria-valuemax=${this.valueMax}
|
|
19
|
-
aria-valuenow=${this.valueCurrent}
|
|
20
|
-
aria-labelledby=${u.o(n)}
|
|
21
|
-
aria-label=${u.o(this.ariaLabel)}
|
|
22
|
-
aria-valuetext=${u.o(this.ariaValueText)}
|
|
23
|
-
>
|
|
24
|
-
<div class=${g}></div>
|
|
25
|
-
</div>
|
|
26
|
-
|
|
27
|
-
${o&&r.x`<div class=${P}>
|
|
28
|
-
<span class=${f} ${h.n(this.labelRef)}>
|
|
29
|
-
${this.statusType==="percentage"?`${e}%`:a}
|
|
30
|
-
</span>
|
|
31
|
-
</div>`}
|
|
32
|
-
</div>`}};i([r.n({type:Number,reflect:!0})],exports.PktProgressbar.prototype,"valueCurrent",2);i([r.n({type:Number,reflect:!0})],exports.PktProgressbar.prototype,"valueMax",2);i([r.n({type:Number,reflect:!0})],exports.PktProgressbar.prototype,"valueMin",2);i([r.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"skin",2);i([r.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"title",2);i([r.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"titlePosition",2);i([r.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"statusType",2);i([r.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"statusPlacement",2);i([r.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"ariaLabel",2);i([r.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"ariaLabelledby",2);i([r.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"ariaValueText",2);i([r.n({type:String,reflect:!0})],exports.PktProgressbar.prototype,"role",2);i([c.r()],exports.PktProgressbar.prototype,"labelWidth",2);i([c.r()],exports.PktProgressbar.prototype,"progressBarId",2);exports.PktProgressbar=i([r.t("pkt-progressbar")],exports.PktProgressbar);const m=exports.PktProgressbar;exports.PktProgressbar$1=m;
|