rask-ui 0.9.2 → 0.10.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 +42 -0
- package/dist/createState.d.ts +1 -0
- package/dist/createState.d.ts.map +1 -1
- package/dist/createState.js +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -326,6 +326,48 @@ function Example() {
|
|
|
326
326
|
|
|
327
327
|
---
|
|
328
328
|
|
|
329
|
+
#### `assignState<T>(state, newState)`
|
|
330
|
+
|
|
331
|
+
Merges properties from a new state object into an existing reactive state object. This is a convenience function that uses `Object.assign` internally.
|
|
332
|
+
|
|
333
|
+
```tsx
|
|
334
|
+
import { assignState, createState } from "rask-ui";
|
|
335
|
+
|
|
336
|
+
function Example() {
|
|
337
|
+
const state = createState({
|
|
338
|
+
name: "Alice",
|
|
339
|
+
age: 30,
|
|
340
|
+
email: "alice@example.com",
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
const updateProfile = (updates) => {
|
|
344
|
+
assignState(state, updates);
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
return () => (
|
|
348
|
+
<div>
|
|
349
|
+
<p>{state.name} - {state.email}</p>
|
|
350
|
+
<button onClick={() => updateProfile({ name: "Bob", age: 35 })}>
|
|
351
|
+
Update Profile
|
|
352
|
+
</button>
|
|
353
|
+
</div>
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
**Parameters:**
|
|
359
|
+
|
|
360
|
+
- `state: T` - The reactive state object to update
|
|
361
|
+
- `newState: T` - Object with properties to merge into the state
|
|
362
|
+
|
|
363
|
+
**Notes:**
|
|
364
|
+
|
|
365
|
+
- Equivalent to `Object.assign(state, newState)`
|
|
366
|
+
- Triggers reactivity for all updated properties
|
|
367
|
+
- Useful for bulk state updates from form data or API responses
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
329
371
|
#### `createView<T>(...objects)`
|
|
330
372
|
|
|
331
373
|
Creates a view that merges multiple objects (reactive or plain) into a single object while maintaining reactivity through getters. Properties from later arguments override earlier ones.
|
package/dist/createState.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createState.d.ts","sourceRoot":"","sources":["../src/createState.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEzD;AAGD,eAAO,MAAM,YAAY,eAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"createState.d.ts","sourceRoot":"","sources":["../src/createState.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,QAElE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEzD;AAGD,eAAO,MAAM,YAAY,eAAoB,CAAC"}
|
package/dist/createState.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { INSPECT_MARKER, INSPECTOR_ENABLED } from "./inspect";
|
|
2
2
|
import { getCurrentObserver, Signal } from "./observation";
|
|
3
|
+
export function assignState(state, newState) {
|
|
4
|
+
Object.assign(state, newState);
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* Creates a reactive state object that tracks property access and notifies observers on changes.
|
|
5
8
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { render } from "./render";
|
|
2
2
|
export { createCleanup, createMountEffect, RaskStatefulComponent, RaskStatelessComponent, } from "./component";
|
|
3
3
|
export { createContext } from "./createContext";
|
|
4
|
-
export { createState } from "./createState";
|
|
4
|
+
export { createState, assignState } from "./createState";
|
|
5
5
|
export { createTask } from "./createTask";
|
|
6
6
|
export { ErrorBoundary } from "./error";
|
|
7
7
|
export { createRef } from "inferno";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,cAAc,EACd,SAAS,GACV,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { render } from "./render";
|
|
2
2
|
export { createCleanup, createMountEffect, RaskStatefulComponent, RaskStatelessComponent, } from "./component";
|
|
3
3
|
export { createContext } from "./createContext";
|
|
4
|
-
export { createState } from "./createState";
|
|
4
|
+
export { createState, assignState } from "./createState";
|
|
5
5
|
export { createTask } from "./createTask";
|
|
6
6
|
export { ErrorBoundary } from "./error";
|
|
7
7
|
export { createRef } from "inferno";
|