@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,9 +1,14 @@
|
|
|
1
1
|
const require_use_as_locale = require("./use-as-locale-eo7FyfaZ.cjs");
|
|
2
|
-
const require__shape = require("./_shape-
|
|
3
|
-
const require_as_field_shell = require("./as-field-shell-
|
|
2
|
+
const require__shape = require("./_shape-DPDZTV_T.cjs");
|
|
3
|
+
const require_as_field_shell = require("./as-field-shell-CMq52Z6e.cjs");
|
|
4
4
|
let vue = require("vue");
|
|
5
5
|
let _atscript_ui = require("@atscript/ui");
|
|
6
6
|
//#region src/composables/use-as-decimal.ts
|
|
7
|
+
/** The fraction digits `v` holds, trailing zeros aside (`"0.1230"` → 3). */
|
|
8
|
+
function heldDigits(v) {
|
|
9
|
+
const text = typeof v === "number" ? String(v) : v ?? "";
|
|
10
|
+
return /\.(\d*?)0*$/.exec(text)?.[1].length ?? 0;
|
|
11
|
+
}
|
|
7
12
|
/**
|
|
8
13
|
* Reactive composable for decimal-typed inputs (the `AsDecimal` SFC and
|
|
9
14
|
* customer swaps built against `TAsComponentProps`).
|
|
@@ -14,9 +19,11 @@ let _atscript_ui = require("@atscript/ui");
|
|
|
14
19
|
*
|
|
15
20
|
* Storage shape is preserved on commit — string `modelValue` commits a
|
|
16
21
|
* string padded to `storageScale`; number `modelValue` commits a number.
|
|
17
|
-
* A
|
|
18
|
-
*
|
|
19
|
-
*
|
|
22
|
+
* A stored digit is never cut: a value with more digits than `scale` shows
|
|
23
|
+
* and edits with them, up to `storageScale` when one is set (as a table cell
|
|
24
|
+
* shows it). A `scale` that shrinks below the model's precision while the
|
|
25
|
+
* model stays (a switch to a currency with fewer digits) re-rounds +
|
|
26
|
+
* re-commits it; a new model arriving with it (a load) is kept.
|
|
20
27
|
*/
|
|
21
28
|
function useAsDecimal(opts) {
|
|
22
29
|
const localeCtx = require_use_as_locale.useAsLocale();
|
|
@@ -25,20 +32,9 @@ function useAsDecimal(opts) {
|
|
|
25
32
|
if (explicit) return explicit;
|
|
26
33
|
return localeCtx.locale.value;
|
|
27
34
|
});
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const storage = opts.storageScale?.();
|
|
32
|
-
if (storage !== void 0) return storage;
|
|
33
|
-
return 2;
|
|
34
|
-
});
|
|
35
|
-
const storageScale = (0, vue.computed)(() => {
|
|
36
|
-
const storage = opts.storageScale?.();
|
|
37
|
-
if (storage !== void 0) return storage;
|
|
38
|
-
const s = opts.scale?.();
|
|
39
|
-
if (s !== void 0) return s;
|
|
40
|
-
return 2;
|
|
41
|
-
});
|
|
35
|
+
const declaredScale = (0, vue.computed)(() => opts.scale?.() ?? opts.storageScale?.() ?? 2);
|
|
36
|
+
const scale = (0, vue.computed)(() => Math.max(declaredScale.value, Math.min(heldDigits(opts.modelValue()), opts.storageScale?.() ?? 100)));
|
|
37
|
+
const storageScale = (0, vue.computed)(() => opts.storageScale?.() ?? scale.value);
|
|
42
38
|
const decimalSeparator = (0, vue.computed)(() => (0, _atscript_ui.getDecimalSeparator)(locale.value));
|
|
43
39
|
const thousandsSeparator = (0, vue.computed)(() => (0, _atscript_ui.getThousandsSeparator)(locale.value));
|
|
44
40
|
const rawValue = (0, vue.computed)(() => {
|
|
@@ -98,17 +94,15 @@ function useAsDecimal(opts) {
|
|
|
98
94
|
decimal: decDigits
|
|
99
95
|
}), scale.value));
|
|
100
96
|
}
|
|
101
|
-
(0, vue.watch)(
|
|
102
|
-
if (
|
|
103
|
-
if (newScale >= oldScale) return;
|
|
104
|
-
const v = opts.modelValue();
|
|
97
|
+
(0, vue.watch)([declaredScale, () => opts.modelValue()], ([newScale, v], [oldScale, oldV]) => {
|
|
98
|
+
if (v !== oldV || newScale >= oldScale) return;
|
|
105
99
|
if (v === null || v === void 0) return;
|
|
106
100
|
const s = typeof v === "number" ? Number.isFinite(v) ? String(v) : "" : v;
|
|
107
101
|
if (s === "") return;
|
|
108
102
|
if ((0, _atscript_ui.splitDecimalString)(s).decimal.length <= newScale) return;
|
|
109
|
-
const shaped = require__shape.preserveShape(v, (0, _atscript_ui.enforceScale)((0, _atscript_ui.enforceScale)(s, newScale), storageScale
|
|
103
|
+
const shaped = require__shape.preserveShape(v, (0, _atscript_ui.enforceScale)((0, _atscript_ui.enforceScale)(s, newScale), opts.storageScale?.() ?? newScale));
|
|
110
104
|
opts.onCommit(shaped);
|
|
111
|
-
}
|
|
105
|
+
});
|
|
112
106
|
return {
|
|
113
107
|
scale,
|
|
114
108
|
storageScale,
|
|
@@ -545,9 +539,9 @@ var as_decimal_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
545
539
|
type: Object,
|
|
546
540
|
required: false
|
|
547
541
|
},
|
|
548
|
-
|
|
549
|
-
type:
|
|
550
|
-
required:
|
|
542
|
+
displayText: {
|
|
543
|
+
type: Function,
|
|
544
|
+
required: true
|
|
551
545
|
},
|
|
552
546
|
singularLabel: {
|
|
553
547
|
type: String,
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { a as useAsLocale, o as useAsTexts } from "./use-as-locale-CznDr-7i.mjs";
|
|
2
|
-
import { n as preserveShape } from "./_shape-
|
|
3
|
-
import { t as as_field_shell_default } from "./as-field-shell-
|
|
2
|
+
import { n as preserveShape } from "./_shape-CnW2sBRs.mjs";
|
|
3
|
+
import { t as as_field_shell_default } from "./as-field-shell-DXbAJupk.mjs";
|
|
4
4
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, nextTick, normalizeClass, normalizeProps, openBlock, ref, toDisplayString, unref, watch, withCtx } from "vue";
|
|
5
5
|
import { enforceScale, formatDecimalForDisplay, getDecimalSeparator, getThousandsSeparator, groupInteger, joinDecimalString, parseDecimalInput, splitDecimalString } from "@atscript/ui";
|
|
6
6
|
//#region src/composables/use-as-decimal.ts
|
|
7
|
+
/** The fraction digits `v` holds, trailing zeros aside (`"0.1230"` → 3). */
|
|
8
|
+
function heldDigits(v) {
|
|
9
|
+
const text = typeof v === "number" ? String(v) : v ?? "";
|
|
10
|
+
return /\.(\d*?)0*$/.exec(text)?.[1].length ?? 0;
|
|
11
|
+
}
|
|
7
12
|
/**
|
|
8
13
|
* Reactive composable for decimal-typed inputs (the `AsDecimal` SFC and
|
|
9
14
|
* customer swaps built against `TAsComponentProps`).
|
|
@@ -14,9 +19,11 @@ import { enforceScale, formatDecimalForDisplay, getDecimalSeparator, getThousand
|
|
|
14
19
|
*
|
|
15
20
|
* Storage shape is preserved on commit — string `modelValue` commits a
|
|
16
21
|
* string padded to `storageScale`; number `modelValue` commits a number.
|
|
17
|
-
* A
|
|
18
|
-
*
|
|
19
|
-
*
|
|
22
|
+
* A stored digit is never cut: a value with more digits than `scale` shows
|
|
23
|
+
* and edits with them, up to `storageScale` when one is set (as a table cell
|
|
24
|
+
* shows it). A `scale` that shrinks below the model's precision while the
|
|
25
|
+
* model stays (a switch to a currency with fewer digits) re-rounds +
|
|
26
|
+
* re-commits it; a new model arriving with it (a load) is kept.
|
|
20
27
|
*/
|
|
21
28
|
function useAsDecimal(opts) {
|
|
22
29
|
const localeCtx = useAsLocale();
|
|
@@ -25,20 +32,9 @@ function useAsDecimal(opts) {
|
|
|
25
32
|
if (explicit) return explicit;
|
|
26
33
|
return localeCtx.locale.value;
|
|
27
34
|
});
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const storage = opts.storageScale?.();
|
|
32
|
-
if (storage !== void 0) return storage;
|
|
33
|
-
return 2;
|
|
34
|
-
});
|
|
35
|
-
const storageScale = computed(() => {
|
|
36
|
-
const storage = opts.storageScale?.();
|
|
37
|
-
if (storage !== void 0) return storage;
|
|
38
|
-
const s = opts.scale?.();
|
|
39
|
-
if (s !== void 0) return s;
|
|
40
|
-
return 2;
|
|
41
|
-
});
|
|
35
|
+
const declaredScale = computed(() => opts.scale?.() ?? opts.storageScale?.() ?? 2);
|
|
36
|
+
const scale = computed(() => Math.max(declaredScale.value, Math.min(heldDigits(opts.modelValue()), opts.storageScale?.() ?? 100)));
|
|
37
|
+
const storageScale = computed(() => opts.storageScale?.() ?? scale.value);
|
|
42
38
|
const decimalSeparator = computed(() => getDecimalSeparator(locale.value));
|
|
43
39
|
const thousandsSeparator = computed(() => getThousandsSeparator(locale.value));
|
|
44
40
|
const rawValue = computed(() => {
|
|
@@ -98,17 +94,15 @@ function useAsDecimal(opts) {
|
|
|
98
94
|
decimal: decDigits
|
|
99
95
|
}), scale.value));
|
|
100
96
|
}
|
|
101
|
-
watch(
|
|
102
|
-
if (
|
|
103
|
-
if (newScale >= oldScale) return;
|
|
104
|
-
const v = opts.modelValue();
|
|
97
|
+
watch([declaredScale, () => opts.modelValue()], ([newScale, v], [oldScale, oldV]) => {
|
|
98
|
+
if (v !== oldV || newScale >= oldScale) return;
|
|
105
99
|
if (v === null || v === void 0) return;
|
|
106
100
|
const s = typeof v === "number" ? Number.isFinite(v) ? String(v) : "" : v;
|
|
107
101
|
if (s === "") return;
|
|
108
102
|
if (splitDecimalString(s).decimal.length <= newScale) return;
|
|
109
|
-
const shaped = preserveShape(v, enforceScale(enforceScale(s, newScale), storageScale
|
|
103
|
+
const shaped = preserveShape(v, enforceScale(enforceScale(s, newScale), opts.storageScale?.() ?? newScale));
|
|
110
104
|
opts.onCommit(shaped);
|
|
111
|
-
}
|
|
105
|
+
});
|
|
112
106
|
return {
|
|
113
107
|
scale,
|
|
114
108
|
storageScale,
|
|
@@ -545,9 +539,9 @@ var as_decimal_default = /* @__PURE__ */ defineComponent({
|
|
|
545
539
|
type: Object,
|
|
546
540
|
required: false
|
|
547
541
|
},
|
|
548
|
-
|
|
549
|
-
type:
|
|
550
|
-
required:
|
|
542
|
+
displayText: {
|
|
543
|
+
type: Function,
|
|
544
|
+
required: true
|
|
551
545
|
},
|
|
552
546
|
singularLabel: {
|
|
553
547
|
type: String,
|
package/dist/as-decimal.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const require_as_decimal = require("./as-decimal-
|
|
1
|
+
const require_as_decimal = require("./as-decimal-48M_h9Sl.cjs");
|
|
2
2
|
module.exports = require_as_decimal.as_decimal_default;
|
package/dist/as-decimal.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as _default } from "./as-decimal.vue-
|
|
1
|
+
import { t as _default } from "./as-decimal.vue-BvvG5aIL.cjs";
|
|
2
2
|
export = _default;
|
package/dist/as-decimal.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as _default } from "./as-decimal.vue-
|
|
1
|
+
import { t as _default } from "./as-decimal.vue-BZ2imea4.mjs";
|
|
2
2
|
export { _default as default };
|
package/dist/as-decimal.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as as_decimal_default } from "./as-decimal-
|
|
1
|
+
import { t as as_decimal_default } from "./as-decimal-CsAJlvie.mjs";
|
|
2
2
|
export { as_decimal_default as default };
|