Browse Source

chore(gui-v2): update text and textarea cells

pull/2972/head
braks 2 years ago
parent
commit
ff14003be0
  1. 40
      packages/nc-gui-v2/components/cell/Text.vue
  2. 24
      packages/nc-gui-v2/components/cell/TextArea.vue

40
packages/nc-gui-v2/components/cell/Text.vue

@ -8,50 +8,16 @@ interface Props {
const props = defineProps<Props>() const props = defineProps<Props>()
const emit = defineEmits(['update:modelValue']) const emits = defineEmits(['update:modelValue'])
const editEnabled = inject(EditModeInj, ref(false)) const editEnabled = inject(EditModeInj, ref(false))
const vModel = useVModel(props, 'modelValue', emit) const vModel = useVModel(props, 'modelValue', emits)
const focus = (el: HTMLInputElement) => el.focus() const focus = (el: HTMLInputElement) => el.focus()
</script> </script>
<template> <template>
<input v-if="editEnabled" :ref="focus" v-model="vModel" /> <input v-if="editEnabled" :ref="focus" v-model="vModel" class="h-full w-full outline-none" />
<span v-else>{{ vModel }}</span> <span v-else>{{ vModel }}</span>
</template> </template>
<style scoped>
input,
textarea {
width: 100%;
height: 100%;
color: var(--v-textColor-base);
outline: none;
}
</style>
<!--
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Naveen MR <oof1lab@gmail.com>
* @author Pranav C Balan <pranavxc@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-->

24
packages/nc-gui-v2/components/cell/TextArea.vue

@ -8,26 +8,24 @@ interface Props {
const props = defineProps<Props>() const props = defineProps<Props>()
const emit = defineEmits(['update:modelValue']) const emits = defineEmits(['update:modelValue'])
const editEnabled = inject(EditModeInj, ref(false)) const editEnabled = inject(EditModeInj, ref(false))
const vModel = useVModel(props, 'modelValue', emit) const vModel = useVModel(props, 'modelValue', emits)
const focus = (el: HTMLTextAreaElement) => el.focus() const focus = (el: HTMLTextAreaElement) => el.focus()
</script> </script>
<template> <template>
<textarea v-if="editEnabled" :ref="focus" v-model="vModel" rows="4" @keydown.alt.enter.stop @keydown.shift.enter.stop /> <textarea
v-if="editEnabled"
:ref="focus"
v-model="vModel"
rows="4"
class="h-full w-full min-h-[60px] outline-none"
@keydown.alt.enter.stop
@keydown.shift.enter.stop
/>
<span v-else>{{ vModel }}</span> <span v-else>{{ vModel }}</span>
</template> </template>
<style scoped>
input,
textarea {
width: 100%;
min-height: 60px;
height: 100%;
color: var(--v-textColor-base);
}
</style>

Loading…
Cancel
Save