sliftutils 0.51.0 → 0.53.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/.cursorrules CHANGED
@@ -84,6 +84,14 @@ Coding Styles
84
84
  Use ref={elem => } callbacks. NEVER use .createRef.
85
85
 
86
86
  NEVER render images with a fixed width+height. This will cause them to be stretched or cut off. This is terrible. Only set the width or height.
87
+
88
+ Callback held should be avoided by using async and `import { PromiseObj } from "socket-function/src/misc";`. Most of the time, if there's an event callback, you should wrap it with a promise obj so that you can wait for it asynchronously.
89
+
90
+ `import { keyBy, keyByArray } from "socket-function/src/misc";` Should be used when you need to create lookups from lists and you know what key you want. This can clobber values, or it can gather in an array.
91
+ let example: Map<number, { x: number }> = keyBy([{ x: 5 }, { x: 6 }]);
92
+ let example: Map<number, { x: number }[]> = keyByArrat([{ x: 5 }, { x: 5, version: 2 } { x: 6 }]);
93
+
94
+ Never use alert. If there's an error, you should throw it.
87
95
 
88
96
 
89
97
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "0.51.0",
3
+ "version": "0.53.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -65,7 +65,7 @@ export class FullscreenModal extends preact.Component<{
65
65
  display: "flex",
66
66
  flexDirection: "column",
67
67
  gap: 10,
68
- maxHeight: "calc(100% - 200px)",
68
+ maxHeight: "100%",
69
69
  overflow: "auto",
70
70
  ...this.props.style
71
71
  }}
@@ -3,6 +3,7 @@ import { observable } from "mobx";
3
3
  import * as mobx from "mobx";
4
4
  import { observer } from "./observer";
5
5
  import { lazy } from "socket-function/src/caching";
6
+ import { nextId } from "socket-function/src/misc";
6
7
 
7
8
  type ModalData = {
8
9
  contents: preact.ComponentChildren;
@@ -31,7 +32,6 @@ const ensureRootMounted = lazy(() => {
31
32
  preact.render(<ModalRoot />, root);
32
33
  });
33
34
 
34
- let modalIdCounter = 0;
35
35
 
36
36
  function closeModal(id: string) {
37
37
  const modal = activeModals[id];
@@ -54,7 +54,7 @@ export function showModal(config: {
54
54
  } {
55
55
  ensureRootMounted();
56
56
 
57
- const id = `modal-${modalIdCounter++}`;
57
+ const id = `modal-${nextId()}`;
58
58
  activeModals[id] = {
59
59
  contents: config.contents,
60
60
  onClose: config.onClose