@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
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Table = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
const onSortRef = useRef(props.onSort);
|
|
7
|
+
onSortRef.current = props.onSort;
|
|
8
|
+
const onSelectRef = useRef(props.onSelect);
|
|
9
|
+
onSelectRef.current = props.onSelect;
|
|
10
|
+
const onExpandRef = useRef(props.onExpand);
|
|
11
|
+
onExpandRef.current = props.onExpand;
|
|
12
|
+
const onPageRef = useRef(props.onPage);
|
|
13
|
+
onPageRef.current = props.onPage;
|
|
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) => onSortRef.current?.(e);
|
|
23
|
+
el.addEventListener('cx-sort', handler);
|
|
24
|
+
return () => el.removeEventListener('cx-sort', handler);
|
|
25
|
+
}, []);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const el = ref.current;
|
|
28
|
+
if (!el)
|
|
29
|
+
return;
|
|
30
|
+
const handler = (e) => onSelectRef.current?.(e);
|
|
31
|
+
el.addEventListener('cx-select', handler);
|
|
32
|
+
return () => el.removeEventListener('cx-select', handler);
|
|
33
|
+
}, []);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const el = ref.current;
|
|
36
|
+
if (!el)
|
|
37
|
+
return;
|
|
38
|
+
const handler = (e) => onExpandRef.current?.(e);
|
|
39
|
+
el.addEventListener('cx-expand', handler);
|
|
40
|
+
return () => el.removeEventListener('cx-expand', handler);
|
|
41
|
+
}, []);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const el = ref.current;
|
|
44
|
+
if (!el)
|
|
45
|
+
return;
|
|
46
|
+
const handler = (e) => onPageRef.current?.(e);
|
|
47
|
+
el.addEventListener('cx-page', handler);
|
|
48
|
+
return () => el.removeEventListener('cx-page', 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.loading != null) {
|
|
71
|
+
el.setAttribute('loading', String(props.loading));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
el.removeAttribute('loading');
|
|
75
|
+
}
|
|
76
|
+
}, [props.loading]);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const el = ref.current;
|
|
79
|
+
if (!el)
|
|
80
|
+
return;
|
|
81
|
+
if (props.columns != null) {
|
|
82
|
+
el.setAttribute('columns', typeof props.columns === 'object' ? JSON.stringify(props.columns) : String(props.columns));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
el.removeAttribute('columns');
|
|
86
|
+
}
|
|
87
|
+
}, [props.columns]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
const el = ref.current;
|
|
90
|
+
if (!el)
|
|
91
|
+
return;
|
|
92
|
+
if (props.rows != null) {
|
|
93
|
+
el.setAttribute('rows', typeof props.rows === 'object' ? JSON.stringify(props.rows) : String(props.rows));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
el.removeAttribute('rows');
|
|
97
|
+
}
|
|
98
|
+
}, [props.rows]);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
const el = ref.current;
|
|
101
|
+
if (!el)
|
|
102
|
+
return;
|
|
103
|
+
if (props.selected != null) {
|
|
104
|
+
el.setAttribute('selected', typeof props.selected === 'object' ? JSON.stringify(props.selected) : String(props.selected));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
el.removeAttribute('selected');
|
|
108
|
+
}
|
|
109
|
+
}, [props.selected]);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const el = ref.current;
|
|
112
|
+
if (!el)
|
|
113
|
+
return;
|
|
114
|
+
if (props.sorts != null) {
|
|
115
|
+
el.setAttribute('sorts', typeof props.sorts === 'object' ? JSON.stringify(props.sorts) : String(props.sorts));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
el.removeAttribute('sorts');
|
|
119
|
+
}
|
|
120
|
+
}, [props.sorts]);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
const el = ref.current;
|
|
123
|
+
if (!el)
|
|
124
|
+
return;
|
|
125
|
+
if (props.pagination != null) {
|
|
126
|
+
el.setAttribute('pagination', typeof props.pagination === 'object' ? JSON.stringify(props.pagination) : String(props.pagination));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
el.removeAttribute('pagination');
|
|
130
|
+
}
|
|
131
|
+
}, [props.pagination]);
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
const el = ref.current;
|
|
134
|
+
if (!el)
|
|
135
|
+
return;
|
|
136
|
+
if (props.footer != null) {
|
|
137
|
+
el.setAttribute('footer', typeof props.footer === 'object' ? JSON.stringify(props.footer) : String(props.footer));
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
el.removeAttribute('footer');
|
|
141
|
+
}
|
|
142
|
+
}, [props.footer]);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
const el = ref.current;
|
|
145
|
+
if (!el)
|
|
146
|
+
return;
|
|
147
|
+
if (props.emptyState != null) {
|
|
148
|
+
el.setAttribute('empty-state', typeof props.emptyState === 'object' ? JSON.stringify(props.emptyState) : String(props.emptyState));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
el.removeAttribute('empty-state');
|
|
152
|
+
}
|
|
153
|
+
}, [props.emptyState]);
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
const el = ref.current;
|
|
156
|
+
if (!el)
|
|
157
|
+
return;
|
|
158
|
+
if (props.columnOrder != null) {
|
|
159
|
+
el.setAttribute('column-order', typeof props.columnOrder === 'object' ? JSON.stringify(props.columnOrder) : String(props.columnOrder));
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
el.removeAttribute('column-order');
|
|
163
|
+
}
|
|
164
|
+
}, [props.columnOrder]);
|
|
165
|
+
// Build attribute object
|
|
166
|
+
const attrs = {};
|
|
167
|
+
if (props.id != null)
|
|
168
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
169
|
+
if (props.caption != null)
|
|
170
|
+
attrs['caption'] = typeof props.caption === 'object' ? JSON.stringify(props.caption) : String(props.caption);
|
|
171
|
+
if (props.variant != null)
|
|
172
|
+
attrs['variant'] = typeof props.variant === 'object' ? JSON.stringify(props.variant) : String(props.variant);
|
|
173
|
+
if (props.size != null)
|
|
174
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
175
|
+
if (props.selectable != null)
|
|
176
|
+
attrs['selectable'] = typeof props.selectable === 'object' ? JSON.stringify(props.selectable) : String(props.selectable);
|
|
177
|
+
if (props.hoverable)
|
|
178
|
+
attrs['hoverable'] = '';
|
|
179
|
+
if (props.stickyHeader)
|
|
180
|
+
attrs['sticky-header'] = '';
|
|
181
|
+
if (props.disabled)
|
|
182
|
+
attrs['disabled'] = '';
|
|
183
|
+
if (props.error != null)
|
|
184
|
+
attrs['error'] = typeof props.error === 'object' ? JSON.stringify(props.error) : String(props.error);
|
|
185
|
+
return (_jsx("cx-table", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
186
|
+
});
|
|
187
|
+
Table.displayName = 'Table';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { SelectDetail, TabItem } from './types.js';
|
|
3
|
+
export interface TabsRef extends HTMLElement {
|
|
4
|
+
/** Focuses the active tab. */
|
|
5
|
+
focus(): void;
|
|
6
|
+
}
|
|
7
|
+
export interface TabsProps {
|
|
8
|
+
id?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
items?: TabItem[] | string;
|
|
11
|
+
defaultTab?: string;
|
|
12
|
+
variant?: 'underline' | 'enclosed' | 'pill';
|
|
13
|
+
orientation?: 'horizontal' | 'vertical';
|
|
14
|
+
width?: 'auto' | 'full';
|
|
15
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
16
|
+
onChange?: (event: CustomEvent<SelectDetail>) => void;
|
|
17
|
+
className?: string;
|
|
18
|
+
style?: React.CSSProperties;
|
|
19
|
+
}
|
|
20
|
+
export declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<TabsRef>>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Tabs = 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.width != null) {
|
|
21
|
+
el.setAttribute('width', String(props.width));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
el.removeAttribute('width');
|
|
25
|
+
}
|
|
26
|
+
}, [props.width]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const el = ref.current;
|
|
29
|
+
if (!el)
|
|
30
|
+
return;
|
|
31
|
+
if (props.items != null) {
|
|
32
|
+
el.setAttribute('items', typeof props.items === 'object' ? JSON.stringify(props.items) : String(props.items));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
el.removeAttribute('items');
|
|
36
|
+
}
|
|
37
|
+
}, [props.items]);
|
|
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.defaultTab != null)
|
|
45
|
+
attrs['default-tab'] = typeof props.defaultTab === 'object' ? JSON.stringify(props.defaultTab) : String(props.defaultTab);
|
|
46
|
+
if (props.variant != null)
|
|
47
|
+
attrs['variant'] = typeof props.variant === 'object' ? JSON.stringify(props.variant) : String(props.variant);
|
|
48
|
+
if (props.orientation != null)
|
|
49
|
+
attrs['orientation'] = typeof props.orientation === 'object' ? JSON.stringify(props.orientation) : String(props.orientation);
|
|
50
|
+
if (props.size != null)
|
|
51
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
52
|
+
return (_jsx("cx-tabs", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
53
|
+
});
|
|
54
|
+
Tabs.displayName = 'Tabs';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { FocusDetail, InputDetail, KeyboardDetail } from './types.js';
|
|
3
|
+
export interface TextInputRef extends HTMLElement {
|
|
4
|
+
/** Focuses the inner input or textarea. */
|
|
5
|
+
focus(): void;
|
|
6
|
+
/** Blurs the inner input or textarea. */
|
|
7
|
+
blur(): void;
|
|
8
|
+
/** Selects all text in the input. */
|
|
9
|
+
select(): void;
|
|
10
|
+
}
|
|
11
|
+
export interface TextInputProps {
|
|
12
|
+
id?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
variant?: 'outline' | 'filled' | 'ghost';
|
|
15
|
+
shape?: 'sharp' | 'rounded' | 'pill';
|
|
16
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
17
|
+
/** Input type. Use `'multiline'` for textarea behavior with optional `rows` and `autoGrow`. */
|
|
18
|
+
kind?: 'text' | 'email' | 'password' | 'search' | 'multiline';
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
/** Controlled value. Set via `onInput` callback: `onInput={(e) => setValue(e.detail.value)}`. */
|
|
21
|
+
value?: string;
|
|
22
|
+
helperText?: string;
|
|
23
|
+
error?: string;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
readonly?: boolean;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
clearable?: boolean;
|
|
28
|
+
prefixIcon?: string;
|
|
29
|
+
suffixIcon?: string;
|
|
30
|
+
passwordToggle?: boolean;
|
|
31
|
+
passwordVisible?: boolean;
|
|
32
|
+
name?: string;
|
|
33
|
+
minLength?: number;
|
|
34
|
+
maxLength?: number;
|
|
35
|
+
pattern?: string;
|
|
36
|
+
autocomplete?: string;
|
|
37
|
+
rows?: number;
|
|
38
|
+
autoGrow?: boolean;
|
|
39
|
+
onInput?: (event: CustomEvent<InputDetail>) => void;
|
|
40
|
+
onChange?: (event: CustomEvent<InputDetail>) => void;
|
|
41
|
+
onFocus?: (event: CustomEvent<FocusDetail>) => void;
|
|
42
|
+
onBlur?: (event: CustomEvent<FocusDetail>) => void;
|
|
43
|
+
onKeydown?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
44
|
+
onKeyup?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
45
|
+
className?: string;
|
|
46
|
+
style?: React.CSSProperties;
|
|
47
|
+
}
|
|
48
|
+
export declare const TextInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<TextInputRef>>;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const TextInput = 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.value != null) {
|
|
71
|
+
el.setAttribute('value', String(props.value));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
el.removeAttribute('value');
|
|
75
|
+
}
|
|
76
|
+
}, [props.value]);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const el = ref.current;
|
|
79
|
+
if (!el)
|
|
80
|
+
return;
|
|
81
|
+
if (props.name != null) {
|
|
82
|
+
el.setAttribute('name', String(props.name));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
el.removeAttribute('name');
|
|
86
|
+
}
|
|
87
|
+
}, [props.name]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
const el = ref.current;
|
|
90
|
+
if (!el)
|
|
91
|
+
return;
|
|
92
|
+
if (props.minLength != null) {
|
|
93
|
+
el.setAttribute('min-length', String(props.minLength));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
el.removeAttribute('min-length');
|
|
97
|
+
}
|
|
98
|
+
}, [props.minLength]);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
const el = ref.current;
|
|
101
|
+
if (!el)
|
|
102
|
+
return;
|
|
103
|
+
if (props.maxLength != null) {
|
|
104
|
+
el.setAttribute('max-length', String(props.maxLength));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
el.removeAttribute('max-length');
|
|
108
|
+
}
|
|
109
|
+
}, [props.maxLength]);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const el = ref.current;
|
|
112
|
+
if (!el)
|
|
113
|
+
return;
|
|
114
|
+
if (props.rows != null) {
|
|
115
|
+
el.setAttribute('rows', String(props.rows));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
el.removeAttribute('rows');
|
|
119
|
+
}
|
|
120
|
+
}, [props.rows]);
|
|
121
|
+
// Build attribute object
|
|
122
|
+
const attrs = {};
|
|
123
|
+
if (props.id != null)
|
|
124
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
125
|
+
if (props.label != null)
|
|
126
|
+
attrs['label'] = typeof props.label === 'object' ? JSON.stringify(props.label) : String(props.label);
|
|
127
|
+
if (props.variant != null)
|
|
128
|
+
attrs['variant'] = typeof props.variant === 'object' ? JSON.stringify(props.variant) : String(props.variant);
|
|
129
|
+
if (props.shape != null)
|
|
130
|
+
attrs['shape'] = typeof props.shape === 'object' ? JSON.stringify(props.shape) : String(props.shape);
|
|
131
|
+
if (props.size != null)
|
|
132
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
133
|
+
if (props.kind != null)
|
|
134
|
+
attrs['kind'] = typeof props.kind === 'object' ? JSON.stringify(props.kind) : String(props.kind);
|
|
135
|
+
if (props.placeholder != null)
|
|
136
|
+
attrs['placeholder'] = typeof props.placeholder === 'object' ? JSON.stringify(props.placeholder) : String(props.placeholder);
|
|
137
|
+
if (props.helperText != null)
|
|
138
|
+
attrs['helper-text'] = typeof props.helperText === 'object' ? JSON.stringify(props.helperText) : String(props.helperText);
|
|
139
|
+
if (props.error != null)
|
|
140
|
+
attrs['error'] = typeof props.error === 'object' ? JSON.stringify(props.error) : String(props.error);
|
|
141
|
+
if (props.disabled)
|
|
142
|
+
attrs['disabled'] = '';
|
|
143
|
+
if (props.readonly)
|
|
144
|
+
attrs['readonly'] = '';
|
|
145
|
+
if (props.required)
|
|
146
|
+
attrs['required'] = '';
|
|
147
|
+
if (props.clearable)
|
|
148
|
+
attrs['clearable'] = '';
|
|
149
|
+
if (props.prefixIcon != null)
|
|
150
|
+
attrs['prefix-icon'] = typeof props.prefixIcon === 'object' ? JSON.stringify(props.prefixIcon) : String(props.prefixIcon);
|
|
151
|
+
if (props.suffixIcon != null)
|
|
152
|
+
attrs['suffix-icon'] = typeof props.suffixIcon === 'object' ? JSON.stringify(props.suffixIcon) : String(props.suffixIcon);
|
|
153
|
+
if (props.passwordToggle)
|
|
154
|
+
attrs['password-toggle'] = '';
|
|
155
|
+
if (props.passwordVisible)
|
|
156
|
+
attrs['password-visible'] = '';
|
|
157
|
+
if (props.pattern != null)
|
|
158
|
+
attrs['pattern'] = typeof props.pattern === 'object' ? JSON.stringify(props.pattern) : String(props.pattern);
|
|
159
|
+
if (props.autocomplete != null)
|
|
160
|
+
attrs['autocomplete'] = typeof props.autocomplete === 'object' ? JSON.stringify(props.autocomplete) : String(props.autocomplete);
|
|
161
|
+
if (props.autoGrow)
|
|
162
|
+
attrs['auto-grow'] = '';
|
|
163
|
+
return (_jsx("cx-text-input", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
164
|
+
});
|
|
165
|
+
TextInput.displayName = 'TextInput';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface TextProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
role?: 'display' | 'h1' | 'h2' | 'h3' | 'label-lg' | 'label-md' | 'label-sm' | 'body-lg' | 'body-md' | 'body-sm' | 'overline' | 'caption' | 'code';
|
|
5
|
+
align?: 'start' | 'center' | 'end';
|
|
6
|
+
color?: 'primary' | 'inverse' | 'muted';
|
|
7
|
+
muted?: boolean;
|
|
8
|
+
strong?: boolean;
|
|
9
|
+
italic?: boolean;
|
|
10
|
+
underline?: boolean;
|
|
11
|
+
underlineStrong?: boolean;
|
|
12
|
+
truncate?: boolean;
|
|
13
|
+
lineClamp?: number;
|
|
14
|
+
balance?: boolean;
|
|
15
|
+
prose?: boolean;
|
|
16
|
+
elementAs?: string;
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
}
|
|
21
|
+
export declare const Text: React.ForwardRefExoticComponent<TextProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Text = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const el = ref.current;
|
|
8
|
+
if (!el)
|
|
9
|
+
return;
|
|
10
|
+
if (props.role != null) {
|
|
11
|
+
el.setAttribute('role', String(props.role));
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
el.removeAttribute('role');
|
|
15
|
+
}
|
|
16
|
+
}, [props.role]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const el = ref.current;
|
|
19
|
+
if (!el)
|
|
20
|
+
return;
|
|
21
|
+
if (props.align != null) {
|
|
22
|
+
el.setAttribute('align', String(props.align));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
el.removeAttribute('align');
|
|
26
|
+
}
|
|
27
|
+
}, [props.align]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const el = ref.current;
|
|
30
|
+
if (!el)
|
|
31
|
+
return;
|
|
32
|
+
if (props.color != null) {
|
|
33
|
+
el.setAttribute('color', String(props.color));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
el.removeAttribute('color');
|
|
37
|
+
}
|
|
38
|
+
}, [props.color]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const el = ref.current;
|
|
41
|
+
if (!el)
|
|
42
|
+
return;
|
|
43
|
+
if (props.lineClamp != null) {
|
|
44
|
+
el.setAttribute('line-clamp', String(props.lineClamp));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
el.removeAttribute('line-clamp');
|
|
48
|
+
}
|
|
49
|
+
}, [props.lineClamp]);
|
|
50
|
+
// Build attribute object
|
|
51
|
+
const attrs = {};
|
|
52
|
+
if (props.id != null)
|
|
53
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
54
|
+
if (props.muted)
|
|
55
|
+
attrs['muted'] = '';
|
|
56
|
+
if (props.strong)
|
|
57
|
+
attrs['strong'] = '';
|
|
58
|
+
if (props.italic)
|
|
59
|
+
attrs['italic'] = '';
|
|
60
|
+
if (props.underline)
|
|
61
|
+
attrs['underline'] = '';
|
|
62
|
+
if (props.underlineStrong)
|
|
63
|
+
attrs['underline-strong'] = '';
|
|
64
|
+
if (props.truncate)
|
|
65
|
+
attrs['truncate'] = '';
|
|
66
|
+
if (props.balance)
|
|
67
|
+
attrs['balance'] = '';
|
|
68
|
+
if (props.prose)
|
|
69
|
+
attrs['prose'] = '';
|
|
70
|
+
if (props.elementAs != null)
|
|
71
|
+
attrs['element-as'] = typeof props.elementAs === 'object' ? JSON.stringify(props.elementAs) : String(props.elementAs);
|
|
72
|
+
return (_jsx("cx-text", { ref: ref, ...attrs, className: props.className, style: props.style, children: props.children }));
|
|
73
|
+
});
|
|
74
|
+
Text.displayName = 'Text';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface ThinkingProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
variant?: 'ghost' | 'filled';
|
|
5
|
+
shape?: 'sharp' | 'rounded' | 'pill';
|
|
6
|
+
label?: string;
|
|
7
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
8
|
+
speed?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
}
|
|
12
|
+
export declare const Thinking: React.ForwardRefExoticComponent<ThinkingProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Thinking = 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.variant != null)
|
|
11
|
+
attrs['variant'] = typeof props.variant === 'object' ? JSON.stringify(props.variant) : String(props.variant);
|
|
12
|
+
if (props.shape != null)
|
|
13
|
+
attrs['shape'] = typeof props.shape === 'object' ? JSON.stringify(props.shape) : String(props.shape);
|
|
14
|
+
if (props.label != null)
|
|
15
|
+
attrs['label'] = typeof props.label === 'object' ? JSON.stringify(props.label) : String(props.label);
|
|
16
|
+
if (props.size != null)
|
|
17
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
18
|
+
if (props.speed != null)
|
|
19
|
+
attrs['speed'] = typeof props.speed === 'object' ? JSON.stringify(props.speed) : String(props.speed);
|
|
20
|
+
return (_jsx("cx-thinking", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
21
|
+
});
|
|
22
|
+
Thinking.displayName = 'Thinking';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { DismissDetail } from './types.js';
|
|
3
|
+
export interface ToastRef extends HTMLElement {
|
|
4
|
+
/** Dismisses the toast with exit animation. */
|
|
5
|
+
dismiss(): void;
|
|
6
|
+
}
|
|
7
|
+
export interface ToastProps {
|
|
8
|
+
id?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
variant?: 'subtle' | 'filled' | 'outline';
|
|
12
|
+
intent?: 'neutral' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
13
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
14
|
+
showIcon?: boolean;
|
|
15
|
+
icon?: string;
|
|
16
|
+
dismissible?: boolean;
|
|
17
|
+
dismissLabel?: string;
|
|
18
|
+
duration?: number;
|
|
19
|
+
onDismiss?: (event: CustomEvent<DismissDetail>) => void;
|
|
20
|
+
action?: React.ReactNode;
|
|
21
|
+
className?: string;
|
|
22
|
+
style?: React.CSSProperties;
|
|
23
|
+
}
|
|
24
|
+
export declare const Toast: React.ForwardRefExoticComponent<ToastProps & React.RefAttributes<ToastRef>>;
|