@stacksjs/components 0.2.870 → 0.2.872

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.
@@ -154,12 +154,19 @@ const nativeVariants = {
154
154
  ghost: { box: '', text: 'text-accent' },
155
155
  danger: { box: 'bg-danger-solid', text: 'text-danger-ink' },
156
156
  }
157
+ /*
158
+ * Heights are a floor, not a fixed size. A host draws text at the reader's
159
+ * chosen size, where 17pt becomes 48 at the largest accessibility setting,
160
+ * and a button held at 44pt cut its own label off top and bottom. The padding
161
+ * is small enough that the floor still decides the height at the default
162
+ * text size, so nothing moves there.
163
+ */
157
164
  const nativeSizes = {
158
- xs: { box: 'h-7 px-2.5 gap-1 rounded-[7px]', text: 'text-[13px]' },
159
- sm: { box: 'h-[34px] px-3 gap-1.5 rounded-[8px]', text: 'text-[15px]' },
160
- md: { box: 'h-11 px-4 gap-2 rounded-[10px]', text: 'text-[17px]' },
161
- lg: { box: 'h-[50px] px-5 gap-2 rounded-[12px]', text: 'text-[17px]' },
162
- xl: { box: 'h-14 px-6 gap-2.5 rounded-[14px]', text: 'text-[19px]' },
165
+ xs: { box: 'min-h-7 py-1 px-2.5 gap-1 rounded-[7px]', text: 'text-[13px]' },
166
+ sm: { box: 'min-h-[34px] py-1.5 px-3 gap-1.5 rounded-[8px]', text: 'text-[15px]' },
167
+ md: { box: 'min-h-11 py-2.5 px-4 gap-2 rounded-[10px]', text: 'text-[17px]' },
168
+ lg: { box: 'min-h-[50px] py-3 px-5 gap-2 rounded-[12px]', text: 'text-[17px]' },
169
+ xl: { box: 'min-h-14 py-3.5 px-6 gap-2.5 rounded-[14px]', text: 'text-[19px]' },
163
170
  }
164
171
  const nativeVariant = nativeVariants[variant] || nativeVariants.primary
165
172
  const nativeSize = nativeSizes[size] || nativeSizes.md
@@ -21,8 +21,13 @@ export const className = $props.className || ''
21
21
  * screen edges while its first chip still lines up with the title above it —
22
22
  * a row that stops at the gutter looks complete when it is not.
23
23
  */
24
+ /*
25
+ * `shrink-0`: a row that scrolls sideways has no height of its own to give
26
+ * up. In a screen taller than the phone (any phone on its side) the column
27
+ * shrank it first, to nothing, and the filters were gone.
28
+ */
24
29
  export const rowClasses = `
25
- -mx-4 flex gap-2 overflow-x-auto px-4 pb-1
30
+ -mx-4 flex shrink-0 gap-2 overflow-x-auto px-4 pb-1
26
31
  [scrollbar-width:none] [&::-webkit-scrollbar]:hidden
27
32
  ${className}
28
33
  `.replace(/\s+/g, ' ').trim()
@@ -216,7 +216,10 @@ defineExpose({ selected, count, go, next, prev })
216
216
 
217
217
  <section class="{{ rootClasses }}" aria-roledescription="carousel" @if(label)aria-label="{{ label }}"@endif @keydown="onKey($event)">
218
218
  @if(nativeHost)
219
- <div data-native="ScrollView" horizontal pagingEnabled :pageIndex="selected()" :scrollEnabled="allowSwipe" showsHorizontalScrollIndicator="false" showsVerticalScrollIndicator="false" class="flex-1 min-h-0" @page-selected="onNativePage($event)">
219
+ {{-- A host's scroller is where a pager's name goes: it announces the
220
+ name on the way in and leaves the pages inside reachable, which the
221
+ box around it cannot do (a named box is a single stop). --}}
222
+ <div data-native="ScrollView" @if(label)aria-label="{{ label }}"@endif horizontal pagingEnabled :pageIndex="selected()" :scrollEnabled="allowSwipe" showsHorizontalScrollIndicator="false" showsVerticalScrollIndicator="false" class="flex-1 min-h-0" @page-selected="onNativePage($event)">
220
223
  <slot />
221
224
  </div>
222
225
  @else
@@ -100,7 +100,7 @@ export const enterKeyHint = $props.enterKeyHint || $props.enterkeyhint || ''
100
100
  * autocomplete is the sign-in password, so the platform offers the saved one.
101
101
  */
102
102
  export const nativeAutocomplete = autocomplete || 'current-password'
103
- export const nativeFieldClasses = `h-12 pl-4 pr-11 text-[17px] text-[#000000] dark:text-[#ffffff] bg-[#767680]/12 dark:bg-[#767680]/24 rounded-[10px] border-0 ${error ? 'border border-[#ff3b30] dark:border-[#ff453a]' : ''} ${disabled ? 'opacity-50' : ''} ${inputClassName}`.replace(/\s+/g, ' ').trim()
103
+ export const nativeFieldClasses = `min-h-12 pl-4 pr-11 text-[17px] text-[#000000] dark:text-[#ffffff] bg-[#767680]/12 dark:bg-[#767680]/24 rounded-[10px] border-0 ${error ? 'border border-[#ff3b30] dark:border-[#ff453a]' : ''} ${disabled ? 'opacity-50' : ''} ${inputClassName}`.replace(/\s+/g, ' ').trim()
104
104
  export const nativeLabelClasses = 'mb-1.5 px-4 text-[13px] uppercase text-[#6d6d72] dark:text-[#8d8d93]'
105
105
  export const nativeHelperClasses = `mt-1.5 px-4 text-[13px] ${error ? 'text-[#ff3b30] dark:text-[#ff453a]' : 'text-[#6d6d72] dark:text-[#8d8d93]'}`
106
106
  </script>
@@ -111,12 +111,19 @@ export const nativeHelperClasses = `mt-1.5 px-4 text-[13px] ${error ? 'text-[#ff
111
111
  const placeholderText = useReactiveProp('placeholder', {{ placeholder }})
112
112
  const emit = defineEmits()
113
113
  const showPassword = state(false)
114
- // Reactive prop binding — parent can drive value via signals. See #1704.
115
- const inputValue = useReactiveProp('value', {{ value }}, { parse: (v) => v == null ? '' : String(v) })
114
+ // Bound both ways, as TextInput, Textarea and NumberInput are (#2059): a
115
+ // form of shared fields wrote every one back through v-model:value except
116
+ // its password, where the binding compiled and then did nothing.
117
+ const inputValue = useModel('value', { default: {{ value }}, parse: (v) => v == null ? '' : String(v) })
116
118
 
117
119
  function onInput(event) {
118
- inputValue.set(event.target.value)
119
- emit('input', inputValue())
120
+ inputValue.input(event.target.value)
121
+ if (!inputValue.modifiers.lazy) emit('input', inputValue())
122
+ }
123
+
124
+ function onChange(event) {
125
+ inputValue.change(event.target.value)
126
+ if (inputValue.modifiers.lazy) emit('input', inputValue())
120
127
  }
121
128
 
122
129
  function toggleVisibility() {
@@ -180,12 +187,13 @@ defineExpose({ value: inputValue })
180
187
  @if(readonly)readonly@endif
181
188
  @if(required)required@endif
182
189
  @input="onInput($event)"
190
+ @change="onChange($event)"
183
191
  aria-invalid="{{ error ? 'true' : 'false' }}"
184
192
  />
185
193
  <button
186
194
  type="button"
187
195
  @click="toggleVisibility()"
188
- class="absolute top-0 right-0 h-12 w-11 items-center justify-center"
196
+ class="absolute top-0 bottom-0 right-0 w-11 items-center justify-center"
189
197
  :aria-label="toggleAriaLabel()"
190
198
  >
191
199
  <i :show="showPassword()" class="i-lucide-eye-off h-5 w-5 text-[#8e8e93]"></i>
@@ -236,6 +244,7 @@ defineExpose({ value: inputValue })
236
244
  @if(readonly)readonly@endif
237
245
  @if(required)required@endif
238
246
  @input="onInput($event)"
247
+ @change="onChange($event)"
239
248
  :aria-invalid="{{ error ? 'true' : 'false' }}"
240
249
  @if(helperText)aria-describedby="{{ helperId }}"@endif
241
250
  />
@@ -309,6 +318,7 @@ defineExpose({ value: inputValue })
309
318
  @if(readonly)readonly@endif
310
319
  @if(required)required@endif
311
320
  @input="onInput($event)"
321
+ @change="onChange($event)"
312
322
  :aria-invalid="{{ error ? 'true' : 'false' }}"
313
323
  @if(helperText)aria-describedby="{{ helperId }}"@endif
314
324
  />
@@ -156,14 +156,16 @@ export const list = type !== 'password' && given($props.list) ? String($props.li
156
156
  export const autofocus = $bool($props.autofocus)
157
157
 
158
158
  /*
159
- * The field a phone app draws, for a native host ($native): 48pt tall, the
159
+ * The field a phone app draws, for a native host ($native): 48pt tall and
160
+ * taller when the reader's text size needs it (a fixed 48pt cut the words in
161
+ * half at the larger accessibility sizes, where 17pt is drawn at 48), the
160
162
  * 17pt body size, a filled rounded box that reads on a grouped background and
161
163
  * a plain one alike, and the system's placeholder grey. The web's rings,
162
164
  * shadow and density roles have nothing to draw on a device, and its icon
163
165
  * slot is a web flourish iOS fields do without. An invalid field gets the
164
166
  * system red outline, a disabled one dims as UIKit's do.
165
167
  */
166
- export const nativeFieldClasses = `h-12 px-4 text-[17px] text-[#000000] dark:text-[#ffffff] bg-[#767680]/12 dark:bg-[#767680]/24 rounded-[10px] border-0 ${inputClassName}`.trim()
168
+ export const nativeFieldClasses = `min-h-12 px-4 text-[17px] text-[#000000] dark:text-[#ffffff] bg-[#767680]/12 dark:bg-[#767680]/24 rounded-[10px] border-0 ${inputClassName}`.trim()
167
169
  export const nativeLabelClasses = 'mb-1.5 px-4 text-[13px] uppercase text-[#6d6d72] dark:text-[#8d8d93]'
168
170
  export const nativeHelperClasses = `mt-1.5 px-4 text-[13px] ${error ? 'text-[#ff3b30] dark:text-[#ff453a]' : 'text-[#6d6d72] dark:text-[#8d8d93]'}`
169
171
  </script>
@@ -319,7 +321,7 @@ defineExpose({ value: inputValue, clear: onClear })
319
321
 
320
322
  @if(clearable)
321
323
  <button :if="!nativeClear" type="button" :show="hasValue() && !isDisabled() && !isReadonly()"
322
- @click="onClear()" class="absolute top-0 right-0 h-12 w-10 items-center justify-center" aria-label="Clear input"
324
+ @click="onClear()" class="absolute top-0 bottom-0 right-0 w-10 items-center justify-center" aria-label="Clear input"
323
325
  ><i class="i-lucide-circle-x h-[17px] w-[17px] text-[#c4c4c7] dark:text-[#5b5b5f]"></i></button>
324
326
  @endif
325
327
  </div>
@@ -222,6 +222,15 @@ function describeTrigger() {
222
222
  target.setAttribute('aria-describedby', existing.join(' '))
223
223
  }
224
224
 
225
+ /*
226
+ * A host has no `aria-describedby`. What it has is a hint: the sentence a
227
+ * screen reader adds after a control's name. Without it the words of a
228
+ * tooltip reached nobody who could not see them appear, since a reader has no
229
+ * reason to tap a button twice to find out what it is for. The hint is bound
230
+ * on the wrapper, which is the stop a reader makes: it is what takes the press.
231
+ */
232
+ const nativeHint = derived(() => isDisabled() ? null : (String(tooltipContent() ?? '').trim() || null))
233
+
225
234
  let restorePanel = null
226
235
  onMount(() => {
227
236
  describeTrigger()
@@ -243,6 +252,7 @@ onDestroy(() => { if (restorePanel) restorePanel() })
243
252
  itself (stacksjs/stx#2048). --}}
244
253
  <span
245
254
  data-native="Pressable"
255
+ @if($native):accessibilityHint="nativeHint()"@endif
246
256
  x-ref="triggerRef"
247
257
  @click="toggleTouch($event)"
248
258
  @mouseenter="showTooltip()"