@joralvmel/cosmos-react 0.3.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 +16 -3
- package/dist/components/badge.d.ts +8 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +14 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/calendar.d.ts +20 -0
- package/dist/components/calendar.d.ts.map +1 -0
- package/dist/components/calendar.js +39 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/checkbox.d.ts +21 -0
- package/dist/components/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox.js +39 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/dialog.d.ts +24 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +39 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/pagination.d.ts +21 -0
- package/dist/components/pagination.d.ts.map +1 -0
- package/dist/components/pagination.js +39 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/radio-group.d.ts +23 -0
- package/dist/components/radio-group.d.ts.map +1 -0
- package/dist/components/radio-group.js +40 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/select.d.ts +23 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +39 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/switch.d.ts +21 -0
- package/dist/components/switch.d.ts.map +1 -0
- package/dist/components/switch.js +39 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/textarea.d.ts +20 -0
- package/dist/components/textarea.d.ts.map +1 -0
- package/dist/components/textarea.js +39 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/llms.md +324 -20
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -45,10 +45,23 @@ value, so ordinary synchronous `setState` handlers do not lose rapid keystrokes.
|
|
|
45
45
|
need to call `flushSync`; deferred updates still leave the previous controlled value in place
|
|
46
46
|
until the owner accepts the proposal.
|
|
47
47
|
|
|
48
|
+
For multiline plain text, use `Textarea`. It uses the same controlled-value event contract and
|
|
49
|
+
preserves native newline behavior:
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { Textarea } from '@joralvmel/cosmos-react';
|
|
53
|
+
|
|
54
|
+
<Textarea
|
|
55
|
+
label="Message"
|
|
56
|
+
value={message}
|
|
57
|
+
onChange={event => setMessage(event.detail.value)}
|
|
58
|
+
rows={4}
|
|
59
|
+
/>;
|
|
60
|
+
```
|
|
61
|
+
|
|
48
62
|
For independent icon colors, put the text-field CSS hooks on a `className` or `style`:
|
|
49
|
-
`--cosm-text-field-start-icon-color
|
|
50
|
-
|
|
51
|
-
focus colors to the editable input. Focus overrides are optional and do not recolor action icons.
|
|
63
|
+
`--cosm-text-field-start-icon-color` and `--cosm-text-field-end-icon-color`. They do not recolor
|
|
64
|
+
affixes or action icons.
|
|
52
65
|
|
|
53
66
|
## License
|
|
54
67
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CosmBadge } from '@joralvmel/cosmos-elements/badge';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/** Badge has no events. */
|
|
4
|
+
export declare const badgeEvents: {};
|
|
5
|
+
/** React wrapper of `<cosm-badge>`. */
|
|
6
|
+
export declare const Badge: import("@lit/react").ReactWebComponent<CosmBadge, {}>;
|
|
7
|
+
export type BadgeProps = React.ComponentProps<typeof Badge>;
|
|
8
|
+
//# sourceMappingURL=badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../src/components/badge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,2BAA2B;AAC3B,eAAO,MAAM,WAAW,IAAK,CAAC;AAE9B,uCAAuC;AACvC,eAAO,MAAM,KAAK,uDAMhB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CosmBadge } from '@joralvmel/cosmos-elements/badge';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
/** Badge has no events. */
|
|
5
|
+
export const badgeEvents = {};
|
|
6
|
+
/** React wrapper of `<cosm-badge>`. */
|
|
7
|
+
export const Badge = createComponent({
|
|
8
|
+
tagName: 'cosm-badge',
|
|
9
|
+
elementClass: CosmBadge,
|
|
10
|
+
react: React,
|
|
11
|
+
events: badgeEvents,
|
|
12
|
+
displayName: 'Badge',
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=badge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.js","sourceRoot":"","sources":["../../src/components/badge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,2BAA2B;AAC3B,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B,uCAAuC;AACvC,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAC;IACnC,OAAO,EAAE,YAAY;IACrB,YAAY,EAAE,SAAS;IACvB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,WAAW;IACnB,WAAW,EAAE,OAAO;CACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CalendarChangeDetail } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { CosmCalendar } from '@joralvmel/cosmos-elements/calendar';
|
|
3
|
+
import { type EventName } from '@lit/react';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
/** React event props of `Calendar`, mapped to the original DOM `CustomEvent`. */
|
|
6
|
+
export declare const calendarEvents: {
|
|
7
|
+
onChange: EventName<CustomEvent<CalendarChangeDetail>>;
|
|
8
|
+
};
|
|
9
|
+
declare const CalendarElement: import("@lit/react").ReactWebComponent<CosmCalendar, {
|
|
10
|
+
onChange: EventName<CustomEvent<CalendarChangeDetail>>;
|
|
11
|
+
}>;
|
|
12
|
+
type ElementProps = React.ComponentProps<typeof CalendarElement>;
|
|
13
|
+
/** React wrapper; binding `value` marks selection as controlled. */
|
|
14
|
+
export declare const Calendar: React.ForwardRefExoticComponent<Omit<CalendarProps, "ref"> & React.RefAttributes<CosmCalendar>>;
|
|
15
|
+
export type CalendarProps = Omit<ElementProps, 'onChange'> & {
|
|
16
|
+
value?: string;
|
|
17
|
+
onChange?: (event: CustomEvent<CalendarChangeDetail>) => void;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=calendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../src/components/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,iFAAiF;AACjF,eAAO,MAAM,cAAc;cACE,SAAS,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;CACxE,CAAC;AAEF,QAAA,MAAM,eAAe;cAHQ,SAAS,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;EASvE,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,CAAC;AAEjE,oEAAoE;AACpE,eAAO,MAAM,QAAQ,iGAsBnB,CAAC;AAIH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;CAC/D,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CosmCalendar } from '@joralvmel/cosmos-elements/calendar';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
/** React event props of `Calendar`, mapped to the original DOM `CustomEvent`. */
|
|
6
|
+
export const calendarEvents = {
|
|
7
|
+
onChange: 'cosm-change',
|
|
8
|
+
};
|
|
9
|
+
const CalendarElement = createComponent({
|
|
10
|
+
tagName: 'cosm-calendar',
|
|
11
|
+
elementClass: CosmCalendar,
|
|
12
|
+
react: React,
|
|
13
|
+
events: calendarEvents,
|
|
14
|
+
displayName: 'CalendarElement',
|
|
15
|
+
});
|
|
16
|
+
/** React wrapper; binding `value` marks selection as controlled. */
|
|
17
|
+
export const Calendar = React.forwardRef((props, forwardedRef) => {
|
|
18
|
+
const { value, onChange, ...elementProps } = props;
|
|
19
|
+
const handleChange = React.useCallback((event) => {
|
|
20
|
+
if (onChange)
|
|
21
|
+
flushSync(() => onChange(event));
|
|
22
|
+
}, [onChange]);
|
|
23
|
+
const setRef = React.useCallback((element) => {
|
|
24
|
+
if (element)
|
|
25
|
+
element.valueControlled = value !== undefined;
|
|
26
|
+
if (typeof forwardedRef === 'function')
|
|
27
|
+
forwardedRef(element);
|
|
28
|
+
else if (forwardedRef)
|
|
29
|
+
forwardedRef.current = element;
|
|
30
|
+
}, [forwardedRef, value]);
|
|
31
|
+
return React.createElement(CalendarElement, {
|
|
32
|
+
...elementProps,
|
|
33
|
+
value,
|
|
34
|
+
onChange: handleChange,
|
|
35
|
+
ref: setRef,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
Calendar.displayName = 'Calendar';
|
|
39
|
+
//# sourceMappingURL=calendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../src/components/calendar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,iFAAiF;AACjF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,QAAQ,EAAE,aAA6D;CACxE,CAAC;AAEF,MAAM,eAAe,GAAG,eAAe,CAAC;IACtC,OAAO,EAAE,eAAe;IACxB,YAAY,EAAE,YAAY;IAC1B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,cAAc;IACtB,WAAW,EAAE,iBAAiB;CAC/B,CAAC,CAAC;AAIH,oEAAoE;AACpE,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAA8B,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IAC5F,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IACnD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CACpC,CAAC,KAAwC,EAAE,EAAE;QAC3C,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,OAA4B,EAAE,EAAE;QAC/B,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,eAAe,EAAE;QAC1C,GAAG,YAAY;QACf,KAAK;QACL,QAAQ,EAAE,YAAY;QACtB,GAAG,EAAE,MAAM;KACI,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CheckboxCheckedChangeDetail } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { CosmCheckbox } from '@joralvmel/cosmos-elements/checkbox';
|
|
3
|
+
import { type EventName } from '@lit/react';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
/** React event props of `Checkbox`, mapped to the original DOM `CustomEvent`. */
|
|
6
|
+
export declare const checkboxEvents: {
|
|
7
|
+
onCheckedChange: EventName<CustomEvent<CheckboxCheckedChangeDetail>>;
|
|
8
|
+
};
|
|
9
|
+
declare const CheckboxElement: import("@lit/react").ReactWebComponent<CosmCheckbox, {
|
|
10
|
+
onCheckedChange: EventName<CustomEvent<CheckboxCheckedChangeDetail>>;
|
|
11
|
+
}>;
|
|
12
|
+
type ElementProps = React.ComponentProps<typeof CheckboxElement>;
|
|
13
|
+
/** React wrapper; a supplied checked value, including false, is controlled. */
|
|
14
|
+
export declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & React.RefAttributes<CosmCheckbox>>;
|
|
15
|
+
export type CheckboxProps = Omit<ElementProps, 'onCheckedChange'> & {
|
|
16
|
+
label: string;
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
onCheckedChange?: (event: CustomEvent<CheckboxCheckedChangeDetail>) => void;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/components/checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,iFAAiF;AACjF,eAAO,MAAM,cAAc;qBACiB,SAAS,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAAC;CAC9F,CAAC;AAEF,QAAA,MAAM,eAAe;qBAHuB,SAAS,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAAC;EAS7F,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,CAAC;AAEjE,+EAA+E;AAC/E,eAAO,MAAM,QAAQ,iGAsBnB,CAAC;AAIH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC,GAAG;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,2BAA2B,CAAC,KAAK,IAAI,CAAC;CAC7E,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CosmCheckbox } from '@joralvmel/cosmos-elements/checkbox';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
/** React event props of `Checkbox`, mapped to the original DOM `CustomEvent`. */
|
|
6
|
+
export const checkboxEvents = {
|
|
7
|
+
onCheckedChange: 'cosm-checked-change',
|
|
8
|
+
};
|
|
9
|
+
const CheckboxElement = createComponent({
|
|
10
|
+
tagName: 'cosm-checkbox',
|
|
11
|
+
elementClass: CosmCheckbox,
|
|
12
|
+
react: React,
|
|
13
|
+
events: checkboxEvents,
|
|
14
|
+
displayName: 'CheckboxElement',
|
|
15
|
+
});
|
|
16
|
+
/** React wrapper; a supplied checked value, including false, is controlled. */
|
|
17
|
+
export const Checkbox = React.forwardRef((props, forwardedRef) => {
|
|
18
|
+
const { checked, onCheckedChange, ...elementProps } = props;
|
|
19
|
+
const handleCheckedChange = React.useCallback((event) => {
|
|
20
|
+
if (onCheckedChange)
|
|
21
|
+
flushSync(() => onCheckedChange(event));
|
|
22
|
+
}, [onCheckedChange]);
|
|
23
|
+
const setRef = React.useCallback((element) => {
|
|
24
|
+
if (element)
|
|
25
|
+
element.checkedControlled = checked !== undefined;
|
|
26
|
+
if (typeof forwardedRef === 'function')
|
|
27
|
+
forwardedRef(element);
|
|
28
|
+
else if (forwardedRef)
|
|
29
|
+
forwardedRef.current = element;
|
|
30
|
+
}, [checked, forwardedRef]);
|
|
31
|
+
return React.createElement(CheckboxElement, {
|
|
32
|
+
...elementProps,
|
|
33
|
+
checked,
|
|
34
|
+
onCheckedChange: handleCheckedChange,
|
|
35
|
+
ref: setRef,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
Checkbox.displayName = 'Checkbox';
|
|
39
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../src/components/checkbox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,iFAAiF;AACjF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,eAAe,EAAE,qBAA4E;CAC9F,CAAC;AAEF,MAAM,eAAe,GAAG,eAAe,CAAC;IACtC,OAAO,EAAE,eAAe;IACxB,YAAY,EAAE,YAAY;IAC1B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,cAAc;IACtB,WAAW,EAAE,iBAAiB;CAC/B,CAAC,CAAC;AAIH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAA8B,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IAC5F,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IAC5D,MAAM,mBAAmB,GAAG,KAAK,CAAC,WAAW,CAC3C,CAAC,KAA+C,EAAE,EAAE;QAClD,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,OAA4B,EAAE,EAAE;QAC/B,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,OAAO,EAAE,YAAY,CAAC,CACxB,CAAC;IACF,OAAO,KAAK,CAAC,aAAa,CAAC,eAAe,EAAE;QAC1C,GAAG,YAAY;QACf,OAAO;QACP,eAAe,EAAE,mBAAmB;QACpC,GAAG,EAAE,MAAM;KACI,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DialogOpenChangeDetail, DialogSize } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { CosmDialog } from '@joralvmel/cosmos-elements/dialog';
|
|
3
|
+
import { type EventName } from '@lit/react';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
/** React event props of `Dialog`, mapped to the original DOM event. */
|
|
6
|
+
export declare const dialogEvents: {
|
|
7
|
+
onOpenChange: EventName<CustomEvent<DialogOpenChangeDetail>>;
|
|
8
|
+
};
|
|
9
|
+
declare const DialogElement: import("@lit/react").ReactWebComponent<CosmDialog, {
|
|
10
|
+
onOpenChange: EventName<CustomEvent<DialogOpenChangeDetail>>;
|
|
11
|
+
}>;
|
|
12
|
+
type ElementProps = React.ComponentProps<typeof DialogElement>;
|
|
13
|
+
type DialogLayoutProps = {
|
|
14
|
+
size?: DialogSize;
|
|
15
|
+
responsiveFullscreen?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** React wrapper; a supplied `open` value, including false, is controlled. */
|
|
18
|
+
export declare const Dialog: React.ForwardRefExoticComponent<Omit<DialogProps, "ref"> & React.RefAttributes<CosmDialog>>;
|
|
19
|
+
export type DialogProps = Omit<ElementProps, 'open' | 'onOpenChange' | keyof DialogLayoutProps> & {
|
|
20
|
+
open?: boolean;
|
|
21
|
+
onOpenChange?: (event: CustomEvent<DialogOpenChangeDetail>) => void;
|
|
22
|
+
} & DialogLayoutProps;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/components/dialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,uEAAuE;AACvE,eAAO,MAAM,YAAY;kBACa,SAAS,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;CACnF,CAAC;AAEF,QAAA,MAAM,aAAa;kBAHmB,SAAS,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;EASlF,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC;AAE/D,KAAK,iBAAiB,GAAG;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,MAAM,6FAuBjB,CAAC;AAGH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,GAAG,MAAM,iBAAiB,CAAC,GAAG;IAChG,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,sBAAsB,CAAC,KAAK,IAAI,CAAC;CACrE,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CosmDialog } from '@joralvmel/cosmos-elements/dialog';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
/** React event props of `Dialog`, mapped to the original DOM event. */
|
|
6
|
+
export const dialogEvents = {
|
|
7
|
+
onOpenChange: 'cosm-open-change',
|
|
8
|
+
};
|
|
9
|
+
const DialogElement = createComponent({
|
|
10
|
+
tagName: 'cosm-dialog',
|
|
11
|
+
elementClass: CosmDialog,
|
|
12
|
+
react: React,
|
|
13
|
+
events: dialogEvents,
|
|
14
|
+
displayName: 'DialogElement',
|
|
15
|
+
});
|
|
16
|
+
/** React wrapper; a supplied `open` value, including false, is controlled. */
|
|
17
|
+
export const Dialog = 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(DialogElement, {
|
|
32
|
+
...elementProps,
|
|
33
|
+
...(open === undefined ? {} : { open }),
|
|
34
|
+
onOpenChange: handleOpenChange,
|
|
35
|
+
ref: setRef,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
Dialog.displayName = 'Dialog';
|
|
39
|
+
//# sourceMappingURL=dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/components/dialog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,uEAAuE;AACvE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,YAAY,EAAE,kBAAoE;CACnF,CAAC;AAEF,MAAM,aAAa,GAAG,eAAe,CAAC;IACpC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,UAAU;IACxB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,YAAY;IACpB,WAAW,EAAE,eAAe;CAC7B,CAAC,CAAC;AASH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAA0B,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IACtF,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IACtD,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,CACxC,CAAC,KAA0C,EAAE,EAAE;QAC7C,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,OAA0B,EAAE,EAAE;QAC7B,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,aAAa,EAAE;QACxC,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,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PaginationChangeDetail } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { CosmPagination } from '@joralvmel/cosmos-elements/pagination';
|
|
3
|
+
import { type EventName } from '@lit/react';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
/** Original DOM events forwarded by the React adapter. */
|
|
6
|
+
export declare const paginationEvents: {
|
|
7
|
+
onChange: EventName<CustomEvent<PaginationChangeDetail>>;
|
|
8
|
+
};
|
|
9
|
+
declare const PaginationElement: import("@lit/react").ReactWebComponent<CosmPagination, {
|
|
10
|
+
onChange: EventName<CustomEvent<PaginationChangeDetail>>;
|
|
11
|
+
}>;
|
|
12
|
+
type ElementProps = React.ComponentProps<typeof PaginationElement>;
|
|
13
|
+
/** Supplying page keeps state with the owner, including a page of one. */
|
|
14
|
+
export declare const Pagination: React.ForwardRefExoticComponent<Omit<PaginationProps, "ref"> & React.RefAttributes<CosmPagination>>;
|
|
15
|
+
export type PaginationProps = Omit<ElementProps, 'onChange'> & {
|
|
16
|
+
label: string;
|
|
17
|
+
totalPages: number;
|
|
18
|
+
onChange?: (event: CustomEvent<PaginationChangeDetail>) => void;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/components/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,0DAA0D;AAC1D,eAAO,MAAM,gBAAgB;cACA,SAAS,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;CAC1E,CAAC;AAEF,QAAA,MAAM,iBAAiB;cAHM,SAAS,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;EASzE,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE,0EAA0E;AAC1E,eAAO,MAAM,UAAU,qGAsBrB,CAAC;AAGH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,sBAAsB,CAAC,KAAK,IAAI,CAAC;CACjE,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CosmPagination } from '@joralvmel/cosmos-elements/pagination';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
/** Original DOM events forwarded by the React adapter. */
|
|
6
|
+
export const paginationEvents = {
|
|
7
|
+
onChange: 'cosm-change',
|
|
8
|
+
};
|
|
9
|
+
const PaginationElement = createComponent({
|
|
10
|
+
tagName: 'cosm-pagination',
|
|
11
|
+
elementClass: CosmPagination,
|
|
12
|
+
react: React,
|
|
13
|
+
events: paginationEvents,
|
|
14
|
+
displayName: 'PaginationElement',
|
|
15
|
+
});
|
|
16
|
+
/** Supplying page keeps state with the owner, including a page of one. */
|
|
17
|
+
export const Pagination = React.forwardRef((props, ref) => {
|
|
18
|
+
const { page, onChange, ...rest } = props;
|
|
19
|
+
const handleChange = React.useCallback((event) => {
|
|
20
|
+
if (onChange)
|
|
21
|
+
flushSync(() => onChange(event));
|
|
22
|
+
}, [onChange]);
|
|
23
|
+
const setRef = React.useCallback((element) => {
|
|
24
|
+
if (element)
|
|
25
|
+
element.pageControlled = page !== undefined;
|
|
26
|
+
if (typeof ref === 'function')
|
|
27
|
+
ref(element);
|
|
28
|
+
else if (ref)
|
|
29
|
+
ref.current = element;
|
|
30
|
+
}, [page, ref]);
|
|
31
|
+
return React.createElement(PaginationElement, {
|
|
32
|
+
...rest,
|
|
33
|
+
page,
|
|
34
|
+
onChange: handleChange,
|
|
35
|
+
ref: setRef,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
Pagination.displayName = 'Pagination';
|
|
39
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/components/pagination.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,aAA+D;CAC1E,CAAC;AAEF,MAAM,iBAAiB,GAAG,eAAe,CAAC;IACxC,OAAO,EAAE,iBAAiB;IAC1B,YAAY,EAAE,cAAc;IAC5B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,gBAAgB;IACxB,WAAW,EAAE,mBAAmB;CACjC,CAAC,CAAC;AAIH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAkC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACzF,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC1C,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CACpC,CAAC,KAA0C,EAAE,EAAE;QAC7C,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,OAA8B,EAAE,EAAE;QACjC,IAAI,OAAO;YAAE,OAAO,CAAC,cAAc,GAAG,IAAI,KAAK,SAAS,CAAC;QACzD,IAAI,OAAO,GAAG,KAAK,UAAU;YAAE,GAAG,CAAC,OAAO,CAAC,CAAC;aACvC,IAAI,GAAG;YAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IACtC,CAAC,EACD,CAAC,IAAI,EAAE,GAAG,CAAC,CACZ,CAAC;IACF,OAAO,KAAK,CAAC,aAAa,CAAC,iBAAiB,EAAE;QAC5C,GAAG,IAAI;QACP,IAAI;QACJ,QAAQ,EAAE,YAAY;QACtB,GAAG,EAAE,MAAM;KACZ,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AACH,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RadioGroupChangeDetail } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { CosmRadioGroup } from '@joralvmel/cosmos-elements/radio-group';
|
|
3
|
+
import { type EventName } from '@lit/react';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
/** React event props of `RadioGroup`, mapped to the original DOM `CustomEvent`. */
|
|
6
|
+
export declare const radioGroupEvents: {
|
|
7
|
+
onChange: EventName<CustomEvent<RadioGroupChangeDetail>>;
|
|
8
|
+
};
|
|
9
|
+
declare const RadioGroupElement: import("@lit/react").ReactWebComponent<CosmRadioGroup, {
|
|
10
|
+
onChange: EventName<CustomEvent<RadioGroupChangeDetail>>;
|
|
11
|
+
}>;
|
|
12
|
+
type ElementProps = React.ComponentProps<typeof RadioGroupElement>;
|
|
13
|
+
/** React wrapper; a supplied value, including null, keeps selection controlled. */
|
|
14
|
+
export declare const RadioGroup: React.ForwardRefExoticComponent<Omit<RadioGroupProps, "ref"> & React.RefAttributes<CosmRadioGroup>>;
|
|
15
|
+
export type RadioGroupProps = Omit<ElementProps, 'onChange'> & {
|
|
16
|
+
label: string;
|
|
17
|
+
options: CosmRadioGroup['options'];
|
|
18
|
+
value?: CosmRadioGroup['value'];
|
|
19
|
+
defaultValue?: CosmRadioGroup['defaultValue'];
|
|
20
|
+
onChange?: (event: CustomEvent<RadioGroupChangeDetail>) => void;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=radio-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-group.d.ts","sourceRoot":"","sources":["../../src/components/radio-group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,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,mFAAmF;AACnF,eAAO,MAAM,gBAAgB;cACA,SAAS,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;CAC1E,CAAC;AAEF,QAAA,MAAM,iBAAiB;cAHM,SAAS,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;EASzE,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE,mFAAmF;AACnF,eAAO,MAAM,UAAU,qGAyBtB,CAAC;AAIF,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC9C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,sBAAsB,CAAC,KAAK,IAAI,CAAC;CACjE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CosmRadioGroup } from '@joralvmel/cosmos-elements/radio-group';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
/** React event props of `RadioGroup`, mapped to the original DOM `CustomEvent`. */
|
|
6
|
+
export const radioGroupEvents = {
|
|
7
|
+
onChange: 'cosm-change',
|
|
8
|
+
};
|
|
9
|
+
const RadioGroupElement = createComponent({
|
|
10
|
+
tagName: 'cosm-radio-group',
|
|
11
|
+
elementClass: CosmRadioGroup,
|
|
12
|
+
react: React,
|
|
13
|
+
events: radioGroupEvents,
|
|
14
|
+
displayName: 'RadioGroupElement',
|
|
15
|
+
});
|
|
16
|
+
/** React wrapper; a supplied value, including null, keeps selection controlled. */
|
|
17
|
+
export const RadioGroup = React.forwardRef((props, forwardedRef) => {
|
|
18
|
+
const { value, onChange, size = 'md', ...elementProps } = props;
|
|
19
|
+
const handleChange = React.useCallback((event) => {
|
|
20
|
+
if (onChange)
|
|
21
|
+
flushSync(() => onChange(event));
|
|
22
|
+
}, [onChange]);
|
|
23
|
+
const setRef = React.useCallback((element) => {
|
|
24
|
+
if (element)
|
|
25
|
+
element.valueControlled = value !== undefined;
|
|
26
|
+
if (typeof forwardedRef === 'function')
|
|
27
|
+
forwardedRef(element);
|
|
28
|
+
else if (forwardedRef)
|
|
29
|
+
forwardedRef.current = element;
|
|
30
|
+
}, [forwardedRef, value]);
|
|
31
|
+
return React.createElement(RadioGroupElement, {
|
|
32
|
+
...elementProps,
|
|
33
|
+
size,
|
|
34
|
+
value,
|
|
35
|
+
onChange: handleChange,
|
|
36
|
+
ref: setRef,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
40
|
+
//# sourceMappingURL=radio-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-group.js","sourceRoot":"","sources":["../../src/components/radio-group.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,mFAAmF;AACnF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,aAA+D;CAC1E,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,mFAAmF;AACnF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CACxC,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IACtB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IAChE,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CACpC,CAAC,KAA0C,EAAE,EAAE;QAC7C,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,OAA8B,EAAE,EAAE;QACjC,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,iBAAiB,EAAE;QAC5C,GAAG,YAAY;QACf,IAAI;QACJ,KAAK;QACL,QAAQ,EAAE,YAAY;QACtB,GAAG,EAAE,MAAM;KACI,CAAC,CAAC;AACrB,CAAC,CACF,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SelectChangeDetail } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { CosmSelect } from '@joralvmel/cosmos-elements/select';
|
|
3
|
+
import { type EventName } from '@lit/react';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
/** React event props of `Select`, mapped to the original DOM `CustomEvent`. */
|
|
6
|
+
export declare const selectEvents: {
|
|
7
|
+
onChange: EventName<CustomEvent<SelectChangeDetail>>;
|
|
8
|
+
};
|
|
9
|
+
declare const SelectElement: import("@lit/react").ReactWebComponent<CosmSelect, {
|
|
10
|
+
onChange: EventName<CustomEvent<SelectChangeDetail>>;
|
|
11
|
+
}>;
|
|
12
|
+
type ElementProps = React.ComponentProps<typeof SelectElement>;
|
|
13
|
+
/** React wrapper; a supplied value, including `null`, keeps the selection controlled. */
|
|
14
|
+
export declare const Select: React.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React.RefAttributes<CosmSelect>>;
|
|
15
|
+
export type SelectProps = Omit<ElementProps, 'onChange'> & {
|
|
16
|
+
label: string;
|
|
17
|
+
items: CosmSelect['items'];
|
|
18
|
+
value?: CosmSelect['value'];
|
|
19
|
+
defaultValue?: CosmSelect['defaultValue'];
|
|
20
|
+
onChange?: (event: CustomEvent<SelectChangeDetail>) => void;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/components/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,+EAA+E;AAC/E,eAAO,MAAM,YAAY;cACI,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;CACtE,CAAC;AAEF,QAAA,MAAM,aAAa;cAHU,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;EASrE,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC;AAE/D,yFAAyF;AACzF,eAAO,MAAM,MAAM,6FAsBjB,CAAC;AAIH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC3B,KAAK,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5B,YAAY,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IAC1C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;CAC7D,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CosmSelect } from '@joralvmel/cosmos-elements/select';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
/** React event props of `Select`, mapped to the original DOM `CustomEvent`. */
|
|
6
|
+
export const selectEvents = {
|
|
7
|
+
onChange: 'cosm-change',
|
|
8
|
+
};
|
|
9
|
+
const SelectElement = createComponent({
|
|
10
|
+
tagName: 'cosm-select',
|
|
11
|
+
elementClass: CosmSelect,
|
|
12
|
+
react: React,
|
|
13
|
+
events: selectEvents,
|
|
14
|
+
displayName: 'SelectElement',
|
|
15
|
+
});
|
|
16
|
+
/** React wrapper; a supplied value, including `null`, keeps the selection controlled. */
|
|
17
|
+
export const Select = React.forwardRef((props, forwardedRef) => {
|
|
18
|
+
const { value, onChange, ...elementProps } = props;
|
|
19
|
+
const handleChange = React.useCallback((event) => {
|
|
20
|
+
if (onChange)
|
|
21
|
+
flushSync(() => onChange(event));
|
|
22
|
+
}, [onChange]);
|
|
23
|
+
const setRef = React.useCallback((element) => {
|
|
24
|
+
if (element)
|
|
25
|
+
element.valueControlled = value !== undefined;
|
|
26
|
+
if (typeof forwardedRef === 'function')
|
|
27
|
+
forwardedRef(element);
|
|
28
|
+
else if (forwardedRef)
|
|
29
|
+
forwardedRef.current = element;
|
|
30
|
+
}, [forwardedRef, value]);
|
|
31
|
+
return React.createElement(SelectElement, {
|
|
32
|
+
...elementProps,
|
|
33
|
+
value,
|
|
34
|
+
onChange: handleChange,
|
|
35
|
+
ref: setRef,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
Select.displayName = 'Select';
|
|
39
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/components/select.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,aAA2D;CACtE,CAAC;AAEF,MAAM,aAAa,GAAG,eAAe,CAAC;IACpC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,UAAU;IACxB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,YAAY;IACpB,WAAW,EAAE,eAAe;CAC7B,CAAC,CAAC;AAIH,yFAAyF;AACzF,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAA0B,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IACtF,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IACnD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CACpC,CAAC,KAAsC,EAAE,EAAE;QACzC,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,OAA0B,EAAE,EAAE;QAC7B,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,aAAa,EAAE;QACxC,GAAG,YAAY;QACf,KAAK;QACL,QAAQ,EAAE,YAAY;QACtB,GAAG,EAAE,MAAM;KACI,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SwitchCheckedChangeDetail } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { CosmSwitch } from '@joralvmel/cosmos-elements/switch';
|
|
3
|
+
import { type EventName } from '@lit/react';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
/** React event props of `Switch`, mapped to the original DOM `CustomEvent`. */
|
|
6
|
+
export declare const switchEvents: {
|
|
7
|
+
onCheckedChange: EventName<CustomEvent<SwitchCheckedChangeDetail>>;
|
|
8
|
+
};
|
|
9
|
+
declare const SwitchElement: import("@lit/react").ReactWebComponent<CosmSwitch, {
|
|
10
|
+
onCheckedChange: EventName<CustomEvent<SwitchCheckedChangeDetail>>;
|
|
11
|
+
}>;
|
|
12
|
+
type ElementProps = React.ComponentProps<typeof SwitchElement>;
|
|
13
|
+
/** React wrapper; a supplied checked value, including false, is controlled. */
|
|
14
|
+
export declare const Switch: React.ForwardRefExoticComponent<Omit<SwitchProps, "ref"> & React.RefAttributes<CosmSwitch>>;
|
|
15
|
+
export type SwitchProps = Omit<ElementProps, 'children' | 'onCheckedChange'> & {
|
|
16
|
+
label: string;
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
onCheckedChange?: (event: CustomEvent<SwitchCheckedChangeDetail>) => void;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=switch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/components/switch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,+EAA+E;AAC/E,eAAO,MAAM,YAAY;qBACmB,SAAS,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;CAC5F,CAAC;AAEF,QAAA,MAAM,aAAa;qBAHyB,SAAS,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;EAS3F,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC;AAE/D,+EAA+E;AAC/E,eAAO,MAAM,MAAM,6FAsBjB,CAAC;AAIH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,iBAAiB,CAAC,GAAG;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,yBAAyB,CAAC,KAAK,IAAI,CAAC;CAC3E,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CosmSwitch } from '@joralvmel/cosmos-elements/switch';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
/** React event props of `Switch`, mapped to the original DOM `CustomEvent`. */
|
|
6
|
+
export const switchEvents = {
|
|
7
|
+
onCheckedChange: 'cosm-checked-change',
|
|
8
|
+
};
|
|
9
|
+
const SwitchElement = createComponent({
|
|
10
|
+
tagName: 'cosm-switch',
|
|
11
|
+
elementClass: CosmSwitch,
|
|
12
|
+
react: React,
|
|
13
|
+
events: switchEvents,
|
|
14
|
+
displayName: 'SwitchElement',
|
|
15
|
+
});
|
|
16
|
+
/** React wrapper; a supplied checked value, including false, is controlled. */
|
|
17
|
+
export const Switch = React.forwardRef((props, forwardedRef) => {
|
|
18
|
+
const { checked, onCheckedChange, ...elementProps } = props;
|
|
19
|
+
const handleCheckedChange = React.useCallback((event) => {
|
|
20
|
+
if (onCheckedChange)
|
|
21
|
+
flushSync(() => onCheckedChange(event));
|
|
22
|
+
}, [onCheckedChange]);
|
|
23
|
+
const setRef = React.useCallback((element) => {
|
|
24
|
+
if (element)
|
|
25
|
+
element.checkedControlled = checked !== undefined;
|
|
26
|
+
if (typeof forwardedRef === 'function')
|
|
27
|
+
forwardedRef(element);
|
|
28
|
+
else if (forwardedRef)
|
|
29
|
+
forwardedRef.current = element;
|
|
30
|
+
}, [checked, forwardedRef]);
|
|
31
|
+
return React.createElement(SwitchElement, {
|
|
32
|
+
...elementProps,
|
|
33
|
+
checked,
|
|
34
|
+
onCheckedChange: handleCheckedChange,
|
|
35
|
+
ref: setRef,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
Switch.displayName = 'Switch';
|
|
39
|
+
//# sourceMappingURL=switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/components/switch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,eAAe,EAAE,qBAA0E;CAC5F,CAAC;AAEF,MAAM,aAAa,GAAG,eAAe,CAAC;IACpC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,UAAU;IACxB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,YAAY;IACpB,WAAW,EAAE,eAAe;CAC7B,CAAC,CAAC;AAIH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAA0B,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IACtF,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IAC5D,MAAM,mBAAmB,GAAG,KAAK,CAAC,WAAW,CAC3C,CAAC,KAA6C,EAAE,EAAE;QAChD,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,OAA0B,EAAE,EAAE;QAC7B,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,OAAO,EAAE,YAAY,CAAC,CACxB,CAAC;IACF,OAAO,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE;QACxC,GAAG,YAAY;QACf,OAAO;QACP,eAAe,EAAE,mBAAmB;QACpC,GAAG,EAAE,MAAM;KACI,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TextareaChangeDetail } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { CosmTextarea } from '@joralvmel/cosmos-elements/textarea';
|
|
3
|
+
import { type EventName } from '@lit/react';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
/** React event props of `Textarea`, mapped to the original DOM `CustomEvent`s. */
|
|
6
|
+
export declare const textareaEvents: {
|
|
7
|
+
onChange: EventName<CustomEvent<TextareaChangeDetail>>;
|
|
8
|
+
};
|
|
9
|
+
declare const TextareaElement: import("@lit/react").ReactWebComponent<CosmTextarea, {
|
|
10
|
+
onChange: EventName<CustomEvent<TextareaChangeDetail>>;
|
|
11
|
+
}>;
|
|
12
|
+
type ElementProps = React.ComponentProps<typeof TextareaElement>;
|
|
13
|
+
/** React wrapper of `<cosm-textarea>`; binding `value`, including `''`, marks it controlled. */
|
|
14
|
+
export declare const Textarea: React.ForwardRefExoticComponent<Omit<TextareaProps, "ref"> & React.RefAttributes<CosmTextarea>>;
|
|
15
|
+
export type TextareaProps = Omit<ElementProps, 'onChange'> & {
|
|
16
|
+
label: string;
|
|
17
|
+
onChange?: (event: CustomEvent<TextareaChangeDetail>) => void;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=textarea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../src/components/textarea.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,kFAAkF;AAClF,eAAO,MAAM,cAAc;cACE,SAAS,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;CACxE,CAAC;AAEF,QAAA,MAAM,eAAe;cAHQ,SAAS,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;EASvE,CAAC;AAEH,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,CAAC;AAEjE,gGAAgG;AAChG,eAAO,MAAM,QAAQ,iGAsBnB,CAAC;AAIH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;CAC/D,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CosmTextarea } from '@joralvmel/cosmos-elements/textarea';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { flushSync } from 'react-dom';
|
|
5
|
+
/** React event props of `Textarea`, mapped to the original DOM `CustomEvent`s. */
|
|
6
|
+
export const textareaEvents = {
|
|
7
|
+
onChange: 'cosm-change',
|
|
8
|
+
};
|
|
9
|
+
const TextareaElement = createComponent({
|
|
10
|
+
tagName: 'cosm-textarea',
|
|
11
|
+
elementClass: CosmTextarea,
|
|
12
|
+
react: React,
|
|
13
|
+
events: textareaEvents,
|
|
14
|
+
displayName: 'TextareaElement',
|
|
15
|
+
});
|
|
16
|
+
/** React wrapper of `<cosm-textarea>`; binding `value`, including `''`, marks it controlled. */
|
|
17
|
+
export const Textarea = React.forwardRef((props, forwardedRef) => {
|
|
18
|
+
const { value, onChange, ...elementProps } = props;
|
|
19
|
+
const handleChange = React.useCallback((event) => {
|
|
20
|
+
if (onChange)
|
|
21
|
+
flushSync(() => onChange(event));
|
|
22
|
+
}, [onChange]);
|
|
23
|
+
const setRef = React.useCallback((element) => {
|
|
24
|
+
if (element)
|
|
25
|
+
element.valueControlled = value !== undefined;
|
|
26
|
+
if (typeof forwardedRef === 'function')
|
|
27
|
+
forwardedRef(element);
|
|
28
|
+
else if (forwardedRef)
|
|
29
|
+
forwardedRef.current = element;
|
|
30
|
+
}, [forwardedRef, value]);
|
|
31
|
+
return React.createElement(TextareaElement, {
|
|
32
|
+
...elementProps,
|
|
33
|
+
value,
|
|
34
|
+
onChange: handleChange,
|
|
35
|
+
ref: setRef,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
Textarea.displayName = 'Textarea';
|
|
39
|
+
//# sourceMappingURL=textarea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea.js","sourceRoot":"","sources":["../../src/components/textarea.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,kFAAkF;AAClF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,QAAQ,EAAE,aAA6D;CACxE,CAAC;AAEF,MAAM,eAAe,GAAG,eAAe,CAAC;IACtC,OAAO,EAAE,eAAe;IACxB,YAAY,EAAE,YAAY;IAC1B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,cAAc;IACtB,WAAW,EAAE,iBAAiB;CAC/B,CAAC,CAAC;AAIH,gGAAgG;AAChG,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAA8B,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;IAC5F,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC;IACnD,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CACpC,CAAC,KAAwC,EAAE,EAAE;QAC3C,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,OAA4B,EAAE,EAAE;QAC/B,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,eAAe,EAAE;QAC1C,GAAG,YAAY;QACf,KAAK;QACL,QAAQ,EAAE,YAAY;QACtB,GAAG,EAAE,MAAM;KACI,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
export type { ButtonPressDetail, ListboxSelectionChangeDetail, PressSource, TextFieldChangeDetail, TextFieldSubmitDetail, } from '@joralvmel/cosmos-core';
|
|
1
|
+
export type { ButtonPressDetail, CheckboxCheckedChangeDetail, ListboxSelectionChangeDetail, PressSource, SwitchCheckedChangeDetail, TextareaChangeDetail, TextFieldChangeDetail, TextFieldSubmitDetail, } from '@joralvmel/cosmos-core';
|
|
2
|
+
export { Badge, type BadgeProps, badgeEvents } from './components/badge.js';
|
|
2
3
|
export { Button, type ButtonProps, buttonEvents } from './components/button.js';
|
|
4
|
+
export { Calendar, type CalendarProps, calendarEvents } from './components/calendar.js';
|
|
5
|
+
export { Checkbox, type CheckboxProps, checkboxEvents } from './components/checkbox.js';
|
|
6
|
+
export { Dialog, type DialogProps, dialogEvents } from './components/dialog.js';
|
|
3
7
|
export { Icon, type IconProps, iconEvents } from './components/icon.js';
|
|
4
8
|
export { IconButton, type IconButtonProps, iconButtonEvents } from './components/icon-button.js';
|
|
5
9
|
export { Listbox, type ListboxProps, listboxEvents } from './components/listbox.js';
|
|
10
|
+
export { Pagination, type PaginationProps, paginationEvents } from './components/pagination.js';
|
|
6
11
|
export { Popover, type PopoverProps, popoverEvents } from './components/popover.js';
|
|
12
|
+
export { RadioGroup, type RadioGroupProps, radioGroupEvents } from './components/radio-group.js';
|
|
13
|
+
export { Select, type SelectProps, selectEvents } from './components/select.js';
|
|
14
|
+
export { Switch, type SwitchProps, switchEvents } from './components/switch.js';
|
|
7
15
|
export { TextField, type TextFieldProps, textFieldEvents } from './components/text-field.js';
|
|
16
|
+
export { Textarea, type TextareaProps, textareaEvents } from './components/textarea.js';
|
|
8
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,4BAA4B,EAC5B,WAAW,EACX,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACxF,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,UAAU,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACjG,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
export { Badge, badgeEvents } from './components/badge.js';
|
|
1
2
|
export { Button, buttonEvents } from './components/button.js';
|
|
3
|
+
export { Calendar, calendarEvents } from './components/calendar.js';
|
|
4
|
+
export { Checkbox, checkboxEvents } from './components/checkbox.js';
|
|
5
|
+
export { Dialog, dialogEvents } from './components/dialog.js';
|
|
2
6
|
export { Icon, iconEvents } from './components/icon.js';
|
|
3
7
|
export { IconButton, iconButtonEvents } from './components/icon-button.js';
|
|
4
8
|
export { Listbox, listboxEvents } from './components/listbox.js';
|
|
9
|
+
export { Pagination, paginationEvents } from './components/pagination.js';
|
|
5
10
|
export { Popover, popoverEvents } from './components/popover.js';
|
|
11
|
+
export { RadioGroup, radioGroupEvents } from './components/radio-group.js';
|
|
12
|
+
export { Select, selectEvents } from './components/select.js';
|
|
13
|
+
export { Switch, switchEvents } from './components/switch.js';
|
|
6
14
|
export { TextField, textFieldEvents } from './components/text-field.js';
|
|
15
|
+
export { Textarea, textareaEvents } from './components/textarea.js';
|
|
7
16
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,EAAmB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAoB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAsB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAsB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACxF,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,UAAU,EAAwB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAE,OAAO,EAAqB,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,UAAU,EAAwB,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACjG,OAAO,EAAE,MAAM,EAAoB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAoB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,SAAS,EAAuB,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAsB,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
|
package/llms.md
CHANGED
|
@@ -113,17 +113,15 @@ export function Example() {
|
|
|
113
113
|
```
|
|
114
114
|
### `Icon`
|
|
115
115
|
|
|
116
|
-
Renders a structured SVG icon.
|
|
116
|
+
Renders a structured SVG icon. Icons are decorative and hidden from assistive technology unless a nonempty label makes them informative.
|
|
117
117
|
|
|
118
118
|
| Prop | Type | Default | Description |
|
|
119
119
|
| --- | --- | --- | --- |
|
|
120
120
|
| `icon` | IconDefinition | Required | Structured icon definition, commonly imported from @joralvmel/cosmos-icons. |
|
|
121
121
|
| `size` | 'sm' \| 'md' \| 'lg' \| number | `md` | Semantic size (16, 20 or 24) or a positive finite number in pixels / native units. |
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `label` | string | — | Accessible name required when decorative is false. |
|
|
126
|
-
| `decorative` | boolean | `true` | Hides the icon from assistive technology when true. |
|
|
122
|
+
| `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. |
|
|
123
|
+
| `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. |
|
|
124
|
+
| `label` | string | — | Accessible name. A nonempty label makes the icon an informative image; without one the icon is decorative and hidden from assistive technology. |
|
|
127
125
|
|
|
128
126
|
Events: none.
|
|
129
127
|
|
|
@@ -139,7 +137,7 @@ export function Example() {
|
|
|
139
137
|
```
|
|
140
138
|
### `TextField`
|
|
141
139
|
|
|
142
|
-
Accepts a single line of text with an accessible label, optional
|
|
140
|
+
Accepts a single line of text with an accessible label, optional helper and error text, and native form validation on the web.
|
|
143
141
|
|
|
144
142
|
| Prop | Type | Default | Description |
|
|
145
143
|
| --- | --- | --- | --- |
|
|
@@ -149,11 +147,11 @@ Accepts a single line of text with an accessible label, optional help and error
|
|
|
149
147
|
| `defaultValue` | string | `` | Initial value for autonomous use. Web form reset restores this value; it does not control subsequent edits. |
|
|
150
148
|
| `type` | 'text' \| 'email' \| 'password' \| 'tel' \| 'url' \| 'search' | `text` | Single-line input type. Native maps it to supported keyboard, autofill and secure-entry behavior. |
|
|
151
149
|
| `variant` | 'outlined' \| 'filled' | `outlined` | Visual treatment of the editable control. |
|
|
152
|
-
| `size` | 'sm' \| 'md' \| 'lg'
|
|
150
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large editable control. |
|
|
153
151
|
| `placeholder` | string | — | Short input hint; it never replaces the accessible label. |
|
|
154
|
-
| `
|
|
155
|
-
| `
|
|
156
|
-
| `invalid` | boolean | `false` | External invalid state, independent of browser constraints or consumer business validation. |
|
|
152
|
+
| `helperText` | string | — | Optional supporting text associated with the editable control. |
|
|
153
|
+
| `errorText` | string | — | Optional consumer-localized error text associated with the editable control; a nonempty trimmed value also exposes invalid state. |
|
|
154
|
+
| `invalid` | boolean | `false` | External invalid state when the visible error is supplied elsewhere, independent of browser constraints or consumer business validation. |
|
|
157
155
|
| `required` | boolean | `false` | Exposes required semantics. On web, participates in native HTML constraint validation. |
|
|
158
156
|
| `disabled` | boolean | `false` | Disables editing and interaction. On web, follows disabled fieldsets and excludes the value from form submission. |
|
|
159
157
|
| `readOnly` | boolean | `false` | Prevents editing while remaining focusable and form-submittable on web; distinct from disabled. |
|
|
@@ -165,7 +163,6 @@ Accepts a single line of text with an accessible label, optional help and error
|
|
|
165
163
|
| `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
164
|
| `startIcon` | IconDefinition | — | Optional structured decorative icon before the editable text. |
|
|
167
165
|
| `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
166
|
| `prefix` | string | — | Optional non-interactive text decoration before the editable text. |
|
|
170
167
|
| `suffix` | string | — | Optional non-interactive text decoration after the editable text. |
|
|
171
168
|
| `clearable` | boolean | `false` | Shows a clear action for non-empty editable fields. Supply clearLabel when enabled. |
|
|
@@ -238,16 +235,11 @@ Non-modal content anchored to a consumer trigger, with cancelable close requests
|
|
|
238
235
|
| `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
236
|
| `closable` | boolean | `false` | Shows a built-in IconButton with an X. Requests a cancelable close with reason close-button. |
|
|
240
237
|
| `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
238
|
| `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
239
|
| `closeOnEscape` | boolean | `true` | Requests closure on unhandled Escape on web and React Native Web. Native Android and iOS hardware Escape is not supported. |
|
|
244
240
|
| `closeOnOutsidePress` | boolean | `true` | Requests closure on an outside press without preventing its interaction or restoring trigger focus. |
|
|
245
|
-
| `
|
|
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. |
|
|
241
|
+
| `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. |
|
|
248
242
|
| `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
243
|
|
|
252
244
|
Events: `onOpenChange` → `PopoverOpenChangeDetail`.
|
|
253
245
|
|
|
@@ -279,7 +271,7 @@ Selects one or more values from a named vertical collection, with groups, descri
|
|
|
279
271
|
| `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
272
|
| `defaultSelectedValues` | ListboxValues | — | Initial autonomous selected values (empty by default). Later changes do not reset selection. |
|
|
281
273
|
| `variant` | 'plain' \| 'outlined' | `plain` | Plain composes inside a panel; outlined adds a standalone container boundary. |
|
|
282
|
-
| `size` | 'sm' \| 'md' \| 'lg'
|
|
274
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large option rows. Content may grow; native touch targets remain at least 44. |
|
|
283
275
|
| `disabled` | boolean | `false` | Prevents interaction and removes the list from keyboard navigation. |
|
|
284
276
|
| `readOnly` | boolean | `false` | Allows exploring options without proposing or committing selection changes. |
|
|
285
277
|
| `locale` | string | — | BCP 47 locale for typeahead. Web inherits the nearest language; native uses the runtime locale when omitted. Invalid locale identifiers are rejected. |
|
|
@@ -303,10 +295,322 @@ export function Example() {
|
|
|
303
295
|
);
|
|
304
296
|
}
|
|
305
297
|
```
|
|
298
|
+
### `Checkbox`
|
|
299
|
+
|
|
300
|
+
Selects an independent boolean value with accessible labeling and native form behavior on the web.
|
|
301
|
+
|
|
302
|
+
| Prop | Type | Default | Description |
|
|
303
|
+
| --- | --- | --- | --- |
|
|
304
|
+
| `label` | string | Required | Required accessible name, visible unless labelHidden is true. |
|
|
305
|
+
| `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |
|
|
306
|
+
| `checked` | boolean | `false` | Controlled checked value when supplied, including false; activation proposes changes without self-committing. |
|
|
307
|
+
| `defaultChecked` | boolean | `false` | Initial autonomous checked value; later changes do not reset it. |
|
|
308
|
+
| `indeterminate` | boolean | `false` | Presentation-only mixed state. Autonomous activation clears it; controlled use leaves it to the owner. |
|
|
309
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large visual box. |
|
|
310
|
+
| `disabled` | boolean | `false` | Prevents user interaction and excludes the value from web form submission. |
|
|
311
|
+
| `required` | boolean | `false` | Exposes required semantics and participates in native web form validation. Native has no automatic validation. |
|
|
312
|
+
| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere; web form validity remains based on required. |
|
|
313
|
+
| `helperText` | string | — | Optional consumer-localized supporting text associated with the checkbox. |
|
|
314
|
+
| `errorText` | string | — | Optional consumer-localized error description; a nonempty trimmed value also exposes invalid state. |
|
|
315
|
+
| `name` | string | — | Web form field name; React Native has no HTML form association. |
|
|
316
|
+
| `value` | string | `on` | Web form value submitted when checked and enabled; defaults to on. Angular Forms uses checked as its boolean value. |
|
|
317
|
+
|
|
318
|
+
Events: `onCheckedChange` → `CheckboxCheckedChangeDetail`.
|
|
319
|
+
|
|
320
|
+
```tsx
|
|
321
|
+
import { Checkbox } from '@joralvmel/cosmos-react';
|
|
322
|
+
|
|
323
|
+
export function Example() {
|
|
324
|
+
return (
|
|
325
|
+
<Checkbox
|
|
326
|
+
label="Checkbox"
|
|
327
|
+
onCheckedChange={event => console.log(event.detail)}
|
|
328
|
+
>
|
|
329
|
+
Checkbox
|
|
330
|
+
</Checkbox>
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
### `Switch`
|
|
335
|
+
|
|
336
|
+
Toggles a binary setting immediately with a stable accessible name and form behavior on the web.
|
|
337
|
+
|
|
338
|
+
| Prop | Type | Default | Description |
|
|
339
|
+
| --- | --- | --- | --- |
|
|
340
|
+
| `label` | string | Required | Required nonempty accessible name; remains stable in both states. |
|
|
341
|
+
| `labelHidden` | boolean | `false` | Visually hides the label while retaining its accessible name. |
|
|
342
|
+
| `checked` | boolean | `false` | Controlled checked value when supplied, including false; activation proposes changes without self-committing. |
|
|
343
|
+
| `defaultChecked` | boolean | `false` | Initial autonomous checked value; later changes do not reset it. |
|
|
344
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large web switch. Native uses system Switch sizing. |
|
|
345
|
+
| `disabled` | boolean | `false` | Prevents user interaction and excludes the value from web form submission. |
|
|
346
|
+
| `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. |
|
|
347
|
+
| `helperText` | string | — | Optional consumer-localized supporting text associated with the switch. |
|
|
348
|
+
| `name` | string | — | Web form field name; React Native has no HTML form association. |
|
|
349
|
+
| `value` | string | `on` | Web form value submitted when checked and enabled; defaults to on. Angular Forms uses checked as its boolean value. |
|
|
350
|
+
|
|
351
|
+
Events: `onCheckedChange` → `SwitchCheckedChangeDetail`.
|
|
352
|
+
|
|
353
|
+
```tsx
|
|
354
|
+
import { Switch } from '@joralvmel/cosmos-react';
|
|
355
|
+
|
|
356
|
+
export function Example() {
|
|
357
|
+
return (
|
|
358
|
+
<Switch
|
|
359
|
+
label="Switch"
|
|
360
|
+
onCheckedChange={event => console.log(event.detail)}
|
|
361
|
+
>
|
|
362
|
+
</Switch>
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
### `Badge`
|
|
367
|
+
|
|
368
|
+
Displays a noninteractive status or category label, or caller-formatted count, with an optional decorative leading icon.
|
|
369
|
+
|
|
370
|
+
| Prop | Type | Default | Description |
|
|
371
|
+
| --- | --- | --- | --- |
|
|
372
|
+
| `variant` | 'soft' \| 'solid' \| 'outline' | `soft` | Visual treatment of the static label. |
|
|
373
|
+
| `tone` | 'neutral' \| 'info' \| 'success' \| 'warning' \| 'danger' | `neutral` | Semantic color intent of the static label. |
|
|
374
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Semantic label size. |
|
|
375
|
+
| `startIcon` | IconDefinition | — | Optional structured decorative icon before the label. |
|
|
376
|
+
|
|
377
|
+
Events: none.
|
|
378
|
+
|
|
379
|
+
```tsx
|
|
380
|
+
import { Badge } from '@joralvmel/cosmos-react';
|
|
381
|
+
import { heart } from '@joralvmel/cosmos-icons/heart';
|
|
382
|
+
|
|
383
|
+
export function Example() {
|
|
384
|
+
return (
|
|
385
|
+
<Badge startIcon={heart}>Badge</Badge>
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
### `Calendar`
|
|
390
|
+
|
|
391
|
+
Selects one Gregorian date from an inline, localized calendar with keyboard navigation and optional bounds. Month and year can be selected directly.
|
|
392
|
+
|
|
393
|
+
| Prop | Type | Default | Description |
|
|
394
|
+
| --- | --- | --- | --- |
|
|
395
|
+
| `value` | string | — | Controlled selected date in YYYY-MM-DD format; when supplied, selection proposals wait for the owner to update this value. |
|
|
396
|
+
| `defaultValue` | string | — | Initial autonomous selected date in YYYY-MM-DD format; later changes do not reset selection. |
|
|
397
|
+
| `min` | string | — | Earliest selectable date in YYYY-MM-DD format, inclusive. |
|
|
398
|
+
| `max` | string | — | Latest selectable date in YYYY-MM-DD format, inclusive. |
|
|
399
|
+
| `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. |
|
|
400
|
+
| `disabled` | boolean | `false` | Disables date selection and calendar navigation. |
|
|
401
|
+
|
|
402
|
+
Events: `onChange` → `CalendarChangeDetail`.
|
|
403
|
+
|
|
404
|
+
```tsx
|
|
405
|
+
import { Calendar } from '@joralvmel/cosmos-react';
|
|
406
|
+
|
|
407
|
+
export function Example() {
|
|
408
|
+
return (
|
|
409
|
+
<Calendar onChange={event => console.log(event.detail)}></Calendar>
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
### `Textarea`
|
|
414
|
+
|
|
415
|
+
Accepts multiline plain text with an accessible label, optional helper and error text, and native form behavior on the web.
|
|
416
|
+
|
|
417
|
+
| Prop | Type | Default | Description |
|
|
418
|
+
| --- | --- | --- | --- |
|
|
419
|
+
| `label` | string | Required | Accessible name for the editable control. It is rendered above the control unless visually hidden. |
|
|
420
|
+
| `labelHidden` | boolean | `false` | Visually hides the label while keeping it available to assistive technology. |
|
|
421
|
+
| `value` | string | — | Current text. When bound, edits are proposals and the component waits for the owner to supply the accepted value. |
|
|
422
|
+
| `defaultValue` | string | `` | Initial value for autonomous use. Web form reset restores this value; it does not control subsequent edits. |
|
|
423
|
+
| `rows` | number | `4` | Visible line count of the multiline editor. It is independent of the visual size. |
|
|
424
|
+
| `variant` | 'outlined' \| 'filled' | `outlined` | Visual treatment of the editable control. |
|
|
425
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Visual size of the editable control, independent of rows. |
|
|
426
|
+
| `placeholder` | string | — | Short input hint; it never replaces the accessible label. |
|
|
427
|
+
| `helperText` | string | — | Optional supporting text associated with the editable control. |
|
|
428
|
+
| `errorText` | string | — | Optional consumer-localized error text associated with the editable control; a nonempty trimmed value also exposes invalid state. |
|
|
429
|
+
| `invalid` | boolean | `false` | External invalid state when the visible error is supplied elsewhere, independent of browser constraints or consumer business validation. |
|
|
430
|
+
| `required` | boolean | `false` | Exposes required semantics. On web, participates in native HTML constraint validation. |
|
|
431
|
+
| `disabled` | boolean | `false` | Disables editing and interaction. On web, follows disabled fieldsets and excludes the value from form submission. |
|
|
432
|
+
| `readOnly` | boolean | `false` | Prevents editing while remaining focusable and form-submittable on web; distinct from disabled. |
|
|
433
|
+
| `maxLength` | number | — | Maximum number of characters. Web uses native HTML length constraints and native applies supported input limits. |
|
|
434
|
+
| `name` | string | — | Form field name on web. React Native has no HTML form association or name-based submission. |
|
|
435
|
+
|
|
436
|
+
Events: `onChange` → `TextareaChangeDetail`.
|
|
437
|
+
|
|
438
|
+
```tsx
|
|
439
|
+
import { Textarea } from '@joralvmel/cosmos-react';
|
|
440
|
+
|
|
441
|
+
export function Example() {
|
|
442
|
+
return (
|
|
443
|
+
<Textarea
|
|
444
|
+
label="Textarea"
|
|
445
|
+
onChange={event => console.log(event.detail)}
|
|
446
|
+
>
|
|
447
|
+
</Textarea>
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
```
|
|
451
|
+
### `RadioGroup`
|
|
452
|
+
|
|
453
|
+
Selects one option from a labeled collection, with optional selection and native Web form behavior.
|
|
454
|
+
|
|
455
|
+
| Prop | Type | Default | Description |
|
|
456
|
+
| --- | --- | --- | --- |
|
|
457
|
+
| `label` | string | Required | Required visible accessible name for the group. |
|
|
458
|
+
| `options` | RadioGroupOptions | Required | Readonly flat options with unique nonempty values and labels, optional descriptions and disabled states. |
|
|
459
|
+
| `value` | RadioGroupValue | — | Controlled selected value; null means no selection, and a supplied null remains controlled. |
|
|
460
|
+
| `defaultValue` | RadioGroupValue | — | Initial autonomous selection; null by default. |
|
|
461
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium or large radio indicator. |
|
|
462
|
+
| `orientation` | 'vertical' \| 'horizontal' | `vertical` | Vertical list or wrapping horizontal options. |
|
|
463
|
+
| `disabled` | boolean | `false` | Prevents interaction and excludes the value from Web form submission. |
|
|
464
|
+
| `required` | boolean | `false` | Requires a selection in Web form validation; Native exposes descriptive semantics. |
|
|
465
|
+
| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere. |
|
|
466
|
+
| `helperText` | string | — | Optional supporting text associated with the group. |
|
|
467
|
+
| `errorText` | string | — | Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state. |
|
|
468
|
+
| `name` | string | — | Web form field name; React Native has no HTML form association. |
|
|
469
|
+
|
|
470
|
+
Events: `onChange` → `RadioGroupChangeDetail`.
|
|
471
|
+
|
|
472
|
+
```tsx
|
|
473
|
+
import { RadioGroup } from '@joralvmel/cosmos-react';
|
|
474
|
+
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;
|
|
475
|
+
|
|
476
|
+
export function Example() {
|
|
477
|
+
return (
|
|
478
|
+
<RadioGroup
|
|
479
|
+
label="RadioGroup"
|
|
480
|
+
options={contactMethods}
|
|
481
|
+
onChange={event => console.log(event.detail)}
|
|
482
|
+
>
|
|
483
|
+
</RadioGroup>
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
```
|
|
487
|
+
### `Select`
|
|
488
|
+
|
|
489
|
+
Selects one option from an accessible collection, with native Web form behavior.
|
|
490
|
+
|
|
491
|
+
| Prop | Type | Default | Description |
|
|
492
|
+
| --- | --- | --- | --- |
|
|
493
|
+
| `label` | string | Required | Required visible accessible name for the control. |
|
|
494
|
+
| `items` | SelectItems | Required | Readonly flat options with unique nonempty values, nonempty labels, and optional disabled state. |
|
|
495
|
+
| `value` | SelectValue | — | Controlled selected value; null means no selection, and a supplied null remains controlled. |
|
|
496
|
+
| `defaultValue` | SelectValue | — | Initial autonomous selection; null by default. |
|
|
497
|
+
| `placeholder` | string | Required | Consumer-localized text shown when no value is selected. |
|
|
498
|
+
| `variant` | 'outlined' \| 'filled' | `outlined` | Outlined or filled trigger appearance. |
|
|
499
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Small, medium, or large control size. |
|
|
500
|
+
| `disabled` | boolean | `false` | Prevents interaction and excludes the value from Web form submission. |
|
|
501
|
+
| `required` | boolean | `false` | Requires a selection in Web form validation; Native exposes descriptive semantics. |
|
|
502
|
+
| `invalid` | boolean | `false` | Externally supplied invalid presentation state when the visible error is supplied elsewhere. |
|
|
503
|
+
| `helperText` | string | — | Optional supporting text associated with the control. |
|
|
504
|
+
| `errorText` | string | — | Optional consumer-localized error text; a nonempty trimmed value also exposes invalid state. |
|
|
505
|
+
| `name` | string | — | Web form field name; React Native has no HTML form association. |
|
|
506
|
+
|
|
507
|
+
Events: `onChange` → `SelectChangeDetail`.
|
|
508
|
+
|
|
509
|
+
```tsx
|
|
510
|
+
import { Select } from '@joralvmel/cosmos-react';
|
|
511
|
+
const flat = [{"value":"apple","label":"Apple"},{"value":"cherry","label":"Cherry"},{"value":"lime","label":"Lime","disabled":true}] as const;
|
|
512
|
+
const none = null as const;
|
|
513
|
+
|
|
514
|
+
export function Example() {
|
|
515
|
+
return (
|
|
516
|
+
<Select
|
|
517
|
+
label="Select"
|
|
518
|
+
items={flat}
|
|
519
|
+
defaultValue={none}
|
|
520
|
+
placeholder="Select"
|
|
521
|
+
onChange={event => console.log(event.detail)}
|
|
522
|
+
>
|
|
523
|
+
</Select>
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
```
|
|
527
|
+
### `Pagination`
|
|
528
|
+
|
|
529
|
+
Navigates a known number of pages using buttons.
|
|
530
|
+
|
|
531
|
+
| Prop | Type | Default | Description |
|
|
532
|
+
| --- | --- | --- | --- |
|
|
533
|
+
| `totalPages` | number | Required | Required nonnegative safe integer page count. |
|
|
534
|
+
| `page` | number | — | Controlled one-based safe integer page; out-of-range values are displayed clamped. |
|
|
535
|
+
| `defaultPage` | number | `1` | Initial one-based page for autonomous state. |
|
|
536
|
+
| `label` | string | Required | Required localized navigation landmark label. |
|
|
537
|
+
| `previousLabel` | string | `Previous page` | Previous button label. |
|
|
538
|
+
| `nextLabel` | string | `Next page` | Next button label. |
|
|
539
|
+
| `firstLabel` | string | `First page` | First button label. |
|
|
540
|
+
| `lastLabel` | string | `Last page` | Last button label. |
|
|
541
|
+
| `pageLabel` | string | `Page {page}` | Page button label template; {page} is replaced with the localized number. |
|
|
542
|
+
| `summaryLabel` | string | `Page {page} of {total}` | Compact summary template with {page} and {total} placeholders. |
|
|
543
|
+
| `locale` | string | — | Locale for formatted page numbers. |
|
|
544
|
+
| `direction` | 'ltr' \| 'rtl' | `ltr` | Layout and directional icon direction. |
|
|
545
|
+
| `presentation` | 'numbered' \| 'compact' | `numbered` | Show up to seven fixed-width numbered positions or a compact summary. |
|
|
546
|
+
| `variant` | 'solid' \| 'soft' \| 'outline' | `solid` | Selected page emphasis. |
|
|
547
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Control size. |
|
|
548
|
+
| `showFirstLast` | boolean | `false` | Show first and last page controls. |
|
|
549
|
+
| `disabled` | boolean | `false` | Disable all controls. |
|
|
550
|
+
|
|
551
|
+
Events: `onChange` → `PaginationChangeDetail`.
|
|
552
|
+
|
|
553
|
+
```tsx
|
|
554
|
+
import { Pagination } from '@joralvmel/cosmos-react';
|
|
555
|
+
|
|
556
|
+
export function Example() {
|
|
557
|
+
return (
|
|
558
|
+
<Pagination
|
|
559
|
+
label="Pagination"
|
|
560
|
+
onChange={event => console.log(event.detail)}
|
|
561
|
+
>
|
|
562
|
+
</Pagination>
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
```
|
|
566
|
+
### `Dialog`
|
|
567
|
+
|
|
568
|
+
Modal content with a title, actions and cancelable close requests.
|
|
569
|
+
|
|
570
|
+
| Prop | Type | Default | Description |
|
|
571
|
+
| --- | --- | --- | --- |
|
|
572
|
+
| `open` | boolean | `false` | Committed visibility; supplying this prop, including false, controls state. |
|
|
573
|
+
| `defaultOpen` | boolean | `false` | Initial autonomous visibility; subsequent changes do not reset state. |
|
|
574
|
+
| `presentation` | 'standard' \| 'fullscreen' | `standard` | Centered standard surface or fullscreen surface. |
|
|
575
|
+
| `size` | 'sm' \| 'md' \| 'lg' | `md` | Maximum standard width: sm 400, md 640, lg 960 pixels or logical points. |
|
|
576
|
+
| `responsiveFullscreen` | boolean | `false` | Use fullscreen when available viewport width is below 640 pixels or logical points. |
|
|
577
|
+
| `closeLabel` | string | `Close` | Non-empty localized accessible name of the built-in close button. |
|
|
578
|
+
| `closeOnEscape` | boolean | `true` | Request closure on unhandled Escape on web. |
|
|
579
|
+
| `closeOnBackdropPress` | boolean | `false` | Request closure when the backdrop itself is pressed. |
|
|
580
|
+
| `initialFocusTarget` | DialogFocusTarget | — | Optional platform focus target used on committed opening; it must be inside the dialog. |
|
|
581
|
+
| `returnFocusTarget` | DialogFocusTarget | — | Optional platform focus target used after committed closure. |
|
|
582
|
+
|
|
583
|
+
Events: `onOpenChange` → `DialogOpenChangeDetail`.
|
|
584
|
+
|
|
585
|
+
```tsx
|
|
586
|
+
import { useRef } from 'react';
|
|
587
|
+
import { Button, Dialog } from '@joralvmel/cosmos-react';
|
|
588
|
+
import type { CosmDialog } from '@joralvmel/cosmos-elements/dialog';
|
|
589
|
+
|
|
590
|
+
export function Example() {
|
|
591
|
+
const dialog = useRef<CosmDialog>(null);
|
|
592
|
+
return (
|
|
593
|
+
<>
|
|
594
|
+
<Button onPress={() => dialog.current?.requestOpen()}>Open dialog</Button>
|
|
595
|
+
<Dialog
|
|
596
|
+
ref={dialog}
|
|
597
|
+
onOpenChange={event => {
|
|
598
|
+
const detail = event.detail;
|
|
599
|
+
console.log(detail);
|
|
600
|
+
}}
|
|
601
|
+
>
|
|
602
|
+
<h2 slot="title">Review details</h2>
|
|
603
|
+
<p>Dialog</p>
|
|
604
|
+
<Button slot="actions" onPress={() => dialog.current?.requestClose()}>Done</Button>
|
|
605
|
+
</Dialog>
|
|
606
|
+
</>
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
```
|
|
306
610
|
|
|
307
611
|
## Themes
|
|
308
612
|
|
|
309
|
-
Built-in themes: `cosmos`, `nebula` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
|
|
613
|
+
Built-in themes: `cosmos`, `nebula`, `terra`, `supernova`, `aurora`, `solstice` (default `cosmos`), each with `light` and `dark` modes; `system` follows the OS.
|
|
310
614
|
|
|
311
615
|
```html
|
|
312
616
|
<html data-theme="nebula" data-mode="system">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joralvmel/cosmos-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "React wrappers for the Cosmos UI Web Components (React 19, Vite, Next.js).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -42,8 +42,8 @@
|
|
|
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.
|
|
45
|
+
"@joralvmel/cosmos-core": "^0.4.0",
|
|
46
|
+
"@joralvmel/cosmos-elements": "^0.4.0",
|
|
47
47
|
"@lit/react": "^1.0.8"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@types/react": "^19.3.
|
|
60
|
+
"@types/react": "^19.3.3",
|
|
61
61
|
"@types/react-dom": "^19.3.0",
|
|
62
62
|
"react": "19.3.1",
|
|
63
63
|
"react-dom": "19.3.1"
|