sliftutils 0.55.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 +27 -1
- package/package.json +1 -1
- package/render-utils/Input.tsx +1 -0
- package/render-utils/InputLabel.d.ts +27 -1
- package/render-utils/InputLabel.tsx +41 -1
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
|
-
|
|
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
package/render-utils/Input.tsx
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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;
|