@stonecrop/aform 0.52.0 → 0.54.0
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/aform.js +168 -60
- package/dist/aform.js.map +1 -1
- package/dist/assets/index.css +46 -34
- package/dist/src/components/form/ACurrencyInput.vue.d.ts.map +1 -1
- package/dist/src/components/form/ANumericInput.vue.d.ts +4 -2
- package/dist/src/components/form/ANumericInput.vue.d.ts.map +1 -1
- package/dist/src/components/form/AQuantityInput.vue.d.ts.map +1 -1
- package/dist/src/components/table/ATupleCellEditor.vue.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +16 -2
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/utils/currencyValue.d.ts +5 -0
- package/dist/src/utils/currencyValue.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/aform.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hasBadgeOptions, isBadgeDescriptor, lookupBadge, partsPatch, readParts, selectChoices } from "@stonecrop/schema";
|
|
2
2
|
import { TABLE_TUPLE_CURRENCY_PICKER, TABLE_TUPLE_QUANTITY_PICKER, install as install$1, isTableTuplePickerModal } from "@stonecrop/atable";
|
|
3
3
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeModels, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, reactive, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, toDisplayString, unref, useId, useModel, useTemplateRef, vModelCheckbox, vModelRadio, vModelSelect, vModelText, vShow, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers } from "vue";
|
|
4
|
-
import { currencyAmountEntryPattern, currencyInputFractionDigits, formatCurrencyAmount, formatCurrencyAmountInput, formatCurrencySymbol, fromISODate, isSemver, isSemverPrefix, parseCurrencyAmountInput } from "@stonecrop/utilities";
|
|
4
|
+
import { currencyAmountEntryPattern, currencyAmountSeparators, currencyInputFractionDigits, formatCurrencyAmount, formatCurrencyAmountInput, formatCurrencySymbol, fromISODate, isSemver, isSemverPrefix, parseCurrencyAmountInput, roundToPrecision, useArithmeticInput } from "@stonecrop/utilities";
|
|
5
5
|
import { vOnClickOutside } from "@vueuse/components";
|
|
6
6
|
import { Temporal } from "temporal-polyfill";
|
|
7
7
|
import { onClickOutside, useElementBounding, useFileDialog } from "@vueuse/core";
|
|
@@ -144,7 +144,7 @@ var _hoisted_6$14 = [
|
|
|
144
144
|
"aria-invalid",
|
|
145
145
|
"aria-describedby"
|
|
146
146
|
];
|
|
147
|
-
var _hoisted_7$
|
|
147
|
+
var _hoisted_7$8 = ["id"];
|
|
148
148
|
var ACheckbox_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
149
149
|
__name: "ACheckbox",
|
|
150
150
|
props: /*@__PURE__*/ mergeModels({
|
|
@@ -191,7 +191,7 @@ var ACheckbox_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
|
|
|
191
191
|
id: unref(errorId),
|
|
192
192
|
class: "aform_error",
|
|
193
193
|
role: "alert"
|
|
194
|
-
}, toDisplayString(errorText.value), 9, _hoisted_7$
|
|
194
|
+
}, toDisplayString(errorText.value), 9, _hoisted_7$8), [[vShow, errorText.value]])
|
|
195
195
|
], 64))]);
|
|
196
196
|
};
|
|
197
197
|
}
|
|
@@ -230,6 +230,13 @@ function asLinkValue(value) {
|
|
|
230
230
|
//#endregion
|
|
231
231
|
//#region src/utils/currencyValue.ts
|
|
232
232
|
var FLOAT_NOISE_DECIMALS = 6;
|
|
233
|
+
/**
|
|
234
|
+
* An amount worked out in a currency box, rounded to the currency's decimals as the box shows it: `10/3` in USD is
|
|
235
|
+
* `3.33`, not `3.3333333333333`.
|
|
236
|
+
*/
|
|
237
|
+
function roundToCurrency(amount, currencyId) {
|
|
238
|
+
return Number(amount.toFixed(currencyInputFractionDigits(currencyId)));
|
|
239
|
+
}
|
|
233
240
|
function normalizeBaseCurrency(options, current) {
|
|
234
241
|
const base = options.baseCurrency ?? current?.baseCurrency;
|
|
235
242
|
if (!base) return { id: "" };
|
|
@@ -439,7 +446,7 @@ var _hoisted_6$13 = [
|
|
|
439
446
|
"aria-describedby",
|
|
440
447
|
"onKeydown"
|
|
441
448
|
];
|
|
442
|
-
var _hoisted_7$
|
|
449
|
+
var _hoisted_7$7 = {
|
|
443
450
|
key: 0,
|
|
444
451
|
class: "loading autocomplete-result"
|
|
445
452
|
};
|
|
@@ -815,7 +822,7 @@ var ADropdown_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
815
822
|
"option-count": optionCount,
|
|
816
823
|
"active-index": () => dropdown.activeItemIndex
|
|
817
824
|
}, {
|
|
818
|
-
default: withCtx(() => [dropdown.loading ? (openBlock(), createElementBlock("li", _hoisted_7$
|
|
825
|
+
default: withCtx(() => [dropdown.loading ? (openBlock(), createElementBlock("li", _hoisted_7$7, "Loading results...")) : linkPicker.value ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(linkResults.value, (option, i) => {
|
|
819
826
|
return openBlock(), createElementBlock("li", {
|
|
820
827
|
id: `${listboxId}-opt-${i}`,
|
|
821
828
|
key: String(option.id),
|
|
@@ -871,10 +878,9 @@ var _hoisted_3$16 = { class: "aform_field-label" };
|
|
|
871
878
|
var _hoisted_4$16 = { class: "acurrency__row" };
|
|
872
879
|
var _hoisted_5$15 = { class: "acurrency__field acurrency__field--amount" };
|
|
873
880
|
var _hoisted_6$12 = { class: "acurrency__group" };
|
|
874
|
-
var _hoisted_7$
|
|
881
|
+
var _hoisted_7$6 = { class: "acurrency__amount-wrap" };
|
|
875
882
|
var _hoisted_8$5 = [
|
|
876
883
|
"id",
|
|
877
|
-
"value",
|
|
878
884
|
"disabled",
|
|
879
885
|
"required",
|
|
880
886
|
"aria-invalid",
|
|
@@ -882,19 +888,27 @@ var _hoisted_8$5 = [
|
|
|
882
888
|
];
|
|
883
889
|
var _hoisted_9$4 = [
|
|
884
890
|
"id",
|
|
891
|
+
"value",
|
|
885
892
|
"disabled",
|
|
886
893
|
"required",
|
|
887
894
|
"aria-invalid",
|
|
888
895
|
"aria-describedby"
|
|
889
896
|
];
|
|
890
|
-
var _hoisted_10$4 = [
|
|
891
|
-
|
|
897
|
+
var _hoisted_10$4 = [
|
|
898
|
+
"id",
|
|
899
|
+
"disabled",
|
|
900
|
+
"required",
|
|
901
|
+
"aria-invalid",
|
|
902
|
+
"aria-describedby"
|
|
903
|
+
];
|
|
904
|
+
var _hoisted_11$4 = ["for"];
|
|
905
|
+
var _hoisted_12$4 = {
|
|
892
906
|
class: "acurrency__field acurrency__field--base-currency",
|
|
893
907
|
"aria-hidden": "true"
|
|
894
908
|
};
|
|
895
|
-
var
|
|
896
|
-
var _hoisted_13$2 = ["id"];
|
|
909
|
+
var _hoisted_13$2 = ["value"];
|
|
897
910
|
var _hoisted_14$1 = ["id"];
|
|
911
|
+
var _hoisted_15 = ["id"];
|
|
898
912
|
//#endregion
|
|
899
913
|
//#region src/components/form/ACurrencyInput.vue
|
|
900
914
|
var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
|
|
@@ -988,6 +1002,18 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
988
1002
|
get: () => modelValue.value?.amount ?? null,
|
|
989
1003
|
set: (value) => modelValue.value = patchCurrencyAmount(modelValue.value, numberFromBox(value), __props.options, resolvedBaseCurrency.value)
|
|
990
1004
|
});
|
|
1005
|
+
const arithmetic = useArithmeticInput({
|
|
1006
|
+
value: () => modelValue.value?.amount,
|
|
1007
|
+
commit: (value) => modelValue.value = patchCurrencyAmount(modelValue.value, value, __props.options, resolvedBaseCurrency.value),
|
|
1008
|
+
format: (value) => amountMaskEnabled.value ? formatCurrencyAmountInput(value, selectedCurrencyId.value) : value === null ? "" : String(value),
|
|
1009
|
+
separators: () => amountMaskEnabled.value ? currencyAmountSeparators() : {},
|
|
1010
|
+
fractionDigits: () => amountMaskEnabled.value ? currencyInputFractionDigits(selectedCurrencyId.value) : void 0,
|
|
1011
|
+
round: (value) => roundToCurrency(value, selectedCurrencyId.value),
|
|
1012
|
+
selectOnFocus: true
|
|
1013
|
+
});
|
|
1014
|
+
watch(selectedCurrencyId, () => {
|
|
1015
|
+
if (!arithmetic.focused.value) arithmetic.syncText();
|
|
1016
|
+
});
|
|
991
1017
|
const currency = computed({
|
|
992
1018
|
get: () => modelValue.value?.currency ?? { id: "" },
|
|
993
1019
|
set: (value) => modelValue.value = patchCurrencyCurrency(modelValue.value, value, __props.options, resolvedBaseCurrency.value)
|
|
@@ -1117,8 +1143,15 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
1117
1143
|
"link-filter-function",
|
|
1118
1144
|
"is-async"
|
|
1119
1145
|
])]),
|
|
1120
|
-
createElementVNode("div", _hoisted_7$
|
|
1121
|
-
|
|
1146
|
+
createElementVNode("div", _hoisted_7$6, [__props.options.arithmetic !== false ? (openBlock(), createElementBlock("input", mergeProps({ key: 0 }, unref(arithmetic).inputAttrs, {
|
|
1147
|
+
id: __props.uuid,
|
|
1148
|
+
class: "acurrency__amount",
|
|
1149
|
+
disabled: __props.mode === "read",
|
|
1150
|
+
required: __props.required,
|
|
1151
|
+
"aria-invalid": unref(invalid),
|
|
1152
|
+
"aria-describedby": unref(describedBy)
|
|
1153
|
+
}), null, 16, _hoisted_8$5)) : amountMaskEnabled.value ? (openBlock(), createElementBlock("input", {
|
|
1154
|
+
key: 1,
|
|
1122
1155
|
id: __props.uuid,
|
|
1123
1156
|
value: amountText.value,
|
|
1124
1157
|
class: "acurrency__amount",
|
|
@@ -1134,8 +1167,8 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
1134
1167
|
onInput: onAmountInput,
|
|
1135
1168
|
onKeydown: onAmountKeydownMasked,
|
|
1136
1169
|
onPaste: onAmountPasteMasked
|
|
1137
|
-
}, null, 40,
|
|
1138
|
-
key:
|
|
1170
|
+
}, null, 40, _hoisted_9$4)) : withDirectives((openBlock(), createElementBlock("input", {
|
|
1171
|
+
key: 2,
|
|
1139
1172
|
id: __props.uuid,
|
|
1140
1173
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => amount.value = $event),
|
|
1141
1174
|
class: "acurrency__amount",
|
|
@@ -1146,7 +1179,7 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
1146
1179
|
"aria-describedby": unref(describedBy),
|
|
1147
1180
|
onKeydown: onAmountKeydown,
|
|
1148
1181
|
onPaste: onAmountPaste
|
|
1149
|
-
}, null, 40,
|
|
1182
|
+
}, null, 40, _hoisted_10$4)), [[
|
|
1150
1183
|
vModelText,
|
|
1151
1184
|
amount.value,
|
|
1152
1185
|
void 0,
|
|
@@ -1155,27 +1188,27 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
1155
1188
|
createElementVNode("label", {
|
|
1156
1189
|
class: "aform_field-label",
|
|
1157
1190
|
for: __props.uuid
|
|
1158
|
-
}, toDisplayString(__props.label), 9,
|
|
1159
|
-
])]), createElementVNode("div",
|
|
1191
|
+
}, toDisplayString(__props.label), 9, _hoisted_11$4)
|
|
1192
|
+
])]), createElementVNode("div", _hoisted_12$4, [createElementVNode("input", {
|
|
1160
1193
|
type: "text",
|
|
1161
1194
|
readonly: "",
|
|
1162
1195
|
tabindex: "-1",
|
|
1163
1196
|
value: baseCurrencyText.value
|
|
1164
|
-
}, null, 8,
|
|
1197
|
+
}, null, 8, _hoisted_13$2)])]),
|
|
1165
1198
|
showBase.value && !errorText.value ? (openBlock(), createElementBlock("p", {
|
|
1166
1199
|
key: 0,
|
|
1167
1200
|
id: helperId.value,
|
|
1168
1201
|
class: "acurrency__helper"
|
|
1169
|
-
}, toDisplayString(conversionHelperText.value), 9,
|
|
1202
|
+
}, toDisplayString(conversionHelperText.value), 9, _hoisted_14$1)) : createCommentVNode("", true),
|
|
1170
1203
|
withDirectives(createElementVNode("p", {
|
|
1171
1204
|
id: unref(errorId),
|
|
1172
1205
|
class: "aform_error",
|
|
1173
1206
|
role: "alert"
|
|
1174
|
-
}, toDisplayString(errorText.value), 9,
|
|
1207
|
+
}, toDisplayString(errorText.value), 9, _hoisted_15), [[vShow, errorText.value]])
|
|
1175
1208
|
], 64))]);
|
|
1176
1209
|
};
|
|
1177
1210
|
}
|
|
1178
|
-
}), [["__scopeId", "data-v-
|
|
1211
|
+
}), [["__scopeId", "data-v-c18d0c0d"]]);
|
|
1179
1212
|
//#endregion
|
|
1180
1213
|
//#region src/utils/typedDay.ts
|
|
1181
1214
|
var TYPED_DAY_FORMAT = {
|
|
@@ -1224,7 +1257,7 @@ var _hoisted_6$11 = {
|
|
|
1224
1257
|
colspan: "5",
|
|
1225
1258
|
tabindex: -1
|
|
1226
1259
|
};
|
|
1227
|
-
var _hoisted_7$
|
|
1260
|
+
var _hoisted_7$5 = { key: 0 };
|
|
1228
1261
|
var _hoisted_8$4 = {
|
|
1229
1262
|
colspan: "7",
|
|
1230
1263
|
class: "range-inputs"
|
|
@@ -1232,7 +1265,7 @@ var _hoisted_8$4 = {
|
|
|
1232
1265
|
var _hoisted_9$3 = { class: "date-input" };
|
|
1233
1266
|
var _hoisted_10$3 = ["value"];
|
|
1234
1267
|
var _hoisted_11$3 = ["value"];
|
|
1235
|
-
var _hoisted_12$
|
|
1268
|
+
var _hoisted_12$3 = { class: "days-header" };
|
|
1236
1269
|
var _hoisted_13$1 = [
|
|
1237
1270
|
"tabindex",
|
|
1238
1271
|
"aria-label",
|
|
@@ -1500,7 +1533,7 @@ var ADatePicker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
|
|
|
1500
1533
|
onClick: nextMonth
|
|
1501
1534
|
}, ">")
|
|
1502
1535
|
]),
|
|
1503
|
-
__props.selectRange ? (openBlock(), createElementBlock("tr", _hoisted_7$
|
|
1536
|
+
__props.selectRange ? (openBlock(), createElementBlock("tr", _hoisted_7$5, [createElementVNode("td", _hoisted_8$4, [createElementVNode("div", _hoisted_9$3, [
|
|
1504
1537
|
createElementVNode("input", {
|
|
1505
1538
|
ref: "start-date-input",
|
|
1506
1539
|
value: getStartDate.value,
|
|
@@ -1521,7 +1554,7 @@ var ADatePicker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
|
|
|
1521
1554
|
onKeydown: enterDate
|
|
1522
1555
|
}, null, 40, _hoisted_11$3)
|
|
1523
1556
|
])])])) : createCommentVNode("", true),
|
|
1524
|
-
createElementVNode("tr", _hoisted_12$
|
|
1557
|
+
createElementVNode("tr", _hoisted_12$3, [(openBlock(true), createElementBlock(Fragment, null, renderList(weekdayLetters.value, (letter, weekdayIndex) => {
|
|
1525
1558
|
return openBlock(), createElementBlock("td", { key: weekdayIndex }, toDisplayString(letter), 1);
|
|
1526
1559
|
}), 128))]),
|
|
1527
1560
|
(openBlock(), createElementBlock(Fragment, null, renderList(numberOfRows, (rowNo) => {
|
|
@@ -2114,7 +2147,7 @@ var _hoisted_6$9 = [
|
|
|
2114
2147
|
"value",
|
|
2115
2148
|
"disabled"
|
|
2116
2149
|
];
|
|
2117
|
-
var _hoisted_7$
|
|
2150
|
+
var _hoisted_7$4 = { class: "aform_segmented-label" };
|
|
2118
2151
|
var _hoisted_8$3 = ["id"];
|
|
2119
2152
|
//#endregion
|
|
2120
2153
|
//#region src/components/form/ASegmentedControl.vue
|
|
@@ -2257,7 +2290,7 @@ var ASegmentedControl_default = /*#__PURE__*/ _plugin_vue_export_helper_default(
|
|
|
2257
2290
|
name: groupName.value,
|
|
2258
2291
|
value: choice,
|
|
2259
2292
|
disabled: __props.mode === "read"
|
|
2260
|
-
}, null, 8, _hoisted_6$9)), [[vModelRadio, selected.value]]), createElementVNode("span", _hoisted_7$
|
|
2293
|
+
}, null, 8, _hoisted_6$9)), [[vModelRadio, selected.value]]), createElementVNode("span", _hoisted_7$4, toDisplayString(segmentLabel(choice)), 1)], 14, _hoisted_4$12);
|
|
2261
2294
|
}), 128))], 8, _hoisted_3$12),
|
|
2262
2295
|
withDirectives(createElementVNode("p", {
|
|
2263
2296
|
id: unref(errorId),
|
|
@@ -3031,7 +3064,7 @@ var _hoisted_5$6 = [
|
|
|
3031
3064
|
"onKeydown"
|
|
3032
3065
|
];
|
|
3033
3066
|
var _hoisted_6$6 = ["onKeydown"];
|
|
3034
|
-
var _hoisted_7$
|
|
3067
|
+
var _hoisted_7$3 = ["data-icon"];
|
|
3035
3068
|
var _hoisted_8$2 = {
|
|
3036
3069
|
key: 0,
|
|
3037
3070
|
d: "M6 3.5 10.5 8 6 12.5"
|
|
@@ -3045,7 +3078,7 @@ var _hoisted_11$2 = {
|
|
|
3045
3078
|
key: 0,
|
|
3046
3079
|
class: "loading autocomplete-result"
|
|
3047
3080
|
};
|
|
3048
|
-
var _hoisted_12$
|
|
3081
|
+
var _hoisted_12$2 = [
|
|
3049
3082
|
"id",
|
|
3050
3083
|
"aria-selected",
|
|
3051
3084
|
"onMousedown",
|
|
@@ -3242,7 +3275,7 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
3242
3275
|
viewBox: "1.75 2.75 12.5 10.5",
|
|
3243
3276
|
"aria-hidden": "true",
|
|
3244
3277
|
focusable: "false"
|
|
3245
|
-
}, [__props.icon === "chevron-right" ? (openBlock(), createElementBlock("path", _hoisted_8$2)) : (openBlock(), createElementBlock("path", _hoisted_9$2))], 8, _hoisted_7$
|
|
3278
|
+
}, [__props.icon === "chevron-right" ? (openBlock(), createElementBlock("path", _hoisted_8$2)) : (openBlock(), createElementBlock("path", _hoisted_9$2))], 8, _hoisted_7$3)), createElementVNode("span", _hoisted_10$2, toDisplayString(__props.icon === "chevron-right" ? "›" : "→"), 1)], 40, _hoisted_6$6)) : createCommentVNode("", true)]), __props.mode !== "read" ? (openBlock(), createBlock(ADropdownList_default, {
|
|
3246
3279
|
key: 0,
|
|
3247
3280
|
"listbox-id": listboxId,
|
|
3248
3281
|
ariaLabel: __props.ariaLabel ?? __props.label ?? "",
|
|
@@ -3262,7 +3295,7 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
|
|
|
3262
3295
|
}]),
|
|
3263
3296
|
onMousedown: withModifiers(($event) => selectOption(option), ["prevent"]),
|
|
3264
3297
|
onMouseenter: ($event) => activeIndex.value = i
|
|
3265
|
-
}, [renderSlot(_ctx.$slots, "option", { option }, () => [createTextVNode(toDisplayString(option.displayText ?? String(option.id)), 1)], true)], 42, _hoisted_12$
|
|
3298
|
+
}, [renderSlot(_ctx.$slots, "option", { option }, () => [createTextVNode(toDisplayString(option.displayText ?? String(option.id)), 1)], true)], 42, _hoisted_12$2);
|
|
3266
3299
|
}), 128))]),
|
|
3267
3300
|
_: 3
|
|
3268
3301
|
}, 8, [
|
|
@@ -3286,11 +3319,18 @@ var _hoisted_4$5 = [
|
|
|
3286
3319
|
"aria-invalid",
|
|
3287
3320
|
"aria-describedby"
|
|
3288
3321
|
];
|
|
3289
|
-
var _hoisted_5$5 = [
|
|
3290
|
-
|
|
3322
|
+
var _hoisted_5$5 = [
|
|
3323
|
+
"id",
|
|
3324
|
+
"disabled",
|
|
3325
|
+
"required",
|
|
3326
|
+
"aria-invalid",
|
|
3327
|
+
"aria-describedby"
|
|
3328
|
+
];
|
|
3329
|
+
var _hoisted_6$5 = ["for"];
|
|
3330
|
+
var _hoisted_7$2 = ["id"];
|
|
3291
3331
|
//#endregion
|
|
3292
3332
|
//#region src/components/form/ANumericInput.vue
|
|
3293
|
-
var ANumericInput_default = /* @__PURE__ */ defineComponent({
|
|
3333
|
+
var ANumericInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
|
|
3294
3334
|
__name: "ANumericInput",
|
|
3295
3335
|
props: /*@__PURE__*/ mergeModels({
|
|
3296
3336
|
schema: {},
|
|
@@ -3301,7 +3341,8 @@ var ANumericInput_default = /* @__PURE__ */ defineComponent({
|
|
|
3301
3341
|
mode: {},
|
|
3302
3342
|
uuid: {},
|
|
3303
3343
|
validation: { default: () => ({ errorMessage: "" }) },
|
|
3304
|
-
errors: {}
|
|
3344
|
+
errors: {},
|
|
3345
|
+
options: { default: () => ({}) }
|
|
3305
3346
|
}, {
|
|
3306
3347
|
"modelValue": {},
|
|
3307
3348
|
"modelModifiers": {}
|
|
@@ -3313,33 +3354,49 @@ var ANumericInput_default = /* @__PURE__ */ defineComponent({
|
|
|
3313
3354
|
const inputNumber = useModel(__props, "modelValue");
|
|
3314
3355
|
const boxNumber = computed({
|
|
3315
3356
|
get: () => inputNumber.value,
|
|
3316
|
-
set: (value) =>
|
|
3357
|
+
set: (value) => {
|
|
3358
|
+
const n = numberFromBox(value);
|
|
3359
|
+
inputNumber.value = n === null ? null : roundToPrecision(n, __props.options.precision);
|
|
3360
|
+
}
|
|
3361
|
+
});
|
|
3362
|
+
const arithmetic = useArithmeticInput({
|
|
3363
|
+
value: () => inputNumber.value,
|
|
3364
|
+
commit: (value) => inputNumber.value = value,
|
|
3365
|
+
round: (value) => roundToPrecision(value, __props.options.precision)
|
|
3317
3366
|
});
|
|
3318
3367
|
return (_ctx, _cache) => {
|
|
3319
3368
|
return openBlock(), createElementBlock("div", _hoisted_1$11, [__props.mode === "display" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("span", _hoisted_2$7, toDisplayString(inputNumber.value ?? ""), 1), createElementVNode("label", _hoisted_3$5, toDisplayString(__props.label), 1)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
3320
|
-
|
|
3369
|
+
__props.options.arithmetic !== false ? (openBlock(), createElementBlock("input", mergeProps({ key: 0 }, unref(arithmetic).inputAttrs, {
|
|
3370
|
+
id: __props.uuid,
|
|
3371
|
+
class: "aform_input-field anumeric__input",
|
|
3372
|
+
disabled: __props.mode === "read",
|
|
3373
|
+
required: __props.required,
|
|
3374
|
+
"aria-invalid": unref(invalid),
|
|
3375
|
+
"aria-describedby": unref(describedBy)
|
|
3376
|
+
}), null, 16, _hoisted_4$5)) : withDirectives((openBlock(), createElementBlock("input", {
|
|
3377
|
+
key: 1,
|
|
3321
3378
|
id: __props.uuid,
|
|
3322
3379
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => boxNumber.value = $event),
|
|
3323
|
-
class: "aform_input-field",
|
|
3380
|
+
class: "aform_input-field anumeric__input",
|
|
3324
3381
|
type: "number",
|
|
3325
3382
|
disabled: __props.mode === "read",
|
|
3326
3383
|
required: __props.required,
|
|
3327
3384
|
"aria-invalid": unref(invalid),
|
|
3328
3385
|
"aria-describedby": unref(describedBy)
|
|
3329
|
-
}, null, 8,
|
|
3386
|
+
}, null, 8, _hoisted_5$5)), [[vModelText, boxNumber.value]]),
|
|
3330
3387
|
createElementVNode("label", {
|
|
3331
3388
|
class: "aform_field-label",
|
|
3332
3389
|
for: __props.uuid
|
|
3333
|
-
}, toDisplayString(__props.label), 9,
|
|
3390
|
+
}, toDisplayString(__props.label), 9, _hoisted_6$5),
|
|
3334
3391
|
withDirectives(createElementVNode("p", {
|
|
3335
3392
|
id: unref(errorId),
|
|
3336
3393
|
class: "aform_error",
|
|
3337
3394
|
role: "alert"
|
|
3338
|
-
}, toDisplayString(errorText.value), 9,
|
|
3395
|
+
}, toDisplayString(errorText.value), 9, _hoisted_7$2), [[vShow, errorText.value]])
|
|
3339
3396
|
], 64))]);
|
|
3340
3397
|
};
|
|
3341
3398
|
}
|
|
3342
|
-
});
|
|
3399
|
+
}), [["__scopeId", "data-v-d13e377b"]]);
|
|
3343
3400
|
//#endregion
|
|
3344
3401
|
//#region src/utils/quantityValue.ts
|
|
3345
3402
|
/** What a quantity box may hold, typed or pasted: digits, one decimal point and a leading minus sign. */
|
|
@@ -3384,10 +3441,17 @@ var _hoisted_7$1 = [
|
|
|
3384
3441
|
"aria-invalid",
|
|
3385
3442
|
"aria-describedby"
|
|
3386
3443
|
];
|
|
3387
|
-
var _hoisted_8$1 =
|
|
3388
|
-
|
|
3389
|
-
|
|
3444
|
+
var _hoisted_8$1 = [
|
|
3445
|
+
"id",
|
|
3446
|
+
"disabled",
|
|
3447
|
+
"required",
|
|
3448
|
+
"aria-invalid",
|
|
3449
|
+
"aria-describedby"
|
|
3450
|
+
];
|
|
3451
|
+
var _hoisted_9$1 = { class: "aquantity__uom" };
|
|
3452
|
+
var _hoisted_10$1 = ["for"];
|
|
3390
3453
|
var _hoisted_11$1 = ["id"];
|
|
3454
|
+
var _hoisted_12$1 = ["id"];
|
|
3391
3455
|
//#endregion
|
|
3392
3456
|
//#region src/components/form/AQuantityInput.vue
|
|
3393
3457
|
var AQuantityInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
|
|
@@ -3420,6 +3484,10 @@ var AQuantityInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
3420
3484
|
get: () => modelValue.value?.qty ?? null,
|
|
3421
3485
|
set: (value) => modelValue.value = patchQuantityQty(modelValue.value, numberFromBox(value), __props.options)
|
|
3422
3486
|
});
|
|
3487
|
+
const arithmetic = useArithmeticInput({
|
|
3488
|
+
value: () => modelValue.value?.qty,
|
|
3489
|
+
commit: (value) => modelValue.value = patchQuantityQty(modelValue.value, value, __props.options)
|
|
3490
|
+
});
|
|
3423
3491
|
const uom = computed({
|
|
3424
3492
|
get: () => modelValue.value?.uom ?? "",
|
|
3425
3493
|
set: (value) => modelValue.value = patchQuantityUom(modelValue.value, value, __props.options)
|
|
@@ -3473,7 +3541,15 @@ var AQuantityInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
3473
3541
|
return (_ctx, _cache) => {
|
|
3474
3542
|
return openBlock(), createElementBlock("div", _hoisted_1$10, [__props.mode === "display" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("span", _hoisted_2$6, toDisplayString(displayText.value), 1), createElementVNode("label", _hoisted_3$4, toDisplayString(__props.label), 1)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
3475
3543
|
createElementVNode("div", _hoisted_4$4, [createElementVNode("div", _hoisted_5$4, [createElementVNode("div", _hoisted_6$4, [
|
|
3476
|
-
|
|
3544
|
+
__props.options.arithmetic !== false ? (openBlock(), createElementBlock("input", mergeProps({ key: 0 }, unref(arithmetic).inputAttrs, {
|
|
3545
|
+
id: __props.uuid,
|
|
3546
|
+
class: "aquantity__qty",
|
|
3547
|
+
disabled: __props.mode === "read",
|
|
3548
|
+
required: __props.required,
|
|
3549
|
+
"aria-invalid": unref(invalid),
|
|
3550
|
+
"aria-describedby": unref(describedBy)
|
|
3551
|
+
}), null, 16, _hoisted_7$1)) : withDirectives((openBlock(), createElementBlock("input", {
|
|
3552
|
+
key: 1,
|
|
3477
3553
|
id: __props.uuid,
|
|
3478
3554
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => qty.value = $event),
|
|
3479
3555
|
class: "aquantity__qty",
|
|
@@ -3484,13 +3560,13 @@ var AQuantityInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
3484
3560
|
"aria-describedby": unref(describedBy),
|
|
3485
3561
|
onKeydown: onQtyKeydown,
|
|
3486
3562
|
onPaste: onQtyPaste
|
|
3487
|
-
}, null, 40,
|
|
3563
|
+
}, null, 40, _hoisted_8$1)), [[
|
|
3488
3564
|
vModelText,
|
|
3489
3565
|
qty.value,
|
|
3490
3566
|
void 0,
|
|
3491
3567
|
{ number: true }
|
|
3492
3568
|
]]),
|
|
3493
|
-
createElementVNode("div",
|
|
3569
|
+
createElementVNode("div", _hoisted_9$1, [createVNode(ADropdown_default, {
|
|
3494
3570
|
modelValue: uom.value,
|
|
3495
3571
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => uom.value = $event),
|
|
3496
3572
|
embedded: "",
|
|
@@ -3512,22 +3588,22 @@ var AQuantityInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
|
|
|
3512
3588
|
createElementVNode("label", {
|
|
3513
3589
|
class: "aform_field-label",
|
|
3514
3590
|
for: __props.uuid
|
|
3515
|
-
}, toDisplayString(__props.label), 9,
|
|
3591
|
+
}, toDisplayString(__props.label), 9, _hoisted_10$1)
|
|
3516
3592
|
])])]),
|
|
3517
3593
|
showStock.value && !errorText.value ? (openBlock(), createElementBlock("p", {
|
|
3518
3594
|
key: 0,
|
|
3519
3595
|
id: helperId.value,
|
|
3520
3596
|
class: "aquantity__helper"
|
|
3521
|
-
}, toDisplayString(conversionHelperText.value), 9,
|
|
3597
|
+
}, toDisplayString(conversionHelperText.value), 9, _hoisted_11$1)) : createCommentVNode("", true),
|
|
3522
3598
|
withDirectives(createElementVNode("p", {
|
|
3523
3599
|
id: unref(errorId),
|
|
3524
3600
|
class: "aform_error",
|
|
3525
3601
|
role: "alert"
|
|
3526
|
-
}, toDisplayString(errorText.value), 9,
|
|
3602
|
+
}, toDisplayString(errorText.value), 9, _hoisted_12$1), [[vShow, errorText.value]])
|
|
3527
3603
|
], 64))]);
|
|
3528
3604
|
};
|
|
3529
3605
|
}
|
|
3530
|
-
}), [["__scopeId", "data-v-
|
|
3606
|
+
}), [["__scopeId", "data-v-72062eb6"]]);
|
|
3531
3607
|
//#endregion
|
|
3532
3608
|
//#region src/components/form/ASemverInput.vue?vue&type=script&setup=true&lang.ts
|
|
3533
3609
|
var _hoisted_1$9 = { class: "aform_form-element" };
|
|
@@ -4259,6 +4335,8 @@ var ATupleCellEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/
|
|
|
4259
4335
|
const amountMaskEnabled = computed(() => __props.category === "currency" && options.value.amountMask !== false);
|
|
4260
4336
|
const column = computed(() => __props.store.columns[__props.colIndex]);
|
|
4261
4337
|
const options = computed(() => column.value?.options ?? {});
|
|
4338
|
+
const arithmeticEnabled = computed(() => options.value.arithmetic !== false);
|
|
4339
|
+
const arithmeticSeparators = () => amountMaskEnabled.value ? currencyAmountSeparators() : {};
|
|
4262
4340
|
const cellValue = computed(() => __props.store.getCellData(__props.colIndex, __props.rowIndex));
|
|
4263
4341
|
const pickerLabel = computed(() => __props.category === "currency" ? "Choose currency" : "Choose unit");
|
|
4264
4342
|
const amountLabel = computed(() => __props.category === "currency" ? "Amount" : "Quantity");
|
|
@@ -4280,6 +4358,10 @@ var ATupleCellEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/
|
|
|
4280
4358
|
});
|
|
4281
4359
|
});
|
|
4282
4360
|
const syncDraftFromModel = () => {
|
|
4361
|
+
if (arithmeticEnabled.value) {
|
|
4362
|
+
arithmetic.syncText();
|
|
4363
|
+
return;
|
|
4364
|
+
}
|
|
4283
4365
|
const v = cellValue.value;
|
|
4284
4366
|
if (__props.category === "quantity") {
|
|
4285
4367
|
const q = v;
|
|
@@ -4306,8 +4388,7 @@ var ATupleCellEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/
|
|
|
4306
4388
|
const n = Number(text);
|
|
4307
4389
|
return Number.isFinite(n) ? n : null;
|
|
4308
4390
|
};
|
|
4309
|
-
const
|
|
4310
|
-
const parsed = parseDraftAmount();
|
|
4391
|
+
const saveNumber = (parsed) => {
|
|
4311
4392
|
if (__props.category === "quantity") {
|
|
4312
4393
|
__props.store.setCellData(__props.colIndex, __props.rowIndex, patchQuantityQty(cellValue.value, parsed, options.value));
|
|
4313
4394
|
return;
|
|
@@ -4315,7 +4396,25 @@ var ATupleCellEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/
|
|
|
4315
4396
|
const base = normalizeBaseCurrency(options.value, cellValue.value);
|
|
4316
4397
|
__props.store.setCellData(__props.colIndex, __props.rowIndex, patchCurrencyAmount(cellValue.value, parsed, options.value, base));
|
|
4317
4398
|
};
|
|
4399
|
+
const arithmetic = useArithmeticInput({
|
|
4400
|
+
value: () => __props.category === "quantity" ? cellValue.value?.qty : cellValue.value?.amount,
|
|
4401
|
+
commit: saveNumber,
|
|
4402
|
+
format: (value) => amountMaskEnabled.value ? formatCurrencyAmountInput(value, selectedCurrencyId.value) : value === null ? "" : String(value),
|
|
4403
|
+
separators: () => arithmeticSeparators(),
|
|
4404
|
+
fractionDigits: () => amountMaskEnabled.value ? currencyInputFractionDigits(selectedCurrencyId.value) : void 0,
|
|
4405
|
+
round: (value) => __props.category === "currency" ? roundToCurrency(value, selectedCurrencyId.value) : value,
|
|
4406
|
+
text: draftText,
|
|
4407
|
+
enabled: () => arithmeticEnabled.value
|
|
4408
|
+
});
|
|
4409
|
+
const commitNumber = () => {
|
|
4410
|
+
if (arithmeticEnabled.value) arithmetic.settle();
|
|
4411
|
+
else saveNumber(parseDraftAmount());
|
|
4412
|
+
};
|
|
4318
4413
|
const onInput = () => {
|
|
4414
|
+
if (arithmeticEnabled.value) {
|
|
4415
|
+
arithmetic.update(draftText.value);
|
|
4416
|
+
return;
|
|
4417
|
+
}
|
|
4319
4418
|
if (__props.category === "currency" && amountMaskEnabled.value) {
|
|
4320
4419
|
const parsed = parseCurrencyAmountInput(draftText.value);
|
|
4321
4420
|
if (draftText.value.trim() === "" || draftText.value.trim() === "-" || parsed !== null) commitNumber();
|
|
@@ -4333,8 +4432,11 @@ var ATupleCellEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/
|
|
|
4333
4432
|
return false;
|
|
4334
4433
|
};
|
|
4335
4434
|
const onInputBlur = (event) => {
|
|
4336
|
-
|
|
4337
|
-
|
|
4435
|
+
if (arithmeticEnabled.value) arithmetic.end();
|
|
4436
|
+
else {
|
|
4437
|
+
commitNumber();
|
|
4438
|
+
if (__props.category === "currency" && amountMaskEnabled.value) syncDraftFromModel();
|
|
4439
|
+
}
|
|
4338
4440
|
if (!shouldStayActiveAfterBlur(event.relatedTarget)) emit("deactivate");
|
|
4339
4441
|
};
|
|
4340
4442
|
const openPicker = () => {
|
|
@@ -4354,6 +4456,10 @@ var ATupleCellEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/
|
|
|
4354
4456
|
openPicker();
|
|
4355
4457
|
return;
|
|
4356
4458
|
}
|
|
4459
|
+
if (arithmeticEnabled.value) {
|
|
4460
|
+
arithmetic.onKeydown(event);
|
|
4461
|
+
return;
|
|
4462
|
+
}
|
|
4357
4463
|
if (__props.category === "currency" && amountMaskEnabled.value && !pickerOpenForCell.value) {
|
|
4358
4464
|
if (onCurrencyKeydownMasked(event)) return;
|
|
4359
4465
|
}
|
|
@@ -4369,11 +4475,12 @@ var ATupleCellEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/
|
|
|
4369
4475
|
});
|
|
4370
4476
|
const onPaste = (event) => {
|
|
4371
4477
|
const pattern = entryPattern.value;
|
|
4372
|
-
if (!pattern) return;
|
|
4478
|
+
if (!arithmeticEnabled.value && !pattern) return;
|
|
4373
4479
|
event.preventDefault();
|
|
4374
4480
|
const input = event.target;
|
|
4375
4481
|
const pasted = (event.clipboardData?.getData("text") ?? "").trim();
|
|
4376
|
-
|
|
4482
|
+
const next = textWith(input, pasted);
|
|
4483
|
+
if (arithmeticEnabled.value ? !arithmetic.accepts(next) : !pattern.test(next)) return;
|
|
4377
4484
|
input.setRangeText(pasted, input.selectionStart ?? 0, input.selectionEnd ?? 0, "end");
|
|
4378
4485
|
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
4379
4486
|
};
|
|
@@ -4416,6 +4523,7 @@ var ATupleCellEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/
|
|
|
4416
4523
|
return true;
|
|
4417
4524
|
};
|
|
4418
4525
|
const onInputFocus = () => {
|
|
4526
|
+
if (arithmeticEnabled.value) arithmetic.begin();
|
|
4419
4527
|
if (selectOnFocus.value) nextTick(() => {
|
|
4420
4528
|
inputRef.value?.select();
|
|
4421
4529
|
selectOnFocus.value = false;
|
|
@@ -4463,7 +4571,7 @@ var ATupleCellEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/
|
|
|
4463
4571
|
]);
|
|
4464
4572
|
};
|
|
4465
4573
|
}
|
|
4466
|
-
}), [["__scopeId", "data-v-
|
|
4574
|
+
}), [["__scopeId", "data-v-9630226d"]]);
|
|
4467
4575
|
//#endregion
|
|
4468
4576
|
//#region src/index.ts
|
|
4469
4577
|
/**
|