idea-react 3.0.0-alpha.0 → 3.0.0-alpha.1

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.
Files changed (60) hide show
  1. package/AGENTS.md +31 -10
  2. package/ReadMe.md +42 -35
  3. package/dist/index.d.mts +301 -100
  4. package/dist/index.d.ts +301 -100
  5. package/dist/index.js +16 -16
  6. package/dist/index.mjs +15 -15
  7. package/dist/style.css +5 -5
  8. package/package.json +4 -7
  9. package/source/Avatar.tsx +65 -12
  10. package/source/Button.tsx +13 -4
  11. package/source/ButtonGroup.tsx +28 -0
  12. package/source/Card.tsx +26 -0
  13. package/source/ClickBoundary.tsx +6 -5
  14. package/source/CloseButton.tsx +23 -0
  15. package/source/CodeBlock.tsx +5 -3
  16. package/source/Countdown.tsx +2 -0
  17. package/source/Drawer.tsx +62 -0
  18. package/source/Editor.tsx +5 -8
  19. package/source/Grid.tsx +92 -0
  20. package/source/HorizontalMarquee/index.tsx +4 -10
  21. package/source/Image.tsx +15 -0
  22. package/source/ListGroup.tsx +103 -0
  23. package/source/LiveTSX.tsx +1 -1
  24. package/source/Loading.tsx +4 -3
  25. package/source/Menu.tsx +99 -1
  26. package/source/MonthCalendar.tsx +60 -22
  27. package/source/NativeDialog/index.tsx +37 -1
  28. package/source/Nav.tsx +52 -0
  29. package/source/Navbar.tsx +48 -1
  30. package/source/Overlay.ts +22 -0
  31. package/source/OverlayBox.tsx +200 -32
  32. package/source/PageNav.tsx +56 -32
  33. package/source/Popover.tsx +36 -0
  34. package/source/ScrollNav/Scroller.tsx +107 -0
  35. package/source/ScrollNav/index.tsx +12 -99
  36. package/source/Select.tsx +66 -55
  37. package/source/ShareBox.tsx +5 -11
  38. package/source/Spinner.tsx +30 -0
  39. package/source/SpinnerButton.tsx +8 -10
  40. package/source/Table.tsx +59 -0
  41. package/source/TableSpinner.tsx +7 -5
  42. package/source/{TextTruncate.tsx → TextTruncate/Content.tsx} +24 -20
  43. package/source/TextTruncate/index.tsx +25 -0
  44. package/source/Time.tsx +7 -33
  45. package/source/TimeDistance.tsx +1 -1
  46. package/source/Timeline/index.tsx +7 -7
  47. package/source/Toast.tsx +114 -29
  48. package/source/ToggleButton.tsx +47 -0
  49. package/source/Tooltip.tsx +32 -0
  50. package/source/TypeEcho/Content.tsx +58 -0
  51. package/source/TypeEcho/index.tsx +14 -0
  52. package/source/UserRank/index.module.less +9 -20
  53. package/source/UserRank/index.tsx +35 -32
  54. package/source/VerticalMarquee/index.module.less +0 -1
  55. package/source/VerticalMarquee/index.tsx +3 -5
  56. package/source/ZodiacBar.tsx +1 -1
  57. package/source/animate.ts +4 -2
  58. package/source/color.ts +3 -5
  59. package/source/index.ts +13 -0
  60. package/source/TypeEcho.tsx +0 -49
@@ -54,8 +54,7 @@
54
54
  i {
55
55
  box-shadow: 0 0 0.5rem 0 #ffd83a;
56
56
  border: 0.1rem solid #ffd83a;
57
- background-image: var(--logo-image),
58
- linear-gradient(#ffd83a, #fdeba0);
57
+ background-image: var(--logo-image), linear-gradient(#ffd83a, #fdeba0);
59
58
  background-position: center;
60
59
  background-size: 1.5rem 1.5rem;
61
60
  background-repeat: no-repeat;
@@ -65,14 +64,12 @@
65
64
  &:first-child {
66
65
  box-shadow: 0 0 0.5rem 0 #d8d8d8;
67
66
  border-color: #d8d8d8;
68
- background-image: var(--logo-image),
69
- linear-gradient(#d8d8d8, #eeeeee);
67
+ background-image: var(--logo-image), linear-gradient(#d8d8d8, #eeeeee);
70
68
  }
71
69
  &:last-child {
72
70
  box-shadow: 0 0 0.5rem 0 #fab36e;
73
71
  border-color: #fab36e;
74
- background-image: var(--logo-image),
75
- linear-gradient(#fab36e, #fbe7d3);
72
+ background-image: var(--logo-image), linear-gradient(#fab36e, #fbe7d3);
76
73
  }
77
74
  }
78
75
  }
@@ -98,12 +95,7 @@
98
95
  left: 0;
99
96
  z-index: 1;
100
97
  margin: 0 auto;
101
- background-image: linear-gradient(
102
- to right,
103
- #d8d8d8 10%,
104
- #ffd83a 60%,
105
- #fab36e 75%
106
- );
98
+ background-image: linear-gradient(to right, #d8d8d8 10%, #ffd83a 60%, #fab36e 75%);
107
99
  background-clip: text;
108
100
  width: 10rem;
109
101
  content: attr(data-text);
@@ -136,8 +128,7 @@
136
128
  0px 1px 0px #969653,
137
129
  0px 2px 5px rgba(240, 219, 100, 0.4);
138
130
  i {
139
- background-image: var(--logo-image),
140
- linear-gradient(#ffd83a, #fdeba0);
131
+ background-image: var(--logo-image), linear-gradient(#ffd83a, #fdeba0);
141
132
  background-position: center;
142
133
  background-size: 2.5rem auto;
143
134
  background-repeat: no-repeat;
@@ -157,11 +148,9 @@
157
148
  .topUser {
158
149
  border-bottom: 1.2rem solid #d8d8d8;
159
150
  color: #d8d8d8;
160
- text-shadow: 0px 1px 0px #d9cdcd 0px 2px 5px
161
- rgba(133, 132, 130, 0.4);
151
+ text-shadow: 0px 1px 0px #d9cdcd 0px 2px 5px rgba(133, 132, 130, 0.4);
162
152
  i {
163
- background-image: var(--logo-image),
164
- linear-gradient(#d8d8d8, #eeeeee);
153
+ background-image: var(--logo-image), linear-gradient(#d8d8d8, #eeeeee);
165
154
  }
166
155
  }
167
156
  .image {
@@ -179,8 +168,7 @@
179
168
  0px 1px 0px #aa8865,
180
169
  0px 2px 5px rgba(167, 129, 67, 0.4);
181
170
  i {
182
- background-image: var(--logo-image),
183
- linear-gradient(#fab36e, #fbe7d3);
171
+ background-image: var(--logo-image), linear-gradient(#fab36e, #fbe7d3);
184
172
  }
185
173
  }
186
174
  .image {
@@ -215,6 +203,7 @@
215
203
  cursor: default;
216
204
  background-color: transparent;
217
205
  .name {
206
+ max-width: 50%;
218
207
  font-size: 0;
219
208
  &:hover {
220
209
  .image > img {
@@ -1,6 +1,9 @@
1
- import { PureComponent } from 'react';
2
- import { Badge, Col, Image, Row, RowProps, Table } from 'react-bootstrap';
1
+ import { FC, HTMLAttributes } from 'react';
3
2
 
3
+ import { Badge } from '../Badge';
4
+ import { Col, Container, Row } from '../Grid';
5
+ import { Image } from '../Image';
6
+ import { Table } from '../Table';
4
7
  import { UserAddress, UserAddressProps } from './Address';
5
8
  import * as style from './index.module.less';
6
9
 
@@ -11,44 +14,45 @@ export interface UserRank extends UserAddressProps {
11
14
  score: number;
12
15
  }
13
16
 
14
- export interface UserRankViewProps extends RowProps {
17
+ export interface UserRankViewProps extends HTMLAttributes<HTMLDivElement> {
15
18
  title: string;
16
19
  rank: UserRank[];
17
20
  linkOf?: (user: UserRank) => string;
18
21
  }
19
22
 
20
- export class UserRankView extends PureComponent<UserRankViewProps> {
21
- static displayName = 'UserRankView';
22
-
23
- renderMedal = (user: UserRank) => (
24
- <Col key={user.id} as="li">
23
+ export const UserRankView: FC<UserRankViewProps> = ({
24
+ className = '',
25
+ title,
26
+ rank = [],
27
+ linkOf,
28
+ ...props
29
+ }) => {
30
+ const renderMedal = (user: UserRank) => (
31
+ <li key={user.id} className="col">
25
32
  <div className={`shadow-lg overflow-hidden rounded-circle m-auto ${style.image}`}>
26
33
  <Image src={user.avatar} alt={user.name} loading="lazy" fluid />
27
34
  </div>
28
35
  <div className={`position-relative overflow-hidden ${style.topUser}`}>
29
36
  <div className="position-relative">
30
37
  <i className="d-block overflow-hidden m-auto mb-1 rounded-circle" />
31
- <a
32
- className="d-block mb-0 stretched-link"
33
- href={this.props.linkOf?.(user) || '#'}
34
- >
38
+ <a className="d-block mb-0 stretched-link" href={linkOf?.(user) || '#'}>
35
39
  {user.name}
36
40
  </a>
37
41
  <strong>{user.score}</strong>
38
42
  </div>
39
43
  <UserAddress {...user} />
40
44
  </div>
41
- </Col>
45
+ </li>
42
46
  );
43
47
 
44
- renderRow = (user: UserRank, index: number, { length }: UserRank[]) => (
48
+ const renderRow = (user: UserRank, index: number, { length }: UserRank[]) => (
45
49
  <tr key={user.id} className="position-relative">
46
50
  <td className="align-middle">
47
51
  <Badge className="fw-bold fst-italic">
48
52
  {(index + 4 + '').padStart((length + '').length, '0')}
49
53
  </Badge>
50
54
  </td>
51
- <td className={`position-relative mw-50 text-truncate ${style.name}`}>
55
+ <td className={`position-relative text-truncate ${style.name}`}>
52
56
  <div
53
57
  className={`d-inline-block overflow-hidden align-middle rounded-circle ${style.image}`}
54
58
  >
@@ -59,7 +63,7 @@ export class UserRankView extends PureComponent<UserRankViewProps> {
59
63
  style={{
60
64
  color: `rgb(248, ${(index + 2) * 15}, ${(index + 2) * 35})`
61
65
  }}
62
- href={this.props.linkOf?.(user) || '#'}
66
+ href={linkOf?.(user) || '#'}
63
67
  >
64
68
  {user.name}
65
69
  </a>
@@ -71,12 +75,10 @@ export class UserRankView extends PureComponent<UserRankViewProps> {
71
75
  </tr>
72
76
  );
73
77
 
74
- render() {
75
- const { className = '', title, rank = [], linkOf, ...props } = this.props;
76
-
77
- return (
78
- <Row className={`${style.rankBox} ${className}`} {...props}>
79
- <Col sm={12} xs={12} lg={7}>
78
+ return (
79
+ <Container className={className} {...props}>
80
+ <Row className={style.rankBox}>
81
+ <Col span={12} lg={7}>
80
82
  <div className={`shadow rounded-3 ${style.title}`}>
81
83
  <div className={style.medal}>
82
84
  <i className="d-inline-block ms-1 overflow-hidden rounded-circle" />
@@ -90,19 +92,20 @@ export class UserRankView extends PureComponent<UserRankViewProps> {
90
92
  {title}
91
93
  </h3>
92
94
  </div>
93
- <Row
94
- as="ul"
95
- className={`mt-2 g-0 align-items-end text-center ps-0 pt-2 list-unstyled ${style.topUsers}`}
95
+ <ul
96
+ className={`row mt-2 g-0 align-items-end text-center ps-0 pt-2 list-unstyled ${style.topUsers}`}
96
97
  >
97
- {rank.slice(0, 3).map(this.renderMedal)}
98
- </Row>
98
+ {rank.slice(0, 3).map(renderMedal)}
99
+ </ul>
99
100
  </Col>
100
- <Col xs={12} sm={12} lg={5}>
101
+ <Col span={12} lg={5}>
101
102
  <Table className={`my-3 pt-2 ${style.restUsers}`} responsive>
102
- <tbody>{rank.slice(3, 10).map(this.renderRow)}</tbody>
103
+ <tbody>{rank.slice(3, 10).map(renderRow)}</tbody>
103
104
  </Table>
104
105
  </Col>
105
106
  </Row>
106
- );
107
- }
108
- }
107
+ </Container>
108
+ );
109
+ };
110
+
111
+ UserRankView.displayName = 'UserRankView';
@@ -26,7 +26,6 @@
26
26
  animation-timing-function: linear;
27
27
  animation-iteration-count: infinite;
28
28
  animation-direction: alternate;
29
- font-size: 0;
30
29
  &:hover {
31
30
  animation-play-state: paused;
32
31
  .scrollItem {
@@ -12,15 +12,13 @@ export const VerticalMarquee: FC<VerticalMarqueeProps> = ({
12
12
  duration,
13
13
  ...props
14
14
  }) => (
15
- <div className={`overflow-hidden ${className}`} {...props}>
15
+ <div className={`overflow-hidden h-100 ${className}`} {...props}>
16
16
  <div
17
- className={`d-inline-block mw-100 mh-100 ${style.scrollWrap}`}
17
+ className={`d-inline-block max-w-100 max-h-100 ${style.scrollWrap}`}
18
18
  // @ts-expect-error remove after React 19 released
19
19
  style={{ '--duration': duration }}
20
20
  >
21
- <div className={`d-inline-block ${style.scrollItem}`}>
22
- {children}
23
- </div>
21
+ <div className={`d-inline-block ${style.scrollItem}`}>{children}</div>
24
22
  </div>
25
23
  </div>
26
24
  );
@@ -39,7 +39,7 @@ export const ZodiacBar: FC<ZodiacBarProps> = ({
39
39
  return (
40
40
  <li key={year} className={itemClassName}>
41
41
  <a className="d-inline-block p-3 text-decoration-none text-center" href={link}>
42
- <div className="fs-1">{zodiac}</div>
42
+ <div className="fs-3xl">{zodiac}</div>
43
43
 
44
44
  {title}
45
45
  </a>
package/source/animate.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { RefCallback } from 'react';
2
2
 
3
3
  export function animate(name: string): RefCallback<Element> {
4
- return element =>
5
- element &&
4
+ return element => {
5
+ if (!element) return;
6
+
6
7
  new IntersectionObserver(([{ isIntersecting, target }], observer) => {
7
8
  if (!isIntersecting) return;
8
9
 
@@ -17,4 +18,5 @@ export function animate(name: string): RefCallback<Element> {
17
18
  );
18
19
  observer.disconnect();
19
20
  }).observe(element);
21
+ };
20
22
  }
package/source/color.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Color } from 'react-bootstrap/esm/types';
1
+ import type { ComponentTheme } from './Button';
2
2
 
3
- export type VariantColor = Exclude<Color, 'white' | 'muted'>;
3
+ export type VariantColor = ComponentTheme;
4
4
 
5
5
  export const VariantColors: VariantColor[] = [
6
6
  'primary',
@@ -15,9 +15,7 @@ export const VariantColors: VariantColor[] = [
15
15
 
16
16
  export function text2color(raw: string, excludeColors: VariantColor[] = []) {
17
17
  const colors = excludeColors[0]
18
- ? VariantColors.filter(
19
- color => !excludeColors.find(c => c === color)
20
- )
18
+ ? VariantColors.filter(color => !excludeColors.find(c => c === color))
21
19
  : VariantColors,
22
20
  sum = [...raw].reduce((sum, char) => sum + char.charCodeAt(0), 0);
23
21
 
package/source/index.ts CHANGED
@@ -2,34 +2,47 @@ export * from './animate';
2
2
  export * from './Avatar';
3
3
  export * from './Badge';
4
4
  export * from './Button';
5
+ export * from './ButtonGroup';
6
+ export * from './Card';
5
7
  export * from './ClickBoundary';
8
+ export * from './CloseButton';
6
9
  export * from './CodeBlock';
7
10
  export * from './color';
8
11
  export * from './Countdown';
9
12
  export * from './Dialog';
13
+ export * from './Drawer';
10
14
  export * from './Editor';
11
15
  export * from './EditorHTML';
16
+ export * from './Grid';
12
17
  export * from './HorizontalMarquee';
13
18
  export * from './Icon';
19
+ export * from './Image';
20
+ export * from './ListGroup';
14
21
  export * from './LiveTSX';
15
22
  export * from './Loading';
16
23
  export * from './Menu';
17
24
  export * from './MonthCalendar';
18
25
  export * from './Nameplate';
19
26
  export * from './NativeDialog';
27
+ export * from './Nav';
20
28
  export * from './Navbar';
21
29
  export * from './OverlayBox';
22
30
  export * from './PageNav';
31
+ export * from './Popover';
23
32
  export * from './ScrollNav';
24
33
  export * from './Select';
25
34
  export * from './ShareBox';
35
+ export * from './Spinner';
26
36
  export * from './SpinnerButton';
37
+ export * from './Table';
27
38
  export * from './TableSpinner';
28
39
  export * from './TextTruncate';
29
40
  export * from './Time';
30
41
  export * from './TimeDistance';
31
42
  export * from './Timeline';
32
43
  export * from './Toast';
44
+ export * from './ToggleButton';
45
+ export * from './Tooltip';
33
46
  export * from './TypeEcho';
34
47
  export * from './UserRank';
35
48
  export * from './VerticalMarquee';
@@ -1,49 +0,0 @@
1
- import classNames from 'classnames';
2
- import { observable } from 'mobx';
3
- import { observer } from 'mobx-react';
4
- import { Component, HTMLAttributes, RefCallback } from 'react';
5
- import { sleep } from 'web-utility';
6
-
7
- export interface TypeEchoProps extends HTMLAttributes<HTMLPreElement> {
8
- text: string;
9
- intervals?: number;
10
- }
11
-
12
- @observer
13
- export class TypeEcho extends Component<TypeEchoProps> {
14
- static displayName = 'TypeEcho';
15
-
16
- @observable
17
- accessor echoed = '';
18
-
19
- init: RefCallback<HTMLPreElement> = node =>
20
- node &&
21
- new IntersectionObserver(async ([{ isIntersecting }], observer) => {
22
- if (!isIntersecting) return;
23
-
24
- observer.disconnect();
25
-
26
- const { text, intervals = 150 } = this.props;
27
-
28
- for (const char of text) {
29
- await sleep(intervals / 1000);
30
-
31
- this.echoed += char;
32
- }
33
- }).observe(node);
34
-
35
- render() {
36
- const { className, text, ...props } = this.props,
37
- { echoed } = this;
38
-
39
- return (
40
- <pre
41
- {...props}
42
- ref={this.init}
43
- className={classNames('text-wrap', className)}
44
- >
45
- {echoed + (echoed === text ? '' : '_')}
46
- </pre>
47
- );
48
- }
49
- }