Skip to content

Commit b738c7e

Browse files
authored
add id (#77)
1 parent c8f879f commit b738c7e

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/lib/DateInput.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
export let min = new Date(defaultDate.getFullYear() - 20, 0, 1)
4343
/** The latest value the user can select */
4444
export let max = new Date(defaultDate.getFullYear(), 11, 31, 23, 59, 59, 999)
45+
/** optional id attribute */
46+
export let id = ''
4547
/** Placeholder text to show when input field is empty */
4648
export let placeholder = '2020-12-31 23:00:00'
4749
/** Whether the text is valid */
@@ -189,6 +191,7 @@
189191
class:invalid={!valid}
190192
type="text"
191193
value={text}
194+
id={id || null}
192195
{placeholder}
193196
{disabled}
194197
{required}

src/lib/DatePicker.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
3939
/** Show a time picker with the specified precision */
4040
export let timePrecision: 'minute' | 'second' | 'millisecond' | null = null
41-
4241
/** The earliest year the user can select */
4342
export let min = new Date(defaultDate.getFullYear() - 20, 0, 1)
4443
/** The latest year the user can select */

src/routes/DateInput.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import Prop from './prop.svelte'
44
import Split from './split.svelte'
55
6+
let id: string
67
let placeholder: string
78
let value: Date
89
let min: Date
@@ -21,6 +22,7 @@
2122
<Split>
2223
<DateInput
2324
slot="left"
25+
bind:id
2426
bind:value
2527
bind:min
2628
bind:max
@@ -41,6 +43,7 @@
4143
<Prop label="value">{value}</Prop>
4244
<Prop label="min" bind:value={min} />
4345
<Prop label="max" bind:value={max} />
46+
<Prop label="id" bind:value={id} />
4447
<Prop label="placeholder" bind:value={placeholder} />
4548
<Prop label="valid" bind:value={valid} />
4649
<Prop label="format" bind:value={format} />

0 commit comments

Comments
 (0)