MCPcopy Create free account
hub / github.com/eclipsesource/jsonforms / useVuetifyControl

Function useVuetifyControl

packages/vue-vuetify/src/util/composition.ts:140–296  ·  view source on GitHub ↗
(
  input: I,
  adaptValue: (target: any) => any = (v) => v,
  debounceWait?: number,
)

Source from the content-addressed store, hash-verified

138 * Adds styles, isFocused, appliedOptions and onChange
139 */
140export 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 ||

Callers

nothing calls this directly

Calls 10

useJsonFormsFunction · 0.90
getControlPathFunction · 0.90
getTranslatorFunction · 0.90
getErrorTranslatorFunction · 0.90
getCombinedErrorMessageFunction · 0.90
useStylesFunction · 0.90
useControlAppliedOptionsFunction · 0.85
useComputedLabelFunction · 0.85
isControlEditableFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…