Skip to content

Commit b82b56c

Browse files
committed
.
1 parent 756ed5b commit b82b56c

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

packages/quasar/src/components/QuasarKeyValueField.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ const quickformsFeatures = computed(() => {
4646
const valueLabel =
4747
schemaFeatures.valueLabel ?? globalDefaults.valueLabel ?? "Value";
4848
49+
// Type inference option (x-infer-types takes priority over defaults)
50+
const inferTypes =
51+
(props.schema as any)["x-infer-types"] ??
52+
schemaFeatures.inferTypes ??
53+
globalDefaults.inferTypes ??
54+
false;
55+
4956
// Merge QBtn props: defaults -> global -> schema (schema has highest priority)
5057
const addButtonDefaults = {
5158
outline: true,
@@ -83,6 +90,7 @@ const quickformsFeatures = computed(() => {
8390
showHeaders,
8491
keyLabel,
8592
valueLabel,
93+
inferTypes,
8694
};
8795
});
8896
@@ -142,8 +150,10 @@ watch(
142150
const obj: Record<string, unknown> = {};
143151
newPairs.forEach((pair) => {
144152
if (pair.key.trim()) {
145-
// Infer type from string value (e.g., "1" -> 1, "true" -> true)
146-
obj[pair.key] = inferType(pair.value);
153+
// Optionally infer type from string value (e.g., "1" -> 1, "true" -> true)
154+
obj[pair.key] = quickformsFeatures.value.inferTypes
155+
? inferType(pair.value)
156+
: pair.value;
147157
}
148158
});
149159
isInternalUpdate.value = true;

packages/quasar/src/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,18 @@ export interface QuickFormsQuasarKeyValueFeatures {
134134
keyLabel?: string;
135135
/** Custom label for the value column. Default: 'Value' */
136136
valueLabel?: string;
137+
/**
138+
* Automatically infer types from string values.
139+
* When enabled:
140+
* - "123" becomes 123 (number)
141+
* - "true"/"false" become booleans
142+
* - "null" becomes null
143+
* - Template expressions ({{ }}) stay as strings
144+
*
145+
* Use via x-infer-types in schema or quickformsDefaults.keyvalue.inferTypes
146+
* Default: false (values stay as strings for backwards compatibility)
147+
*/
148+
inferTypes?: boolean;
137149
}
138150

139151
/**

0 commit comments

Comments
 (0)