@atscript/vue-form 0.1.206 → 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-rT6WXLph.cjs → as-action-BGIbuTxh.cjs} +3 -3
- package/dist/{as-action-kBskX68v.mjs → as-action-CPQ64nNi.mjs} +3 -3
- package/dist/as-action.cjs +1 -1
- package/dist/as-action.d.cts +1 -1
- package/dist/as-action.d.mts +1 -1
- package/dist/as-action.mjs +1 -1
- package/dist/{as-action.vue-B7RrjGhF.d.cts → as-action.vue-D0twy1JK.d.cts} +1 -1
- package/dist/{as-action.vue-Dtez-EWu.d.mts → as-action.vue-Dse77iCr.d.mts} +1 -1
- package/dist/{as-array-Tt_4kl5r.mjs → as-array-CEtgj6nd.mjs} +13 -14
- package/dist/{as-array-C5lqDDLN.cjs → as-array-CKedVJIz.cjs} +13 -14
- package/dist/{as-array-clear-btn-DGUQY_7_.mjs → as-array-clear-btn-BFfll2RA.mjs} +1 -1
- package/dist/{as-array-clear-btn-Dk88CYmS.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-Ca_xan2n.d.mts → as-array.vue-BCB8mLx-.d.mts} +1 -1
- package/dist/{as-array.vue-Dp_zd3ZM.d.cts → as-array.vue-DJNzEE8-.d.cts} +1 -1
- package/dist/{as-checkbox-CCX9E19U.mjs → as-checkbox-B7C-CvhT.mjs} +9 -17
- package/dist/{as-checkbox-D7NywgIa.cjs → as-checkbox-DKaEfo7e.cjs} +9 -17
- 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-BClSBx1g.d.mts → as-checkbox.vue-CoCgt4vV.d.mts} +1 -1
- package/dist/{as-checkbox.vue-Bf3qqcKu.d.cts → as-checkbox.vue-fPeyQDp5.d.cts} +1 -1
- package/dist/{as-collapsible-CTOLQ3IK.cjs → as-collapsible-Bs0LOl1t.cjs} +1 -1
- package/dist/{as-collapsible-CvBoWb0D.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-BXdpM7_K.d.cts → as-collapsible.vue-CH3ez8zm.d.cts} +1 -1
- package/dist/{as-collapsible.vue-CUhn1EVX.d.mts → as-collapsible.vue-DewV2oaE.d.mts} +1 -1
- package/dist/{as-date-Ubw_1-Ai.cjs → as-date-BMKMiM_d.cjs} +6 -6
- package/dist/{as-date-3haOaiAG.mjs → as-date-CFQtrpZT.mjs} +6 -6
- 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-B5NWZ5ON.d.cts → as-date.vue-BSghCVx0.d.cts} +1 -1
- package/dist/{as-date.vue-CJQOrfj3.d.mts → as-date.vue-CPgqqKMB.d.mts} +1 -1
- package/dist/{as-datetime--7bl-yGW.cjs → as-datetime-Bl1K4U51.cjs} +6 -6
- package/dist/{as-datetime-BTekpasP.mjs → as-datetime-DqfSymmL.mjs} +6 -6
- 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-BvmFdGxe.d.cts → as-datetime.vue-B-KRC-0X.d.mts} +1 -1
- package/dist/{as-datetime.vue-CzMz_RUy.d.mts → as-datetime.vue-CjDTsMDw.d.cts} +1 -1
- package/dist/{as-decimal-DWPRXsYY.cjs → as-decimal-48M_h9Sl.cjs} +22 -28
- package/dist/{as-decimal-7CIE6UKX.mjs → as-decimal-CsAJlvie.mjs} +22 -28
- 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-DdVqHtMT.d.cts → as-decimal.vue-BZ2imea4.d.mts} +1 -1
- package/dist/{as-decimal.vue-DyDt1ds0.d.mts → as-decimal.vue-BvvG5aIL.d.cts} +1 -1
- package/dist/{as-field-jh5AWref.mjs → as-field-C6iquEB1.mjs} +123 -173
- package/dist/{as-field-DAClnYiP.cjs → as-field-CJMJJfXO.cjs} +122 -172
- package/dist/{as-field-shell-Cu8jxZYj.cjs → as-field-shell-CMq52Z6e.cjs} +7 -7
- package/dist/{as-field-shell-DPzfvPo0.mjs → as-field-shell-DXbAJupk.mjs} +7 -7
- 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-CPy2uA-b.d.mts → as-field-shell.vue-BbSIqZSY.d.cts} +1 -1
- package/dist/{as-field-shell.vue-D-8AWUGW.d.cts → as-field-shell.vue-D0NYcajH.d.mts} +1 -1
- package/dist/as-field.cjs +1 -1
- package/dist/as-field.d.mts +1 -1
- package/dist/as-field.mjs +1 -1
- package/dist/{as-form-r5pkXt5U.cjs → as-form-B4-StU3b.cjs} +41 -43
- package/dist/{as-form-B8d1MVTB.mjs → as-form-DQePBFwR.mjs} +42 -44
- 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-D1AS3Xf6.d.mts → as-form.vue-BMNZuvpb.d.mts} +66 -54
- package/dist/{as-form.vue-BvRHy6mu.d.cts → as-form.vue-DS5r3CWl.d.cts} +66 -54
- package/dist/{as-input-tKw19JnF.mjs → as-input-D1IO72Tn.mjs} +6 -6
- package/dist/{as-input-BTbu0eF-.cjs → as-input-Dy7v1AjV.cjs} +6 -6
- package/dist/{as-input-control-1igViaqC.mjs → as-input-control-CINIJm-h.mjs} +13 -5
- package/dist/{as-input-control-uJpmle-G.cjs → as-input-control-DXJBrgih.cjs} +13 -5
- 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-CuC3DYeR.d.cts → as-input.vue-DMxFk9uv.d.cts} +1 -1
- package/dist/{as-input.vue-DawR7pA-.d.mts → as-input.vue-DzG-WB4x.d.mts} +1 -1
- package/dist/{as-iterator-B1o83rKV.mjs → as-iterator-A9ozhHhf.mjs} +2 -2
- package/dist/{as-iterator-q_w9HBHt.cjs → as-iterator-C8aJ6SUs.cjs} +2 -2
- package/dist/as-iterator.cjs +1 -1
- package/dist/as-iterator.d.mts +1 -1
- package/dist/as-iterator.mjs +1 -1
- package/dist/{as-multi-select-DPQ9_Qf1.cjs → as-multi-select-BiOEQf1L.cjs} +7 -11
- package/dist/{as-multi-select-DhOlsgdq.mjs → as-multi-select-CoT5MJd_.mjs} +8 -12
- 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-CbVBJq8N.d.mts → as-multi-select.vue-CBtBFW6X.d.cts} +1 -1
- package/dist/{as-multi-select.vue-CXC47PBk.d.cts → as-multi-select.vue-CGjTCFGD.d.mts} +1 -1
- package/dist/{as-number-CVjNUjiS.mjs → as-number-Ck8nNMCB.mjs} +5 -5
- package/dist/{as-number-CJmX5rb1.cjs → as-number-DKW_PZcq.cjs} +5 -5
- 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-BdNvLZca.d.mts → as-number.vue-AKk1tllp.d.mts} +1 -1
- package/dist/{as-number.vue-hJuiJJ70.d.cts → as-number.vue-i5gytLQ2.d.cts} +1 -1
- package/dist/{as-object-DY5IEc94.mjs → as-object-6GgXdo_K.mjs} +8 -8
- package/dist/{as-object-Dq5CPM3i.cjs → as-object-DfHzCJcJ.cjs} +8 -8
- 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-DHFGLetx.d.cts → as-object.vue-Gor6cnwh.d.mts} +1 -1
- package/dist/{as-object.vue-DVK_BKOL.d.mts → as-object.vue-cwrRrJ2O.d.cts} +1 -1
- package/dist/{as-paragraph-CaytophZ.cjs → as-paragraph-DHtc4LrM.cjs} +3 -3
- package/dist/{as-paragraph-ChOqmJe2.mjs → as-paragraph-ScTsCm_J.mjs} +3 -3
- package/dist/as-paragraph.cjs +1 -1
- package/dist/as-paragraph.d.cts +1 -1
- package/dist/as-paragraph.d.mts +1 -1
- package/dist/as-paragraph.mjs +1 -1
- package/dist/{as-paragraph.vue-6mBonWFb.d.mts → as-paragraph.vue-DqHrI7WD.d.mts} +1 -1
- package/dist/{as-paragraph.vue-B_aPmK-B.d.cts → as-paragraph.vue-Ds64gwEP.d.cts} +1 -1
- package/dist/{as-radio-BW9K8h6V.mjs → as-radio-Cc3VOm3A.mjs} +4 -4
- package/dist/{as-radio-C6PnEdjD.cjs → as-radio-DLGMEC9o.cjs} +4 -4
- 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-BFxeAHfl.d.mts → as-radio.vue-CkooFq0m.d.cts} +1 -1
- package/dist/{as-radio.vue-B_tDoVl1.d.cts → as-radio.vue-T0Ejt0II.d.mts} +1 -1
- package/dist/{as-ref-CXtYo-UZ.mjs → as-ref-Cs4i9tpS.mjs} +14 -14
- package/dist/{as-ref-DTsWT_zU.cjs → as-ref-FknTPCae.cjs} +14 -14
- 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-CqFDKTYk.d.mts → as-ref.vue-CCzEnDNd.d.cts} +1 -1
- package/dist/{as-ref.vue-gCsaCDQx.d.cts → as-ref.vue-CvStQFs3.d.mts} +1 -1
- package/dist/{as-select-DOvo86Oc.cjs → as-select-DBxxq0jZ.cjs} +7 -16
- package/dist/{as-select-CbZNupL6.mjs → as-select-br9EmsoX.mjs} +8 -17
- 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-BN3zvSGs.d.mts → as-select.vue-CK4AWxmk.d.cts} +1 -1
- package/dist/{as-select.vue-Bh7ppdg9.d.cts → as-select.vue-LKjJASjX.d.mts} +1 -1
- package/dist/{as-time-CfnhY3Pf.cjs → as-time-BmTk1YfU.cjs} +6 -6
- package/dist/{as-time-BDpnkjy8.mjs → as-time-DTz7PrnB.mjs} +6 -6
- 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-C-ruJhmX.d.mts → as-time.vue-DTRJCO4G.d.cts} +1 -1
- package/dist/{as-time.vue-C_0z-HOS.d.cts → as-time.vue-q2i-2K0N.d.mts} +1 -1
- package/dist/{as-tuple-C5_dcvsH.cjs → as-tuple-BemXpNrJ.cjs} +22 -14
- package/dist/{as-tuple--wL64cCu.mjs → as-tuple-D3IoTMkI.mjs} +23 -15
- 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-BDiSN-np.d.cts → as-tuple.vue-BEY7sq9x.d.cts} +1 -1
- package/dist/{as-tuple.vue-CGWun6Iw.d.mts → as-tuple.vue-CNgBlckL.d.mts} +1 -1
- package/dist/{as-union-DAnpGBeK.mjs → as-union-CIEUE2Xd.mjs} +32 -11
- package/dist/{as-union-D3NoKN1H.cjs → as-union-DqRkSoIr.cjs} +31 -10
- 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-BpcREl7L.d.mts → as-union.vue-B3KVCUUI.d.mts} +1 -1
- package/dist/{as-union.vue-DuUeLY1X.d.cts → as-union.vue-CGk27JvO.d.cts} +1 -1
- package/dist/{as-variant-picker-CihlFH-c.mjs → as-variant-picker-O_6JNWLk.mjs} +2 -2
- package/dist/{as-variant-picker-CpCxKFtT.cjs → as-variant-picker-apxtW5rZ.cjs} +2 -2
- package/dist/index.cjs +48 -28
- package/dist/index.d.cts +23 -23
- package/dist/index.d.mts +25 -25
- package/dist/index.mjs +31 -30
- package/dist/locale.cjs +2 -0
- package/dist/locale.d.cts +2 -2
- package/dist/locale.d.mts +2 -2
- package/dist/locale.mjs +2 -1
- package/dist/{types-271BUWyf.d.mts → types-BXTpoOfM.d.cts} +112 -17
- package/dist/{types-DbjorSCn.d.cts → types-CXGcf7sO.d.mts} +112 -17
- package/dist/{use-as-date-BigwPKEs.cjs → use-as-date-CpkJjcyB.cjs} +21 -17
- package/dist/{use-as-date-iSu5NS79.mjs → use-as-date-FsgcnN9l.mjs} +21 -17
- package/dist/{use-as-model-texts-Cpx5bHJQ.mjs → use-as-model-texts-D26kn80o.mjs} +1 -1
- package/dist/{use-as-model-texts-C3V56UDt.cjs → use-as-model-texts-DR4s80Mb.cjs} +1 -1
- package/dist/{use-as-value-help-CQMUkP1r.cjs → use-as-value-help-CIvYUvdk.cjs} +57 -29
- package/dist/{use-as-value-help-DE8KCbqo.mjs → use-as-value-help-b4tk3NRF.mjs} +53 -31
- 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/dist/{use-as-locale-D4NDG8Vg.d.mts → use-value-help-texts-BL1qfGA2.d.cts} +26 -2
- package/dist/use-value-help-texts-LySFdZya.mjs +52 -0
- package/dist/{use-as-locale-CtvT6oO5.d.cts → use-value-help-texts-fzgKU4NG.d.mts} +26 -2
- package/dist/use-value-help-texts-ikiPKy-U.cjs +57 -0
- package/package.json +9 -9
- /package/dist/{_editing-hold-D2uqwszu.cjs → _editing-hold-DbM25sc_.cjs} +0 -0
- /package/dist/{_editing-hold-D_X5gXHh.mjs → _editing-hold-s65mkJu2.mjs} +0 -0
- /package/dist/{_shape-A661ZxnJ.mjs → _shape-CnW2sBRs.mjs} +0 -0
- /package/dist/{_shape-7OdPsQao.cjs → _shape-DPDZTV_T.cjs} +0 -0
- /package/dist/{as-adornment-shell-CBaksXGT.mjs → as-adornment-shell-C_z_q-mz.mjs} +0 -0
- /package/dist/{as-adornment-shell-CmS9BOFm.cjs → as-adornment-shell-CgwCACXA.cjs} +0 -0
- /package/dist/{as-field.vue-BWaTLJd6.d.mts → as-field.vue-BMg2Ep8h.d.mts} +0 -0
- /package/dist/{as-iterator.vue-BUCohjxw.d.mts → as-iterator.vue-BdUxcovH.d.mts} +0 -0
- /package/dist/{use-as-optional-add-flow-DMDd4Ms0.cjs → use-as-optional-add-flow-CsUjhfkc.cjs} +0 -0
- /package/dist/{use-as-optional-add-flow-C1Ol6KO2.mjs → use-as-optional-add-flow-WA-R6yXz.mjs} +0 -0
- /package/dist/{variant-label-_GLezszT.cjs → variant-label-CSzBE4T6.cjs} +0 -0
- /package/dist/{variant-label-CmzTQC2B.mjs → variant-label-Drm3s-28.mjs} +0 -0
|
@@ -1,10 +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
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const require_use_value_help_texts = require("./use-value-help-texts-ikiPKy-U.cjs");
|
|
7
|
+
const require_as_field = require("./as-field-CJMJJfXO.cjs");
|
|
8
|
+
const require_as_iterator = require("./as-iterator-C8aJ6SUs.cjs");
|
|
8
9
|
let vue = require("vue");
|
|
9
10
|
let _atscript_ui = require("@atscript/ui");
|
|
10
11
|
//#region src/composables/use-as-form-patch.ts
|
|
@@ -299,6 +300,11 @@ function useAsExternalErrors(options) {
|
|
|
299
300
|
}
|
|
300
301
|
//#endregion
|
|
301
302
|
//#region src/composables/use-as-state.ts
|
|
303
|
+
/** A value as itself: a scalar written out, `""` for none (or an object). */
|
|
304
|
+
function plainText(value) {
|
|
305
|
+
if (value === null || value === void 0 || typeof value === "object") return "";
|
|
306
|
+
return String(value);
|
|
307
|
+
}
|
|
302
308
|
function useAsState(opts) {
|
|
303
309
|
const fieldsById = /* @__PURE__ */ new Map();
|
|
304
310
|
const fieldsRevision = (0, vue.shallowRef)(0);
|
|
@@ -312,12 +318,20 @@ function useAsState(opts) {
|
|
|
312
318
|
fieldsRevision.value++;
|
|
313
319
|
formState.freshFields.delete(id);
|
|
314
320
|
};
|
|
321
|
+
const texts = require_use_value_help_texts.useValueHelpTexts(opts.clientFactory ?? (0, vue.inject)(require_use_as_value_help.CLIENT_FACTORY_KEY, null) ?? void 0);
|
|
322
|
+
const { t } = require_use_as_locale.useAsTexts();
|
|
323
|
+
const displayText = (field, value, o) => (0, _atscript_ui.displayValue)(o ?? {}, value, {
|
|
324
|
+
siblingText: o?.siblingText,
|
|
325
|
+
valueText: () => texts.text(field, value),
|
|
326
|
+
t
|
|
327
|
+
}) ?? plainText(value);
|
|
315
328
|
const formState = (0, vue.reactive)({
|
|
316
329
|
firstSubmitHappened: false,
|
|
317
330
|
firstValidation: (0, vue.toValue)(opts.firstValidation) ?? "on-change",
|
|
318
331
|
freshFields: /* @__PURE__ */ new Set(),
|
|
319
332
|
register,
|
|
320
|
-
unregister
|
|
333
|
+
unregister,
|
|
334
|
+
displayText
|
|
321
335
|
});
|
|
322
336
|
(0, vue.watchEffect)(() => {
|
|
323
337
|
const v = (0, vue.toValue)(opts.firstValidation) ?? "on-change";
|
|
@@ -340,28 +354,20 @@ function useAsState(opts) {
|
|
|
340
354
|
formState.firstSubmitHappened = true;
|
|
341
355
|
formState.freshFields.clear();
|
|
342
356
|
if (formState.firstValidation === "none") return true;
|
|
343
|
-
|
|
344
|
-
const errors = opts.submitValidator();
|
|
345
|
-
const entries = Object.entries(errors);
|
|
346
|
-
if (entries.length === 0) return true;
|
|
347
|
-
setErrors(errors);
|
|
348
|
-
return entries.map(([path, message]) => ({
|
|
349
|
-
path,
|
|
350
|
-
message
|
|
351
|
-
}));
|
|
352
|
-
}
|
|
353
|
-
const errors = [];
|
|
357
|
+
const errors = { ...opts.submitValidator?.() };
|
|
354
358
|
for (const reg of fieldsById.values()) {
|
|
359
|
+
if (opts.submitValidator && reg.validated) continue;
|
|
355
360
|
const result = reg.callbacks.validate();
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
errors.push({
|
|
359
|
-
path,
|
|
360
|
-
message: result
|
|
361
|
-
});
|
|
362
|
-
}
|
|
361
|
+
const path = reg.path();
|
|
362
|
+
if (result !== true && errors[path] === void 0) errors[path] = result;
|
|
363
363
|
}
|
|
364
|
-
|
|
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
|
+
}));
|
|
365
371
|
}
|
|
366
372
|
function setErrors(errors) {
|
|
367
373
|
for (const reg of fieldsById.values()) {
|
|
@@ -429,9 +435,12 @@ function useAsForm(options) {
|
|
|
429
435
|
(0, vue.provide)(require_use_form_context.FORM_NORMALIZED_DATA_KEY, (0, vue.computed)(() => formValidator.value.normalize(getDomainData()) ?? {}));
|
|
430
436
|
const modelT = () => options.def().served ? void 0 : t;
|
|
431
437
|
(0, vue.provide)(require_use_form_context.MODEL_TEXTS_KEY, modelT);
|
|
432
|
-
const
|
|
438
|
+
const cf = options.clientFactory?.();
|
|
439
|
+
if (cf) (0, vue.provide)(require_use_as_value_help.CLIENT_FACTORY_KEY, cf);
|
|
440
|
+
const { formState, clearErrors: clearFieldErrors, reset: resetState, submit, setErrors, liveErrors, registeredPaths } = useAsState({
|
|
433
441
|
formData: data,
|
|
434
442
|
formContext,
|
|
443
|
+
clientFactory: cf,
|
|
435
444
|
firstValidation: (0, vue.computed)(() => options.firstValidation?.()),
|
|
436
445
|
submitValidator: () => formValidator.value({
|
|
437
446
|
data: submitting,
|
|
@@ -472,8 +481,6 @@ function useAsForm(options) {
|
|
|
472
481
|
(0, vue.provide)(require_use_form_context.ERRORS_KEY, ext.effective);
|
|
473
482
|
(0, vue.provide)(require_use_form_context.DISMISS_EXTERNAL_AT_KEY, ext.dismissAt);
|
|
474
483
|
const sectionsStore = require_use_as_nested_sections_store.useAsNestedSectionsStore() ?? require_use_as_nested_sections_store.provideAsNestedSectionsStore();
|
|
475
|
-
const cf = options.clientFactory?.();
|
|
476
|
-
if (cf) (0, vue.provide)(require_use_as_value_help.CLIENT_FACTORY_KEY, cf);
|
|
477
484
|
const internalErrors = (0, vue.ref)({});
|
|
478
485
|
const orphanInternalErrors = (0, vue.computed)(() => (0, _atscript_ui.omitPaths)(internalErrors.value, registeredPaths.value));
|
|
479
486
|
const allErrors = (0, vue.computed)(() => (0, _atscript_ui.mergeErrorMaps)(ext.effective.value, orphanInternalErrors.value, liveErrors.value));
|
|
@@ -544,6 +551,7 @@ function useAsForm(options) {
|
|
|
544
551
|
const resolveRootProp = (fnKey, staticKey) => (0, _atscript_ui.resolveFormProp)(options.def().type, fnKey, staticKey, ctx.value, { t: modelT() });
|
|
545
552
|
const title = (0, vue.computed)(() => resolveRootProp(_atscript_ui.UI_FORM_FN_TITLE, _atscript_ui.META_LABEL));
|
|
546
553
|
const description = (0, vue.computed)(() => resolveRootProp(_atscript_ui.UI_FORM_FN_DESCRIPTION, _atscript_ui.META_DESCRIPTION));
|
|
554
|
+
const displayText = require_use_as_value_help.fieldDisplayText(formState, (path) => (0, _atscript_ui.getByPath)(data.value, path));
|
|
547
555
|
const slotProps = (0, vue.computed)(() => ({
|
|
548
556
|
title: title.value,
|
|
549
557
|
description: description.value,
|
|
@@ -554,6 +562,7 @@ function useAsForm(options) {
|
|
|
554
562
|
loading: options.loading?.() === true,
|
|
555
563
|
submitText: submitText.value,
|
|
556
564
|
submit: onSubmit,
|
|
565
|
+
action: invokeAction,
|
|
557
566
|
reset,
|
|
558
567
|
revert,
|
|
559
568
|
clearErrors,
|
|
@@ -565,24 +574,13 @@ function useAsForm(options) {
|
|
|
565
574
|
changes: patch ? patch.changes.value : EMPTY_CHANGES,
|
|
566
575
|
getPatch: patch ? patch.getPatch : EMPTY_GET_PATCH,
|
|
567
576
|
getChanges: patch ? patch.getChanges : EMPTY_GET_CHANGES,
|
|
568
|
-
isDirtyPath: patch ? patch.isDirtyPath : EMPTY_IS_DIRTY_PATH
|
|
577
|
+
isDirtyPath: patch ? patch.isDirtyPath : EMPTY_IS_DIRTY_PATH,
|
|
578
|
+
displayText
|
|
569
579
|
}));
|
|
570
|
-
function supportsAction(def, actionId) {
|
|
571
|
-
return (0, _atscript_ui.getDeclaredFormActions)(def).some((a) => a.id === actionId);
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* What the form sends — on submit and with an action: without the related rows of
|
|
575
|
-
* navigation fields the form leaves out (loaded with `$with`, never rendered or
|
|
576
|
-
* validated) and without the fields the server owns (`derived`: `/meta` `readOnly`,
|
|
577
|
-
* computed, …).
|
|
578
|
-
*/
|
|
579
|
-
function outgoing(def, data) {
|
|
580
|
-
return (0, _atscript_ui.omitDerivedFields)(def, (0, _atscript_ui.omitSkippedNavFields)(def, data));
|
|
581
|
-
}
|
|
582
580
|
function invokeAction(name) {
|
|
583
581
|
const def = options.def();
|
|
584
|
-
const data =
|
|
585
|
-
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);
|
|
586
584
|
else options.emits?.unsupportedAction?.(name, data);
|
|
587
585
|
}
|
|
588
586
|
(0, vue.provide)(require_use_form_context.ACTION_HANDLER_KEY, invokeAction);
|
|
@@ -604,7 +602,7 @@ function useAsForm(options) {
|
|
|
604
602
|
const result = submit();
|
|
605
603
|
if (result === true) {
|
|
606
604
|
internalErrors.value = {};
|
|
607
|
-
const payload =
|
|
605
|
+
const payload = (0, _atscript_ui.formPayload)(options.def(), data);
|
|
608
606
|
options.emits?.submit?.(payload);
|
|
609
607
|
return {
|
|
610
608
|
ok: true,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { r as resetKeepingFocus } from "./focus-after-toggle-DAwak7c1.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { S as TYPES_KEY, a as ACTION_HANDLER_KEY, b as PATH_PREFIX_KEY, c as DISMISS_EXTERNAL_AT_KEY, d as FORM_DATA_KEY, f as FORM_NORMALIZED_DATA_KEY, g as HIDE_ROOT_TITLE_KEY, h as FORM_STATE_KEY, l as ERRORS_KEY, m as FORM_PATCH_KEY, o as CHANGE_HANDLER_KEY, p as FORM_OPTIONAL_KEY, s as COMPONENTS_KEY, u as FORM_CONTEXT_KEY, v as LOCK_KEY, x as ROOT_DATA_KEY, y as MODEL_TEXTS_KEY } from "./use-form-context-D_ejQqCc.mjs";
|
|
3
3
|
import { i as useAsNestedSectionsStore, n as provideAsNestedSectionsStore, t as DESCENDANT_ERROR_COUNTS_KEY } from "./use-as-nested-sections-store-CkrMJbnN.mjs";
|
|
4
|
-
import { t as CLIENT_FACTORY_KEY } from "./use-as-value-help-
|
|
4
|
+
import { r as fieldDisplayText, t as CLIENT_FACTORY_KEY } from "./use-as-value-help-b4tk3NRF.mjs";
|
|
5
5
|
import { o as useAsTexts } from "./use-as-locale-CznDr-7i.mjs";
|
|
6
|
-
import { t as
|
|
7
|
-
import { t as
|
|
6
|
+
import { t as useValueHelpTexts } from "./use-value-help-texts-LySFdZya.mjs";
|
|
7
|
+
import { t as as_field_default } from "./as-field-C6iquEB1.mjs";
|
|
8
|
+
import { t as as_iterator_default } from "./as-iterator-A9ozhHhf.mjs";
|
|
8
9
|
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, guardReactiveProps, inject, isProxy, isRef, mergeProps, nextTick, normalizeProps, openBlock, provide, reactive, ref, renderSlot, shallowRef, toDisplayString, toRaw, toValue, unref, watch, watchEffect, withModifiers } from "vue";
|
|
9
|
-
import { FORM_ERROR_KEY, META_DESCRIPTION, META_LABEL, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_SUBMIT_TEXT, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, collectDirtyPaths, createFormData, createFormValueResolver, deepClone, deepEqual, deleteByPath, getByPath,
|
|
10
|
+
import { FORM_ERROR_KEY, META_DESCRIPTION, META_LABEL, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_SUBMIT_TEXT, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, collectDirtyPaths, createFormData, createFormValueResolver, deepClone, deepEqual, deleteByPath, displayValue, formPayload, getByPath, getDeclaredFormAction, getFormValidator, iteratePathAncestors, mergeErrorMaps, normalizeLoadedEmpty, omitPaths, resolveFormProp, setByPath, unionVariantChanged } from "@atscript/ui";
|
|
10
11
|
//#region src/composables/use-as-form-patch.ts
|
|
11
12
|
/**
|
|
12
13
|
* Internal factory invoked by `useAsForm` when `trackChanges` is enabled. Owns
|
|
@@ -299,6 +300,11 @@ function useAsExternalErrors(options) {
|
|
|
299
300
|
}
|
|
300
301
|
//#endregion
|
|
301
302
|
//#region src/composables/use-as-state.ts
|
|
303
|
+
/** A value as itself: a scalar written out, `""` for none (or an object). */
|
|
304
|
+
function plainText(value) {
|
|
305
|
+
if (value === null || value === void 0 || typeof value === "object") return "";
|
|
306
|
+
return String(value);
|
|
307
|
+
}
|
|
302
308
|
function useAsState(opts) {
|
|
303
309
|
const fieldsById = /* @__PURE__ */ new Map();
|
|
304
310
|
const fieldsRevision = shallowRef(0);
|
|
@@ -312,12 +318,20 @@ function useAsState(opts) {
|
|
|
312
318
|
fieldsRevision.value++;
|
|
313
319
|
formState.freshFields.delete(id);
|
|
314
320
|
};
|
|
321
|
+
const texts = useValueHelpTexts(opts.clientFactory ?? inject(CLIENT_FACTORY_KEY, null) ?? void 0);
|
|
322
|
+
const { t } = useAsTexts();
|
|
323
|
+
const displayText = (field, value, o) => displayValue(o ?? {}, value, {
|
|
324
|
+
siblingText: o?.siblingText,
|
|
325
|
+
valueText: () => texts.text(field, value),
|
|
326
|
+
t
|
|
327
|
+
}) ?? plainText(value);
|
|
315
328
|
const formState = reactive({
|
|
316
329
|
firstSubmitHappened: false,
|
|
317
330
|
firstValidation: toValue(opts.firstValidation) ?? "on-change",
|
|
318
331
|
freshFields: /* @__PURE__ */ new Set(),
|
|
319
332
|
register,
|
|
320
|
-
unregister
|
|
333
|
+
unregister,
|
|
334
|
+
displayText
|
|
321
335
|
});
|
|
322
336
|
watchEffect(() => {
|
|
323
337
|
const v = toValue(opts.firstValidation) ?? "on-change";
|
|
@@ -340,28 +354,20 @@ function useAsState(opts) {
|
|
|
340
354
|
formState.firstSubmitHappened = true;
|
|
341
355
|
formState.freshFields.clear();
|
|
342
356
|
if (formState.firstValidation === "none") return true;
|
|
343
|
-
|
|
344
|
-
const errors = opts.submitValidator();
|
|
345
|
-
const entries = Object.entries(errors);
|
|
346
|
-
if (entries.length === 0) return true;
|
|
347
|
-
setErrors(errors);
|
|
348
|
-
return entries.map(([path, message]) => ({
|
|
349
|
-
path,
|
|
350
|
-
message
|
|
351
|
-
}));
|
|
352
|
-
}
|
|
353
|
-
const errors = [];
|
|
357
|
+
const errors = { ...opts.submitValidator?.() };
|
|
354
358
|
for (const reg of fieldsById.values()) {
|
|
359
|
+
if (opts.submitValidator && reg.validated) continue;
|
|
355
360
|
const result = reg.callbacks.validate();
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
errors.push({
|
|
359
|
-
path,
|
|
360
|
-
message: result
|
|
361
|
-
});
|
|
362
|
-
}
|
|
361
|
+
const path = reg.path();
|
|
362
|
+
if (result !== true && errors[path] === void 0) errors[path] = result;
|
|
363
363
|
}
|
|
364
|
-
|
|
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
|
+
}));
|
|
365
371
|
}
|
|
366
372
|
function setErrors(errors) {
|
|
367
373
|
for (const reg of fieldsById.values()) {
|
|
@@ -429,9 +435,12 @@ function useAsForm(options) {
|
|
|
429
435
|
provide(FORM_NORMALIZED_DATA_KEY, computed(() => formValidator.value.normalize(getDomainData()) ?? {}));
|
|
430
436
|
const modelT = () => options.def().served ? void 0 : t;
|
|
431
437
|
provide(MODEL_TEXTS_KEY, modelT);
|
|
432
|
-
const
|
|
438
|
+
const cf = options.clientFactory?.();
|
|
439
|
+
if (cf) provide(CLIENT_FACTORY_KEY, cf);
|
|
440
|
+
const { formState, clearErrors: clearFieldErrors, reset: resetState, submit, setErrors, liveErrors, registeredPaths } = useAsState({
|
|
433
441
|
formData: data,
|
|
434
442
|
formContext,
|
|
443
|
+
clientFactory: cf,
|
|
435
444
|
firstValidation: computed(() => options.firstValidation?.()),
|
|
436
445
|
submitValidator: () => formValidator.value({
|
|
437
446
|
data: submitting,
|
|
@@ -472,8 +481,6 @@ function useAsForm(options) {
|
|
|
472
481
|
provide(ERRORS_KEY, ext.effective);
|
|
473
482
|
provide(DISMISS_EXTERNAL_AT_KEY, ext.dismissAt);
|
|
474
483
|
const sectionsStore = useAsNestedSectionsStore() ?? provideAsNestedSectionsStore();
|
|
475
|
-
const cf = options.clientFactory?.();
|
|
476
|
-
if (cf) provide(CLIENT_FACTORY_KEY, cf);
|
|
477
484
|
const internalErrors = ref({});
|
|
478
485
|
const orphanInternalErrors = computed(() => omitPaths(internalErrors.value, registeredPaths.value));
|
|
479
486
|
const allErrors = computed(() => mergeErrorMaps(ext.effective.value, orphanInternalErrors.value, liveErrors.value));
|
|
@@ -544,6 +551,7 @@ function useAsForm(options) {
|
|
|
544
551
|
const resolveRootProp = (fnKey, staticKey) => resolveFormProp(options.def().type, fnKey, staticKey, ctx.value, { t: modelT() });
|
|
545
552
|
const title = computed(() => resolveRootProp(UI_FORM_FN_TITLE, META_LABEL));
|
|
546
553
|
const description = computed(() => resolveRootProp(UI_FORM_FN_DESCRIPTION, META_DESCRIPTION));
|
|
554
|
+
const displayText = fieldDisplayText(formState, (path) => getByPath(data.value, path));
|
|
547
555
|
const slotProps = computed(() => ({
|
|
548
556
|
title: title.value,
|
|
549
557
|
description: description.value,
|
|
@@ -554,6 +562,7 @@ function useAsForm(options) {
|
|
|
554
562
|
loading: options.loading?.() === true,
|
|
555
563
|
submitText: submitText.value,
|
|
556
564
|
submit: onSubmit,
|
|
565
|
+
action: invokeAction,
|
|
557
566
|
reset,
|
|
558
567
|
revert,
|
|
559
568
|
clearErrors,
|
|
@@ -565,24 +574,13 @@ function useAsForm(options) {
|
|
|
565
574
|
changes: patch ? patch.changes.value : EMPTY_CHANGES,
|
|
566
575
|
getPatch: patch ? patch.getPatch : EMPTY_GET_PATCH,
|
|
567
576
|
getChanges: patch ? patch.getChanges : EMPTY_GET_CHANGES,
|
|
568
|
-
isDirtyPath: patch ? patch.isDirtyPath : EMPTY_IS_DIRTY_PATH
|
|
577
|
+
isDirtyPath: patch ? patch.isDirtyPath : EMPTY_IS_DIRTY_PATH,
|
|
578
|
+
displayText
|
|
569
579
|
}));
|
|
570
|
-
function supportsAction(def, actionId) {
|
|
571
|
-
return getDeclaredFormActions(def).some((a) => a.id === actionId);
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* What the form sends — on submit and with an action: without the related rows of
|
|
575
|
-
* navigation fields the form leaves out (loaded with `$with`, never rendered or
|
|
576
|
-
* validated) and without the fields the server owns (`derived`: `/meta` `readOnly`,
|
|
577
|
-
* computed, …).
|
|
578
|
-
*/
|
|
579
|
-
function outgoing(def, data) {
|
|
580
|
-
return omitDerivedFields(def, omitSkippedNavFields(def, data));
|
|
581
|
-
}
|
|
582
580
|
function invokeAction(name) {
|
|
583
581
|
const def = options.def();
|
|
584
|
-
const data =
|
|
585
|
-
if (
|
|
582
|
+
const data = formPayload(def, formValidator.value.normalize(domainData()));
|
|
583
|
+
if (getDeclaredFormAction(def, name)) options.emits?.action?.(name, data);
|
|
586
584
|
else options.emits?.unsupportedAction?.(name, data);
|
|
587
585
|
}
|
|
588
586
|
provide(ACTION_HANDLER_KEY, invokeAction);
|
|
@@ -604,7 +602,7 @@ function useAsForm(options) {
|
|
|
604
602
|
const result = submit();
|
|
605
603
|
if (result === true) {
|
|
606
604
|
internalErrors.value = {};
|
|
607
|
-
const payload =
|
|
605
|
+
const payload = formPayload(options.def(), data);
|
|
608
606
|
options.emits?.submit?.(payload);
|
|
609
607
|
return {
|
|
610
608
|
ok: true,
|
package/dist/as-form.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const require_as_form = require("./as-form-
|
|
1
|
+
const require_as_form = require("./as-form-B4-StU3b.cjs");
|
|
2
2
|
module.exports = require_as_form.as_form_default;
|
package/dist/as-form.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as _default, t as Props } from "./as-form.vue-
|
|
1
|
+
import { n as _default, t as Props } from "./as-form.vue-DS5r3CWl.cjs";
|
|
2
2
|
export { Props, _default as default };
|
package/dist/as-form.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as _default, t as Props } from "./as-form.vue-
|
|
1
|
+
import { n as _default, t as Props } from "./as-form.vue-BMNZuvpb.mjs";
|
|
2
2
|
export { Props, _default as default };
|
package/dist/as-form.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as as_form_default } from "./as-form-
|
|
1
|
+
import { t as as_form_default } from "./as-form-DQePBFwR.mjs";
|
|
2
2
|
export { as_form_default as default };
|