File tree Expand file tree Collapse file tree 6 files changed +16
-24
lines changed Expand file tree Collapse file tree 6 files changed +16
-24
lines changed Original file line number Diff line number Diff line change 11<script setup>
2- import { ref , computed } from ' vue'
3- import { getFieldComponentName , hasLabel } from ' @/helpers'
2+ import { computed , useTemplateRef } from ' vue'
3+ import { getFieldComponentName } from ' @/helpers'
44
5- const fieldComponent = ref ( null )
5+ const fieldComponent = useTemplateRef ( ' fieldComponent ' )
66
77const props = defineProps ({
88 formOptions: {
@@ -39,8 +39,10 @@ const fieldId = computed(() => {
3939})
4040
4141const shouldHaveLabel = computed (() => {
42- // checkbox will have their own label
43- return hasLabel (props .field ) && ! [ props .field .inputType , props .field .type ].includes (' checkbox' ) && ! props .field .noLabel
42+ if (fieldComponent .value ? .noLabel || props .field .noLabel === true ) {
43+ return false
44+ }
45+ return props .field .label
4446})
4547< / script>
4648
Original file line number Diff line number Diff line change @@ -11,4 +11,6 @@ import { useFieldProps } from '@/composables/index.ts'
1111const props = defineProps (useFieldProps ())
1212
1313const { model , field } = toRefs (props)
14+
15+ defineExpose ({ noLabel: true })
1416 </script >
Original file line number Diff line number Diff line change 11<template >
22 <input
3- :id =" id"
3+ :id =" props. id"
44 type =" checkbox"
55 :name =" field.name"
66 :required =" isRequired"
99 :checked =" currentModelValue"
1010 @change =" onFieldValueChanged"
1111 >
12- <label v-if =" field.label" style =" margin-left : .4em " :for =" id" > {{ field.label }}</label >
12+ <label v-if =" field.label" style =" margin-left : .4em " :for =" props. id" > {{ field.label }}</label >
1313</template >
1414
1515<script setup>
@@ -49,5 +49,5 @@ const onFieldValueChanged = ({ target }) => {
4949 emits (' onInput' , target .checked )
5050}
5151
52- defineExpose ({ hint })
52+ defineExpose ({ hint, noLabel : true })
5353 </script >
Original file line number Diff line number Diff line change @@ -9,4 +9,6 @@ import { useFieldProps } from '@/composables/index.ts'
99const props = defineProps (useFieldProps ())
1010
1111const { field } = toRefs (props)
12+
13+ defineExpose ({ noLabel: true })
1214 </script >
Original file line number Diff line number Diff line change @@ -17,4 +17,6 @@ const props = defineProps(useFieldProps())
1717const { model , field } = toRefs (props)
1818
1919const { isDisabled } = useFieldAttributes (model .value , field .value )
20+
21+ defineExpose ({ noLabel: true })
2022 </script >
Original file line number Diff line number Diff line change @@ -66,22 +66,6 @@ export function isNotEmpty (value: any): boolean {
6666 return ! isEmpty ( value )
6767}
6868
69- /**
70- * Determine if a field should have a top-level label.
71- */
72- export function hasLabel ( field : Field ) : boolean {
73- if ( ! ( 'label' in field ) || ! field . label ) return false
74-
75- switch ( field . type ) {
76- case 'button' :
77- case 'submit' :
78- case 'reset' :
79- return false
80- default :
81- return true
82- }
83- }
84-
8569/**
8670 * Reset all properties to an empty value of the same type. Will recursively try and
8771 * reset all properties if an object has a property with another object as its value.
You can’t perform that action at this time.
0 commit comments