@oslokommune/punkt-elements 12.2.0 → 12.3.1

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.
Files changed (91) hide show
  1. package/README.md +30 -0
  2. package/dist/alert.d.ts +1 -0
  3. package/dist/calendar.d.ts +1 -0
  4. package/dist/card.d.ts +1 -0
  5. package/dist/class-map-CA8wadiN.cjs +5 -0
  6. package/dist/class-map-DiT0qP3E.js +34 -0
  7. package/dist/component-template.d.ts +1 -0
  8. package/dist/converters-DNCwIFwr.js +17 -0
  9. package/dist/converters-DhM11VlY.cjs +1 -0
  10. package/dist/datepicker.d.ts +1 -0
  11. package/dist/directive-19_ixLKS.cjs +9 -0
  12. package/dist/directive-DA0-wdk7.js +38 -0
  13. package/dist/element.d.ts +1 -0
  14. package/dist/icon.d.ts +1 -0
  15. package/dist/index-BHzxfdBK.js +807 -0
  16. package/dist/index-BJ_4AGO3.cjs +23 -0
  17. package/dist/index-BlHnvy7v.js +82 -0
  18. package/dist/index-CPvZ03uX.js +577 -0
  19. package/dist/index-DSplpVWQ.cjs +9 -0
  20. package/dist/index-DkGcZra2.cjs +90 -0
  21. package/dist/index.d.ts +393 -3
  22. package/dist/input-wrapper.d.ts +1 -0
  23. package/dist/link.d.ts +1 -0
  24. package/dist/messagebox.d.ts +1 -0
  25. package/dist/pkt-alert.cjs +27 -0
  26. package/dist/pkt-alert.js +86 -0
  27. package/dist/pkt-calendar.cjs +1 -0
  28. package/dist/pkt-calendar.js +10 -0
  29. package/dist/pkt-card.cjs +23 -0
  30. package/dist/pkt-card.js +177 -0
  31. package/dist/pkt-component-template.cjs +29 -0
  32. package/dist/{pkt-el-component-template.js → pkt-component-template.js} +25 -26
  33. package/dist/pkt-datepicker.cjs +140 -0
  34. package/dist/pkt-datepicker.js +1769 -0
  35. package/dist/pkt-element.cjs +1 -0
  36. package/dist/pkt-element.js +5 -0
  37. package/dist/pkt-icon.cjs +1 -0
  38. package/dist/pkt-icon.js +6 -0
  39. package/dist/pkt-index.cjs +1 -0
  40. package/dist/pkt-index.js +20 -0
  41. package/dist/pkt-input-wrapper.cjs +59 -0
  42. package/dist/pkt-input-wrapper.js +293 -0
  43. package/dist/pkt-link.cjs +3 -0
  44. package/dist/pkt-link.js +90 -0
  45. package/dist/pkt-messagebox.cjs +12 -0
  46. package/dist/pkt-messagebox.js +62 -0
  47. package/dist/pkt-tag.cjs +17 -0
  48. package/dist/pkt-tag.js +151 -0
  49. package/dist/ref-Bk590hog.cjs +13 -0
  50. package/dist/ref-Co_S0Cgj.js +173 -0
  51. package/dist/state-BRgFbJX9.js +12 -0
  52. package/dist/state-D2tUtTi6.cjs +5 -0
  53. package/dist/tag.d.ts +1 -0
  54. package/package.json +10 -7
  55. package/src/components/alert/index.ts +86 -0
  56. package/src/components/calendar/index.ts +391 -143
  57. package/src/components/card/index.ts +78 -0
  58. package/src/components/component-template/index.ts +25 -9
  59. package/src/components/datepicker/index.ts +546 -0
  60. package/src/components/element/index.ts +181 -8
  61. package/src/components/icon/index.ts +44 -49
  62. package/src/components/index.ts +7 -1
  63. package/src/components/input-wrapper/index.ts +260 -0
  64. package/src/components/link/index.ts +51 -0
  65. package/src/components/messagebox/index.ts +63 -0
  66. package/src/components/tag/index.ts +110 -0
  67. package/dist/components/calendar/index.d.ts +0 -59
  68. package/dist/components/component-template/index.d.ts +0 -34
  69. package/dist/components/element/index.d.ts +0 -24
  70. package/dist/components/icon/index.d.ts +0 -29
  71. package/dist/components/index.d.ts +0 -3
  72. package/dist/controllers/pkt-slot-controller.d.ts +0 -11
  73. package/dist/converters-Bi8tmNvQ.cjs +0 -5
  74. package/dist/converters-DMveycvc.js +0 -100
  75. package/dist/directive-C7mkmyiy.js +0 -573
  76. package/dist/directive-DfhMJ1ie.cjs +0 -23
  77. package/dist/helpers/converters.d.ts +0 -3
  78. package/dist/index-0PZgk9Oc.js +0 -159
  79. package/dist/index-xoVy6sfy.cjs +0 -13
  80. package/dist/pkt-el-calendar.cjs +0 -60
  81. package/dist/pkt-el-calendar.js +0 -1496
  82. package/dist/pkt-el-component-template.cjs +0 -29
  83. package/dist/pkt-el-element.cjs +0 -1
  84. package/dist/pkt-el-element.js +0 -5
  85. package/dist/pkt-el-icon.cjs +0 -9
  86. package/dist/pkt-el-icon.js +0 -98
  87. package/dist/pkt-el-index.cjs +0 -1
  88. package/dist/pkt-el-index.js +0 -8
  89. package/dist/property-BBVRv-DT.js +0 -47
  90. package/dist/property-CK6SFc5B.cjs +0 -9
  91. package/dist/src/translations/no.json.d.ts +0 -43
@@ -0,0 +1,63 @@
1
+ import { PktElement } from '../element'
2
+ import { PktSlotController } from '../../controllers/pkt-slot-controller'
3
+ import { ref, createRef, Ref } from 'lit/directives/ref.js'
4
+ import { html, nothing } from 'lit'
5
+ import { classMap } from 'lit/directives/class-map.js'
6
+ import { customElement, property } from 'lit/decorators.js'
7
+ import '../icon'
8
+
9
+ @customElement('pkt-messagebox')
10
+ export class PktMessagebox extends PktElement {
11
+ defaultSlot: Ref<HTMLElement> = createRef()
12
+
13
+ constructor() {
14
+ super()
15
+ this.slotController = new PktSlotController(this, this.defaultSlot)
16
+ }
17
+
18
+ @property({ type: Boolean, reflect: true })
19
+ closable = false
20
+ @property({ type: Boolean, reflect: true })
21
+ compact = false
22
+ @property({ type: String, reflect: true })
23
+ title = ''
24
+ @property({ type: String, reflect: true })
25
+ skin = 'beige'
26
+ @property({ type: Boolean, reflect: true })
27
+ isDisplayed = true
28
+ @property({ type: Function, reflect: true })
29
+ onClose?: () => void
30
+
31
+ handleClose() {
32
+ this.isDisplayed = false
33
+ if (this.onClose) {
34
+ this.onClose()
35
+ }
36
+ }
37
+
38
+ render() {
39
+ const classes = {
40
+ 'pkt-messagebox': true,
41
+ 'pkt-messagebox--compact': this.compact,
42
+ [`pkt-messagebox--${this.skin}`]: this.skin,
43
+ 'pkt-messagebox--closable': this.closable,
44
+ }
45
+
46
+ if (!this.isDisplayed) return nothing
47
+
48
+ return html`<div class=${classMap(classes)}>
49
+ ${this.closable
50
+ ? html`<div class="pkt-messagebox__close">
51
+ <button
52
+ @click=${this.handleClose}
53
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
54
+ >
55
+ <pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
56
+ </button>
57
+ </div>`
58
+ : nothing}
59
+ ${this.title ? html`<div class="pkt-messagebox__title">${this.title}</div>` : nothing}
60
+ <div class="pkt-messagebox__text" ${ref(this.defaultSlot)}></div>
61
+ </div>`
62
+ }
63
+ }
@@ -0,0 +1,110 @@
1
+ import { classMap } from 'lit/directives/class-map.js'
2
+ import { customElement, property, state } from 'lit/decorators.js'
3
+ import { html, nothing } from 'lit'
4
+ import { PktElement } from '../element'
5
+ import { PktSlotController } from '@/controllers/pkt-slot-controller'
6
+ import { ref } from 'lit/directives/ref.js'
7
+ import { Ref, createRef } from 'lit/directives/ref.js'
8
+ import specs from 'componentSpecs/tag.json'
9
+
10
+ import '../icon'
11
+
12
+ type TagSize = 'small' | 'medium' | 'large'
13
+ type TagSkin = 'blue' | 'green' | 'red' | 'yellow'
14
+
15
+ export interface IPktTag {
16
+ closeTag?: boolean
17
+ size?: TagSize
18
+ skin?: 'blue' | 'green' | 'red' | 'yellow'
19
+ textStyle?: string
20
+ iconName?: string
21
+ type?: string
22
+ ariaLabel?: string
23
+ }
24
+
25
+ @customElement('pkt-tag')
26
+ export class PktTag extends PktElement {
27
+ slotController: PktSlotController
28
+ defaultSlot: Ref<HTMLElement> = createRef()
29
+
30
+ constructor() {
31
+ super()
32
+ this.slotController = new PktSlotController(this, this.defaultSlot)
33
+ this._isClosed = false
34
+ }
35
+
36
+ /**
37
+ * Element attributes
38
+ */
39
+ @property({ type: Boolean, reflect: true }) closeTag: boolean = specs.props.closeTag.default
40
+ @property({ type: String, reflect: true }) size: TagSize = specs.props.size.default as TagSize
41
+ @property({ type: String, reflect: true }) skin: TagSkin = specs.props.skin.default as TagSkin
42
+ @property({ type: String, reflect: true }) textStyle: string = specs.props.textStyle.default
43
+ @property({ type: String, reflect: true }) iconName: string | undefined = undefined
44
+ @property({ type: String, reflect: true }) type: string = specs.props.type.default
45
+ @property({ type: String, reflect: true }) ariaLabel: string = specs.props.ariaLabel.default
46
+
47
+ /**
48
+ * Element state
49
+ */
50
+ @state() _isClosed: boolean = false
51
+
52
+ /**
53
+ * Element functions
54
+ */
55
+ private close = (event: MouseEvent) => {
56
+ this._isClosed = true
57
+ this.dispatchEvent(
58
+ new CustomEvent('onClose', {
59
+ detail: { origin: event },
60
+ bubbles: true,
61
+ composed: true,
62
+ }),
63
+ )
64
+ }
65
+
66
+ render() {
67
+ const classes = {
68
+ 'pkt-tag': true,
69
+ [`pkt-tag--${this.size}`]: !!this.size,
70
+ [`pkt-tag--${this.skin}`]: !!this.skin,
71
+ [`pkt-tag--${this.textStyle}`]: !!this.textStyle,
72
+ }
73
+
74
+ const btnClasses = {
75
+ 'pkt-tag': true,
76
+ 'pkt-btn': true,
77
+ 'pkt-btn--tertiary': true,
78
+ [`pkt-tag--${this.size}`]: !!this.size,
79
+ [`pkt-tag--${this.skin}`]: !!this.skin,
80
+ [`pkt-tag--${this.textStyle}`]: !!this.textStyle,
81
+ 'pkt-btn--icons-right-and-left': this.closeTag && !!this.iconName,
82
+ }
83
+
84
+ if (this.closeTag) {
85
+ return !this._isClosed
86
+ ? html`
87
+ <button
88
+ class=${classMap(btnClasses)}
89
+ type=${this.type}
90
+ aria-label=${this.ariaLabel}
91
+ @click=${this.close}
92
+ >
93
+ ${this.iconName &&
94
+ html`<pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon>`}
95
+ <span ${ref(this.defaultSlot)}></span>
96
+ <pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
97
+ </button>
98
+ `
99
+ : nothing
100
+ } else {
101
+ return html`
102
+ <span class=${classMap(classes)}>
103
+ ${this.iconName &&
104
+ html` <pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon> `}
105
+ <span ${ref(this.defaultSlot)}> </span>
106
+ </span>
107
+ `
108
+ }
109
+ }
110
+ }
@@ -1,59 +0,0 @@
1
- import { PktElement } from '../element';
2
- export declare class PktCalendar extends PktElement {
3
- /**
4
- * Element attributes
5
- */
6
- date: Date;
7
- selected: string[];
8
- excludeweekdays: string[];
9
- excludedates: Date[];
10
- earliest: Date | null;
11
- latest: Date | null;
12
- weeknumbers: boolean;
13
- withcontrols: boolean;
14
- multiple: boolean;
15
- range: boolean;
16
- /**
17
- * Strings
18
- */
19
- dayStrings: string[];
20
- monthStrings: string[];
21
- weekString: string;
22
- prevMonthString: string;
23
- nextMonthString: string;
24
- /**
25
- * Private properties
26
- */
27
- private _selected;
28
- private year;
29
- private month;
30
- private week;
31
- private rangeHovered;
32
- /**
33
- * Runs on mount, used to set up various values and whatever you need to run
34
- */
35
- connectedCallback(): void;
36
- /**
37
- * Component functionality and render
38
- */
39
- render(): import('lit-html').TemplateResult<1>;
40
- private renderDayNames;
41
- private renderMonthNav;
42
- private renderCalendarBody;
43
- private isExcluded;
44
- private formatISODate;
45
- isPrevMonthAllowed(): boolean;
46
- private prevMonth;
47
- isNextMonthAllowed(): boolean;
48
- private nextMonth;
49
- private changeMonth;
50
- private isInRange;
51
- private isRangeAllowed;
52
- private emptySelected;
53
- private addToSelected;
54
- private removeFromSelected;
55
- private toggleSelected;
56
- private handleRangeSelect;
57
- private handleRangeHover;
58
- private handleDateSelect;
59
- }
@@ -1,34 +0,0 @@
1
- import { PktElement } from '../element';
2
- export declare class PktComponent extends PktElement {
3
- /**
4
- * Element attributes => props
5
- * Example:
6
- * <pkt-el-component string="hei" strings="hei,og,hallo" darkmode>
7
- * Hei!
8
- * </pkt-el-component>
9
- */
10
- string: string;
11
- strings: string[];
12
- darkmode: boolean;
13
- /**
14
- * Private properties, for internal use only
15
- */
16
- private _list;
17
- /**
18
- * Runs on mount, used to set up various values and whatever you need to run
19
- */
20
- connectedCallback(): void;
21
- /**
22
- * Render functions
23
- */
24
- render(): import('lit-html').TemplateResult<1>;
25
- private renderList;
26
- /**
27
- * Add other functionality under here
28
- */
29
- private doStuff;
30
- /**
31
- * Handlers for returning data from the component
32
- */
33
- private handleGreeting;
34
- }
@@ -1,24 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import { Ref } from 'lit/directives/ref.js';
3
- import { PktSlotController } from '../../src/controllers/pkt-slot-controller';
4
- export declare class PktElement extends LitElement {
5
- /**
6
- * Runs on mount, used to set up various values and whatever you need to run
7
- */
8
- connectedCallback(): void;
9
- /**
10
- * Make sure the component renders in light DOM instead of shadow DOM
11
- */
12
- createRenderRoot(): this;
13
- /**
14
- * Add support for Hot Module Reloading in dev mode
15
- */
16
- hotReplacedCallback(): void;
17
- /**
18
- * Set up slot support for Light DOM
19
- */
20
- slotController: PktSlotController;
21
- defaultSlot: Ref<HTMLElement>;
22
- namedSlot: Ref<HTMLElement>;
23
- constructor();
24
- }
@@ -1,29 +0,0 @@
1
- import { LitElement } from 'lit';
2
- export declare class PktIcon extends LitElement {
3
- /**
4
- * Element attributes
5
- */
6
- name: string;
7
- path: string;
8
- private icon;
9
- /**
10
- * Make sure the component renders in light DOM instead of shadow DOM
11
- */
12
- createRenderRoot(): this;
13
- /**
14
- * Add support for Hot Module Reloading in dev mode
15
- */
16
- hotReplacedCallback(): void;
17
- /**
18
- * Runs on mount, used to set up various values and whatever you need to run
19
- */
20
- connectedCallback(): Promise<void>;
21
- /**
22
- * Runs every time a property changes
23
- */
24
- update(changedProperties: Map<string, unknown>): Promise<void>;
25
- /**
26
- * Component functionality and render
27
- */
28
- render(): import('lit-html').TemplateResult<1>;
29
- }
@@ -1,3 +0,0 @@
1
- export { PktCalendar } from './calendar';
2
- export { PktIcon } from './icon';
3
- export { PktComponent } from './component-template';
@@ -1,11 +0,0 @@
1
- import { LitElement, ReactiveController, ReactiveControllerHost } from 'lit';
2
- import { Ref } from 'lit/directives/ref.js';
3
- export declare class PktSlotController implements ReactiveController {
4
- host: LitElement & ReactiveControllerHost;
5
- nodes: Element[];
6
- slots: Ref<HTMLElement>[];
7
- constructor(host: LitElement & ReactiveControllerHost, ...slots: Ref<HTMLElement>[]);
8
- hostUpdate(): void;
9
- hostUpdated(): void;
10
- private nodeFromElement;
11
- }
@@ -1,5 +0,0 @@
1
- "use strict";const s=require("./directive-DfhMJ1ie.cjs");/**
2
- * @license
3
- * Copyright 2018 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */const d=s.e(class extends s.i{constructor(t){var e;if(super(t),t.type!==s.t.ATTRIBUTE||t.name!=="class"||((e=t.strings)==null?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){var i,a;if(this.st===void 0){this.st=new Set,t.strings!==void 0&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in e)e[r]&&!((i=this.nt)!=null&&i.has(r))&&this.st.add(r);return this.render(e)}const n=t.element.classList;for(const r of this.st)r in e||(n.remove(r),this.st.delete(r));for(const r in e){const o=!!e[r];o===this.st.has(r)||(a=this.nt)!=null&&a.has(r)||(o?(n.add(r),this.st.add(r)):(n.remove(r),this.st.delete(r)))}return s.R}}),h={hi:"Hei!"},c={days:["Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag","Søndag"],daysShort:["Man","Tir","Ons","Tor","Fre","Lør","Søn"],months:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],monthsShort:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],week:"Uke",prevMonth:"Forrige måned",nextMonth:"Neste måned"},u={example:h,dates:c},g=t=>{if(Array.isArray(t))return t;if(typeof t=="string")return t.split(",")},p=t=>t?new Date(t):void 0,l=t=>{if(typeof t=="string")return t.split(",").map(e=>new Date(e));if(Array.isArray(t))return t.map(e=>new Date(e))};exports.Rt=d;exports.csvToArray=g;exports.stringToDate=p;exports.stringsToDate=l;exports.translations=u;
@@ -1,100 +0,0 @@
1
- import { e as o, i as d, t as h, R as c } from "./directive-C7mkmyiy.js";
2
- /**
3
- * @license
4
- * Copyright 2018 Google LLC
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- */
7
- const m = o(class extends d {
8
- constructor(t) {
9
- var e;
10
- if (super(t), t.type !== h.ATTRIBUTE || t.name !== "class" || ((e = t.strings) == null ? void 0 : e.length) > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
11
- }
12
- render(t) {
13
- return " " + Object.keys(t).filter((e) => t[e]).join(" ") + " ";
14
- }
15
- update(t, [e]) {
16
- var n, i;
17
- if (this.st === void 0) {
18
- this.st = /* @__PURE__ */ new Set(), t.strings !== void 0 && (this.nt = new Set(t.strings.join(" ").split(/\s/).filter((r) => r !== "")));
19
- for (const r in e) e[r] && !((n = this.nt) != null && n.has(r)) && this.st.add(r);
20
- return this.render(e);
21
- }
22
- const s = t.element.classList;
23
- for (const r of this.st) r in e || (s.remove(r), this.st.delete(r));
24
- for (const r in e) {
25
- const a = !!e[r];
26
- a === this.st.has(r) || (i = this.nt) != null && i.has(r) || (a ? (s.add(r), this.st.add(r)) : (s.remove(r), this.st.delete(r)));
27
- }
28
- return c;
29
- }
30
- }), p = {
31
- hi: "Hei!"
32
- }, u = {
33
- days: [
34
- "Mandag",
35
- "Tirsdag",
36
- "Onsdag",
37
- "Torsdag",
38
- "Fredag",
39
- "Lørdag",
40
- "Søndag"
41
- ],
42
- daysShort: [
43
- "Man",
44
- "Tir",
45
- "Ons",
46
- "Tor",
47
- "Fre",
48
- "Lør",
49
- "Søn"
50
- ],
51
- months: [
52
- "Januar",
53
- "Februar",
54
- "Mars",
55
- "April",
56
- "Mai",
57
- "Juni",
58
- "Juli",
59
- "August",
60
- "September",
61
- "Oktober",
62
- "November",
63
- "Desember"
64
- ],
65
- monthsShort: [
66
- "Jan",
67
- "Feb",
68
- "Mar",
69
- "Apr",
70
- "Mai",
71
- "Jun",
72
- "Jul",
73
- "Aug",
74
- "Sep",
75
- "Okt",
76
- "Nov",
77
- "Des"
78
- ],
79
- week: "Uke",
80
- prevMonth: "Forrige måned",
81
- nextMonth: "Neste måned"
82
- }, f = {
83
- example: p,
84
- dates: u
85
- }, l = (t) => {
86
- if (Array.isArray(t)) return t;
87
- if (typeof t == "string") return t.split(",");
88
- }, y = (t) => t ? new Date(t) : void 0, b = (t) => {
89
- if (typeof t == "string")
90
- return t.split(",").map((e) => new Date(e));
91
- if (Array.isArray(t))
92
- return t.map((e) => new Date(e));
93
- };
94
- export {
95
- m as R,
96
- b as a,
97
- l as c,
98
- y as s,
99
- f as t
100
- };