You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following symbols have been renamed to better reflect their purpose:
ENUM_COLLECTION is now IS_ENUM
ENUM_ITEM is now IS_ENUM_ITEM
ENUM_ITEMS is now IS_ENUM_ITEMS
🔥 Add enum.named to aggregate all enum items by their names, so that you can quick access an enum item by enum.named.XXX.
🔥 Add enum.meta object to aggregate all custom fields defined in the enum. The keys are the field names, and values are the raw values of each field. It's a good way of accessing custom fields without iterating through the enum items.
🔥 Change the behavior of enum.values, now it returns an array of the member raw values. Use enum.items for the old behavior.
🔥 Add enum.labels property, which returns an readonly array of the member labels.
🔥 Add enum.toList, method which is an alternative of toSelect、toMenu、toFilter. The latter methods are moving out of the core library and will be available as plugins.
🔥 Add enum.toMap as an alternative of enum.toValueMap.
Add Enum.isEnum method to check if an object is an instance of Enum.
🔥 Add enum.findBy method, which allows searching for enum items by built-in fields, and the custom meta fields (i.e. custom fields).
Add type assertion for instanceof check of EnumCollection.
🔥 Simplify the enum initialization that no longer requires as const assertion. by @otomad
🔥 Release the UMD module format of enum-plus in umd folder.
Reuse one copy of testing code for both Jest and e2e testing.
Remove private member syntax from the codebase.
Support graceful downgrade for multiple TypeScript versions. For v5.0 and later, Enum initializations allows omitting the as const assertion. For earlier versions, will be automatically downgraded to the earlier syntax, just manually adding as const as needed.
Remove the internal proxy from EnumItemClass, and use getter instead. This is to prevent circular-reference to support JSON.stringify in WeChat mini-programs.
Plugin System
🔥 Introduce a new plugin system for extending features and ship them as separate npm packages.
Add Enum.install which is used to install plugins.
🔥 Implement enum-plus-plugin-antd project and move Ant Design oriented code into the plugin, including enum.toSelect, enum.toMenu, enum.toFilter, and enum.toValueMap. Set the default value of valueField to value and labelField to label in the plugin.
Github Actions
Improve Github Actions that updates the CDN url of UMD files in README.md when releasing a new version.
Add e2e tests to cover unit tests for browser compatibility.
es folder ( ES2020 )
es-legacy folder ( ES2015 )
umd folder ( ES2020 )
Breaking Changes
enum.options method is removed, use enum.toSelect instead.
enum.menus method is removed, use enum.toMenu instead.
enum.filters method is removed, use enum.toFilter instead.
enum.valuesEnum method is removed, use enum.toValueMap instead.
The behavior of enum.values is changed. Use enum.items for the old behavior.
Bug Fixes
Fix the issue where sourcemap files under the lib directory could not be parsed.
enum-plus v3.0 - A Major Update
■■■■■■■■■■■■■■■■■■■■ (100%)
Features
Codebase
enum.optionsenum.menusenum.filtersenum.valuesEnumENUM_COLLECTIONis nowIS_ENUMENUM_ITEMis nowIS_ENUM_ITEMENUM_ITEMSis nowIS_ENUM_ITEMSenum.namedto aggregate all enum items by their names, so that you can quick access an enum item byenum.named.XXX.enum.metaobject to aggregate all custom fields defined in the enum. The keys are the field names, and values are the raw values of each field. It's a good way of accessing custom fields without iterating through the enum items.enum.values, now it returns an array of the member raw values. Useenum.itemsfor the old behavior.enum.labelsproperty, which returns an readonly array of the member labels.enum.toList, method which is an alternative oftoSelect、toMenu、toFilter. The latter methods are moving out of the core library and will be available as plugins.enum.toMapas an alternative ofenum.toValueMap.Enum.isEnummethod to check if an object is an instance ofEnum.enum.findBymethod, which allows searching for enum items by built-in fields, and the custom meta fields (i.e. custom fields).instanceofcheck of EnumCollection.as constassertion. by @otomadUMDmodule format ofenum-plusinumdfolder.Jestande2etesting.private membersyntax from the codebase.proxyfromEnumItemClass, and usegetterinstead. This is to prevent circular-reference to supportJSON.stringifyin WeChat mini-programs.Plugin System
Enum.installwhich is used to install plugins.enum-plus-plugin-antdproject and move Ant Design oriented code into the plugin, includingenum.toSelect,enum.toMenu,enum.toFilter, andenum.toValueMap. Set the default value ofvalueFieldtovalueandlabelFieldtolabelin the plugin.Github Actions
Improve Github Actions that updates the CDN url of UMD files in README.md when releasing a new version.
Add e2e tests to cover unit tests for browser compatibility.
esfolder ( ES2020 )es-legacyfolder ( ES2015 )umdfolder ( ES2020 )Breaking Changes
enum.optionsmethod is removed, useenum.toSelectinstead.enum.menusmethod is removed, useenum.toMenuinstead.enum.filtersmethod is removed, useenum.toFilterinstead.enum.valuesEnummethod is removed, useenum.toValueMapinstead.enum.valuesis changed. Useenum.itemsfor the old behavior.Bug Fixes
libdirectory could not be parsed.