@joralvmel/cosmos-react 0.1.0 → 0.3.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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  React wrappers for [Cosmos UI](../../README.md).
4
4
 
5
- React 19 wrappers of the Cosmos Web Components.
5
+ React 19 wrappers of the Cosmos Web Components. Install with React DOM 19; both are peer dependencies.
6
6
 
7
7
  ```tsx
8
8
  import '@joralvmel/cosmos-tokens/tokens.css';
@@ -17,6 +17,39 @@ export function Toolbar() {
17
17
  }
18
18
  ```
19
19
 
20
+ For controlled text entry, bind `value` and update it from the original event detail:
21
+
22
+ ```tsx
23
+ import { useState } from 'react';
24
+ import { TextField } from '@joralvmel/cosmos-react';
25
+
26
+ export function EmailField() {
27
+ const [email, setEmail] = useState('');
28
+ return (
29
+ <TextField
30
+ label="Email"
31
+ type="email"
32
+ value={email}
33
+ onChange={event => setEmail(event.detail.value)}
34
+ clearable
35
+ clearLabel="Clear email"
36
+ />
37
+ );
38
+ }
39
+ ```
40
+
41
+ `onChange` and `onSubmit` receive the original bubbling DOM `CustomEvent`; use `.detail.value`.
42
+ Passing `value`, including an empty string, makes the field controlled.
43
+ The adapter synchronizes `onChange` updates with React DOM before Lit reconciles the controlled
44
+ value, so ordinary synchronous `setState` handlers do not lose rapid keystrokes. Consumers do not
45
+ need to call `flushSync`; deferred updates still leave the previous controlled value in place
46
+ until the owner accepts the proposal.
47
+
48
+ For independent icon colors, put the text-field CSS hooks on a `className` or `style`:
49
+ `--cosm-text-field-start-icon-color`, `--cosm-text-field-start-icon-focus-color`, and the corresponding
50
+ `end-icon` hooks. `iconFocusScope="control"` (default) includes input/action focus; `"input"` limits
51
+ focus colors to the editable input. Focus overrides are optional and do not recolor action icons.
52
+
20
53
  ## License
21
54
 
22
55
  MIT
@@ -0,0 +1,22 @@
1
+ import type { IconButtonPressDetail, IconButtonPressedChangeDetail } from '@joralvmel/cosmos-core';
2
+ import { CosmIconButton } from '@joralvmel/cosmos-elements/icon-button';
3
+ import { type EventName } from '@lit/react';
4
+ import * as React from 'react';
5
+ export declare const iconButtonEvents: {
6
+ onPress: EventName<CustomEvent<IconButtonPressDetail>>;
7
+ onPressedChange: EventName<CustomEvent<IconButtonPressedChangeDetail>>;
8
+ };
9
+ declare const IconButtonElement: import("@lit/react").ReactWebComponent<CosmIconButton, {
10
+ onPress: EventName<CustomEvent<IconButtonPressDetail>>;
11
+ onPressedChange: EventName<CustomEvent<IconButtonPressedChangeDetail>>;
12
+ }>;
13
+ type ElementProps = React.ComponentProps<typeof IconButtonElement>;
14
+ /** React wrapper; a supplied pressed value, including false, is controlled. */
15
+ export declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & React.RefAttributes<CosmIconButton>>;
16
+ export type IconButtonProps = Omit<ElementProps, 'label' | 'onPress' | 'onPressedChange'> & {
17
+ label: string;
18
+ onPress?: (event: CustomEvent<IconButtonPressDetail>) => void;
19
+ onPressedChange?: (event: CustomEvent<IconButtonPressedChangeDetail>) => void;
20
+ };
21
+ export {};
22
+ //# sourceMappingURL=icon-button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../src/components/icon-button.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,gBAAgB;aACF,SAAS,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;qBAC5B,SAAS,CAAC,WAAW,CAAC,6BAA6B,CAAC,CAAC;CAChG,CAAC;AAEF,QAAA,MAAM,iBAAiB;aAJI,SAAS,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;qBAC5B,SAAS,CAAC,WAAW,CAAC,6BAA6B,CAAC,CAAC;EAS/F,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE,+EAA+E;AAC/E,eAAO,MAAM,UAAU,qGAwBtB,CAAC;AAGF,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,SAAS,GAAG,iBAAiB,CAAC,GAAG;IAC1F,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,qBAAqB,CAAC,KAAK,IAAI,CAAC;IAC9D,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,6BAA6B,CAAC,KAAK,IAAI,CAAC;CAC/E,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { CosmIconButton } from '@joralvmel/cosmos-elements/icon-button';
2
+ import { createComponent } from '@lit/react';
3
+ import * as React from 'react';
4
+ import { flushSync } from 'react-dom';
5
+ export const iconButtonEvents = {
6
+ onPress: 'cosm-press',
7
+ onPressedChange: 'cosm-pressed-change',
8
+ };
9
+ const IconButtonElement = createComponent({
10
+ tagName: 'cosm-icon-button',
11
+ elementClass: CosmIconButton,
12
+ react: React,
13
+ events: iconButtonEvents,
14
+ displayName: 'IconButtonElement',
15
+ });
16
+ /** React wrapper; a supplied pressed value, including false, is controlled. */
17
+ export const IconButton = React.forwardRef((props, forwardedRef) => {
18
+ const { pressed, onPressedChange, ...elementProps } = props;
19
+ const handleChange = React.useCallback((event) => {
20
+ if (onPressedChange)
21
+ flushSync(() => onPressedChange(event));
22
+ }, [onPressedChange]);
23
+ const setRef = React.useCallback((element) => {
24
+ if (element)
25
+ element.pressedControlled = pressed !== undefined;
26
+ if (typeof forwardedRef === 'function')
27
+ forwardedRef(element);
28
+ else if (forwardedRef)
29
+ forwardedRef.current = element;
30
+ }, [forwardedRef, pressed]);
31
+ return React.createElement(IconButtonElement, {
32
+ ...elementProps,
33
+ pressed,
34
+ onPressedChange: handleChange,
35
+ ref: setRef,
36
+ });
37
+ });
38
+ IconButton.displayName = 'IconButton';
39
+ //# sourceMappingURL=icon-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon-button.js","sourceRoot":"","sources":["../../src/components/icon-button.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO,EAAE,YAA6D;IACtE,eAAe,EAAE,qBAA8E;CAChG,CAAC;AAEF,MAAM,iBAAiB,GAAG,eAAe,CAAC;IACxC,OAAO,EAAE,kBAAkB;IAC3B,YAAY,EAAE,cAAc;IAC5B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,gBAAgB;IACxB,WAAW,EAAE,mBAAmB;CACjC,CAAC,CAAC;AAIH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CACxC,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IACtB,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IAC5D,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CACpC,CAAC,KAAiD,EAAE,EAAE;QACpD,IAAI,eAAe;YAAE,SAAS,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,CAAC,EACD,CAAC,eAAe,CAAC,CAClB,CAAC;IACF,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAC9B,CAAC,OAA8B,EAAE,EAAE;QACjC,IAAI,OAAO;YAAE,OAAO,CAAC,iBAAiB,GAAG,OAAO,KAAK,SAAS,CAAC;QAC/D,IAAI,OAAO,YAAY,KAAK,UAAU;YAAE,YAAY,CAAC,OAAO,CAAC,CAAC;aACzD,IAAI,YAAY;YAAE,YAAY,CAAC,OAAO,GAAG,OAAO,CAAC;IACxD,CAAC,EACD,CAAC,YAAY,EAAE,OAAO,CAAC,CACxB,CAAC;IACF,OAAO,KAAK,CAAC,aAAa,CAAC,iBAAiB,EAAE;QAC5C,GAAG,YAAY;QACf,OAAO;QACP,eAAe,EAAE,YAAY;QAC7B,GAAG,EAAE,MAAM;KACI,CAAC,CAAC;AACrB,CAAC,CACF,CAAC;AACF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { CosmIcon } from '@joralvmel/cosmos-elements/icon';
2
+ import * as React from 'react';
3
+ /** The icon contract has no events. */
4
+ export declare const iconEvents: {};
5
+ /** React wrapper of `<cosm-icon>`. */
6
+ export declare const Icon: import("@lit/react").ReactWebComponent<CosmIcon, {}>;
7
+ export type IconProps = React.ComponentProps<typeof Icon>;
8
+ //# sourceMappingURL=icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../src/components/icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,uCAAuC;AACvC,eAAO,MAAM,UAAU,IAAK,CAAC;AAE7B,sCAAsC;AACtC,eAAO,MAAM,IAAI,sDAMf,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { CosmIcon } from '@joralvmel/cosmos-elements/icon';
2
+ import { createComponent } from '@lit/react';
3
+ import * as React from 'react';
4
+ /** The icon contract has no events. */
5
+ export const iconEvents = {};
6
+ /** React wrapper of `<cosm-icon>`. */
7
+ export const Icon = createComponent({
8
+ tagName: 'cosm-icon',
9
+ elementClass: CosmIcon,
10
+ react: React,
11
+ events: iconEvents,
12
+ displayName: 'Icon',
13
+ });
14
+ //# sourceMappingURL=icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.js","sourceRoot":"","sources":["../../src/components/icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,uCAAuC;AACvC,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAE7B,sCAAsC;AACtC,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAC;IAClC,OAAO,EAAE,WAAW;IACpB,YAAY,EAAE,QAAQ;IACtB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,UAAU;IAClB,WAAW,EAAE,MAAM;CACpB,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { ListboxSelectionChangeDetail } from '@joralvmel/cosmos-core';
2
+ import { CosmListbox } from '@joralvmel/cosmos-elements/listbox';
3
+ import { type EventName } from '@lit/react';
4
+ import * as React from 'react';
5
+ /** React event props of `Listbox`, mapped to the original DOM `CustomEvent`. */
6
+ export declare const listboxEvents: {
7
+ onSelectionChange: EventName<CustomEvent<ListboxSelectionChangeDetail>>;
8
+ };
9
+ declare const ListboxElement: import("@lit/react").ReactWebComponent<CosmListbox, {
10
+ onSelectionChange: EventName<CustomEvent<ListboxSelectionChangeDetail>>;
11
+ }>;
12
+ type ElementProps = React.ComponentProps<typeof ListboxElement>;
13
+ /** React wrapper of `<cosm-listbox>`; a supplied selectedValues array, including `[]`, is controlled. */
14
+ export declare const Listbox: React.ForwardRefExoticComponent<Omit<ListboxProps, "ref"> & React.RefAttributes<CosmListbox>>;
15
+ export type ListboxProps = Omit<ElementProps, 'onSelectionChange'> & {
16
+ label: string;
17
+ items: CosmListbox['items'];
18
+ selectedValues?: readonly string[];
19
+ onSelectionChange?: (event: CustomEvent<ListboxSelectionChangeDetail>) => void;
20
+ };
21
+ export {};
22
+ //# sourceMappingURL=listbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listbox.d.ts","sourceRoot":"","sources":["../../src/components/listbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,gFAAgF;AAChF,eAAO,MAAM,aAAa;uBACsB,SAAS,CACrD,WAAW,CAAC,4BAA4B,CAAC,CAC1C;CACF,CAAC;AAEF,QAAA,MAAM,cAAc;uBAL4B,SAAS,CACrD,WAAW,CAAC,4BAA4B,CAAC,CAC1C;EASD,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,CAAC;AAEhE,yGAAyG;AACzG,eAAO,MAAM,OAAO,+FAsBlB,CAAC;AAIH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,mBAAmB,CAAC,GAAG;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5B,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,4BAA4B,CAAC,KAAK,IAAI,CAAC;CAChF,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { CosmListbox } from '@joralvmel/cosmos-elements/listbox';
2
+ import { createComponent } from '@lit/react';
3
+ import * as React from 'react';
4
+ import { flushSync } from 'react-dom';
5
+ /** React event props of `Listbox`, mapped to the original DOM `CustomEvent`. */
6
+ export const listboxEvents = {
7
+ onSelectionChange: 'cosm-selection-change',
8
+ };
9
+ const ListboxElement = createComponent({
10
+ tagName: 'cosm-listbox',
11
+ elementClass: CosmListbox,
12
+ react: React,
13
+ events: listboxEvents,
14
+ displayName: 'ListboxElement',
15
+ });
16
+ /** React wrapper of `<cosm-listbox>`; a supplied selectedValues array, including `[]`, is controlled. */
17
+ export const Listbox = React.forwardRef((props, forwardedRef) => {
18
+ const { selectedValues, onSelectionChange, ...elementProps } = props;
19
+ const handleSelectionChange = React.useCallback((event) => {
20
+ if (onSelectionChange)
21
+ flushSync(() => onSelectionChange(event));
22
+ }, [onSelectionChange]);
23
+ const setRef = React.useCallback((element) => {
24
+ if (element)
25
+ element.selectedValuesControlled = selectedValues !== undefined;
26
+ if (typeof forwardedRef === 'function')
27
+ forwardedRef(element);
28
+ else if (forwardedRef)
29
+ forwardedRef.current = element;
30
+ }, [forwardedRef, selectedValues]);
31
+ return React.createElement(ListboxElement, {
32
+ ...elementProps,
33
+ selectedValues,
34
+ onSelectionChange: handleSelectionChange,
35
+ ref: setRef,
36
+ });
37
+ });
38
+ Listbox.displayName = 'Listbox';
39
+ //# sourceMappingURL=listbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listbox.js","sourceRoot":"","sources":["../../src/components/listbox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,gFAAgF;AAChF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,iBAAiB,EAAE,uBAElB;CACF,CAAC;AAEF,MAAM,cAAc,GAAG,eAAe,CAAC;IACrC,OAAO,EAAE,cAAc;IACvB,YAAY,EAAE,WAAW;IACzB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,aAAa;IACrB,WAAW,EAAE,gBAAgB;CAC9B,CAAC,CAAC;AAIH,yGAAyG;AACzG,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAA4B,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IACzF,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IACrE,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAC7C,CAAC,KAAgD,EAAE,EAAE;QACnD,IAAI,iBAAiB;YAAE,SAAS,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,CAAC,EACD,CAAC,iBAAiB,CAAC,CACpB,CAAC;IACF,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAC9B,CAAC,OAA2B,EAAE,EAAE;QAC9B,IAAI,OAAO;YAAE,OAAO,CAAC,wBAAwB,GAAG,cAAc,KAAK,SAAS,CAAC;QAC7E,IAAI,OAAO,YAAY,KAAK,UAAU;YAAE,YAAY,CAAC,OAAO,CAAC,CAAC;aACzD,IAAI,YAAY;YAAE,YAAY,CAAC,OAAO,GAAG,OAAO,CAAC;IACxD,CAAC,EACD,CAAC,YAAY,EAAE,cAAc,CAAC,CAC/B,CAAC;IACF,OAAO,KAAK,CAAC,aAAa,CAAC,cAAc,EAAE;QACzC,GAAG,YAAY;QACf,cAAc;QACd,iBAAiB,EAAE,qBAAqB;QACxC,GAAG,EAAE,MAAM;KACI,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { PopoverOpenChangeDetail } from '@joralvmel/cosmos-core';
2
+ import { CosmPopover } from '@joralvmel/cosmos-elements/popover';
3
+ import { type EventName } from '@lit/react';
4
+ import * as React from 'react';
5
+ /** React event props of `Popover`, mapped to the original DOM event. */
6
+ export declare const popoverEvents: {
7
+ onOpenChange: EventName<CustomEvent<PopoverOpenChangeDetail>>;
8
+ };
9
+ declare const PopoverElement: import("@lit/react").ReactWebComponent<CosmPopover, {
10
+ onOpenChange: EventName<CustomEvent<PopoverOpenChangeDetail>>;
11
+ }>;
12
+ type ElementProps = React.ComponentProps<typeof PopoverElement>;
13
+ /** React wrapper; a supplied `open` value, including false, is controlled. */
14
+ export declare const Popover: React.ForwardRefExoticComponent<Omit<PopoverProps, "ref"> & React.RefAttributes<CosmPopover>>;
15
+ export type PopoverProps = Omit<ElementProps, 'open' | 'onOpenChange'> & {
16
+ open?: boolean;
17
+ onOpenChange?: (event: CustomEvent<PopoverOpenChangeDetail>) => void;
18
+ };
19
+ export {};
20
+ //# sourceMappingURL=popover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/components/popover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,wEAAwE;AACxE,eAAO,MAAM,aAAa;kBACY,SAAS,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;CACpF,CAAC;AAEF,QAAA,MAAM,cAAc;kBAHkB,SAAS,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;EASnF,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,CAAC;AAEhE,8EAA8E;AAC9E,eAAO,MAAM,OAAO,+FAuBlB,CAAC;AAGH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,CAAC,GAAG;IACvE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,uBAAuB,CAAC,KAAK,IAAI,CAAC;CACtE,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { CosmPopover } from '@joralvmel/cosmos-elements/popover';
2
+ import { createComponent } from '@lit/react';
3
+ import * as React from 'react';
4
+ import { flushSync } from 'react-dom';
5
+ /** React event props of `Popover`, mapped to the original DOM event. */
6
+ export const popoverEvents = {
7
+ onOpenChange: 'cosm-open-change',
8
+ };
9
+ const PopoverElement = createComponent({
10
+ tagName: 'cosm-popover',
11
+ elementClass: CosmPopover,
12
+ react: React,
13
+ events: popoverEvents,
14
+ displayName: 'PopoverElement',
15
+ });
16
+ /** React wrapper; a supplied `open` value, including false, is controlled. */
17
+ export const Popover = React.forwardRef((props, forwardedRef) => {
18
+ const { open, onOpenChange, ...elementProps } = props;
19
+ const handleOpenChange = React.useCallback((event) => {
20
+ if (onOpenChange)
21
+ flushSync(() => onOpenChange(event));
22
+ }, [onOpenChange]);
23
+ const setRef = React.useCallback((element) => {
24
+ if (element)
25
+ element.open = open;
26
+ if (typeof forwardedRef === 'function')
27
+ forwardedRef(element);
28
+ else if (forwardedRef)
29
+ forwardedRef.current = element;
30
+ }, [forwardedRef, open]);
31
+ return React.createElement(PopoverElement, {
32
+ ...elementProps,
33
+ ...(open === undefined ? {} : { open }),
34
+ onOpenChange: handleOpenChange,
35
+ ref: setRef,
36
+ });
37
+ });
38
+ Popover.displayName = 'Popover';
39
+ //# sourceMappingURL=popover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover.js","sourceRoot":"","sources":["../../src/components/popover.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,wEAAwE;AACxE,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,kBAAqE;CACpF,CAAC;AAEF,MAAM,cAAc,GAAG,eAAe,CAAC;IACrC,OAAO,EAAE,cAAc;IACvB,YAAY,EAAE,WAAW;IACzB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,aAAa;IACrB,WAAW,EAAE,gBAAgB;CAC9B,CAAC,CAAC;AAIH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAA4B,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IACzF,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IACtD,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,CACxC,CAAC,KAA2C,EAAE,EAAE;QAC9C,IAAI,YAAY;YAAE,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACzD,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IACF,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAC9B,CAAC,OAA2B,EAAE,EAAE;QAC9B,IAAI,OAAO;YAAE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QACjC,IAAI,OAAO,YAAY,KAAK,UAAU;YAAE,YAAY,CAAC,OAAO,CAAC,CAAC;aACzD,IAAI,YAAY;YAAE,YAAY,CAAC,OAAO,GAAG,OAAO,CAAC;IACxD,CAAC,EACD,CAAC,YAAY,EAAE,IAAI,CAAC,CACrB,CAAC;IAEF,OAAO,KAAK,CAAC,aAAa,CAAC,cAAc,EAAE;QACzC,GAAG,YAAY;QACf,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QACvC,YAAY,EAAE,gBAAgB;QAC9B,GAAG,EAAE,MAAM;KACI,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { TextFieldChangeDetail, TextFieldSubmitDetail } from '@joralvmel/cosmos-core';
2
+ import { CosmTextField } from '@joralvmel/cosmos-elements/text-field';
3
+ import { type EventName } from '@lit/react';
4
+ import * as React from 'react';
5
+ /** React event props of `TextField`, mapped to the original DOM `CustomEvent`s. */
6
+ export declare const textFieldEvents: {
7
+ onChange: EventName<CustomEvent<TextFieldChangeDetail>>;
8
+ onSubmit: EventName<CustomEvent<TextFieldSubmitDetail>>;
9
+ };
10
+ declare const TextFieldElement: import("@lit/react").ReactWebComponent<CosmTextField, {
11
+ onChange: EventName<CustomEvent<TextFieldChangeDetail>>;
12
+ onSubmit: EventName<CustomEvent<TextFieldSubmitDetail>>;
13
+ }>;
14
+ type ElementProps = React.ComponentProps<typeof TextFieldElement>;
15
+ /** React wrapper of `<cosm-text-field>`; binding `value`, including `''`, marks it controlled. */
16
+ export declare const TextField: React.ForwardRefExoticComponent<Omit<TextFieldProps, "ref"> & React.RefAttributes<CosmTextField>>;
17
+ export type TextFieldProps = Omit<ElementProps, 'onChange' | 'onSubmit'> & {
18
+ label: string;
19
+ onChange?: (event: CustomEvent<TextFieldChangeDetail>) => void;
20
+ onSubmit?: (event: CustomEvent<TextFieldSubmitDetail>) => void;
21
+ };
22
+ export {};
23
+ //# sourceMappingURL=text-field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-field.d.ts","sourceRoot":"","sources":["../../src/components/text-field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,mFAAmF;AACnF,eAAO,MAAM,eAAe;cACC,SAAS,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;cAC7C,SAAS,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;CACzE,CAAC;AAEF,QAAA,MAAM,gBAAgB;cAJO,SAAS,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;cAC7C,SAAS,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;EASxE,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAElE,kGAAkG;AAClG,eAAO,MAAM,SAAS,mGAsBpB,CAAC;AAIH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,UAAU,CAAC,GAAG;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,qBAAqB,CAAC,KAAK,IAAI,CAAC;IAC/D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,qBAAqB,CAAC,KAAK,IAAI,CAAC;CAChE,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { CosmTextField } from '@joralvmel/cosmos-elements/text-field';
2
+ import { createComponent } from '@lit/react';
3
+ import * as React from 'react';
4
+ import { flushSync } from 'react-dom';
5
+ /** React event props of `TextField`, mapped to the original DOM `CustomEvent`s. */
6
+ export const textFieldEvents = {
7
+ onChange: 'cosm-change',
8
+ onSubmit: 'cosm-submit',
9
+ };
10
+ const TextFieldElement = createComponent({
11
+ tagName: 'cosm-text-field',
12
+ elementClass: CosmTextField,
13
+ react: React,
14
+ events: textFieldEvents,
15
+ displayName: 'TextFieldElement',
16
+ });
17
+ /** React wrapper of `<cosm-text-field>`; binding `value`, including `''`, marks it controlled. */
18
+ export const TextField = React.forwardRef((props, forwardedRef) => {
19
+ const { value, onChange, ...elementProps } = props;
20
+ const handleChange = React.useCallback((event) => {
21
+ if (onChange)
22
+ flushSync(() => onChange(event));
23
+ }, [onChange]);
24
+ const setRef = React.useCallback((element) => {
25
+ if (element)
26
+ element.valueControlled = value !== undefined;
27
+ if (typeof forwardedRef === 'function')
28
+ forwardedRef(element);
29
+ else if (forwardedRef)
30
+ forwardedRef.current = element;
31
+ }, [forwardedRef, value]);
32
+ return React.createElement(TextFieldElement, {
33
+ ...elementProps,
34
+ value,
35
+ onChange: handleChange,
36
+ ref: setRef,
37
+ });
38
+ });
39
+ TextField.displayName = 'TextField';
40
+ //# sourceMappingURL=text-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-field.js","sourceRoot":"","sources":["../../src/components/text-field.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,mFAAmF;AACnF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,QAAQ,EAAE,aAA8D;IACxE,QAAQ,EAAE,aAA8D;CACzE,CAAC;AAEF,MAAM,gBAAgB,GAAG,eAAe,CAAC;IACvC,OAAO,EAAE,iBAAiB;IAC1B,YAAY,EAAE,aAAa;IAC3B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,eAAe;IACvB,WAAW,EAAE,kBAAkB;CAChC,CAAC,CAAC;AAIH,kGAAkG;AAClG,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAgC,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IAC/F,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IACnD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CACpC,CAAC,KAAyC,EAAE,EAAE;QAC5C,IAAI,QAAQ;YAAE,SAAS,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IACF,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAC9B,CAAC,OAA6B,EAAE,EAAE;QAChC,IAAI,OAAO;YAAE,OAAO,CAAC,eAAe,GAAG,KAAK,KAAK,SAAS,CAAC;QAC3D,IAAI,OAAO,YAAY,KAAK,UAAU;YAAE,YAAY,CAAC,OAAO,CAAC,CAAC;aACzD,IAAI,YAAY;YAAE,YAAY,CAAC,OAAO,GAAG,OAAO,CAAC;IACxD,CAAC,EACD,CAAC,YAAY,EAAE,KAAK,CAAC,CACtB,CAAC;IACF,OAAO,KAAK,CAAC,aAAa,CAAC,gBAAgB,EAAE;QAC3C,GAAG,YAAY;QACf,KAAK;QACL,QAAQ,EAAE,YAAY;QACtB,GAAG,EAAE,MAAM;KACI,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
- export type { ButtonPressDetail, PressSource } from '@joralvmel/cosmos-core';
1
+ export type { ButtonPressDetail, ListboxSelectionChangeDetail, PressSource, TextFieldChangeDetail, TextFieldSubmitDetail, } from '@joralvmel/cosmos-core';
2
2
  export { Button, type ButtonProps, buttonEvents } from './components/button.js';
3
+ export { Icon, type IconProps, iconEvents } from './components/icon.js';
4
+ export { IconButton, type IconButtonProps, iconButtonEvents } from './components/icon-button.js';
5
+ export { Listbox, type ListboxProps, listboxEvents } from './components/listbox.js';
6
+ export { Popover, type PopoverProps, popoverEvents } from './components/popover.js';
7
+ export { TextField, type TextFieldProps, textFieldEvents } from './components/text-field.js';
3
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,4BAA4B,EAC5B,WAAW,EACX,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACjG,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,7 @@
1
1
  export { Button, buttonEvents } from './components/button.js';
2
+ export { Icon, iconEvents } from './components/icon.js';
3
+ export { IconButton, iconButtonEvents } from './components/icon-button.js';
4
+ export { Listbox, listboxEvents } from './components/listbox.js';
5
+ export { Popover, popoverEvents } from './components/popover.js';
6
+ export { TextField, textFieldEvents } from './components/text-field.js';
2
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAoB,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAoB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAkB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAwB,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACjG,OAAO,EAAE,OAAO,EAAqB,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,OAAO,EAAqB,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAuB,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
package/llms.md CHANGED
@@ -111,6 +111,198 @@ export function Example() {
111
111
  );
112
112
  }
113
113
  ```
114
+ ### `Icon`
115
+
116
+ Renders a structured SVG icon. Decorative icons are hidden from assistive technology; informative icons require a text label.
117
+
118
+ | Prop | Type | Default | Description |
119
+ | --- | --- | --- | --- |
120
+ | `icon` | IconDefinition | Required | Structured icon definition, commonly imported from @joralvmel/cosmos-icons. |
121
+ | `size` | 'sm' \| 'md' \| 'lg' \| number | `md` | Semantic size (16, 20 or 24) or a positive finite number in pixels / native units. |
122
+ | `stroke` | string | `currentColor` | Stroke paint; currentColor inherits on web and resolves to the theme foreground on native. |
123
+ | `fill` | string | `none` | Root fill paint. Explicit node fills take precedence. |
124
+ | `strokeWidth` | number | `2` | Finite nonnegative stroke width in SVG viewBox units. |
125
+ | `label` | string | — | Accessible name required when decorative is false. |
126
+ | `decorative` | boolean | `true` | Hides the icon from assistive technology when true. |
127
+
128
+ Events: none.
129
+
130
+ ```tsx
131
+ import { Icon } from '@joralvmel/cosmos-react';
132
+ import { house } from '@joralvmel/cosmos-icons/house';
133
+
134
+ export function Example() {
135
+ return (
136
+ <Icon icon={house}></Icon>
137
+ );
138
+ }
139
+ ```
140
+ ### `TextField`
141
+
142
+ Accepts a single line of text with an accessible label, optional help and error text, and native form validation on the web.
143
+
144
+ | Prop | Type | Default | Description |
145
+ | --- | --- | --- | --- |
146
+ | `label` | string | Required | Accessible name for the editable control. It is rendered above the control unless visually hidden. |
147
+ | `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |
148
+ | `value` | string | — | Current text. When bound, edits are proposals and the component waits for the owner to supply the accepted value. |
149
+ | `defaultValue` | string | `` | Initial value for autonomous use. Web form reset restores this value; it does not control subsequent edits. |
150
+ | `type` | 'text' \| 'email' \| 'password' \| 'tel' \| 'url' \| 'search' | `text` | Single-line input type. Native maps it to supported keyboard, autofill and secure-entry behavior. |
151
+ | `variant` | 'outlined' \| 'filled' | `outlined` | Visual treatment of the editable control. |
152
+ | `size` | 'sm' \| 'md' \| 'lg' \| number | `md` | Semantic size or a positive finite minimum editable-control height in CSS pixels on web and logical units on native. |
153
+ | `placeholder` | string | — | Short input hint; it never replaces the accessible label. |
154
+ | `helpText` | string | — | Optional supporting text associated with the editable control. |
155
+ | `error` | string | — | Optional externally supplied error text associated with the editable control. |
156
+ | `invalid` | boolean | `false` | External invalid state, independent of browser constraints or consumer business validation. |
157
+ | `required` | boolean | `false` | Exposes required semantics. On web, participates in native HTML constraint validation. |
158
+ | `disabled` | boolean | `false` | Disables editing and interaction. On web, follows disabled fieldsets and excludes the value from form submission. |
159
+ | `readOnly` | boolean | `false` | Prevents editing while remaining focusable and form-submittable on web; distinct from disabled. |
160
+ | `minLength` | number | — | Minimum number of characters. Web uses native HTML validity; native business validation remains the consumer’s responsibility. |
161
+ | `maxLength` | number | — | Maximum number of characters. Web uses native HTML validity and native applies supported input limits. |
162
+ | `pattern` | string | — | Web-only HTML pattern constraint. Native does not emulate HTML regular-expression validation. |
163
+ | `name` | string | — | Form field name on web. React Native has no HTML form association or name-based submission. |
164
+ | `autoComplete` | string | — | Consumer-provided completion/autofill hint, mapped to attributes supported by each platform. |
165
+ | `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. |
166
+ | `startIcon` | IconDefinition | — | Optional structured decorative icon before the editable text. |
167
+ | `endIcon` | IconDefinition | — | Optional structured decorative icon after the editable text. |
168
+ | `iconFocusScope` | 'control' \| 'input' | `control` | When configured icon focus colors apply: control includes the input and clear/reveal buttons; input includes only the editable input. Does not change icons without a focus-color override. |
169
+ | `prefix` | string | — | Optional non-interactive text decoration before the editable text. |
170
+ | `suffix` | string | — | Optional non-interactive text decoration after the editable text. |
171
+ | `clearable` | boolean | `false` | Shows a clear action for non-empty editable fields. Supply clearLabel when enabled. |
172
+ | `clearLabel` | string | — | Consumer-supplied localized accessible name for the clear action. |
173
+ | `passwordReveal` | boolean | `false` | Opts into a reveal action for password fields. Supply both revealPasswordLabel and hidePasswordLabel when enabled. |
174
+ | `revealPasswordLabel` | string | — | Consumer-supplied localized accessible name while the password is concealed. |
175
+ | `hidePasswordLabel` | string | — | Consumer-supplied localized accessible name while the password is revealed. |
176
+
177
+ Events: `onChange` → `TextFieldChangeDetail`, `onSubmit` → `TextFieldSubmitDetail`.
178
+
179
+ ```tsx
180
+ import { TextField } from '@joralvmel/cosmos-react';
181
+ import { search } from '@joralvmel/cosmos-icons/search';
182
+
183
+ export function Example() {
184
+ return (
185
+ <TextField
186
+ label="TextField"
187
+ startIcon={search}
188
+ endIcon={search}
189
+ onChange={event => console.log(event.detail)}
190
+ onSubmit={event => console.log(event.detail)}
191
+ >
192
+ </TextField>
193
+ );
194
+ }
195
+ ```
196
+ ### `IconButton`
197
+
198
+ Activates an action or toggles a boolean state using a labeled icon.
199
+
200
+ | Prop | Type | Default | Description |
201
+ | --- | --- | --- | --- |
202
+ | `label` | string | Required | Required localized accessible name. Missing, empty or whitespace-only labels are rejected. |
203
+ | `mode` | 'action' \| 'toggle' | `action` | Action activates without toggle state; toggle exposes and changes pressed state. |
204
+ | `variant` | 'solid' \| 'soft' \| 'outline' \| 'ghost' | `solid` | Visual emphasis, from highest (solid) to lowest (ghost). |
205
+ | `tone` | 'primary' \| 'neutral' \| 'danger' | `primary` | Color role. Use danger for destructive actions. |
206
+ | `size` | 'sm' \| 'md' \| 'lg' | `md` | Size of the square visual control. |
207
+ | `disabled` | boolean | `false` | Prevents activation and removes the web button from the tab order. |
208
+ | `type` | 'button' \| 'submit' \| 'reset' | `button` | Native web button form behavior. |
209
+ | `pressed` | boolean | `false` | Toggle state. If supplied, including false, activation proposes changes without committing them until the owner updates this prop. |
210
+ | `defaultPressed` | boolean | `false` | Initial toggle state when pressed is not supplied; it does not control later changes. |
211
+
212
+ Events: `onPress` → `IconButtonPressDetail`, `onPressedChange` → `IconButtonPressedChangeDetail`.
213
+
214
+ ```tsx
215
+ import { heart } from '@joralvmel/cosmos-icons/heart';
216
+ import { IconButton, Icon } from '@joralvmel/cosmos-react';
217
+
218
+ export function Example() {
219
+ return (
220
+ <IconButton
221
+ label="IconButton"
222
+ onPress={event => console.log(event.detail)}
223
+ onPressedChange={event => console.log(event.detail)}
224
+ >
225
+ <Icon icon={heart}></Icon>
226
+ </IconButton>
227
+ );
228
+ }
229
+ ```
230
+ ### `Popover`
231
+
232
+ Non-modal content anchored to a consumer trigger, with cancelable close requests and no imposed panel semantics.
233
+
234
+ | Prop | Type | Default | Description |
235
+ | --- | --- | --- | --- |
236
+ | `open` | boolean | `false` | Committed visibility. Supplying this prop, including false, controls state; its metadata default does not establish a binding. |
237
+ | `defaultOpen` | boolean | `false` | Initial autonomous visibility only; ignored when open is supplied. Later updates do not reset state. |
238
+ | `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. |
239
+ | `closable` | boolean | `false` | Shows a built-in IconButton with an X. Requests a cancelable close with reason close-button. |
240
+ | `closeLabel` | string | `Close` | Localized accessible name of the close button. Must be non-empty when closable is true. |
241
+ | `gap` | number | `8` | Non-negative finite distance from trigger to panel, or to the arrow tip. CSS pixels on web, logical units on native. Viewport/safe-area collision handling takes priority. |
242
+ | `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. |
243
+ | `closeOnEscape` | boolean | `true` | Requests closure on unhandled Escape on web and React Native Web. Native Android and iOS hardware Escape is not supported. |
244
+ | `closeOnOutsidePress` | boolean | `true` | Requests closure on an outside press without preventing its interaction or restoring trigger focus. |
245
+ | `initialFocus` | boolean | `false` | On committed opening (including initially open), focus the first focusable panel descendant, falling back to the panel without adding semantics. False leaves focus unchanged. Native moves accessible/input focus where supported. |
246
+ | `restoreFocus` | boolean | `true` | After committed trigger, Escape, action or Back closure, restore focus only if still inside the panel and the trigger is connected and focusable. Never steal outside focus, restore after outside press, or restore for unsolicited prop closure. |
247
+ | `side` | 'top' \| 'right' \| 'bottom' \| 'left' | `bottom` | Requested physical side; actual placement may flip. Recompute for trigger/panel size, viewport/safe-area, scrolling and orientation changes. |
248
+ | `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. |
249
+ | `flip` | boolean | `true` | Try the opposite side when the requested side overflows the available viewport/safe area; flip only if it reduces main-axis overflow. Ties keep the requested side. Runs before shift. |
250
+ | `shift` | boolean | `true` | After flip, translate within available viewport/safe-area bounds to reduce overflow. Constrain oversized panels to that region regardless of collision flags; flags never change requested props. |
251
+
252
+ Events: `onOpenChange` → `PopoverOpenChangeDetail`.
253
+
254
+ ```tsx
255
+ import { Popover, IconButton, Icon } from '@joralvmel/cosmos-react';
256
+ import { info } from '@joralvmel/cosmos-icons/info';
257
+
258
+ export function Example() {
259
+ return (
260
+ <Popover
261
+ onOpenChange={event => console.log(event.detail)}
262
+ >
263
+ <IconButton slot="trigger" label="Details" variant="ghost" tone="neutral"><Icon icon={info} /></IconButton>
264
+ Popover
265
+ </Popover>
266
+ );
267
+ }
268
+ ```
269
+ ### `Listbox`
270
+
271
+ Selects one or more values from a named vertical collection, with groups, descriptions, icons and independent keyboard focus.
272
+
273
+ | Prop | Type | Default | Description |
274
+ | --- | --- | --- | --- |
275
+ | `label` | string | Required | Required nonempty accessible label, visible unless labelHidden is true. |
276
+ | `labelHidden` | boolean | `false` | Visually hides the label without removing its accessible name. |
277
+ | `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. |
278
+ | `selectionMode` | 'single' \| 'multiple' | `single` | Single permits at most one selected value; multiple toggles each activation. |
279
+ | `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. |
280
+ | `defaultSelectedValues` | ListboxValues | — | Initial autonomous selected values (empty by default). Later changes do not reset selection. |
281
+ | `variant` | 'plain' \| 'outlined' | `plain` | Plain composes inside a panel; outlined adds a standalone container boundary. |
282
+ | `size` | 'sm' \| 'md' \| 'lg' \| number | `md` | Semantic size or a positive finite minimum option height in CSS pixels/native logical units. Content may grow; native touch targets remain at least 44. |
283
+ | `disabled` | boolean | `false` | Prevents interaction and removes the list from keyboard navigation. |
284
+ | `readOnly` | boolean | `false` | Allows exploring options without proposing or committing selection changes. |
285
+ | `locale` | string | — | BCP 47 locale for typeahead. Web inherits the nearest language; native uses the runtime locale when omitted. Invalid locale identifiers are rejected. |
286
+
287
+ Events: `onSelectionChange` → `ListboxSelectionChangeDetail`.
288
+
289
+ ```tsx
290
+ import { Listbox } from '@joralvmel/cosmos-react';
291
+ 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;
292
+ const empty = [] as const;
293
+
294
+ export function Example() {
295
+ return (
296
+ <Listbox
297
+ label="Listbox"
298
+ items={grouped}
299
+ defaultSelectedValues={empty}
300
+ onSelectionChange={event => console.log(event.detail)}
301
+ >
302
+ </Listbox>
303
+ );
304
+ }
305
+ ```
114
306
 
115
307
  ## Themes
116
308
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joralvmel/cosmos-react",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "React wrappers for the Cosmos UI Web Components (React 19, Vite, Next.js).",
5
5
  "keywords": [
6
6
  "react",
@@ -42,13 +42,14 @@
42
42
  "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
43
43
  },
44
44
  "dependencies": {
45
- "@joralvmel/cosmos-core": "^0.1.0",
46
- "@joralvmel/cosmos-elements": "^0.1.0",
45
+ "@joralvmel/cosmos-core": "^0.3.0",
46
+ "@joralvmel/cosmos-elements": "^0.3.0",
47
47
  "@lit/react": "^1.0.8"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@types/react": "^19.0.0",
51
- "react": "^19.0.0"
51
+ "react": "^19.0.0",
52
+ "react-dom": "^19.0.0"
52
53
  },
53
54
  "peerDependenciesMeta": {
54
55
  "@types/react": {