@koordinates/xstate-tree 4.10.0 → 4.11.1

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.
@@ -16,7 +16,9 @@ function singleSlot(name) {
16
16
  return {
17
17
  type: SlotType.SingleSlot,
18
18
  name,
19
- getId: () => `${name.toLowerCase()}-slot`,
19
+ getId: (suffix) => suffix
20
+ ? `${name.toLowerCase()}-${suffix}-slot`
21
+ : `${name.toLowerCase()}-slot`,
20
22
  };
21
23
  }
22
24
  exports.singleSlot = singleSlot;
@@ -27,7 +29,9 @@ function multiSlot(name) {
27
29
  return {
28
30
  type: SlotType.MultiSlot,
29
31
  name: `${name}Multi`,
30
- getId: (id) => `${id}-${name.toLowerCase()}multi-slots`,
32
+ getId: (id, suffix) => suffix
33
+ ? `${id}-${name.toLowerCase()}multi-slots-${suffix}`
34
+ : `${id}-${name.toLowerCase()}multi-slots`,
31
35
  };
32
36
  }
33
37
  exports.multiSlot = multiSlot;
@@ -450,7 +450,7 @@ export declare type Meta<T> = T extends {
450
450
  export declare type MultiSlot<T extends string> = {
451
451
  type: SlotType.MultiSlot;
452
452
  name: `${T}Multi`;
453
- getId(id: string): string;
453
+ getId(id: string, suffix?: string): string;
454
454
  };
455
455
 
456
456
  /**
@@ -742,7 +742,7 @@ export declare type SharedMeta = {
742
742
  export declare type SingleSlot<T extends string> = {
743
743
  type: SlotType.SingleSlot;
744
744
  name: T;
745
- getId(): string;
745
+ getId(suffix?: string): string;
746
746
  };
747
747
 
748
748
  /**
package/lib/xstateTree.js CHANGED
@@ -113,7 +113,13 @@ function useSlots(interpreter, slots) {
113
113
  return react_2.default.createElement(MultiView, null);
114
114
  }
115
115
  else {
116
- const interpreterForSlot = children.get(`${slot.toLowerCase()}-slot`);
116
+ const slotPrefix = `${slot.toLowerCase()}-`;
117
+ const childKey = [...children.keys()].find((key) => typeof key === "string" &&
118
+ key.startsWith(slotPrefix) &&
119
+ key.endsWith("-slot"));
120
+ const interpreterForSlot = childKey
121
+ ? children.get(childKey)
122
+ : undefined;
117
123
  if (interpreterForSlot) {
118
124
  const View = getViewForInterpreter(interpreterForSlot);
119
125
  return react_2.default.createElement(View, null);
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": "4.10.0",
5
+ "version": "4.11.1",
6
6
  "license": "MIT",
7
7
  "description": "Build UIs with Actors using xstate and React",
8
8
  "keywords": [