@stonecrop/aform 0.46.1 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/aform.js +142 -88
- package/dist/aform.js.map +1 -1
- package/dist/assets/index.css +61 -61
- package/dist/src/components/AForm.vue.d.ts.map +1 -1
- package/dist/src/components/form/ACurrencyInput.vue.d.ts.map +1 -1
- package/dist/src/components/form/ADropdown.vue.d.ts.map +1 -1
- package/dist/src/components/form/AFormLink.vue.d.ts.map +1 -1
- package/dist/src/components/form/AQuantityInput.vue.d.ts.map +1 -1
- package/dist/src/utils/currencyValue.d.ts.map +1 -1
- package/dist/src/utils/quantityValue.d.ts.map +1 -1
- package/dist/src/utils/recordNumber.d.ts +6 -0
- package/dist/src/utils/recordNumber.d.ts.map +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ Provide `filterFunction` to enable the search dropdown. The function receives a
|
|
|
147
147
|
The function is called in two distinct situations:
|
|
148
148
|
|
|
149
149
|
1. **On user interaction** — when the user focuses or types into the field, the current input text is passed as the search string.
|
|
150
|
-
2. **On mount (and on id change)** — when the field has an `id` but no `displayText`, the function is called automatically with the existing `id` string so the display name can be resolved without user interaction. The first result whose `id` matches is
|
|
150
|
+
2. **On mount (and on id change)** — when the field has an `id` but no `displayText`, the function is called automatically with the existing `id` string so the display name can be resolved without user interaction. The first result whose `id` matches is shown; the bound value keeps its bare `id`, since a lookup is not an edit.
|
|
151
151
|
|
|
152
152
|
Because of case 2, implementations should handle both name-based searches (partial strings typed by the user) and exact id lookups (full id strings passed on mount). A common pattern is to attempt both:
|
|
153
153
|
|
package/dist/aform.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { hasBadgeOptions, isBadgeDescriptor, lookupBadge, selectChoices } from "@stonecrop/schema";
|
|
1
|
+
import { hasBadgeOptions, isBadgeDescriptor, lookupBadge, partsPatch, readParts, selectChoices } from "@stonecrop/schema";
|
|
2
2
|
import { TABLE_TUPLE_CURRENCY_PICKER, TABLE_TUPLE_QUANTITY_PICKER, install as install$1, isTableTuplePickerModal } from "@stonecrop/atable";
|
|
3
3
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeModels, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, reactive, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, toDisplayString, unref, useId, useModel, useTemplateRef, vModelCheckbox, vModelRadio, vModelSelect, vModelText, vShow, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers } from "vue";
|
|
4
|
-
import { currencyAmountEntryPattern, currencyInputFractionDigits, formatCurrencyAmount, formatCurrencyAmountInput, fromISODate, isSemver, isSemverPrefix, parseCurrencyAmountInput } from "@stonecrop/utilities";
|
|
4
|
+
import { currencyAmountEntryPattern, currencyInputFractionDigits, formatCurrencyAmount, formatCurrencyAmountInput, formatCurrencySymbol, fromISODate, isSemver, isSemverPrefix, parseCurrencyAmountInput } from "@stonecrop/utilities";
|
|
5
5
|
import { vOnClickOutside } from "@vueuse/components";
|
|
6
6
|
import { Temporal } from "temporal-polyfill";
|
|
7
7
|
import { onClickOutside, useElementBounding, useFileDialog } from "@vueuse/core";
|
|
@@ -207,6 +207,27 @@ var _plugin_vue_export_helper_default = (sfc, props) => {
|
|
|
207
207
|
//#region src/components/form/ACheckbox.vue
|
|
208
208
|
var ACheckbox_default = /*#__PURE__*/ _plugin_vue_export_helper_default(ACheckbox_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-f28e7db6"]]);
|
|
209
209
|
//#endregion
|
|
210
|
+
//#region src/utils/linkValue.ts
|
|
211
|
+
function linkId(value) {
|
|
212
|
+
if (value == null) return void 0;
|
|
213
|
+
if (typeof value === "string") return value === "" ? void 0 : value;
|
|
214
|
+
if (typeof value === "number") return String(value);
|
|
215
|
+
const id = value.id;
|
|
216
|
+
if (id === null || id === void 0 || id === "") return void 0;
|
|
217
|
+
return String(id);
|
|
218
|
+
}
|
|
219
|
+
function linkDisplayText(value) {
|
|
220
|
+
if (value == null || typeof value !== "object") return void 0;
|
|
221
|
+
const text = value.displayText;
|
|
222
|
+
if (typeof text === "string") return text;
|
|
223
|
+
if (typeof text === "number") return String(text);
|
|
224
|
+
}
|
|
225
|
+
function asLinkValue(value) {
|
|
226
|
+
if (value != null && typeof value === "object") return value;
|
|
227
|
+
const id = linkId(value);
|
|
228
|
+
return id !== void 0 ? { id } : { id: "" };
|
|
229
|
+
}
|
|
230
|
+
//#endregion
|
|
210
231
|
//#region src/utils/currencyValue.ts
|
|
211
232
|
var FLOAT_NOISE_DECIMALS = 6;
|
|
212
233
|
function normalizeBaseCurrency(options, current) {
|
|
@@ -222,7 +243,7 @@ function baseAmountDecimals(options) {
|
|
|
222
243
|
function resolveCurrencyExchangeRate(currencyId, options, baseCurrency, current) {
|
|
223
244
|
const baseId = baseCurrency.id;
|
|
224
245
|
if (!currencyId || String(currencyId) === String(baseId)) return 1;
|
|
225
|
-
if (String(currencyId) ===
|
|
246
|
+
if (String(currencyId) === linkId(current?.currency)) return current?.exchangeRate ?? options.exchangeRates?.[String(currencyId)] ?? 1;
|
|
226
247
|
return options.exchangeRates?.[String(currencyId)] ?? 1;
|
|
227
248
|
}
|
|
228
249
|
var roundAmount = (value, decimals) => Number(value.toFixed(decimals));
|
|
@@ -238,7 +259,12 @@ function recomputeCurrencyValue(amount, currencyValue, options, baseCurrency, cu
|
|
|
238
259
|
};
|
|
239
260
|
}
|
|
240
261
|
function patchCurrencyAmount(current, amount, options, baseCurrency) {
|
|
241
|
-
return recomputeCurrencyValue(amount,
|
|
262
|
+
if (!current) return recomputeCurrencyValue(amount, { id: "" }, options, baseCurrency, current);
|
|
263
|
+
return {
|
|
264
|
+
...recomputeCurrencyValue(amount, current.currency ?? { id: "" }, options, baseCurrency, current),
|
|
265
|
+
currency: current.currency,
|
|
266
|
+
exchangeRate: current.exchangeRate
|
|
267
|
+
};
|
|
242
268
|
}
|
|
243
269
|
function patchCurrencyCurrency(current, currencyValue, options, baseCurrency) {
|
|
244
270
|
return recomputeCurrencyValue(current?.amount ?? null, currencyValue, options, baseCurrency, current);
|
|
@@ -283,25 +309,14 @@ function numberFromBox(value) {
|
|
|
283
309
|
return value === "" ? null : value;
|
|
284
310
|
}
|
|
285
311
|
//#endregion
|
|
286
|
-
//#region src/utils/
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (
|
|
293
|
-
return
|
|
294
|
-
}
|
|
295
|
-
function linkDisplayText(value) {
|
|
296
|
-
if (value == null || typeof value !== "object") return void 0;
|
|
297
|
-
const text = value.displayText;
|
|
298
|
-
if (typeof text === "string") return text;
|
|
299
|
-
if (typeof text === "number") return String(text);
|
|
300
|
-
}
|
|
301
|
-
function asLinkValue(value) {
|
|
302
|
-
if (value != null && typeof value === "object") return value;
|
|
303
|
-
const id = linkId(value);
|
|
304
|
-
return id !== void 0 ? { id } : { id: "" };
|
|
312
|
+
//#region src/utils/recordNumber.ts
|
|
313
|
+
/**
|
|
314
|
+
* A number part of a box's value as a number, or null when it holds none. A part read from a record's
|
|
315
|
+
* own field holds what the server sent, and Postgres sends a `numeric` column as its decimal text.
|
|
316
|
+
*/
|
|
317
|
+
function numberFromRecord(value) {
|
|
318
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
319
|
+
return typeof value === "number" ? value : Number(value);
|
|
305
320
|
}
|
|
306
321
|
//#endregion
|
|
307
322
|
//#region src/composables/dropdownList.ts
|
|
@@ -522,7 +537,18 @@ var ADropdown_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
522
537
|
const record = asLinkValue(value);
|
|
523
538
|
return __props.formatter ? __props.formatter(record) : linkDisplayText(record) ?? String(record.id);
|
|
524
539
|
};
|
|
525
|
-
const
|
|
540
|
+
const knownLink = ref();
|
|
541
|
+
watch(() => linkModel.value, (value) => {
|
|
542
|
+
if (linkPicker.value && linkDisplayText(value)) knownLink.value = asLinkValue(value);
|
|
543
|
+
}, { immediate: true });
|
|
544
|
+
const shownLink = computed(() => {
|
|
545
|
+
const value = linkModel.value;
|
|
546
|
+
if (linkDisplayText(value)) return value;
|
|
547
|
+
const id = linkId(value);
|
|
548
|
+
const known = knownLink.value;
|
|
549
|
+
return known && id !== void 0 && String(known.id) === String(id) ? known : value;
|
|
550
|
+
});
|
|
551
|
+
const linkDisplayedText = computed(() => linkId(shownLink.value) === void 0 ? "—" : linkText(shownLink.value));
|
|
526
552
|
const search = ref("");
|
|
527
553
|
watch(modelValue, (value) => {
|
|
528
554
|
if (linkPicker.value) return;
|
|
@@ -530,16 +556,12 @@ var ADropdown_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
530
556
|
search.value = next;
|
|
531
557
|
if (next === "" || choiceList.value.includes(next)) committedValue.value = next;
|
|
532
558
|
}, { immediate: true });
|
|
533
|
-
watch(
|
|
559
|
+
watch(shownLink, (value) => {
|
|
534
560
|
if (!linkPicker.value) return;
|
|
535
561
|
search.value = linkId(value) ? linkText(value) : "";
|
|
536
562
|
}, { immediate: true });
|
|
537
|
-
watch(() => linkPicker.value ? linkId(linkModel.value) : void 0, async (id) => {
|
|
563
|
+
watch(() => linkPicker.value && !linkDisplayText(shownLink.value) ? linkId(linkModel.value) : void 0, async (id) => {
|
|
538
564
|
if (!linkPicker.value || !id) return;
|
|
539
|
-
if (linkDisplayText(linkModel.value)) {
|
|
540
|
-
search.value = linkText(linkModel.value);
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
565
|
try {
|
|
544
566
|
let match;
|
|
545
567
|
let displayText;
|
|
@@ -547,16 +569,12 @@ var ADropdown_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
547
569
|
match = (await (typeof __props.linkFilterFunction === "string" ? deserializeFunction(__props.linkFilterFunction) : __props.linkFilterFunction)(String(id))).find((r) => String(r.id) === String(id));
|
|
548
570
|
displayText = match?.displayText;
|
|
549
571
|
} else if (resolver && __props.doctype) displayText = await resolver(__props.doctype, id.toString()) ?? void 0;
|
|
550
|
-
if (displayText) {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
};
|
|
557
|
-
search.value = linkText(resolved);
|
|
558
|
-
linkModel.value = resolved;
|
|
559
|
-
}
|
|
572
|
+
if (displayText) knownLink.value = {
|
|
573
|
+
...asLinkValue(linkModel.value),
|
|
574
|
+
...match,
|
|
575
|
+
id,
|
|
576
|
+
displayText
|
|
577
|
+
};
|
|
560
578
|
} catch {}
|
|
561
579
|
}, { immediate: true });
|
|
562
580
|
const onClickOutside = () => closeDropdown();
|
|
@@ -565,7 +583,7 @@ var ADropdown_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
565
583
|
const id = linkId(linkModel.value);
|
|
566
584
|
return id !== void 0 && String(option.id) === String(id);
|
|
567
585
|
};
|
|
568
|
-
const embeddedLinkDisplayText = computed(() => linkId(
|
|
586
|
+
const embeddedLinkDisplayText = computed(() => linkId(shownLink.value) ? linkText(shownLink.value) : __props.placeholder ?? "");
|
|
569
587
|
const embeddedLinkInputSize = computed(() => {
|
|
570
588
|
if (!__props.embedded || !linkPicker.value) return void 0;
|
|
571
589
|
const text = embeddedLinkDisplayText.value;
|
|
@@ -592,8 +610,8 @@ var ADropdown_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
592
610
|
};
|
|
593
611
|
const embeddedLinkFilterQuery = () => {
|
|
594
612
|
if (!__props.embedded || !linkPicker.value) return search.value;
|
|
595
|
-
if (linkId(
|
|
596
|
-
const formatted = __props.formatter(asLinkValue(
|
|
613
|
+
if (linkId(shownLink.value) && __props.formatter) {
|
|
614
|
+
const formatted = __props.formatter(asLinkValue(shownLink.value));
|
|
597
615
|
if (search.value === formatted) return "";
|
|
598
616
|
}
|
|
599
617
|
return search.value;
|
|
@@ -639,7 +657,7 @@ var ADropdown_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
639
657
|
dropdown.activeItemIndex = null;
|
|
640
658
|
dropdown.open = false;
|
|
641
659
|
if (linkPicker.value) {
|
|
642
|
-
search.value = linkId(
|
|
660
|
+
search.value = linkId(shownLink.value) ? linkText(shownLink.value) : "";
|
|
643
661
|
return;
|
|
644
662
|
}
|
|
645
663
|
const typed = result || search.value || "";
|
|
@@ -844,7 +862,7 @@ var ADropdown_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
844
862
|
}, toDisplayString(errorText.value), 9, _hoisted_11$5)), [[vShow, errorText.value]]) : createCommentVNode("", true)], 64))], 2);
|
|
845
863
|
};
|
|
846
864
|
}
|
|
847
|
-
}), [["__scopeId", "data-v-
|
|
865
|
+
}), [["__scopeId", "data-v-a96ab394"]]);
|
|
848
866
|
//#endregion
|
|
849
867
|
//#region src/components/form/ACurrencyInput.vue?vue&type=script&setup=true&lang.ts
|
|
850
868
|
var _hoisted_1$23 = { class: "aform_form-element acurrency" };
|
|
@@ -902,13 +920,21 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
902
920
|
const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
|
|
903
921
|
const helperId = computed(() => __props.uuid ? `${__props.uuid}-helper` : void 0);
|
|
904
922
|
const modelValue = useModel(__props, "modelValue");
|
|
923
|
+
const shown = computed(() => {
|
|
924
|
+
const boxValue = modelValue.value;
|
|
925
|
+
if (!boxValue) return null;
|
|
926
|
+
const readValue = {
|
|
927
|
+
...boxValue,
|
|
928
|
+
currency: asLinkValue(boxValue.currency)
|
|
929
|
+
};
|
|
930
|
+
return recomputeCurrencyValue(numberFromRecord(boxValue.amount), readValue.currency, __props.options, normalizeBaseCurrency(__props.options, boxValue), readValue);
|
|
931
|
+
});
|
|
905
932
|
const showBase = computed(() => {
|
|
906
|
-
const
|
|
907
|
-
return !!
|
|
933
|
+
const shownValue = shown.value;
|
|
934
|
+
return !!shownValue?.baseCurrency?.id && (shownValue.currency?.id !== shownValue.baseCurrency?.id || shownValue.amount !== shownValue.baseAmount);
|
|
908
935
|
});
|
|
909
936
|
const helperDescribedBy = computed(() => showBase.value && !errorText.value ? helperId.value : void 0);
|
|
910
937
|
const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText, helperDescribedBy);
|
|
911
|
-
const currencySymbol = (value) => value.symbol ?? value.displayText ?? String(value.id);
|
|
912
938
|
const currencyDropdownRef = useTemplateRef("currencyDropdownRef");
|
|
913
939
|
const openCurrencyList = () => {
|
|
914
940
|
currencyDropdownRef.value?.openCurrencyList?.();
|
|
@@ -925,7 +951,7 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
925
951
|
const amountMaskEnabled = computed(() => __props.options.amountMask !== false);
|
|
926
952
|
const amountFocused = ref(false);
|
|
927
953
|
const amountText = ref("");
|
|
928
|
-
const selectedCurrencyId = computed(() =>
|
|
954
|
+
const selectedCurrencyId = computed(() => linkId(modelValue.value?.currency) ?? "");
|
|
929
955
|
const syncAmountTextFromModel = () => {
|
|
930
956
|
amountText.value = formatCurrencyAmountInput(modelValue.value?.amount ?? null, selectedCurrencyId.value);
|
|
931
957
|
};
|
|
@@ -1041,19 +1067,19 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
1041
1067
|
if (!currencyAmountEntryPattern(selectedCurrencyId.value).test(text)) event.preventDefault();
|
|
1042
1068
|
};
|
|
1043
1069
|
const conversionHelperText = computed(() => {
|
|
1044
|
-
const
|
|
1045
|
-
if (!
|
|
1046
|
-
const baseLabel = baseCurrencyText.value || String(
|
|
1047
|
-
const enteredId = String(
|
|
1048
|
-
const rate =
|
|
1049
|
-
return `≈ ${formatCurrencyAmount(
|
|
1070
|
+
const shownValue = shown.value;
|
|
1071
|
+
if (!shownValue || shownValue.baseAmount === null || shownValue.amount === null) return "";
|
|
1072
|
+
const baseLabel = baseCurrencyText.value || String(shownValue.baseCurrency?.id ?? "");
|
|
1073
|
+
const enteredId = String(shownValue.currency?.id ?? "");
|
|
1074
|
+
const rate = shownValue.exchangeRate;
|
|
1075
|
+
return `≈ ${formatCurrencyAmount(shownValue.baseAmount, shownValue.baseCurrency)} · 1 ${enteredId} = ${rate} ${baseLabel}`;
|
|
1050
1076
|
});
|
|
1051
1077
|
const displayText = computed(() => {
|
|
1052
|
-
const
|
|
1053
|
-
if (!
|
|
1054
|
-
const base = formatCurrencyAmount(
|
|
1078
|
+
const shownValue = shown.value;
|
|
1079
|
+
if (!shownValue || !shownValue.currency?.id || shownValue.amount === null) return "—";
|
|
1080
|
+
const base = formatCurrencyAmount(shownValue.amount, shownValue.currency);
|
|
1055
1081
|
if (!showBase.value) return base;
|
|
1056
|
-
return `${base} (≈ ${formatCurrencyAmount(
|
|
1082
|
+
return `${base} (≈ ${formatCurrencyAmount(shownValue.baseAmount, shownValue.baseCurrency)})`;
|
|
1057
1083
|
});
|
|
1058
1084
|
return (_ctx, _cache) => {
|
|
1059
1085
|
return openBlock(), createElementBlock("div", _hoisted_1$23, [__props.mode === "display" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("span", _hoisted_2$19, toDisplayString(displayText.value), 1), createElementVNode("label", _hoisted_3$16, toDisplayString(__props.label), 1)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
@@ -1073,7 +1099,7 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
1073
1099
|
required: __props.required,
|
|
1074
1100
|
placeholder: __props.currencyLabel,
|
|
1075
1101
|
"aria-label": __props.currencyLabel,
|
|
1076
|
-
formatter:
|
|
1102
|
+
formatter: unref(formatCurrencySymbol),
|
|
1077
1103
|
doctype: __props.options.doctype,
|
|
1078
1104
|
"link-filter-function": __props.options.filterFunction,
|
|
1079
1105
|
"is-async": __props.options.isAsync
|
|
@@ -1086,6 +1112,7 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
1086
1112
|
"required",
|
|
1087
1113
|
"placeholder",
|
|
1088
1114
|
"aria-label",
|
|
1115
|
+
"formatter",
|
|
1089
1116
|
"doctype",
|
|
1090
1117
|
"link-filter-function",
|
|
1091
1118
|
"is-async"
|
|
@@ -1148,7 +1175,7 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
1148
1175
|
], 64))]);
|
|
1149
1176
|
};
|
|
1150
1177
|
}
|
|
1151
|
-
}), [["__scopeId", "data-v-
|
|
1178
|
+
}), [["__scopeId", "data-v-f934faab"]]);
|
|
1152
1179
|
//#endregion
|
|
1153
1180
|
//#region src/utils/typedDay.ts
|
|
1154
1181
|
var TYPED_DAY_FORMAT = {
|
|
@@ -2732,7 +2759,8 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2732
2759
|
"hidden",
|
|
2733
2760
|
"mode",
|
|
2734
2761
|
"width",
|
|
2735
|
-
"height"
|
|
2762
|
+
"height",
|
|
2763
|
+
"parts"
|
|
2736
2764
|
].includes(key)) propsToPass[key] = value;
|
|
2737
2765
|
propsToPass["uuid"] ??= `${formId}-${componentObj.fieldname}`;
|
|
2738
2766
|
if (componentObj.kind === "table") {
|
|
@@ -2762,17 +2790,29 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2762
2790
|
if (fieldMode) return fieldMode;
|
|
2763
2791
|
return effectiveFormMode.value;
|
|
2764
2792
|
}
|
|
2793
|
+
const fieldParts = (field) => field.kind === "field" ? field.parts : void 0;
|
|
2794
|
+
const fieldErrors = (field) => {
|
|
2795
|
+
const parts = fieldParts(field);
|
|
2796
|
+
if (!parts) return __props.errors?.[field.fieldname];
|
|
2797
|
+
return Object.values(parts).flatMap((fieldname) => __props.errors?.[fieldname] ?? []);
|
|
2798
|
+
};
|
|
2765
2799
|
const childModelsCache = ref([]);
|
|
2766
2800
|
watchEffect(() => {
|
|
2767
2801
|
if (!__props.schema) return;
|
|
2768
|
-
if (childModelsCache.value.length !== __props.schema.length) childModelsCache.value = __props.schema.map((
|
|
2802
|
+
if (childModelsCache.value.length !== __props.schema.length) childModelsCache.value = __props.schema.map((_field, index) => {
|
|
2769
2803
|
return computed({
|
|
2770
2804
|
get() {
|
|
2771
|
-
|
|
2805
|
+
const parts = fieldParts(__props.schema[index]);
|
|
2806
|
+
if (parts) return readParts(parts, dataModel.value ?? {});
|
|
2807
|
+
return dataModel.value?.[__props.schema[index].fieldname];
|
|
2772
2808
|
},
|
|
2773
2809
|
set: (newValue) => {
|
|
2774
|
-
const
|
|
2775
|
-
|
|
2810
|
+
const parts = fieldParts(__props.schema[index]);
|
|
2811
|
+
const fieldname = __props.schema[index].fieldname;
|
|
2812
|
+
if (parts && dataModel.value) {
|
|
2813
|
+
Object.assign(dataModel.value, partsPatch(parts, dataModel.value, newValue));
|
|
2814
|
+
emit("update:data", { ...dataModel.value });
|
|
2815
|
+
} else if (fieldname && dataModel.value) {
|
|
2776
2816
|
dataModel.value[fieldname] = newValue;
|
|
2777
2817
|
emit("update:data", { ...dataModel.value });
|
|
2778
2818
|
}
|
|
@@ -2822,7 +2862,7 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2822
2862
|
schema: componentObj,
|
|
2823
2863
|
data: dataModel.value[componentObj.fieldname],
|
|
2824
2864
|
mode: resolvedMode(componentObj),
|
|
2825
|
-
errors:
|
|
2865
|
+
errors: fieldErrors(componentObj)
|
|
2826
2866
|
}, { ref_for: true }, componentProps(componentObj)), createSlots({ _: 2 }, [isListExpansionTable(componentObj) ? {
|
|
2827
2867
|
name: "content",
|
|
2828
2868
|
fn: withCtx(({ row, rowIndex }) => [createVNode(_component_AForm, {
|
|
@@ -2850,7 +2890,7 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2850
2890
|
}), 128))]);
|
|
2851
2891
|
};
|
|
2852
2892
|
}
|
|
2853
|
-
}), [["__scopeId", "data-v-
|
|
2893
|
+
}), [["__scopeId", "data-v-e40cafaf"]]);
|
|
2854
2894
|
//#endregion
|
|
2855
2895
|
//#region src/components/base/CollapseButton.vue
|
|
2856
2896
|
var CollapseButton_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
|
|
@@ -3065,11 +3105,22 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
3065
3105
|
const listboxId = `${__props.uuid ?? `aform-link-${useId()}`}-listbox`;
|
|
3066
3106
|
const modelValue = useModel(__props, "modelValue");
|
|
3067
3107
|
const hasValidId = computed(() => linkId(modelValue.value) !== void 0);
|
|
3108
|
+
const knownLink = ref();
|
|
3109
|
+
watch(() => modelValue.value, (value) => {
|
|
3110
|
+
if (linkDisplayText(value)) knownLink.value = asLinkValue(value);
|
|
3111
|
+
}, { immediate: true });
|
|
3112
|
+
const shownLink = computed(() => {
|
|
3113
|
+
const value = modelValue.value;
|
|
3114
|
+
if (linkDisplayText(value)) return value;
|
|
3115
|
+
const id = linkId(value);
|
|
3116
|
+
const known = knownLink.value;
|
|
3117
|
+
return known && id !== void 0 && String(known.id) === String(id) ? known : value;
|
|
3118
|
+
});
|
|
3068
3119
|
const displayedText = computed(() => {
|
|
3069
|
-
const id = linkId(
|
|
3120
|
+
const id = linkId(shownLink.value);
|
|
3070
3121
|
if (id === void 0) return "—";
|
|
3071
|
-
if (__props.formatter) return __props.formatter(asLinkValue(
|
|
3072
|
-
return linkDisplayText(
|
|
3122
|
+
if (__props.formatter) return __props.formatter(asLinkValue(shownLink.value));
|
|
3123
|
+
return linkDisplayText(shownLink.value) ?? id;
|
|
3073
3124
|
});
|
|
3074
3125
|
const searchText = ref(hasValidId.value ? displayedText.value : "");
|
|
3075
3126
|
const dropdownOpen = ref(false);
|
|
@@ -3079,7 +3130,7 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
3079
3130
|
const navigator = inject("aformLinkNavigator", null);
|
|
3080
3131
|
const resolver = inject("aformLinkResolver", null);
|
|
3081
3132
|
watch(() => linkId(modelValue.value), async (id) => {
|
|
3082
|
-
if (id && linkDisplayText(
|
|
3133
|
+
if (id && linkDisplayText(shownLink.value)) {
|
|
3083
3134
|
searchText.value = displayedText.value;
|
|
3084
3135
|
return;
|
|
3085
3136
|
}
|
|
@@ -3093,14 +3144,13 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
3093
3144
|
if (displayText === void 0) console.warn(`[AFormLink] filterFunction returned no matching result for id "${id}". The function must return an item whose \`id\` exactly matches the search string.`);
|
|
3094
3145
|
} else if (resolver && __props.doctype) displayText = await resolver(__props.doctype, id.toString()) ?? void 0;
|
|
3095
3146
|
if (displayText) {
|
|
3096
|
-
|
|
3147
|
+
knownLink.value = {
|
|
3097
3148
|
...asLinkValue(modelValue.value),
|
|
3098
3149
|
...match,
|
|
3099
3150
|
id,
|
|
3100
3151
|
displayText
|
|
3101
3152
|
};
|
|
3102
|
-
searchText.value =
|
|
3103
|
-
modelValue.value = resolved;
|
|
3153
|
+
searchText.value = displayedText.value;
|
|
3104
3154
|
}
|
|
3105
3155
|
} catch {}
|
|
3106
3156
|
}, { immediate: true });
|
|
@@ -3223,7 +3273,7 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
3223
3273
|
])) : createCommentVNode("", true)])), [[unref(vOnClickOutside), onClickOutside]]), __props.label && !__props.embedded ? (openBlock(), createElementBlock("label", _hoisted_13, toDisplayString(__props.label), 1)) : createCommentVNode("", true)], 64))], 2);
|
|
3224
3274
|
};
|
|
3225
3275
|
}
|
|
3226
|
-
}), [["__scopeId", "data-v-
|
|
3276
|
+
}), [["__scopeId", "data-v-7e0002c9"]]);
|
|
3227
3277
|
//#endregion
|
|
3228
3278
|
//#region src/components/form/ANumericInput.vue?vue&type=script&setup=true&lang.ts
|
|
3229
3279
|
var _hoisted_1$11 = { class: "aform_form-element" };
|
|
@@ -3314,7 +3364,7 @@ function recomputeQuantityValue(qty, uom, options, current) {
|
|
|
3314
3364
|
};
|
|
3315
3365
|
}
|
|
3316
3366
|
function patchQuantityQty(current, qty, options) {
|
|
3317
|
-
return recomputeQuantityValue(qty, current
|
|
3367
|
+
return recomputeQuantityValue(qty, current ? current.uom : "", options, current);
|
|
3318
3368
|
}
|
|
3319
3369
|
function patchQuantityUom(current, uom, options) {
|
|
3320
3370
|
return recomputeQuantityValue(current?.qty ?? null, uom, options, current);
|
|
@@ -3400,21 +3450,25 @@ var AQuantityInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
3400
3450
|
const pasted = event.clipboardData?.getData("text") ?? "";
|
|
3401
3451
|
if (!quantityEntryPattern.test(pasted)) event.preventDefault();
|
|
3402
3452
|
};
|
|
3453
|
+
const shown = computed(() => {
|
|
3454
|
+
const boxValue = modelValue.value;
|
|
3455
|
+
return boxValue ? recomputeQuantityValue(numberFromRecord(boxValue.qty), boxValue.uom, __props.options, boxValue) : null;
|
|
3456
|
+
});
|
|
3403
3457
|
const showStock = computed(() => {
|
|
3404
|
-
const
|
|
3405
|
-
return !!
|
|
3458
|
+
const shownValue = shown.value;
|
|
3459
|
+
return !!shownValue?.stockUom && (shownValue.uom !== shownValue.stockUom || shownValue.qty !== shownValue.stockQty);
|
|
3406
3460
|
});
|
|
3407
3461
|
const conversionHelperText = computed(() => {
|
|
3408
|
-
const
|
|
3409
|
-
if (!
|
|
3410
|
-
const factor =
|
|
3411
|
-
return `= ${
|
|
3462
|
+
const shownValue = shown.value;
|
|
3463
|
+
if (!shownValue || shownValue.stockQty === null || shownValue.qty === null) return "";
|
|
3464
|
+
const factor = shownValue.conversionFactor;
|
|
3465
|
+
return `= ${shownValue.stockQty} ${shownValue.stockUom} · 1 ${shownValue.uom} = ${factor} ${shownValue.stockUom}`;
|
|
3412
3466
|
});
|
|
3413
3467
|
const displayText = computed(() => {
|
|
3414
|
-
const
|
|
3415
|
-
if (!
|
|
3416
|
-
const base = `${
|
|
3417
|
-
return showStock.value ? `${base} (${
|
|
3468
|
+
const shownValue = shown.value;
|
|
3469
|
+
if (!shownValue || !shownValue.uom || shownValue.qty === null) return "—";
|
|
3470
|
+
const base = `${shownValue.qty} ${shownValue.uom}`;
|
|
3471
|
+
return showStock.value ? `${base} (${shownValue.stockQty} ${shownValue.stockUom})` : base;
|
|
3418
3472
|
});
|
|
3419
3473
|
return (_ctx, _cache) => {
|
|
3420
3474
|
return openBlock(), createElementBlock("div", _hoisted_1$10, [__props.mode === "display" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("span", _hoisted_2$6, toDisplayString(displayText.value), 1), createElementVNode("label", _hoisted_3$4, toDisplayString(__props.label), 1)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
@@ -3473,7 +3527,7 @@ var AQuantityInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
3473
3527
|
], 64))]);
|
|
3474
3528
|
};
|
|
3475
3529
|
}
|
|
3476
|
-
}), [["__scopeId", "data-v-
|
|
3530
|
+
}), [["__scopeId", "data-v-9bdbcd8c"]]);
|
|
3477
3531
|
//#endregion
|
|
3478
3532
|
//#region src/components/form/ASemverInput.vue?vue&type=script&setup=true&lang.ts
|
|
3479
3533
|
var _hoisted_1$9 = { class: "aform_form-element" };
|