@stonecrop/aform 0.59.0 → 0.60.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/dist/aform.js +37 -50
- package/dist/aform.js.map +1 -1
- package/dist/assets/index.css +9 -9
- package/dist/src/components/AForm.vue.d.ts +2 -0
- package/dist/src/components/AForm.vue.d.ts.map +1 -1
- package/dist/src/components/form/AFieldset.vue.d.ts +2 -0
- package/dist/src/components/form/AFieldset.vue.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/aform.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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
|
-
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";
|
|
@@ -2691,7 +2691,8 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2691
2691
|
props: /*@__PURE__*/ mergeModels({
|
|
2692
2692
|
schema: {},
|
|
2693
2693
|
mode: { default: "edit" },
|
|
2694
|
-
errors: {}
|
|
2694
|
+
errors: {},
|
|
2695
|
+
"onUpdate:data": { type: Function }
|
|
2695
2696
|
}, {
|
|
2696
2697
|
"data": { required: true },
|
|
2697
2698
|
"dataModifiers": {}
|
|
@@ -2700,9 +2701,17 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2700
2701
|
setup(__props, { emit: __emit }) {
|
|
2701
2702
|
const emit = __emit;
|
|
2702
2703
|
const dataModel = useModel(__props, "data");
|
|
2704
|
+
const heard = computed(() => Boolean(__props["onUpdate:data"]));
|
|
2705
|
+
const listenersWhenHeard = (handler) => heard.value ? { "update:data": handler } : {};
|
|
2703
2706
|
const hasChildSchema = (componentObj) => "schema" in componentObj && Array.isArray(componentObj.schema) && componentObj.schema.length > 0;
|
|
2704
2707
|
const isLinkSection = (componentObj) => componentObj.kind === "link" && hasChildSchema(componentObj);
|
|
2705
2708
|
const isFieldsetSection = (componentObj) => componentObj.kind === "fieldset" && hasChildSchema(componentObj);
|
|
2709
|
+
const applyChanges = (changes) => {
|
|
2710
|
+
if (dataModel.value) dataModel.value = {
|
|
2711
|
+
...dataModel.value,
|
|
2712
|
+
...changes
|
|
2713
|
+
};
|
|
2714
|
+
};
|
|
2706
2715
|
const nestedData = ref({});
|
|
2707
2716
|
watch(() => dataModel.value, (newData) => {
|
|
2708
2717
|
if (!__props.schema || !newData) return;
|
|
@@ -2712,29 +2721,16 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2712
2721
|
}, { immediate: true });
|
|
2713
2722
|
const updateNestedData = (fieldname, val) => {
|
|
2714
2723
|
nestedData.value[fieldname] = val;
|
|
2715
|
-
|
|
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
|
-
}
|
|
2724
|
+
applyChanges({ [fieldname]: val });
|
|
2725
2725
|
};
|
|
2726
|
+
const updateFieldsetData = (val) => applyChanges(val);
|
|
2726
2727
|
const isListExpansionTable = (componentObj) => componentObj.kind === "table" && componentObj.config?.view === "list-expansion";
|
|
2727
2728
|
const tableExpansionSchema = (table) => table.schema.filter((col) => Boolean(col.component)).map(({ fieldname, component, ...rest }) => Object.assign(rest, {
|
|
2728
2729
|
kind: "field",
|
|
2729
2730
|
fieldname,
|
|
2730
2731
|
component
|
|
2731
2732
|
}));
|
|
2732
|
-
const updateTableRows = (fieldname, rows) => {
|
|
2733
|
-
if (dataModel.value) {
|
|
2734
|
-
dataModel.value[fieldname] = rows;
|
|
2735
|
-
emit("update:data", { ...dataModel.value });
|
|
2736
|
-
}
|
|
2737
|
-
};
|
|
2733
|
+
const updateTableRows = (fieldname, rows) => applyChanges({ [fieldname]: rows });
|
|
2738
2734
|
const updateTableRow = (fieldname, rowIndex, val) => {
|
|
2739
2735
|
const rows = Array.isArray(dataModel.value?.[fieldname]) ? [...dataModel.value[fieldname]] : [];
|
|
2740
2736
|
rows[rowIndex] = {
|
|
@@ -2761,6 +2757,7 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2761
2757
|
if (componentObj.kind === "table") {
|
|
2762
2758
|
propsToPass["rows"] = dataModel.value[componentObj.fieldname] || [];
|
|
2763
2759
|
propsToPass["onUpdate:rows"] = (rows) => updateTableRows(componentObj.fieldname, rows);
|
|
2760
|
+
if (resolvedMode(componentObj) !== "edit") propsToPass["schema"] = componentObj.schema.map((column) => Object.assign({}, column, { edit: false }));
|
|
2764
2761
|
}
|
|
2765
2762
|
return propsToPass;
|
|
2766
2763
|
};
|
|
@@ -2781,9 +2778,8 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2781
2778
|
};
|
|
2782
2779
|
const effectiveFormMode = computed(() => __props.mode ?? "edit");
|
|
2783
2780
|
function resolvedMode(componentObj) {
|
|
2784
|
-
const
|
|
2785
|
-
|
|
2786
|
-
return effectiveFormMode.value;
|
|
2781
|
+
const declared = componentObj.mode ?? effectiveFormMode.value;
|
|
2782
|
+
return declared === "edit" && !heard.value ? "read" : declared;
|
|
2787
2783
|
}
|
|
2788
2784
|
const fieldParts = (field) => field.kind === "field" || field.kind === "table" ? field.parts : void 0;
|
|
2789
2785
|
const fieldErrors = (field) => {
|
|
@@ -2804,13 +2800,8 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2804
2800
|
set: (newValue) => {
|
|
2805
2801
|
const parts = fieldParts(__props.schema[index]);
|
|
2806
2802
|
const fieldname = __props.schema[index].fieldname;
|
|
2807
|
-
if (parts && dataModel.value)
|
|
2808
|
-
|
|
2809
|
-
emit("update:data", { ...dataModel.value });
|
|
2810
|
-
} else if (fieldname && dataModel.value) {
|
|
2811
|
-
dataModel.value[fieldname] = newValue;
|
|
2812
|
-
emit("update:data", { ...dataModel.value });
|
|
2813
|
-
}
|
|
2803
|
+
if (parts && dataModel.value) applyChanges(partsPatch(parts, dataModel.value, newValue));
|
|
2804
|
+
else if (fieldname) applyChanges({ [fieldname]: newValue });
|
|
2814
2805
|
emit("update:schema", __props.schema);
|
|
2815
2806
|
}
|
|
2816
2807
|
});
|
|
@@ -2820,29 +2811,26 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2820
2811
|
return (_ctx, _cache) => {
|
|
2821
2812
|
const _component_AForm = resolveComponent("AForm", true);
|
|
2822
2813
|
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"), {
|
|
2814
|
+
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
2815
|
data: nestedData.value[componentObj.fieldname],
|
|
2825
2816
|
mode: resolvedMode(componentObj),
|
|
2826
2817
|
schema: componentObj.schema,
|
|
2827
2818
|
label: componentObj.label,
|
|
2828
|
-
errors: __props.errors
|
|
2829
|
-
|
|
2830
|
-
}, null, 40, [
|
|
2819
|
+
errors: __props.errors
|
|
2820
|
+
}, toHandlers(listenersWhenHeard((val) => updateNestedData(componentObj.fieldname, val)))), null, 16, [
|
|
2831
2821
|
"data",
|
|
2832
2822
|
"mode",
|
|
2833
2823
|
"schema",
|
|
2834
2824
|
"label",
|
|
2835
|
-
"errors"
|
|
2836
|
-
|
|
2837
|
-
]))])) : isFieldsetSection(componentObj) ? (openBlock(), createElementBlock("div", _hoisted_4$8, [(openBlock(), createBlock(resolveDynamicComponent(componentObj.component ?? "AFieldset"), {
|
|
2825
|
+
"errors"
|
|
2826
|
+
]))])) : isFieldsetSection(componentObj) ? (openBlock(), createElementBlock("div", _hoisted_4$8, [(openBlock(), createBlock(resolveDynamicComponent(componentObj.component ?? "AFieldset"), mergeProps({
|
|
2838
2827
|
data: dataModel.value,
|
|
2839
2828
|
mode: resolvedMode(componentObj),
|
|
2840
2829
|
schema: componentObj.schema,
|
|
2841
2830
|
label: componentObj.label,
|
|
2842
2831
|
collapsible: componentObj.collapsible,
|
|
2843
|
-
errors: __props.errors
|
|
2844
|
-
|
|
2845
|
-
}, null, 40, [
|
|
2832
|
+
errors: __props.errors
|
|
2833
|
+
}, toHandlers(listenersWhenHeard(updateFieldsetData))), null, 16, [
|
|
2846
2834
|
"data",
|
|
2847
2835
|
"mode",
|
|
2848
2836
|
"schema",
|
|
@@ -2860,17 +2848,15 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2860
2848
|
errors: fieldErrors(componentObj)
|
|
2861
2849
|
}, { ref_for: true }, componentProps(componentObj)), createSlots({ _: 2 }, [isListExpansionTable(componentObj) ? {
|
|
2862
2850
|
name: "content",
|
|
2863
|
-
fn: withCtx(({ row, rowIndex }) => [createVNode(_component_AForm, {
|
|
2851
|
+
fn: withCtx(({ row, rowIndex }) => [createVNode(_component_AForm, mergeProps({
|
|
2864
2852
|
class: "aform-table-expansion",
|
|
2865
2853
|
data: row,
|
|
2866
2854
|
schema: tableExpansionSchema(componentObj),
|
|
2867
|
-
mode: resolvedMode(componentObj)
|
|
2868
|
-
|
|
2869
|
-
}, null, 8, [
|
|
2855
|
+
mode: resolvedMode(componentObj)
|
|
2856
|
+
}, toHandlers(listenersWhenHeard((val) => updateTableRow(componentObj.fieldname, rowIndex, val)))), null, 16, [
|
|
2870
2857
|
"data",
|
|
2871
2858
|
"schema",
|
|
2872
|
-
"mode"
|
|
2873
|
-
"onUpdate:data"
|
|
2859
|
+
"mode"
|
|
2874
2860
|
])]),
|
|
2875
2861
|
key: "0"
|
|
2876
2862
|
} : void 0]), 1040, [
|
|
@@ -2885,7 +2871,7 @@ var AForm_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
2885
2871
|
}), 128))]);
|
|
2886
2872
|
};
|
|
2887
2873
|
}
|
|
2888
|
-
}), [["__scopeId", "data-v-
|
|
2874
|
+
}), [["__scopeId", "data-v-9065abbb"]]);
|
|
2889
2875
|
// src/components/base/CollapseButton.vue
|
|
2890
2876
|
var CollapseButton_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
|
|
2891
2877
|
__name: "CollapseButton",
|
|
@@ -2904,7 +2890,8 @@ var AFieldset_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
2904
2890
|
label: { default: () => void 0 },
|
|
2905
2891
|
collapsible: { type: Boolean },
|
|
2906
2892
|
mode: { default: "edit" },
|
|
2907
|
-
errors: { default: () => void 0 }
|
|
2893
|
+
errors: { default: () => void 0 },
|
|
2894
|
+
"onUpdate:data": { type: Function }
|
|
2908
2895
|
}, {
|
|
2909
2896
|
"data": { default: () => ({}) },
|
|
2910
2897
|
"dataModifiers": {}
|
|
@@ -2913,6 +2900,7 @@ var AFieldset_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
2913
2900
|
setup(__props, { expose: __expose }) {
|
|
2914
2901
|
/** The record the fieldset's fields belong to: a fieldset is layout, so they are its own keys. */
|
|
2915
2902
|
const formData = useModel(__props, "data");
|
|
2903
|
+
const heard = computed(() => Boolean(__props["onUpdate:data"]));
|
|
2916
2904
|
const collapsed = ref(false);
|
|
2917
2905
|
const toggleCollapse = (event) => {
|
|
2918
2906
|
event.preventDefault();
|
|
@@ -2927,13 +2915,12 @@ var AFieldset_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
2927
2915
|
}, [createTextVNode(toDisplayString(__props.label) + " ", 1), __props.collapsible ? (openBlock(), createBlock(CollapseButton_default, {
|
|
2928
2916
|
key: 0,
|
|
2929
2917
|
collapsed: collapsed.value
|
|
2930
|
-
}, null, 8, ["collapsed"])) : createCommentVNode("", true)], 32)) : createCommentVNode("", true), renderSlot(_ctx.$slots, "default", { collapsed: collapsed.value }, () => [withDirectives(createVNode(AForm_default, {
|
|
2918
|
+
}, null, 8, ["collapsed"])) : createCommentVNode("", true)], 32)) : createCommentVNode("", true), renderSlot(_ctx.$slots, "default", { collapsed: collapsed.value }, () => [withDirectives(createVNode(AForm_default, mergeProps({
|
|
2931
2919
|
data: formData.value,
|
|
2932
|
-
"onUpdate:data": _cache[0] || (_cache[0] = ($event) => formData.value = $event),
|
|
2933
2920
|
schema: __props.schema,
|
|
2934
2921
|
mode: __props.mode,
|
|
2935
2922
|
errors: __props.errors
|
|
2936
|
-
}, null,
|
|
2923
|
+
}, toHandlers(heard.value ? { "update:data": (record) => formData.value = record } : {})), null, 16, [
|
|
2937
2924
|
"data",
|
|
2938
2925
|
"schema",
|
|
2939
2926
|
"mode",
|
|
@@ -2941,7 +2928,7 @@ var AFieldset_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
2941
2928
|
]), [[vShow, !collapsed.value]])], true)]);
|
|
2942
2929
|
};
|
|
2943
2930
|
}
|
|
2944
|
-
}), [["__scopeId", "data-v-
|
|
2931
|
+
}), [["__scopeId", "data-v-45ea7837"]]);
|
|
2945
2932
|
// src/components/form/AFileAttach.vue?vue&type=script&setup=true&lang.ts
|
|
2946
2933
|
var _hoisted_1$13 = { class: "aform_form-element aform_file-attach aform__grid--full" };
|
|
2947
2934
|
var _hoisted_2$9 = {
|