idea-react 3.0.0-beta.3 → 3.0.0-beta.4
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/dist/index.d.mts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/source/Button.tsx +7 -1
- package/source/Extension/UserRank/index.tsx +2 -2
- package/source/Grid.tsx +12 -11
- package/source/Progress/index.tsx +15 -5
- package/source/Progress/style.module.css +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "idea-react",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
5
|
"author": "shiy2008@gmail.com",
|
|
6
6
|
"description": "A React advanced components library based on TypeScript & Bootstrap, built by idea2app remote developers team.",
|
package/source/Button.tsx
CHANGED
|
@@ -42,6 +42,12 @@ export const Button = polymorphic<ButtonProps>(
|
|
|
42
42
|
const link = isButtonLink(attributes);
|
|
43
43
|
const Root = RootAs ?? (link ? 'a' : 'button');
|
|
44
44
|
const nativeButton = Root === 'button';
|
|
45
|
+
const onClick =
|
|
46
|
+
!nativeButton && disabled
|
|
47
|
+
? typeof Root === 'string'
|
|
48
|
+
? undefined
|
|
49
|
+
: preventNavigation
|
|
50
|
+
: attributes.onClick;
|
|
45
51
|
const classes = classNames(
|
|
46
52
|
variant === false ? undefined : variant ? `btn-${variant}` : icon ? undefined : 'btn',
|
|
47
53
|
theme && `theme-${theme}`,
|
|
@@ -64,7 +70,7 @@ export const Button = polymorphic<ButtonProps>(
|
|
|
64
70
|
: attributes['aria-pressed']
|
|
65
71
|
}
|
|
66
72
|
tabIndex={!nativeButton && disabled ? -1 : attributes.tabIndex}
|
|
67
|
-
onClick={
|
|
73
|
+
onClick={onClick}
|
|
68
74
|
/>
|
|
69
75
|
);
|
|
70
76
|
}
|
|
@@ -73,7 +73,7 @@ export const UserRankView = polymorphic<UserRankViewProps>(
|
|
|
73
73
|
return (
|
|
74
74
|
<Container as={RootAs} className={className} {...props}>
|
|
75
75
|
<Row className={style.rankBox}>
|
|
76
|
-
<Col
|
|
76
|
+
<Col xs={12} lg={7}>
|
|
77
77
|
<div className={`shadow rounded-3 ${style.title}`}>
|
|
78
78
|
<div className={style.medal}>
|
|
79
79
|
<i className="d-inline-block ms-1 overflow-hidden rounded-circle" />
|
|
@@ -93,7 +93,7 @@ export const UserRankView = polymorphic<UserRankViewProps>(
|
|
|
93
93
|
{rank.slice(0, 3).map(renderMedal)}
|
|
94
94
|
</ul>
|
|
95
95
|
</Col>
|
|
96
|
-
<Col
|
|
96
|
+
<Col xs={12} lg={5}>
|
|
97
97
|
<Table className={`my-3 pt-2 ${style.restUsers}`} responsive>
|
|
98
98
|
<tbody>{rank.slice(3, 10).map(renderRow)}</tbody>
|
|
99
99
|
</Table>
|
package/source/Grid.tsx
CHANGED
|
@@ -8,16 +8,15 @@ export type ColSize = number | 'auto';
|
|
|
8
8
|
export type BreakpointColSize = ColSize | true;
|
|
9
9
|
|
|
10
10
|
export interface ContainerProps extends ComponentPropsWithRef<'div'> {
|
|
11
|
-
fluid?: boolean;
|
|
12
|
-
breakpoint?: Breakpoint;
|
|
11
|
+
fluid?: boolean | Breakpoint;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
export const Container = polymorphic<ContainerProps>(
|
|
16
|
-
({ as: Root = 'div', fluid,
|
|
15
|
+
({ as: Root = 'div', fluid, className, ...props }) => (
|
|
17
16
|
<Root
|
|
18
17
|
{...props}
|
|
19
18
|
className={classNames(
|
|
20
|
-
|
|
19
|
+
fluid === true ? 'container-fluid' : fluid ? `${fluid}:container` : 'container',
|
|
21
20
|
className
|
|
22
21
|
)}
|
|
23
22
|
/>
|
|
@@ -28,7 +27,7 @@ Container.displayName = 'Container';
|
|
|
28
27
|
export type RowCols = number | 'auto';
|
|
29
28
|
|
|
30
29
|
export interface RowProps extends ComponentPropsWithRef<'div'> {
|
|
31
|
-
|
|
30
|
+
xs?: RowCols;
|
|
32
31
|
sm?: RowCols;
|
|
33
32
|
md?: RowCols;
|
|
34
33
|
lg?: RowCols;
|
|
@@ -37,7 +36,7 @@ export interface RowProps extends ComponentPropsWithRef<'div'> {
|
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
export const Row = polymorphic<RowProps>(
|
|
40
|
-
({ as: Root = 'div',
|
|
39
|
+
({ as: Root = 'div', xs, sm, md, lg, xl, '2xl': xxl, className, ...props }) => {
|
|
41
40
|
const sizes: [Breakpoint, RowCols | undefined][] = [
|
|
42
41
|
['sm', sm],
|
|
43
42
|
['md', md],
|
|
@@ -51,7 +50,7 @@ export const Row = polymorphic<RowProps>(
|
|
|
51
50
|
{...props}
|
|
52
51
|
className={classNames(
|
|
53
52
|
'row',
|
|
54
|
-
|
|
53
|
+
xs !== undefined && `row-cols-${xs}`,
|
|
55
54
|
sizes.map(
|
|
56
55
|
([breakpoint, size]) =>
|
|
57
56
|
size !== undefined && `${breakpoint}:row-cols-${size}`
|
|
@@ -65,7 +64,7 @@ export const Row = polymorphic<RowProps>(
|
|
|
65
64
|
Row.displayName = 'Row';
|
|
66
65
|
|
|
67
66
|
export interface ColProps extends ComponentPropsWithRef<'div'> {
|
|
68
|
-
|
|
67
|
+
xs?: BreakpointColSize;
|
|
69
68
|
sm?: BreakpointColSize;
|
|
70
69
|
md?: BreakpointColSize;
|
|
71
70
|
lg?: BreakpointColSize;
|
|
@@ -74,7 +73,7 @@ export interface ColProps extends ComponentPropsWithRef<'div'> {
|
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
export const Col = polymorphic<ColProps>(
|
|
77
|
-
({ as: Root = 'div',
|
|
76
|
+
({ as: Root = 'div', xs, sm, md, lg, xl, '2xl': xxl, className, ...props }) => {
|
|
78
77
|
const sizes: [Breakpoint, BreakpointColSize | undefined][] = [
|
|
79
78
|
['sm', sm],
|
|
80
79
|
['md', md],
|
|
@@ -88,8 +87,10 @@ export const Col = polymorphic<ColProps>(
|
|
|
88
87
|
<Root
|
|
89
88
|
{...props}
|
|
90
89
|
className={classNames(
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
{
|
|
91
|
+
col: (xs === undefined && !sized) || xs === true,
|
|
92
|
+
[`col-${xs}`]: xs !== undefined && xs !== true
|
|
93
|
+
},
|
|
93
94
|
sizes.map(
|
|
94
95
|
([breakpoint, size]) =>
|
|
95
96
|
size !== undefined &&
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import './style.module.css';
|
|
2
|
-
|
|
3
1
|
import classNames from 'classnames';
|
|
4
2
|
import { ComponentPropsWithRef, CSSProperties } from 'react';
|
|
5
3
|
|
|
@@ -36,7 +34,9 @@ export const Progress = polymorphic<ProgressProps>(
|
|
|
36
34
|
|
|
37
35
|
const current = Math.min(max, Math.max(min, value));
|
|
38
36
|
const width = `${((current - min) / (max - min)) * 100}%`;
|
|
37
|
+
// Stacks set the offset to zero and fill each segment's inner bar.
|
|
39
38
|
const progressStyle: CSSProperties & { '--_progress-width': string } = {
|
|
39
|
+
width: 'min(100%, calc(var(--_progress-width) + var(--_progress-stack-offset, 100%)))',
|
|
40
40
|
...style,
|
|
41
41
|
'--_progress-width': width
|
|
42
42
|
};
|
|
@@ -63,7 +63,7 @@ export const Progress = polymorphic<ProgressProps>(
|
|
|
63
63
|
},
|
|
64
64
|
barClass
|
|
65
65
|
)}
|
|
66
|
-
style={barStyle}
|
|
66
|
+
style={{ width: `var(--_progress-bar-width, ${width})`, ...barStyle }}
|
|
67
67
|
>
|
|
68
68
|
{children}
|
|
69
69
|
</div>
|
|
@@ -74,8 +74,18 @@ export const Progress = polymorphic<ProgressProps>(
|
|
|
74
74
|
Progress.displayName = 'Progress';
|
|
75
75
|
|
|
76
76
|
export const ProgressStack = polymorphic<ComponentPropsWithRef<'div'>>(
|
|
77
|
-
({ as: Root = 'div', className, ...props }) => (
|
|
78
|
-
<Root
|
|
77
|
+
({ as: Root = 'div', className, style, ...props }) => (
|
|
78
|
+
<Root
|
|
79
|
+
{...props}
|
|
80
|
+
className={classNames('progress-stacked', className)}
|
|
81
|
+
style={
|
|
82
|
+
{
|
|
83
|
+
'--_progress-stack-offset': '0%',
|
|
84
|
+
'--_progress-bar-width': '100%',
|
|
85
|
+
...style
|
|
86
|
+
} as CSSProperties
|
|
87
|
+
}
|
|
88
|
+
/>
|
|
79
89
|
)
|
|
80
90
|
);
|
|
81
91
|
ProgressStack.displayName = 'ProgressStack';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
:global(.progress) {
|
|
2
|
-
width: 100%;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
:global(.progress) > :global(.progress-bar) {
|
|
6
|
-
width: var(--_progress-width);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
:global(.progress-stacked) > :global(.progress) {
|
|
10
|
-
width: var(--_progress-width);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
:global(.progress-stacked) > :global(.progress) > :global(.progress-bar) {
|
|
14
|
-
width: 100%;
|
|
15
|
-
}
|