Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the LineItems changeset inspection API.
No open issues 🎉
What changed in this PR
Adds net changeset inspection to LineItems, extending its local editing API so consumers can prepare persistence changes without maintaining their own diff logic. Inspection excludes unconfirmed drafts and does not validate, save, or advance the baseline.
Changes:
- Exposes
getChanges()andLineItemsChangesetfor additions, field updates, removals, and final ordering. - Shares property-level equality rules between changeset inspection and dirty detection.
- Adds runtime and type coverage for explicit clears, cancellation, draft exclusion, and render-local equality.
| File | Description |
|---|---|
packages/core/tests/dts/line-items-changes/check.tsx |
Verifies published changeset and equality types. |
packages/core/src/index.ts |
Exports the public changeset type. |
packages/core/src/components/line-items/use-line-items.ts |
Exposes inspection with render-local equality. |
packages/core/src/components/line-items/types.ts |
Adds the hook’s changeset contract. |
packages/core/src/components/line-items/index.ts |
Re-exports the changeset type. |
packages/core/src/components/line-items/document/types.ts |
Defines changeset results and property equality. |
packages/core/src/components/line-items/document/store.ts |
Exposes document inspection through the store. |
packages/core/src/components/line-items/document/model.ts |
Computes net changes and shares dirty-state comparison. |
packages/core/src/components/line-items/document/changes.test.ts |
Covers net changes, ordering, clears, and equality rules. |
packages/core/src/components/line-items/changes.test.tsx |
Covers retained getters, suspended renders, and draft exclusion. |
packages/core/src/components/line-items/changes.test-d.ts |
Checks public changeset and equality type constraints. |
Review effort: Balanced
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
LineItems already owns local editing and dirty-state detection, but consumers still need to calculate their own persistence differences. A dirty boolean alone cannot identify added lines, changed fields, removals, or the final document order, and it cannot distinguish an untouched field from an explicit clear.
This is an incremental PR into the LineItems integration branch (#710), covering LI-08, LI-09, LI-10, LI-11, LI-41, and LI-43 from the initial milestone checklist. Persistence and document-wide validation remain consumer responsibilities.
Design Decision
Inspect committed net state
Expose
getChanges()andLineItemsChangeset<TRow>withadded,updated,removed, andorderresults. Compare the saved baseline with current committed rows rather than retaining an operation history. Creation rows retain their complete current data; removals retain their baseline data; updates contain only changed accessor-owned fields, including ownundefinedkeys for explicit clears.Inspection does not confirm drafts, run validation, persist data, clear changes, or advance the baseline. Unconfirmed and rejected drafts are excluded without preventing inspection of other committed changes.
Share comparison rules without normalizing values
Property columns may supply
equals(baseline, current), defaulting toObject.is. BothisDirtyand changeset inspection use the same comparison, without changing adopted values. Duplicate displays inherit one explicit equality function per property; conflicting functions are rejected rather than letting column order choose the result.A getter retains its render's comparison configuration while reading current committed rows, so suspended renders do not mutate shared configuration.
orderis the complete final line-key sequence whenever ordered membership differs, including additions/removals;nullmeans unchanged and[]represents an emptied collection.Summary