Skip to content

fix: export constant component types #2001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 1, 2025
Merged

Conversation

pimlie
Copy link
Contributor

@pimlie pimlie commented Jun 23, 2025

The builds provide a reka-ui/constant export but at the moment those give an error in TS because dist/constant.d.ts only has an empty export.

This was caused due to the constant/ folder being outside the src/ folder which was the only folder being included in the TS build config.

The as const's are ensuring that the TS exports do not fallback to string[]

--edit--

Due to build error also simplified the nuxt module and remove the flat() and function usage. Flat causes a new array to be created which just isn't needed if we use a for loop as in this pr.

With these changes it's also possible to support a per component configuration. Currently you can only add all components in a group, but extending ModuleOptions.components with the following type would allow users to toggle individual components. Let me know if you want me to add that.

// Toggle components by group
type ComponentGroupConfig = {
  [K in keyof Components]?: boolean
}

// Toggle components invidually (still nested per group)
type ComponentConfig = {
  [K in keyof Components]?: {
    [K2 in Components[K][number]]: boolean
  }
}

export interface ModuleOptions {
  components: ComponentConfig | ComponentGroupConfig | boolean
  prefix: string
}

--edit--
The two config types can be combined for even more flexiblity ofc

type ComponentConfig = {
  [K in keyof Components]?: boolean | {
    [K2 in Components[K][number]]: boolean
  }
}

export interface ModuleOptions {
  components: ComponentConfig | boolean
  prefix: string
}

Copy link

pkg-pr-new bot commented Jun 28, 2025

Open in StackBlitz

npm i https://pkg.pr.new/reka-ui@2001

commit: 4d373dd

@zernonia
Copy link
Member

zernonia commented Jul 1, 2025

LGTM @pimlie ! As for your suggestion above, perhaps we can have another ticket for it. 😁

@zernonia zernonia merged commit f54a275 into unovue:v2 Jul 1, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants