@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,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Progress = 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.value != null) {
|
|
11
|
+
el.setAttribute('value', String(props.value));
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
el.removeAttribute('value');
|
|
15
|
+
}
|
|
16
|
+
}, [props.value]);
|
|
17
|
+
// Build attribute object
|
|
18
|
+
const attrs = {};
|
|
19
|
+
if (props.id != null)
|
|
20
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
21
|
+
if (props.label != null)
|
|
22
|
+
attrs['label'] = typeof props.label === 'object' ? JSON.stringify(props.label) : String(props.label);
|
|
23
|
+
if (props.valueText != null)
|
|
24
|
+
attrs['value-text'] = typeof props.valueText === 'object' ? JSON.stringify(props.valueText) : String(props.valueText);
|
|
25
|
+
if (props.intent != null)
|
|
26
|
+
attrs['intent'] = typeof props.intent === 'object' ? JSON.stringify(props.intent) : String(props.intent);
|
|
27
|
+
if (props.shape != null)
|
|
28
|
+
attrs['shape'] = typeof props.shape === 'object' ? JSON.stringify(props.shape) : String(props.shape);
|
|
29
|
+
if (props.size != null)
|
|
30
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
31
|
+
return (_jsx("cx-progress", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
32
|
+
});
|
|
33
|
+
Progress.displayName = 'Progress';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { FocusDetail, KeyboardDetail, RadioOption, SelectDetail } from './types.js';
|
|
3
|
+
export interface RadioGroupProps {
|
|
4
|
+
name?: string;
|
|
5
|
+
legend: string;
|
|
6
|
+
options?: RadioOption[] | string;
|
|
7
|
+
shape?: 'round' | 'rounded';
|
|
8
|
+
orientation?: 'vertical' | 'horizontal';
|
|
9
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
10
|
+
selected?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
helperText?: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
onInput?: (event: CustomEvent) => void;
|
|
16
|
+
onChange?: (event: CustomEvent<SelectDetail>) => void;
|
|
17
|
+
onFocus?: (event: CustomEvent<FocusDetail>) => void;
|
|
18
|
+
onBlur?: (event: CustomEvent<FocusDetail>) => void;
|
|
19
|
+
onKeydown?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
20
|
+
onKeyup?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
21
|
+
className?: string;
|
|
22
|
+
style?: React.CSSProperties;
|
|
23
|
+
}
|
|
24
|
+
export declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const RadioGroup = 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.options != null) {
|
|
82
|
+
el.setAttribute('options', typeof props.options === 'object' ? JSON.stringify(props.options) : String(props.options));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
el.removeAttribute('options');
|
|
86
|
+
}
|
|
87
|
+
}, [props.options]);
|
|
88
|
+
// Build attribute object
|
|
89
|
+
const attrs = {};
|
|
90
|
+
if (props.legend != null)
|
|
91
|
+
attrs['legend'] = typeof props.legend === 'object' ? JSON.stringify(props.legend) : String(props.legend);
|
|
92
|
+
if (props.shape != null)
|
|
93
|
+
attrs['shape'] = typeof props.shape === 'object' ? JSON.stringify(props.shape) : String(props.shape);
|
|
94
|
+
if (props.orientation != null)
|
|
95
|
+
attrs['orientation'] = typeof props.orientation === 'object' ? JSON.stringify(props.orientation) : String(props.orientation);
|
|
96
|
+
if (props.size != null)
|
|
97
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
98
|
+
if (props.selected != null)
|
|
99
|
+
attrs['selected'] = typeof props.selected === 'object' ? JSON.stringify(props.selected) : String(props.selected);
|
|
100
|
+
if (props.disabled)
|
|
101
|
+
attrs['disabled'] = '';
|
|
102
|
+
if (props.required)
|
|
103
|
+
attrs['required'] = '';
|
|
104
|
+
if (props.helperText != null)
|
|
105
|
+
attrs['helper-text'] = typeof props.helperText === 'object' ? JSON.stringify(props.helperText) : String(props.helperText);
|
|
106
|
+
if (props.error != null)
|
|
107
|
+
attrs['error'] = typeof props.error === 'object' ? JSON.stringify(props.error) : String(props.error);
|
|
108
|
+
return (_jsx("cx-radio-group", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
109
|
+
});
|
|
110
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface ScrollbarProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
shape?: 'sharp' | 'rounded' | 'pill';
|
|
5
|
+
track?: 'with-track' | 'floating';
|
|
6
|
+
axis?: 'vertical' | 'horizontal' | 'both';
|
|
7
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
8
|
+
height?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
export declare const Scrollbar: React.ForwardRefExoticComponent<ScrollbarProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Scrollbar = 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.height != null) {
|
|
11
|
+
el.setAttribute('height', String(props.height));
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
el.removeAttribute('height');
|
|
15
|
+
}
|
|
16
|
+
}, [props.height]);
|
|
17
|
+
// Build attribute object
|
|
18
|
+
const attrs = {};
|
|
19
|
+
if (props.id != null)
|
|
20
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
21
|
+
if (props.shape != null)
|
|
22
|
+
attrs['shape'] = typeof props.shape === 'object' ? JSON.stringify(props.shape) : String(props.shape);
|
|
23
|
+
if (props.track != null)
|
|
24
|
+
attrs['track'] = typeof props.track === 'object' ? JSON.stringify(props.track) : String(props.track);
|
|
25
|
+
if (props.axis != null)
|
|
26
|
+
attrs['axis'] = typeof props.axis === 'object' ? JSON.stringify(props.axis) : String(props.axis);
|
|
27
|
+
if (props.size != null)
|
|
28
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
29
|
+
if (props.label != null)
|
|
30
|
+
attrs['label'] = typeof props.label === 'object' ? JSON.stringify(props.label) : String(props.label);
|
|
31
|
+
return (_jsx("cx-scrollbar", { ref: ref, ...attrs, className: props.className, style: props.style, children: props.children }));
|
|
32
|
+
});
|
|
33
|
+
Scrollbar.displayName = 'Scrollbar';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { FocusDetail, KeyboardDetail } from './types.js';
|
|
3
|
+
export interface SearchBarRef extends HTMLElement {
|
|
4
|
+
/** Focuses the search input. */
|
|
5
|
+
focus(): void;
|
|
6
|
+
/** Clears the search input value. */
|
|
7
|
+
clear(): void;
|
|
8
|
+
}
|
|
9
|
+
export interface SearchBarProps {
|
|
10
|
+
id?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
variant?: 'outline' | 'filled' | 'ghost';
|
|
14
|
+
shape?: 'sharp' | 'rounded' | 'pill';
|
|
15
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
16
|
+
name?: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
debounceMs?: number;
|
|
19
|
+
loading?: boolean;
|
|
20
|
+
shortcut?: string;
|
|
21
|
+
expandable?: boolean;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
readonly?: boolean;
|
|
24
|
+
controls?: string;
|
|
25
|
+
shimmer?: boolean;
|
|
26
|
+
onFocus?: (event: CustomEvent<FocusDetail>) => void;
|
|
27
|
+
onBlur?: (event: CustomEvent<FocusDetail>) => void;
|
|
28
|
+
onKeydown?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
29
|
+
onKeyup?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
30
|
+
className?: string;
|
|
31
|
+
style?: React.CSSProperties;
|
|
32
|
+
}
|
|
33
|
+
export declare const SearchBar: React.ForwardRefExoticComponent<SearchBarProps & React.RefAttributes<SearchBarRef>>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const SearchBar = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
const onFocusRef = useRef(props.onFocus);
|
|
7
|
+
onFocusRef.current = props.onFocus;
|
|
8
|
+
const onBlurRef = useRef(props.onBlur);
|
|
9
|
+
onBlurRef.current = props.onBlur;
|
|
10
|
+
const onKeydownRef = useRef(props.onKeydown);
|
|
11
|
+
onKeydownRef.current = props.onKeydown;
|
|
12
|
+
const onKeyupRef = useRef(props.onKeyup);
|
|
13
|
+
onKeyupRef.current = props.onKeyup;
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const el = ref.current;
|
|
16
|
+
if (!el)
|
|
17
|
+
return;
|
|
18
|
+
const handler = (e) => onFocusRef.current?.(e);
|
|
19
|
+
el.addEventListener('cx-focus', handler);
|
|
20
|
+
return () => el.removeEventListener('cx-focus', handler);
|
|
21
|
+
}, []);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const el = ref.current;
|
|
24
|
+
if (!el)
|
|
25
|
+
return;
|
|
26
|
+
const handler = (e) => onBlurRef.current?.(e);
|
|
27
|
+
el.addEventListener('cx-blur', handler);
|
|
28
|
+
return () => el.removeEventListener('cx-blur', handler);
|
|
29
|
+
}, []);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const el = ref.current;
|
|
32
|
+
if (!el)
|
|
33
|
+
return;
|
|
34
|
+
const handler = (e) => onKeydownRef.current?.(e);
|
|
35
|
+
el.addEventListener('cx-keydown', handler);
|
|
36
|
+
return () => el.removeEventListener('cx-keydown', handler);
|
|
37
|
+
}, []);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const el = ref.current;
|
|
40
|
+
if (!el)
|
|
41
|
+
return;
|
|
42
|
+
const handler = (e) => onKeyupRef.current?.(e);
|
|
43
|
+
el.addEventListener('cx-keyup', handler);
|
|
44
|
+
return () => el.removeEventListener('cx-keyup', handler);
|
|
45
|
+
}, []);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const el = ref.current;
|
|
48
|
+
if (!el)
|
|
49
|
+
return;
|
|
50
|
+
if (props.name != null) {
|
|
51
|
+
el.setAttribute('name', String(props.name));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
el.removeAttribute('name');
|
|
55
|
+
}
|
|
56
|
+
}, [props.name]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const el = ref.current;
|
|
59
|
+
if (!el)
|
|
60
|
+
return;
|
|
61
|
+
if (props.value != null) {
|
|
62
|
+
el.setAttribute('value', String(props.value));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
el.removeAttribute('value');
|
|
66
|
+
}
|
|
67
|
+
}, [props.value]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const el = ref.current;
|
|
70
|
+
if (!el)
|
|
71
|
+
return;
|
|
72
|
+
if (props.loading != null) {
|
|
73
|
+
el.setAttribute('loading', String(props.loading));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
el.removeAttribute('loading');
|
|
77
|
+
}
|
|
78
|
+
}, [props.loading]);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
const el = ref.current;
|
|
81
|
+
if (!el)
|
|
82
|
+
return;
|
|
83
|
+
if (props.debounceMs != null) {
|
|
84
|
+
el.setAttribute('debounce-ms', String(props.debounceMs));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
el.removeAttribute('debounce-ms');
|
|
88
|
+
}
|
|
89
|
+
}, [props.debounceMs]);
|
|
90
|
+
// Build attribute object
|
|
91
|
+
const attrs = {};
|
|
92
|
+
if (props.id != null)
|
|
93
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
94
|
+
if (props.placeholder != null)
|
|
95
|
+
attrs['placeholder'] = typeof props.placeholder === 'object' ? JSON.stringify(props.placeholder) : String(props.placeholder);
|
|
96
|
+
if (props.label != null)
|
|
97
|
+
attrs['label'] = typeof props.label === 'object' ? JSON.stringify(props.label) : String(props.label);
|
|
98
|
+
if (props.variant != null)
|
|
99
|
+
attrs['variant'] = typeof props.variant === 'object' ? JSON.stringify(props.variant) : String(props.variant);
|
|
100
|
+
if (props.shape != null)
|
|
101
|
+
attrs['shape'] = typeof props.shape === 'object' ? JSON.stringify(props.shape) : String(props.shape);
|
|
102
|
+
if (props.size != null)
|
|
103
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
104
|
+
if (props.shortcut != null)
|
|
105
|
+
attrs['shortcut'] = typeof props.shortcut === 'object' ? JSON.stringify(props.shortcut) : String(props.shortcut);
|
|
106
|
+
if (props.expandable)
|
|
107
|
+
attrs['expandable'] = '';
|
|
108
|
+
if (props.disabled)
|
|
109
|
+
attrs['disabled'] = '';
|
|
110
|
+
if (props.readonly)
|
|
111
|
+
attrs['readonly'] = '';
|
|
112
|
+
if (props.controls != null)
|
|
113
|
+
attrs['controls'] = typeof props.controls === 'object' ? JSON.stringify(props.controls) : String(props.controls);
|
|
114
|
+
if (props.shimmer)
|
|
115
|
+
attrs['shimmer'] = '';
|
|
116
|
+
return (_jsx("cx-search-bar", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
117
|
+
});
|
|
118
|
+
SearchBar.displayName = 'SearchBar';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { FocusDetail, InputDetail, KeyboardDetail, OptionGroup, SelectDetail, SelectOption } from './types.js';
|
|
3
|
+
export interface SelectRef extends HTMLElement {
|
|
4
|
+
/** Opens the dropdown. */
|
|
5
|
+
open(): void;
|
|
6
|
+
/** Closes the dropdown. */
|
|
7
|
+
close(): void;
|
|
8
|
+
/** Focuses the trigger button. */
|
|
9
|
+
focus(): void;
|
|
10
|
+
}
|
|
11
|
+
export interface SelectProps {
|
|
12
|
+
id?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
variant?: 'outline' | 'filled' | 'ghost';
|
|
15
|
+
shape?: 'sharp' | 'rounded' | 'pill';
|
|
16
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
17
|
+
mode?: 'single' | 'multiple';
|
|
18
|
+
selected?: string[] | string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
helperText?: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
name?: string;
|
|
25
|
+
items?: SelectOption[] | string;
|
|
26
|
+
groups?: OptionGroup[] | string;
|
|
27
|
+
onInput?: (event: CustomEvent<InputDetail>) => void;
|
|
28
|
+
onChange?: (event: CustomEvent<SelectDetail>) => void;
|
|
29
|
+
onFocus?: (event: CustomEvent<FocusDetail>) => void;
|
|
30
|
+
onBlur?: (event: CustomEvent<FocusDetail>) => void;
|
|
31
|
+
onKeydown?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
32
|
+
onKeyup?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
33
|
+
className?: string;
|
|
34
|
+
style?: React.CSSProperties;
|
|
35
|
+
}
|
|
36
|
+
export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<SelectRef>>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Select = 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.placeholder != null)
|
|
125
|
+
attrs['placeholder'] = typeof props.placeholder === 'object' ? JSON.stringify(props.placeholder) : String(props.placeholder);
|
|
126
|
+
if (props.helperText != null)
|
|
127
|
+
attrs['helper-text'] = typeof props.helperText === 'object' ? JSON.stringify(props.helperText) : String(props.helperText);
|
|
128
|
+
if (props.error != null)
|
|
129
|
+
attrs['error'] = typeof props.error === 'object' ? JSON.stringify(props.error) : String(props.error);
|
|
130
|
+
if (props.disabled)
|
|
131
|
+
attrs['disabled'] = '';
|
|
132
|
+
if (props.required)
|
|
133
|
+
attrs['required'] = '';
|
|
134
|
+
return (_jsx("cx-select", { ref: ref, ...attrs, className: props.className, style: props.style }));
|
|
135
|
+
});
|
|
136
|
+
Select.displayName = 'Select';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Serialize React.ReactNode content fields to HTML strings.
|
|
2
|
+
// Used by Tier 2 wrappers (Accordion, Tabs, Table) that pass
|
|
3
|
+
// HTML content as JSON attributes to WASM-rendered custom elements.
|
|
4
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
5
|
+
export function serializeContent(content) {
|
|
6
|
+
if (typeof content === 'string')
|
|
7
|
+
return content;
|
|
8
|
+
if (content == null || typeof content === 'boolean')
|
|
9
|
+
return '';
|
|
10
|
+
if (typeof content === 'number')
|
|
11
|
+
return String(content);
|
|
12
|
+
return renderToStaticMarkup(content);
|
|
13
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { CloseDetail, NavigateDetail, SidebarGroup } from './types.js';
|
|
3
|
+
export interface SidebarRef extends HTMLElement {
|
|
4
|
+
/** Opens the mobile sidebar drawer. */
|
|
5
|
+
open(): void;
|
|
6
|
+
/** Closes the mobile sidebar drawer. */
|
|
7
|
+
close(): void;
|
|
8
|
+
}
|
|
9
|
+
export interface SidebarProps {
|
|
10
|
+
id?: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
groups?: SidebarGroup[] | string;
|
|
13
|
+
separatorsAfter?: string;
|
|
14
|
+
side?: 'left' | 'right';
|
|
15
|
+
state?: 'expanded' | 'narrow' | 'hidden';
|
|
16
|
+
shape?: 'sharp' | 'rounded' | 'pill';
|
|
17
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
18
|
+
onClose?: (event: CustomEvent<CloseDetail>) => void;
|
|
19
|
+
onNavigate?: (event: CustomEvent<NavigateDetail>) => void;
|
|
20
|
+
header?: React.ReactNode;
|
|
21
|
+
footer?: React.ReactNode;
|
|
22
|
+
className?: string;
|
|
23
|
+
style?: React.CSSProperties;
|
|
24
|
+
}
|
|
25
|
+
export declare const Sidebar: React.ForwardRefExoticComponent<SidebarProps & React.RefAttributes<SidebarRef>>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
export const Sidebar = forwardRef((props, forwardedRef) => {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
6
|
+
const onCloseRef = useRef(props.onClose);
|
|
7
|
+
onCloseRef.current = props.onClose;
|
|
8
|
+
const onNavigateRef = useRef(props.onNavigate);
|
|
9
|
+
onNavigateRef.current = props.onNavigate;
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const el = ref.current;
|
|
12
|
+
if (!el)
|
|
13
|
+
return;
|
|
14
|
+
const handler = (e) => onCloseRef.current?.(e);
|
|
15
|
+
el.addEventListener('cx-close', handler);
|
|
16
|
+
return () => el.removeEventListener('cx-close', handler);
|
|
17
|
+
}, []);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const el = ref.current;
|
|
20
|
+
if (!el)
|
|
21
|
+
return;
|
|
22
|
+
const handler = (e) => onNavigateRef.current?.(e);
|
|
23
|
+
el.addEventListener('cx-navigate', handler);
|
|
24
|
+
return () => el.removeEventListener('cx-navigate', handler);
|
|
25
|
+
}, []);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const el = ref.current;
|
|
28
|
+
if (!el)
|
|
29
|
+
return;
|
|
30
|
+
if (props.groups != null) {
|
|
31
|
+
el.setAttribute('groups', typeof props.groups === 'object' ? JSON.stringify(props.groups) : String(props.groups));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
el.removeAttribute('groups');
|
|
35
|
+
}
|
|
36
|
+
}, [props.groups]);
|
|
37
|
+
// Build attribute object
|
|
38
|
+
const attrs = {};
|
|
39
|
+
if (props.id != null)
|
|
40
|
+
attrs['id'] = typeof props.id === 'object' ? JSON.stringify(props.id) : String(props.id);
|
|
41
|
+
if (props.label != null)
|
|
42
|
+
attrs['label'] = typeof props.label === 'object' ? JSON.stringify(props.label) : String(props.label);
|
|
43
|
+
if (props.separatorsAfter != null)
|
|
44
|
+
attrs['separators-after'] = typeof props.separatorsAfter === 'object' ? JSON.stringify(props.separatorsAfter) : String(props.separatorsAfter);
|
|
45
|
+
if (props.side != null)
|
|
46
|
+
attrs['side'] = typeof props.side === 'object' ? JSON.stringify(props.side) : String(props.side);
|
|
47
|
+
if (props.state != null)
|
|
48
|
+
attrs['state'] = typeof props.state === 'object' ? JSON.stringify(props.state) : String(props.state);
|
|
49
|
+
if (props.shape != null)
|
|
50
|
+
attrs['shape'] = typeof props.shape === 'object' ? JSON.stringify(props.shape) : String(props.shape);
|
|
51
|
+
if (props.size != null)
|
|
52
|
+
attrs['size'] = typeof props.size === 'object' ? JSON.stringify(props.size) : String(props.size);
|
|
53
|
+
return (_jsxs("cx-sidebar", { ref: ref, ...attrs, className: props.className, style: props.style, children: [props.header && _jsx("div", { slot: "header", style: { display: 'contents' }, children: props.header }), props.footer && _jsx("div", { slot: "footer", style: { display: 'contents' }, children: props.footer })] }));
|
|
54
|
+
});
|
|
55
|
+
Sidebar.displayName = 'Sidebar';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface SkeletonProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
variant?: 'text' | 'circle' | 'rectangular';
|
|
5
|
+
animation?: 'pulse' | 'wave';
|
|
6
|
+
label?: string;
|
|
7
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
8
|
+
lines?: number;
|
|
9
|
+
className?: string;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
}
|
|
12
|
+
export declare const Skeleton: React.ForwardRefExoticComponent<SkeletonProps & React.RefAttributes<HTMLElement>>;
|