@joralvmel/cosmos-mcp 0.1.1 → 0.4.0
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/data/docs.json +1 -1
- package/dist/data/llms/angular.md +520 -7
- package/dist/data/llms/core.md +797 -6
- package/dist/data/llms/elements.md +455 -7
- package/dist/data/llms/native.md +483 -7
- package/dist/data/llms/react.md +477 -7
- package/dist/data/llms/tailwind.md +1 -1
- package/dist/data/llms/tokens.md +1 -1
- package/dist/data/status.json +1 -1
- package/package.json +3 -3
package/dist/data/llms/native.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
React Native components of Cosmos UI with the same contracts and themes as the web. Callbacks receive the event detail directly.
|
|
4
4
|
|
|
5
|
+
On React Native Web, TextField draws its focus indicator on the outer control, without a second
|
|
6
|
+
browser outline around the editable input.
|
|
7
|
+
Icons do not take focus independently of their owning controls. TextField reserves at least
|
|
8
|
+
44 units of editable width when long affixes and actions compete for space.
|
|
9
|
+
Its `appearance` accepts `startIconColor` and `endIconColor` (native colors); action icons,
|
|
10
|
+
affixes and editable text retain their own colors.
|
|
11
|
+
|
|
12
|
+
Checkbox, TextField and Select highlight enabled valid controls on pointer hover without simulating
|
|
13
|
+
touch hover. Checked/mixed Checkbox uses `primary-hover`; invalid borders keep danger. TextField
|
|
14
|
+
input or action focus adds `primary-subtle`. Select keeps its trigger active and rotates its
|
|
15
|
+
chevron while expanded. Disabled controls do not react, and existing appearance/style customization
|
|
16
|
+
keeps priority.
|
|
17
|
+
|
|
5
18
|
<!-- generated:start (npm run llms, do not edit this block by hand) -->
|
|
6
19
|
|
|
7
20
|
## Setup: React Native (Expo)
|
|
@@ -71,17 +84,15 @@ export function Example() {
|
|
|
71
84
|
```
|
|
72
85
|
### `Icon`
|
|
73
86
|
|
|
74
|
-
Renders a structured SVG icon.
|
|
87
|
+
Renders a structured SVG icon. Icons are decorative and hidden from assistive technology unless a nonempty label makes them informative.
|
|
75
88
|
|
|
76
89
|
| Prop | Type | Default | Description |
|
|
77
90
|
| --- | --- | --- | --- |
|
|
78
91
|
| `icon` | IconDefinition | Required | Structured icon definition, commonly imported from @joralvmel/cosmos-icons. |
|
|
79
92
|
| `size` | 'sm' \| 'md' \| 'lg' \| number | `md` | Semantic size (16, 20 or 24) or a positive finite number in pixels / native units. |
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `label` | string | — | Accessible name required when decorative is false. |
|
|
84
|
-
| `decorative` | boolean | `true` | Hides the icon from assistive technology when true. |
|
|
93
|
+
| `variant` | 'outline' \| 'filled' | `outline` | Appearance. outline draws only the stroke; filled also fills the shapes with the icon color (for example a favorite star or heart). Explicit node fills in the definition always win. |
|
|
94
|
+
| `color` | string | `currentColor` | Icon color (stroke, currentColor fills and the filled variant). currentColor inherits the surrounding text color on web and the parent control or theme foreground on native; otherwise a supported color without URLs. |
|
|
95
|
+
| `label` | string | — | Accessible name. A nonempty label makes the icon an informative image; without one the icon is decorative and hidden from assistive technology. |
|
|
85
96
|
|
|
86
97
|
Events: none.
|
|
87
98
|
|
|
@@ -95,10 +106,475 @@ export function Example() {
|
|
|
95
106
|
);
|
|
96
107
|
}
|
|
97
108
|
```
|
|
109
|
+
### `TextField`
|
|
110
|
+
|
|
111
|
+
Accepts a single line of text with an accessible label, optional helper and error text, and native form validation on the web.
|
|
112
|
+
|
|
113
|
+
| Prop | Type | Default | Description |
|
|
114
|
+
| --- | --- | --- | --- |
|
|
115
|
+
| `label` | string | Required | Accessible name for the editable control. It is rendered above the control unless visually hidden. |
|
|
116
|
+
| `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |
|
|
117
|
+
| `value` | string | — | Current text. When bound, edits are proposals and the component waits for the owner to supply the accepted value. |
|
|
118
|
+
| `defaultValue` | string | `` | Initial value for autonomous use. Web form reset restores this value; it does not control subsequent edits. |
|
|
119
|
+
| `type` | 'text' \| 'email' \| 'password' \| 'tel' \| 'url' \| 'search' | `text` | Single-line input type. Native maps it to supported keyboard, autofill and secure-entry behavior. |
|
|
120
|
+
| `variant` | 'outlined' \| 'filled' | `outlined` | Visual treatment of the editable control. |
|
|
121
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large editable control. |
|
|
122
|
+
| `placeholder` | string | — | Short input hint; it never replaces the accessible label. |
|
|
123
|
+
| `helperText` | string | — | Optional supporting text associated with the editable control. |
|
|
124
|
+
| `errorText` | string | — | Optional consumer-localized error text associated with the editable control; a nonempty trimmed value also exposes invalid state. |
|
|
125
|
+
| `invalid` | boolean | `false` | External invalid state when the visible error is supplied elsewhere, independent of browser constraints or consumer business validation. |
|
|
126
|
+
| `required` | boolean | `false` | Exposes required semantics. On web, participates in native HTML constraint validation. |
|
|
127
|
+
| `disabled` | boolean | `false` | Disables editing and interaction. On web, follows disabled fieldsets and excludes the value from form submission. |
|
|
128
|
+
| `readOnly` | boolean | `false` | Prevents editing while remaining focusable and form-submittable on web; distinct from disabled. |
|
|
129
|
+
| `minLength` | number | — | Minimum number of characters. Web uses native HTML validity; native business validation remains the consumer’s responsibility. |
|
|
130
|
+
| `maxLength` | number | — | Maximum number of characters. Web uses native HTML validity and native applies supported input limits. |
|
|
131
|
+
| `autoComplete` | string | — | Consumer-provided completion/autofill hint, mapped to attributes supported by each platform. |
|
|
132
|
+
| `inputMode` | 'none' \| 'text' \| 'decimal' \| 'numeric' \| 'tel' \| 'search' \| 'email' \| 'url' | — | Input or keyboard hint (none, text, decimal, numeric, tel, search, email or url); it does not add numeric or multiline field behavior. |
|
|
133
|
+
| `startIcon` | IconDefinition | — | Optional structured decorative icon before the editable text. |
|
|
134
|
+
| `endIcon` | IconDefinition | — | Optional structured decorative icon after the editable text. |
|
|
135
|
+
| `prefix` | string | — | Optional non-interactive text decoration before the editable text. |
|
|
136
|
+
| `suffix` | string | — | Optional non-interactive text decoration after the editable text. |
|
|
137
|
+
| `clearable` | boolean | `false` | Shows a clear action for non-empty editable fields. Supply clearLabel when enabled. |
|
|
138
|
+
| `clearLabel` | string | — | Consumer-supplied localized accessible name for the clear action. |
|
|
139
|
+
| `passwordReveal` | boolean | `false` | Opts into a reveal action for password fields. Supply both revealPasswordLabel and hidePasswordLabel when enabled. |
|
|
140
|
+
| `revealPasswordLabel` | string | — | Consumer-supplied localized accessible name while the password is concealed. |
|
|
141
|
+
| `hidePasswordLabel` | string | — | Consumer-supplied localized accessible name while the password is revealed. |
|
|
142
|
+
|
|
143
|
+
Events: `onValueChange` → `TextFieldChangeDetail`, `onSubmitEditing` → `TextFieldSubmitDetail`.
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import { TextField } from '@joralvmel/cosmos-native';
|
|
147
|
+
import { search } from '@joralvmel/cosmos-icons/search';
|
|
148
|
+
|
|
149
|
+
export function Example() {
|
|
150
|
+
return (
|
|
151
|
+
<TextField
|
|
152
|
+
label="TextField"
|
|
153
|
+
startIcon={search}
|
|
154
|
+
endIcon={search}
|
|
155
|
+
onValueChange={detail => console.log(detail)}
|
|
156
|
+
onSubmitEditing={detail => console.log(detail)}
|
|
157
|
+
>
|
|
158
|
+
</TextField>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
### `IconButton`
|
|
163
|
+
|
|
164
|
+
Activates an action or toggles a boolean state using a labeled icon.
|
|
165
|
+
|
|
166
|
+
| Prop | Type | Default | Description |
|
|
167
|
+
| --- | --- | --- | --- |
|
|
168
|
+
| `label` | string | Required | Required localized accessible name. Missing, empty or whitespace-only labels are rejected. |
|
|
169
|
+
| `mode` | 'action' \| 'toggle' | `action` | Action activates without toggle state; toggle exposes and changes pressed state. |
|
|
170
|
+
| `variant` | 'solid' \| 'soft' \| 'outline' \| 'ghost' | `solid` | Visual emphasis, from highest (solid) to lowest (ghost). |
|
|
171
|
+
| `tone` | 'primary' \| 'neutral' \| 'danger' | `primary` | Color role. Use danger for destructive actions. |
|
|
172
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Size of the square visual control. |
|
|
173
|
+
| `disabled` | boolean | `false` | Prevents activation and removes the web button from the tab order. |
|
|
174
|
+
| `pressed` | boolean | `false` | Toggle state. If supplied, including false, activation proposes changes without committing them until the owner updates this prop. |
|
|
175
|
+
| `defaultPressed` | boolean | `false` | Initial toggle state when pressed is not supplied; it does not control later changes. |
|
|
176
|
+
|
|
177
|
+
Events: `onPress` → `IconButtonPressDetail`, `onPressedChange` → `IconButtonPressedChangeDetail`.
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
import { heart } from '@joralvmel/cosmos-icons/heart';
|
|
181
|
+
import { IconButton, Icon } from '@joralvmel/cosmos-native';
|
|
182
|
+
|
|
183
|
+
export function Example() {
|
|
184
|
+
return (
|
|
185
|
+
<IconButton
|
|
186
|
+
label="IconButton"
|
|
187
|
+
onPress={detail => console.log(detail)}
|
|
188
|
+
onPressedChange={detail => console.log(detail)}
|
|
189
|
+
>
|
|
190
|
+
<Icon icon={heart}></Icon>
|
|
191
|
+
</IconButton>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
### `Popover`
|
|
196
|
+
|
|
197
|
+
Non-modal content anchored to a consumer trigger, with cancelable close requests and no imposed panel semantics.
|
|
198
|
+
|
|
199
|
+
| Prop | Type | Default | Description |
|
|
200
|
+
| --- | --- | --- | --- |
|
|
201
|
+
| `open` | boolean | `false` | Committed visibility. Supplying this prop, including false, controls state; its metadata default does not establish a binding. |
|
|
202
|
+
| `defaultOpen` | boolean | `false` | Initial autonomous visibility only; ignored when open is supplied. Later updates do not reset state. |
|
|
203
|
+
| `triggerMode` | 'press' \| 'hover' | `press` | Hover adds pointer and keyboard-focus opening on web and React Native Web, while keeping press activation. Android/iOS use press. Does not change panel semantics. |
|
|
204
|
+
| `closable` | boolean | `false` | Shows a built-in IconButton with an X. Requests a cancelable close with reason close-button. |
|
|
205
|
+
| `closeLabel` | string | `Close` | Localized accessible name of the close button. Must be non-empty when closable is true. |
|
|
206
|
+
| `arrow` | boolean | `false` | Shows a decorative triangular pointer (16 wide, 8 deep), following the actual side, panel background and border. Hidden if it cannot point to the trigger without crossing a corner or viewport edge. |
|
|
207
|
+
| `closeOnEscape` | boolean | `true` | Requests closure on unhandled Escape on web and React Native Web. Native Android and iOS hardware Escape is not supported. |
|
|
208
|
+
| `closeOnOutsidePress` | boolean | `true` | Requests closure on an outside press without preventing its interaction or restoring trigger focus. |
|
|
209
|
+
| `side` | 'top' \| 'right' \| 'bottom' \| 'left' | `bottom` | Requested physical side; actual placement flips to the opposite side when that reduces viewport/safe-area overflow, then shifts within bounds. |
|
|
210
|
+
| `align` | 'start' \| 'center' \| 'end' | `center` | Cross-axis alignment. On top/bottom, start/end follow inline direction (RTL reverses them); on left/right they mean top/bottom. |
|
|
211
|
+
|
|
212
|
+
Events: `onOpenChange` → `PopoverOpenChangeDetail`.
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import { Popover, PopoverProvider, IconButton, Icon } from '@joralvmel/cosmos-native';
|
|
216
|
+
import { info } from '@joralvmel/cosmos-icons/info';
|
|
217
|
+
import { Text } from 'react-native';
|
|
218
|
+
|
|
219
|
+
export function Example() {
|
|
220
|
+
return (
|
|
221
|
+
<PopoverProvider>
|
|
222
|
+
<Popover
|
|
223
|
+
trigger={props => <IconButton {...props} label="Details" variant="ghost" tone="neutral"><Icon icon={info} /></IconButton>}
|
|
224
|
+
onOpenChange={detail => console.log(detail)}
|
|
225
|
+
>
|
|
226
|
+
<Text>Popover</Text>
|
|
227
|
+
</Popover>
|
|
228
|
+
</PopoverProvider>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
### `Listbox`
|
|
233
|
+
|
|
234
|
+
Selects one or more values from a named vertical collection, with groups, descriptions, icons and independent keyboard focus.
|
|
235
|
+
|
|
236
|
+
| Prop | Type | Default | Description |
|
|
237
|
+
| --- | --- | --- | --- |
|
|
238
|
+
| `label` | string | Required | Required nonempty accessible label, visible unless labelHidden is true. |
|
|
239
|
+
| `labelHidden` | boolean | `false` | Visually hides the label without removing its accessible name. |
|
|
240
|
+
| `items` | ListboxItems | Required | Readonly collection of options or named groups. Options have globally unique nonempty value and label strings, optional description, decorative IconDefinition and disabled. Groups have a nonempty label and options array. |
|
|
241
|
+
| `selectionMode` | 'single' \| 'multiple' | `single` | Single permits at most one selected value; multiple toggles each activation. |
|
|
242
|
+
| `selectedValues` | ListboxValues | — | Controlled selected values, including an empty array. Activation only proposes changes until the owner updates this prop. Missing collection values are retained, not automatically selected or removed. |
|
|
243
|
+
| `defaultSelectedValues` | ListboxValues | — | Initial autonomous selected values (empty by default). Later changes do not reset selection. |
|
|
244
|
+
| `variant` | 'plain' \| 'outlined' | `plain` | Plain composes inside a panel; outlined adds a standalone container boundary. |
|
|
245
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large option rows. Content may grow; native touch targets remain at least 44. |
|
|
246
|
+
| `disabled` | boolean | `false` | Prevents interaction and removes the list from keyboard navigation. |
|
|
247
|
+
| `readOnly` | boolean | `false` | Allows exploring options without proposing or committing selection changes. |
|
|
248
|
+
| `locale` | string | — | BCP 47 locale for typeahead. Web inherits the nearest language; native uses the runtime locale when omitted. Invalid locale identifiers are rejected. |
|
|
249
|
+
|
|
250
|
+
Events: `onSelectionChange` → `ListboxSelectionChangeDetail`.
|
|
251
|
+
|
|
252
|
+
```tsx
|
|
253
|
+
import { Listbox } from '@joralvmel/cosmos-native';
|
|
254
|
+
const grouped = [{"label":"Fruit","options":[{"value":"apple","label":"Apple"},{"value":"cherry","label":"Cherry","description":"Seasonal"}]},{"label":"Vegetables","options":[{"value":"carrot","label":"Carrot"},{"value":"broccoli","label":"Broccoli","disabled":true}]}] as const;
|
|
255
|
+
const empty = [] as const;
|
|
256
|
+
|
|
257
|
+
export function Example() {
|
|
258
|
+
return (
|
|
259
|
+
<Listbox
|
|
260
|
+
label="Listbox"
|
|
261
|
+
items={grouped}
|
|
262
|
+
defaultSelectedValues={empty}
|
|
263
|
+
onSelectionChange={detail => console.log(detail)}
|
|
264
|
+
>
|
|
265
|
+
</Listbox>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
### `Checkbox`
|
|
270
|
+
|
|
271
|
+
Selects an independent boolean value with accessible labeling and native form behavior on the web.
|
|
272
|
+
|
|
273
|
+
| Prop | Type | Default | Description |
|
|
274
|
+
| --- | --- | --- | --- |
|
|
275
|
+
| `label` | string | Required | Required accessible name, visible unless labelHidden is true. |
|
|
276
|
+
| `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |
|
|
277
|
+
| `checked` | boolean | `false` | Controlled checked value when supplied, including false; activation proposes changes without self-committing. |
|
|
278
|
+
| `defaultChecked` | boolean | `false` | Initial autonomous checked value; later changes do not reset it. |
|
|
279
|
+
| `indeterminate` | boolean | `false` | Presentation-only mixed state. Autonomous activation clears it; controlled use leaves it to the owner. |
|
|
280
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large visual box. |
|
|
281
|
+
| `disabled` | boolean | `false` | Prevents user interaction and excludes the value from web form submission. |
|
|
282
|
+
| `required` | boolean | `false` | Exposes required semantics and participates in native web form validation. Native has no automatic validation. |
|
|
283
|
+
| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere; web form validity remains based on required. |
|
|
284
|
+
| `helperText` | string | — | Optional consumer-localized supporting text associated with the checkbox. |
|
|
285
|
+
| `errorText` | string | — | Optional consumer-localized error description; a nonempty trimmed value also exposes invalid state. |
|
|
286
|
+
|
|
287
|
+
Events: `onCheckedChange` → `CheckboxCheckedChangeDetail`.
|
|
288
|
+
|
|
289
|
+
```tsx
|
|
290
|
+
import { Checkbox } from '@joralvmel/cosmos-native';
|
|
291
|
+
|
|
292
|
+
export function Example() {
|
|
293
|
+
return (
|
|
294
|
+
<Checkbox
|
|
295
|
+
label="Checkbox"
|
|
296
|
+
onCheckedChange={detail => console.log(detail)}
|
|
297
|
+
>
|
|
298
|
+
Checkbox
|
|
299
|
+
</Checkbox>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
### `Switch`
|
|
304
|
+
|
|
305
|
+
Toggles a binary setting immediately with a stable accessible name and form behavior on the web.
|
|
306
|
+
|
|
307
|
+
| Prop | Type | Default | Description |
|
|
308
|
+
| --- | --- | --- | --- |
|
|
309
|
+
| `label` | string | Required | Required nonempty accessible name; remains stable in both states. |
|
|
310
|
+
| `labelHidden` | boolean | `false` | Visually hides the label while retaining its accessible name. |
|
|
311
|
+
| `checked` | boolean | `false` | Controlled checked value when supplied, including false; activation proposes changes without self-committing. |
|
|
312
|
+
| `defaultChecked` | boolean | `false` | Initial autonomous checked value; later changes do not reset it. |
|
|
313
|
+
| `disabled` | boolean | `false` | Prevents user interaction and excludes the value from web form submission. |
|
|
314
|
+
| `invalid` | boolean | `false` | Externally supplied invalid presentation. Does not change checked state or form validity; native uses danger colors without an equivalent system invalid trait. |
|
|
315
|
+
| `helperText` | string | — | Optional consumer-localized supporting text associated with the switch. |
|
|
316
|
+
|
|
317
|
+
Events: `onCheckedChange` → `SwitchCheckedChangeDetail`.
|
|
318
|
+
|
|
319
|
+
```tsx
|
|
320
|
+
import { Switch } from '@joralvmel/cosmos-native';
|
|
321
|
+
|
|
322
|
+
export function Example() {
|
|
323
|
+
return (
|
|
324
|
+
<Switch
|
|
325
|
+
label="Switch"
|
|
326
|
+
onCheckedChange={detail => console.log(detail)}
|
|
327
|
+
>
|
|
328
|
+
</Switch>
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
### `Badge`
|
|
333
|
+
|
|
334
|
+
Displays a noninteractive status or category label, or caller-formatted count, with an optional decorative leading icon.
|
|
335
|
+
|
|
336
|
+
| Prop | Type | Default | Description |
|
|
337
|
+
| --- | --- | --- | --- |
|
|
338
|
+
| `variant` | 'soft' \| 'solid' \| 'outline' | `soft` | Visual treatment of the static label. |
|
|
339
|
+
| `tone` | 'neutral' \| 'info' \| 'success' \| 'warning' \| 'danger' | `neutral` | Semantic color intent of the static label. |
|
|
340
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Semantic label size. |
|
|
341
|
+
| `startIcon` | IconDefinition | — | Optional structured decorative icon before the label. |
|
|
342
|
+
|
|
343
|
+
Events: none.
|
|
344
|
+
|
|
345
|
+
```tsx
|
|
346
|
+
import { Badge } from '@joralvmel/cosmos-native';
|
|
347
|
+
import { heart } from '@joralvmel/cosmos-icons/heart';
|
|
348
|
+
|
|
349
|
+
export function Example() {
|
|
350
|
+
return (
|
|
351
|
+
<Badge startIcon={heart}>Badge</Badge>
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
### `Calendar`
|
|
356
|
+
|
|
357
|
+
Selects one Gregorian date from an inline, localized calendar with keyboard navigation and optional bounds. Month and year can be selected directly.
|
|
358
|
+
|
|
359
|
+
| Prop | Type | Default | Description |
|
|
360
|
+
| --- | --- | --- | --- |
|
|
361
|
+
| `value` | string | — | Controlled selected date in YYYY-MM-DD format; when supplied, selection proposals wait for the owner to update this value. |
|
|
362
|
+
| `defaultValue` | string | — | Initial autonomous selected date in YYYY-MM-DD format; later changes do not reset selection. |
|
|
363
|
+
| `min` | string | — | Earliest selectable date in YYYY-MM-DD format, inclusive. |
|
|
364
|
+
| `max` | string | — | Latest selectable date in YYYY-MM-DD format, inclusive. |
|
|
365
|
+
| `locale` | string | — | BCP 47 locale for month and weekday names, week start, and text direction; defaults to the environment locale. Invalid locale identifiers are rejected. |
|
|
366
|
+
| `disabled` | boolean | `false` | Disables date selection and calendar navigation. |
|
|
367
|
+
|
|
368
|
+
Events: `onValueChange` → `CalendarChangeDetail`.
|
|
369
|
+
|
|
370
|
+
```tsx
|
|
371
|
+
import { Calendar } from '@joralvmel/cosmos-native';
|
|
372
|
+
|
|
373
|
+
export function Example() {
|
|
374
|
+
return (
|
|
375
|
+
<Calendar onValueChange={detail => console.log(detail)}></Calendar>
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
### `Textarea`
|
|
380
|
+
|
|
381
|
+
Accepts multiline plain text with an accessible label, optional helper and error text, and native form behavior on the web.
|
|
382
|
+
|
|
383
|
+
| Prop | Type | Default | Description |
|
|
384
|
+
| --- | --- | --- | --- |
|
|
385
|
+
| `label` | string | Required | Accessible name for the editable control. It is rendered above the control unless visually hidden. |
|
|
386
|
+
| `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |
|
|
387
|
+
| `value` | string | — | Current text. When bound, edits are proposals and the component waits for the owner to supply the accepted value. |
|
|
388
|
+
| `defaultValue` | string | `` | Initial value for autonomous use. Web form reset restores this value; it does not control subsequent edits. |
|
|
389
|
+
| `rows` | number | `4` | Visible line count of the multiline editor. It is independent of the visual size. |
|
|
390
|
+
| `variant` | 'outlined' \| 'filled' | `outlined` | Visual treatment of the editable control. |
|
|
391
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Visual size of the editable control, independent of rows. |
|
|
392
|
+
| `placeholder` | string | — | Short input hint; it never replaces the accessible label. |
|
|
393
|
+
| `helperText` | string | — | Optional supporting text associated with the editable control. |
|
|
394
|
+
| `errorText` | string | — | Optional consumer-localized error text associated with the editable control; a nonempty trimmed value also exposes invalid state. |
|
|
395
|
+
| `invalid` | boolean | `false` | External invalid state when the visible error is supplied elsewhere, independent of browser constraints or consumer business validation. |
|
|
396
|
+
| `required` | boolean | `false` | Exposes required semantics. On web, participates in native HTML constraint validation. |
|
|
397
|
+
| `disabled` | boolean | `false` | Disables editing and interaction. On web, follows disabled fieldsets and excludes the value from form submission. |
|
|
398
|
+
| `readOnly` | boolean | `false` | Prevents editing while remaining focusable and form-submittable on web; distinct from disabled. |
|
|
399
|
+
| `maxLength` | number | — | Maximum number of characters. Web uses native HTML length constraints and native applies supported input limits. |
|
|
400
|
+
|
|
401
|
+
Events: `onValueChange` → `TextareaChangeDetail`.
|
|
402
|
+
|
|
403
|
+
```tsx
|
|
404
|
+
import { Textarea } from '@joralvmel/cosmos-native';
|
|
405
|
+
|
|
406
|
+
export function Example() {
|
|
407
|
+
return (
|
|
408
|
+
<Textarea
|
|
409
|
+
label="Textarea"
|
|
410
|
+
onValueChange={detail => console.log(detail)}
|
|
411
|
+
>
|
|
412
|
+
</Textarea>
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
### `RadioGroup`
|
|
417
|
+
|
|
418
|
+
Selects one option from a labeled collection, with optional selection and native Web form behavior.
|
|
419
|
+
|
|
420
|
+
| Prop | Type | Default | Description |
|
|
421
|
+
| --- | --- | --- | --- |
|
|
422
|
+
| `label` | string | Required | Required visible accessible name for the group. |
|
|
423
|
+
| `options` | RadioGroupOptions | Required | Readonly flat options with unique nonempty values and labels, optional descriptions and disabled states. |
|
|
424
|
+
| `value` | RadioGroupValue | — | Controlled selected value; null means no selection, and a supplied null remains controlled. |
|
|
425
|
+
| `defaultValue` | RadioGroupValue | — | Initial autonomous selection; null by default. |
|
|
426
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large radio indicator. |
|
|
427
|
+
| `orientation` | 'vertical' \| 'horizontal' | `vertical` | Vertical list or wrapping horizontal options. |
|
|
428
|
+
| `disabled` | boolean | `false` | Prevents interaction and excludes the value from Web form submission. |
|
|
429
|
+
| `required` | boolean | `false` | Requires a selection in Web form validation; Native exposes descriptive semantics. |
|
|
430
|
+
| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere. |
|
|
431
|
+
| `helperText` | string | — | Optional supporting text associated with the group. |
|
|
432
|
+
| `errorText` | string | — | Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state. |
|
|
433
|
+
|
|
434
|
+
Events: `onValueChange` → `RadioGroupChangeDetail`.
|
|
435
|
+
|
|
436
|
+
```tsx
|
|
437
|
+
import { RadioGroup } from '@joralvmel/cosmos-native';
|
|
438
|
+
const contactMethods = [{"value":"email","label":"Email","description":"Receive updates by email."},{"value":"phone","label":"Phone","description":"Receive updates by text."},{"value":"mail","label":"Mail","disabled":true}] as const;
|
|
439
|
+
|
|
440
|
+
export function Example() {
|
|
441
|
+
return (
|
|
442
|
+
<RadioGroup
|
|
443
|
+
label="RadioGroup"
|
|
444
|
+
options={contactMethods}
|
|
445
|
+
onValueChange={detail => console.log(detail)}
|
|
446
|
+
>
|
|
447
|
+
</RadioGroup>
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
```
|
|
451
|
+
### `Select`
|
|
452
|
+
|
|
453
|
+
Selects one option from an accessible collection, with native Web form behavior.
|
|
454
|
+
|
|
455
|
+
| Prop | Type | Default | Description |
|
|
456
|
+
| --- | --- | --- | --- |
|
|
457
|
+
| `label` | string | Required | Required visible accessible name for the control. |
|
|
458
|
+
| `items` | SelectItems | Required | Readonly flat options with unique nonempty values, nonempty labels, and optional disabled state. |
|
|
459
|
+
| `value` | SelectValue | — | Controlled selected value; null means no selection, and a supplied null remains controlled. |
|
|
460
|
+
| `defaultValue` | SelectValue | — | Initial autonomous selection; null by default. |
|
|
461
|
+
| `placeholder` | string | Required | Consumer-localized text shown when no value is selected. |
|
|
462
|
+
| `variant` | 'outlined' \| 'filled' | `outlined` | Outlined or filled trigger appearance. |
|
|
463
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium, or large control size. |
|
|
464
|
+
| `disabled` | boolean | `false` | Prevents interaction and excludes the value from Web form submission. |
|
|
465
|
+
| `required` | boolean | `false` | Requires a selection in Web form validation; Native exposes descriptive semantics. |
|
|
466
|
+
| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere. |
|
|
467
|
+
| `helperText` | string | — | Optional supporting text associated with the control. |
|
|
468
|
+
| `errorText` | string | — | Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state. |
|
|
469
|
+
|
|
470
|
+
Events: `onValueChange` → `SelectChangeDetail`.
|
|
471
|
+
|
|
472
|
+
```tsx
|
|
473
|
+
import { Select } from '@joralvmel/cosmos-native';
|
|
474
|
+
const flat = [{"value":"apple","label":"Apple"},{"value":"cherry","label":"Cherry"},{"value":"lime","label":"Lime","disabled":true}] as const;
|
|
475
|
+
const none = null as const;
|
|
476
|
+
|
|
477
|
+
export function Example() {
|
|
478
|
+
return (
|
|
479
|
+
<Select
|
|
480
|
+
label="Select"
|
|
481
|
+
items={flat}
|
|
482
|
+
defaultValue={none}
|
|
483
|
+
placeholder="Select"
|
|
484
|
+
onValueChange={detail => console.log(detail)}
|
|
485
|
+
>
|
|
486
|
+
</Select>
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
```
|
|
490
|
+
### `Pagination`
|
|
491
|
+
|
|
492
|
+
Navigates a known number of pages using buttons.
|
|
493
|
+
|
|
494
|
+
| Prop | Type | Default | Description |
|
|
495
|
+
| --- | --- | --- | --- |
|
|
496
|
+
| `totalPages` | number | Required | Required nonnegative safe integer page count. |
|
|
497
|
+
| `page` | number | — | Controlled one-based safe integer page; out-of-range values are displayed clamped. |
|
|
498
|
+
| `defaultPage` | number | `1` | Initial one-based page for autonomous state. |
|
|
499
|
+
| `label` | string | Required | Required localized navigation landmark label. |
|
|
500
|
+
| `previousLabel` | string | `Previous page` | Previous button label. |
|
|
501
|
+
| `nextLabel` | string | `Next page` | Next button label. |
|
|
502
|
+
| `firstLabel` | string | `First page` | First button label. |
|
|
503
|
+
| `lastLabel` | string | `Last page` | Last button label. |
|
|
504
|
+
| `pageLabel` | string | `Page {page}` | Page button label template; {page} is replaced with the localized number. |
|
|
505
|
+
| `summaryLabel` | string | `Page {page} of {total}` | Compact summary template with {page} and {total} placeholders. |
|
|
506
|
+
| `locale` | string | — | Locale for formatted page numbers. |
|
|
507
|
+
| `direction` | 'ltr' \| 'rtl' | `ltr` | Layout and directional icon direction. |
|
|
508
|
+
| `presentation` | 'numbered' \| 'compact' | `numbered` | Show up to seven fixed-width numbered positions or a compact summary. |
|
|
509
|
+
| `variant` | 'solid' \| 'soft' \| 'outline' | `solid` | Selected page emphasis. |
|
|
510
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Control size. |
|
|
511
|
+
| `showFirstLast` | boolean | `false` | Show first and last page controls. |
|
|
512
|
+
| `disabled` | boolean | `false` | Disable all controls. |
|
|
513
|
+
|
|
514
|
+
Events: `onPageChange` → `PaginationChangeDetail`.
|
|
515
|
+
|
|
516
|
+
```tsx
|
|
517
|
+
import { Pagination } from '@joralvmel/cosmos-native';
|
|
518
|
+
|
|
519
|
+
export function Example() {
|
|
520
|
+
return (
|
|
521
|
+
<Pagination
|
|
522
|
+
label="Pagination"
|
|
523
|
+
onPageChange={detail => console.log(detail)}
|
|
524
|
+
>
|
|
525
|
+
</Pagination>
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
### `Dialog`
|
|
530
|
+
|
|
531
|
+
Modal content with a title, actions and cancelable close requests.
|
|
532
|
+
|
|
533
|
+
| Prop | Type | Default | Description |
|
|
534
|
+
| --- | --- | --- | --- |
|
|
535
|
+
| `open` | boolean | `false` | Committed visibility; supplying this prop, including false, controls state. |
|
|
536
|
+
| `defaultOpen` | boolean | `false` | Initial autonomous visibility; subsequent changes do not reset state. |
|
|
537
|
+
| `presentation` | 'standard' \| 'fullscreen' | `standard` | Centered standard surface or fullscreen surface. |
|
|
538
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Maximum standard width: sm 400, md 640, lg 960 pixels or logical points. |
|
|
539
|
+
| `responsiveFullscreen` | boolean | `false` | Use fullscreen when available viewport width is below 640 pixels or logical points. |
|
|
540
|
+
| `closeLabel` | string | `Close` | Non-empty localized accessible name of the built-in close button. |
|
|
541
|
+
| `closeOnAndroidBack` | boolean | `true` | Request closure on Android Back; consume Back even if the request is canceled. |
|
|
542
|
+
| `closeOnBackdropPress` | boolean | `false` | Request closure when the backdrop itself is pressed. |
|
|
543
|
+
| `initialFocusTarget` | DialogFocusTarget | — | Optional platform focus target used on committed opening; it must be inside the dialog. |
|
|
544
|
+
| `returnFocusTarget` | DialogFocusTarget | — | Optional platform focus target used after committed closure. |
|
|
545
|
+
|
|
546
|
+
Events: `onOpenChange` → `DialogOpenChangeDetail`.
|
|
547
|
+
|
|
548
|
+
```tsx
|
|
549
|
+
import { type ComponentRef, useRef } from 'react';
|
|
550
|
+
import { Button, Dialog, type DialogHandle } from '@joralvmel/cosmos-native';
|
|
551
|
+
import { type Pressable, Text } from 'react-native';
|
|
552
|
+
|
|
553
|
+
export function Example() {
|
|
554
|
+
const dialog = useRef<DialogHandle>(null);
|
|
555
|
+
const opener = useRef<ComponentRef<typeof Pressable>>(null);
|
|
556
|
+
return (
|
|
557
|
+
<>
|
|
558
|
+
<Button ref={opener} onPress={() => dialog.current?.requestOpen()}>Open dialog</Button>
|
|
559
|
+
<Dialog
|
|
560
|
+
ref={dialog}
|
|
561
|
+
title="Review details"
|
|
562
|
+
returnFocusTarget={opener}
|
|
563
|
+
onOpenChange={detail => {
|
|
564
|
+
console.log(detail);
|
|
565
|
+
}}
|
|
566
|
+
actions={<Button onPress={() => dialog.current?.requestClose()}>Done</Button>}
|
|
567
|
+
>
|
|
568
|
+
<Text>Dialog</Text>
|
|
569
|
+
</Dialog>
|
|
570
|
+
</>
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
```
|
|
98
574
|
|
|
99
575
|
## Themes
|
|
100
576
|
|
|
101
|
-
Built-in themes: `cosmos`, `nebula` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
|
|
577
|
+
Built-in themes: `cosmos`, `nebula`, `terra`, `supernova`, `aurora`, `solstice` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
|
|
102
578
|
|
|
103
579
|
```tsx
|
|
104
580
|
<CosmosThemeProvider theme="nebula" mode="system">{children}</CosmosThemeProvider>
|