@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
@@ -26,7 +26,14 @@ export declare const footer: unknown;
26
26
  export declare const flush: ReturnType<typeof $bool>;
27
27
  export declare const testID: unknown;
28
28
  export declare const className: unknown;
29
- export declare const groupClasses: unknown;
30
29
  export declare const noteInset: unknown;
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 declare const groupClasses: unknown;
36
+ export declare const headingClasses: string;
37
+ export declare const noteClasses: string;
31
38
  declare type __DtsxStxComponentType = DefineComponent<{ title?: string, footer?: string, flush?: unknown, testID?: string, className?: string }>;
32
39
  export default __dtsx_component__;
@@ -32,8 +32,16 @@ export declare const className: unknown;
32
32
  export declare const hasIcon: boolean;
33
33
  export declare const tag: unknown;
34
34
  export declare const tileClasses: string;
35
+ /*
36
+ * On a native host ($native) the row is a table cell: it highlights grey
37
+ * while pressed (TouchableHighlight, a translucent fill that reads in both
38
+ * appearances), its hairline is the system separator, its words are the
39
+ * label and secondary-label colours and its chevron the SF Symbol.
40
+ */
35
41
  export declare const rowClasses: unknown;
36
- export declare const ruleClasses: string;
37
- export declare const titleClasses: string;
42
+ export declare const ruleClasses: unknown;
43
+ export declare const titleClasses: unknown;
44
+ export declare const subtitleClasses: string;
45
+ export declare const valueClasses: string;
38
46
  declare type __DtsxStxComponentType = DefineComponent<{ title?: string, subtitle?: string, value?: string, icon?: string, tint?: unknown, chevron?: unknown, pressable?: unknown, destructive?: unknown, separator?: unknown, testID?: string, className?: string }> & { readonly __stxEmits?: ["select"] }
39
47
  export default __dtsx_component__;
@@ -24,5 +24,13 @@ export declare const autocomplete: unknown;
24
24
  export declare const form: unknown;
25
25
  export declare const inputMode: unknown;
26
26
  export declare const enterKeyHint: unknown;
27
+ /*
28
+ * On a native host ($native) the field is the platform's: no envelope glyph
29
+ * and no monospace, which iOS mail fields do without. type="email" brings the
30
+ * email keyboard, no capitals and the person's addresses as autofill there
31
+ * (text-entry.ts).
32
+ */
33
+ export declare const fieldIcon: unknown;
34
+ export declare const fieldFont: unknown;
27
35
  declare type __DtsxStxComponentType = DefineComponent<{ value?: string, placeholder?: string, disabled?: unknown, readonly?: unknown, size?: string, error?: unknown, label?: string, helperText?: string, required?: unknown, className?: string, name?: string, autocomplete?: unknown, autoComplete?: string, form?: string, inputMode?: unknown, inputmode?: string, enterKeyHint?: unknown, enterkeyhint?: string }>;
28
36
  export default __dtsx_component__;
@@ -80,5 +80,15 @@ export declare const autocomplete: unknown;
80
80
  export declare const form: unknown;
81
81
  export declare const inputMode: unknown;
82
82
  export declare const enterKeyHint: unknown;
83
+ /*
84
+ * The field on a native host ($native), as TextInput draws it there: 48pt,
85
+ * filled, the system placeholder grey. Secure entry follows the reveal
86
+ * button through `:type` (text-entry.ts), and a field that names no
87
+ * autocomplete is the sign-in password, so the platform offers the saved one.
88
+ */
89
+ export declare const nativeAutocomplete: unknown;
90
+ export declare const nativeFieldClasses: unknown;
91
+ export declare const nativeLabelClasses: 'mb-1.5 px-4 text-[13px] uppercase text-[#6d6d72] dark:text-[#8d8d93]';
92
+ export declare const nativeHelperClasses: string;
83
93
  declare type __DtsxStxComponentType = DefineComponent<{ value?: string, placeholder?: string, disabled?: unknown, readonly?: unknown, size?: string, error?: unknown, label?: string, id?: string, helperText?: string, required?: unknown, showStrength?: unknown, className?: string, inputClassName?: string, name?: string, autocomplete?: unknown, autoComplete?: string, form?: string, inputMode?: unknown, inputmode?: string, enterKeyHint?: unknown, enterkeyhint?: string }> & { readonly __stxExposed?: { value: unknown } }
84
94
  export default __dtsx_component__;
@@ -141,5 +141,16 @@ export declare const minLength: unknown;
141
141
  export declare const htmlSize: unknown;
142
142
  export declare const list: boolean;
143
143
  export declare const autofocus: ReturnType<typeof $bool>;
144
+ /*
145
+ * The field a phone app draws, for a native host ($native): 48pt tall, the
146
+ * 17pt body size, a filled rounded box that reads on a grouped background and
147
+ * a plain one alike, and the system's placeholder grey. The web's rings,
148
+ * shadow and density roles have nothing to draw on a device, and its icon
149
+ * slot is a web flourish iOS fields do without. An invalid field gets the
150
+ * system red outline, a disabled one dims as UIKit's do.
151
+ */
152
+ export declare const nativeFieldClasses: unknown;
153
+ export declare const nativeLabelClasses: 'mb-1.5 px-4 text-[13px] uppercase text-[#6d6d72] dark:text-[#8d8d93]';
154
+ export declare const nativeHelperClasses: string;
144
155
  declare type __DtsxStxComponentType = DefineComponent<{ value?: string, placeholder?: string, disabled?: unknown, readonly?: unknown, size?: string, error?: unknown, label?: string, helperText?: string, required?: unknown, leftIcon?: string, rightIcon?: string, clearable?: unknown, maxLength?: unknown, maxlength?: unknown, showCount?: unknown, className?: string, inputClassName?: string, id?: string, name?: string, autocomplete?: unknown, autoComplete?: string, form?: string, inputMode?: unknown, inputmode?: string, enterKeyHint?: unknown, enterkeyhint?: string, type?: unknown, min?: unknown, max?: unknown, step?: unknown, pattern?: unknown, minLength?: unknown, minlength?: unknown, htmlSize?: unknown, list?: unknown, autofocus?: unknown }> & { readonly __stxExposed?: { value: unknown, clear: unknown } }
145
156
  export default __dtsx_component__;
@@ -31,5 +31,18 @@ export declare const className: unknown;
31
31
  export declare const interactive: boolean;
32
32
  export declare const tag: unknown;
33
33
  export declare const rowClasses: unknown;
34
+ /*
35
+ * On a native host ($native): the label and secondary-label colours, the
36
+ * title clamped to two lines as a native Text clamps, and a link row that
37
+ * highlights grey while pressed, as a table cell does.
38
+ */
39
+ export declare const eyebrowClasses: unknown;
40
+ export declare const titleClasses: unknown;
41
+ export declare const detailClasses: unknown;
42
+ export declare const metaClasses: unknown;
43
+ export declare const trailingClasses: unknown;
44
+ // A column natively: a span holding spans is otherwise one run of text there.
45
+ export declare const bodyClasses: unknown;
46
+ export declare const unreadClasses: unknown;
34
47
  declare type __DtsxStxComponentType = DefineComponent<{ title?: string, eyebrow?: string, detail?: string, meta?: string, trailing?: string, icon?: string, unread?: unknown, href?: string, className?: string }>;
35
48
  export default __dtsx_component__;
@@ -32,7 +32,17 @@ export declare const title: unknown;
32
32
  export declare const action: unknown;
33
33
  export declare const actionHref: unknown;
34
34
  export declare const className: unknown;
35
+ /*
36
+ * On a native host ($native) the card is iOS's inset group: white
37
+ * (#1c1c1e in dark) with 10pt corners and no outline, its rows parted by
38
+ * the system separator through the same `divide-y` (the host gives the
39
+ * border to every row shown after the first), under the large bold header a
40
+ * Today-style list heads a group with.
41
+ */
35
42
  export declare const cardClasses: unknown;
43
+ export declare const headerClasses: unknown;
44
+ export declare const titleClasses: unknown;
45
+ export declare const actionClasses: unknown;
36
46
  export declare const actionRouterOwned: ReturnType<typeof routerOwns>;
37
47
  declare type __DtsxStxComponentType = DefineComponent<{ title?: string, action?: string, actionHref?: string, className?: string }>;
38
48
  export default __dtsx_component__;
@@ -64,10 +64,18 @@ declare const sizeClasses: {
64
64
  }
65
65
  };
66
66
  export declare const sizing: unknown;
67
- // A block flex box already fills its column, so `stretch` needs no `w-full` -
68
- // which beside a margin (`mx-4`) ran the track off the screen's edge.
67
+ /*
68
+ * On a native host ($native) the track and segments are UISegmentedControl's
69
+ * own: a translucent grey track with 9pt corners, the chosen segment raised
70
+ * white (#636366 in dark) with 7pt corners, every label in the label colour
71
+ * and the chosen one semibold.
72
+ */
69
73
  export declare const trackClasses: unknown;
70
74
  export declare const segmentBase: unknown;
75
+ export declare const segmentOn: unknown;
76
+ export declare const segmentOff: unknown;
77
+ export declare const labelOn: unknown;
78
+ export declare const labelOff: unknown;
71
79
  declare const selected: ReturnType<typeof useModel>;
72
80
  declare type __DtsxStxComponentType = DefineComponent<{ value?: string, options?: unknown[], label?: string, stretch?: unknown, disabled?: unknown, size?: unknown, testID?: string, className?: string }> & { readonly __stxEmits?: ["change"], readonly __stxExposed?: { selected: typeof selected } }
73
81
  export default __dtsx_component__;
@@ -14,6 +14,6 @@ export declare const controls: unknown;
14
14
  export declare const disabled: ReturnType<typeof $bool>;
15
15
  export declare const variant: unknown;
16
16
  export declare const className: unknown;
17
- export declare const tabClasses: unknown;
17
+ export declare const tabClasses: boolean;
18
18
  declare type __DtsxStxComponentType = DefineComponent<{ value?: string, controls?: string, disabled?: unknown, variant?: string, className?: string }>;
19
19
  export default __dtsx_component__;
@@ -28,7 +28,12 @@ export declare const labelledby: unknown;
28
28
  export declare const orientation: boolean;
29
29
  export declare const variant: unknown;
30
30
  export declare const className: unknown;
31
- export declare const listClasses: unknown;
31
+ /*
32
+ * On a native host ($native) a horizontal strip is the phone's segmented
33
+ * control, the control iOS uses to switch a screen between views; its tabs
34
+ * draw the raised segment through `aria-selected:` (Tab.stx).
35
+ */
36
+ export declare const listClasses: boolean;
32
37
  declare const selected: ReturnType<typeof useModel>;
33
38
  declare type __DtsxStxComponentType = DefineComponent<{ value?: string, label?: string, labelledby?: string, orientation?: unknown, variant?: string, className?: string }> & { readonly __stxExposed?: { selected: typeof selected } }
34
39
  export default __dtsx_component__;
@@ -20,6 +20,14 @@ export declare const className: unknown;
20
20
  */
21
21
  export declare const tabsInstanceId: unknown;
22
22
  export declare const containerClasses: unknown;
23
+ /*
24
+ * On a native host ($native) a horizontal strip is the phone's segmented
25
+ * control: a grey track, the selected tab raised (getTabClasses).
26
+ */
27
+ export declare const nativeTabs: boolean;
28
+ // Empty on the web, so its stylesheet never meets them.
29
+ export declare const nativeTabBase: unknown;
30
+ export declare const nativeTabOn: unknown;
23
31
  export declare const tabListClasses: unknown;
24
32
  export declare const tabPanelClasses: unknown;
25
33
  // True when the parent passes a non-empty `tabs` array — switches to the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/components",
3
3
  "type": "module",
4
- "version": "0.2.655",
4
+ "version": "0.2.661",
5
5
  "description": "A modern component library built with STX, featuring headwind utility classes and TypeScript syntax highlighting.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -77,8 +77,8 @@
77
77
  "dependencies": {
78
78
  "@iconify-json/f7": "^1.2.2",
79
79
  "@stacksjs/ts-css": "^0.3.11",
80
- "@stacksjs/stx": "0.2.655",
81
- "bun-plugin-stx": "0.2.655",
80
+ "@stacksjs/stx": "0.2.661",
81
+ "bun-plugin-stx": "0.2.661",
82
82
  "ts-syntax-highlighter": "^0.2.17",
83
83
  "ts-video-player": "^0.1.9"
84
84
  },
@@ -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"
@@ -1,6 +1,8 @@
1
1
  export { default as Checkbox } from './Checkbox.stx'
2
2
 
3
3
  export interface CheckboxProps {
4
+ /** Use the host browser's native switch while retaining checkbox semantics. */
5
+ appearance?: 'checkbox' | 'switch'
4
6
  checked?: boolean
5
7
  onChange?: (checked: boolean) => void
6
8
  disabled?: boolean
@@ -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 {
@@ -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 }}>
@@ -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
  />