@stacksjs/components 0.2.655 → 0.2.661

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 (59) hide show
  1. package/dist/{Button-55ahz0j6.stx → Button-j7gjvpxz.stx} +53 -0
  2. package/dist/{Checkbox-m90hgax3.stx → Checkbox-0grmgne5.stx} +20 -3
  3. package/dist/{Dialog-gec1h2y7.stx → Dialog-bb8d6zav.stx} +8 -0
  4. package/dist/{DialogDescription-gth4c2kx.stx → DialogDescription-yd2jgt2m.stx} +2 -1
  5. package/dist/{DialogPanel-dj0qjfdq.stx → DialogPanel-efae92wv.stx} +24 -0
  6. package/dist/{DialogTitle-ke58hh68.stx → DialogTitle-nw0pw114.stx} +2 -1
  7. package/dist/{Drawer-4rqfcg4f.stx → Drawer-fzvxe2c3.stx} +31 -0
  8. package/dist/{EmailInput-57626391.stx → EmailInput-sf9jfrgz.stx} +11 -2
  9. package/dist/{GroupedList-mx0b5fe7.stx → GroupedList-j3sxv5pb.stx} +13 -3
  10. package/dist/{GroupedListRow-nz8b6vx4.stx → GroupedListRow-v52zmzpk.stx} +42 -15
  11. package/dist/{ListRow-8d3e1yxh.stx → ListRow-nvyg2fwb.stx} +32 -8
  12. package/dist/{PasswordInput-dg41ktgd.stx → PasswordInput-r51qzgc0.stx} +64 -0
  13. package/dist/{SectionCard-8ctdacjr.stx → SectionCard-8b5fyrjd.stx} +16 -4
  14. package/dist/{SegmentedControl-yvkjtc7y.stx → SegmentedControl-z9gk2fpn.stx} +23 -5
  15. package/dist/{Select-61zv5tr7.stx → Select-1cnqbcmg.stx} +39 -0
  16. package/dist/{Switch-rbxpzn5g.stx → Switch-nay7zdee.stx} +46 -0
  17. package/dist/{Tab-46mxm7f8.stx → Tab-j9f4t166.stx} +5 -1
  18. package/dist/{TabList-5xwk2zmz.stx → TabList-r1pc87xs.stx} +8 -1
  19. package/dist/{Tabs-bp03efe6.stx → Tabs-psm5wj7c.stx} +16 -1
  20. package/dist/{TextInput-9bm9gy8j.stx → TextInput-9x2gwera.stx} +64 -0
  21. package/dist/index.js +10 -10
  22. package/dist/ui/button/Button.d.ts +61 -0
  23. package/dist/ui/checkbox/Checkbox.d.ts +8 -1
  24. package/dist/ui/checkbox/index.d.ts +1 -0
  25. package/dist/ui/dialog/Dialog.d.ts +7 -1
  26. package/dist/ui/dialog/DialogPanel.d.ts +10 -0
  27. package/dist/ui/grouped-list/GroupedList.d.ts +8 -1
  28. package/dist/ui/grouped-list/GroupedListRow.d.ts +10 -2
  29. package/dist/ui/input/EmailInput.d.ts +8 -0
  30. package/dist/ui/input/PasswordInput.d.ts +10 -0
  31. package/dist/ui/input/TextInput.d.ts +11 -0
  32. package/dist/ui/mobile/ListRow.d.ts +13 -0
  33. package/dist/ui/mobile/SectionCard.d.ts +10 -0
  34. package/dist/ui/segmented-control/SegmentedControl.d.ts +10 -2
  35. package/dist/ui/tabs/Tab.d.ts +1 -1
  36. package/dist/ui/tabs/TabList.d.ts +6 -1
  37. package/dist/ui/tabs/Tabs.d.ts +8 -0
  38. package/package.json +3 -3
  39. package/src/ui/button/Button.stx +53 -0
  40. package/src/ui/checkbox/Checkbox.stx +20 -3
  41. package/src/ui/checkbox/index.ts +2 -0
  42. package/src/ui/dialog/Dialog.stx +8 -0
  43. package/src/ui/dialog/DialogDescription.stx +2 -1
  44. package/src/ui/dialog/DialogPanel.stx +24 -0
  45. package/src/ui/dialog/DialogTitle.stx +2 -1
  46. package/src/ui/drawer/Drawer.stx +31 -0
  47. package/src/ui/grouped-list/GroupedList.stx +13 -3
  48. package/src/ui/grouped-list/GroupedListRow.stx +42 -15
  49. package/src/ui/input/EmailInput.stx +11 -2
  50. package/src/ui/input/PasswordInput.stx +64 -0
  51. package/src/ui/input/TextInput.stx +64 -0
  52. package/src/ui/mobile/ListRow.stx +32 -8
  53. package/src/ui/mobile/SectionCard.stx +16 -4
  54. package/src/ui/segmented-control/SegmentedControl.stx +23 -5
  55. package/src/ui/select/Select.stx +39 -0
  56. package/src/ui/switch/Switch.stx +46 -0
  57. package/src/ui/tabs/Tab.stx +5 -1
  58. package/src/ui/tabs/TabList.stx +8 -1
  59. package/src/ui/tabs/Tabs.stx +16 -1
@@ -107,6 +107,35 @@ export const isDisabled = disabled || loading
107
107
  export const buttonClasses = `${baseClasses} ${variantClasses[variant] || variantClasses.primary} ${sizeClasses[size] || sizeClasses.md} ${widthClasses} ${className}`.trim()
108
108
  export const iconClasses = iconSizeClasses[size] || iconSizeClasses.md
109
109
  export const spinnerClasses = `animate-spin ${iconClasses}`.trim()
110
+
111
+ /*
112
+ * The button a phone app draws, for a native host ($native): iOS's filled
113
+ * system-blue button for `primary`, its grey-filled tinted one for
114
+ * `secondary`, a plain tinted label for `ghost`, and the system red for
115
+ * `danger`, at the platform's control heights (44pt by default, 50pt for the
116
+ * `lg` button at the end of a flow). The web's hover, shadow and focus ring
117
+ * have nothing to draw on a device; the host dims the button while it is
118
+ * pressed, and `disabled:` dims it while it is off.
119
+ */
120
+ const nativeVariants = {
121
+ primary: { box: 'bg-[#007aff] dark:bg-[#0a84ff]', text: 'text-white' },
122
+ secondary: { box: 'bg-[#767680]/12 dark:bg-[#767680]/24', text: 'text-[#007aff] dark:text-[#0a84ff]' },
123
+ outline: { box: 'border border-[#007aff] dark:border-[#0a84ff]', text: 'text-[#007aff] dark:text-[#0a84ff]' },
124
+ ghost: { box: '', text: 'text-[#007aff] dark:text-[#0a84ff]' },
125
+ danger: { box: 'bg-[#ff3b30] dark:bg-[#ff453a]', text: 'text-white' },
126
+ }
127
+ const nativeSizes = {
128
+ xs: { box: 'h-7 px-2.5 gap-1 rounded-[7px]', text: 'text-[13px]' },
129
+ sm: { box: 'h-[34px] px-3 gap-1.5 rounded-[8px]', text: 'text-[15px]' },
130
+ md: { box: 'h-11 px-4 gap-2 rounded-[10px]', text: 'text-[17px]' },
131
+ lg: { box: 'h-[50px] px-5 gap-2 rounded-[12px]', text: 'text-[17px]' },
132
+ xl: { box: 'h-14 px-6 gap-2.5 rounded-[14px]', text: 'text-[19px]' },
133
+ }
134
+ const nativeVariant = nativeVariants[variant] || nativeVariants.primary
135
+ const nativeSize = nativeSizes[size] || nativeSizes.md
136
+ export const nativeButtonClasses = `flex-row items-center justify-center ${nativeSize.box} ${nativeVariant.box} disabled:opacity-50 ${fullWidth ? 'w-full' : ''} ${className}`.replace(/\s+/g, ' ').trim()
137
+ export const nativeTextClasses = `font-semibold ${nativeSize.text} ${nativeVariant.text}`
138
+ export const nativeTint = nativeVariant.text === 'text-white' ? '#ffffff' : '#007aff'
110
139
  </script>
111
140
 
112
141
  <script client>
@@ -156,6 +185,29 @@ function onClick(event) {
156
185
  }
157
186
  </script>
158
187
 
188
+ @if($native)
189
+ <button
190
+ type="{{ type }}"
191
+ class="{{ nativeButtonClasses }}"
192
+ activeOpacity="0.6"
193
+ @if(isDisabled)disabled@endif
194
+ :disabled="isDisabled()"
195
+ aria-busy="{{ loading ? 'true' : 'false' }}"
196
+ :aria-busy="isLoading() ? 'true' : 'false'"
197
+ @if(ariaLabel)aria-label="{{ ariaLabel }}"@endif
198
+ @click="onClick($event)"
199
+ >
200
+ <div data-native="ActivityIndicator" :show="isLoading()" color="{{ nativeTint }}" role="status"></div>
201
+ @if(leftIcon)
202
+ <span :show="!isLoading()" class="{{ iconClasses }} {{ nativeTextClasses }}">{!! leftIcon !!}</span>
203
+ @endif
204
+ <span :if="!labelText()" class="{{ nativeTextClasses }}"><slot /></span>
205
+ <span :if="labelText()" class="{{ nativeTextClasses }}" :text="labelText()">{{ label }}</span>
206
+ @if(rightIcon)
207
+ <span :show="!isLoading()" class="{{ iconClasses }} {{ nativeTextClasses }}">{!! rightIcon !!}</span>
208
+ @endif
209
+ </button>
210
+ @else
159
211
  <button
160
212
  type="{{ type }}"
161
213
  class="{{ buttonClasses }}"
@@ -226,3 +278,4 @@ function onClick(event) {
226
278
  <span :show="!isLoading()" @if(loading)x-cloak@endif class="{{ iconClasses }}">{!! rightIcon !!}</span>
227
279
  @endif
228
280
  </button>
281
+ @endif
@@ -10,6 +10,9 @@ export const required = $bool($props.required)
10
10
  export const value = $props.value || ''
11
11
  export const name = $props.name || ''
12
12
  export const className = $props.className || ''
13
+ // WebKit's native switch retains checkbox form, label and keyboard semantics.
14
+ // Other engines keep their ordinary checkbox until they implement `switch`.
15
+ export const switchAppearance = $props.appearance === 'switch'
13
16
 
14
17
  const sizeClasses = { sm: 'h-4 w-4', md: 'h-5 w-5', lg: 'h-6 w-6' }
15
18
  const baseClasses = 'rounded border-line-strong text-accent focus:ring-accent focus:ring-2 focus:ring-offset-2 focus:ring-offset-panel transition-colors'
@@ -23,9 +26,22 @@ export const stateInvalidClasses = 'border-danger-line text-danger focus:ring-da
23
26
  const stateClasses = error ? stateInvalidClasses : ''
24
27
  const disabledClasses = disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'
25
28
 
26
- export const checkboxClasses = `${baseClasses} ${sizeClasses[size] || sizeClasses.md} ${stateClasses} ${disabledClasses}`.trim()
27
- export const labelClasses = `text-sm font-medium ${error ? 'text-danger' : 'text-fg'} ${disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`.trim()
28
- export const descriptionClasses = `text-sm ${error ? 'text-danger' : 'text-fg-soft'}`.trim()
29
+ /*
30
+ * On a native host ($native) the box is the platform's own control, tinted
31
+ * system blue (red while invalid), beside a label at the 17pt body size.
32
+ */
33
+ const nativeTint = error ? 'text-[#ff3b30] dark:text-[#ff453a]' : 'text-[#007aff] dark:text-[#0a84ff]'
34
+ export const checkboxClasses = $native
35
+ ? `h-[22px] w-[22px] ${nativeTint} disabled:opacity-50`
36
+ : switchAppearance
37
+ ? `shrink-0 cursor-pointer ${disabledClasses}`.trim()
38
+ : `${baseClasses} ${sizeClasses[size] || sizeClasses.md} ${stateClasses} ${disabledClasses}`.trim()
39
+ export const labelClasses = $native
40
+ ? `text-[17px] ${error ? 'text-[#ff3b30] dark:text-[#ff453a]' : 'text-[#000000] dark:text-[#ffffff]'} ${disabled ? 'opacity-50' : ''}`.trim()
41
+ : `text-sm font-medium ${error ? 'text-danger' : 'text-fg'} ${disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`.trim()
42
+ export const descriptionClasses = $native
43
+ ? 'text-[15px] text-[#6d6d72] dark:text-[#8d8d93]'
44
+ : `text-sm ${error ? 'text-danger' : 'text-fg-soft'}`.trim()
29
45
  /*
30
46
  * Ids unique to this instance.
31
47
  *
@@ -83,6 +99,7 @@ defineExpose({ isChecked })
83
99
  data-stx-native-host-root
84
100
  id="{{ inputId }}"
85
101
  type="checkbox"
102
+ @if(switchAppearance)switch role="switch"@endif
86
103
  name="{{ name }}"
87
104
  @if(label)aria-label="{{ label }}"@endif
88
105
  :aria-label="currentLabel() || null"
@@ -31,6 +31,13 @@ export const dialogClasses = `${baseClasses} ${className}`.trim()
31
31
  * each other's Escape. Same idiom as Drawer, Dropdown and Popover.
32
32
  */
33
33
  export const dialogInstanceId = $uid
34
+
35
+ /*
36
+ * On a native host ($native) a dialog is presented the phone's way, as a
37
+ * sheet that slides up from the bottom edge (DialogPanel draws the sheet).
38
+ * `animationType="fade"` keeps an alert-like centred card from sliding.
39
+ */
40
+ export const nativeAnimation = $props.animationType || 'slide'
34
41
  </script>
35
42
 
36
43
  <script client>
@@ -183,6 +190,7 @@ defineExpose({
183
190
 
184
191
  <div
185
192
  data-native="Modal"
193
+ @if($native)animationType="{{ nativeAnimation }}"@endif
186
194
  x-ref="rootRef"
187
195
  :show="isOpen()"
188
196
  :data-state="isOpen() ? 'open' : 'closed'"
@@ -2,7 +2,8 @@
2
2
  export const className = $props.className || ''
3
3
  export const as = $props.as || 'p'
4
4
 
5
- const baseClasses = 'mt-2 text-sm text-fg-soft'
5
+ // The secondary-label body text under it, on a native host ($native).
6
+ const baseClasses = $native ? 'mt-1.5 text-[15px] text-[#3c3c43] dark:text-[#ebebf5]' : 'mt-2 text-sm text-fg-soft'
6
7
  const descriptionClasses = `${baseClasses} ${className}`.trim()
7
8
  </script>
8
9
 
@@ -31,8 +31,31 @@ const shape = isSheet
31
31
  const panelClasses = `transform overflow-hidden ${shape} bg-panel text-left align-middle shadow-xl transition-all ${className}`.replace(/\s+/g, ' ').trim()
32
32
  const panelStyle = isSheet ? (flush ? 'padding-bottom: env(safe-area-inset-bottom);' : 'padding-bottom: max(1.25rem, env(safe-area-inset-bottom));') : ''
33
33
  const grabberClasses = `mx-auto h-1.5 w-10 shrink-0 rounded-pill bg-line sm:hidden ${flush ? 'mt-2.5' : '-mt-2 mb-4'}`
34
+
35
+ /*
36
+ * On a native host ($native) a panel is a sheet unless it asks to be the
37
+ * centred card (`variant="center"`): what a phone presents a form or a
38
+ * confirmation in. Anchored to the bottom edge, 10pt top corners, the
39
+ * system's grabber, and room for the home indicator under its content.
40
+ */
41
+ export const nativeSheet = $props.variant !== 'center'
42
+ export const nativeWrapperClasses = nativeSheet ? 'absolute inset-0 justify-end' : 'absolute inset-0 items-center justify-center p-6'
43
+ export const nativePanelClasses = nativeSheet
44
+ ? `w-full max-h-[92%] rounded-t-[10px] bg-[#ffffff] dark:bg-[#1c1c1e] ${flush ? 'flex-col pb-[34px]' : 'px-5 pt-2 pb-[34px]'} ${className}`.replace(/\s+/g, ' ').trim()
45
+ : `w-full max-w-[400px] rounded-[14px] bg-[#ffffff] dark:bg-[#2c2c2e] ${flush ? 'flex-col' : 'p-5'} ${className}`.replace(/\s+/g, ' ').trim()
46
+ export const nativeGrabberClasses = `self-center h-[5px] w-9 shrink-0 rounded-full bg-[#c6c6c8] dark:bg-[#48484a] ${flush ? 'mt-1.5 mb-1.5' : 'mb-4'}`
34
47
  </script>
35
48
 
49
+ @if($native)
50
+ <div class="{{ nativeWrapperClasses }}">
51
+ <div class="{{ nativePanelClasses }}" data-stx-dialog-panel tabindex="-1">
52
+ @if(nativeSheet)
53
+ <div aria-hidden="true" class="{{ nativeGrabberClasses }}"></div>
54
+ @endif
55
+ <slot />
56
+ </div>
57
+ </div>
58
+ @else
36
59
  <component :is="{{ as }}" class="{{ baseClasses }}">
37
60
  <div class="{{ panelWrapperClasses }}">
38
61
  <!-- data-stx-dialog-panel is what Dialog scopes its focus trap and its
@@ -46,3 +69,4 @@ const grabberClasses = `mx-auto h-1.5 w-10 shrink-0 rounded-pill bg-line sm:hidd
46
69
  </div>
47
70
  </div>
48
71
  </component>
72
+ @endif
@@ -2,7 +2,8 @@
2
2
  export const className = $props.className || ''
3
3
  export const as = $props.as || 'h3'
4
4
 
5
- const baseClasses = 'text-lg font-medium leading-6 text-fg'
5
+ // A sheet's title on a native host ($native): iOS's 17pt semibold headline.
6
+ const baseClasses = $native ? 'text-[17px] font-semibold text-[#000000] dark:text-[#ffffff]' : 'text-lg font-medium leading-6 text-fg'
6
7
  const titleClasses = `${baseClasses} ${className}`.trim()
7
8
  </script>
8
9
 
@@ -181,6 +181,36 @@ defineExpose({
181
181
  })
182
182
  </script>
183
183
 
184
+ @if($native)
185
+ {{-- On a native host a drawer is the phone's sheet: it slides up from the
186
+ bottom edge whichever edge it is given, under a title bar with the close
187
+ button where iOS puts it. --}}
188
+ <div x-ref="rootRef" data-native="Modal" animationType="slide" data-stx-drawer="{{ drawerInstanceId }}" :show="isOpen()">
189
+ <div class="absolute inset-0 bg-[#000000]/40" aria-hidden="true" @click="onBackdropClick()"></div>
190
+ <div class="absolute inset-0 justify-end pt-12">
191
+ <div
192
+ class="w-full max-h-full rounded-t-[10px] bg-[#f2f2f7] dark:bg-[#1c1c1e] {{ className }}"
193
+ data-stx-drawer-panel="{{ drawerInstanceId }}"
194
+ x-ref="panelRef"
195
+ role="dialog"
196
+ aria-modal="true"
197
+ aria-label="{{ title }}"
198
+ tabindex="-1"
199
+ >
200
+ <div aria-hidden="true" class="self-center mt-1.5 h-[5px] w-9 rounded-full bg-[#c6c6c8] dark:bg-[#48484a]"></div>
201
+ <div class="flex-row items-center min-h-[44px] px-4">
202
+ <h2 class="flex-1 text-[17px] font-semibold text-[#000000] dark:text-[#ffffff]">{{ title }}</h2>
203
+ <button type="button" @click="close()" aria-label="Close panel" class="h-[30px] w-[30px] items-center justify-center rounded-full bg-[#767680]/12 dark:bg-[#767680]/24">
204
+ <i class="i-lucide-x h-3.5 w-3.5 text-[#8a8a8e] dark:text-[#98989f]"></i>
205
+ </button>
206
+ </div>
207
+ <div class="overflow-y-auto px-4 pb-[34px]">
208
+ <slot />
209
+ </div>
210
+ </div>
211
+ </div>
212
+ </div>
213
+ @else
184
214
  <div x-ref="rootRef" data-native="Modal" data-stx-drawer="{{ drawerInstanceId }}" :show="isOpen()">
185
215
  <div
186
216
  class="fixed inset-0 z-50 {{ backdropClass }} transition-opacity duration-500"
@@ -233,6 +263,7 @@ defineExpose({
233
263
  </div>
234
264
  </div>
235
265
  </div>
266
+ @endif
236
267
 
237
268
  <style>
238
269
  @keyframes fadeIn {
@@ -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="emailIcon"
56
+ :leftIcon="fieldIcon"
48
57
  :clearable="true"
49
58
  :className="className"
50
- inputClassName="font-mono"
59
+ :inputClassName="fieldFont"
51
60
  />
@@ -26,8 +26,18 @@ export const flush = $bool($props.flush)
26
26
  export const testID = $props.testID || ''
27
27
  export const className = $props.className || ''
28
28
 
29
- export const groupClasses = `overflow-hidden bg-panel ${flush ? '' : 'mx-4 rounded-panel'}`.replace(/\s+/g, ' ').trim()
30
29
  export const noteInset = flush ? 'mx-4' : 'mx-8'
30
+ /*
31
+ * On a native host ($native) the group is iOS's own: a white
32
+ * (#1c1c1e in dark) inset group with 10pt corners on the grouped background,
33
+ * its heading and note in the system's grouped-header grey.
34
+ */
35
+ export const groupClasses = $native
36
+ ? `overflow-hidden bg-[#ffffff] dark:bg-[#1c1c1e] ${flush ? '' : 'mx-4 rounded-[10px]'}`.replace(/\s+/g, ' ').trim()
37
+ : `overflow-hidden bg-panel ${flush ? '' : 'mx-4 rounded-panel'}`.replace(/\s+/g, ' ').trim()
38
+ const noteColour = $native ? 'text-[#6d6d72] dark:text-[#8d8d93]' : 'text-fg-soft'
39
+ export const headingClasses = `mb-1.5 ${noteInset} text-[13px] uppercase ${noteColour}`
40
+ export const noteClasses = `mt-1.5 ${noteInset} text-[13px] ${noteColour}`
31
41
  </script>
32
42
 
33
43
  <script client>
@@ -36,9 +46,9 @@ const note = useReactiveProp('footer', {{ footer }})
36
46
  </script>
37
47
 
38
48
  <section class="flex flex-col {{ className }}" @if(testID)testID="{{ testID }}"@endif data-stx-grouped-list>
39
- <h2 :show="heading()" :text="heading()" class="mb-1.5 {{ noteInset }} text-[13px] uppercase text-fg-soft">{{ title }}</h2>
49
+ <h2 :show="heading()" :text="heading()" class="{{ headingClasses }}">{{ title }}</h2>
40
50
  <div class="{{ groupClasses }}">
41
51
  <slot />
42
52
  </div>
43
- <p :show="note()" :text="note()" class="mt-1.5 {{ noteInset }} text-[13px] text-fg-soft">{{ footer }}</p>
53
+ <p :show="note()" :text="note()" class="{{ noteClasses }}">{{ footer }}</p>
44
54
  </section>
@@ -29,20 +29,45 @@ export const separator = $bool($props.separator)
29
29
  export const testID = $props.testID || ''
30
30
  export const className = $props.className || ''
31
31
 
32
- const tintFills = {
33
- accent: 'bg-accent-solid',
34
- success: 'bg-success-solid',
35
- danger: 'bg-danger-solid',
36
- warning: 'bg-warning-solid',
37
- info: 'bg-info-solid',
38
- secondary: 'bg-secondary-solid',
39
- }
32
+ const tintFills = $native
33
+ ? {
34
+ // The system colours a Settings tile is filled with.
35
+ accent: 'bg-[#007aff]',
36
+ success: 'bg-[#34c759]',
37
+ danger: 'bg-[#ff3b30]',
38
+ warning: 'bg-[#ff9500]',
39
+ info: 'bg-[#32ade6]',
40
+ secondary: 'bg-[#8e8e93]',
41
+ }
42
+ : {
43
+ accent: 'bg-accent-solid',
44
+ success: 'bg-success-solid',
45
+ danger: 'bg-danger-solid',
46
+ warning: 'bg-warning-solid',
47
+ info: 'bg-info-solid',
48
+ secondary: 'bg-secondary-solid',
49
+ }
40
50
  export const hasIcon = icon !== ''
41
51
  export const tag = pressable ? 'button' : 'div'
42
52
  export const tileClasses = `flex shrink-0 items-center justify-center h-[29px] w-[29px] rounded-[7px] text-white ${tintFills[tint]}`
43
- export const rowClasses = `flex flex-row items-center gap-3 w-full min-h-[44px] px-4 py-2.5 text-left ${pressable ? 'cursor-pointer active:bg-surface-hover focus:outline-none focus-visible:bg-surface-hover' : ''} ${className}`.replace(/\s+/g, ' ').trim()
44
- export const ruleClasses = `h-[0.5px] bg-line ${hasIcon ? 'ml-[57px]' : 'ml-4'}`
45
- export const titleClasses = `text-[17px] ${destructive ? 'text-danger' : 'text-fg'}`
53
+ /*
54
+ * On a native host ($native) the row is a table cell: it highlights grey
55
+ * while pressed (TouchableHighlight, a translucent fill that reads in both
56
+ * appearances), its hairline is the system separator, its words are the
57
+ * label and secondary-label colours and its chevron the SF Symbol.
58
+ */
59
+ export const rowClasses = $native
60
+ ? `flex-row items-center gap-3 w-full min-h-[44px] px-4 py-2.5 ${className}`.replace(/\s+/g, ' ').trim()
61
+ : `flex flex-row items-center gap-3 w-full min-h-[44px] px-4 py-2.5 text-left ${pressable ? 'cursor-pointer active:bg-surface-hover focus:outline-none focus-visible:bg-surface-hover' : ''} ${className}`.replace(/\s+/g, ' ').trim()
62
+ export const ruleClasses = $native
63
+ ? `h-[0.5px] bg-[#c6c6c8] dark:bg-[#38383a] ${hasIcon ? 'ml-[57px]' : 'ml-4'}`
64
+ : `h-[0.5px] bg-line ${hasIcon ? 'ml-[57px]' : 'ml-4'}`
65
+ export const titleClasses = $native
66
+ ? `text-[17px] ${destructive ? 'text-[#ff3b30] dark:text-[#ff453a]' : 'text-[#000000] dark:text-[#ffffff]'}`
67
+ : `text-[17px] ${destructive ? 'text-danger' : 'text-fg'}`
68
+ const secondary = $native ? 'text-[#8a8a8e] dark:text-[#98989f]' : 'text-fg-soft'
69
+ export const subtitleClasses = `text-[15px] ${secondary}`
70
+ export const valueClasses = `shrink-0 text-[17px] ${secondary}`
46
71
  </script>
47
72
 
48
73
  <script client>
@@ -59,17 +84,19 @@ function select() {
59
84
 
60
85
  <div class="flex flex-col" data-stx-grouped-list-row>
61
86
  <div :show="ruled()" class="{{ ruleClasses }}" aria-hidden="true"></div>
62
- <{{ tag }} @if(pressable)type="button" @click="select()"@endif class="{{ rowClasses }}" @if(testID)testID="{{ testID }}"@endif>
87
+ <{{ tag }} @if(pressable)type="button" @click="select()"@endif @if(pressable && $native)data-native="TouchableHighlight" underlayColor="#7676803d"@endif class="{{ rowClasses }}" @if(testID)testID="{{ testID }}"@endif>
63
88
  @if(hasIcon)
64
89
  <span class="{{ tileClasses }}" aria-hidden="true">{!! icon !!}</span>
65
90
  @endif
66
91
  <span class="flex flex-1 min-w-0 flex-col">
67
92
  <span :text="heading()" class="{{ titleClasses }}">{{ title }}</span>
68
- <span :show="detail()" :text="detail()" class="text-[15px] text-fg-soft">{{ subtitle }}</span>
93
+ <span :show="detail()" :text="detail()" class="{{ subtitleClasses }}">{{ subtitle }}</span>
69
94
  </span>
70
- <span :show="trailing()" :text="trailing()" class="shrink-0 text-[17px] text-fg-soft">{{ value }}</span>
95
+ <span :show="trailing()" :text="trailing()" class="{{ valueClasses }}">{{ value }}</span>
71
96
  <slot />
72
- @if(chevron)
97
+ @if(chevron && $native)
98
+ <i class="i-lucide-chevron-right h-3.5 w-3.5 shrink-0 text-[#c4c4c7] dark:text-[#5b5b5f]" aria-hidden="true"></i>
99
+ @elseif(chevron)
73
100
  <svg class="h-3.5 w-3.5 shrink-0 text-fg-soft" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6" /></svg>
74
101
  @endif
75
102
  </{{ tag }}>
@@ -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="h-2 w-2 rounded-full bg-accent"></span>
82
+ <span class="{{ unreadClasses }}"></span>
59
83
  @endif
60
84
  </span>
61
85
  @endif
62
86
 
63
- <span class="min-w-0 flex-1">
87
+ <span class="{{ bodyClasses }}">
64
88
  @if (eyebrow)
65
- <span class="block truncate text-sm text-fg-muted">{{ eyebrow }}</span>
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="block text-[15px] font-semibold leading-snug text-fg-strong [display:-webkit-box] [-webkit-box-orient:vertical] [-webkit-line-clamp:2] overflow-hidden">
97
+ <span class="{{ titleClasses }}">
74
98
  {{ title }}
75
99
  </span>
76
100
 
77
101
  @if (detail)
78
- <span class="mt-0.5 block truncate text-sm text-fg-muted">{{ detail }}</span>
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="text-sm text-fg-muted">{{ meta }}</span>
114
+ <span class="{{ metaClasses }}">{{ meta }}</span>
91
115
  @endif
92
116
 
93
117
  @if (trailing)
94
- <span class="rounded-control bg-surface-sunken px-1.5 py-0.5 text-xs font-medium text-fg-muted">{{ trailing }}</span>
118
+ <span class="{{ trailingClasses }}">{{ trailing }}</span>
95
119
  @endif
96
120
  </span>
97
121
  @endif
@@ -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
@@ -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
- export const cardClasses = `
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="flex items-baseline justify-between px-1 pb-2">
61
+ <header class="{{ headerClasses }}">
50
62
  @if (title)
51
- <h2 class="text-2xl font-bold tracking-tight text-fg-strong">{{ title }}</h2>
63
+ <h2 class="{{ titleClasses }}">{{ title }}</h2>
52
64
  @endif
53
65
 
54
66
  @if (action)
55
67
  <a
56
68
  href="{{ actionHref }}"
57
- class="text-sm font-medium text-accent"
69
+ class="{{ actionClasses }}"
58
70
  @if (actionRouterOwned)
59
71
  data-stx-link
60
72
  @endif