Skip to content

Commit

Permalink
feat: expose TurnstileTheme and TurnstileLangCode types
Browse files Browse the repository at this point in the history
fix #35
  • Loading branch information
marsidev committed Sep 6, 2023
1 parent a96daa8 commit 1ddb870
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ export type {
TurnstileProps,
TurnstileInstance,
TurnstileServerValidationErrorCode,
TurnstileServerValidationResponse
TurnstileServerValidationResponse,
TurnstileTheme,
TurnstileLangCode
} from './types'
12 changes: 8 additions & 4 deletions packages/lib/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ interface RenderOptions {
*
* @default `auto`
*/
theme?: 'light' | 'dark' | 'auto'
theme?: TurnstileTheme

/**
* Language to display, must be either: `auto` (default) to use the language that the visitor has chosen, or an ISO 639-1 two-letter language code (e.g. `en`).
* @default `auto`
*/
language?: 'auto' | LangCode
language?: 'auto' | TurnstileLangCode | (string & Record<never, never>)

/**
* The tabindex of Turnstile’s iframe for accessibility purposes.
Expand Down Expand Up @@ -337,7 +337,7 @@ type ContainerSizeSet = {
[size in NonNullable<ComponentRenderOptions['size']> | 'interactionOnly']: React.CSSProperties
}

type LangCode =
type TurnstileLangCode =
| 'ar'
| 'ar-EG'
| 'de'
Expand All @@ -358,6 +358,8 @@ type LangCode =
| 'zh-CN'
| 'zh-TW'

type TurnstileTheme = 'light' | 'dark' | 'auto'

interface TurnstileServerValidationResponse {
/** Indicate if the token validation was successful or not. */
success: boolean
Expand Down Expand Up @@ -403,5 +405,7 @@ export type {
InjectTurnstileScriptParams,
ContainerSizeSet,
TurnstileServerValidationResponse,
TurnstileServerValidationErrorCode
TurnstileServerValidationErrorCode,
TurnstileTheme,
TurnstileLangCode
}

0 comments on commit 1ddb870

Please sign in to comment.