@samline/forms 2.3.4 → 2.4.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/README.md +3 -3
- package/dist/browser/global.global.js +9 -2
- package/dist/browser/global.global.js.map +1 -1
- package/dist/index.cjs +9 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -272,6 +272,11 @@ var readInputType = (event) => {
|
|
|
272
272
|
const candidate = event;
|
|
273
273
|
return typeof candidate.inputType === "string" ? candidate.inputType : void 0;
|
|
274
274
|
};
|
|
275
|
+
var buildAutoInterpretedOptions = (formatOptions) => ({
|
|
276
|
+
...formatOptions ?? {},
|
|
277
|
+
interpretInputAs: "auto"
|
|
278
|
+
});
|
|
279
|
+
var shouldForceAutoInterpretation = (formatOptions) => formatOptions?.interpretInputAs === void 0;
|
|
275
280
|
var buildHandler = (visible, mirror, formatFn, formatType, formatOptions) => {
|
|
276
281
|
const handler = (event) => {
|
|
277
282
|
if (!visible.isConnected || !mirror.isConnected) return;
|
|
@@ -280,7 +285,8 @@ var buildHandler = (visible, mirror, formatFn, formatType, formatOptions) => {
|
|
|
280
285
|
if (!isVisible && !isMirror) return;
|
|
281
286
|
const rawInput = isMirror ? mirror.value : visible.value;
|
|
282
287
|
const inputType = readInputType(event);
|
|
283
|
-
const
|
|
288
|
+
const sourceOptions = isMirror && shouldForceAutoInterpretation(formatOptions) ? buildAutoInterpretedOptions(formatOptions) : formatOptions;
|
|
289
|
+
const { formatted, raw } = formatFn(rawInput, formatType, sourceOptions);
|
|
284
290
|
if (!formatted && !raw) {
|
|
285
291
|
visible.value = "";
|
|
286
292
|
if (mirror.value !== "") mirror.value = "";
|
|
@@ -365,7 +371,8 @@ var applyFormat = async (state2, helpers, config) => {
|
|
|
365
371
|
entry.handler = handler;
|
|
366
372
|
const initial = entry.visible.value;
|
|
367
373
|
if (initial !== "") {
|
|
368
|
-
const
|
|
374
|
+
const initialOptions = shouldForceAutoInterpretation(formatOptions) ? buildAutoInterpretedOptions(formatOptions) : formatOptions;
|
|
375
|
+
const { formatted, raw } = formatter.format(initial, formatType, initialOptions);
|
|
369
376
|
applyFormattedValue(entry.visible, entry.mirror, formatted, raw);
|
|
370
377
|
} else if (entry.mirrorIsOwned && entry.mirror.value !== "") {
|
|
371
378
|
entry.mirror.value = "";
|