Conversation
WalkthroughAdds three new content components — generic Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/ctablex-core/index.d.ts(2 hunks)packages/ctablex-core/src/contents/content.test.tsx(2 hunks)packages/ctablex-core/src/contents/empty-content.tsx(1 hunks)packages/ctablex-core/src/contents/null-content.tsx(1 hunks)packages/ctablex-core/src/index.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/ctablex-core/index.d.ts (3)
packages/ctablex-core/src/contents/empty-content.tsx (2)
EmptyContent(13-20)EmptyContentProps(4-7)packages/ctablex-core/src/index.ts (4)
EmptyContent(12-12)EmptyContentProps(13-13)NullContent(20-20)NullContentProps(21-21)packages/ctablex-core/src/contents/null-content.tsx (2)
NullContent(8-15)NullContentProps(4-6)
🪛 GitHub Actions: CI
packages/ctablex-core/index.d.ts
[error] 1-1: git diff --exit-code --name-only failed with exit code 1. Modified file: packages/ctablex-core/index.d.ts.
🔇 Additional comments (5)
packages/ctablex-core/src/contents/null-content.tsx (1)
4-15: NullContent implementation looks correct and minimalLogic cleanly gates rendering on
content === null || content === undefinedand otherwise returnsnull; matches the intended semantics and the tests. No changes needed.packages/ctablex-core/src/contents/content.test.tsx (1)
12-13: New content tests are comprehensive and consistent with behaviorThe new suites for
NullableContent,NullContent, andEmptyContentexercise null/undefined, empty vs non-empty arrays, non-array values, and customisEmptylogic, which nicely pins down the intended semantics. Structure with separatedescribeblocks improves readability without introducing brittle assertions.Also applies to: 247-405
packages/ctablex-core/index.d.ts (1)
207-213: NullContent declarations align with implementationThe
NullContentandNullContentPropsdeclarations (non-generic,children?: ReactNode, returnJSX_2.Element | null) match the implementation insrc/contents/null-content.tsxand the intended semantics. Once the EmptyContent declarations are fixed and regenerated, this section should be good.packages/ctablex-core/src/index.ts (1)
12-13: Public exports for EmptyContent/NullContent are correctly wiredThe new exports for
EmptyContent/EmptyContentPropsandNullContent/NullContentPropsfollow the existing pattern for other content components and point to the correct source files. Onceindex.d.tsis updated to match, the public surface will be consistent.Also applies to: 20-21
packages/ctablex-core/src/contents/empty-content.tsx (1)
4-20: EmptyContent implementation matches the intended generic, overridable “emptiness” semanticsThe component cleanly combines a generic
isEmptypredicate with a sensible default for arrays and explicit handling ofnull/undefined. The use ofuseContent<C>()andEmptyContentProps<C>is consistent and aligns with the tests. No changes needed here; just ensure the publicindex.d.tsdeclarations mirror this generic shape (see separate comment).
3e5a126 to
bed9cc2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 35 38 +3
Lines 213 233 +20
Branches 45 51 +6
=========================================
+ Hits 213 233 +20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bed9cc2 to
fb8c41d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
packages/ctablex-core/src/contents/empty-content.tsx (1)
9-11: ExtractdefaultIsEmptyto a shared utility.This function is duplicated from
packages/ctablex-core/src/contents/non-empty-content.tsx. Consolidate it into a shared utility to maintain consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/ctablex-core/index.d.ts(3 hunks)packages/ctablex-core/src/contents/content.test.tsx(2 hunks)packages/ctablex-core/src/contents/empty-content.tsx(1 hunks)packages/ctablex-core/src/contents/non-empty-content.tsx(1 hunks)packages/ctablex-core/src/contents/null-content.tsx(1 hunks)packages/ctablex-core/src/index.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/ctablex-core/src/contents/null-content.tsx
- packages/ctablex-core/src/index.ts
🧰 Additional context used
🧬 Code graph analysis (3)
packages/ctablex-core/src/contents/empty-content.tsx (1)
packages/ctablex-core/src/index.ts (3)
EmptyContentProps(13-13)EmptyContent(12-12)useContent(4-4)
packages/ctablex-core/src/contents/content.test.tsx (9)
packages/ctablex-core/src/index.ts (9)
ContentProvider(4-4)NullableContent(19-19)ArrayContent(10-10)NullContent(22-22)EmptyContent(12-12)NonEmptyContent(14-14)DefaultContent(17-17)ObjectContent(31-31)KeyContent(34-34)packages/ctablex-core/src/contents/nullable-content.tsx (1)
NullableContent(11-18)packages/ctablex-core/src/contents/array-content.tsx (1)
ArrayContent(18-46)packages/ctablex-core/src/contents/null-content.tsx (1)
NullContent(8-15)packages/ctablex-core/src/contents/empty-content.tsx (1)
EmptyContent(13-20)packages/ctablex-core/src/contents/non-empty-content.tsx (1)
NonEmptyContent(13-20)packages/ctablex-core/src/contents/default-content.tsx (1)
DefaultContent(3-6)packages/ctablex-core/src/contents/object-content.tsx (1)
ObjectContent(21-42)packages/ctablex-core/src/contents/key-content.tsx (1)
KeyContent(3-6)
packages/ctablex-core/index.d.ts (3)
packages/ctablex-core/src/contents/empty-content.tsx (2)
EmptyContent(13-20)EmptyContentProps(4-7)packages/ctablex-core/src/contents/non-empty-content.tsx (2)
NonEmptyContent(13-20)NonEmptyContentProps(4-7)packages/ctablex-core/src/contents/null-content.tsx (2)
NullContent(8-15)NullContentProps(4-6)
🔇 Additional comments (7)
packages/ctablex-core/src/contents/non-empty-content.tsx (1)
13-20: LGTM! Component logic is correct.The component correctly renders children only when content exists (not null/undefined) and is non-empty according to the
isEmptypredicate. The inverse logic appropriately returns null for empty or null/undefined content.packages/ctablex-core/src/contents/empty-content.tsx (1)
13-20: LGTM! Component logic is correct.The component correctly renders children when content is null, undefined, or empty according to the
isEmptypredicate. This provides the inverse behavior ofNonEmptyContent.packages/ctablex-core/src/contents/content.test.tsx (2)
12-14: LGTM! Imports added for new components.The imports correctly bring in the three new content components for testing.
248-624: Excellent test coverage for the new content components.The expanded test suite comprehensively covers:
NullableContentbehavior with null, undefined, custom nullContent, and non-null valuesNullContentrendering with null, undefined, and non-null contentNonEmptyContentscenarios including null, undefined, empty arrays, non-empty arrays, non-array content, and customisEmptypredicatesEmptyContentscenarios with various content types and custom predicates- Mixed interactions between
NullableContent,EmptyContent, andNonEmptyContentThe test structure is well-organized with clear expectations and good edge case coverage.
packages/ctablex-core/index.d.ts (3)
115-122: LGTM! Type declarations match the implementation.The
EmptyContent<C>andEmptyContentProps<C>declarations correctly include the generic parameter and theisEmptycallback, matching the implementation inpackages/ctablex-core/src/contents/empty-content.tsx.
199-206: LGTM! Type declarations match the implementation.The
NonEmptyContent<C>andNonEmptyContentProps<C>declarations correctly include the generic parameter and theisEmptycallback, matching the implementation inpackages/ctablex-core/src/contents/non-empty-content.tsx.
217-223: LGTM! Type declarations match the implementation.The
NullContentandNullContentPropsdeclarations are correctly non-generic and include only thechildrenprop, matching the implementation inpackages/ctablex-core/src/contents/null-content.tsx.
fb8c41d to
4449749
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/ctablex-core/src/contents/content.test.tsx (1)
337-495: Comprehensive NonEmptyContent/EmptyContent coverage, with a small DRY opportunityThe
non empty contenttests exercise all key cases (null, undefined, empty/non-empty arrays, and custom object-basedisEmpty), and validate interaction withEmptyContentand list rendering. Together with theempty contenttests they give strong coverage of the shared emptiness semantics.Minor suggestion: the
isEmpty = (content: object) => Object.keys(content).length === 0;helper is defined multiple times (here and again in theempty contentblock). You could factor this into a shared top-level helper to reduce duplication and make it easier to tweak the object-emptiness rule in one place:@@ -import { NonEmptyContent } from './non-empty-content'; +import { NonEmptyContent } from './non-empty-content'; + +const isObjectEmpty = (content: object) => Object.keys(content).length === 0; @@ - const isEmpty = (content: object) => { - return Object.keys(content).length === 0; - }; + const isEmpty = isObjectEmpty; @@ - const isEmpty = (content: object) => { - return Object.keys(content).length === 0; - }; + const isEmpty = isObjectEmpty; @@ - const isEmpty = (content: object) => { - return Object.keys(content).length === 0; - }; + const isEmpty = isObjectEmpty;Purely optional, tests are fine as-is.
Also applies to: 553-556
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/ctablex-core/index.d.ts(3 hunks)packages/ctablex-core/src/contents/content.test.tsx(2 hunks)packages/ctablex-core/src/contents/empty-content.tsx(1 hunks)packages/ctablex-core/src/contents/non-empty-content.tsx(1 hunks)packages/ctablex-core/src/contents/null-content.tsx(1 hunks)packages/ctablex-core/src/index.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/ctablex-core/index.d.ts
- packages/ctablex-core/src/contents/null-content.tsx
- packages/ctablex-core/src/index.ts
🧰 Additional context used
🧬 Code graph analysis (1)
packages/ctablex-core/src/contents/empty-content.tsx (1)
packages/ctablex-core/src/index.ts (3)
EmptyContentProps(13-13)EmptyContent(12-12)useContent(4-4)
🔇 Additional comments (7)
packages/ctablex-core/src/contents/non-empty-content.tsx (1)
5-16: NonEmptyContent logic and reuse ofdefaultIsEmptylook solidThe generic props typing, use of
useContent<C>(), and the null/undefined +isEmptycheck correctly mirrorEmptyContentwith inverted rendering semantics. Importing and reusingdefaultIsEmptyavoids duplication and keeps the “emptiness” definition centralized. No changes needed.packages/ctablex-core/src/contents/content.test.tsx (5)
12-14: New content component imports are consistentImporting
NullContent,EmptyContent, andNonEmptyContenthere matches the new components added in the contents module and keeps this test suite as the central place validating their interactions. Looks consistent and clear.
248-300: NullableContent scenarios are well coveredThese four tests nicely pin down
NullableContentbehavior fornull,undefined, customnullContent, and non-null content. They give good confidence thatNullableContentneither swallows real data nor renders children when content is actually null/undefined.
302-335: NullContent behavior is clearly specified by testsThe
null contentdescribe block cleanly encodes the contract: render children only fornull/undefined, and render nothing for non-null values. This aligns well with the intended semantics and keeps behavior around “nullish” content unambiguous.
497-566: EmptyContent tests match intended emptiness semanticsThese cases clearly establish that
EmptyContenttreatsnull,undefined, and empty arrays (or custom-isEmptyempties) as “empty”, while skipping rendering for non-empty arrays and non-array values. This aligns withdefaultIsEmptyand helps prevent surprises for primitive values.
568-623: Mixed null/empty tests nicely validate component compositionThe
mixed null and emptyblock is very helpful: it confirms thatNullableContent’snullContenttakes precedence when content isnull/undefined, and that for non-nullish values it delegates correctly toEmptyContent+ArrayContent. This gives high confidence that these wrappers compose correctly in real UIs.packages/ctablex-core/src/contents/empty-content.tsx (1)
4-20: EmptyContent anddefaultIsEmptyare simple and correctly factored
EmptyContent’s logic (render on null/undefined orisEmpty(content)) plus the exporteddefaultIsEmptyfor empty arrays is clear and matches the test expectations. ReusingdefaultIsEmptyfrom other components keeps the notion of “empty” centralized. No changes needed.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.