@colletdev/react 0.1.3
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 +67 -0
- package/dist/generated/accordion.d.ts +17 -0
- package/dist/generated/accordion.js +56 -0
- package/dist/generated/activity-group.d.ts +14 -0
- package/dist/generated/activity-group.js +26 -0
- package/dist/generated/alert.d.ts +22 -0
- package/dist/generated/alert.js +55 -0
- package/dist/generated/autocomplete.d.ts +46 -0
- package/dist/generated/autocomplete.js +144 -0
- package/dist/generated/avatar.d.ts +13 -0
- package/dist/generated/avatar.js +24 -0
- package/dist/generated/backdrop.d.ts +9 -0
- package/dist/generated/backdrop.js +16 -0
- package/dist/generated/badge.d.ts +17 -0
- package/dist/generated/badge.js +40 -0
- package/dist/generated/breadcrumb.d.ts +14 -0
- package/dist/generated/breadcrumb.js +41 -0
- package/dist/generated/button.d.ts +21 -0
- package/dist/generated/button.js +46 -0
- package/dist/generated/card.d.ts +20 -0
- package/dist/generated/card.js +54 -0
- package/dist/generated/carousel.d.ts +28 -0
- package/dist/generated/carousel.js +62 -0
- package/dist/generated/chat-input.d.ts +27 -0
- package/dist/generated/chat-input.js +92 -0
- package/dist/generated/checkbox.d.ts +28 -0
- package/dist/generated/checkbox.js +93 -0
- package/dist/generated/code-block.d.ts +17 -0
- package/dist/generated/code-block.js +32 -0
- package/dist/generated/collapsible.d.ts +26 -0
- package/dist/generated/collapsible.js +36 -0
- package/dist/generated/date-picker.d.ts +39 -0
- package/dist/generated/date-picker.js +124 -0
- package/dist/generated/dialog.d.ts +28 -0
- package/dist/generated/dialog.js +59 -0
- package/dist/generated/drawer.d.ts +28 -0
- package/dist/generated/drawer.js +59 -0
- package/dist/generated/fab.d.ts +19 -0
- package/dist/generated/fab.js +42 -0
- package/dist/generated/file-upload.d.ts +22 -0
- package/dist/generated/file-upload.js +59 -0
- package/dist/generated/index.d.ts +56 -0
- package/dist/generated/index.js +58 -0
- package/dist/generated/listbox.d.ts +19 -0
- package/dist/generated/listbox.js +93 -0
- package/dist/generated/menu.d.ts +26 -0
- package/dist/generated/menu.js +86 -0
- package/dist/generated/message-bubble.d.ts +18 -0
- package/dist/generated/message-bubble.js +41 -0
- package/dist/generated/message-group.d.ts +14 -0
- package/dist/generated/message-group.js +42 -0
- package/dist/generated/message-part.d.ts +20 -0
- package/dist/generated/message-part.js +36 -0
- package/dist/generated/pagination.d.ts +17 -0
- package/dist/generated/pagination.js +59 -0
- package/dist/generated/popover.d.ts +27 -0
- package/dist/generated/popover.js +65 -0
- package/dist/generated/profile-menu.d.ts +23 -0
- package/dist/generated/profile-menu.js +56 -0
- package/dist/generated/progress.d.ts +14 -0
- package/dist/generated/progress.js +33 -0
- package/dist/generated/radio-group.d.ts +24 -0
- package/dist/generated/radio-group.js +110 -0
- package/dist/generated/scrollbar.d.ts +14 -0
- package/dist/generated/scrollbar.js +33 -0
- package/dist/generated/search-bar.d.ts +33 -0
- package/dist/generated/search-bar.js +118 -0
- package/dist/generated/select.d.ts +36 -0
- package/dist/generated/select.js +136 -0
- package/dist/generated/serialize.d.ts +2 -0
- package/dist/generated/serialize.js +13 -0
- package/dist/generated/sidebar.d.ts +25 -0
- package/dist/generated/sidebar.js +55 -0
- package/dist/generated/skeleton.d.ts +12 -0
- package/dist/generated/skeleton.js +31 -0
- package/dist/generated/slider.d.ts +34 -0
- package/dist/generated/slider.js +140 -0
- package/dist/generated/speed-dial.d.ts +29 -0
- package/dist/generated/speed-dial.js +63 -0
- package/dist/generated/spinner.d.ts +10 -0
- package/dist/generated/spinner.js +18 -0
- package/dist/generated/split-button.d.ts +27 -0
- package/dist/generated/split-button.js +63 -0
- package/dist/generated/stepper.d.ts +17 -0
- package/dist/generated/stepper.js +56 -0
- package/dist/generated/switch.d.ts +29 -0
- package/dist/generated/switch.js +92 -0
- package/dist/generated/table.d.ts +31 -0
- package/dist/generated/table.js +187 -0
- package/dist/generated/tabs.d.ts +20 -0
- package/dist/generated/tabs.js +54 -0
- package/dist/generated/text-input.d.ts +48 -0
- package/dist/generated/text-input.js +165 -0
- package/dist/generated/text.d.ts +21 -0
- package/dist/generated/text.js +74 -0
- package/dist/generated/thinking.d.ts +12 -0
- package/dist/generated/thinking.js +22 -0
- package/dist/generated/toast.d.ts +24 -0
- package/dist/generated/toast.js +60 -0
- package/dist/generated/toggle-group.d.ts +21 -0
- package/dist/generated/toggle-group.js +70 -0
- package/dist/generated/tooltip.d.ts +18 -0
- package/dist/generated/tooltip.js +42 -0
- package/dist/generated/types.d.ts +300 -0
- package/dist/generated/types.js +6 -0
- package/dist/generated/use-markdown-stream.d.ts +45 -0
- package/dist/generated/use-markdown-stream.js +48 -0
- package/dist/generated/use-markdown.d.ts +20 -0
- package/dist/generated/use-markdown.js +49 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @collet/react
|
|
2
|
+
|
|
3
|
+
React 18+ wrappers for the Collet component library. Typed props, ref forwarding, and idiomatic event callbacks over 48 Rust/WASM Custom Elements.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @collet/react @collet/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { init } from '@collet/react';
|
|
15
|
+
import { Button, TextInput } from '@collet/react';
|
|
16
|
+
|
|
17
|
+
await init(); // once, at app startup
|
|
18
|
+
|
|
19
|
+
function App() {
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<Button variant="filled" label="Save" intent="primary" onClick={() => save()} />
|
|
23
|
+
<TextInput label="Email" kind="email" onInput={(e) => setEmail(e.detail.value)} />
|
|
24
|
+
</>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- **Typed props** -- union-literal types for variant, intent, size, and all other enums
|
|
32
|
+
- **Event callbacks** -- `onClick`, `onInput`, `onChange`, etc. with typed `CustomEvent` `detail`
|
|
33
|
+
- **Ref types** -- `ButtonRef`, `TextInputRef`, `DialogRef`, etc. for imperative access (`.open()`, `.close()`, `.focus()`)
|
|
34
|
+
- **Structured data** -- `SelectOption[]`, `TableColumn[]`, `AccordionItem[]` and other complex prop types are fully typed
|
|
35
|
+
- **Markdown** -- `useMarkdown(content)` hook renders GFM to sanitized HTML via WASM
|
|
36
|
+
- **Streaming** -- `useMarkdownStream()` for token-by-token rendering with cursor animation
|
|
37
|
+
|
|
38
|
+
## Markdown
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import { useMarkdown } from '@collet/react';
|
|
42
|
+
|
|
43
|
+
function Docs({ content }: { content: string }) {
|
|
44
|
+
const html = useMarkdown(content);
|
|
45
|
+
return <div dangerouslySetInnerHTML={{ __html: html }} />;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Event Pattern
|
|
50
|
+
|
|
51
|
+
Event callbacks use standard React naming (`onChange`, `onClick`, `onInput`, etc.) and receive typed `CustomEvent` objects:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
<Select
|
|
55
|
+
label="Country"
|
|
56
|
+
options={countries}
|
|
57
|
+
onChange={(e) => setCountry(e.detail.value)}
|
|
58
|
+
/>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## API Reference
|
|
62
|
+
|
|
63
|
+
See [@collet/docs](https://www.npmjs.com/package/@collet/docs) for the full props/events reference and framework guides.
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
MIT -- [github.com/Danrozen87/collet](https://github.com/Danrozen87/collet)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { AccordionDetail, AccordionItem } from './types.js';
|
|
3
|
+
export interface AccordionProps {
|
|
4
|
+
id?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
items?: AccordionItem[] | string;
|
|
7
|
+
mode?: 'single' | 'multiple';
|
|
8
|
+
collapsible?: boolean;
|
|
9
|
+
headingLevel?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
10
|
+
defaultExpanded?: string[] | string;
|
|
11
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onChange?: (event: CustomEvent<AccordionDetail>) => void;
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
}
|
|
17
|
+
export declare const Accordion: React.ForwardRefExoticComponent<AccordionProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Accordion = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
const onChangeRef = useRef(props.onChange);
|
|
7
|
+
onChangeRef.current = props.onChange;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const el = ref.current;
|
|
10
|
+
if (!el)
|
|
11
|
+
return;
|
|
12
|
+
const handler = (e) => onChangeRef.current?.(e);
|
|
13
|
+
el.addEventListener('cx-change', handler);
|
|
14
|
+
return () => el.removeEventListener('cx-change', handler);
|
|
15
|
+
}, []);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const el = ref.current;
|
|
18
|
+
if (!el)
|
|
19
|
+
return;
|
|
20
|
+
if (props.items != null) {
|
|
21
|
+
el.setAttribute('items', typeof props.items === 'object' ? JSON.stringify(props.items) : String(props.items));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
el.removeAttribute('items');
|
|
25
|
+
}
|
|
26
|
+
}, [props.items]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const el = ref.current;
|
|
29
|
+
if (!el)
|
|
30
|
+
return;
|
|
31
|
+
if (props.defaultExpanded != null) {
|
|
32
|
+
el.setAttribute('default-expanded', typeof props.defaultExpanded === 'object' ? JSON.stringify(props.defaultExpanded) : String(props.defaultExpanded));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
el.removeAttribute('default-expanded');
|
|
36
|
+
}
|
|
37
|
+
}, [props.defaultExpanded]);
|
|
38
|
+
// Build attribute object
|
|
39
|
+
const attrs = {};
|
|
40
|
+
if (props.id != null)
|
|
41
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
42
|
+
if (props.label != null)
|
|
43
|
+
attrs['label'] = typeof props.label === 'object' ? JSON.stringify(props.label) : String(props.label);
|
|
44
|
+
if (props.mode != null)
|
|
45
|
+
attrs['mode'] = typeof props.mode === 'object' ? JSON.stringify(props.mode) : String(props.mode);
|
|
46
|
+
if (props.collapsible)
|
|
47
|
+
attrs['collapsible'] = '';
|
|
48
|
+
if (props.headingLevel != null)
|
|
49
|
+
attrs['heading-level'] = typeof props.headingLevel === 'object' ? JSON.stringify(props.headingLevel) : String(props.headingLevel);
|
|
50
|
+
if (props.size != null)
|
|
51
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
52
|
+
if (props.disabled)
|
|
53
|
+
attrs['disabled'] = '';
|
|
54
|
+
return (_jsx("cx-accordion", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
55
|
+
});
|
|
56
|
+
Accordion.displayName = 'Accordion';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface ActivityGroupProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
status?: string;
|
|
5
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
6
|
+
border?: string;
|
|
7
|
+
summary?: string;
|
|
8
|
+
action?: string;
|
|
9
|
+
expanded?: boolean;
|
|
10
|
+
parts?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
export declare const ActivityGroup: React.ForwardRefExoticComponent<ActivityGroupProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const ActivityGroup = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
// Build attribute object
|
|
7
|
+
const attrs = {};
|
|
8
|
+
if (props.id != null)
|
|
9
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
10
|
+
if (props.status != null)
|
|
11
|
+
attrs['status'] = typeof props.status === 'object' ? JSON.stringify(props.status) : String(props.status);
|
|
12
|
+
if (props.size != null)
|
|
13
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
14
|
+
if (props.border != null)
|
|
15
|
+
attrs['border'] = typeof props.border === 'object' ? JSON.stringify(props.border) : String(props.border);
|
|
16
|
+
if (props.summary != null)
|
|
17
|
+
attrs['summary'] = typeof props.summary === 'object' ? JSON.stringify(props.summary) : String(props.summary);
|
|
18
|
+
if (props.action != null)
|
|
19
|
+
attrs['action'] = typeof props.action === 'object' ? JSON.stringify(props.action) : String(props.action);
|
|
20
|
+
if (props.expanded)
|
|
21
|
+
attrs['expanded'] = '';
|
|
22
|
+
if (props.parts != null)
|
|
23
|
+
attrs['parts'] = typeof props.parts === 'object' ? JSON.stringify(props.parts) : String(props.parts);
|
|
24
|
+
return (_jsx("cx-activity-group", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
25
|
+
});
|
|
26
|
+
ActivityGroup.displayName = 'ActivityGroup';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { DismissDetail } from './types.js';
|
|
3
|
+
export interface AlertProps {
|
|
4
|
+
id?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
variant?: 'subtle' | 'filled' | 'outline';
|
|
8
|
+
intent?: 'neutral' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
9
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
10
|
+
showIcon?: boolean;
|
|
11
|
+
icon?: string;
|
|
12
|
+
dismissible?: boolean;
|
|
13
|
+
dismissLabel?: string;
|
|
14
|
+
compact?: boolean;
|
|
15
|
+
dynamic?: boolean;
|
|
16
|
+
actionsHtml?: string;
|
|
17
|
+
onDismiss?: (event: CustomEvent<DismissDetail>) => void;
|
|
18
|
+
actions?: React.ReactNode;
|
|
19
|
+
className?: string;
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
}
|
|
22
|
+
export declare const Alert: React.ForwardRefExoticComponent<AlertProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Alert = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
const onDismissRef = useRef(props.onDismiss);
|
|
7
|
+
onDismissRef.current = props.onDismiss;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const el = ref.current;
|
|
10
|
+
if (!el)
|
|
11
|
+
return;
|
|
12
|
+
const handler = (e) => onDismissRef.current?.(e);
|
|
13
|
+
el.addEventListener('cx-dismiss', handler);
|
|
14
|
+
return () => el.removeEventListener('cx-dismiss', handler);
|
|
15
|
+
}, []);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const el = ref.current;
|
|
18
|
+
if (!el)
|
|
19
|
+
return;
|
|
20
|
+
if (props.title != null) {
|
|
21
|
+
el.setAttribute('title', String(props.title));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
el.removeAttribute('title');
|
|
25
|
+
}
|
|
26
|
+
}, [props.title]);
|
|
27
|
+
// Build attribute object
|
|
28
|
+
const attrs = {};
|
|
29
|
+
if (props.id != null)
|
|
30
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
31
|
+
if (props.description != null)
|
|
32
|
+
attrs['description'] = typeof props.description === 'object' ? JSON.stringify(props.description) : String(props.description);
|
|
33
|
+
if (props.variant != null)
|
|
34
|
+
attrs['variant'] = typeof props.variant === 'object' ? JSON.stringify(props.variant) : String(props.variant);
|
|
35
|
+
if (props.intent != null)
|
|
36
|
+
attrs['intent'] = typeof props.intent === 'object' ? JSON.stringify(props.intent) : String(props.intent);
|
|
37
|
+
if (props.size != null)
|
|
38
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
39
|
+
if (props.showIcon)
|
|
40
|
+
attrs['show-icon'] = '';
|
|
41
|
+
if (props.icon != null)
|
|
42
|
+
attrs['icon'] = typeof props.icon === 'object' ? JSON.stringify(props.icon) : String(props.icon);
|
|
43
|
+
if (props.dismissible)
|
|
44
|
+
attrs['dismissible'] = '';
|
|
45
|
+
if (props.dismissLabel != null)
|
|
46
|
+
attrs['dismiss-label'] = typeof props.dismissLabel === 'object' ? JSON.stringify(props.dismissLabel) : String(props.dismissLabel);
|
|
47
|
+
if (props.compact)
|
|
48
|
+
attrs['compact'] = '';
|
|
49
|
+
if (props.dynamic)
|
|
50
|
+
attrs['dynamic'] = '';
|
|
51
|
+
if (props.actionsHtml != null)
|
|
52
|
+
attrs['actions-html'] = typeof props.actionsHtml === 'object' ? JSON.stringify(props.actionsHtml) : String(props.actionsHtml);
|
|
53
|
+
return (_jsx("cx-alert", { ref: ref, ...attrs, className: props.className, style: props.style, children: props.actions && _jsx("div", { slot: "actions", style: { display: 'contents' }, children: props.actions }) }));
|
|
54
|
+
});
|
|
55
|
+
Alert.displayName = 'Alert';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { FocusDetail, InputDetail, KeyboardDetail, OptionGroup, SelectDetail, SelectOption } from './types.js';
|
|
3
|
+
export interface AutocompleteRef extends HTMLElement {
|
|
4
|
+
/** Opens the suggestion dropdown. */
|
|
5
|
+
open(): void;
|
|
6
|
+
/** Closes the suggestion dropdown. */
|
|
7
|
+
close(): void;
|
|
8
|
+
/** Clears all selections (multi-mode) or the input (single-mode). */
|
|
9
|
+
clear(): void;
|
|
10
|
+
/** Focuses the search input. */
|
|
11
|
+
focus(): void;
|
|
12
|
+
}
|
|
13
|
+
export interface AutocompleteProps {
|
|
14
|
+
id?: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
variant?: 'outline' | 'filled' | 'ghost';
|
|
17
|
+
shape?: 'sharp' | 'rounded' | 'pill';
|
|
18
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
19
|
+
/** `'single'` for single select, `'multiple'` for multi-select with chips. */
|
|
20
|
+
mode?: 'single' | 'multiple';
|
|
21
|
+
selected?: string[] | string;
|
|
22
|
+
/** Current search query text. Controlled by `onInput` events. */
|
|
23
|
+
query?: string;
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
helperText?: string;
|
|
26
|
+
error?: string;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
required?: boolean;
|
|
29
|
+
readonly?: boolean;
|
|
30
|
+
name?: string;
|
|
31
|
+
/** When true, user can submit values not in the items list. */
|
|
32
|
+
allowCustom?: boolean;
|
|
33
|
+
clearable?: boolean;
|
|
34
|
+
/** Options to filter from. Filtering is client-side (fuzzy substring match). For server-side search, update this array in your `onInput` handler. */
|
|
35
|
+
items?: SelectOption[] | string;
|
|
36
|
+
groups?: OptionGroup[] | string;
|
|
37
|
+
onInput?: (event: CustomEvent<InputDetail>) => void;
|
|
38
|
+
onChange?: (event: CustomEvent<SelectDetail>) => void;
|
|
39
|
+
onFocus?: (event: CustomEvent<FocusDetail>) => void;
|
|
40
|
+
onBlur?: (event: CustomEvent<FocusDetail>) => void;
|
|
41
|
+
onKeydown?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
42
|
+
onKeyup?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
43
|
+
className?: string;
|
|
44
|
+
style?: React.CSSProperties;
|
|
45
|
+
}
|
|
46
|
+
export declare const Autocomplete: React.ForwardRefExoticComponent<AutocompleteProps & React.RefAttributes<AutocompleteRef>>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Autocomplete = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
const onInputRef = useRef(props.onInput);
|
|
7
|
+
onInputRef.current = props.onInput;
|
|
8
|
+
const onChangeRef = useRef(props.onChange);
|
|
9
|
+
onChangeRef.current = props.onChange;
|
|
10
|
+
const onFocusRef = useRef(props.onFocus);
|
|
11
|
+
onFocusRef.current = props.onFocus;
|
|
12
|
+
const onBlurRef = useRef(props.onBlur);
|
|
13
|
+
onBlurRef.current = props.onBlur;
|
|
14
|
+
const onKeydownRef = useRef(props.onKeydown);
|
|
15
|
+
onKeydownRef.current = props.onKeydown;
|
|
16
|
+
const onKeyupRef = useRef(props.onKeyup);
|
|
17
|
+
onKeyupRef.current = props.onKeyup;
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const el = ref.current;
|
|
20
|
+
if (!el)
|
|
21
|
+
return;
|
|
22
|
+
const handler = (e) => onInputRef.current?.(e);
|
|
23
|
+
el.addEventListener('cx-input', handler);
|
|
24
|
+
return () => el.removeEventListener('cx-input', handler);
|
|
25
|
+
}, []);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const el = ref.current;
|
|
28
|
+
if (!el)
|
|
29
|
+
return;
|
|
30
|
+
const handler = (e) => onChangeRef.current?.(e);
|
|
31
|
+
el.addEventListener('cx-change', handler);
|
|
32
|
+
return () => el.removeEventListener('cx-change', handler);
|
|
33
|
+
}, []);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const el = ref.current;
|
|
36
|
+
if (!el)
|
|
37
|
+
return;
|
|
38
|
+
const handler = (e) => onFocusRef.current?.(e);
|
|
39
|
+
el.addEventListener('cx-focus', handler);
|
|
40
|
+
return () => el.removeEventListener('cx-focus', handler);
|
|
41
|
+
}, []);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const el = ref.current;
|
|
44
|
+
if (!el)
|
|
45
|
+
return;
|
|
46
|
+
const handler = (e) => onBlurRef.current?.(e);
|
|
47
|
+
el.addEventListener('cx-blur', handler);
|
|
48
|
+
return () => el.removeEventListener('cx-blur', handler);
|
|
49
|
+
}, []);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const el = ref.current;
|
|
52
|
+
if (!el)
|
|
53
|
+
return;
|
|
54
|
+
const handler = (e) => onKeydownRef.current?.(e);
|
|
55
|
+
el.addEventListener('cx-keydown', handler);
|
|
56
|
+
return () => el.removeEventListener('cx-keydown', handler);
|
|
57
|
+
}, []);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const el = ref.current;
|
|
60
|
+
if (!el)
|
|
61
|
+
return;
|
|
62
|
+
const handler = (e) => onKeyupRef.current?.(e);
|
|
63
|
+
el.addEventListener('cx-keyup', handler);
|
|
64
|
+
return () => el.removeEventListener('cx-keyup', handler);
|
|
65
|
+
}, []);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const el = ref.current;
|
|
68
|
+
if (!el)
|
|
69
|
+
return;
|
|
70
|
+
if (props.name != null) {
|
|
71
|
+
el.setAttribute('name', String(props.name));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
el.removeAttribute('name');
|
|
75
|
+
}
|
|
76
|
+
}, [props.name]);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const el = ref.current;
|
|
79
|
+
if (!el)
|
|
80
|
+
return;
|
|
81
|
+
if (props.selected != null) {
|
|
82
|
+
el.setAttribute('selected', typeof props.selected === 'object' ? JSON.stringify(props.selected) : String(props.selected));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
el.removeAttribute('selected');
|
|
86
|
+
}
|
|
87
|
+
}, [props.selected]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
const el = ref.current;
|
|
90
|
+
if (!el)
|
|
91
|
+
return;
|
|
92
|
+
if (props.items != null) {
|
|
93
|
+
el.setAttribute('items', typeof props.items === 'object' ? JSON.stringify(props.items) : String(props.items));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
el.removeAttribute('items');
|
|
97
|
+
}
|
|
98
|
+
}, [props.items]);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
const el = ref.current;
|
|
101
|
+
if (!el)
|
|
102
|
+
return;
|
|
103
|
+
if (props.groups != null) {
|
|
104
|
+
el.setAttribute('groups', typeof props.groups === 'object' ? JSON.stringify(props.groups) : String(props.groups));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
el.removeAttribute('groups');
|
|
108
|
+
}
|
|
109
|
+
}, [props.groups]);
|
|
110
|
+
// Build attribute object
|
|
111
|
+
const attrs = {};
|
|
112
|
+
if (props.id != null)
|
|
113
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
114
|
+
if (props.label != null)
|
|
115
|
+
attrs['label'] = typeof props.label === 'object' ? JSON.stringify(props.label) : String(props.label);
|
|
116
|
+
if (props.variant != null)
|
|
117
|
+
attrs['variant'] = typeof props.variant === 'object' ? JSON.stringify(props.variant) : String(props.variant);
|
|
118
|
+
if (props.shape != null)
|
|
119
|
+
attrs['shape'] = typeof props.shape === 'object' ? JSON.stringify(props.shape) : String(props.shape);
|
|
120
|
+
if (props.size != null)
|
|
121
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
122
|
+
if (props.mode != null)
|
|
123
|
+
attrs['mode'] = typeof props.mode === 'object' ? JSON.stringify(props.mode) : String(props.mode);
|
|
124
|
+
if (props.query != null)
|
|
125
|
+
attrs['query'] = typeof props.query === 'object' ? JSON.stringify(props.query) : String(props.query);
|
|
126
|
+
if (props.placeholder != null)
|
|
127
|
+
attrs['placeholder'] = typeof props.placeholder === 'object' ? JSON.stringify(props.placeholder) : String(props.placeholder);
|
|
128
|
+
if (props.helperText != null)
|
|
129
|
+
attrs['helper-text'] = typeof props.helperText === 'object' ? JSON.stringify(props.helperText) : String(props.helperText);
|
|
130
|
+
if (props.error != null)
|
|
131
|
+
attrs['error'] = typeof props.error === 'object' ? JSON.stringify(props.error) : String(props.error);
|
|
132
|
+
if (props.disabled)
|
|
133
|
+
attrs['disabled'] = '';
|
|
134
|
+
if (props.required)
|
|
135
|
+
attrs['required'] = '';
|
|
136
|
+
if (props.readonly)
|
|
137
|
+
attrs['readonly'] = '';
|
|
138
|
+
if (props.allowCustom)
|
|
139
|
+
attrs['allow-custom'] = '';
|
|
140
|
+
if (props.clearable)
|
|
141
|
+
attrs['clearable'] = '';
|
|
142
|
+
return (_jsx("cx-autocomplete", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
143
|
+
});
|
|
144
|
+
Autocomplete.displayName = 'Autocomplete';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface AvatarProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
shape?: 'circle' | 'rounded';
|
|
6
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
7
|
+
image?: string;
|
|
8
|
+
initials?: string;
|
|
9
|
+
clickable?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
}
|
|
13
|
+
export declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Avatar = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
// Build attribute object
|
|
7
|
+
const attrs = {};
|
|
8
|
+
if (props.id != null)
|
|
9
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
10
|
+
if (props.label != null)
|
|
11
|
+
attrs['label'] = typeof props.label === 'object' ? JSON.stringify(props.label) : String(props.label);
|
|
12
|
+
if (props.shape != null)
|
|
13
|
+
attrs['shape'] = typeof props.shape === 'object' ? JSON.stringify(props.shape) : String(props.shape);
|
|
14
|
+
if (props.size != null)
|
|
15
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
16
|
+
if (props.image != null)
|
|
17
|
+
attrs['image'] = typeof props.image === 'object' ? JSON.stringify(props.image) : String(props.image);
|
|
18
|
+
if (props.initials != null)
|
|
19
|
+
attrs['initials'] = typeof props.initials === 'object' ? JSON.stringify(props.initials) : String(props.initials);
|
|
20
|
+
if (props.clickable)
|
|
21
|
+
attrs['clickable'] = '';
|
|
22
|
+
return (_jsx("cx-avatar", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
23
|
+
});
|
|
24
|
+
Avatar.displayName = 'Avatar';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface BackdropProps {
|
|
3
|
+
tint?: string;
|
|
4
|
+
blur?: string;
|
|
5
|
+
dismissible?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
export declare const Backdrop: React.ForwardRefExoticComponent<BackdropProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Backdrop = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
// Build attribute object
|
|
7
|
+
const attrs = {};
|
|
8
|
+
if (props.tint != null)
|
|
9
|
+
attrs['tint'] = typeof props.tint === 'object' ? JSON.stringify(props.tint) : String(props.tint);
|
|
10
|
+
if (props.blur != null)
|
|
11
|
+
attrs['blur'] = typeof props.blur === 'object' ? JSON.stringify(props.blur) : String(props.blur);
|
|
12
|
+
if (props.dismissible)
|
|
13
|
+
attrs['dismissible'] = '';
|
|
14
|
+
return (_jsx("cx-backdrop", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
15
|
+
});
|
|
16
|
+
Backdrop.displayName = 'Backdrop';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface BadgeProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
variant?: 'filled' | 'outline' | 'ghost';
|
|
6
|
+
intent?: 'neutral' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
7
|
+
shape?: 'rounded' | 'pill';
|
|
8
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
9
|
+
dot?: boolean;
|
|
10
|
+
dismissible?: boolean;
|
|
11
|
+
dismissLabel?: string;
|
|
12
|
+
dynamic?: boolean;
|
|
13
|
+
onDismiss?: (event: CustomEvent) => void;
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
}
|
|
17
|
+
export declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Badge = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
const onDismissRef = useRef(props.onDismiss);
|
|
7
|
+
onDismissRef.current = props.onDismiss;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const el = ref.current;
|
|
10
|
+
if (!el)
|
|
11
|
+
return;
|
|
12
|
+
const handler = (e) => onDismissRef.current?.(e);
|
|
13
|
+
el.addEventListener('cx-dismiss', handler);
|
|
14
|
+
return () => el.removeEventListener('cx-dismiss', handler);
|
|
15
|
+
}, []);
|
|
16
|
+
// Build attribute object
|
|
17
|
+
const attrs = {};
|
|
18
|
+
if (props.id != null)
|
|
19
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
20
|
+
if (props.label != null)
|
|
21
|
+
attrs['label'] = typeof props.label === 'object' ? JSON.stringify(props.label) : String(props.label);
|
|
22
|
+
if (props.variant != null)
|
|
23
|
+
attrs['variant'] = typeof props.variant === 'object' ? JSON.stringify(props.variant) : String(props.variant);
|
|
24
|
+
if (props.intent != null)
|
|
25
|
+
attrs['intent'] = typeof props.intent === 'object' ? JSON.stringify(props.intent) : String(props.intent);
|
|
26
|
+
if (props.shape != null)
|
|
27
|
+
attrs['shape'] = typeof props.shape === 'object' ? JSON.stringify(props.shape) : String(props.shape);
|
|
28
|
+
if (props.size != null)
|
|
29
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
30
|
+
if (props.dot)
|
|
31
|
+
attrs['dot'] = '';
|
|
32
|
+
if (props.dismissible)
|
|
33
|
+
attrs['dismissible'] = '';
|
|
34
|
+
if (props.dismissLabel != null)
|
|
35
|
+
attrs['dismiss-label'] = typeof props.dismissLabel === 'object' ? JSON.stringify(props.dismissLabel) : String(props.dismissLabel);
|
|
36
|
+
if (props.dynamic)
|
|
37
|
+
attrs['dynamic'] = '';
|
|
38
|
+
return (_jsx("cx-badge", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
39
|
+
});
|
|
40
|
+
Badge.displayName = 'Badge';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { BreadcrumbItem, NavigateDetail } from './types.js';
|
|
3
|
+
export interface BreadcrumbProps {
|
|
4
|
+
id?: string;
|
|
5
|
+
items?: BreadcrumbItem[] | string;
|
|
6
|
+
separator?: string;
|
|
7
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
8
|
+
navLabel?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
onNavigate?: (event: CustomEvent<NavigateDetail>) => void;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
export declare const Breadcrumb: React.ForwardRefExoticComponent<BreadcrumbProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Breadcrumb = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
const onNavigateRef = useRef(props.onNavigate);
|
|
7
|
+
onNavigateRef.current = props.onNavigate;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const el = ref.current;
|
|
10
|
+
if (!el)
|
|
11
|
+
return;
|
|
12
|
+
const handler = (e) => onNavigateRef.current?.(e);
|
|
13
|
+
el.addEventListener('cx-navigate', handler);
|
|
14
|
+
return () => el.removeEventListener('cx-navigate', handler);
|
|
15
|
+
}, []);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const el = ref.current;
|
|
18
|
+
if (!el)
|
|
19
|
+
return;
|
|
20
|
+
if (props.items != null) {
|
|
21
|
+
el.setAttribute('items', typeof props.items === 'object' ? JSON.stringify(props.items) : String(props.items));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
el.removeAttribute('items');
|
|
25
|
+
}
|
|
26
|
+
}, [props.items]);
|
|
27
|
+
// Build attribute object
|
|
28
|
+
const attrs = {};
|
|
29
|
+
if (props.id != null)
|
|
30
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
31
|
+
if (props.separator != null)
|
|
32
|
+
attrs['separator'] = typeof props.separator === 'object' ? JSON.stringify(props.separator) : String(props.separator);
|
|
33
|
+
if (props.size != null)
|
|
34
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
35
|
+
if (props.navLabel != null)
|
|
36
|
+
attrs['nav-label'] = typeof props.navLabel === 'object' ? JSON.stringify(props.navLabel) : String(props.navLabel);
|
|
37
|
+
if (props.disabled)
|
|
38
|
+
attrs['disabled'] = '';
|
|
39
|
+
return (_jsx("cx-breadcrumb", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
40
|
+
});
|
|
41
|
+
Breadcrumb.displayName = 'Breadcrumb';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ClickDetail } from './types.js';
|
|
3
|
+
export interface ButtonProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
variant?: 'filled' | 'ghost' | 'outline' | 'underline' | 'side-indicator';
|
|
6
|
+
intent?: 'neutral' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
7
|
+
shape?: 'sharp' | 'rounded' | 'pill';
|
|
8
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
iconLeading?: string;
|
|
11
|
+
iconTrailing?: string;
|
|
12
|
+
iconOnly?: string;
|
|
13
|
+
ariaLabel?: string;
|
|
14
|
+
kind?: 'button' | 'submit' | 'toggle' | 'link';
|
|
15
|
+
pressed?: boolean;
|
|
16
|
+
href?: string;
|
|
17
|
+
onClick?: (event: CustomEvent<ClickDetail>) => void;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
}
|
|
21
|
+
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLElement>>;
|