Skip to content

Commit

Permalink
Merge branch 'main' into feat/trpc
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagebakers committed Sep 21, 2024
2 parents 2c6d466 + a23917d commit 54f73cc
Show file tree
Hide file tree
Showing 42 changed files with 254 additions and 70 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/pkg-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Package PR

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn

- name: Build
run: yarn build:packages

- run: yarn dlx pkg-pr-new publish './packages/saas-ui-auth'
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint:staged
# yarn lint:staged
8 changes: 8 additions & 0 deletions apps/palette/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# palette

## 1.4.43

### Patch Changes

- Updated dependencies [5e000e0]
- @saas-ui/react@2.8.11
- @saas-ui/theme-glass@0.5.5

## 1.4.42

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/palette/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "palette-docs",
"version": "1.4.42",
"version": "1.4.43",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
8 changes: 8 additions & 0 deletions apps/website/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# website

## 2.3.41

### Patch Changes

- Updated dependencies [5e000e0]
- @saas-ui/react@2.8.11
- @saas-ui/forms@2.6.11

## 2.3.40

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "website",
"version": "2.3.40",
"version": "2.3.41",
"private": true,
"author": "Eelco Wiersma <eelco@appulse.nl>",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"changelog:commit": "git add CHANGELOG.md && git commit -am 'docs: add changelog' && git push",
"changeset:next": "yarn changeset pre enter next",
"changeset:version": "yarn changelog:gen && changeset version",
"publish:next": "yarn workspaces foreach --from '@saas-ui/*' --exclude '@saas-ui/pro' --exclude '@saas-ui-pro/*' npm publish --access public --tag next",
"publish:next": "yarn workspaces foreach -Wp --from '@saas-ui/*' --exclude '@saas-ui/pro' --exclude '@saas-ui-pro/*' npm publish --access public --tag next",
"publish": "yarn workspaces foreach -Wp --from '@saas-ui/*' --exclude '@saas-ui/pro' --exclude '@saas-ui-pro/*' npm publish && yarn changeset tag",
"storybook": "yarn w saas-ui-storybook dev",
"build:storybook": "yarn w saas-ui-storybook build",
Expand Down
19 changes: 19 additions & 0 deletions packages/saas-ui-auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# @saas-ui/auth

## 3.3.1

### Patch Changes

- @saas-ui/core@2.5.6
- @saas-ui/forms@2.6.11

## 3.3.0

### Minor Changes

- c8c696e: onGetToken no longer required for authentication service

## 3.3.0-next.0

### Minor Changes

- c8c696e: onGetToken no longer required for authentication service

## 3.2.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/saas-ui-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@saas-ui/auth",
"version": "3.2.2",
"version": "3.3.1",
"description": "Authentication provider and components for Chakra UI",
"source": "src/index.ts",
"exports": {
Expand Down
63 changes: 28 additions & 35 deletions packages/saas-ui-auth/src/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export interface AuthContextValue<TUser extends User = DefaultUser> {
updatePassword: AuthFunction<UpdatePasswordParams>
logOut: (options?: AuthOptions) => Promise<unknown>
loadUser: () => void
getToken: () => Promise<AuthToken>
getToken?: () => Promise<AuthToken>
}

const createAuthContext = <TUser extends User = DefaultUser>() => {
Expand Down Expand Up @@ -190,61 +190,54 @@ export const AuthProvider = <TUser extends User = DefaultUser>({
}
}, [onRestoreAuthState])

const checkAuth = useCallback(async () => {
try {
if (onGetToken) {
const isAuthenticated = !!(await onGetToken())
setAuthenticated(isAuthenticated)
return isAuthenticated
}
} catch (e) {
setAuthenticated(false)
}
}, [onGetToken])

useEffect(() => {
if (!refetchUserOnWindowFocus) {
return
}

const onWindowFocus = async () => {
loadUser()
}

window.addEventListener('focus', onWindowFocus)

return () => {
if (onWindowFocus) {
window.removeEventListener('focus', onWindowFocus)
}
}
}, [checkAuth, refetchUserOnWindowFocus])

const loadUser = useCallback(async () => {
try {
// Prevent multiple calls to loadUser
if (isFetchingRef.current) {
return
}

const isAuthenticated = await checkAuth()

if (isAuthenticated && !isFetchingRef.current) {
if (
(typeof onGetToken === 'undefined' || (await onGetToken())) &&
!isFetchingRef.current
) {
isFetchingRef.current = true
const user = await onLoadUser()

if (user) {
setUser(user)
setAuthenticated(true)
} else {
setAuthenticated(false)
setUser(null)
}
}
} catch {
setAuthenticated(false)
setUser(null)
} finally {
isFetchingRef.current = false
setLoading(false)
}
}, [onLoadUser, checkAuth])
}, [onLoadUser, onGetToken])

useEffect(() => {
if (!refetchUserOnWindowFocus) {
return
}

const onWindowFocus = async () => {
loadUser()
}

window.addEventListener('focus', onWindowFocus)

return () => {
if (onWindowFocus) {
window.removeEventListener('focus', onWindowFocus)
}
}
}, [loadUser, refetchUserOnWindowFocus])

const signUp = useCallback(
async (params: AuthParams, options?: AuthOptions) => {
Expand Down
5 changes: 0 additions & 5 deletions packages/saas-ui-auth/stories/auth.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ const createAuthService = (): AuthProviderProps<CustomUser> => {
console.log('onLoadUser', user)
return user
},
onGetToken: async () => {
// return a session token if it's supported.
console.log('onGetToken', user?.email)
return user?.email
},
onResetPassword: async (params: AuthParams) => {
// send a reset password email
},
Expand Down
20 changes: 20 additions & 0 deletions packages/saas-ui-auth0/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# @saas-ui/auth0

## 0.1.14

### Patch Changes

- @saas-ui/auth@3.3.1

## 0.1.13

### Patch Changes

- Updated dependencies [c8c696e]
- @saas-ui/auth@3.3.0

## 0.1.13-next.0

### Patch Changes

- Updated dependencies [c8c696e]
- @saas-ui/auth@3.3.0-next.0

## 0.1.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/saas-ui-auth0/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@saas-ui/auth0",
"version": "0.1.12",
"version": "0.1.14",
"description": "Auth0 authentication for Saas UI",
"source": "src/index.ts",
"exports": {
Expand Down
20 changes: 20 additions & 0 deletions packages/saas-ui-clerk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# @saas-ui/clerk

## 3.0.50

### Patch Changes

- @saas-ui/auth@3.3.1

## 3.0.49

### Patch Changes

- Updated dependencies [c8c696e]
- @saas-ui/auth@3.3.0

## 3.0.49-next.0

### Patch Changes

- Updated dependencies [c8c696e]
- @saas-ui/auth@3.3.0-next.0

## 3.0.48

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/saas-ui-clerk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@saas-ui/clerk",
"version": "3.0.48",
"version": "3.0.50",
"description": "Clerk Authentication Service for Saas UI",
"source": "src/index.ts",
"exports": {
Expand Down
7 changes: 7 additions & 0 deletions packages/saas-ui-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @saas-ui/react

## 2.5.6

### Patch Changes

- Updated dependencies [5e000e0]
- @saas-ui/theme@2.4.2

## 2.5.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/saas-ui-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@saas-ui/core",
"version": "2.5.5",
"version": "2.5.6",
"description": "Saas UI - The React component library for startups.",
"source": "src/index.ts",
"exports": {
Expand Down
8 changes: 8 additions & 0 deletions packages/saas-ui-data-table/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @saas-ui/data-table

## 10.0.11

### Patch Changes

- Updated dependencies [5e000e0]
- @saas-ui/react@2.8.11
- @saas-ui/core@2.5.6

## 10.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/saas-ui-data-table/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@saas-ui/data-table",
"version": "10.0.10",
"version": "10.0.11",
"description": "Data-table Component",
"source": "src/index.ts",
"exports": {
Expand Down
7 changes: 7 additions & 0 deletions packages/saas-ui-date-picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @saas-ui/date-picker

## 0.12.43

### Patch Changes

- @saas-ui/core@2.5.6
- @saas-ui/modals@2.1.41

## 0.12.42

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/saas-ui-date-picker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@saas-ui/date-picker",
"version": "0.12.42",
"version": "0.12.43",
"description": "Chakra UI - Date Picker Component",
"source": "src/index.ts",
"exports": {
Expand Down
6 changes: 6 additions & 0 deletions packages/saas-ui-forms/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @saas-ui/forms

## 2.6.11

### Patch Changes

- @saas-ui/core@2.5.6

## 2.6.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/saas-ui-forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@saas-ui/forms",
"version": "2.6.10",
"version": "2.6.11",
"description": "Fully functional forms for Chakra UI.",
"source": "src/index.ts",
"exports": {
Expand Down
6 changes: 6 additions & 0 deletions packages/saas-ui-hotkeys/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @saas-ui/hotkeys

## 2.2.14

### Patch Changes

- @saas-ui/core@2.5.6

## 2.2.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/saas-ui-hotkeys/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@saas-ui/hotkeys",
"version": "2.2.13",
"version": "2.2.14",
"description": "Easy manageable keyboard shortcuts for Chakra UI",
"source": "src/index.ts",
"exports": {
Expand Down
Loading

0 comments on commit 54f73cc

Please sign in to comment.