-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add label slot * Update docs/api-reference.md * Update docs/api-reference.md * return emptyModelValue if nothing is selected * lint * only expose selected Co-authored-by: Ernest <iendeavor.github.io@gmail.com>
- Loading branch information
Showing
7 changed files
with
150 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link | ||
type="text/css" | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" | ||
/> | ||
<link type="text/css" rel="stylesheet" href="/dist/index.css" /> | ||
<script src="https://unpkg.com/vue@next/dist/vue.global.prod.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div id="app"></div> | ||
<script src="/dist/vue-next-select.iife.js"></script> | ||
<script> | ||
const { ref, createApp } = Vue | ||
const app = createApp({ | ||
name: 'app', | ||
setup() { | ||
const selectedOptions = ref() | ||
const options = ref(['i']) | ||
return { | ||
selectedOptions, | ||
options, | ||
} | ||
}, | ||
template: ` | ||
<vue-select | ||
v-model="selectedOptions" | ||
:options="options" | ||
> | ||
<template #label="{ selected }"> | ||
<span v-if="selected">{{ selected.toUpperCase() }}</span> | ||
<span v-else>Select option</span> | ||
</template> | ||
</vue-select> | ||
`, | ||
}) | ||
|
||
app.component('vue-select', VueNextSelect) | ||
app.mount(document.querySelector('#app')) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference types="cypress" /> | ||
import path from 'path' | ||
|
||
context('label', () => { | ||
it('should show the placeholder then the selected', () => { | ||
cy.visit(path.join(__dirname, 'index.html')) | ||
cy.get('.vue-input').should('have.text', 'Select option') | ||
cy.get('.vue-select').click() | ||
cy.get('.vue-dropdown').children().first().click() | ||
cy.get('.vue-input').should('have.text', 'I') | ||
}) | ||
|
||
it('should show the selected options count', () => { | ||
cy.visit(path.join(__dirname, 'multiple.html')) | ||
cy.get('.vue-input').should('have.text', 'Select option') | ||
cy.get('.vue-select').click() | ||
cy.get('.vue-dropdown').children().first().click() | ||
cy.get('.vue-input').should('have.text', '1') | ||
cy.get('.vue-dropdown').children().first().next().click() | ||
cy.get('.vue-input').should('have.text', '2') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link | ||
type="text/css" | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" | ||
/> | ||
<link type="text/css" rel="stylesheet" href="/dist/index.css" /> | ||
<script src="https://unpkg.com/vue@next/dist/vue.global.prod.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div id="app"></div> | ||
<script src="/dist/vue-next-select.iife.js"></script> | ||
<script> | ||
const { ref, createApp } = Vue | ||
const app = createApp({ | ||
name: 'app', | ||
setup() { | ||
const selectedOptions = ref([]) | ||
const options = ref(['i', 'j', 'k']) | ||
return { | ||
selectedOptions, | ||
options, | ||
} | ||
}, | ||
template: ` | ||
<vue-select | ||
v-model="selectedOptions" | ||
:options="options" | ||
multiple | ||
> | ||
<template #label="{ selected }"> | ||
<span v-if="selected.length">{{ selected.length }}</span> | ||
<span v-else>Select option</span> | ||
</template> | ||
</vue-select> | ||
`, | ||
}) | ||
|
||
app.component('vue-select', VueNextSelect) | ||
app.mount(document.querySelector('#app')) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters