scb-wc 0.1.129 → 0.1.131

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.
@@ -1,5 +1,20 @@
1
- import{h as m,m as v,p as c,v as y,y as k}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as a}from"../../vendor/decorate.js";import{n as x,t as n}from"../../vendor/assertClassBrand.js";import{n as _,r as S,t as g}from"../../vendor/classPrivateFieldGet2.js";(function(){try{var s=typeof globalThis<"u"?globalThis:window;if(!s.__scb_ce_guard_installed__){s.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(o,p,e){try{customElements.get(o)||t(o,p,e)}catch(u){var h=String(u||"");if(h.indexOf("already been used")===-1&&h.indexOf("NotSupportedError")===-1)throw u}}}}catch{}})();var l,r,d,i=(l=new WeakMap,r=new WeakSet,d=class extends m{constructor(...t){super(...t),x(this,r),S(this,l,void 0),this.orientation="vertical",this.disabled=!1,this.size="medium",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,_(l,this,()=>{const o=this.shadowRoot?.querySelector("slot");if(!o)return;const p=o.assignedElements({flatten:!0}).filter(e=>e.tagName.toLowerCase()==="scb-checkbox");for(const e of p){this.disabled?e.setAttribute("disabled",""):e.removeAttribute("disabled"),this.orientation==="horizontal"?e.setAttribute("orientation","horizontal"):e.removeAttribute("orientation");const h=e.hasAttribute("data-size-from-group");this.size==="medium"?h&&(e.removeAttribute("size"),e.removeAttribute("data-size-from-group")):(!e.hasAttribute("size")||h)&&(e.setAttribute("size",this.size),e.setAttribute("data-size-from-group",""))}})}render(){const t=this.orientation==="horizontal"?"row":"column";return y`
2
- <div class="g" role="group" aria-disabled=${String(this.disabled)} style=${`--_dir:${t}`}>
3
- <slot @slotchange=${g(l,this)}></slot>
1
+ import{g as f,h as V,m as M,p as n,v as y,y as C}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import"../../vendor/icon.js";import{t as a}from"../../vendor/decorate.js";import{n as A,t as s}from"../../vendor/assertClassBrand.js";import{n as x,r as k,t as c}from"../../vendor/classPrivateFieldGet2.js";(function(){try{var r=typeof globalThis<"u"?globalThis:window;if(!r.__scb_ce_guard_installed__){r.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,l,g){try{customElements.get(e)||t(e,l,g)}catch(S){var _=String(S||"");if(_.indexOf("already been used")===-1&&_.indexOf("NotSupportedError")===-1)throw S}}}}catch{}})();var p,u,i,d,v,o=(p=new WeakMap,u=new WeakMap,i=new WeakSet,d=new WeakMap,v=class extends V{constructor(){super(),A(this,i),k(this,p,void 0),k(this,u,void 0),k(this,d,void 0),this.name="",this.orientation="vertical",this.disabled=!1,this.required=!1,this.error=!1,this.ariaLabel=null,this.supportingText="",this.errorText="",this.size="medium",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._internals=null,this._form=null,this._formResetHandler=null,this._formSubmitHandler=null,this._initialChecked=new WeakMap,this._customValidationMessage="",this._validationMessage="",this._hasValidationBeenReported=!1,this._supportingTextId=`scb-checkbox-group-supporting-${Math.random().toString(36).slice(2,11)}`,x(p,this,()=>{const t=c(u,this).call(this);for(const e of t){s(i,this,T).call(this,e),this.disabled?e.setAttribute("disabled",""):e.removeAttribute("disabled"),this.orientation==="horizontal"?e.setAttribute("orientation","horizontal"):e.removeAttribute("orientation");const l=e.hasAttribute("data-size-from-group");this.size==="medium"?l&&(e.removeAttribute("size"),e.removeAttribute("data-size-from-group")):(!e.hasAttribute("size")||l)&&(e.setAttribute("size",this.size),e.setAttribute("data-size-from-group",""))}s(i,this,z).call(this),s(i,this,b).call(this),s(i,this,h).call(this)}),x(u,this,()=>{const t=this.shadowRoot?.querySelector("slot");return t?t.assignedElements({flatten:!0}).filter(e=>e.tagName.toLowerCase()==="scb-checkbox"):[]}),x(d,this,t=>{t.target!==this&&t.composedPath().find(e=>e?.tagName?.toLowerCase()==="scb-checkbox")&&(s(i,this,b).call(this),s(i,this,h).call(this))}),"attachInternals"in this&&(this._internals=this.attachInternals())}render(){const t=this.orientation==="horizontal"?"row":"column",e=s(i,this,L).call(this);return y`
2
+ <div
3
+ class="g"
4
+ role="group"
5
+ aria-disabled=${String(this.disabled)}
6
+ aria-required=${String(this.required)}
7
+ aria-invalid=${this.error?"true":"false"}
8
+ aria-describedby=${e?this._supportingTextId:f}
9
+ aria-label=${this.ariaLabel??f}
10
+ style=${`--_dir:${t}`}
11
+ >
12
+ <slot @slotchange=${c(p,this)}></slot>
4
13
  </div>
5
- `}firstUpdated(){n(r,this,f).call(this),g(l,this).call(this)}updated(t){(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&n(r,this,f).call(this),(t.has("disabled")||t.has("orientation")||t.has("size"))&&g(l,this).call(this)}},d.styles=k`:host{display:block;--scb-checkbox-gap:var(--spacing-4, 12px);margin-block-start:var(--scb-checkbox-group-spacing-block-start, 0);margin-block-end:var(--scb-checkbox-group-spacing-block-end, 0);margin-inline-start:var(--scb-checkbox-group-spacing-inline-start, 0);margin-inline-end:var(--scb-checkbox-group-spacing-inline-end, 0)}:host([orientation='horizontal']){--scb-checkbox-gap:var(--spacing-8, 32px)}.g{display:flex;flex-direction:var(--_dir, column);align-items:flex-start;gap:var(--scb-checkbox-gap)}::slotted(scb-checkbox){--scb-checkbox-gap:0}`,d);function f(){const s=n(r,this,b).call(this,this.spacing),t=n(r,this,b).call(this,this.spacingTop)??s,o=n(r,this,b).call(this,this.spacingBottom)??s,p=n(r,this,b).call(this,this.spacingLeft),e=n(r,this,b).call(this,this.spacingRight);t?this.style.setProperty("--scb-checkbox-group-spacing-block-start",t):this.style.removeProperty("--scb-checkbox-group-spacing-block-start"),o?this.style.setProperty("--scb-checkbox-group-spacing-block-end",o):this.style.removeProperty("--scb-checkbox-group-spacing-block-end"),p?this.style.setProperty("--scb-checkbox-group-spacing-inline-start",p):this.style.removeProperty("--scb-checkbox-group-spacing-inline-start"),e?this.style.setProperty("--scb-checkbox-group-spacing-inline-end",e):this.style.removeProperty("--scb-checkbox-group-spacing-inline-end")}function b(s){if(!s)return;const t=String(s).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}a([c({type:String,reflect:!0})],i.prototype,"orientation",void 0);a([c({type:Boolean,reflect:!0})],i.prototype,"disabled",void 0);a([c({type:String,reflect:!0})],i.prototype,"size",void 0);a([c({type:String,reflect:!0})],i.prototype,"spacing",void 0);a([c({type:String,attribute:"spacing-top",reflect:!0})],i.prototype,"spacingTop",void 0);a([c({type:String,attribute:"spacing-bottom",reflect:!0})],i.prototype,"spacingBottom",void 0);a([c({type:String,attribute:"spacing-left",reflect:!0})],i.prototype,"spacingLeft",void 0);a([c({type:String,attribute:"spacing-right",reflect:!0})],i.prototype,"spacingRight",void 0);i=a([v("scb-checkbox-group")],i);
14
+ ${e?y`
15
+ <div id=${this._supportingTextId} class="supporting-text">
16
+ <span>${e}</span>
17
+ ${this.error?y`<md-icon aria-hidden="true">error</md-icon>`:f}
18
+ </div>
19
+ `:f}
20
+ `}firstUpdated(){s(i,this,w).call(this),c(p,this).call(this),s(i,this,z).call(this),this.addEventListener("input",c(d,this)),this.addEventListener("change",c(d,this)),this._form=this.closest("form"),this._form&&(this._formResetHandler=()=>{for(const t of c(u,this).call(this))t.checked=this._initialChecked.get(t)??t.hasAttribute("checked");this.error=!1,this._hasValidationBeenReported=!1,c(p,this).call(this),s(i,this,b).call(this),s(i,this,h).call(this)},this._formSubmitHandler=t=>{this.reportValidity()||(t.preventDefault(),t.stopPropagation())},this._form.addEventListener("reset",this._formResetHandler,!0),this._form.addEventListener("submit",this._formSubmitHandler,!0)),s(i,this,b).call(this),s(i,this,h).call(this)}disconnectedCallback(){this.removeEventListener("input",c(d,this)),this.removeEventListener("change",c(d,this)),this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),this._form&&this._formSubmitHandler&&this._form.removeEventListener("submit",this._formSubmitHandler,!0),super.disconnectedCallback()}updated(t){(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&s(i,this,w).call(this),(t.has("name")||t.has("disabled")||t.has("orientation")||t.has("size")||t.has("required"))&&c(p,this).call(this),(t.has("disabled")||t.has("name"))&&s(i,this,b).call(this),(t.has("disabled")||t.has("required")||t.has("errorText"))&&s(i,this,h).call(this)}get form(){return this._internals?.form??this._form}get validity(){return this._internals?.validity}get validationMessage(){return this._internals?.validationMessage||this._validationMessage}get willValidate(){return this._internals?.willValidate??!this.disabled}get labels(){return this._internals?.labels}checkValidity(){return s(i,this,h).call(this),this._internals?.checkValidity()??!this.error}reportValidity(){return this._hasValidationBeenReported=!0,s(i,this,h).call(this),this._internals?.reportValidity()??!this.error}setCustomValidity(t){this._customValidationMessage=String(t??""),s(i,this,h).call(this)}formDisabledCallback(t){this.disabled=t,t&&(this._hasValidationBeenReported=!1),s(i,this,h).call(this)}},v.formAssociated=!0,v.styles=C`:host{display:block;--scb-checkbox-gap:var(--spacing-4, 12px);margin-block-start:var(--scb-checkbox-group-spacing-block-start, 0);margin-block-end:var(--scb-checkbox-group-spacing-block-end, 0);margin-inline-start:var(--scb-checkbox-group-spacing-inline-start, 0);margin-inline-end:var(--scb-checkbox-group-spacing-inline-end, 0);--scb-checkbox-group-supporting-font-size:var(--md-sys-typescale-body-medium-size, 16px);--scb-checkbox-group-supporting-line-height:var(--md-sys-typescale-body-medium-line-height, 24px);--scb-checkbox-group-supporting-tracking:var(--md-sys-typescale-body-medium-tracking, 0);--scb-checkbox-group-supporting-weight:var(--md-sys-typescale-body-medium-weight, var(--weight-regular, 400));--scb-checkbox-group-error-icon-size:var(--icon-size-small, 20px)}:host([orientation='horizontal']){--scb-checkbox-gap:var(--spacing-8, 32px)}:host([size='small']){--scb-checkbox-group-supporting-font-size:var(--md-sys-typescale-body-small-size, 14px);--scb-checkbox-group-supporting-line-height:var(--md-sys-typescale-body-small-line-height, 20px);--scb-checkbox-group-supporting-tracking:var(--md-sys-typescale-body-small-tracking, 0);--scb-checkbox-group-supporting-weight:var(--md-sys-typescale-body-small-weight, var(--weight-regular, 400));--scb-checkbox-group-error-icon-size:var(--icon-size-extra-small, 16px)}:host([size='large']){--scb-checkbox-group-supporting-font-size:var(--md-sys-typescale-body-large-size, 18px);--scb-checkbox-group-supporting-line-height:var(--md-sys-typescale-body-large-line-height, 26px);--scb-checkbox-group-supporting-tracking:var(--md-sys-typescale-body-large-tracking, 0);--scb-checkbox-group-supporting-weight:var(--md-sys-typescale-body-large-weight, var(--weight-regular, 400));--scb-checkbox-group-error-icon-size:var(--icon-size-medium, 24px)}.g{display:flex;flex-direction:var(--_dir, column);align-items:flex-start;gap:var(--scb-checkbox-gap)}.supporting-text{display:block;margin-block-start:var(--spacing-3, 8px);color:var(--md-sys-color-on-surface-variant);font-family:var(--brand-font, 'Inter', sans-serif);font-size:var(--scb-checkbox-group-supporting-font-size);line-height:var(--scb-checkbox-group-supporting-line-height);font-weight:var(--scb-checkbox-group-supporting-weight);letter-spacing:var(--scb-checkbox-group-supporting-tracking)}.supporting-text md-icon{display:inline-flex;color:var(--md-sys-color-error);--md-icon-size:var(--scb-checkbox-group-error-icon-size);font-size:var(--scb-checkbox-group-error-icon-size);line-height:1;margin-inline-start:var(--spacing-2, 4px);vertical-align:-.18em}:host([error]) .supporting-text{color:var(--md-sys-color-error)}::slotted(scb-checkbox){--scb-checkbox-gap:0}:host([error]) ::slotted(scb-checkbox){--md-checkbox-outline-color:var(--md-sys-color-error);--md-checkbox-hover-outline-color:var(--md-sys-color-error);--md-checkbox-focus-outline-color:var(--md-sys-color-error);--md-checkbox-pressed-outline-color:var(--md-sys-color-error)}`,v);function T(r){const t=r.hasAttribute("data-name-from-group");this.name?(!r.hasAttribute("name")||t)&&(r.setAttribute("name",this.name),r.setAttribute("data-name-from-group","")):t&&(r.removeAttribute("name"),r.removeAttribute("data-name-from-group"))}function z(){for(const r of c(u,this).call(this))this._initialChecked.has(r)||this._initialChecked.set(r,r.checked===!0||r.hasAttribute("checked"))}function E(){return c(u,this).call(this).some(r=>r.checked===!0)}function h(){const r=!this.disabled&&this.required&&!s(i,this,E).call(this),t=this.disabled?"":this._customValidationMessage||(r?this.errorText||"Välj minst ett alternativ.":""),e=this.error,l=this._validationMessage;if(this._internals){const g=t?this._customValidationMessage?{customError:!0}:{valueMissing:!0}:{};this._internals.setValidity(g,t,this.shadowRoot?.querySelector(".g")??void 0)}this._validationMessage=t,this.error=this.disabled?!1:t?this._hasValidationBeenReported||e:e&&!this._hasValidationBeenReported&&!l,this.toggleAttribute("aria-invalid",this.error),(e!==this.error||l!==this._validationMessage)&&this.requestUpdate()}function L(){return this.error?this._validationMessage||this.errorText||"Ogiltigt val.":this.supportingText}function b(){this._internals&&this._internals.setFormValue(null)}function w(){const r=s(i,this,m).call(this,this.spacing),t=s(i,this,m).call(this,this.spacingTop)??r,e=s(i,this,m).call(this,this.spacingBottom)??r,l=s(i,this,m).call(this,this.spacingLeft),g=s(i,this,m).call(this,this.spacingRight);t?this.style.setProperty("--scb-checkbox-group-spacing-block-start",t):this.style.removeProperty("--scb-checkbox-group-spacing-block-start"),e?this.style.setProperty("--scb-checkbox-group-spacing-block-end",e):this.style.removeProperty("--scb-checkbox-group-spacing-block-end"),l?this.style.setProperty("--scb-checkbox-group-spacing-inline-start",l):this.style.removeProperty("--scb-checkbox-group-spacing-inline-start"),g?this.style.setProperty("--scb-checkbox-group-spacing-inline-end",g):this.style.removeProperty("--scb-checkbox-group-spacing-inline-end")}function m(r){if(!r)return;const t=String(r).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}a([n({type:String})],o.prototype,"name",void 0);a([n({type:String,reflect:!0})],o.prototype,"orientation",void 0);a([n({type:Boolean,reflect:!0})],o.prototype,"disabled",void 0);a([n({type:Boolean,reflect:!0})],o.prototype,"required",void 0);a([n({type:Boolean,reflect:!0})],o.prototype,"error",void 0);a([n({type:String,attribute:"aria-label"})],o.prototype,"ariaLabel",void 0);a([n({type:String,attribute:"supporting-text"})],o.prototype,"supportingText",void 0);a([n({type:String,attribute:"error-text"})],o.prototype,"errorText",void 0);a([n({type:String,reflect:!0})],o.prototype,"size",void 0);a([n({type:String,reflect:!0})],o.prototype,"spacing",void 0);a([n({type:String,attribute:"spacing-top",reflect:!0})],o.prototype,"spacingTop",void 0);a([n({type:String,attribute:"spacing-bottom",reflect:!0})],o.prototype,"spacingBottom",void 0);a([n({type:String,attribute:"spacing-left",reflect:!0})],o.prototype,"spacingLeft",void 0);a([n({type:String,attribute:"spacing-right",reflect:!0})],o.prototype,"spacingRight",void 0);o=a([M("scb-checkbox-group")],o);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scb-wc",
3
- "version": "0.1.129",
3
+ "version": "0.1.131",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -472,5 +472,5 @@
472
472
  },
473
473
  "./mvc/*": "./mvc/*"
474
474
  },
475
- "buildHash": "EC1B3CCF9970F32B80DBFF7CA20CDC58781F126F37A933658BA0A3267AA0EF2A"
475
+ "buildHash": "74D54EE59309B4A054E039954535E2150D5A883613C47504A1D732332E180E9E"
476
476
  }
@@ -1,19 +1,27 @@
1
1
  import { __decorate as e } from "../_virtual/_@oxc-project_runtime@0.126.0/helpers/decorate.js";
2
- import { LitElement as t, css as n, html as r } from "lit";
3
- import { customElement as i, property as a } from "lit/decorators.js";
2
+ import { LitElement as t, css as n, html as r, nothing as i } from "lit";
3
+ import { customElement as a, property as o } from "lit/decorators.js";
4
+ import "@material/web/icon/icon.js";
4
5
  //#region src/scb-components/scb-checkbox/scb-checkbox-group.ts
5
- var o = class extends t {
6
- constructor(...e) {
7
- super(...e), this.orientation = "vertical", this.disabled = !1, this.size = "medium", this.spacing = void 0, this.spacingTop = void 0, this.spacingBottom = void 0, this.spacingLeft = void 0, this.spacingRight = void 0, this.#e = () => {
8
- let e = this.shadowRoot?.querySelector("slot");
9
- if (!e) return;
10
- let t = e.assignedElements({ flatten: !0 }).filter((e) => e.tagName.toLowerCase() === "scb-checkbox");
11
- for (let e of t) {
12
- this.disabled ? e.setAttribute("disabled", "") : e.removeAttribute("disabled"), this.orientation === "horizontal" ? e.setAttribute("orientation", "horizontal") : e.removeAttribute("orientation");
13
- let t = e.hasAttribute("data-size-from-group");
14
- this.size === "medium" ? t && (e.removeAttribute("size"), e.removeAttribute("data-size-from-group")) : (!e.hasAttribute("size") || t) && (e.setAttribute("size", this.size), e.setAttribute("data-size-from-group", ""));
6
+ var s = class extends t {
7
+ static {
8
+ this.formAssociated = !0;
9
+ }
10
+ constructor() {
11
+ super(), this.name = "", this.orientation = "vertical", this.disabled = !1, this.required = !1, this.error = !1, this.ariaLabel = null, this.supportingText = "", this.errorText = "", this.size = "medium", this.spacing = void 0, this.spacingTop = void 0, this.spacingBottom = void 0, this.spacingLeft = void 0, this.spacingRight = void 0, this._internals = null, this._form = null, this._formResetHandler = null, this._formSubmitHandler = null, this._initialChecked = /* @__PURE__ */ new WeakMap(), this._customValidationMessage = "", this._validationMessage = "", this._hasValidationBeenReported = !1, this._supportingTextId = `scb-checkbox-group-supporting-${Math.random().toString(36).slice(2, 11)}`, this.#e = () => {
12
+ let e = this.#t();
13
+ for (let t of e) {
14
+ this.#n(t), this.disabled ? t.setAttribute("disabled", "") : t.removeAttribute("disabled"), this.orientation === "horizontal" ? t.setAttribute("orientation", "horizontal") : t.removeAttribute("orientation");
15
+ let e = t.hasAttribute("data-size-from-group");
16
+ this.size === "medium" ? e && (t.removeAttribute("size"), t.removeAttribute("data-size-from-group")) : (!t.hasAttribute("size") || e) && (t.setAttribute("size", this.size), t.setAttribute("data-size-from-group", ""));
15
17
  }
16
- };
18
+ this.#r(), this.#c(), this.#o();
19
+ }, this.#t = () => {
20
+ let e = this.shadowRoot?.querySelector("slot");
21
+ return e ? e.assignedElements({ flatten: !0 }).filter((e) => e.tagName.toLowerCase() === "scb-checkbox") : [];
22
+ }, this.#i = (e) => {
23
+ e.target !== this && e.composedPath().find((e) => e?.tagName?.toLowerCase() === "scb-checkbox") && (this.#c(), this.#o());
24
+ }, "attachInternals" in this && (this._internals = this.attachInternals());
17
25
  }
18
26
  static {
19
27
  this.styles = n`
@@ -26,6 +34,12 @@ var o = class extends t {
26
34
  margin-block-end: var(--scb-checkbox-group-spacing-block-end, 0);
27
35
  margin-inline-start: var(--scb-checkbox-group-spacing-inline-start, 0);
28
36
  margin-inline-end: var(--scb-checkbox-group-spacing-inline-end, 0);
37
+
38
+ --scb-checkbox-group-supporting-font-size: var(--md-sys-typescale-body-medium-size, 16px);
39
+ --scb-checkbox-group-supporting-line-height: var(--md-sys-typescale-body-medium-line-height, 24px);
40
+ --scb-checkbox-group-supporting-tracking: var(--md-sys-typescale-body-medium-tracking, 0);
41
+ --scb-checkbox-group-supporting-weight: var(--md-sys-typescale-body-medium-weight, var(--weight-regular, 400));
42
+ --scb-checkbox-group-error-icon-size: var(--icon-size-small, 20px);
29
43
  }
30
44
 
31
45
  /* Horisontell standard-spacing mellan items om spacing för gruppen inte overrideas via CSS-variabel */
@@ -33,6 +47,22 @@ var o = class extends t {
33
47
  --scb-checkbox-gap: var(--spacing-8, 32px);
34
48
  }
35
49
 
50
+ :host([size='small']) {
51
+ --scb-checkbox-group-supporting-font-size: var(--md-sys-typescale-body-small-size, 14px);
52
+ --scb-checkbox-group-supporting-line-height: var(--md-sys-typescale-body-small-line-height, 20px);
53
+ --scb-checkbox-group-supporting-tracking: var(--md-sys-typescale-body-small-tracking, 0);
54
+ --scb-checkbox-group-supporting-weight: var(--md-sys-typescale-body-small-weight, var(--weight-regular, 400));
55
+ --scb-checkbox-group-error-icon-size: var(--icon-size-extra-small, 16px);
56
+ }
57
+
58
+ :host([size='large']) {
59
+ --scb-checkbox-group-supporting-font-size: var(--md-sys-typescale-body-large-size, 18px);
60
+ --scb-checkbox-group-supporting-line-height: var(--md-sys-typescale-body-large-line-height, 26px);
61
+ --scb-checkbox-group-supporting-tracking: var(--md-sys-typescale-body-large-tracking, 0);
62
+ --scb-checkbox-group-supporting-weight: var(--md-sys-typescale-body-large-weight, var(--weight-regular, 400));
63
+ --scb-checkbox-group-error-icon-size: var(--icon-size-medium, 24px);
64
+ }
65
+
36
66
  .g {
37
67
  display: flex;
38
68
  flex-direction: var(--_dir, column);
@@ -40,65 +70,188 @@ var o = class extends t {
40
70
  gap: var(--scb-checkbox-gap);
41
71
  }
42
72
 
73
+ .supporting-text {
74
+ display: block;
75
+ margin-block-start: var(--spacing-3, 8px);
76
+ color: var(--md-sys-color-on-surface-variant);
77
+ font-family: var(--brand-font, 'Inter', sans-serif);
78
+ font-size: var(--scb-checkbox-group-supporting-font-size);
79
+ line-height: var(--scb-checkbox-group-supporting-line-height);
80
+ font-weight: var(--scb-checkbox-group-supporting-weight);
81
+ letter-spacing: var(--scb-checkbox-group-supporting-tracking);
82
+ }
83
+
84
+ .supporting-text md-icon {
85
+ display: inline-flex;
86
+ color: var(--md-sys-color-error);
87
+ --md-icon-size: var(--scb-checkbox-group-error-icon-size);
88
+ font-size: var(--scb-checkbox-group-error-icon-size);
89
+ line-height: 1;
90
+ margin-inline-start: var(--spacing-2, 4px);
91
+ vertical-align: -0.18em;
92
+ }
93
+
94
+ :host([error]) .supporting-text {
95
+ color: var(--md-sys-color-error);
96
+ }
97
+
43
98
  /* När checkboxar ligger i en grupp ska spacing ägas av gruppen, inte av enskilda items */
44
99
  ::slotted(scb-checkbox) {
45
100
  --scb-checkbox-gap: 0;
46
101
  }
102
+
103
+ :host([error]) ::slotted(scb-checkbox) {
104
+ --md-checkbox-outline-color: var(--md-sys-color-error);
105
+ --md-checkbox-hover-outline-color: var(--md-sys-color-error);
106
+ --md-checkbox-focus-outline-color: var(--md-sys-color-error);
107
+ --md-checkbox-pressed-outline-color: var(--md-sys-color-error);
108
+ }
47
109
  `;
48
110
  }
49
111
  render() {
50
- let e = this.orientation === "horizontal" ? "row" : "column";
112
+ let e = this.orientation === "horizontal" ? "row" : "column", t = this.#s();
51
113
  return r`
52
- <div class="g" role="group" aria-disabled=${String(this.disabled)} style=${`--_dir:${e}`}>
114
+ <div
115
+ class="g"
116
+ role="group"
117
+ aria-disabled=${String(this.disabled)}
118
+ aria-required=${String(this.required)}
119
+ aria-invalid=${this.error ? "true" : "false"}
120
+ aria-describedby=${t ? this._supportingTextId : i}
121
+ aria-label=${this.ariaLabel ?? i}
122
+ style=${`--_dir:${e}`}
123
+ >
53
124
  <slot @slotchange=${this.#e}></slot>
54
125
  </div>
126
+ ${t ? r`
127
+ <div id=${this._supportingTextId} class="supporting-text">
128
+ <span>${t}</span>
129
+ ${this.error ? r`<md-icon aria-hidden="true">error</md-icon>` : i}
130
+ </div>
131
+ ` : i}
55
132
  `;
56
133
  }
57
134
  firstUpdated() {
58
- this.#t(), this.#e();
135
+ this.#l(), this.#e(), this.#r(), this.addEventListener("input", this.#i), this.addEventListener("change", this.#i), this._form = this.closest("form"), this._form && (this._formResetHandler = () => {
136
+ for (let e of this.#t()) e.checked = this._initialChecked.get(e) ?? e.hasAttribute("checked");
137
+ this.error = !1, this._hasValidationBeenReported = !1, this.#e(), this.#c(), this.#o();
138
+ }, this._formSubmitHandler = (e) => {
139
+ this.reportValidity() || (e.preventDefault(), e.stopPropagation());
140
+ }, this._form.addEventListener("reset", this._formResetHandler, !0), this._form.addEventListener("submit", this._formSubmitHandler, !0)), this.#c(), this.#o();
141
+ }
142
+ disconnectedCallback() {
143
+ this.removeEventListener("input", this.#i), this.removeEventListener("change", this.#i), this._form && this._formResetHandler && this._form.removeEventListener("reset", this._formResetHandler, !0), this._form && this._formSubmitHandler && this._form.removeEventListener("submit", this._formSubmitHandler, !0), super.disconnectedCallback();
59
144
  }
60
145
  updated(e) {
61
- (e.has("spacing") || e.has("spacingTop") || e.has("spacingBottom") || e.has("spacingLeft") || e.has("spacingRight")) && this.#t(), (e.has("disabled") || e.has("orientation") || e.has("size")) && this.#e();
146
+ (e.has("spacing") || e.has("spacingTop") || e.has("spacingBottom") || e.has("spacingLeft") || e.has("spacingRight")) && this.#l(), (e.has("name") || e.has("disabled") || e.has("orientation") || e.has("size") || e.has("required")) && this.#e(), (e.has("disabled") || e.has("name")) && this.#c(), (e.has("disabled") || e.has("required") || e.has("errorText")) && this.#o();
147
+ }
148
+ get form() {
149
+ return this._internals?.form ?? this._form;
150
+ }
151
+ get validity() {
152
+ return this._internals?.validity;
153
+ }
154
+ get validationMessage() {
155
+ return this._internals?.validationMessage || this._validationMessage;
156
+ }
157
+ get willValidate() {
158
+ return this._internals?.willValidate ?? !this.disabled;
159
+ }
160
+ get labels() {
161
+ return this._internals?.labels;
162
+ }
163
+ checkValidity() {
164
+ return this.#o(), this._internals?.checkValidity() ?? !this.error;
165
+ }
166
+ reportValidity() {
167
+ return this._hasValidationBeenReported = !0, this.#o(), this._internals?.reportValidity() ?? !this.error;
168
+ }
169
+ setCustomValidity(e) {
170
+ this._customValidationMessage = String(e ?? ""), this.#o();
171
+ }
172
+ formDisabledCallback(e) {
173
+ this.disabled = e, e && (this._hasValidationBeenReported = !1), this.#o();
62
174
  }
63
175
  #e;
64
- #t() {
65
- let e = this.#n(this.spacing), t = this.#n(this.spacingTop) ?? e, n = this.#n(this.spacingBottom) ?? e, r = this.#n(this.spacingLeft), i = this.#n(this.spacingRight);
176
+ #t;
177
+ #n(e) {
178
+ let t = e.hasAttribute("data-name-from-group");
179
+ this.name ? (!e.hasAttribute("name") || t) && (e.setAttribute("name", this.name), e.setAttribute("data-name-from-group", "")) : t && (e.removeAttribute("name"), e.removeAttribute("data-name-from-group"));
180
+ }
181
+ #r() {
182
+ for (let e of this.#t()) this._initialChecked.has(e) || this._initialChecked.set(e, e.checked === !0 || e.hasAttribute("checked"));
183
+ }
184
+ #i;
185
+ #a() {
186
+ return this.#t().some((e) => e.checked === !0);
187
+ }
188
+ #o() {
189
+ let e = !this.disabled && this.required && !this.#a(), t = this.disabled ? "" : this._customValidationMessage || (e ? this.errorText || "Välj minst ett alternativ." : ""), n = this.error, r = this._validationMessage;
190
+ if (this._internals) {
191
+ let e = t ? this._customValidationMessage ? { customError: !0 } : { valueMissing: !0 } : {};
192
+ this._internals.setValidity(e, t, this.shadowRoot?.querySelector(".g") ?? void 0);
193
+ }
194
+ this._validationMessage = t, this.error = this.disabled ? !1 : t ? this._hasValidationBeenReported || n : n && !this._hasValidationBeenReported && !r, this.toggleAttribute("aria-invalid", this.error), (n !== this.error || r !== this._validationMessage) && this.requestUpdate();
195
+ }
196
+ #s() {
197
+ return this.error ? this._validationMessage || this.errorText || "Ogiltigt val." : this.supportingText;
198
+ }
199
+ #c() {
200
+ this._internals && this._internals.setFormValue(null);
201
+ }
202
+ #l() {
203
+ let e = this.#u(this.spacing), t = this.#u(this.spacingTop) ?? e, n = this.#u(this.spacingBottom) ?? e, r = this.#u(this.spacingLeft), i = this.#u(this.spacingRight);
66
204
  t ? this.style.setProperty("--scb-checkbox-group-spacing-block-start", t) : this.style.removeProperty("--scb-checkbox-group-spacing-block-start"), n ? this.style.setProperty("--scb-checkbox-group-spacing-block-end", n) : this.style.removeProperty("--scb-checkbox-group-spacing-block-end"), r ? this.style.setProperty("--scb-checkbox-group-spacing-inline-start", r) : this.style.removeProperty("--scb-checkbox-group-spacing-inline-start"), i ? this.style.setProperty("--scb-checkbox-group-spacing-inline-end", i) : this.style.removeProperty("--scb-checkbox-group-spacing-inline-end");
67
205
  }
68
- #n(e) {
206
+ #u(e) {
69
207
  if (!e) return;
70
208
  let t = String(e).trim();
71
209
  if (t) return /^\d+$/.test(t) ? `var(--spacing-${Math.max(0, Math.min(14, parseInt(t, 10)))})` : t;
72
210
  }
73
211
  };
74
- e([a({
212
+ e([o({ type: String })], s.prototype, "name", void 0), e([o({
75
213
  type: String,
76
214
  reflect: !0
77
- })], o.prototype, "orientation", void 0), e([a({
215
+ })], s.prototype, "orientation", void 0), e([o({
216
+ type: Boolean,
217
+ reflect: !0
218
+ })], s.prototype, "disabled", void 0), e([o({
78
219
  type: Boolean,
79
220
  reflect: !0
80
- })], o.prototype, "disabled", void 0), e([a({
221
+ })], s.prototype, "required", void 0), e([o({
222
+ type: Boolean,
223
+ reflect: !0
224
+ })], s.prototype, "error", void 0), e([o({
225
+ type: String,
226
+ attribute: "aria-label"
227
+ })], s.prototype, "ariaLabel", void 0), e([o({
228
+ type: String,
229
+ attribute: "supporting-text"
230
+ })], s.prototype, "supportingText", void 0), e([o({
231
+ type: String,
232
+ attribute: "error-text"
233
+ })], s.prototype, "errorText", void 0), e([o({
81
234
  type: String,
82
235
  reflect: !0
83
- })], o.prototype, "size", void 0), e([a({
236
+ })], s.prototype, "size", void 0), e([o({
84
237
  type: String,
85
238
  reflect: !0
86
- })], o.prototype, "spacing", void 0), e([a({
239
+ })], s.prototype, "spacing", void 0), e([o({
87
240
  type: String,
88
241
  attribute: "spacing-top",
89
242
  reflect: !0
90
- })], o.prototype, "spacingTop", void 0), e([a({
243
+ })], s.prototype, "spacingTop", void 0), e([o({
91
244
  type: String,
92
245
  attribute: "spacing-bottom",
93
246
  reflect: !0
94
- })], o.prototype, "spacingBottom", void 0), e([a({
247
+ })], s.prototype, "spacingBottom", void 0), e([o({
95
248
  type: String,
96
249
  attribute: "spacing-left",
97
250
  reflect: !0
98
- })], o.prototype, "spacingLeft", void 0), e([a({
251
+ })], s.prototype, "spacingLeft", void 0), e([o({
99
252
  type: String,
100
253
  attribute: "spacing-right",
101
254
  reflect: !0
102
- })], o.prototype, "spacingRight", void 0), o = e([i("scb-checkbox-group")], o);
255
+ })], s.prototype, "spacingRight", void 0), s = e([a("scb-checkbox-group")], s);
103
256
  //#endregion
104
- export { o as ScbCheckboxGroup };
257
+ export { s as ScbCheckboxGroup };
@@ -2,18 +2,45 @@ import { LitElement } from 'lit';
2
2
  type ScbCheckboxSize = 'small' | 'medium' | 'large';
3
3
  export declare class ScbCheckboxGroup extends LitElement {
4
4
  #private;
5
+ static formAssociated: boolean;
6
+ name: string;
5
7
  orientation: 'vertical' | 'horizontal';
6
8
  disabled: boolean;
9
+ required: boolean;
10
+ error: boolean;
11
+ ariaLabel: string | null;
12
+ supportingText: string;
13
+ errorText: string;
7
14
  size: ScbCheckboxSize;
8
15
  spacing: undefined;
9
16
  spacingTop: undefined;
10
17
  spacingBottom: undefined;
11
18
  spacingLeft: undefined;
12
19
  spacingRight: undefined;
20
+ private _internals;
21
+ private _form;
22
+ private _formResetHandler;
23
+ private _formSubmitHandler;
24
+ private _initialChecked;
25
+ private _customValidationMessage;
26
+ private _validationMessage;
27
+ private _hasValidationBeenReported;
28
+ private _supportingTextId;
29
+ constructor();
13
30
  static styles: import('lit').CSSResult;
14
31
  render(): import('lit-html').TemplateResult<1>;
15
32
  firstUpdated(): void;
33
+ disconnectedCallback(): void;
16
34
  updated(changed: Map<string, unknown>): void;
35
+ get form(): HTMLFormElement | null;
36
+ get validity(): ValidityState | undefined;
37
+ get validationMessage(): string;
38
+ get willValidate(): boolean;
39
+ get labels(): NodeList | undefined;
40
+ checkValidity(): boolean;
41
+ reportValidity(): boolean;
42
+ setCustomValidity(message: string): void;
43
+ formDisabledCallback(disabled: boolean): void;
17
44
  }
18
45
  declare global {
19
46
  interface HTMLElementTagNameMap {