Skip to content

Commit c8f879f

Browse files
authored
Add required property (#74)
1 parent 7f6b40f commit c8f879f

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## Next
4+
- Add `required` prop (@ChromuSx)
5+
36
## 2.9.0 - 2023 Nov 3
47
- Add `timePrecision` prop for showing a time picker (@nihanmubashshir)
58

src/lib/DateInput.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
export let valid = true
4949
/** Disable the input **/
5050
export let disabled = false
51+
/** Require a value to submit form **/
52+
export let required = false
5153
/** Pass custom classes */
5254
let classes = ''
5355
export { classes as class }
@@ -189,6 +191,7 @@
189191
value={text}
190192
{placeholder}
191193
{disabled}
194+
{required}
192195
on:focus={() => (visible = true)}
193196
on:mousedown={() => (visible = true)}
194197
on:input={(e) => {

src/routes/DateInput.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
let valid: boolean
1111
let visible: boolean
1212
let disabled: boolean
13+
let required: boolean
1314
let closeOnSelection: boolean
1415
let browseWithoutSelecting: boolean
1516
let format: string
@@ -28,6 +29,7 @@
2829
bind:format
2930
bind:visible
3031
bind:disabled
32+
bind:required
3133
bind:closeOnSelection
3234
bind:browseWithoutSelecting
3335
bind:dynamicPositioning
@@ -44,6 +46,7 @@
4446
<Prop label="format" bind:value={format} />
4547
<Prop label="visible" bind:value={visible} />
4648
<Prop label="disabled" bind:value={disabled} />
49+
<Prop label="required" bind:value={required} />
4750
<Prop label="closeOnSelection" bind:value={closeOnSelection} />
4851
<Prop label="browseWithoutSelecting" bind:value={browseWithoutSelecting} />
4952
<Prop label="dynamicPositioning" bind:value={dynamicPositioning} />

src/routes/docs/+page.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The component will not assign a date value until a specific date is selected in
4040
| `format` | string | Format string |
4141
| `visible` | bool | Whether the date popup is visible |
4242
| `disabled` | bool | Disable the input |
43+
| `required` | bool | Require a value to submit form |
4344
| `closeOnSelection` | bool | Close the date popup when a date is selected |
4445
| `browseWithoutSelecting` | bool | Wait with updating the date until a value is selected |
4546
| `dynamicPositioning` | bool | Dynamicly postions the date popup to best fit on the screen |

0 commit comments

Comments
 (0)