Skip to content

Commit 2b76ed5

Browse files
committed
Allow adding side button to inputs + copy
1 parent 7690ab1 commit 2b76ed5

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

frontend/app/components/ui/controls/m-input.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
:class="classes"
1515
:disabled="disabled"
1616
style="width: 100px;"
17+
@click="clickInput"
1718
@input="forceUpdateColor"
1819
>
1920
<textarea
@@ -23,6 +24,7 @@
2324
class="mw-input"
2425
:rows="rows"
2526
v-bind="$attrs"
27+
@click="clickInput"
2628
:disabled="disabled"
2729
/>
2830
<input
@@ -55,9 +57,11 @@
5557
:class="classes"
5658
:type="type"
5759
:disabled="disabled"
60+
@click="clickInput"
5861
:style="{ padding: type == 'range' ? 0 : undefined }"
5962
>
6063
<span v-if="type == 'range'" class="text-xl">{{ vm }}</span>
64+
<slot name="next-to"/>
6165
</m-flex>
6266
<slot v-else/>
6367
<label v-if="isCheckbox && label" :for="labelId" class="flex-grow">
@@ -84,8 +88,9 @@ const props = defineProps<{
8488
type?: string;
8589
value?: string;
8690
required?: boolean;
91+
clickCopy?: boolean;
8792
}>();
88-
const emit = defineEmits(['update:elementRef']);
93+
const emit = defineEmits(['update:elementRef', 'clickInput']);
8994
const vm = defineModel<any>('modelValue');
9095
const elementRef = defineModel<HTMLInputElement>('elementRef');
9196
const uniqueId = useId();
@@ -109,6 +114,13 @@ watch(() => props.validity, val => {
109114
}
110115
});
111116
117+
function clickInput(e) {
118+
emit('clickInput', e);
119+
if (props.clickCopy) {
120+
navigator.clipboard.writeText(vm.value);
121+
}
122+
}
123+
112124
// force refresh for firefox
113125
function forceUpdateColor(element) {
114126
vm.value = element.target.value;

0 commit comments

Comments
 (0)