@skf-design-system/ui-components 1.0.0-beta.4 → 1.0.0-beta.7

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 (159) hide show
  1. package/README.md +26 -6
  2. package/dist/components/accordion/accordion-item.d.ts +1 -1
  3. package/dist/components/accordion/accordion.component.d.ts +13 -9
  4. package/dist/components/accordion/accordion.component.js +34 -30
  5. package/dist/components/accordion/accordion.d.ts +1 -1
  6. package/dist/components/accordion/accordion.styles.d.ts +1 -2
  7. package/dist/components/accordion/accordion.styles.js +5 -4
  8. package/dist/components/alert/alert.component.d.ts +10 -7
  9. package/dist/components/alert/alert.component.js +50 -37
  10. package/dist/components/alert/alert.styles.d.ts +1 -2
  11. package/dist/components/alert/alert.styles.js +42 -34
  12. package/dist/components/button/button.component.d.ts +28 -4
  13. package/dist/components/button/button.component.js +80 -56
  14. package/dist/components/button/button.styles.js +2 -1
  15. package/dist/components/card/card.component.d.ts +1 -1
  16. package/dist/components/card/card.component.js +29 -21
  17. package/dist/components/card/card.styles.d.ts +1 -2
  18. package/dist/components/card/card.styles.js +22 -12
  19. package/dist/components/checkbox/checkbox.component.d.ts +20 -18
  20. package/dist/components/checkbox/checkbox.component.js +95 -89
  21. package/dist/components/checkbox/checkbox.styles.js +7 -2
  22. package/dist/components/checkbox/checkbox.test.d.ts +1 -0
  23. package/dist/components/collapse/collapse.component.d.ts +8 -5
  24. package/dist/components/collapse/collapse.component.js +50 -39
  25. package/dist/components/collapse/collapse.styles.js +13 -12
  26. package/dist/components/collapse/collapse.test.d.ts +1 -0
  27. package/dist/components/dialog/dialog.component.d.ts +75 -0
  28. package/dist/components/dialog/dialog.component.js +189 -0
  29. package/dist/components/dialog/dialog.d.ts +8 -0
  30. package/dist/components/dialog/dialog.js +6 -0
  31. package/dist/components/dialog/dialog.styles.d.ts +1 -0
  32. package/dist/components/dialog/dialog.styles.js +91 -0
  33. package/dist/components/divider/divider.component.d.ts +14 -11
  34. package/dist/components/divider/divider.component.js +46 -29
  35. package/dist/components/divider/divider.styles.d.ts +1 -2
  36. package/dist/components/divider/divider.styles.js +26 -30
  37. package/dist/components/heading/heading.component.d.ts +14 -4
  38. package/dist/components/heading/heading.component.js +14 -14
  39. package/dist/components/heading/heading.styles.js +1 -1
  40. package/dist/components/icon/icon.component.d.ts +15 -9
  41. package/dist/components/icon/icon.component.js +6 -6
  42. package/dist/components/icon/icon.styles.js +56 -54
  43. package/dist/components/input/input.component.d.ts +48 -33
  44. package/dist/components/input/input.component.js +108 -99
  45. package/dist/components/link/link.component.d.ts +20 -17
  46. package/dist/components/link/link.component.js +20 -14
  47. package/dist/components/link/link.styles.js +36 -40
  48. package/dist/components/loader/loader.component.d.ts +7 -7
  49. package/dist/components/loader/loader.component.js +42 -61
  50. package/dist/components/loader/loader.styles.js +44 -11
  51. package/dist/components/logo/logo.component.d.ts +7 -5
  52. package/dist/components/logo/logo.component.js +25 -14
  53. package/dist/components/logo/logo.styles.d.ts +1 -2
  54. package/dist/components/logo/logo.styles.js +12 -10
  55. package/dist/components/progress/progress.component.d.ts +22 -0
  56. package/dist/components/progress/progress.component.js +49 -0
  57. package/dist/components/progress/progress.d.ts +8 -0
  58. package/dist/components/progress/progress.js +6 -0
  59. package/dist/components/progress/progress.styles.d.ts +1 -0
  60. package/dist/components/progress/progress.styles.js +48 -0
  61. package/dist/components/radio/radio.component.d.ts +21 -21
  62. package/dist/components/radio/radio.component.js +94 -78
  63. package/dist/components/radio/radio.styles.js +6 -1
  64. package/dist/components/select/select.component.d.ts +14 -12
  65. package/dist/components/select/select.component.js +119 -103
  66. package/dist/components/select/select.controllers.d.ts +1 -1
  67. package/dist/components/select/select.controllers.js +5 -2
  68. package/dist/components/select/select.styles.js +18 -3
  69. package/dist/components/select-option/select-option.component.d.ts +3 -3
  70. package/dist/components/select-option/select-option.component.js +16 -10
  71. package/dist/components/select-option/select-option.controllers.d.ts +1 -1
  72. package/dist/components/select-option-group/select-option-group.component.d.ts +1 -1
  73. package/dist/components/switch/switch.component.d.ts +4 -5
  74. package/dist/components/switch/switch.component.js +17 -7
  75. package/dist/components/switch/switch.styles.js +19 -11
  76. package/dist/components/switch/switch.test.d.ts +1 -0
  77. package/dist/components/tab/tab.component.d.ts +29 -0
  78. package/dist/components/tab/tab.component.js +57 -0
  79. package/dist/components/tab/tab.d.ts +8 -0
  80. package/dist/components/tab/tab.js +6 -0
  81. package/dist/components/tab/tab.styles.d.ts +1 -0
  82. package/dist/components/tab/tab.styles.js +123 -0
  83. package/dist/components/tab-group/tab-group.component.d.ts +43 -0
  84. package/dist/components/tab-group/tab-group.component.js +98 -0
  85. package/dist/components/tab-group/tab-group.d.ts +8 -0
  86. package/dist/components/tab-group/tab-group.js +6 -0
  87. package/dist/components/tab-group/tab-group.styles.d.ts +1 -0
  88. package/dist/components/tab-group/tab-group.styles.js +75 -0
  89. package/dist/components/tab-panel/tab-panel.component.d.ts +19 -0
  90. package/dist/components/tab-panel/tab-panel.component.js +36 -0
  91. package/dist/components/tab-panel/tab-panel.d.ts +8 -0
  92. package/dist/components/tab-panel/tab-panel.js +6 -0
  93. package/dist/components/tab-panel/tab-panel.styles.d.ts +1 -0
  94. package/dist/components/tab-panel/tab-panel.styles.js +13 -0
  95. package/dist/components/tag/tag.component.d.ts +14 -9
  96. package/dist/components/tag/tag.component.js +63 -47
  97. package/dist/components/tag/tag.styles.js +35 -28
  98. package/dist/components/textarea/textarea.component.d.ts +30 -27
  99. package/dist/components/textarea/textarea.component.js +20 -17
  100. package/dist/components/toast/toast.component.d.ts +35 -0
  101. package/dist/components/toast/toast.component.js +52 -0
  102. package/dist/components/toast/toast.d.ts +8 -0
  103. package/dist/components/toast/toast.js +6 -0
  104. package/dist/components/toast/toast.singleton.d.ts +26 -0
  105. package/dist/components/toast/toast.singleton.js +53 -0
  106. package/dist/components/toast/toast.styles.d.ts +1 -0
  107. package/dist/components/toast/toast.styles.js +9 -0
  108. package/dist/components/toast-item/toast-item.component.d.ts +21 -0
  109. package/dist/components/toast-item/toast-item.component.js +65 -0
  110. package/dist/components/toast-item/toast-item.d.ts +6 -0
  111. package/dist/components/toast-item/toast-item.js +2 -0
  112. package/dist/components/toast-item/toast-item.styles.d.ts +2 -0
  113. package/dist/components/toast-item/toast-item.styles.js +16 -0
  114. package/dist/components/toast-wrapper/toast-wrapper.component.d.ts +24 -0
  115. package/dist/components/toast-wrapper/toast-wrapper.component.js +37 -0
  116. package/dist/components/toast-wrapper/toast-wrapper.d.ts +8 -0
  117. package/dist/components/toast-wrapper/toast-wrapper.js +6 -0
  118. package/dist/components/toast-wrapper/toast-wrapper.styles.d.ts +1 -0
  119. package/dist/components/toast-wrapper/toast-wrapper.styles.js +20 -0
  120. package/dist/custom-elements.json +3090 -1993
  121. package/dist/index.d.ts +6 -0
  122. package/dist/index.js +60 -42
  123. package/dist/internal/components/formBase.d.ts +1 -0
  124. package/dist/internal/components/formBase.js +11 -11
  125. package/dist/internal/components/hint/hint.component.d.ts +2 -2
  126. package/dist/internal/components/hint/hint.component.js +12 -10
  127. package/dist/internal/components/hint/hint.styles.js +26 -10
  128. package/dist/internal/components/skf-element.js +26 -25
  129. package/dist/internal/helpers/hintSeverity.d.ts +1 -1
  130. package/dist/internal/helpers/watch.d.ts +27 -0
  131. package/dist/internal/helpers/watch.js +28 -0
  132. package/dist/internal/storybook/shadowRootTraverser.d.ts +16 -8
  133. package/dist/internal/templates/asterisk.d.ts +1 -1
  134. package/dist/internal/templates/asterisk.js +7 -6
  135. package/dist/react/index.d.ts +10 -3
  136. package/dist/react/index.js +10 -3
  137. package/dist/react/skf-button/index.d.ts +7 -1
  138. package/dist/react/skf-button/index.js +5 -1
  139. package/dist/react/skf-dialog/index.d.ts +15 -0
  140. package/dist/react/skf-dialog/index.js +19 -0
  141. package/dist/react/skf-progress/index.d.ts +3 -0
  142. package/dist/react/skf-progress/index.js +13 -0
  143. package/dist/react/skf-tab/index.d.ts +12 -0
  144. package/dist/react/skf-tab/index.js +18 -0
  145. package/dist/react/skf-tab-group/index.d.ts +3 -0
  146. package/dist/react/skf-tab-group/index.js +13 -0
  147. package/dist/react/skf-tab-panel/index.d.ts +3 -0
  148. package/dist/react/skf-tab-panel/index.js +13 -0
  149. package/dist/react/skf-toast/index.d.ts +3 -0
  150. package/dist/react/skf-toast/index.js +13 -0
  151. package/dist/react/skf-toast-wrapper/index.d.ts +3 -0
  152. package/dist/react/skf-toast-wrapper/index.js +13 -0
  153. package/dist/styles/component.styles.js +15 -2
  154. package/dist/styles/form-field.styles.js +5 -1
  155. package/dist/types/jsx/custom-element-jsx.d.ts +300 -117
  156. package/dist/types/vue/index.d.ts +266 -76
  157. package/dist/vscode.html-custom-data.json +349 -216
  158. package/dist/web-types.json +686 -292
  159. package/package.json +33 -32
@@ -1,48 +1,66 @@
1
1
  import "../icon/icon.js";
2
2
  import "../loader/loader.js";
3
- import { SkfElement as c } from "../../internal/components/skf-element.js";
3
+ import { SkfElement as f } from "../../internal/components/skf-element.js";
4
4
  import b from "../../styles/component.styles.js";
5
- import { html as d } from "lit";
6
- import { property as e, state as m, query as f } from "lit/decorators.js";
5
+ import { html as h, LitElement as m } from "lit";
6
+ import { property as s, state as u, query as p } from "lit/decorators.js";
7
7
  import { ifDefined as y } from "lit/directives/if-defined.js";
8
- import u from "./button.styles.js";
9
- var _ = Object.defineProperty, i = (p, o, r, a) => {
10
- for (var s = void 0, n = p.length - 1, h; n >= 0; n--)
11
- (h = p[n]) && (s = h(o, r, s) || s);
12
- return s && _(o, r, s), s;
8
+ import _ from "./button.styles.js";
9
+ var $ = Object.defineProperty, o = (c, t, r, n) => {
10
+ for (var e = void 0, a = c.length - 1, l; a >= 0; a--)
11
+ (l = c[a]) && (e = l(t, r, e) || e);
12
+ return e && $(t, r, e), e;
13
13
  };
14
- const l = class l extends c {
14
+ const d = class d extends f {
15
15
  constructor() {
16
- super(...arguments), this._transitionOptions = {
16
+ super(), this._transitionOptions = {
17
17
  duration: 200,
18
18
  fill: "forwards"
19
- }, this.destructive = !1, this.disabled = !1, this.iconPosition = "left", this.loading = !1, this.size = "md", this.type = "button", this.variant = "primary", this._loaderVisible = !1, this._renderIcon = () => d`<skf-icon class="skf-icon-host" name=${y(this.icon)}></skf-icon>`;
19
+ }, this.destructive = !1, this.disabled = !1, this.iconPosition = "left", this.loading = !1, this.noValidate = !1, this.size = "md", this.type = "button", this.variant = "primary", this._loaderVisible = !1, this._handleClick = (t) => {
20
+ t.preventDefault(), t.stopPropagation(), !(this.disabled || this.loading) && (this.dispatchEvent(new CustomEvent("click", { bubbles: !0, composed: !0, detail: t })), this.type === "submit" && this._submitForm(), this.type === "reset" && this._resetForm());
21
+ }, this._submitForm = () => {
22
+ var e, a, l;
23
+ const t = !((e = this._internals.form) != null && e.reportValidity()), r = !this.noValidate, n = !((a = this._internals.form) != null && a.hasAttribute("no-validate"));
24
+ (r || n) && t || (l = this._internals.form) == null || l.submit();
25
+ }, this._resetForm = () => {
26
+ var t;
27
+ (t = this._internals.form) == null || t.reset();
28
+ }, this._renderIcon = () => h`<skf-icon class="skf-icon-host" name=${y(this.icon)}></skf-icon>`, this._internals = this.attachInternals();
20
29
  }
21
- firstUpdated(o) {
22
- if (o.has("loading") && this.loading) {
30
+ firstUpdated(t) {
31
+ if (t.has("loading") && this.loading) {
23
32
  if (!this.$body || !this.$loader) return;
24
33
  this._loaderVisible = !0, this.$body.style.opacity = "0", this.$loader.style.opacity = "1";
25
34
  }
26
35
  }
27
- attributeChangedCallback(o, r, a) {
28
- super.attributeChangedCallback(o, r, a), o === "loading" && (a !== null ? this._showLoader() : this._hideLoader());
36
+ attributeChangedCallback(t, r, n) {
37
+ super.attributeChangedCallback(t, r, n), t === "loading" && (n !== null ? this._showLoader() : this._hideLoader());
29
38
  }
39
+ /** Simulates a click on the button. */
40
+ click() {
41
+ var t;
42
+ (t = this.$button) == null || t.click();
43
+ }
44
+ /** @internal */
30
45
  async _showLoader() {
31
- var o;
32
- this._loaderVisible = !0, await ((o = this.$body) == null ? void 0 : o.animate({ opacity: 0 }, this._transitionOptions).finished), !(!this.$body || !this.$loader) && this.$loader.animate({ opacity: 1 }, this._transitionOptions);
46
+ var t;
47
+ this._loaderVisible = !0, await ((t = this.$body) == null ? void 0 : t.animate({ opacity: 0 }, this._transitionOptions).finished), !(!this.$body || !this.$loader) && this.$loader.animate({ opacity: 1 }, this._transitionOptions);
33
48
  }
49
+ /** @internal */
34
50
  async _hideLoader() {
35
51
  !this.$body || !this.$loader || (await this.$loader.animate({ opacity: 0 }, this._transitionOptions).finished, this._loaderVisible = !1, this.$body.animate({ opacity: 1 }, this._transitionOptions));
36
52
  }
37
53
  render() {
38
- return d`
54
+ return h`
39
55
  <button
40
56
  ?disabled=${this.disabled || this.loading}
41
57
  aria-busy=${this.loading}
42
- id="button"
58
+ id="root"
43
59
  type=${y(this.type)}
60
+ @click=${this._handleClick}
61
+ title=${this.title}
44
62
  >
45
- ${this.variant === "primary" && this._loaderVisible ? d`<skf-loader invert size="sm"></skf-loader>` : ""}
63
+ ${this.variant === "primary" && this._loaderVisible ? h`<skf-loader invert size="sm"></skf-loader>` : ""}
46
64
  <div id="body">
47
65
  ${this.icon && this.iconPosition === "left" ? this._renderIcon() : ""}
48
66
  <div id="label">
@@ -54,41 +72,47 @@ const l = class l extends c {
54
72
  `;
55
73
  }
56
74
  };
57
- l.styles = [b, u];
58
- let t = l;
59
- i([
60
- e({ type: Boolean })
61
- ], t.prototype, "destructive");
62
- i([
63
- e({ type: Boolean })
64
- ], t.prototype, "disabled");
65
- i([
66
- e()
67
- ], t.prototype, "icon");
68
- i([
69
- e({ attribute: "icon-position" })
70
- ], t.prototype, "iconPosition");
71
- i([
72
- e({ type: Boolean })
73
- ], t.prototype, "loading");
74
- i([
75
- e({ reflect: !0 })
76
- ], t.prototype, "size");
77
- i([
78
- e()
79
- ], t.prototype, "type");
80
- i([
81
- e({ reflect: !0 })
82
- ], t.prototype, "variant");
83
- i([
84
- m()
85
- ], t.prototype, "_loaderVisible");
86
- i([
87
- f("skf-loader")
88
- ], t.prototype, "$loader");
89
- i([
90
- f("#body")
91
- ], t.prototype, "$body");
75
+ d.formAssociated = !0, d.shadowRootOptions = { ...m.shadowRootOptions, delegatesFocus: !0 }, d.styles = [b, _];
76
+ let i = d;
77
+ o([
78
+ s({ type: Boolean })
79
+ ], i.prototype, "destructive");
80
+ o([
81
+ s({ type: Boolean })
82
+ ], i.prototype, "disabled");
83
+ o([
84
+ s()
85
+ ], i.prototype, "icon");
86
+ o([
87
+ s({ attribute: "icon-position" })
88
+ ], i.prototype, "iconPosition");
89
+ o([
90
+ s({ type: Boolean })
91
+ ], i.prototype, "loading");
92
+ o([
93
+ s({ type: Boolean, attribute: "no-validate" })
94
+ ], i.prototype, "noValidate");
95
+ o([
96
+ s({ reflect: !0 })
97
+ ], i.prototype, "size");
98
+ o([
99
+ s()
100
+ ], i.prototype, "type");
101
+ o([
102
+ s({ reflect: !0 })
103
+ ], i.prototype, "variant");
104
+ o([
105
+ u()
106
+ ], i.prototype, "_loaderVisible");
107
+ o([
108
+ p("skf-loader")
109
+ ], i.prototype, "$loader");
110
+ o([
111
+ p("#body")
112
+ ], i.prototype, "$body");
113
+ o([
114
+ p("button")
115
+ ], i.prototype, "$button");
92
116
  export {
93
- t as SkfButton
117
+ i as SkfButton
94
118
  };
@@ -3,9 +3,10 @@ const r = o`
3
3
  @layer components {
4
4
  :host {
5
5
  contain: initial;
6
+ display: inline-flex;
6
7
  }
7
8
 
8
- #button {
9
+ #root {
9
10
  background-color: var(--_skf-button-state-bg-color, var(--_skf-button-bg-color));
10
11
  block-size: var(--_skf-button-block-size);
11
12
  border: var(--skf-border-width-sm) solid
@@ -1,4 +1,4 @@
1
- import { SkfElement } from '@internal/components/skf-element.js';
1
+ import { SkfElement } from '../../internal/components/skf-element.js';
2
2
  import { type CSSResultGroup } from 'lit';
3
3
  /**
4
4
  * The `<skf-card>` can be used to group related subjects in a container
@@ -1,36 +1,44 @@
1
- import { SkfElement as d } from "../../internal/components/skf-element.js";
2
- import m from "../../styles/component.styles.js";
3
- import { html as f } from "lit";
4
- import { property as r } from "lit/decorators.js";
5
- import y from "./card.styles.js";
6
- var c = Object.defineProperty, s = (p, i, l, h) => {
7
- for (var t = void 0, o = p.length - 1, a; o >= 0; o--)
8
- (a = p[o]) && (t = a(i, l, t) || t);
9
- return t && c(i, l, t), t;
1
+ import { SkfElement as l } from "../../internal/components/skf-element.js";
2
+ import c from "../../styles/component.styles.js";
3
+ import { html as m } from "lit";
4
+ import { property as o } from "lit/decorators.js";
5
+ import { classMap as f } from "lit/directives/class-map.js";
6
+ import { styles as h } from "./card.styles.js";
7
+ var u = Object.defineProperty, s = (i, p, a, y) => {
8
+ for (var t = void 0, e = i.length - 1, d; e >= 0; e--)
9
+ (d = i[e]) && (t = d(p, a, t) || t);
10
+ return t && u(p, a, t), t;
10
11
  };
11
- const n = class n extends d {
12
+ const n = class n extends l {
12
13
  constructor() {
13
14
  super(...arguments), this.noBorder = !1, this.noPadding = !1, this.stretch = !1;
14
15
  }
15
16
  render() {
16
- return f`
17
- <div id="card">
17
+ return m`
18
+ <div
19
+ class=${f({
20
+ card: !0,
21
+ "card--no-border": this.noBorder,
22
+ "card--no-padding": this.noPadding,
23
+ "card--stretch": this.stretch
24
+ })}
25
+ >
18
26
  <slot></slot>
19
27
  </div>
20
28
  `;
21
29
  }
22
30
  };
23
- n.styles = [m, y];
24
- let e = n;
31
+ n.styles = [c, h];
32
+ let r = n;
25
33
  s([
26
- r({ type: Boolean, attribute: "no-border" })
27
- ], e.prototype, "noBorder");
34
+ o({ type: Boolean, attribute: "no-border" })
35
+ ], r.prototype, "noBorder");
28
36
  s([
29
- r({ type: Boolean, attribute: "no-padding" })
30
- ], e.prototype, "noPadding");
37
+ o({ type: Boolean, attribute: "no-padding" })
38
+ ], r.prototype, "noPadding");
31
39
  s([
32
- r({ type: Boolean })
33
- ], e.prototype, "stretch");
40
+ o({ type: Boolean, reflect: !0 })
41
+ ], r.prototype, "stretch");
34
42
  export {
35
- e as SkfCard
43
+ r as SkfCard
36
44
  };
@@ -1,2 +1 @@
1
- declare const _default: import("lit").CSSResult;
2
- export default _default;
1
+ export declare const styles: import("lit").CSSResult;
@@ -1,26 +1,36 @@
1
1
  import { css as r } from "lit";
2
- const d = r`
3
- #card {
2
+ const a = r`
3
+ /* stylelint-disable selector-class-pattern */
4
+
5
+ :host {
6
+ contain: layout;
7
+ }
8
+
9
+ :host([stretch]) {
10
+ block-size: 100%;
11
+ }
12
+
13
+ .card {
4
14
  background-color: var(--skf-bg-color-neutral-1);
5
15
  border: var(--skf-border-width-sm) solid
6
16
  var(--_skf-card-border-color, var(--skf-border-color-tertiary));
7
17
  border-radius: var(--skf-border-radius-sm);
8
18
  box-shadow: var(--skf-shadow-md);
9
19
  padding: var(--_skf-card-padding, var(--skf-spacing-100));
20
+ }
10
21
 
11
- :host([no-border]) & {
12
- --_skf-card-border-color: transparent;
13
- }
22
+ .card--no-border {
23
+ --_skf-card-border-color: transparent;
24
+ }
14
25
 
15
- :host([no-padding]) & {
16
- --_skf-card-padding: 0;
17
- }
26
+ .card--no-padding {
27
+ --_skf-card-padding: 0;
28
+ }
18
29
 
19
- :host([stretch]) & {
20
- block-size: inherit;
21
- }
30
+ .card--stretch {
31
+ block-size: inherit;
22
32
  }
23
33
  `;
24
34
  export {
25
- d as default
35
+ a as styles
26
36
  };
@@ -1,33 +1,34 @@
1
- import '@components/icon/icon.js';
2
- import { FormBase } from '@internal/components/formBase.js';
3
- import type { FormFieldBaseProps } from '@internal/types/formField.js';
1
+ import '../icon/icon.js';
2
+ import { FormBase } from '../../internal/components/formBase.js';
3
+ import type { FormFieldBaseProps } from '../../internal/types/formField.js';
4
4
  import { type CSSResultGroup } from 'lit';
5
5
  /**
6
6
  * The `<skf-checkbox>` component is used to create a checkbox input
7
7
  *
8
- * @documentation See [InVision DSM](https://skf.invisionapp.com/dsm/ab-skf/4-web-applications/nav/5fa7caf78c01200018354495/asset/6229d63d9fe16020a60657e5) for design principles
8
+ * @documentation See [zeroheight](https://zeroheight.com/853e936c9/p/94464f-checkbox) for design principles
9
9
  *
10
10
  * @attribute {boolean} disabled - If true, sets disabled state
11
11
  * @attribute {boolean} required - If true, value is required or must be checked for the form to be submittable
12
12
  *
13
13
  * @event change {object} - When the value of the input changes
14
14
  *
15
- * @slot Default - Alternatively, you can use the `label` attribute
15
+ * @slot - The Radios label. Alternatively, you can use the `label` attribute.
16
16
  *
17
17
  * @tagname skf-checkbox
18
18
  */
19
19
  export declare class SkfCheckbox extends FormBase implements FormFieldBaseProps {
20
20
  static styles: CSSResultGroup;
21
- /** @internal */
22
- private _initialChecked;
21
+ /**
22
+ * @internal
23
+ * Initial state saved here as default for form resets.
24
+ */
25
+ private _initiallyChecked;
23
26
  /** If defined, outputs helping hints in console */
24
27
  debug?: boolean;
25
28
  /** If true, outputs helping hints in console */
26
29
  checked?: boolean;
27
30
  /** If true, forces component to invalid state until removed */
28
31
  customInvalid?: boolean;
29
- /** If true, hides the label visually */
30
- hideLabel?: boolean;
31
32
  /** If true and the checkbox is unchecked, the checkbox will appear indeterminate */
32
33
  indeterminate?: boolean;
33
34
  /** If defined, sets the input's label. Alternatively, you can use the `label` attribute. */
@@ -36,12 +37,15 @@ export declare class SkfCheckbox extends FormBase implements FormFieldBaseProps
36
37
  name?: string;
37
38
  /** If defined, renders an alternative A11y text for the asterisk */
38
39
  requiredLabel?: string;
39
- /** Size of the checkbox */
40
- size: 'sm' | 'md';
41
- /** If defined, styles checkbox using provided severity */
40
+ /**
41
+ * If defined, styles checkbox using provided severity
42
+ * @type { "alert" | "success" | "info" | "warning" }
43
+ */
42
44
  severity?: FormFieldBaseProps['severity'];
43
- /** If defined, displays valid state after interaction */
45
+ /** If true, displays valid state after interaction */
44
46
  showValid?: boolean;
47
+ /** Size of the checkbox */
48
+ size: 'sm' | 'md';
45
49
  /** The current value of the input field */
46
50
  value: string;
47
51
  /** @internal */
@@ -49,12 +53,10 @@ export declare class SkfCheckbox extends FormBase implements FormFieldBaseProps
49
53
  private _invalid;
50
54
  /** @internal */
51
55
  private $input?;
52
- connectedCallback(): void;
53
- willUpdate(changedProperties: Map<string | number | symbol, unknown>): void;
56
+ handleInvalidChange(): void;
57
+ handleDebugInvalid(): void;
58
+ handleCustomInvalidChange(): void;
54
59
  protected firstUpdated(): void;
55
- updated(changedProperties: Map<string | number | symbol, unknown>): void;
56
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
57
- debugOutput(): void;
58
60
  /** @internal */
59
61
  private _validateInput;
60
62
  /** @internal */
@@ -1,68 +1,68 @@
1
1
  import "../icon/icon.js";
2
- import { FormBase as p } from "../../internal/components/formBase.js";
3
- import { Asterisk as c } from "../../internal/templates/asterisk.js";
4
- import v from "../../styles/component.styles.js";
5
- import { html as u, nothing as m } from "lit";
6
- import { property as s, state as f, query as y } from "lit/decorators.js";
2
+ import { FormBase as c } from "../../internal/components/formBase.js";
3
+ import { watch as h } from "../../internal/helpers/watch.js";
4
+ import { Asterisk as v } from "../../internal/templates/asterisk.js";
5
+ import m from "../../styles/component.styles.js";
6
+ import { html as p, nothing as y } from "lit";
7
+ import { property as r, state as f, query as _ } from "lit/decorators.js";
7
8
  import { ifDefined as b } from "lit/directives/if-defined.js";
8
- import _ from "./checkbox.styles.js";
9
- var k = Object.defineProperty, i = (n, t, r, a) => {
10
- for (var l = void 0, o = n.length - 1, d; o >= 0; o--)
11
- (d = n[o]) && (l = d(t, r, l) || l);
12
- return l && k(t, r, l), l;
9
+ import g from "./checkbox.styles.js";
10
+ var $ = Object.defineProperty, I = Object.getOwnPropertyDescriptor, e = (u, i, s, a) => {
11
+ for (var l = a > 1 ? void 0 : a ? I(i, s) : i, o = u.length - 1, n; o >= 0; o--)
12
+ (n = u[o]) && (l = (a ? n(i, s, l) : n(l)) || l);
13
+ return a && l && $(i, s, l), l;
13
14
  };
14
- const h = class h extends p {
15
+ const d = class d extends c {
15
16
  constructor() {
16
- super(...arguments), this._initialChecked = !1, this.size = "md", this.value = "", this._invalid = !1, this._resetValue = (t) => {
17
- t.stopPropagation(), this.checked = this._initialChecked, this.$input && (this.$input.checked = !!this._initialChecked), this.setFormValue(this.checked ? this.value : null);
18
- }, this._renderIcon = (t) => u`
19
- <skf-icon color="inverse" name=${t} size=${this.size === "sm" ? "sm" : "md"}></skf-icon>
17
+ super(...arguments), this._initiallyChecked = !1, this.size = "md", this.value = "", this._invalid = !1, this._resetValue = (i) => {
18
+ i.stopPropagation(), this.checked = this._initiallyChecked, this.$input && (this.$input.checked = !!this._initiallyChecked), this.setFormValue(this.checked ? this.value : null);
19
+ }, this._renderIcon = (i) => p`
20
+ <skf-icon color="inverse" name=${i} size=${this.size === "sm" ? "sm" : "md"}></skf-icon>
20
21
  `;
21
22
  }
22
- connectedCallback() {
23
- super.connectedCallback(), this._validateInput();
23
+ handleInvalidChange() {
24
+ this._invalid ? (this.setAttribute("invalid", ""), this.showValid && this.removeAttribute("valid"), this.checkValidity()) : (this.removeAttribute("invalid"), !this.pristine && this.showValid && this.setAttribute("valid", "true"));
24
25
  }
25
- willUpdate(t) {
26
- t.has("_invalid") && (this._invalid ? (this.setAttribute("invalid", ""), this.showValid && this.removeAttribute("valid"), this.checkValidity()) : (this.removeAttribute("invalid"), !this.pristine && this.showValid && this.setAttribute("valid", "true")));
26
+ handleDebugInvalid() {
27
+ this._invalid && this.debug && !this.validity.valid && console.log(`Checkbox invalidity reason: ${this.validationMessage}`);
28
+ }
29
+ handleCustomInvalidChange() {
30
+ if (this.customInvalid) {
31
+ const s = (
32
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
33
+ this.getAttribute("data-customerror") || "Set a custom error message using the data-customerror attribute"
34
+ );
35
+ this.pristine = !1, this._invalid = !0, this.setValidity({ customError: !0 }, s), this.checkValidity();
36
+ } else
37
+ this.setValidity({}), this._validateInput();
27
38
  }
28
39
  firstUpdated() {
29
- var t;
30
- (t = this.$input) == null || t.addEventListener("change", (r) => {
40
+ var i;
41
+ (i = this.$input) == null || i.addEventListener("change", (s) => {
31
42
  var a;
32
- r.stopPropagation(), this.pristine = !1, this.checked = (a = this.$input) == null ? void 0 : a.checked, this._validateInput(), this.checked ? (this.indeterminate = !1, this.setFormValue(this.value)) : this.setFormValue(null), this.emitEvent("change");
33
- }), this.addEventListener("invalid", (r) => {
34
- this.pristine = !1, this._invalid = !0, this.customErrorDisplay && r.preventDefault();
35
- }), this._initialChecked = this.checked, this.addEventListener("reset", this._resetValue);
36
- }
37
- updated(t) {
38
- super.updated(t), t.has("_invalid") && this._invalid && this.debug && this.debugOutput();
39
- }
40
- attributeChangedCallback(t, r, a) {
41
- if (super.attributeChangedCallback(t, r, a), t === "custom-invalid")
42
- if (typeof a == "string") {
43
- const o = String(a).trim() || "Custom error";
44
- this.pristine = !1, this._invalid = !0, this.setValidity({ customError: !0 }, o), this.checkValidity();
45
- } else
46
- this.setValidity({}), this._validateInput();
47
- }
48
- debugOutput() {
49
- this.debug && !this.validity.valid && console.log(`Checkbox invalidity reason: ${this.validationMessage}`);
43
+ s.stopPropagation(), this.pristine = !1, this.checked = (a = this.$input) == null ? void 0 : a.checked, this._validateInput(), this.checked ? (this.indeterminate = !1, this.setFormValue(this.value)) : this.setFormValue(null), this.emitEvent("change");
44
+ }), this.addEventListener("invalid", (s) => {
45
+ this.pristine = !1, this._invalid = !0, this.customErrorDisplay && s.preventDefault();
46
+ }), this._initiallyChecked = this.checked, this.addEventListener("reset", this._resetValue), this._validateInput();
50
47
  }
51
48
  /** @internal */
52
49
  _validateInput() {
53
- var t;
50
+ var i;
54
51
  if (this._invalid = !1, this.customInvalid)
55
52
  this.setValidity({ customError: !0 }, "Custom error"), this._invalid = !0;
56
53
  else if (this.required && !this.checked) {
57
54
  this.pristine || (this._invalid = !0);
58
- const r = this.hasAttribute("data-valuemissing") ? this.getAttribute("data-valuemissing") : ((t = this.$input) == null ? void 0 : t.validationMessage) ?? "Please check this box if you want to proceed";
59
- this.setValidity({ valueMissing: !0 }, String(r));
55
+ const s = this.hasAttribute("data-valuemissing") ? this.getAttribute("data-valuemissing") : (
56
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
57
+ ((i = this.$input) == null ? void 0 : i.validationMessage) || "Please check this box if you want to proceed"
58
+ );
59
+ this.setValidity({ valueMissing: !0 }, String(s));
60
60
  } else
61
61
  this.setValidity({});
62
62
  }
63
63
  render() {
64
- return u`
65
- <label id="checkbox">
64
+ return p`
65
+ <label id="root">
66
66
  <input
67
67
  ?checked=${this.checked}
68
68
  ?disabled=${this.disabled}
@@ -76,56 +76,62 @@ const h = class h extends p {
76
76
  ${this._renderIcon("check")} ${this._renderIcon("removeMinus")}
77
77
  <div id="label">
78
78
  <slot>${this.label}</slot>
79
- ${this.required ? c(this.requiredLabel) : m}
79
+ ${this.required ? v(this.requiredLabel) : y}
80
80
  </div>
81
81
  </label>
82
82
  `;
83
83
  }
84
84
  };
85
- h.styles = [v, _];
86
- let e = h;
87
- i([
88
- s({ type: Boolean })
89
- ], e.prototype, "debug");
90
- i([
91
- s({ type: Boolean, reflect: !0 })
92
- ], e.prototype, "checked");
93
- i([
94
- s({ type: Boolean, attribute: "custom-invalid" })
95
- ], e.prototype, "customInvalid");
96
- i([
97
- s({ type: Boolean, attribute: "hide-label", reflect: !0 })
98
- ], e.prototype, "hideLabel");
99
- i([
100
- s({ type: Boolean, reflect: !0 })
101
- ], e.prototype, "indeterminate");
102
- i([
103
- s()
104
- ], e.prototype, "label");
105
- i([
106
- s()
107
- ], e.prototype, "name");
108
- i([
109
- s({ attribute: "required-label" })
110
- ], e.prototype, "requiredLabel");
111
- i([
112
- s({ reflect: !0 })
113
- ], e.prototype, "size");
114
- i([
115
- s({ reflect: !0 })
116
- ], e.prototype, "severity");
117
- i([
118
- s({ type: Boolean, attribute: "show-valid" })
119
- ], e.prototype, "showValid");
120
- i([
121
- s()
122
- ], e.prototype, "value");
123
- i([
85
+ d.styles = [m, g];
86
+ let t = d;
87
+ e([
88
+ r({ type: Boolean })
89
+ ], t.prototype, "debug", 2);
90
+ e([
91
+ r({ type: Boolean, reflect: !0 })
92
+ ], t.prototype, "checked", 2);
93
+ e([
94
+ r({ type: Boolean, attribute: "custom-invalid", reflect: !0 })
95
+ ], t.prototype, "customInvalid", 2);
96
+ e([
97
+ r({ type: Boolean, reflect: !0 })
98
+ ], t.prototype, "indeterminate", 2);
99
+ e([
100
+ r()
101
+ ], t.prototype, "label", 2);
102
+ e([
103
+ r()
104
+ ], t.prototype, "name", 2);
105
+ e([
106
+ r({ attribute: "required-label" })
107
+ ], t.prototype, "requiredLabel", 2);
108
+ e([
109
+ r({ reflect: !0 })
110
+ ], t.prototype, "severity", 2);
111
+ e([
112
+ r({ type: Boolean, attribute: "show-valid" })
113
+ ], t.prototype, "showValid", 2);
114
+ e([
115
+ r({ reflect: !0 })
116
+ ], t.prototype, "size", 2);
117
+ e([
118
+ r()
119
+ ], t.prototype, "value", 2);
120
+ e([
124
121
  f()
125
- ], e.prototype, "_invalid");
126
- i([
127
- y("input")
128
- ], e.prototype, "$input");
122
+ ], t.prototype, "_invalid", 2);
123
+ e([
124
+ _("input")
125
+ ], t.prototype, "$input", 2);
126
+ e([
127
+ h("_invalid")
128
+ ], t.prototype, "handleInvalidChange", 1);
129
+ e([
130
+ h("_invalid", { afterUpdate: !0 })
131
+ ], t.prototype, "handleDebugInvalid", 1);
132
+ e([
133
+ h("customInvalid")
134
+ ], t.prototype, "handleCustomInvalidChange", 1);
129
135
  export {
130
- e as SkfCheckbox
136
+ t as SkfCheckbox
131
137
  };
@@ -8,12 +8,17 @@ const i = [
8
8
  contain: initial;
9
9
  }
10
10
 
11
- #checkbox {
11
+ #root {
12
12
  align-items: center;
13
+ color: var(--_skf-checkbox-color, var(--skf-text-color-primary));
13
14
  display: grid;
14
15
  grid-gap: var(--skf-spacing-50);
15
16
  grid-template: 'input label' / auto minmax(0, 1fr);
16
17
 
18
+ :host([disabled]) & {
19
+ --_skf-checkbox-color: var(--skf-interactive-text-color-disabled);
20
+ }
21
+
17
22
  :host([size='sm']) & {
18
23
  --_skf-checkbox-size: var(--skf-size-20);
19
24
 
@@ -57,7 +62,7 @@ const i = [
57
62
  }
58
63
 
59
64
  :host([valid]) & {
60
- --_skf-checkbox-border-color: var(--skf-severity-fg-color-error);
65
+ --_skf-checkbox-border-color: var(--skf-severity-fg-color-success);
61
66
  }
62
67
 
63
68
  :host([severity='alert']:not([invalid], [valid])) & {
@@ -0,0 +1 @@
1
+ export {};