@oslokommune/punkt-elements 19.10.1 → 19.11.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 +32 -0
- package/dist/{accordion-BhCmUDoS.js → accordion-CjGAmoQq.js} +1 -1
- package/dist/{accordion-BFKmnCDh.cjs → accordion-lbYihdiw.cjs} +1 -1
- package/dist/{alert-BJPi5ylH.cjs → alert-CuXM6TnC.cjs} +1 -1
- package/dist/{alert-CUH_2zb2.js → alert-Xt26J9yX.js} +2 -2
- package/dist/base-elements/element-with-slot.d.ts +13 -0
- package/dist/{button-CWHqXdSG.cjs → button-BFG-7bDB.cjs} +1 -1
- package/dist/{button-DQ8rH8hx.js → button-DhCqyX4D.js} +1 -1
- package/dist/{card-DfVOJCWA.js → card-DCc3wfUb.js} +2 -2
- package/dist/{card-pJ0CDH2Y.cjs → card-Diivw_vm.cjs} +1 -1
- package/dist/{checkbox-BEBBPgYW.js → checkbox-CCBZc3Ix.js} +1 -1
- package/dist/{checkbox-3z2uH8rd.cjs → checkbox-Dyyrw5TE.cjs} +1 -1
- package/dist/{checkbox-group-DRQmSHyN.cjs → checkbox-group-COWUvl52.cjs} +1 -1
- package/dist/{checkbox-group-BiPX1EhY.js → checkbox-group-CsrEj7oZ.js} +2 -2
- package/dist/{combobox-CdmzQtCh.js → combobox-B0VWv9c_.js} +5 -5
- package/dist/{combobox-C_SMnNsj.cjs → combobox-I8qdg8A4.cjs} +1 -1
- package/dist/{consent-eTXt052m.js → consent-BUS6GEUu.js} +2 -2
- package/dist/{consent-CkK9BZ7t.cjs → consent-DBYZaCTp.cjs} +1 -1
- package/dist/{datepicker-BrQhahYy.cjs → datepicker-0NSvgPXK.cjs} +1 -1
- package/dist/{datepicker-DILpPWCY.js → datepicker-B80E_4Cg.js} +4 -4
- package/dist/directives/slot-content.d.ts +259 -62
- package/dist/docs/components/alert.d.ts +1 -1
- package/dist/docs/components/slot-internals.d.ts +14 -0
- package/dist/docs/components/slots.d.ts +2 -0
- package/dist/docs/punkt-docs.d.ts +3 -0
- package/dist/docs/tableOfContents.d.ts +15 -0
- package/dist/element-with-slot-CVmm0_IE.js +703 -0
- package/dist/element-with-slot-CcJPCLgn.cjs +1 -0
- package/dist/{fileupload-BZjZh8Mp.js → fileupload-BmfFC748.js} +3 -3
- package/dist/{fileupload-l1d9UQf9.cjs → fileupload-CyLRyoVU.cjs} +1 -1
- package/dist/{footer-C8Zh-eUU.cjs → footer-C6ajmlq2.cjs} +1 -1
- package/dist/{footer-X5MBVUoo.js → footer-L2vhQTAS.js} +1 -1
- package/dist/{header-DLH6Xx97.js → header-DLKiD7xm.js} +6 -6
- package/dist/{header-EvwDJXP-.cjs → header-IQvyDow3.cjs} +1 -1
- package/dist/{header-menu-0UtMd2_H.js → header-menu-Ch135F5Y.js} +1 -1
- package/dist/{header-menu-BqFpYI-V.cjs → header-menu-DpuxDU9a.cjs} +1 -1
- package/dist/{heading-DMHbL3xs.cjs → heading-BluavR6A.cjs} +1 -1
- package/dist/{heading-tWSLaRPD.js → heading-y72aIgB8.js} +1 -1
- package/dist/{helptext-CGa1p-yd.cjs → helptext-Bdv80rcs.cjs} +1 -1
- package/dist/{helptext-Dy2Ehs9W.js → helptext-Dujce_W9.js} +1 -1
- package/dist/{input-element-kIrd5ABs.cjs → input-element-B9Mhkoog.cjs} +1 -1
- package/dist/{input-element-BGbT4ICl.js → input-element-BdDamXvR.js} +1 -1
- package/dist/{input-wrapper-Uks0spRR.js → input-wrapper-Bb6CZxmg.js} +3 -3
- package/dist/{input-wrapper-EvzyXMw-.cjs → input-wrapper-BwzajfFX.cjs} +1 -1
- package/dist/{link-CLdiz-ly.cjs → link-CRLAhYi0.cjs} +1 -1
- package/dist/{link-C0yBFscy.js → link-sO401Ieh.js} +1 -1
- package/dist/{linkcard-B5-p-YC4.js → linkcard-DdmGxzAP.js} +1 -1
- package/dist/{linkcard-v9UsV9Os.cjs → linkcard-DnZgMzqL.cjs} +1 -1
- package/dist/{loader-DWvjIMsT.js → loader-Di5kHEQ4.js} +1 -1
- package/dist/{loader-C4UfUu2u.cjs → loader-Zo_VSsNw.cjs} +1 -1
- package/dist/{messagebox-clOimkn7.cjs → messagebox-CR59jv8N.cjs} +1 -1
- package/dist/{messagebox-CJTqxfu3.js → messagebox-CzaFlrYz.js} +1 -1
- package/dist/{modal-Bm1daKaW.js → modal-B3CQEBBB.js} +2 -2
- package/dist/{modal-BPweteoS.cjs → modal-BKeSXrzi.cjs} +1 -1
- package/dist/{option-group-element-2A4TBcp-.cjs → option-group-element-CzehfgVZ.cjs} +1 -1
- package/dist/{option-group-element-Ber7NAlg.js → option-group-element-D5PgGNdt.js} +2 -2
- 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-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-checkbox-group.cjs +1 -1
- package/dist/pkt-checkbox-group.js +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.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-heading.cjs +1 -1
- package/dist/pkt-heading.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 +29 -29
- 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-options-controller-Ck_549wx.cjs → pkt-options-controller-139UsV4h.cjs} +1 -1
- package/dist/{pkt-options-controller-DTOlYR9b.js → pkt-options-controller-CHosj1Oo.js} +1 -1
- package/dist/pkt-radio-group.cjs +1 -1
- package/dist/pkt-radio-group.js +1 -1
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.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/{radio-group-CMtx_GRV.js → radio-group-CZGcjEmV.js} +2 -2
- package/dist/{radio-group-9Szx2XyM.cjs → radio-group-DaIRh-fL.cjs} +1 -1
- package/dist/{radiobutton-CYbvJ9y8.js → radiobutton-BJCSVvcQ.js} +1 -1
- package/dist/{radiobutton-Dq2qkfi0.cjs → radiobutton-qTPNeZl5.cjs} +1 -1
- package/dist/{scroll-lock-BN8lOhV5.cjs → scroll-lock-B46ur0FF.cjs} +1 -1
- package/dist/{scroll-lock-DAbNKAUy.js → scroll-lock-BALd8hF9.js} +4 -1
- package/dist/{select-DlgOxHIl.js → select-CIAfUw8F.js} +4 -4
- package/dist/{select-1nm17iN8.cjs → select-CQpwjRPh.cjs} +1 -1
- package/dist/shared-utils/heading-ids.d.ts +12 -0
- package/dist/shared-utils/scroll-lock/index.d.ts +3 -1
- package/dist/{tabs-D3pPS9us.js → tabs-DBW3P90Z.js} +2 -1
- package/dist/{tabs-8Y5PlmLl.cjs → tabs-R1Jzzj3-.cjs} +1 -1
- package/dist/{tag-DOUsW7nS.cjs → tag-BMtnaJ1A.cjs} +1 -1
- package/dist/{tag-qHYIycl8.js → tag-uVXp7uP-.js} +1 -1
- package/dist/{textarea-B3qIDyEQ.js → textarea-553WDMEq.js} +3 -3
- package/dist/{textarea-DkeCQKmM.cjs → textarea-DWLVisQX.cjs} +1 -1
- package/dist/{textinput-DibZCHh_.cjs → textinput-C7JFm9jD.cjs} +1 -1
- package/dist/{textinput-CwvVRNsP.js → textinput-wZSCpQgv.js} +3 -3
- package/dist/{timepicker-C_oG9W9Y.js → timepicker-CMe0IbPm.js} +3 -3
- package/dist/{timepicker-CZ_1HVlF.cjs → timepicker-DVyi8teh.cjs} +1 -1
- package/package.json +2 -2
- package/src/components/button/button.test.ts +13 -0
- package/src/components/consent/consent.ts +3 -1
- package/src/components/tabs/tabitem.ts +1 -0
- package/dist/element-with-slot-DOt8HbXA.cjs +0 -1
- package/dist/element-with-slot-U981OZM_.js +0 -353
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./element-with-slot-CcJPCLgn.cjs"),n=require("./if-defined-CiML3MTM.cjs"),r=require("./ref-CB7e9nMY.cjs"),i=require("./input-element-B9Mhkoog.cjs"),a=require("./pkt-options-controller-139UsV4h.cjs"),o=require("./input-wrapper-BwzajfFX.cjs");var s=class extends i.t{constructor(...e){super(...e),this._optionsProp=[],this._options=[]}get options(){return this._options.map(e=>({...e,selected:this.isOptionSelected(e)}))}set options(e){this._optionsProp=e,this.requestUpdate(`_optionsProp`,this._options)}isOptionSelected(e){return Array.isArray(this.value)?this.value.includes(e.value):e.value===this.value}findOptionByValue(e){return this._options.find(t=>t.value===e)}getSelectedOptions(){return this._options.filter(e=>this.isOptionSelected(e))}parseOptions(){let e=this._optionsProp.length>0,t=this.optionsController?.nodes?.length&&this.optionsController.nodes.length>0;e?this._options=this._optionsProp:t&&(this._options=this.optionsController.options)}willUpdate(e){super.willUpdate(e),this.parseOptions()}};e.n([e.u({type:Array,attribute:`options`})],s.prototype,`_optionsProp`,void 0),e.n([e.l()],s.prototype,`_options`,void 0);var c=class extends s{constructor(){super(),this.inputRef=r.t(),this.value=``,this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new a.t(this)}connectedCallback(){super.connectedCallback(),this.parseOptions(),this._options.forEach(e=>{e.selected&&!this.value&&(this.value=e.value)})}add(e,t){let n={value:e.value||e.text,label:e.text||e.value,selected:e.selected,disabled:e.disabled};if(t===void 0)this._options.push(n);else if(typeof t==`number`)this._options.splice(t,0,n);else{let e=t.value||t.text,r=this._options.findIndex(t=>t.value===e);r>=0?this._options.splice(r,0,n):this._options.push(n)}e.selected&&(this.value=e.value||e.text,this.selectedIndex=this._options.findIndex(e=>e.value===this.value)),this.requestUpdate()}remove(e){typeof e==`number`&&(this.selectedIndex===e&&(this.value=this._options[0]?.value||``),this._options.splice(e,1),this.requestUpdate())}item(e){return this.inputRef.value?.item(e)}namedItem(e){return this.inputRef.value?.namedItem(e)}showPicker(){this.inputRef.value&&`showPicker`in this.inputRef.value&&this.inputRef.value.showPicker()}attributeChangedCallback(e,t,n){e===`options`&&(this._options=n?JSON.parse(n):[]),e===`value`&&this.value!==t&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===n),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(n,t)),super.attributeChangedCallback(e,t,n)}update(e){super.update(e),e.has(`_optionsProp`)&&this._optionsProp.length>0&&(this._options=this._optionsProp,this.requestUpdate(`_options`),!this.value&&this._options.length>0&&(this.value=this._options[0].value,this.selectedIndex=0)),e.has(`value`)&&this.value!==e.get(`value`)&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(this.value,e.get(`value`))),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(e){super.firstUpdated(e),this.classList.add(`pkt-select`),this._optionsProp.length&&(this._options=this._optionsProp),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions}render(){let i=`pkt-input pkt-input--${this.inputSize} ${this.fullwidth?`pkt-input--fullwidth`:``}`;return e._`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
${t.n(this,[`helptext`])}
|
|
4
4
|
.strings=${this.strings}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ITocHeading {
|
|
2
|
+
id: string;
|
|
3
|
+
text: string;
|
|
4
|
+
level: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const ensureHeadingIds: (root: ParentNode, selector?: string) => ITocHeading[];
|
|
7
|
+
export declare const getTocHeadings: (root: ParentNode) => ITocHeading[];
|
|
8
|
+
export declare const scrollToHash: (behavior?: ScrollBehavior) => void;
|
|
9
|
+
export declare const watchActiveHeading: (ids: string[], onChange: (id: string) => void, offset?: number) => {
|
|
10
|
+
update: () => void;
|
|
11
|
+
stop: () => void;
|
|
12
|
+
};
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* Strategy: an iOS-safe `position: fixed` lock — `overflow: hidden` alone is
|
|
6
6
|
* ignored by iOS Safari. The current scroll position is saved, the body is
|
|
7
7
|
* pinned, scrollbar width is reserved to avoid a layout shift, and the scroll
|
|
8
|
-
* position is restored on release.
|
|
8
|
+
* position is restored on release. The restore is always instant, so a page
|
|
9
|
+
* with `scroll-behavior: smooth` does not animate from the top back to where
|
|
10
|
+
* it was when the overlay closes.
|
|
9
11
|
*
|
|
10
12
|
* Reference-counted so several open overlays don't unlock the page when one of
|
|
11
13
|
* them closes. Each caller holds a token (see {@link createScrollLockToken}) so
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { _ as e, d as t, l as n, n as r, u as i } from "./element-DBugHPKM.js";
|
|
2
|
-
import { i as a, t as o } from "./element-with-slot-
|
|
2
|
+
import { i as a, t as o } from "./element-with-slot-CVmm0_IE.js";
|
|
3
3
|
import { t as s } from "./if-defined-O59_I-e-.js";
|
|
4
4
|
import { n as c, t as l } from "./consume-Bp12si68.js";
|
|
5
5
|
import { t as u } from "./provide-_MnlMGnw.js";
|
|
6
6
|
import { n as d, t as f } from "./ref-y_5qv9vU.js";
|
|
7
|
+
import "./tag-uVXp7uP-.js";
|
|
7
8
|
//#region src/components/tabs/tabs-context.ts
|
|
8
9
|
var p = c(Symbol("pkt-tabs-context")), m = class extends o {
|
|
9
10
|
constructor(...e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./element-with-slot-CcJPCLgn.cjs"),n=require("./if-defined-CiML3MTM.cjs"),r=require("./consume-kEjgTrAp.cjs"),i=require("./provide-Cz18sYug.cjs"),a=require("./ref-CB7e9nMY.cjs");require("./tag-BMtnaJ1A.cjs");var o=r.n(Symbol(`pkt-tabs-context`)),s=class extends t.t{constructor(...e){super(...e),this.arrowNav=!0,this.disableArrowNav=!1,this.separatorIconName=``,this.separatorIconPath=``,this.tabRefs=[],this.disabledMap={},this.tabCount=0,this.context={useArrowNav:this.useArrowNav,registerTab:this.registerTab.bind(this),handleClick:this.handleClick.bind(this),handleKeyUp:this.handleKeyUp.bind(this)}}get useArrowNav(){return this.arrowNav&&!this.disableArrowNav}willUpdate(e){(e.has(`arrowNav`)||e.has(`disableArrowNav`))&&(this.context={...this.context,useArrowNav:this.useArrowNav})}updated(){this.updateComplete.then(()=>this.syncSeparators())}syncSeparators(){let e=this.querySelector(`.pkt-tabs__list`);if(!e||(e.querySelectorAll(`.pkt-tabs__separator`).forEach(e=>e.remove()),!(this.separatorIconName||this.separatorIconPath)))return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`pkt-tabs__separator`));for(let e=0;e<t.length-1;e++){let n=document.createElement(`span`);if(n.className=`pkt-tabs__separator`,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`role`,`presentation`),this.separatorIconPath){let e=document.createElement(`img`);e.setAttribute(`src`,this.separatorIconPath),e.setAttribute(`alt`,``),e.setAttribute(`aria-hidden`,`true`),n.appendChild(e)}else if(this.separatorIconName){let e=document.createElement(`pkt-icon`);e.setAttribute(`name`,this.separatorIconName),e.classList.add(`pkt-tabs__separator-icon`),n.appendChild(e)}t[e].after(n)}}registerTab(e,t,n=!1){this.tabRefs[t]=e,this.disabledMap[t]=n,this.tabCount=Math.max(this.tabCount,t+1)}isTabDisabled(e){return!!this.disabledMap[e]}findEnabledIndex(e,t){let n=e+t;for(;n>=0&&n<this.tabCount;){if(!this.isTabDisabled(n))return n;n+=t}return null}handleClick(e){this.isTabDisabled(e)||this.dispatchEvent(new CustomEvent(`tab-selected`,{detail:{index:e},bubbles:!0,composed:!0}))}handleKeyUp(e,t){if(this.useArrowNav){if(e.key===`ArrowLeft`){e.preventDefault();let n=this.findEnabledIndex(t,-1);n!==null&&this.tabRefs[n]?.focus()}if(e.key===`ArrowRight`){e.preventDefault();let n=this.findEnabledIndex(t,1);n!==null&&this.tabRefs[n]?.focus()}(e.key===`Enter`||e.key===` `||e.key===`Spacebar`||e.key===`ArrowDown`)&&(e.preventDefault(),this.handleClick(t))}}render(){let n=this.useArrowNav?`tablist`:`navigation`,r=this.separatorIconName||this.separatorIconPath?`pkt-tabs pkt-tabs--with-separator`:`pkt-tabs`;return e._`
|
|
2
2
|
<div class=${r}>
|
|
3
3
|
<div class="pkt-tabs__list" role=${n}>${t.i(this)}</div>
|
|
4
4
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-CcJPCLgn.cjs");require("./icon-jPhyZD1z.cjs");const i=require("./if-defined-CiML3MTM.cjs");var a={name:`pkt-tag`,react:`PktTag`,"css-class":`pkt-tag`,isElement:!0,"dark-mode":!0,props:{size:{name:`Størrelse`,description:`Størrelsen på taggen`,required:!1,default:`medium`,type:[`small`,`medium`,`large`],category:`ui`},iconName:{name:`Ikon`,description:`Navnet på ikonet som skal vises i taggen`,type:`icon`,required:!1,category:`ui`},skin:{name:`Utseende`,description:`Utseendet til taggen`,required:!1,default:`blue`,type:[`blue`,`blue-light`,`blue-dark`,`green`,`red`,`beige`,`yellow`,`gray`],category:`ui`},closeTag:{name:`Lukk tag`,description:`Skal taggen ha en lukkeknapp?`,type:`boolean`,required:!1,default:!1,category:`ui`},textStyle:{name:`Tekststil`,description:`Stilen på teksten i taggen`,required:!1,default:`normal-text`,type:[`thin-text`,`normal-text`],category:`ui`},type:{name:`Type, dersom lukkeknapp`,description:`Type tag, brukes for å spesifisere om det er en knapp, submit eller reset`,required:!1,default:`button`,type:[`button`,`submit`,`reset`],category:`tech`},ariaLabel:{name:`aria-label`,description:`aria-label for taggen, brukes for tilgjengelighet`,type:`string`,required:!1,category:`accessibility`}},slots:{default:{description:`Teksten til tag`}}},o=class extends r.t{constructor(){super(),this.closeTag=a.props.closeTag.default,this.size=a.props.size.default,this.skin=a.props.skin.default,this.textStyle=null,this.iconName=void 0,this.type=a.props.type.default,this.ariaLabel=null,this.buttonTabindex=void 0,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._isClosed=!1}willUpdate(e){if(super.willUpdate(e),this.closeTag&&!this.ariaLabel){let e=r.r(this).getNodes().map(e=>e.textContent??``).join(``).trim();e&&(this._ariaDescription=n.t(this.pktStrings.get(`tag`).remove,{label:e}))}}render(){let n={"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-tag--${this.textStyle}`]:!!this.textStyle,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,"pkt-hide":this._isClosed};return this.closeTag?e._`
|
|
2
2
|
<button
|
|
3
3
|
class=${t.t(a)}
|
|
4
4
|
type=${this.type}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as e, d as t, l as n, n as r, u as i } from "./element-DBugHPKM.js";
|
|
2
2
|
import { t as a } from "./class-map-Bf-QzUpN.js";
|
|
3
3
|
import { t as o } from "./format-BTeSVkED.js";
|
|
4
|
-
import { i as s, r as c, t as l } from "./element-with-slot-
|
|
4
|
+
import { i as s, r as c, t as l } from "./element-with-slot-CVmm0_IE.js";
|
|
5
5
|
import "./icon-Bao96Zb8.js";
|
|
6
6
|
import { t as u } from "./if-defined-O59_I-e-.js";
|
|
7
7
|
var d = {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { _ as e, d as t, f as n, g as r, h as i, l as a, m as o, n as s, p as c, u as l } from "./element-DBugHPKM.js";
|
|
2
2
|
import { t as u } from "./class-map-Bf-QzUpN.js";
|
|
3
3
|
import { i as d, r as f } from "./directive-helpers-CwxFepWh.js";
|
|
4
|
-
import { n as p } from "./element-with-slot-
|
|
4
|
+
import { n as p } from "./element-with-slot-CVmm0_IE.js";
|
|
5
5
|
import "./icon-Bao96Zb8.js";
|
|
6
6
|
import { t as m } from "./if-defined-O59_I-e-.js";
|
|
7
7
|
import { n as h, t as g } from "./ref-y_5qv9vU.js";
|
|
8
|
-
import { t as _ } from "./input-element-
|
|
9
|
-
import { r as v } from "./input-wrapper-
|
|
8
|
+
import { t as _ } from "./input-element-BdDamXvR.js";
|
|
9
|
+
import { r as v } from "./input-wrapper-Bb6CZxmg.js";
|
|
10
10
|
//#region ../../node_modules/lit-html/directives/live.js
|
|
11
11
|
var y = n(class extends c {
|
|
12
12
|
constructor(e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./directive-helpers-Bv70GjQh.cjs"),r=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./directive-helpers-Bv70GjQh.cjs"),r=require("./element-with-slot-CcJPCLgn.cjs");require("./icon-jPhyZD1z.cjs");const i=require("./if-defined-CiML3MTM.cjs"),a=require("./ref-CB7e9nMY.cjs"),o=require("./input-element-B9Mhkoog.cjs"),s=require("./input-wrapper-BwzajfFX.cjs");var c=e.f(class extends e.p{constructor(t){if(super(t),t.type!==e.m.PROPERTY&&t.type!==e.m.ATTRIBUTE&&t.type!==e.m.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!n.i(t))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(t,[r]){if(r===e.g||r===e.h)return r;let i=t.element,a=t.name;if(t.type===e.m.PROPERTY){if(r===i[a])return e.g}else if(t.type===e.m.BOOLEAN_ATTRIBUTE){if(!!r===i.hasAttribute(a))return e.g}else if(t.type===e.m.ATTRIBUTE&&i.getAttribute(a)===r+``)return e.g;return n.r(t),r}}),l=class extends o.t{constructor(...e){super(...e),this.inputRef=a.t(),this.value=``,this.autocomplete=`off`,this.rows=null,this.cols=null,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`,`pkt-textarea`),e.has(`value`)&&this.valueChanged(this.value,e.get(`value`))}render(){let n=this.effectiveCounter(this.counterMaxLength>0),o=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":n&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`<pkt-input-wrapper
|
|
2
2
|
${r.n(this,[`helptext`])}
|
|
3
3
|
.strings=${this.strings}
|
|
4
4
|
label=${this.label}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./element-with-slot-CcJPCLgn.cjs");require("./icon-jPhyZD1z.cjs");const r=require("./if-defined-CiML3MTM.cjs"),i=require("./ref-CB7e9nMY.cjs"),a=require("./input-element-B9Mhkoog.cjs"),o=require("./input-wrapper-BwzajfFX.cjs");var s=class extends a.t{constructor(...e){super(...e),this.inputRef=i.t(),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}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`),e.has(`value`)&&this.valueChanged(this.value,e.get(`value`))}render(){let a=this.type===`search`&&!this.iconNameRight&&!this.omitSearchIcon,s=this.effectiveCounter(this.counterMaxLength>0),c=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":s&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
${n.n(this,[`helptext`])}
|
|
4
4
|
.strings=${this.strings}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-DBugHPKM.js";
|
|
2
2
|
import { t as o } from "./class-map-Bf-QzUpN.js";
|
|
3
|
-
import { n as s } from "./element-with-slot-
|
|
3
|
+
import { n as s } from "./element-with-slot-CVmm0_IE.js";
|
|
4
4
|
import "./icon-Bao96Zb8.js";
|
|
5
5
|
import { t as c } from "./if-defined-O59_I-e-.js";
|
|
6
6
|
import { n as l, t as u } from "./ref-y_5qv9vU.js";
|
|
7
|
-
import { t as d } from "./input-element-
|
|
8
|
-
import { r as f } from "./input-wrapper-
|
|
7
|
+
import { t as d } from "./input-element-BdDamXvR.js";
|
|
8
|
+
import { r as f } from "./input-wrapper-Bb6CZxmg.js";
|
|
9
9
|
//#region src/components/textinput/textinput.ts
|
|
10
10
|
var p = class extends d {
|
|
11
11
|
constructor(...e) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, u as a } from "./element-DBugHPKM.js";
|
|
2
2
|
import { t as o } from "./class-map-Bf-QzUpN.js";
|
|
3
3
|
import { t as s } from "./format-BTeSVkED.js";
|
|
4
|
-
import { n as c } from "./element-with-slot-
|
|
4
|
+
import { n as c } from "./element-with-slot-CVmm0_IE.js";
|
|
5
5
|
import "./icon-Bao96Zb8.js";
|
|
6
6
|
import { t as l } from "./if-defined-O59_I-e-.js";
|
|
7
7
|
import { n as u, t as d } from "./ref-y_5qv9vU.js";
|
|
8
|
-
import { t as f } from "./input-element-
|
|
9
|
-
import { r as p } from "./input-wrapper-
|
|
8
|
+
import { t as f } from "./input-element-BdDamXvR.js";
|
|
9
|
+
import { r as p } from "./input-wrapper-Bb6CZxmg.js";
|
|
10
10
|
//#region ../../shared-utils/timepicker/time-utils.ts
|
|
11
11
|
var m = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && parseInt(e.slice(3), 10) <= 59, h = (e) => {
|
|
12
12
|
let [t, n] = e.split(":").map(Number);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-DOt8HbXA.cjs");require("./icon-jPhyZD1z.cjs");const i=require("./if-defined-CiML3MTM.cjs"),a=require("./ref-CB7e9nMY.cjs"),o=require("./input-element-kIrd5ABs.cjs"),s=require("./input-wrapper-EvzyXMw-.cjs");var c=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,l=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},u=e=>e?Math.max(1,Math.round(e/60)):1,d=(e,t)=>{let n=e?parseInt(String(e).split(`:`)[0],10):0,r=t?parseInt(String(t).split(`:`)[0],10):23;return Array.from({length:r-n+1},(e,t)=>t+n)},f=e=>{let t=u(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},p=(e,t,n,r)=>{let i=e===``?n===1?0:23:parseInt(e,10),a=t===``?n===1?0:Math.floor(59/r)*r:parseInt(t,10);return a+=n*r,a>59?(a=0,i=(i+1)%24):a<0&&(a=Math.floor(59/r)*r,i=(i-1+24)%24),{hours:String(i).padStart(2,`0`),minutes:String(a).padStart(2,`0`)}},m=class extends o.t{constructor(...e){super(...e),this.hiddenInputRef=a.t(),this.hoursInputRef=a.t(),this.minutesInputRef=a.t(),this.buttonRef=a.t(),this.value=``,this.hidePicker=!1,this.stepArrows=!1,this._hours=``,this._minutes=``,this._isOpen=!1,this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._hasFocus=!1,this._outsideClickHandler=e=>{this.contains(e.target)||this._closePopup()},this._handleComponentFocusIn=()=>{this._hasFocus||(this._hasFocus=!0,this.onFocus())},this._handleComponentFocusOut=e=>{this.contains(e.relatedTarget)||(this._hasFocus=!1,this.onBlur())},this._handleHoursKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t+1)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t-1+24)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowRight`:e.preventDefault(),this.minutesInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._hoursDigitCount=0,this._hoursFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._hoursDigitCount===0)this._hoursFirstDigit=t,this._hours=String(t).padStart(2,`0`),this._hoursDigitCount=1,this.onInput(),t>=3&&(this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.minutesInputRef.value?.focus());else{let e=this._hoursFirstDigit*10+t;this._hours=e<=23?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.onInput(),this.minutesInputRef.value?.focus()}}else e.preventDefault()}},this._handleHoursBlur=()=>{this._hours!==``&&(this._hours=String(parseInt(this._hours,10)).padStart(2,`0`)),this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._syncValueFromDisplay()},this._handleMinutesKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t+this._minuteStep)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t-this._minuteStep+60)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowLeft`:e.preventDefault(),this.hoursInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._minutesDigitCount=0,this._minutesFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._minutesDigitCount===0)this._minutesFirstDigit=t,this._minutes=String(t).padStart(2,`0`),this._minutesDigitCount=1,this.onInput(),t>=6&&(this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay());else{let e=this._minutesFirstDigit*10+t;this._minutes=e<=59?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay(),this.onInput()}}else e.preventDefault()}},this._handleMinutesBlur=()=>{this._minutes!==``&&(this._minutes=String(parseInt(this._minutes,10)).padStart(2,`0`)),this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._syncValueFromDisplay()},this._handlePopupKeydown=e=>{let t=document.activeElement,n=t.closest(`.pkt-timepicker-popup__col`);if(!n)return;let r=Array.from(n.querySelectorAll(`.pkt-timepicker-popup__option`)),i=r.indexOf(t),a=t.dataset.type??``;switch(e.key){case`ArrowDown`:e.preventDefault(),this._focusOptionAndSync(r[Math.min(i+1,r.length-1)],a);break;case`ArrowUp`:e.preventDefault(),this._focusOptionAndSync(r[Math.max(i-1,0)],a);break;case`Home`:e.preventDefault(),this._focusOptionAndSync(r[0],a);break;case`End`:e.preventDefault(),this._focusOptionAndSync(r[r.length-1],a);break;case`ArrowRight`:e.preventDefault(),a===`hour`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`minute`)}));break;case`ArrowLeft`:e.preventDefault(),a===`minute`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)}));break;case`Enter`:case` `:e.preventDefault(),t.click();break;case`Escape`:e.preventDefault(),this._closePopup(),this.buttonRef.value?.focus()}}}get inputRef(){return this.hiddenInputRef}manageValidity(e){let t=this.hoursInputRef.value;if(!t)return;let r=this.pktStrings.get(`validation`);if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},r.valueMissing,t),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let i=l(this.value),a=u(this.step);if(this.min&&i<l(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},n.t(r.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);return}if(this.max&&i>l(String(this.max))){this.internals.setValidity({rangeOverflow:!0},n.t(r.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);return}if(this.step&&i%a!==0){let e=a===60?r.timeStepMismatchHour:a===30?r.timeStepMismatchHalfHour:n.t(r.timeStepMismatch,{step:`${a}, ${a*2}, ${a*3}`});this.internals.setValidity({stepMismatch:!0},e,t),this._setAriaInvalid(!0);return}this.internals.setValidity({}),this._setAriaInvalid(!1)}_describedBy(){return s.r({id:`${this.id}-hours`,hasHelptext:!!this.helptext||this.hasSlotContent(`helptext`),ariaDescribedby:this.ariaDescribedby})}_setAriaInvalid(e){if(!this.touched&&e)return;let t=this.hoursInputRef.value,n=this.minutesInputRef.value;if(e)t?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-invalid`,`true`);else{if(this.hasError)return;t?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-invalid`)}}connectedCallback(){super.connectedCallback(),this.addEventListener(`focusin`,this._handleComponentFocusIn),this.addEventListener(`focusout`,this._handleComponentFocusOut),document.addEventListener(`click`,this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`focusin`,this._handleComponentFocusIn),this.removeEventListener(`focusout`,this._handleComponentFocusOut),document.removeEventListener(`click`,this._outsideClickHandler)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&this._syncDisplayFromValue()}updated(e){super.updated(e),this.classList.add(`pkt-timepicker`),this.classList.toggle(`pkt-timepicker--stepper`,this.stepArrows),this.classList.toggle(`pkt-timepicker--fullwidth`,this.fullwidth),this.classList.toggle(`pkt-timepicker--medium`,this.inputSize===`medium`),this.classList.toggle(`pkt-timepicker--small`,this.inputSize===`small`),this.classList.toggle(`pkt-timepicker--xsmall`,this.inputSize===`xsmall`),e.has(`step`)&&this.step!==null&&!this._isValidStep(this.step)&&console.warn(`pkt-timepicker: step="${this.step}" er ikke en gyldig verdi. Step må være et multiplum av 60 (hele minutter) eller nøyaktig 3600 (hel time).`)}formResetCallback(){super.formResetCallback(),this._hours=``,this._minutes=``,this._isOpen=!1}_isValidStep(e){return e===3600||e<3600&&3600%e==0&&e%60==0}_syncDisplayFromValue(){let e=c(this.value)?this.value.split(`:`):null;e?(this._hours=e[0],this._minutes=e[1]):(this._hours=``,this._minutes=``)}_syncValueFromDisplay(){if(this._hours!==``&&this._minutes!==``){let e=`${this._hours}:${this._minutes}`;e!==this.value&&(this.value=e,this.onChange(e))}else this.value!==``&&(this.value=``,this.onChange(``))}get _minuteStep(){return u(this.step)}get _hourOptions(){return d(this.min,this.max)}get _minuteOptions(){return f(this.step)}_openPopup(){this._isOpen=!0,this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)})}_closePopup(){this._isOpen=!1,this._syncValueFromDisplay()}_togglePopup(){this._isOpen?this._closePopup():this._openPopup()}_scrollToSelected(){let e=this.querySelector(`.pkt-timepicker-popup`);e&&e.querySelectorAll(`.pkt-timepicker-popup__col`).forEach(e=>{let t=e.querySelector(`.pkt-timepicker-popup__option--selected`);t&&t.scrollIntoView({block:`center`})})}_focusSelectedOrFirst(e){let t=this.querySelector(`.pkt-timepicker-popup`);if(!t)return;let n=t.querySelectorAll(`.pkt-timepicker-popup__col`),r=e===`hour`?n[0]:n[1];if(!r)return;let i=r.querySelector(`.pkt-timepicker-popup__option--selected`),a=r.querySelector(`.pkt-timepicker-popup__option`);(i||a)?.focus()}_handleOptionClick(e,t){let n=String(e).padStart(2,`0`);t===`hour`?(this._hours=n,this.updateComplete.then(()=>this._focusSelectedOrFirst(`minute`))):(this._minutes=n,this._closePopup(),this.buttonRef.value?.focus())}_focusOptionAndSync(e,t){if(!e)return;let n=parseInt(e.dataset.value??`0`,10);t===`hour`?this._hours=String(n).padStart(2,`0`):this._minutes=String(n).padStart(2,`0`),e.focus()}_stepTime(e){let t=p(this._hours,this._minutes,e,this._minuteStep);this._hours=t.hours,this._minutes=t.minutes,this._syncValueFromDisplay()}_renderOption(n,r){let i=String(n).padStart(2,`0`),a=n===(r===`hour`?this._hours===``?NaN:parseInt(this._hours,10):this._minutes===``?NaN:parseInt(this._minutes,10));return e._`
|
|
1
|
+
const e=require("./element-C6WTyJFE.cjs"),t=require("./class-map-Bh6toDeV.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-CcJPCLgn.cjs");require("./icon-jPhyZD1z.cjs");const i=require("./if-defined-CiML3MTM.cjs"),a=require("./ref-CB7e9nMY.cjs"),o=require("./input-element-B9Mhkoog.cjs"),s=require("./input-wrapper-BwzajfFX.cjs");var c=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,l=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},u=e=>e?Math.max(1,Math.round(e/60)):1,d=(e,t)=>{let n=e?parseInt(String(e).split(`:`)[0],10):0,r=t?parseInt(String(t).split(`:`)[0],10):23;return Array.from({length:r-n+1},(e,t)=>t+n)},f=e=>{let t=u(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},p=(e,t,n,r)=>{let i=e===``?n===1?0:23:parseInt(e,10),a=t===``?n===1?0:Math.floor(59/r)*r:parseInt(t,10);return a+=n*r,a>59?(a=0,i=(i+1)%24):a<0&&(a=Math.floor(59/r)*r,i=(i-1+24)%24),{hours:String(i).padStart(2,`0`),minutes:String(a).padStart(2,`0`)}},m=class extends o.t{constructor(...e){super(...e),this.hiddenInputRef=a.t(),this.hoursInputRef=a.t(),this.minutesInputRef=a.t(),this.buttonRef=a.t(),this.value=``,this.hidePicker=!1,this.stepArrows=!1,this._hours=``,this._minutes=``,this._isOpen=!1,this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._hasFocus=!1,this._outsideClickHandler=e=>{this.contains(e.target)||this._closePopup()},this._handleComponentFocusIn=()=>{this._hasFocus||(this._hasFocus=!0,this.onFocus())},this._handleComponentFocusOut=e=>{this.contains(e.relatedTarget)||(this._hasFocus=!1,this.onBlur())},this._handleHoursKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t+1)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t-1+24)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowRight`:e.preventDefault(),this.minutesInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._hoursDigitCount=0,this._hoursFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._hoursDigitCount===0)this._hoursFirstDigit=t,this._hours=String(t).padStart(2,`0`),this._hoursDigitCount=1,this.onInput(),t>=3&&(this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.minutesInputRef.value?.focus());else{let e=this._hoursFirstDigit*10+t;this._hours=e<=23?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.onInput(),this.minutesInputRef.value?.focus()}}else e.preventDefault()}},this._handleHoursBlur=()=>{this._hours!==``&&(this._hours=String(parseInt(this._hours,10)).padStart(2,`0`)),this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._syncValueFromDisplay()},this._handleMinutesKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t+this._minuteStep)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t-this._minuteStep+60)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowLeft`:e.preventDefault(),this.hoursInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._minutesDigitCount=0,this._minutesFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._minutesDigitCount===0)this._minutesFirstDigit=t,this._minutes=String(t).padStart(2,`0`),this._minutesDigitCount=1,this.onInput(),t>=6&&(this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay());else{let e=this._minutesFirstDigit*10+t;this._minutes=e<=59?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay(),this.onInput()}}else e.preventDefault()}},this._handleMinutesBlur=()=>{this._minutes!==``&&(this._minutes=String(parseInt(this._minutes,10)).padStart(2,`0`)),this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._syncValueFromDisplay()},this._handlePopupKeydown=e=>{let t=document.activeElement,n=t.closest(`.pkt-timepicker-popup__col`);if(!n)return;let r=Array.from(n.querySelectorAll(`.pkt-timepicker-popup__option`)),i=r.indexOf(t),a=t.dataset.type??``;switch(e.key){case`ArrowDown`:e.preventDefault(),this._focusOptionAndSync(r[Math.min(i+1,r.length-1)],a);break;case`ArrowUp`:e.preventDefault(),this._focusOptionAndSync(r[Math.max(i-1,0)],a);break;case`Home`:e.preventDefault(),this._focusOptionAndSync(r[0],a);break;case`End`:e.preventDefault(),this._focusOptionAndSync(r[r.length-1],a);break;case`ArrowRight`:e.preventDefault(),a===`hour`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`minute`)}));break;case`ArrowLeft`:e.preventDefault(),a===`minute`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)}));break;case`Enter`:case` `:e.preventDefault(),t.click();break;case`Escape`:e.preventDefault(),this._closePopup(),this.buttonRef.value?.focus()}}}get inputRef(){return this.hiddenInputRef}manageValidity(e){let t=this.hoursInputRef.value;if(!t)return;let r=this.pktStrings.get(`validation`);if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},r.valueMissing,t),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let i=l(this.value),a=u(this.step);if(this.min&&i<l(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},n.t(r.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);return}if(this.max&&i>l(String(this.max))){this.internals.setValidity({rangeOverflow:!0},n.t(r.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);return}if(this.step&&i%a!==0){let e=a===60?r.timeStepMismatchHour:a===30?r.timeStepMismatchHalfHour:n.t(r.timeStepMismatch,{step:`${a}, ${a*2}, ${a*3}`});this.internals.setValidity({stepMismatch:!0},e,t),this._setAriaInvalid(!0);return}this.internals.setValidity({}),this._setAriaInvalid(!1)}_describedBy(){return s.r({id:`${this.id}-hours`,hasHelptext:!!this.helptext||this.hasSlotContent(`helptext`),ariaDescribedby:this.ariaDescribedby})}_setAriaInvalid(e){if(!this.touched&&e)return;let t=this.hoursInputRef.value,n=this.minutesInputRef.value;if(e)t?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-invalid`,`true`);else{if(this.hasError)return;t?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-invalid`)}}connectedCallback(){super.connectedCallback(),this.addEventListener(`focusin`,this._handleComponentFocusIn),this.addEventListener(`focusout`,this._handleComponentFocusOut),document.addEventListener(`click`,this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`focusin`,this._handleComponentFocusIn),this.removeEventListener(`focusout`,this._handleComponentFocusOut),document.removeEventListener(`click`,this._outsideClickHandler)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&this._syncDisplayFromValue()}updated(e){super.updated(e),this.classList.add(`pkt-timepicker`),this.classList.toggle(`pkt-timepicker--stepper`,this.stepArrows),this.classList.toggle(`pkt-timepicker--fullwidth`,this.fullwidth),this.classList.toggle(`pkt-timepicker--medium`,this.inputSize===`medium`),this.classList.toggle(`pkt-timepicker--small`,this.inputSize===`small`),this.classList.toggle(`pkt-timepicker--xsmall`,this.inputSize===`xsmall`),e.has(`step`)&&this.step!==null&&!this._isValidStep(this.step)&&console.warn(`pkt-timepicker: step="${this.step}" er ikke en gyldig verdi. Step må være et multiplum av 60 (hele minutter) eller nøyaktig 3600 (hel time).`)}formResetCallback(){super.formResetCallback(),this._hours=``,this._minutes=``,this._isOpen=!1}_isValidStep(e){return e===3600||e<3600&&3600%e==0&&e%60==0}_syncDisplayFromValue(){let e=c(this.value)?this.value.split(`:`):null;e?(this._hours=e[0],this._minutes=e[1]):(this._hours=``,this._minutes=``)}_syncValueFromDisplay(){if(this._hours!==``&&this._minutes!==``){let e=`${this._hours}:${this._minutes}`;e!==this.value&&(this.value=e,this.onChange(e))}else this.value!==``&&(this.value=``,this.onChange(``))}get _minuteStep(){return u(this.step)}get _hourOptions(){return d(this.min,this.max)}get _minuteOptions(){return f(this.step)}_openPopup(){this._isOpen=!0,this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)})}_closePopup(){this._isOpen=!1,this._syncValueFromDisplay()}_togglePopup(){this._isOpen?this._closePopup():this._openPopup()}_scrollToSelected(){let e=this.querySelector(`.pkt-timepicker-popup`);e&&e.querySelectorAll(`.pkt-timepicker-popup__col`).forEach(e=>{let t=e.querySelector(`.pkt-timepicker-popup__option--selected`);t&&t.scrollIntoView({block:`center`})})}_focusSelectedOrFirst(e){let t=this.querySelector(`.pkt-timepicker-popup`);if(!t)return;let n=t.querySelectorAll(`.pkt-timepicker-popup__col`),r=e===`hour`?n[0]:n[1];if(!r)return;let i=r.querySelector(`.pkt-timepicker-popup__option--selected`),a=r.querySelector(`.pkt-timepicker-popup__option`);(i||a)?.focus()}_handleOptionClick(e,t){let n=String(e).padStart(2,`0`);t===`hour`?(this._hours=n,this.updateComplete.then(()=>this._focusSelectedOrFirst(`minute`))):(this._minutes=n,this._closePopup(),this.buttonRef.value?.focus())}_focusOptionAndSync(e,t){if(!e)return;let n=parseInt(e.dataset.value??`0`,10);t===`hour`?this._hours=String(n).padStart(2,`0`):this._minutes=String(n).padStart(2,`0`),e.focus()}_stepTime(e){let t=p(this._hours,this._minutes,e,this._minuteStep);this._hours=t.hours,this._minutes=t.minutes,this._syncValueFromDisplay()}_renderOption(n,r){let i=String(n).padStart(2,`0`),a=n===(r===`hour`?this._hours===``?NaN:parseInt(this._hours,10):this._minutes===``?NaN:parseInt(this._minutes,10));return e._`
|
|
2
2
|
<button
|
|
3
3
|
class=${t.t({"pkt-btn":!0,"pkt-btn--tertiary":!0,"pkt-btn--small":!0,"pkt-btn--label-only":!0,"pkt-timepicker-popup__option":!0,"pkt-timepicker-popup__option--selected":a})}
|
|
4
4
|
type="button"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.11.0",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, designsystem for Oslo kommune",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo kommune",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "d83cbdb71c65b51c7eb5270970a287c4eff8f19a"
|
|
88
88
|
}
|
|
@@ -80,6 +80,19 @@ describe('PktButton', () => {
|
|
|
80
80
|
expect(textSpan).toBeInTheDocument()
|
|
81
81
|
expect(textSpan?.textContent?.trim()).toContain('Button Text Content')
|
|
82
82
|
})
|
|
83
|
+
|
|
84
|
+
test('keeps its template when textContent is changed after rendering', async () => {
|
|
85
|
+
const { button } = await createButtonTest({ content: 'Lagre' })
|
|
86
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
87
|
+
|
|
88
|
+
button.textContent = 'Lagrer'
|
|
89
|
+
await button.updateComplete
|
|
90
|
+
button.textContent = 'Lagret'
|
|
91
|
+
await button.updateComplete
|
|
92
|
+
|
|
93
|
+
expect(button.querySelector('button')).toBeInTheDocument()
|
|
94
|
+
expect(button.querySelector('.pkt-btn__text')?.textContent?.trim()).toBe('Lagret')
|
|
95
|
+
})
|
|
83
96
|
})
|
|
84
97
|
|
|
85
98
|
describe('Properties and attributes', () => {
|
|
@@ -96,7 +96,9 @@ export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
|
|
|
96
96
|
connectedCallback(): void {
|
|
97
97
|
super.connectedCallback()
|
|
98
98
|
const language = (
|
|
99
|
-
Object.
|
|
99
|
+
Object.prototype.hasOwnProperty.call(consentStrings.i18n, this.i18nLanguage)
|
|
100
|
+
? this.i18nLanguage
|
|
101
|
+
: 'nb'
|
|
100
102
|
) as keyof typeof consentStrings.i18n
|
|
101
103
|
this.triggerText =
|
|
102
104
|
this.triggerText || consentStrings.i18n[language].contentPresentation.buttons.settings
|
|
@@ -6,6 +6,7 @@ import { consume } from '@lit/context'
|
|
|
6
6
|
import { createRef, Ref, ref } from 'lit/directives/ref.js'
|
|
7
7
|
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
8
8
|
import { tabsContext, type TabsContext } from './tabs-context'
|
|
9
|
+
import '@/components/tag'
|
|
9
10
|
|
|
10
11
|
export type TSkin = 'blue' | 'green' | 'red' | 'beige' | 'yellow' | 'grey' | 'gray' | 'blue-light'
|
|
11
12
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./element-C6WTyJFE.cjs"),t=require("./async-directive-DpyKp6qv.cjs");function n(e){return e.classList&&(e.classList.contains(`_dialog_overlay`)||e.classList.contains(`backdrop`))?!0:typeof e.hasAttribute==`function`&&e.hasAttribute(`data-skip`)}function r(e){return e.nodeName===`OPTION`||e.nodeName===`DATA`}function i(e){return e.nodeType===Node.TEXT_NODE&&e.nodeValue?.trim()!==``}var a=new WeakMap,o=new WeakMap;function s(e){let t=a.get(e);return t||(t=new g(e),a.set(e,t)),t}var c=Symbol(`default`);function l(e){return e===void 0?c:e}function u(e){return Array.isArray(e)?e.map(e=>{let t=e===null?c:e;return[t,t]}):Object.entries(e).map(([e,t])=>[e,t===null?c:t])}function d(e,t){return e.length===t.length&&e.every(([e,n],r)=>t[r][0]===e&&t[r][1]===n)}function f(e,t){if(e.nodeType===Node.COMMENT_NODE)return!1;if(e.nodeType===Node.TEXT_NODE)return i(e)?(h(t,c,e),!0):!1;if(e.nodeType===Node.ELEMENT_NODE){let i=e;if(n(i)||r(i))return!1;if(i instanceof HTMLTemplateElement){let e=Array.from(i.content.childNodes),n=l(i.getAttribute(`slot`)??void 0);for(let r of e)h(t,n,r);return!0}return h(t,p(e),e),!0}return!1}function p(e){if(e.nodeType!==Node.ELEMENT_NODE)return c;let t=e.getAttribute(`slot`);return t===null?c:l(t)}function m(e,t){return e.node.compareDocumentPosition(t.node)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function h(e,t,n){let r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}var g=class e{static{this.PLACEHOLDER_PREFIX=`pkt-slot`}constructor(e){this.observer=null,this.nodesBySlot=new Map,this.directives=new Set,this.observing=!1,this.trackedNodes=new Set,this.generation=0,this.initialCollectionDone=!1,this.processingMutations=!1,this.placeholderToNode=new Map,this.nodeToPlaceholder=new Map,this.sources=new Map,this.subscribers=new Set,this.followsHostRenders=!1,this.wantsObserver=!1,this.host=e,typeof e.addController==`function`&&(this.followsHostRenders=!0,e.addController({hostConnected:()=>{this.wantsObserver&&this.startObserving()},hostDisconnected:()=>this.stopObservingIfUnused(),hostUpdate:()=>{e.hasUpdated||this.collectLateChildren(),this.flushMutations(!1)},hostUpdated:()=>this.flushMutations(!0)}))}collectNodes(){if(this.initialCollectionDone)return;this.initialCollectionDone=!0,this.generation++;let e=Array.from(this.host.childNodes);for(let t of e)f(t,this.nodesBySlot)&&this.track(t)}collectLateChildren(){if(this.initialCollectionDone)for(let e of Array.from(this.host.childNodes))this.trackedNodes.has(e)||!this.isUserContent(e)||(e instanceof HTMLTemplateElement?f(e,this.nodesBySlot):this.insertInSlotOrder(e),this.track(e),this.generation++)}addDirective(e){this.directives.add(e),this.startObserving()}removeDirective(e){this.directives.delete(e),this.stopObservingIfUnused()}addSource(e,t,n){let r=this.sources.get(e);r&&r.manager===t&&d(r.mapping,n)||(r&&r.manager!==t&&this.detachFrom(r.manager,e),this.sources.set(e,{manager:t,mapping:n}),t.subscribers.add(this),t.startObserving(),this.handleChange())}removeSource(e){let t=this.sources.get(e);t&&(this.sources.delete(e),this.detachFrom(t.manager,e),this.handleChange())}getNodes(e){return this.nodesFor(l(e))}hasContent(e){return this.getNodes(e).length>0}ensurePlaceholder(t){if(this.nodeToPlaceholder.has(t))return;if(t.parentNode!==this.host){for(let{manager:e}of this.sources.values())e.ensurePlaceholder(t);return}let n=document.createComment(e.PLACEHOLDER_PREFIX);this.host.insertBefore(n,t),this.placeholderToNode.set(n,t),this.nodeToPlaceholder.set(t,n)}nodesFor(e){let t=this.nodesBySlot.get(e)??[];if(this.sources.size===0)return t;let n=[];for(let{manager:t,mapping:r}of this.sources.values())for(let[i,a]of r)a===e&&n.push(...t.nodesFor(i));return n.length?[...t,...n]:t}detachFrom(e,t){[...this.sources.entries()].some(([n,r])=>n!==t&&r.manager===e)||(e.subscribers.delete(this),e.stopObservingIfUnused())}handleChange(){this.generation++,this.notifyDirectives();for(let e of this.subscribers)e.handleChange();this.host.requestUpdate()}stopObservingIfUnused(){let e=this.directives.size===0&&this.subscribers.size===0;(!this.host.isConnected||e&&!this.followsHostRenders)&&this.stopObserving()}startObserving(){if(this.wantsObserver=!0,this.observing)return;this.observing=!0;let e=()=>{!this.observing||typeof MutationObserver>`u`||(this.observer=new MutationObserver(e=>{this.handleMutations(e)}),this.observer.observe(this.host,{childList:!0,subtree:!0}))};this.followsHostRenders?e():setTimeout(e,0)}flushMutations(e){if(this.processingMutations)return;let t=this.observer?.takeRecords();t?.length&&this.handleMutations(t,e)}stopObserving(){this.observing&&(this.observing=!1,this.observer?.disconnect(),this.observer=null)}handleMutations(e,t=!1){if(this.processingMutations)return;this.processingMutations=!0;let n=!1,r=[],i=new Map,a=[];for(let o of e){for(let e of o.removedNodes){let a=this.placeholderToNode.get(e);if(a){if(this.placeholderToNode.delete(e),this.nodeToPlaceholder.delete(a),t)continue;a.parentNode?.removeChild(a),this.untrack(a),this.removeFromSlots(a),n=!0;continue}if(this.trackedNodes.has(e)&&!this.host.contains(e)&&!t){this.untrack(e),this.removeFromSlots(e);let t=this.nodeToPlaceholder.get(e);if(t&&(this.placeholderToNode.delete(t),this.nodeToPlaceholder.delete(e),r.push(t),o.target!==this.host)){let e=i.get(o.target)??[];e.push(t),i.set(o.target,e)}n=!0}}if(o.target!==this.host){o.addedNodes.length&&a.push(o);continue}if(!t)for(let e of o.addedNodes)this.placeholderToNode.has(e)||!this.trackedNodes.has(e)&&this.isUserContent(e)&&(e instanceof HTMLTemplateElement?f(e,this.nodesBySlot):this.insertInSlotOrder(e),this.track(e),n=!0)}i.size&&this.adoptNodesInParts(a,i)&&(n=!0);for(let e of r)e.parentNode?.removeChild(e);n&&this.handleChange(),this.observer?.takeRecords(),this.processingMutations=!1}adoptNodesInParts(t,n){let r=new Set;for(let e of t)n.has(e.target)&&e.addedNodes.forEach(e=>r.add(e));if(r.size===0)return!1;let i=this.reachableParts(),a=[];for(let e of r){if(!e.parentNode||!n.has(e.parentNode)||o.has(e)||this.placeholderToNode.has(e))continue;let t=i.find(t=>t.contains(e));if(!t)continue;let r=this.hostPositionFor(e,t,n);r&&a.push({node:e,before:r.before})}if(a.length===0)return!1;let s=!1;for(let{node:t,before:n}of a.sort(m))if(this.isUserContent(t)&&!(t instanceof HTMLTemplateElement)){let r=document.createComment(e.PLACEHOLDER_PREFIX);this.host.insertBefore(r,n),this.placeholderToNode.set(r,t),this.nodeToPlaceholder.set(t,r),this.insertInSlotOrder(t),this.track(t),s=!0}else this.host.insertBefore(t,n);return s}hostPositionFor(e,t,n){let{startNode:r,endNode:i}=t.bounds();for(let t=e.nextSibling;t&&t!==i;t=t.nextSibling){let e=this.placeholderOf(t);if(e)return{before:e}}for(let t=e.previousSibling;t&&t!==r;t=t.previousSibling){let e=this.placeholderOf(t);if(e)return{before:e.nextSibling}}let a=e.parentNode?n.get(e.parentNode):void 0;return a?{before:a[0]}:null}placeholderOf(e){return this.trackedNodes.has(e)?this.nodeToPlaceholder.get(e):void 0}reachableParts(e=new Set){if(e.has(this))return[];e.add(this);let t=[...this.directives];for(let n of this.subscribers)t.push(...n.reachableParts(e));return t}insertInSlotOrder(e){let t=p(e),n=this.nodesBySlot.get(t)??[];this.nodesBySlot.set(t,n);let r=this.nodeToPlaceholder.get(e)??e,i=e=>{let t=this.nodeToPlaceholder.get(e)??e;return!!(r.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)};if(n.length===0||!i(n[n.length-1])){n.push(e);return}n.splice(n.findIndex(i),0,e)}track(e){this.trackedNodes.add(e),o.set(e,this)}untrack(e){this.trackedNodes.delete(e),o.get(e)===this&&o.delete(e)}isUserContent(e){if(e.nodeType===Node.COMMENT_NODE)return!1;if(e.nodeType===Node.TEXT_NODE)return i(e);if(e.nodeType===Node.ELEMENT_NODE){let t=e;return!(n(t)||r(t))}return!1}removeFromSlots(e){for(let[t,n]of this.nodesBySlot){let r=n.indexOf(e);if(r!==-1){n.splice(r,1),n.length===0&&this.nodesBySlot.delete(t);return}}}notifyDirectives(){for(let e of this.directives)e.handleNodesChanged()}},_=class extends t.t{constructor(t){if(super(t),this.manager=null,this.host=null,this.part=null,this.lastGeneration=-1,t.type!==e.m.CHILD)throw Error(`slotContent() can only be used in child expressions`)}render(t,n){return e.g}update(t,[n,r]){return this.part=t,this.host=n,this.slotName=r,this.manager||(this.manager=s(n),this.manager.collectNodes(),this.manager.addDirective(this)),this.placeNodes(),e.g}handleNodesChanged(){!this.isConnected||!this.manager||this.placeNodes()}disconnected(){this.manager?.removeDirective(this),this.manager=null,this.lastGeneration=-1}reconnected(){this.host&&(this.manager=s(this.host),this.manager.addDirective(this),this.placeNodes())}contains(e){let t=this.parentOfPart();return this.isConnected&&!!t&&this.isInsidePart(e,t)}bounds(){return{startNode:this.part?.startNode??null,endNode:this.part?.endNode??null}}parentOfPart(){return this.part?this.part.startNode?this.part.startNode.parentNode:this.part.parentNode:null}placeNodes(){if(!this.manager||!this.part)return;let e=this.manager.generation;if(e===this.lastGeneration)return;this.lastGeneration=e;let t=this.manager.getNodes(this.slotName);for(let e of t)this.manager.ensurePlaceholder(e);let n=this.parentOfPart();if(!n)return;let r=this.part.endNode;for(let e=t.length-1;e>=0;e--){let i=t[e];this.isInsidePart(i,n)||n.insertBefore(i,r),r=i}}isInsidePart(e,t){if(!this.part||e.parentNode!==t)return!1;let{startNode:n,endNode:r}=this.part,i=!n||!!(n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING),a=!r||!!(e.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_FOLLOWING);return i&&a}},v=e.f(_),y=class extends t.t{constructor(t){if(super(t),this.target=null,this.source=null,this.mapping=[],t.type!==e.m.ELEMENT)throw Error(`forwardSlots() can only be used as an element directive`)}render(t,n){return e.g}update(t,[n,r]){let i=s(t.element);return this.target&&this.target!==i&&this.target.removeSource(this),this.target=i,this.source=s(n),this.source.collectNodes(),this.mapping=u(r),this.target.addSource(this,this.source,this.mapping),e.g}disconnected(){this.target?.removeSource(this)}reconnected(){this.target&&this.source&&this.target.addSource(this,this.source,this.mapping)}},b=e.f(y),x=class extends e.t{connectedCallback(){s(this).collectNodes(),super.connectedCallback()}hasSlotContent(e){return s(this).hasContent(e)}};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return x}});
|