Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(QSelect): add disabled class for wrapper #316

Merged
merged 2 commits into from
Jul 1, 2022
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
13 changes: 12 additions & 1 deletion src/qComponents/QSelect/src/QSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div
ref="root"
class="q-select"
:class="qSelectClasses"
@click="toggleMenu"
@mouseenter="state.hover = true"
@mouseleave="state.hover = false"
Expand Down Expand Up @@ -122,7 +123,12 @@ import type { QFormItemProvider } from '@/qComponents/QFormItem';
import type { QInputInstance } from '@/qComponents/QInput';
import type { QOptionModel, QOptionPropValue } from '@/qComponents/QOption';

import type { Nullable, Optional, UnwrappedInstance } from '#/helpers';
import type {
Nullable,
Optional,
UnwrappedInstance,
ClassValue
} from '#/helpers';

import QSelectDropdown from './components/QSelectDropdown';
import type { QSelectDropdownInstance } from './components/QSelectDropdown';
Expand Down Expand Up @@ -464,6 +470,10 @@ export default defineComponent({
);
});

const qSelectClasses = computed<ClassValue>(() => ({
'q-select_disabled': isDisabled.value
}));

const iconClass = computed<string>(() => {
if (props.remote && props.filterable) return 'q-icon-search';
return state.isDropdownShown
Expand Down Expand Up @@ -944,6 +954,7 @@ export default defineComponent({
isReadonly,
isDisabled,
isClearBtnShown,
qSelectClasses,
iconClass,
emptyText,
isNewOptionShown,
Expand Down
3 changes: 2 additions & 1 deletion src/qComponents/QSelect/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Ref, ComputedRef } from 'vue';
import type { QInputInstance } from '@/qComponents/QInput';
import type { QOptionModel, QOptionPropValue } from '@/qComponents/QOption';

import type { Nullable, UnwrappedInstance } from '#/helpers';
import type { Nullable, UnwrappedInstance, ClassValue } from '#/helpers';

import type { QSelectDropdownInstance } from './components/QSelectDropdown';
import type { QSelectTagsInstance } from './components/QSelectTags';
Expand Down Expand Up @@ -76,6 +76,7 @@ export interface QSelectInstance {
isReadonly: ComputedRef<Nullable<boolean>>;
isDisabled: ComputedRef<boolean>;
isClearBtnShown: ComputedRef<Nullable<boolean>>;
qSelectClasses: ComputedRef<ClassValue>;
iconClass: ComputedRef<string>;
emptyText: ComputedRef<string>;
isNewOptionShown: ComputedRef<boolean>;
Expand Down