Skip to content

Commit

Permalink
merge: #47 from ginger/autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
alycejenni authored Jan 23, 2025
2 parents 7f569f7 + b70c480 commit 0030be8
Show file tree
Hide file tree
Showing 12 changed files with 845 additions and 48 deletions.
8 changes: 5 additions & 3 deletions src/components/inputs/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ defineExpose({
}
}
.checkbox {
.checkbox,
.radio {
&.rootWrapper {
width: auto;
Expand Down Expand Up @@ -357,8 +358,9 @@ defineExpose({
}
&.rootWrapper--right {
grid-template-areas: 'input label .';
grid-template-columns: auto auto 1fr;
// extend the label to the right for dropdowns
grid-template-areas: 'input label';
grid-template-columns: auto 1fr;
&.rootWrapper--help {
grid-template-areas: 'input label help';
Expand Down
9 changes: 7 additions & 2 deletions src/components/inputs/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ export function useChangeEmits(emit, props) {
emit('change', newValue);
}

function _updateModel(newValue) {
emit('update:modelValue', newValue);
internalModel.value = newValue;
}

const emitChange = debounce(_emitChange, delay);
const updateModel = debounce(_updateModel, delay);

function valueChanged(newValue) {
emit('update:modelValue', newValue);
internalModel.value = newValue;
updateModel(newValue);
emitChange(newValue);
}

Expand Down
65 changes: 65 additions & 0 deletions src/components/inputs/dropdown/DropdownSearch.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import ZoaDropdownSearch from './DropdownSearch.vue';
import { ZoaInput } from '../../index.js';
import { argTypes, renderSetup } from '../stories.js';

const meta = {
component: ZoaDropdownSearch,
title: 'Components/Inputs/Select/DropdownSearch',
argTypes,
parameters: {
docs: {
description: {
component:
'A dropdown/select component allowing searching/filtering the list of potential options. Options can be passed in as a mixed list of strings or objects with `label` and `value` keys. Each option must have a unique value (or label, if not using values).',
},
},
},
};

export default meta;

const Base = {
args: {
label: 'Searchable Dropdown',
labelPosition: 'above',
help: 'Some example help text.',
helpPosition: 'right',
disabled: false,
delay: 0,
placeholder: 'select option',
options: [
'Option 1',
{
label: 'Option 2',
value: 'opt2',
},
{ label: 'Option 3', value: 'opt3' },
{ label: 'Option 4' },
'Option 5',
],
searchDelay: 200,
enableSearch: true,
itemHeight: 38,
},
render: (args) => ({
components: { ZoaInput },
setup() {
return renderSetup(args);
},
template: `
<zoa-input zoa-type="dropdown-search"
:class="rootClass"
:label="label"
:label-position="labelPosition"
:help="help"
:help-position="helpPosition"
:disabled="disabled"
:options="{delay, placeholder, options, searchDelay, enableSearch, itemHeight}"
/>
`,
}),
};

export const Default = {
...Base,
};
Loading

0 comments on commit 0030be8

Please sign in to comment.