File size: 1,573 Bytes
71174bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | <template>
<div :class="cls">
<label
v-if="label !== ''"
:for="randomID"
:class="'form-label mb-0' + (disabled ? ' disabled-txt' : '') + (useSubLabelFormatting ? ' fst-italic fw-light' : '')"
>
<small v-if="smallLabel">{{ label }}</small>
<span v-else>{{ label }}</span>
</label>
<div :id="randomID" :aria-label="label" :title="label">
<slot></slot>
</div>
</div>
</template>
<script lang="ts">
import { Options, Vue } from "vue-class-component";
import { Prop } from "vue-property-decorator";
/**
* FormWrapper component
*/
@Options({
components: {},
})
export default class FormWrapper extends Vue {
@Prop({ default: "" }) label!: string;
@Prop({ default: false }) smallLabel!: boolean;
@Prop({ default: "mb-2" }) cls!: string;
@Prop({ default: false }) disabled!: boolean;
@Prop({ default: false }) useSubLabelFormatting!: boolean;
randomID = "";
// /**
// * Get a random ID.
// *
// * @returns {string} The random ID.
// */
// get randomID(): string {
// return
// }
/**
* Called when the component is mounted.
*/
mounted() {
this.randomID = (
"a" +
Math.random().toString(36).substring(2, 15) +
Math.random().toString(36).substring(2, 15)
);
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.disabled-txt {
opacity: 0.5;
}
</style>
|