This commit is contained in:
2023-02-24 22:05:05 +10:00
parent bb0be1dadf
commit 158da60922

View File

@@ -6,6 +6,7 @@
'sm-input-active': inputActive, 'sm-input-active': inputActive,
'sm-feedback-invalid': feedbackInvalid, 'sm-feedback-invalid': feedbackInvalid,
}, },
computedClassType,
]"> ]">
<label v-if="label">{{ label }}</label> <label v-if="label">{{ label }}</label>
<ion-icon <ion-icon
@@ -22,7 +23,6 @@
type == 'datetime' type == 'datetime'
" "
:type="type" :type="type"
:placeholder="placeholder"
:value="value" :value="value"
@input="handleInput" @input="handleInput"
@focus="handleFocus" @focus="handleFocus"
@@ -48,10 +48,6 @@
{{ modelValue?.name ? modelValue.name : modelValue }} {{ modelValue?.name ? modelValue.name : modelValue }}
</div> </div>
</div> </div>
<a v-else-if="type == 'link'" :href="href" target="_blank">{{
props.modelValue
}}</a>
<span v-else-if="type == 'static'">{{ props.modelValue }}</span>
<select <select
v-else-if="type == 'select'" v-else-if="type == 'select'"
:value="value" :value="value"
@@ -67,8 +63,8 @@
{{ optionValue }} {{ optionValue }}
</option> </option>
</select> </select>
<div v-else-if="type == 'media'" class="sm-input-media-group"> <div v-else-if="type == 'media'" class="sm-input-media">
<div class="sm-input-media-display"> <div class="sm-input-media-item">
<img v-if="mediaUrl.length > 0" :src="mediaUrl" /> <img v-if="mediaUrl.length > 0" :src="mediaUrl" />
<ion-icon v-else name="image-outline" /> <ion-icon v-else name="image-outline" />
</div> </div>
@@ -82,10 +78,6 @@
<slot></slot> <slot></slot>
</span> </span>
</div> </div>
<div v-if="help" class="form-group-help">
<ion-icon v-if="helpIcon" name="information-circle-outline" />
{{ help }}
</div>
</div> </div>
</template> </template>
@@ -107,15 +99,6 @@ const props = defineProps({
default: "", default: "",
required: false, required: false,
}, },
placeholder: {
type: String,
default: "",
required: false,
},
required: {
type: Boolean,
default: false,
},
type: { type: {
type: String, type: String,
default: "text", default: "text",
@@ -124,14 +107,6 @@ const props = defineProps({
type: String, type: String,
default: "", default: "",
}, },
help: {
type: String,
default: "",
},
helpIcon: {
type: String,
default: "",
},
accept: { accept: {
type: String, type: String,
default: "", default: "",
@@ -168,6 +143,13 @@ const feedbackInvalid = ref(props.feedbackInvalid);
const value = ref(props.modelValue); const value = ref(props.modelValue);
const inputActive = ref(value.value.length > 0 || props.type == "select"); const inputActive = ref(value.value.length > 0 || props.type == "select");
/**
* Return the classname based on type
*/
const computedClassType = computed(() => {
return `sm-input-${props.type}`;
});
watch( watch(
() => props.label, () => props.label,
(newValue) => { (newValue) => {
@@ -276,10 +258,6 @@ const handleKeydown = (event: Event) => {
emits("keydown", event); emits("keydown", event);
}; };
const inline = computed(() => {
return ["static", "link"].includes(props.type);
});
const handleMediaSelect = async (event) => { const handleMediaSelect = async (event) => {
let result = await openDialog(SMDialogMedia); let result = await openDialog(SMDialogMedia);
if (result) { if (result) {
@@ -378,19 +356,35 @@ const handleMediaSelect = async (event) => {
resize: none; resize: none;
} }
.sm-input-media-display { &.sm-input-media {
display: flex; label {
margin-bottom: 1rem; position: relative;
border: 1px solid $border-color; transform: none;
background-color: #fff; }
}
img { .sm-input-media {
max-width: 100%; text-align: center;
max-height: 100%;
.sm-input-media-item {
display: block;
margin-bottom: 0.5rem;
img {
max-width: 100%;
max-height: 100%;
}
ion-icon {
padding: 4rem;
font-size: 3rem;
border: 1px solid $border-color;
background-color: #fff;
}
} }
ion-icon { .button {
padding: 4rem; display: inline-block;
} }
} }