( input: I, adaptValue: (target: any) => any = (v) => v, debounceWait?: number, )
| 138 | * Adds styles, isFocused, appliedOptions and onChange |
| 139 | */ |
| 140 | export const useVuetifyControl = < |
| 141 | T extends { |
| 142 | schema: JsonSchema; |
| 143 | uischema: ControlElement; |
| 144 | path: string; |
| 145 | config: any; |
| 146 | label: string; |
| 147 | description: string; |
| 148 | required: boolean; |
| 149 | errors: string; |
| 150 | id: string; |
| 151 | visible: boolean; |
| 152 | enabled: boolean; |
| 153 | readonly: boolean; |
| 154 | }, |
| 155 | I extends { |
| 156 | control: ComputedRef<T>; |
| 157 | } & (DispatchPropsOfControl | DispatchPropsOfMultiEnumControl), |
| 158 | >( |
| 159 | input: I, |
| 160 | adaptValue: (target: any) => any = (v) => v, |
| 161 | debounceWait?: number, |
| 162 | ) => { |
| 163 | const touched = ref(false); |
| 164 | |
| 165 | const changeEmitter = |
| 166 | typeof debounceWait === 'number' && |
| 167 | (input as DispatchPropsOfControl).handleChange |
| 168 | ? debounce((input as DispatchPropsOfControl).handleChange, debounceWait) |
| 169 | : (input as DispatchPropsOfControl).handleChange; |
| 170 | |
| 171 | const onChange = (value: any) => { |
| 172 | if (changeEmitter) { |
| 173 | changeEmitter(input.control.value.path, adaptValue(value)); |
| 174 | } |
| 175 | }; |
| 176 | |
| 177 | const appliedOptions = useControlAppliedOptions(input); |
| 178 | const isFocused = ref(false); |
| 179 | |
| 180 | const handleFocus = () => { |
| 181 | isFocused.value = true; |
| 182 | }; |
| 183 | |
| 184 | const handleBlur = () => { |
| 185 | touched.value = true; |
| 186 | isFocused.value = false; |
| 187 | if (changeEmitter && (changeEmitter as any).flush) { |
| 188 | (changeEmitter as any).flush(); |
| 189 | } |
| 190 | }; |
| 191 | |
| 192 | const jsonforms = useJsonForms(); |
| 193 | const filteredErrors = computed(() => { |
| 194 | // Always show errors if touched, no errors exist, or filtering is not enabled |
| 195 | if ( |
| 196 | touched.value || |
| 197 | !input.control.value.errors || |
nothing calls this directly
no test coverage detected
searching dependent graphs…