PhoenixAssets. Enums
(PhoenixAssets v0.1.0)
View Source
Integration plugin that emits every Ash.Type.Enum as localized options.
PhoenixAssets.Types renders an enum as a TypeScript string-literal union,
which types a value but cannot label one. A select box needs the label too, and
in the reader's locale — so three platforms independently wrote the same Mix
task to discover enum modules by behaviour and dump {value, label, description} per locale.
This is that task, once. Enum modules are found by behaviour, so there is no registry to keep in step:
config :phoenix_assets, :stack,
enums: [gettext_backend: MyAppWeb.Gettext]Emits enums.json beside the TypeScript contracts:
{"<locale>": {"<enum_group>": [{"value": _, "label": _, "description": _}]}}Labels come from the enum's own display_name/1 and description/1 when it
defines them, read once per locale so a Gettext-backed implementation resolves
in each. An enum that defines neither still emits its values, humanized.
Set only: to a list of modules to bypass discovery.
A host can also discover enums owned by reusable dependency applications:
config :phoenix_assets, :stack,
enums: [
gettext_backend: MyAppWeb.Gettext,
apps: [:my_shared_domain]
]The host application is always included; apps: only adds to it.
Summary
Functions
Callback implementation for PhoenixAssets.Plugin.dev_processes/2.
Callback implementation for PhoenixAssets.Plugin.name/0.
Callback implementation for PhoenixAssets.Plugin.vite_config/2.
Functions
Callback implementation for PhoenixAssets.Plugin.dev_processes/2.
Callback implementation for PhoenixAssets.Plugin.name/0.
Callback implementation for PhoenixAssets.Plugin.vite_config/2.