@samline/forms 2.7.0 → 2.7.1

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 CHANGED
@@ -42,10 +42,10 @@ Requires Node 20+ when bundling. Runtime target is ES2020.
42
42
  Use the browser build when you do not have a bundler and need to run the package directly in HTML, Shopify, WordPress, or any traditional template.
43
43
 
44
44
  ```html
45
- <script src="https://unpkg.com/@samline/forms@2.7.0/dist/browser/global.global.js"></script>
45
+ <script src="https://unpkg.com/@samline/forms@2.7.1/dist/browser/global.global.js"></script>
46
46
  ```
47
47
 
48
- > Pin the version in production. Replace `2.7.0` with the version you ship.
48
+ > Pin the version in production. Replace `2.7.1` with the version you ship.
49
49
 
50
50
  The browser bundle exposes a single global: `window.Forms`.
51
51
 
@@ -55,7 +55,7 @@ The browser bundle exposes a single global: `window.Forms`.
55
55
  <button type="submit">Send</button>
56
56
  </form>
57
57
 
58
- <script src="https://unpkg.com/@samline/forms@2.7.0/dist/browser/global.global.js"></script>
58
+ <script src="https://unpkg.com/@samline/forms@2.7.1/dist/browser/global.global.js"></script>
59
59
  <script>
60
60
  const contactForm = window.Forms.newForm({ id: 'contact-form' })
61
61
 
@@ -5025,6 +5025,10 @@ var Forms = (() => {
5025
5025
  ...formatOptions ?? {},
5026
5026
  interpretInputAs: "auto"
5027
5027
  });
5028
+ var buildDisplayInterpretedOptions = (formatOptions) => ({
5029
+ ...formatOptions ?? {},
5030
+ interpretInputAs: "display"
5031
+ });
5028
5032
  var shouldForceAutoInterpretation = (formatOptions) => formatOptions?.interpretInputAs === void 0;
5029
5033
  var buildHandler = (visible, mirror, formatFn, formatType, formatOptions) => {
5030
5034
  const handler = (event) => {
@@ -5034,7 +5038,7 @@ var Forms = (() => {
5034
5038
  if (!isVisible && !isMirror) return;
5035
5039
  const rawInput = isMirror ? mirror.value : visible.value;
5036
5040
  const inputType = readInputType(event);
5037
- const sourceOptions = isMirror && shouldForceAutoInterpretation(formatOptions) ? buildAutoInterpretedOptions(formatOptions) : formatOptions;
5041
+ const sourceOptions = shouldForceAutoInterpretation(formatOptions) ? isMirror ? buildAutoInterpretedOptions(formatOptions) : buildDisplayInterpretedOptions(formatOptions) : formatOptions;
5038
5042
  const { formatted, raw } = formatFn(rawInput, formatType, sourceOptions);
5039
5043
  if (!formatted && !raw) {
5040
5044
  visible.value = "";
@@ -5116,7 +5120,8 @@ var Forms = (() => {
5116
5120
  if (entry.handler !== UNBOUND) {
5117
5121
  const current = entry.visible.value;
5118
5122
  if (current !== "") {
5119
- const { formatted, raw } = formatter.format(current, formatType, formatOptions);
5123
+ const rebindOptions = shouldForceAutoInterpretation(formatOptions) ? buildDisplayInterpretedOptions(formatOptions) : formatOptions;
5124
+ const { formatted, raw } = formatter.format(current, formatType, rebindOptions);
5120
5125
  applyFormattedValue(entry.visible, entry.mirror, formatted, raw);
5121
5126
  }
5122
5127
  continue;