Previews

No matching results.

x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="fHjJVOM5y49mm44hzBtpNXj01qthNl4iW7txP70hnkOepgKqjcZ95enWX30IH3s1rEDZjPGw6f3RuMAjlDddpA" />
<!-- ATTENTION: The following line is required for Turbo dialog works see: https://github.com/hotwired/turbo/issues/1191#issuecomment-1952959217 -->
<meta name="turbo-prefetch" content="false">
<link rel="stylesheet" href="/assets/tailwind-b07d8146.css" data-turbo-track="reload" />
<link rel="stylesheet" href="/assets/elevate-9611e0ae.css" />
<script src="/vite/assets/application-Dhu5wEut.js" crossorigin="anonymous" type="module"></script><link rel="modulepreload" href="/vite/assets/monaco-editor-C1G6nEm4.js" as="script" crossorigin="anonymous"><link rel="stylesheet" href="/vite/assets/monaco-editor-DQmwQvws.css" media="screen" />
</head>
<body>
<div id="elevate-toast-host" data-controller="toast" data-turbo-permanent="true" data-toast-position-value="top-center" data-toast-layout-value="default" data-toast-auto-dismiss-duration-value="4000" data-toast-limit-value="3" data-toast-gap-value="14" class="elevate-toast elevate-toast--position--top-center">
<ol data-toast-target="container" class="relative flex flex-col-reverse sm:flex-col gap-0 pointer-events-auto [&>li]:pointer-events-auto" style="height: 0px;"></ol>
<div data-toast-target="livePolite" role="status" aria-live="polite" aria-atomic="true" class="sr-only"></div>
<div data-toast-target="liveAssertive" role="alert" aria-live="assertive" aria-atomic="true" class="sr-only"></div>
<template data-toast-template data-toast-type="default">
<li class="toast-item">
<div class="elevate-toast--content">
<div class="elevate-toast--row">
<div class="elevate-toast--plate elevate-toast--plate--default"
aria-hidden="true">
<span class="elevate-toast--plate-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true">
<circle cx="9" cy="9" r="7.4"></circle>
<circle cx="9" cy="9" r="1.4" fill="currentColor" stroke="none"></circle>
</svg>
</span>
</div>
<div class="elevate-toast--text">
<p class="elevate-toast--title" data-toast-slot="message"></p>
<p class="elevate-toast--description" data-toast-slot="description"></p>
</div>
<button type="button" class="elevate-toast--close" data-toast-slot="close" aria-label="Close">
<span class="elevate-toast--close-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 14 14" fill="none" focusable="false" aria-hidden="true">
<path d="M3.5 3.5 L10.5 10.5 M10.5 3.5 L3.5 10.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></path>
</svg>
</span>
</button>
</div>
</div>
</li>
</template>
<template data-toast-template data-toast-type="success">
<li class="toast-item">
<div class="elevate-toast--content">
<div class="elevate-toast--row">
<div class="elevate-toast--plate elevate-toast--plate--success"
aria-hidden="true">
<span class="elevate-toast--plate-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true">
<circle cx="9" cy="9" r="7.4"></circle>
<path d="M5.6 9.2 L8 11.6 L12.4 6.8"></path>
</svg>
</span>
</div>
<div class="elevate-toast--text">
<p class="elevate-toast--title" data-toast-slot="message"></p>
<p class="elevate-toast--description" data-toast-slot="description"></p>
</div>
<button type="button" class="elevate-toast--close" data-toast-slot="close" aria-label="Close">
<span class="elevate-toast--close-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 14 14" fill="none" focusable="false" aria-hidden="true">
<path d="M3.5 3.5 L10.5 10.5 M10.5 3.5 L3.5 10.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></path>
</svg>
</span>
</button>
</div>
</div>
</li>
</template>
<template data-toast-template data-toast-type="error">
<li class="toast-item">
<div class="elevate-toast--content">
<div class="elevate-toast--row">
<div class="elevate-toast--plate elevate-toast--plate--error"
aria-hidden="true">
<span class="elevate-toast--plate-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true">
<circle cx="9" cy="9" r="7.4"></circle>
<path d="M6.2 6.2 L11.8 11.8 M11.8 6.2 L6.2 11.8"></path>
</svg>
</span>
</div>
<div class="elevate-toast--text">
<p class="elevate-toast--title" data-toast-slot="message"></p>
<p class="elevate-toast--description" data-toast-slot="description"></p>
</div>
<button type="button" class="elevate-toast--close" data-toast-slot="close" aria-label="Close">
<span class="elevate-toast--close-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 14 14" fill="none" focusable="false" aria-hidden="true">
<path d="M3.5 3.5 L10.5 10.5 M10.5 3.5 L3.5 10.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></path>
</svg>
</span>
</button>
</div>
</div>
</li>
</template>
<template data-toast-template data-toast-type="info">
<li class="toast-item">
<div class="elevate-toast--content">
<div class="elevate-toast--row">
<div class="elevate-toast--plate elevate-toast--plate--info"
aria-hidden="true">
<span class="elevate-toast--plate-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true">
<circle cx="9" cy="9" r="7.4"></circle>
<path d="M9 8 L9 12.4"></path>
<circle cx="9" cy="5.6" r="0.5" fill="currentColor" stroke="none"></circle>
</svg>
</span>
</div>
<div class="elevate-toast--text">
<p class="elevate-toast--title" data-toast-slot="message"></p>
<p class="elevate-toast--description" data-toast-slot="description"></p>
</div>
<button type="button" class="elevate-toast--close" data-toast-slot="close" aria-label="Close">
<span class="elevate-toast--close-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 14 14" fill="none" focusable="false" aria-hidden="true">
<path d="M3.5 3.5 L10.5 10.5 M10.5 3.5 L3.5 10.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></path>
</svg>
</span>
</button>
</div>
</div>
</li>
</template>
<template data-toast-template data-toast-type="warning">
<li class="toast-item">
<div class="elevate-toast--content">
<div class="elevate-toast--row">
<div class="elevate-toast--plate elevate-toast--plate--warning"
aria-hidden="true">
<span class="elevate-toast--plate-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true">
<path d="M9 2.4 L16.2 14.6 L1.8 14.6 Z"></path>
<path d="M9 7.2 L9 10.6"></path>
<circle cx="9" cy="12.6" r="0.5" fill="currentColor" stroke="none"></circle>
</svg>
</span>
</div>
<div class="elevate-toast--text">
<p class="elevate-toast--title" data-toast-slot="message"></p>
<p class="elevate-toast--description" data-toast-slot="description"></p>
</div>
<button type="button" class="elevate-toast--close" data-toast-slot="close" aria-label="Close">
<span class="elevate-toast--close-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 14 14" fill="none" focusable="false" aria-hidden="true">
<path d="M3.5 3.5 L10.5 10.5 M10.5 3.5 L3.5 10.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></path>
</svg>
</span>
</button>
</div>
</div>
</li>
</template>
<template data-toast-template data-toast-type="danger">
<li class="toast-item">
<div class="elevate-toast--content">
<div class="elevate-toast--row">
<div class="elevate-toast--plate elevate-toast--plate--danger"
aria-hidden="true">
<span class="elevate-toast--plate-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 18 18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true">
<path d="M9 1.8 L15.6 5.4 L15.6 10 C15.6 13.4 12.6 15.6 9 16.6 C5.4 15.6 2.4 13.4 2.4 10 L2.4 5.4 Z"></path>
<path d="M9 6.4 L9 10"></path>
<circle cx="9" cy="12" r="0.5" fill="currentColor" stroke="none"></circle>
</svg>
</span>
</div>
<div class="elevate-toast--text">
<p class="elevate-toast--title" data-toast-slot="message"></p>
<p class="elevate-toast--description" data-toast-slot="description"></p>
</div>
<button type="button" class="elevate-toast--close" data-toast-slot="close" aria-label="Close">
<span class="elevate-toast--close-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 14 14" fill="none" focusable="false" aria-hidden="true">
<path d="M3.5 3.5 L10.5 10.5 M10.5 3.5 L3.5 10.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></path>
</svg>
</span>
</button>
</div>
</div>
</li>
</template>
<template data-toast-template data-toast-type="loading">
<li class="toast-item">
<div class="elevate-toast--content">
<div class="elevate-toast--row">
<div class="elevate-toast--plate elevate-toast--plate--loading"
role="progressbar" aria-label="Loading…">
<span class="elevate-toast--plate-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 18 18" fill="none" focusable="false" aria-hidden="true">
<circle cx="9" cy="9" r="7" stroke="currentColor" stroke-opacity="0.2" stroke-width="1.6"></circle>
<path d="M9 2 A7 7 0 0 1 16 9" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"></path>
</svg>
</span>
</div>
<div class="elevate-toast--text">
<p class="elevate-toast--title" data-toast-slot="message"></p>
<p class="elevate-toast--description" data-toast-slot="description"></p>
</div>
<button type="button" class="elevate-toast--close" data-toast-slot="close" aria-label="Close">
<span class="elevate-toast--close-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 14 14" fill="none" focusable="false" aria-hidden="true">
<path d="M3.5 3.5 L10.5 10.5 M10.5 3.5 L3.5 10.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></path>
</svg>
</span>
</button>
</div>
</div>
</li>
</template>
<template data-toast-template-rich>
<li class="toast-item">
<div class="elevate-toast--content elevate-toast--content--rich">
<div data-toast-slot="content"></div>
<button type="button" class="elevate-toast--close elevate-toast--close--floating" data-toast-slot="close" aria-label="Close"><span class="elevate-toast--close-icon elevate-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewbox="0 0 14 14" fill="none" focusable="false" aria-hidden="true">
<path d="M3.5 3.5 L10.5 10.5 M10.5 3.5 L3.5 10.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"></path>
</svg>
</span></button></div>
</li>
</template>
</div>
<main class="container mx-auto mt-12 px-5">
<form data-controller="elevate-hotwire" data-elevate-hotwire-values-value="{"elevate_lookbook_user":{"id":null,"first_name":null,"last_name":"Doe","phone":null,"email":null,"amount":null,"website":null,"country":null,"birth_date":null,"appointment_at":null,"code_snippet":null,"bio":null,"preferred_time":null,"newsletter":false,"marketing_emails":null,"terms_accepted":false,"privacy_policy_accepted":false,"interests":null,"notification_preferences":[],"errors":{"_is_valid":true},"warnings":{"_is_valid":true},"suggested_values":{"first_name":"Oscar Botyglot","country":"france","birth_date":"2026-08-25","appointment_at":"2026-05-18T08:00:00.000Z","code_snippet":"# Sample Ruby code\nclass HelloWorld\n def greet(name)\n puts \"Hello, #{name}!\"\n end\nend\n\nhello = HelloWorld.new\nhello.greet(\"World\")\n","phone":"+33 1 23 45 67 89","amount":1234.56,"bio":"Passionate software developer with expertise in Ruby on Rails and Vue.js. Always eager to learn new technologies and share knowledge with the community.","preferred_time":"2026-08-25T14:30:00.000Z","newsletter":true,"marketing_emails":true,"terms_accepted":true,"privacy_policy_accepted":true,"interests":["ruby","javascript"],"notification_preferences":["email","push"]}}}" data-elevate-hotwire-validation-url-value="/elevate/users" id="new_elevate_lookbook_user_form" class="form elevate_lookbook_user-form" action="/elevate/users" accept-charset="UTF-8" method="post"><input type="hidden" name="authenticity_token" value="OxTrCqfZhLWKIKTH6iv-TNSuHwz6T9KW6aBPVT3BWxjeM4aMTOMYgUVceyD7tKv_znH_flY8P09kwXJ6j_bIAg" autocomplete="off" />
<div class="input-block" id="elevate_lookbook_user_last_name__wrapper" data-controller="elevate-hotwire-field" data-elevate-hotwire-field-elevate-hotwire-outlet="form" data-elevate-hotwire-field-name-value="elevate_lookbook_user[last_name]">
<input data-elevate-hotwire-field-target="hidden" autocomplete="off" type="hidden" value="Doe" name="elevate_lookbook_user[last_name]" />
<div class="botyglot--form-component--field--wrapper">
<input class="botyglot--form-component--field--input" data-elevate-hotwire-field-target="input" placeholder="Enter your last name" type="text" id="elevate_lookbook_user_last_name" />
</div>
</div>
</form>
</main>
</body>
<script>
/* see this fix: https://github.com/rails/importmap-rails/issues/65#issuecomment-999939960 */
window.process = { env: { NODE_ENV: 'production'} }
</script>
</html>
1
2
3
4
5
6
7
8
9
<%- url = Elevate::Engine.routes.url_helpers.users_path -%>
<%= elevate_form_with(model: user, url: url, scope: :elevate_lookbook_user) do |form| %>
<%= render Elevate::Hotwire::FieldComponent.new(
form: form,
field_name: :last_name,
placeholder: "Enter your last name",
) %>
<% end %>

No assets to display.

app/components/elevate/hotwire/field/field_controller.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// Field-level Stimulus controller for Elevate::Hotwire::FieldComponent (and any
// future form field component built on the same pattern).
//
// Composes the field-side behaviors:
// - useFormState → outlet wiring, store reads/writes, subscriptions
// - useTouchOnFocus → focus → markFieldTouched
// - useEmptyClass → wrapper class based on emptiness
// - useValidityClasses → input class based on touched + error/warning
// - useErrorPlaceholder → inline error/warning <span> (when displayError)
// - useSuggestedValue → reactive auto-fill (when suggestValue is set)
//
// Plus a value adapter (strategy, not behavior):
// - identityAdapter for plain text fields
// - makeNumericFormatAdapter(locale) for locale-aware numeric formatting
//
// The adapter has two methods:
// - formatForDisplay(storeValue) → string (for the visible input)
// - parseFromInput(input) → any | SKIP_WRITE (for store writes)
//
// Decisions: 0002 (runtime via outlet), 0003 (store + outlets), 0005
// (composable behaviors), 0007 (state-derived rendering in JS).
import { Controller } from "@hotwired/stimulus";
import { useFormState } from "../../../../assets/javascripts/hotwire/behaviors/use_form_state";
import { useTouchOnFocus } from "../../../../assets/javascripts/hotwire/behaviors/use_touch_on_focus";
import { useEmptyClass } from "../../../../assets/javascripts/hotwire/behaviors/use_empty_class";
import { useValidityClasses } from "../../../../assets/javascripts/hotwire/behaviors/use_validity_classes";
import { useErrorPlaceholder } from "../../../../assets/javascripts/hotwire/behaviors/use_error_placeholder";
import { useSuggestedValue } from "../../../../assets/javascripts/hotwire/behaviors/use_suggested_value";
import { identityAdapter } from "../../../../assets/javascripts/hotwire/adapters/identity";
import { makeNumericFormatAdapter } from "../../../../assets/javascripts/hotwire/adapters/numeric_format";
import { SKIP_WRITE } from "../../../../assets/javascripts/hotwire/adapters/sentinels";
export default class ElevateHotwireFieldController extends Controller {
static outlets = ['elevate-hotwire'];
static targets = ['input', 'hidden'];
static values = {
name: String,
displayError: { type: Boolean, default: true },
numericFormat: { type: String, default: '' }, // '' | 'true' | 'en' | 'fr'
suggestValue: { type: String, default: '' }, // '' | 'true' | 'force'
};
connect() {
const name = this.nameValue;
const locale = this.#numericLocale();
const adapter = locale ? makeNumericFormatAdapter(locale) : identityAdapter;
// The hidden input is the only form-submitting one (the visible input has
// its `name` stripped), so it must carry the store's CANONICAL value as a
// string — never the adapter's display string, which may add locale
// grouping (numeric_format renders "1234.56" → "1,234.56" for display).
// The store already holds the canonical value (parseFromInput writes it;
// the JSON wire payload hydrates it), so stringifying it is all the hidden
// needs. For plain text fields display === canonical, so this matches the
// previous behavior; it only diverges for formatting adapters.
const canonical = (v) => (v == null ? "" : String(v));
// The controller's own element is the outer "input-block" wrapper that
// carries the empty/not-empty class — matching legacy ComponentWrapper.vue.
//
// onValueChange mirrors store value changes onto the hidden input (canonical,
// for form submission) and the visible input (display, via the adapter).
useFormState(this, {
name,
onValueChange: (v) => {
this.hiddenTarget.value = canonical(v);
this.inputTarget.value = adapter.formatForDisplay(v);
},
});
useTouchOnFocus(this, { target: this.inputTarget });
useEmptyClass(this, { name, wrapper: this.element });
useValidityClasses(this, { name, input: this.inputTarget });
if (this.displayErrorValue) {
useErrorPlaceholder(this, { name, parent: this.element });
}
// Input-display sync from the store. We do this in two places:
//
// 1. Now, synchronously. Covers the common case where the outlet is
// already connected at use-time — store.getValue(name) returns the
// real value, the adapter formats it, both inputs show it.
//
// 2. After outlet-connected fires, AFTER all behavior wrappers
// resolve. Covers the deferred case where the outlet isn't ready
// yet during connect() (e.g. a turbo-streamed form): step 1 saw
// fieldValue() as undefined and wrote ''. By the time outlet-
// connected has rippled through every wrapper, useSuggestedValue
// has potentially written a suggestion to the store, and
// useFormState's subscription is live for future changes — so
// this is the right moment to format the *now-current* value into
// both inputs.
//
// The store-side `subscribe` wrapper deliberately suppresses the
// initial fire (it requires `next !== last`), which is why we can't
// rely on `onValueChange` to do this for us at outlet-connect time.
//
// We sync BOTH the visible and the hidden input. The hidden input is
// the only form-submitting one (visible has its `name` stripped), so
// it must carry the canonical store value at all times. Relying on
// Rails' server-rendered `value=` attribute breaks down for
// Ransack::Search-backed forms: Ransack predicate methods like
// `firstname_cont` are exposed via `method_missing` without a matching
// `respond_to_missing?`, so Rails' `Tags::Base#value(object)` (which
// gates the read on `object.respond_to?(method_name)`) returns nil
// and `hidden_field` omits the value attribute entirely. The form
// would then submit `q[firstname_cont]=` even though the URL it came
// from carried `q[firstname_cont]=john`. Making the store the single
// source of truth on connect fixes that — the same JSON wire payload
// that hydrates the store already carries the value (via
// `Oscar::Common::RansackWrapper.to_builder(@q).attributes!`).
const syncFromStore = () => {
const raw = this.fieldValue();
const display = adapter.formatForDisplay(raw);
this.inputTarget.value = display;
// Sync hidden only when the store has a meaningful value — empty
// display means either "store has no entry for this field" (e.g. an
// AR-record with a nil attribute) or "user cleared it" (handled by
// onValueChange on the actual change, not at init). Touching the
// hidden in the empty case would force a `value=""` attribute onto
// the DOM and break byte-for-byte parity with the legacy Vue
// baseline in `spec/parity/`, which renders no `value` attribute
// for empty fields. The Ransack case the surrounding comment
// describes always has a non-empty `display` (the JSON wire payload
// includes the value precisely because the user filtered on it).
// The hidden gets the CANONICAL value (display is for the visible input).
if (display !== "") this.hiddenTarget.value = canonical(raw);
};
syncFromStore();
// Visible input → store, through the adapter. The adapter may return
// SKIP_WRITE (e.g. mid-decimal-separator typing) to ask the controller
// to leave the store alone for this keystroke.
this.#inputHandler = (e) => {
const parsed = adapter.parseFromInput(e.target.value);
if (parsed !== SKIP_WRITE) this.updateFieldValue(parsed);
};
this.inputTarget.addEventListener('input', this.#inputHandler);
useSuggestedValue(this, { name, mode: this.suggestValueValue });
// Late-sync wrapper: install LAST so it runs AFTER every behavior's
// own outlet-connected setup. See the comment above.
const prevOutletConnected = this.elevateHotwireOutletConnected?.bind(this);
this.elevateHotwireOutletConnected = function (outlet, element) {
if (prevOutletConnected) prevOutletConnected(outlet, element);
syncFromStore();
};
}
disconnect() {
if (this.#inputHandler) {
this.inputTarget.removeEventListener('input', this.#inputHandler);
}
super.disconnect();
}
#inputHandler = null;
// 'true' / true → 'en'
// 'en' / 'fr' → as-is
// anything else → null (numeric formatting disabled)
#numericLocale() {
const v = this.numericFormatValue;
if (v === 'true' || v === true) return 'en';
if (v === 'en' || v === 'fr') return v;
return null;
}
}