Skip to content

enum-plus v3.0 plan #14

Description

@shijistar

enum-plus v3.0 - A Major Update

■■■■■■■■■■■■■■■■■■■■ (100%)

Features

Codebase

  • Remove deprecated enum.options
  • Remove deprecated enum.menus
  • Remove deprecated enum.filters
  • Remove deprecated enum.valuesEnum
  • 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 toSelecttoMenutoFilter. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: DoneThe issue has been resolved

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions