@atscript/vue-form 0.1.207 → 0.1.208
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/as-action.d.cts +1 -1
- package/dist/as-action.d.mts +1 -1
- package/dist/{as-action.vue-BjGc3z94.d.mts → as-action.vue-D0twy1JK.d.cts} +1 -1
- package/dist/{as-action.vue-wGCmd-ww.d.cts → as-action.vue-Dse77iCr.d.mts} +1 -1
- package/dist/{as-array-CHVronOS.mjs → as-array-CEtgj6nd.mjs} +8 -9
- package/dist/{as-array-BCmGCZul.cjs → as-array-CKedVJIz.cjs} +8 -9
- package/dist/{as-array-clear-btn-DOBKhLCy.mjs → as-array-clear-btn-BFfll2RA.mjs} +1 -1
- package/dist/{as-array-clear-btn-BolX7Wpe.cjs → as-array-clear-btn-nYR8rEeL.cjs} +1 -1
- package/dist/as-array.cjs +1 -1
- package/dist/as-array.d.cts +1 -1
- package/dist/as-array.d.mts +1 -1
- package/dist/as-array.mjs +1 -1
- package/dist/{as-array.vue-BB22gE0u.d.cts → as-array.vue-BCB8mLx-.d.mts} +1 -1
- package/dist/{as-array.vue-CgYp_DSb.d.mts → as-array.vue-DJNzEE8-.d.cts} +1 -1
- package/dist/{as-checkbox-BX5N5GHR.mjs → as-checkbox-B7C-CvhT.mjs} +4 -2
- package/dist/{as-checkbox-BKWtScvS.cjs → as-checkbox-DKaEfo7e.cjs} +4 -2
- package/dist/as-checkbox.cjs +1 -1
- package/dist/as-checkbox.d.cts +1 -1
- package/dist/as-checkbox.d.mts +1 -1
- package/dist/as-checkbox.mjs +1 -1
- package/dist/{as-checkbox.vue-CQzeu4IP.d.mts → as-checkbox.vue-CoCgt4vV.d.mts} +1 -1
- package/dist/{as-checkbox.vue-RTW5hwvE.d.cts → as-checkbox.vue-fPeyQDp5.d.cts} +1 -1
- package/dist/{as-collapsible-C37-3_Rp.cjs → as-collapsible-Bs0LOl1t.cjs} +1 -1
- package/dist/{as-collapsible-B9KPgJyo.mjs → as-collapsible-DOIWkQ0v.mjs} +1 -1
- package/dist/as-collapsible.cjs +1 -1
- package/dist/as-collapsible.d.cts +1 -1
- package/dist/as-collapsible.d.mts +1 -1
- package/dist/as-collapsible.mjs +1 -1
- package/dist/{as-collapsible.vue-BKN4DmSy.d.mts → as-collapsible.vue-CH3ez8zm.d.cts} +1 -1
- package/dist/{as-collapsible.vue-CPmozkkf.d.cts → as-collapsible.vue-DewV2oaE.d.mts} +1 -1
- package/dist/{as-date-C6tT9FPz.cjs → as-date-BMKMiM_d.cjs} +2 -2
- package/dist/{as-date-Bkrp2GY4.mjs → as-date-CFQtrpZT.mjs} +2 -2
- package/dist/as-date.cjs +1 -1
- package/dist/as-date.d.cts +1 -1
- package/dist/as-date.d.mts +1 -1
- package/dist/as-date.mjs +1 -1
- package/dist/{as-date.vue-BpfWumrA.d.cts → as-date.vue-BSghCVx0.d.cts} +1 -1
- package/dist/{as-date.vue-DJ125nVS.d.mts → as-date.vue-CPgqqKMB.d.mts} +1 -1
- package/dist/{as-datetime-DWLW4W7O.cjs → as-datetime-Bl1K4U51.cjs} +2 -2
- package/dist/{as-datetime-Dt_AWrCG.mjs → as-datetime-DqfSymmL.mjs} +2 -2
- package/dist/as-datetime.cjs +1 -1
- package/dist/as-datetime.d.cts +1 -1
- package/dist/as-datetime.d.mts +1 -1
- package/dist/as-datetime.mjs +1 -1
- package/dist/{as-datetime.vue-DO3tkof1.d.cts → as-datetime.vue-B-KRC-0X.d.mts} +1 -1
- package/dist/{as-datetime.vue-DfFAaVdS.d.mts → as-datetime.vue-CjDTsMDw.d.cts} +1 -1
- package/dist/{as-decimal-DuWZDjbg.cjs → as-decimal-48M_h9Sl.cjs} +18 -24
- package/dist/{as-decimal-BUr24VTI.mjs → as-decimal-CsAJlvie.mjs} +18 -24
- package/dist/as-decimal.cjs +1 -1
- package/dist/as-decimal.d.cts +1 -1
- package/dist/as-decimal.d.mts +1 -1
- package/dist/as-decimal.mjs +1 -1
- package/dist/{as-decimal.vue-BODauGXK.d.mts → as-decimal.vue-BZ2imea4.d.mts} +1 -1
- package/dist/{as-decimal.vue-C42_-oK9.d.cts → as-decimal.vue-BvvG5aIL.d.cts} +1 -1
- package/dist/{as-field-iQ2H3VGd.mjs → as-field-C6iquEB1.mjs} +99 -137
- package/dist/{as-field-lMMfms8d.cjs → as-field-CJMJJfXO.cjs} +98 -136
- package/dist/{as-field-shell-BPesuJKa.cjs → as-field-shell-CMq52Z6e.cjs} +2 -2
- package/dist/{as-field-shell-QMsYyJ8r.mjs → as-field-shell-DXbAJupk.mjs} +2 -2
- package/dist/as-field-shell.cjs +1 -1
- package/dist/as-field-shell.d.cts +1 -1
- package/dist/as-field-shell.d.mts +1 -1
- package/dist/as-field-shell.mjs +1 -1
- package/dist/{as-field-shell.vue-CQqwykWy.d.cts → as-field-shell.vue-BbSIqZSY.d.cts} +1 -1
- package/dist/{as-field-shell.vue-o7T2u4aw.d.mts → as-field-shell.vue-D0NYcajH.d.mts} +1 -1
- package/dist/as-field.cjs +1 -1
- package/dist/as-field.mjs +1 -1
- package/dist/{as-form-DE3TVGV-.cjs → as-form-B4-StU3b.cjs} +19 -38
- package/dist/{as-form-CuMRP5aZ.mjs → as-form-DQePBFwR.mjs} +20 -39
- package/dist/as-form.cjs +1 -1
- package/dist/as-form.d.cts +1 -1
- package/dist/as-form.d.mts +1 -1
- package/dist/as-form.mjs +1 -1
- package/dist/{as-form.vue-DwqofFJa.d.mts → as-form.vue-BMNZuvpb.d.mts} +54 -20
- package/dist/{as-form.vue-B9MZrw7V.d.cts → as-form.vue-DS5r3CWl.d.cts} +54 -20
- package/dist/{as-input-BEP6nX82.mjs → as-input-D1IO72Tn.mjs} +1 -1
- package/dist/{as-input-BrgRxZag.cjs → as-input-Dy7v1AjV.cjs} +1 -1
- package/dist/as-input.cjs +1 -1
- package/dist/as-input.d.cts +1 -1
- package/dist/as-input.d.mts +1 -1
- package/dist/as-input.mjs +1 -1
- package/dist/{as-input.vue-Cl8DTJqr.d.cts → as-input.vue-DMxFk9uv.d.cts} +1 -1
- package/dist/{as-input.vue-CqV91VOb.d.mts → as-input.vue-DzG-WB4x.d.mts} +1 -1
- package/dist/{as-iterator-DbCm61j1.mjs → as-iterator-A9ozhHhf.mjs} +2 -2
- package/dist/{as-iterator-DeLt7-BO.cjs → as-iterator-C8aJ6SUs.cjs} +2 -2
- package/dist/as-iterator.cjs +1 -1
- package/dist/as-iterator.mjs +1 -1
- package/dist/{as-multi-select-CJ3iRsiL.cjs → as-multi-select-BiOEQf1L.cjs} +4 -8
- package/dist/{as-multi-select-Ca2ULklw.mjs → as-multi-select-CoT5MJd_.mjs} +5 -9
- package/dist/as-multi-select.cjs +1 -1
- package/dist/as-multi-select.d.cts +1 -1
- package/dist/as-multi-select.d.mts +1 -1
- package/dist/as-multi-select.mjs +1 -1
- package/dist/{as-multi-select.vue-B6M_f7u-.d.cts → as-multi-select.vue-CBtBFW6X.d.cts} +1 -1
- package/dist/{as-multi-select.vue-Cvvy1kMm.d.mts → as-multi-select.vue-CGjTCFGD.d.mts} +1 -1
- package/dist/{as-number-CgHRTx6P.mjs → as-number-Ck8nNMCB.mjs} +1 -1
- package/dist/{as-number-CHXaKqtg.cjs → as-number-DKW_PZcq.cjs} +1 -1
- package/dist/as-number.cjs +1 -1
- package/dist/as-number.d.cts +1 -1
- package/dist/as-number.d.mts +1 -1
- package/dist/as-number.mjs +1 -1
- package/dist/{as-number.vue-5U6oFVJC.d.cts → as-number.vue-AKk1tllp.d.mts} +1 -1
- package/dist/{as-number.vue-BN6_1oQf.d.mts → as-number.vue-i5gytLQ2.d.cts} +1 -1
- package/dist/{as-object-BCeBkKCo.mjs → as-object-6GgXdo_K.mjs} +4 -4
- package/dist/{as-object-Babu0BIk.cjs → as-object-DfHzCJcJ.cjs} +4 -4
- package/dist/as-object.cjs +1 -1
- package/dist/as-object.d.cts +1 -1
- package/dist/as-object.d.mts +1 -1
- package/dist/as-object.mjs +1 -1
- package/dist/{as-object.vue-BNCOIwjS.d.mts → as-object.vue-Gor6cnwh.d.mts} +1 -1
- package/dist/{as-object.vue-BnUdIcLW.d.cts → as-object.vue-cwrRrJ2O.d.cts} +1 -1
- package/dist/as-paragraph.d.cts +1 -1
- package/dist/as-paragraph.d.mts +1 -1
- package/dist/{as-paragraph.vue-80Q1bZMd.d.cts → as-paragraph.vue-DqHrI7WD.d.mts} +1 -1
- package/dist/{as-paragraph.vue-Dhy9ke_Z.d.mts → as-paragraph.vue-Ds64gwEP.d.cts} +1 -1
- package/dist/{as-radio-CL6Np-X5.mjs → as-radio-Cc3VOm3A.mjs} +1 -1
- package/dist/{as-radio-BFM_CPvW.cjs → as-radio-DLGMEC9o.cjs} +1 -1
- package/dist/as-radio.cjs +1 -1
- package/dist/as-radio.d.cts +1 -1
- package/dist/as-radio.d.mts +1 -1
- package/dist/as-radio.mjs +1 -1
- package/dist/{as-radio.vue-ByorW-nk.d.cts → as-radio.vue-CkooFq0m.d.cts} +1 -1
- package/dist/{as-radio.vue-CLdvEAmZ.d.mts → as-radio.vue-T0Ejt0II.d.mts} +1 -1
- package/dist/{as-ref-D14yC6np.mjs → as-ref-Cs4i9tpS.mjs} +2 -2
- package/dist/{as-ref-CEj1RBnH.cjs → as-ref-FknTPCae.cjs} +2 -2
- package/dist/as-ref.cjs +1 -1
- package/dist/as-ref.d.cts +1 -1
- package/dist/as-ref.d.mts +1 -1
- package/dist/as-ref.mjs +1 -1
- package/dist/{as-ref.vue--ISeV6VM.d.cts → as-ref.vue-CCzEnDNd.d.cts} +1 -1
- package/dist/{as-ref.vue-DW7vsBE6.d.mts → as-ref.vue-CvStQFs3.d.mts} +1 -1
- package/dist/{as-select-B-ZeOCu5.cjs → as-select-DBxxq0jZ.cjs} +1 -1
- package/dist/{as-select-BME-vti2.mjs → as-select-br9EmsoX.mjs} +1 -1
- package/dist/as-select.cjs +1 -1
- package/dist/as-select.d.cts +1 -1
- package/dist/as-select.d.mts +1 -1
- package/dist/as-select.mjs +1 -1
- package/dist/{as-select.vue-BEfTkycX.d.cts → as-select.vue-CK4AWxmk.d.cts} +1 -1
- package/dist/{as-select.vue-C45NS5Rq.d.mts → as-select.vue-LKjJASjX.d.mts} +1 -1
- package/dist/{as-time-CnuojSkh.cjs → as-time-BmTk1YfU.cjs} +2 -2
- package/dist/{as-time-HRZh7pdx.mjs → as-time-DTz7PrnB.mjs} +2 -2
- package/dist/as-time.cjs +1 -1
- package/dist/as-time.d.cts +1 -1
- package/dist/as-time.d.mts +1 -1
- package/dist/as-time.mjs +1 -1
- package/dist/{as-time.vue--Qmcr-O0.d.cts → as-time.vue-DTRJCO4G.d.cts} +1 -1
- package/dist/{as-time.vue-0M0m0DXe.d.mts → as-time.vue-q2i-2K0N.d.mts} +1 -1
- package/dist/{as-tuple-XpcKK1LK.cjs → as-tuple-BemXpNrJ.cjs} +18 -10
- package/dist/{as-tuple-qHmf6fwJ.mjs → as-tuple-D3IoTMkI.mjs} +19 -11
- package/dist/as-tuple.cjs +1 -1
- package/dist/as-tuple.d.cts +1 -1
- package/dist/as-tuple.d.mts +1 -1
- package/dist/as-tuple.mjs +1 -1
- package/dist/{as-tuple.vue-CKbx_YFz.d.mts → as-tuple.vue-BEY7sq9x.d.cts} +1 -1
- package/dist/{as-tuple.vue-Di5D2HD4.d.cts → as-tuple.vue-CNgBlckL.d.mts} +1 -1
- package/dist/{as-union-Ca5o9xw2.mjs → as-union-CIEUE2Xd.mjs} +26 -5
- package/dist/{as-union-CwB0ACpI.cjs → as-union-DqRkSoIr.cjs} +25 -4
- package/dist/as-union.cjs +1 -1
- package/dist/as-union.d.cts +1 -1
- package/dist/as-union.d.mts +1 -1
- package/dist/as-union.mjs +1 -1
- package/dist/{as-union.vue-UnG0zG81.d.cts → as-union.vue-B3KVCUUI.d.mts} +1 -1
- package/dist/{as-union.vue-eGlHN_hp.d.mts → as-union.vue-CGk27JvO.d.cts} +1 -1
- package/dist/{as-variant-picker-CKSLKefM.mjs → as-variant-picker-O_6JNWLk.mjs} +1 -1
- package/dist/{as-variant-picker-CceIhZUk.cjs → as-variant-picker-apxtW5rZ.cjs} +1 -1
- package/dist/index.cjs +42 -24
- package/dist/index.d.cts +22 -22
- package/dist/index.d.mts +22 -22
- package/dist/index.mjs +26 -26
- package/dist/{types-C5Gx4ZuF.d.mts → types-BXTpoOfM.d.cts} +26 -9
- package/dist/{types-D23g9Vs-.d.cts → types-CXGcf7sO.d.mts} +26 -9
- package/dist/{use-as-date-BWJbi_j2.cjs → use-as-date-CpkJjcyB.cjs} +18 -14
- package/dist/{use-as-date-B2hKWXAl.mjs → use-as-date-FsgcnN9l.mjs} +18 -14
- package/dist/{use-as-model-texts-BXSEzUWJ.mjs → use-as-model-texts-D26kn80o.mjs} +1 -1
- package/dist/{use-as-model-texts-BSFCEwAa.cjs → use-as-model-texts-DR4s80Mb.cjs} +1 -1
- package/dist/{use-as-value-help-ZR_BvS0L.cjs → use-as-value-help-CIvYUvdk.cjs} +12 -7
- package/dist/{use-as-value-help-B5yNO1tE.mjs → use-as-value-help-b4tk3NRF.mjs} +12 -7
- package/dist/{use-form-context-U6vg1uqK.cjs → use-form-context-BPlkQwkM.cjs} +16 -0
- package/dist/{use-form-context-0FtVVTvf.mjs → use-form-context-D_ejQqCc.mjs} +12 -2
- package/package.json +9 -9
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
const require_use_form_context = require("./use-form-context-
|
|
2
|
-
const require_use_as_value_help = require("./use-as-value-help-
|
|
1
|
+
const require_use_form_context = require("./use-form-context-BPlkQwkM.cjs");
|
|
2
|
+
const require_use_as_value_help = require("./use-as-value-help-CIvYUvdk.cjs");
|
|
3
3
|
const require_use_as_locale = require("./use-as-locale-eo7FyfaZ.cjs");
|
|
4
|
-
const require_use_as_model_texts = require("./use-as-model-texts-
|
|
4
|
+
const require_use_as_model_texts = require("./use-as-model-texts-DR4s80Mb.cjs");
|
|
5
5
|
const require__shape = require("./_shape-DPDZTV_T.cjs");
|
|
6
6
|
let vue = require("vue");
|
|
7
7
|
let _atscript_ui = require("@atscript/ui");
|
|
8
8
|
let _atscript_ui_fns = require("@atscript/ui-fns");
|
|
9
9
|
//#region src/composables/use-as-field.ts
|
|
10
10
|
function useAsField(opts) {
|
|
11
|
+
return fieldState(opts, false);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `<AsField>`'s field state (internal): its one rule is the form validator's
|
|
15
|
+
* verdict on the field, which a submit running that validator has already —
|
|
16
|
+
* so the submit leaves the rule out ({@link TValidatedRegistration}).
|
|
17
|
+
*/
|
|
18
|
+
function useAsValidatedField(opts) {
|
|
19
|
+
return fieldState(opts, true);
|
|
20
|
+
}
|
|
21
|
+
function fieldState(opts, validated) {
|
|
11
22
|
const formState = (0, vue.inject)(require_use_form_context.FORM_STATE_KEY);
|
|
12
23
|
const formData = (0, vue.inject)(require_use_form_context.FORM_DATA_KEY);
|
|
13
24
|
const formContext = (0, vue.inject)(require_use_form_context.FORM_CONTEXT_KEY);
|
|
@@ -55,28 +66,32 @@ function useAsField(opts) {
|
|
|
55
66
|
blur.value = true;
|
|
56
67
|
formState?.freshFields.delete(id);
|
|
57
68
|
}
|
|
58
|
-
if (formState)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
if (formState) {
|
|
70
|
+
const registration = {
|
|
71
|
+
validated,
|
|
72
|
+
path: opts.path,
|
|
73
|
+
callbacks: {
|
|
74
|
+
validate: () => {
|
|
75
|
+
submitError.value = validate();
|
|
76
|
+
return submitError.value || true;
|
|
77
|
+
},
|
|
78
|
+
clearErrors: () => {
|
|
79
|
+
touched.value = false;
|
|
80
|
+
blur.value = false;
|
|
81
|
+
submitError.value = void 0;
|
|
82
|
+
externalError.value = void 0;
|
|
83
|
+
},
|
|
84
|
+
reset: () => {
|
|
85
|
+
if ("resetValue" in opts) model.value = opts.resetValue;
|
|
86
|
+
},
|
|
87
|
+
setExternalError: (msg) => {
|
|
88
|
+
externalError.value = msg;
|
|
89
|
+
},
|
|
90
|
+
getError: () => error.value
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
formState.register(id, registration);
|
|
94
|
+
}
|
|
80
95
|
(0, vue.onUnmounted)(() => {
|
|
81
96
|
formState?.unregister(id);
|
|
82
97
|
});
|
|
@@ -114,13 +129,9 @@ function useAsFieldScope() {
|
|
|
114
129
|
return buildPath(field.path);
|
|
115
130
|
}
|
|
116
131
|
function scopeFor(field, opts) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
return (0, _atscript_ui_fns.buildFieldEntry)(field
|
|
120
|
-
type: field.type,
|
|
121
|
-
name: field.name,
|
|
122
|
-
modelT: modelT()
|
|
123
|
-
});
|
|
132
|
+
const path = absolutePath(field);
|
|
133
|
+
const base = buildScope(getByPath(path));
|
|
134
|
+
return opts?.withEntry ? (0, _atscript_ui_fns.buildFieldEntry)(field, base, path, { modelT: modelT() }) : base;
|
|
124
135
|
}
|
|
125
136
|
function resolveProp(field, fnKey, staticKey, opts) {
|
|
126
137
|
const hasFn = fnKey !== void 0 && (0, _atscript_ui.hasFieldMeta)(field.prop, fnKey);
|
|
@@ -144,8 +155,10 @@ function useAsFieldScope() {
|
|
|
144
155
|
function useAsOptionalField(field) {
|
|
145
156
|
const { buildPath, getByPath, setByPath, emptyValueOf } = require_use_form_context.useFormContext("useAsOptionalField");
|
|
146
157
|
const handleChange = (0, vue.inject)(require_use_form_context.CHANGE_HANDLER_KEY, () => {});
|
|
158
|
+
const locked = require_use_form_context.useInheritedLock();
|
|
147
159
|
const enabled = (0, vue.computed)(() => getByPath(buildPath(field.path)) != null);
|
|
148
160
|
function toggle(on) {
|
|
161
|
+
if (locked.value) return;
|
|
149
162
|
const path = buildPath(field.path);
|
|
150
163
|
setByPath(path, on ? emptyValueOf(field.prop) : void 0);
|
|
151
164
|
handleChange("update", path, getByPath(path));
|
|
@@ -160,13 +173,6 @@ function useAsOptionalField(field) {
|
|
|
160
173
|
//#region src/composables/use-as-value-help-options.ts
|
|
161
174
|
/** One dev-mode warning per binding (url + field). */
|
|
162
175
|
const warned = /* @__PURE__ */ new Set();
|
|
163
|
-
function isDev() {
|
|
164
|
-
try {
|
|
165
|
-
return process.env.NODE_ENV !== "production";
|
|
166
|
-
} catch {
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
176
|
const isEmpty = (v) => v === void 0 || v === null || v === "";
|
|
171
177
|
/**
|
|
172
178
|
* Options of a `select` / `radio` field that lists its dictionary
|
|
@@ -189,7 +195,7 @@ function useAsValueHelpOptions(opts) {
|
|
|
189
195
|
const overflow = (0, vue.computed)(() => listed.value === void 0);
|
|
190
196
|
(0, vue.watch)(overflow, (over) => {
|
|
191
197
|
const key = (0, _atscript_ui.valueHelpKey)(info);
|
|
192
|
-
if (over &&
|
|
198
|
+
if (over && _atscript_ui.DEV && !warned.has(key)) {
|
|
193
199
|
warned.add(key);
|
|
194
200
|
console.warn(`[vue-form] The dictionary at ${info.url} has more than ${_atscript_ui.VALUE_HELP_OPTIONS_CAP} values for a dropdown: the field shows the search picker instead.`);
|
|
195
201
|
}
|
|
@@ -269,7 +275,7 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
269
275
|
const normalizedFormData = (0, vue.inject)(require_use_form_context.FORM_NORMALIZED_DATA_KEY, void 0);
|
|
270
276
|
const { t } = require_use_as_locale.useAsTexts();
|
|
271
277
|
const modelT = require_use_as_model_texts.useAsModelTexts();
|
|
272
|
-
const { rootFormData, formContext, joinPath, buildPath, getByPath, setByPath, buildScope } = require_use_form_context.useFormContext("AsField");
|
|
278
|
+
const { formState, rootFormData, formContext, joinPath, buildPath, getByPath, setByPath, buildScope } = require_use_form_context.useFormContext("AsField");
|
|
273
279
|
const absolutePath = joinPath(() => props.field.path);
|
|
274
280
|
const isStructured = (0, _atscript_ui.isObjectField)(props.field) || (0, _atscript_ui.isArrayField)(props.field) || (0, _atscript_ui.isTupleField)(props.field);
|
|
275
281
|
const isUnion = (0, _atscript_ui.isUnionField)(props.field);
|
|
@@ -290,84 +296,43 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
290
296
|
if (own === false || inherited === true) return inherited;
|
|
291
297
|
return (0, vue.computed)(() => own.value || inherited.value);
|
|
292
298
|
}
|
|
293
|
-
function buildFieldClasses(classValue, isDisabled, isRequired
|
|
299
|
+
function buildFieldClasses(classValue, isDisabled, isRequired) {
|
|
294
300
|
return {
|
|
295
301
|
...typeof classValue === "string" ? { [classValue]: true } : Array.isArray(classValue) ? Object.fromEntries(classValue.filter((c) => typeof c === "string").map((c) => [c, true])) : classValue,
|
|
296
302
|
disabled: isDisabled,
|
|
297
|
-
required: isRequired
|
|
303
|
+
required: isRequired
|
|
298
304
|
};
|
|
299
305
|
}
|
|
300
306
|
const prop = props.field.prop;
|
|
301
307
|
const autocomplete = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_AUTOCOMPLETE);
|
|
302
308
|
const maxLength = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.EXPECT_MAX_LENGTH)?.length;
|
|
303
|
-
const componentName = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_COMPONENT);
|
|
304
309
|
const prefixIcon = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_PREFIX_ICON);
|
|
305
310
|
const suffixIcon = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_SUFFIX_ICON);
|
|
306
311
|
const valueHelp = props.field.valueHelpInfo;
|
|
307
|
-
const
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
const prefixLiteral = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_PREFIX);
|
|
312
|
-
const prefixRefField = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_PREFIX_REF);
|
|
313
|
-
const suffixLiteral = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_SUFFIX);
|
|
314
|
-
const suffixRefField = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_SUFFIX_REF);
|
|
315
|
-
const precisionScale = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.DB_COLUMN_PRECISION)?.scale;
|
|
316
|
-
const hasAdornment = currencyLiteral !== void 0 || currencyRefField !== void 0 || unitLiteral !== void 0 || unitRefField !== void 0 || prefixLiteral !== void 0 || prefixRefField !== void 0 || prefixIcon !== void 0 || suffixLiteral !== void 0 || suffixRefField !== void 0 || suffixIcon !== void 0;
|
|
317
|
-
let resolvedCurrencyCode;
|
|
318
|
-
let resolvedUnitCode;
|
|
312
|
+
const measurement = (0, _atscript_ui.extractMeasurement)(prop);
|
|
313
|
+
const hasAdornment = (0, _atscript_ui.numberAdornment)(prop) !== void 0;
|
|
314
|
+
const read = (path) => getByPath(buildPath(path));
|
|
315
|
+
let measured;
|
|
319
316
|
let resolvedPrefix;
|
|
320
317
|
let resolvedSuffix;
|
|
321
|
-
let resolvedScale;
|
|
322
|
-
const siblingPrefix = props.field.path.slice(0, props.field.path.lastIndexOf(".") + 1);
|
|
323
318
|
if (hasAdornment) {
|
|
324
|
-
const _data = require_use_as_value_help.useAsData();
|
|
325
319
|
const { locale: _locale } = require_use_as_locale.useAsLocale();
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
if (unitLiteral !== void 0) resolvedUnitCode = unitLiteral;
|
|
335
|
-
else if (unitRefField !== void 0) {
|
|
336
|
-
const ref = _data.siblingValue(siblingPrefix + unitRefField);
|
|
337
|
-
resolvedUnitCode = (0, vue.computed)(() => {
|
|
338
|
-
const v = ref.value;
|
|
339
|
-
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
const readCode = (v) => (0, vue.isRef)(v) ? v.value : v;
|
|
343
|
-
const prefixRefValue = prefixRefField ? _data.siblingValue(siblingPrefix + prefixRefField) : void 0;
|
|
320
|
+
const prefixLiteral = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_PREFIX);
|
|
321
|
+
const prefixRefField = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_PREFIX_REF);
|
|
322
|
+
const suffixLiteral = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_SUFFIX);
|
|
323
|
+
const suffixRefField = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_SUFFIX_REF);
|
|
324
|
+
const m = (0, vue.computed)(() => (0, _atscript_ui.resolveMeasurement)(measurement, props.field.path, read, _locale.value));
|
|
325
|
+
measured = m;
|
|
326
|
+
const adornment = (key, literal, ref) => literal ? (0, _atscript_ui.userText)(key, literal, modelT()) : (0, _atscript_ui.refText)(props.field.path, ref, read);
|
|
344
327
|
resolvedPrefix = (0, vue.computed)(() => {
|
|
345
|
-
|
|
346
|
-
if (
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
const code = readCode(resolvedCurrencyCode);
|
|
351
|
-
if (code) return (0, _atscript_ui.getCurrencyDisplayParts)(code, _locale.value).symbol;
|
|
352
|
-
});
|
|
353
|
-
const suffixRefValue = suffixRefField ? _data.siblingValue(siblingPrefix + suffixRefField) : void 0;
|
|
354
|
-
resolvedSuffix = (0, vue.computed)(() => {
|
|
355
|
-
if (suffixLiteral !== void 0 && suffixLiteral.length > 0) return (0, _atscript_ui.userText)(_atscript_ui.UI_FORM_SUFFIX, suffixLiteral, modelT());
|
|
356
|
-
if (suffixRefValue) {
|
|
357
|
-
const v = suffixRefValue.value;
|
|
358
|
-
if (typeof v === "string" && v.length > 0) return v;
|
|
359
|
-
}
|
|
360
|
-
return readCode(resolvedUnitCode);
|
|
361
|
-
});
|
|
362
|
-
resolvedScale = (0, vue.computed)(() => {
|
|
363
|
-
const code = readCode(resolvedCurrencyCode);
|
|
364
|
-
const currDecimals = code ? (0, _atscript_ui.getCurrencyDecimals)(code, _locale.value) : void 0;
|
|
365
|
-
if (currDecimals !== void 0 && typeof precisionScale === "number") return Math.min(currDecimals, precisionScale);
|
|
366
|
-
if (currDecimals !== void 0) return currDecimals;
|
|
367
|
-
if (typeof precisionScale === "number") return precisionScale;
|
|
328
|
+
const explicit = adornment(_atscript_ui.UI_FORM_PREFIX, prefixLiteral, prefixRefField);
|
|
329
|
+
if (explicit !== void 0) return explicit;
|
|
330
|
+
const code = m.value.currency;
|
|
331
|
+
return code ? (0, _atscript_ui.getCurrencyDisplayParts)(code, _locale.value).symbol : void 0;
|
|
368
332
|
});
|
|
333
|
+
resolvedSuffix = (0, vue.computed)(() => adornment(_atscript_ui.UI_FORM_SUFFIX, suffixLiteral, suffixRefField) ?? m.value.unit);
|
|
369
334
|
}
|
|
370
|
-
const arrayItemProp = (0, _atscript_ui.isArrayField)(props.field) ? props.field
|
|
335
|
+
const arrayItemProp = ((0, _atscript_ui.isArrayField)(props.field) ? props.field : void 0)?.itemField.prop;
|
|
371
336
|
const singularLabelOf = () => {
|
|
372
337
|
if (!arrayItemProp) return arrayItemProp;
|
|
373
338
|
const text = modelT();
|
|
@@ -407,22 +372,22 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
407
372
|
const { toggle: toggleOptional } = useAsOptionalField(props.field);
|
|
408
373
|
const formOptional = (0, vue.inject)(require_use_form_context.FORM_OPTIONAL_KEY, void 0);
|
|
409
374
|
const optionalMode = props.field.prop.optional ? (0, _atscript_ui.resolveOptionalMode)(props.field, formOptional?.mode.value) : void 0;
|
|
410
|
-
const
|
|
375
|
+
const emptyOpts = {
|
|
411
376
|
mode: optionalMode,
|
|
412
377
|
edit: formOptional?.edit.value
|
|
413
|
-
}
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
378
|
+
};
|
|
379
|
+
const emptied = (0, _atscript_ui.emptiedValue)(props.field, emptyOpts);
|
|
380
|
+
const resolvedComponent = (0, vue.computed)(() => (0, _atscript_ui.resolveComponent)(boundOptions?.overflow.value ? {
|
|
381
|
+
...props.field,
|
|
382
|
+
customType: "ref"
|
|
383
|
+
} : props.field, {
|
|
384
|
+
components: components?.value,
|
|
385
|
+
types: types?.value
|
|
386
|
+
}));
|
|
421
387
|
let disabled;
|
|
422
388
|
let hidden;
|
|
423
389
|
let optional;
|
|
424
390
|
let readonly;
|
|
425
|
-
let required;
|
|
426
391
|
let label;
|
|
427
392
|
let description;
|
|
428
393
|
let hint;
|
|
@@ -442,14 +407,12 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
442
407
|
};
|
|
443
408
|
const isDerived = props.field.derived === true;
|
|
444
409
|
const staticReadonly = isDerived || (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.META_READONLY) !== void 0;
|
|
445
|
-
const hasMetaRequired = !isDerived && (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.META_REQUIRED) !== void 0;
|
|
446
410
|
if (props.field.allStatic) {
|
|
447
411
|
hasCustomValidators = false;
|
|
448
412
|
disabled = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_DISABLED) !== void 0;
|
|
449
413
|
hidden = (0, _atscript_ui.hasFieldMeta)(prop, _atscript_ui.UI_FORM_HIDDEN);
|
|
450
414
|
optional = props.field.prop.optional ?? false;
|
|
451
415
|
readonly = staticReadonly;
|
|
452
|
-
required = props.field.phantom ? void 0 : hasMetaRequired;
|
|
453
416
|
label = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.META_LABEL);
|
|
454
417
|
description = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.META_DESCRIPTION);
|
|
455
418
|
hint = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_HINT);
|
|
@@ -470,17 +433,11 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
470
433
|
const needsBaseScope = hasFn.has("disabled") || hasFn.has("hidden") || hasFn.has("readonly");
|
|
471
434
|
const needsFullScope = hasFn.has("label") || hasFn.has("description") || hasFn.has("hint") || hasFn.has("placeholder") || hasFn.has("classes") || hasFn.has("styles") || hasFn.has("options") || hasFn.has("value") || hasFn.has("attr") || hasFn.has("title") || hasCustomValidators;
|
|
472
435
|
const bs = needsBaseScope || needsFullScope ? (0, vue.computed)(() => buildScope(getModel())) : void 0;
|
|
473
|
-
|
|
474
|
-
disabled = maybeComputed(hasFn.has("disabled"), () => (0, _atscript_ui.resolveFieldProp)(prop, _atscript_ui.UI_FORM_FN_DISABLED, _atscript_ui.UI_FORM_DISABLED, bs.value, boolOpts) ?? false, (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_DISABLED) !== void 0);
|
|
436
|
+
disabled = maybeComputed(hasFn.has("disabled"), () => (0, _atscript_ui.isFieldDisabled)(prop, bs.value), (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_DISABLED) !== void 0);
|
|
475
437
|
hidden = maybeComputed(hasFn.has("hidden"), () => (0, _atscript_ui.isFieldHidden)(prop, bs.value), (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_HIDDEN) !== void 0);
|
|
476
438
|
optional = props.field.prop.optional ?? false;
|
|
477
|
-
readonly = maybeComputed(hasFn.has("readonly") && !isDerived, () => (0, _atscript_ui.
|
|
478
|
-
|
|
479
|
-
const fs = needsFullScope ? (0, vue.computed)(() => (0, _atscript_ui_fns.buildFieldEntry)(prop, bs.value, props.field.path, {
|
|
480
|
-
type: props.field.type,
|
|
481
|
-
component: componentName,
|
|
482
|
-
name: props.field.name,
|
|
483
|
-
optional: unwrap(optional),
|
|
439
|
+
readonly = maybeComputed(hasFn.has("readonly") && !isDerived, () => (0, _atscript_ui.isFieldReadonly)(props.field, bs.value), staticReadonly);
|
|
440
|
+
const fs = needsFullScope ? (0, vue.computed)(() => (0, _atscript_ui_fns.buildFieldEntry)(props.field, bs.value, absolutePath.value, {
|
|
484
441
|
disabled: unwrap(disabled),
|
|
485
442
|
hidden: unwrap(hidden),
|
|
486
443
|
readonly: unwrap(readonly),
|
|
@@ -511,19 +468,24 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
511
468
|
disabled: shownDisabled,
|
|
512
469
|
readonly: shownReadonly
|
|
513
470
|
});
|
|
471
|
+
const shownRequired = !(0, _atscript_ui.isFieldRequired)(props.field, {
|
|
472
|
+
...emptyOpts,
|
|
473
|
+
readonly: false
|
|
474
|
+
}) ? false : typeof shownReadonly === "boolean" ? !shownReadonly : (0, vue.computed)(() => !shownReadonly.value);
|
|
514
475
|
const staticClasses = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_CLASSES);
|
|
515
|
-
const classesOf = (isDisabled) => buildFieldClasses(fnClasses ? fnClasses() : staticClasses, isDisabled,
|
|
516
|
-
const classesBase = fnClasses || typeof shownDisabled !== "boolean" ? (0, vue.computed)(() => classesOf(unwrap(shownDisabled))) : classesOf(shownDisabled);
|
|
476
|
+
const classesOf = (isDisabled, isRequired) => buildFieldClasses(fnClasses ? fnClasses() : staticClasses, isDisabled, isRequired);
|
|
477
|
+
const classesBase = fnClasses || typeof shownDisabled !== "boolean" || typeof shownRequired !== "boolean" ? (0, vue.computed)(() => classesOf(unwrap(shownDisabled), unwrap(shownRequired))) : classesOf(shownDisabled, shownRequired);
|
|
517
478
|
function formRule(v) {
|
|
518
479
|
return formValidate(v, {
|
|
519
480
|
get data() {
|
|
520
481
|
return normalizedFormData?.value ?? rootFormData().value ?? {};
|
|
521
482
|
},
|
|
522
483
|
context: formContext.value,
|
|
523
|
-
t
|
|
484
|
+
t,
|
|
485
|
+
path: absolutePath.value
|
|
524
486
|
});
|
|
525
487
|
}
|
|
526
|
-
const { model, error: formError, onBlur: _onBlur, isDirty } =
|
|
488
|
+
const { model, error: formError, onBlur: _onBlur, isDirty } = useAsValidatedField({
|
|
527
489
|
getValue: getModel,
|
|
528
490
|
setValue: setModel,
|
|
529
491
|
rules: isDerived ? [] : [formRule],
|
|
@@ -539,8 +501,8 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
539
501
|
}
|
|
540
502
|
};
|
|
541
503
|
const ownOptions = options;
|
|
542
|
-
const
|
|
543
|
-
const displayText = () =>
|
|
504
|
+
const textOf = require_use_as_value_help.fieldDisplayText(formState, read);
|
|
505
|
+
const displayText = () => textOf(props.field, model.value, unwrap(ownOptions));
|
|
544
506
|
const boundOptions = (0, _atscript_ui.listsDictionary)(props.field) ? useAsValueHelpOptions({
|
|
545
507
|
info: valueHelp,
|
|
546
508
|
model,
|
|
@@ -578,7 +540,7 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
578
540
|
path: absolutePath.value,
|
|
579
541
|
valueHelp,
|
|
580
542
|
displayText,
|
|
581
|
-
precisionScale,
|
|
543
|
+
precisionScale: measurement.precisionScale,
|
|
582
544
|
hasAdornment,
|
|
583
545
|
inputId,
|
|
584
546
|
errorId,
|
|
@@ -600,7 +562,7 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
600
562
|
style: unwrap(styles),
|
|
601
563
|
optional: unwrap(optional),
|
|
602
564
|
onToggleOptional: unwrap(optional) ? toggleOptional : void 0,
|
|
603
|
-
required:
|
|
565
|
+
required: unwrap(shownRequired),
|
|
604
566
|
disabled: unwrap(shownDisabled),
|
|
605
567
|
hidden: unwrap(hidden),
|
|
606
568
|
readonly: unwrap(shownReadonly),
|
|
@@ -610,11 +572,11 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
610
572
|
canRemove: props.canRemove,
|
|
611
573
|
removeLabel: props.removeLabel,
|
|
612
574
|
arrayIndex: props.arrayIndex,
|
|
613
|
-
currencyCode:
|
|
614
|
-
unitCode:
|
|
615
|
-
prefix:
|
|
616
|
-
suffix:
|
|
617
|
-
scale:
|
|
575
|
+
currencyCode: measured?.value.currency,
|
|
576
|
+
unitCode: measured?.value.unit,
|
|
577
|
+
prefix: resolvedPrefix?.value,
|
|
578
|
+
suffix: resolvedSuffix?.value,
|
|
579
|
+
scale: measured ? measured.value.scale : measurement.precisionScale,
|
|
618
580
|
...unwrap(attrs)
|
|
619
581
|
};
|
|
620
582
|
});
|
|
@@ -653,7 +615,7 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
653
615
|
"is-dirty",
|
|
654
616
|
"ariaDescribedBy",
|
|
655
617
|
"onAction"
|
|
656
|
-
])) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1, " [" + (0, vue.toDisplayString)(unwrap((0, vue.unref)(label)) ?? __props.field.name) + "] No component for type \"" + (0, vue.toDisplayString)(__props.field.customType ?? __props.field.type) + "\"" + (0, vue.toDisplayString)(
|
|
618
|
+
])) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1, " [" + (0, vue.toDisplayString)(unwrap((0, vue.unref)(label)) ?? __props.field.name) + "] No component for type \"" + (0, vue.toDisplayString)(__props.field.customType ?? __props.field.type) + "\"" + (0, vue.toDisplayString)(__props.field.component ? ` (component "${__props.field.component}" not supplied)` : ""), 1));
|
|
657
619
|
};
|
|
658
620
|
}
|
|
659
621
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_focus_after_toggle = require("./focus-after-toggle-BhZGqrUK.cjs");
|
|
2
|
-
const require_use_form_context = require("./use-form-context-
|
|
2
|
+
const require_use_form_context = require("./use-form-context-BPlkQwkM.cjs");
|
|
3
3
|
const require_use_as_locale = require("./use-as-locale-eo7FyfaZ.cjs");
|
|
4
4
|
const require__shape = require("./_shape-DPDZTV_T.cjs");
|
|
5
|
-
const require_as_variant_picker = require("./as-variant-picker-
|
|
5
|
+
const require_as_variant_picker = require("./as-variant-picker-apxtW5rZ.cjs");
|
|
6
6
|
const require__editing_hold = require("./_editing-hold-DbM25sc_.cjs");
|
|
7
7
|
let vue = require("vue");
|
|
8
8
|
//#region src/components/internal/as-no-data.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as useAsFocusFirstAfter } from "./focus-after-toggle-DAwak7c1.mjs";
|
|
2
|
-
import { n as useAsUnionVariant, t as formatIndexedLabelParts } from "./use-form-context-
|
|
2
|
+
import { n as useAsUnionVariant, t as formatIndexedLabelParts } from "./use-form-context-D_ejQqCc.mjs";
|
|
3
3
|
import { o as useAsTexts } from "./use-as-locale-CznDr-7i.mjs";
|
|
4
4
|
import { t as isTriState } from "./_shape-CnW2sBRs.mjs";
|
|
5
|
-
import { n as as_optional_clear_default, t as as_variant_picker_default } from "./as-variant-picker-
|
|
5
|
+
import { n as as_optional_clear_default, t as as_variant_picker_default } from "./as-variant-picker-O_6JNWLk.mjs";
|
|
6
6
|
import { n as useEditingHold } from "./_editing-hold-s65mkJu2.mjs";
|
|
7
7
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, ref, renderSlot, toDisplayString, unref, vShow, withDirectives, withKeys, withModifiers } from "vue";
|
|
8
8
|
//#region src/components/internal/as-no-data.vue?vue&type=script&setup=true&lang.ts
|
package/dist/as-field-shell.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const require_as_field_shell = require("./as-field-shell-
|
|
1
|
+
const require_as_field_shell = require("./as-field-shell-CMq52Z6e.cjs");
|
|
2
2
|
module.exports = require_as_field_shell.as_field_shell_default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as _default } from "./as-field-shell.vue-
|
|
1
|
+
import { t as _default } from "./as-field-shell.vue-BbSIqZSY.cjs";
|
|
2
2
|
export = _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as _default } from "./as-field-shell.vue-
|
|
1
|
+
import { t as _default } from "./as-field-shell.vue-D0NYcajH.mjs";
|
|
2
2
|
export { _default as default };
|
package/dist/as-field-shell.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as as_field_shell_default } from "./as-field-shell-
|
|
1
|
+
import { t as as_field_shell_default } from "./as-field-shell-DXbAJupk.mjs";
|
|
2
2
|
export { as_field_shell_default as default };
|
package/dist/as-field.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const require_as_field = require("./as-field-
|
|
1
|
+
const require_as_field = require("./as-field-CJMJJfXO.cjs");
|
|
2
2
|
module.exports = require_as_field.as_field_default;
|
package/dist/as-field.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as as_field_default } from "./as-field-
|
|
1
|
+
import { t as as_field_default } from "./as-field-C6iquEB1.mjs";
|
|
2
2
|
export { as_field_default as default };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_focus_after_toggle = require("./focus-after-toggle-BhZGqrUK.cjs");
|
|
2
|
-
const require_use_form_context = require("./use-form-context-
|
|
2
|
+
const require_use_form_context = require("./use-form-context-BPlkQwkM.cjs");
|
|
3
3
|
const require_use_as_nested_sections_store = require("./use-as-nested-sections-store-ApstV9NL.cjs");
|
|
4
|
-
const require_use_as_value_help = require("./use-as-value-help-
|
|
4
|
+
const require_use_as_value_help = require("./use-as-value-help-CIvYUvdk.cjs");
|
|
5
5
|
const require_use_as_locale = require("./use-as-locale-eo7FyfaZ.cjs");
|
|
6
6
|
const require_use_value_help_texts = require("./use-value-help-texts-ikiPKy-U.cjs");
|
|
7
|
-
const require_as_field = require("./as-field-
|
|
8
|
-
const require_as_iterator = require("./as-iterator-
|
|
7
|
+
const require_as_field = require("./as-field-CJMJJfXO.cjs");
|
|
8
|
+
const require_as_iterator = require("./as-iterator-C8aJ6SUs.cjs");
|
|
9
9
|
let vue = require("vue");
|
|
10
10
|
let _atscript_ui = require("@atscript/ui");
|
|
11
11
|
//#region src/composables/use-as-form-patch.ts
|
|
@@ -354,28 +354,20 @@ function useAsState(opts) {
|
|
|
354
354
|
formState.firstSubmitHappened = true;
|
|
355
355
|
formState.freshFields.clear();
|
|
356
356
|
if (formState.firstValidation === "none") return true;
|
|
357
|
-
|
|
358
|
-
const errors = opts.submitValidator();
|
|
359
|
-
const entries = Object.entries(errors);
|
|
360
|
-
if (entries.length === 0) return true;
|
|
361
|
-
setErrors(errors);
|
|
362
|
-
return entries.map(([path, message]) => ({
|
|
363
|
-
path,
|
|
364
|
-
message
|
|
365
|
-
}));
|
|
366
|
-
}
|
|
367
|
-
const errors = [];
|
|
357
|
+
const errors = { ...opts.submitValidator?.() };
|
|
368
358
|
for (const reg of fieldsById.values()) {
|
|
359
|
+
if (opts.submitValidator && reg.validated) continue;
|
|
369
360
|
const result = reg.callbacks.validate();
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
errors.push({
|
|
373
|
-
path,
|
|
374
|
-
message: result
|
|
375
|
-
});
|
|
376
|
-
}
|
|
361
|
+
const path = reg.path();
|
|
362
|
+
if (result !== true && errors[path] === void 0) errors[path] = result;
|
|
377
363
|
}
|
|
378
|
-
|
|
364
|
+
const entries = Object.entries(errors);
|
|
365
|
+
if (entries.length === 0) return true;
|
|
366
|
+
setErrors(errors);
|
|
367
|
+
return entries.map(([path, message]) => ({
|
|
368
|
+
path,
|
|
369
|
+
message
|
|
370
|
+
}));
|
|
379
371
|
}
|
|
380
372
|
function setErrors(errors) {
|
|
381
373
|
for (const reg of fieldsById.values()) {
|
|
@@ -570,6 +562,7 @@ function useAsForm(options) {
|
|
|
570
562
|
loading: options.loading?.() === true,
|
|
571
563
|
submitText: submitText.value,
|
|
572
564
|
submit: onSubmit,
|
|
565
|
+
action: invokeAction,
|
|
573
566
|
reset,
|
|
574
567
|
revert,
|
|
575
568
|
clearErrors,
|
|
@@ -584,22 +577,10 @@ function useAsForm(options) {
|
|
|
584
577
|
isDirtyPath: patch ? patch.isDirtyPath : EMPTY_IS_DIRTY_PATH,
|
|
585
578
|
displayText
|
|
586
579
|
}));
|
|
587
|
-
function supportsAction(def, actionId) {
|
|
588
|
-
return (0, _atscript_ui.getDeclaredFormActions)(def).some((a) => a.id === actionId);
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* What the form sends — on submit and with an action: without the related rows of
|
|
592
|
-
* navigation fields the form leaves out (loaded with `$with`, never rendered or
|
|
593
|
-
* validated) and without the fields the server owns (`derived`: `/meta` `readOnly`,
|
|
594
|
-
* computed, …).
|
|
595
|
-
*/
|
|
596
|
-
function outgoing(def, data) {
|
|
597
|
-
return (0, _atscript_ui.omitDerivedFields)(def, (0, _atscript_ui.omitSkippedNavFields)(def, data));
|
|
598
|
-
}
|
|
599
580
|
function invokeAction(name) {
|
|
600
581
|
const def = options.def();
|
|
601
|
-
const data =
|
|
602
|
-
if (
|
|
582
|
+
const data = (0, _atscript_ui.formPayload)(def, formValidator.value.normalize(domainData()));
|
|
583
|
+
if ((0, _atscript_ui.getDeclaredFormAction)(def, name)) options.emits?.action?.(name, data);
|
|
603
584
|
else options.emits?.unsupportedAction?.(name, data);
|
|
604
585
|
}
|
|
605
586
|
(0, vue.provide)(require_use_form_context.ACTION_HANDLER_KEY, invokeAction);
|
|
@@ -621,7 +602,7 @@ function useAsForm(options) {
|
|
|
621
602
|
const result = submit();
|
|
622
603
|
if (result === true) {
|
|
623
604
|
internalErrors.value = {};
|
|
624
|
-
const payload =
|
|
605
|
+
const payload = (0, _atscript_ui.formPayload)(options.def(), data);
|
|
625
606
|
options.emits?.submit?.(payload);
|
|
626
607
|
return {
|
|
627
608
|
ok: true,
|