@streamscloud/kit 0.90.1 → 0.92.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/dist/core/validation/form-validation-handler/form-validation-handler.svelte.d.ts +20 -8
- package/dist/core/validation/form-validation-handler/form-validation-handler.svelte.js +80 -63
- package/dist/core/validation/form-validation-handler/index.d.ts +1 -1
- package/dist/core/validation/form-validation-handler/types.d.ts +4 -0
- package/dist/core/validation/form-validation-handler/validation-helper.d.ts +6 -0
- package/dist/core/validation/form-validation-handler/validation-helper.js +27 -0
- package/dist/styles/_semantic.scss +0 -1
- package/dist/ui/_internal/_top-layer.scss +10 -0
- package/dist/ui/_internal/input-emoji-picker/cmp.input-emoji-picker.svelte +1 -1
- package/dist/ui/_internal/top-layer/index.d.ts +1 -0
- package/dist/ui/_internal/top-layer/index.js +6 -0
- package/dist/ui/breadcrumb/cmp.breadcrumb.svelte +4 -11
- package/dist/ui/color-picker/cmp.color-picker.svelte +0 -1
- package/dist/ui/date-picker/cmp.date-picker.svelte +50 -100
- package/dist/ui/date-picker/cmp.date-picker.svelte.d.ts +1 -1
- package/dist/ui/form-field/cmp.form-field-validatable.svelte +2 -9
- package/dist/ui/form-field/cmp.form-field-validatable.svelte.d.ts +3 -7
- package/dist/ui/player/buttons/player-context-menu.svelte +1 -1
- package/dist/ui/popover/cmp.hover-popover.svelte.d.ts +0 -1
- package/dist/ui/popover/cmp.popover.svelte +84 -41
- package/dist/ui/popover/cmp.popover.svelte.d.ts +15 -9
- package/dist/ui/select/cmp.multiselect.svelte.d.ts +1 -1
- package/dist/ui/select/select-listbox.svelte +17 -9
- package/dist/ui/tile-card/cmp.tile-card.svelte +0 -1
- package/dist/ui/toast/cmp.toaster.svelte +0 -4
- package/dist/ui/tooltip/cmp.tooltip.svelte +15 -8
- package/dist/ui/tooltip/cmp.tooltip.svelte.d.ts +0 -1
- package/dist/ui/tree/cmp.tree-node-view.svelte +1 -1
- package/dist/ui/url-input/cmp.url-input.svelte +1 -1
- package/dist/ui/validatable/cmp.validatable.svelte +9 -46
- package/dist/ui/validatable/cmp.validatable.svelte.d.ts +4 -29
- package/dist/ui/validatable/index.d.ts +1 -2
- package/dist/ui/validatable/types.d.ts +12 -0
- package/package.json +1 -1
|
@@ -1,33 +1,9 @@
|
|
|
1
|
-
<script lang="ts"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { default as FieldFrame } from './field-frame.svelte';
|
|
6
|
-
let { handler, name, validateOn = ['input', 'change', 'blur'], debounceMs = 0, disableTouchedTracking = false, errorPlacement = 'overlay', on, children } = $props();
|
|
7
|
-
// True between a value change and the next completed validation. Hides the stale error in the
|
|
8
|
-
// UI without mutating handler.errors — the model keeps the last known result, the view just
|
|
9
|
-
// doesn't trust it until the validator has caught up.
|
|
10
|
-
let pendingValidation = $state(false);
|
|
11
|
-
// Monotonic counter: each value change and each validation start bumps it. Completing
|
|
12
|
-
// validation clears `pendingValidation` only when the token still matches the latest bump —
|
|
13
|
-
// this discards results from validations that were superseded by further input.
|
|
14
|
-
let activeToken = 0;
|
|
15
|
-
const runValidate = async () => {
|
|
16
|
-
const myToken = ++activeToken;
|
|
17
|
-
try {
|
|
18
|
-
await handler.validateField(name);
|
|
19
|
-
}
|
|
20
|
-
finally {
|
|
21
|
-
// A rejecting validator would otherwise strand pendingValidation, and the children snippet reads it as a never-ending `validating`.
|
|
22
|
-
if (myToken === activeToken) {
|
|
23
|
-
pendingValidation = false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const validate = $derived(debounceMs > 0 ? Utils.debounce(runValidate, debounceMs) : runValidate);
|
|
28
|
-
const runs = (mode) => validateOn.includes(mode);
|
|
29
|
-
const showErrors = $derived(!pendingValidation && !!handler.errors[name] && (disableTouchedTracking || !!handler.touched[name]));
|
|
1
|
+
<script lang="ts" generics="T extends Record<string, unknown>, K extends keyof T & string">import { default as FieldFrame } from './field-frame.svelte';
|
|
2
|
+
let { handler, name, debounceMs = 0, disableTouchedTracking = false, errorPlacement = 'overlay', on, children } = $props();
|
|
3
|
+
const validating = $derived(handler.isFieldValidating(name));
|
|
4
|
+
const showErrors = $derived(!validating && !!handler.errors[name] && (disableTouchedTracking || !!handler.touched[name]));
|
|
30
5
|
const messageId = $props.id();
|
|
6
|
+
const validate = () => void handler.validateField(name, { debounceMs, onlyIfChanged: true });
|
|
31
7
|
const field = $derived({
|
|
32
8
|
name,
|
|
33
9
|
value: handler.form[name],
|
|
@@ -36,30 +12,17 @@ const field = $derived({
|
|
|
36
12
|
on: {
|
|
37
13
|
input: (v) => {
|
|
38
14
|
handler.updateField(name, v);
|
|
39
|
-
|
|
40
|
-
pendingValidation = true;
|
|
41
|
-
if (runs('input')) {
|
|
42
|
-
validate();
|
|
43
|
-
}
|
|
15
|
+
validate();
|
|
44
16
|
on?.input?.(v);
|
|
45
17
|
},
|
|
46
18
|
change: (v) => {
|
|
47
19
|
handler.updateField(name, v);
|
|
48
|
-
|
|
49
|
-
pendingValidation = true;
|
|
50
|
-
if (runs('change')) {
|
|
51
|
-
validate();
|
|
52
|
-
}
|
|
20
|
+
validate();
|
|
53
21
|
on?.change?.(v);
|
|
54
22
|
},
|
|
55
23
|
blur: () => {
|
|
56
24
|
handler.updateTouched(name, true);
|
|
57
|
-
|
|
58
|
-
validate();
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
pendingValidation = false;
|
|
62
|
-
}
|
|
25
|
+
validate();
|
|
63
26
|
on?.blur?.();
|
|
64
27
|
}
|
|
65
28
|
}
|
|
@@ -67,7 +30,7 @@ const field = $derived({
|
|
|
67
30
|
</script>
|
|
68
31
|
|
|
69
32
|
<FieldFrame error={showErrors ? handler.errors[name] : null} errorPlacement={errorPlacement} messageId={messageId}>
|
|
70
|
-
{@render children(field,
|
|
33
|
+
{@render children(field, validating)}
|
|
71
34
|
</FieldFrame>
|
|
72
35
|
|
|
73
36
|
<!--
|
|
@@ -1,37 +1,13 @@
|
|
|
1
|
-
export type ValidateOnEvent = 'input' | 'change' | 'blur';
|
|
2
|
-
export type FieldBinding<V> = {
|
|
3
|
-
name: string;
|
|
4
|
-
value: V;
|
|
5
|
-
error: boolean;
|
|
6
|
-
/** Id of the visible error message, set only while the error is shown. */
|
|
7
|
-
'aria-describedby'?: string;
|
|
8
|
-
on: {
|
|
9
|
-
input: (v: V) => void;
|
|
10
|
-
change: (v: V) => void;
|
|
11
|
-
blur: () => void;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
1
|
import type { FormValidationHandler } from '../../core/validation';
|
|
15
|
-
import type { ErrorPlacement } from './types';
|
|
2
|
+
import type { ErrorPlacement, FieldBinding } from './types';
|
|
16
3
|
import type { Snippet } from 'svelte';
|
|
17
4
|
declare function $$render<T extends Record<string, unknown>, K extends keyof T & string>(): {
|
|
18
5
|
props: {
|
|
19
|
-
/** Form validation handler instance. */
|
|
20
6
|
handler: FormValidationHandler<T>;
|
|
21
|
-
/** Field name in the form handler. */
|
|
22
7
|
name: K;
|
|
23
|
-
/**
|
|
24
|
-
* Which events trigger validation. Value is always updated synchronously on `input`/`change`
|
|
25
|
-
* regardless of this option — it only controls when the validator runs.
|
|
26
|
-
* @default ['input', 'change', 'blur']
|
|
27
|
-
*/
|
|
28
|
-
validateOn?: ValidateOnEvent[];
|
|
29
|
-
/**
|
|
30
|
-
* Debounce validator calls in ms. Value update stays sync; only validation is delayed.
|
|
31
|
-
* @default 0
|
|
32
|
-
*/
|
|
8
|
+
/** Delay before the validator runs after the value changes; the value itself updates at once. */
|
|
33
9
|
debounceMs?: number;
|
|
34
|
-
/** Show errors even when the field has not been touched.
|
|
10
|
+
/** Show errors even when the field has not been touched. */
|
|
35
11
|
disableTouchedTracking?: boolean;
|
|
36
12
|
/**
|
|
37
13
|
* Where the error message sits: `'overlay'` covers whatever is below the field, `'reserved'` keeps a
|
|
@@ -51,8 +27,7 @@ declare function $$render<T extends Record<string, unknown>, K extends keyof T &
|
|
|
51
27
|
/**
|
|
52
28
|
* Receives a wired `FieldBinding<T[K]>` to spread into a kit input (`aria-describedby` points at the visible error message; inputs without that
|
|
53
29
|
* prop ignore it; a control whose value prop is not `value`, e.g. `Checkbox`, is wired by hand), plus a `validating` flag — true from the value
|
|
54
|
-
* change until the validator has caught up, debounce window included
|
|
55
|
-
* excludes `input` and `change` the flag stays true for the whole typing session.
|
|
30
|
+
* change until the validator has caught up, debounce window included.
|
|
56
31
|
*/
|
|
57
32
|
children: Snippet<[FieldBinding<T[K]>, boolean]>;
|
|
58
33
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { default as Validatable } from './cmp.validatable.svelte';
|
|
2
|
-
export type { FieldBinding, ValidateOnEvent } from './cmp.validatable.svelte';
|
|
3
2
|
export { default as ValidationError } from './cmp.validation-error.svelte';
|
|
4
|
-
export type { ErrorPlacement } from './types';
|
|
3
|
+
export type { ErrorPlacement, FieldBinding } from './types';
|
|
@@ -5,3 +5,15 @@
|
|
|
5
5
|
* - `'inline'` — in normal flow, only while an error is shown: the field grows on error and shrinks back when it clears.
|
|
6
6
|
*/
|
|
7
7
|
export type ErrorPlacement = 'overlay' | 'reserved' | 'inline';
|
|
8
|
+
export type FieldBinding<V> = {
|
|
9
|
+
name: string;
|
|
10
|
+
value: V;
|
|
11
|
+
error: boolean;
|
|
12
|
+
/** Id of the visible error message, set only while the error is shown. */
|
|
13
|
+
'aria-describedby'?: string;
|
|
14
|
+
on: {
|
|
15
|
+
input: (v: V) => void;
|
|
16
|
+
change: (v: V) => void;
|
|
17
|
+
blur: () => void;
|
|
18
|
+
};
|
|
19
|
+
};
|