Skip to content

Commit

Permalink
radio: disable/enable
Browse files Browse the repository at this point in the history
  • Loading branch information
denisavitski committed Jan 11, 2025
1 parent 2e01e3d commit 9f543cf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aptechka",
"version": "0.51.2",
"version": "0.51.3",
"repository": {
"type": "git",
"url": "git+https://github.com/denisavitski/aptechka.git"
Expand Down
24 changes: 20 additions & 4 deletions src/components/packages/radio/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export class RadioElement<T extends string = string> extends HTMLElement {
#value: T | undefined
#currentButtonElement: HTMLElement | null = null

#disabled = false

public get value() {
return this.#value
}
Expand All @@ -21,6 +23,18 @@ export class RadioElement<T extends string = string> extends HTMLElement {
return this.#currentButtonElement
}

public get disabled() {
return this.#disabled
}

public disable() {
this.#disabled = true
}

public enable() {
this.#disabled = false
}

public addButton(element: HTMLElement) {
this.#buttonElements.push(element)

Expand Down Expand Up @@ -99,12 +113,14 @@ export class RadioElement<T extends string = string> extends HTMLElement {
}

#buttonClickListener = (e: Event) => {
const ct = e.currentTarget as HTMLElement
if (!this.#disabled) {
const ct = e.currentTarget as HTMLElement

const value = ct.getAttribute('data-value')
const value = ct.getAttribute('data-value')

if (value) {
this.setValue(value as T)
if (value) {
this.setValue(value as T)
}
}
}

Expand Down

0 comments on commit 9f543cf

Please sign in to comment.