@oslokommune/punkt-elements 14.5.3 → 14.5.4
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 +17 -0
- package/dist/{alert-DqXar67l.js → alert-Cc5FtxHN.js} +2 -2
- package/dist/{alert-GrKyqxuR.cjs → alert-DVCenNTM.cjs} +1 -1
- package/dist/{backlink-QDcQd6vK.cjs → backlink-Bn16ZEIX.cjs} +1 -1
- package/dist/{backlink-CqUcmiPQ.js → backlink-DfMabyBp.js} +1 -1
- package/dist/{button-f36menSU.js → button-DrTXtc-n.js} +1 -1
- package/dist/{button-R4l10Nqd.cjs → button-Ju4zPhVx.cjs} +1 -1
- package/dist/{calendar-wuD6ZH0t.cjs → calendar-5Obd0ZT3.cjs} +1 -1
- package/dist/{calendar-DiNuZ8Ai.js → calendar-CTx8PD1L.js} +1 -1
- package/dist/{card-CnINxZma.js → card-CTtmPB2n.js} +2 -2
- package/dist/{card-C2hWaMev.cjs → card-DvHL7pNu.cjs} +1 -1
- package/dist/{combobox-Dxa7XjLz.js → combobox-DNPfpTjW.js} +3 -3
- package/dist/{combobox-yy6hIGmB.cjs → combobox-DvL3SKz2.cjs} +1 -1
- package/dist/{consent-FbFS1pmz.cjs → consent-DJW7YEat.cjs} +1 -1
- package/dist/{consent-c9PhWxnP.js → consent-OdhmtIK-.js} +2 -2
- package/dist/{datepicker-D_3vYgMt.cjs → datepicker-CTCaZuZU.cjs} +1 -1
- package/dist/{datepicker-C7GWMtXH.js → datepicker-t0W9fA1e.js} +4 -4
- package/dist/{helptext-DebHGRsD.cjs → helptext-7fyVJK2C.cjs} +1 -1
- package/dist/{helptext-DuyRRfCn.js → helptext-CfR0SYe9.js} +1 -1
- package/dist/icon-DBZvMard.js +103 -0
- package/dist/icon-n4-ve48P.cjs +9 -0
- package/dist/{input-wrapper-rgXsRNkk.cjs → input-wrapper-Bta4FZe3.cjs} +1 -1
- package/dist/{input-wrapper-3qfjLkrP.js → input-wrapper-DVUh5rxv.js} +3 -3
- package/dist/{link-CZvcdRek.js → link-40XAFlYS.js} +1 -1
- package/dist/{link-D85g20GS.cjs → link-CBQ7uKqb.cjs} +1 -1
- package/dist/{linkcard-B-9K02q8.cjs → linkcard-D8hxLedl.cjs} +1 -1
- package/dist/{linkcard-C3RTcMqc.js → linkcard-Opb42K2k.js} +1 -1
- package/dist/{loader-Dci0SrOz.js → loader-Bv1R6-AA.js} +1 -1
- package/dist/{loader-1EXLdxfq.cjs → loader-Dh_5sihO.cjs} +1 -1
- package/dist/{messagebox-dscnWgCd.cjs → messagebox-B9MCodIz.cjs} +1 -1
- package/dist/{messagebox-CnZlttZp.js → messagebox-DEXCTOrz.js} +1 -1
- package/dist/{modal-wSGthXAC.js → modal-B4adxB6X.js} +1 -1
- package/dist/{modal-ncKVjcyZ.cjs → modal-Bw61rVrQ.cjs} +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-calendar.cjs +1 -1
- package/dist/pkt-calendar.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 +2 -2
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +4 -4
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +1 -1
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +21 -21
- 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-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +2 -2
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.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/{progressbar-D5WBW1Dm.js → progressbar-CJa70NEo.js} +1 -1
- package/dist/{progressbar-ClY1WgnM.cjs → progressbar-ClZOyCz9.cjs} +1 -1
- package/dist/{select-jbIbD7hW.cjs → select--wvwpJ0_.cjs} +1 -1
- package/dist/{select-Bug9sfr5.js → select-DfsNb_Yi.js} +1 -1
- package/dist/{tag-DgoTYNVA.js → tag-Cw3OQqLW.js} +1 -1
- package/dist/{tag-BfjOlIyS.cjs → tag-P9lfQZbM.cjs} +1 -1
- package/dist/{textarea-Da9E3RM7.js → textarea-CM_bj81t.js} +2 -2
- package/dist/{textarea-Dfa4_ZBy.cjs → textarea-DcEKhXia.cjs} +1 -1
- package/dist/{textinput-DaMYc5gd.js → textinput-AVll6Nh7.js} +2 -2
- package/dist/{textinput-CLM9fRjm.cjs → textinput-BzuYzKZ6.cjs} +1 -1
- package/package.json +2 -2
- package/src/components/icon/icon.ts +56 -39
- package/dist/icon-BgG6oO4Q.js +0 -89
- package/dist/icon-Dl9ZPqe6.cjs +0 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const h=require("./class-map-CApIYSRo.cjs"),t=require("./element-aUzIoa1s.cjs"),k=require("./state-GDzxl12x.cjs"),g=require("./pkt-slot-controller-BzddBp7z.cjs"),c=require("./ref-C5iJMIE1.cjs");require("./icon-
|
|
1
|
+
"use strict";const h=require("./class-map-CApIYSRo.cjs"),t=require("./element-aUzIoa1s.cjs"),k=require("./state-GDzxl12x.cjs"),g=require("./pkt-slot-controller-BzddBp7z.cjs"),c=require("./ref-C5iJMIE1.cjs");require("./icon-n4-ve48P.cjs");const u=require("./if-defined-BElHLTlB.cjs"),d={size:{default:"medium"},skin:{default:"blue"},closeTag:{default:!1},type:{default:"button"}},r={props:d};var f=Object.defineProperty,y=Object.getOwnPropertyDescriptor,i=(n,e,a,o)=>{for(var s=o>1?void 0:o?y(e,a):e,l=n.length-1,p;l>=0;l--)(p=n[l])&&(s=(o?p(e,a,s):p(s))||s);return o&&s&&f(e,a,s),s};exports.PktTag=class extends t.PktElement{constructor(){super(),this.defaultSlot=c.e(),this.closeTag=r.props.closeTag.default,this.size=r.props.size.default,this.skin=r.props.skin.default,this.textStyle=null,this.iconName=void 0,this.type=r.props.type.default,this.ariaLabel=null,this._isClosed=!1,this._ariaDescription=null,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent("close",{detail:{origin:e},bubbles:!1,composed:!0})),this.dispatchEvent(new CustomEvent("on-close",{detail:{origin:e},bubbles:!1,composed:!0}))},this.slotController=new g.PktSlotController(this,this.defaultSlot),this._isClosed=!1}firstUpdated(e){var a,o;if(super.firstUpdated(e),this.closeTag&&!this.ariaLabel){const s=(o=(a=this.defaultSlot.value)==null?void 0:a.textContent)==null?void 0:o.trim();s&&(this._ariaDescription=`Klikk for å fjerne ${s}`)}}render(){const e={"pkt-tag":!0,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,[`pkt-tag--${this.textStyle}`]:!!this.textStyle},a={"pkt-tag":!0,"pkt-btn":!0,"pkt-btn--tertiary":!0,[`pkt-tag--${this.textStyle}`]:!!this.textStyle,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,"pkt-btn--icons-right-and-left":this.closeTag&&!!this.iconName,"pkt-hide":this._isClosed};return this.closeTag?t.x`
|
|
2
2
|
<button
|
|
3
3
|
class=${h.e(a)}
|
|
4
4
|
type=${this.type}
|
|
@@ -7,8 +7,8 @@ import { e as T, i as b, t as a } from "./directive-oAbCiebi.js";
|
|
|
7
7
|
import { f as y, m as w } from "./directive-helpers-CQef4qUQ.js";
|
|
8
8
|
import { P as C } from "./input-element-DVZhYDJ_.js";
|
|
9
9
|
import { P as E } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
10
|
-
import "./input-wrapper-
|
|
11
|
-
import "./icon-
|
|
10
|
+
import "./input-wrapper-DVUh5rxv.js";
|
|
11
|
+
import "./icon-DBZvMard.js";
|
|
12
12
|
/**
|
|
13
13
|
* @license
|
|
14
14
|
* Copyright 2020 Google LLC
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const s=require("./element-aUzIoa1s.cjs"),p=require("./if-defined-BElHLTlB.cjs"),c=require("./state-GDzxl12x.cjs"),l=require("./ref-C5iJMIE1.cjs"),$=require("./class-map-CApIYSRo.cjs"),a=require("./directive-C7oCP5Bh.cjs"),d=require("./directive-helpers-CYIEJ8pI.cjs"),x=require("./input-element-RBQVA8i0.cjs"),T=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-
|
|
1
|
+
"use strict";const s=require("./element-aUzIoa1s.cjs"),p=require("./if-defined-BElHLTlB.cjs"),c=require("./state-GDzxl12x.cjs"),l=require("./ref-C5iJMIE1.cjs"),$=require("./class-map-CApIYSRo.cjs"),a=require("./directive-C7oCP5Bh.cjs"),d=require("./directive-helpers-CYIEJ8pI.cjs"),x=require("./input-element-RBQVA8i0.cjs"),T=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-Bta4FZe3.cjs");require("./icon-n4-ve48P.cjs");/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2020 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -5,8 +5,8 @@ import { e as d, n as m } from "./ref-BxiKhrfa.js";
|
|
|
5
5
|
import { e as g } from "./class-map-Dt2jXOlF.js";
|
|
6
6
|
import { P as x } from "./input-element-DVZhYDJ_.js";
|
|
7
7
|
import { P as v } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
8
|
-
import "./input-wrapper-
|
|
9
|
-
import "./icon-
|
|
8
|
+
import "./input-wrapper-DVUh5rxv.js";
|
|
9
|
+
import "./icon-DBZvMard.js";
|
|
10
10
|
var y = Object.defineProperty, b = Object.getOwnPropertyDescriptor, o = (i, e, r, t) => {
|
|
11
11
|
for (var n = t > 1 ? void 0 : t ? b(e, r) : e, l = i.length - 1, c; l >= 0; l--)
|
|
12
12
|
(c = i[l]) && (n = (t ? c(e, r, n) : c(n)) || n);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("./element-aUzIoa1s.cjs"),a=require("./if-defined-BElHLTlB.cjs"),l=require("./state-GDzxl12x.cjs"),h=require("./ref-C5iJMIE1.cjs"),c=require("./class-map-CApIYSRo.cjs"),d=require("./input-element-RBQVA8i0.cjs"),x=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-
|
|
1
|
+
"use strict";const t=require("./element-aUzIoa1s.cjs"),a=require("./if-defined-BElHLTlB.cjs"),l=require("./state-GDzxl12x.cjs"),h=require("./ref-C5iJMIE1.cjs"),c=require("./class-map-CApIYSRo.cjs"),d=require("./input-element-RBQVA8i0.cjs"),x=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-Bta4FZe3.cjs");require("./icon-n4-ve48P.cjs");var $=Object.defineProperty,f=Object.getOwnPropertyDescriptor,r=(u,i,s,n)=>{for(var e=n>1?void 0:n?f(i,s):i,o=u.length-1,p;o>=0;o--)(p=u[o])&&(e=(n?p(i,s,e):p(e))||e);return n&&e&&$(i,s,e),e};exports.PktTextinput=class extends d.PktInputElement{constructor(){super(),this.inputRef=h.e(),this.helptextSlot=h.e(),this.value="",this.type="text",this.size=null,this.autocomplete=null,this.iconNameRight=null,this.prefix=null,this.suffix=null,this.omitSearchIcon=!1,this.counterCurrent=0,this.slotController=new x.PktSlotController(this,this.helptextSlot)}attributeChangedCallback(i,s,n){i==="value"&&this.value!==s&&(this.counterCurrent=n?n.length:0,this.valueChanged(n,s)),super.attributeChangedCallback(i,s,n)}updated(i){var s;super.updated(i),i.has("value")&&(this.counterCurrent=((s=this.value)==null?void 0:s.length)||0,this.valueChanged(this.value,i.get("value"))),i.has("id")&&!this.name&&this.id&&(this.name=this.id)}render(){const i=this.type==="search"&&!this.iconNameRight&&!this.omitSearchIcon,s=c.e({"pkt-input":!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":this.counter&&this.counterMaxLength&&this.value.length&&this.value.length>this.counterMaxLength}),n=this.ariaLabelledby||`${this.id}-input-label`;return t.x`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
label="${this.label}"
|
|
4
4
|
?counter=${this.counter}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "14.5.
|
|
3
|
+
"version": "14.5.4",
|
|
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",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
80
80
|
},
|
|
81
81
|
"license": "MIT",
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "be4a01f06388571ca22a28c90fa518e1a6dff097"
|
|
83
83
|
}
|
|
@@ -13,51 +13,64 @@ if (typeof window !== 'undefined') {
|
|
|
13
13
|
window.pktIconPath = window.pktIconPath || defaultPath
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
17
16
|
const errorSvg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>'
|
|
18
|
-
const
|
|
17
|
+
const dlCache: { [key: string]: Promise<string> } = {}
|
|
18
|
+
const MAX_RETRIES = 2
|
|
19
|
+
const RETRY_DELAY = 1500
|
|
20
|
+
|
|
21
|
+
const isSessionStorageAvailable =
|
|
22
|
+
typeof Storage !== 'undefined' && typeof sessionStorage !== 'undefined'
|
|
23
|
+
|
|
24
|
+
const fetchIcon = (url: string): Promise<string> =>
|
|
25
|
+
window
|
|
26
|
+
.pktFetch!(url)
|
|
27
|
+
.then((response: Response) => {
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
throw new Error('Missing icon: ' + url)
|
|
30
|
+
}
|
|
31
|
+
return response.text()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const fetchIconWithRetry = async (url: string, retries = MAX_RETRIES): Promise<string> => {
|
|
35
|
+
try {
|
|
36
|
+
return await fetchIcon(url)
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (retries > 0) {
|
|
39
|
+
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY))
|
|
40
|
+
return fetchIconWithRetry(url, retries - 1)
|
|
41
|
+
}
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.error('Failed to fetch icon: ' + url)
|
|
44
|
+
return errorSvg
|
|
45
|
+
}
|
|
46
|
+
}
|
|
19
47
|
|
|
20
48
|
const downloadIconOrGetFromCache = async (
|
|
21
49
|
name: PktIconName,
|
|
22
50
|
path: string | undefined,
|
|
23
51
|
): Promise<string | null> => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
await sleep(50)
|
|
52
|
+
const key = path + name + '.svg'
|
|
53
|
+
|
|
54
|
+
if (isSessionStorageAvailable && sessionStorage.getItem(key)) {
|
|
55
|
+
return sessionStorage.getItem(key)
|
|
29
56
|
}
|
|
30
57
|
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (isSessionStorageAvailable && sessionStorage.getItem(path + name + '.svg')) {
|
|
36
|
-
return Promise.resolve(sessionStorage.getItem(path + name + '.svg'))
|
|
37
|
-
} else if (typeof window !== 'undefined' && typeof window.pktFetch === 'function') {
|
|
38
|
-
dlStatus[path + name + '.svg'] = 'fetching'
|
|
39
|
-
return Promise.resolve(
|
|
40
|
-
window
|
|
41
|
-
.pktFetch(path + name + '.svg')
|
|
42
|
-
.then((response) => {
|
|
43
|
-
if (!response.ok) {
|
|
44
|
-
// eslint-disable-next-line no-console
|
|
45
|
-
console.error('Missing icon: ' + path + name + '.svg')
|
|
46
|
-
return errorSvg
|
|
47
|
-
} else {
|
|
48
|
-
return response.text()
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
.then((text) => {
|
|
52
|
-
if (text !== errorSvg && isSessionStorageAvailable) {
|
|
53
|
-
sessionStorage.setItem(path + name + '.svg', text)
|
|
54
|
-
}
|
|
55
|
-
dlStatus[path + name + '.svg'] = 'fetched'
|
|
56
|
-
return text
|
|
57
|
-
}),
|
|
58
|
-
)
|
|
58
|
+
// If a fetch is already in-flight for this icon, await the same promise
|
|
59
|
+
if (key in dlCache) {
|
|
60
|
+
return dlCache[key]
|
|
59
61
|
}
|
|
60
|
-
|
|
62
|
+
|
|
63
|
+
if (typeof window !== 'undefined' && typeof window.pktFetch === 'function') {
|
|
64
|
+
dlCache[key] = fetchIconWithRetry(key).then((text) => {
|
|
65
|
+
if (text !== errorSvg && isSessionStorageAvailable) {
|
|
66
|
+
sessionStorage.setItem(key, text)
|
|
67
|
+
}
|
|
68
|
+
delete dlCache[key]
|
|
69
|
+
return text
|
|
70
|
+
})
|
|
71
|
+
return dlCache[key]
|
|
72
|
+
}
|
|
73
|
+
return errorSvg
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
type Props = ElementProps<PktIcon, 'path' | 'name'>
|
|
@@ -95,9 +108,13 @@ export class PktIcon extends PktElement<Props> {
|
|
|
95
108
|
protected async getIcon(name: PktIconName = '') {
|
|
96
109
|
if (this._updatedProps.length > 0) {
|
|
97
110
|
if (!this.path) this.path = typeof window !== 'undefined' ? window.pktIconPath : defaultPath
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
111
|
+
try {
|
|
112
|
+
this.icon = unsafeSVG(
|
|
113
|
+
await downloadIconOrGetFromCache(this.name || '', this.path),
|
|
114
|
+
) as SVGElement
|
|
115
|
+
} catch {
|
|
116
|
+
this.icon = unsafeSVG(errorSvg)
|
|
117
|
+
}
|
|
101
118
|
this._updatedProps = []
|
|
102
119
|
} else {
|
|
103
120
|
if (!this._updatedProps.includes(name)) {
|
package/dist/icon-BgG6oO4Q.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { E as w, T as y, P as m, x as P, n as d, t as k } from "./element-BXsf_NlG.js";
|
|
2
|
-
import { e as v, i as _, t as I } from "./directive-oAbCiebi.js";
|
|
3
|
-
/**
|
|
4
|
-
* @license
|
|
5
|
-
* Copyright 2017 Google LLC
|
|
6
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
7
|
-
*/
|
|
8
|
-
class a extends _ {
|
|
9
|
-
constructor(t) {
|
|
10
|
-
if (super(t), this.it = w, t.type !== I.CHILD) throw Error(this.constructor.directiveName + "() can only be used in child bindings");
|
|
11
|
-
}
|
|
12
|
-
render(t) {
|
|
13
|
-
if (t === w || t == null) return this._t = void 0, this.it = t;
|
|
14
|
-
if (t === y) return t;
|
|
15
|
-
if (typeof t != "string") throw Error(this.constructor.directiveName + "() called with a non-string value");
|
|
16
|
-
if (t === this.it) return this._t;
|
|
17
|
-
this.it = t;
|
|
18
|
-
const i = [t];
|
|
19
|
-
return i.raw = i, this._t = { _$litType$: this.constructor.resultType, strings: i, values: [] };
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
a.directiveName = "unsafeHTML", a.resultType = 1;
|
|
23
|
-
const F = v(a);
|
|
24
|
-
/**
|
|
25
|
-
* @license
|
|
26
|
-
* Copyright 2017 Google LLC
|
|
27
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
28
|
-
*/
|
|
29
|
-
class l extends a {
|
|
30
|
-
}
|
|
31
|
-
l.directiveName = "unsafeSVG", l.resultType = 2;
|
|
32
|
-
const g = v(l);
|
|
33
|
-
var S = Object.defineProperty, b = Object.getOwnPropertyDescriptor, r = (e, t, i, o) => {
|
|
34
|
-
for (var s = o > 1 ? void 0 : o ? b(t, i) : t, p = e.length - 1, h; p >= 0; p--)
|
|
35
|
-
(h = e[p]) && (s = (o ? h(t, i, s) : h(s)) || s);
|
|
36
|
-
return o && s && S(t, i, s), s;
|
|
37
|
-
};
|
|
38
|
-
const f = "https://punkt-cdn.oslo.kommune.no/latest/icons/";
|
|
39
|
-
typeof window < "u" && (window.pktFetch = window.pktFetch === void 0 ? fetch : window.pktFetch, window.pktIconPath = window.pktIconPath || f);
|
|
40
|
-
const C = (e) => new Promise((t) => setTimeout(t, e)), c = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>', u = {}, T = async (e, t) => {
|
|
41
|
-
let i = 0;
|
|
42
|
-
for (; u[t + e + ".svg"] === "fetching" && (i++, !(i > 50)); )
|
|
43
|
-
await C(50);
|
|
44
|
-
const o = typeof Storage < "u" && typeof sessionStorage < "u";
|
|
45
|
-
return o && sessionStorage.getItem(t + e + ".svg") ? Promise.resolve(sessionStorage.getItem(t + e + ".svg")) : typeof window < "u" && typeof window.pktFetch == "function" ? (u[t + e + ".svg"] = "fetching", Promise.resolve(
|
|
46
|
-
window.pktFetch(t + e + ".svg").then((s) => s.ok ? s.text() : (console.error("Missing icon: " + t + e + ".svg"), c)).then((s) => (s !== c && o && sessionStorage.setItem(t + e + ".svg", s), u[t + e + ".svg"] = "fetched", s))
|
|
47
|
-
)) : Promise.resolve(c);
|
|
48
|
-
};
|
|
49
|
-
let n = class extends m {
|
|
50
|
-
constructor() {
|
|
51
|
-
super(...arguments), this.path = typeof window < "u" ? window.pktIconPath : f, this.name = "", this.icon = g(c), this._updatedProps = [];
|
|
52
|
-
}
|
|
53
|
-
connectedCallback() {
|
|
54
|
-
super.connectedCallback(), this.classList.add("pkt-icon");
|
|
55
|
-
}
|
|
56
|
-
async attributeChangedCallback(e, t, i) {
|
|
57
|
-
super.attributeChangedCallback(e, t, i), (e === "name" || e === "path") && this.getIcon(this.name);
|
|
58
|
-
}
|
|
59
|
-
async updated(e) {
|
|
60
|
-
super.updated(e), (e.has("name") || e.has("path")) && this.getIcon(this.name);
|
|
61
|
-
}
|
|
62
|
-
async getIcon(e = "") {
|
|
63
|
-
this._updatedProps.length > 0 ? (this.path || (this.path = typeof window < "u" ? window.pktIconPath : f), this.icon = g(
|
|
64
|
-
await T(this.name || "", this.path).then((t) => t)
|
|
65
|
-
), this._updatedProps = []) : this._updatedProps.includes(e) || this._updatedProps.push(e);
|
|
66
|
-
}
|
|
67
|
-
render() {
|
|
68
|
-
return P`${this.name && this.icon}`;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
r([
|
|
72
|
-
d({ type: String, reflect: !1 })
|
|
73
|
-
], n.prototype, "path", 2);
|
|
74
|
-
r([
|
|
75
|
-
d({ type: String, reflect: !0 })
|
|
76
|
-
], n.prototype, "name", 2);
|
|
77
|
-
r([
|
|
78
|
-
d({ type: SVGElement })
|
|
79
|
-
], n.prototype, "icon", 2);
|
|
80
|
-
r([
|
|
81
|
-
d({ type: Array, noAccessor: !0 })
|
|
82
|
-
], n.prototype, "_updatedProps", 2);
|
|
83
|
-
n = r([
|
|
84
|
-
k("pkt-icon")
|
|
85
|
-
], n);
|
|
86
|
-
export {
|
|
87
|
-
n as P,
|
|
88
|
-
F as o
|
|
89
|
-
};
|
package/dist/icon-Dl9ZPqe6.cjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";const o=require("./element-aUzIoa1s.cjs"),a=require("./directive-C7oCP5Bh.cjs");/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/class d extends a.i{constructor(t){if(super(t),this.it=o.E,t.type!==a.t.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===o.E||t==null)return this._t=void 0,this.it=t;if(t===o.T)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const s=[t];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}d.directiveName="unsafeHTML",d.resultType=1;const g=a.e(d);/**
|
|
6
|
-
* @license
|
|
7
|
-
* Copyright 2017 Google LLC
|
|
8
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/class l extends d{}l.directiveName="unsafeSVG",l.resultType=2;const w=a.e(l);var v=Object.defineProperty,y=Object.getOwnPropertyDescriptor,r=(e,t,s,i)=>{for(var n=i>1?void 0:i?y(t,s):t,p=e.length-1,u;p>=0;p--)(u=e[p])&&(n=(i?u(t,s,n):u(n))||n);return i&&n&&v(t,s,n),n};const f="https://punkt-cdn.oslo.kommune.no/latest/icons/";typeof window<"u"&&(window.pktFetch=window.pktFetch===void 0?fetch:window.pktFetch,window.pktIconPath=window.pktIconPath||f);const P=e=>new Promise(t=>setTimeout(t,e)),c='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"></svg>',h={},k=async(e,t)=>{let s=0;for(;h[t+e+".svg"]==="fetching"&&(s++,!(s>50));)await P(50);const i=typeof Storage<"u"&&typeof sessionStorage<"u";return i&&sessionStorage.getItem(t+e+".svg")?Promise.resolve(sessionStorage.getItem(t+e+".svg")):typeof window<"u"&&typeof window.pktFetch=="function"?(h[t+e+".svg"]="fetching",Promise.resolve(window.pktFetch(t+e+".svg").then(n=>n.ok?n.text():(console.error("Missing icon: "+t+e+".svg"),c)).then(n=>(n!==c&&i&&sessionStorage.setItem(t+e+".svg",n),h[t+e+".svg"]="fetched",n)))):Promise.resolve(c)};exports.PktIcon=class extends o.PktElement{constructor(){super(...arguments),this.path=typeof window<"u"?window.pktIconPath:f,this.name="",this.icon=w(c),this._updatedProps=[]}connectedCallback(){super.connectedCallback(),this.classList.add("pkt-icon")}async attributeChangedCallback(t,s,i){super.attributeChangedCallback(t,s,i),(t==="name"||t==="path")&&this.getIcon(this.name)}async updated(t){super.updated(t),(t.has("name")||t.has("path"))&&this.getIcon(this.name)}async getIcon(t=""){this._updatedProps.length>0?(this.path||(this.path=typeof window<"u"?window.pktIconPath:f),this.icon=w(await k(this.name||"",this.path).then(s=>s)),this._updatedProps=[]):this._updatedProps.includes(t)||this._updatedProps.push(t)}render(){return o.x`${this.name&&this.icon}`}};r([o.n({type:String,reflect:!1})],exports.PktIcon.prototype,"path",2);r([o.n({type:String,reflect:!0})],exports.PktIcon.prototype,"name",2);r([o.n({type:SVGElement})],exports.PktIcon.prototype,"icon",2);r([o.n({type:Array,noAccessor:!0})],exports.PktIcon.prototype,"_updatedProps",2);exports.PktIcon=r([o.t("pkt-icon")],exports.PktIcon);exports.o=g;
|