-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from shariquerik/cc-bcc-reply-all
feat: CC, BCC & ReplyAll
- Loading branch information
Showing
6 changed files
with
241 additions
and
41 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<template> | ||
<div> | ||
<div class="flex flex-wrap gap-1"> | ||
<Button | ||
v-for="value in values" | ||
:label="value" | ||
theme="gray" | ||
variant="subtle" | ||
class="rounded-full" | ||
> | ||
<template #suffix> | ||
<FeatherIcon | ||
class="h-3.5" | ||
name="x" | ||
@click.stop="removeValue(value)" | ||
/> | ||
</template> | ||
</Button> | ||
<TextInput | ||
class="min-w-20 flex-1 border-none bg-white hover:bg-white focus:border-none focus:shadow-none focus-visible:ring-0" | ||
v-model="currentValue" | ||
@keydown.enter.capture.stop="addValue" | ||
@keydown.tab.capture.stop="addValue" | ||
@keydown.delete.capture.stop="removeLastValue" | ||
@keydown.meta.delete.capture.stop="removeAllValue" | ||
/> | ||
</div> | ||
<ErrorMessage class="mt-2 pl-2" v-if="error" :message="error" /> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { Button, ErrorMessage, FeatherIcon, TextInput } from 'frappe-ui' | ||
import { ref, defineModel } from 'vue' | ||
const props = defineProps({ | ||
validate: { | ||
type: Function, | ||
default: null, | ||
}, | ||
errorMessage: { | ||
type: Function, | ||
default: (value) => `${value} is an Invalid value`, | ||
}, | ||
}) | ||
const values = defineModel() | ||
const currentValue = ref('') | ||
const error = ref(null) | ||
const addValue = () => { | ||
error.value = null | ||
if (currentValue.value) { | ||
const splitValues = currentValue.value.split(',') | ||
splitValues.forEach((value) => { | ||
value = value.trim() | ||
if (value) { | ||
// check if value is not already in the values array | ||
if (!values.value.includes(value)) { | ||
// check if value is valid | ||
if (value && props.validate && !props.validate(value)) { | ||
error.value = props.errorMessage(value) | ||
return | ||
} | ||
// add value to values array | ||
values.value.push(value) | ||
currentValue.value = currentValue.value.replace(value, '') | ||
} | ||
} | ||
}) | ||
!error.value && (currentValue.value = '') | ||
} | ||
} | ||
const removeValue = (value) => { | ||
values.value = values.value.filter((v) => v !== value) | ||
} | ||
const removeAllValue = () => { | ||
values.value = [] | ||
} | ||
const removeLastValue = () => { | ||
if (!currentValue.value) { | ||
values.value.pop() | ||
} | ||
} | ||
</script> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<template> | ||
<svg | ||
width="16" | ||
height="16" | ||
viewBox="0 0 16 16" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M5.85355 3.14645C5.65829 2.95118 5.34171 2.95118 5.14645 3.14645L1.14645 7.14645C0.951184 7.34171 0.951184 7.65829 1.14645 7.85355L5.14645 11.8536C5.34171 12.0488 5.65829 12.0488 5.85355 11.8536C6.04882 11.6583 6.04882 11.3417 5.85355 11.1464L2.20711 7.5L5.85355 3.85355C6.04882 3.65829 6.04882 3.34171 5.85355 3.14645ZM10 8C11.933 8 13.5 9.567 13.5 11.5V12C13.5 12.2761 13.7239 12.5 14 12.5C14.2761 12.5 14.5 12.2761 14.5 12V11.5C14.5 9.01472 12.4853 7 10 7H6.6728L9.81924 3.85355C10.0145 3.65829 10.0145 3.34171 9.81924 3.14645C9.62398 2.95118 9.3074 2.95118 9.11214 3.14645L5.11214 7.14645C4.91688 7.34171 4.91688 7.65829 5.11214 7.85355L9.11214 11.8536C9.3074 12.0488 9.62398 12.0488 9.81924 11.8536C10.0145 11.6583 10.0145 11.3417 9.81924 11.1464L6.6728 8H10Z" | ||
fill="currentColor" | ||
/> | ||
</svg> | ||
</template> |
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