idea-react 3.0.0-beta.0 → 3.0.0-beta.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 (107) hide show
  1. package/AGENTS.md +11 -2
  2. package/ReadMe.md +62 -49
  3. package/dist/DatePickerPlugin-CpGuQRsi.js +1 -0
  4. package/dist/DatePickerPlugin-DB3nnslN.mjs +1 -0
  5. package/dist/index.d.mts +1116 -442
  6. package/dist/index.d.ts +1116 -442
  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 +69 -66
  11. package/package.json +1 -1
  12. package/source/Accordion.tsx +137 -0
  13. package/source/Alert.tsx +138 -0
  14. package/source/Avatar.tsx +7 -1
  15. package/source/Badge.tsx +2 -0
  16. package/source/Breadcrumb.tsx +36 -0
  17. package/source/Button.tsx +40 -5
  18. package/source/ButtonGroup.tsx +10 -1
  19. package/source/Card.tsx +65 -4
  20. package/source/Carousel/index.tsx +391 -0
  21. package/source/Carousel/model.ts +113 -0
  22. package/source/Carousel/scroll.ts +79 -0
  23. package/source/Collapse.tsx +178 -0
  24. package/source/Drawer.tsx +127 -30
  25. package/source/{CodeBlock.tsx → Extension/CodeBlock/index.tsx} +23 -5
  26. package/source/Extension/CodeBlock/style.module.css +3 -0
  27. package/source/{Dialog.tsx → Extension/Dialog.tsx} +10 -6
  28. package/source/{EditorHTML.tsx → Extension/EditorHTML.tsx} +1 -1
  29. package/source/{HorizontalMarquee → Extension/HorizontalMarquee}/index.module.less +1 -3
  30. package/source/{Icon.tsx → Extension/Icon.tsx} +1 -7
  31. package/source/{Loading.tsx → Extension/Loading.tsx} +8 -3
  32. package/source/{MonthCalendar.tsx → Extension/MonthCalendar.tsx} +3 -3
  33. package/source/{Nameplate.tsx → Extension/Nameplate.tsx} +1 -1
  34. package/source/Extension/OverlayBox.tsx +280 -0
  35. package/source/{PageNav.tsx → Extension/PageNav.tsx} +27 -9
  36. package/source/{ScrollNav → Extension/ScrollNav}/index.tsx +1 -1
  37. package/source/Extension/Select.tsx +127 -0
  38. package/source/{ShareBox.tsx → Extension/ShareBox.tsx} +1 -1
  39. package/source/{SpinnerButton.tsx → Extension/SpinnerButton.tsx} +2 -2
  40. package/source/{TableSpinner.tsx → Extension/TableSpinner.tsx} +1 -1
  41. package/source/{Timeline → Extension/Timeline}/index.tsx +1 -1
  42. package/source/{UserRank → Extension/UserRank}/index.tsx +4 -4
  43. package/source/Extension/index.ts +27 -0
  44. package/source/Form/Adorn.tsx +32 -11
  45. package/source/Form/Checkbox.tsx +11 -6
  46. package/source/Form/ChipInput.tsx +125 -0
  47. package/source/Form/Chips.tsx +42 -24
  48. package/source/Form/Combobox.tsx +337 -72
  49. package/source/Form/Control.tsx +50 -15
  50. package/source/Form/DatePicker.tsx +231 -40
  51. package/source/Form/DatePickerPlugin.ts +37 -0
  52. package/source/Form/Feedback.tsx +10 -4
  53. package/source/Form/FloatingLabel.tsx +24 -7
  54. package/source/Form/InputGroup.tsx +155 -5
  55. package/source/Form/OTP.tsx +138 -45
  56. package/source/Form/PasswordStrength.tsx +43 -17
  57. package/source/Form/Plugin.tsx +53 -0
  58. package/source/Form/Primitives.tsx +51 -9
  59. package/source/Form/Radio.tsx +20 -28
  60. package/source/Form/Range.tsx +103 -52
  61. package/source/Form/Switch.tsx +30 -7
  62. package/source/Form/index.ts +1 -0
  63. package/source/Grid.tsx +4 -0
  64. package/source/ListGroup.tsx +28 -15
  65. package/source/Menu.tsx +226 -17
  66. package/source/NativeDialog/index.tsx +109 -5
  67. package/source/Nav.tsx +18 -2
  68. package/source/NavOverflow/index.tsx +307 -0
  69. package/source/NavOverflow/model.ts +21 -0
  70. package/source/Navbar.tsx +18 -3
  71. package/source/Overlay.ts +163 -1
  72. package/source/Pagination.tsx +92 -0
  73. package/source/Placeholder.tsx +66 -0
  74. package/source/Popover.tsx +7 -2
  75. package/source/Progress/index.tsx +76 -0
  76. package/source/Progress/style.module.css +15 -0
  77. package/source/ScrollSpy/index.tsx +365 -0
  78. package/source/ScrollSpy/model.ts +17 -0
  79. package/source/Spinner.tsx +10 -0
  80. package/source/Stepper.tsx +85 -0
  81. package/source/Tab.tsx +248 -0
  82. package/source/Toast.tsx +46 -14
  83. package/source/ToggleButton.tsx +21 -7
  84. package/source/Toggler.tsx +108 -0
  85. package/source/Tooltip.tsx +6 -1
  86. package/source/index.ts +15 -27
  87. package/source/OverlayBox.tsx +0 -208
  88. package/source/Select.tsx +0 -95
  89. /package/source/{ClickBoundary.tsx → Extension/ClickBoundary.tsx} +0 -0
  90. /package/source/{Countdown.tsx → Extension/Countdown.tsx} +0 -0
  91. /package/source/{Editor.tsx → Extension/Editor.tsx} +0 -0
  92. /package/source/{HorizontalMarquee → Extension/HorizontalMarquee}/index.tsx +0 -0
  93. /package/source/{LiveTSX.tsx → Extension/LiveTSX.tsx} +0 -0
  94. /package/source/{ScrollNav → Extension/ScrollNav}/Scroller.tsx +0 -0
  95. /package/source/{ScrollNav → Extension/ScrollNav}/index.module.less +0 -0
  96. /package/source/{TextTruncate → Extension/TextTruncate}/Content.tsx +0 -0
  97. /package/source/{TextTruncate → Extension/TextTruncate}/index.tsx +0 -0
  98. /package/source/{Time.tsx → Extension/Time.tsx} +0 -0
  99. /package/source/{TimeDistance.tsx → Extension/TimeDistance.tsx} +0 -0
  100. /package/source/{Timeline → Extension/Timeline}/index.module.less +0 -0
  101. /package/source/{TypeEcho → Extension/TypeEcho}/Content.tsx +0 -0
  102. /package/source/{TypeEcho → Extension/TypeEcho}/index.tsx +0 -0
  103. /package/source/{UserRank → Extension/UserRank}/Address.tsx +0 -0
  104. /package/source/{UserRank → Extension/UserRank}/index.module.less +0 -0
  105. /package/source/{VerticalMarquee → Extension/VerticalMarquee}/index.module.less +0 -0
  106. /package/source/{VerticalMarquee → Extension/VerticalMarquee}/index.tsx +0 -0
  107. /package/source/{ZodiacBar.tsx → Extension/ZodiacBar.tsx} +0 -0
@@ -1,208 +0,0 @@
1
- 'use client';
2
-
3
- import classNames from 'classnames';
4
- import { action, observable } from 'mobx';
5
- import { observer } from 'mobx-react';
6
- import {
7
- cloneElement,
8
- Component,
9
- createRef,
10
- FocusEvent,
11
- HTMLAttributes,
12
- isValidElement,
13
- KeyboardEvent,
14
- MouseEvent,
15
- ReactElement,
16
- ReactNode
17
- } from 'react';
18
- import { uniqueID } from 'web-utility';
19
-
20
- import { OverlayPlacement } from './Overlay';
21
- import { Popover } from './Popover';
22
- import { Tooltip } from './Tooltip';
23
-
24
- export type OverlayTrigger = 'click' | 'focus' | 'hover';
25
-
26
- export interface OverlayBoxProps extends Omit<
27
- HTMLAttributes<HTMLSpanElement>,
28
- 'children' | 'title'
29
- > {
30
- title: ReactNode;
31
- detail?: ReactNode;
32
- placement?: OverlayPlacement;
33
- trigger?: OverlayTrigger | OverlayTrigger[];
34
- delay?: number | { show: number; hide: number };
35
- overlayClassName?: string;
36
- children: ReactElement<{ 'aria-describedby'?: string }>;
37
- }
38
-
39
- const PLACEMENT_CLASSES: Record<OverlayPlacement, string> = {
40
- top: 'bottom-100 start-50 translate-middle-x',
41
- right: 'top-50 start-100 translate-middle-y',
42
- bottom: 'top-100 start-50 translate-middle-x',
43
- left: 'top-50 end-100 translate-middle-y'
44
- };
45
-
46
- const OVERLAY_GAPS: Record<OverlayPlacement, Record<'popover' | 'tooltip', string>> = {
47
- top: { popover: 'mb-3', tooltip: 'mb-2' },
48
- right: { popover: 'ms-3', tooltip: 'ms-2' },
49
- bottom: { popover: 'mt-3', tooltip: 'mt-2' },
50
- left: { popover: 'me-3', tooltip: 'me-2' }
51
- };
52
-
53
- @observer
54
- export class OverlayBox extends Component<OverlayBoxProps> {
55
- static displayName = 'OverlayBox';
56
-
57
- @observable accessor open = false;
58
-
59
- id = uniqueID();
60
- root = createRef<HTMLSpanElement>();
61
- timer?: ReturnType<typeof setTimeout>;
62
-
63
- @action
64
- setOpen = (open: boolean) => (this.open = open);
65
-
66
- hide = () => {
67
- clearTimeout(this.timer);
68
- this.setOpen(false);
69
- };
70
-
71
- setOpenAfterDelay = (open: boolean) => {
72
- clearTimeout(this.timer);
73
-
74
- const { delay } = this.props;
75
- const timeout = typeof delay === 'number' ? delay : delay?.[open ? 'show' : 'hide'];
76
-
77
- if (!timeout) return this.setOpen(open);
78
-
79
- this.timer = setTimeout(() => this.setOpen(open), timeout);
80
- };
81
-
82
- componentWillUnmount() {
83
- document.removeEventListener('pointerdown', this.handleOutside);
84
- clearTimeout(this.timer);
85
- }
86
-
87
- componentDidMount() {
88
- document.addEventListener('pointerdown', this.handleOutside);
89
- }
90
-
91
- hasTrigger = (trigger: OverlayTrigger) => {
92
- const triggers: OverlayTrigger[] = this.props.trigger
93
- ? Array.isArray(this.props.trigger)
94
- ? this.props.trigger
95
- : [this.props.trigger]
96
- : ['hover', 'focus'];
97
-
98
- return triggers.includes(trigger);
99
- };
100
-
101
- handleMouseEnter = (event: MouseEvent<HTMLSpanElement>) => {
102
- this.props.onMouseEnter?.(event);
103
-
104
- if (this.hasTrigger('hover')) this.setOpenAfterDelay(true);
105
- };
106
-
107
- handleMouseLeave = (event: MouseEvent<HTMLSpanElement>) => {
108
- this.props.onMouseLeave?.(event);
109
-
110
- if (this.hasTrigger('hover') && !this.root.current?.contains(document.activeElement))
111
- this.setOpenAfterDelay(false);
112
- };
113
-
114
- handleFocus = (event: FocusEvent<HTMLSpanElement>) => {
115
- this.props.onFocus?.(event);
116
-
117
- if (this.hasTrigger('focus')) this.setOpenAfterDelay(true);
118
- };
119
-
120
- handleBlur = (event: FocusEvent<HTMLSpanElement>) => {
121
- this.props.onBlur?.(event);
122
-
123
- if (this.hasTrigger('focus') && !event.currentTarget.contains(event.relatedTarget))
124
- this.setOpenAfterDelay(false);
125
- };
126
-
127
- handleClick = (event: MouseEvent<HTMLSpanElement>) => {
128
- this.props.onClick?.(event);
129
-
130
- if (!event.defaultPrevented && this.hasTrigger('click')) this.setOpenAfterDelay(!this.open);
131
- };
132
-
133
- handleOutside = ({ target }: PointerEvent) => {
134
- if (target instanceof Node && !this.root.current?.contains(target)) this.hide();
135
- };
136
-
137
- handleKeyDown = (event: KeyboardEvent<HTMLSpanElement>) => {
138
- this.props.onKeyDown?.(event);
139
-
140
- if (event.key === 'Escape' && this.open) {
141
- event.preventDefault();
142
- this.hide();
143
- }
144
- };
145
-
146
- render() {
147
- const {
148
- title,
149
- detail,
150
- placement = 'top',
151
- trigger: _trigger,
152
- delay: _delay,
153
- overlayClassName,
154
- children,
155
- className = '',
156
- onMouseEnter: _onMouseEnter,
157
- onMouseLeave: _onMouseLeave,
158
- onFocus: _onFocus,
159
- onBlur: _onBlur,
160
- onClick: _onClick,
161
- onKeyDown: _onKeyDown,
162
- ...props
163
- } = this.props;
164
- const id = this.open ? this.id : undefined;
165
- const position = PLACEMENT_CLASSES[placement];
166
- const gap = OVERLAY_GAPS[placement][detail ? 'popover' : 'tooltip'];
167
- const overlayClass = classNames('position-absolute w-max', position, gap, overlayClassName);
168
- const trigger = isValidElement(children)
169
- ? cloneElement(children, {
170
- 'aria-describedby':
171
- [children.props['aria-describedby'], id].filter(Boolean).join(' ') ||
172
- undefined
173
- })
174
- : children;
175
-
176
- return (
177
- <span
178
- {...props}
179
- ref={this.root}
180
- className={`position-relative d-inline-block ${className}`}
181
- onMouseEnter={this.handleMouseEnter}
182
- onMouseLeave={this.handleMouseLeave}
183
- onFocus={this.handleFocus}
184
- onBlur={this.handleBlur}
185
- onClick={this.handleClick}
186
- onKeyDown={this.handleKeyDown}
187
- >
188
- {trigger}
189
-
190
- {this.open &&
191
- (detail ? (
192
- <Popover
193
- id={id}
194
- className={overlayClass}
195
- title={title}
196
- placement={placement}
197
- >
198
- {detail}
199
- </Popover>
200
- ) : (
201
- <Tooltip id={id} className={overlayClass} placement={placement}>
202
- {title}
203
- </Tooltip>
204
- ))}
205
- </span>
206
- );
207
- }
208
- }
package/source/Select.tsx DELETED
@@ -1,95 +0,0 @@
1
- 'use client';
2
-
3
- import classNames from 'classnames';
4
- import {
5
- ButtonHTMLAttributes,
6
- Children,
7
- FC,
8
- isValidElement,
9
- MouseEvent,
10
- ReactElement,
11
- ReactNode
12
- } from 'react';
13
-
14
- import { ButtonProps } from './Button';
15
- import { Menu } from './Menu';
16
-
17
- export interface OptionProps extends ButtonHTMLAttributes<HTMLButtonElement> {
18
- value?: string;
19
- }
20
-
21
- export const Option: FC<OptionProps> = ({ value, className, children, ...props }) => (
22
- <button
23
- {...props}
24
- type="button"
25
- className={classNames('menu-item', className)}
26
- data-value={value}
27
- >
28
- {children}
29
- </button>
30
- );
31
-
32
- Option.displayName = 'Option';
33
-
34
- export type SelectProps = Pick<
35
- ButtonProps,
36
- 'className' | 'style' | 'size' | 'theme' | 'variant' | 'disabled' | 'children'
37
- > & {
38
- align?: 'start' | 'end';
39
- menuClassName?: string;
40
- value?: string;
41
- onChange?: (value: string) => void;
42
- valueRender?: (value: string) => ReactNode;
43
- };
44
-
45
- export const Select: FC<SelectProps> = ({
46
- align,
47
- className,
48
- menuClassName,
49
- children,
50
- theme = 'primary',
51
- variant = 'solid',
52
- size,
53
- disabled,
54
- style,
55
- value,
56
- onChange,
57
- valueRender
58
- }) => {
59
- const current = Children.toArray(children).find(
60
- node =>
61
- isValidElement<OptionProps>(node) && node.type === Option && node.props.value === value
62
- ) as ReactElement<OptionProps> | undefined;
63
-
64
- const handleSelect = ({ target }: MouseEvent<HTMLDivElement>) => {
65
- if (!(target instanceof Element)) return;
66
-
67
- const option = target.closest<HTMLButtonElement>('[data-value]');
68
- if (option) onChange?.(option.dataset.value || '');
69
- };
70
-
71
- return (
72
- <Menu
73
- align={align}
74
- className="w-100"
75
- menuClassName={menuClassName}
76
- label={valueRender?.(value ?? '') ?? current?.props.children}
77
- toggleProps={{
78
- className: classNames(
79
- 'w-100 d-flex justify-content-between align-items-center',
80
- className
81
- ),
82
- theme,
83
- variant,
84
- size,
85
- disabled,
86
- style
87
- }}
88
- onClick={handleSelect}
89
- >
90
- {children}
91
- </Menu>
92
- );
93
- };
94
-
95
- Select.displayName = 'Select';
File without changes
File without changes
File without changes