idea-react 3.0.0-beta.0 → 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.
Files changed (130) hide show
  1. package/AGENTS.md +19 -2
  2. package/ReadMe.md +95 -54
  3. package/dist/DatePickerPlugin-CpGuQRsi.js +1 -0
  4. package/dist/DatePickerPlugin-DB3nnslN.mjs +1 -0
  5. package/dist/index.d.mts +1232 -474
  6. package/dist/index.d.ts +1232 -474
  7. package/dist/index.js +16 -16
  8. package/dist/index.mjs +15 -15
  9. package/dist/rolldown-runtime-5iZMYShA.js +1 -0
  10. package/dist/style.css +66 -66
  11. package/package.json +1 -1
  12. package/source/Accordion.tsx +161 -0
  13. package/source/Alert.tsx +153 -0
  14. package/source/Avatar.tsx +57 -46
  15. package/source/Badge.tsx +17 -15
  16. package/source/Breadcrumb.tsx +50 -0
  17. package/source/Button.tsx +69 -40
  18. package/source/ButtonGroup.tsx +23 -18
  19. package/source/Card.tsx +86 -17
  20. package/source/Carousel/index.tsx +392 -0
  21. package/source/Carousel/model.ts +113 -0
  22. package/source/Carousel/scroll.ts +79 -0
  23. package/source/CloseButton.tsx +20 -15
  24. package/source/Collapse.tsx +233 -0
  25. package/source/Drawer.tsx +158 -38
  26. package/source/{ClickBoundary.tsx → Extension/ClickBoundary.tsx} +24 -5
  27. package/source/Extension/CodeBlock.tsx +64 -0
  28. package/source/{Countdown.tsx → Extension/Countdown.tsx} +21 -9
  29. package/source/{Dialog.tsx → Extension/Dialog.tsx} +10 -6
  30. package/source/Extension/Editor.tsx +78 -0
  31. package/source/Extension/EditorHTML.tsx +20 -0
  32. package/source/{HorizontalMarquee → Extension/HorizontalMarquee}/index.module.less +1 -3
  33. package/source/Extension/HorizontalMarquee/index.tsx +85 -0
  34. package/source/Extension/Icon.tsx +19 -0
  35. package/source/Extension/Loading.tsx +30 -0
  36. package/source/{MonthCalendar.tsx → Extension/MonthCalendar.tsx} +29 -13
  37. package/source/{Nameplate.tsx → Extension/Nameplate.tsx} +1 -1
  38. package/source/Extension/OverlayBox.tsx +293 -0
  39. package/source/{PageNav.tsx → Extension/PageNav.tsx} +43 -16
  40. package/source/{ScrollNav → Extension/ScrollNav}/Scroller.tsx +21 -5
  41. package/source/Extension/ScrollNav/index.tsx +47 -0
  42. package/source/Extension/Select.tsx +128 -0
  43. package/source/{ShareBox.tsx → Extension/ShareBox.tsx} +1 -1
  44. package/source/Extension/SpinnerButton.tsx +30 -0
  45. package/source/Extension/TableSpinner.tsx +22 -0
  46. package/source/Extension/TextTruncate/index.tsx +29 -0
  47. package/source/Extension/Time.tsx +17 -0
  48. package/source/Extension/TimeDistance.tsx +45 -0
  49. package/source/Extension/Timeline/index.tsx +63 -0
  50. package/source/Extension/TypeEcho/Content.tsx +123 -0
  51. package/source/Extension/TypeEcho/index.tsx +22 -0
  52. package/source/Extension/UserRank/Address.tsx +22 -0
  53. package/source/Extension/UserRank/index.tsx +106 -0
  54. package/source/Extension/VerticalMarquee/index.tsx +23 -0
  55. package/source/Extension/ZodiacBar.tsx +59 -0
  56. package/source/Extension/index.ts +27 -0
  57. package/source/Form/Adorn.tsx +45 -26
  58. package/source/Form/Checkbox.tsx +20 -11
  59. package/source/Form/ChipInput.tsx +129 -0
  60. package/source/Form/Chips.tsx +57 -37
  61. package/source/Form/Combobox.tsx +362 -78
  62. package/source/Form/Control.tsx +72 -42
  63. package/source/Form/DatePicker.tsx +245 -45
  64. package/source/Form/DatePickerPlugin.ts +37 -0
  65. package/source/Form/Feedback.tsx +21 -16
  66. package/source/Form/FloatingLabel.tsx +21 -7
  67. package/source/Form/InputGroup.tsx +162 -11
  68. package/source/Form/OTP.tsx +156 -45
  69. package/source/Form/PasswordStrength.tsx +43 -17
  70. package/source/Form/Plugin.tsx +53 -0
  71. package/source/Form/Primitives.tsx +70 -20
  72. package/source/Form/Radio.tsx +35 -40
  73. package/source/Form/Range.tsx +125 -56
  74. package/source/Form/Switch.tsx +53 -27
  75. package/source/Form/index.ts +1 -0
  76. package/source/Grid.tsx +68 -56
  77. package/source/Image.tsx +10 -6
  78. package/source/ListGroup.tsx +59 -58
  79. package/source/Menu.tsx +317 -46
  80. package/source/NativeDialog/index.tsx +148 -22
  81. package/source/Nav.tsx +49 -33
  82. package/source/NavOverflow/index.tsx +323 -0
  83. package/source/NavOverflow/model.ts +21 -0
  84. package/source/Navbar.tsx +65 -45
  85. package/source/Overlay.ts +163 -1
  86. package/source/Pagination.tsx +86 -0
  87. package/source/Placeholder.tsx +70 -0
  88. package/source/Polymorphic.ts +57 -0
  89. package/source/Popover.tsx +34 -26
  90. package/source/Progress/index.tsx +81 -0
  91. package/source/Progress/style.module.css +15 -0
  92. package/source/ScrollSpy/index.tsx +380 -0
  93. package/source/ScrollSpy/model.ts +17 -0
  94. package/source/Spinner.tsx +31 -17
  95. package/source/Stack.tsx +25 -0
  96. package/source/Stepper.tsx +91 -0
  97. package/source/Tab.tsx +261 -0
  98. package/source/Table.tsx +53 -42
  99. package/source/Toast.tsx +93 -46
  100. package/source/ToggleButton.tsx +47 -30
  101. package/source/Toggler.tsx +117 -0
  102. package/source/Tooltip.tsx +31 -24
  103. package/source/index.ts +17 -27
  104. package/source/CodeBlock.tsx +0 -40
  105. package/source/Editor.tsx +0 -43
  106. package/source/EditorHTML.tsx +0 -16
  107. package/source/HorizontalMarquee/index.tsx +0 -61
  108. package/source/Icon.tsx +0 -24
  109. package/source/Loading.tsx +0 -22
  110. package/source/OverlayBox.tsx +0 -208
  111. package/source/ScrollNav/index.tsx +0 -22
  112. package/source/Select.tsx +0 -95
  113. package/source/SpinnerButton.tsx +0 -35
  114. package/source/TableSpinner.tsx +0 -26
  115. package/source/TextTruncate/index.tsx +0 -25
  116. package/source/Time.tsx +0 -15
  117. package/source/TimeDistance.tsx +0 -41
  118. package/source/Timeline/index.tsx +0 -60
  119. package/source/TypeEcho/Content.tsx +0 -58
  120. package/source/TypeEcho/index.tsx +0 -14
  121. package/source/UserRank/Address.tsx +0 -20
  122. package/source/UserRank/index.tsx +0 -111
  123. package/source/VerticalMarquee/index.tsx +0 -25
  124. package/source/ZodiacBar.tsx +0 -51
  125. /package/source/{LiveTSX.tsx → Extension/LiveTSX.tsx} +0 -0
  126. /package/source/{ScrollNav → Extension/ScrollNav}/index.module.less +0 -0
  127. /package/source/{TextTruncate → Extension/TextTruncate}/Content.tsx +0 -0
  128. /package/source/{Timeline → Extension/Timeline}/index.module.less +0 -0
  129. /package/source/{UserRank → Extension/UserRank}/index.module.less +0 -0
  130. /package/source/{VerticalMarquee → Extension/VerticalMarquee}/index.module.less +0 -0
@@ -0,0 +1,86 @@
1
+ import classNames from 'classnames';
2
+ import { cloneElement, ComponentPropsWithRef, isValidElement } from 'react';
3
+
4
+ import { ComponentTheme } from './Button';
5
+ import { polymorphic } from './Polymorphic';
6
+
7
+ export interface PaginationProps extends ComponentPropsWithRef<'ul'> {
8
+ theme?: ComponentTheme;
9
+ size?: 'sm' | 'lg';
10
+ }
11
+
12
+ export const Pagination = polymorphic<PaginationProps>(
13
+ ({ as: Root = 'ul', theme, size, className, ...props }) => (
14
+ <Root
15
+ {...props}
16
+ className={classNames(
17
+ 'pagination',
18
+ theme && `theme-${theme}`,
19
+ size && `pagination-${size}`,
20
+ className
21
+ )}
22
+ />
23
+ )
24
+ );
25
+ Pagination.displayName = 'Pagination';
26
+
27
+ type PageState = Partial<Record<'active' | 'disabled', boolean>>;
28
+
29
+ export type PageItemProps = ComponentPropsWithRef<'li'> & PageState;
30
+
31
+ export const PageItem = polymorphic<PageItemProps>(
32
+ ({ as: Root = 'li', active, disabled, className, children, ...props }) => {
33
+ const child =
34
+ isValidElement<PageLinkProps>(children) && children.type === PageLink
35
+ ? cloneElement(children, {
36
+ active: children.props.active ?? active,
37
+ disabled: children.props.disabled ?? disabled
38
+ })
39
+ : children;
40
+
41
+ return (
42
+ <Root {...props} className={classNames('page-item', { active, disabled }, className)}>
43
+ {child}
44
+ </Root>
45
+ );
46
+ }
47
+ );
48
+ PageItem.displayName = 'PageItem';
49
+
50
+ export type PageLinkProps = ComponentPropsWithRef<'a'> & PageState;
51
+
52
+ export const PageLink = polymorphic<PageLinkProps>(
53
+ ({
54
+ as: RootAs,
55
+ active,
56
+ disabled,
57
+ className,
58
+ href,
59
+ tabIndex,
60
+ onClick,
61
+ 'aria-current': current,
62
+ ...props
63
+ }) => {
64
+ const Root = RootAs ?? (href === undefined ? 'span' : 'a');
65
+
66
+ return (
67
+ <Root
68
+ {...props}
69
+ className={classNames('page-link', className)}
70
+ href={disabled ? undefined : href}
71
+ tabIndex={disabled ? -1 : tabIndex}
72
+ aria-disabled={disabled || undefined}
73
+ aria-current={current ?? (active ? 'page' : undefined)}
74
+ onClick={disabled ? undefined : onClick}
75
+ />
76
+ );
77
+ }
78
+ );
79
+ PageLink.displayName = 'PageLink';
80
+
81
+ export const PageText = polymorphic<ComponentPropsWithRef<'span'>>(
82
+ ({ as: Root = 'span', className, ...props }) => (
83
+ <Root {...props} className={classNames('page-link', className)} />
84
+ )
85
+ );
86
+ PageText.displayName = 'PageText';
@@ -0,0 +1,70 @@
1
+ import classNames from 'classnames';
2
+ import { ComponentPropsWithRef, CSSProperties } from 'react';
3
+
4
+ import { Button, ButtonProps, ComponentTheme } from './Button';
5
+ import { polymorphic } from './Polymorphic';
6
+
7
+ export interface PlaceholderProps extends ComponentPropsWithRef<'span'> {
8
+ size?: 'xs' | 'sm' | 'lg';
9
+ animation?: 'wave' | 'pulse' | 'glow';
10
+ theme?: ComponentTheme;
11
+ width?: CSSProperties['width'];
12
+ }
13
+
14
+ export const Placeholder = polymorphic<PlaceholderProps>(
15
+ ({
16
+ as: Root = 'span',
17
+ size,
18
+ animation,
19
+ theme,
20
+ width,
21
+ className,
22
+ style,
23
+ 'aria-hidden': hidden = true,
24
+ ...props
25
+ }) => (
26
+ <Root
27
+ {...props}
28
+ className={classNames(
29
+ 'placeholder',
30
+ size && `placeholder-${size}`,
31
+ animation && `placeholder-${animation}`,
32
+ theme && `bg-${theme}`,
33
+ className
34
+ )}
35
+ style={{ width, ...style }}
36
+ aria-hidden={hidden}
37
+ />
38
+ )
39
+ );
40
+ Placeholder.displayName = 'Placeholder';
41
+
42
+ export interface PlaceholderAnimationProps extends ComponentPropsWithRef<'div'> {
43
+ animation?: PlaceholderProps['animation'];
44
+ }
45
+
46
+ export const PlaceholderAnimation = polymorphic<PlaceholderAnimationProps>(
47
+ ({ as: Root = 'div', animation = 'wave', className, ...props }) => (
48
+ <Root
49
+ {...props}
50
+ className={classNames(`placeholder-${animation}`, className)}
51
+ aria-hidden="true"
52
+ />
53
+ )
54
+ );
55
+ PlaceholderAnimation.displayName = 'PlaceholderAnimation';
56
+
57
+ export type PlaceholderButtonProps = ButtonProps;
58
+
59
+ export const PlaceholderButton = polymorphic<PlaceholderButtonProps>(
60
+ ({ as: RootAs, className, ...props }) => (
61
+ <Button
62
+ as={RootAs}
63
+ {...props}
64
+ className={classNames('placeholder', className)}
65
+ aria-hidden="true"
66
+ disabled
67
+ />
68
+ )
69
+ );
70
+ PlaceholderButton.displayName = 'PlaceholderButton';
@@ -0,0 +1,57 @@
1
+ import { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType, FC, ReactNode } from 'react';
2
+
3
+ export interface AsProps<T extends ElementType = ElementType> {
4
+ as?: T;
5
+ }
6
+
7
+ type RequiredKeys<T> = {
8
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
9
+ }[keyof T];
10
+
11
+ type TargetProps<T, P extends object> = T extends unknown
12
+ ? Omit<T, keyof P | 'as'> & Pick<T, Extract<RequiredKeys<T>, keyof P>>
13
+ : never;
14
+
15
+ type ReadonlyTargetProps<T, P extends object> = T extends unknown
16
+ ? Readonly<TargetProps<T, P>>
17
+ : never;
18
+
19
+ type PolymorphicRef<T extends ElementType> = T extends unknown
20
+ ? 'ref' extends keyof ComponentPropsWithRef<T>
21
+ ? ComponentPropsWithRef<T>['ref']
22
+ : never
23
+ : never;
24
+
25
+ export type PolymorphicProps<T extends ElementType, P extends object = {}> = P extends unknown
26
+ ? Omit<P, 'as' | 'ref'> &
27
+ TargetProps<ComponentPropsWithRef<T>, P> & {
28
+ ref?: NoInfer<PolymorphicRef<T>>;
29
+ } & AsProps<T>
30
+ : never;
31
+
32
+ export type PolymorphicClassProps<
33
+ T extends ElementType | undefined,
34
+ P extends object = {}
35
+ > = P extends unknown
36
+ ? Readonly<Omit<P, 'as' | 'ref'> & { as?: T }> &
37
+ NoInfer<
38
+ [T] extends [undefined]
39
+ ? {}
40
+ : ReadonlyTargetProps<ComponentPropsWithoutRef<Exclude<T, undefined>>, P>
41
+ >
42
+ : never;
43
+
44
+ export interface PolymorphicComponent<P extends object> {
45
+ <T extends ElementType | undefined>(
46
+ props: { as: T } & ([T] extends [undefined]
47
+ ? P
48
+ : NoInfer<PolymorphicProps<Exclude<T, undefined>, P>>)
49
+ ): ReactNode;
50
+ (props: P & { as?: never }): ReactNode;
51
+ displayName?: string;
52
+ }
53
+
54
+ // Preserve the component's identity and lifecycle; only its public call signature changes.
55
+ export const polymorphic = <P extends object>(
56
+ component: FC<P & AsProps>
57
+ ): PolymorphicComponent<P> => component as PolymorphicComponent<P>;
@@ -1,36 +1,44 @@
1
1
  import classNames from 'classnames';
2
- import { FC, ReactNode } from 'react';
2
+ import { ReactNode } from 'react';
3
3
 
4
4
  import { OVERLAY_ARROW_POSITIONS, OVERLAY_DIRECTIONS, OverlayTriggerProps } from './Overlay';
5
+ import { polymorphic } from './Polymorphic';
5
6
 
6
7
  export interface PopoverProps extends Omit<OverlayTriggerProps, 'title'> {
7
8
  title?: ReactNode;
8
9
  }
9
10
 
10
- export const Popover: FC<PopoverProps> = ({
11
- title,
12
- placement = 'top',
13
- show = true,
14
- role = 'tooltip',
15
- className,
16
- children,
17
- ...props
18
- }) => (
19
- <div
20
- {...props}
21
- className={classNames(
22
- 'popover',
23
- { show },
24
- `bs-popover-${OVERLAY_DIRECTIONS[placement]}`,
25
- className
26
- )}
27
- role={role}
28
- data-bs-placement={placement}
29
- >
30
- <div className={classNames('popover-arrow', OVERLAY_ARROW_POSITIONS[placement])} />
31
- <h3 className="popover-header">{title}</h3>
32
- <div className="popover-body">{children}</div>
33
- </div>
11
+ export const Popover = polymorphic<PopoverProps>(
12
+ ({
13
+ as: Root = 'div',
14
+ title,
15
+ placement = 'top',
16
+ show = true,
17
+ role = 'tooltip',
18
+ className,
19
+ children,
20
+ arrowStyle,
21
+ ...props
22
+ }) => (
23
+ <Root
24
+ {...props}
25
+ className={classNames(
26
+ 'popover',
27
+ { show },
28
+ `bs-popover-${OVERLAY_DIRECTIONS[placement]}`,
29
+ className
30
+ )}
31
+ role={role}
32
+ hidden={!show}
33
+ data-bs-placement={placement}
34
+ >
35
+ <div
36
+ style={arrowStyle}
37
+ className={classNames('popover-arrow', OVERLAY_ARROW_POSITIONS[placement])}
38
+ />
39
+ {title != null && <h3 className="popover-header">{title}</h3>}
40
+ <div className="popover-body">{children}</div>
41
+ </Root>
42
+ )
34
43
  );
35
-
36
44
  Popover.displayName = 'Popover';
@@ -0,0 +1,81 @@
1
+ import './style.module.css';
2
+
3
+ import classNames from 'classnames';
4
+ import { ComponentPropsWithRef, CSSProperties } from 'react';
5
+
6
+ import { ComponentTheme } from '../Button';
7
+ import { polymorphic } from '../Polymorphic';
8
+
9
+ export interface ProgressProps extends ComponentPropsWithRef<'div'> {
10
+ value: number;
11
+ min?: number;
12
+ max?: number;
13
+ theme?: ComponentTheme;
14
+ striped?: boolean;
15
+ animated?: boolean;
16
+ barProps?: ComponentPropsWithRef<'div'>;
17
+ }
18
+
19
+ export const Progress = polymorphic<ProgressProps>(
20
+ ({
21
+ as: Root = 'div',
22
+ value,
23
+ min = 0,
24
+ max = 100,
25
+ theme,
26
+ striped,
27
+ animated,
28
+ barProps = {},
29
+ className,
30
+ style,
31
+ children,
32
+ ...props
33
+ }) => {
34
+ if (![value, min, max].every(Number.isFinite) || max <= min)
35
+ throw new RangeError('Progress requires finite values and max greater than min');
36
+
37
+ const current = Math.min(max, Math.max(min, value));
38
+ const width = `${((current - min) / (max - min)) * 100}%`;
39
+ const progressStyle: CSSProperties & { '--_progress-width': string } = {
40
+ ...style,
41
+ '--_progress-width': width
42
+ };
43
+ const { className: barClass, style: barStyle, ...barAttributes } = barProps;
44
+
45
+ return (
46
+ <Root
47
+ {...props}
48
+ className={classNames('progress', className)}
49
+ style={progressStyle}
50
+ role="progressbar"
51
+ aria-valuenow={current}
52
+ aria-valuemin={min}
53
+ aria-valuemax={max}
54
+ >
55
+ <div
56
+ {...barAttributes}
57
+ className={classNames(
58
+ 'progress-bar',
59
+ theme && `theme-${theme}`,
60
+ {
61
+ 'progress-bar-striped': striped || animated,
62
+ 'progress-bar-animated': animated
63
+ },
64
+ barClass
65
+ )}
66
+ style={barStyle}
67
+ >
68
+ {children}
69
+ </div>
70
+ </Root>
71
+ );
72
+ }
73
+ );
74
+ Progress.displayName = 'Progress';
75
+
76
+ export const ProgressStack = polymorphic<ComponentPropsWithRef<'div'>>(
77
+ ({ as: Root = 'div', className, ...props }) => (
78
+ <Root {...props} className={classNames('progress-stacked', className)} />
79
+ )
80
+ );
81
+ ProgressStack.displayName = 'ProgressStack';
@@ -0,0 +1,15 @@
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
+ }