@stonecrop/aform 0.59.0 → 0.60.1

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/dist/aform.js CHANGED
@@ -1,6 +1,6 @@
1
- import { hasBadgeOptions, isBadgeDescriptor, lookupBadge, partsPatch, readParts, selectChoices } from "@stonecrop/schema";
1
+ import { flattenFields, 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
- 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";
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, toHandlers, unref, useId, useModel, useTemplateRef, vModelCheckbox, vModelRadio, vModelSelect, vModelText, vShow, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers } from "vue";
4
4
  import { currencyAmountEntryPattern, currencyAmountSeparators, currencyInputFractionDigits, formatCurrencyAmount, formatCurrencyAmountInput, formatCurrencySymbol, fromISODate, isSemver, isSemverPrefix, parseCurrencyAmountInput, roundToPrecision, useArithmeticInput } from "@stonecrop/utilities";
5
5
  import { vOnClickOutside } from "@vueuse/components";
6
6
  import { Temporal } from "temporal-polyfill";
@@ -114,6 +114,15 @@ function resolvedFieldsToColumns(fields) {
114
114
  return columns;
115
115
  }
116
116
  // src/composables/fieldErrorA11y.ts
117
+ /**
118
+ * The message a field shows: the errors it is handed, joined, and nothing when it is handed none.
119
+ *
120
+ * A field only shows; it never words. Wording an error reported without a message is AForm's job
121
+ * (see `wordErrors`), since only the form knows which field each error came from.
122
+ */
123
+ function fieldErrorText(errors) {
124
+ return (errors ?? []).filter(Boolean).join("; ");
125
+ }
117
126
  function fieldErrorA11y(uuid, errorText, extraDescribedBy) {
118
127
  const errorId = computed(() => uuid ? `${uuid}-error` : void 0);
119
128
  const hasError = computed(() => Boolean(errorText.value));
@@ -151,7 +160,7 @@ var ACheckbox_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
151
160
  required: { type: Boolean },
152
161
  mode: {},
153
162
  uuid: {},
154
- validation: { default: () => ({ errorMessage: "" }) },
163
+ validation: {},
155
164
  errors: {}
156
165
  }, {
157
166
  "modelValue": { type: [
@@ -164,7 +173,7 @@ var ACheckbox_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
164
173
  }),
165
174
  emits: ["update:modelValue"],
166
175
  setup(__props) {
167
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
176
+ const errorText = computed(() => fieldErrorText(__props.errors));
168
177
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText);
169
178
  const checkbox = useModel(__props, "modelValue");
170
179
  return (_ctx, _cache) => {
@@ -199,7 +208,7 @@ var _plugin_vue_export_helper_default = (sfc, props) => {
199
208
  return target;
200
209
  };
201
210
  // src/components/form/ACheckbox.vue
202
- var ACheckbox_default = /*#__PURE__*/ _plugin_vue_export_helper_default(ACheckbox_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-f28e7db6"]]);
211
+ var ACheckbox_default = /*#__PURE__*/ _plugin_vue_export_helper_default(ACheckbox_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-fd79e86d"]]);
203
212
  // src/utils/linkValue.ts
204
213
  function linkId(value) {
205
214
  if (value == null) return void 0;
@@ -461,7 +470,7 @@ var ADropdown_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
461
470
  required: { type: Boolean },
462
471
  mode: {},
463
472
  uuid: {},
464
- validation: { default: () => ({ errorMessage: "" }) },
473
+ validation: {},
465
474
  errors: {},
466
475
  options: { default: () => [] },
467
476
  format: {},
@@ -510,7 +519,7 @@ var ADropdown_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
510
519
  const badgeDescriptor = computed(() => linkPicker.value ? null : resolveFieldBadge(search.value, __props.options, formatFn.value));
511
520
  const inputAccentStyle = computed(() => badgeInputAccentStyle(badgeDescriptor.value ?? void 0));
512
521
  const displayAccentStyle = computed(() => badgeInputAccentStyle(badgeDescriptor.value ?? void 0));
513
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
522
+ const errorText = computed(() => fieldErrorText(__props.errors));
514
523
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText);
515
524
  const modelValue = useModel(__props, "modelValue");
516
525
  const linkModel = useModel(__props, "linkValue");
@@ -854,7 +863,7 @@ var ADropdown_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
854
863
  }, toDisplayString(errorText.value), 9, _hoisted_11$5)), [[vShow, errorText.value]]) : createCommentVNode("", true)], 64))], 2);
855
864
  };
856
865
  }
857
- }), [["__scopeId", "data-v-a96ab394"]]);
866
+ }), [["__scopeId", "data-v-486dd9d1"]]);
858
867
  // src/components/form/ACurrencyInput.vue?vue&type=script&setup=true&lang.ts
859
868
  var _hoisted_1$23 = { class: "aform_form-element acurrency" };
860
869
  var _hoisted_2$19 = { class: "aform_display-value" };
@@ -904,7 +913,7 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
904
913
  required: { type: Boolean },
905
914
  mode: {},
906
915
  uuid: {},
907
- validation: { default: () => ({ errorMessage: "" }) },
916
+ validation: {},
908
917
  errors: {},
909
918
  options: { default: () => ({}) },
910
919
  currencyLabel: { default: "Currency" }
@@ -914,7 +923,7 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
914
923
  }),
915
924
  emits: ["update:modelValue"],
916
925
  setup(__props) {
917
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
926
+ const errorText = computed(() => fieldErrorText(__props.errors));
918
927
  const helperId = computed(() => __props.uuid ? `${__props.uuid}-helper` : void 0);
919
928
  const modelValue = useModel(__props, "modelValue");
920
929
  const shown = computed(() => {
@@ -1191,7 +1200,7 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
1191
1200
  ], 64))]);
1192
1201
  };
1193
1202
  }
1194
- }), [["__scopeId", "data-v-c18d0c0d"]]);
1203
+ }), [["__scopeId", "data-v-2aebb435"]]);
1195
1204
  // src/utils/typedDay.ts
1196
1205
  var TYPED_DAY_FORMAT = {
1197
1206
  calendar: "gregory",
@@ -1273,7 +1282,7 @@ var ADatePicker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
1273
1282
  required: { type: Boolean },
1274
1283
  mode: {},
1275
1284
  uuid: {},
1276
- validation: { default: () => ({ errorMessage: "" }) },
1285
+ validation: {},
1277
1286
  errors: {}
1278
1287
  }, {
1279
1288
  "modelValue": {},
@@ -1281,7 +1290,7 @@ var ADatePicker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
1281
1290
  }),
1282
1291
  emits: /*@__PURE__*/ mergeModels(["get-date"], ["update:modelValue"]),
1283
1292
  setup(__props, { expose: __expose, emit: __emit }) {
1284
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
1293
+ const errorText = computed(() => fieldErrorText(__props.errors));
1285
1294
  const { errorId } = fieldErrorA11y(__props.uuid, errorText);
1286
1295
  const date = useModel(__props, "modelValue");
1287
1296
  const selectedDate = ref(fromISODate(date.value ?? "") ?? Temporal.Now.plainDateISO());
@@ -1569,7 +1578,7 @@ var ADatePicker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
1569
1578
  }, toDisplayString(errorText.value), 9, _hoisted_14$1), [[vShow, errorText.value]])], 64));
1570
1579
  };
1571
1580
  }
1572
- }), [["__scopeId", "data-v-d0133599"]]);
1581
+ }), [["__scopeId", "data-v-2d02eab2"]]);
1573
1582
  // src/components/form/ADateTimeInput.vue?vue&type=script&setup=true&lang.ts
1574
1583
  var _hoisted_1$21 = { class: "adate_time" };
1575
1584
  var _hoisted_2$17 = { class: "adate_time_fields" };
@@ -1970,7 +1979,7 @@ var ADate_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
1970
1979
  required: { type: Boolean },
1971
1980
  mode: {},
1972
1981
  uuid: {},
1973
- validation: { default: () => ({ errorMessage: "" }) },
1982
+ validation: {},
1974
1983
  errors: {}
1975
1984
  }, {
1976
1985
  "modelValue": {},
@@ -1978,7 +1987,7 @@ var ADate_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
1978
1987
  }),
1979
1988
  emits: ["update:modelValue"],
1980
1989
  setup(__props) {
1981
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
1990
+ const errorText = computed(() => fieldErrorText(__props.errors));
1982
1991
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText);
1983
1992
  const modelValue = useModel(__props, "modelValue");
1984
1993
  const boxDay = computed({
@@ -2043,7 +2052,7 @@ var ADate_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
2043
2052
  ], 64))], 32);
2044
2053
  };
2045
2054
  }
2046
- }), [["__scopeId", "data-v-16f8f8f2"]]);
2055
+ }), [["__scopeId", "data-v-ea25d026"]]);
2047
2056
  // src/components/form/ABadge.vue
2048
2057
  var ABadge_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
2049
2058
  __name: "ABadge",
@@ -2131,7 +2140,7 @@ var ASegmentedControl_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
2131
2140
  required: { type: Boolean },
2132
2141
  mode: {},
2133
2142
  uuid: {},
2134
- validation: { default: () => ({ errorMessage: "" }) },
2143
+ validation: {},
2135
2144
  errors: {},
2136
2145
  options: { default: () => void 0 },
2137
2146
  size: { default: "sm" },
@@ -2165,7 +2174,7 @@ var ASegmentedControl_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
2165
2174
  selected.value = value;
2166
2175
  }
2167
2176
  });
2168
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
2177
+ const errorText = computed(() => fieldErrorText(__props.errors));
2169
2178
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText);
2170
2179
  const fallbackId = useId();
2171
2180
  const groupName = computed(() => __props.uuid ?? `aform-segmented-${fallbackId}`);
@@ -2270,7 +2279,7 @@ var ASegmentedControl_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
2270
2279
  ], 64))], 2);
2271
2280
  };
2272
2281
  }
2273
- }), [["__scopeId", "data-v-8b740fd8"]]);
2282
+ }), [["__scopeId", "data-v-07144f65"]]);
2274
2283
  // src/components/form/ADateTime.vue?vue&type=script&setup=true&lang.ts
2275
2284
  var _hoisted_1$17 = { class: "aform_display-value" };
2276
2285
  var _hoisted_2$13 = { class: "aform_field-label" };
@@ -2296,7 +2305,7 @@ var ADateTime_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
2296
2305
  required: { type: Boolean },
2297
2306
  mode: {},
2298
2307
  uuid: {},
2299
- validation: { default: () => ({ errorMessage: "" }) },
2308
+ validation: {},
2300
2309
  errors: {},
2301
2310
  allowMilitaryTime: {
2302
2311
  type: Boolean,
@@ -2312,7 +2321,7 @@ var ADateTime_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
2312
2321
  }),
2313
2322
  emits: ["update:modelValue"],
2314
2323
  setup(__props) {
2315
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
2324
+ const errorText = computed(() => fieldErrorText(__props.errors));
2316
2325
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText);
2317
2326
  const modelValue = useModel(__props, "modelValue");
2318
2327
  /** Now, cut down to the smallest unit the picker shows, so a pick that leaves the time alone saves the time shown. */
@@ -2450,7 +2459,7 @@ var ADateTime_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
2450
2459
  ], 64))], 32);
2451
2460
  };
2452
2461
  }
2453
- }), [["__scopeId", "data-v-05cbbabe"]]);
2462
+ }), [["__scopeId", "data-v-e0566056"]]);
2454
2463
  // src/components/form/ADuration.vue?vue&type=script&setup=true&lang.ts
2455
2464
  var _hoisted_1$16 = { class: "aduration" };
2456
2465
  var _hoisted_2$12 = { class: "aform_display-value" };
@@ -2561,7 +2570,7 @@ var ADateRange_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__P
2561
2570
  required: { type: Boolean },
2562
2571
  mode: {},
2563
2572
  uuid: {},
2564
- validation: { default: () => ({ errorMessage: "" }) },
2573
+ validation: {},
2565
2574
  errors: {}
2566
2575
  }, {
2567
2576
  "modelValue": { default: () => ({
@@ -2573,7 +2582,7 @@ var ADateRange_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__P
2573
2582
  emits: ["update:modelValue"],
2574
2583
  setup(__props) {
2575
2584
  const fmt = (d) => fromISODate(d)?.toLocaleString() ?? "Invalid Date";
2576
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
2585
+ const errorText = computed(() => fieldErrorText(__props.errors));
2577
2586
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText);
2578
2587
  const modelValue = useModel(__props, "modelValue");
2579
2588
  const readDay = (day) => day ? fromISODate(day) ?? null : null;
@@ -2670,7 +2679,24 @@ var ADateRange_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__P
2670
2679
  ], 64))], 32);
2671
2680
  };
2672
2681
  }
2673
- }), [["__scopeId", "data-v-ac2c160b"]]);
2682
+ }), [["__scopeId", "data-v-0e870cba"]]);
2683
+ // src/utils/fieldErrors.ts
2684
+ /**
2685
+ * The errors reported on one field, worded for display.
2686
+ *
2687
+ * An error reported without a message (a trigger's `setError(field)`) takes the field's own
2688
+ * `validation.errorMessage`; one with no message and no wording to give it is dropped. A static
2689
+ * message is never an error on its own: a field cannot tell that its value failed validation, so a
2690
+ * message shown with no reported error would sit on every record, valid or not, and mark the input
2691
+ * `aria-invalid` for a screen reader.
2692
+ *
2693
+ * Applied by AForm, the only place that knows which field an error came from: a component bound to
2694
+ * several fields' parts is handed all of their errors and cannot tell whose wording each one needs.
2695
+ */
2696
+ function wordErrors(errors, validation) {
2697
+ const messages = errors.map((error) => error || validation?.errorMessage || "").filter(Boolean);
2698
+ return [...new Set(messages)];
2699
+ }
2674
2700
  // src/components/AForm.vue?vue&type=script&setup=true&lang.ts
2675
2701
  var _hoisted_1$14 = { class: "aform" };
2676
2702
  var _hoisted_2$10 = {
@@ -2691,7 +2717,8 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
2691
2717
  props: /*@__PURE__*/ mergeModels({
2692
2718
  schema: {},
2693
2719
  mode: { default: "edit" },
2694
- errors: {}
2720
+ errors: {},
2721
+ "onUpdate:data": { type: Function }
2695
2722
  }, {
2696
2723
  "data": { required: true },
2697
2724
  "dataModifiers": {}
@@ -2700,9 +2727,17 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
2700
2727
  setup(__props, { emit: __emit }) {
2701
2728
  const emit = __emit;
2702
2729
  const dataModel = useModel(__props, "data");
2730
+ const heard = computed(() => Boolean(__props["onUpdate:data"]));
2731
+ const listenersWhenHeard = (handler) => heard.value ? { "update:data": handler } : {};
2703
2732
  const hasChildSchema = (componentObj) => "schema" in componentObj && Array.isArray(componentObj.schema) && componentObj.schema.length > 0;
2704
2733
  const isLinkSection = (componentObj) => componentObj.kind === "link" && hasChildSchema(componentObj);
2705
2734
  const isFieldsetSection = (componentObj) => componentObj.kind === "fieldset" && hasChildSchema(componentObj);
2735
+ const applyChanges = (changes) => {
2736
+ if (dataModel.value) dataModel.value = {
2737
+ ...dataModel.value,
2738
+ ...changes
2739
+ };
2740
+ };
2706
2741
  const nestedData = ref({});
2707
2742
  watch(() => dataModel.value, (newData) => {
2708
2743
  if (!__props.schema || !newData) return;
@@ -2712,29 +2747,16 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
2712
2747
  }, { immediate: true });
2713
2748
  const updateNestedData = (fieldname, val) => {
2714
2749
  nestedData.value[fieldname] = val;
2715
- if (dataModel.value) {
2716
- dataModel.value[fieldname] = val;
2717
- emit("update:data", { ...dataModel.value });
2718
- }
2719
- };
2720
- const updateFieldsetData = (val) => {
2721
- if (dataModel.value) {
2722
- Object.assign(dataModel.value, val);
2723
- emit("update:data", { ...dataModel.value });
2724
- }
2750
+ applyChanges({ [fieldname]: val });
2725
2751
  };
2752
+ const updateFieldsetData = (val) => applyChanges(val);
2726
2753
  const isListExpansionTable = (componentObj) => componentObj.kind === "table" && componentObj.config?.view === "list-expansion";
2727
2754
  const tableExpansionSchema = (table) => table.schema.filter((col) => Boolean(col.component)).map(({ fieldname, component, ...rest }) => Object.assign(rest, {
2728
2755
  kind: "field",
2729
2756
  fieldname,
2730
2757
  component
2731
2758
  }));
2732
- const updateTableRows = (fieldname, rows) => {
2733
- if (dataModel.value) {
2734
- dataModel.value[fieldname] = rows;
2735
- emit("update:data", { ...dataModel.value });
2736
- }
2737
- };
2759
+ const updateTableRows = (fieldname, rows) => applyChanges({ [fieldname]: rows });
2738
2760
  const updateTableRow = (fieldname, rowIndex, val) => {
2739
2761
  const rows = Array.isArray(dataModel.value?.[fieldname]) ? [...dataModel.value[fieldname]] : [];
2740
2762
  rows[rowIndex] = {
@@ -2761,6 +2783,7 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
2761
2783
  if (componentObj.kind === "table") {
2762
2784
  propsToPass["rows"] = dataModel.value[componentObj.fieldname] || [];
2763
2785
  propsToPass["onUpdate:rows"] = (rows) => updateTableRows(componentObj.fieldname, rows);
2786
+ if (resolvedMode(componentObj) !== "edit") propsToPass["schema"] = componentObj.schema.map((column) => Object.assign({}, column, { edit: false }));
2764
2787
  }
2765
2788
  return propsToPass;
2766
2789
  };
@@ -2781,15 +2804,22 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
2781
2804
  };
2782
2805
  const effectiveFormMode = computed(() => __props.mode ?? "edit");
2783
2806
  function resolvedMode(componentObj) {
2784
- const fieldMode = componentObj.mode;
2785
- if (fieldMode) return fieldMode;
2786
- return effectiveFormMode.value;
2807
+ const declared = componentObj.mode ?? effectiveFormMode.value;
2808
+ return declared === "edit" && !heard.value ? "read" : declared;
2787
2809
  }
2788
2810
  const fieldParts = (field) => field.kind === "field" || field.kind === "table" ? field.parts : void 0;
2811
+ const fieldsByName = computed(() => new Map(flattenFields(__props.schema).map((field) => [field.fieldname, field])));
2812
+ const formErrors = computed(() => {
2813
+ if (!__props.errors) return void 0;
2814
+ return Object.fromEntries(Object.entries(__props.errors).map(([fieldname, list]) => {
2815
+ const field = fieldsByName.value.get(fieldname);
2816
+ return [fieldname, wordErrors(list, field && "validation" in field ? field.validation : void 0)];
2817
+ }));
2818
+ });
2789
2819
  const fieldErrors = (field) => {
2790
2820
  const parts = fieldParts(field);
2791
- if (!parts) return __props.errors?.[field.fieldname];
2792
- return [.../* @__PURE__ */ new Set([field.fieldname, ...Object.values(parts)])].flatMap((fieldname) => __props.errors?.[fieldname] ?? []);
2821
+ if (!parts) return formErrors.value?.[field.fieldname];
2822
+ return [.../* @__PURE__ */ new Set([field.fieldname, ...Object.values(parts)])].flatMap((fieldname) => formErrors.value?.[fieldname] ?? []);
2793
2823
  };
2794
2824
  const childModelsCache = ref([]);
2795
2825
  watchEffect(() => {
@@ -2804,13 +2834,8 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
2804
2834
  set: (newValue) => {
2805
2835
  const parts = fieldParts(__props.schema[index]);
2806
2836
  const fieldname = __props.schema[index].fieldname;
2807
- if (parts && dataModel.value) {
2808
- Object.assign(dataModel.value, partsPatch(parts, dataModel.value, newValue));
2809
- emit("update:data", { ...dataModel.value });
2810
- } else if (fieldname && dataModel.value) {
2811
- dataModel.value[fieldname] = newValue;
2812
- emit("update:data", { ...dataModel.value });
2813
- }
2837
+ if (parts && dataModel.value) applyChanges(partsPatch(parts, dataModel.value, newValue));
2838
+ else if (fieldname) applyChanges({ [fieldname]: newValue });
2814
2839
  emit("update:schema", __props.schema);
2815
2840
  }
2816
2841
  });
@@ -2820,29 +2845,26 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
2820
2845
  return (_ctx, _cache) => {
2821
2846
  const _component_AForm = resolveComponent("AForm", true);
2822
2847
  return openBlock(), createElementBlock("form", _hoisted_1$14, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.schema, (componentObj, key) => {
2823
- return openBlock(), createElementBlock(Fragment, { key }, [isLinkSection(componentObj) ? (openBlock(), createElementBlock("div", _hoisted_2$10, [componentObj.label ? (openBlock(), createElementBlock("h4", _hoisted_3$8, toDisplayString(componentObj.label), 1)) : createCommentVNode("", true), (openBlock(), createBlock(resolveDynamicComponent(componentObj.component ?? "AForm"), {
2848
+ return openBlock(), createElementBlock(Fragment, { key }, [isLinkSection(componentObj) ? (openBlock(), createElementBlock("div", _hoisted_2$10, [componentObj.label ? (openBlock(), createElementBlock("h4", _hoisted_3$8, toDisplayString(componentObj.label), 1)) : createCommentVNode("", true), (openBlock(), createBlock(resolveDynamicComponent(componentObj.component ?? "AForm"), mergeProps({
2824
2849
  data: nestedData.value[componentObj.fieldname],
2825
2850
  mode: resolvedMode(componentObj),
2826
2851
  schema: componentObj.schema,
2827
2852
  label: componentObj.label,
2828
- errors: __props.errors,
2829
- "onUpdate:data": (val) => updateNestedData(componentObj.fieldname, val)
2830
- }, null, 40, [
2853
+ errors: __props.errors
2854
+ }, toHandlers(listenersWhenHeard((val) => updateNestedData(componentObj.fieldname, val)))), null, 16, [
2831
2855
  "data",
2832
2856
  "mode",
2833
2857
  "schema",
2834
2858
  "label",
2835
- "errors",
2836
- "onUpdate:data"
2837
- ]))])) : isFieldsetSection(componentObj) ? (openBlock(), createElementBlock("div", _hoisted_4$8, [(openBlock(), createBlock(resolveDynamicComponent(componentObj.component ?? "AFieldset"), {
2859
+ "errors"
2860
+ ]))])) : isFieldsetSection(componentObj) ? (openBlock(), createElementBlock("div", _hoisted_4$8, [(openBlock(), createBlock(resolveDynamicComponent(componentObj.component ?? "AFieldset"), mergeProps({
2838
2861
  data: dataModel.value,
2839
2862
  mode: resolvedMode(componentObj),
2840
2863
  schema: componentObj.schema,
2841
2864
  label: componentObj.label,
2842
2865
  collapsible: componentObj.collapsible,
2843
- errors: __props.errors,
2844
- "onUpdate:data": updateFieldsetData
2845
- }, null, 40, [
2866
+ errors: formErrors.value
2867
+ }, toHandlers(listenersWhenHeard(updateFieldsetData))), null, 16, [
2846
2868
  "data",
2847
2869
  "mode",
2848
2870
  "schema",
@@ -2860,17 +2882,15 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
2860
2882
  errors: fieldErrors(componentObj)
2861
2883
  }, { ref_for: true }, componentProps(componentObj)), createSlots({ _: 2 }, [isListExpansionTable(componentObj) ? {
2862
2884
  name: "content",
2863
- fn: withCtx(({ row, rowIndex }) => [createVNode(_component_AForm, {
2885
+ fn: withCtx(({ row, rowIndex }) => [createVNode(_component_AForm, mergeProps({
2864
2886
  class: "aform-table-expansion",
2865
2887
  data: row,
2866
2888
  schema: tableExpansionSchema(componentObj),
2867
- mode: resolvedMode(componentObj),
2868
- "onUpdate:data": (val) => updateTableRow(componentObj.fieldname, rowIndex, val)
2869
- }, null, 8, [
2889
+ mode: resolvedMode(componentObj)
2890
+ }, toHandlers(listenersWhenHeard((val) => updateTableRow(componentObj.fieldname, rowIndex, val)))), null, 16, [
2870
2891
  "data",
2871
2892
  "schema",
2872
- "mode",
2873
- "onUpdate:data"
2893
+ "mode"
2874
2894
  ])]),
2875
2895
  key: "0"
2876
2896
  } : void 0]), 1040, [
@@ -2885,7 +2905,7 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
2885
2905
  }), 128))]);
2886
2906
  };
2887
2907
  }
2888
- }), [["__scopeId", "data-v-9a38e038"]]);
2908
+ }), [["__scopeId", "data-v-33120a88"]]);
2889
2909
  // src/components/base/CollapseButton.vue
2890
2910
  var CollapseButton_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
2891
2911
  __name: "CollapseButton",
@@ -2904,7 +2924,8 @@ var AFieldset_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
2904
2924
  label: { default: () => void 0 },
2905
2925
  collapsible: { type: Boolean },
2906
2926
  mode: { default: "edit" },
2907
- errors: { default: () => void 0 }
2927
+ errors: { default: () => void 0 },
2928
+ "onUpdate:data": { type: Function }
2908
2929
  }, {
2909
2930
  "data": { default: () => ({}) },
2910
2931
  "dataModifiers": {}
@@ -2913,6 +2934,7 @@ var AFieldset_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
2913
2934
  setup(__props, { expose: __expose }) {
2914
2935
  /** The record the fieldset's fields belong to: a fieldset is layout, so they are its own keys. */
2915
2936
  const formData = useModel(__props, "data");
2937
+ const heard = computed(() => Boolean(__props["onUpdate:data"]));
2916
2938
  const collapsed = ref(false);
2917
2939
  const toggleCollapse = (event) => {
2918
2940
  event.preventDefault();
@@ -2927,13 +2949,12 @@ var AFieldset_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
2927
2949
  }, [createTextVNode(toDisplayString(__props.label) + " ", 1), __props.collapsible ? (openBlock(), createBlock(CollapseButton_default, {
2928
2950
  key: 0,
2929
2951
  collapsed: collapsed.value
2930
- }, null, 8, ["collapsed"])) : createCommentVNode("", true)], 32)) : createCommentVNode("", true), renderSlot(_ctx.$slots, "default", { collapsed: collapsed.value }, () => [withDirectives(createVNode(AForm_default, {
2952
+ }, null, 8, ["collapsed"])) : createCommentVNode("", true)], 32)) : createCommentVNode("", true), renderSlot(_ctx.$slots, "default", { collapsed: collapsed.value }, () => [withDirectives(createVNode(AForm_default, mergeProps({
2931
2953
  data: formData.value,
2932
- "onUpdate:data": _cache[0] || (_cache[0] = ($event) => formData.value = $event),
2933
2954
  schema: __props.schema,
2934
2955
  mode: __props.mode,
2935
2956
  errors: __props.errors
2936
- }, null, 8, [
2957
+ }, toHandlers(heard.value ? { "update:data": (record) => formData.value = record } : {})), null, 16, [
2937
2958
  "data",
2938
2959
  "schema",
2939
2960
  "mode",
@@ -2941,7 +2962,7 @@ var AFieldset_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
2941
2962
  ]), [[vShow, !collapsed.value]])], true)]);
2942
2963
  };
2943
2964
  }
2944
- }), [["__scopeId", "data-v-8215ff87"]]);
2965
+ }), [["__scopeId", "data-v-45ea7837"]]);
2945
2966
  // src/components/form/AFileAttach.vue?vue&type=script&setup=true&lang.ts
2946
2967
  var _hoisted_1$13 = { class: "aform_form-element aform_file-attach aform__grid--full" };
2947
2968
  var _hoisted_2$9 = {
@@ -3060,7 +3081,7 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
3060
3081
  required: { type: Boolean },
3061
3082
  mode: {},
3062
3083
  uuid: {},
3063
- validation: { default: () => ({ errorMessage: "" }) },
3084
+ validation: {},
3064
3085
  errors: {},
3065
3086
  doctype: { default: () => void 0 },
3066
3087
  formatter: {
@@ -3096,7 +3117,7 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
3096
3117
  emits: ["update:modelValue"],
3097
3118
  setup(__props) {
3098
3119
  const listboxId = `${__props.uuid ?? `aform-link-${useId()}`}-listbox`;
3099
- const errorText = computed(() => __props.embedded ? "" : __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
3120
+ const errorText = computed(() => __props.embedded ? "" : fieldErrorText(__props.errors));
3100
3121
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText);
3101
3122
  const modelValue = useModel(__props, "modelValue");
3102
3123
  const hasValidId = computed(() => linkId(modelValue.value) !== void 0);
@@ -3286,7 +3307,7 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
3286
3307
  ])) : createCommentVNode("", true)])), [[unref(vOnClickOutside), onClickOutside]]), __props.label && !__props.embedded ? (openBlock(), createElementBlock("label", _hoisted_15, toDisplayString(__props.label), 1)) : createCommentVNode("", true)], 64))], 2);
3287
3308
  };
3288
3309
  }
3289
- }), [["__scopeId", "data-v-df32226b"]]);
3310
+ }), [["__scopeId", "data-v-cca04ca2"]]);
3290
3311
  // src/components/form/ANumericInput.vue?vue&type=script&setup=true&lang.ts
3291
3312
  var _hoisted_1$11 = { class: "aform_form-element" };
3292
3313
  var _hoisted_2$7 = { class: "aform_display-value" };
@@ -3318,7 +3339,7 @@ var ANumericInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @
3318
3339
  required: { type: Boolean },
3319
3340
  mode: {},
3320
3341
  uuid: {},
3321
- validation: { default: () => ({ errorMessage: "" }) },
3342
+ validation: {},
3322
3343
  errors: {},
3323
3344
  options: { default: () => ({}) }
3324
3345
  }, {
@@ -3327,7 +3348,7 @@ var ANumericInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @
3327
3348
  }),
3328
3349
  emits: ["update:modelValue"],
3329
3350
  setup(__props) {
3330
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
3351
+ const errorText = computed(() => fieldErrorText(__props.errors));
3331
3352
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText);
3332
3353
  const inputNumber = useModel(__props, "modelValue");
3333
3354
  const boxNumber = computed({
@@ -3374,7 +3395,7 @@ var ANumericInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @
3374
3395
  ], 64))]);
3375
3396
  };
3376
3397
  }
3377
- }), [["__scopeId", "data-v-d13e377b"]]);
3398
+ }), [["__scopeId", "data-v-21f65960"]]);
3378
3399
  // src/utils/quantityValue.ts
3379
3400
  /** What a quantity box may hold, typed or pasted: digits, one decimal point and a leading minus sign. */
3380
3401
  var quantityEntryPattern = /^-?\d*\.?\d*$/;
@@ -3439,7 +3460,7 @@ var AQuantityInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
3439
3460
  required: { type: Boolean },
3440
3461
  mode: {},
3441
3462
  uuid: {},
3442
- validation: { default: () => ({ errorMessage: "" }) },
3463
+ validation: {},
3443
3464
  errors: {},
3444
3465
  options: { default: () => ({}) },
3445
3466
  uomLabel: { default: "UOM" }
@@ -3449,7 +3470,7 @@ var AQuantityInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
3449
3470
  }),
3450
3471
  emits: ["update:modelValue"],
3451
3472
  setup(__props) {
3452
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
3473
+ const errorText = computed(() => fieldErrorText(__props.errors));
3453
3474
  const helperId = computed(() => __props.uuid ? `${__props.uuid}-helper` : void 0);
3454
3475
  const helperDescribedBy = computed(() => showStock.value && !errorText.value ? helperId.value : void 0);
3455
3476
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText, helperDescribedBy);
@@ -3578,7 +3599,7 @@ var AQuantityInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
3578
3599
  ], 64))]);
3579
3600
  };
3580
3601
  }
3581
- }), [["__scopeId", "data-v-72062eb6"]]);
3602
+ }), [["__scopeId", "data-v-c08ba0bf"]]);
3582
3603
  // src/components/form/ASemverInput.vue?vue&type=script&setup=true&lang.ts
3583
3604
  var _hoisted_1$9 = { class: "aform_form-element" };
3584
3605
  var _hoisted_2$5 = { class: "aform_display-value" };
@@ -3604,7 +3625,7 @@ var ASemverInput_default = /* @__PURE__ */ defineComponent({
3604
3625
  required: { type: Boolean },
3605
3626
  mode: {},
3606
3627
  uuid: {},
3607
- validation: { default: () => ({ errorMessage: "" }) },
3628
+ validation: {},
3608
3629
  errors: {}
3609
3630
  }, {
3610
3631
  "modelValue": {},
@@ -3612,7 +3633,7 @@ var ASemverInput_default = /* @__PURE__ */ defineComponent({
3612
3633
  }),
3613
3634
  emits: ["update:modelValue"],
3614
3635
  setup(__props) {
3615
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
3636
+ const errorText = computed(() => fieldErrorText(__props.errors));
3616
3637
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText);
3617
3638
  const version = useModel(__props, "modelValue");
3618
3639
  const text = ref("");
@@ -3772,7 +3793,7 @@ var ATextInput_default = /* @__PURE__ */ defineComponent({
3772
3793
  required: { type: Boolean },
3773
3794
  mode: {},
3774
3795
  uuid: {},
3775
- validation: { default: () => ({ errorMessage: "" }) },
3796
+ validation: {},
3776
3797
  errors: {}
3777
3798
  }, {
3778
3799
  "modelValue": {},
@@ -3780,7 +3801,7 @@ var ATextInput_default = /* @__PURE__ */ defineComponent({
3780
3801
  }),
3781
3802
  emits: ["update:modelValue"],
3782
3803
  setup(__props) {
3783
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
3804
+ const errorText = computed(() => fieldErrorText(__props.errors));
3784
3805
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText);
3785
3806
  const maskFilled = ref(true);
3786
3807
  const inputText = useModel(__props, "modelValue");
@@ -3836,7 +3857,7 @@ var ATextboxInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @
3836
3857
  required: { type: Boolean },
3837
3858
  mode: {},
3838
3859
  uuid: {},
3839
- validation: { default: () => ({ errorMessage: "" }) },
3860
+ validation: {},
3840
3861
  errors: {},
3841
3862
  placeholder: { default: "" },
3842
3863
  rows: { default: 4 },
@@ -3847,7 +3868,7 @@ var ATextboxInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @
3847
3868
  }),
3848
3869
  emits: ["update:modelValue"],
3849
3870
  setup(__props) {
3850
- const errorText = computed(() => __props.errors?.length ? __props.errors.join("; ") : __props.validation.errorMessage ?? "");
3871
+ const errorText = computed(() => fieldErrorText(__props.errors));
3851
3872
  const { errorId, describedBy, invalid } = fieldErrorA11y(__props.uuid, errorText);
3852
3873
  const inputText = useModel(__props, "modelValue");
3853
3874
  return (_ctx, _cache) => {
@@ -3876,7 +3897,7 @@ var ATextboxInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @
3876
3897
  ], 64))]);
3877
3898
  };
3878
3899
  }
3879
- }), [["__scopeId", "data-v-19e611fa"]]);
3900
+ }), [["__scopeId", "data-v-14b32545"]]);
3880
3901
  // src/components/utilities/Login.vue?vue&type=script&setup=true&lang.ts
3881
3902
  var _hoisted_1$6 = { class: "login-container" };
3882
3903
  var _hoisted_2$2 = { class: "account-container" };