@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,33 @@
|
|
|
1
|
-
const require_use_form_context = require("./use-form-context-
|
|
1
|
+
const require_use_form_context = require("./use-form-context-BPlkQwkM.cjs");
|
|
2
2
|
const require_use_as_locale = require("./use-as-locale-eo7FyfaZ.cjs");
|
|
3
3
|
let vue = require("vue");
|
|
4
4
|
let _atscript_ui = require("@atscript/ui");
|
|
5
5
|
//#region src/composables/use-as-data.ts
|
|
6
|
+
/**
|
|
7
|
+
* {@link UseAsDataReturn.displayText} over `formState`: the field's
|
|
8
|
+
* `@ui.valueLabel` sibling is read through `read` (a data path below where the
|
|
9
|
+
* field's def is rendered) — the one sibling read of `useAsData`, `AsField` and
|
|
10
|
+
* the form's slot (`useAsForm`).
|
|
11
|
+
*/
|
|
12
|
+
function fieldDisplayText(formState, read) {
|
|
13
|
+
return (field, value, options) => {
|
|
14
|
+
const label = (0, _atscript_ui.valueLabelOf)(field.prop);
|
|
15
|
+
const siblingText = label && {
|
|
16
|
+
text: read((0, _atscript_ui.parentPrefix)(field.path) + label.field),
|
|
17
|
+
arrangement: label.arrangement
|
|
18
|
+
};
|
|
19
|
+
return formState.displayText(field, value, {
|
|
20
|
+
options,
|
|
21
|
+
siblingText
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
6
25
|
const EMPTY_PATH = (0, vue.computed)(() => "");
|
|
7
26
|
const EMPTY_DATA = (0, vue.computed)(() => void 0);
|
|
27
|
+
const NO_FORM_OPTIONAL = {
|
|
28
|
+
mode: (0, vue.computed)(() => void 0),
|
|
29
|
+
edit: (0, vue.computed)(() => false)
|
|
30
|
+
};
|
|
8
31
|
/**
|
|
9
32
|
* Reactive access to form data at any point in the `<AsForm>` tree: readers
|
|
10
33
|
* plus `setValueAt` / `setSibling` writers. Outside a form, all readers
|
|
@@ -15,8 +38,10 @@ const EMPTY_DATA = (0, vue.computed)(() => void 0);
|
|
|
15
38
|
*/
|
|
16
39
|
function useAsData() {
|
|
17
40
|
const wrapped = (0, vue.inject)(require_use_form_context.ROOT_DATA_KEY, EMPTY_DATA);
|
|
41
|
+
const formState = (0, vue.inject)(require_use_form_context.FORM_STATE_KEY, void 0);
|
|
18
42
|
const pathPrefix = (0, vue.inject)(require_use_form_context.PATH_PREFIX_KEY, EMPTY_PATH);
|
|
19
43
|
const handleChange = (0, vue.inject)(require_use_form_context.CHANGE_HANDLER_KEY, void 0);
|
|
44
|
+
const formOptional = (0, vue.inject)(require_use_form_context.FORM_OPTIONAL_KEY, NO_FORM_OPTIONAL);
|
|
20
45
|
const rootData = (0, vue.computed)(() => {
|
|
21
46
|
return wrapped.value?.value;
|
|
22
47
|
});
|
|
@@ -27,12 +52,13 @@ function useAsData() {
|
|
|
27
52
|
return (0, _atscript_ui.getByPath)(w, path);
|
|
28
53
|
});
|
|
29
54
|
}
|
|
55
|
+
/** The value of the field `name` below this position. */
|
|
56
|
+
function readSibling(name) {
|
|
57
|
+
const w = wrapped.value;
|
|
58
|
+
return w ? (0, _atscript_ui.getByPath)(w, (0, _atscript_ui.joinPath)(pathPrefix.value, name)) : void 0;
|
|
59
|
+
}
|
|
30
60
|
function siblingValue(name) {
|
|
31
|
-
return (0, vue.computed)(() =>
|
|
32
|
-
const w = wrapped.value;
|
|
33
|
-
if (!w) return void 0;
|
|
34
|
-
return (0, _atscript_ui.getByPath)(w, (0, _atscript_ui.joinPath)(pathPrefix.value, name));
|
|
35
|
-
});
|
|
61
|
+
return (0, vue.computed)(() => readSibling(name));
|
|
36
62
|
}
|
|
37
63
|
function setValueAt(path, value) {
|
|
38
64
|
const w = wrapped.value;
|
|
@@ -48,7 +74,10 @@ function useAsData() {
|
|
|
48
74
|
getValueAt,
|
|
49
75
|
siblingValue,
|
|
50
76
|
setValueAt,
|
|
51
|
-
setSibling
|
|
77
|
+
setSibling,
|
|
78
|
+
displayText: formState ? fieldDisplayText(formState, readSibling) : () => "",
|
|
79
|
+
optionalMode: formOptional.mode,
|
|
80
|
+
edit: formOptional.edit
|
|
52
81
|
};
|
|
53
82
|
}
|
|
54
83
|
//#endregion
|
|
@@ -71,24 +100,22 @@ function useAsValueHelp(options) {
|
|
|
71
100
|
const hostLocals = new Set(info.hostFilter?.map((h) => h.local));
|
|
72
101
|
/** What this field's last pick wrote into each fill target. */
|
|
73
102
|
const written = /* @__PURE__ */ new Map();
|
|
74
|
-
/** A cleared fill on an edit form holds `null`, so a whole-record update clears it too. */
|
|
75
|
-
const formOptional = (0, vue.inject)(require_use_form_context.FORM_OPTIONAL_KEY, void 0);
|
|
76
103
|
const injectedFactory = (0, vue.inject)(CLIENT_FACTORY_KEY, null) ?? void 0;
|
|
77
104
|
const texts = require_use_as_locale.useAsTexts();
|
|
78
105
|
const scoped = !!(0, vue.getCurrentScope)();
|
|
79
106
|
const browser = typeof window !== "undefined";
|
|
80
107
|
let release;
|
|
81
|
-
let
|
|
82
|
-
/**
|
|
83
|
-
* Binds the entry of the app's current locale — held while mounted, so
|
|
84
|
-
* `kickoff`'s `resolveValueHelp` finds it (and its client).
|
|
85
|
-
*/
|
|
108
|
+
let source;
|
|
109
|
+
/** Binds the dictionary in the app's current locale — its entry held while mounted. */
|
|
86
110
|
function bindEntry() {
|
|
87
|
-
const
|
|
111
|
+
const next = (0, _atscript_ui.valueHelpSource)(info, {
|
|
112
|
+
texts,
|
|
113
|
+
clientFactory: injectedFactory
|
|
114
|
+
});
|
|
88
115
|
const previous = release;
|
|
89
|
-
release = scoped ? (0, _atscript_ui.retainMetaEntry)(entry) : void 0;
|
|
116
|
+
release = scoped ? (0, _atscript_ui.retainMetaEntry)(next.entry) : void 0;
|
|
90
117
|
previous?.();
|
|
91
|
-
|
|
118
|
+
source = next;
|
|
92
119
|
}
|
|
93
120
|
if (browser) bindEntry();
|
|
94
121
|
if (scoped) (0, vue.onScopeDispose)(() => release?.());
|
|
@@ -97,7 +124,6 @@ function useAsValueHelp(options) {
|
|
|
97
124
|
const searchText = (0, vue.ref)("");
|
|
98
125
|
const results = (0, vue.shallowRef)([]);
|
|
99
126
|
const searching = (0, vue.ref)(false);
|
|
100
|
-
const labelIsFkValue = (0, vue.computed)(() => !!resolved.value && info.targetField === resolved.value.labelField);
|
|
101
127
|
let debounceTimer;
|
|
102
128
|
let kickoffPromise;
|
|
103
129
|
/** Bumped per kickoff: a superseded one (a previous locale's) never lands. */
|
|
@@ -111,10 +137,8 @@ function useAsValueHelp(options) {
|
|
|
111
137
|
async function kickoff() {
|
|
112
138
|
if (kickoffPromise) return kickoffPromise;
|
|
113
139
|
const mine = ++kickoffSeq;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
clientFactory: injectedFactory
|
|
117
|
-
}).then((r) => {
|
|
140
|
+
if (!source) bindEntry();
|
|
141
|
+
kickoffPromise = source.resolve().then((r) => {
|
|
118
142
|
if (mine !== kickoffSeq) return;
|
|
119
143
|
resolved.value = r;
|
|
120
144
|
status.value = "ready";
|
|
@@ -140,19 +164,18 @@ function useAsValueHelp(options) {
|
|
|
140
164
|
}, DEBOUNCE_MS);
|
|
141
165
|
}
|
|
142
166
|
async function doSearch(text) {
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
167
|
+
const s = source;
|
|
168
|
+
if (!resolved.value || !s) return;
|
|
145
169
|
if (text === lastSearchedText) return;
|
|
146
170
|
lastSearchedText = text;
|
|
147
171
|
const mine = ++searchSeq;
|
|
148
172
|
searching.value = true;
|
|
149
173
|
try {
|
|
150
|
-
const result = await
|
|
174
|
+
const result = await s.search({
|
|
151
175
|
text: text || void 0,
|
|
152
176
|
mode: "form",
|
|
153
177
|
limit,
|
|
154
|
-
filter: scope.value.filter
|
|
155
|
-
info
|
|
178
|
+
filter: scope.value.filter
|
|
156
179
|
});
|
|
157
180
|
if (mine === searchSeq) results.value = result.items;
|
|
158
181
|
} catch {
|
|
@@ -188,7 +211,7 @@ function useAsValueHelp(options) {
|
|
|
188
211
|
}
|
|
189
212
|
function commitValue(value) {
|
|
190
213
|
model.value = value;
|
|
191
|
-
for (const [local, wrote] of written) if (wrote !== void 0 && !hostLocals.has(local) && Object.is(readSibling(local), wrote)) data.setSibling(local,
|
|
214
|
+
for (const [local, wrote] of written) if (wrote !== void 0 && !hostLocals.has(local) && Object.is(readSibling(local), wrote)) data.setSibling(local, data.edit.value ? null : void 0);
|
|
192
215
|
written.clear();
|
|
193
216
|
}
|
|
194
217
|
function clear(value) {
|
|
@@ -202,7 +225,6 @@ function useAsValueHelp(options) {
|
|
|
202
225
|
searchText,
|
|
203
226
|
results,
|
|
204
227
|
searching,
|
|
205
|
-
labelIsFkValue,
|
|
206
228
|
kickoff,
|
|
207
229
|
selectItem,
|
|
208
230
|
clear,
|
|
@@ -217,6 +239,12 @@ Object.defineProperty(exports, "CLIENT_FACTORY_KEY", {
|
|
|
217
239
|
return CLIENT_FACTORY_KEY;
|
|
218
240
|
}
|
|
219
241
|
});
|
|
242
|
+
Object.defineProperty(exports, "fieldDisplayText", {
|
|
243
|
+
enumerable: true,
|
|
244
|
+
get: function() {
|
|
245
|
+
return fieldDisplayText;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
220
248
|
Object.defineProperty(exports, "useAsData", {
|
|
221
249
|
enumerable: true,
|
|
222
250
|
get: function() {
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as PATH_PREFIX_KEY, h as FORM_STATE_KEY, o as CHANGE_HANDLER_KEY, p as FORM_OPTIONAL_KEY, x as ROOT_DATA_KEY } from "./use-form-context-D_ejQqCc.mjs";
|
|
2
2
|
import { o as useAsTexts, s as useUiLocaleKey } from "./use-as-locale-CznDr-7i.mjs";
|
|
3
3
|
import { computed, getCurrentScope, inject, onMounted, onScopeDispose, onUnmounted, ref, shallowRef, watch } from "vue";
|
|
4
|
-
import {
|
|
4
|
+
import { getByPath, joinPath, parentPrefix, retainMetaEntry, setByPath, valueHelpFills, valueHelpScope, valueHelpSource, valueLabelOf } from "@atscript/ui";
|
|
5
5
|
//#region src/composables/use-as-data.ts
|
|
6
|
+
/**
|
|
7
|
+
* {@link UseAsDataReturn.displayText} over `formState`: the field's
|
|
8
|
+
* `@ui.valueLabel` sibling is read through `read` (a data path below where the
|
|
9
|
+
* field's def is rendered) — the one sibling read of `useAsData`, `AsField` and
|
|
10
|
+
* the form's slot (`useAsForm`).
|
|
11
|
+
*/
|
|
12
|
+
function fieldDisplayText(formState, read) {
|
|
13
|
+
return (field, value, options) => {
|
|
14
|
+
const label = valueLabelOf(field.prop);
|
|
15
|
+
const siblingText = label && {
|
|
16
|
+
text: read(parentPrefix(field.path) + label.field),
|
|
17
|
+
arrangement: label.arrangement
|
|
18
|
+
};
|
|
19
|
+
return formState.displayText(field, value, {
|
|
20
|
+
options,
|
|
21
|
+
siblingText
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
6
25
|
const EMPTY_PATH = computed(() => "");
|
|
7
26
|
const EMPTY_DATA = computed(() => void 0);
|
|
27
|
+
const NO_FORM_OPTIONAL = {
|
|
28
|
+
mode: computed(() => void 0),
|
|
29
|
+
edit: computed(() => false)
|
|
30
|
+
};
|
|
8
31
|
/**
|
|
9
32
|
* Reactive access to form data at any point in the `<AsForm>` tree: readers
|
|
10
33
|
* plus `setValueAt` / `setSibling` writers. Outside a form, all readers
|
|
@@ -15,8 +38,10 @@ const EMPTY_DATA = computed(() => void 0);
|
|
|
15
38
|
*/
|
|
16
39
|
function useAsData() {
|
|
17
40
|
const wrapped = inject(ROOT_DATA_KEY, EMPTY_DATA);
|
|
41
|
+
const formState = inject(FORM_STATE_KEY, void 0);
|
|
18
42
|
const pathPrefix = inject(PATH_PREFIX_KEY, EMPTY_PATH);
|
|
19
43
|
const handleChange = inject(CHANGE_HANDLER_KEY, void 0);
|
|
44
|
+
const formOptional = inject(FORM_OPTIONAL_KEY, NO_FORM_OPTIONAL);
|
|
20
45
|
const rootData = computed(() => {
|
|
21
46
|
return wrapped.value?.value;
|
|
22
47
|
});
|
|
@@ -27,12 +52,13 @@ function useAsData() {
|
|
|
27
52
|
return getByPath(w, path);
|
|
28
53
|
});
|
|
29
54
|
}
|
|
55
|
+
/** The value of the field `name` below this position. */
|
|
56
|
+
function readSibling(name) {
|
|
57
|
+
const w = wrapped.value;
|
|
58
|
+
return w ? getByPath(w, joinPath(pathPrefix.value, name)) : void 0;
|
|
59
|
+
}
|
|
30
60
|
function siblingValue(name) {
|
|
31
|
-
return computed(() =>
|
|
32
|
-
const w = wrapped.value;
|
|
33
|
-
if (!w) return void 0;
|
|
34
|
-
return getByPath(w, joinPath(pathPrefix.value, name));
|
|
35
|
-
});
|
|
61
|
+
return computed(() => readSibling(name));
|
|
36
62
|
}
|
|
37
63
|
function setValueAt(path, value) {
|
|
38
64
|
const w = wrapped.value;
|
|
@@ -48,7 +74,10 @@ function useAsData() {
|
|
|
48
74
|
getValueAt,
|
|
49
75
|
siblingValue,
|
|
50
76
|
setValueAt,
|
|
51
|
-
setSibling
|
|
77
|
+
setSibling,
|
|
78
|
+
displayText: formState ? fieldDisplayText(formState, readSibling) : () => "",
|
|
79
|
+
optionalMode: formOptional.mode,
|
|
80
|
+
edit: formOptional.edit
|
|
52
81
|
};
|
|
53
82
|
}
|
|
54
83
|
//#endregion
|
|
@@ -71,24 +100,22 @@ function useAsValueHelp(options) {
|
|
|
71
100
|
const hostLocals = new Set(info.hostFilter?.map((h) => h.local));
|
|
72
101
|
/** What this field's last pick wrote into each fill target. */
|
|
73
102
|
const written = /* @__PURE__ */ new Map();
|
|
74
|
-
/** A cleared fill on an edit form holds `null`, so a whole-record update clears it too. */
|
|
75
|
-
const formOptional = inject(FORM_OPTIONAL_KEY, void 0);
|
|
76
103
|
const injectedFactory = inject(CLIENT_FACTORY_KEY, null) ?? void 0;
|
|
77
104
|
const texts = useAsTexts();
|
|
78
105
|
const scoped = !!getCurrentScope();
|
|
79
106
|
const browser = typeof window !== "undefined";
|
|
80
107
|
let release;
|
|
81
|
-
let
|
|
82
|
-
/**
|
|
83
|
-
* Binds the entry of the app's current locale — held while mounted, so
|
|
84
|
-
* `kickoff`'s `resolveValueHelp` finds it (and its client).
|
|
85
|
-
*/
|
|
108
|
+
let source;
|
|
109
|
+
/** Binds the dictionary in the app's current locale — its entry held while mounted. */
|
|
86
110
|
function bindEntry() {
|
|
87
|
-
const
|
|
111
|
+
const next = valueHelpSource(info, {
|
|
112
|
+
texts,
|
|
113
|
+
clientFactory: injectedFactory
|
|
114
|
+
});
|
|
88
115
|
const previous = release;
|
|
89
|
-
release = scoped ? retainMetaEntry(entry) : void 0;
|
|
116
|
+
release = scoped ? retainMetaEntry(next.entry) : void 0;
|
|
90
117
|
previous?.();
|
|
91
|
-
|
|
118
|
+
source = next;
|
|
92
119
|
}
|
|
93
120
|
if (browser) bindEntry();
|
|
94
121
|
if (scoped) onScopeDispose(() => release?.());
|
|
@@ -97,7 +124,6 @@ function useAsValueHelp(options) {
|
|
|
97
124
|
const searchText = ref("");
|
|
98
125
|
const results = shallowRef([]);
|
|
99
126
|
const searching = ref(false);
|
|
100
|
-
const labelIsFkValue = computed(() => !!resolved.value && info.targetField === resolved.value.labelField);
|
|
101
127
|
let debounceTimer;
|
|
102
128
|
let kickoffPromise;
|
|
103
129
|
/** Bumped per kickoff: a superseded one (a previous locale's) never lands. */
|
|
@@ -111,10 +137,8 @@ function useAsValueHelp(options) {
|
|
|
111
137
|
async function kickoff() {
|
|
112
138
|
if (kickoffPromise) return kickoffPromise;
|
|
113
139
|
const mine = ++kickoffSeq;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
clientFactory: injectedFactory
|
|
117
|
-
}).then((r) => {
|
|
140
|
+
if (!source) bindEntry();
|
|
141
|
+
kickoffPromise = source.resolve().then((r) => {
|
|
118
142
|
if (mine !== kickoffSeq) return;
|
|
119
143
|
resolved.value = r;
|
|
120
144
|
status.value = "ready";
|
|
@@ -140,19 +164,18 @@ function useAsValueHelp(options) {
|
|
|
140
164
|
}, DEBOUNCE_MS);
|
|
141
165
|
}
|
|
142
166
|
async function doSearch(text) {
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
167
|
+
const s = source;
|
|
168
|
+
if (!resolved.value || !s) return;
|
|
145
169
|
if (text === lastSearchedText) return;
|
|
146
170
|
lastSearchedText = text;
|
|
147
171
|
const mine = ++searchSeq;
|
|
148
172
|
searching.value = true;
|
|
149
173
|
try {
|
|
150
|
-
const result = await
|
|
174
|
+
const result = await s.search({
|
|
151
175
|
text: text || void 0,
|
|
152
176
|
mode: "form",
|
|
153
177
|
limit,
|
|
154
|
-
filter: scope.value.filter
|
|
155
|
-
info
|
|
178
|
+
filter: scope.value.filter
|
|
156
179
|
});
|
|
157
180
|
if (mine === searchSeq) results.value = result.items;
|
|
158
181
|
} catch {
|
|
@@ -188,7 +211,7 @@ function useAsValueHelp(options) {
|
|
|
188
211
|
}
|
|
189
212
|
function commitValue(value) {
|
|
190
213
|
model.value = value;
|
|
191
|
-
for (const [local, wrote] of written) if (wrote !== void 0 && !hostLocals.has(local) && Object.is(readSibling(local), wrote)) data.setSibling(local,
|
|
214
|
+
for (const [local, wrote] of written) if (wrote !== void 0 && !hostLocals.has(local) && Object.is(readSibling(local), wrote)) data.setSibling(local, data.edit.value ? null : void 0);
|
|
192
215
|
written.clear();
|
|
193
216
|
}
|
|
194
217
|
function clear(value) {
|
|
@@ -202,7 +225,6 @@ function useAsValueHelp(options) {
|
|
|
202
225
|
searchText,
|
|
203
226
|
results,
|
|
204
227
|
searching,
|
|
205
|
-
labelIsFkValue,
|
|
206
228
|
kickoff,
|
|
207
229
|
selectItem,
|
|
208
230
|
clear,
|
|
@@ -211,4 +233,4 @@ function useAsValueHelp(options) {
|
|
|
211
233
|
};
|
|
212
234
|
}
|
|
213
235
|
//#endregion
|
|
214
|
-
export { useAsValueHelp as n,
|
|
236
|
+
export { useAsData as i, useAsValueHelp as n, fieldDisplayText as r, CLIENT_FACTORY_KEY as t };
|
|
@@ -109,6 +109,16 @@ function formatIndexedLabelParts(label, arrayIndex) {
|
|
|
109
109
|
suffix: `#${arrayIndex + 1}`
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether the structured field being rendered is locked — disabled or read-only,
|
|
114
|
+
* its own or an ancestor's: the state `<AsField>` hands to the fields inside a
|
|
115
|
+
* structured field. Its value cannot change through it: the one lock reader of
|
|
116
|
+
* `useAsArray`, `useAsTuple`, `useAsUnion` and `useAsOptionalField`.
|
|
117
|
+
*/
|
|
118
|
+
function useInheritedLock() {
|
|
119
|
+
const lock = (0, vue.inject)(LOCK_KEY, void 0);
|
|
120
|
+
return (0, vue.computed)(() => !!lock && ((0, vue.unref)(lock.disabled) || (0, vue.unref)(lock.readonly)));
|
|
121
|
+
}
|
|
112
122
|
//#endregion
|
|
113
123
|
Object.defineProperty(exports, "ACTION_HANDLER_KEY", {
|
|
114
124
|
enumerable: true,
|
|
@@ -242,3 +252,9 @@ Object.defineProperty(exports, "useFormContext", {
|
|
|
242
252
|
return useFormContext;
|
|
243
253
|
}
|
|
244
254
|
});
|
|
255
|
+
Object.defineProperty(exports, "useInheritedLock", {
|
|
256
|
+
enumerable: true,
|
|
257
|
+
get: function() {
|
|
258
|
+
return useInheritedLock;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as useAsTexts } from "./use-as-locale-CznDr-7i.mjs";
|
|
2
|
-
import { computed, inject, provide } from "vue";
|
|
2
|
+
import { computed, inject, provide, unref } from "vue";
|
|
3
3
|
import { createFormData, createFormValueResolver, getByPath, joinPath, setByPath } from "@atscript/ui";
|
|
4
4
|
//#region src/composables/internal-keys.ts
|
|
5
5
|
/**
|
|
@@ -109,5 +109,15 @@ function formatIndexedLabelParts(label, arrayIndex) {
|
|
|
109
109
|
suffix: `#${arrayIndex + 1}`
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether the structured field being rendered is locked — disabled or read-only,
|
|
114
|
+
* its own or an ancestor's: the state `<AsField>` hands to the fields inside a
|
|
115
|
+
* structured field. Its value cannot change through it: the one lock reader of
|
|
116
|
+
* `useAsArray`, `useAsTuple`, `useAsUnion` and `useAsOptionalField`.
|
|
117
|
+
*/
|
|
118
|
+
function useInheritedLock() {
|
|
119
|
+
const lock = inject(LOCK_KEY, void 0);
|
|
120
|
+
return computed(() => !!lock && (unref(lock.disabled) || unref(lock.readonly)));
|
|
121
|
+
}
|
|
112
122
|
//#endregion
|
|
113
|
-
export { UNION_CONTEXT_KEY as S,
|
|
123
|
+
export { UNION_CONTEXT_KEY as C, TYPES_KEY as S, LEVEL_KEY as _, ACTION_HANDLER_KEY as a, PATH_PREFIX_KEY as b, DISMISS_EXTERNAL_AT_KEY as c, FORM_DATA_KEY as d, FORM_NORMALIZED_DATA_KEY as f, HIDE_ROOT_TITLE_KEY as g, FORM_STATE_KEY as h, useInheritedLock as i, ERRORS_KEY as l, FORM_PATCH_KEY as m, useAsUnionVariant as n, CHANGE_HANDLER_KEY as o, FORM_OPTIONAL_KEY as p, useFormContext as r, COMPONENTS_KEY as s, formatIndexedLabelParts as t, FORM_CONTEXT_KEY as u, LOCK_KEY as v, ROOT_DATA_KEY as x, MODEL_TEXTS_KEY as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { App, ComputedRef, ShallowRef } from "vue";
|
|
2
|
-
import { UiT, UiTexts, UiTranslate } from "@atscript/ui";
|
|
2
|
+
import { ClientFactory, UiT, UiTexts, UiTranslate, ValueHelpInfo, ValueHelpTextOptions, ValueText } from "@atscript/ui";
|
|
3
3
|
|
|
4
4
|
//#region src/composables/use-as-locale.d.ts
|
|
5
5
|
/**
|
|
@@ -83,4 +83,28 @@ declare function useAsLocale(): UseAsLocaleReturn;
|
|
|
83
83
|
*/
|
|
84
84
|
declare function useUiLocaleKey(texts: Pick<UiTexts, "locale">): ShallowRef<string | undefined>;
|
|
85
85
|
//#endregion
|
|
86
|
-
|
|
86
|
+
//#region src/composables/use-value-help-texts.d.ts
|
|
87
|
+
interface UseValueHelpTextsReturn {
|
|
88
|
+
/**
|
|
89
|
+
* The dictionary text of a code in `field` — a column or a form field bound
|
|
90
|
+
* by `valueHelpInfo` (`valueHelpText`) — read in the app's UI locale through
|
|
91
|
+
* the host's client factory; `undefined` for an unbound one. Reactive: a
|
|
92
|
+
* computed or a render that calls it runs again when the binding's texts
|
|
93
|
+
* arrive. `opts.peek`: only a text already read, asking nothing (a value
|
|
94
|
+
* still being typed).
|
|
95
|
+
*/
|
|
96
|
+
text: (field: {
|
|
97
|
+
valueHelpInfo?: ValueHelpInfo;
|
|
98
|
+
}, value: unknown, opts?: Pick<ValueHelpTextOptions, "peek">) => ValueText | undefined;
|
|
99
|
+
/** Loads the texts of `values` in one batched read (`loadValueHelpTexts`); never rejects. */
|
|
100
|
+
load: (info: ValueHelpInfo, values: Iterable<unknown>) => Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The texts of codes bound to a dictionary, for a Vue host — a table's or a
|
|
104
|
+
* form's root wires them once and hands them to its parts (since 0.1.207).
|
|
105
|
+
* `clientFactory`: the host's (a table's or a form's), so texts are read the
|
|
106
|
+
* way its pickers search. Call in `setup` (it reads the app's UI texts).
|
|
107
|
+
*/
|
|
108
|
+
declare function useValueHelpTexts(clientFactory?: ClientFactory): UseValueHelpTextsReturn;
|
|
109
|
+
//#endregion
|
|
110
|
+
export { getAsServedTexts as a, provideAsServedTexts as c, useUiLocaleKey as d, UseAsLocaleReturn as i, useAsLocale as l, useValueHelpTexts as n, injectAsTexts as o, AsServedTexts as r, provideAsLocale as s, UseValueHelpTextsReturn as t, useAsTexts as u };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { o as useAsTexts } from "./use-as-locale-CznDr-7i.mjs";
|
|
2
|
+
import { shallowRef } from "vue";
|
|
3
|
+
import { loadValueHelpTexts, onValueHelpTexts, valueHelpKey, valueHelpText } from "@atscript/ui";
|
|
4
|
+
//#region src/composables/use-value-help-texts.ts
|
|
5
|
+
/**
|
|
6
|
+
* Per binding (`valueHelpKey`): bumped when its texts arrive, and every one
|
|
7
|
+
* when the cache is dropped — so only the views of that binding read again.
|
|
8
|
+
*/
|
|
9
|
+
const arrivals = /* @__PURE__ */ new Map();
|
|
10
|
+
let subscribed = false;
|
|
11
|
+
function trackArrivals(info) {
|
|
12
|
+
if (!subscribed) {
|
|
13
|
+
subscribed = true;
|
|
14
|
+
onValueHelpTexts((binding) => {
|
|
15
|
+
if (binding === void 0) for (const counter of arrivals.values()) counter.value++;
|
|
16
|
+
else {
|
|
17
|
+
const counter = arrivals.get(binding);
|
|
18
|
+
if (counter) counter.value++;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const binding = valueHelpKey(info);
|
|
23
|
+
let counter = arrivals.get(binding);
|
|
24
|
+
if (!counter) arrivals.set(binding, counter = shallowRef(0));
|
|
25
|
+
counter.value;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The texts of codes bound to a dictionary, for a Vue host — a table's or a
|
|
29
|
+
* form's root wires them once and hands them to its parts (since 0.1.207).
|
|
30
|
+
* `clientFactory`: the host's (a table's or a form's), so texts are read the
|
|
31
|
+
* way its pickers search. Call in `setup` (it reads the app's UI texts).
|
|
32
|
+
*/
|
|
33
|
+
function useValueHelpTexts(clientFactory) {
|
|
34
|
+
const options = {
|
|
35
|
+
texts: useAsTexts(),
|
|
36
|
+
clientFactory
|
|
37
|
+
};
|
|
38
|
+
const peekOptions = {
|
|
39
|
+
...options,
|
|
40
|
+
peek: true
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
text: ({ valueHelpInfo }, value, opts) => {
|
|
44
|
+
if (!valueHelpInfo) return void 0;
|
|
45
|
+
trackArrivals(valueHelpInfo);
|
|
46
|
+
return valueHelpText(valueHelpInfo, value, opts?.peek ? peekOptions : options);
|
|
47
|
+
},
|
|
48
|
+
load: (info, values) => loadValueHelpTexts(info, values, options)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { useValueHelpTexts as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { App, ComputedRef, ShallowRef } from "vue";
|
|
2
|
-
import { UiT, UiTexts, UiTranslate } from "@atscript/ui";
|
|
2
|
+
import { ClientFactory, UiT, UiTexts, UiTranslate, ValueHelpInfo, ValueHelpTextOptions, ValueText } from "@atscript/ui";
|
|
3
3
|
|
|
4
4
|
//#region src/composables/use-as-locale.d.ts
|
|
5
5
|
/**
|
|
@@ -83,4 +83,28 @@ declare function useAsLocale(): UseAsLocaleReturn;
|
|
|
83
83
|
*/
|
|
84
84
|
declare function useUiLocaleKey(texts: Pick<UiTexts, "locale">): ShallowRef<string | undefined>;
|
|
85
85
|
//#endregion
|
|
86
|
-
|
|
86
|
+
//#region src/composables/use-value-help-texts.d.ts
|
|
87
|
+
interface UseValueHelpTextsReturn {
|
|
88
|
+
/**
|
|
89
|
+
* The dictionary text of a code in `field` — a column or a form field bound
|
|
90
|
+
* by `valueHelpInfo` (`valueHelpText`) — read in the app's UI locale through
|
|
91
|
+
* the host's client factory; `undefined` for an unbound one. Reactive: a
|
|
92
|
+
* computed or a render that calls it runs again when the binding's texts
|
|
93
|
+
* arrive. `opts.peek`: only a text already read, asking nothing (a value
|
|
94
|
+
* still being typed).
|
|
95
|
+
*/
|
|
96
|
+
text: (field: {
|
|
97
|
+
valueHelpInfo?: ValueHelpInfo;
|
|
98
|
+
}, value: unknown, opts?: Pick<ValueHelpTextOptions, "peek">) => ValueText | undefined;
|
|
99
|
+
/** Loads the texts of `values` in one batched read (`loadValueHelpTexts`); never rejects. */
|
|
100
|
+
load: (info: ValueHelpInfo, values: Iterable<unknown>) => Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The texts of codes bound to a dictionary, for a Vue host — a table's or a
|
|
104
|
+
* form's root wires them once and hands them to its parts (since 0.1.207).
|
|
105
|
+
* `clientFactory`: the host's (a table's or a form's), so texts are read the
|
|
106
|
+
* way its pickers search. Call in `setup` (it reads the app's UI texts).
|
|
107
|
+
*/
|
|
108
|
+
declare function useValueHelpTexts(clientFactory?: ClientFactory): UseValueHelpTextsReturn;
|
|
109
|
+
//#endregion
|
|
110
|
+
export { getAsServedTexts as a, provideAsServedTexts as c, useUiLocaleKey as d, UseAsLocaleReturn as i, useAsLocale as l, useValueHelpTexts as n, injectAsTexts as o, AsServedTexts as r, provideAsLocale as s, UseValueHelpTextsReturn as t, useAsTexts as u };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const require_use_as_locale = require("./use-as-locale-eo7FyfaZ.cjs");
|
|
2
|
+
let vue = require("vue");
|
|
3
|
+
let _atscript_ui = require("@atscript/ui");
|
|
4
|
+
//#region src/composables/use-value-help-texts.ts
|
|
5
|
+
/**
|
|
6
|
+
* Per binding (`valueHelpKey`): bumped when its texts arrive, and every one
|
|
7
|
+
* when the cache is dropped — so only the views of that binding read again.
|
|
8
|
+
*/
|
|
9
|
+
const arrivals = /* @__PURE__ */ new Map();
|
|
10
|
+
let subscribed = false;
|
|
11
|
+
function trackArrivals(info) {
|
|
12
|
+
if (!subscribed) {
|
|
13
|
+
subscribed = true;
|
|
14
|
+
(0, _atscript_ui.onValueHelpTexts)((binding) => {
|
|
15
|
+
if (binding === void 0) for (const counter of arrivals.values()) counter.value++;
|
|
16
|
+
else {
|
|
17
|
+
const counter = arrivals.get(binding);
|
|
18
|
+
if (counter) counter.value++;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const binding = (0, _atscript_ui.valueHelpKey)(info);
|
|
23
|
+
let counter = arrivals.get(binding);
|
|
24
|
+
if (!counter) arrivals.set(binding, counter = (0, vue.shallowRef)(0));
|
|
25
|
+
counter.value;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The texts of codes bound to a dictionary, for a Vue host — a table's or a
|
|
29
|
+
* form's root wires them once and hands them to its parts (since 0.1.207).
|
|
30
|
+
* `clientFactory`: the host's (a table's or a form's), so texts are read the
|
|
31
|
+
* way its pickers search. Call in `setup` (it reads the app's UI texts).
|
|
32
|
+
*/
|
|
33
|
+
function useValueHelpTexts(clientFactory) {
|
|
34
|
+
const options = {
|
|
35
|
+
texts: require_use_as_locale.useAsTexts(),
|
|
36
|
+
clientFactory
|
|
37
|
+
};
|
|
38
|
+
const peekOptions = {
|
|
39
|
+
...options,
|
|
40
|
+
peek: true
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
text: ({ valueHelpInfo }, value, opts) => {
|
|
44
|
+
if (!valueHelpInfo) return void 0;
|
|
45
|
+
trackArrivals(valueHelpInfo);
|
|
46
|
+
return (0, _atscript_ui.valueHelpText)(valueHelpInfo, value, opts?.peek ? peekOptions : options);
|
|
47
|
+
},
|
|
48
|
+
load: (info, values) => (0, _atscript_ui.loadValueHelpTexts)(info, values, options)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
Object.defineProperty(exports, "useValueHelpTexts", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function() {
|
|
55
|
+
return useValueHelpTexts;
|
|
56
|
+
}
|
|
57
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/vue-form",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.208",
|
|
4
4
|
"description": "Type-driven form rendering for Atscript with Vue 3",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -165,27 +165,27 @@
|
|
|
165
165
|
"access": "public"
|
|
166
166
|
},
|
|
167
167
|
"dependencies": {
|
|
168
|
-
"@atscript/ui": "^0.1.
|
|
169
|
-
"@atscript/ui-fns": "^0.1.
|
|
168
|
+
"@atscript/ui": "^0.1.208",
|
|
169
|
+
"@atscript/ui-fns": "^0.1.208"
|
|
170
170
|
},
|
|
171
171
|
"devDependencies": {
|
|
172
|
-
"@atscript/core": "^0.2.
|
|
173
|
-
"@atscript/db-client": "^0.1.
|
|
174
|
-
"@atscript/typescript": "^0.2.
|
|
172
|
+
"@atscript/core": "^0.2.34",
|
|
173
|
+
"@atscript/db-client": "^0.1.212",
|
|
174
|
+
"@atscript/typescript": "^0.2.34",
|
|
175
175
|
"@tsdown/css": "^0.21.4",
|
|
176
176
|
"@vitejs/plugin-vue": "^6",
|
|
177
177
|
"@vue/test-utils": "^2",
|
|
178
178
|
"happy-dom": "^18",
|
|
179
179
|
"reka-ui": "^2.9.8",
|
|
180
|
-
"unplugin-atscript": "^0.2.
|
|
180
|
+
"unplugin-atscript": "^0.2.34",
|
|
181
181
|
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14",
|
|
182
182
|
"vue": "^3",
|
|
183
183
|
"vue-tsc": "~3.2.9",
|
|
184
184
|
"vunor": "^0.5.4"
|
|
185
185
|
},
|
|
186
186
|
"peerDependencies": {
|
|
187
|
-
"@atscript/db-client": "^0.1.
|
|
188
|
-
"@atscript/typescript": "^0.2.
|
|
187
|
+
"@atscript/db-client": "^0.1.212",
|
|
188
|
+
"@atscript/typescript": "^0.2.34",
|
|
189
189
|
"reka-ui": "^2.9.8",
|
|
190
190
|
"vue": "^3"
|
|
191
191
|
},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{use-as-optional-add-flow-DMDd4Ms0.cjs → use-as-optional-add-flow-CsUjhfkc.cjs}
RENAMED
|
File without changes
|
/package/dist/{use-as-optional-add-flow-C1Ol6KO2.mjs → use-as-optional-add-flow-WA-R6yXz.mjs}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|