sliftutils 0.54.0 → 0.56.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/index.d.ts CHANGED
@@ -231,7 +231,32 @@ declare module "sliftutils/render-utils/Input" {
231
231
 
232
232
  declare module "sliftutils/render-utils/InputLabel" {
233
233
  import preact from "preact";
234
- import { InputProps } from "./Input";
234
+ type InputProps = (preact.JSX.HTMLAttributes<HTMLInputElement> & {
235
+ /** ONLY throttles onChangeValue */
236
+ throttle?: number;
237
+ flavor?: "large" | "small" | "none";
238
+ focusOnMount?: boolean;
239
+ textarea?: boolean;
240
+ /** Update on key stroke, not on blur (just does onInput = onChange, as onInput already does this) */
241
+ hot?: boolean;
242
+ /** Updates arrow keys with modifier behavior to use larger numbers, instead of decimals. */
243
+ integer?: boolean;
244
+ /** Only works with number/integer */
245
+ reverseArrowKeyDirection?: boolean;
246
+ inputRef?: (x: HTMLInputElement | null) => void;
247
+ /** Don't blur on enter key */
248
+ noEnterKeyBlur?: boolean;
249
+ noFocusSelect?: boolean;
250
+ inputKey?: string;
251
+ fillWidth?: boolean;
252
+ autocompleteValues?: string[];
253
+ /** Forces the input to update when focused. Usually we hold updates, to prevent the user's
254
+ * typing to be interrupted by background updates.
255
+ * NOTE: "hot" is usually required when using this.
256
+ */
257
+ forceInputValueUpdatesWhenFocused?: boolean;
258
+ onChangeValue?: (value: string) => void;
259
+ });
235
260
  export type InputLabelProps = Omit<InputProps, "label" | "title"> & {
236
261
  label?: preact.ComponentChild;
237
262
  number?: boolean;
@@ -266,6 +291,7 @@ declare module "sliftutils/render-utils/InputLabel" {
266
291
  }> {
267
292
  render(): preact.JSX.Element;
268
293
  }
294
+ export {};
269
295
 
270
296
  }
271
297
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "0.54.0",
3
+ "version": "0.56.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -48,7 +48,7 @@
48
48
  "mobx": "^6.13.3",
49
49
  "preact": "10.24.3",
50
50
  "shell-quote": "^1.8.3",
51
- "socket-function": "^0.162.0",
51
+ "socket-function": "^0.163.0",
52
52
  "typenode": "^6.0.0",
53
53
  "typesafecss": "*",
54
54
  "ws": "^8.18.3",
@@ -9,6 +9,7 @@ import { throttleFunction } from "socket-function/src/misc";
9
9
  // This is useful for inputs which you want to run an action on, such as "add new item",
10
10
  // as it allows you to remove a local state value to cache the value, by just
11
11
  // doing the add on "onChangeValue".
12
+ // IMPORTANT! InputProps is in both InputLabel.tsx and Input.tsx, so the types export correctly
12
13
  export type InputProps = (
13
14
  preact.JSX.HTMLAttributes<HTMLInputElement>
14
15
  & {
@@ -1,5 +1,30 @@
1
1
  import preact from "preact";
2
- import { InputProps } from "./Input";
2
+ type InputProps = (preact.JSX.HTMLAttributes<HTMLInputElement> & {
3
+ /** ONLY throttles onChangeValue */
4
+ throttle?: number;
5
+ flavor?: "large" | "small" | "none";
6
+ focusOnMount?: boolean;
7
+ textarea?: boolean;
8
+ /** Update on key stroke, not on blur (just does onInput = onChange, as onInput already does this) */
9
+ hot?: boolean;
10
+ /** Updates arrow keys with modifier behavior to use larger numbers, instead of decimals. */
11
+ integer?: boolean;
12
+ /** Only works with number/integer */
13
+ reverseArrowKeyDirection?: boolean;
14
+ inputRef?: (x: HTMLInputElement | null) => void;
15
+ /** Don't blur on enter key */
16
+ noEnterKeyBlur?: boolean;
17
+ noFocusSelect?: boolean;
18
+ inputKey?: string;
19
+ fillWidth?: boolean;
20
+ autocompleteValues?: string[];
21
+ /** Forces the input to update when focused. Usually we hold updates, to prevent the user's
22
+ * typing to be interrupted by background updates.
23
+ * NOTE: "hot" is usually required when using this.
24
+ */
25
+ forceInputValueUpdatesWhenFocused?: boolean;
26
+ onChangeValue?: (value: string) => void;
27
+ });
3
28
  export type InputLabelProps = Omit<InputProps, "label" | "title"> & {
4
29
  label?: preact.ComponentChild;
5
30
  number?: boolean;
@@ -34,3 +59,4 @@ export declare class InputLabelURL extends preact.Component<InputLabelProps & {
34
59
  }> {
35
60
  render(): preact.JSX.Element;
36
61
  }
62
+ export {};
@@ -1,10 +1,50 @@
1
1
  import preact from "preact";
2
- import { Input, InputProps } from "./Input";
2
+ import { Input } from "./Input";
3
3
  import { css } from "typesafecss";
4
4
  import { lazy } from "socket-function/src/caching";
5
5
  import { observer } from "./observer";
6
6
  import { observable } from "mobx";
7
7
 
8
+ // IMPORTANT! InputProps is in both InputLabel.tsx and Input.tsx, so the types export correctly
9
+ type InputProps = (
10
+ preact.JSX.HTMLAttributes<HTMLInputElement>
11
+ & {
12
+ /** ONLY throttles onChangeValue */
13
+ throttle?: number;
14
+
15
+ flavor?: "large" | "small" | "none";
16
+ focusOnMount?: boolean;
17
+ textarea?: boolean;
18
+ /** Update on key stroke, not on blur (just does onInput = onChange, as onInput already does this) */
19
+ hot?: boolean;
20
+ /** Updates arrow keys with modifier behavior to use larger numbers, instead of decimals. */
21
+ integer?: boolean;
22
+
23
+ /** Only works with number/integer */
24
+ reverseArrowKeyDirection?: boolean;
25
+
26
+ inputRef?: (x: HTMLInputElement | null) => void;
27
+ /** Don't blur on enter key */
28
+ noEnterKeyBlur?: boolean;
29
+ noFocusSelect?: boolean;
30
+ inputKey?: string;
31
+ fillWidth?: boolean;
32
+
33
+
34
+ autocompleteValues?: string[];
35
+
36
+ /** Forces the input to update when focused. Usually we hold updates, to prevent the user's
37
+ * typing to be interrupted by background updates.
38
+ * NOTE: "hot" is usually required when using this.
39
+ */
40
+ forceInputValueUpdatesWhenFocused?: boolean;
41
+
42
+ // NOTE: We trigger onChange (and onChangeValue) whenever
43
+ // e.ctrlKey && (e.code.startsWith("Key") || e.code === "Enter") || e.code === "Enter" && e.shiftKey
44
+ // This is because ctrl usually means a hotkey, and hotkeys usually want committed values.
45
+ onChangeValue?: (value: string) => void;
46
+ }
47
+ )
8
48
 
9
49
  export type InputLabelProps = Omit<InputProps, "label" | "title"> & {
10
50
  label?: preact.ComponentChild;
package/yarn.lock CHANGED
@@ -1494,10 +1494,10 @@ slash@^3.0.0:
1494
1494
  resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
1495
1495
  integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==
1496
1496
 
1497
- socket-function@^0.162.0:
1498
- version "0.162.0"
1499
- resolved "https://registry.yarnpkg.com/socket-function/-/socket-function-0.162.0.tgz#659dcff669a777c765c2d609ce733ee3674bb468"
1500
- integrity sha512-vBlGEWbYtPIAYSG9qmBuZ1Yec8fetIDzPR6TzKFOHXOlWtwq4W/rHz3aALw+afLNGBpJs4SI21WrS8efOepN/A==
1497
+ socket-function@^0.163.0:
1498
+ version "0.163.0"
1499
+ resolved "https://registry.yarnpkg.com/socket-function/-/socket-function-0.163.0.tgz#90f70833a10d6fa2fe2be65713d84a7c9be124d9"
1500
+ integrity sha512-ufJZDIn2ZOpP8cnMh+B9NQZF2NNRS1HJB/bd4JL+9ZKv2E218epdrGmWh6OrQs2+8L1UPB51HJj0uLniHLM7nA==
1501
1501
  dependencies:
1502
1502
  "@types/pako" "^2.0.3"
1503
1503
  "@types/ws" "^8.5.3"