-
Notifications
You must be signed in to change notification settings - Fork 13
feat: React 19 migration - 3 #710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
09c4e2c
d3e0b34
8d3bfac
f6428f1
a03669e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,3 +286,5 @@ export function Content({ | |
| </div> | ||
| ); | ||
| } | ||
|
|
||
| Content.displayName = 'DataTable.Content'; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,3 +166,5 @@ export function Filters<TData, TValue>({ | |
| </Flex> | ||
| ); | ||
| } | ||
|
|
||
| Filters.displayName = 'DataTable.Filters'; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,64 +1,64 @@ | ||
| 'use client'; | ||
|
|
||
| import { forwardRef } from 'react'; | ||
| import { ChangeEvent, type ComponentProps } from 'react'; | ||
| import { Search } from '../../search'; | ||
| import { SearchProps } from '../../search/search'; | ||
| import { useDataTable } from '../hooks/useDataTable'; | ||
|
|
||
| export interface DataTableSearchProps extends SearchProps { | ||
| export interface DataTableSearchProps extends ComponentProps<typeof Search> { | ||
| /** | ||
| * Automatically disable search in zero state (when no data and no filters/search applied). | ||
| * @defaultValue true | ||
| */ | ||
| autoDisableInZeroState?: boolean; | ||
| } | ||
|
|
||
| export const TableSearch = forwardRef<HTMLInputElement, DataTableSearchProps>( | ||
| ({ autoDisableInZeroState = true, disabled, ...props }, ref) => { | ||
| const { | ||
| updateTableQuery, | ||
| tableQuery, | ||
| shouldShowFilters = false | ||
| } = useDataTable(); | ||
| export function TableSearch({ | ||
| autoDisableInZeroState = true, | ||
| disabled, | ||
| ...props | ||
| }: DataTableSearchProps) { | ||
| const { | ||
| updateTableQuery, | ||
| tableQuery, | ||
| shouldShowFilters = false | ||
| } = useDataTable(); | ||
|
|
||
| const handleSearch = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| const value = e.target.value; | ||
| updateTableQuery(query => { | ||
| return { | ||
| ...query, | ||
| search: value | ||
| }; | ||
| }); | ||
| }; | ||
| const handleSearch = (e: ChangeEvent<HTMLInputElement>) => { | ||
| const value = e.target.value; | ||
| updateTableQuery(query => { | ||
| return { | ||
| ...query, | ||
| search: value | ||
| }; | ||
| }); | ||
| }; | ||
|
|
||
| const handleClear = () => { | ||
| updateTableQuery(query => { | ||
| return { | ||
| ...query, | ||
| search: '' | ||
| }; | ||
| }); | ||
| }; | ||
| const handleClear = () => { | ||
| updateTableQuery(query => { | ||
| return { | ||
| ...query, | ||
| search: '' | ||
| }; | ||
| }); | ||
| }; | ||
|
|
||
| // Auto-disable in zero state if enabled, but allow manual override | ||
| // Once search is applied, keep it enabled (even if shouldShowFilters is false) | ||
| const hasSearch = Boolean( | ||
| tableQuery?.search && tableQuery.search.trim() !== '' | ||
| ); | ||
| const isDisabled = | ||
| disabled ?? (autoDisableInZeroState && !shouldShowFilters && !hasSearch); | ||
| // Auto-disable in zero state if enabled, but allow manual override | ||
| // Once search is applied, keep it enabled (even if shouldShowFilters is false) | ||
| const hasSearch = Boolean( | ||
| tableQuery?.search && tableQuery.search.trim() !== '' | ||
| ); | ||
| const isDisabled = | ||
| disabled ?? (autoDisableInZeroState && !shouldShowFilters && !hasSearch); | ||
|
|
||
| return ( | ||
| <Search | ||
| {...props} | ||
| ref={ref} | ||
| onChange={handleSearch} | ||
| value={tableQuery?.search} | ||
| onClear={handleClear} | ||
| disabled={isDisabled} | ||
| /> | ||
| ); | ||
| } | ||
| ); | ||
| return ( | ||
| <Search | ||
| {...props} | ||
| onChange={handleSearch} | ||
| value={tableQuery?.search} | ||
| onClear={handleClear} | ||
| disabled={isDisabled} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| TableSearch.displayName = 'TableSearch'; | ||
| TableSearch.displayName = 'DataTable.Search'; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Dialog as DialogPrimitive } from '@base-ui/react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { cx } from 'class-variance-authority'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { type ElementRef, forwardRef } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import styles from './dialog.module.css'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { CloseButton } from './dialog-misc'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -17,51 +16,42 @@ export interface DialogContentProps extends DialogPrimitive.Popup.Props { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showNestedAnimation?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const DialogContent = forwardRef< | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ElementRef<typeof DialogPrimitive.Popup>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DialogContentProps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| >( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| children, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showCloseButton = true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| overlay, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| width, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showNestedAnimation = true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...props | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DialogPrimitive.Portal> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DialogPrimitive.Backdrop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {...overlay} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function DialogContent({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| children, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showCloseButton = true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| overlay, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| width, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showNestedAnimation = true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...props | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }: DialogContentProps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DialogPrimitive.Portal> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DialogPrimitive.Backdrop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {...overlay} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className={cx( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| styles.dialogOverlay, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| overlay?.blur && styles.overlayBlur, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| overlay?.className | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -type f -name "*dialog*" | head -20Repository: raystack/apsara Length of output: 730 🏁 Script executed: cat -n packages/raystack/components/dialog/dialog-content.tsx | head -50Repository: raystack/apsara Length of output: 1784 🏁 Script executed: rg "DialogPrimitive" packages/raystack/components/dialog/ -A 2 -B 2Repository: raystack/apsara Length of output: 6169 🏁 Script executed: rg "DialogContentProps" packages/raystack/components/dialog/ -A 10 -B 2Repository: raystack/apsara Length of output: 2174 🌐 Web query:
💡 Result: The Citations:
🏁 Script executed: # Check package.json to confirm `@base-ui/react` version
rg "@base-ui/react" packages/raystack/components/ -B 2 -A 2Repository: raystack/apsara Length of output: 31037 🏁 Script executed: # Check if there are any tests or usage examples showing overlay className
rg "overlay.*className" packages/raystack/components/dialog/ -A 3 -B 3Repository: raystack/apsara Length of output: 655 🏁 Script executed: # Look for any test files to understand expected behavior
cat -n packages/raystack/components/dialog/__tests__/dialog.test.tsx | head -100Repository: raystack/apsara Length of output: 3919 Fix
Suggested fix export function DialogContent({
className,
children,
showCloseButton = true,
overlay,
width,
style,
showNestedAnimation = true,
...props
}: DialogContentProps) {
+ const {
+ blur,
+ className: overlayClassName,
+ ...overlayProps
+ } = overlay ?? {};
+
return (
<DialogPrimitive.Portal>
<DialogPrimitive.Backdrop
- {...overlay}
- className={cx(
- styles.dialogOverlay,
- overlay?.blur && styles.overlayBlur,
- overlay?.className
- )}
+ {...overlayProps}
+ className={
+ typeof overlayClassName === 'function'
+ ? state =>
+ cx(
+ styles.dialogOverlay,
+ blur && styles.overlayBlur,
+ overlayClassName(state)
+ )
+ : cx(styles.dialogOverlay, blur && styles.overlayBlur, overlayClassName)
+ }
/>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DialogPrimitive.Viewport className={styles.viewport}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DialogPrimitive.Popup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className={cx( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| styles.dialogOverlay, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| overlay?.blur && styles.overlayBlur, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| overlay?.className | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| styles.dialogContent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showNestedAnimation && styles.showNestedAnimation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DialogPrimitive.Viewport className={styles.viewport}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <DialogPrimitive.Popup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref={ref} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className={cx( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| styles.dialogContent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| showNestedAnimation && styles.showNestedAnimation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style={{ width, ...style }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {...props} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {children} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {showCloseButton && <CloseButton className={styles.closeButton} />} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </DialogPrimitive.Popup> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </DialogPrimitive.Viewport> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </DialogPrimitive.Portal> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style={{ width, ...style }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {...props} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {children} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {showCloseButton && <CloseButton className={styles.closeButton} />} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </DialogPrimitive.Popup> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </DialogPrimitive.Viewport> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </DialogPrimitive.Portal> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DialogContent.displayName = 'Dialog.Content'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: raystack/apsara
Length of output: 114
🏁 Script executed:
Repository: raystack/apsara
Length of output: 8661
Remove React 19-only context syntax or drop React 18 support.
The change on line 218 uses
<TableContext value={contextValue}>(React 19 syntax) instead of<TableContext.Provider value={...}>(React 18 syntax). Sincepackage.jsondeclares support for^18 || ^19, this breaks React 18 compatibility. Other contexts in the codebase (e.g.,ThemeContextintheme-provider/theme.tsxline 201) still use the.Providersyntax, indicating this is an inconsistent partial migration. Either revert to.Providersyntax for React 18 compatibility or explicitly drop React 18 support frompackage.json.🤖 Prompt for AI Agents