Enums
Description
Enums provides the shared enum wrappers and Pinia bootstrap used across Enso UI packages.
It turns raw enum dictionaries into helper objects with translated labels, option builders, randomizers, and a central store-registration flow.
Installation
Install the package:
yarn add @enso-ui/enums
This package is also available through the full enso-ui workspace bundle.
Features
- exports the
Enumclass wrapper as the default export - exports
initEnumsfor building wrapped enum collections - exports the
enumsPinia store accessor - exports
registerto bootstrap the store module
Usage
import Enum, { initEnums, enums, register } from '@enso-ui/enums';
register();
const wrapped = initEnums({ statuses: { 1: 'Draft', 2: 'Sent' } }, key => key);
const statusEnum = new Enum({ 1: 'Draft', 2: 'Sent' }, key => key);
API
Enum
Default export for the enum wrapper class.
Import: @enso-ui/enums
Methods:
_get(key)_has(key)_select()_filter()_keys()_values()_all()_data()_randomKey()_randomValue()
initEnums
Builds an object of wrapped Enum instances from a raw enum dictionary payload.
Import: @enso-ui/enums
enums
Pinia store accessor for the shared enums store.
Import: @enso-ui/enums
register
Bootstraps the Pinia enum store.
Import: @enso-ui/enums
Companion Backend Package
The backend companion provides the enum dictionaries that are hydrated into the frontend store during bootstrap.
Depends On
pinia
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!