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

Documentation for kselect #821

Merged
merged 4 commits into from
Nov 28, 2024
Merged
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
33 changes: 29 additions & 4 deletions lib/KSelect/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
:class="labelClasses"
:style="activeColorStyle"
>
<!-- @slot Optional slot as alternative to `label` prop -->
<slot>{{ label }}</slot>
</div>

Expand All @@ -51,6 +52,7 @@
class="ui-select-display-value"
:class="{ 'is-placeholder': !hasDisplayText }"
>
<!-- @slot Optional slot to override the display of the selected value -->
<slot name="display">
{{ hasDisplayText ? displayText : (
hasFloatingLabel && isLabelInline) ? null : placeholder }}
Expand Down Expand Up @@ -106,6 +108,7 @@

@mouseover.native.stop="onMouseover(option)"
>
<!-- @slot Optional slot to override the display of the option in the options dropdown -->
<slot
name="option"

Expand All @@ -117,6 +120,7 @@
</KSelectOption>

<div v-show="hasNoResults" class="ui-select-no-results">
<!-- @slot Optional slot as alternative to `noResultsText` prop -->
<slot name="no-results">
{{ noResultsText }}
</slot>
Expand All @@ -128,12 +132,14 @@

<div v-if="hasFeedback" class="ui-select-feedback">
<div v-if="showError" class="ui-select-feedback-text">
<!-- @slot Optional slot as alternative to `invalidText` prop -->
<slot name="error">
{{ invalidText }}
</slot>
</div>

<div v-else-if="showHelp" class="ui-select-feedback-text">
<!-- @slot Optional slot as alternative to `help` prop -->
<slot name="help">
{{ help }}
</slot>
Expand Down Expand Up @@ -214,14 +220,14 @@
},
},
/**
* Placeholder
* Sets the placeholder value
*/
placeholder: {
type: String,
default: '',
},
/**
* Label
* Specifies the label text. Default is empty if not provided.
*/
label: {
type: String,
Expand Down Expand Up @@ -255,6 +261,10 @@
type: String,
default: '',
},
/**
* Object that defines the label, value and image keys in objects of the `options` prop.
* Default: { label: 'label', value: 'value', image: 'image' }
*/
keys: {
type: Object,
default() {
Expand Down Expand Up @@ -297,6 +307,9 @@
type: Boolean,
default: false,
},
/**
* Defines the tooltip and aria-label of the clear button if the select is clearable.
*/
clearText: {
type: String,
default: '',
Expand Down Expand Up @@ -500,14 +513,23 @@
showDropdown() {
if (this.showDropdown) {
this.onOpen();
/**
* Emit on opening dropdown
*/
this.$emit('dropdown-open');
} else {
this.onClose();
/**
* Emit on closing dropdown
*/
this.$emit('dropdown-close');
}
},

query() {
/**
* Emits whenever the query value changes.
*/
this.$emit('query-change', this.query);
},

Expand Down Expand Up @@ -575,7 +597,9 @@
setValue(value) {
value = value ? value : this.multiple ? [] : '';
this.selection = value;

/**
* Emits an 'input' event with the new value when the selection is updated.
*/
this.$emit('input', value);
},

Expand Down Expand Up @@ -863,7 +887,8 @@
},

/**
* @public
* Resets the selected values of dropdown
* @public This is a public method
*/
reset() {
this.setValue(JSON.parse(this.initialValue));
Expand Down