@cas-smartdesign/radio-button-group 4.1.1 → 4.3.0

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.
@@ -47,6 +47,8 @@ export declare class RadioButtonGroup extends LitElement {
47
47
  private handleButtonClick;
48
48
  private fireValueChangeEvent;
49
49
  private handleKeyDown;
50
+ private focusNext;
51
+ private focusPrevious;
50
52
  private getNextFocusIndex;
51
53
  private getPreviousFocusIndex;
52
54
  private isFocusable;
@@ -1,11 +1,11 @@
1
- import { LitElement as b, unsafeCSS as v, css as g, html as f } from "lit";
1
+ import { LitElement as b, unsafeCSS as v, css as g, html as p } from "lit";
2
2
  import { property as r } from "lit/decorators/property.js";
3
3
  import { ifDefined as k } from "lit/directives/if-defined.js";
4
4
  import { ValidationLevel as x } from "@cas-smartdesign/field-validation-message";
5
5
  const y = ":host{display:block}:host,.label,.checkbox{outline:none}:host([disabled]){pointer-events:none}:host([disabled]) .root{opacity:.6;cursor:default;filter:grayscale(100%)}:host(:not([disabled])[focused]) .highlight{display:block!important}:host([checked]) circle.inner{display:block!important}:host([checked]) circle.outer{stroke:var(--sd-radio-button-checked-color, #1467ba)!important}:host([oneline]) .label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.root{display:inline-flex;align-items:center;vertical-align:middle;width:100%;padding-top:6px;padding-bottom:6px}.root .radio-button-container{position:relative;display:inline-block;width:28px;height:28px;box-sizing:border-box;cursor:pointer;margin-right:5px;flex-shrink:0}.root .radio-button-container input{position:absolute;top:0;left:0;opacity:0}.root .radio-button-container circle.highlight{stroke:var(--sd-radio-button-highlight-color, rgba(20, 103, 186, .3))}.root .radio-button-container circle.inner{fill:var(--sd-radio-button-checked-color, #1467ba)}.root .radio-button-container circle.outer{stroke:var(--sd-radio-button-unchecked-color, #767676)}.root .label{font-family:Segoe UI,Lucida Sans,Arial,sans-serif;text-overflow:ellipsis;overflow-x:hidden;-webkit-user-select:none;user-select:none;cursor:pointer;padding-top:2px;padding-bottom:2px}";
6
- var I = Object.defineProperty, p = (o, t, e, i) => {
7
- for (var s = void 0, d = o.length - 1, u; d >= 0; d--)
8
- (u = o[d]) && (s = u(t, e, s) || s);
6
+ var I = Object.defineProperty, f = (o, t, e, i) => {
7
+ for (var s = void 0, c = o.length - 1, u; c >= 0; c--)
8
+ (u = o[c]) && (s = u(t, e, s) || s);
9
9
  return s && I(t, e, s), s;
10
10
  };
11
11
  let m = 0;
@@ -24,7 +24,7 @@ const h = (n = class extends b {
24
24
  ];
25
25
  }
26
26
  render() {
27
- return f`
27
+ return p`
28
28
  <div class="root">
29
29
  <div class="radio-button-container">
30
30
  <input
@@ -54,26 +54,26 @@ const h = (n = class extends b {
54
54
  }, n.ID = "sd-radio-button", n.ensureDefined = () => {
55
55
  customElements.get(n.ID) || customElements.define(n.ID, n);
56
56
  }, n);
57
- p([
57
+ f([
58
58
  r({ type: Boolean, reflect: !0, attribute: !0 })
59
59
  ], h.prototype, "checked");
60
- p([
60
+ f([
61
61
  r({ type: String, reflect: !0, attribute: !0 })
62
62
  ], h.prototype, "value");
63
- p([
63
+ f([
64
64
  r({ type: Boolean, reflect: !0, attribute: !0 })
65
65
  ], h.prototype, "disabled");
66
- p([
66
+ f([
67
67
  r({ type: String, reflect: !0, attribute: !0 })
68
68
  ], h.prototype, "label");
69
69
  let w = h;
70
70
  const B = ":host(:focus){outline:none}.buttons-container{display:flex}.buttons-container.vertical{flex-direction:column}.validation-message{margin-left:5px}";
71
- var C = Object.defineProperty, c = (o, t, e, i) => {
72
- for (var s = void 0, d = o.length - 1, u; d >= 0; d--)
73
- (u = o[d]) && (s = u(t, e, s) || s);
71
+ var C = Object.defineProperty, d = (o, t, e, i) => {
72
+ for (var s = void 0, c = o.length - 1, u; c >= 0; c--)
73
+ (u = o[c]) && (s = u(t, e, s) || s);
74
74
  return s && C(t, e, s), s;
75
- }, l;
76
- const a = (l = class extends b {
75
+ }, a;
76
+ const l = (a = class extends b {
77
77
  constructor() {
78
78
  super(...arguments), this.layout = "horizontal", this.value = "", this.uncheckAllowed = !1, this.disabled = !1, this._focusIndex = -1, this._checkedButton = null, this.handleSlotChange = () => {
79
79
  this._buttons = this.buttonsSlot.assignedElements(), this._buttons.forEach((t) => {
@@ -92,15 +92,17 @@ const a = (l = class extends b {
92
92
  let e = !0;
93
93
  switch (t.key) {
94
94
  case "Down":
95
- case "ArrowDown": {
96
- const i = this.getNextFocusIndex(this.focusIndex + 1);
97
- this.focusIndex = i !== -1 ? i : this.getNextFocusIndex(0), this.uncheckAllowed || this.updateChecked();
95
+ case "ArrowDown":
96
+ case "Right":
97
+ case "ArrowRight": {
98
+ this.focusNext();
98
99
  break;
99
100
  }
100
101
  case "Up":
101
- case "ArrowUp": {
102
- const i = this.getPreviousFocusIndex(this.focusIndex - 1);
103
- this.focusIndex = i !== -1 ? i : this.getPreviousFocusIndex(this.childElementCount - 1), this.uncheckAllowed || this.updateChecked();
102
+ case "ArrowUp":
103
+ case "Left":
104
+ case "ArrowLeft": {
105
+ this.focusPrevious();
104
106
  break;
105
107
  }
106
108
  case "Enter": {
@@ -139,14 +141,14 @@ const a = (l = class extends b {
139
141
  ];
140
142
  }
141
143
  render() {
142
- return f`
144
+ return p`
143
145
  <div
144
146
  class="buttons-container ${this.layout === "vertical" ? "vertical" : "horizontal"}"
145
147
  @click="${k(this.disabled ? void 0 : this.handleButtonClick)}"
146
148
  >
147
149
  <slot></slot>
148
150
  </div>
149
- ${this.validationMessage && f`
151
+ ${this.validationMessage && p`
150
152
  <sd-field-validation-message
151
153
  class="validation-message"
152
154
  .message=${this.validationMessage}
@@ -186,6 +188,14 @@ const a = (l = class extends b {
186
188
  })
187
189
  );
188
190
  }
191
+ focusNext() {
192
+ const t = this.getNextFocusIndex(this.focusIndex + 1);
193
+ this.focusIndex = t !== -1 ? t : this.getNextFocusIndex(0), this.uncheckAllowed || this.updateChecked();
194
+ }
195
+ focusPrevious() {
196
+ const t = this.getPreviousFocusIndex(this.focusIndex - 1);
197
+ this.focusIndex = t !== -1 ? t : this.getPreviousFocusIndex(this.childElementCount - 1), this.uncheckAllowed || this.updateChecked();
198
+ }
189
199
  getNextFocusIndex(t) {
190
200
  for (let e = t; e < this.childElementCount; e++) {
191
201
  const i = this._buttons[e];
@@ -230,28 +240,28 @@ const a = (l = class extends b {
230
240
  get selectedIndex() {
231
241
  return this._buttons.indexOf(this._checkedButton);
232
242
  }
233
- }, l.ID = "sd-radio-button-group", l.ensureDefined = () => {
234
- w.ensureDefined(), customElements.get(l.ID) || customElements.define(l.ID, l);
235
- }, l);
236
- c([
243
+ }, a.ID = "sd-radio-button-group", a.ensureDefined = () => {
244
+ w.ensureDefined(), customElements.get(a.ID) || customElements.define(a.ID, a);
245
+ }, a);
246
+ d([
237
247
  r({ type: String, reflect: !0, attribute: !0 })
238
- ], a.prototype, "layout");
239
- c([
248
+ ], l.prototype, "layout");
249
+ d([
240
250
  r({ type: String })
241
- ], a.prototype, "value");
242
- c([
251
+ ], l.prototype, "value");
252
+ d([
243
253
  r({ type: Boolean, reflect: !0, attribute: "uncheck-allowed" })
244
- ], a.prototype, "uncheckAllowed");
245
- c([
254
+ ], l.prototype, "uncheckAllowed");
255
+ d([
246
256
  r({ type: Boolean, reflect: !0, attribute: !0 })
247
- ], a.prototype, "disabled");
248
- c([
257
+ ], l.prototype, "disabled");
258
+ d([
249
259
  r({ type: String })
250
- ], a.prototype, "validationMessage");
251
- c([
260
+ ], l.prototype, "validationMessage");
261
+ d([
252
262
  r({ type: String })
253
- ], a.prototype, "validationIconSrc");
254
- c([
263
+ ], l.prototype, "validationIconSrc");
264
+ d([
255
265
  r({
256
266
  type: {
257
267
  fromAttribute(o) {
@@ -263,8 +273,8 @@ c([
263
273
  },
264
274
  reflect: !0
265
275
  })
266
- ], a.prototype, "validationLevel");
267
- let _ = a;
276
+ ], l.prototype, "validationLevel");
277
+ let _ = l;
268
278
  _.ensureDefined();
269
279
  export {
270
280
  w as RadioButton,
@@ -1 +1 @@
1
- {"version":3,"file":"radio-button-group.mjs","sources":["../radio-button.ts","../radio-button-group.ts"],"sourcesContent":["import { LitElement, TemplateResult, html, unsafeCSS, css, nothing } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [RadioButton.ID]: RadioButton;\n }\n}\n\nimport style from \"./scss/button.scss?inline\";\nlet idCounter = 0;\n\nexport class RadioButton extends LitElement {\n public static readonly ID = \"sd-radio-button\";\n public static ensureDefined = (): void => {\n if (!customElements.get(RadioButton.ID)) {\n customElements.define(RadioButton.ID, RadioButton);\n }\n };\n @property({ type: Boolean, reflect: true, attribute: true })\n public checked = false;\n @property({ type: String, reflect: true, attribute: true })\n public value = \"\";\n @property({ type: Boolean, reflect: true, attribute: true })\n public disabled = false;\n @property({ type: String, reflect: true, attribute: true })\n public label = \"\";\n\n private a11yID;\n\n constructor() {\n super();\n this.a11yID = RadioButton.ID + \"_\" + idCounter++;\n }\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n\n public render(): TemplateResult {\n return html`\n <div class=\"root\">\n <div class=\"radio-button-container\">\n <input\n type=\"radio\"\n id=\"${this.a11yID}\"\n .checked=\"${this.checked}\"\n ?disabled=\"${this.disabled}\"\n @click=\"${this.handleClick}\"\n class=\"radio-button\"\n />\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-14 -14 28 28\">\n <circle\n class=\"highlight\"\n style=\"display:none\"\n r=\"11px\"\n fill=\"transparent\"\n stroke-width=\"6px\"\n ></circle>\n <circle class=\"inner\" r=\"6px\" style=\"display:none\" stroke=\"none\"></circle>\n <circle class=\"outer\" r=\"9px\" fill=\"transparent\" stroke-width=\"2px\"></circle>\n </svg>\n </div>\n <label class=\"label\" for=\"${this.a11yID}\" @click=\"${this.handleClick}\">${this.label}</label>\n </div>\n `;\n }\n\n private handleClick = (event: MouseEvent): void => {\n event.preventDefault();\n };\n}\n","import { LitElement, TemplateResult, html, PropertyValues, ComplexAttributeConverter, unsafeCSS, css } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { RadioButton } from \"./radio-button\";\nimport { ValidationLevel } from \"@cas-smartdesign/field-validation-message\";\nimport type { LayoutType, IValueChangeEvent } from \"./types\";\n\nexport { RadioButton } from \"./radio-button\";\nexport type * from \"./types\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [RadioButtonGroup.ID]: RadioButtonGroup;\n }\n}\nimport style from \"./scss/group.scss?inline\";\n\nexport interface CustomEventMap extends HTMLElementEventMap {\n \"value-change\": CustomEvent<IValueChangeEvent>;\n}\n\nexport interface RadioButtonGroup {\n addEventListener<K extends keyof CustomEventMap>(\n event: K,\n listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n addEventListener(\n type: string,\n callback: EventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n removeEventListener<K extends keyof CustomEventMap>(\n type: K,\n listener: (this: this, ev: CustomEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;\n}\n\nexport class RadioButtonGroup extends LitElement {\n public static readonly ID = \"sd-radio-button-group\";\n public static ensureDefined = (): void => {\n RadioButton.ensureDefined();\n if (!customElements.get(RadioButtonGroup.ID)) {\n customElements.define(RadioButtonGroup.ID, RadioButtonGroup);\n }\n };\n @property({ type: String, reflect: true, attribute: true })\n public layout: LayoutType = \"horizontal\";\n @property({ type: String })\n public value = \"\";\n @property({ type: Boolean, reflect: true, attribute: \"uncheck-allowed\" })\n public uncheckAllowed = false;\n @property({ type: Boolean, reflect: true, attribute: true })\n public disabled = false;\n @property({ type: String })\n public validationMessage: string;\n @property({ type: String })\n public validationIconSrc: string;\n @property({\n type: {\n fromAttribute(value: string): ValidationLevel {\n return value && ValidationLevel[value.toLowerCase()];\n },\n toAttribute(value: ValidationLevel): string {\n return value && value.toLowerCase();\n },\n } as ComplexAttributeConverter,\n reflect: true,\n })\n public validationLevel: ValidationLevel;\n\n private _buttonsSlot: HTMLSlotElement;\n private _buttons: HTMLElement[];\n private _focusIndex = -1;\n private _checkedButton: HTMLElement = null;\n\n public get focusIndex(): number {\n return this._focusIndex;\n }\n\n public set focusIndex(index: number) {\n if (index >= -1 && index < this.childElementCount) {\n const oldValue = this._focusIndex;\n this._focusIndex = index;\n if (oldValue !== index) {\n const previousButton = this._buttons[oldValue];\n const currentButton = this._buttons[this.focusIndex];\n this.updateFocused(previousButton, currentButton);\n }\n }\n }\n\n protected firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n this.buttonsSlot.addEventListener(\"slotchange\", this.handleSlotChange);\n this.addEventListener(\"focusin\", this.handleFocusIn);\n this.addEventListener(\"focusout\", this.handleFocusOut);\n this.addEventListener(\"keydown\", this.handleKeyDown);\n }\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (changedProperties.has(\"disabled\")) {\n if (this.disabled) {\n this.disableButtons();\n } else {\n this.enableButtons();\n }\n }\n }\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n public render(): TemplateResult {\n return html`\n <div\n class=\"buttons-container ${this.layout === \"vertical\" ? \"vertical\" : \"horizontal\"}\"\n @click=\"${ifDefined(this.disabled ? undefined : this.handleButtonClick)}\"\n >\n <slot></slot>\n </div>\n ${this.validationMessage &&\n html`\n <sd-field-validation-message\n class=\"validation-message\"\n .message=${this.validationMessage}\n .icon=${this.validationIconSrc}\n .level=${this.validationLevel}\n >\n </sd-field-validation-message>\n `}\n `;\n }\n\n private handleSlotChange = (): void => {\n this._buttons = this.buttonsSlot.assignedElements() as HTMLElement[];\n this._buttons.forEach((button) => {\n if (!button.hasAttribute(\"disabled\") && this.disabled) {\n button.setAttribute(\"disabled\", \"\");\n }\n // prevent radio buttons to be able to get focus by tabbing\n // as focus is handled by this element\n button.setAttribute(\"tabIndex\", \"-1\");\n this.updateCheckedButton(button);\n });\n };\n\n private updateCheckedButton(button: HTMLElement): void {\n if (this._checkedButton && this._checkedButton !== button) {\n this.uncheckButton(button);\n } else if (button.hasAttribute(\"checked\")) {\n this._checkedButton = button;\n const value = button.getAttribute(\"value\");\n this.updateValue(value);\n }\n }\n\n private handleFocusIn = (event: FocusEvent): void => {\n const target = event.target as HTMLElement;\n const ind = this._buttons.findIndex((button) => button == target);\n this.focusIndex = this.focusIndex >= 0 ? this.focusIndex : this.getNextFocusIndex(ind !== -1 ? ind : 0);\n this.updateFocused(null, this._buttons[this.focusIndex]);\n };\n\n private handleFocusOut = (): void => {\n this.updateFocused(this._buttons[this.focusIndex]);\n };\n\n private disableButtons(): void {\n this._buttons?.forEach((button) => {\n button.setAttribute(\"disabled\", \"\");\n });\n }\n\n private enableButtons(): void {\n this._buttons?.forEach((button) => {\n button.removeAttribute(\"disabled\");\n });\n }\n\n private handleButtonClick = (event: MouseEvent): void => {\n // the individual buttons are not focusable\n this.focus();\n const target = this._buttons.find((button) => button.contains(event.target as Node));\n const targetIndex = this._buttons.findIndex((button) => button == target);\n if (targetIndex >= 0) {\n this.focusIndex = targetIndex;\n this.updateChecked();\n }\n };\n\n private fireValueChangeEvent(): void {\n this.dispatchEvent(\n new CustomEvent<IValueChangeEvent>(\"value-change\", {\n detail: {\n value: this.value,\n selectedIndex: this.selectedIndex,\n },\n }),\n );\n }\n\n private handleKeyDown = (event: KeyboardEvent): void => {\n let shouldPrevent = true;\n switch (event.key) {\n case \"Down\":\n case \"ArrowDown\": {\n const newIndex = this.getNextFocusIndex(this.focusIndex + 1);\n this.focusIndex = newIndex !== -1 ? newIndex : this.getNextFocusIndex(0);\n if (!this.uncheckAllowed) {\n this.updateChecked();\n }\n break;\n }\n case \"Up\":\n case \"ArrowUp\": {\n const newIndex = this.getPreviousFocusIndex(this.focusIndex - 1);\n this.focusIndex = newIndex !== -1 ? newIndex : this.getPreviousFocusIndex(this.childElementCount - 1);\n if (!this.uncheckAllowed) {\n this.updateChecked();\n }\n break;\n }\n case \"Enter\": {\n this.updateChecked();\n break;\n }\n default: {\n shouldPrevent = false;\n }\n }\n if (shouldPrevent) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n\n private getNextFocusIndex(index: number): number {\n for (let i = index; i < this.childElementCount; i++) {\n const button = this._buttons[i];\n if (this.isFocusable(button)) {\n return i;\n }\n }\n\n return -1;\n }\n\n private getPreviousFocusIndex(index: number): number {\n for (let i = index; i >= 0; i--) {\n const button = this._buttons[i];\n if (this.isFocusable(button)) {\n return i;\n }\n }\n\n return -1;\n }\n\n private isFocusable(button: HTMLElement): boolean {\n return !button.hasAttribute(\"disabled\");\n }\n\n private updateChecked(): void {\n const previousChecked = this._checkedButton;\n const currentChecked = this._buttons[this.focusIndex];\n this._checkedButton = currentChecked;\n if (previousChecked && previousChecked !== currentChecked) {\n this.uncheckButton(previousChecked);\n }\n if (currentChecked) {\n this.toggleButton(currentChecked);\n }\n }\n\n private toggleButton(button: HTMLElement): void {\n const checked = button.hasAttribute(\"checked\");\n if (checked) {\n if (this.uncheckAllowed) {\n this.uncheckButton(button);\n this._checkedButton = null;\n this.updateValue(\"\");\n }\n } else {\n this.checkButton(button);\n this.updateValue(button.getAttribute(\"value\"));\n }\n }\n\n private updateValue(newValue: string): void {\n this.value = newValue;\n this.fireValueChangeEvent();\n }\n\n private updateFocused(previousFocused?: HTMLElement, currentFocused?: HTMLElement): void {\n previousFocused?.removeAttribute?.(\"focused\");\n currentFocused?.setAttribute?.(\"focused\", \"\");\n }\n\n private checkButton(button: HTMLElement): void {\n button.setAttribute(\"checked\", \"\");\n }\n\n private uncheckButton(button: HTMLElement): void {\n button.removeAttribute(\"checked\");\n }\n\n private get buttonsSlot(): HTMLSlotElement {\n if (this.shadowRoot && !this._buttonsSlot) {\n this._buttonsSlot = this.shadowRoot.querySelector(\"slot\");\n }\n return this._buttonsSlot;\n }\n\n private get selectedIndex(): number {\n return this._buttons.indexOf(this._checkedButton);\n }\n}\n\nRadioButtonGroup.ensureDefined();\n"],"names":["idCounter","_RadioButton","_a","LitElement","event","css","unsafeCSS","style","html","__decorateClass","property","RadioButton","_RadioButtonGroup","button","target","ind","targetIndex","shouldPrevent","newIndex","index","oldValue","previousButton","currentButton","changedProperties","ifDefined","value","i","previousChecked","currentChecked","newValue","previousFocused","currentFocused","ValidationLevel","RadioButtonGroup"],"mappings":";;;;;;;;;;AAUA,IAAIA,IAAY;;AAET,MAAMC,KAANC,IAAA,cAA0BC,EAAW;AAAA,EAkBxC,cAAc;AACV,UAAA,GAXJ,KAAO,UAAU,IAEjB,KAAO,QAAQ,IAEf,KAAO,WAAW,IAElB,KAAO,QAAQ,IA8Cf,KAAQ,cAAc,CAACC,MAA4B;AAC/C,MAAAA,EAAM,eAAA;AAAA,IACV,GA1CI,KAAK,SAASF,EAAY,KAAK,MAAMF;AAAA,EACzC;AAAA,EAEA,WAAW,SAAS;AAChB,WAAO;AAAA,MACHK;AAAA,kBACMC,EAAUC,CAAK,CAAC;AAAA;AAAA,IAAA;AAAA,EAG9B;AAAA,EAEO,SAAyB;AAC5B,WAAOC;AAAA;AAAA;AAAA;AAAA;AAAA,8BAKe,KAAK,MAAM;AAAA,oCACL,KAAK,OAAO;AAAA,qCACX,KAAK,QAAQ;AAAA,kCAChB,KAAK,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4CAeN,KAAK,MAAM,aAAa,KAAK,WAAW,KAAK,KAAK,KAAK;AAAA;AAAA;AAAA,EAG/F;AAKJ,GA9DIN,EAAuB,KAAK,mBAC5BA,EAAc,gBAAgB,MAAY;AACtC,EAAK,eAAe,IAAIA,EAAY,EAAE,KAClC,eAAe,OAAOA,EAAY,IAAIA,CAAW;AAEzD,GANGA;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AAA,CAAQ;AAAA,GAhBjBE,EAiBF,WAAA,mBAAA;AAEAH,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAlBjBE,EAmBF,WAAA,mBAAA;AAYAH,EAAA;AAAA,EAXNC,EAAS;AAAA,IACN,MAAM;AAAA,MACF,cAAce,GAAgC;AAC1C,eAAOA,KAASO,EAAgBP,EAAM,YAAA,CAAa;AAAA,MACvD;AAAA,MACA,YAAYA,GAAgC;AACxC,eAAOA,KAASA,EAAM,YAAA;AAAA,MAC1B;AAAA,IAAA;AAAA,IAEJ,SAAS;AAAA,EAAA,CACZ;AAAA,GA9BQb,EA+BF,WAAA,iBAAA;AA/BJ,IAAMqB,IAANrB;AA8RPqB,EAAiB,cAAA;"}
1
+ {"version":3,"file":"radio-button-group.mjs","sources":["../radio-button.ts","../radio-button-group.ts"],"sourcesContent":["import { LitElement, TemplateResult, html, unsafeCSS, css, nothing } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [RadioButton.ID]: RadioButton;\n }\n}\n\nimport style from \"./scss/button.scss?inline\";\nlet idCounter = 0;\n\nexport class RadioButton extends LitElement {\n public static readonly ID = \"sd-radio-button\";\n public static ensureDefined = (): void => {\n if (!customElements.get(RadioButton.ID)) {\n customElements.define(RadioButton.ID, RadioButton);\n }\n };\n @property({ type: Boolean, reflect: true, attribute: true })\n public checked = false;\n @property({ type: String, reflect: true, attribute: true })\n public value = \"\";\n @property({ type: Boolean, reflect: true, attribute: true })\n public disabled = false;\n @property({ type: String, reflect: true, attribute: true })\n public label = \"\";\n\n private a11yID;\n\n constructor() {\n super();\n this.a11yID = RadioButton.ID + \"_\" + idCounter++;\n }\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n\n public render(): TemplateResult {\n return html`\n <div class=\"root\">\n <div class=\"radio-button-container\">\n <input\n type=\"radio\"\n id=\"${this.a11yID}\"\n .checked=\"${this.checked}\"\n ?disabled=\"${this.disabled}\"\n @click=\"${this.handleClick}\"\n class=\"radio-button\"\n />\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-14 -14 28 28\">\n <circle\n class=\"highlight\"\n style=\"display:none\"\n r=\"11px\"\n fill=\"transparent\"\n stroke-width=\"6px\"\n ></circle>\n <circle class=\"inner\" r=\"6px\" style=\"display:none\" stroke=\"none\"></circle>\n <circle class=\"outer\" r=\"9px\" fill=\"transparent\" stroke-width=\"2px\"></circle>\n </svg>\n </div>\n <label class=\"label\" for=\"${this.a11yID}\" @click=\"${this.handleClick}\">${this.label}</label>\n </div>\n `;\n }\n\n private handleClick = (event: MouseEvent): void => {\n event.preventDefault();\n };\n}\n","import { LitElement, TemplateResult, html, PropertyValues, ComplexAttributeConverter, unsafeCSS, css } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { RadioButton } from \"./radio-button\";\nimport { ValidationLevel } from \"@cas-smartdesign/field-validation-message\";\nimport type { LayoutType, IValueChangeEvent } from \"./types\";\n\nexport { RadioButton } from \"./radio-button\";\nexport type * from \"./types\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [RadioButtonGroup.ID]: RadioButtonGroup;\n }\n}\nimport style from \"./scss/group.scss?inline\";\n\nexport interface CustomEventMap extends HTMLElementEventMap {\n \"value-change\": CustomEvent<IValueChangeEvent>;\n}\n\nexport interface RadioButtonGroup {\n addEventListener<K extends keyof CustomEventMap>(\n event: K,\n listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n addEventListener(\n type: string,\n callback: EventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n removeEventListener<K extends keyof CustomEventMap>(\n type: K,\n listener: (this: this, ev: CustomEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;\n}\n\nexport class RadioButtonGroup extends LitElement {\n public static readonly ID = \"sd-radio-button-group\";\n public static ensureDefined = (): void => {\n RadioButton.ensureDefined();\n if (!customElements.get(RadioButtonGroup.ID)) {\n customElements.define(RadioButtonGroup.ID, RadioButtonGroup);\n }\n };\n @property({ type: String, reflect: true, attribute: true })\n public layout: LayoutType = \"horizontal\";\n @property({ type: String })\n public value = \"\";\n @property({ type: Boolean, reflect: true, attribute: \"uncheck-allowed\" })\n public uncheckAllowed = false;\n @property({ type: Boolean, reflect: true, attribute: true })\n public disabled = false;\n @property({ type: String })\n public validationMessage: string;\n @property({ type: String })\n public validationIconSrc: string;\n @property({\n type: {\n fromAttribute(value: string): ValidationLevel {\n return value && ValidationLevel[value.toLowerCase()];\n },\n toAttribute(value: ValidationLevel): string {\n return value && value.toLowerCase();\n },\n } as ComplexAttributeConverter,\n reflect: true,\n })\n public validationLevel: ValidationLevel;\n\n private _buttonsSlot: HTMLSlotElement;\n private _buttons: HTMLElement[];\n private _focusIndex = -1;\n private _checkedButton: HTMLElement = null;\n\n public get focusIndex(): number {\n return this._focusIndex;\n }\n\n public set focusIndex(index: number) {\n if (index >= -1 && index < this.childElementCount) {\n const oldValue = this._focusIndex;\n this._focusIndex = index;\n if (oldValue !== index) {\n const previousButton = this._buttons[oldValue];\n const currentButton = this._buttons[this.focusIndex];\n this.updateFocused(previousButton, currentButton);\n }\n }\n }\n\n protected firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n this.buttonsSlot.addEventListener(\"slotchange\", this.handleSlotChange);\n this.addEventListener(\"focusin\", this.handleFocusIn);\n this.addEventListener(\"focusout\", this.handleFocusOut);\n this.addEventListener(\"keydown\", this.handleKeyDown);\n }\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (changedProperties.has(\"disabled\")) {\n if (this.disabled) {\n this.disableButtons();\n } else {\n this.enableButtons();\n }\n }\n }\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n public render(): TemplateResult {\n return html`\n <div\n class=\"buttons-container ${this.layout === \"vertical\" ? \"vertical\" : \"horizontal\"}\"\n @click=\"${ifDefined(this.disabled ? undefined : this.handleButtonClick)}\"\n >\n <slot></slot>\n </div>\n ${this.validationMessage &&\n html`\n <sd-field-validation-message\n class=\"validation-message\"\n .message=${this.validationMessage}\n .icon=${this.validationIconSrc}\n .level=${this.validationLevel}\n >\n </sd-field-validation-message>\n `}\n `;\n }\n\n private handleSlotChange = (): void => {\n this._buttons = this.buttonsSlot.assignedElements() as HTMLElement[];\n this._buttons.forEach((button) => {\n if (!button.hasAttribute(\"disabled\") && this.disabled) {\n button.setAttribute(\"disabled\", \"\");\n }\n // prevent radio buttons to be able to get focus by tabbing\n // as focus is handled by this element\n button.setAttribute(\"tabIndex\", \"-1\");\n this.updateCheckedButton(button);\n });\n };\n\n private updateCheckedButton(button: HTMLElement): void {\n if (this._checkedButton && this._checkedButton !== button) {\n this.uncheckButton(button);\n } else if (button.hasAttribute(\"checked\")) {\n this._checkedButton = button;\n const value = button.getAttribute(\"value\");\n this.updateValue(value);\n }\n }\n\n private handleFocusIn = (event: FocusEvent): void => {\n const target = event.target as HTMLElement;\n const ind = this._buttons.findIndex((button) => button == target);\n this.focusIndex = this.focusIndex >= 0 ? this.focusIndex : this.getNextFocusIndex(ind !== -1 ? ind : 0);\n this.updateFocused(null, this._buttons[this.focusIndex]);\n };\n\n private handleFocusOut = (): void => {\n this.updateFocused(this._buttons[this.focusIndex]);\n };\n\n private disableButtons(): void {\n this._buttons?.forEach((button) => {\n button.setAttribute(\"disabled\", \"\");\n });\n }\n\n private enableButtons(): void {\n this._buttons?.forEach((button) => {\n button.removeAttribute(\"disabled\");\n });\n }\n\n private handleButtonClick = (event: MouseEvent): void => {\n // the individual buttons are not focusable\n this.focus();\n const target = this._buttons.find((button) => button.contains(event.target as Node));\n const targetIndex = this._buttons.findIndex((button) => button == target);\n if (targetIndex >= 0) {\n this.focusIndex = targetIndex;\n this.updateChecked();\n }\n };\n\n private fireValueChangeEvent(): void {\n this.dispatchEvent(\n new CustomEvent<IValueChangeEvent>(\"value-change\", {\n detail: {\n value: this.value,\n selectedIndex: this.selectedIndex,\n },\n }),\n );\n }\n\n private handleKeyDown = (event: KeyboardEvent): void => {\n let shouldPrevent = true;\n switch (event.key) {\n case \"Down\":\n case \"ArrowDown\":\n case \"Right\":\n case \"ArrowRight\": {\n this.focusNext();\n break;\n }\n case \"Up\":\n case \"ArrowUp\":\n case \"Left\":\n case \"ArrowLeft\": {\n this.focusPrevious();\n break;\n }\n case \"Enter\": {\n this.updateChecked();\n break;\n }\n default: {\n shouldPrevent = false;\n }\n }\n if (shouldPrevent) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n\n private focusNext() {\n const newIndex = this.getNextFocusIndex(this.focusIndex + 1);\n this.focusIndex = newIndex !== -1 ? newIndex : this.getNextFocusIndex(0);\n if (!this.uncheckAllowed) {\n this.updateChecked();\n }\n }\n\n private focusPrevious() {\n const newIndex = this.getPreviousFocusIndex(this.focusIndex - 1);\n this.focusIndex = newIndex !== -1 ? newIndex : this.getPreviousFocusIndex(this.childElementCount - 1);\n if (!this.uncheckAllowed) {\n this.updateChecked();\n }\n }\n\n private getNextFocusIndex(index: number): number {\n for (let i = index; i < this.childElementCount; i++) {\n const button = this._buttons[i];\n if (this.isFocusable(button)) {\n return i;\n }\n }\n\n return -1;\n }\n\n private getPreviousFocusIndex(index: number): number {\n for (let i = index; i >= 0; i--) {\n const button = this._buttons[i];\n if (this.isFocusable(button)) {\n return i;\n }\n }\n\n return -1;\n }\n\n private isFocusable(button: HTMLElement): boolean {\n return !button.hasAttribute(\"disabled\");\n }\n\n private updateChecked(): void {\n const previousChecked = this._checkedButton;\n const currentChecked = this._buttons[this.focusIndex];\n this._checkedButton = currentChecked;\n if (previousChecked && previousChecked !== currentChecked) {\n this.uncheckButton(previousChecked);\n }\n if (currentChecked) {\n this.toggleButton(currentChecked);\n }\n }\n\n private toggleButton(button: HTMLElement): void {\n const checked = button.hasAttribute(\"checked\");\n if (checked) {\n if (this.uncheckAllowed) {\n this.uncheckButton(button);\n this._checkedButton = null;\n this.updateValue(\"\");\n }\n } else {\n this.checkButton(button);\n this.updateValue(button.getAttribute(\"value\"));\n }\n }\n\n private updateValue(newValue: string): void {\n this.value = newValue;\n this.fireValueChangeEvent();\n }\n\n private updateFocused(previousFocused?: HTMLElement, currentFocused?: HTMLElement): void {\n previousFocused?.removeAttribute?.(\"focused\");\n currentFocused?.setAttribute?.(\"focused\", \"\");\n }\n\n private checkButton(button: HTMLElement): void {\n button.setAttribute(\"checked\", \"\");\n }\n\n private uncheckButton(button: HTMLElement): void {\n button.removeAttribute(\"checked\");\n }\n\n private get buttonsSlot(): HTMLSlotElement {\n if (this.shadowRoot && !this._buttonsSlot) {\n this._buttonsSlot = this.shadowRoot.querySelector(\"slot\");\n }\n return this._buttonsSlot;\n }\n\n private get selectedIndex(): number {\n return this._buttons.indexOf(this._checkedButton);\n }\n}\n\nRadioButtonGroup.ensureDefined();\n"],"names":["idCounter","_RadioButton","_a","LitElement","event","css","unsafeCSS","style","html","__decorateClass","property","RadioButton","_RadioButtonGroup","button","target","ind","targetIndex","shouldPrevent","index","oldValue","previousButton","currentButton","changedProperties","ifDefined","value","newIndex","i","previousChecked","currentChecked","newValue","previousFocused","currentFocused","ValidationLevel","RadioButtonGroup"],"mappings":";;;;;;;;;;AAUA,IAAIA,IAAY;;AAET,MAAMC,KAANC,IAAA,cAA0BC,EAAW;AAAA,EAkBxC,cAAc;AACV,UAAA,GAXJ,KAAO,UAAU,IAEjB,KAAO,QAAQ,IAEf,KAAO,WAAW,IAElB,KAAO,QAAQ,IA8Cf,KAAQ,cAAc,CAACC,MAA4B;AAC/C,MAAAA,EAAM,eAAA;AAAA,IACV,GA1CI,KAAK,SAASF,EAAY,KAAK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0SPqB,EAAiB,cAAA;"}
@@ -34,15 +34,15 @@
34
34
  "repository": "https://github.com/typescript-eslint/typescript-eslint",
35
35
  "licenseUrl": "https://unpkg.com/@typescript-eslint/parser@8.41.0/LICENSE"
36
36
  },
37
- "@vitest/coverage-v8@3.2.4": {
37
+ "@vitest/coverage-v8@4.0.18": {
38
38
  "licenses": "MIT",
39
39
  "repository": "https://github.com/vitest-dev/vitest",
40
- "licenseUrl": "https://unpkg.com/@vitest/coverage-v8@3.2.4/LICENSE"
40
+ "licenseUrl": "https://unpkg.com/@vitest/coverage-v8@4.0.18/LICENSE"
41
41
  },
42
- "@vitest/ui@3.2.4": {
42
+ "@vitest/ui@4.0.18": {
43
43
  "licenses": "MIT",
44
44
  "repository": "https://github.com/vitest-dev/vitest",
45
- "licenseUrl": "https://unpkg.com/@vitest/ui@3.2.4/LICENSE"
45
+ "licenseUrl": "https://unpkg.com/@vitest/ui@4.0.18/LICENSE"
46
46
  },
47
47
  "axe-core@4.10.3": {
48
48
  "licenses": "MPL-2.0",
@@ -59,10 +59,10 @@
59
59
  "repository": "https://github.com/cypress-io/cypress",
60
60
  "licenseUrl": "https://cypress.io"
61
61
  },
62
- "esbuild@0.25.9": {
62
+ "esbuild@0.27.2": {
63
63
  "licenses": "MIT",
64
64
  "repository": "https://github.com/evanw/esbuild",
65
- "licenseUrl": "https://unpkg.com/esbuild@0.25.9/LICENSE.md"
65
+ "licenseUrl": "https://unpkg.com/esbuild@0.27.2/LICENSE.md"
66
66
  },
67
67
  "eslint-config-google@0.14.0": {
68
68
  "licenses": "Apache-2.0",
@@ -119,10 +119,10 @@
119
119
  "repository": "https://github.com/postcss/postcss",
120
120
  "licenseUrl": "https://unpkg.com/postcss@8.5.6/LICENSE"
121
121
  },
122
- "prettier@3.6.2": {
122
+ "prettier@3.8.1": {
123
123
  "licenses": "MIT",
124
124
  "repository": "https://github.com/prettier/prettier",
125
- "licenseUrl": "https://unpkg.com/prettier@3.6.2/LICENSE"
125
+ "licenseUrl": "https://unpkg.com/prettier@3.8.1/LICENSE"
126
126
  },
127
127
  "resolve-pkg@2.0.0": {
128
128
  "licenses": "MIT",
@@ -154,10 +154,10 @@
154
154
  "repository": "https://github.com/stylelint/stylelint",
155
155
  "licenseUrl": "https://unpkg.com/stylelint@16.23.1/LICENSE"
156
156
  },
157
- "tsup@8.5.0": {
157
+ "tsup@8.5.1": {
158
158
  "licenses": "MIT",
159
159
  "repository": "https://github.com/egoist/tsup",
160
- "licenseUrl": "https://unpkg.com/tsup@8.5.0/LICENSE"
160
+ "licenseUrl": "https://unpkg.com/tsup@8.5.1/LICENSE"
161
161
  },
162
162
  "turbo@2.5.6": {
163
163
  "licenses": "MIT",
@@ -169,25 +169,25 @@
169
169
  "repository": "https://github.com/typescript-eslint/typescript-eslint",
170
170
  "licenseUrl": "https://unpkg.com/typescript-eslint@8.41.0/LICENSE"
171
171
  },
172
- "typescript@5.9.2": {
172
+ "typescript@5.9.3": {
173
173
  "licenses": "Apache-2.0",
174
174
  "repository": "https://github.com/microsoft/TypeScript",
175
- "licenseUrl": "https://unpkg.com/typescript@5.9.2/LICENSE.txt"
175
+ "licenseUrl": "https://unpkg.com/typescript@5.9.3/LICENSE.txt"
176
176
  },
177
177
  "vite-tsconfig-paths@5.1.4": {
178
178
  "licenses": "MIT",
179
179
  "repository": "https://github.com/aleclarson/vite-tsconfig-paths",
180
180
  "licenseUrl": "https://unpkg.com/vite-tsconfig-paths@5.1.4/LICENSE"
181
181
  },
182
- "vite@7.1.3": {
182
+ "vite@7.3.1": {
183
183
  "licenses": "MIT",
184
184
  "repository": "https://github.com/vitejs/vite",
185
- "licenseUrl": "https://unpkg.com/vite@7.1.3/LICENSE.md"
185
+ "licenseUrl": "https://unpkg.com/vite@7.3.1/LICENSE.md"
186
186
  },
187
- "vitest@3.2.4": {
187
+ "vitest@4.0.18": {
188
188
  "licenses": "MIT",
189
189
  "repository": "https://github.com/vitest-dev/vitest",
190
- "licenseUrl": "https://unpkg.com/vitest@3.2.4/LICENSE.md"
190
+ "licenseUrl": "https://unpkg.com/vitest@4.0.18/LICENSE.md"
191
191
  },
192
192
  "yargs@18.0.0": {
193
193
  "licenses": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cas-smartdesign/radio-button-group",
3
- "version": "4.1.1",
3
+ "version": "4.3.0",
4
4
  "description": "Radio button and radio button group elements with SmartDesign look & feel",
5
5
  "main": "dist/radio-button-group-with-externals.js",
6
6
  "module": "dist/radio-button-group.mjs",
@@ -8,8 +8,8 @@
8
8
  "types": "dist/radio-button-group.d.ts",
9
9
  "dependencies": {
10
10
  "lit": "^3.3.1",
11
- "@cas-smartdesign/field-validation-message": "^5.1.1",
12
- "@cas-smartdesign/styles": "^3.7.1"
11
+ "@cas-smartdesign/field-validation-message": "^5.3.0",
12
+ "@cas-smartdesign/styles": "^3.8.0"
13
13
  },
14
14
  "files": [
15
15
  "dist",
@@ -20,9 +20,9 @@
20
20
  "access": "public"
21
21
  },
22
22
  "devDependencies": {
23
- "@cas-smartdesign/button": "^5.2.1",
24
- "@cas-smartdesign/element-preview": "^0.3.1",
25
- "@cas-smartdesign/license-generator": "^1.8.1"
23
+ "@cas-smartdesign/button": "^5.3.0",
24
+ "@cas-smartdesign/element-preview": "^0.4.0",
25
+ "@cas-smartdesign/license-generator": "^1.9.0"
26
26
  },
27
27
  "scripts": {
28
28
  "version": "pnpm version",