@oslokommune/punkt-elements 14.2.0 → 14.4.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 +34 -0
- package/dist/{checkbox-CnhA52o_.js → checkbox-DfVUNTjH.js} +1 -1
- package/dist/{checkbox-C0TPnShf.cjs → checkbox-uxeHrTLH.cjs} +1 -1
- package/dist/{combobox-C1xwAju5.cjs → combobox-CcyHcqdW.cjs} +13 -13
- package/dist/{combobox-Dcp_fHcL.js → combobox-MZsqmVL-.js} +45 -45
- package/dist/{datepicker-COIRRau0.cjs → datepicker-BeMs_vsm.cjs} +25 -25
- package/dist/{datepicker-Bjb9GK1E.js → datepicker-a2LvhbRb.js} +215 -234
- package/dist/index.d.ts +236 -34
- package/dist/input-element-CARcDzQB.js +840 -0
- package/dist/input-element-CiaV6jln.cjs +1 -0
- 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-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +2 -2
- package/dist/pkt-header.cjs +9 -7
- package/dist/pkt-header.js +137 -123
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +7 -7
- package/dist/pkt-options-controller-DjBCEHU4.cjs +1 -0
- package/dist/{pkt-options-controller-CZO1nxZ8.js → pkt-options-controller-zn5cmMvL.js} +3 -3
- 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-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/{radiobutton-Caq8-GhM.js → radiobutton-BmgdSpYf.js} +1 -1
- package/dist/{radiobutton-BkqaqO5E.cjs → radiobutton-DVe09YxP.cjs} +1 -1
- package/dist/select-7KFOnLln.cjs +49 -0
- package/dist/select-CKqz-JKZ.js +228 -0
- package/dist/{textarea-a6T4aJJU.js → textarea-Bmrv_vve.js} +1 -1
- package/dist/{textarea-DyUy8u7X.cjs → textarea-VBUXPS1O.cjs} +1 -1
- package/dist/{textinput-IN3b0nSH.cjs → textinput-BkYKotc1.cjs} +1 -1
- package/dist/{textinput-DIuM70dd.js → textinput-Lp1crOmj.js} +1 -1
- package/package.json +2 -2
- package/src/components/checkbox/checkbox.ts +1 -1
- package/src/components/combobox/combobox.ts +2 -2
- package/src/components/datepicker/datepicker-utils.test.ts +0 -25
- package/src/components/datepicker/datepicker-utils.ts +0 -28
- package/src/components/datepicker/datepicker.ts +0 -6
- package/src/components/header/header-service.ts +12 -8
- package/src/components/header/header.ts +8 -2
- package/src/components/header/index.ts +4 -1
- package/src/components/header/types.ts +18 -22
- package/src/components/index.ts +4 -1
- package/src/components/radiobutton/radiobutton.ts +1 -1
- package/src/components/select/select.ts +12 -47
- package/src/components/textarea/textarea.ts +1 -1
- package/src/components/textinput/textinput.ts +1 -1
- package/dist/input-element-B8M8Nppd.js +0 -708
- package/dist/input-element-D697OAJo.cjs +0 -1
- package/dist/pkt-options-controller-CiuBG6Lt.cjs +0 -1
- package/dist/select-3dwlk22G.cjs +0 -49
- package/dist/select-_C-yztI0.js +0 -173
package/dist/pkt-select.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./select-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./select-7KFOnLln.cjs"),t=e.PktSelect;Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>e.PktSelect});exports.default=t;
|
package/dist/pkt-select.js
CHANGED
package/dist/pkt-textarea.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./textarea-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./textarea-VBUXPS1O.cjs"),t=e.PktTextarea;Object.defineProperty(exports,"PktTextarea",{enumerable:!0,get:()=>e.PktTextarea});exports.default=t;
|
package/dist/pkt-textarea.js
CHANGED
package/dist/pkt-textinput.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./textinput-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./textinput-BkYKotc1.cjs"),t=e.PktTextinput;Object.defineProperty(exports,"PktTextinput",{enumerable:!0,get:()=>e.PktTextinput});exports.default=t;
|
package/dist/pkt-textinput.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { x as h, E as n, n as s, a as d } from "./element-CRDRygXu.js";
|
|
2
2
|
import { r as k } from "./state-DS_kr2Fy.js";
|
|
3
|
-
import { P as f } from "./input-element-
|
|
3
|
+
import { P as f } from "./input-element-CARcDzQB.js";
|
|
4
4
|
import { e as g, n as y } from "./ref-Xa5dbh--.js";
|
|
5
5
|
import { e as u } from "./class-map-wy7PUk0P.js";
|
|
6
6
|
var $ = Object.defineProperty, b = Object.getOwnPropertyDescriptor, i = (e, p, c, l) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("./element-CJ_QKaki.cjs"),r=require("./state-DSjcvzDN.cjs"),u=require("./input-element-
|
|
1
|
+
"use strict";const t=require("./element-CJ_QKaki.cjs"),r=require("./state-DSjcvzDN.cjs"),u=require("./input-element-CiaV6jln.cjs"),h=require("./ref-BFa5Utho.cjs"),c=require("./class-map-C_erArZz.cjs");var d=Object.defineProperty,k=Object.getOwnPropertyDescriptor,i=(p,e,n,a)=>{for(var s=a>1?void 0:a?k(e,n):e,o=p.length-1,l;o>=0;o--)(l=p[o])&&(s=(a?l(e,n,s):l(s))||s);return a&&s&&d(e,n,s),s};exports.PktRadioButton=class extends u.PktInputElement{constructor(){super(...arguments),this.inputRef=h.e(),this.value="",this.checkHelptext=null,this.defaultChecked=!1,this.hasTile=!1,this.checked=null,this.type="radio",this.tagText=null,this.optionalTag=!1,this.optionalText="Valgfritt",this.requiredTag=!1,this.requiredText="Må fylles ut",this._checked=!1}connectedCallback(){super.connectedCallback()}attributeChangedCallback(e,n,a){e==="defaultChecked"&&(this._checked=this.defaultChecked),e==="checked"&&(this._checked=this.checked===""||this.checked==="true"||this.checked===!0),super.attributeChangedCallback(e,n,a)}render(){const e=c.e({"pkt-input-check__input":!0,"pkt-input-check__input--tile":this.hasTile,"pkt-input-check__input--tile-disabled":this.disabled&&this.hasTile}),n=c.e({"pkt-input-check__input-checkbox":!0,"pkt-input-check__input-checkbox--error":this.hasError}),a=c.e({"pkt-input-check__input-label":!0,"pkt-input-check__input-label--disabled":this.disabled,"pkt-sr-only":this.hideLabel}),s="pkt-tag pkt-tag--small pkt-tag--thin-text",o=()=>t.x`
|
|
2
2
|
${this.tagText?t.x`<span class=${s+" pkt-tag--gray"}>${this.tagText}</span>`:t.E}
|
|
3
3
|
${this.optionalTag?t.x`<span class=${s+" pkt-tag--blue-light"}>${this.optionalText}</span>`:t.E}
|
|
4
4
|
${this.requiredTag?t.x`<span class=${s+" pkt-tag--beige"}>${this.requiredText}</span>`:t.E}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";const p=require("./element-CJ_QKaki.cjs"),h=require("./ref-BFa5Utho.cjs"),l=require("./if-defined-Bc9-_I01.cjs"),c=require("./state-DSjcvzDN.cjs"),v=require("./input-element-CiaV6jln.cjs"),f=require("./pkt-options-controller-DjBCEHU4.cjs"),_=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-CtBiAb04.cjs");var $=Object.defineProperty,u=(r,t,e,i)=>{for(var s=void 0,o=r.length-1,n;o>=0;o--)(n=r[o])&&(s=n(t,e,s)||s);return s&&$(t,e,s),s};class a extends v.PktInputElement{constructor(){super(...arguments),this._optionsProp=[],this._options=[]}get options(){return this._options.map(t=>({...t,selected:this.isOptionSelected(t)}))}set options(t){this._optionsProp=t,this.requestUpdate("_optionsProp",this._options)}isOptionSelected(t){return Array.isArray(this.value)?this.value.includes(t.value):t.value===this.value}findOptionByValue(t){return this._options.find(e=>e.value===t)}getSelectedOptions(){return this._options.filter(t=>this.isOptionSelected(t))}parseOptions(){var i,s;const t=this._optionsProp.length>0,e=((s=(i=this.optionsController)==null?void 0:i.nodes)==null?void 0:s.length)&&this.optionsController.nodes.length>0;t?this._options=this._optionsProp:e&&(this._options=this.optionsController.options)}willUpdate(t){super.willUpdate(t),this.parseOptions()}}u([p.n({type:Array,attribute:"options"})],a.prototype,"_optionsProp");u([c.r()],a.prototype,"_options");var x=Object.defineProperty,b=Object.getOwnPropertyDescriptor,d=(r,t,e,i)=>{for(var s=i>1?void 0:i?b(t,e):t,o=r.length-1,n;o>=0;o--)(n=r[o])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&x(t,e,s),s};exports.PktSelect=class extends a{constructor(){super(),this.inputRef=h.e(),this.helptextSlot=h.e(),this.value="",this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new f.PktOptionsSlotController(this),this.slotController=new _.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}connectedCallback(){super.connectedCallback(),this.parseOptions(),this._options.forEach(t=>{t.selected&&!this.value&&(this.value=t.value)})}add(t,e){const i={value:t.value||t.text,label:t.text||t.value,selected:t.selected,disabled:t.disabled};if(e===void 0)this._options.push(i);else if(typeof e=="number")this._options.splice(e,0,i);else{const s=e.value||e.text,o=this._options.findIndex(n=>n.value===s);o>=0?this._options.splice(o,0,i):this._options.push(i)}t.selected&&(this.value=t.value||t.text,this.selectedIndex=this._options.findIndex(s=>s.value===this.value)),this.requestUpdate()}remove(t){var e;typeof t=="number"&&(this.selectedIndex===t&&(this.value=((e=this._options[0])==null?void 0:e.value)||""),this._options.splice(t,1),this.requestUpdate())}item(t){var e;return(e=this.inputRef.value)==null?void 0:e.item(t)}namedItem(t){var e;return(e=this.inputRef.value)==null?void 0:e.namedItem(t)}showPicker(){this.inputRef.value&&"showPicker"in this.inputRef.value&&this.inputRef.value.showPicker()}attributeChangedCallback(t,e,i){var s,o;t==="options"&&(this._options=i?JSON.parse(i):[]),t==="value"&&this.value!==e&&(this.selectedIndex=this.touched?this.returnNumberOrNull((s=this.inputRef.value)==null?void 0:s.selectedIndex):this._options.findIndex(n=>n.value===i),this.selectedOptions=(o=this.inputRef.value)==null?void 0:o.selectedOptions,this.valueChanged(i,e)),super.attributeChangedCallback(t,e,i)}update(t){var e,i;super.update(t),t.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)),t.has("value")&&this.value!==t.get("value")&&(this.selectedIndex=this.touched?this.returnNumberOrNull((e=this.inputRef.value)==null?void 0:e.selectedIndex):this._options.findIndex(s=>s.value===this.value),this.selectedOptions=(i=this.inputRef.value)==null?void 0:i.selectedOptions,this.valueChanged(this.value,t.get("value"))),t.has("id")&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(t){var e;super.firstUpdated(t),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(i=>i.value===this.value),this.selectedOptions=(e=this.inputRef.value)==null?void 0:e.selectedOptions}render(){const t=`pkt-input ${this.fullwidth?"pkt-input--fullwidth":""}`;return p.x`
|
|
2
|
+
<pkt-input-wrapper
|
|
3
|
+
?counter=${this.counter}
|
|
4
|
+
?disabled=${this.disabled}
|
|
5
|
+
?hasError=${this.hasError}
|
|
6
|
+
?hasFieldset=${this.hasFieldset}
|
|
7
|
+
?inline=${this.inline}
|
|
8
|
+
?optionalTag=${this.optionalTag}
|
|
9
|
+
?requiredTag=${this.requiredTag}
|
|
10
|
+
useWrapper=${this.useWrapper}
|
|
11
|
+
ariaDescribedBy=${l.o(this.ariaDescribedBy)}
|
|
12
|
+
class="pkt-select"
|
|
13
|
+
errorMessage=${l.o(this.errorMessage)}
|
|
14
|
+
forId=${this.id+"-input"}
|
|
15
|
+
helptext=${l.o(this.helptext)}
|
|
16
|
+
helptextDropdown=${l.o(this.helptextDropdown)}
|
|
17
|
+
helptextDropdownButton=${l.o(this.helptextDropdownButton)}
|
|
18
|
+
label=${l.o(this.label)}
|
|
19
|
+
optionalText=${l.o(this.optionalText)}
|
|
20
|
+
requiredText=${l.o(this.requiredText)}
|
|
21
|
+
tagText=${l.o(this.tagText)}
|
|
22
|
+
>
|
|
23
|
+
<select
|
|
24
|
+
class=${t}
|
|
25
|
+
aria-invalid=${this.hasError}
|
|
26
|
+
aria-errormessage=${`${this.id}-error`}
|
|
27
|
+
aria-labelledby=${l.o(this.ariaLabelledby)}
|
|
28
|
+
?disabled=${this.disabled}
|
|
29
|
+
id=${this.id+"-input"}
|
|
30
|
+
name=${(this.name||this.id)+"-input"}
|
|
31
|
+
value=${this.value}
|
|
32
|
+
@change=${e=>{this.touched=!0,this.value=e.target.value,e.stopImmediatePropagation()}}
|
|
33
|
+
@input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
|
|
34
|
+
@focus=${e=>{this.onFocus(),e.stopImmediatePropagation()}}
|
|
35
|
+
@blur=${e=>{this.onBlur(),e.stopImmediatePropagation()}}
|
|
36
|
+
${h.n(this.inputRef)}
|
|
37
|
+
>
|
|
38
|
+
${this._options.length>0?this._options.map(e=>p.x`<option
|
|
39
|
+
value=${e.value}
|
|
40
|
+
?selected=${this.value==e.value||e.selected}
|
|
41
|
+
?disabled=${e.disabled}
|
|
42
|
+
?hidden=${e.hidden}
|
|
43
|
+
>
|
|
44
|
+
${e.label}
|
|
45
|
+
</option>`):""}
|
|
46
|
+
</select>
|
|
47
|
+
<div class="pkt-contents" ${h.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
48
|
+
</pkt-input-wrapper>
|
|
49
|
+
`}returnNumberOrNull(t){return t==null||isNaN(t)?null:t}};d([p.n({type:String})],exports.PktSelect.prototype,"value",2);exports.PktSelect=d([p.t("pkt-select")],exports.PktSelect);
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { n as c, x as a, a as _ } from "./element-CRDRygXu.js";
|
|
2
|
+
import { e as u, n as d } from "./ref-Xa5dbh--.js";
|
|
3
|
+
import { o as n } from "./if-defined-BWZGb3bh.js";
|
|
4
|
+
import { r as $ } from "./state-DS_kr2Fy.js";
|
|
5
|
+
import { P as x } from "./input-element-CARcDzQB.js";
|
|
6
|
+
import { P as m } from "./pkt-options-controller-zn5cmMvL.js";
|
|
7
|
+
import { P as b } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
8
|
+
import "./input-wrapper-1PCXqtiu.js";
|
|
9
|
+
var P = Object.defineProperty, v = (e, t, s, o) => {
|
|
10
|
+
for (var i = void 0, l = e.length - 1, p; l >= 0; l--)
|
|
11
|
+
(p = e[l]) && (i = p(t, s, i) || i);
|
|
12
|
+
return i && P(t, s, i), i;
|
|
13
|
+
};
|
|
14
|
+
class h extends x {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments), this._optionsProp = [], this._options = [];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Public getter for options that includes selected state
|
|
20
|
+
* Override this in subclasses to customize the selected state logic
|
|
21
|
+
*/
|
|
22
|
+
get options() {
|
|
23
|
+
return this._options.map((t) => ({
|
|
24
|
+
...t,
|
|
25
|
+
selected: this.isOptionSelected(t)
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Public setter for options
|
|
30
|
+
*/
|
|
31
|
+
set options(t) {
|
|
32
|
+
this._optionsProp = t, this.requestUpdate("_optionsProp", this._options);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Determines if an option is selected
|
|
36
|
+
* Subclasses should override this to implement their selection logic
|
|
37
|
+
*
|
|
38
|
+
* @param option - The option to check
|
|
39
|
+
* @returns True if the option is selected
|
|
40
|
+
* @protected
|
|
41
|
+
*/
|
|
42
|
+
isOptionSelected(t) {
|
|
43
|
+
return Array.isArray(this.value) ? this.value.includes(t.value) : t.value === this.value;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Finds an option by its value
|
|
47
|
+
*
|
|
48
|
+
* @param value - The value to search for
|
|
49
|
+
* @returns The option if found, undefined otherwise
|
|
50
|
+
* @protected
|
|
51
|
+
*/
|
|
52
|
+
findOptionByValue(t) {
|
|
53
|
+
return this._options.find((s) => s.value === t);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Gets all currently selected options
|
|
57
|
+
*
|
|
58
|
+
* @returns Array of selected options
|
|
59
|
+
* @protected
|
|
60
|
+
*/
|
|
61
|
+
getSelectedOptions() {
|
|
62
|
+
return this._options.filter((t) => this.isOptionSelected(t));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Parses options from either props or slot controller
|
|
66
|
+
* Call this in connectedCallback to initialize options
|
|
67
|
+
*
|
|
68
|
+
* @protected
|
|
69
|
+
*/
|
|
70
|
+
parseOptions() {
|
|
71
|
+
var o, i;
|
|
72
|
+
const t = this._optionsProp.length > 0, s = ((i = (o = this.optionsController) == null ? void 0 : o.nodes) == null ? void 0 : i.length) && this.optionsController.nodes.length > 0;
|
|
73
|
+
t ? this._options = this._optionsProp : s && (this._options = this.optionsController.options);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Re-parse options when the component updates
|
|
77
|
+
* This ensures options stay in sync when they change dynamically
|
|
78
|
+
*
|
|
79
|
+
* @protected
|
|
80
|
+
*/
|
|
81
|
+
willUpdate(t) {
|
|
82
|
+
super.willUpdate(t), this.parseOptions();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
v([
|
|
86
|
+
c({ type: Array, attribute: "options" })
|
|
87
|
+
], h.prototype, "_optionsProp");
|
|
88
|
+
v([
|
|
89
|
+
$()
|
|
90
|
+
], h.prototype, "_options");
|
|
91
|
+
var g = Object.defineProperty, O = Object.getOwnPropertyDescriptor, f = (e, t, s, o) => {
|
|
92
|
+
for (var i = o > 1 ? void 0 : o ? O(t, s) : t, l = e.length - 1, p; l >= 0; l--)
|
|
93
|
+
(p = e[l]) && (i = (o ? p(t, s, i) : p(i)) || i);
|
|
94
|
+
return o && i && g(t, s, i), i;
|
|
95
|
+
};
|
|
96
|
+
let r = class extends h {
|
|
97
|
+
constructor() {
|
|
98
|
+
super(), this.inputRef = u(), this.helptextSlot = u(), this.value = "", this.selectedIndex = -1, this.selectedOptions = void 0, this.optionsController = new m(this), this.slotController = new b(this, this.helptextSlot), this.slotController.skipOptions = !0;
|
|
99
|
+
}
|
|
100
|
+
connectedCallback() {
|
|
101
|
+
super.connectedCallback(), this.parseOptions(), this._options.forEach((e) => {
|
|
102
|
+
e.selected && !this.value && (this.value = e.value);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// Support native Select method `add`
|
|
106
|
+
add(e, t) {
|
|
107
|
+
const s = {
|
|
108
|
+
value: e.value || e.text,
|
|
109
|
+
label: e.text || e.value,
|
|
110
|
+
selected: e.selected,
|
|
111
|
+
disabled: e.disabled
|
|
112
|
+
};
|
|
113
|
+
if (t === void 0)
|
|
114
|
+
this._options.push(s);
|
|
115
|
+
else if (typeof t == "number")
|
|
116
|
+
this._options.splice(t, 0, s);
|
|
117
|
+
else {
|
|
118
|
+
const o = t.value || t.text, i = this._options.findIndex((l) => l.value === o);
|
|
119
|
+
i >= 0 ? this._options.splice(i, 0, s) : this._options.push(s);
|
|
120
|
+
}
|
|
121
|
+
e.selected && (this.value = e.value || e.text, this.selectedIndex = this._options.findIndex((o) => o.value === this.value)), this.requestUpdate();
|
|
122
|
+
}
|
|
123
|
+
// Support native Select method `remove`
|
|
124
|
+
remove(e) {
|
|
125
|
+
var t;
|
|
126
|
+
typeof e == "number" && (this.selectedIndex === e && (this.value = ((t = this._options[0]) == null ? void 0 : t.value) || ""), this._options.splice(e, 1), this.requestUpdate());
|
|
127
|
+
}
|
|
128
|
+
// Support native Select method `item`
|
|
129
|
+
item(e) {
|
|
130
|
+
var t;
|
|
131
|
+
return (t = this.inputRef.value) == null ? void 0 : t.item(e);
|
|
132
|
+
}
|
|
133
|
+
// Support native Select method `namedItem`
|
|
134
|
+
namedItem(e) {
|
|
135
|
+
var t;
|
|
136
|
+
return (t = this.inputRef.value) == null ? void 0 : t.namedItem(e);
|
|
137
|
+
}
|
|
138
|
+
// Support native Select method `showPicker`
|
|
139
|
+
showPicker() {
|
|
140
|
+
this.inputRef.value && "showPicker" in this.inputRef.value && this.inputRef.value.showPicker();
|
|
141
|
+
}
|
|
142
|
+
attributeChangedCallback(e, t, s) {
|
|
143
|
+
var o, i;
|
|
144
|
+
e === "options" && (this._options = s ? JSON.parse(s) : []), e === "value" && this.value !== t && (this.selectedIndex = this.touched ? this.returnNumberOrNull((o = this.inputRef.value) == null ? void 0 : o.selectedIndex) : this._options.findIndex((l) => l.value === s), this.selectedOptions = (i = this.inputRef.value) == null ? void 0 : i.selectedOptions, this.valueChanged(s, t)), super.attributeChangedCallback(e, t, s);
|
|
145
|
+
}
|
|
146
|
+
update(e) {
|
|
147
|
+
var t, s;
|
|
148
|
+
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((t = this.inputRef.value) == null ? void 0 : t.selectedIndex) : this._options.findIndex((o) => o.value === this.value), this.selectedOptions = (s = this.inputRef.value) == null ? void 0 : s.selectedOptions, this.valueChanged(this.value, e.get("value"))), e.has("id") && !this.name && this.id && (this.name = this.id);
|
|
149
|
+
}
|
|
150
|
+
firstUpdated(e) {
|
|
151
|
+
var t;
|
|
152
|
+
super.firstUpdated(e), 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((s) => s.value === this.value), this.selectedOptions = (t = this.inputRef.value) == null ? void 0 : t.selectedOptions;
|
|
153
|
+
}
|
|
154
|
+
render() {
|
|
155
|
+
const e = `pkt-input ${this.fullwidth ? "pkt-input--fullwidth" : ""}`;
|
|
156
|
+
return a`
|
|
157
|
+
<pkt-input-wrapper
|
|
158
|
+
?counter=${this.counter}
|
|
159
|
+
?disabled=${this.disabled}
|
|
160
|
+
?hasError=${this.hasError}
|
|
161
|
+
?hasFieldset=${this.hasFieldset}
|
|
162
|
+
?inline=${this.inline}
|
|
163
|
+
?optionalTag=${this.optionalTag}
|
|
164
|
+
?requiredTag=${this.requiredTag}
|
|
165
|
+
useWrapper=${this.useWrapper}
|
|
166
|
+
ariaDescribedBy=${n(this.ariaDescribedBy)}
|
|
167
|
+
class="pkt-select"
|
|
168
|
+
errorMessage=${n(this.errorMessage)}
|
|
169
|
+
forId=${this.id + "-input"}
|
|
170
|
+
helptext=${n(this.helptext)}
|
|
171
|
+
helptextDropdown=${n(this.helptextDropdown)}
|
|
172
|
+
helptextDropdownButton=${n(this.helptextDropdownButton)}
|
|
173
|
+
label=${n(this.label)}
|
|
174
|
+
optionalText=${n(this.optionalText)}
|
|
175
|
+
requiredText=${n(this.requiredText)}
|
|
176
|
+
tagText=${n(this.tagText)}
|
|
177
|
+
>
|
|
178
|
+
<select
|
|
179
|
+
class=${e}
|
|
180
|
+
aria-invalid=${this.hasError}
|
|
181
|
+
aria-errormessage=${`${this.id}-error`}
|
|
182
|
+
aria-labelledby=${n(this.ariaLabelledby)}
|
|
183
|
+
?disabled=${this.disabled}
|
|
184
|
+
id=${this.id + "-input"}
|
|
185
|
+
name=${(this.name || this.id) + "-input"}
|
|
186
|
+
value=${this.value}
|
|
187
|
+
@change=${(t) => {
|
|
188
|
+
this.touched = !0, this.value = t.target.value, t.stopImmediatePropagation();
|
|
189
|
+
}}
|
|
190
|
+
@input=${(t) => {
|
|
191
|
+
this.onInput(), t.stopImmediatePropagation();
|
|
192
|
+
}}
|
|
193
|
+
@focus=${(t) => {
|
|
194
|
+
this.onFocus(), t.stopImmediatePropagation();
|
|
195
|
+
}}
|
|
196
|
+
@blur=${(t) => {
|
|
197
|
+
this.onBlur(), t.stopImmediatePropagation();
|
|
198
|
+
}}
|
|
199
|
+
${d(this.inputRef)}
|
|
200
|
+
>
|
|
201
|
+
${this._options.length > 0 ? this._options.map(
|
|
202
|
+
(t) => a`<option
|
|
203
|
+
value=${t.value}
|
|
204
|
+
?selected=${this.value == t.value || t.selected}
|
|
205
|
+
?disabled=${t.disabled}
|
|
206
|
+
?hidden=${t.hidden}
|
|
207
|
+
>
|
|
208
|
+
${t.label}
|
|
209
|
+
</option>`
|
|
210
|
+
) : ""}
|
|
211
|
+
</select>
|
|
212
|
+
<div class="pkt-contents" ${d(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
213
|
+
</pkt-input-wrapper>
|
|
214
|
+
`;
|
|
215
|
+
}
|
|
216
|
+
returnNumberOrNull(e) {
|
|
217
|
+
return e == null || isNaN(e) ? null : e;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
f([
|
|
221
|
+
c({ type: String })
|
|
222
|
+
], r.prototype, "value", 2);
|
|
223
|
+
r = f([
|
|
224
|
+
_("pkt-select")
|
|
225
|
+
], r);
|
|
226
|
+
export {
|
|
227
|
+
r as P
|
|
228
|
+
};
|
|
@@ -5,7 +5,7 @@ import { e as m, n as c } from "./ref-Xa5dbh--.js";
|
|
|
5
5
|
import { e as v } from "./class-map-wy7PUk0P.js";
|
|
6
6
|
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-BzAtj9by.js";
|
|
8
|
-
import { P as C } from "./input-element-
|
|
8
|
+
import { P as C } from "./input-element-CARcDzQB.js";
|
|
9
9
|
import { P as E } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
10
10
|
import "./input-wrapper-1PCXqtiu.js";
|
|
11
11
|
import "./icon-BB7e5iQN.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const s=require("./element-CJ_QKaki.cjs"),p=require("./if-defined-Bc9-_I01.cjs"),c=require("./state-DSjcvzDN.cjs"),l=require("./ref-BFa5Utho.cjs"),$=require("./class-map-C_erArZz.cjs"),a=require("./directive-C7oCP5Bh.cjs"),d=require("./directive-helpers-4oOjKnGY.cjs"),x=require("./input-element-
|
|
1
|
+
"use strict";const s=require("./element-CJ_QKaki.cjs"),p=require("./if-defined-Bc9-_I01.cjs"),c=require("./state-DSjcvzDN.cjs"),l=require("./ref-BFa5Utho.cjs"),$=require("./class-map-C_erArZz.cjs"),a=require("./directive-C7oCP5Bh.cjs"),d=require("./directive-helpers-4oOjKnGY.cjs"),x=require("./input-element-CiaV6jln.cjs"),T=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-CtBiAb04.cjs");require("./icon-MRx-m0Or.cjs");/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2020 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("./element-CJ_QKaki.cjs"),a=require("./if-defined-Bc9-_I01.cjs"),l=require("./state-DSjcvzDN.cjs"),h=require("./ref-BFa5Utho.cjs"),c=require("./class-map-C_erArZz.cjs"),d=require("./input-element-
|
|
1
|
+
"use strict";const t=require("./element-CJ_QKaki.cjs"),a=require("./if-defined-Bc9-_I01.cjs"),l=require("./state-DSjcvzDN.cjs"),h=require("./ref-BFa5Utho.cjs"),c=require("./class-map-C_erArZz.cjs"),d=require("./input-element-CiaV6jln.cjs"),x=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-CtBiAb04.cjs");require("./icon-MRx-m0Or.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}
|
|
@@ -3,7 +3,7 @@ import { o as u } from "./if-defined-BWZGb3bh.js";
|
|
|
3
3
|
import { r as f } from "./state-DS_kr2Fy.js";
|
|
4
4
|
import { e as d, n as m } from "./ref-Xa5dbh--.js";
|
|
5
5
|
import { e as g } from "./class-map-wy7PUk0P.js";
|
|
6
|
-
import { P as x } from "./input-element-
|
|
6
|
+
import { P as x } from "./input-element-CARcDzQB.js";
|
|
7
7
|
import { P as v } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
8
8
|
import "./input-wrapper-1PCXqtiu.js";
|
|
9
9
|
import "./icon-BB7e5iQN.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.4.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",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
80
80
|
},
|
|
81
81
|
"license": "MIT",
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "60b409e10bc60371f696d76a84ce6e0d25cb225a"
|
|
83
83
|
}
|
|
@@ -23,7 +23,7 @@ type Props = ElementProps<
|
|
|
23
23
|
|
|
24
24
|
@customElement('pkt-checkbox')
|
|
25
25
|
export class PktCheckbox extends PktInputElement<Props> {
|
|
26
|
-
|
|
26
|
+
inputRef: Ref<HTMLInputElement> = createRef()
|
|
27
27
|
|
|
28
28
|
@property({ type: String, reflect: true }) value: string = ''
|
|
29
29
|
@property({ type: String }) checkHelptext: string | null = null
|
|
@@ -93,8 +93,8 @@ export class PktCombobox extends PktInputElement implements IPktCombobox {
|
|
|
93
93
|
|
|
94
94
|
// State
|
|
95
95
|
@state() _options: IPktComboboxOption[] = []
|
|
96
|
+
@state() _value: string[] = [] // Internal value representation
|
|
96
97
|
@state() private _isOptionsOpen = false
|
|
97
|
-
@state() private _value: string[] = []
|
|
98
98
|
@state() private _userInfoMessage: string = ''
|
|
99
99
|
@state() private _addValueText: string | null = null
|
|
100
100
|
@state() private _maxIsReached: boolean = false
|
|
@@ -130,7 +130,7 @@ export class PktCombobox extends PktInputElement implements IPktCombobox {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// If options are provided via the options slot, we need to extract them
|
|
133
|
-
if (this.optionsController.nodes.length) {
|
|
133
|
+
if (this.optionsController?.nodes && this.optionsController.nodes.length) {
|
|
134
134
|
const options: IPktComboboxOption[] = []
|
|
135
135
|
this.optionsController.nodes.forEach((node: Element) => {
|
|
136
136
|
if (!node.textContent && !node.getAttribute('value')) return null
|
|
@@ -13,31 +13,6 @@ import { createRef } from 'lit/directives/ref.js'
|
|
|
13
13
|
|
|
14
14
|
describe('datepicker-utils', () => {
|
|
15
15
|
describe('valueUtils', () => {
|
|
16
|
-
describe('normalizeNameForMultiple', () => {
|
|
17
|
-
it('should return null when name is null', () => {
|
|
18
|
-
expect(valueUtils.normalizeNameForMultiple(null, false, false)).toBe(null)
|
|
19
|
-
expect(valueUtils.normalizeNameForMultiple(null, true, false)).toBe(null)
|
|
20
|
-
expect(valueUtils.normalizeNameForMultiple(null, false, true)).toBe(null)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('should add [] suffix for multiple inputs without []', () => {
|
|
24
|
-
expect(valueUtils.normalizeNameForMultiple('dates', true, false)).toBe('dates[]')
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('should add [] suffix for range inputs without []', () => {
|
|
28
|
-
expect(valueUtils.normalizeNameForMultiple('daterange', false, true)).toBe('daterange[]')
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('should not add [] suffix when already present', () => {
|
|
32
|
-
expect(valueUtils.normalizeNameForMultiple('dates[]', true, false)).toBe('dates[]')
|
|
33
|
-
expect(valueUtils.normalizeNameForMultiple('range[]', false, true)).toBe('range[]')
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('should not modify name for single inputs', () => {
|
|
37
|
-
expect(valueUtils.normalizeNameForMultiple('singledate', false, false)).toBe('singledate')
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
16
|
describe('validateRangeOrder', () => {
|
|
42
17
|
it('should return true for incomplete ranges', () => {
|
|
43
18
|
expect(valueUtils.validateRangeOrder([])).toBe(true)
|
|
@@ -27,34 +27,6 @@ import { PktCalendar } from '@/components/calendar/calendar'
|
|
|
27
27
|
* Value parsing and validation utilities
|
|
28
28
|
*/
|
|
29
29
|
export const valueUtils = {
|
|
30
|
-
/**
|
|
31
|
-
* Ensures name attribute ends with [] for multiple/range inputs
|
|
32
|
-
*
|
|
33
|
-
* For form submission to work correctly with multiple values,
|
|
34
|
-
* the input name must end with [] to indicate it's an array.
|
|
35
|
-
*
|
|
36
|
-
* @param name - The original name attribute value
|
|
37
|
-
* @param isMultiple - Whether this is a multiple-date picker
|
|
38
|
-
* @param isRange - Whether this is a range date picker
|
|
39
|
-
* @returns The normalized name with [] suffix if needed, or null if name is null
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* normalizeNameForMultiple('dates', true, false) // Returns 'dates[]'
|
|
43
|
-
* normalizeNameForMultiple('dates[]', true, false) // Returns 'dates[]' (no change)
|
|
44
|
-
* normalizeNameForMultiple('date', false, false) // Returns 'date' (no change)
|
|
45
|
-
*/
|
|
46
|
-
normalizeNameForMultiple(
|
|
47
|
-
name: string | null,
|
|
48
|
-
isMultiple: boolean,
|
|
49
|
-
isRange: boolean,
|
|
50
|
-
): string | null {
|
|
51
|
-
if (!name) return null
|
|
52
|
-
if ((isMultiple || isRange) && !name.endsWith('[]')) {
|
|
53
|
-
return name + '[]'
|
|
54
|
-
}
|
|
55
|
-
return name
|
|
56
|
-
},
|
|
57
|
-
|
|
58
30
|
/**
|
|
59
31
|
* Validates that a range has valid order (start <= end)
|
|
60
32
|
*
|
|
@@ -142,8 +142,6 @@ export class PktDatepicker extends PktInputElement<Props> {
|
|
|
142
142
|
if (this.timezone && this.timezone !== window.pktTz) {
|
|
143
143
|
window.pktTz = this.timezone
|
|
144
144
|
}
|
|
145
|
-
this.name =
|
|
146
|
-
valueUtils.normalizeNameForMultiple(this.name, this.multiple, this.range) || this.name
|
|
147
145
|
}
|
|
148
146
|
|
|
149
147
|
disconnectedCallback(): void {
|
|
@@ -211,10 +209,6 @@ export class PktDatepicker extends PktInputElement<Props> {
|
|
|
211
209
|
const oldValueStr = Array.isArray(oldValue) ? oldValue.join(',') : oldValue
|
|
212
210
|
this.valueChanged(newValue, oldValueStr)
|
|
213
211
|
}
|
|
214
|
-
if (changedProperties.has('multiple') || changedProperties.has('range')) {
|
|
215
|
-
this.name =
|
|
216
|
-
valueUtils.normalizeNameForMultiple(this.name, this.multiple, this.range) || this.name
|
|
217
|
-
}
|
|
218
212
|
if (changedProperties.has('multiple')) {
|
|
219
213
|
if (this.multiple && !Array.isArray(this._value)) {
|
|
220
214
|
this._value = valueToArray(this.value)
|
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
User,
|
|
9
9
|
Representing,
|
|
10
10
|
UserMenuItem,
|
|
11
|
-
|
|
11
|
+
THeaderMenu,
|
|
12
12
|
TLogOutButtonPlacement,
|
|
13
13
|
THeaderPosition,
|
|
14
14
|
THeaderScrollBehavior,
|
|
15
|
+
TSlotMenuVariant,
|
|
15
16
|
IPktHeader,
|
|
16
17
|
Booleanish,
|
|
17
18
|
booleanishConverter,
|
|
@@ -35,12 +36,15 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
35
36
|
@property({ type: String, attribute: 'search-value' }) searchValue = ''
|
|
36
37
|
@property({ type: Number, attribute: 'mobile-breakpoint' }) mobileBreakpoint: number = 768
|
|
37
38
|
@property({ type: Number, attribute: 'tablet-breakpoint' }) tabletBreakpoint: number = 1280
|
|
38
|
-
@property({ type: String, attribute: 'opened-menu' }) openedMenu:
|
|
39
|
+
@property({ type: String, attribute: 'opened-menu' }) openedMenu: THeaderMenu = 'none'
|
|
39
40
|
@property({ type: String, attribute: 'log-out-button-placement' })
|
|
40
41
|
logOutButtonPlacement: TLogOutButtonPlacement = 'none'
|
|
41
42
|
@property({ type: String }) position: THeaderPosition = 'fixed'
|
|
42
43
|
@property({ type: String, attribute: 'scroll-behavior' }) scrollBehavior: THeaderScrollBehavior =
|
|
43
44
|
'hide'
|
|
45
|
+
@property({ type: String, attribute: 'slot-menu-variant' })
|
|
46
|
+
slotMenuVariant: TSlotMenuVariant = 'icon-only'
|
|
47
|
+
@property({ type: String, attribute: 'slot-menu-text' }) slotMenuText = 'Meny'
|
|
44
48
|
|
|
45
49
|
@property({ type: Boolean, attribute: 'hide-logo', converter: booleanishConverter })
|
|
46
50
|
hideLogo: Booleanish = false
|
|
@@ -62,7 +66,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
62
66
|
|
|
63
67
|
@state() private isMobile = false
|
|
64
68
|
@state() private isTablet = false
|
|
65
|
-
@state() private openMenu:
|
|
69
|
+
@state() private openMenu: THeaderMenu = 'none'
|
|
66
70
|
@state() private isHidden = false
|
|
67
71
|
@state() private componentWidth = typeof window !== 'undefined' ? window.innerWidth : 0
|
|
68
72
|
@state() private hasSlotContent = false
|
|
@@ -123,7 +127,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
if (changedProperties.has('openMenu')) {
|
|
126
|
-
const previousOpenMenu = changedProperties.get('openMenu') as
|
|
130
|
+
const previousOpenMenu = changedProperties.get('openMenu') as THeaderMenu | undefined
|
|
127
131
|
if (
|
|
128
132
|
this.openMenu !== 'none' &&
|
|
129
133
|
(previousOpenMenu === 'none' || previousOpenMenu === undefined)
|
|
@@ -263,7 +267,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
263
267
|
}
|
|
264
268
|
}
|
|
265
269
|
|
|
266
|
-
private handleFocusOut = (event: FocusEvent, menuType:
|
|
270
|
+
private handleFocusOut = (event: FocusEvent, menuType: THeaderMenu) => {
|
|
267
271
|
const relatedTarget = event.relatedTarget as HTMLElement | null
|
|
268
272
|
|
|
269
273
|
let containerRef: Ref<HTMLElement>
|
|
@@ -325,7 +329,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
325
329
|
}
|
|
326
330
|
}
|
|
327
331
|
|
|
328
|
-
private handleMenuToggle(mode:
|
|
332
|
+
private handleMenuToggle(mode: THeaderMenu) {
|
|
329
333
|
if (this.openMenu !== 'none') {
|
|
330
334
|
this.openMenu = 'none'
|
|
331
335
|
} else {
|
|
@@ -520,7 +524,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
520
524
|
? html`
|
|
521
525
|
<pkt-button
|
|
522
526
|
skin="secondary"
|
|
523
|
-
variant
|
|
527
|
+
variant=${this.slotMenuVariant}
|
|
524
528
|
iconName="menu"
|
|
525
529
|
size=${this.isMobile ? 'small' : 'medium'}
|
|
526
530
|
state=${this.openMenu === 'slot' ? 'active' : 'normal'}
|
|
@@ -529,7 +533,7 @@ export class PktHeaderService extends PktElement<IPktHeader> implements IPktHead
|
|
|
529
533
|
aria-controls="mobile-slot-menu"
|
|
530
534
|
aria-label="Åpne meny"
|
|
531
535
|
>
|
|
532
|
-
|
|
536
|
+
${this.slotMenuText}
|
|
533
537
|
</pkt-button>
|
|
534
538
|
`
|
|
535
539
|
: nothing}
|
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
User,
|
|
9
9
|
Representing,
|
|
10
10
|
UserMenuItem,
|
|
11
|
-
|
|
11
|
+
THeaderMenu,
|
|
12
12
|
TLogOutButtonPlacement,
|
|
13
13
|
THeaderPosition,
|
|
14
14
|
THeaderScrollBehavior,
|
|
15
|
+
TSlotMenuVariant,
|
|
15
16
|
IPktHeader,
|
|
16
17
|
Booleanish,
|
|
17
18
|
booleanishConverter,
|
|
@@ -43,12 +44,15 @@ export class PktHeader extends PktElement<IPktHeader> implements IPktHeader {
|
|
|
43
44
|
@property({ type: String, attribute: 'search-value' }) searchValue = ''
|
|
44
45
|
@property({ type: Number, attribute: 'mobile-breakpoint' }) mobileBreakpoint: number = 768
|
|
45
46
|
@property({ type: Number, attribute: 'tablet-breakpoint' }) tabletBreakpoint: number = 1280
|
|
46
|
-
@property({ type: String, attribute: 'opened-menu' }) openedMenu:
|
|
47
|
+
@property({ type: String, attribute: 'opened-menu' }) openedMenu: THeaderMenu = 'none'
|
|
47
48
|
@property({ type: String, attribute: 'log-out-button-placement' })
|
|
48
49
|
logOutButtonPlacement: TLogOutButtonPlacement = 'none'
|
|
49
50
|
@property({ type: String }) position: THeaderPosition = 'fixed'
|
|
50
51
|
@property({ type: String, attribute: 'scroll-behavior' }) scrollBehavior: THeaderScrollBehavior =
|
|
51
52
|
'hide'
|
|
53
|
+
@property({ type: String, attribute: 'slot-menu-variant' })
|
|
54
|
+
slotMenuVariant: TSlotMenuVariant = 'icon-only'
|
|
55
|
+
@property({ type: String, attribute: 'slot-menu-text' }) slotMenuText = 'Meny'
|
|
52
56
|
|
|
53
57
|
@property({ type: Boolean, attribute: 'hide-logo', converter: booleanishConverter })
|
|
54
58
|
hideLogo: Booleanish = false
|
|
@@ -119,6 +123,8 @@ export class PktHeader extends PktElement<IPktHeader> implements IPktHeader {
|
|
|
119
123
|
log-out-button-placement=${this.logOutButtonPlacement}
|
|
120
124
|
position=${this.position}
|
|
121
125
|
scroll-behavior=${this.scrollBehavior}
|
|
126
|
+
slot-menu-variant=${this.slotMenuVariant}
|
|
127
|
+
slot-menu-text=${this.slotMenuText}
|
|
122
128
|
.hideLogo=${this.hideLogo}
|
|
123
129
|
.compact=${this.compact}
|
|
124
130
|
.showSearch=${this.showSearch}
|