# Changelog

## [v0.3.3] — 2026-11-18

### Added

* `Money.Input.Currency` has a `:grouping` field, read from the locale's currency pattern without a symbol, which `<.money_input>` renders as `data-grouping` (`"3,2"`) for the `MoneyInput` hook.

### Changed

* Requires `localize ~> 1.7` and `ex_money ~> 6.3 and >= 6.3.1`. localize 1.7 formats a currency the locale does not list, which blanked the field in 72 locales, and ex_money 6.3.1 rounds and validates such a currency in any process locale.

### Fixed

* A currency the locale does not list, such as BHD in `az-Cyrl`, shows its symbol and sends `data-iso-digits` to the hook, where 14,020 locale and currency pairs in 508 locales showed neither. The symbol is read from the locale's parents and then the default locale, as `Money.to_string/2` writes it.

* An amount stored with more digits than its currency allows is shown with all of them, where the server and the `MoneyInput` hook rounded it (`1.2345` USD showed `1.23`, `1234.5` JPY `1,235`) and an unchanged save stored the rounded amount. `Money.Input.Validator` now reports the extra digits instead.

* With AutoNumeric loaded, `hi`, `bn-IN`, `gu`, `te` and the other Indian-grouping locales show `12,34,567` as the server writes it, and `tok` groups in twos, so its amounts of 1,000 or more no longer fail to submit. `en-IN` groups in threes in the field as on the server, where the hook showed `123,45,67,890.12`.

* A stored amount outside `:min` / `:max` (±10 trillion when neither is set) is no longer blanked and erased on save, and one the server sends later no longer reverts to the previous amount. The `MoneyInput` hook falls back to the plain input with the server's text when AutoNumeric refuses an amount.

* A paste into the plain amount input reaches `phx-change`, and a padded ` (1,234.56) ` shows as `-1,234.56`. The `MoneyInput` hook cancels the browser's paste to clean the text, which also cancelled its `input` event.

## [v0.3.2] — 2026-11-09

### Changed

* Requires `ex_money ~> 6.3`, and so `localize ~> 1.5`.

* In locales with digits of their own (`fa`, `ar-SA`, `bn`, `mr` and others) the `MoneyInput` hook leaves the field a plain input, since AutoNumeric only writes Latin digits and the server could not read them back with Arabic separators.

### Fixed

* The `MoneyInput` hook no longer blanks the amount in `ar`, `he`, `ur` and other locales whose minus sign carries a direction mark, and falls back to a plain input if AutoNumeric rejects a locale's separators.

* A form reset restores the amount in `ar` and `he` instead of blanking it.

* `<.money_input>` and `Money.Input.Cast` no longer raise `BadMapError` on a string amount in locales such as `fa`, `ar-SA` and `bn`; the fix is in ex_money 6.3.

## [v0.3.1] — 2026-11-08

### Added

* The amount input carries a `data-amount` attribute with the plain decimal amount (`"1234.56"`), which the `MoneyInput` hook uses to start and resync AutoNumeric.

* A `package.json`, so the hooks import as `"ex_money_input"` wherever `deps` is on esbuild's `NODE_PATH`, as in Phoenix's generated config.

### Changed

* `<.money_input>` and `<.currency_picker>` validate `:locale` once into a `Localize.LanguageTag` and accept a string, atom or tag. An invalid locale renders without a `data-locale` attribute instead of echoing it.

### Fixed

* The `MoneyInput` hook resyncs AutoNumeric after every LiveView update, so the amount no longer disappears or reverts to an old value when the pointer leaves the field. Fixes [#2](https://github.com/ex-money/money_input/issues/2).

* `<.money_input>` without a `:locale` attribute formats the amount in the current locale instead of English, matching the separators it gives the hook.

* With AutoNumeric loaded, grouped amounts in zero-decimal currencies such as JPY in `de` no longer start misread.

* `<.money_input>` with an invalid `:locale` and an amount to format no longer raises `Localize.InvalidLocaleError`.

* The documented `"money_input"` import and `deps/money_input` paths did not resolve. The README, guides and moduledoc now import `"ex_money_input"` and load the stylesheet from `deps/ex_money_input/priv/static/`.

## [v0.3.0] — 2026-07-31

### Changed

* Requires `localize ~> 1.0` and `ex_money ~> 6.2`. The previous requirements excluded Localize 1.0.

## [v0.2.3] — 2026-05-17

### Bug Fixes

* `Money.Input.Validator.validate_money/2` no longer raises `FunctionClauseError` when called with a non-`%Money{}` value (binary, atom, map, etc.). `check_money_range/3` now has a final catch-all that skips the range check on type mismatch.

* `<.money_input>` no longer raises when `:min` / `:max` is a value Phoenix can't render as iodata — `value_attr/1` rescues `Protocol.UndefinedError` and drops the attribute.

* `<.money_input>` with an unknown `:locale` no longer 500s on downstream `@locale_data.X` reads. The placeholder when both the requested locale AND its fallback fail to resolve is now a shaped `%Money.Input.Currency{}` struct (all fields `nil`) rather than a bare `%{}` — so attribute reads degrade to `nil` and Phoenix omits the attribute.

* `<.currency_picker>` no longer raises on `:preferred` non-list values (`nil`, atom, integer). `assign_picker/1` coerces to `[]` and writes the safe value back to assigns so the template's `Enum.map_join(@preferred, ...)` reads the coerced value.

* Adversarial-input test suite added (`test/adversarial_render_test.exs`) that exercises every public component with a matrix of bad attr values, and an atom-safety guard (`test/atom_safety_test.exs`) that fails the suite if any new `String.to_atom/1` is added to `lib/`.

## [v0.2.2] — 2026-05-17

### Bug Fixes

* Currency picker's search `<input>` field now picks up the dark theme. The element had no explicit `background`/`color` declarations, so it fell back to the browser-default white/black even when the rest of the picker overlay correctly used the dark `--mi-*` tokens.

## [v0.2.1] — 2026-05-17

### Bug Fixes

* `Money.Input.Components.money_input/1` no longer raises when the form submits an empty or unknown currency (e.g. the picker's hidden carrier before any selection). `normalize_currency_code/1` blacklists `""` and `:""`, and `assign_money_locale_data/1` falls back to the locale's natural currency on unknown ISO codes instead of `MatchError`.

* `Money.Input.Components.currency_picker/1` tolerates an unknown locale — `assign_picker/1` now falls back to a placeholder rather than crashing on `{:ok, _} = ...`.

* Dark-mode CSS tokens added — `priv/static/money_input.css` now ships `@media (prefers-color-scheme: dark)` and `[data-theme="dark"]` override blocks so the picker and money input pick up the host page's dark theme instead of staying light-themed.

## [v0.2.0] — 2026-05-15

* Gettext-backed localization of the picker's UI strings (aria labels, search placeholder, section headers, empty-state). Catalog ships English source plus de, fr, and ja translations. Activated via `Money.Input.Gettext` backend. `:gettext` is now a required dep when the components are used (it was optional in 0.1).

* Currency names in the picker rendering localize to the active locale via `Localize.Currency.display_name/2` instead of the static English `:name` field.

* `Money.Input.Visualizer` and the standalone helper have moved to the sibling [`money_input_playground`](https://github.com/ex-money/money_input_playground) package (under the `MoneyInputPlayground.Visualizer` namespace). Drops the `:plug` and `:bandit` optional deps from this package. If you embedded the visualizer in your own router via `forward "/money-input", Money.Input.Visualizer`, add `{:money_input_playground, "~> 0.1", only: :dev}` and update the forward target to `MoneyInputPlayground.Visualizer`.

## [v0.1.0] — 2026-05-15

* `Money.Input.Components.money_input/1` and `Money.Input.Components.currency_picker/1` — locale-aware money HEEx components backed by an AutoNumeric JS hook, submitting `%{"amount", "currency"}` maps compatible with `Money.Ecto.Composite.Type`.

* `Money.Input.Cast`, `Money.Input.Validator`, `Money.Input.Currency`, and `Money.Input.Changeset` — headless cast/validate layer with currency-aware precision (USD: 2, JPY: 0, BHD: 3) and an Ecto changeset bridge.

* `Money.Input.Visualizer` — Plug-based development tool with light/dark theme toggle that demonstrates the components across CLDR locales and currencies.
