From 82ba580e9bdd0e4e03f6010b34fcf957dd33aaf9 Mon Sep 17 00:00:00 2001 From: Dany Castillo <31006608+dcastil@users.noreply.github.com> Date: Sat, 18 Nov 2023 14:02:58 +0100 Subject: [PATCH 1/3] export ClassValidator from package --- src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 1e043fe6..25d16cb2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,5 +5,10 @@ export { fromTheme } from './lib/from-theme' export { mergeConfigs } from './lib/merge-configs' export { twJoin, type ClassNameValue } from './lib/tw-join' export { twMerge } from './lib/tw-merge' -export { type Config, type DefaultClassGroupIds, type DefaultThemeGroupIds } from './lib/types' +export { + type ClassValidator, + type Config, + type DefaultClassGroupIds, + type DefaultThemeGroupIds, +} from './lib/types' export * as validators from './lib/validators' From 5d1f6677bec99740073ca356a5c7388756dcf2c7 Mon Sep 17 00:00:00 2001 From: Dany Castillo <31006608+dcastil@users.noreply.github.com> Date: Sat, 18 Nov 2023 14:10:37 +0100 Subject: [PATCH 2/3] add documentation for new export --- docs/api-reference.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/api-reference.md b/docs/api-reference.md index f2b90803..9738396e 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -382,6 +382,14 @@ function myWrappedTwMerge(...args: ClassNameValue[]) { } ``` +## `ClassValidator` + +```ts +type ClassValidator = (value: string) => boolean +``` + +TypeScript type for class validators accepted in class definitions within [`extendTailwindMerge`](#extendtailwindmerge) and [`createTailwindMerge`](#createtailwindmerge). + --- Next: [Writing plugins](./writing-plugins.md) From b86b0dfbae5b2fdc4796ebd773bd444adf4d10ea Mon Sep 17 00:00:00 2001 From: Dany Castillo <31006608+dcastil@users.noreply.github.com> Date: Sat, 18 Nov 2023 14:12:13 +0100 Subject: [PATCH 3/3] add ClassValidator to public-api test --- tests/public-api.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/public-api.test.ts b/tests/public-api.test.ts index 12deb896..2fa33cad 100644 --- a/tests/public-api.test.ts +++ b/tests/public-api.test.ts @@ -1,5 +1,6 @@ import { ClassNameValue, + ClassValidator, Config, DefaultClassGroupIds, DefaultThemeGroupIds, @@ -40,12 +41,14 @@ test('has correct export types', () => { const noRun = () => { const config: Config = getDefaultConfig() const classNameValue: ClassNameValue = 'some-class' + const classValidator: ClassValidator = (value: string) => false twMerge(classNameValue, classNameValue, classNameValue) twJoin(classNameValue, classNameValue, classNameValue) return { config, + classValidator, } } })