Search code examples
angularvmware-clarityclarity

Use internal Clarity services in own components


I'm experimenting with writing a custom form control wrapper component like e.g. Clarity's clr-input-container for an own form control I've already implemented. For the wrapper I wanted to use the utility services IfErrorService, NgControlService, ControlIdService, ControlClassService and LayoutService like it is done in the clr-input-containerimplementation.

However I'm getting these build errors for every service:

ERROR in ./.../my-control-container.component.ts
Module not found: Error: Can't resolve '@clr/angular/forms/common/if-error/if-error.service' in '/.../my-control-container'

Is there any way I can use internal Clarity services in my own project?


Solution

  • We currently don't export this publicly on purpose, as it is specific to our forms at the moment. We want to solve this by creating a generic input-container for you to leverage. It isn't currently in progress, so I don't have a timeline on that.

    The only workaround I would suggest is that you could copy the services into your project and redeclare them like you see in the input implementation. You'll have to ensure everything wires up correctly, which is not something we have documented, so it is not necessarily clear if it is compatible with what you're working on.