@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
@@ -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 }}"
@@ -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"
@@ -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 }}"
@@ -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()"
@@ -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)"
@@ -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 }}"