@stacksjs/components 0.2.656 → 0.2.662
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.
- package/dist/{Button-55ahz0j6.stx → Button-j7gjvpxz.stx} +53 -0
- package/dist/{Checkbox-m90hgax3.stx → Checkbox-0grmgne5.stx} +20 -3
- package/dist/{Dialog-gec1h2y7.stx → Dialog-bb8d6zav.stx} +8 -0
- package/dist/{DialogDescription-gth4c2kx.stx → DialogDescription-yd2jgt2m.stx} +2 -1
- package/dist/{DialogPanel-dj0qjfdq.stx → DialogPanel-efae92wv.stx} +24 -0
- package/dist/{DialogTitle-ke58hh68.stx → DialogTitle-nw0pw114.stx} +2 -1
- package/dist/{Drawer-4rqfcg4f.stx → Drawer-fzvxe2c3.stx} +31 -0
- package/dist/{EmailInput-57626391.stx → EmailInput-sf9jfrgz.stx} +11 -2
- package/dist/{GroupedList-mx0b5fe7.stx → GroupedList-j3sxv5pb.stx} +13 -3
- package/dist/{GroupedListRow-nz8b6vx4.stx → GroupedListRow-v52zmzpk.stx} +42 -15
- package/dist/{Image-71fhf8fg.stx → Image-nwxax17j.stx} +8 -1
- package/dist/{ListRow-8d3e1yxh.stx → ListRow-nvyg2fwb.stx} +32 -8
- package/dist/{PasswordInput-dg41ktgd.stx → PasswordInput-r51qzgc0.stx} +64 -0
- package/dist/{SectionCard-8ctdacjr.stx → SectionCard-8b5fyrjd.stx} +16 -4
- package/dist/{SegmentedControl-yvkjtc7y.stx → SegmentedControl-z9gk2fpn.stx} +23 -5
- package/dist/{Select-61zv5tr7.stx → Select-1cnqbcmg.stx} +39 -0
- package/dist/{Switch-rbxpzn5g.stx → Switch-nay7zdee.stx} +46 -0
- package/dist/{Tab-46mxm7f8.stx → Tab-j9f4t166.stx} +5 -1
- package/dist/{TabList-5xwk2zmz.stx → TabList-r1pc87xs.stx} +8 -1
- package/dist/{Tabs-bp03efe6.stx → Tabs-psm5wj7c.stx} +16 -1
- package/dist/{TextInput-9bm9gy8j.stx → TextInput-vy4qpncz.stx} +138 -6
- package/dist/index.js +10 -10
- package/dist/ui/button/Button.d.ts +61 -0
- package/dist/ui/checkbox/Checkbox.d.ts +8 -1
- package/dist/ui/checkbox/index.d.ts +1 -0
- package/dist/ui/dialog/Dialog.d.ts +7 -1
- package/dist/ui/dialog/DialogPanel.d.ts +10 -0
- package/dist/ui/grouped-list/GroupedList.d.ts +8 -1
- package/dist/ui/grouped-list/GroupedListRow.d.ts +10 -2
- package/dist/ui/image/Image.d.ts +3 -1
- package/dist/ui/input/EmailInput.d.ts +8 -0
- package/dist/ui/input/PasswordInput.d.ts +10 -0
- package/dist/ui/input/TextInput.d.ts +12 -1
- package/dist/ui/mobile/ListRow.d.ts +13 -0
- package/dist/ui/mobile/SectionCard.d.ts +10 -0
- package/dist/ui/segmented-control/SegmentedControl.d.ts +10 -2
- package/dist/ui/tabs/Tab.d.ts +1 -1
- package/dist/ui/tabs/TabList.d.ts +6 -1
- package/dist/ui/tabs/Tabs.d.ts +8 -0
- package/package.json +3 -3
- package/src/ui/button/Button.stx +53 -0
- package/src/ui/checkbox/Checkbox.stx +20 -3
- package/src/ui/checkbox/index.ts +2 -0
- package/src/ui/dialog/Dialog.stx +8 -0
- package/src/ui/dialog/DialogDescription.stx +2 -1
- package/src/ui/dialog/DialogPanel.stx +24 -0
- package/src/ui/dialog/DialogTitle.stx +2 -1
- package/src/ui/drawer/Drawer.stx +31 -0
- package/src/ui/grouped-list/GroupedList.stx +13 -3
- package/src/ui/grouped-list/GroupedListRow.stx +42 -15
- package/src/ui/image/Image.stx +8 -1
- package/src/ui/input/EmailInput.stx +11 -2
- package/src/ui/input/PasswordInput.stx +64 -0
- package/src/ui/input/TextInput.stx +138 -6
- package/src/ui/mobile/ListRow.stx +32 -8
- package/src/ui/mobile/SectionCard.stx +16 -4
- package/src/ui/segmented-control/SegmentedControl.stx +23 -5
- package/src/ui/select/Select.stx +39 -0
- package/src/ui/switch/Switch.stx +46 -0
- package/src/ui/tabs/Tab.stx +5 -1
- package/src/ui/tabs/TabList.stx +8 -1
- package/src/ui/tabs/Tabs.stx +16 -1
package/src/ui/image/Image.stx
CHANGED
|
@@ -59,7 +59,9 @@ export const placeholder = placeholderMode === 'empty' || placeholderMode === 'n
|
|
|
59
59
|
: placeholderMode === 'blur' || placeholderMode === 'thumbhash' ? (imagePlaceholder?.transparent ? '' : preview ? `url("${preview}")` : placeholderColor)
|
|
60
60
|
: customPlaceholder || (delivered?.placeholder ? `url("${delivered.placeholder}")` : '')
|
|
61
61
|
export const aspectRatio = $props.aspectRatio
|
|
62
|
-
export const
|
|
62
|
+
export const authoredObjectFit = $props.objectFit || ''
|
|
63
|
+
export const authoredFit = $props.fit || ''
|
|
64
|
+
export const objectFit = authoredObjectFit || authoredFit || 'cover'
|
|
63
65
|
export const objectPosition = $props.objectPosition || $props.position || 'center'
|
|
64
66
|
export const rounded = $bool($props.rounded)
|
|
65
67
|
export const zoomOnHover = $bool($props.zoomOnHover)
|
|
@@ -126,6 +128,10 @@ export const imageStyle = [
|
|
|
126
128
|
|
|
127
129
|
<script client>
|
|
128
130
|
const imageSrc = useReactiveProp('src', {{ originalSrc }})
|
|
131
|
+
// Keep the documented alias live without letting it override objectFit.
|
|
132
|
+
const primaryFit = useReactiveProp('objectFit', {{ authoredObjectFit }})
|
|
133
|
+
const fallbackFit = useReactiveProp('fit', {{ authoredFit }})
|
|
134
|
+
const imageFit = derived(() => primaryFit() || fallbackFit() || 'cover')
|
|
129
135
|
// Preserve the delivered URL/candidates at hydration. A replacement URL must
|
|
130
136
|
// not keep selecting a responsive candidate belonging to the previous image.
|
|
131
137
|
const currentSrc = derived(() => imageSrc() === {{ originalSrc }} ? {{ src }} : (imageSrc() == null ? '' : String(imageSrc())))
|
|
@@ -177,5 +183,6 @@ const initialBackground = {{ placeholder ? `${placeholder} center / cover no-rep
|
|
|
177
183
|
decoding="{{ decoding }}"
|
|
178
184
|
fetchpriority="{{ fetchpriority }}"
|
|
179
185
|
style="{{ imageStyle }}"
|
|
186
|
+
:style="{ objectFit: imageFit() }"
|
|
180
187
|
/>
|
|
181
188
|
</picture>
|
|
@@ -24,6 +24,15 @@ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
|
|
|
24
24
|
export const form = $props.form || ''
|
|
25
25
|
export const inputMode = $props.inputMode || $props.inputmode || ''
|
|
26
26
|
export const enterKeyHint = $props.enterKeyHint || $props.enterkeyhint || ''
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* On a native host ($native) the field is the platform's: no envelope glyph
|
|
30
|
+
* and no monospace, which iOS mail fields do without. type="email" brings the
|
|
31
|
+
* email keyboard, no capitals and the person's addresses as autofill there
|
|
32
|
+
* (text-entry.ts).
|
|
33
|
+
*/
|
|
34
|
+
export const fieldIcon = $native ? '' : emailIcon
|
|
35
|
+
export const fieldFont = $native ? '' : 'font-mono'
|
|
27
36
|
</script>
|
|
28
37
|
|
|
29
38
|
{{-- type="email": served as text, an email field got no email keyboard on a
|
|
@@ -44,8 +53,8 @@ export const enterKeyHint = $props.enterKeyHint || $props.enterkeyhint || ''
|
|
|
44
53
|
:label="label"
|
|
45
54
|
:helperText="helperText"
|
|
46
55
|
:required="required"
|
|
47
|
-
:leftIcon="
|
|
56
|
+
:leftIcon="fieldIcon"
|
|
48
57
|
:clearable="true"
|
|
49
58
|
:className="className"
|
|
50
|
-
inputClassName="
|
|
59
|
+
:inputClassName="fieldFont"
|
|
51
60
|
/>
|
|
@@ -84,6 +84,17 @@ export const autocomplete = $props.autocomplete || $props.autoComplete || ''
|
|
|
84
84
|
export const form = $props.form || ''
|
|
85
85
|
export const inputMode = $props.inputMode || $props.inputmode || ''
|
|
86
86
|
export const enterKeyHint = $props.enterKeyHint || $props.enterkeyhint || ''
|
|
87
|
+
|
|
88
|
+
/*
|
|
89
|
+
* The field on a native host ($native), as TextInput draws it there: 48pt,
|
|
90
|
+
* filled, the system placeholder grey. Secure entry follows the reveal
|
|
91
|
+
* button through `:type` (text-entry.ts), and a field that names no
|
|
92
|
+
* autocomplete is the sign-in password, so the platform offers the saved one.
|
|
93
|
+
*/
|
|
94
|
+
export const nativeAutocomplete = autocomplete || 'current-password'
|
|
95
|
+
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()
|
|
96
|
+
export const nativeLabelClasses = 'mb-1.5 px-4 text-[13px] uppercase text-[#6d6d72] dark:text-[#8d8d93]'
|
|
97
|
+
export const nativeHelperClasses = `mt-1.5 px-4 text-[13px] ${error ? 'text-[#ff3b30] dark:text-[#ff453a]' : 'text-[#6d6d72] dark:text-[#8d8d93]'}`
|
|
87
98
|
</script>
|
|
88
99
|
|
|
89
100
|
<script client>
|
|
@@ -131,6 +142,58 @@ const toggleAriaLabel = derived(() => showPassword() ? 'Hide password' : 'Show p
|
|
|
131
142
|
defineExpose({ value: inputValue })
|
|
132
143
|
</script>
|
|
133
144
|
|
|
145
|
+
@if($native)
|
|
146
|
+
<div class="w-full {{ className }}">
|
|
147
|
+
@if(label)
|
|
148
|
+
<label for="{{ inputId }}" class="{{ nativeLabelClasses }}">{{ label }}</label>
|
|
149
|
+
@endif
|
|
150
|
+
<div class="relative justify-center">
|
|
151
|
+
<input
|
|
152
|
+
data-stx-native-host-root
|
|
153
|
+
@if(name)name="{{ name }}"@endif
|
|
154
|
+
autocomplete="{{ nativeAutocomplete }}"
|
|
155
|
+
@if(form)form="{{ form }}"@endif
|
|
156
|
+
@if(enterKeyHint)enterkeyhint="{{ enterKeyHint }}"@endif
|
|
157
|
+
type="password"
|
|
158
|
+
:type="inputType()"
|
|
159
|
+
id="{{ inputId }}"
|
|
160
|
+
class="{{ nativeFieldClasses }}"
|
|
161
|
+
placeholderTextColor="#8e8e93"
|
|
162
|
+
value="{{ value }}"
|
|
163
|
+
:value="inputValue()"
|
|
164
|
+
placeholder="{{ placeholder }}"
|
|
165
|
+
@if(disabled)disabled@endif
|
|
166
|
+
@if(readonly)readonly@endif
|
|
167
|
+
@if(required)required@endif
|
|
168
|
+
@input="onInput($event)"
|
|
169
|
+
aria-invalid="{{ error ? 'true' : 'false' }}"
|
|
170
|
+
/>
|
|
171
|
+
<button
|
|
172
|
+
type="button"
|
|
173
|
+
@click="toggleVisibility()"
|
|
174
|
+
class="absolute top-0 right-0 h-12 w-11 items-center justify-center"
|
|
175
|
+
:aria-label="toggleAriaLabel()"
|
|
176
|
+
>
|
|
177
|
+
<i :show="showPassword()" class="i-lucide-eye-off h-5 w-5 text-[#8e8e93]"></i>
|
|
178
|
+
<i :show="!showPassword()" class="i-lucide-eye h-5 w-5 text-[#8e8e93]"></i>
|
|
179
|
+
</button>
|
|
180
|
+
</div>
|
|
181
|
+
@if(showStrength)
|
|
182
|
+
<div :show="inputValue().length > 0" class="mt-2 px-4">
|
|
183
|
+
<div class="flex-row items-center justify-between mb-1">
|
|
184
|
+
<span class="text-[13px] text-[#6d6d72] dark:text-[#8d8d93]">Password strength</span>
|
|
185
|
+
<span class="text-[13px] font-medium" :class="strengthLabelColor()" :text="strengthText()"></span>
|
|
186
|
+
</div>
|
|
187
|
+
<div class="w-full h-1.5 bg-[#767680]/12 dark:bg-[#767680]/24 rounded-full overflow-hidden">
|
|
188
|
+
<div class="h-full rounded-full" :class="strengthColor()" :style="`width: ${strength()}%`"></div>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
@endif
|
|
192
|
+
@if(helperText)
|
|
193
|
+
<p id="{{ helperId }}" class="{{ nativeHelperClasses }}">{{ helperText }}</p>
|
|
194
|
+
@endif
|
|
195
|
+
</div>
|
|
196
|
+
@else
|
|
134
197
|
<div class="w-full {{ className }}">
|
|
135
198
|
@if(label)
|
|
136
199
|
<label for="{{ inputId }}" class="{{ labelClasses }}">
|
|
@@ -213,3 +276,4 @@ defineExpose({ value: inputValue })
|
|
|
213
276
|
</p>
|
|
214
277
|
@endif
|
|
215
278
|
</div>
|
|
279
|
+
@endif
|
|
@@ -143,29 +143,99 @@ export const minLength = freeText && given($props.minLength ?? $props.minlength)
|
|
|
143
143
|
export const htmlSize = freeText && given($props.htmlSize) ? String($props.htmlSize) : ''
|
|
144
144
|
export const list = type !== 'password' && given($props.list) ? String($props.list) : ''
|
|
145
145
|
export const autofocus = $bool($props.autofocus)
|
|
146
|
+
|
|
147
|
+
/*
|
|
148
|
+
* The field a phone app draws, for a native host ($native): 48pt tall, the
|
|
149
|
+
* 17pt body size, a filled rounded box that reads on a grouped background and
|
|
150
|
+
* a plain one alike, and the system's placeholder grey. The web's rings,
|
|
151
|
+
* shadow and density roles have nothing to draw on a device, and its icon
|
|
152
|
+
* slot is a web flourish iOS fields do without. An invalid field gets the
|
|
153
|
+
* system red outline, a disabled one dims as UIKit's do.
|
|
154
|
+
*/
|
|
155
|
+
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()
|
|
156
|
+
export const nativeLabelClasses = 'mb-1.5 px-4 text-[13px] uppercase text-[#6d6d72] dark:text-[#8d8d93]'
|
|
157
|
+
export const nativeHelperClasses = `mt-1.5 px-4 text-[13px] ${error ? 'text-[#ff3b30] dark:text-[#ff453a]' : 'text-[#6d6d72] dark:text-[#8d8d93]'}`
|
|
146
158
|
</script>
|
|
147
159
|
|
|
148
160
|
<script client>
|
|
149
|
-
|
|
161
|
+
// Reserve value events before the first edit: lazy input must not leak its
|
|
162
|
+
// bubbling DOM/native event object to a caller expecting the committed value.
|
|
163
|
+
const emit = defineEmits(['input', 'clear', 'focus', 'blur', 'submit', 'submit-editing'])
|
|
150
164
|
// Validity is live, for the same reason `disabled` is: a form posted with
|
|
151
165
|
// fetch learns it after the submit, and nothing re-renders (#2047).
|
|
152
166
|
const isError = useReactiveProp('error', {{ error }})
|
|
153
167
|
// Keep the physical control and its affordances live on both web and native.
|
|
154
168
|
const isDisabled = useReactiveProp('disabled', {{ disabled }})
|
|
169
|
+
const isReadonly = useReactiveProp('readonly', {{ readonly }})
|
|
155
170
|
// v-model:value supports modifiers; @input remains available to existing callers.
|
|
156
171
|
const inputValue = useModel('value', { default: {{ value }}, parse: (v) => v == null ? '' : String(v) })
|
|
172
|
+
let lastNativeCommit = String(inputValue() ?? '')
|
|
173
|
+
let lastInputText = lastNativeCommit
|
|
174
|
+
|
|
175
|
+
function onNativeFocus(event) {
|
|
176
|
+
lastNativeCommit = String(event.text ?? event.target.value ?? '')
|
|
177
|
+
lastInputText = lastNativeCommit
|
|
178
|
+
onFocus(event)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Focus/blur do not bubble from the physical input to the component scope.
|
|
182
|
+
// Forward the original event so browser FocusEvent methods and native payloads survive.
|
|
183
|
+
function onFocus(event) {
|
|
184
|
+
if (!isDisabled() && event.target.isConnected !== false) emit('focus', event)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function onBlur(event) {
|
|
188
|
+
if (event.target.isConnected !== false) emit('blur', event)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Native return-key callbacks use submit-editing (with submit as an alias).
|
|
192
|
+
// Do not commit lazy models here: end-editing owns that, and browser form
|
|
193
|
+
// submission remains the form's event rather than a synthetic input event.
|
|
194
|
+
function onNativeSubmit(event) {
|
|
195
|
+
if (isDisabled() || event.target.isConnected === false) return
|
|
196
|
+
emit('submit-editing', event)
|
|
197
|
+
emit('submit', event)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function onNativeChange(event) {
|
|
201
|
+
if (isDisabled() || isReadonly()) {
|
|
202
|
+
event.target.value = inputValue()
|
|
203
|
+
return
|
|
204
|
+
}
|
|
205
|
+
lastNativeCommit = String(event.target.value ?? '')
|
|
206
|
+
onChange(event)
|
|
207
|
+
emit('change', { ...event, type: 'change' })
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Craft commits text with onEndEditing, not a picker's onValueChange.
|
|
211
|
+
// Keep the shared @change event-shaped and @input value-shaped; the legacy
|
|
212
|
+
// primitive still exposes its original native payload without this adapter.
|
|
213
|
+
function onNativeEndEditing(event) {
|
|
214
|
+
if (isDisabled() || isReadonly()) {
|
|
215
|
+
event.target.value = inputValue()
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
const text = String(event.text ?? event.nativeEvent?.text ?? event.target.value ?? '')
|
|
219
|
+
if (text === lastNativeCommit) return
|
|
220
|
+
lastNativeCommit = text
|
|
221
|
+
event.target.value = text
|
|
222
|
+
if (inputValue.modifiers.lazy) onChange(event)
|
|
223
|
+
else if (lastInputText !== text) onInput(event)
|
|
224
|
+
emit('change', { ...event, type: 'change' })
|
|
225
|
+
}
|
|
157
226
|
|
|
158
227
|
function onInput(event) {
|
|
159
|
-
if (isDisabled()) {
|
|
228
|
+
if (isDisabled() || isReadonly()) {
|
|
160
229
|
event.target.value = inputValue()
|
|
161
230
|
return
|
|
162
231
|
}
|
|
232
|
+
lastInputText = String(event.target.value ?? '')
|
|
163
233
|
inputValue.input(event.target.value)
|
|
164
234
|
if (!inputValue.modifiers.lazy) emit('input', inputValue())
|
|
165
235
|
}
|
|
166
236
|
|
|
167
237
|
function onChange(event) {
|
|
168
|
-
if (isDisabled()) {
|
|
238
|
+
if (isDisabled() || isReadonly()) {
|
|
169
239
|
event.target.value = inputValue()
|
|
170
240
|
return
|
|
171
241
|
}
|
|
@@ -174,8 +244,10 @@ function onChange(event) {
|
|
|
174
244
|
}
|
|
175
245
|
|
|
176
246
|
function onClear() {
|
|
177
|
-
if (isDisabled()) return
|
|
247
|
+
if (isDisabled() || isReadonly()) return
|
|
178
248
|
inputValue.set('')
|
|
249
|
+
lastNativeCommit = ''
|
|
250
|
+
lastInputText = ''
|
|
179
251
|
emit('input', '')
|
|
180
252
|
emit('clear')
|
|
181
253
|
}
|
|
@@ -186,6 +258,62 @@ const charCount = derived(() => `${String(inputValue()).length} / {{ maxLength |
|
|
|
186
258
|
defineExpose({ value: inputValue, clear: onClear })
|
|
187
259
|
</script>
|
|
188
260
|
|
|
261
|
+
@if($native)
|
|
262
|
+
<div class="w-full {{ className }}">
|
|
263
|
+
@if(label)
|
|
264
|
+
<label for="{{ inputId }}" class="{{ nativeLabelClasses }}">{{ label }}</label>
|
|
265
|
+
@endif
|
|
266
|
+
<div class="relative justify-center">
|
|
267
|
+
<input
|
|
268
|
+
data-stx-native-host-root
|
|
269
|
+
@if(name)name="{{ name }}"@endif
|
|
270
|
+
@if(autocomplete)autocomplete="{{ autocomplete }}"@endif
|
|
271
|
+
@if(form)form="{{ form }}"@endif
|
|
272
|
+
@if(inputMode)inputmode="{{ inputMode }}"@endif
|
|
273
|
+
@if(enterKeyHint)enterkeyhint="{{ enterKeyHint }}"@endif
|
|
274
|
+
type="{{ type }}"
|
|
275
|
+
@if(autofocus)autofocus@endif
|
|
276
|
+
id="{{ inputId }}"
|
|
277
|
+
class="{{ nativeFieldClasses }}"
|
|
278
|
+
placeholderTextColor="#8e8e93"
|
|
279
|
+
value="{{ value }}"
|
|
280
|
+
:value="inputValue()"
|
|
281
|
+
placeholder="{{ placeholder }}"
|
|
282
|
+
@if(disabled)disabled@endif
|
|
283
|
+
:disabled="isDisabled()"
|
|
284
|
+
@if(readonly)readonly@endif
|
|
285
|
+
:readonly="isReadonly()"
|
|
286
|
+
@if(required)required@endif
|
|
287
|
+
@if(maxLength && freeText)maxlength="{{ maxLength }}"@endif
|
|
288
|
+
@input="onInput($event)"
|
|
289
|
+
@change="onNativeChange($event)"
|
|
290
|
+
@focus="onNativeFocus($event)"
|
|
291
|
+
@blur="onBlur($event)"
|
|
292
|
+
@submit-editing="onNativeSubmit($event)"
|
|
293
|
+
@end-editing="onNativeEndEditing($event)"
|
|
294
|
+
aria-invalid="{{ error ? 'true' : 'false' }}"
|
|
295
|
+
:aria-invalid="isError() ? 'true' : 'false'"
|
|
296
|
+
:class="{ 'border border-[#ff3b30] dark:border-[#ff453a]': isError(), 'opacity-50': isDisabled() }"
|
|
297
|
+
@if(clearable)style="padding-right: 40px"@endif
|
|
298
|
+
/>
|
|
299
|
+
@if(clearable)
|
|
300
|
+
<button
|
|
301
|
+
type="button"
|
|
302
|
+
:show="hasValue() && !isDisabled() && !isReadonly()"
|
|
303
|
+
@click="onClear()"
|
|
304
|
+
class="absolute top-0 right-0 h-12 w-10 items-center justify-center"
|
|
305
|
+
aria-label="Clear input"
|
|
306
|
+
><i class="i-lucide-circle-x h-[17px] w-[17px] text-[#c4c4c7] dark:text-[#5b5b5f]"></i></button>
|
|
307
|
+
@endif
|
|
308
|
+
</div>
|
|
309
|
+
@if(helperText)
|
|
310
|
+
<p id="{{ helperId }}" class="{{ nativeHelperClasses }}">{{ helperText }}</p>
|
|
311
|
+
@endif
|
|
312
|
+
@if(showCount && maxLength)
|
|
313
|
+
<p class="mt-1.5 px-4 text-right text-[13px] text-[#6d6d72] dark:text-[#8d8d93]" :text="charCount()"></p>
|
|
314
|
+
@endif
|
|
315
|
+
</div>
|
|
316
|
+
@else
|
|
189
317
|
<div class="w-full {{ className }}">
|
|
190
318
|
@if(label)
|
|
191
319
|
<label for="{{ inputId }}" class="{{ labelClasses }}">
|
|
@@ -238,18 +366,21 @@ defineExpose({ value: inputValue, clear: onClear })
|
|
|
238
366
|
@if(disabled)disabled@endif
|
|
239
367
|
:disabled="isDisabled()"
|
|
240
368
|
@if(readonly)readonly@endif
|
|
369
|
+
:readonly="isReadonly()"
|
|
241
370
|
@if(required)required@endif
|
|
242
371
|
@if(maxLength && freeText)maxlength="{{ maxLength }}"@endif
|
|
243
372
|
@input="onInput($event)"
|
|
244
373
|
@change="onChange($event)"
|
|
374
|
+
@focus="onFocus($event)"
|
|
375
|
+
@blur="onBlur($event)"
|
|
245
376
|
aria-invalid="{{ error ? 'true' : 'false' }}"
|
|
246
377
|
:aria-invalid="isError() ? 'true' : 'false'"
|
|
247
|
-
:class="{ '{{ stateInvalidClasses }}': isError(), '{{ stateValidClasses }}': !isError(), 'opacity-50 cursor-not-allowed': isDisabled(), 'bg-surface': isDisabled() ||
|
|
378
|
+
:class="{ '{{ stateInvalidClasses }}': isError(), '{{ stateValidClasses }}': !isError(), 'opacity-50 cursor-not-allowed': isDisabled(), 'bg-surface': isDisabled() || isReadonly(), 'bg-field': !isDisabled() && !isReadonly(), 'cursor-default': !isDisabled() && isReadonly() }"
|
|
248
379
|
@if(helperText)aria-describedby="{{ helperId }}"@endif
|
|
249
380
|
/>
|
|
250
381
|
|
|
251
382
|
@if(clearable)
|
|
252
|
-
<div :show="hasValue() && !isDisabled() && !
|
|
383
|
+
<div :show="hasValue() && !isDisabled() && !isReadonly()" class="absolute inset-y-0 right-0 flex items-center pr-3">
|
|
253
384
|
<button
|
|
254
385
|
type="button"
|
|
255
386
|
@click="onClear()"
|
|
@@ -285,3 +416,4 @@ defineExpose({ value: inputValue, clear: onClear })
|
|
|
285
416
|
</div>
|
|
286
417
|
@endif
|
|
287
418
|
</div>
|
|
419
|
+
@endif
|
|
@@ -31,11 +31,32 @@ export const className = $props.className || ''
|
|
|
31
31
|
export const interactive = href !== ''
|
|
32
32
|
export const tag = interactive ? 'a' : 'div'
|
|
33
33
|
|
|
34
|
-
export const rowClasses =
|
|
34
|
+
export const rowClasses = $native
|
|
35
|
+
? `flex-row w-full items-start gap-3 px-4 py-3 ${className}`.replace(/\s+/g, ' ').trim()
|
|
36
|
+
: `
|
|
35
37
|
flex w-full items-start gap-3 px-4 py-3 text-left
|
|
36
38
|
${interactive ? 'transition-colors active:bg-surface-sunken' : ''}
|
|
37
39
|
${className}
|
|
38
40
|
`.replace(/\s+/g, ' ').trim()
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* On a native host ($native): the label and secondary-label colours, the
|
|
44
|
+
* title clamped to two lines as a native Text clamps, and a link row that
|
|
45
|
+
* highlights grey while pressed, as a table cell does.
|
|
46
|
+
*/
|
|
47
|
+
const secondary = $native ? 'text-[#8a8a8e] dark:text-[#98989f]' : 'text-fg-muted'
|
|
48
|
+
export const eyebrowClasses = $native ? `text-[13px] ${secondary}` : 'block truncate text-sm text-fg-muted'
|
|
49
|
+
export const titleClasses = $native
|
|
50
|
+
? 'text-[15px] font-semibold text-[#000000] dark:text-[#ffffff] line-clamp-2'
|
|
51
|
+
: 'block text-[15px] font-semibold leading-snug text-fg-strong [display:-webkit-box] [-webkit-box-orient:vertical] [-webkit-line-clamp:2] overflow-hidden'
|
|
52
|
+
export const detailClasses = $native ? `mt-0.5 text-[13px] ${secondary} truncate` : 'mt-0.5 block truncate text-sm text-fg-muted'
|
|
53
|
+
export const metaClasses = $native ? `text-[13px] ${secondary}` : 'text-sm text-fg-muted'
|
|
54
|
+
export const trailingClasses = $native
|
|
55
|
+
? `rounded-[6px] bg-[#767680]/12 dark:bg-[#767680]/24 px-1.5 py-0.5 text-[12px] font-medium ${secondary}`
|
|
56
|
+
: 'rounded-control bg-surface-sunken px-1.5 py-0.5 text-xs font-medium text-fg-muted'
|
|
57
|
+
// A column natively: a span holding spans is otherwise one run of text there.
|
|
58
|
+
export const bodyClasses = $native ? 'flex flex-col min-w-0 flex-1' : 'min-w-0 flex-1'
|
|
59
|
+
export const unreadClasses = $native ? 'h-2 w-2 rounded-full bg-[#007aff] dark:bg-[#0a84ff]' : 'h-2 w-2 rounded-full bg-accent'
|
|
39
60
|
</script>
|
|
40
61
|
|
|
41
62
|
<{{ tag }}
|
|
@@ -44,6 +65,9 @@ export const rowClasses = `
|
|
|
44
65
|
@if (interactive)
|
|
45
66
|
href="{{ href }}"
|
|
46
67
|
@endif
|
|
68
|
+
@if (interactive && $native)
|
|
69
|
+
data-native="TouchableHighlight" underlayColor="#7676803d"
|
|
70
|
+
@endif
|
|
47
71
|
>
|
|
48
72
|
@if (icon || unread)
|
|
49
73
|
<span class="flex w-6 shrink-0 flex-col items-center gap-1.5 pt-0.5" aria-hidden="true">
|
|
@@ -55,14 +79,14 @@ export const rowClasses = `
|
|
|
55
79
|
hierarchy, and an unread list rendered entirely in bold has no
|
|
56
80
|
hierarchy left to spend.
|
|
57
81
|
--}}
|
|
58
|
-
<span class="
|
|
82
|
+
<span class="{{ unreadClasses }}"></span>
|
|
59
83
|
@endif
|
|
60
84
|
</span>
|
|
61
85
|
@endif
|
|
62
86
|
|
|
63
|
-
<span class="
|
|
87
|
+
<span class="{{ bodyClasses }}">
|
|
64
88
|
@if (eyebrow)
|
|
65
|
-
<span class="
|
|
89
|
+
<span class="{{ eyebrowClasses }}">{{ eyebrow }}</span>
|
|
66
90
|
@endif
|
|
67
91
|
|
|
68
92
|
{{--
|
|
@@ -70,12 +94,12 @@ export const rowClasses = `
|
|
|
70
94
|
title; unbounded lets a single pasted stack trace push the rest of the
|
|
71
95
|
list off the screen.
|
|
72
96
|
--}}
|
|
73
|
-
<span class="
|
|
97
|
+
<span class="{{ titleClasses }}">
|
|
74
98
|
{{ title }}
|
|
75
99
|
</span>
|
|
76
100
|
|
|
77
101
|
@if (detail)
|
|
78
|
-
<span class="
|
|
102
|
+
<span class="{{ detailClasses }}">{{ detail }}</span>
|
|
79
103
|
@endif
|
|
80
104
|
</span>
|
|
81
105
|
|
|
@@ -87,11 +111,11 @@ export const rowClasses = `
|
|
|
87
111
|
--}}
|
|
88
112
|
<span class="flex shrink-0 flex-col items-end gap-2 pt-0.5">
|
|
89
113
|
@if (meta)
|
|
90
|
-
<span class="
|
|
114
|
+
<span class="{{ metaClasses }}">{{ meta }}</span>
|
|
91
115
|
@endif
|
|
92
116
|
|
|
93
117
|
@if (trailing)
|
|
94
|
-
<span class="
|
|
118
|
+
<span class="{{ trailingClasses }}">{{ trailing }}</span>
|
|
95
119
|
@endif
|
|
96
120
|
</span>
|
|
97
121
|
@endif
|
|
@@ -17,10 +17,22 @@ export const action = $props.action || ''
|
|
|
17
17
|
export const actionHref = $props.actionHref || ''
|
|
18
18
|
export const className = $props.className || ''
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/*
|
|
21
|
+
* On a native host ($native) the card is iOS's inset group: white
|
|
22
|
+
* (#1c1c1e in dark) with 10pt corners and no outline, its rows parted by
|
|
23
|
+
* the system separator through the same `divide-y` (the host gives the
|
|
24
|
+
* border to every row shown after the first), under the large bold header a
|
|
25
|
+
* Today-style list heads a group with.
|
|
26
|
+
*/
|
|
27
|
+
export const cardClasses = $native
|
|
28
|
+
? 'overflow-hidden rounded-[10px] bg-[#ffffff] dark:bg-[#1c1c1e] divide-y-[0.5px] divide-[#c6c6c8] dark:divide-[#38383a]'
|
|
29
|
+
: `
|
|
21
30
|
overflow-hidden rounded-2xl border border-line bg-surface-raised
|
|
22
31
|
divide-y divide-line
|
|
23
32
|
`.replace(/\s+/g, ' ').trim()
|
|
33
|
+
export const headerClasses = $native ? 'flex-row items-baseline justify-between px-1 pb-2' : 'flex items-baseline justify-between px-1 pb-2'
|
|
34
|
+
export const titleClasses = $native ? 'text-[22px] font-bold text-[#000000] dark:text-[#ffffff]' : 'text-2xl font-bold tracking-tight text-fg-strong'
|
|
35
|
+
export const actionClasses = $native ? 'text-[17px] text-[#007aff] dark:text-[#0a84ff]' : 'text-sm font-medium text-accent'
|
|
24
36
|
|
|
25
37
|
/*
|
|
26
38
|
* Whether the router should own this link.
|
|
@@ -46,15 +58,15 @@ export const actionRouterOwned = routerOwns(actionHref)
|
|
|
46
58
|
|
|
47
59
|
<section class="{{ className }}" data-stx-section-card>
|
|
48
60
|
@if (title || action)
|
|
49
|
-
<header class="
|
|
61
|
+
<header class="{{ headerClasses }}">
|
|
50
62
|
@if (title)
|
|
51
|
-
<h2 class="
|
|
63
|
+
<h2 class="{{ titleClasses }}">{{ title }}</h2>
|
|
52
64
|
@endif
|
|
53
65
|
|
|
54
66
|
@if (action)
|
|
55
67
|
<a
|
|
56
68
|
href="{{ actionHref }}"
|
|
57
|
-
class="
|
|
69
|
+
class="{{ actionClasses }}"
|
|
58
70
|
@if (actionRouterOwned)
|
|
59
71
|
data-stx-link
|
|
60
72
|
@endif
|
|
@@ -52,9 +52,23 @@ export const sizing = sizeClasses[size]
|
|
|
52
52
|
|
|
53
53
|
// A block flex box already fills its column, so `stretch` needs no `w-full` -
|
|
54
54
|
// which beside a margin (`mx-4`) ran the track off the screen's edge.
|
|
55
|
-
export const trackClasses = `${stretch ? 'flex' : 'inline-flex'} flex-row gap-0.5 p-0.5 rounded-control bg-surface-sunken ${className}`.replace(/\s+/g, ' ').trim()
|
|
56
55
|
const segmentSizing = stretch ? sizing.segment.replace(/\bpx-\S+/, stretchedPadding[size]) : sizing.segment
|
|
57
|
-
|
|
56
|
+
/*
|
|
57
|
+
* On a native host ($native) the track and segments are UISegmentedControl's
|
|
58
|
+
* own: a translucent grey track with 9pt corners, the chosen segment raised
|
|
59
|
+
* white (#636366 in dark) with 7pt corners, every label in the label colour
|
|
60
|
+
* and the chosen one semibold.
|
|
61
|
+
*/
|
|
62
|
+
export const trackClasses = $native
|
|
63
|
+
? `${stretch ? 'flex' : 'self-start'} flex-row gap-0.5 p-0.5 rounded-[9px] bg-[#767680]/12 dark:bg-[#767680]/24 ${className}`.replace(/\s+/g, ' ').trim()
|
|
64
|
+
: `${stretch ? 'flex' : 'inline-flex'} flex-row gap-0.5 p-0.5 rounded-control bg-surface-sunken ${className}`.replace(/\s+/g, ' ').trim()
|
|
65
|
+
export const segmentBase = $native
|
|
66
|
+
? `${stretch ? 'flex-1 min-w-0' : ''} items-center justify-center rounded-[7px] ${segmentSizing}`.replace(/\s+/g, ' ').trim()
|
|
67
|
+
: `${stretch ? 'flex-1 min-w-0' : ''} items-center justify-center rounded-control transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${segmentSizing}`.replace(/\s+/g, ' ').trim()
|
|
68
|
+
export const segmentOn = $native ? 'bg-[#ffffff] dark:bg-[#636366] shadow-sm' : 'bg-panel dark:bg-neutral-600 shadow-sm'
|
|
69
|
+
export const segmentOff = $native ? 'opacity-50' : 'opacity-50 cursor-not-allowed'
|
|
70
|
+
export const labelOn = $native ? 'font-semibold text-[#000000] dark:text-[#ffffff]' : 'font-semibold text-fg'
|
|
71
|
+
export const labelOff = $native ? 'font-medium text-[#000000] dark:text-[#ffffff]' : 'font-medium text-fg-muted'
|
|
58
72
|
</script>
|
|
59
73
|
|
|
60
74
|
<script client>
|
|
@@ -67,6 +81,10 @@ const isDisabled = useReactiveProp('disabled', {{ disabled }})
|
|
|
67
81
|
const segmentBase = {{ segmentBase }}
|
|
68
82
|
const textSize = {{ sizing.text }}
|
|
69
83
|
const groupID = {{ testID }}
|
|
84
|
+
const segmentOn = {{ segmentOn }}
|
|
85
|
+
const segmentOff = {{ segmentOff }}
|
|
86
|
+
const labelOn = {{ labelOn }}
|
|
87
|
+
const labelOff = {{ labelOff }}
|
|
70
88
|
|
|
71
89
|
/** A choice as `{ value, label, disabled }`, whichever way it was written. */
|
|
72
90
|
function normalise(choice) {
|
|
@@ -102,12 +120,12 @@ function choose(segment) {
|
|
|
102
120
|
}
|
|
103
121
|
|
|
104
122
|
function segmentClasses(segment) {
|
|
105
|
-
const state = isOn(segment) ?
|
|
106
|
-
return `${segmentBase} ${state} ${isOff(segment) ?
|
|
123
|
+
const state = isOn(segment) ? segmentOn : 'bg-transparent'
|
|
124
|
+
return `${segmentBase} ${state} ${isOff(segment) ? segmentOff : 'cursor-pointer'}`
|
|
107
125
|
}
|
|
108
126
|
|
|
109
127
|
function labelClasses(segment) {
|
|
110
|
-
return `${textSize} ${isOn(segment) ?
|
|
128
|
+
return `${textSize} ${isOn(segment) ? labelOn : labelOff}`
|
|
111
129
|
}
|
|
112
130
|
|
|
113
131
|
function segmentID(segment) {
|
package/src/ui/select/Select.stx
CHANGED
|
@@ -146,6 +146,19 @@ function normaliseOptions(list) {
|
|
|
146
146
|
const optionSource = useReactiveProp('options', {{ options }}, { parse: v => normaliseOptions(v) })
|
|
147
147
|
const optionList = derived(() => normaliseOptions(optionSource()))
|
|
148
148
|
|
|
149
|
+
/*
|
|
150
|
+
* The choices as a native picker takes them (`items`), for a native host.
|
|
151
|
+
* Disabled choices are left out, since neither platform picker can show one
|
|
152
|
+
* it will not let you pick; the placeholder leads the list only while
|
|
153
|
+
* nothing in it is chosen, as the web's disabled first option does.
|
|
154
|
+
*/
|
|
155
|
+
const placeholderText = {{ placeholder }}
|
|
156
|
+
const nativeItems = derived(() => {
|
|
157
|
+
const list = optionList().filter(option => !option.disabled).map(option => ({ value: option.value, label: option.label }))
|
|
158
|
+
const chosen = list.some(option => option.value === selectedValue())
|
|
159
|
+
return placeholderText && !chosen ? [{ value: '', label: placeholderText }, ...list] : list
|
|
160
|
+
})
|
|
161
|
+
|
|
149
162
|
function onChange(event) {
|
|
150
163
|
selectedValue.set(event.target.value)
|
|
151
164
|
emit('change', selectedValue())
|
|
@@ -154,6 +167,31 @@ function onChange(event) {
|
|
|
154
167
|
defineExpose({ value: selectedValue, options: optionList })
|
|
155
168
|
</script>
|
|
156
169
|
|
|
170
|
+
@if($native)
|
|
171
|
+
{{-- On a native host the control is the platform's picker (UIPickerView,
|
|
172
|
+
Android's Spinner) fed with its items. Children are not something either
|
|
173
|
+
picker holds, so slotted <option>s are a web-only spelling. --}}
|
|
174
|
+
<div class="w-full {{ className }}">
|
|
175
|
+
@if(label)
|
|
176
|
+
<label for="{{ selectId }}" class="mb-1.5 px-4 text-[13px] uppercase text-[#6d6d72] dark:text-[#8d8d93]">{{ label }}</label>
|
|
177
|
+
@endif
|
|
178
|
+
<div
|
|
179
|
+
data-native="Picker"
|
|
180
|
+
data-stx-native-host-root
|
|
181
|
+
id="{{ selectId }}"
|
|
182
|
+
:items="nativeItems()"
|
|
183
|
+
:value="selectedValue()"
|
|
184
|
+
@if(disabled)disabled@endif
|
|
185
|
+
class="w-full disabled:opacity-50"
|
|
186
|
+
@change="onChange($event)"
|
|
187
|
+
aria-invalid="{{ error ? 'true' : 'false' }}"
|
|
188
|
+
:aria-invalid="isError() ? 'true' : 'false'"
|
|
189
|
+
></div>
|
|
190
|
+
@if(helperText)
|
|
191
|
+
<p id="{{ helperId }}" class="mt-1.5 px-4 text-[13px] {{ error ? 'text-[#ff3b30] dark:text-[#ff453a]' : 'text-[#6d6d72] dark:text-[#8d8d93]' }}">{{ helperText }}</p>
|
|
192
|
+
@endif
|
|
193
|
+
</div>
|
|
194
|
+
@else
|
|
157
195
|
<div class="w-full">
|
|
158
196
|
@if(label)
|
|
159
197
|
<label for="{{ selectId }}" class="{{ labelClasses }}">
|
|
@@ -224,3 +262,4 @@ defineExpose({ value: selectedValue, options: optionList })
|
|
|
224
262
|
</p>
|
|
225
263
|
@endif
|
|
226
264
|
</div>
|
|
265
|
+
@endif
|
package/src/ui/switch/Switch.stx
CHANGED
|
@@ -63,6 +63,18 @@ function trackClasses() {
|
|
|
63
63
|
return `${trackBase} ${stateClass} ${isDisabled() ? trackDisabled : ''} ${config.track} ${extraClass}`.trim()
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// The platform's switch reports its new value itself (a native host's
|
|
67
|
+
// value change); the web's button only says it was pressed.
|
|
68
|
+
function onNativeChange(event) {
|
|
69
|
+
if (isDisabled()) return
|
|
70
|
+
const next = event && typeof event === 'object'
|
|
71
|
+
? (event.value ?? event.nativeEvent?.value ?? event.target?.value)
|
|
72
|
+
: event
|
|
73
|
+
if (typeof next !== 'boolean' || next === isChecked()) return
|
|
74
|
+
isChecked.set(next)
|
|
75
|
+
emit('change', isChecked())
|
|
76
|
+
}
|
|
77
|
+
|
|
66
78
|
function thumbClasses() {
|
|
67
79
|
const pos = isChecked() ? config.translate : 'translate-x-0'
|
|
68
80
|
return `${thumbBase} ${pos} ${config.thumb}`.trim()
|
|
@@ -71,6 +83,39 @@ function thumbClasses() {
|
|
|
71
83
|
defineExpose({ isChecked, toggle })
|
|
72
84
|
</script>
|
|
73
85
|
|
|
86
|
+
@if($native)
|
|
87
|
+
{{-- On a native host the control is the platform's own switch (UISwitch,
|
|
88
|
+
Android's Switch), at the end of its row as a settings row puts it. --}}
|
|
89
|
+
<label class="flex-row items-center justify-between gap-3 {{ className }}">
|
|
90
|
+
<span :if="currentLabel()" :text="currentLabel()" class="flex-1 text-[17px] text-[#000000] dark:text-[#ffffff]">{{ label }}</span>
|
|
91
|
+
@if(name)
|
|
92
|
+
<input
|
|
93
|
+
type="hidden"
|
|
94
|
+
name="{{ name }}"
|
|
95
|
+
@if(disabled)disabled@endif
|
|
96
|
+
:disabled="isDisabled()"
|
|
97
|
+
@if(form)form="{{ form }}"@endif
|
|
98
|
+
value="{{ checked ? checkedValue : uncheckedValue }}"
|
|
99
|
+
:value="isChecked() ? '{{ checkedValue }}' : '{{ uncheckedValue }}'"
|
|
100
|
+
/>
|
|
101
|
+
@endif
|
|
102
|
+
<div
|
|
103
|
+
data-native="Switch"
|
|
104
|
+
data-stx-native-host-root
|
|
105
|
+
role="switch"
|
|
106
|
+
value="{{ checked ? 'true' : 'false' }}"
|
|
107
|
+
:value="isChecked()"
|
|
108
|
+
aria-label="{{ label || 'Toggle switch' }}"
|
|
109
|
+
:aria-label="currentLabel() || 'Toggle switch'"
|
|
110
|
+
:aria-checked="isChecked() ? 'true' : 'false'"
|
|
111
|
+
@if(disabled)disabled@endif
|
|
112
|
+
:disabled="isDisabled()"
|
|
113
|
+
:aria-disabled="isDisabled() ? 'true' : 'false'"
|
|
114
|
+
class="disabled:opacity-50"
|
|
115
|
+
@change="onNativeChange($event)"
|
|
116
|
+
></div>
|
|
117
|
+
</label>
|
|
118
|
+
@else
|
|
74
119
|
<label class="inline-flex items-center gap-3 cursor-pointer">
|
|
75
120
|
<span :if="currentLabel()" :text="currentLabel()" class="text-sm font-medium text-fg-strong">
|
|
76
121
|
{{ label }}
|
|
@@ -108,3 +153,4 @@ defineExpose({ isChecked, toggle })
|
|
|
108
153
|
<span aria-hidden="true" :class="thumbClasses()"></span>
|
|
109
154
|
</button>
|
|
110
155
|
</label>
|
|
156
|
+
@endif
|