@atscript/vue-form 0.1.205 → 0.1.207
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-BjGc3z94.d.mts} +1 -1
- package/dist/{as-action.vue-Dtez-EWu.d.mts → as-action.vue-wGCmd-ww.d.cts} +1 -1
- package/dist/{as-array-C5lqDDLN.cjs → as-array-BCmGCZul.cjs} +10 -10
- package/dist/{as-array-Tt_4kl5r.mjs → as-array-CHVronOS.mjs} +10 -10
- package/dist/{as-array-clear-btn-Dk88CYmS.cjs → as-array-clear-btn-BolX7Wpe.cjs} +1 -1
- package/dist/{as-array-clear-btn-DGUQY_7_.mjs → as-array-clear-btn-DOBKhLCy.mjs} +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-BB22gE0u.d.cts} +1 -1
- package/dist/{as-array.vue-Dp_zd3ZM.d.cts → as-array.vue-CgYp_DSb.d.mts} +1 -1
- package/dist/{as-checkbox-D7NywgIa.cjs → as-checkbox-BKWtScvS.cjs} +7 -17
- package/dist/{as-checkbox-CCX9E19U.mjs → as-checkbox-BX5N5GHR.mjs} +7 -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-CQzeu4IP.d.mts} +1 -1
- package/dist/{as-checkbox.vue-Bf3qqcKu.d.cts → as-checkbox.vue-RTW5hwvE.d.cts} +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-BKN4DmSy.d.mts} +1 -1
- package/dist/{as-collapsible.vue-CUhn1EVX.d.mts → as-collapsible.vue-CPmozkkf.d.cts} +1 -1
- package/dist/{as-date-3haOaiAG.mjs → as-date-Bkrp2GY4.mjs} +6 -6
- package/dist/{as-date-Ubw_1-Ai.cjs → as-date-C6tT9FPz.cjs} +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-BpfWumrA.d.cts} +1 -1
- package/dist/{as-date.vue-CJQOrfj3.d.mts → as-date.vue-DJ125nVS.d.mts} +1 -1
- package/dist/{as-datetime--7bl-yGW.cjs → as-datetime-DWLW4W7O.cjs} +6 -6
- package/dist/{as-datetime-BTekpasP.mjs → as-datetime-Dt_AWrCG.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-DO3tkof1.d.cts} +1 -1
- package/dist/{as-datetime.vue-CzMz_RUy.d.mts → as-datetime.vue-DfFAaVdS.d.mts} +1 -1
- package/dist/{as-decimal-7CIE6UKX.mjs → as-decimal-BUr24VTI.mjs} +5 -5
- package/dist/{as-decimal-DWPRXsYY.cjs → as-decimal-DuWZDjbg.cjs} +5 -5
- 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-BODauGXK.d.mts} +1 -1
- package/dist/{as-decimal.vue-DyDt1ds0.d.mts → as-decimal.vue-C42_-oK9.d.cts} +1 -1
- package/dist/{as-field-jh5AWref.mjs → as-field-iQ2H3VGd.mjs} +30 -42
- package/dist/{as-field-DAClnYiP.cjs → as-field-lMMfms8d.cjs} +29 -41
- package/dist/{as-field-shell-Cu8jxZYj.cjs → as-field-shell-BPesuJKa.cjs} +6 -6
- package/dist/{as-field-shell-DPzfvPo0.mjs → as-field-shell-QMsYyJ8r.mjs} +6 -6
- 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-CQqwykWy.d.cts} +1 -1
- package/dist/{as-field-shell.vue-D-8AWUGW.d.cts → as-field-shell.vue-o7T2u4aw.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-B8d1MVTB.mjs → as-form-CuMRP5aZ.mjs} +26 -9
- package/dist/{as-form-r5pkXt5U.cjs → as-form-DE3TVGV-.cjs} +25 -8
- 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-bt-v037w.d.cts → as-form.vue-B9MZrw7V.d.cts} +16 -38
- package/dist/{as-form.vue-BSY6AhPz.d.mts → as-form.vue-DwqofFJa.d.mts} +16 -38
- package/dist/{as-input-tKw19JnF.mjs → as-input-BEP6nX82.mjs} +6 -6
- package/dist/{as-input-BTbu0eF-.cjs → as-input-BrgRxZag.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-Cl8DTJqr.d.cts} +1 -1
- package/dist/{as-input.vue-DawR7pA-.d.mts → as-input.vue-CqV91VOb.d.mts} +1 -1
- package/dist/{as-iterator-B1o83rKV.mjs → as-iterator-DbCm61j1.mjs} +1 -1
- package/dist/{as-iterator-q_w9HBHt.cjs → as-iterator-DeLt7-BO.cjs} +1 -1
- 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-CJ3iRsiL.cjs} +4 -4
- package/dist/{as-multi-select-DhOlsgdq.mjs → as-multi-select-Ca2ULklw.mjs} +4 -4
- 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-B6M_f7u-.d.cts} +1 -1
- package/dist/{as-multi-select.vue-CXC47PBk.d.cts → as-multi-select.vue-Cvvy1kMm.d.mts} +1 -1
- package/dist/{as-number-CJmX5rb1.cjs → as-number-CHXaKqtg.cjs} +5 -5
- package/dist/{as-number-CVjNUjiS.mjs → as-number-CgHRTx6P.mjs} +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-5U6oFVJC.d.cts} +1 -1
- package/dist/{as-number.vue-hJuiJJ70.d.cts → as-number.vue-BN6_1oQf.d.mts} +1 -1
- package/dist/{as-object-DY5IEc94.mjs → as-object-BCeBkKCo.mjs} +7 -7
- package/dist/{as-object-Dq5CPM3i.cjs → as-object-Babu0BIk.cjs} +7 -7
- 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-BNCOIwjS.d.mts} +1 -1
- package/dist/{as-object.vue-DVK_BKOL.d.mts → as-object.vue-BnUdIcLW.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-80Q1bZMd.d.cts} +1 -1
- package/dist/{as-paragraph.vue-B_aPmK-B.d.cts → as-paragraph.vue-Dhy9ke_Z.d.mts} +1 -1
- package/dist/{as-radio-C6PnEdjD.cjs → as-radio-BFM_CPvW.cjs} +4 -4
- package/dist/{as-radio-BW9K8h6V.mjs → as-radio-CL6Np-X5.mjs} +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-ByorW-nk.d.cts} +1 -1
- package/dist/{as-radio.vue-B_tDoVl1.d.cts → as-radio.vue-CLdvEAmZ.d.mts} +1 -1
- package/dist/{as-ref-DTsWT_zU.cjs → as-ref-CEj1RBnH.cjs} +14 -14
- package/dist/{as-ref-CXtYo-UZ.mjs → as-ref-D14yC6np.mjs} +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--ISeV6VM.d.cts} +1 -1
- package/dist/{as-ref.vue-gCsaCDQx.d.cts → as-ref.vue-DW7vsBE6.d.mts} +1 -1
- package/dist/{as-select-DOvo86Oc.cjs → as-select-B-ZeOCu5.cjs} +7 -16
- package/dist/{as-select-CbZNupL6.mjs → as-select-BME-vti2.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-BEfTkycX.d.cts} +1 -1
- package/dist/{as-select.vue-Bh7ppdg9.d.cts → as-select.vue-C45NS5Rq.d.mts} +1 -1
- package/dist/{as-time-CfnhY3Pf.cjs → as-time-CnuojSkh.cjs} +6 -6
- package/dist/{as-time-BDpnkjy8.mjs → as-time-HRZh7pdx.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--Qmcr-O0.d.cts} +1 -1
- package/dist/{as-time.vue-C_0z-HOS.d.cts → as-time.vue-0M0m0DXe.d.mts} +1 -1
- package/dist/{as-tuple-C5_dcvsH.cjs → as-tuple-XpcKK1LK.cjs} +8 -8
- package/dist/{as-tuple--wL64cCu.mjs → as-tuple-qHmf6fwJ.mjs} +8 -8
- 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-CKbx_YFz.d.mts} +1 -1
- package/dist/{as-tuple.vue-CGWun6Iw.d.mts → as-tuple.vue-Di5D2HD4.d.cts} +1 -1
- package/dist/{as-union-DAnpGBeK.mjs → as-union-Ca5o9xw2.mjs} +7 -7
- package/dist/{as-union-D3NoKN1H.cjs → as-union-CwB0ACpI.cjs} +7 -7
- 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-UnG0zG81.d.cts} +1 -1
- package/dist/{as-union.vue-DuUeLY1X.d.cts → as-union.vue-eGlHN_hp.d.mts} +1 -1
- package/dist/{as-variant-picker-CihlFH-c.mjs → as-variant-picker-CKSLKefM.mjs} +2 -2
- package/dist/{as-variant-picker-CpCxKFtT.cjs → as-variant-picker-CceIhZUk.cjs} +2 -2
- package/dist/index.cjs +29 -27
- package/dist/index.d.cts +23 -23
- package/dist/index.d.mts +25 -25
- package/dist/index.mjs +29 -28
- 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-C5Gx4ZuF.d.mts} +86 -8
- package/dist/{types-DbjorSCn.d.cts → types-D23g9Vs-.d.cts} +86 -8
- package/dist/{use-as-date-iSu5NS79.mjs → use-as-date-B2hKWXAl.mjs} +3 -3
- package/dist/{use-as-date-BigwPKEs.cjs → use-as-date-BWJbi_j2.cjs} +3 -3
- package/dist/{use-as-value-help-DE8KCbqo.mjs → use-as-value-help-B5yNO1tE.mjs} +45 -28
- package/dist/{use-as-value-help-CQMUkP1r.cjs → use-as-value-help-ZR_BvS0L.cjs} +48 -25
- 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 +10 -10
- /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-collapsible-CvBoWb0D.mjs → as-collapsible-B9KPgJyo.mjs} +0 -0
- /package/dist/{as-collapsible-CTOLQ3IK.cjs → as-collapsible-C37-3_Rp.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-model-texts-C3V56UDt.cjs → use-as-model-texts-BSFCEwAa.cjs} +0 -0
- /package/dist/{use-as-model-texts-Cpx5bHJQ.mjs → use-as-model-texts-BXSEzUWJ.mjs} +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,5 +1,5 @@
|
|
|
1
1
|
import { Component, ComputedRef, Ref } from "vue";
|
|
2
|
-
import { ClientFactory, FormDef, FormDiffOptions, FormFieldChange, FormFieldDef, FormRebaseOptions, FormUnionVariant, TFormAction, TFormEntryOptions, TOptionalMode, ValueHelpInfo, ValueHelpScope } from "@atscript/ui";
|
|
2
|
+
import { ClientFactory, DisplayValueOptions, FormDef, FormDiffOptions, FormFieldChange, FormFieldDef, FormRebaseOptions, FormUnionVariant, TFormAction, TFormEntryOptions, TOptionalMode, ValueHelpInfo, ValueHelpScope } from "@atscript/ui";
|
|
3
3
|
|
|
4
4
|
//#region src/composables/use-as-form-patch.d.ts
|
|
5
5
|
/**
|
|
@@ -162,7 +162,77 @@ interface TFormState {
|
|
|
162
162
|
freshFields: Set<symbol>;
|
|
163
163
|
register: (id: symbol, registration: TFormFieldRegistration) => void;
|
|
164
164
|
unregister: (id: symbol) => void;
|
|
165
|
+
/**
|
|
166
|
+
* The text `value` of `field` shows as where a field shows it as text — a
|
|
167
|
+
* read-only field, the reference field while not focused (since 0.1.207):
|
|
168
|
+
* `displayValue` with the field's own options (`opts.options`), its
|
|
169
|
+
* `@ui.valueLabel` sibling's text (`opts.siblingText`) and, on a field bound
|
|
170
|
+
* to a dictionary (`field.valueHelpInfo`: `@db.rel.FK` or `@ui.valueHelp`)
|
|
171
|
+
* whose binding declares a label, the dictionary row's text — read by key
|
|
172
|
+
* through the form's client factory, the code alone until it arrives; else
|
|
173
|
+
* the value as text, `""` for none. Reactive. Call it where the text shows:
|
|
174
|
+
* the dictionary is read only then. `useAsData().displayText` — also the
|
|
175
|
+
* `<AsForm>` slot's and `useAsForm`'s — reads the sibling for you; `AsField`
|
|
176
|
+
* hands its result to every control as `displayText`.
|
|
177
|
+
*/
|
|
178
|
+
displayText: (field: {
|
|
179
|
+
valueHelpInfo?: ValueHelpInfo;
|
|
180
|
+
}, value: unknown, opts?: TFormDisplayTextOptions) => string;
|
|
165
181
|
}
|
|
182
|
+
/** What `TFormState.displayText` reads besides the field and the value. Since 0.1.207. */
|
|
183
|
+
interface TFormDisplayTextOptions {
|
|
184
|
+
/**
|
|
185
|
+
* The field's own options (`@ui.form.options`, `@ui.form.fn.options`, a
|
|
186
|
+
* literal union's) — not the dictionary rows a dropdown lists: a code shows
|
|
187
|
+
* with its dictionary text, as in a table.
|
|
188
|
+
*/
|
|
189
|
+
options?: readonly TFormEntryOptions[];
|
|
190
|
+
/** The field's `@ui.valueLabel` sibling: its text and arrangement. */
|
|
191
|
+
siblingText?: DisplayValueOptions["siblingText"];
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/composables/use-as-data.d.ts
|
|
195
|
+
interface UseAsDataReturn {
|
|
196
|
+
/** Domain data (the unwrapped inner value of the form's `{ value }` container). */
|
|
197
|
+
rootData: ComputedRef<unknown>;
|
|
198
|
+
/** Read the value at an absolute dotted path inside the form. */
|
|
199
|
+
getValueAt: (path: string) => ComputedRef<unknown>;
|
|
200
|
+
/** Read a sibling field's value relative to the current `useAsPath()` prefix. */
|
|
201
|
+
siblingValue: <T = unknown>(name: string) => ComputedRef<T | undefined>;
|
|
202
|
+
/**
|
|
203
|
+
* Write the value at an absolute dotted path inside the form (missing
|
|
204
|
+
* containers are created: an array where the next segment is an index,
|
|
205
|
+
* else an object; an empty form root too). The write is a committed edit:
|
|
206
|
+
* change tracking sees it, the field at that path re-validates like one the
|
|
207
|
+
* user changed, and `AsForm` emits `change` with type `"update"`. Outside a
|
|
208
|
+
* form, a no-op.
|
|
209
|
+
*/
|
|
210
|
+
setValueAt: (path: string, value: unknown) => void;
|
|
211
|
+
/**
|
|
212
|
+
* Write a sibling field's value, relative to the current `useAsPath()`
|
|
213
|
+
* prefix — e.g. a custom picker filling the fields next to it. Same rules
|
|
214
|
+
* as `setValueAt`.
|
|
215
|
+
*/
|
|
216
|
+
setSibling: (name: string, value: unknown) => void;
|
|
217
|
+
/**
|
|
218
|
+
* The text `value` of `field` shows as (`TFormState.displayText`, since
|
|
219
|
+
* 0.1.207), with the field's own `options` and its `@ui.valueLabel` sibling
|
|
220
|
+
* read next to it — what `AsField` hands a control as `displayText`, for a
|
|
221
|
+
* custom control; the `<AsForm>` slot's and `useAsForm`'s are the same.
|
|
222
|
+
* Call it where the text shows: a dictionary text is read only then.
|
|
223
|
+
* Outside a form, `""`.
|
|
224
|
+
*/
|
|
225
|
+
displayText: (field: Pick<FormFieldDef, "path" | "prop" | "valueHelpInfo">, value: unknown, options?: readonly TFormEntryOptions[]) => string;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Reactive access to form data at any point in the `<AsForm>` tree: readers
|
|
229
|
+
* plus `setValueAt` / `setSibling` writers. Outside a form, all readers
|
|
230
|
+
* return `undefined` and the writers do nothing.
|
|
231
|
+
*
|
|
232
|
+
* Call sites get a `ComputedRef` so they can compose it directly with
|
|
233
|
+
* other reactive primitives without an extra `computed()` wrapper.
|
|
234
|
+
*/
|
|
235
|
+
declare function useAsData(): UseAsDataReturn;
|
|
166
236
|
//#endregion
|
|
167
237
|
//#region src/composables/use-as-form.d.ts
|
|
168
238
|
/**
|
|
@@ -354,6 +424,11 @@ interface UseAsFormReturn<TFormData = unknown, TFormContext = unknown> {
|
|
|
354
424
|
getPatch: (opts?: FormDiffOptions) => Record<string, unknown>; /** Build the per-field change list on demand (`[]` when tracking is off). */
|
|
355
425
|
getChanges: () => FormFieldChange[]; /** Per-field dirty predicate (`false` for every path when tracking is off). */
|
|
356
426
|
isDirtyPath: (path: string) => boolean;
|
|
427
|
+
/**
|
|
428
|
+
* The text a field's value shows as, its `@ui.valueLabel` sibling read
|
|
429
|
+
* from the form's data — `useAsData().displayText`. Since 0.1.207.
|
|
430
|
+
*/
|
|
431
|
+
displayText: UseAsDataReturn["displayText"];
|
|
357
432
|
}>;
|
|
358
433
|
/**
|
|
359
434
|
* Change-tracking handle — present ONLY when `trackChanges` is enabled.
|
|
@@ -495,13 +570,16 @@ interface TAsComponentProps<V = unknown> extends TAsBaseComponentProps {
|
|
|
495
570
|
/** Resolved value-help descriptor for FK ref fields (`@db.rel.FK` → `@db.http.path`). */
|
|
496
571
|
valueHelp?: ValueHelpInfo;
|
|
497
572
|
/**
|
|
498
|
-
* The value as
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
573
|
+
* The field's value as text, as a read-only field shows it
|
|
574
|
+
* (`TFormState.displayText`, since 0.1.207; it replaces `valueLabel`): its
|
|
575
|
+
* option's label, `Yes` / `No`, a code with its text, arranged
|
|
576
|
+
* (`Berlin (BER)`) — its `@ui.valueLabel` sibling's, else its dictionary
|
|
577
|
+
* row's (the code alone until it arrives) — else the value as text; `""`
|
|
578
|
+
* for none. Call it where the text shows — a read-only field, the
|
|
579
|
+
* reference field while it is not focused: the dictionary is read only
|
|
580
|
+
* then, never while the field is edited. Reactive.
|
|
503
581
|
*/
|
|
504
|
-
|
|
582
|
+
displayText: () => string;
|
|
505
583
|
/** Singular label for array fields (`@ui.form.label.singular`) — used in "Add <singular>" affordances. */
|
|
506
584
|
singularLabel?: string;
|
|
507
585
|
/** Stable input element id, suitable for `<label :for>`. Co-resolved with `errorId` / `descId` so a11y wiring is consistent. Always populated by AsField. */
|
|
@@ -779,4 +857,4 @@ interface AsFormExposed<TFormData = any> extends Pick<AsFormPatchHandle, "getPat
|
|
|
779
857
|
readonly changes: readonly FormFieldChange[];
|
|
780
858
|
}
|
|
781
859
|
//#endregion
|
|
782
|
-
export {
|
|
860
|
+
export { TFormState as C, useAsFormPatch as E, TFormRule as S, RebaseOntoResult as T, useAsData as _, TAsCollapsibleSlots as a, TFormFieldCallbacks as b, TAsRefSlotProps as c, TAsFormSubmitResult as d, TAsFormValue as f, UseAsDataReturn as g, useAsForm as h, TAsCollapsibleProps as i, TAsTypeComponents as l, UseAsFormReturn as m, TAsBaseComponentProps as n, TAsComponentEmits as o, UseAsFormOptions as p, TAsChangeType as r, TAsComponentProps as s, AsFormExposed as t, TAsUnionContext as u, TAsFormError as v, AsFormPatchHandle as w, TFormFieldRegistration as x, TFormDisplayTextOptions as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, ComputedRef, Ref } from "vue";
|
|
2
|
-
import { ClientFactory, FormDef, FormDiffOptions, FormFieldChange, FormFieldDef, FormRebaseOptions, FormUnionVariant, TFormAction, TFormEntryOptions, TOptionalMode, ValueHelpInfo, ValueHelpScope } from "@atscript/ui";
|
|
2
|
+
import { ClientFactory, DisplayValueOptions, FormDef, FormDiffOptions, FormFieldChange, FormFieldDef, FormRebaseOptions, FormUnionVariant, TFormAction, TFormEntryOptions, TOptionalMode, ValueHelpInfo, ValueHelpScope } from "@atscript/ui";
|
|
3
3
|
|
|
4
4
|
//#region src/composables/use-as-form-patch.d.ts
|
|
5
5
|
/**
|
|
@@ -162,7 +162,77 @@ interface TFormState {
|
|
|
162
162
|
freshFields: Set<symbol>;
|
|
163
163
|
register: (id: symbol, registration: TFormFieldRegistration) => void;
|
|
164
164
|
unregister: (id: symbol) => void;
|
|
165
|
+
/**
|
|
166
|
+
* The text `value` of `field` shows as where a field shows it as text — a
|
|
167
|
+
* read-only field, the reference field while not focused (since 0.1.207):
|
|
168
|
+
* `displayValue` with the field's own options (`opts.options`), its
|
|
169
|
+
* `@ui.valueLabel` sibling's text (`opts.siblingText`) and, on a field bound
|
|
170
|
+
* to a dictionary (`field.valueHelpInfo`: `@db.rel.FK` or `@ui.valueHelp`)
|
|
171
|
+
* whose binding declares a label, the dictionary row's text — read by key
|
|
172
|
+
* through the form's client factory, the code alone until it arrives; else
|
|
173
|
+
* the value as text, `""` for none. Reactive. Call it where the text shows:
|
|
174
|
+
* the dictionary is read only then. `useAsData().displayText` — also the
|
|
175
|
+
* `<AsForm>` slot's and `useAsForm`'s — reads the sibling for you; `AsField`
|
|
176
|
+
* hands its result to every control as `displayText`.
|
|
177
|
+
*/
|
|
178
|
+
displayText: (field: {
|
|
179
|
+
valueHelpInfo?: ValueHelpInfo;
|
|
180
|
+
}, value: unknown, opts?: TFormDisplayTextOptions) => string;
|
|
165
181
|
}
|
|
182
|
+
/** What `TFormState.displayText` reads besides the field and the value. Since 0.1.207. */
|
|
183
|
+
interface TFormDisplayTextOptions {
|
|
184
|
+
/**
|
|
185
|
+
* The field's own options (`@ui.form.options`, `@ui.form.fn.options`, a
|
|
186
|
+
* literal union's) — not the dictionary rows a dropdown lists: a code shows
|
|
187
|
+
* with its dictionary text, as in a table.
|
|
188
|
+
*/
|
|
189
|
+
options?: readonly TFormEntryOptions[];
|
|
190
|
+
/** The field's `@ui.valueLabel` sibling: its text and arrangement. */
|
|
191
|
+
siblingText?: DisplayValueOptions["siblingText"];
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/composables/use-as-data.d.ts
|
|
195
|
+
interface UseAsDataReturn {
|
|
196
|
+
/** Domain data (the unwrapped inner value of the form's `{ value }` container). */
|
|
197
|
+
rootData: ComputedRef<unknown>;
|
|
198
|
+
/** Read the value at an absolute dotted path inside the form. */
|
|
199
|
+
getValueAt: (path: string) => ComputedRef<unknown>;
|
|
200
|
+
/** Read a sibling field's value relative to the current `useAsPath()` prefix. */
|
|
201
|
+
siblingValue: <T = unknown>(name: string) => ComputedRef<T | undefined>;
|
|
202
|
+
/**
|
|
203
|
+
* Write the value at an absolute dotted path inside the form (missing
|
|
204
|
+
* containers are created: an array where the next segment is an index,
|
|
205
|
+
* else an object; an empty form root too). The write is a committed edit:
|
|
206
|
+
* change tracking sees it, the field at that path re-validates like one the
|
|
207
|
+
* user changed, and `AsForm` emits `change` with type `"update"`. Outside a
|
|
208
|
+
* form, a no-op.
|
|
209
|
+
*/
|
|
210
|
+
setValueAt: (path: string, value: unknown) => void;
|
|
211
|
+
/**
|
|
212
|
+
* Write a sibling field's value, relative to the current `useAsPath()`
|
|
213
|
+
* prefix — e.g. a custom picker filling the fields next to it. Same rules
|
|
214
|
+
* as `setValueAt`.
|
|
215
|
+
*/
|
|
216
|
+
setSibling: (name: string, value: unknown) => void;
|
|
217
|
+
/**
|
|
218
|
+
* The text `value` of `field` shows as (`TFormState.displayText`, since
|
|
219
|
+
* 0.1.207), with the field's own `options` and its `@ui.valueLabel` sibling
|
|
220
|
+
* read next to it — what `AsField` hands a control as `displayText`, for a
|
|
221
|
+
* custom control; the `<AsForm>` slot's and `useAsForm`'s are the same.
|
|
222
|
+
* Call it where the text shows: a dictionary text is read only then.
|
|
223
|
+
* Outside a form, `""`.
|
|
224
|
+
*/
|
|
225
|
+
displayText: (field: Pick<FormFieldDef, "path" | "prop" | "valueHelpInfo">, value: unknown, options?: readonly TFormEntryOptions[]) => string;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Reactive access to form data at any point in the `<AsForm>` tree: readers
|
|
229
|
+
* plus `setValueAt` / `setSibling` writers. Outside a form, all readers
|
|
230
|
+
* return `undefined` and the writers do nothing.
|
|
231
|
+
*
|
|
232
|
+
* Call sites get a `ComputedRef` so they can compose it directly with
|
|
233
|
+
* other reactive primitives without an extra `computed()` wrapper.
|
|
234
|
+
*/
|
|
235
|
+
declare function useAsData(): UseAsDataReturn;
|
|
166
236
|
//#endregion
|
|
167
237
|
//#region src/composables/use-as-form.d.ts
|
|
168
238
|
/**
|
|
@@ -354,6 +424,11 @@ interface UseAsFormReturn<TFormData = unknown, TFormContext = unknown> {
|
|
|
354
424
|
getPatch: (opts?: FormDiffOptions) => Record<string, unknown>; /** Build the per-field change list on demand (`[]` when tracking is off). */
|
|
355
425
|
getChanges: () => FormFieldChange[]; /** Per-field dirty predicate (`false` for every path when tracking is off). */
|
|
356
426
|
isDirtyPath: (path: string) => boolean;
|
|
427
|
+
/**
|
|
428
|
+
* The text a field's value shows as, its `@ui.valueLabel` sibling read
|
|
429
|
+
* from the form's data — `useAsData().displayText`. Since 0.1.207.
|
|
430
|
+
*/
|
|
431
|
+
displayText: UseAsDataReturn["displayText"];
|
|
357
432
|
}>;
|
|
358
433
|
/**
|
|
359
434
|
* Change-tracking handle — present ONLY when `trackChanges` is enabled.
|
|
@@ -495,13 +570,16 @@ interface TAsComponentProps<V = unknown> extends TAsBaseComponentProps {
|
|
|
495
570
|
/** Resolved value-help descriptor for FK ref fields (`@db.rel.FK` → `@db.http.path`). */
|
|
496
571
|
valueHelp?: ValueHelpInfo;
|
|
497
572
|
/**
|
|
498
|
-
* The value as
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
573
|
+
* The field's value as text, as a read-only field shows it
|
|
574
|
+
* (`TFormState.displayText`, since 0.1.207; it replaces `valueLabel`): its
|
|
575
|
+
* option's label, `Yes` / `No`, a code with its text, arranged
|
|
576
|
+
* (`Berlin (BER)`) — its `@ui.valueLabel` sibling's, else its dictionary
|
|
577
|
+
* row's (the code alone until it arrives) — else the value as text; `""`
|
|
578
|
+
* for none. Call it where the text shows — a read-only field, the
|
|
579
|
+
* reference field while it is not focused: the dictionary is read only
|
|
580
|
+
* then, never while the field is edited. Reactive.
|
|
503
581
|
*/
|
|
504
|
-
|
|
582
|
+
displayText: () => string;
|
|
505
583
|
/** Singular label for array fields (`@ui.form.label.singular`) — used in "Add <singular>" affordances. */
|
|
506
584
|
singularLabel?: string;
|
|
507
585
|
/** Stable input element id, suitable for `<label :for>`. Co-resolved with `errorId` / `descId` so a11y wiring is consistent. Always populated by AsField. */
|
|
@@ -779,4 +857,4 @@ interface AsFormExposed<TFormData = any> extends Pick<AsFormPatchHandle, "getPat
|
|
|
779
857
|
readonly changes: readonly FormFieldChange[];
|
|
780
858
|
}
|
|
781
859
|
//#endregion
|
|
782
|
-
export {
|
|
860
|
+
export { TFormState as C, useAsFormPatch as E, TFormRule as S, RebaseOntoResult as T, useAsData as _, TAsCollapsibleSlots as a, TFormFieldCallbacks as b, TAsRefSlotProps as c, TAsFormSubmitResult as d, TAsFormValue as f, UseAsDataReturn as g, useAsForm as h, TAsCollapsibleProps as i, TAsTypeComponents as l, UseAsFormReturn as m, TAsBaseComponentProps as n, TAsComponentEmits as o, UseAsFormOptions as p, TAsChangeType as r, TAsComponentProps as s, AsFormExposed as t, TAsUnionContext as u, TAsFormError as v, AsFormPatchHandle as w, TFormFieldRegistration as x, TFormDisplayTextOptions as y };
|
|
@@ -153,9 +153,9 @@ var as_date_control_default = /* @__PURE__ */ defineComponent({
|
|
|
153
153
|
type: Object,
|
|
154
154
|
required: false
|
|
155
155
|
},
|
|
156
|
-
|
|
157
|
-
type:
|
|
158
|
-
required:
|
|
156
|
+
displayText: {
|
|
157
|
+
type: Function,
|
|
158
|
+
required: true
|
|
159
159
|
},
|
|
160
160
|
singularLabel: {
|
|
161
161
|
type: String,
|
|
@@ -153,9 +153,9 @@ var as_date_control_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
153
153
|
type: Object,
|
|
154
154
|
required: false
|
|
155
155
|
},
|
|
156
|
-
|
|
157
|
-
type:
|
|
158
|
-
required:
|
|
156
|
+
displayText: {
|
|
157
|
+
type: Function,
|
|
158
|
+
required: true
|
|
159
159
|
},
|
|
160
160
|
singularLabel: {
|
|
161
161
|
type: String,
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
import { a as CHANGE_HANDLER_KEY, b as ROOT_DATA_KEY, f as FORM_OPTIONAL_KEY, y as PATH_PREFIX_KEY } from "./use-form-context-0FtVVTvf.mjs";
|
|
1
|
+
import { a as CHANGE_HANDLER_KEY, b as ROOT_DATA_KEY, f as FORM_OPTIONAL_KEY, m as FORM_STATE_KEY, y as PATH_PREFIX_KEY } from "./use-form-context-0FtVVTvf.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` and the form's
|
|
10
|
+
* 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);
|
|
8
27
|
/**
|
|
@@ -15,6 +34,7 @@ const EMPTY_DATA = computed(() => void 0);
|
|
|
15
34
|
*/
|
|
16
35
|
function useAsData() {
|
|
17
36
|
const wrapped = inject(ROOT_DATA_KEY, EMPTY_DATA);
|
|
37
|
+
const formState = inject(FORM_STATE_KEY, void 0);
|
|
18
38
|
const pathPrefix = inject(PATH_PREFIX_KEY, EMPTY_PATH);
|
|
19
39
|
const handleChange = inject(CHANGE_HANDLER_KEY, void 0);
|
|
20
40
|
const rootData = computed(() => {
|
|
@@ -27,12 +47,13 @@ function useAsData() {
|
|
|
27
47
|
return getByPath(w, path);
|
|
28
48
|
});
|
|
29
49
|
}
|
|
50
|
+
/** The value of the field `name` below this position. */
|
|
51
|
+
function readSibling(name) {
|
|
52
|
+
const w = wrapped.value;
|
|
53
|
+
return w ? getByPath(w, joinPath(pathPrefix.value, name)) : void 0;
|
|
54
|
+
}
|
|
30
55
|
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
|
-
});
|
|
56
|
+
return computed(() => readSibling(name));
|
|
36
57
|
}
|
|
37
58
|
function setValueAt(path, value) {
|
|
38
59
|
const w = wrapped.value;
|
|
@@ -48,7 +69,8 @@ function useAsData() {
|
|
|
48
69
|
getValueAt,
|
|
49
70
|
siblingValue,
|
|
50
71
|
setValueAt,
|
|
51
|
-
setSibling
|
|
72
|
+
setSibling,
|
|
73
|
+
displayText: formState ? fieldDisplayText(formState, readSibling) : () => ""
|
|
52
74
|
};
|
|
53
75
|
}
|
|
54
76
|
//#endregion
|
|
@@ -78,17 +100,17 @@ function useAsValueHelp(options) {
|
|
|
78
100
|
const scoped = !!getCurrentScope();
|
|
79
101
|
const browser = typeof window !== "undefined";
|
|
80
102
|
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
|
-
*/
|
|
103
|
+
let source;
|
|
104
|
+
/** Binds the dictionary in the app's current locale — its entry held while mounted. */
|
|
86
105
|
function bindEntry() {
|
|
87
|
-
const
|
|
106
|
+
const next = valueHelpSource(info, {
|
|
107
|
+
texts,
|
|
108
|
+
clientFactory: injectedFactory
|
|
109
|
+
});
|
|
88
110
|
const previous = release;
|
|
89
|
-
release = scoped ? retainMetaEntry(entry) : void 0;
|
|
111
|
+
release = scoped ? retainMetaEntry(next.entry) : void 0;
|
|
90
112
|
previous?.();
|
|
91
|
-
|
|
113
|
+
source = next;
|
|
92
114
|
}
|
|
93
115
|
if (browser) bindEntry();
|
|
94
116
|
if (scoped) onScopeDispose(() => release?.());
|
|
@@ -97,7 +119,6 @@ function useAsValueHelp(options) {
|
|
|
97
119
|
const searchText = ref("");
|
|
98
120
|
const results = shallowRef([]);
|
|
99
121
|
const searching = ref(false);
|
|
100
|
-
const labelIsFkValue = computed(() => !!resolved.value && info.targetField === resolved.value.labelField);
|
|
101
122
|
let debounceTimer;
|
|
102
123
|
let kickoffPromise;
|
|
103
124
|
/** Bumped per kickoff: a superseded one (a previous locale's) never lands. */
|
|
@@ -111,10 +132,8 @@ function useAsValueHelp(options) {
|
|
|
111
132
|
async function kickoff() {
|
|
112
133
|
if (kickoffPromise) return kickoffPromise;
|
|
113
134
|
const mine = ++kickoffSeq;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
clientFactory: injectedFactory
|
|
117
|
-
}).then((r) => {
|
|
135
|
+
if (!source) bindEntry();
|
|
136
|
+
kickoffPromise = source.resolve().then((r) => {
|
|
118
137
|
if (mine !== kickoffSeq) return;
|
|
119
138
|
resolved.value = r;
|
|
120
139
|
status.value = "ready";
|
|
@@ -140,19 +159,18 @@ function useAsValueHelp(options) {
|
|
|
140
159
|
}, DEBOUNCE_MS);
|
|
141
160
|
}
|
|
142
161
|
async function doSearch(text) {
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
162
|
+
const s = source;
|
|
163
|
+
if (!resolved.value || !s) return;
|
|
145
164
|
if (text === lastSearchedText) return;
|
|
146
165
|
lastSearchedText = text;
|
|
147
166
|
const mine = ++searchSeq;
|
|
148
167
|
searching.value = true;
|
|
149
168
|
try {
|
|
150
|
-
const result = await
|
|
169
|
+
const result = await s.search({
|
|
151
170
|
text: text || void 0,
|
|
152
171
|
mode: "form",
|
|
153
172
|
limit,
|
|
154
|
-
filter: scope.value.filter
|
|
155
|
-
info
|
|
173
|
+
filter: scope.value.filter
|
|
156
174
|
});
|
|
157
175
|
if (mine === searchSeq) results.value = result.items;
|
|
158
176
|
} catch {
|
|
@@ -202,7 +220,6 @@ function useAsValueHelp(options) {
|
|
|
202
220
|
searchText,
|
|
203
221
|
results,
|
|
204
222
|
searching,
|
|
205
|
-
labelIsFkValue,
|
|
206
223
|
kickoff,
|
|
207
224
|
selectItem,
|
|
208
225
|
clear,
|
|
@@ -211,4 +228,4 @@ function useAsValueHelp(options) {
|
|
|
211
228
|
};
|
|
212
229
|
}
|
|
213
230
|
//#endregion
|
|
214
|
-
export { useAsValueHelp as n,
|
|
231
|
+
export { useAsData as i, useAsValueHelp as n, fieldDisplayText as r, CLIENT_FACTORY_KEY as t };
|
|
@@ -3,6 +3,25 @@ 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` and the form's
|
|
10
|
+
* 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);
|
|
8
27
|
/**
|
|
@@ -15,6 +34,7 @@ const EMPTY_DATA = (0, vue.computed)(() => void 0);
|
|
|
15
34
|
*/
|
|
16
35
|
function useAsData() {
|
|
17
36
|
const wrapped = (0, vue.inject)(require_use_form_context.ROOT_DATA_KEY, EMPTY_DATA);
|
|
37
|
+
const formState = (0, vue.inject)(require_use_form_context.FORM_STATE_KEY, void 0);
|
|
18
38
|
const pathPrefix = (0, vue.inject)(require_use_form_context.PATH_PREFIX_KEY, EMPTY_PATH);
|
|
19
39
|
const handleChange = (0, vue.inject)(require_use_form_context.CHANGE_HANDLER_KEY, void 0);
|
|
20
40
|
const rootData = (0, vue.computed)(() => {
|
|
@@ -27,12 +47,13 @@ function useAsData() {
|
|
|
27
47
|
return (0, _atscript_ui.getByPath)(w, path);
|
|
28
48
|
});
|
|
29
49
|
}
|
|
50
|
+
/** The value of the field `name` below this position. */
|
|
51
|
+
function readSibling(name) {
|
|
52
|
+
const w = wrapped.value;
|
|
53
|
+
return w ? (0, _atscript_ui.getByPath)(w, (0, _atscript_ui.joinPath)(pathPrefix.value, name)) : void 0;
|
|
54
|
+
}
|
|
30
55
|
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
|
-
});
|
|
56
|
+
return (0, vue.computed)(() => readSibling(name));
|
|
36
57
|
}
|
|
37
58
|
function setValueAt(path, value) {
|
|
38
59
|
const w = wrapped.value;
|
|
@@ -48,7 +69,8 @@ function useAsData() {
|
|
|
48
69
|
getValueAt,
|
|
49
70
|
siblingValue,
|
|
50
71
|
setValueAt,
|
|
51
|
-
setSibling
|
|
72
|
+
setSibling,
|
|
73
|
+
displayText: formState ? fieldDisplayText(formState, readSibling) : () => ""
|
|
52
74
|
};
|
|
53
75
|
}
|
|
54
76
|
//#endregion
|
|
@@ -78,17 +100,17 @@ function useAsValueHelp(options) {
|
|
|
78
100
|
const scoped = !!(0, vue.getCurrentScope)();
|
|
79
101
|
const browser = typeof window !== "undefined";
|
|
80
102
|
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
|
-
*/
|
|
103
|
+
let source;
|
|
104
|
+
/** Binds the dictionary in the app's current locale — its entry held while mounted. */
|
|
86
105
|
function bindEntry() {
|
|
87
|
-
const
|
|
106
|
+
const next = (0, _atscript_ui.valueHelpSource)(info, {
|
|
107
|
+
texts,
|
|
108
|
+
clientFactory: injectedFactory
|
|
109
|
+
});
|
|
88
110
|
const previous = release;
|
|
89
|
-
release = scoped ? (0, _atscript_ui.retainMetaEntry)(entry) : void 0;
|
|
111
|
+
release = scoped ? (0, _atscript_ui.retainMetaEntry)(next.entry) : void 0;
|
|
90
112
|
previous?.();
|
|
91
|
-
|
|
113
|
+
source = next;
|
|
92
114
|
}
|
|
93
115
|
if (browser) bindEntry();
|
|
94
116
|
if (scoped) (0, vue.onScopeDispose)(() => release?.());
|
|
@@ -97,7 +119,6 @@ function useAsValueHelp(options) {
|
|
|
97
119
|
const searchText = (0, vue.ref)("");
|
|
98
120
|
const results = (0, vue.shallowRef)([]);
|
|
99
121
|
const searching = (0, vue.ref)(false);
|
|
100
|
-
const labelIsFkValue = (0, vue.computed)(() => !!resolved.value && info.targetField === resolved.value.labelField);
|
|
101
122
|
let debounceTimer;
|
|
102
123
|
let kickoffPromise;
|
|
103
124
|
/** Bumped per kickoff: a superseded one (a previous locale's) never lands. */
|
|
@@ -111,10 +132,8 @@ function useAsValueHelp(options) {
|
|
|
111
132
|
async function kickoff() {
|
|
112
133
|
if (kickoffPromise) return kickoffPromise;
|
|
113
134
|
const mine = ++kickoffSeq;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
clientFactory: injectedFactory
|
|
117
|
-
}).then((r) => {
|
|
135
|
+
if (!source) bindEntry();
|
|
136
|
+
kickoffPromise = source.resolve().then((r) => {
|
|
118
137
|
if (mine !== kickoffSeq) return;
|
|
119
138
|
resolved.value = r;
|
|
120
139
|
status.value = "ready";
|
|
@@ -140,19 +159,18 @@ function useAsValueHelp(options) {
|
|
|
140
159
|
}, DEBOUNCE_MS);
|
|
141
160
|
}
|
|
142
161
|
async function doSearch(text) {
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
162
|
+
const s = source;
|
|
163
|
+
if (!resolved.value || !s) return;
|
|
145
164
|
if (text === lastSearchedText) return;
|
|
146
165
|
lastSearchedText = text;
|
|
147
166
|
const mine = ++searchSeq;
|
|
148
167
|
searching.value = true;
|
|
149
168
|
try {
|
|
150
|
-
const result = await
|
|
169
|
+
const result = await s.search({
|
|
151
170
|
text: text || void 0,
|
|
152
171
|
mode: "form",
|
|
153
172
|
limit,
|
|
154
|
-
filter: scope.value.filter
|
|
155
|
-
info
|
|
173
|
+
filter: scope.value.filter
|
|
156
174
|
});
|
|
157
175
|
if (mine === searchSeq) results.value = result.items;
|
|
158
176
|
} catch {
|
|
@@ -202,7 +220,6 @@ function useAsValueHelp(options) {
|
|
|
202
220
|
searchText,
|
|
203
221
|
results,
|
|
204
222
|
searching,
|
|
205
|
-
labelIsFkValue,
|
|
206
223
|
kickoff,
|
|
207
224
|
selectItem,
|
|
208
225
|
clear,
|
|
@@ -217,6 +234,12 @@ Object.defineProperty(exports, "CLIENT_FACTORY_KEY", {
|
|
|
217
234
|
return CLIENT_FACTORY_KEY;
|
|
218
235
|
}
|
|
219
236
|
});
|
|
237
|
+
Object.defineProperty(exports, "fieldDisplayText", {
|
|
238
|
+
enumerable: true,
|
|
239
|
+
get: function() {
|
|
240
|
+
return fieldDisplayText;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
220
243
|
Object.defineProperty(exports, "useAsData", {
|
|
221
244
|
enumerable: true,
|
|
222
245
|
get: function() {
|
|
@@ -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 };
|