@katn30/trakr 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -306,16 +306,16 @@ function openEditModal(model: PersonModel) {
|
|
|
306
306
|
model,
|
|
307
307
|
onConfirm: () => session.end(),
|
|
308
308
|
onCancel: () => session.rollback(),
|
|
309
|
-
canSave: () => session.
|
|
309
|
+
canSave: () => session.canCommit,
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
312
|
```
|
|
313
313
|
|
|
314
|
-
**`isDirty`** is `false` when the session starts (even if other objects are already dirty elsewhere), and becomes `true` the moment the user writes to any property listed in the scope.
|
|
314
|
+
**`isDirty`** is `false` when the session starts (even if other objects are already dirty elsewhere), and becomes `true` the moment the user writes to any property listed in the scope. Defaults to `false` when no scope is provided.
|
|
315
315
|
|
|
316
|
-
**`isValid`** checks `validationMessages` for every declared property. If any has a validation error — including one that existed *before* the session started — `isValid` is `false`, keeping the save button disabled until the user resolves it.
|
|
316
|
+
**`isValid`** checks `validationMessages` for every declared property. If any has a validation error — including one that existed *before* the session started — `isValid` is `false`, keeping the save button disabled until the user resolves it. Defaults to `true` when no scope is provided.
|
|
317
317
|
|
|
318
|
-
|
|
318
|
+
**`canCommit`** is `true` when `isDirty && isValid` — ready to enable a save button.
|
|
319
319
|
|
|
320
320
|
**Multiple objects in scope**
|
|
321
321
|
|
|
@@ -617,6 +617,12 @@ const session = tracker.startSession(); // begin a session
|
|
|
617
617
|
const session = tracker.startSession([…]); // same, with a property scope
|
|
618
618
|
session.end(); // commit — all changes become one undo step
|
|
619
619
|
session.rollback(); // revert — all changes since startSession
|
|
620
|
+
|
|
621
|
+
session.isDirty; // false until a scoped property is written
|
|
622
|
+
session.isValid; // false if any scoped property has a validation error
|
|
623
|
+
session.canCommit; // isDirty && isValid
|
|
624
|
+
session.trackedObjects; // objects in scope ([] when no scope)
|
|
625
|
+
session.deletedObjects; // scoped objects in Deleted state
|
|
620
626
|
```
|
|
621
627
|
|
|
622
628
|
**Object construction**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@katn30/trakr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "TypeScript state-management library implementing the Unit of Work pattern, with object tracking for undo/redo and validation support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/prod/index.cjs",
|