opnform-host-nginx/client/components/forms/TextInput.vue

115 lines
2.6 KiB
Vue
Raw Normal View History

2023-12-09 15:47:03 +01:00
<template>
<input-wrapper v-bind="inputWrapperProps">
2023-12-09 15:47:03 +01:00
<template #label>
<slot name="label" />
</template>
<input
:id="id ? id : name"
v-model="compVal"
:disabled="disabled ? true : null"
:type="nativeType"
:autocomplete="autocomplete"
:pattern="pattern"
:style="inputStyle"
:class="[
theme.default.input,
theme.default.borderRadius,
theme.default.spacing.horizontal,
theme.default.spacing.vertical,
theme.default.fontSize,
{
'!ring-red-500 !ring-2 !border-transparent': hasError,
'!cursor-not-allowed !bg-gray-200': disabled,
},
]"
:name="name"
:accept="accept"
:placeholder="placeholder"
:min="min"
:max="max"
:maxlength="maxCharLimit"
@change="onChange"
@keydown.enter.prevent="onEnterPress"
@focus="onFocus"
@blur="onBlur"
2023-12-09 15:47:03 +01:00
>
<template
v-if="$slots.help"
#help
>
Notification & Integrations refactoring (#346) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Lint --------- Co-authored-by: Julien Nahum <julien@nahum.net>
2024-03-28 18:14:30 +01:00
<slot name="help" />
</template>
<template
v-if="maxCharLimit && showCharLimit"
#bottom_after_help
>
2023-12-09 15:47:03 +01:00
<small :class="theme.default.help">
{{ charCount }}/{{ maxCharLimit }}
</small>
</template>
<template
v-if="$slots.error"
#error
>
2023-12-09 15:47:03 +01:00
<slot name="error" />
</template>
</input-wrapper>
</template>
<script>
import {inputProps, useFormInput} from "./useFormInput.js"
import InputWrapper from "./components/InputWrapper.vue"
2023-12-09 15:47:03 +01:00
export default {
name: "TextInput",
components: {InputWrapper},
2023-12-09 15:47:03 +01:00
props: {
...inputProps,
nativeType: {type: String, default: "text"},
accept: {type: String, default: null},
min: {type: Number, required: false, default: null},
max: {type: Number, required: false, default: null},
autocomplete: {type: [Boolean, String, Object], default: null},
maxCharLimit: {type: Number, required: false, default: null},
pattern: {type: String, default: null},
2023-12-09 15:47:03 +01:00
},
setup(props, context) {
2023-12-09 15:47:03 +01:00
const onChange = (event) => {
if (props.nativeType !== "file") return
2023-12-09 15:47:03 +01:00
const file = event.target.files[0]
// eslint-disable-next-line vue/no-mutating-props
props.form[props.name] = file
}
const onEnterPress = (event) => {
event.preventDefault()
return false
}
return {
...useFormInput(
props,
context,
{
formPrefixKey: props.nativeType === "file" ? "file-" : null
},
),
2023-12-09 15:47:03 +01:00
onEnterPress,
onChange
2023-12-09 15:47:03 +01:00
}
},
computed: {
charCount() {
return this.compVal ? this.compVal.length : 0
},
},
2023-12-09 15:47:03 +01:00
}
</script>