@streamscloud/kit 0.51.0 → 0.51.1
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.
|
@@ -3,19 +3,38 @@ import { Icon } from '../icon';
|
|
|
3
3
|
import { Tooltip } from '../tooltip';
|
|
4
4
|
import IconInfo from '@fluentui/svg-icons/icons/info_20_regular.svg?raw';
|
|
5
5
|
let { label, hint, required = false, children } = $props();
|
|
6
|
+
let rootEl = $state.raw(undefined);
|
|
7
|
+
let labelRowEl = $state.raw(undefined);
|
|
8
|
+
let swallowLabelActivation = false;
|
|
6
9
|
// Unhandled, the click activates the labelled field (a checkbox would toggle); cancelling it on interactive content would kill a link's navigation.
|
|
7
10
|
const swallowClick = (event) => {
|
|
8
11
|
event.stopPropagation();
|
|
12
|
+
// This click never reaches guardLabelActivation, so the flag would outlive the gesture and swallow a later keyboard-activated click.
|
|
13
|
+
swallowLabelActivation = false;
|
|
9
14
|
if (DomHelper.isInsideInteractive(event.target)) {
|
|
10
15
|
return;
|
|
11
16
|
}
|
|
12
17
|
event.preventDefault();
|
|
13
18
|
};
|
|
19
|
+
const isLabelChrome = (target) => target instanceof Node && (target === rootEl || !!labelRowEl?.contains(target));
|
|
20
|
+
// Read at mousedown: by click time the popup field has already dismissed itself and the forwarded activation would reopen it.
|
|
21
|
+
const rememberLabelActivation = (event) => {
|
|
22
|
+
swallowLabelActivation = isLabelChrome(event.target) && !!rootEl?.querySelector('[aria-haspopup][aria-expanded="true"]');
|
|
23
|
+
};
|
|
24
|
+
const guardLabelActivation = (event) => {
|
|
25
|
+
const swallow = swallowLabelActivation;
|
|
26
|
+
swallowLabelActivation = false;
|
|
27
|
+
if (swallow && isLabelChrome(event.target)) {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
14
31
|
</script>
|
|
15
32
|
|
|
16
|
-
|
|
33
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
34
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
35
|
+
<label bind:this={rootEl} class="form-field" onmousedown={rememberLabelActivation} onclick={guardLabelActivation}>
|
|
17
36
|
{#if label}
|
|
18
|
-
<span class="form-field__label">
|
|
37
|
+
<span bind:this={labelRowEl} class="form-field__label">
|
|
19
38
|
{#if typeof label === 'string'}
|
|
20
39
|
{label}
|
|
21
40
|
{:else}
|
|
@@ -45,6 +64,8 @@ const swallowClick = (event) => {
|
|
|
45
64
|
@component
|
|
46
65
|
FormField — pure layout shell: optional label (string or snippet) above an input slot. The root is a `<label>` element, so the first labelable form control inside is automatically associated via HTML's implicit-association rule — no id wiring required. Does NOT render errors or helper text; pair with `Validatable` for that.
|
|
47
66
|
|
|
67
|
+
Clicking the label opens a popup field inside it (select, date picker) but never re-opens one that is already expanded — that click dismisses it, exactly like a click on empty space.
|
|
68
|
+
|
|
48
69
|
`hint` pins an affordance to the trailing edge of the label row — a string gives the standard info icon with a tooltip, a snippet takes over completely (button, link, badge). It rides on the label row, so it renders only when `label` is set. Clicks inside the hint are swallowed, so an interactive hint never activates the labelled field.
|
|
49
70
|
|
|
50
71
|
### CSS Custom Properties
|
|
@@ -12,6 +12,8 @@ type Props = {
|
|
|
12
12
|
/**
|
|
13
13
|
* FormField — pure layout shell: optional label (string or snippet) above an input slot. The root is a `<label>` element, so the first labelable form control inside is automatically associated via HTML's implicit-association rule — no id wiring required. Does NOT render errors or helper text; pair with `Validatable` for that.
|
|
14
14
|
*
|
|
15
|
+
* Clicking the label opens a popup field inside it (select, date picker) but never re-opens one that is already expanded — that click dismisses it, exactly like a click on empty space.
|
|
16
|
+
*
|
|
15
17
|
* `hint` pins an affordance to the trailing edge of the label row — a string gives the standard info icon with a tooltip, a snippet takes over completely (button, link, badge). It rides on the label row, so it renders only when `label` is set. Clicks inside the hint are swallowed, so an interactive hint never activates the labelled field.
|
|
16
18
|
*
|
|
17
19
|
* ### CSS Custom Properties
|