sliftutils 0.43.0 → 0.44.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -4,20 +4,19 @@ import * as mobx from "mobx";
4
4
  import { observer } from "./observer";
5
5
  import { lazy } from "socket-function/src/caching";
6
6
 
7
- // Global observable map to store all active modals
8
- const activeModals = new mobx.ObservableMap<string, preact.ComponentChildren>();
7
+ const activeModals = observable({} as { [key: string]: preact.ComponentChildren }, undefined, { deep: false });
9
8
 
10
9
  @observer
11
10
  class ModalRoot extends preact.Component {
12
11
  render() {
13
- const modals: Array<[string, preact.ComponentChildren]> = Array.from(activeModals.entries());
14
- return <>
12
+ const modals: Array<[string, preact.ComponentChildren]> = Object.entries(activeModals);
13
+ return <div>
15
14
  {modals.map(([id, contents]) => (
16
15
  <div key={id}>
17
16
  {contents}
18
17
  </div>
19
18
  ))}
20
- </>;
19
+ </div>;
21
20
  }
22
21
  }
23
22
 
@@ -37,15 +36,17 @@ export function showModal(config: {
37
36
  ensureRootMounted();
38
37
 
39
38
  const id = `modal-${modalIdCounter++}`;
40
- activeModals.set(id, config.contents);
39
+ activeModals[id] = config.contents;
41
40
 
42
41
  return {
43
42
  close() {
44
- activeModals.delete(id);
43
+ delete activeModals[id];
45
44
  }
46
45
  };
47
46
  }
48
47
 
49
48
  export function closeAllModals() {
50
- activeModals.clear();
49
+ for (let key in activeModals) {
50
+ delete activeModals[key];
51
+ }
51
52
  }