Skip to content

Commit

Permalink
Link no href & to props and Button update
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Oct 15, 2024
1 parent 0367729 commit 8aadaab
Show file tree
Hide file tree
Showing 25 changed files with 182 additions and 134 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@eslint-react/eslint-plugin": "^1.15.0",
"@mui/icons-material": "^6.1.3",
"@mui/material": "^6.1.3",
"@mui/icons-material": "^6.1.4",
"@mui/material": "^6.1.4",
"@storybook/addon-actions": "^8.3.5",
"@storybook/addon-docs": "^8.3.5",
"@storybook/addon-essentials": "^8.3.5",
Expand All @@ -111,7 +111,7 @@
"@xylabs/ts-scripts-yarn3": "^4.2.1",
"@xylabs/tsconfig": "^4.2.1",
"@xylabs/tsconfig-react": "^4.2.1",
"@xyo-network/react-theme": "^4.0.4",
"@xyo-network/react-theme": "^4.1.0",
"axios": "^1.7.7",
"buffer": "^6.0.3",
"eslint": "^9.12.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/accordion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"@xylabs/react-button": "workspace:^"
},
"devDependencies": {
"@mui/icons-material": "^6.1.3",
"@mui/material": "^6.1.3",
"@mui/icons-material": "^6.1.4",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/react-flexbox": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/animation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@xylabs/react-flexbox": "workspace:^"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/appbar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"@xylabs/react-flexbox": "workspace:^"
},
"devDependencies": {
"@mui/icons-material": "^6.1.3",
"@mui/material": "^6.1.3",
"@mui/icons-material": "^6.1.4",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/async-effect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@xylabs/react-promise": "workspace:^"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/base-page/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"react-helmet": "^6.1.0"
},
"devDependencies": {
"@mui/icons-material": "^6.1.3",
"@mui/material": "^6.1.3",
"@mui/icons-material": "^6.1.4",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@types/react-helmet": "^6.1.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"react-router-dom": "^6.27.0"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/react-flexbox": "workspace:^",
Expand Down
45 changes: 30 additions & 15 deletions packages/button/src/components/ButtonExProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,45 @@ import type { ButtonProps } from '@mui/material'
import type { BoxlikeComponentProps, BusyProps } from '@xylabs/react-shared'
import type { NavigateOptions, To } from 'react-router-dom'

export interface ButtonBaseExProps extends Omit<ButtonProps, 'ref' | 'href'>, BoxlikeComponentProps, BusyProps {
disableUserEvents?: boolean
funnel?: string
intent?: string
placement?: string
target?: string
export interface ButtonOnlyHrefProps {
href?: string
to?: never
toOptions?: never
}

export interface ButtonToExProps extends ButtonBaseExProps {
export interface ButtonOnlyToProps {
href?: never
to: To
to?: To
toOptions?: NavigateOptions
}

export interface ButtonHrefExProps extends ButtonBaseExProps {
href: string
export interface ButtonNoToOrHrefProps {
href?: never
to?: never
toOptions?: never
}

export interface ButtonClickExProps extends ButtonBaseExProps {
href?: never
to?: never
toOptions?: never
export type ButtonHrefOrToOrNoProps = ButtonOnlyHrefProps | ButtonOnlyToProps | ButtonNoToOrHrefProps

export interface ButtonHrefAndToProps {
href?: string
to?: To
toOptions?: NavigateOptions
}

export const asButtonHrefOrToProps = (props: ButtonHrefAndToProps): ButtonHrefOrToOrNoProps => {
if (props.href && (props.to || props.toOptions)) {
throw new Error('ButtonExProps: cannot have both href and to')
}
return props.href ? { href: props.href } : props.to ? { to: props.to, toOptions: props.toOptions } : {}
}

export interface ButtonBaseExProps extends Omit<ButtonProps, 'ref' | 'href'>, BoxlikeComponentProps, BusyProps {
disableUserEvents?: boolean
funnel?: string
intent?: string
placement?: string
target?: string
}

export type ButtonExProps = ButtonToExProps | ButtonHrefExProps | ButtonClickExProps
export type ButtonExProps = ButtonBaseExProps & ButtonHrefOrToOrNoProps
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"react-router-dom": "^6.27.0"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cookie-consent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@xylabs/react-shared": "workspace:^"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
"ethers": "^6.13.4",
"lru-cache": "^11.0.1",
"react-router-dom": "^6.27.0",
"viem": "^2.21.25",
"viem": "^2.21.26",
"webextension-polyfill": "^0.12.0"
},
"devDependencies": {
"@mui/icons-material": "^6.1.3",
"@mui/material": "^6.1.3",
"@mui/icons-material": "^6.1.4",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/dialogs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"axios": "^1.7.7"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/error/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"@xylabs/react-flexbox": "workspace:^"
},
"devDependencies": {
"@mui/icons-material": "^6.1.3",
"@mui/material": "^6.1.3",
"@mui/icons-material": "^6.1.4",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/experiments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@xylabs/react-shared": "workspace:^"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"packages/*"
],
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/identicon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"md5": "^2.3.0"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@types/md5": "^2.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/invertible-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"rfdc": "^1.4.1"
},
"devDependencies": {
"@mui/icons-material": "^6.1.3",
"@mui/material": "^6.1.3",
"@mui/icons-material": "^6.1.4",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
39 changes: 36 additions & 3 deletions packages/link/src/LinkExProps.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
import type { LinkProps } from '@mui/material'
import type { NavigateOptions, To } from 'react-router-dom'

export interface LinkExProps extends Omit<LinkProps, 'ref'> {
export interface LinkOnlyHrefProps {
href?: string
to?: never
toOptions?: never
}

export interface LinkOnlyToProps {
href?: never
to?: To
toOptions?: NavigateOptions
}

export interface LinkNoToOrHrefProps {
href?: never
to?: never
toOptions?: never
}

export type LinkHrefOrToOrNoProps = LinkOnlyHrefProps | LinkOnlyToProps | LinkNoToOrHrefProps

export interface LinkHrefAndToProps {
href?: string
to?: To
toOptions?: NavigateOptions
}

export const asLinkHrefOrToProps = (props: LinkHrefAndToProps): LinkHrefOrToOrNoProps => {
if (props.href && (props.to || props.toOptions)) {
throw new Error('LinkExProps: cannot have both href and to')
}
return props.href ? { href: props.href } : props.to ? { to: props.to, toOptions: props.toOptions } : {}
}

export interface LinkExBaseProps extends Omit<LinkProps, 'ref' | 'href'> {
disableUserEvents?: boolean
funnel?: string
intent?: string
placement?: string
to?: To
toOptions?: NavigateOptions
}

export type LinkExProps = LinkExBaseProps & LinkHrefOrToOrNoProps
2 changes: 1 addition & 1 deletion packages/number-status/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"numeral": "^2.0.6"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/numeral": "^2.0.5",
"@types/react": "^18.3.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/pixel-debugger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@xylabs/react-shared": "workspace:^"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/promise/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"async-mutex": "^0.5.0"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/delay": "^4.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/quick-tip-button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"@xylabs/react-dialogs": "workspace:^"
},
"devDependencies": {
"@mui/icons-material": "^6.1.3",
"@mui/material": "^6.1.3",
"@mui/icons-material": "^6.1.4",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/react-flexbox": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/select/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"packages/*"
],
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
"@xylabs/tsconfig-react": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@xylabs/react-async-effect": "workspace:^"
},
"devDependencies": {
"@mui/material": "^6.1.3",
"@mui/material": "^6.1.4",
"@storybook/react": "^8.3.5",
"@types/react": "^18.3.11",
"@xylabs/ts-scripts-yarn3": "^4.2.1",
Expand Down
Loading

0 comments on commit 8aadaab

Please sign in to comment.