slim-select 1.27.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/.prettierrc +6 -0
- package/.vscode/extensions.json +3 -0
- package/.vscode/settings.json +15 -5
- package/README.md +2 -1
- package/dist/helper.d.ts +1 -4
- package/dist/index.d.ts +38 -58
- package/dist/render.d.ts +109 -0
- package/dist/select.d.ts +31 -20
- package/dist/settings.d.ts +33 -0
- package/dist/slimselect.cjs.js +2 -0
- package/dist/slimselect.cjs.js.map +1 -0
- package/dist/slimselect.css +1 -2
- package/dist/slimselect.css.map +1 -0
- package/dist/slimselect.es.js +2 -0
- package/dist/slimselect.es.js.map +1 -0
- package/dist/slimselect.global.js +2 -0
- package/dist/slimselect.global.js.map +1 -0
- package/dist/slimselect.js +2 -1956
- package/dist/slimselect.js.map +1 -0
- package/dist/slimselect.umd.js +2 -0
- package/dist/slimselect.umd.js.map +1 -0
- package/dist/store.d.ts +71 -0
- package/docs/assets/check-mark.svg +6 -0
- package/docs/assets/data.js +59 -0
- package/docs/assets/home.css +1 -0
- package/docs/assets/home.js +1 -0
- package/docs/assets/index.css +1 -0
- package/docs/assets/index.js +16 -0
- package/docs/assets/index2.js +274 -0
- package/docs/assets/index3.js +126 -0
- package/docs/assets/index4.js +60 -0
- package/docs/assets/install.js +34 -0
- package/docs/assets/selects.js +55 -0
- package/docs/index.html +18 -5
- package/docs.go +3 -1
- package/index.html +16 -0
- package/jest.config.js +7 -0
- package/package.json +39 -39
- package/src/docs/app.vue +185 -76
- package/src/docs/assets/scss/_variables.scss +26 -10
- package/src/docs/assets/scss/alert.scss +12 -0
- package/src/docs/assets/scss/animations.scss +5 -3
- package/src/docs/assets/scss/button.scss +21 -0
- package/src/docs/assets/scss/index.scss +8 -6
- package/src/docs/assets/scss/input.scss +2 -2
- package/src/docs/assets/scss/layout.scss +195 -65
- package/src/docs/assets/scss/misc.scss +144 -34
- package/src/docs/assets/scss/prism.scss +155 -153
- package/src/docs/env.d.ts +12 -0
- package/src/docs/images/check-mark.svg +6 -0
- package/src/docs/images/chrome.svg +22 -0
- package/src/docs/images/firefox.svg +58 -0
- package/src/docs/images/github.png +0 -0
- package/src/docs/images/ie.svg +11 -0
- package/src/docs/images/npm.png +0 -0
- package/src/docs/images/opera.svg +15 -0
- package/src/docs/images/safari.svg +22 -0
- package/src/docs/main.ts +27 -0
- package/src/docs/pages/data.vue +130 -0
- package/src/docs/pages/events/addable.vue +79 -0
- package/src/docs/pages/events/before_after_change.vue +140 -0
- package/src/docs/pages/events/before_after_open_close.vue +122 -0
- package/src/docs/pages/events/error.vue +59 -0
- package/src/docs/pages/events/index.vue +33 -0
- package/src/docs/pages/events/search.vue +154 -0
- package/src/docs/pages/events/search_filter.vue +45 -0
- package/src/docs/pages/home.vue +96 -116
- package/src/docs/pages/install.vue +47 -74
- package/src/docs/pages/methods/destroy.vue +66 -0
- package/src/docs/pages/methods/enable_disable.vue +70 -0
- package/src/docs/pages/methods/get_data.vue +81 -0
- package/src/docs/pages/methods/get_selected.vue +78 -0
- package/src/docs/pages/methods/index.vue +36 -0
- package/src/docs/pages/methods/open_close.vue +63 -0
- package/src/docs/pages/methods/search.vue +62 -0
- package/src/docs/pages/methods/set_data.vue +106 -0
- package/src/docs/pages/methods/set_selected.vue +70 -0
- package/src/docs/pages/selects.vue +108 -114
- package/src/docs/pages/settings/always_open.vue +88 -0
- package/src/docs/pages/settings/close_on_select.vue +69 -0
- package/src/docs/pages/settings/content_location.vue +64 -0
- package/src/docs/pages/settings/content_position.vue +86 -0
- package/src/docs/pages/settings/css.vue +73 -0
- package/src/docs/pages/settings/data_attributes.vue +39 -0
- package/src/docs/pages/settings/deselect.vue +69 -0
- package/src/docs/pages/settings/display.vue +88 -0
- package/src/docs/pages/settings/hide_selected.vue +73 -0
- package/src/docs/pages/settings/html.vue +86 -0
- package/src/docs/pages/settings/index.vue +73 -0
- package/src/docs/pages/settings/mandatory.vue +91 -0
- package/src/docs/pages/settings/min_max.vue +61 -0
- package/src/docs/pages/settings/open_position.vue +60 -0
- package/src/docs/pages/settings/placeholder.vue +72 -0
- package/src/docs/pages/settings/search.vue +140 -0
- package/src/docs/pages/settings/select.vue +32 -0
- package/src/docs/pages/settings/select_by_group.vue +46 -0
- package/src/docs/pages/settings/show_tooltip.vue +44 -0
- package/src/docs/pages/settings/styles.vue +51 -0
- package/src/docs/router.ts +41 -13
- package/src/slim-select/helper.ts +25 -86
- package/src/slim-select/index.ts +318 -413
- package/src/slim-select/render.test.ts +39 -0
- package/src/slim-select/render.ts +1129 -0
- package/src/slim-select/rollup.config.mjs +39 -0
- package/src/slim-select/select.test.ts +155 -0
- package/src/slim-select/select.ts +280 -107
- package/src/slim-select/settings.ts +68 -0
- package/src/slim-select/slimselect.scss +263 -278
- package/src/slim-select/store.test.ts +220 -0
- package/src/slim-select/store.ts +320 -0
- package/src/slim-select/tsconfig.json +11 -5
- package/src/vue/slimselect.vue +61 -0
- package/tsconfig.json +10 -29
- package/vite.config.ts +18 -0
- package/.browserslistrc +0 -4
- package/.postcssrc.js +0 -5
- package/.travis.yml +0 -22
- package/babel.config.js +0 -5
- package/dist/config.d.ts +0 -83
- package/dist/data.d.ts +0 -50
- package/dist/slim.d.ts +0 -50
- package/dist/slimselect.min.css +0 -1
- package/dist/slimselect.min.js +0 -1
- package/dist/slimselect.min.mjs +0 -1
- package/docs/css/app.d5840d21.css +0 -1
- package/docs/css/chunk-vendors.4db6930d.css +0 -1
- package/docs/css/home.57020178.css +0 -1
- package/docs/css/install.baa5d3fb.css +0 -1
- package/docs/css/methods.728c742a.css +0 -1
- package/docs/css/options.b28a32ef.css +0 -1
- package/docs/css/selects.1a7e1e6a.css +0 -1
- package/docs/js/app.db13c724.js +0 -2
- package/docs/js/app.db13c724.js.map +0 -1
- package/docs/js/chunk-vendors.cc40aa28.js +0 -28
- package/docs/js/chunk-vendors.cc40aa28.js.map +0 -1
- package/docs/js/home.8bcb44fd.js +0 -2
- package/docs/js/home.8bcb44fd.js.map +0 -1
- package/docs/js/install.02f31028.js +0 -2
- package/docs/js/install.02f31028.js.map +0 -1
- package/docs/js/methods.1b31e988.js +0 -11
- package/docs/js/methods.1b31e988.js.map +0 -1
- package/docs/js/options.39fe1005.js +0 -2
- package/docs/js/options.39fe1005.js.map +0 -1
- package/docs/js/selects.f4d0b859.js +0 -2
- package/docs/js/selects.f4d0b859.js.map +0 -1
- package/src/docs/pages/methods.vue +0 -427
- package/src/docs/pages/options.vue +0 -1480
- package/src/main.ts +0 -29
- package/src/shims-vue.d.ts +0 -8
- package/src/slim-select/config.ts +0 -118
- package/src/slim-select/data.ts +0 -377
- package/src/slim-select/slim.ts +0 -770
- package/tslint.json +0 -26
- package/vue.config.js +0 -23
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
import SlimSelect from '../../../slim-select'
|
|
5
|
+
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
name: 'GetSelected',
|
|
8
|
+
data() {
|
|
9
|
+
return {
|
|
10
|
+
selectedSingle: null as SlimSelect | null,
|
|
11
|
+
selectedSingleValue: [] as string[],
|
|
12
|
+
selectedMultiple: null as SlimSelect | null,
|
|
13
|
+
selectedMultipleValue: [] as string[],
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
mounted() {
|
|
17
|
+
this.selectedSingle = new SlimSelect({
|
|
18
|
+
select: this.$refs.selectedSingle as HTMLSelectElement,
|
|
19
|
+
})
|
|
20
|
+
this.selectedMultiple = new SlimSelect({
|
|
21
|
+
select: this.$refs.selectedMultiple as HTMLSelectElement,
|
|
22
|
+
})
|
|
23
|
+
},
|
|
24
|
+
methods: {
|
|
25
|
+
getSelected() {
|
|
26
|
+
this.selectedSingleValue = this.selectedSingle!.getSelected()
|
|
27
|
+
this.selectedMultipleValue = this.selectedMultiple!.getSelected()
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<div id="getSelected" class="content">
|
|
35
|
+
<h2 class="header">getSelected</h2>
|
|
36
|
+
<p>The getSelected method will return an array of the currently selected value strings.</p>
|
|
37
|
+
|
|
38
|
+
<div class="alert info">
|
|
39
|
+
Whether or not its a single or multiple select, getSelected will always return an array.
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div class="row">
|
|
43
|
+
<div class="btn" @click="getSelected">Get Selected</div>
|
|
44
|
+
|
|
45
|
+
<div>
|
|
46
|
+
<select ref="selectedSingle">
|
|
47
|
+
<option value="value1">Value 1</option>
|
|
48
|
+
<option value="value2">Value 2</option>
|
|
49
|
+
<option value="value3">Value 3</option>
|
|
50
|
+
</select>
|
|
51
|
+
<div class="pad-t-m pad-b-m" v-if="selectedSingleValue.length">
|
|
52
|
+
<b>Single Select Value:</b> {{ selectedSingleValue }}
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div>
|
|
57
|
+
<select ref="selectedMultiple" multiple>
|
|
58
|
+
<option value="value1">Value 1</option>
|
|
59
|
+
<option value="value2" selected>Value 2</option>
|
|
60
|
+
<option value="value3" selected>Value 3</option>
|
|
61
|
+
</select>
|
|
62
|
+
<div class="pad-t-m pad-b-m" v-if="selectedMultipleValue.length">
|
|
63
|
+
<b>Multi Select Value:</b> {{ selectedMultipleValue }}
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<pre>
|
|
69
|
+
<code class="language-javascript">
|
|
70
|
+
var select = new SlimSelect({
|
|
71
|
+
select: '#selectElement'
|
|
72
|
+
})
|
|
73
|
+
var values = select.getSelected() // Will return an array of strings
|
|
74
|
+
console.log(values)
|
|
75
|
+
</code>
|
|
76
|
+
</pre>
|
|
77
|
+
</div>
|
|
78
|
+
</template>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
import GetSelected from './get_selected.vue'
|
|
5
|
+
import SetSelected from './set_selected.vue'
|
|
6
|
+
import GetData from './get_data.vue'
|
|
7
|
+
import SetData from './set_data.vue'
|
|
8
|
+
import EnableDisable from './enable_disable.vue'
|
|
9
|
+
import Search from './search.vue'
|
|
10
|
+
import Destroy from './destroy.vue'
|
|
11
|
+
|
|
12
|
+
export default defineComponent({
|
|
13
|
+
name: 'Methods',
|
|
14
|
+
components: {
|
|
15
|
+
GetSelected,
|
|
16
|
+
SetSelected,
|
|
17
|
+
GetData,
|
|
18
|
+
SetData,
|
|
19
|
+
EnableDisable,
|
|
20
|
+
Search,
|
|
21
|
+
Destroy,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<div id="methods" class="contents">
|
|
28
|
+
<GetSelected />
|
|
29
|
+
<SetSelected />
|
|
30
|
+
<GetData />
|
|
31
|
+
<SetData />
|
|
32
|
+
<EnableDisable />
|
|
33
|
+
<Search />
|
|
34
|
+
<Destroy />
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
import SlimSelect, { DataArray } from '../../../slim-select'
|
|
5
|
+
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
name: 'OpenClose',
|
|
8
|
+
data() {
|
|
9
|
+
return {
|
|
10
|
+
openCloseSingle: null as SlimSelect | null,
|
|
11
|
+
openCloseMultiple: null as SlimSelect | null,
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
mounted() {
|
|
15
|
+
// Open / Close
|
|
16
|
+
this.openCloseSingle = new SlimSelect({
|
|
17
|
+
select: this.$refs.openCloseSingle as HTMLSelectElement,
|
|
18
|
+
})
|
|
19
|
+
this.openCloseMultiple = new SlimSelect({
|
|
20
|
+
select: this.$refs.openCloseMultiple as HTMLSelectElement,
|
|
21
|
+
})
|
|
22
|
+
},
|
|
23
|
+
methods: {
|
|
24
|
+
setOpenClose() {
|
|
25
|
+
if (!this.openCloseSingle!.settings.isOpen) {
|
|
26
|
+
this.openCloseSingle!.open()
|
|
27
|
+
this.openCloseMultiple!.open()
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<div class="content">
|
|
36
|
+
<h2 class="header">open / close</h2>
|
|
37
|
+
<p>The open and close methods will do just that.</p>
|
|
38
|
+
|
|
39
|
+
<div class="row">
|
|
40
|
+
<div class="btn" @click="setOpenClose">Open/Close</div>
|
|
41
|
+
<select ref="openCloseSingle">
|
|
42
|
+
<option value="value1">Value 1</option>
|
|
43
|
+
<option value="value2">Value 2</option>
|
|
44
|
+
<option value="value3">Value 3</option>
|
|
45
|
+
</select>
|
|
46
|
+
<select ref="openCloseMultiple" multiple>
|
|
47
|
+
<option value="value1">Value 1</option>
|
|
48
|
+
<option value="value2">Value 2</option>
|
|
49
|
+
<option value="value3">Value 3</option>
|
|
50
|
+
</select>
|
|
51
|
+
</div>
|
|
52
|
+
<pre>
|
|
53
|
+
<code class="language-javascript">
|
|
54
|
+
var select = new SlimSelect({
|
|
55
|
+
select: '#selectElement',
|
|
56
|
+
})
|
|
57
|
+
select.open()
|
|
58
|
+
// or
|
|
59
|
+
select.close()
|
|
60
|
+
</code>
|
|
61
|
+
</pre>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
import SlimSelect from '../../../slim-select'
|
|
5
|
+
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
name: 'Search',
|
|
8
|
+
data() {
|
|
9
|
+
return {
|
|
10
|
+
searchSingle: null as SlimSelect | null,
|
|
11
|
+
searchMultiple: null as SlimSelect | null,
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
mounted() {
|
|
15
|
+
this.searchSingle = new SlimSelect({
|
|
16
|
+
select: this.$refs.searchSingle as HTMLSelectElement,
|
|
17
|
+
})
|
|
18
|
+
this.searchMultiple = new SlimSelect({
|
|
19
|
+
select: this.$refs.searchMultiple as HTMLSelectElement,
|
|
20
|
+
})
|
|
21
|
+
},
|
|
22
|
+
methods: {
|
|
23
|
+
setSearch() {
|
|
24
|
+
this.searchSingle!.open()
|
|
25
|
+
this.searchSingle!.search('value 2')
|
|
26
|
+
|
|
27
|
+
this.searchMultiple!.open()
|
|
28
|
+
this.searchMultiple!.search('value 2')
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<div id="search" class="content">
|
|
36
|
+
<h2 class="header">search</h2>
|
|
37
|
+
<p>The search method will update the search input field and search the data against that value.</p>
|
|
38
|
+
|
|
39
|
+
<div class="row">
|
|
40
|
+
<div class="btn" @click="setSearch">Set Search</div>
|
|
41
|
+
<select ref="searchSingle">
|
|
42
|
+
<option value="value1">Value 1</option>
|
|
43
|
+
<option value="value2">Value 2</option>
|
|
44
|
+
<option value="value3">Value 3</option>
|
|
45
|
+
</select>
|
|
46
|
+
<select ref="searchMultiple" multiple>
|
|
47
|
+
<option value="value1">Value 1</option>
|
|
48
|
+
<option value="value2">Value 2</option>
|
|
49
|
+
<option value="value3">Value 3</option>
|
|
50
|
+
</select>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<pre>
|
|
54
|
+
<code class="language-javascript">
|
|
55
|
+
var select = new SlimSelect({
|
|
56
|
+
select: '#selectElement'
|
|
57
|
+
})
|
|
58
|
+
select.search('value')
|
|
59
|
+
</code>
|
|
60
|
+
</pre>
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
import SlimSelect from '../../../slim-select'
|
|
5
|
+
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
name: 'SetData',
|
|
8
|
+
data() {
|
|
9
|
+
return {
|
|
10
|
+
setDataSingle: null as SlimSelect | null,
|
|
11
|
+
setDataMultiple: null as SlimSelect | null,
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
mounted() {
|
|
15
|
+
// Set Data
|
|
16
|
+
this.setDataSingle = new SlimSelect({
|
|
17
|
+
select: this.$refs.setDataSingle as HTMLSelectElement,
|
|
18
|
+
events: {
|
|
19
|
+
error: (err: Error) => {
|
|
20
|
+
console.error(err)
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
this.setDataMultiple = new SlimSelect({
|
|
25
|
+
select: this.$refs.setDataMultiple as HTMLSelectElement,
|
|
26
|
+
events: {
|
|
27
|
+
error: (err: Error) => {
|
|
28
|
+
console.error(err)
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
methods: {
|
|
34
|
+
setData() {
|
|
35
|
+
// Fetch random json array data from gofakeit
|
|
36
|
+
fetch('https://api.gofakeit.com/json', {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: {
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
type: 'array',
|
|
43
|
+
rowcount: 10,
|
|
44
|
+
indent: false,
|
|
45
|
+
fields: [
|
|
46
|
+
{ name: 'text', function: 'generate', params: { str: '{firstname} {lastname}' } },
|
|
47
|
+
{ name: 'selected', function: 'bool' },
|
|
48
|
+
],
|
|
49
|
+
}),
|
|
50
|
+
})
|
|
51
|
+
.then((res) => res.json())
|
|
52
|
+
.then((data) => {
|
|
53
|
+
this.setDataSingle!.setData(data)
|
|
54
|
+
this.setDataMultiple!.setData(data)
|
|
55
|
+
})
|
|
56
|
+
.catch((err) => console.error(err))
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<div id="setData" class="content">
|
|
64
|
+
<h2 class="header">setData</h2>
|
|
65
|
+
<p>
|
|
66
|
+
The setData method can take in an array of objects. This will set the options of the original select and rerender
|
|
67
|
+
slim select.
|
|
68
|
+
</p>
|
|
69
|
+
<div class="alert info">
|
|
70
|
+
If you use a single select but an option is not selected it will select the first option.
|
|
71
|
+
</div>
|
|
72
|
+
<div class="alert info">
|
|
73
|
+
If you use a single select but pass in data with multiple selected options, the first option will be selected.
|
|
74
|
+
</div>
|
|
75
|
+
<div class="alert info">
|
|
76
|
+
To get a better break down of possible data options see <router-link to="/data#types">data</router-link>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div class="row">
|
|
80
|
+
<div class="btn" @click="setData">Set Data</div>
|
|
81
|
+
<select ref="setDataSingle"></select>
|
|
82
|
+
<select ref="setDataMultiple" multiple></select>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<pre>
|
|
86
|
+
<code class="language-javascript">
|
|
87
|
+
var select = new SlimSelect({
|
|
88
|
+
select: '#selectElement'
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
// Array of objects
|
|
92
|
+
select.setData([
|
|
93
|
+
{text: 'Value 1', value: 'value1'},
|
|
94
|
+
{text: 'Value 2', value: 'value2'},
|
|
95
|
+
{
|
|
96
|
+
label: 'Group 1',
|
|
97
|
+
options: [
|
|
98
|
+
{text: 'Value 3', value: 'value3'},
|
|
99
|
+
{text: 'Value 4', value: 'value4'},
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
])
|
|
103
|
+
</code>
|
|
104
|
+
</pre>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
import SlimSelect from '../../../slim-select'
|
|
5
|
+
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
name: 'SetSelected',
|
|
8
|
+
data() {
|
|
9
|
+
return {
|
|
10
|
+
selectedSingle: null as SlimSelect | null,
|
|
11
|
+
selectedMultiple: null as SlimSelect | null,
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
mounted() {
|
|
15
|
+
this.selectedSingle = new SlimSelect({
|
|
16
|
+
select: this.$refs.selectedSingle as HTMLSelectElement,
|
|
17
|
+
})
|
|
18
|
+
this.selectedMultiple = new SlimSelect({
|
|
19
|
+
select: this.$refs.selectedMultiple as HTMLSelectElement,
|
|
20
|
+
})
|
|
21
|
+
},
|
|
22
|
+
methods: {
|
|
23
|
+
setSelected() {
|
|
24
|
+
this.selectedSingle!.open()
|
|
25
|
+
this.selectedSingle!.setSelected('value2')
|
|
26
|
+
this.selectedMultiple!.open()
|
|
27
|
+
this.selectedMultiple!.setSelected(['value1', 'value3'])
|
|
28
|
+
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
this.selectedSingle!.close()
|
|
31
|
+
this.selectedMultiple!.close()
|
|
32
|
+
}, 1000)
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<template>
|
|
39
|
+
<div id="setSelected" class="content">
|
|
40
|
+
<h2 class="header">setSelected</h2>
|
|
41
|
+
<p>The setSelected method will set the selected value(s) of the select.</p>
|
|
42
|
+
<p>setSelected will accept both string or array of strings.</p>
|
|
43
|
+
|
|
44
|
+
<div class="row">
|
|
45
|
+
<div class="btn" @click="setSelected">Set Selected</div>
|
|
46
|
+
|
|
47
|
+
<select ref="selectedSingle">
|
|
48
|
+
<option value="value1">Value 1</option>
|
|
49
|
+
<option value="value2">Value 2</option>
|
|
50
|
+
<option value="value3">Value 3</option>
|
|
51
|
+
</select>
|
|
52
|
+
|
|
53
|
+
<select ref="selectedMultiple" multiple>
|
|
54
|
+
<option value="value1">Value 1</option>
|
|
55
|
+
<option value="value2">Value 2</option>
|
|
56
|
+
<option value="value3">Value 3</option>
|
|
57
|
+
</select>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<pre>
|
|
61
|
+
<code class="language-javascript">
|
|
62
|
+
var select = new SlimSelect({
|
|
63
|
+
select: '#selectElement'
|
|
64
|
+
})
|
|
65
|
+
select.setSelected('value1' /* or */ ['value1', 'value3'])
|
|
66
|
+
console.log(select.getSelected())
|
|
67
|
+
</code>
|
|
68
|
+
</pre>
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
@@ -1,124 +1,117 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
import SlimSelect from '@/slim-select'
|
|
2
|
+
import { defineComponent } from 'vue'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
data() {
|
|
7
|
-
return {
|
|
8
|
-
states: [
|
|
9
|
-
{abv: 'AL', state: 'Alabama'},
|
|
10
|
-
{abv: 'AK', state: 'Alaska'},
|
|
11
|
-
{abv: 'AZ', state: 'Arizona'},
|
|
12
|
-
{abv: 'AR', state: 'Arkansas'},
|
|
13
|
-
{abv: 'CA', state: 'California', selected: true},
|
|
14
|
-
{abv: 'CO', state: 'Colorado'},
|
|
15
|
-
{abv: 'CT', state: 'Connecticut'},
|
|
16
|
-
{abv: 'DE', state: 'Delaware'},
|
|
17
|
-
{abv: 'DC', state: 'District Of Columbia'},
|
|
18
|
-
{abv: 'FL', state: 'Florida'},
|
|
19
|
-
{abv: 'GA', state: 'Georgia'},
|
|
20
|
-
{abv: 'HI', state: 'Hawaii'},
|
|
21
|
-
{abv: 'ID', state: 'Idaho'},
|
|
22
|
-
{abv: 'IL', state: 'Illinois', selected: true},
|
|
23
|
-
{abv: 'IN', state: 'Indiana'},
|
|
24
|
-
{abv: 'IA', state: 'Iowa'},
|
|
25
|
-
{abv: 'KS', state: 'Kansas'},
|
|
26
|
-
{abv: 'KY', state: 'Kentucky'},
|
|
27
|
-
{abv: 'LA', state: 'Louisiana'},
|
|
28
|
-
{abv: 'ME', state: 'Maine'},
|
|
29
|
-
{abv: 'MD', state: 'Maryland'},
|
|
30
|
-
{abv: 'MA', state: 'Massachusetts'},
|
|
31
|
-
{abv: 'MI', state: 'Michigan'},
|
|
32
|
-
{abv: 'MN', state: 'Minnesota'},
|
|
33
|
-
{abv: 'MS', state: 'Mississippi'},
|
|
34
|
-
{abv: 'MO', state: 'Missouri'},
|
|
35
|
-
{abv: 'MT', state: 'Montana'},
|
|
36
|
-
{abv: 'NE', state: 'Nebraska'},
|
|
37
|
-
{abv: 'NV', state: 'Nevada'},
|
|
38
|
-
{abv: 'NH', state: 'New Hampshire'},
|
|
39
|
-
{abv: 'NJ', state: 'New Jersey'},
|
|
40
|
-
{abv: 'NM', state: 'New Mexico'},
|
|
41
|
-
{abv: 'NY', state: 'New York'},
|
|
42
|
-
{abv: 'NC', state: 'North Carolina'},
|
|
43
|
-
{abv: 'ND', state: 'North Dakota'},
|
|
44
|
-
{abv: 'OH', state: 'Ohio'},
|
|
45
|
-
{abv: 'OK', state: 'Oklahoma'},
|
|
46
|
-
{abv: 'OR', state: 'Oregon'},
|
|
47
|
-
{abv: 'PA', state: 'Pennsylvania'},
|
|
48
|
-
{abv: 'RI', state: 'Rhode Island'},
|
|
49
|
-
{abv: 'SC', state: 'South Carolina'},
|
|
50
|
-
{abv: 'SD', state: 'South Dakota'},
|
|
51
|
-
{abv: 'TN', state: 'Tennessee'},
|
|
52
|
-
{abv: 'TX', state: 'Texas'},
|
|
53
|
-
{abv: 'UT', state: 'Utah'},
|
|
54
|
-
{abv: 'VT', state: 'Vermont'},
|
|
55
|
-
{abv: 'VA', state: 'Virginia'},
|
|
56
|
-
{abv: 'WA', state: 'Washington'},
|
|
57
|
-
{abv: 'WV', state: 'West Virginia'},
|
|
58
|
-
{abv: 'WI', state: 'Wisconsin'},
|
|
59
|
-
{abv: 'WY', state: 'Wyoming'}
|
|
60
|
-
],
|
|
61
|
-
foods: [
|
|
62
|
-
{ label: 'Dairy', options: ['Milk', 'Cheese', 'Butter', 'Ice Cream'] },
|
|
63
|
-
{ label: 'Meat', options: ['Beef', 'Ham', 'Pork', 'Sausage', 'Chicken', 'Turkey'] },
|
|
64
|
-
{ label: 'Fruits', options: ['Apple', 'Banana', 'Grape', 'Orange', 'Strawberry', 'Blueberry', 'Raspberry'] },
|
|
65
|
-
{ label: 'Vegetables', options: ['Carrot', 'Tomato', 'Broccoli', 'Celery', 'Corn', 'Pumpkin', 'Kale', 'Spinach'] }
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
mounted() {
|
|
70
|
-
new SlimSelect({
|
|
71
|
-
select: '#single'
|
|
72
|
-
})
|
|
73
|
-
new SlimSelect({
|
|
74
|
-
select: '#single-group'
|
|
75
|
-
})
|
|
4
|
+
import SlimSelect from '../../slim-select'
|
|
76
5
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
name: 'Selects',
|
|
8
|
+
data() {
|
|
9
|
+
return {
|
|
10
|
+
states: [
|
|
11
|
+
{ abv: 'AL', state: 'Alabama' },
|
|
12
|
+
{ abv: 'AK', state: 'Alaska' },
|
|
13
|
+
{ abv: 'AZ', state: 'Arizona' },
|
|
14
|
+
{ abv: 'AR', state: 'Arkansas' },
|
|
15
|
+
{ abv: 'CA', state: 'California' },
|
|
16
|
+
{ abv: 'CO', state: 'Colorado' },
|
|
17
|
+
{ abv: 'CT', state: 'Connecticut' },
|
|
18
|
+
{ abv: 'DE', state: 'Delaware' },
|
|
19
|
+
{ abv: 'FL', state: 'Florida' },
|
|
20
|
+
{ abv: 'GA', state: 'Georgia' },
|
|
21
|
+
{ abv: 'HI', state: 'Hawaii' },
|
|
22
|
+
{ abv: 'ID', state: 'Idaho' },
|
|
23
|
+
{ abv: 'IL', state: 'Illinois' },
|
|
24
|
+
{ abv: 'IN', state: 'Indiana' },
|
|
25
|
+
{ abv: 'IA', state: 'Iowa' },
|
|
26
|
+
{ abv: 'KS', state: 'Kansas' },
|
|
27
|
+
{ abv: 'KY', state: 'Kentucky' },
|
|
28
|
+
{ abv: 'LA', state: 'Louisiana' },
|
|
29
|
+
{ abv: 'ME', state: 'Maine' },
|
|
30
|
+
{ abv: 'MD', state: 'Maryland' },
|
|
31
|
+
{ abv: 'MA', state: 'Massachusetts' },
|
|
32
|
+
{ abv: 'MI', state: 'Michigan' },
|
|
33
|
+
{ abv: 'MN', state: 'Minnesota' },
|
|
34
|
+
{ abv: 'MS', state: 'Mississippi' },
|
|
35
|
+
{ abv: 'MO', state: 'Missouri' },
|
|
36
|
+
{ abv: 'MT', state: 'Montana' },
|
|
37
|
+
{ abv: 'NE', state: 'Nebraska' },
|
|
38
|
+
{ abv: 'NV', state: 'Nevada' },
|
|
39
|
+
{ abv: 'NH', state: 'New Hampshire' },
|
|
40
|
+
{ abv: 'NJ', state: 'New Jersey' },
|
|
41
|
+
{ abv: 'NM', state: 'New Mexico' },
|
|
42
|
+
{ abv: 'NY', state: 'New York' },
|
|
43
|
+
{ abv: 'NC', state: 'North Carolina' },
|
|
44
|
+
{ abv: 'ND', state: 'North Dakota' },
|
|
45
|
+
{ abv: 'OH', state: 'Ohio' },
|
|
46
|
+
{ abv: 'OK', state: 'Oklahoma' },
|
|
47
|
+
{ abv: 'OR', state: 'Oregon' },
|
|
48
|
+
{ abv: 'PA', state: 'Pennsylvania' },
|
|
49
|
+
{ abv: 'RI', state: 'Rhode Island' },
|
|
50
|
+
{ abv: 'SC', state: 'South Carolina' },
|
|
51
|
+
{ abv: 'SD', state: 'South Dakota' },
|
|
52
|
+
{ abv: 'TN', state: 'Tennessee', selected: true },
|
|
53
|
+
{ abv: 'TX', state: 'Texas' },
|
|
54
|
+
{ abv: 'UT', state: 'Utah' },
|
|
55
|
+
{ abv: 'VT', state: 'Vermont' },
|
|
56
|
+
{ abv: 'VA', state: 'Virginia' },
|
|
57
|
+
{ abv: 'WA', state: 'Washington' },
|
|
58
|
+
{ abv: 'WV', state: 'West Virginia' },
|
|
59
|
+
{ abv: 'WI', state: 'Wisconsin' },
|
|
60
|
+
{ abv: 'WY', state: 'Wyoming' },
|
|
61
|
+
],
|
|
62
|
+
foods: [
|
|
63
|
+
{ label: 'Dairy', options: ['Milk', 'Cheese', 'Butter', 'Ice Cream'] },
|
|
64
|
+
{ label: 'Meat', options: ['Beef', 'Ham', 'Pork', 'Sausage', 'Chicken', 'Turkey'] },
|
|
65
|
+
{ label: 'Fruits', options: ['Apple', 'Banana', 'Grape', 'Orange', 'Strawberry', 'Blueberry', 'Raspberry'] },
|
|
66
|
+
{
|
|
67
|
+
label: 'Vegetables',
|
|
68
|
+
options: ['Carrot', 'Tomato', 'Broccoli', 'Celery', 'Corn', 'Pumpkin', 'Kale', 'Spinach'],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
84
71
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
72
|
+
},
|
|
73
|
+
mounted() {
|
|
74
|
+
// Single
|
|
75
|
+
new SlimSelect({
|
|
76
|
+
select: this.$refs.single as HTMLSelectElement,
|
|
77
|
+
})
|
|
78
|
+
new SlimSelect({
|
|
79
|
+
select: this.$refs.singleOptgroup as HTMLSelectElement,
|
|
80
|
+
})
|
|
93
81
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
82
|
+
// Multiple
|
|
83
|
+
new SlimSelect({
|
|
84
|
+
select: this.$refs.multiple as HTMLSelectElement,
|
|
85
|
+
})
|
|
86
|
+
const multiGroup = new SlimSelect({
|
|
87
|
+
select: this.$refs.multipleOptgroup as HTMLSelectElement,
|
|
88
|
+
})
|
|
89
|
+
multiGroup.setSelected(['Cheese', 'Apple', 'Corn'])
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
</script>
|
|
100
93
|
|
|
101
94
|
<template>
|
|
102
|
-
<div id="selects
|
|
103
|
-
|
|
104
|
-
<div class="content">
|
|
95
|
+
<div id="selects" class="contents">
|
|
96
|
+
<div id="single" class="content">
|
|
105
97
|
<h2 class="header">Single</h2>
|
|
106
98
|
<p>
|
|
107
|
-
Basic single select usage with Slim Select is extremely easy.
|
|
108
|
-
Just set the select value to your select element.
|
|
99
|
+
Basic single select usage with Slim Select is extremely easy. Just set the select value to your select element.
|
|
109
100
|
</p>
|
|
110
|
-
<div class="
|
|
101
|
+
<div class="row">
|
|
111
102
|
<div>
|
|
112
103
|
<h4>Options</h4>
|
|
113
|
-
<select
|
|
114
|
-
<option v-for="value in states" :key="value.abv" :value="value.abv" :selected="value.selected">
|
|
104
|
+
<select ref="single">
|
|
105
|
+
<option v-for="value in states" :key="value.abv" :value="value.abv" :selected="value.selected">
|
|
106
|
+
{{ value.state }}
|
|
107
|
+
</option>
|
|
115
108
|
</select>
|
|
116
109
|
</div>
|
|
117
110
|
<div>
|
|
118
111
|
<h4>Optgroups</h4>
|
|
119
|
-
<select
|
|
112
|
+
<select ref="singleOptgroup">
|
|
120
113
|
<optgroup v-for="food in foods" :key="food.label" :label="food.label">
|
|
121
|
-
<option v-for="option in food.options" :key="option" :value="option">{{option}}</option>
|
|
114
|
+
<option v-for="option in food.options" :key="option" :value="option">{{ option }}</option>
|
|
122
115
|
</optgroup>
|
|
123
116
|
</select>
|
|
124
117
|
</div>
|
|
@@ -157,25 +150,27 @@
|
|
|
157
150
|
</code>
|
|
158
151
|
</pre>
|
|
159
152
|
</div>
|
|
160
|
-
|
|
161
|
-
<div class="content">
|
|
153
|
+
|
|
154
|
+
<div id="multiple" class="content">
|
|
162
155
|
<h2 class="header">Multiple</h2>
|
|
163
156
|
<p>
|
|
164
|
-
Multi selects work just the same as a single select.
|
|
165
|
-
|
|
157
|
+
Multi selects work just the same as a single select. The only difference is setting the multiple attribute on
|
|
158
|
+
your select.
|
|
166
159
|
</p>
|
|
167
|
-
<div class="
|
|
160
|
+
<div class="row">
|
|
168
161
|
<div>
|
|
169
162
|
<h4>Options</h4>
|
|
170
|
-
<select
|
|
171
|
-
<option v-for="value in states" :value="value.abv" :key="value.abv" :selected="value.selected">
|
|
163
|
+
<select ref="multiple" multiple>
|
|
164
|
+
<option v-for="value in states" :value="value.abv" :key="value.abv" :selected="value.selected">
|
|
165
|
+
{{ value.state }}
|
|
166
|
+
</option>
|
|
172
167
|
</select>
|
|
173
168
|
</div>
|
|
174
169
|
<div>
|
|
175
170
|
<h4>Optgroups</h4>
|
|
176
|
-
<select
|
|
171
|
+
<select ref="multipleOptgroup" multiple>
|
|
177
172
|
<optgroup v-for="food in foods" :key="food.label" :label="food.label">
|
|
178
|
-
<option v-for="option in food.options" :key="option" :value="option">{{option}}</option>
|
|
173
|
+
<option v-for="option in food.options" :key="option" :value="option">{{ option }}</option>
|
|
179
174
|
</optgroup>
|
|
180
175
|
</select>
|
|
181
176
|
</div>
|
|
@@ -214,6 +209,5 @@
|
|
|
214
209
|
</code>
|
|
215
210
|
</pre>
|
|
216
211
|
</div>
|
|
217
|
-
|
|
218
212
|
</div>
|
|
219
213
|
</template>
|