@stacksjs/components 0.2.382 → 0.2.384

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 (30) hide show
  1. package/dist/{Button-k2q6811a.stx → Button-bpjmfkq6.stx} +32 -1
  2. package/dist/{Checkbox-tt8bze29.stx → Checkbox-8kw03j51.stx} +10 -0
  3. package/dist/{Dialog-d1020hj6.stx → Dialog-e9a4r6d0.stx} +34 -0
  4. package/dist/{DialogTitle-0jjdk5ra.stx → DialogTitle-ke58hh68.stx} +1 -1
  5. package/dist/{EmailInput-agb8kqae.stx → EmailInput-ffzwvp9r.stx} +18 -0
  6. package/dist/{NumberInput-g3jfy120.stx → NumberInput-q5qjdwbt.stx} +26 -0
  7. package/dist/{PasswordInput-p2rt5926.stx → PasswordInput-zr84vsv4.stx} +26 -0
  8. package/dist/{Radio-50f4wq25.stx → Radio-8j21bgbg.stx} +10 -0
  9. package/dist/{SearchInput-psbjk2ye.stx → SearchInput-w15r5t95.stx} +18 -0
  10. package/dist/{Select-1p9mcbsb.stx → Select-nbr6aaxk.stx} +22 -0
  11. package/dist/{Switch-27hp6pq5.stx → Switch-acwd7n07.stx} +31 -0
  12. package/dist/{Tabs-s3g7d1ys.stx → Tabs-3j2h0jjn.stx} +29 -4
  13. package/dist/{TextInput-t0a4ch49.stx → TextInput-165w1cth.stx} +26 -0
  14. package/dist/{Textarea-4zzr72zh.stx → Textarea-1yd7aswb.stx} +26 -0
  15. package/dist/index.js +7 -7
  16. package/package.json +3 -3
  17. package/src/ui/button/Button.stx +32 -1
  18. package/src/ui/checkbox/Checkbox.stx +10 -0
  19. package/src/ui/dialog/Dialog.stx +34 -0
  20. package/src/ui/dialog/DialogTitle.stx +1 -1
  21. package/src/ui/input/EmailInput.stx +18 -0
  22. package/src/ui/input/NumberInput.stx +26 -0
  23. package/src/ui/input/PasswordInput.stx +26 -0
  24. package/src/ui/input/SearchInput.stx +18 -0
  25. package/src/ui/input/TextInput.stx +26 -0
  26. package/src/ui/radio/Radio.stx +10 -0
  27. package/src/ui/select/Select.stx +22 -0
  28. package/src/ui/switch/Switch.stx +31 -0
  29. package/src/ui/tabs/Tabs.stx +29 -4
  30. package/src/ui/textarea/Textarea.stx +26 -0
@@ -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
@@ -2,6 +2,19 @@
2
2
  export const open = $bool($props.open)
3
3
  export const className = $props.className || ''
4
4
 
5
+ /*
6
+ * The dialog's accessible name.
7
+ *
8
+ * `role="dialog"` with no name is announced as just "dialog", which tells a
9
+ * screen reader user nothing about what has taken over the page -- WCAG 4.1.2.
10
+ * The slot idiom puts the name in a <DialogTitle>, which the client script
11
+ * below associates on mount; this prop is the server-rendered half, so a
12
+ * dialog is named before hydration and without JavaScript at all. Emitted only
13
+ * when set: an empty aria-label is worse than none, because it suppresses the
14
+ * name the title would otherwise supply. Same idiom as Drawer.
15
+ */
16
+ export const title = $props.title || ''
17
+
5
18
  const baseClasses = 'relative z-50'
6
19
  export const dialogClasses = `${baseClasses} ${className}`.trim()
7
20
 
@@ -38,8 +51,28 @@ const mounted = state(false)
38
51
 
39
52
  onMount(() => {
40
53
  mounted.set(true)
54
+ labelFromTitle()
41
55
  })
42
56
 
57
+ /*
58
+ * Name the dialog after its <DialogTitle>, when the server could not.
59
+ *
60
+ * The documented idiom puts the name in the slot, which the server cannot see
61
+ * from here -- it renders the title as opaque slot content. So a dialog
62
+ * without the `title` prop reaches the browser announced as bare "dialog".
63
+ * This associates the two once the slot content exists. Skipped when a name is
64
+ * already present, so the prop always wins.
65
+ */
66
+ function labelFromTitle() {
67
+ const root = rootRef.value
68
+ if (!root) return
69
+ if (root.getAttribute('aria-label') || root.getAttribute('aria-labelledby')) return
70
+ const heading = root.querySelector('[data-stx-dialog-title]')
71
+ if (!heading) return
72
+ if (!heading.id) heading.id = `${dialogInstanceId}-title`
73
+ root.setAttribute('aria-labelledby', heading.id)
74
+ }
75
+
43
76
  function close() {
44
77
  isOpen.set(false)
45
78
  emit('close')
@@ -262,6 +295,7 @@ defineExpose({
262
295
  data-stx-dialog="{{ dialogInstanceId }}"
263
296
  role="dialog"
264
297
  aria-modal="true"
298
+ @if(title)aria-label="{{ title }}"@endif
265
299
  @click="onRootClick($event)"
266
300
  >
267
301
  <slot />
@@ -6,6 +6,6 @@ const baseClasses = 'text-lg font-medium leading-6 text-fg'
6
6
  const titleClasses = `${baseClasses} ${className}`.trim()
7
7
  </script>
8
8
 
9
- <component :is="{{ as }}" class="{{ titleClasses }}">
9
+ <component :is="{{ as }}" class="{{ titleClasses }}" data-stx-dialog-title>
10
10
  <slot />
11
11
  </component>
@@ -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"
@@ -13,6 +13,12 @@ export const orientation = $props.orientation || 'horizontal'
13
13
  export const variant = $props.variant || 'line'
14
14
  export const className = $props.className || ''
15
15
 
16
+ /*
17
+ * This tab set's own id, so the ids it mints for slot-mode tabs and panels
18
+ * cannot collide with a second <Tabs> on the same page. Same idiom as Dialog.
19
+ */
20
+ export const tabsInstanceId = $uid
21
+
16
22
  const orientationClasses = {
17
23
  horizontal: 'flex-col',
18
24
  vertical: 'flex-row',
@@ -39,6 +45,7 @@ export const hasPropTabs = Array.isArray(tabs) && tabs.length > 0
39
45
 
40
46
  <script client>
41
47
  const emit = defineEmits()
48
+ const tabsInstanceId = {{ tabsInstanceId }}
42
49
  const tabs = {{ tabs }}
43
50
  const variant = {{ variant }}
44
51
  const orientation = {{ orientation }}
@@ -81,10 +88,26 @@ function findOwnPanels() {
81
88
  onMount(() => {
82
89
  if (hasPropTabs) return // legacy mode: prop array already in discoveredTabs
83
90
  const panels = findOwnPanels()
84
- const list = panels.map(p => ({
85
- label: p.dataset.label || '',
86
- icon: p.dataset.icon || '',
87
- }))
91
+ /*
92
+ * Give each panel an id and hand it to its tab, so the tab can point at it.
93
+ *
94
+ * Prop mode numbers both sides itself (`tab-N` / `tab-panel-N`), but in slot
95
+ * mode the panels are the consumer's own markup and may carry no id at all --
96
+ * so the tab button rendered with role="tab" and no aria-controls, and a
97
+ * screen reader had no way to get from the tab to the panel it controls
98
+ * (WCAG 4.1.2). Only assigned when the panel has no id of its own.
99
+ */
100
+ const list = panels.map((p, i) => {
101
+ if (!p.id) p.id = `${tabsInstanceId}-panel-${i}`
102
+ const tabId = `${tabsInstanceId}-tab-${i}`
103
+ p.setAttribute('aria-labelledby', tabId)
104
+ return {
105
+ label: p.dataset.label || '',
106
+ icon: p.dataset.icon || '',
107
+ panelId: p.id,
108
+ tabId,
109
+ }
110
+ })
88
111
  discoveredTabs.set(list)
89
112
  mounted.set(true)
90
113
  })
@@ -193,6 +216,8 @@ defineExpose({ activeTab, selectTab })
193
216
  x-class="getTabClasses(idx)"
194
217
  role="tab"
195
218
  :aria-selected="isActive(idx) ? 'true' : 'false'"
219
+ :aria-controls="tab.panelId"
220
+ :id="tab.tabId"
196
221
  :tabindex="isActive(idx) ? 0 : -1"
197
222
  @click="selectTab(idx)"
198
223
  @keydown="onTabKey($event, idx)"
@@ -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 }}"