Skip to content

Commit

Permalink
Release prep v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
delowardev committed Dec 6, 2021
1 parent 6895fb8 commit b584310
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
22 changes: 19 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
<template>
<h2>Default</h2>
<picker />
<picker @select="onSelect" />

<h2>With input</h2>
<picker :text="text" picker-type="input" @update:text="onChangeText" />
<picker
:text="text"
picker-type="input"
@select="onSelect"
@update:text="onChangeText"
/>

<h2>With textarea</h2>
<picker :text="text" picker-type="textarea" @update:text="onChangeText" />
<picker
:text="text"
picker-type="textarea"
@select="onSelect"
@update:text="onChangeText"
/>
</template>

<script lang="ts">
Expand Down Expand Up @@ -36,12 +46,18 @@ export default defineComponent({
text.value = new_text || ''
}
function onSelect(emoji: any) {
alert(`${emoji.i} selected, check console log for emoji details.`)
console.log(emoji)
}
/**
* Return vars
*/
return {
onChangeText,
text,
onSelect,
}
},
})
Expand Down
9 changes: 7 additions & 2 deletions src/components/Picker.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<picker-root :type="type" :text="input" @update:text="onChangeText" />
<picker-root
:type="type"
:text="input"
@select="$emit('select', $event)"
@update:text="onChangeText"
/>
</template>

<script lang="ts">
Expand Down Expand Up @@ -74,7 +79,7 @@ export default defineComponent({
default: '',
},
},
emits: ['update:text'],
emits: ['update:text', 'select'],
setup(props, { emit }) {
const input = ref(props.text)
Expand Down
27 changes: 15 additions & 12 deletions src/components/Root.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default defineComponent({
default: '',
},
},
emits: ['update:text'],
emits: ['update:text', 'select'],
setup(props, { emit }) {
const elem = ref<HTMLInputElement>()
const button = ref<HTMLButtonElement>()
Expand All @@ -89,19 +89,22 @@ export default defineComponent({
* Functions
*/
function onSelect(emoji: any) {
const mode = state.options.mode
if (mode === 'prepend') {
input.value = emoji.i + input.value
} else if (mode === 'insert' && cursor !== -1) {
input.value = `${input.value.slice(0, cursor)}${
emoji.i
}${input.value.slice(cursor)}`
cursor += emoji.i.length
} else {
input.value += emoji.i
if (isInputType) {
const mode = state.options.mode
if (mode === 'prepend') {
input.value = emoji.i + input.value
} else if (mode === 'insert' && cursor !== -1) {
input.value = `${input.value.slice(0, cursor)}${
emoji.i
}${input.value.slice(cursor)}`
cursor += emoji.i.length
} else {
input.value += emoji.i
}
emit('update:text', input.value)
}
emit('update:text', input.value)
emit('select', emoji)
}
function updateCursor() {
Expand Down

0 comments on commit b584310

Please sign in to comment.