@joralvmel/cosmos-angular 0.2.0 → 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/README.md +38 -0
- package/dist/components/badge.component.d.ts +20 -0
- package/dist/components/badge.component.js +46 -0
- package/dist/components/badge.component.js.map +1 -0
- package/dist/components/button.component.js +3 -3
- package/dist/components/calendar.component.d.ts +28 -0
- package/dist/components/calendar.component.js +65 -0
- package/dist/components/calendar.component.js.map +1 -0
- package/dist/components/checkbox.component.d.ts +52 -0
- package/dist/components/checkbox.component.js +152 -0
- package/dist/components/checkbox.component.js.map +1 -0
- package/dist/components/dialog.component.d.ts +44 -0
- package/dist/components/dialog.component.js +106 -0
- package/dist/components/dialog.component.js.map +1 -0
- package/dist/components/icon-button.component.d.ts +26 -0
- package/dist/components/icon-button.component.js +83 -0
- package/dist/components/icon-button.component.js.map +1 -0
- package/dist/components/icon.component.d.ts +6 -8
- package/dist/components/icon.component.js +12 -22
- package/dist/components/icon.component.js.map +1 -1
- package/dist/components/listbox.component.d.ts +41 -0
- package/dist/components/listbox.component.js +100 -0
- package/dist/components/listbox.component.js.map +1 -0
- package/dist/components/pagination.component.d.ts +36 -0
- package/dist/components/pagination.component.js +129 -0
- package/dist/components/pagination.component.js.map +1 -0
- package/dist/components/popover.component.d.ts +43 -0
- package/dist/components/popover.component.js +101 -0
- package/dist/components/popover.component.js.map +1 -0
- package/dist/components/radio-group.component.d.ts +49 -0
- package/dist/components/radio-group.component.js +146 -0
- package/dist/components/radio-group.component.js.map +1 -0
- package/dist/components/select.component.d.ts +49 -0
- package/dist/components/select.component.js +147 -0
- package/dist/components/select.component.js.map +1 -0
- package/dist/components/switch.component.d.ts +47 -0
- package/dist/components/switch.component.js +135 -0
- package/dist/components/switch.component.js.map +1 -0
- package/dist/components/text-field.component.d.ts +73 -0
- package/dist/components/text-field.component.js +239 -0
- package/dist/components/text-field.component.js.map +1 -0
- package/dist/components/textarea.component.d.ts +54 -0
- package/dist/components/textarea.component.js +168 -0
- package/dist/components/textarea.component.js.map +1 -0
- package/dist/index.d.ts +28 -2
- package/dist/index.js +43 -1
- package/dist/index.js.map +1 -1
- package/llms.md +520 -7
- package/package.json +10 -10
package/llms.md
CHANGED
|
@@ -82,17 +82,15 @@ export class ExampleComponent {
|
|
|
82
82
|
```
|
|
83
83
|
### `CosmIconComponent` (`<cosm-icon>`)
|
|
84
84
|
|
|
85
|
-
Renders a structured SVG icon.
|
|
85
|
+
Renders a structured SVG icon. Icons are decorative and hidden from assistive technology unless a nonempty label makes them informative.
|
|
86
86
|
|
|
87
87
|
| Prop | Type | Default | Description |
|
|
88
88
|
| --- | --- | --- | --- |
|
|
89
89
|
| `icon` | IconDefinition | Required | Structured icon definition, commonly imported from @joralvmel/cosmos-icons. |
|
|
90
90
|
| `size` | 'sm' \| 'md' \| 'lg' \| number | `md` | Semantic size (16, 20 or 24) or a positive finite number in pixels / native units. |
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `label` | string | — | Accessible name required when decorative is false. |
|
|
95
|
-
| `decorative` | boolean | `true` | Hides the icon from assistive technology when true. |
|
|
91
|
+
| `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. |
|
|
92
|
+
| `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. |
|
|
93
|
+
| `label` | string | — | Accessible name. A nonempty label makes the icon an informative image; without one the icon is decorative and hidden from assistive technology. |
|
|
96
94
|
|
|
97
95
|
Events: none.
|
|
98
96
|
|
|
@@ -110,10 +108,525 @@ export class ExampleComponent {
|
|
|
110
108
|
readonly house = house;
|
|
111
109
|
}
|
|
112
110
|
```
|
|
111
|
+
### `CosmTextFieldComponent` (`<cosm-text-field>`)
|
|
112
|
+
|
|
113
|
+
Accepts a single line of text with an accessible label, optional helper and error text, and native form validation on the web.
|
|
114
|
+
|
|
115
|
+
| Prop | Type | Default | Description |
|
|
116
|
+
| --- | --- | --- | --- |
|
|
117
|
+
| `label` | string | Required | Accessible name for the editable control. It is rendered above the control unless visually hidden. |
|
|
118
|
+
| `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |
|
|
119
|
+
| `value` | string | — | Current text. When bound, edits are proposals and the component waits for the owner to supply the accepted value. |
|
|
120
|
+
| `defaultValue` | string | `` | Initial value for autonomous use. Web form reset restores this value; it does not control subsequent edits. |
|
|
121
|
+
| `type` | 'text' \| 'email' \| 'password' \| 'tel' \| 'url' \| 'search' | `text` | Single-line input type. Native maps it to supported keyboard, autofill and secure-entry behavior. |
|
|
122
|
+
| `variant` | 'outlined' \| 'filled' | `outlined` | Visual treatment of the editable control. |
|
|
123
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large editable control. |
|
|
124
|
+
| `placeholder` | string | — | Short input hint; it never replaces the accessible label. |
|
|
125
|
+
| `helperText` | string | — | Optional supporting text associated with the editable control. |
|
|
126
|
+
| `errorText` | string | — | Optional consumer-localized error text associated with the editable control; a nonempty trimmed value also exposes invalid state. |
|
|
127
|
+
| `invalid` | boolean | `false` | External invalid state when the visible error is supplied elsewhere, independent of browser constraints or consumer business validation. |
|
|
128
|
+
| `required` | boolean | `false` | Exposes required semantics. On web, participates in native HTML constraint validation. |
|
|
129
|
+
| `disabled` | boolean | `false` | Disables editing and interaction. On web, follows disabled fieldsets and excludes the value from form submission. |
|
|
130
|
+
| `readOnly` | boolean | `false` | Prevents editing while remaining focusable and form-submittable on web; distinct from disabled. |
|
|
131
|
+
| `minLength` | number | — | Minimum number of characters. Web uses native HTML validity; native business validation remains the consumer’s responsibility. |
|
|
132
|
+
| `maxLength` | number | — | Maximum number of characters. Web uses native HTML validity and native applies supported input limits. |
|
|
133
|
+
| `pattern` | string | — | Web-only HTML pattern constraint. Native does not emulate HTML regular-expression validation. |
|
|
134
|
+
| `name` | string | — | Form field name on web. React Native has no HTML form association or name-based submission. |
|
|
135
|
+
| `autoComplete` | string | — | Consumer-provided completion/autofill hint, mapped to attributes supported by each platform. |
|
|
136
|
+
| `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. |
|
|
137
|
+
| `startIcon` | IconDefinition | — | Optional structured decorative icon before the editable text. |
|
|
138
|
+
| `endIcon` | IconDefinition | — | Optional structured decorative icon after the editable text. |
|
|
139
|
+
| `prefix` | string | — | Optional non-interactive text decoration before the editable text. |
|
|
140
|
+
| `suffix` | string | — | Optional non-interactive text decoration after the editable text. |
|
|
141
|
+
| `clearable` | boolean | `false` | Shows a clear action for non-empty editable fields. Supply clearLabel when enabled. |
|
|
142
|
+
| `clearLabel` | string | — | Consumer-supplied localized accessible name for the clear action. |
|
|
143
|
+
| `passwordReveal` | boolean | `false` | Opts into a reveal action for password fields. Supply both revealPasswordLabel and hidePasswordLabel when enabled. |
|
|
144
|
+
| `revealPasswordLabel` | string | — | Consumer-supplied localized accessible name while the password is concealed. |
|
|
145
|
+
| `hidePasswordLabel` | string | — | Consumer-supplied localized accessible name while the password is revealed. |
|
|
146
|
+
|
|
147
|
+
Events: `(valueChange)` → `TextFieldChangeDetail`, `(submit)` → `TextFieldSubmitDetail`.
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
import { Component } from '@angular/core';
|
|
151
|
+
import { CosmTextFieldComponent } from '@joralvmel/cosmos-angular';
|
|
152
|
+
import { search } from '@joralvmel/cosmos-icons/search';
|
|
153
|
+
import type { TextFieldChangeDetail, TextFieldSubmitDetail } from '@joralvmel/cosmos-core';
|
|
154
|
+
|
|
155
|
+
@Component({
|
|
156
|
+
selector: 'app-example',
|
|
157
|
+
imports: [CosmTextFieldComponent],
|
|
158
|
+
template: `<cosm-text-field label="TextField" [startIcon]="search" [endIcon]="search" (valueChange)="onValueChange($event.detail)" (submit)="onSubmit($event.detail)"></cosm-text-field>`,
|
|
159
|
+
})
|
|
160
|
+
export class ExampleComponent {
|
|
161
|
+
readonly search = search;
|
|
162
|
+
onValueChange(detail: TextFieldChangeDetail) {
|
|
163
|
+
console.log(detail);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
onSubmit(detail: TextFieldSubmitDetail) {
|
|
167
|
+
console.log(detail);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
### `CosmIconButtonComponent` (`<cosm-icon-button>`)
|
|
172
|
+
|
|
173
|
+
Activates an action or toggles a boolean state using a labeled icon.
|
|
174
|
+
|
|
175
|
+
| Prop | Type | Default | Description |
|
|
176
|
+
| --- | --- | --- | --- |
|
|
177
|
+
| `label` | string | Required | Required localized accessible name. Missing, empty or whitespace-only labels are rejected. |
|
|
178
|
+
| `mode` | 'action' \| 'toggle' | `action` | Action activates without toggle state; toggle exposes and changes pressed state. |
|
|
179
|
+
| `variant` | 'solid' \| 'soft' \| 'outline' \| 'ghost' | `solid` | Visual emphasis, from highest (solid) to lowest (ghost). |
|
|
180
|
+
| `tone` | 'primary' \| 'neutral' \| 'danger' | `primary` | Color role. Use danger for destructive actions. |
|
|
181
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Size of the square visual control. |
|
|
182
|
+
| `disabled` | boolean | `false` | Prevents activation and removes the web button from the tab order. |
|
|
183
|
+
| `type` | 'button' \| 'submit' \| 'reset' | `button` | Native web button form behavior. |
|
|
184
|
+
| `pressed` | boolean | `false` | Toggle state. If supplied, including false, activation proposes changes without committing them until the owner updates this prop. |
|
|
185
|
+
| `defaultPressed` | boolean | `false` | Initial toggle state when pressed is not supplied; it does not control later changes. |
|
|
186
|
+
|
|
187
|
+
Events: `(press)` → `IconButtonPressDetail`, `(pressedChange)` → `IconButtonPressedChangeDetail`.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
import { heart } from '@joralvmel/cosmos-icons/heart';
|
|
191
|
+
import { Component } from '@angular/core';
|
|
192
|
+
import { CosmIconButtonComponent, CosmIconComponent } from '@joralvmel/cosmos-angular';
|
|
193
|
+
import type { IconButtonPressDetail, IconButtonPressedChangeDetail } from '@joralvmel/cosmos-core';
|
|
194
|
+
|
|
195
|
+
@Component({
|
|
196
|
+
selector: 'app-example',
|
|
197
|
+
imports: [CosmIconButtonComponent, CosmIconComponent],
|
|
198
|
+
template: `<cosm-icon-button label="IconButton" (press)="onPress($event.detail)" (pressedChange)="onPressedChange($event.detail)"><cosm-icon [icon]="heart"></cosm-icon></cosm-icon-button>`,
|
|
199
|
+
})
|
|
200
|
+
export class ExampleComponent {
|
|
201
|
+
readonly heart = heart;
|
|
202
|
+
onPress(detail: IconButtonPressDetail) {
|
|
203
|
+
console.log(detail);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
onPressedChange(detail: IconButtonPressedChangeDetail) {
|
|
207
|
+
console.log(detail);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
### `CosmPopoverComponent` (`<cosm-popover>`)
|
|
212
|
+
|
|
213
|
+
Non-modal content anchored to a consumer trigger, with cancelable close requests and no imposed panel semantics.
|
|
214
|
+
|
|
215
|
+
| Prop | Type | Default | Description |
|
|
216
|
+
| --- | --- | --- | --- |
|
|
217
|
+
| `open` | boolean | `false` | Committed visibility. Supplying this prop, including false, controls state; its metadata default does not establish a binding. |
|
|
218
|
+
| `defaultOpen` | boolean | `false` | Initial autonomous visibility only; ignored when open is supplied. Later updates do not reset state. |
|
|
219
|
+
| `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. |
|
|
220
|
+
| `closable` | boolean | `false` | Shows a built-in IconButton with an X. Requests a cancelable close with reason close-button. |
|
|
221
|
+
| `closeLabel` | string | `Close` | Localized accessible name of the close button. Must be non-empty when closable is true. |
|
|
222
|
+
| `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. |
|
|
223
|
+
| `closeOnEscape` | boolean | `true` | Requests closure on unhandled Escape on web and React Native Web. Native Android and iOS hardware Escape is not supported. |
|
|
224
|
+
| `closeOnOutsidePress` | boolean | `true` | Requests closure on an outside press without preventing its interaction or restoring trigger focus. |
|
|
225
|
+
| `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. |
|
|
226
|
+
| `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. |
|
|
227
|
+
|
|
228
|
+
Events: `(openChange)` → `PopoverOpenChangeDetail`.
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
import { Component } from '@angular/core';
|
|
232
|
+
import { CosmPopoverComponent, CosmIconButtonComponent, CosmIconComponent } from '@joralvmel/cosmos-angular';
|
|
233
|
+
import { info } from '@joralvmel/cosmos-icons/info';
|
|
234
|
+
import type { PopoverOpenChangeDetail } from '@joralvmel/cosmos-core';
|
|
235
|
+
|
|
236
|
+
@Component({
|
|
237
|
+
selector: 'app-example',
|
|
238
|
+
imports: [CosmPopoverComponent, CosmIconButtonComponent, CosmIconComponent],
|
|
239
|
+
template: `<cosm-popover (openChange)="onOpenChange($event.detail)"><cosm-icon-button slot="trigger" label="Details" variant="ghost" tone="neutral"><cosm-icon [icon]="info" /></cosm-icon-button>Popover</cosm-popover>`,
|
|
240
|
+
})
|
|
241
|
+
export class ExampleComponent {
|
|
242
|
+
readonly info = info;
|
|
243
|
+
onOpenChange(detail: PopoverOpenChangeDetail) {
|
|
244
|
+
console.log(detail);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
### `CosmListboxComponent` (`<cosm-listbox>`)
|
|
249
|
+
|
|
250
|
+
Selects one or more values from a named vertical collection, with groups, descriptions, icons and independent keyboard focus.
|
|
251
|
+
|
|
252
|
+
| Prop | Type | Default | Description |
|
|
253
|
+
| --- | --- | --- | --- |
|
|
254
|
+
| `label` | string | Required | Required nonempty accessible label, visible unless labelHidden is true. |
|
|
255
|
+
| `labelHidden` | boolean | `false` | Visually hides the label without removing its accessible name. |
|
|
256
|
+
| `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. |
|
|
257
|
+
| `selectionMode` | 'single' \| 'multiple' | `single` | Single permits at most one selected value; multiple toggles each activation. |
|
|
258
|
+
| `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. |
|
|
259
|
+
| `defaultSelectedValues` | ListboxValues | — | Initial autonomous selected values (empty by default). Later changes do not reset selection. |
|
|
260
|
+
| `variant` | 'plain' \| 'outlined' | `plain` | Plain composes inside a panel; outlined adds a standalone container boundary. |
|
|
261
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large option rows. Content may grow; native touch targets remain at least 44. |
|
|
262
|
+
| `disabled` | boolean | `false` | Prevents interaction and removes the list from keyboard navigation. |
|
|
263
|
+
| `readOnly` | boolean | `false` | Allows exploring options without proposing or committing selection changes. |
|
|
264
|
+
| `locale` | string | — | BCP 47 locale for typeahead. Web inherits the nearest language; native uses the runtime locale when omitted. Invalid locale identifiers are rejected. |
|
|
265
|
+
|
|
266
|
+
Events: `(selectionChange)` → `ListboxSelectionChangeDetail`.
|
|
267
|
+
|
|
268
|
+
```ts
|
|
269
|
+
import { Component } from '@angular/core';
|
|
270
|
+
import { CosmListboxComponent } from '@joralvmel/cosmos-angular';
|
|
271
|
+
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;
|
|
272
|
+
const empty = [] as const;
|
|
273
|
+
import type { ListboxSelectionChangeDetail } from '@joralvmel/cosmos-core';
|
|
274
|
+
|
|
275
|
+
@Component({
|
|
276
|
+
selector: 'app-example',
|
|
277
|
+
imports: [CosmListboxComponent],
|
|
278
|
+
template: `<cosm-listbox label="Listbox" [items]="grouped" [defaultSelectedValues]="empty" (selectionChange)="onSelectionChange($event.detail)"></cosm-listbox>`,
|
|
279
|
+
})
|
|
280
|
+
export class ExampleComponent {
|
|
281
|
+
readonly grouped = grouped;
|
|
282
|
+
readonly empty = empty;
|
|
283
|
+
onSelectionChange(detail: ListboxSelectionChangeDetail) {
|
|
284
|
+
console.log(detail);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
### `CosmCheckboxComponent` (`<cosm-checkbox>`)
|
|
289
|
+
|
|
290
|
+
Selects an independent boolean value with accessible labeling and native form behavior on the web.
|
|
291
|
+
|
|
292
|
+
| Prop | Type | Default | Description |
|
|
293
|
+
| --- | --- | --- | --- |
|
|
294
|
+
| `label` | string | Required | Required accessible name, visible unless labelHidden is true. |
|
|
295
|
+
| `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |
|
|
296
|
+
| `checked` | boolean | `false` | Controlled checked value when supplied, including false; activation proposes changes without self-committing. |
|
|
297
|
+
| `defaultChecked` | boolean | `false` | Initial autonomous checked value; later changes do not reset it. |
|
|
298
|
+
| `indeterminate` | boolean | `false` | Presentation-only mixed state. Autonomous activation clears it; controlled use leaves it to the owner. |
|
|
299
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large visual box. |
|
|
300
|
+
| `disabled` | boolean | `false` | Prevents user interaction and excludes the value from web form submission. |
|
|
301
|
+
| `required` | boolean | `false` | Exposes required semantics and participates in native web form validation. Native has no automatic validation. |
|
|
302
|
+
| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere; web form validity remains based on required. |
|
|
303
|
+
| `helperText` | string | — | Optional consumer-localized supporting text associated with the checkbox. |
|
|
304
|
+
| `errorText` | string | — | Optional consumer-localized error description; a nonempty trimmed value also exposes invalid state. |
|
|
305
|
+
| `name` | string | — | Web form field name; React Native has no HTML form association. |
|
|
306
|
+
| `value` | string | `on` | Web form value submitted when checked and enabled; defaults to on. Angular Forms uses checked as its boolean value. |
|
|
307
|
+
|
|
308
|
+
Events: `(checkedChange)` → `CheckboxCheckedChangeDetail`.
|
|
309
|
+
|
|
310
|
+
```ts
|
|
311
|
+
import { Component } from '@angular/core';
|
|
312
|
+
import { CosmCheckboxComponent } from '@joralvmel/cosmos-angular';
|
|
313
|
+
import type { CheckboxCheckedChangeDetail } from '@joralvmel/cosmos-core';
|
|
314
|
+
|
|
315
|
+
@Component({
|
|
316
|
+
selector: 'app-example',
|
|
317
|
+
imports: [CosmCheckboxComponent],
|
|
318
|
+
template: `<cosm-checkbox label="Checkbox" (checkedChange)="onCheckedChange($event.detail)">Checkbox</cosm-checkbox>`,
|
|
319
|
+
})
|
|
320
|
+
export class ExampleComponent {
|
|
321
|
+
onCheckedChange(detail: CheckboxCheckedChangeDetail) {
|
|
322
|
+
console.log(detail);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
### `CosmSwitchComponent` (`<cosm-switch>`)
|
|
327
|
+
|
|
328
|
+
Toggles a binary setting immediately with a stable accessible name and form behavior on the web.
|
|
329
|
+
|
|
330
|
+
| Prop | Type | Default | Description |
|
|
331
|
+
| --- | --- | --- | --- |
|
|
332
|
+
| `label` | string | Required | Required nonempty accessible name; remains stable in both states. |
|
|
333
|
+
| `labelHidden` | boolean | `false` | Visually hides the label while retaining its accessible name. |
|
|
334
|
+
| `checked` | boolean | `false` | Controlled checked value when supplied, including false; activation proposes changes without self-committing. |
|
|
335
|
+
| `defaultChecked` | boolean | `false` | Initial autonomous checked value; later changes do not reset it. |
|
|
336
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large web switch. Native uses system Switch sizing. |
|
|
337
|
+
| `disabled` | boolean | `false` | Prevents user interaction and excludes the value from web form submission. |
|
|
338
|
+
| `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. |
|
|
339
|
+
| `helperText` | string | — | Optional consumer-localized supporting text associated with the switch. |
|
|
340
|
+
| `name` | string | — | Web form field name; React Native has no HTML form association. |
|
|
341
|
+
| `value` | string | `on` | Web form value submitted when checked and enabled; defaults to on. Angular Forms uses checked as its boolean value. |
|
|
342
|
+
|
|
343
|
+
Events: `(checkedChange)` → `SwitchCheckedChangeDetail`.
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
import { Component } from '@angular/core';
|
|
347
|
+
import { CosmSwitchComponent } from '@joralvmel/cosmos-angular';
|
|
348
|
+
import type { SwitchCheckedChangeDetail } from '@joralvmel/cosmos-core';
|
|
349
|
+
|
|
350
|
+
@Component({
|
|
351
|
+
selector: 'app-example',
|
|
352
|
+
imports: [CosmSwitchComponent],
|
|
353
|
+
template: `<cosm-switch label="Switch" (checkedChange)="onCheckedChange($event.detail)"></cosm-switch>`,
|
|
354
|
+
})
|
|
355
|
+
export class ExampleComponent {
|
|
356
|
+
onCheckedChange(detail: SwitchCheckedChangeDetail) {
|
|
357
|
+
console.log(detail);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
### `CosmBadgeComponent` (`<cosm-badge>`)
|
|
362
|
+
|
|
363
|
+
Displays a noninteractive status or category label, or caller-formatted count, with an optional decorative leading icon.
|
|
364
|
+
|
|
365
|
+
| Prop | Type | Default | Description |
|
|
366
|
+
| --- | --- | --- | --- |
|
|
367
|
+
| `variant` | 'soft' \| 'solid' \| 'outline' | `soft` | Visual treatment of the static label. |
|
|
368
|
+
| `tone` | 'neutral' \| 'info' \| 'success' \| 'warning' \| 'danger' | `neutral` | Semantic color intent of the static label. |
|
|
369
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Semantic label size. |
|
|
370
|
+
| `startIcon` | IconDefinition | — | Optional structured decorative icon before the label. |
|
|
371
|
+
|
|
372
|
+
Events: none.
|
|
373
|
+
|
|
374
|
+
```ts
|
|
375
|
+
import { Component } from '@angular/core';
|
|
376
|
+
import { CosmBadgeComponent } from '@joralvmel/cosmos-angular';
|
|
377
|
+
import { heart } from '@joralvmel/cosmos-icons/heart';
|
|
378
|
+
|
|
379
|
+
@Component({
|
|
380
|
+
selector: 'app-example',
|
|
381
|
+
imports: [CosmBadgeComponent],
|
|
382
|
+
template: `<cosm-badge [startIcon]="heart">Badge</cosm-badge>`,
|
|
383
|
+
})
|
|
384
|
+
export class ExampleComponent {
|
|
385
|
+
readonly heart = heart;
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
### `CosmCalendarComponent` (`<cosm-calendar>`)
|
|
389
|
+
|
|
390
|
+
Selects one Gregorian date from an inline, localized calendar with keyboard navigation and optional bounds. Month and year can be selected directly.
|
|
391
|
+
|
|
392
|
+
| Prop | Type | Default | Description |
|
|
393
|
+
| --- | --- | --- | --- |
|
|
394
|
+
| `value` | string | — | Controlled selected date in YYYY-MM-DD format; when supplied, selection proposals wait for the owner to update this value. |
|
|
395
|
+
| `defaultValue` | string | — | Initial autonomous selected date in YYYY-MM-DD format; later changes do not reset selection. |
|
|
396
|
+
| `min` | string | — | Earliest selectable date in YYYY-MM-DD format, inclusive. |
|
|
397
|
+
| `max` | string | — | Latest selectable date in YYYY-MM-DD format, inclusive. |
|
|
398
|
+
| `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. |
|
|
399
|
+
| `disabled` | boolean | `false` | Disables date selection and calendar navigation. |
|
|
400
|
+
|
|
401
|
+
Events: `(valueChange)` → `CalendarChangeDetail`.
|
|
402
|
+
|
|
403
|
+
```ts
|
|
404
|
+
import { Component } from '@angular/core';
|
|
405
|
+
import { CosmCalendarComponent } from '@joralvmel/cosmos-angular';
|
|
406
|
+
import type { CalendarChangeDetail } from '@joralvmel/cosmos-core';
|
|
407
|
+
|
|
408
|
+
@Component({
|
|
409
|
+
selector: 'app-example',
|
|
410
|
+
imports: [CosmCalendarComponent],
|
|
411
|
+
template: `<cosm-calendar (valueChange)="onValueChange($event.detail)"></cosm-calendar>`,
|
|
412
|
+
})
|
|
413
|
+
export class ExampleComponent {
|
|
414
|
+
onValueChange(detail: CalendarChangeDetail) {
|
|
415
|
+
console.log(detail);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
### `CosmTextareaComponent` (`<cosm-textarea>`)
|
|
420
|
+
|
|
421
|
+
Accepts multiline plain text with an accessible label, optional helper and error text, and native form behavior on the web.
|
|
422
|
+
|
|
423
|
+
| Prop | Type | Default | Description |
|
|
424
|
+
| --- | --- | --- | --- |
|
|
425
|
+
| `label` | string | Required | Accessible name for the editable control. It is rendered above the control unless visually hidden. |
|
|
426
|
+
| `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |
|
|
427
|
+
| `value` | string | — | Current text. When bound, edits are proposals and the component waits for the owner to supply the accepted value. |
|
|
428
|
+
| `defaultValue` | string | `` | Initial value for autonomous use. Web form reset restores this value; it does not control subsequent edits. |
|
|
429
|
+
| `rows` | number | `4` | Visible line count of the multiline editor. It is independent of the visual size. |
|
|
430
|
+
| `variant` | 'outlined' \| 'filled' | `outlined` | Visual treatment of the editable control. |
|
|
431
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Visual size of the editable control, independent of rows. |
|
|
432
|
+
| `placeholder` | string | — | Short input hint; it never replaces the accessible label. |
|
|
433
|
+
| `helperText` | string | — | Optional supporting text associated with the editable control. |
|
|
434
|
+
| `errorText` | string | — | Optional consumer-localized error text associated with the editable control; a nonempty trimmed value also exposes invalid state. |
|
|
435
|
+
| `invalid` | boolean | `false` | External invalid state when the visible error is supplied elsewhere, independent of browser constraints or consumer business validation. |
|
|
436
|
+
| `required` | boolean | `false` | Exposes required semantics. On web, participates in native HTML constraint validation. |
|
|
437
|
+
| `disabled` | boolean | `false` | Disables editing and interaction. On web, follows disabled fieldsets and excludes the value from form submission. |
|
|
438
|
+
| `readOnly` | boolean | `false` | Prevents editing while remaining focusable and form-submittable on web; distinct from disabled. |
|
|
439
|
+
| `maxLength` | number | — | Maximum number of characters. Web uses native HTML length constraints and native applies supported input limits. |
|
|
440
|
+
| `name` | string | — | Form field name on web. React Native has no HTML form association or name-based submission. |
|
|
441
|
+
|
|
442
|
+
Events: `(valueChange)` → `TextareaChangeDetail`.
|
|
443
|
+
|
|
444
|
+
```ts
|
|
445
|
+
import { Component } from '@angular/core';
|
|
446
|
+
import { CosmTextareaComponent } from '@joralvmel/cosmos-angular';
|
|
447
|
+
import type { TextareaChangeDetail } from '@joralvmel/cosmos-core';
|
|
448
|
+
|
|
449
|
+
@Component({
|
|
450
|
+
selector: 'app-example',
|
|
451
|
+
imports: [CosmTextareaComponent],
|
|
452
|
+
template: `<cosm-textarea label="Textarea" (valueChange)="onValueChange($event.detail)"></cosm-textarea>`,
|
|
453
|
+
})
|
|
454
|
+
export class ExampleComponent {
|
|
455
|
+
onValueChange(detail: TextareaChangeDetail) {
|
|
456
|
+
console.log(detail);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
```
|
|
460
|
+
### `CosmRadioGroupComponent` (`<cosm-radio-group>`)
|
|
461
|
+
|
|
462
|
+
Selects one option from a labeled collection, with optional selection and native Web form behavior.
|
|
463
|
+
|
|
464
|
+
| Prop | Type | Default | Description |
|
|
465
|
+
| --- | --- | --- | --- |
|
|
466
|
+
| `label` | string | Required | Required visible accessible name for the group. |
|
|
467
|
+
| `options` | RadioGroupOptions | Required | Readonly flat options with unique nonempty values and labels, optional descriptions and disabled states. |
|
|
468
|
+
| `value` | RadioGroupValue | — | Controlled selected value; null means no selection, and a supplied null remains controlled. |
|
|
469
|
+
| `defaultValue` | RadioGroupValue | — | Initial autonomous selection; null by default. |
|
|
470
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large radio indicator. |
|
|
471
|
+
| `orientation` | 'vertical' \| 'horizontal' | `vertical` | Vertical list or wrapping horizontal options. |
|
|
472
|
+
| `disabled` | boolean | `false` | Prevents interaction and excludes the value from Web form submission. |
|
|
473
|
+
| `required` | boolean | `false` | Requires a selection in Web form validation; Native exposes descriptive semantics. |
|
|
474
|
+
| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere. |
|
|
475
|
+
| `helperText` | string | — | Optional supporting text associated with the group. |
|
|
476
|
+
| `errorText` | string | — | Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state. |
|
|
477
|
+
| `name` | string | — | Web form field name; React Native has no HTML form association. |
|
|
478
|
+
|
|
479
|
+
Events: `(valueChange)` → `RadioGroupChangeDetail`.
|
|
480
|
+
|
|
481
|
+
```ts
|
|
482
|
+
import { Component } from '@angular/core';
|
|
483
|
+
import { CosmRadioGroupComponent } from '@joralvmel/cosmos-angular';
|
|
484
|
+
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;
|
|
485
|
+
import type { RadioGroupChangeDetail } from '@joralvmel/cosmos-core';
|
|
486
|
+
|
|
487
|
+
@Component({
|
|
488
|
+
selector: 'app-example',
|
|
489
|
+
imports: [CosmRadioGroupComponent],
|
|
490
|
+
template: `<cosm-radio-group label="RadioGroup" [options]="contactMethods" (valueChange)="onValueChange($event.detail)"></cosm-radio-group>`,
|
|
491
|
+
})
|
|
492
|
+
export class ExampleComponent {
|
|
493
|
+
readonly contactMethods = contactMethods;
|
|
494
|
+
onValueChange(detail: RadioGroupChangeDetail) {
|
|
495
|
+
console.log(detail);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
```
|
|
499
|
+
### `CosmSelectComponent` (`<cosm-select>`)
|
|
500
|
+
|
|
501
|
+
Selects one option from an accessible collection, with native Web form behavior.
|
|
502
|
+
|
|
503
|
+
| Prop | Type | Default | Description |
|
|
504
|
+
| --- | --- | --- | --- |
|
|
505
|
+
| `label` | string | Required | Required visible accessible name for the control. |
|
|
506
|
+
| `items` | SelectItems | Required | Readonly flat options with unique nonempty values, nonempty labels, and optional disabled state. |
|
|
507
|
+
| `value` | SelectValue | — | Controlled selected value; null means no selection, and a supplied null remains controlled. |
|
|
508
|
+
| `defaultValue` | SelectValue | — | Initial autonomous selection; null by default. |
|
|
509
|
+
| `placeholder` | string | Required | Consumer-localized text shown when no value is selected. |
|
|
510
|
+
| `variant` | 'outlined' \| 'filled' | `outlined` | Outlined or filled trigger appearance. |
|
|
511
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium, or large control size. |
|
|
512
|
+
| `disabled` | boolean | `false` | Prevents interaction and excludes the value from Web form submission. |
|
|
513
|
+
| `required` | boolean | `false` | Requires a selection in Web form validation; Native exposes descriptive semantics. |
|
|
514
|
+
| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere. |
|
|
515
|
+
| `helperText` | string | — | Optional supporting text associated with the control. |
|
|
516
|
+
| `errorText` | string | — | Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state. |
|
|
517
|
+
| `name` | string | — | Web form field name; React Native has no HTML form association. |
|
|
518
|
+
|
|
519
|
+
Events: `(valueChange)` → `SelectChangeDetail`.
|
|
520
|
+
|
|
521
|
+
```ts
|
|
522
|
+
import { Component } from '@angular/core';
|
|
523
|
+
import { CosmSelectComponent } from '@joralvmel/cosmos-angular';
|
|
524
|
+
const flat = [{"value":"apple","label":"Apple"},{"value":"cherry","label":"Cherry"},{"value":"lime","label":"Lime","disabled":true}] as const;
|
|
525
|
+
const none = null as const;
|
|
526
|
+
import type { SelectChangeDetail } from '@joralvmel/cosmos-core';
|
|
527
|
+
|
|
528
|
+
@Component({
|
|
529
|
+
selector: 'app-example',
|
|
530
|
+
imports: [CosmSelectComponent],
|
|
531
|
+
template: `<cosm-select label="Select" [items]="flat" [defaultValue]="none" placeholder="Select" (valueChange)="onValueChange($event.detail)"></cosm-select>`,
|
|
532
|
+
})
|
|
533
|
+
export class ExampleComponent {
|
|
534
|
+
readonly flat = flat;
|
|
535
|
+
readonly none = none;
|
|
536
|
+
onValueChange(detail: SelectChangeDetail) {
|
|
537
|
+
console.log(detail);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
```
|
|
541
|
+
### `CosmPaginationComponent` (`<cosm-pagination>`)
|
|
542
|
+
|
|
543
|
+
Navigates a known number of pages using buttons.
|
|
544
|
+
|
|
545
|
+
| Prop | Type | Default | Description |
|
|
546
|
+
| --- | --- | --- | --- |
|
|
547
|
+
| `totalPages` | number | Required | Required nonnegative safe integer page count. |
|
|
548
|
+
| `page` | number | — | Controlled one-based safe integer page; out-of-range values are displayed clamped. |
|
|
549
|
+
| `defaultPage` | number | `1` | Initial one-based page for autonomous state. |
|
|
550
|
+
| `label` | string | Required | Required localized navigation landmark label. |
|
|
551
|
+
| `previousLabel` | string | `Previous page` | Previous button label. |
|
|
552
|
+
| `nextLabel` | string | `Next page` | Next button label. |
|
|
553
|
+
| `firstLabel` | string | `First page` | First button label. |
|
|
554
|
+
| `lastLabel` | string | `Last page` | Last button label. |
|
|
555
|
+
| `pageLabel` | string | `Page {page}` | Page button label template; {page} is replaced with the localized number. |
|
|
556
|
+
| `summaryLabel` | string | `Page {page} of {total}` | Compact summary template with {page} and {total} placeholders. |
|
|
557
|
+
| `locale` | string | — | Locale for formatted page numbers. |
|
|
558
|
+
| `direction` | 'ltr' \| 'rtl' | `ltr` | Layout and directional icon direction. |
|
|
559
|
+
| `presentation` | 'numbered' \| 'compact' | `numbered` | Show up to seven fixed-width numbered positions or a compact summary. |
|
|
560
|
+
| `variant` | 'solid' \| 'soft' \| 'outline' | `solid` | Selected page emphasis. |
|
|
561
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Control size. |
|
|
562
|
+
| `showFirstLast` | boolean | `false` | Show first and last page controls. |
|
|
563
|
+
| `disabled` | boolean | `false` | Disable all controls. |
|
|
564
|
+
|
|
565
|
+
Events: `(pageChange)` → `PaginationChangeDetail`.
|
|
566
|
+
|
|
567
|
+
```ts
|
|
568
|
+
import { Component } from '@angular/core';
|
|
569
|
+
import { CosmPaginationComponent } from '@joralvmel/cosmos-angular';
|
|
570
|
+
import type { PaginationChangeDetail } from '@joralvmel/cosmos-core';
|
|
571
|
+
|
|
572
|
+
@Component({
|
|
573
|
+
selector: 'app-example',
|
|
574
|
+
imports: [CosmPaginationComponent],
|
|
575
|
+
template: `<cosm-pagination label="Pagination" (pageChange)="onPageChange($event.detail)"></cosm-pagination>`,
|
|
576
|
+
})
|
|
577
|
+
export class ExampleComponent {
|
|
578
|
+
onPageChange(detail: PaginationChangeDetail) {
|
|
579
|
+
console.log(detail);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
```
|
|
583
|
+
### `CosmDialogComponent` (`<cosm-dialog>`)
|
|
584
|
+
|
|
585
|
+
Modal content with a title, actions and cancelable close requests.
|
|
586
|
+
|
|
587
|
+
| Prop | Type | Default | Description |
|
|
588
|
+
| --- | --- | --- | --- |
|
|
589
|
+
| `open` | boolean | `false` | Committed visibility; supplying this prop, including false, controls state. |
|
|
590
|
+
| `defaultOpen` | boolean | `false` | Initial autonomous visibility; subsequent changes do not reset state. |
|
|
591
|
+
| `presentation` | 'standard' \| 'fullscreen' | `standard` | Centered standard surface or fullscreen surface. |
|
|
592
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Maximum standard width: sm 400, md 640, lg 960 pixels or logical points. |
|
|
593
|
+
| `responsiveFullscreen` | boolean | `false` | Use fullscreen when available viewport width is below 640 pixels or logical points. |
|
|
594
|
+
| `closeLabel` | string | `Close` | Non-empty localized accessible name of the built-in close button. |
|
|
595
|
+
| `closeOnEscape` | boolean | `true` | Request closure on unhandled Escape on web. |
|
|
596
|
+
| `closeOnBackdropPress` | boolean | `false` | Request closure when the backdrop itself is pressed. |
|
|
597
|
+
| `initialFocusTarget` | DialogFocusTarget | — | Optional platform focus target used on committed opening; it must be inside the dialog. |
|
|
598
|
+
| `returnFocusTarget` | DialogFocusTarget | — | Optional platform focus target used after committed closure. |
|
|
599
|
+
|
|
600
|
+
Events: `(openChange)` → `DialogOpenChangeDetail`.
|
|
601
|
+
|
|
602
|
+
```ts
|
|
603
|
+
import { Component, ViewChild } from '@angular/core';
|
|
604
|
+
import { CosmButtonComponent, CosmDialogComponent } from '@joralvmel/cosmos-angular';
|
|
605
|
+
import type { DialogOpenChangeDetail } from '@joralvmel/cosmos-core';
|
|
606
|
+
|
|
607
|
+
@Component({
|
|
608
|
+
selector: 'app-example',
|
|
609
|
+
imports: [CosmButtonComponent, CosmDialogComponent],
|
|
610
|
+
template: `
|
|
611
|
+
<cosm-button type="button" (press)="dialog?.requestOpen()">Open dialog</cosm-button>
|
|
612
|
+
<cosm-dialog (openChange)="onOpenChange($event)">
|
|
613
|
+
<h2 slot="title">Review details</h2>
|
|
614
|
+
<p>Dialog</p>
|
|
615
|
+
<cosm-button slot="actions" type="button" (press)="dialog?.requestClose()">Done</cosm-button>
|
|
616
|
+
</cosm-dialog>
|
|
617
|
+
`,
|
|
618
|
+
})
|
|
619
|
+
export class ExampleComponent {
|
|
620
|
+
@ViewChild(CosmDialogComponent) dialog?: CosmDialogComponent;
|
|
621
|
+
onOpenChange(event: CustomEvent<DialogOpenChangeDetail>) {
|
|
622
|
+
console.log(event.detail);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
```
|
|
113
626
|
|
|
114
627
|
## Themes
|
|
115
628
|
|
|
116
|
-
Built-in themes: `cosmos`, `nebula` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
|
|
629
|
+
Built-in themes: `cosmos`, `nebula`, `terra`, `supernova`, `aurora`, `solstice` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
|
|
117
630
|
|
|
118
631
|
```html
|
|
119
632
|
<html data-theme="nebula" data-mode="system">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joralvmel/cosmos-angular",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Angular standalone components and forms integration for the Cosmos UI Web Components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@joralvmel/cosmos-core": "^0.
|
|
46
|
-
"@joralvmel/cosmos-elements": "^0.
|
|
47
|
-
"@joralvmel/cosmos-icons": "^0.
|
|
45
|
+
"@joralvmel/cosmos-core": "^0.4.0",
|
|
46
|
+
"@joralvmel/cosmos-elements": "^0.4.0",
|
|
47
|
+
"@joralvmel/cosmos-icons": "^0.4.0",
|
|
48
48
|
"tslib": "^2.9.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"@angular/forms": ">=21.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@angular/common": "
|
|
56
|
-
"@angular/compiler": "
|
|
57
|
-
"@angular/compiler-cli": "
|
|
58
|
-
"@angular/core": "
|
|
59
|
-
"@angular/forms": "
|
|
60
|
-
"@angular/platform-browser": "
|
|
55
|
+
"@angular/common": "~22.3.0",
|
|
56
|
+
"@angular/compiler": "~22.3.0",
|
|
57
|
+
"@angular/compiler-cli": "~22.3.0",
|
|
58
|
+
"@angular/core": "~22.3.0",
|
|
59
|
+
"@angular/forms": "~22.3.0",
|
|
60
|
+
"@angular/platform-browser": "~22.3.0",
|
|
61
61
|
"rxjs": "^7.8.2"
|
|
62
62
|
}
|
|
63
63
|
}
|