Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 584ac6e

Browse files
committed
Refactor UI component IDs
1 parent 2f40640 commit 584ac6e

File tree

3 files changed

+9
-29
lines changed

3 files changed

+9
-29
lines changed

ui-components/Checkbox.vue

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
<input
44
:class="checkbox()"
55
type="checkbox"
6-
:id="checkboxId"
6+
:id="$props.id"
77
:checked="modelValue"
88
@input="emitUpdate"
99
:disabled="disabled"
1010
/>
11-
<label :class="label()" :for="checkboxId">
11+
<label :class="label()" :for="$props.id">
1212
{{ props.label }}
1313
</label>
1414
<small :class="small()">
@@ -91,9 +91,9 @@ type Props = {
9191
label?: string
9292
9393
// Checkbox props
94+
id: string
9495
modelValue?: boolean
9596
disabled?: boolean,
96-
id?: string
9797
}
9898
9999
const emit = defineEmits(['update:modelValue'])
@@ -104,13 +104,6 @@ const emitUpdate = (event: Event) => {
104104
105105
const props = defineProps<Props>()
106106
107-
const checkboxId = ref(props.id || '')
108-
onMounted(() => {
109-
if (!props.id) {
110-
checkboxId.value = crypto.randomUUID()
111-
}
112-
})
113-
114107
const { base, checkbox, small, label, svg } = checkboxTV({
115108
size: props.size,
116109
variant: props.variant

ui-components/Input.vue

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div :class="base()">
33
<input
4-
:id="inputId"
4+
:id="$props.id"
55
:type="$props.type"
66
:placeholder="$props.label"
77
:disabled="$props.disabled"
@@ -10,7 +10,7 @@
1010
@input="emitUpdate"
1111
:pattern="pattern"
1212
/>
13-
<label :for="inputId" :class="label()">
13+
<label :for="$props.id" :class="label()">
1414
{{ $props.label }}
1515
</label>
1616
<small :class="small()">
@@ -78,12 +78,12 @@ type Props = {
7878
label?: string
7979
8080
// Text input props
81+
id: string
8182
value?: string | number | null
8283
modelValue?: string | number | null
8384
disabled?: boolean
8485
pattern?: string
8586
type?: 'text' | 'password' | 'number'
86-
id?: string
8787
8888
// Number input
8989
min?: number | string
@@ -106,13 +106,6 @@ const props = withDefaults(defineProps<Props>(), {
106106
type: 'text'
107107
})
108108
109-
const inputId = ref(props.id || '')
110-
onMounted(() => {
111-
if (!props.id) {
112-
inputId.value = crypto.randomUUID()
113-
}
114-
})
115-
116109
const { base, input, small, label } = inputTV({
117110
size: props.size,
118111
variant: props.variant

ui-components/Toggle.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
<input
44
:class="toggle()"
55
type="checkbox"
6-
:id="toggleId"
6+
:id="$props.id"
77
:value="modelValue"
88
@input="emitUpdate"
99
:disabled="disabled"
1010
/>
11-
<label :class="label()" :for="toggleId">
11+
<label :class="label()" :for="$props.id">
1212
{{ props.helper }}
1313
</label>
1414
<small :class="small()">
@@ -77,9 +77,9 @@ type Props = {
7777
label?: string
7878
7979
// Toggle props
80+
id: string
8081
modelValue?: boolean
8182
disabled?: boolean
82-
id?: string
8383
}
8484
8585
const emit = defineEmits(['update:modelValue'])
@@ -90,12 +90,6 @@ const emitUpdate = (event: Event) => {
9090
9191
const props = defineProps<Props>()
9292
93-
const toggleId = ref(props.id || '')
94-
onMounted(() => {
95-
if (!props.id) {
96-
toggleId.value = crypto.randomUUID()
97-
}
98-
})
9993
10094
const { base, toggle, small, label, svg } = toggleTV({
10195
size: props.size,

0 commit comments

Comments
 (0)