SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.5k stars 260 forks source link

custom-element-manifest: add `reference` to the `type` object #7822

Closed MarcusNotheis closed 8 months ago

MarcusNotheis commented 10 months ago

Feature Request Description

In Web Components for React, we're currently exploring the custom-element-manifest for our wrapper generation. In order to create proper interfaces, we would need an enhancement to the CEM so that the origin of an enum is part of the manifest.

Example: The following snippet is an excerpt of ui5-button CEM:

{
  "default": "\"Default\"",
  "deprecated": false,
  "fieldName": "design",
  "name": "design",
  "type": {
    "text": "ButtonDesign"
  },
  "description": "Defines the component design."
},

With this information we know that the design attribute is of type ButtonDesign, but we don't know where to import the enum from.

Proposed Solution

To solve this issue, the CEM offers a references array as part of the type, where a name and a package can be specified: https://github.com/webcomponents/custom-elements-manifest/blob/efaf2fc1ca3dcd93e4f392e5d9c72840813ad5ea/schema.d.ts#L179-L183

With the new information, the CEM would now look like this:

{
  "default": "\"Default\"",
  "deprecated": false,
  "fieldName": "design",
  "name": "design",
  "type": {
    "text": "ButtonDesign",
    "references": [
      { 
        "name": "ButtonDesign", 
        "package": "@ui5/webcomponents", 
        "module": "dist/types/ButtonDesign.js" 
      }
    ]
  },
  "description": "Defines the component design."
},

Proposed Alternatives

No response

Organization

UI5 Web Components for React

Additional Context

No response

Priority

None

Privacy Policy

petyabegovska commented 10 months ago

Hi @MarcusNotheis,

This request will be resolved with issues #6958 and #7610, which we plan for UI5 Web Components version 1.20.0.

Best regards, Petya