@@ -52,7 +104,7 @@ export class StarRadioGroup extends LitElement {
`
}
- handleEvent(evt: Event) {
+ _onSingleRadioClick(evt: Event) {
const target = evt.target as StarRadio
if (this.radios.indexOf(target) !== -1 && target.checked !== true) {
target.checked = true
@@ -61,18 +113,26 @@ export class StarRadioGroup extends LitElement {
radio.checked = false
}
}
- this.selected = target.value
- this.dispatchEvent(
- new Event('change', {
- bubbles: true,
- composed: false,
- })
- )
+ this.emit('change')
}
}
- protected override firstUpdated(changes: PropertyValues): void {
- super.firstUpdated(changes)
+ _onMultipleRadioClick(evt: Event) {
+ const target = evt.target as StarRadio
+ if (this.radios.indexOf(target) !== -1) {
+ target.checked = !target.checked
+ this.emit('change')
+ }
+ }
+
+ handleEvent(evt: Event) {
+ ;(this.multiple
+ ? this._onMultipleRadioClick
+ : this._onSingleRadioClick
+ ).call(this, evt)
+ }
+
+ protected override firstUpdated(): void {
for (const radio of this.radios) {
if (radio.value === this.selected) {
radio.checked = true
diff --git a/src/components/select/README.md b/src/components/select/README.md
index 1ab43dc..c3190d2 100644
--- a/src/components/select/README.md
+++ b/src/components/select/README.md
@@ -1,8 +1,155 @@
# 选择
-如: iPhone-通用-键盘-听写语言
+star-select 的作用: 将原生 \