-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(vue,types): Add initial support for SFC files to improve runtim…
…e prop checking (#4902)
- Loading branch information
1 parent
8d8c2f3
commit 4af3538
Showing
15 changed files
with
540 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@clerk/types': patch | ||
'@clerk/vue': patch | ||
--- | ||
|
||
Improve runtime prop checking for single-file components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<script setup lang="ts"> | ||
import { useAttrs, useSlots } from 'vue'; | ||
import type { SignInProps } from '@clerk/types'; | ||
import { useClerk } from '../composables/useClerk'; | ||
import { assertSingleChild, normalizeWithDefaultValue } from '../utils'; | ||
type SignInButtonProps = Pick< | ||
SignInProps, | ||
'fallbackRedirectUrl' | 'forceRedirectUrl' | 'signUpForceRedirectUrl' | 'signUpFallbackRedirectUrl' | 'initialValues' | ||
> & { | ||
mode?: 'modal' | 'redirect'; | ||
}; | ||
const props = defineProps<SignInButtonProps>(); | ||
const clerk = useClerk(); | ||
const slots = useSlots(); | ||
const attrs = useAttrs(); | ||
function getChildComponent() { | ||
const children = normalizeWithDefaultValue(slots.default?.({}), 'Sign in'); | ||
return assertSingleChild(children, 'SignInButton'); | ||
} | ||
function clickHandler() { | ||
const { mode, ...opts } = props; | ||
if (mode === 'modal') { | ||
return clerk.value?.openSignIn(opts); | ||
} | ||
void clerk.value?.redirectToSignIn({ | ||
...opts, | ||
signInFallbackRedirectUrl: props.fallbackRedirectUrl, | ||
signInForceRedirectUrl: props.forceRedirectUrl, | ||
}); | ||
} | ||
</script> | ||
|
||
<template> | ||
<component | ||
:is="getChildComponent" | ||
v-bind="attrs" | ||
@click="clickHandler" | ||
> | ||
<slot /> | ||
</component> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script setup lang="ts"> | ||
import { Portal } from '../uiComponents'; | ||
import { useClerk } from '../../composables'; | ||
import type { SignInProps } from '@clerk/types'; | ||
const clerk = useClerk(); | ||
const props = defineProps<SignInProps>(); | ||
</script> | ||
|
||
<template> | ||
<Portal | ||
:mount="clerk?.mountSignIn" | ||
:unmount="clerk?.unmountSignIn" | ||
:props="props" | ||
:update-props="(clerk as any)?.__unstable__updateProps" | ||
/> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
declare module '*.vue' { | ||
import type { DefineComponent } from 'vue'; | ||
|
||
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, any>; | ||
export default component; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationDir": "./dist" | ||
}, | ||
"include": ["src/**/*.ts", "src/**/*.vue"], | ||
"exclude": ["src/**/*.test.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import vue from '@vitejs/plugin-vue'; | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
export default defineConfig({ | ||
test: { | ||
globals: true, | ||
environment: 'jsdom', | ||
}, | ||
plugins: [vue()], | ||
}); |
Oops, something went wrong.