Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions components/custom/SearchableSelect/SearchableSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export let maxlength = 255
export let disabled = false
/** @type {boolean} if the input is required or not */
export let required = false
/** @type {boolean} applies the showError using error themes*/
export let showError = false

let element = {}
let randomId = generateRandomID('dataList-')
Expand Down Expand Up @@ -74,6 +76,10 @@ const onChange = (e) => {
font-size: 10px;
color: #222;
}
.showError {
border-color: var(--mdc-theme-status-error, var(--mdc-theme-error));
color: var(--mdc-theme-status-error, var(--mdc-theme-error));
}
</style>

<label class="custom-field" style="--field-padding: {padding}; {$$props.class || ''}">
Expand All @@ -82,14 +88,17 @@ const onChange = (e) => {
{disabled}
{maxlength}
class="fs-14 {$$props.class || ''}"
class:showError
style="width: {width}"
{required}
list={randomId}
placeholder="&nbsp;"
bind:this={element}
value={choice}
on:change={onChange}
on:change
on:blur={(e) => dispatch('check', e.target.value)}
on:blur
on:focus
/>
<span class="placeholder">{placeholder}</span>
Expand Down
2 changes: 2 additions & 0 deletions stories/SearchableSelect.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const args = {
required: false,
width: '232px',
maxlength: 255,
showError: false,
'on:chosen': (e) => setNotice(e.detail + ' chosen (accessed by event.detail)'),
'on:check': (e) => {
!args.options[e.detail] && setNotice(e.detail + ' not available')
Expand Down Expand Up @@ -57,3 +58,4 @@ setTimeout(() => {
name="required"
args={copyAndModifyArgs(args, { required: true, 'on:check': () => console.log('this is required') })}
/>
<Story name="showError" args={copyAndModifyArgs(args, { showError: true })} />