Skip to content

Commit 053af32

Browse files
committed
feat(SearchableSelect): add required prop
1 parent a065d4e commit 053af32

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

components/custom/SearchableSelect/SearchableSelect.svelte

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export let padding = '12px'
99
export let width = '232px'
1010
export let maxlength = 255
1111
export let disabled = false
12+
export let required = false
1213
1314
let element = {}
1415
@@ -73,6 +74,7 @@ const onChange = () => {
7374
{maxlength}
7475
class="fs-14 {$$props.class}"
7576
style="width: {width}"
77+
{required}
7678
list={randomId}
7779
placeholder=" "
7880
bind:this={element}

stories/SearchableSelect.stories.svelte

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script>
22
import { Meta, Template, Story } from '@storybook/addon-svelte-csf'
33
import { SearchableSelect } from '../components/custom'
4+
import { Button } from '../components/mdc'
45
import { copyAndModifyArgs } from './helpers.js'
56
67
const args = {
@@ -12,6 +13,7 @@ const args = {
1213
},
1314
placeholder: 'choice 1',
1415
padding: '12px',
16+
required: false,
1517
choice: 'choice 1',
1618
width: '232px',
1719
maxlength: 255,
@@ -26,7 +28,10 @@ const args = {
2628
<Meta title="Atoms/SearchableSelect" component={SearchableSelect} />
2729

2830
<Template let:args>
29-
<SearchableSelect {...args} on:chosen={args['on:chosen']} on:check={args['on:check']} />
31+
<form on:submit={() => console.log('submitted')}>
32+
<SearchableSelect {...args} on:chosen={args['on:chosen']} on:check={args['on:check']} />
33+
<Button>Submit</Button>
34+
</form>
3035
</Template>
3136

3237
<Story name="Default" {args} />
@@ -35,3 +40,7 @@ const args = {
3540
<Story name="Disabled" args={copyAndModifyArgs(args, { disabled: true })} />
3641
<Story name="Maxlength" args={copyAndModifyArgs(args, { maxlength: 25 })} />
3742
<Story name="padding" args={copyAndModifyArgs(args, { padding: '20px' })} />
43+
<Story
44+
name="required"
45+
args={copyAndModifyArgs(args, { required: true, 'on:check': () => console.log('this is required') })}
46+
/>

0 commit comments

Comments
 (0)