@stacksjs/components 0.2.383 → 0.2.385

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.
Files changed (28) hide show
  1. package/dist/{Badge-4jxqhkv9.stx → Badge-33phrqza.stx} +25 -1
  2. package/dist/{Button-k2q6811a.stx → Button-bpjmfkq6.stx} +32 -1
  3. package/dist/{Checkbox-tt8bze29.stx → Checkbox-8kw03j51.stx} +10 -0
  4. package/dist/{EmailInput-agb8kqae.stx → EmailInput-ffzwvp9r.stx} +18 -0
  5. package/dist/{NumberInput-g3jfy120.stx → NumberInput-q5qjdwbt.stx} +26 -0
  6. package/dist/{PasswordInput-p2rt5926.stx → PasswordInput-zr84vsv4.stx} +26 -0
  7. package/dist/{Radio-50f4wq25.stx → Radio-8j21bgbg.stx} +10 -0
  8. package/dist/{SearchInput-psbjk2ye.stx → SearchInput-w15r5t95.stx} +18 -0
  9. package/dist/{Select-1p9mcbsb.stx → Select-nbr6aaxk.stx} +22 -0
  10. package/dist/{Switch-27hp6pq5.stx → Switch-acwd7n07.stx} +31 -0
  11. package/dist/{TextInput-t0a4ch49.stx → TextInput-165w1cth.stx} +26 -0
  12. package/dist/{Textarea-4zzr72zh.stx → Textarea-1yd7aswb.stx} +26 -0
  13. package/dist/{Tooltip-sq6tfy00.stx → Tooltip-cqp0hz6h.stx} +30 -1
  14. package/dist/index.js +7 -7
  15. package/package.json +3 -3
  16. package/src/ui/badge/Badge.stx +25 -1
  17. package/src/ui/button/Button.stx +32 -1
  18. package/src/ui/checkbox/Checkbox.stx +10 -0
  19. package/src/ui/input/EmailInput.stx +18 -0
  20. package/src/ui/input/NumberInput.stx +26 -0
  21. package/src/ui/input/PasswordInput.stx +26 -0
  22. package/src/ui/input/SearchInput.stx +18 -0
  23. package/src/ui/input/TextInput.stx +26 -0
  24. package/src/ui/radio/Radio.stx +10 -0
  25. package/src/ui/select/Select.stx +22 -0
  26. package/src/ui/switch/Switch.stx +31 -0
  27. package/src/ui/textarea/Textarea.stx +26 -0
  28. package/src/ui/tooltip/Tooltip.stx +30 -1
@@ -3,6 +3,27 @@ export const variant = $props.variant || 'default'
3
3
  export const size = $props.size || 'md'
4
4
  export const dot = $bool($props.dot)
5
5
  export const removable = $bool($props.removable)
6
+
7
+ /*
8
+ * Whether this badge announces itself. Off by default (stacksjs/stx#2043-adjacent).
9
+ *
10
+ * Every badge carried `role="status"`, which is an ARIA live region: a screen
11
+ * reader watches it and reads out any change to its contents. A badge is
12
+ * usually a styled label -- a tag, a count, a status pill sitting in a table
13
+ * cell -- and a page of them becomes a page of live regions. One estate has
14
+ * 126 badges on a single view, so a single re-render could queue 126
15
+ * announcements, and the interruptions are the point: a live region speaks
16
+ * over whatever the user is reading.
17
+ *
18
+ * A live region is right when the badge is the thing that CHANGED and nothing
19
+ * else says so -- an unread count going up while focus is elsewhere. That is
20
+ * the caller's judgement, not a default, so it is opt-in: `<Badge live>` for
21
+ * polite, `<Badge live="assertive">` to interrupt.
22
+ */
23
+ const liveProp = $props.live
24
+ export const live = liveProp === 'assertive'
25
+ ? 'assertive'
26
+ : ($bool(liveProp) ? 'polite' : '')
6
27
  export const className = $props.className || ''
7
28
 
8
29
  /*
@@ -52,7 +73,10 @@ function onRemove() {
52
73
  }
53
74
  </script>
54
75
 
55
- <span class="{{ badgeClasses }}" role="status">
76
+ <span
77
+ class="{{ badgeClasses }}"
78
+ @if(live)role="status" aria-live="{{ live }}"@endif
79
+ >
56
80
  @if(dot)
57
81
  <span class="{{ dotClasses }}" aria-hidden="true"></span>
58
82
  @endif
@@ -21,6 +21,19 @@ export const fullWidth = $bool($props.fullWidth)
21
21
  */
22
22
  export const label = $props.label || ''
23
23
  export const hasLabel = label !== ''
24
+
25
+ /*
26
+ * A server-rendered accessible name, for the one case the slot cannot cover.
27
+ *
28
+ * `:label` is client-categorised, so the server cannot see it: a
29
+ * `<Button :label="confirmLabel()" />` with no slot content has no text and no
30
+ * name in the markup actually served, and assistive technology reaching it
31
+ * before hydration finds an unlabelled button. On a destructive confirmation
32
+ * that is the worst case (stacksjs/stx#2034). Slot content is the better
33
+ * answer where there is any, because it is visible as well as announced; this
34
+ * is for a button that has neither.
35
+ */
36
+ export const ariaLabel = $props.ariaLabel || $props['aria-label'] || ''
24
37
  export const leftIcon = $props.leftIcon || ''
25
38
  export const rightIcon = $props.rightIcon || ''
26
39
  export const className = $props.className || ''
@@ -146,6 +159,7 @@ function onClick(event) {
146
159
  :disabled="isDisabled()"
147
160
  aria-busy="{{ loading ? 'true' : 'false' }}"
148
161
  :aria-busy="isLoading() ? 'true' : 'false'"
162
+ @if(ariaLabel)aria-label="{{ ariaLabel }}"@endif
149
163
  @click="onClick($event)"
150
164
  >
151
165
  {{-- The spinner is always in the DOM so `loading` can turn it on after render;
@@ -169,7 +183,24 @@ function onClick(event) {
169
183
  <span :show="!isLoading()" @if(loading)x-cloak@endif class="{{ iconClasses }}">{!! leftIcon !!}</span>
170
184
  @endif
171
185
 
172
- <slot />
186
+ {{-- The slot is the label's FALLBACK, not its sibling (stacksjs/stx#2034).
187
+
188
+ A reactive label is invisible to the server, so the only text a
189
+ `<Button :label="confirmLabel()">Confirm</Button>` can serve is the slot
190
+ content -- and it used to render it NEXT TO the label span, so once
191
+ labelText() resolved the button read "ConfirmDelete project". An author
192
+ had to choose between a server-rendered accessible name and a reactive
193
+ one, which is why the reporting app kept a plain <button>.
194
+
195
+ Wrapped rather than put on the slot itself: `<slot :if="...">` does not
196
+ work, because the slot is replaced by the caller's markup at render time
197
+ and the attribute goes with it. display:contents so the wrapper is not a
198
+ box -- slot children stay direct flex items of the button, so the gap
199
+ between them is unchanged.
200
+
201
+ `:if` rather than `:show` for the same reason: `:show` writes
202
+ style.display, which would fight the display:contents this needs. --}}
203
+ <span style="display:contents" :if="!labelText()"><slot /></span>
173
204
 
174
205
  {{-- The label span is decided on the CLIENT, because the server cannot see a
175
206
  reactive prop at all: `:label="rotateLabel()"` is categorised as client
@@ -36,6 +36,14 @@ export const descriptionClasses = `text-sm ${error ? 'text-danger' : 'text-fg-so
36
36
  */
37
37
  export const inputId = $props.id || `checkbox-${$uid}`
38
38
  export const descriptionId = `${inputId}-description`
39
+ /*
40
+ * `autocomplete` and `form`, alongside the `name` this already had
41
+ * (stacksjs/stx#2043). `autocomplete` is how the browser and a password
42
+ * manager identify a field; `form` lets a control live outside the <form>
43
+ * element it belongs to. Emitted only when given.
44
+ */
45
+ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
46
+ export const form = $props.form || ''
39
47
  </script>
40
48
 
41
49
  <script client>
@@ -71,6 +79,8 @@ defineExpose({ isChecked })
71
79
  id="{{ inputId }}"
72
80
  type="checkbox"
73
81
  name="{{ name }}"
82
+ @if(autocomplete)autocomplete="{{ autocomplete }}"@endif
83
+ @if(form)form="{{ form }}"@endif
74
84
  value="{{ value }}"
75
85
  :checked="isChecked()"
76
86
  @if(disabled)disabled@endif
@@ -11,9 +11,27 @@ export const required = $bool($props.required)
11
11
  export const className = $props.className || ''
12
12
 
13
13
  export const emailIcon = '<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" /></svg>'
14
+ /*
15
+ * Forwarded to the TextInput this renders (stacksjs/stx#2043).
16
+ *
17
+ * A wrapper that does not pass them through is as unsubmittable as a control
18
+ * that never accepted them: the inner input is the one that lands in FormData.
19
+ * `type` is the wrapper's own business, but `name`, `autocomplete` and `form`
20
+ * belong to the caller.
21
+ */
22
+ export const name = $props.name || ''
23
+ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
24
+ export const form = $props.form || ''
25
+ export const inputMode = $props.inputMode || $props.inputmode || ''
26
+ export const enterKeyHint = $props.enterKeyHint || $props.enterkeyhint || ''
14
27
  </script>
15
28
 
16
29
  <TextInput
30
+ :name="name"
31
+ :autocomplete="autocomplete"
32
+ :form="form"
33
+ :inputMode="inputMode"
34
+ :enterKeyHint="enterKeyHint"
17
35
  :value="value"
18
36
  :placeholder="placeholder"
19
37
  :disabled="disabled"
@@ -57,6 +57,27 @@ const paddingClasses = showControls ? 'pr-10' : ''
57
57
  export const inputClasses = `${baseClasses} ${sizeClasses[size] || sizeClasses.md} ${stateClasses} ${disabledClasses} ${paddingClasses} ${inputClassName}`.trim()
58
58
  export const labelClasses = `block text-sm font-medium leading-6 mb-2 ${error ? 'text-danger' : 'text-fg'}`.trim()
59
59
  export const helperClasses = `mt-2 text-sm ${error ? 'text-danger' : 'text-fg-soft'}`.trim()
60
+ /*
61
+ * The attributes that make this a form control (stacksjs/stx#2043).
62
+ *
63
+ * A control with no `name` is not a form control in the HTML sense: it is left
64
+ * out of FormData, out of form.elements.namedItem(), and out of an ordinary
65
+ * non-JS POST. A form built from these components submitted nothing for every
66
+ * field, silently -- which is how six apps read their forms.
67
+ *
68
+ * `autocomplete` is separate and just as load-bearing: it is how the browser
69
+ * and a password manager identify a field, so a password input without
70
+ * `autocomplete="current-password"` is never offered for autofill and is not
71
+ * recognised as part of a sign-in form at all.
72
+ *
73
+ * Emitted only when given, so a control that passes none of them renders
74
+ * exactly the markup it did before.
75
+ */
76
+ export const name = $props.name || ''
77
+ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
78
+ export const form = $props.form || ''
79
+ export const inputMode = $props.inputMode || $props.inputmode || ''
80
+ export const enterKeyHint = $props.enterKeyHint || $props.enterkeyhint || ''
60
81
  </script>
61
82
 
62
83
  <script client>
@@ -103,6 +124,11 @@ defineExpose({ value: inputValue, increment, decrement })
103
124
 
104
125
  <div class="relative">
105
126
  <input
127
+ @if(name)name="{{ name }}"@endif
128
+ @if(autocomplete)autocomplete="{{ autocomplete }}"@endif
129
+ @if(form)form="{{ form }}"@endif
130
+ @if(inputMode)inputmode="{{ inputMode }}"@endif
131
+ @if(enterKeyHint)enterkeyhint="{{ enterKeyHint }}"@endif
106
132
  type="number"
107
133
  id="{{ inputId }}"
108
134
  class="{{ inputClasses }}"
@@ -56,6 +56,27 @@ export const inputClasses = `${baseClasses} ${sizeClasses[size] || sizeClasses.m
56
56
  export const labelClasses = `block text-sm font-medium leading-6 mb-2 ${error ? 'text-danger' : 'text-fg'}`.trim()
57
57
  export const helperClasses = `mt-2 text-sm ${error ? 'text-danger' : 'text-fg-soft'}`.trim()
58
58
  export const iconClasses = iconSizeClasses[size] || iconSizeClasses.md
59
+ /*
60
+ * The attributes that make this a form control (stacksjs/stx#2043).
61
+ *
62
+ * A control with no `name` is not a form control in the HTML sense: it is left
63
+ * out of FormData, out of form.elements.namedItem(), and out of an ordinary
64
+ * non-JS POST. A form built from these components submitted nothing for every
65
+ * field, silently -- which is how six apps read their forms.
66
+ *
67
+ * `autocomplete` is separate and just as load-bearing: it is how the browser
68
+ * and a password manager identify a field, so a password input without
69
+ * `autocomplete="current-password"` is never offered for autofill and is not
70
+ * recognised as part of a sign-in form at all.
71
+ *
72
+ * Emitted only when given, so a control that passes none of them renders
73
+ * exactly the markup it did before.
74
+ */
75
+ export const name = $props.name || ''
76
+ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
77
+ export const form = $props.form || ''
78
+ export const inputMode = $props.inputMode || $props.inputmode || ''
79
+ export const enterKeyHint = $props.enterKeyHint || $props.enterkeyhint || ''
59
80
  </script>
60
81
 
61
82
  <script client>
@@ -115,6 +136,11 @@ defineExpose({ value: inputValue })
115
136
 
116
137
  <div class="relative">
117
138
  <input
139
+ @if(name)name="{{ name }}"@endif
140
+ @if(autocomplete)autocomplete="{{ autocomplete }}"@endif
141
+ @if(form)form="{{ form }}"@endif
142
+ @if(inputMode)inputmode="{{ inputMode }}"@endif
143
+ @if(enterKeyHint)enterkeyhint="{{ enterKeyHint }}"@endif
118
144
  :type="inputType()"
119
145
  id="{{ inputId }}"
120
146
  class="{{ inputClasses }}"
@@ -35,6 +35,14 @@ export const descriptionClasses = `text-sm ${error ? 'text-danger' : 'text-fg-so
35
35
  */
36
36
  export const inputId = $props.id || `radio-${$uid}`
37
37
  export const descriptionId = `${inputId}-description`
38
+ /*
39
+ * `autocomplete` and `form`, alongside the `name` this already had
40
+ * (stacksjs/stx#2043). `autocomplete` is how the browser and a password
41
+ * manager identify a field; `form` lets a control live outside the <form>
42
+ * element it belongs to. Emitted only when given.
43
+ */
44
+ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
45
+ export const form = $props.form || ''
38
46
  </script>
39
47
 
40
48
  <script client>
@@ -75,6 +83,8 @@ defineExpose({ isChecked })
75
83
  id="{{ inputId }}"
76
84
  type="radio"
77
85
  name="{{ name }}"
86
+ @if(autocomplete)autocomplete="{{ autocomplete }}"@endif
87
+ @if(form)form="{{ form }}"@endif
78
88
  value="{{ value }}"
79
89
  :value="radioValue()"
80
90
  :checked="isChecked()"
@@ -12,6 +12,19 @@ export const className = $props.className || ''
12
12
  export const searchIcon = '<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /></svg>'
13
13
  export const spinnerIcon = '<svg class="animate-spin" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>'
14
14
  export const rightIcon = loading ? spinnerIcon : ''
15
+ /*
16
+ * Forwarded to the TextInput this renders (stacksjs/stx#2043).
17
+ *
18
+ * A wrapper that does not pass them through is as unsubmittable as a control
19
+ * that never accepted them: the inner input is the one that lands in FormData.
20
+ * `type` is the wrapper's own business, but `name`, `autocomplete` and `form`
21
+ * belong to the caller.
22
+ */
23
+ export const name = $props.name || ''
24
+ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
25
+ export const form = $props.form || ''
26
+ export const inputMode = $props.inputMode || $props.inputmode || ''
27
+ export const enterKeyHint = $props.enterKeyHint || $props.enterkeyhint || ''
15
28
  </script>
16
29
 
17
30
  <script client>
@@ -28,6 +41,11 @@ function onSearchInput(event) {
28
41
 
29
42
  <div @input="onSearchInput($event)">
30
43
  <TextInput
44
+ :name="name"
45
+ :autocomplete="autocomplete"
46
+ :form="form"
47
+ :inputMode="inputMode"
48
+ :enterKeyHint="enterKeyHint"
31
49
  :value="value"
32
50
  :placeholder="placeholder"
33
51
  :disabled="disabled"
@@ -49,6 +49,25 @@ export const helperClasses = `mt-2 text-sm ${error ? 'text-danger' : 'text-fg-so
49
49
  */
50
50
  export const selectId = $props.id || `select-${$uid}`
51
51
  export const helperId = `${selectId}-helper`
52
+ /*
53
+ * The attributes that make this a form control (stacksjs/stx#2043).
54
+ *
55
+ * A control with no `name` is not a form control in the HTML sense: it is left
56
+ * out of FormData, out of form.elements.namedItem(), and out of an ordinary
57
+ * non-JS POST. A form built from these components submitted nothing for every
58
+ * field, silently -- which is how six apps read their forms.
59
+ *
60
+ * `autocomplete` is separate and just as load-bearing: it is how the browser
61
+ * and a password manager identify a field, so a password input without
62
+ * `autocomplete="current-password"` is never offered for autofill and is not
63
+ * recognised as part of a sign-in form at all.
64
+ *
65
+ * Emitted only when given, so a control that passes none of them renders
66
+ * exactly the markup it did before.
67
+ */
68
+ export const name = $props.name || ''
69
+ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
70
+ export const form = $props.form || ''
52
71
  </script>
53
72
 
54
73
  <script client>
@@ -76,6 +95,9 @@ defineExpose({ value: selectedValue })
76
95
 
77
96
  <div class="{{ label ? 'mt-2' : '' }}">
78
97
  <select
98
+ @if(name)name="{{ name }}"@endif
99
+ @if(autocomplete)autocomplete="{{ autocomplete }}"@endif
100
+ @if(form)form="{{ form }}"@endif
79
101
  id="{{ selectId }}"
80
102
  class="{{ selectClasses }}"
81
103
  :value="selectedValue()"
@@ -1,5 +1,22 @@
1
1
  <script server>
2
2
  export const checked = $bool($props.checked)
3
+
4
+ /*
5
+ * Form participation, which a <button role="switch"> cannot have on its own
6
+ * (stacksjs/stx#2043).
7
+ *
8
+ * The control the user operates is a button, and a button is never submitted
9
+ * by name -- so a Switch inside a form contributed nothing to FormData no
10
+ * matter what it was set to. A hidden input carries the state instead, which
11
+ * is what it takes for a custom switch to be readable the way a checkbox is.
12
+ *
13
+ * Only rendered when a `name` is given, so a Switch used as a plain toggle
14
+ * emits exactly the markup it did before.
15
+ */
16
+ export const name = $props.name || ''
17
+ export const form = $props.form || ''
18
+ export const checkedValue = $props.checkedValue || 'true'
19
+ export const uncheckedValue = $props.uncheckedValue || 'false'
3
20
  export const disabled = $bool($props.disabled)
4
21
  export const size = $props.size || 'md'
5
22
  export const className = $props.className || ''
@@ -60,6 +77,20 @@ defineExpose({ isChecked, toggle })
60
77
  </span>
61
78
  @endif
62
79
 
80
+ @if(name)
81
+ {{-- Always submitted, carrying one of two values, rather than a checkbox's
82
+ present-or-absent convention: a reader then gets an explicit "false"
83
+ instead of a missing key, which is the difference between "switched
84
+ off" and "field was never in the form". --}}
85
+ <input
86
+ type="hidden"
87
+ name="{{ name }}"
88
+ @if(form)form="{{ form }}"@endif
89
+ value="{{ checked ? checkedValue : uncheckedValue }}"
90
+ :value="isChecked() ? '{{ checkedValue }}' : '{{ uncheckedValue }}'"
91
+ />
92
+ @endif
93
+
63
94
  <button
64
95
  type="button"
65
96
  role="switch"
@@ -61,6 +61,27 @@ export const iconClasses = iconSizeClasses[size] || iconSizeClasses.md
61
61
  */
62
62
  export const inputId = $props.id || `input-${$uid}`
63
63
  export const helperId = `${inputId}-helper`
64
+ /*
65
+ * The attributes that make this a form control (stacksjs/stx#2043).
66
+ *
67
+ * A control with no `name` is not a form control in the HTML sense: it is left
68
+ * out of FormData, out of form.elements.namedItem(), and out of an ordinary
69
+ * non-JS POST. A form built from these components submitted nothing for every
70
+ * field, silently -- which is how six apps read their forms.
71
+ *
72
+ * `autocomplete` is separate and just as load-bearing: it is how the browser
73
+ * and a password manager identify a field, so a password input without
74
+ * `autocomplete="current-password"` is never offered for autofill and is not
75
+ * recognised as part of a sign-in form at all.
76
+ *
77
+ * Emitted only when given, so a control that passes none of them renders
78
+ * exactly the markup it did before.
79
+ */
80
+ export const name = $props.name || ''
81
+ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
82
+ export const form = $props.form || ''
83
+ export const inputMode = $props.inputMode || $props.inputmode || ''
84
+ export const enterKeyHint = $props.enterKeyHint || $props.enterkeyhint || ''
64
85
  </script>
65
86
 
66
87
  <script client>
@@ -108,6 +129,11 @@ defineExpose({ value: inputValue, clear: onClear })
108
129
  @endif
109
130
 
110
131
  <input
132
+ @if(name)name="{{ name }}"@endif
133
+ @if(autocomplete)autocomplete="{{ autocomplete }}"@endif
134
+ @if(form)form="{{ form }}"@endif
135
+ @if(inputMode)inputmode="{{ inputMode }}"@endif
136
+ @if(enterKeyHint)enterkeyhint="{{ enterKeyHint }}"@endif
111
137
  type="text"
112
138
  id="{{ inputId }}"
113
139
  class="{{ inputClasses }}"
@@ -46,6 +46,27 @@ const disabledClasses = disabled
46
46
  export const textareaClasses = `${baseClasses} ${stateClasses} ${disabledClasses} ${resizeClasses[resize] || resizeClasses.vertical} ${className}`.trim()
47
47
  export const labelClasses = `block text-sm font-medium leading-6 mb-2 ${error ? 'text-danger' : 'text-fg'}`.trim()
48
48
  export const helperClasses = `mt-2 text-sm ${error ? 'text-danger' : 'text-fg-soft'}`.trim()
49
+ /*
50
+ * The attributes that make this a form control (stacksjs/stx#2043).
51
+ *
52
+ * A control with no `name` is not a form control in the HTML sense: it is left
53
+ * out of FormData, out of form.elements.namedItem(), and out of an ordinary
54
+ * non-JS POST. A form built from these components submitted nothing for every
55
+ * field, silently -- which is how six apps read their forms.
56
+ *
57
+ * `autocomplete` is separate and just as load-bearing: it is how the browser
58
+ * and a password manager identify a field, so a password input without
59
+ * `autocomplete="current-password"` is never offered for autofill and is not
60
+ * recognised as part of a sign-in form at all.
61
+ *
62
+ * Emitted only when given, so a control that passes none of them renders
63
+ * exactly the markup it did before.
64
+ */
65
+ export const name = $props.name || ''
66
+ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
67
+ export const form = $props.form || ''
68
+ export const inputMode = $props.inputMode || $props.inputmode || ''
69
+ export const enterKeyHint = $props.enterKeyHint || $props.enterkeyhint || ''
49
70
  </script>
50
71
 
51
72
  <script client>
@@ -94,6 +115,11 @@ defineExpose({ value: inputValue })
94
115
  @endif
95
116
 
96
117
  <textarea
118
+ @if(name)name="{{ name }}"@endif
119
+ @if(autocomplete)autocomplete="{{ autocomplete }}"@endif
120
+ @if(form)form="{{ form }}"@endif
121
+ @if(inputMode)inputmode="{{ inputMode }}"@endif
122
+ @if(enterKeyHint)enterkeyhint="{{ enterKeyHint }}"@endif
97
123
  id="{{ inputId }}"
98
124
  class="{{ textareaClasses }}"
99
125
  rows="{{ rows }}"
@@ -6,6 +6,28 @@ export const className = $props.className || ''
6
6
  export const show = $bool($props.show)
7
7
  export const disabled = $bool($props.disabled)
8
8
 
9
+ /*
10
+ * The id that makes the tooltip reachable from its trigger.
11
+ *
12
+ * `role="tooltip"` names what the element IS; it does not attach it to
13
+ * anything. Without `aria-describedby` on the trigger pointing here, a screen
14
+ * reader never reaches this element at all and the role announces nothing --
15
+ * so the component was a DOWNGRADE from the native `title=` it replaces, which
16
+ * at least is announced.
17
+ */
18
+ export const tooltipId = `tooltip-${$uid}`
19
+
20
+ /*
21
+ * Whether the text may wrap. It may, by default.
22
+ *
23
+ * `whitespace-nowrap` keeps a two-word hint on one line, which is what a
24
+ * tooltip usually is -- but a sentence-length one then grows past the viewport
25
+ * instead of wrapping, and on a phone the end of it is simply unreachable.
26
+ * Wrapping with a sensible max width is right for both; `nowrap` is there for
27
+ * a caller who knows the content is short.
28
+ */
29
+ export const nowrap = $bool($props.nowrap)
30
+
9
31
  const positionClasses = {
10
32
  top: 'bottom-full left-1/2 -translate-x-1/2 mb-2',
11
33
  bottom: 'top-full left-1/2 -translate-x-1/2 mt-2',
@@ -20,7 +42,8 @@ const arrowClasses = {
20
42
  right: 'right-full top-1/2 -translate-y-1/2 border-r-inverse',
21
43
  }
22
44
 
23
- export const tooltipClasses = `absolute z-50 px-3 py-2 text-sm font-medium text-inverse-ink bg-inverse rounded-panel shadow-lg whitespace-nowrap pointer-events-none transition-opacity duration-200 ${positionClasses[position] || positionClasses.top} ${className}`.trim()
45
+ const wrapClasses = nowrap ? 'whitespace-nowrap' : 'max-w-xs break-words'
46
+ export const tooltipClasses = `absolute z-50 px-3 py-2 text-sm font-medium text-inverse-ink bg-inverse rounded-panel shadow-lg ${wrapClasses} pointer-events-none transition-opacity duration-200 ${positionClasses[position] || positionClasses.top} ${className}`.trim()
24
47
  export const arrowClass = `absolute w-0 h-0 border-4 border-transparent ${arrowClasses[position] || arrowClasses.top}`.trim()
25
48
  </script>
26
49
 
@@ -54,7 +77,12 @@ function hideTooltip() {
54
77
  </script>
55
78
 
56
79
  <div class="relative inline-block {{ disabled ? 'cursor-not-allowed' : '' }}">
80
+ {{-- aria-describedby is what attaches the tooltip to what it describes.
81
+ The element is always in the DOM -- :show toggles it -- so the
82
+ description resolves whether or not the tooltip is on screen, which is
83
+ how a screen reader is meant to reach it. --}}
57
84
  <div
85
+ aria-describedby="{{ tooltipId }}"
58
86
  @mouseenter="showTooltip()"
59
87
  @mouseleave="hideTooltip()"
60
88
  @focusin="showTooltip()"
@@ -64,6 +92,7 @@ function hideTooltip() {
64
92
  </div>
65
93
 
66
94
  <div
95
+ id="{{ tooltipId }}"
67
96
  :show="isVisible() && !{{ disabled }}"
68
97
  class="{{ tooltipClasses }}"
69
98
  role="tooltip"