feat(core): add Sugar#useTransform method#75
Conversation
- Add useTransform method to create connected sugars with bidirectional transformation - Implement SugarTransformConfig and SugarUseTransform types - Add useTransform to SugarInner class following useObject pattern - Include NullableStringInput example test case from issue #14 - Support async forward/backward transformation functions - Maintain proper event propagation between original and transformed sugars - close #14 Co-Authored-By: あすぱる <contact@aspulse.dev>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
@@ Coverage Diff @@
## main #75 +/- ##
==========================================
- Coverage 81.15% 80.11% -1.05%
==========================================
Files 7 8 +1
Lines 329 362 +33
Branches 80 85 +5
==========================================
+ Hits 267 290 +23
- Misses 62 72 +10
|
Bundle ReportChanges will increase total bundle size by 9.45kB (10.47%) ⬆️
Affected Assets, Files, and Routes:view changes for bundle: esm-@sugarform/coreAssets Changed:
view changes for bundle: all-@sugarform/coreAssets Changed:
view changes for bundle: cjs-@sugarform/coreAssets Changed:
|
- Fix template initialization to use original sugar's template with proper casting - Add Japanese explanatory comments for non-null assertions following useObject pattern - Remove unnecessary async Promise-based initialization that caused test failures - Ensure synchronous initialization for proper component attachment Co-Authored-By: あすぱる <contact@aspulse.dev>
|
|
Co-Authored-By: あすぱる <contact@aspulse.dev>
…mplate pattern
- Combine useTransform and useIsPending imports in index.ts and types.ts
- Update useTransform to use new { status: 'pending' } template initialization
- Add proper template synchronization with original sugar's template state
- Add explanatory comments for non-null assertions following codebase conventions
Co-Authored-By: あすぱる <contact@aspulse.dev>
Add Sugar#useTransform method
This PR implements the
Sugar#useTransformmethod requested in issue #14, which allows creating a new Sugar instance connected to an existing Sugar with bidirectional transformation functions.Features
forwardandbackwardtransformation functionsSugar#useTransform#14 where empty strings can be converted to nullAPI
Implementation Details
useObjectanduseValidationsetTemplatefunctionalityTesting
Files Changed
packages/core/src/sugar/types.ts- Added type definitionspackages/core/src/sugar/useTransform.ts- Core implementationpackages/core/src/sugar/index.ts- Added method to SugarInner classtests/core-unittest/src/useTransform-simple.spec.tsx- Test casesLink to Devin run: https://app.devin.ai/sessions/87157fa55aed4027ac092aeb3a6a7ba7
Sugar#useTransform#14