@koordinates/xstate-tree 3.0.0 → 4.0.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 CHANGED
@@ -164,8 +164,8 @@ Slots are how invoked/spawned children of the machine are supplied to the Machin
164
164
 
165
165
  Slotted machines are determined based on the id of the invoked/spawned machine. There are two types of slots, single and multi. Single slots are for invoked machines, where there will only be a single machine per slot. Multi slots are for spawned machines where there are multiple children per slot, rendered as a group; think lists. There is a set of helper functions for creating slots which in turn can be used to get the id for the slot.
166
166
 
167
- `singleSlot` accepts the name of the slot (must not end in `s`) as the first argument and returns an object with a method `getId()` that returns the id of the slot.
168
- `multiSlot` accepts the name of the slot (must end in `s`) and returns an object with a method `getId(id: string)` that returns the id of the slot
167
+ `singleSlot` accepts the name of the slot as the first argument and returns an object with a method `getId()` that returns the id of the slot.
168
+ `multiSlot` accepts the name of the slot and returns an object with a method `getId(id: string)` that returns the id of the slot
169
169
 
170
170
  You should always use the `getId` methods when invoking/spawning something into a slot. Each slot the machine has must be represented by a call to `singleSlot` or `multiSlot` and stored into an array of slots. These slots must be passed to the `buildView` and `buildXStateTreeMachine` functions.
171
171
 
@@ -22,7 +22,7 @@ export function singleSlot(name) {
22
22
  export function multiSlot(name) {
23
23
  return {
24
24
  type: SlotType.MultiSlot,
25
- name,
26
- getId: (id) => `${id}-${name.toLowerCase()}-slots`,
25
+ name: `${name}Multi`,
26
+ getId: (id) => `${id}-${name.toLowerCase()}multi-slots`,
27
27
  };
28
28
  }
@@ -361,9 +361,9 @@ export declare type Meta<T> = T extends {
361
361
  /**
362
362
  * @public
363
363
  */
364
- export declare type MultiSlot<T> = {
364
+ export declare type MultiSlot<T extends string> = {
365
365
  type: SlotType.MultiSlot;
366
- name: T;
366
+ name: `${T}Multi`;
367
367
  getId(id: string): string;
368
368
  };
369
369
 
@@ -612,7 +612,7 @@ export declare type SharedMeta = {
612
612
  /**
613
613
  * @public
614
614
  */
615
- export declare type SingleSlot<T> = {
615
+ export declare type SingleSlot<T extends string> = {
616
616
  type: SlotType.SingleSlot;
617
617
  name: T;
618
618
  getId(): string;
package/lib/xstateTree.js CHANGED
@@ -77,7 +77,8 @@ function useSlots(interpreter, slots) {
77
77
  [slot]: () => {
78
78
  // eslint-disable-next-line react-hooks/rules-of-hooks
79
79
  const [__, children] = useService(interpreter);
80
- if (slot.toString().endsWith("s")) {
80
+ console.log(slot.toString());
81
+ if (slot.toString().endsWith("Multi")) {
81
82
  const MultiView = getMultiSlotViewForChildren(interpreter, slot.toLowerCase());
82
83
  return React.createElement(MultiView, null);
83
84
  }
@@ -237,7 +238,7 @@ export function buildRootComponent(machine, routing) {
237
238
  // params/query to ensure that all params/query are present
238
239
  query: { ...((_a = activeRoutesEvent.query) !== null && _a !== void 0 ? _a : {}) },
239
240
  params: { ...((_b = activeRoutesEvent.params) !== null && _b !== void 0 ? _b : {}) },
240
- meta: { ...((_c = activeRoutesEvent.meta) !== null && _c !== void 0 ? _c : {}) },
241
+ meta: { replace: true, ...((_c = activeRoutesEvent.meta) !== null && _c !== void 0 ? _c : {}) },
241
242
  });
242
243
  activeRoute.navigate(routeArguments);
243
244
  });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@koordinates/xstate-tree",
3
3
  "main": "lib/index.js",
4
4
  "types": "lib/xstate-tree.d.ts",
5
- "version": "3.0.0",
5
+ "version": "4.0.0",
6
6
  "license": "MIT",
7
7
  "description": "Build UIs with Actors using xstate and React",
8
8
  "keywords": [