@oslokommune/punkt-elements 12.18.4 → 12.18.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{datepicker-BhavwiBZ.js → datepicker-BrAEkscZ.js} +1 -1
- package/dist/{datepicker-vX74tb3R.cjs → datepicker-D5Dsxvio.cjs} +1 -1
- package/dist/index.d.ts +37 -2
- package/dist/{input-element-BQTCZtNQ.js → input-element--t-9j6bw.js} +17 -14
- package/dist/input-element-BxMdqhqV.cjs +1 -0
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-index.cjs +2 -2
- package/dist/pkt-index.js +9 -7
- package/dist/pkt-select.cjs +1 -0
- package/dist/pkt-select.js +6 -0
- 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/select-DM0MVMQz.js +103 -0
- package/dist/select-DduzRK8a.cjs +40 -0
- package/dist/select.d.ts +8 -0
- package/dist/{textarea-BFWHQHLs.cjs → textarea-DfhBTXe_.cjs} +1 -1
- package/dist/{textarea-BYtGXst8.js → textarea-u9h8Iyx5.js} +1 -1
- package/dist/{textinput-33wZwZ4O.cjs → textinput-Bm5IU-UB.cjs} +1 -1
- package/dist/{textinput-IgHewJDJ.js → textinput-Dvln5e5X.js} +1 -1
- package/package.json +2 -2
- package/src/components/index.ts +3 -0
- package/src/components/select/index.ts +5 -0
- package/src/components/select/select.ts +124 -0
- package/dist/input-element-DNklGY_O.cjs +0 -1
|
@@ -3,7 +3,7 @@ import { o as k } from "./if-defined-ZFE4ti2t.js";
|
|
|
3
3
|
import { e as L, i as j, b as F, T as q, x as v, E as T, n as u, t as H } from "./icon-wUXeHiBk.js";
|
|
4
4
|
import { r as V } from "./state-BfyXV7EL.js";
|
|
5
5
|
import { n as D, f as _, a as N, b as E, d as A } from "./calendar-BUqcNvfI.js";
|
|
6
|
-
import { P as U } from "./input-element-
|
|
6
|
+
import { P as U } from "./input-element--t-9j6bw.js";
|
|
7
7
|
import { p as K, v as y, r as w, M as I, m as W, e as R, n as $ } from "./ref-DuFGTLVX.js";
|
|
8
8
|
import "./input-wrapper-BTQk3W8T.js";
|
|
9
9
|
import "./tag-DGFgUF3l.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const $=require("./class-map-Boa7BqCc.cjs"),k=require("./if-defined-DEDlGbAc.cjs"),s=require("./icon-CdMQ6zBT.cjs"),T=require("./state-SKYD8kRO.cjs"),g=require("./calendar-QSulz7im.cjs"),S=require("./input-element-
|
|
1
|
+
"use strict";const $=require("./class-map-Boa7BqCc.cjs"),k=require("./if-defined-DEDlGbAc.cjs"),s=require("./icon-CdMQ6zBT.cjs"),T=require("./state-SKYD8kRO.cjs"),g=require("./calendar-QSulz7im.cjs"),S=require("./input-element-BxMdqhqV.cjs"),r=require("./ref-DCOsLZQg.cjs");require("./input-wrapper-D-PNRJB_.cjs");require("./tag-CGy2mSLE.cjs");/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2017 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ export declare interface IPktProgressbar {
|
|
|
38
38
|
role?: TProgressbarRole;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
declare interface IPktSelect {
|
|
42
|
+
options: TSelectOption[];
|
|
43
|
+
}
|
|
44
|
+
|
|
41
45
|
declare interface IPktTag {
|
|
42
46
|
closeTag?: boolean;
|
|
43
47
|
size?: TPktSize;
|
|
@@ -317,6 +321,7 @@ export declare class PktIcon extends PktElement {
|
|
|
317
321
|
*/
|
|
318
322
|
declare class PktInputElement extends PktElement {
|
|
319
323
|
static get formAssociated(): boolean;
|
|
324
|
+
defaultValue: string | string[] | null;
|
|
320
325
|
disabled: boolean;
|
|
321
326
|
readonly: boolean;
|
|
322
327
|
required: boolean;
|
|
@@ -327,8 +332,8 @@ declare class PktInputElement extends PktElement {
|
|
|
327
332
|
ariaDescribedBy: string | null;
|
|
328
333
|
ariaLabelledby: string | null;
|
|
329
334
|
name: string;
|
|
330
|
-
pattern: string;
|
|
331
|
-
placeholder: string;
|
|
335
|
+
pattern: string | null;
|
|
336
|
+
placeholder: string | null;
|
|
332
337
|
id: string;
|
|
333
338
|
counter: boolean;
|
|
334
339
|
hasError: boolean;
|
|
@@ -470,6 +475,29 @@ export declare class PktProgressbar extends PktElement implements IPktProgressba
|
|
|
470
475
|
render(): TemplateResult<1>;
|
|
471
476
|
}
|
|
472
477
|
|
|
478
|
+
/**
|
|
479
|
+
* Pkt Select is a wrapper for the native select element using the pkt-input-wrapper component.
|
|
480
|
+
*
|
|
481
|
+
* The component will prioritize options passed as a prop over options passed as children if both are provided.
|
|
482
|
+
* This is to allow for dynamic options that might change in the case of both children/slot and props are provided.
|
|
483
|
+
*
|
|
484
|
+
* @slot (default) - Options to be rendered as children
|
|
485
|
+
* @prop {TSelectOption[]} options - Options to be rendered as children
|
|
486
|
+
*
|
|
487
|
+
*
|
|
488
|
+
*/
|
|
489
|
+
export declare class PktSelect extends PktInputElement implements IPktSelect {
|
|
490
|
+
private selectRef;
|
|
491
|
+
defaultSlot: Ref<HTMLElement>;
|
|
492
|
+
options: TSelectOption[];
|
|
493
|
+
value: string;
|
|
494
|
+
private _options;
|
|
495
|
+
constructor();
|
|
496
|
+
connectedCallback(): void;
|
|
497
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
498
|
+
render(): TemplateResult<1>;
|
|
499
|
+
}
|
|
500
|
+
|
|
473
501
|
declare class PktSlotController implements ReactiveController {
|
|
474
502
|
host: LitElement & ReactiveControllerHost;
|
|
475
503
|
nodes: Element[];
|
|
@@ -563,6 +591,13 @@ export declare type TProgressbarStatusType = 'none' | 'percentage' | 'fraction';
|
|
|
563
591
|
|
|
564
592
|
export declare type TProgressbarTitlePosition = 'left' | 'center';
|
|
565
593
|
|
|
594
|
+
export declare type TSelectOption = {
|
|
595
|
+
value: string;
|
|
596
|
+
label: string;
|
|
597
|
+
selected?: boolean;
|
|
598
|
+
disabled?: boolean;
|
|
599
|
+
};
|
|
600
|
+
|
|
566
601
|
export declare type TTagSkin = 'blue' | 'green' | 'red' | 'yellow' | 'beige' | 'blue-light' | 'gray' | 'grey';
|
|
567
602
|
|
|
568
603
|
export declare type TTagType = 'button' | 'reset' | 'submit';
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { n as s, P as
|
|
1
|
+
import { n as s, P as y, s as l } from "./icon-wUXeHiBk.js";
|
|
2
2
|
import { r as m } from "./state-BfyXV7EL.js";
|
|
3
3
|
import { u as g } from "./stringutils-DJjRa8dG.js";
|
|
4
4
|
import { s as c } from "./helptext--4FLdAWi.js";
|
|
5
|
-
var v = Object.defineProperty, e = (p, t, r,
|
|
5
|
+
var v = Object.defineProperty, e = (p, t, r, o) => {
|
|
6
6
|
for (var a = void 0, n = p.length - 1, h; n >= 0; n--)
|
|
7
7
|
(h = p[n]) && (a = h(t, r, a) || a);
|
|
8
8
|
return a && v(t, r, a), a;
|
|
9
9
|
};
|
|
10
|
-
class i extends
|
|
10
|
+
class i extends y {
|
|
11
11
|
constructor() {
|
|
12
|
-
super(), this.disabled = !1, this.readonly = !1, this.required = !1, this.max = null, this.maxlength =
|
|
12
|
+
super(), this.defaultValue = null, this.disabled = !1, this.readonly = !1, this.required = !1, this.max = null, this.maxlength = null, this.min = null, this.minlength = null, this.ariaDescribedBy = null, this.ariaLabelledby = null, this.name = "", this.pattern = null, this.placeholder = null, this.id = g(), this.counter = !1, this.hasError = !1, this.inline = !1, this.optionalTag = !1, this.requiredTag = !1, this.skipForwardTestid = !1, this.useWrapper = !0, this.fullwidth = !1, this.counterMaxLength = 0, this.errorMessage = "", this.helptext = "", this.helptextDropdown = "", this.helptextDropdownButton = c.props.helptextDropdownButton.default, this.label = null, this.optionalText = l.forms.labels.optional, this.requiredText = l.forms.labels.required, this.dataTestid = "", this.touched = !1, this.internals = this.attachInternals();
|
|
13
13
|
}
|
|
14
14
|
static get formAssociated() {
|
|
15
15
|
return !0;
|
|
16
16
|
}
|
|
17
17
|
manageValidity(t) {
|
|
18
|
-
var r,
|
|
19
|
-
t && (this.required && !this.value ? this.internals.setValidity({ valueMissing: !0 },
|
|
18
|
+
var r, o, a, n, h, u, d, f;
|
|
19
|
+
t && (this.required && !this.value ? this.internals.setValidity({ valueMissing: !0 }, l.forms.messages.required, t) : (r = t.validity) != null && r.typeMismatch || (o = t.validity) != null && o.badInput ? this.internals.setValidity({ typeMismatch: !0 }, l.forms.messages.invalid, t) : (a = t.validity) != null && a.patternMismatch ? this.internals.setValidity(
|
|
20
20
|
{ patternMismatch: !0 },
|
|
21
|
-
|
|
21
|
+
l.forms.messages.invalidPattern,
|
|
22
22
|
t
|
|
23
|
-
) : (n = t.validity) != null && n.tooShort || this.minlength && this.minlength > 0 && this.value.length < this.minlength ? this.internals.setValidity({ tooShort: !0 },
|
|
23
|
+
) : (n = t.validity) != null && n.tooShort || this.minlength && this.minlength > 0 && this.value.length < this.minlength ? this.internals.setValidity({ tooShort: !0 }, l.forms.messages.tooShort, t) : (h = t.validity) != null && h.tooLong || this.maxlength && this.maxlength > 0 && this.value.length > this.maxlength ? this.internals.setValidity({ tooLong: !0 }, l.forms.messages.tooLong, t) : (u = t.validity) != null && u.rangeUnderflow ? this.internals.setValidity(
|
|
24
24
|
{ rangeUnderflow: !0 },
|
|
25
|
-
|
|
25
|
+
l.forms.messages.rangeUnderflow,
|
|
26
26
|
t
|
|
27
27
|
) : (d = t.validity) != null && d.rangeOverflow ? this.internals.setValidity(
|
|
28
28
|
{ rangeOverflow: !0 },
|
|
29
|
-
|
|
29
|
+
l.forms.messages.rangeOverflow,
|
|
30
30
|
t
|
|
31
|
-
) : (
|
|
31
|
+
) : (f = t.validity) != null && f.customError ? this.internals.setValidity({ customError: !0 }, t.validationMessage, t) : this.internals.setValidity({}));
|
|
32
32
|
}
|
|
33
33
|
setFormValue(t) {
|
|
34
34
|
if (this.internals)
|
|
35
35
|
if (Array.isArray(t)) {
|
|
36
36
|
const r = new FormData();
|
|
37
|
-
t.forEach((
|
|
38
|
-
r.append(this.name,
|
|
37
|
+
t.forEach((o) => {
|
|
38
|
+
r.append(this.name, o);
|
|
39
39
|
}), this.internals.setFormValue(r);
|
|
40
40
|
} else
|
|
41
41
|
this.internals.setFormValue(t);
|
|
@@ -84,9 +84,12 @@ class i extends f {
|
|
|
84
84
|
super.updated(t), t.has("dataTestid") && this.dataTestid && this.inputRef.value && (this.skipForwardTestid ? this.hasAttribute("data-testid") || this.setAttribute("data-testid", this.dataTestid) : (this.inputRef.value.dataset.testid = this.dataTestid, this.removeAttribute("data-testid")));
|
|
85
85
|
}
|
|
86
86
|
firstUpdated(t) {
|
|
87
|
-
super.firstUpdated(t), this.required && (this.internals.ariaRequired = !0), this.disabled && (this.internals.ariaDisabled = !0), this.
|
|
87
|
+
super.firstUpdated(t), this.value && this.defaultValue !== null && (this.defaultValue = this.value), this.defaultValue !== null && !this.value && this.valueChanged(this.defaultValue, null), this.required && (this.internals.ariaRequired = !0), this.disabled && (this.internals.ariaDisabled = !0), this.id && !this.name && (this.name = this.id), this.setFormValue(this.value), this.inputRef && this.inputRef.value && (this.inputRef.value.setAttribute("form", ""), this.manageValidity(this.inputRef.value)), this.inputRefTo && this.inputRefTo.value && (this.inputRefTo.value.setAttribute("form", ""), this.manageValidity(this.inputRefTo.value));
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
e([
|
|
91
|
+
s()
|
|
92
|
+
], i.prototype, "defaultValue");
|
|
90
93
|
e([
|
|
91
94
|
s({ type: Boolean, reflect: !0 })
|
|
92
95
|
], i.prototype, "disabled");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("./icon-CdMQ6zBT.cjs"),f=require("./state-SKYD8kRO.cjs"),y=require("./stringutils-CkVRq4jP.cjs"),g=require("./helptext-iZEgxz2U.cjs");var m=Object.defineProperty,s=(h,t,r,l)=>{for(var a=void 0,n=h.length-1,o;n>=0;n--)(o=h[n])&&(a=o(t,r,a)||a);return a&&m(t,r,a),a};class i extends e.PktElement{constructor(){super(),this.defaultValue=null,this.disabled=!1,this.readonly=!1,this.required=!1,this.max=null,this.maxlength=null,this.min=null,this.minlength=null,this.ariaDescribedBy=null,this.ariaLabelledby=null,this.name="",this.pattern=null,this.placeholder=null,this.id=y.uuidish(),this.counter=!1,this.hasError=!1,this.inline=!1,this.optionalTag=!1,this.requiredTag=!1,this.skipForwardTestid=!1,this.useWrapper=!0,this.fullwidth=!1,this.counterMaxLength=0,this.errorMessage="",this.helptext="",this.helptextDropdown="",this.helptextDropdownButton=g.specs.props.helptextDropdownButton.default,this.label=null,this.optionalText=e.strings.forms.labels.optional,this.requiredText=e.strings.forms.labels.required,this.dataTestid="",this.touched=!1,this.internals=this.attachInternals()}static get formAssociated(){return!0}manageValidity(t){var r,l,a,n,o,p,u,d;t&&(this.required&&!this.value?this.internals.setValidity({valueMissing:!0},e.strings.forms.messages.required,t):(r=t.validity)!=null&&r.typeMismatch||(l=t.validity)!=null&&l.badInput?this.internals.setValidity({typeMismatch:!0},e.strings.forms.messages.invalid,t):(a=t.validity)!=null&&a.patternMismatch?this.internals.setValidity({patternMismatch:!0},e.strings.forms.messages.invalidPattern,t):(n=t.validity)!=null&&n.tooShort||this.minlength&&this.minlength>0&&this.value.length<this.minlength?this.internals.setValidity({tooShort:!0},e.strings.forms.messages.tooShort,t):(o=t.validity)!=null&&o.tooLong||this.maxlength&&this.maxlength>0&&this.value.length>this.maxlength?this.internals.setValidity({tooLong:!0},e.strings.forms.messages.tooLong,t):(p=t.validity)!=null&&p.rangeUnderflow?this.internals.setValidity({rangeUnderflow:!0},e.strings.forms.messages.rangeUnderflow,t):(u=t.validity)!=null&&u.rangeOverflow?this.internals.setValidity({rangeOverflow:!0},e.strings.forms.messages.rangeOverflow,t):(d=t.validity)!=null&&d.customError?this.internals.setValidity({customError:!0},t.validationMessage,t):this.internals.setValidity({}))}setFormValue(t){if(this.internals)if(Array.isArray(t)){const r=new FormData;t.forEach(l=>{r.append(this.name,l)}),this.internals.setFormValue(r)}else this.internals.setFormValue(t)}valueChanged(t,r){(r!==this.value||r!==this._value)&&(typeof t=="string"?((this.multiple||this.range)&&t.includes(",")&&(t=t.split(",")),this.value=t,this._value=Array.isArray(t)?t:[t]):Array.isArray(t)?(this.value=t,this._value=t):(this.value="",this._value=[]),(!this.value||this.value.length===0)&&r&&r.length!==0?this.clearInputValue():this.value&&this.value.toString()!==(r==null?void 0:r.toString())&&this.onChange(this.value),this.updateComplete.then(()=>this.requestUpdate()))}clearInputValue(){const t=this.multiple||this.range?[]:"";this.value=t,this.internals.setFormValue(t),this.dispatchEvent(new Event("change")),this.dispatchEvent(new CustomEvent("value-change",{detail:t,bubbles:!0,composed:!0}))}onFocus(){this.dispatchEvent(new FocusEvent("focus"))}onBlur(){this.dispatchEvent(new FocusEvent("blur"))}onInput(){this.dispatchEvent(new InputEvent("input"))}onChange(t){if(!this.touched){this.touched=!0,t&&this.setFormValue(t);return}typeof t!="string"&&!Array.isArray(t)||((this.range||this.multiple)&&!Array.isArray(t)&&t.includes(",")&&(t=t.split(",")),!this.multiple&&!this.range&&Array.isArray(t)&&(t=t[0]),this.setFormValue(t),this.manageValidity(this.inputRef.value),this.inputRefTo&&this.manageValidity(this.inputRefTo.value),this.dispatchEvent(new Event("change")),this.dispatchEvent(new CustomEvent("value-change",{detail:t,bubbles:!0,composed:!0})),this.internals.reportValidity())}updated(t){super.updated(t),t.has("dataTestid")&&this.dataTestid&&this.inputRef.value&&(this.skipForwardTestid?this.hasAttribute("data-testid")||this.setAttribute("data-testid",this.dataTestid):(this.inputRef.value.dataset.testid=this.dataTestid,this.removeAttribute("data-testid")))}firstUpdated(t){super.firstUpdated(t),this.value&&this.defaultValue!==null&&(this.defaultValue=this.value),this.defaultValue!==null&&!this.value&&this.valueChanged(this.defaultValue,null),this.required&&(this.internals.ariaRequired=!0),this.disabled&&(this.internals.ariaDisabled=!0),this.id&&!this.name&&(this.name=this.id),this.setFormValue(this.value),this.inputRef&&this.inputRef.value&&(this.inputRef.value.setAttribute("form",""),this.manageValidity(this.inputRef.value)),this.inputRefTo&&this.inputRefTo.value&&(this.inputRefTo.value.setAttribute("form",""),this.manageValidity(this.inputRefTo.value))}}s([e.n()],i.prototype,"defaultValue");s([e.n({type:Boolean,reflect:!0})],i.prototype,"disabled");s([e.n({type:Boolean,reflect:!0})],i.prototype,"readonly");s([e.n({type:Boolean,reflect:!0})],i.prototype,"required");s([e.n({type:Number,reflect:!0})],i.prototype,"max");s([e.n({type:Number,reflect:!0})],i.prototype,"maxlength");s([e.n({type:Number,reflect:!0})],i.prototype,"min");s([e.n({type:Number,reflect:!0})],i.prototype,"minlength");s([e.n({type:String})],i.prototype,"ariaDescribedBy");s([e.n({type:String})],i.prototype,"ariaLabelledby");s([e.n({type:String,reflect:!0})],i.prototype,"name");s([e.n({type:String,reflect:!0})],i.prototype,"pattern");s([e.n({type:String,reflect:!0})],i.prototype,"placeholder");s([e.n({type:String,reflect:!0})],i.prototype,"id");s([e.n({type:Boolean})],i.prototype,"counter");s([e.n({type:Boolean})],i.prototype,"hasError");s([e.n({type:Boolean})],i.prototype,"inline");s([e.n({type:Boolean})],i.prototype,"optionalTag");s([e.n({type:Boolean})],i.prototype,"requiredTag");s([e.n({type:Boolean})],i.prototype,"skipForwardTestid");s([e.n({type:Boolean})],i.prototype,"useWrapper");s([e.n({type:Boolean,reflect:!0})],i.prototype,"fullwidth");s([e.n({type:Number})],i.prototype,"counterMaxLength");s([e.n({type:String})],i.prototype,"errorMessage");s([e.n({type:String})],i.prototype,"helptext");s([e.n({type:String})],i.prototype,"helptextDropdown");s([e.n({type:String})],i.prototype,"helptextDropdownButton");s([e.n({type:String})],i.prototype,"label");s([e.n({type:String})],i.prototype,"optionalText");s([e.n({type:String})],i.prototype,"requiredText");s([e.n({type:String,attribute:"data-testid"})],i.prototype,"dataTestid");s([f.r()],i.prototype,"touched");exports.PktInputElement=i;
|
package/dist/pkt-datepicker.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./datepicker-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./datepicker-D5Dsxvio.cjs"),t=e.PktDatepicker;Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>e.PktDatepicker});exports.default=t;
|
package/dist/pkt-datepicker.js
CHANGED
package/dist/pkt-index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./alert-BbVWu2lm.cjs"),u=require("./calendar-QSulz7im.cjs"),d=require("./card-B0GPdG5M.cjs"),t=require("./icon-CdMQ6zBT.cjs"),k=require("./pkt-slot-controller-Ckk_yV0j.cjs"),i=require("./ref-DCOsLZQg.cjs"),P=require("./class-map-Boa7BqCc.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./alert-BbVWu2lm.cjs"),u=require("./calendar-QSulz7im.cjs"),d=require("./card-B0GPdG5M.cjs"),t=require("./icon-CdMQ6zBT.cjs"),k=require("./pkt-slot-controller-Ckk_yV0j.cjs"),i=require("./ref-DCOsLZQg.cjs"),P=require("./class-map-Boa7BqCc.cjs"),b=require("./datepicker-D5Dsxvio.cjs"),g=require("./helptext-iZEgxz2U.cjs"),h=require("./input-wrapper-D-PNRJB_.cjs"),m=require("./link-BpqavGSD.cjs"),f=require("./linkcard-DSu3A4Yx.cjs"),y=require("./messagebox-C1aWoQbu.cjs"),v=require("./modal-Avai5eVz.cjs"),x=require("./progressbar-CuXkbAhJ.cjs"),C=require("./tag-CGy2mSLE.cjs"),O=require("./textarea-DfhBTXe_.cjs"),j=require("./textinput-Bm5IU-UB.cjs"),q=require("./select-DduzRK8a.cjs");var S=Object.defineProperty,$=Object.getOwnPropertyDescriptor,o=(a,e,r,s)=>{for(var n=s>1?void 0:s?$(e,r):e,l=a.length-1,p;l>=0;l--)(p=a[l])&&(n=(s?p(e,r,n):p(n))||n);return s&&n&&S(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=i.e(),this.namedSlot=i.e(),this.slotController=new k.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
|
|
2
2
|
<div class="${P.e(e)}">
|
|
3
3
|
<h1 class="pkt-txt-28">${this.string}</h1>
|
|
4
4
|
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
<ul>
|
|
27
27
|
${e.map(r=>t.x`<li>${r}</li>`)}
|
|
28
28
|
</ul>
|
|
29
|
-
`}doStuff(e){return e.reverse()}handleGreeting(){this.dispatchEvent(new CustomEvent("pkt-greeting",{detail:"Hei på deg!"}))}};o([t.n({type:String})],exports.PktComponent.prototype,"string",2);o([t.n({converter:u.csvToArray})],exports.PktComponent.prototype,"strings",2);o([t.n({type:Boolean})],exports.PktComponent.prototype,"darkmode",2);o([t.n({type:Array})],exports.PktComponent.prototype,"_list",2);exports.PktComponent=o([t.t("pkt-component")],exports.PktComponent);Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>c.PktAlert});Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>u.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>d.PktCard});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>t.PktIcon});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>
|
|
29
|
+
`}doStuff(e){return e.reverse()}handleGreeting(){this.dispatchEvent(new CustomEvent("pkt-greeting",{detail:"Hei på deg!"}))}};o([t.n({type:String})],exports.PktComponent.prototype,"string",2);o([t.n({converter:u.csvToArray})],exports.PktComponent.prototype,"strings",2);o([t.n({type:Boolean})],exports.PktComponent.prototype,"darkmode",2);o([t.n({type:Array})],exports.PktComponent.prototype,"_list",2);exports.PktComponent=o([t.t("pkt-component")],exports.PktComponent);Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>c.PktAlert});Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>u.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>d.PktCard});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>t.PktIcon});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>b.PktDatepicker});Object.defineProperty(exports,"PktHelptext",{enumerable:!0,get:()=>g.PktHelptext});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>h.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>m.PktLink});Object.defineProperty(exports,"PktLinkCard",{enumerable:!0,get:()=>f.PktLinkCard});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>y.PktMessagebox});Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>v.PktModal});Object.defineProperty(exports,"PktProgressbar",{enumerable:!0,get:()=>x.PktProgressbar});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>C.PktTag});Object.defineProperty(exports,"PktTextarea",{enumerable:!0,get:()=>O.PktTextarea});Object.defineProperty(exports,"PktTextinput",{enumerable:!0,get:()=>j.PktTextinput});Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>q.PktSelect});
|
package/dist/pkt-index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { P as w } from "./alert-Dh6A96vo.js";
|
|
2
|
-
import { c as
|
|
2
|
+
import { c as P } from "./calendar-BUqcNvfI.js";
|
|
3
3
|
import { P as O } from "./calendar-BUqcNvfI.js";
|
|
4
4
|
import { P as j } from "./card-kWt0BA2a.js";
|
|
5
|
-
import { P, x as h, s as c, n, t as k } from "./icon-wUXeHiBk.js";
|
|
5
|
+
import { P as f, x as h, s as c, n, t as k } from "./icon-wUXeHiBk.js";
|
|
6
6
|
import { a as D } from "./icon-wUXeHiBk.js";
|
|
7
7
|
import { P as x } from "./pkt-slot-controller-RJvOnbF4.js";
|
|
8
8
|
import { e as m, n as d } from "./ref-DuFGTLVX.js";
|
|
9
9
|
import { e as u } from "./class-map-hz16xq5a.js";
|
|
10
|
-
import { P as G } from "./datepicker-
|
|
10
|
+
import { P as G } from "./datepicker-BrAEkscZ.js";
|
|
11
11
|
import { P as M } from "./helptext--4FLdAWi.js";
|
|
12
12
|
import { P as B } from "./input-wrapper-BTQk3W8T.js";
|
|
13
13
|
import { P as N } from "./link-Bx9nVgZi.js";
|
|
@@ -16,14 +16,15 @@ import { P as z } from "./messagebox-LpiVQIoM.js";
|
|
|
16
16
|
import { P as J } from "./modal-Co1YFmHi.js";
|
|
17
17
|
import { P as V } from "./progressbar-BS_oawSB.js";
|
|
18
18
|
import { P as Y } from "./tag-DGFgUF3l.js";
|
|
19
|
-
import { P as tt } from "./textarea-
|
|
20
|
-
import { P as rt } from "./textinput-
|
|
19
|
+
import { P as tt } from "./textarea-u9h8Iyx5.js";
|
|
20
|
+
import { P as rt } from "./textinput-Dvln5e5X.js";
|
|
21
|
+
import { P as ot } from "./select-DM0MVMQz.js";
|
|
21
22
|
var g = Object.defineProperty, v = Object.getOwnPropertyDescriptor, o = (t, e, i, a) => {
|
|
22
23
|
for (var r = a > 1 ? void 0 : a ? v(e, i) : e, p = t.length - 1, l; p >= 0; p--)
|
|
23
24
|
(l = t[p]) && (r = (a ? l(e, i, r) : l(r)) || r);
|
|
24
25
|
return a && r && g(e, i, r), r;
|
|
25
26
|
};
|
|
26
|
-
let s = class extends
|
|
27
|
+
let s = class extends f {
|
|
27
28
|
constructor() {
|
|
28
29
|
super(), this.string = "", this.strings = [], this.darkmode = !1, this._list = [], this.defaultSlot = m(), this.namedSlot = m(), this.slotController = new x(this, this.defaultSlot, this.namedSlot);
|
|
29
30
|
}
|
|
@@ -98,7 +99,7 @@ o([
|
|
|
98
99
|
n({ type: String })
|
|
99
100
|
], s.prototype, "string", 2);
|
|
100
101
|
o([
|
|
101
|
-
n({ converter:
|
|
102
|
+
n({ converter: P })
|
|
102
103
|
], s.prototype, "strings", 2);
|
|
103
104
|
o([
|
|
104
105
|
n({ type: Boolean })
|
|
@@ -123,6 +124,7 @@ export {
|
|
|
123
124
|
z as PktMessagebox,
|
|
124
125
|
J as PktModal,
|
|
125
126
|
V as PktProgressbar,
|
|
127
|
+
ot as PktSelect,
|
|
126
128
|
Y as PktTag,
|
|
127
129
|
tt as PktTextarea,
|
|
128
130
|
rt as PktTextinput
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./select-DduzRK8a.cjs"),t=e.PktSelect;Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>e.PktSelect});exports.default=t;
|
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-DfhBTXe_.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-Bm5IU-UB.cjs"),t=e.PktTextinput;Object.defineProperty(exports,"PktTextinput",{enumerable:!0,get:()=>e.PktTextinput});exports.default=t;
|
package/dist/pkt-textinput.js
CHANGED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { x as a, n as c, t as $ } from "./icon-wUXeHiBk.js";
|
|
2
|
+
import { r as f } from "./state-BfyXV7EL.js";
|
|
3
|
+
import { e as u, n as d } from "./ref-DuFGTLVX.js";
|
|
4
|
+
import { o as i } from "./if-defined-ZFE4ti2t.js";
|
|
5
|
+
import { P as b } from "./input-element--t-9j6bw.js";
|
|
6
|
+
import "./input-wrapper-BTQk3W8T.js";
|
|
7
|
+
class m {
|
|
8
|
+
constructor(t) {
|
|
9
|
+
this.nodes = [], this.host = t, this.host.addController(this), this.nodes = [];
|
|
10
|
+
}
|
|
11
|
+
hostConnected() {
|
|
12
|
+
for (Array.from(this.host.childNodes).forEach((t) => {
|
|
13
|
+
(t.nodeName === "OPTION" || t.nodeName === "DATA") && this.nodes.push(t);
|
|
14
|
+
}); this.host.firstChild; )
|
|
15
|
+
this.host.removeChild(this.host.firstChild);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
var v = Object.defineProperty, C = Object.getOwnPropertyDescriptor, n = (s, t, e, r) => {
|
|
19
|
+
for (var o = r > 1 ? void 0 : r ? C(t, e) : t, h = s.length - 1, p; h >= 0; h--)
|
|
20
|
+
(p = s[h]) && (o = (r ? p(t, e, o) : p(o)) || o);
|
|
21
|
+
return r && o && v(t, e, o), o;
|
|
22
|
+
};
|
|
23
|
+
let l = class extends b {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(), this.selectRef = u(), this.defaultSlot = u(), this.options = [], this.value = "", this._options = [], this.optionsController = new m(this);
|
|
26
|
+
}
|
|
27
|
+
// Used for initilization
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
super.connectedCallback();
|
|
30
|
+
const s = this.options.length > 0, t = this.optionsController.nodes.length && this.optionsController.nodes.length > 0;
|
|
31
|
+
!s && t ? this.optionsController.nodes.forEach((e) => {
|
|
32
|
+
if (!e.textContent && !e.getAttribute("value")) return null;
|
|
33
|
+
const r = {
|
|
34
|
+
value: e.getAttribute("value") || e.textContent || "",
|
|
35
|
+
label: e.textContent || e.getAttribute("value") || ""
|
|
36
|
+
};
|
|
37
|
+
this._options.push(r);
|
|
38
|
+
}) : this._options = this.options;
|
|
39
|
+
}
|
|
40
|
+
firstUpdated(s) {
|
|
41
|
+
super.firstUpdated(s), this.options.length && (this._options = this.options);
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
const s = `pkt-input ${this.fullwidth ? "pkt-input--fullwidth" : ""}`;
|
|
45
|
+
return a`
|
|
46
|
+
<pkt-input-wrapper
|
|
47
|
+
?counter=${this.counter}
|
|
48
|
+
?disabled=${this.disabled}
|
|
49
|
+
?hasError=${this.hasError}
|
|
50
|
+
?inline=${this.inline}
|
|
51
|
+
?optionalTag=${this.optionalTag}
|
|
52
|
+
?requiredTag=${this.requiredTag}
|
|
53
|
+
?useWrapper=${this.useWrapper}
|
|
54
|
+
ariaDescribedBy=${i(this.ariaDescribedBy)}
|
|
55
|
+
.counterCurrent=${this.counterCurrent}
|
|
56
|
+
.counterMaxLength=${this.counterMaxLength}
|
|
57
|
+
class="pkt-select"
|
|
58
|
+
errorMessage=${i(this.errorMessage)}
|
|
59
|
+
forId=${this.id}
|
|
60
|
+
helptext=${i(this.helptext)}
|
|
61
|
+
helptextDropdown=${i(this.helptextDropdown)}
|
|
62
|
+
helptextDropdownButton=${i(this.helptextDropdownButton)}
|
|
63
|
+
label=${i(this.label)}
|
|
64
|
+
optionalText=${i(this.optionalText)}
|
|
65
|
+
requiredText=${i(this.requiredText)}
|
|
66
|
+
>
|
|
67
|
+
<select
|
|
68
|
+
class=${s}
|
|
69
|
+
aria-invalid=${this.hasError}
|
|
70
|
+
aria-errormessage=${`${this.id}-error`}
|
|
71
|
+
aria-labelledby=${i(this.ariaLabelledby)}
|
|
72
|
+
?disabled=${this.disabled}
|
|
73
|
+
id=${this.id}
|
|
74
|
+
name=${this.name || this.id}
|
|
75
|
+
value=${this.value}
|
|
76
|
+
${d(this.selectRef)}
|
|
77
|
+
${d(this.defaultSlot)}
|
|
78
|
+
>
|
|
79
|
+
${this._options.length > 0 && this._options.map(
|
|
80
|
+
(t) => a`<option value=${t.value} ?selected=${this.value == t.value}>
|
|
81
|
+
${t.label}
|
|
82
|
+
</option>`
|
|
83
|
+
)}
|
|
84
|
+
</select>
|
|
85
|
+
</pkt-input-wrapper>
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
n([
|
|
90
|
+
c({ type: Array })
|
|
91
|
+
], l.prototype, "options", 2);
|
|
92
|
+
n([
|
|
93
|
+
c({ type: String })
|
|
94
|
+
], l.prototype, "value", 2);
|
|
95
|
+
n([
|
|
96
|
+
f()
|
|
97
|
+
], l.prototype, "_options", 2);
|
|
98
|
+
l = n([
|
|
99
|
+
$("pkt-select")
|
|
100
|
+
], l);
|
|
101
|
+
export {
|
|
102
|
+
l as P
|
|
103
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";const r=require("./icon-CdMQ6zBT.cjs"),u=require("./state-SKYD8kRO.cjs"),l=require("./ref-DCOsLZQg.cjs"),o=require("./if-defined-DEDlGbAc.cjs"),c=require("./input-element-BxMdqhqV.cjs");require("./input-wrapper-D-PNRJB_.cjs");class d{constructor(t){this.nodes=[],this.host=t,this.host.addController(this),this.nodes=[]}hostConnected(){for(Array.from(this.host.childNodes).forEach(t=>{(t.nodeName==="OPTION"||t.nodeName==="DATA")&&this.nodes.push(t)});this.host.firstChild;)this.host.removeChild(this.host.firstChild)}}var $=Object.defineProperty,f=Object.getOwnPropertyDescriptor,h=(n,t,s,e)=>{for(var i=e>1?void 0:e?f(t,s):t,a=n.length-1,p;a>=0;a--)(p=n[a])&&(i=(e?p(t,s,i):p(i))||i);return e&&i&&$(t,s,i),i};exports.PktSelect=class extends c.PktInputElement{constructor(){super(),this.selectRef=l.e(),this.defaultSlot=l.e(),this.options=[],this.value="",this._options=[],this.optionsController=new d(this)}connectedCallback(){super.connectedCallback();const t=this.options.length>0,s=this.optionsController.nodes.length&&this.optionsController.nodes.length>0;!t&&s?this.optionsController.nodes.forEach(e=>{if(!e.textContent&&!e.getAttribute("value"))return null;const i={value:e.getAttribute("value")||e.textContent||"",label:e.textContent||e.getAttribute("value")||""};this._options.push(i)}):this._options=this.options}firstUpdated(t){super.firstUpdated(t),this.options.length&&(this._options=this.options)}render(){const t=`pkt-input ${this.fullwidth?"pkt-input--fullwidth":""}`;return r.x`
|
|
2
|
+
<pkt-input-wrapper
|
|
3
|
+
?counter=${this.counter}
|
|
4
|
+
?disabled=${this.disabled}
|
|
5
|
+
?hasError=${this.hasError}
|
|
6
|
+
?inline=${this.inline}
|
|
7
|
+
?optionalTag=${this.optionalTag}
|
|
8
|
+
?requiredTag=${this.requiredTag}
|
|
9
|
+
?useWrapper=${this.useWrapper}
|
|
10
|
+
ariaDescribedBy=${o.o(this.ariaDescribedBy)}
|
|
11
|
+
.counterCurrent=${this.counterCurrent}
|
|
12
|
+
.counterMaxLength=${this.counterMaxLength}
|
|
13
|
+
class="pkt-select"
|
|
14
|
+
errorMessage=${o.o(this.errorMessage)}
|
|
15
|
+
forId=${this.id}
|
|
16
|
+
helptext=${o.o(this.helptext)}
|
|
17
|
+
helptextDropdown=${o.o(this.helptextDropdown)}
|
|
18
|
+
helptextDropdownButton=${o.o(this.helptextDropdownButton)}
|
|
19
|
+
label=${o.o(this.label)}
|
|
20
|
+
optionalText=${o.o(this.optionalText)}
|
|
21
|
+
requiredText=${o.o(this.requiredText)}
|
|
22
|
+
>
|
|
23
|
+
<select
|
|
24
|
+
class=${t}
|
|
25
|
+
aria-invalid=${this.hasError}
|
|
26
|
+
aria-errormessage=${`${this.id}-error`}
|
|
27
|
+
aria-labelledby=${o.o(this.ariaLabelledby)}
|
|
28
|
+
?disabled=${this.disabled}
|
|
29
|
+
id=${this.id}
|
|
30
|
+
name=${this.name||this.id}
|
|
31
|
+
value=${this.value}
|
|
32
|
+
${l.n(this.selectRef)}
|
|
33
|
+
${l.n(this.defaultSlot)}
|
|
34
|
+
>
|
|
35
|
+
${this._options.length>0&&this._options.map(s=>r.x`<option value=${s.value} ?selected=${this.value==s.value}>
|
|
36
|
+
${s.label}
|
|
37
|
+
</option>`)}
|
|
38
|
+
</select>
|
|
39
|
+
</pkt-input-wrapper>
|
|
40
|
+
`}};h([r.n({type:Array})],exports.PktSelect.prototype,"options",2);h([r.n({type:String})],exports.PktSelect.prototype,"value",2);h([u.r()],exports.PktSelect.prototype,"_options",2);exports.PktSelect=h([r.t("pkt-select")],exports.PktSelect);
|
package/dist/select.d.ts
ADDED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const r=require("./icon-CdMQ6zBT.cjs"),h=require("./state-SKYD8kRO.cjs"),o=require("./ref-DCOsLZQg.cjs"),p=require("./class-map-Boa7BqCc.cjs"),d=require("./input-element-
|
|
1
|
+
"use strict";const r=require("./icon-CdMQ6zBT.cjs"),h=require("./state-SKYD8kRO.cjs"),o=require("./ref-DCOsLZQg.cjs"),p=require("./class-map-Boa7BqCc.cjs"),d=require("./input-element-BxMdqhqV.cjs");require("./input-wrapper-D-PNRJB_.cjs");/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2020 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -2,7 +2,7 @@ import { e as c, i as $, b as n, T as l, E as h, x as m, n as p, t as g } from "
|
|
|
2
2
|
import { r as f } from "./state-BfyXV7EL.js";
|
|
3
3
|
import { f as b, m as v, e as x, n as T } from "./ref-DuFGTLVX.js";
|
|
4
4
|
import { e as y } from "./class-map-hz16xq5a.js";
|
|
5
|
-
import { P as w } from "./input-element-
|
|
5
|
+
import { P as w } from "./input-element--t-9j6bw.js";
|
|
6
6
|
import "./input-wrapper-BTQk3W8T.js";
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const t=require("./icon-CdMQ6zBT.cjs"),h=require("./state-SKYD8kRO.cjs"),o=require("./ref-DCOsLZQg.cjs"),l=require("./class-map-Boa7BqCc.cjs"),c=require("./input-element-
|
|
1
|
+
"use strict";const t=require("./icon-CdMQ6zBT.cjs"),h=require("./state-SKYD8kRO.cjs"),o=require("./ref-DCOsLZQg.cjs"),l=require("./class-map-Boa7BqCc.cjs"),c=require("./input-element-BxMdqhqV.cjs");require("./input-wrapper-D-PNRJB_.cjs");var d=Object.defineProperty,x=Object.getOwnPropertyDescriptor,r=(p,i,n,s)=>{for(var e=s>1?void 0:s?x(i,n):i,a=p.length-1,u;a>=0;a--)(u=p[a])&&(e=(s?u(i,n,e):u(e))||e);return s&&e&&d(i,n,e),e};exports.PktTextinput=class extends c.PktInputElement{constructor(){super(...arguments),this.value="",this.type="text",this.size=null,this.autocomplete="off",this.iconNameRight=null,this.prefix=null,this.suffix=null,this.omitSearchIcon=!1,this.counterCurrent=0,this.inputRef=o.e()}attributeChangedCallback(i,n,s){i==="value"&&this.value!==n&&(this.counterCurrent=s?s.length:0,this.valueChanged(s,n)),super.attributeChangedCallback(i,n,s)}updated(i){var n;super.updated(i),i.has("value")&&(this.counterCurrent=((n=this.value)==null?void 0:n.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,n=l.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}),s=this.ariaLabelledby||`${this.id}-input-label`;return t.x`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
label="${this.label}"
|
|
4
4
|
?counter=${this.counter}
|
|
@@ -2,7 +2,7 @@ import { x as h, E as n, n as o, t as c } from "./icon-wUXeHiBk.js";
|
|
|
2
2
|
import { r as d } from "./state-BfyXV7EL.js";
|
|
3
3
|
import { e as $, n as g } from "./ref-DuFGTLVX.js";
|
|
4
4
|
import { e as m } from "./class-map-hz16xq5a.js";
|
|
5
|
-
import { P as f } from "./input-element-
|
|
5
|
+
import { P as f } from "./input-element--t-9j6bw.js";
|
|
6
6
|
import "./input-wrapper-BTQk3W8T.js";
|
|
7
7
|
var x = Object.defineProperty, y = Object.getOwnPropertyDescriptor, a = (i, e, r, t) => {
|
|
8
8
|
for (var p = t > 1 ? void 0 : t ? y(e, r) : e, u = i.length - 1, l; u >= 0; u--)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "12.18.
|
|
3
|
+
"version": "12.18.6",
|
|
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",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
58
58
|
},
|
|
59
59
|
"license": "MIT",
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "ac72fa517f291b04958eb8a0d69de61036ed00d8"
|
|
61
61
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { PktProgressbar } from '@/components/progressbar'
|
|
|
15
15
|
export { PktTag } from '@/components/tag'
|
|
16
16
|
export { PktTextarea } from '@/components/textarea'
|
|
17
17
|
export { PktTextinput } from '@/components/textinput'
|
|
18
|
+
export { PktSelect } from '@/components/select'
|
|
18
19
|
|
|
19
20
|
// Export types
|
|
20
21
|
export type {
|
|
@@ -27,3 +28,5 @@ export type {
|
|
|
27
28
|
} from '@/components/progressbar'
|
|
28
29
|
|
|
29
30
|
export type { TTagSkin, TTagType } from '@/components/tag'
|
|
31
|
+
|
|
32
|
+
export type { TSelectOption } from '@/components/select'
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { html, PropertyValues } from 'lit'
|
|
2
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
|
3
|
+
import { Ref, createRef, ref } from 'lit/directives/ref.js'
|
|
4
|
+
import { ifDefined } from 'lit/directives/if-defined.js'
|
|
5
|
+
import { PktInputElement } from '@/base-elements/input-element'
|
|
6
|
+
import { PktOptionsSlotController } from '@/controllers/pkt-options-controller'
|
|
7
|
+
import '@/components/input-wrapper'
|
|
8
|
+
|
|
9
|
+
export type TSelectOption = {
|
|
10
|
+
value: string
|
|
11
|
+
label: string
|
|
12
|
+
selected?: boolean
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface IPktSelect {
|
|
17
|
+
options: TSelectOption[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Pkt Select is a wrapper for the native select element using the pkt-input-wrapper component.
|
|
22
|
+
*
|
|
23
|
+
* The component will prioritize options passed as a prop over options passed as children if both are provided.
|
|
24
|
+
* This is to allow for dynamic options that might change in the case of both children/slot and props are provided.
|
|
25
|
+
*
|
|
26
|
+
* @slot (default) - Options to be rendered as children
|
|
27
|
+
* @prop {TSelectOption[]} options - Options to be rendered as children
|
|
28
|
+
*
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
@customElement('pkt-select')
|
|
33
|
+
export class PktSelect extends PktInputElement implements IPktSelect {
|
|
34
|
+
private selectRef: Ref<HTMLSelectElement> = createRef()
|
|
35
|
+
defaultSlot: Ref<HTMLElement> = createRef()
|
|
36
|
+
|
|
37
|
+
@property({ type: Array }) options: TSelectOption[] = []
|
|
38
|
+
@property({ type: String }) value: string = ''
|
|
39
|
+
|
|
40
|
+
@state() private _options: TSelectOption[] = []
|
|
41
|
+
|
|
42
|
+
constructor() {
|
|
43
|
+
super()
|
|
44
|
+
this.optionsController = new PktOptionsSlotController(this)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Used for initilization
|
|
48
|
+
connectedCallback(): void {
|
|
49
|
+
super.connectedCallback()
|
|
50
|
+
|
|
51
|
+
const optionsReceivedFromProps = this.options.length > 0
|
|
52
|
+
const checkIfOptionNodesInSlot =
|
|
53
|
+
this.optionsController.nodes.length && this.optionsController.nodes.length > 0
|
|
54
|
+
|
|
55
|
+
if (!optionsReceivedFromProps && checkIfOptionNodesInSlot) {
|
|
56
|
+
this.optionsController.nodes.forEach((node: Element) => {
|
|
57
|
+
if (!node.textContent && !node.getAttribute('value')) return null
|
|
58
|
+
const option: TSelectOption = {
|
|
59
|
+
value: node.getAttribute('value') || node.textContent || '',
|
|
60
|
+
label: node.textContent || node.getAttribute('value') || '',
|
|
61
|
+
}
|
|
62
|
+
this._options.push(option)
|
|
63
|
+
})
|
|
64
|
+
} else {
|
|
65
|
+
this._options = this.options
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
protected firstUpdated(_changedProperties: PropertyValues): void {
|
|
70
|
+
super.firstUpdated(_changedProperties)
|
|
71
|
+
if (this.options.length) {
|
|
72
|
+
this._options = this.options
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
render() {
|
|
77
|
+
const inputClass = `pkt-input ${this.fullwidth ? 'pkt-input--fullwidth' : ''}`
|
|
78
|
+
|
|
79
|
+
return html`
|
|
80
|
+
<pkt-input-wrapper
|
|
81
|
+
?counter=${this.counter}
|
|
82
|
+
?disabled=${this.disabled}
|
|
83
|
+
?hasError=${this.hasError}
|
|
84
|
+
?inline=${this.inline}
|
|
85
|
+
?optionalTag=${this.optionalTag}
|
|
86
|
+
?requiredTag=${this.requiredTag}
|
|
87
|
+
?useWrapper=${this.useWrapper}
|
|
88
|
+
ariaDescribedBy=${ifDefined(this.ariaDescribedBy)}
|
|
89
|
+
.counterCurrent=${this.counterCurrent}
|
|
90
|
+
.counterMaxLength=${this.counterMaxLength}
|
|
91
|
+
class="pkt-select"
|
|
92
|
+
errorMessage=${ifDefined(this.errorMessage)}
|
|
93
|
+
forId=${this.id}
|
|
94
|
+
helptext=${ifDefined(this.helptext)}
|
|
95
|
+
helptextDropdown=${ifDefined(this.helptextDropdown)}
|
|
96
|
+
helptextDropdownButton=${ifDefined(this.helptextDropdownButton)}
|
|
97
|
+
label=${ifDefined(this.label)}
|
|
98
|
+
optionalText=${ifDefined(this.optionalText)}
|
|
99
|
+
requiredText=${ifDefined(this.requiredText)}
|
|
100
|
+
>
|
|
101
|
+
<select
|
|
102
|
+
class=${inputClass}
|
|
103
|
+
aria-invalid=${this.hasError}
|
|
104
|
+
aria-errormessage=${`${this.id}-error`}
|
|
105
|
+
aria-labelledby=${ifDefined(this.ariaLabelledby)}
|
|
106
|
+
?disabled=${this.disabled}
|
|
107
|
+
id=${this.id}
|
|
108
|
+
name=${this.name || this.id}
|
|
109
|
+
value=${this.value}
|
|
110
|
+
${ref(this.selectRef)}
|
|
111
|
+
${ref(this.defaultSlot)}
|
|
112
|
+
>
|
|
113
|
+
${this._options.length > 0 &&
|
|
114
|
+
this._options.map(
|
|
115
|
+
(option) =>
|
|
116
|
+
html`<option value=${option.value} ?selected=${this.value == option.value}>
|
|
117
|
+
${option.label}
|
|
118
|
+
</option>`,
|
|
119
|
+
)}
|
|
120
|
+
</select>
|
|
121
|
+
</pkt-input-wrapper>
|
|
122
|
+
`
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./icon-CdMQ6zBT.cjs"),y=require("./state-SKYD8kRO.cjs"),f=require("./stringutils-CkVRq4jP.cjs"),g=require("./helptext-iZEgxz2U.cjs");var m=Object.defineProperty,s=(h,t,r,o)=>{for(var a=void 0,n=h.length-1,l;n>=0;n--)(l=h[n])&&(a=l(t,r,a)||a);return a&&m(t,r,a),a};class i extends e.PktElement{constructor(){super(),this.disabled=!1,this.readonly=!1,this.required=!1,this.max=null,this.maxlength=0,this.min=null,this.minlength=0,this.ariaDescribedBy=null,this.ariaLabelledby=null,this.name="",this.pattern="",this.placeholder="",this.id=f.uuidish(),this.counter=!1,this.hasError=!1,this.inline=!1,this.optionalTag=!1,this.requiredTag=!1,this.skipForwardTestid=!1,this.useWrapper=!0,this.fullwidth=!1,this.counterMaxLength=0,this.errorMessage="",this.helptext="",this.helptextDropdown="",this.helptextDropdownButton=g.specs.props.helptextDropdownButton.default,this.label=null,this.optionalText=e.strings.forms.labels.optional,this.requiredText=e.strings.forms.labels.required,this.dataTestid="",this.touched=!1,this.internals=this.attachInternals()}static get formAssociated(){return!0}manageValidity(t){var r,o,a,n,l,p,u,d;t&&(this.required&&!this.value?this.internals.setValidity({valueMissing:!0},e.strings.forms.messages.required,t):(r=t.validity)!=null&&r.typeMismatch||(o=t.validity)!=null&&o.badInput?this.internals.setValidity({typeMismatch:!0},e.strings.forms.messages.invalid,t):(a=t.validity)!=null&&a.patternMismatch?this.internals.setValidity({patternMismatch:!0},e.strings.forms.messages.invalidPattern,t):(n=t.validity)!=null&&n.tooShort||this.minlength&&this.minlength>0&&this.value.length<this.minlength?this.internals.setValidity({tooShort:!0},e.strings.forms.messages.tooShort,t):(l=t.validity)!=null&&l.tooLong||this.maxlength&&this.maxlength>0&&this.value.length>this.maxlength?this.internals.setValidity({tooLong:!0},e.strings.forms.messages.tooLong,t):(p=t.validity)!=null&&p.rangeUnderflow?this.internals.setValidity({rangeUnderflow:!0},e.strings.forms.messages.rangeUnderflow,t):(u=t.validity)!=null&&u.rangeOverflow?this.internals.setValidity({rangeOverflow:!0},e.strings.forms.messages.rangeOverflow,t):(d=t.validity)!=null&&d.customError?this.internals.setValidity({customError:!0},t.validationMessage,t):this.internals.setValidity({}))}setFormValue(t){if(this.internals)if(Array.isArray(t)){const r=new FormData;t.forEach(o=>{r.append(this.name,o)}),this.internals.setFormValue(r)}else this.internals.setFormValue(t)}valueChanged(t,r){(r!==this.value||r!==this._value)&&(typeof t=="string"?((this.multiple||this.range)&&t.includes(",")&&(t=t.split(",")),this.value=t,this._value=Array.isArray(t)?t:[t]):Array.isArray(t)?(this.value=t,this._value=t):(this.value="",this._value=[]),(!this.value||this.value.length===0)&&r&&r.length!==0?this.clearInputValue():this.value&&this.value.toString()!==(r==null?void 0:r.toString())&&this.onChange(this.value),this.updateComplete.then(()=>this.requestUpdate()))}clearInputValue(){const t=this.multiple||this.range?[]:"";this.value=t,this.internals.setFormValue(t),this.dispatchEvent(new Event("change")),this.dispatchEvent(new CustomEvent("value-change",{detail:t,bubbles:!0,composed:!0}))}onFocus(){this.dispatchEvent(new FocusEvent("focus"))}onBlur(){this.dispatchEvent(new FocusEvent("blur"))}onInput(){this.dispatchEvent(new InputEvent("input"))}onChange(t){if(!this.touched){this.touched=!0,t&&this.setFormValue(t);return}typeof t!="string"&&!Array.isArray(t)||((this.range||this.multiple)&&!Array.isArray(t)&&t.includes(",")&&(t=t.split(",")),!this.multiple&&!this.range&&Array.isArray(t)&&(t=t[0]),this.setFormValue(t),this.manageValidity(this.inputRef.value),this.inputRefTo&&this.manageValidity(this.inputRefTo.value),this.dispatchEvent(new Event("change")),this.dispatchEvent(new CustomEvent("value-change",{detail:t,bubbles:!0,composed:!0})),this.internals.reportValidity())}updated(t){super.updated(t),t.has("dataTestid")&&this.dataTestid&&this.inputRef.value&&(this.skipForwardTestid?this.hasAttribute("data-testid")||this.setAttribute("data-testid",this.dataTestid):(this.inputRef.value.dataset.testid=this.dataTestid,this.removeAttribute("data-testid")))}firstUpdated(t){super.firstUpdated(t),this.required&&(this.internals.ariaRequired=!0),this.disabled&&(this.internals.ariaDisabled=!0),this.internals.setFormValue(this.value),this.inputRef&&this.inputRef.value&&(this.inputRef.value.setAttribute("form",""),this.manageValidity(this.inputRef.value)),this.inputRefTo&&this.inputRefTo.value&&(this.inputRefTo.value.setAttribute("form",""),this.manageValidity(this.inputRefTo.value))}}s([e.n({type:Boolean,reflect:!0})],i.prototype,"disabled");s([e.n({type:Boolean,reflect:!0})],i.prototype,"readonly");s([e.n({type:Boolean,reflect:!0})],i.prototype,"required");s([e.n({type:Number,reflect:!0})],i.prototype,"max");s([e.n({type:Number,reflect:!0})],i.prototype,"maxlength");s([e.n({type:Number,reflect:!0})],i.prototype,"min");s([e.n({type:Number,reflect:!0})],i.prototype,"minlength");s([e.n({type:String})],i.prototype,"ariaDescribedBy");s([e.n({type:String})],i.prototype,"ariaLabelledby");s([e.n({type:String,reflect:!0})],i.prototype,"name");s([e.n({type:String,reflect:!0})],i.prototype,"pattern");s([e.n({type:String,reflect:!0})],i.prototype,"placeholder");s([e.n({type:String,reflect:!0})],i.prototype,"id");s([e.n({type:Boolean})],i.prototype,"counter");s([e.n({type:Boolean})],i.prototype,"hasError");s([e.n({type:Boolean})],i.prototype,"inline");s([e.n({type:Boolean})],i.prototype,"optionalTag");s([e.n({type:Boolean})],i.prototype,"requiredTag");s([e.n({type:Boolean})],i.prototype,"skipForwardTestid");s([e.n({type:Boolean})],i.prototype,"useWrapper");s([e.n({type:Boolean,reflect:!0})],i.prototype,"fullwidth");s([e.n({type:Number})],i.prototype,"counterMaxLength");s([e.n({type:String})],i.prototype,"errorMessage");s([e.n({type:String})],i.prototype,"helptext");s([e.n({type:String})],i.prototype,"helptextDropdown");s([e.n({type:String})],i.prototype,"helptextDropdownButton");s([e.n({type:String})],i.prototype,"label");s([e.n({type:String})],i.prototype,"optionalText");s([e.n({type:String})],i.prototype,"requiredText");s([e.n({type:String,attribute:"data-testid"})],i.prototype,"dataTestid");s([y.r()],i.prototype,"touched");exports.PktInputElement=i;
|