@sbb-esta/lyne-elements-dev 5.13.2-dev.1794463730 → 5.13.2-dev.1794474447

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.
@@ -29023,11 +29023,11 @@
29023
29023
  "kind": "field",
29024
29024
  "name": "_fallbackValue",
29025
29025
  "type": {
29026
- "text": "T | null"
29026
+ "text": "T | null | typeof emptyValue"
29027
29027
  },
29028
29028
  "privacy": "private",
29029
- "default": "null",
29030
- "description": "Used to preserve the `value` in case the radios are not yet 'loaded'"
29029
+ "default": "emptyValue",
29030
+ "description": "Used to preserve the `value` in case the radios are not yet 'loaded'."
29031
29031
  },
29032
29032
  {
29033
29033
  "kind": "field",
@@ -31,7 +31,7 @@ export declare class SbbRadioButtonGroupElement<T = string> extends SbbSelection
31
31
  set value(val: T | null);
32
32
  get value(): T | null;
33
33
  /**
34
- * Used to preserve the `value` in case the radios are not yet 'loaded'
34
+ * Used to preserve the `value` in case the radios are not yet 'loaded'.
35
35
  */
36
36
  private _fallbackValue;
37
37
  /** Name for the group. Will be propagated to the child radio buttons. Must be unique if multiple groups are used on the same page. */
@@ -3,6 +3,7 @@ import { property } from "lit/decorators.js";
3
3
  import { SbbSelectionGroupBaseElement, forceType } from "./core.js";
4
4
 
5
5
  // src/elements/radio-button-group/radio-button-group.component.ts
6
+ const emptyValue = Symbol("emptyValue");
6
7
  let nextId = 0;
7
8
  /**
8
9
  * It can be used as a container for radio button elements.
@@ -133,11 +134,11 @@ let SbbRadioButtonGroupElement = (() => {
133
134
  set value(val) {
134
135
  this._fallbackValue = val;
135
136
  if (!this.hasUpdated) return;
136
- const toCheck = val == null ? null : this.selectionElements.find((r) => this.compareWith(r.value, val));
137
+ const toCheck = this.selectionElements.find((r) => this.compareWith(r.value, val));
137
138
  this.selectionElements.forEach((r) => r.checked = r === toCheck);
138
139
  }
139
140
  get value() {
140
- return this.selectionElements.find((r) => r.checked && !r.disabled)?.value ?? this._fallbackValue;
141
+ return this.selectionElements.find((r) => r.checked && !r.disabled)?.value ?? (this._fallbackValue === emptyValue ? null : this._fallbackValue);
141
142
  }
142
143
  #name_accessor_storage;
143
144
  /** Name for the group. Will be propagated to the child radio buttons. Must be unique if multiple groups are used on the same page. */
@@ -158,9 +159,9 @@ let SbbRadioButtonGroupElement = (() => {
158
159
  this.#allowEmptySelection_accessor_storage = __runInitializers(this, _allowEmptySelection_initializers, false);
159
160
  this.#compareWith_accessor_storage = (__runInitializers(this, _allowEmptySelection_extraInitializers), __runInitializers(this, _compareWith_initializers, (v1, v2) => v1 === v2));
160
161
  /**
161
- * Used to preserve the `value` in case the radios are not yet 'loaded'
162
+ * Used to preserve the `value` in case the radios are not yet 'loaded'.
162
163
  */
163
- this._fallbackValue = (__runInitializers(this, _compareWith_extraInitializers), null);
164
+ this._fallbackValue = (__runInitializers(this, _compareWith_extraInitializers), emptyValue);
164
165
  this.#name_accessor_storage = __runInitializers(this, _name_initializers, `sbb-radio-button-group-${++nextId}`);
165
166
  __runInitializers(this, _name_extraInitializers);
166
167
  this.addEventListener?.("change", (e) => this._onRadioChange(e));
@@ -177,7 +178,7 @@ let SbbRadioButtonGroupElement = (() => {
177
178
  _onRadioChange(event) {
178
179
  const target = event.target;
179
180
  if (target.localName !== "sbb-radio-button" && target.localName !== "sbb-radio-button-panel" || target.group !== this) return;
180
- this._fallbackValue = null;
181
+ this._fallbackValue = emptyValue;
181
182
  /**
182
183
  * Deprecated. Mirrors change event for React. Will be removed once React properly supports change events.
183
184
  * @deprecated
@@ -195,7 +196,7 @@ let SbbRadioButtonGroupElement = (() => {
195
196
  * Mainly used to cover cases where the setter is called before the radios are loaded
196
197
  */
197
198
  _updateRadioState() {
198
- if (this._fallbackValue != null) this.value = this.value;
199
+ if (this._fallbackValue !== emptyValue) this.value = this.value;
199
200
  }
200
201
  onSlotChange() {
201
202
  super.onSlotChange();
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sbb-esta/lyne-elements-dev",
3
- "version": "5.13.2-dev.1794463730",
3
+ "version": "5.13.2-dev.1794474447",
4
4
  "description": "Lyne Design System",
5
5
  "keywords": [
6
6
  "design system",
7
7
  "web components",
8
8
  "lit",
9
- "https://github.com/sbb-design-systems/lyne-components/commit/a515546e8c5f6c688fb353c48e751b7799b527a4"
9
+ "https://github.com/sbb-design-systems/lyne-components/commit/7db263c67e69e891a902a7c0dfdc4b75034666c6"
10
10
  ],
11
11
  "type": "module",
12
12
  "exports": {
@@ -1 +1 @@
1
- import{__esDecorate as e,__runInitializers as t}from"tslib";import{property as n}from"lit/decorators.js";import{SbbSelectionGroupBaseElement as r,forceType as i}from"./core.js";let a=0,o=(()=>{let o=r,s=[],c,l=[],u=[],d,f=[],p=[],m,h,g=[],_=[];return class extends o{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(o[Symbol.metadata]??null):void 0;c=[i(),n({attribute:`allow-empty-selection`,type:Boolean})],d=[n({attribute:!1})],m=[n()],h=[i(),n()],e(this,null,c,{kind:`accessor`,name:`allowEmptySelection`,static:!1,private:!1,access:{has:e=>`allowEmptySelection`in e,get:e=>e.allowEmptySelection,set:(e,t)=>{e.allowEmptySelection=t}},metadata:t},l,u),e(this,null,d,{kind:`accessor`,name:`compareWith`,static:!1,private:!1,access:{has:e=>`compareWith`in e,get:e=>e.compareWith,set:(e,t)=>{e.compareWith=t}},metadata:t},f,p),e(this,null,m,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,s),e(this,null,h,{kind:`accessor`,name:`name`,static:!1,private:!1,access:{has:e=>`name`in e,get:e=>e.name,set:(e,t)=>{e.name=t}},metadata:t},g,_),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-radio-button-group`}static{this.role=`radiogroup`}static{this.events={didChange:`didChange`,change:`change`,input:`input`}}#e;get allowEmptySelection(){return this.#e}set allowEmptySelection(e){this.#e=e}#t;get compareWith(){return this.#t}set compareWith(e){this.#t=e}set value(e){if(this._fallbackValue=e,!this.hasUpdated)return;let t=e==null?null:this.selectionElements.find(t=>this.compareWith(t.value,e));this.selectionElements.forEach(e=>e.checked=e===t)}get value(){return this.selectionElements.find(e=>e.checked&&!e.disabled)?.value??this._fallbackValue}#n;get name(){return this.#n}set name(e){this.#n=e}get radioButtons(){return this.selectionElements}constructor(){super(),this.selectionElementSelectors=(t(this,s),`sbb-radio-button, sbb-radio-button-panel`),this.panelElementSelector=`sbb-radio-button-panel`,this.#e=t(this,l,!1),this.#t=(t(this,u),t(this,f,(e,t)=>e===t)),this._fallbackValue=(t(this,p),null),this.#n=t(this,g,`sbb-radio-button-group-${++a}`),t(this,_),this.addEventListener?.(`change`,e=>this._onRadioChange(e)),this.addEventListener?.(`ɵradiobuttonvaluechange`,()=>this._updateRadioState())}willUpdate(e){super.willUpdate(e),e.has(`name`)&&this._updateRadiosName()}firstUpdated(e){super.firstUpdated(e),this.updateComplete.then(()=>this._updateRadioState())}_onRadioChange(e){let t=e.target;t.localName!==`sbb-radio-button`&&t.localName!==`sbb-radio-button-panel`||t.group!==this||(this._fallbackValue=null,this.dispatchEvent(new Event(`didChange`,{bubbles:!0})))}_updateRadiosName(){this.selectionElements.forEach(e=>e.name=this.name)}_updateRadioState(){this._fallbackValue!=null&&(this.value=this.value)}onSlotChange(){super.onSlotChange(),this._updateRadiosName(),this._updateRadioState()}}})();export{o as SbbRadioButtonGroupElement};
1
+ import{__esDecorate as e,__runInitializers as t}from"tslib";import{property as n}from"lit/decorators.js";import{SbbSelectionGroupBaseElement as r,forceType as i}from"./core.js";const a=Symbol(`emptyValue`);let o=0,s=(()=>{let s=r,c=[],l,u=[],d=[],f,p=[],m=[],h,g,_=[],v=[];return class extends s{static{let t=typeof Symbol==`function`&&Symbol.metadata?Object.create(s[Symbol.metadata]??null):void 0;l=[i(),n({attribute:`allow-empty-selection`,type:Boolean})],f=[n({attribute:!1})],h=[n()],g=[i(),n()],e(this,null,l,{kind:`accessor`,name:`allowEmptySelection`,static:!1,private:!1,access:{has:e=>`allowEmptySelection`in e,get:e=>e.allowEmptySelection,set:(e,t)=>{e.allowEmptySelection=t}},metadata:t},u,d),e(this,null,f,{kind:`accessor`,name:`compareWith`,static:!1,private:!1,access:{has:e=>`compareWith`in e,get:e=>e.compareWith,set:(e,t)=>{e.compareWith=t}},metadata:t},p,m),e(this,null,h,{kind:`setter`,name:`value`,static:!1,private:!1,access:{has:e=>`value`in e,set:(e,t)=>{e.value=t}},metadata:t},null,c),e(this,null,g,{kind:`accessor`,name:`name`,static:!1,private:!1,access:{has:e=>`name`in e,get:e=>e.name,set:(e,t)=>{e.name=t}},metadata:t},_,v),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}static{this.elementName=`sbb-radio-button-group`}static{this.role=`radiogroup`}static{this.events={didChange:`didChange`,change:`change`,input:`input`}}#e;get allowEmptySelection(){return this.#e}set allowEmptySelection(e){this.#e=e}#t;get compareWith(){return this.#t}set compareWith(e){this.#t=e}set value(e){if(this._fallbackValue=e,!this.hasUpdated)return;let t=this.selectionElements.find(t=>this.compareWith(t.value,e));this.selectionElements.forEach(e=>e.checked=e===t)}get value(){return this.selectionElements.find(e=>e.checked&&!e.disabled)?.value??(this._fallbackValue===a?null:this._fallbackValue)}#n;get name(){return this.#n}set name(e){this.#n=e}get radioButtons(){return this.selectionElements}constructor(){super(),this.selectionElementSelectors=(t(this,c),`sbb-radio-button, sbb-radio-button-panel`),this.panelElementSelector=`sbb-radio-button-panel`,this.#e=t(this,u,!1),this.#t=(t(this,d),t(this,p,(e,t)=>e===t)),this._fallbackValue=(t(this,m),a),this.#n=t(this,_,`sbb-radio-button-group-${++o}`),t(this,v),this.addEventListener?.(`change`,e=>this._onRadioChange(e)),this.addEventListener?.(`ɵradiobuttonvaluechange`,()=>this._updateRadioState())}willUpdate(e){super.willUpdate(e),e.has(`name`)&&this._updateRadiosName()}firstUpdated(e){super.firstUpdated(e),this.updateComplete.then(()=>this._updateRadioState())}_onRadioChange(e){let t=e.target;t.localName!==`sbb-radio-button`&&t.localName!==`sbb-radio-button-panel`||t.group!==this||(this._fallbackValue=a,this.dispatchEvent(new Event(`didChange`,{bubbles:!0})))}_updateRadiosName(){this.selectionElements.forEach(e=>e.name=this.name)}_updateRadioState(){this._fallbackValue!==a&&(this.value=this.value)}onSlotChange(){super.onSlotChange(),this._updateRadiosName(),this._updateRadioState()}}})();export{s as SbbRadioButtonGroupElement};