idea-react 3.0.0-beta.1 → 3.0.0-beta.2
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/AGENTS.md +9 -1
- package/ReadMe.md +34 -6
- package/dist/index.d.mts +270 -186
- package/dist/index.d.ts +270 -186
- package/dist/index.js +16 -16
- package/dist/index.mjs +15 -15
- package/dist/style.css +0 -3
- package/package.json +1 -1
- package/source/Accordion.tsx +61 -37
- package/source/Alert.tsx +30 -15
- package/source/Avatar.tsx +55 -50
- package/source/Badge.tsx +16 -16
- package/source/Breadcrumb.tsx +36 -22
- package/source/Button.tsx +63 -69
- package/source/ButtonGroup.tsx +21 -25
- package/source/Card.tsx +67 -59
- package/source/Carousel/index.tsx +22 -21
- package/source/CloseButton.tsx +20 -15
- package/source/Collapse.tsx +74 -19
- package/source/Drawer.tsx +40 -17
- package/source/Extension/ClickBoundary.tsx +24 -5
- package/source/Extension/CodeBlock.tsx +64 -0
- package/source/Extension/Countdown.tsx +21 -9
- package/source/Extension/Editor.tsx +53 -18
- package/source/Extension/EditorHTML.tsx +7 -3
- package/source/Extension/HorizontalMarquee/index.tsx +69 -45
- package/source/Extension/Icon.tsx +15 -14
- package/source/Extension/Loading.tsx +20 -17
- package/source/Extension/MonthCalendar.tsx +26 -10
- package/source/Extension/OverlayBox.tsx +28 -15
- package/source/Extension/PageNav.tsx +16 -7
- package/source/Extension/ScrollNav/Scroller.tsx +21 -5
- package/source/Extension/ScrollNav/index.tsx +32 -7
- package/source/Extension/Select.tsx +12 -11
- package/source/Extension/SpinnerButton.tsx +19 -24
- package/source/Extension/TableSpinner.tsx +10 -14
- package/source/Extension/TextTruncate/index.tsx +17 -13
- package/source/Extension/Time.tsx +7 -5
- package/source/Extension/TimeDistance.tsx +22 -18
- package/source/Extension/Timeline/index.tsx +37 -34
- package/source/Extension/TypeEcho/Content.tsx +79 -14
- package/source/Extension/TypeEcho/index.tsx +13 -5
- package/source/Extension/UserRank/Address.tsx +17 -15
- package/source/Extension/UserRank/index.tsx +79 -84
- package/source/Extension/VerticalMarquee/index.tsx +14 -16
- package/source/Extension/ZodiacBar.tsx +40 -32
- package/source/Form/Adorn.tsx +30 -32
- package/source/Form/Checkbox.tsx +9 -5
- package/source/Form/ChipInput.tsx +9 -5
- package/source/Form/Chips.tsx +41 -39
- package/source/Form/Combobox.tsx +80 -61
- package/source/Form/Control.tsx +53 -58
- package/source/Form/DatePicker.tsx +74 -65
- package/source/Form/Feedback.tsx +18 -19
- package/source/Form/FloatingLabel.tsx +16 -19
- package/source/Form/InputGroup.tsx +27 -26
- package/source/Form/OTP.tsx +30 -12
- package/source/Form/Primitives.tsx +47 -39
- package/source/Form/Radio.tsx +25 -22
- package/source/Form/Range.tsx +30 -12
- package/source/Form/Switch.tsx +43 -40
- package/source/Grid.tsx +67 -59
- package/source/Image.tsx +10 -6
- package/source/ListGroup.tsx +57 -69
- package/source/Menu.tsx +128 -66
- package/source/NativeDialog/index.tsx +51 -29
- package/source/Nav.tsx +46 -46
- package/source/NavOverflow/index.tsx +26 -10
- package/source/Navbar.tsx +60 -55
- package/source/Pagination.tsx +63 -69
- package/source/Placeholder.tsx +47 -43
- package/source/Polymorphic.ts +57 -0
- package/source/Popover.tsx +34 -31
- package/source/Progress/index.tsx +59 -54
- package/source/ScrollSpy/index.tsx +48 -33
- package/source/Spinner.tsx +27 -23
- package/source/Stack.tsx +25 -0
- package/source/Stepper.tsx +46 -40
- package/source/Tab.tsx +40 -27
- package/source/Table.tsx +53 -42
- package/source/Toast.tsx +62 -47
- package/source/ToggleButton.tsx +40 -37
- package/source/Toggler.tsx +17 -8
- package/source/Tooltip.tsx +31 -29
- package/source/index.ts +2 -0
- package/source/Extension/CodeBlock/index.tsx +0 -58
- package/source/Extension/CodeBlock/style.module.css +0 -3
package/source/Grid.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { ComponentPropsWithRef
|
|
2
|
+
import { ComponentPropsWithRef } from 'react';
|
|
3
|
+
|
|
4
|
+
import { polymorphic } from './Polymorphic';
|
|
3
5
|
|
|
4
6
|
export type Breakpoint = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
5
7
|
export type ColSize = number | 'auto';
|
|
@@ -10,15 +12,18 @@ export interface ContainerProps extends ComponentPropsWithRef<'div'> {
|
|
|
10
12
|
breakpoint?: Breakpoint;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
export const Container
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export const Container = polymorphic<ContainerProps>(
|
|
16
|
+
({ as: Root = 'div', fluid, breakpoint, className, ...props }) => (
|
|
17
|
+
<Root
|
|
18
|
+
{...props}
|
|
19
|
+
className={classNames(
|
|
20
|
+
breakpoint ? `${breakpoint}:container` : fluid ? 'container-fluid' : 'container',
|
|
21
|
+
className
|
|
22
|
+
)}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
21
25
|
);
|
|
26
|
+
Container.displayName = 'Container';
|
|
22
27
|
|
|
23
28
|
export type RowCols = number | 'auto';
|
|
24
29
|
|
|
@@ -31,29 +36,33 @@ export interface RowProps extends ComponentPropsWithRef<'div'> {
|
|
|
31
36
|
'2xl'?: RowCols;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
export const Row
|
|
35
|
-
|
|
36
|
-
[
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
export const Row = polymorphic<RowProps>(
|
|
40
|
+
({ as: Root = 'div', cols, sm, md, lg, xl, '2xl': xxl, className, ...props }) => {
|
|
41
|
+
const sizes: [Breakpoint, RowCols | undefined][] = [
|
|
42
|
+
['sm', sm],
|
|
43
|
+
['md', md],
|
|
44
|
+
['lg', lg],
|
|
45
|
+
['xl', xl],
|
|
46
|
+
['2xl', xxl]
|
|
47
|
+
];
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
return (
|
|
50
|
+
<Root
|
|
51
|
+
{...props}
|
|
52
|
+
className={classNames(
|
|
53
|
+
'row',
|
|
54
|
+
cols !== undefined && `row-cols-${cols}`,
|
|
55
|
+
sizes.map(
|
|
56
|
+
([breakpoint, size]) =>
|
|
57
|
+
size !== undefined && `${breakpoint}:row-cols-${size}`
|
|
58
|
+
),
|
|
59
|
+
className
|
|
60
|
+
)}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
Row.displayName = 'Row';
|
|
57
66
|
|
|
58
67
|
export interface ColProps extends ComponentPropsWithRef<'div'> {
|
|
59
68
|
span?: ColSize;
|
|
@@ -64,33 +73,32 @@ export interface ColProps extends ComponentPropsWithRef<'div'> {
|
|
|
64
73
|
'2xl'?: BreakpointColSize;
|
|
65
74
|
}
|
|
66
75
|
|
|
67
|
-
export const Col
|
|
68
|
-
|
|
69
|
-
[
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
export const Col = polymorphic<ColProps>(
|
|
77
|
+
({ as: Root = 'div', span, sm, md, lg, xl, '2xl': xxl, className, ...props }) => {
|
|
78
|
+
const sizes: [Breakpoint, BreakpointColSize | undefined][] = [
|
|
79
|
+
['sm', sm],
|
|
80
|
+
['md', md],
|
|
81
|
+
['lg', lg],
|
|
82
|
+
['xl', xl],
|
|
83
|
+
['2xl', xxl]
|
|
84
|
+
];
|
|
85
|
+
const sized = sizes.some(([, size]) => size !== undefined);
|
|
76
86
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
Container.displayName = 'Container';
|
|
95
|
-
Row.displayName = 'Row';
|
|
87
|
+
return (
|
|
88
|
+
<Root
|
|
89
|
+
{...props}
|
|
90
|
+
className={classNames(
|
|
91
|
+
!span && !sized && 'col',
|
|
92
|
+
span !== undefined && `col-${span}`,
|
|
93
|
+
sizes.map(
|
|
94
|
+
([breakpoint, size]) =>
|
|
95
|
+
size !== undefined &&
|
|
96
|
+
(size === true ? `${breakpoint}:col` : `${breakpoint}:col-${size}`)
|
|
97
|
+
),
|
|
98
|
+
className
|
|
99
|
+
)}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
);
|
|
96
104
|
Col.displayName = 'Col';
|
package/source/Image.tsx
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { ComponentPropsWithRef
|
|
2
|
+
import { ComponentPropsWithRef } from 'react';
|
|
3
|
+
|
|
4
|
+
import { polymorphic } from './Polymorphic';
|
|
3
5
|
|
|
4
6
|
export interface ImageProps extends ComponentPropsWithRef<'img'> {
|
|
5
7
|
fluid?: boolean;
|
|
6
8
|
thumbnail?: boolean;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
|
-
export const Image
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
export const Image = polymorphic<ImageProps>(
|
|
12
|
+
({ as: Root = 'img', fluid, thumbnail, className, ...props }) => (
|
|
13
|
+
<Root
|
|
14
|
+
{...props}
|
|
15
|
+
className={classNames({ 'img-fluid': fluid, 'img-thumbnail': thumbnail }, className)}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
14
18
|
);
|
|
15
19
|
Image.displayName = 'Image';
|
package/source/ListGroup.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { ComponentPropsWithRef
|
|
2
|
+
import { ComponentPropsWithRef } from 'react';
|
|
3
3
|
|
|
4
4
|
import type { ComponentTheme } from './Button';
|
|
5
5
|
import type { Breakpoint } from './Grid';
|
|
6
|
+
import { polymorphic } from './Polymorphic';
|
|
6
7
|
|
|
7
8
|
export type ListGroupHorizontal = boolean | Breakpoint;
|
|
8
9
|
|
|
@@ -19,32 +20,22 @@ export type ListGroupProps = ListGroupStyleProps &
|
|
|
19
20
|
| (ComponentPropsWithRef<'div'> & { as: 'div' })
|
|
20
21
|
);
|
|
21
22
|
|
|
22
|
-
export const ListGroup
|
|
23
|
-
flush,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(horizontal === true ? 'list-group-horizontal' : `${horizontal}:list-group-horizontal`),
|
|
34
|
-
className
|
|
35
|
-
);
|
|
23
|
+
export const ListGroup = polymorphic<ListGroupStyleProps & ComponentPropsWithRef<'ul'>>(
|
|
24
|
+
({ as: Root = 'ul', flush, numbered, horizontal, className, ...props }) => {
|
|
25
|
+
const classes = classNames(
|
|
26
|
+
'list-group',
|
|
27
|
+
{ 'list-group-flush': flush, 'list-group-numbered': numbered },
|
|
28
|
+
horizontal &&
|
|
29
|
+
(horizontal === true
|
|
30
|
+
? 'list-group-horizontal'
|
|
31
|
+
: `${horizontal}:list-group-horizontal`),
|
|
32
|
+
className
|
|
33
|
+
);
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
const { as: _as, ...attributes } = props;
|
|
39
|
-
return <ol {...attributes} className={classes} />;
|
|
40
|
-
}
|
|
41
|
-
if (props.as === 'div') {
|
|
42
|
-
const { as: _as, ...attributes } = props;
|
|
43
|
-
return <div {...attributes} className={classes} />;
|
|
35
|
+
return <Root {...props} className={classes} />;
|
|
44
36
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
37
|
+
);
|
|
38
|
+
ListGroup.displayName = 'ListGroup';
|
|
48
39
|
|
|
49
40
|
interface ListGroupItemStyleProps {
|
|
50
41
|
theme?: ComponentTheme;
|
|
@@ -67,50 +58,47 @@ const isLink = (props: ListGroupItemElementAttributes): props is ListGroupItemLi
|
|
|
67
58
|
const isButton = (props: ListGroupItemElementAttributes): props is ListGroupItemButtonAttributes =>
|
|
68
59
|
typeof props.type === 'string';
|
|
69
60
|
|
|
70
|
-
export const ListGroupItem
|
|
71
|
-
theme,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
className,
|
|
76
|
-
...props
|
|
77
|
-
}) => {
|
|
78
|
-
const classes = classNames(
|
|
79
|
-
'list-group-item',
|
|
80
|
-
theme && `theme-${theme}`,
|
|
81
|
-
action && 'list-group-item-action',
|
|
82
|
-
{ active, disabled },
|
|
83
|
-
disabled && 'pe-none',
|
|
84
|
-
className
|
|
85
|
-
);
|
|
61
|
+
export const ListGroupItem = polymorphic<ListGroupItemProps>(
|
|
62
|
+
({ as: RootAs, theme, action, active, disabled, className, ...props }) => {
|
|
63
|
+
const Root = RootAs ?? 'a';
|
|
64
|
+
const Root1 = RootAs ?? 'button';
|
|
65
|
+
const Root2 = RootAs ?? 'li';
|
|
86
66
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
onClick={disabled ? undefined : props.onClick}
|
|
96
|
-
/>
|
|
97
|
-
) : isButton(props) ? (
|
|
98
|
-
<button
|
|
99
|
-
{...props}
|
|
100
|
-
type={props.type || 'button'}
|
|
101
|
-
className={classes}
|
|
102
|
-
aria-current={active ? 'true' : undefined}
|
|
103
|
-
disabled={disabled}
|
|
104
|
-
/>
|
|
105
|
-
) : (
|
|
106
|
-
<li
|
|
107
|
-
{...(props as ListGroupItemAttributes)}
|
|
108
|
-
className={classes}
|
|
109
|
-
aria-current={active ? 'true' : undefined}
|
|
110
|
-
aria-disabled={disabled || undefined}
|
|
111
|
-
/>
|
|
112
|
-
);
|
|
113
|
-
};
|
|
67
|
+
const classes = classNames(
|
|
68
|
+
'list-group-item',
|
|
69
|
+
theme && `theme-${theme}`,
|
|
70
|
+
action && 'list-group-item-action',
|
|
71
|
+
{ active, disabled },
|
|
72
|
+
disabled && 'pe-none',
|
|
73
|
+
className
|
|
74
|
+
);
|
|
114
75
|
|
|
115
|
-
|
|
76
|
+
return isLink(props) ? (
|
|
77
|
+
<Root
|
|
78
|
+
{...props}
|
|
79
|
+
className={classes}
|
|
80
|
+
href={disabled ? undefined : props.href}
|
|
81
|
+
aria-current={active ? 'true' : undefined}
|
|
82
|
+
aria-disabled={disabled || undefined}
|
|
83
|
+
tabIndex={disabled ? -1 : props.tabIndex}
|
|
84
|
+
onClick={disabled ? undefined : props.onClick}
|
|
85
|
+
/>
|
|
86
|
+
) : isButton(props) ? (
|
|
87
|
+
<Root1
|
|
88
|
+
{...props}
|
|
89
|
+
type={props.type || 'button'}
|
|
90
|
+
className={classes}
|
|
91
|
+
aria-current={active ? 'true' : undefined}
|
|
92
|
+
disabled={disabled}
|
|
93
|
+
/>
|
|
94
|
+
) : (
|
|
95
|
+
<Root2
|
|
96
|
+
{...(props as ListGroupItemAttributes)}
|
|
97
|
+
className={classes}
|
|
98
|
+
aria-current={active ? 'true' : undefined}
|
|
99
|
+
aria-disabled={disabled || undefined}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
);
|
|
116
104
|
ListGroupItem.displayName = 'ListGroupItem';
|